diff --git a/Conf/lang.yaml b/Conf/lang.yaml index aa700f4d97..0177945cc6 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -8,6 +8,7 @@ 80386 Assembly: 8080 Assembly: 8086 Assembly: + A+: ABAP: ACL2: @@ -178,21 +179,185 @@ Euler Math Toolbox: Euphoria: Excel: +F: +F Sharp: + ext: fs +Factor: +Falcon: +FALSE: +Fan: +Fancy: +Fantom: +FAUST: +FBSL: +FeatureC++: + ext: cpp +Felix: +Ferite: +Fexl: +Fish: +FLORA-2: + ext: +Florid: Forth: ext: fth Fortran: ext: f +Fortress: +FP: +FPI: +Free Pascal/Lazarus: + ext: pas +FreeMat: +Frege: +Friendly interactive shell: + ext: fish +Frink: +Gambas: +GAP: +Gdl: +Gecho: +Gema: +Gentee: +Genyris: +GLBasic: +Glee: +GML: +Gnuplot: Go: +# Go!: +Golfscript: + ext: golf +Goo: +Gosu: +Groovy: +GUISS: +GW-BASIC: + ext: bas Haskell: ext: hs +Haxe: +Heron: +HicEst: +HLA: +Hope: +HQ9+: +HyperTalk: + ext: ht +Icon: +IDL: +Inform 6: + ext: inf +Inform 7: + ext: inf +Informix 4GL: + ext: 4gl +Integer BASIC: + ext: bas +Intercal: + ext: ical +Io: +Ioke: +Iptscrae: +J: +Jabaco: +Jacquard Loom: +JAMES II/Rule-based Cellular Automata: Java: +JavaFX Script: JavaScript: ext: js +JCL: +Jcon: +JoCaml: +Joy: +JScript.NET: + ext: net +JudoScript: + ext: judo +Julia: +K: +K3d: +Kaya: +KeyList Databasing: + ext: +Kite: +KonsolScript: + ext: konso +Kotlin: +L.in.oleum: + ext: lin +LabVIEW: +Lang5: LaTeX: ext: tex +Lhogho: +Liberty BASIC: +Lilypond: +Limbo: +Lisaac: +Lisp: +LLP: +LLVM: +Locomotive Basic: + ext: bas +Logo: +Logtalk: +LOLCODE: + ext: lol +Lolli: +Lotus 123 Macro Scripting: +LotusScript: + ext: lotus +Lout: +LSE64: +LSL: Lua: +Lucid: +Lush: +Lygon: +M4: +M680x0: +Make: +Maple: +MAPPER: +Mathematica: +Mathprog: MATLAB: ext: m +Maxima: +MAXScript: + ext: max +MBS: +ME10 macro: +MEL: +Mercury: +Metafont: +Metapost: +MGS: +MIPS Assembly: +Mirah: +MIRC Scripting Language: +Mirelle: +ML/I: +MMIX: +Modula-2: + ext: mod2 +Modula-3: + ext: mod3 +MOO: +Moonscript: + ext: moon +MPIF90: +MS SQL: +MSSQL: +MUF: +MUMPS: +MySQL: +Mython: +Mythryl: + + Perl: ext: pl PHP: diff --git a/Conf/task.yaml b/Conf/task.yaml index d5921041e6..62cf250f0d 100644 --- a/Conf/task.yaml +++ b/Conf/task.yaml @@ -1,5 +1,6 @@ 100 doors: 24 game: +24 game/Solve: 99 Bottles of Beer: A+B: @@ -185,16 +186,195 @@ Exponentiation operator: Extend your language: Extreme floating point values: - +Factorial: +Factors of a Mersenne number: +Factors of an integer: +Fast Fourier transform: +Fibonacci n-step number sequences: +Fibonacci sequence: +File IO: +File modification time: +File size: +Filter: +Find common directory path: +Find largest left truncatable prime in a given base: +Find limit of recursion: +Find the missing permutation: +First class environments: +First-class functions: +First-class functions/Use numbers analogously: +Five weekends: FizzBuzz: +Flatten a list: +Flow-control structures: +Floyd's triangle: #' Forest fire: +Fork: +Formal power series: +Formatted numeric output: +Forward difference: +Four bit adder: +Fractal tree: +Function composition: +Function definition: +Function frequency: +Function prototype: +Galton box animation: +Gamma function: +Generator/Exponential: +Generic swap: +Globally replace text in several files: Go Fish: -# Happy numbers: +Gray code: +Grayscale image: +Greatest common divisor: +Greatest element of a list: +Greatest subsequential sum: +Greyscale bars/Display: +Guess the number: +Guess the number/With feedback: +Guess the number/With feedback (player): +GUI component interaction: +GUI enabling/disabling of controls: +GUI/Maximum window dimensions: +Hailstone sequence: +Hamming numbers: +Handle a signal: +Happy numbers: +Harshad or Niven series: +Hash from two arrays: +Haversine formula: +Hello world/Graphical: +Hello world/Line printer: +Hello world/Newline omission: +Hello world/Standard error: +Hello world/Text: +Hello world/Web server: +Here document: +Higher-order functions: +History variables: +Hofstadter Figure-Figure sequences: +Hofstadter Q sequence: +Hofstadter-Conway $10,000 sequence: +Holidays related to Easter: +Honeycombs: +Horizontal sundial calculations: +Horner's rule for polynomial evaluation: #' +Host introspection: +Hostname: +Hough transform: +HTTP: +HTTPS: +HTTPS/Authenticated: +HTTPS/Client-authenticated: +Huffman coding: +I before E except after C: +Identity matrix: +Image convolution: +Image noise: +Include a file: +Increment a numerical string: Infinity: +Inheritance/Multiple: +Inheritance/Single: +Input loop: +Integer comparison: +Integer sequence: +Interactive programming: +Introspection: +Inverted index: +Inverted syntax: +Jensen's Device: #' +Josephus problem: +Joystick position: JSON: +Jump anywhere: +K-means++ clustering: +Kaprekar numbers: +Keyboard input/Flush the keyboard buffer: +Keyboard input/Keypress check: +Keyboard input/Obtain a Y or N response: +Keyboard macros: +Knapsack problem/0-1: +Knapsack problem/Bounded: +Knapsack problem/Continuous: +Knapsack problem/Unbounded: +Knight's tour: #' Knuth shuffle: -# Leap year: -# Mandlbrot set: +Knuth's algorithm S: #' +Langton's ant: #' +Largest int from concatenated ints: +Last Friday of each month: +Last letter-first letter: +Leap year: +Least common multiple: +Letter frequency: +Levenshtein distance: +Linear congruential generator: +List comprehensions: +Literals/Floating point: +Literals/Integer: +Literals/String: +Logical operations: +Long multiplication: +Longest common subsequence: +Longest string challenge: +Look-and-say sequence: +Loop over multiple arrays simultaneously: +Loops/Break: +Loops/Continue: +Loops/Do-while: +Loops/Downward for: +Loops/For: +Loops/For with a specified step: +Loops/Foreach: +Loops/Infinite: +Loops/N plus one half: +Loops/Nested: +Loops/While: +LU decomposition: +Lucas-Lehmer test: +Luhn test of credit card numbers: +LZW compression: +Mad Libs: +Main step of GOST 28147-89: +Man or boy test: +Mandelbrot set: +Map range: +Matrix arithmetic: +Matrix multiplication: +Matrix transposition: +Matrix-exponentiation operator: +Maze generation: +Maze solving: +MD4: +MD5: +MD5/Implementation: +Median filter: +Memory allocation: +Memory layout of a data structure: +Menu: +Metaprogramming: +Metered concurrency: +Metronome: +Middle three digits: +Miller-Rabin primality test: +Minesweeper game: +Modular exponentiation: +Modular inverse: +Monte Carlo methods: +Monty Hall problem: +Morse code: +Mouse position: +Multifactorial: +Multiple distinct objects: +Multiple regression: +Multiplication tables: +Multiplicative order: +Multisplit: +Mutex: +Mutual recursion: + Narcissist: Ordered words: Pi: diff --git a/Lang/0815/Factorial b/Lang/0815/Factorial new file mode 120000 index 0000000000..c902de1a9c --- /dev/null +++ b/Lang/0815/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/0815 \ No newline at end of file diff --git a/Lang/0815/Factors-of-an-integer b/Lang/0815/Factors-of-an-integer new file mode 120000 index 0000000000..a782a565b6 --- /dev/null +++ b/Lang/0815/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/0815 \ No newline at end of file diff --git a/Lang/0815/Fibonacci-sequence b/Lang/0815/Fibonacci-sequence new file mode 120000 index 0000000000..d5bedd87af --- /dev/null +++ b/Lang/0815/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/0815 \ No newline at end of file diff --git a/Lang/0815/Hello-world-Text b/Lang/0815/Hello-world-Text new file mode 120000 index 0000000000..bc50767e75 --- /dev/null +++ b/Lang/0815/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/0815 \ No newline at end of file diff --git a/Lang/0815/Integer-sequence b/Lang/0815/Integer-sequence new file mode 120000 index 0000000000..ab56a4e541 --- /dev/null +++ b/Lang/0815/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/0815 \ No newline at end of file diff --git a/Lang/0815/Loops-While b/Lang/0815/Loops-While new file mode 120000 index 0000000000..60b0b9ec30 --- /dev/null +++ b/Lang/0815/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/0815 \ No newline at end of file diff --git a/Lang/360-Assembly/Hello-world-Text b/Lang/360-Assembly/Hello-world-Text new file mode 120000 index 0000000000..da0b162190 --- /dev/null +++ b/Lang/360-Assembly/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/360-Assembly \ No newline at end of file diff --git a/Lang/360-Assembly/Memory-allocation b/Lang/360-Assembly/Memory-allocation new file mode 120000 index 0000000000..5e1996f6c9 --- /dev/null +++ b/Lang/360-Assembly/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/360-Assembly \ No newline at end of file diff --git a/Lang/4DOS-Batch/Hello-world-Standard-error b/Lang/4DOS-Batch/Hello-world-Standard-error new file mode 120000 index 0000000000..eaa1e04087 --- /dev/null +++ b/Lang/4DOS-Batch/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/4DOS-Batch \ No newline at end of file diff --git a/Lang/4DOS-Batch/Hello-world-Text b/Lang/4DOS-Batch/Hello-world-Text new file mode 120000 index 0000000000..d83d940c44 --- /dev/null +++ b/Lang/4DOS-Batch/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/4DOS-Batch \ No newline at end of file diff --git a/Lang/4DOS-Batch/Loops-Infinite b/Lang/4DOS-Batch/Loops-Infinite new file mode 120000 index 0000000000..fe09ba07af --- /dev/null +++ b/Lang/4DOS-Batch/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/4DOS-Batch \ No newline at end of file diff --git a/Lang/6502-Assembly/Flow-control-structures b/Lang/6502-Assembly/Flow-control-structures new file mode 120000 index 0000000000..7701e5300a --- /dev/null +++ b/Lang/6502-Assembly/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Hello-world-Text b/Lang/6502-Assembly/Hello-world-Text new file mode 120000 index 0000000000..047795d96b --- /dev/null +++ b/Lang/6502-Assembly/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Integer-comparison b/Lang/6502-Assembly/Integer-comparison new file mode 120000 index 0000000000..6e4854f64e --- /dev/null +++ b/Lang/6502-Assembly/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Loops-Break b/Lang/6502-Assembly/Loops-Break new file mode 120000 index 0000000000..cc7c05e97c --- /dev/null +++ b/Lang/6502-Assembly/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Loops-Do-while b/Lang/6502-Assembly/Loops-Do-while new file mode 120000 index 0000000000..aa4f333b05 --- /dev/null +++ b/Lang/6502-Assembly/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Loops-Downward-for b/Lang/6502-Assembly/Loops-Downward-for new file mode 120000 index 0000000000..6a270d6465 --- /dev/null +++ b/Lang/6502-Assembly/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Loops-Infinite b/Lang/6502-Assembly/Loops-Infinite new file mode 120000 index 0000000000..6beb71e6da --- /dev/null +++ b/Lang/6502-Assembly/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/6502-Assembly \ No newline at end of file diff --git a/Lang/6502-Assembly/Loops-While b/Lang/6502-Assembly/Loops-While new file mode 120000 index 0000000000..809dbe62ee --- /dev/null +++ b/Lang/6502-Assembly/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/6502-Assembly \ No newline at end of file diff --git a/Lang/6800-Assembly/Hello-world-Text b/Lang/6800-Assembly/Hello-world-Text new file mode 120000 index 0000000000..6e93cdee24 --- /dev/null +++ b/Lang/6800-Assembly/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/6800-Assembly \ No newline at end of file diff --git a/Lang/8086-Assembly/Hello-world-Text b/Lang/8086-Assembly/Hello-world-Text new file mode 120000 index 0000000000..9d53c34a5d --- /dev/null +++ b/Lang/8086-Assembly/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/8086-Assembly \ No newline at end of file diff --git a/Lang/ABAP/24-game-Solve b/Lang/ABAP/24-game-Solve new file mode 120000 index 0000000000..cb754e337c --- /dev/null +++ b/Lang/ABAP/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Factorial b/Lang/ABAP/Factorial new file mode 120000 index 0000000000..05305589c9 --- /dev/null +++ b/Lang/ABAP/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Hello-world-Text b/Lang/ABAP/Hello-world-Text new file mode 120000 index 0000000000..3aa1c339d9 --- /dev/null +++ b/Lang/ABAP/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Increment-a-numerical-string b/Lang/ABAP/Increment-a-numerical-string new file mode 120000 index 0000000000..d529020116 --- /dev/null +++ b/Lang/ABAP/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Luhn-test-of-credit-card-numbers b/Lang/ABAP/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..5a32eb4145 --- /dev/null +++ b/Lang/ABAP/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/ABAP \ No newline at end of file diff --git a/Lang/ACL2/Arbitrary-precision-integers-included b/Lang/ACL2/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..ef5de56eee --- /dev/null +++ b/Lang/ACL2/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Factors-of-an-integer b/Lang/ACL2/Factors-of-an-integer new file mode 120000 index 0000000000..1931fa4bf7 --- /dev/null +++ b/Lang/ACL2/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Fibonacci-n-step-number-sequences b/Lang/ACL2/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..b1708027de --- /dev/null +++ b/Lang/ACL2/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Fibonacci-sequence b/Lang/ACL2/Fibonacci-sequence new file mode 120000 index 0000000000..5752839895 --- /dev/null +++ b/Lang/ACL2/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/File-IO b/Lang/ACL2/File-IO new file mode 120000 index 0000000000..da5caed497 --- /dev/null +++ b/Lang/ACL2/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Filter b/Lang/ACL2/Filter new file mode 120000 index 0000000000..8cbc3b3fee --- /dev/null +++ b/Lang/ACL2/Filter @@ -0,0 +1 @@ +../../Task/Filter/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Find-limit-of-recursion b/Lang/ACL2/Find-limit-of-recursion new file mode 120000 index 0000000000..8d5ba44dd3 --- /dev/null +++ b/Lang/ACL2/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Flatten-a-list b/Lang/ACL2/Flatten-a-list new file mode 120000 index 0000000000..8b0d20d1c1 --- /dev/null +++ b/Lang/ACL2/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Function-definition b/Lang/ACL2/Function-definition new file mode 120000 index 0000000000..75607dc57c --- /dev/null +++ b/Lang/ACL2/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Function-frequency b/Lang/ACL2/Function-frequency new file mode 120000 index 0000000000..fa786200a7 --- /dev/null +++ b/Lang/ACL2/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Generic-swap b/Lang/ACL2/Generic-swap new file mode 120000 index 0000000000..3cd596d5ff --- /dev/null +++ b/Lang/ACL2/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Greatest-common-divisor b/Lang/ACL2/Greatest-common-divisor new file mode 120000 index 0000000000..e95ec9d48b --- /dev/null +++ b/Lang/ACL2/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Greatest-element-of-a-list b/Lang/ACL2/Greatest-element-of-a-list new file mode 120000 index 0000000000..1d93798539 --- /dev/null +++ b/Lang/ACL2/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Hailstone-sequence b/Lang/ACL2/Hailstone-sequence new file mode 120000 index 0000000000..b6973b5283 --- /dev/null +++ b/Lang/ACL2/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Happy-numbers b/Lang/ACL2/Happy-numbers new file mode 120000 index 0000000000..d3d8f48675 --- /dev/null +++ b/Lang/ACL2/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Hello-world-Newline-omission b/Lang/ACL2/Hello-world-Newline-omission new file mode 120000 index 0000000000..a0f04f5133 --- /dev/null +++ b/Lang/ACL2/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Hello-world-Text b/Lang/ACL2/Hello-world-Text new file mode 120000 index 0000000000..33700ab3a2 --- /dev/null +++ b/Lang/ACL2/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Horners-rule-for-polynomial-evaluation b/Lang/ACL2/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..ffbbb49a88 --- /dev/null +++ b/Lang/ACL2/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Include-a-file b/Lang/ACL2/Include-a-file new file mode 120000 index 0000000000..92eb199211 --- /dev/null +++ b/Lang/ACL2/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Letter-frequency b/Lang/ACL2/Letter-frequency new file mode 120000 index 0000000000..3532c0774d --- /dev/null +++ b/Lang/ACL2/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Logical-operations b/Lang/ACL2/Logical-operations new file mode 120000 index 0000000000..d2a90ba1b1 --- /dev/null +++ b/Lang/ACL2/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Loop-over-multiple-arrays-simultaneously b/Lang/ACL2/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..75d7f48b77 --- /dev/null +++ b/Lang/ACL2/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Loops-Foreach b/Lang/ACL2/Loops-Foreach new file mode 120000 index 0000000000..e9d22ad593 --- /dev/null +++ b/Lang/ACL2/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Loops-Infinite b/Lang/ACL2/Loops-Infinite new file mode 120000 index 0000000000..28bb646f6e --- /dev/null +++ b/Lang/ACL2/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Loops-N-plus-one-half b/Lang/ACL2/Loops-N-plus-one-half new file mode 120000 index 0000000000..77c02486c7 --- /dev/null +++ b/Lang/ACL2/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Luhn-test-of-credit-card-numbers b/Lang/ACL2/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..2dd369061b --- /dev/null +++ b/Lang/ACL2/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Mandelbrot-set b/Lang/ACL2/Mandelbrot-set new file mode 120000 index 0000000000..98ba0de064 --- /dev/null +++ b/Lang/ACL2/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Map-range b/Lang/ACL2/Map-range new file mode 120000 index 0000000000..775a94a8f6 --- /dev/null +++ b/Lang/ACL2/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Matrix-transposition b/Lang/ACL2/Matrix-transposition new file mode 120000 index 0000000000..6b2e406bd6 --- /dev/null +++ b/Lang/ACL2/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Mutual-recursion b/Lang/ACL2/Mutual-recursion new file mode 120000 index 0000000000..e3431fb726 --- /dev/null +++ b/Lang/ACL2/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/ACL2 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factorial b/Lang/ALGOL-68/Factorial new file mode 120000 index 0000000000..b406800839 --- /dev/null +++ b/Lang/ALGOL-68/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factors-of-a-Mersenne-number b/Lang/ALGOL-68/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..4143c3543e --- /dev/null +++ b/Lang/ALGOL-68/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Factors-of-an-integer b/Lang/ALGOL-68/Factors-of-an-integer new file mode 120000 index 0000000000..97160e4b04 --- /dev/null +++ b/Lang/ALGOL-68/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Fast-Fourier-transform b/Lang/ALGOL-68/Fast-Fourier-transform new file mode 120000 index 0000000000..22083e6a38 --- /dev/null +++ b/Lang/ALGOL-68/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Fibonacci-sequence b/Lang/ALGOL-68/Fibonacci-sequence new file mode 120000 index 0000000000..286c4fb060 --- /dev/null +++ b/Lang/ALGOL-68/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/File-IO b/Lang/ALGOL-68/File-IO new file mode 120000 index 0000000000..25da6d4ee9 --- /dev/null +++ b/Lang/ALGOL-68/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/File-size b/Lang/ALGOL-68/File-size new file mode 120000 index 0000000000..bb44db7a96 --- /dev/null +++ b/Lang/ALGOL-68/File-size @@ -0,0 +1 @@ +../../Task/File-size/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Filter b/Lang/ALGOL-68/Filter new file mode 120000 index 0000000000..2ef91ce8ba --- /dev/null +++ b/Lang/ALGOL-68/Filter @@ -0,0 +1 @@ +../../Task/Filter/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Find-common-directory-path b/Lang/ALGOL-68/Find-common-directory-path new file mode 120000 index 0000000000..5b804b63bb --- /dev/null +++ b/Lang/ALGOL-68/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/First-class-functions b/Lang/ALGOL-68/First-class-functions new file mode 120000 index 0000000000..2040eb2db2 --- /dev/null +++ b/Lang/ALGOL-68/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/First-class-functions-Use-numbers-analogously b/Lang/ALGOL-68/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..4ceb01b940 --- /dev/null +++ b/Lang/ALGOL-68/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Five-weekends b/Lang/ALGOL-68/Five-weekends new file mode 120000 index 0000000000..8040a3cc51 --- /dev/null +++ b/Lang/ALGOL-68/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Flatten-a-list b/Lang/ALGOL-68/Flatten-a-list new file mode 120000 index 0000000000..59ea0daafa --- /dev/null +++ b/Lang/ALGOL-68/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Flow-control-structures b/Lang/ALGOL-68/Flow-control-structures new file mode 120000 index 0000000000..f106a36579 --- /dev/null +++ b/Lang/ALGOL-68/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Fork b/Lang/ALGOL-68/Fork new file mode 120000 index 0000000000..fd24d58d6c --- /dev/null +++ b/Lang/ALGOL-68/Fork @@ -0,0 +1 @@ +../../Task/Fork/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Formatted-numeric-output b/Lang/ALGOL-68/Formatted-numeric-output new file mode 120000 index 0000000000..083560fe8f --- /dev/null +++ b/Lang/ALGOL-68/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Forward-difference b/Lang/ALGOL-68/Forward-difference new file mode 120000 index 0000000000..92d8b3d7e2 --- /dev/null +++ b/Lang/ALGOL-68/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Function-composition b/Lang/ALGOL-68/Function-composition new file mode 120000 index 0000000000..2076e2aff4 --- /dev/null +++ b/Lang/ALGOL-68/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Function-definition b/Lang/ALGOL-68/Function-definition new file mode 120000 index 0000000000..f44ea7a8b8 --- /dev/null +++ b/Lang/ALGOL-68/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Gamma-function b/Lang/ALGOL-68/Gamma-function new file mode 120000 index 0000000000..2f227bbfce --- /dev/null +++ b/Lang/ALGOL-68/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Generator-Exponential b/Lang/ALGOL-68/Generator-Exponential new file mode 120000 index 0000000000..524af5305c --- /dev/null +++ b/Lang/ALGOL-68/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Generic-swap b/Lang/ALGOL-68/Generic-swap new file mode 120000 index 0000000000..f3fad26184 --- /dev/null +++ b/Lang/ALGOL-68/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Greatest-common-divisor b/Lang/ALGOL-68/Greatest-common-divisor new file mode 120000 index 0000000000..d79d65a724 --- /dev/null +++ b/Lang/ALGOL-68/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Greatest-element-of-a-list b/Lang/ALGOL-68/Greatest-element-of-a-list new file mode 120000 index 0000000000..0f0b147e9a --- /dev/null +++ b/Lang/ALGOL-68/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Greatest-subsequential-sum b/Lang/ALGOL-68/Greatest-subsequential-sum new file mode 120000 index 0000000000..36fcf71b18 --- /dev/null +++ b/Lang/ALGOL-68/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Guess-the-number b/Lang/ALGOL-68/Guess-the-number new file mode 120000 index 0000000000..240daad6aa --- /dev/null +++ b/Lang/ALGOL-68/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/HTTP b/Lang/ALGOL-68/HTTP new file mode 120000 index 0000000000..84326dfac5 --- /dev/null +++ b/Lang/ALGOL-68/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hailstone-sequence b/Lang/ALGOL-68/Hailstone-sequence new file mode 120000 index 0000000000..42e1a55b1f --- /dev/null +++ b/Lang/ALGOL-68/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hamming-numbers b/Lang/ALGOL-68/Hamming-numbers new file mode 120000 index 0000000000..1b94f54a37 --- /dev/null +++ b/Lang/ALGOL-68/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Happy-numbers b/Lang/ALGOL-68/Happy-numbers new file mode 120000 index 0000000000..cb100646b6 --- /dev/null +++ b/Lang/ALGOL-68/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Haversine-formula b/Lang/ALGOL-68/Haversine-formula new file mode 120000 index 0000000000..7337d735b7 --- /dev/null +++ b/Lang/ALGOL-68/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hello-world-Standard-error b/Lang/ALGOL-68/Hello-world-Standard-error new file mode 120000 index 0000000000..0004a87096 --- /dev/null +++ b/Lang/ALGOL-68/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hello-world-Text b/Lang/ALGOL-68/Hello-world-Text new file mode 120000 index 0000000000..80eb303a7e --- /dev/null +++ b/Lang/ALGOL-68/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Here-document b/Lang/ALGOL-68/Here-document new file mode 120000 index 0000000000..9ec03af7ca --- /dev/null +++ b/Lang/ALGOL-68/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Higher-order-functions b/Lang/ALGOL-68/Higher-order-functions new file mode 120000 index 0000000000..036ae6a10a --- /dev/null +++ b/Lang/ALGOL-68/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hofstadter-Conway-$10,000-sequence b/Lang/ALGOL-68/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..ff83519095 --- /dev/null +++ b/Lang/ALGOL-68/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hofstadter-Q-sequence b/Lang/ALGOL-68/Hofstadter-Q-sequence new file mode 120000 index 0000000000..fc42afd7da --- /dev/null +++ b/Lang/ALGOL-68/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Holidays-related-to-Easter b/Lang/ALGOL-68/Holidays-related-to-Easter new file mode 120000 index 0000000000..1e04f034af --- /dev/null +++ b/Lang/ALGOL-68/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Horizontal-sundial-calculations b/Lang/ALGOL-68/Horizontal-sundial-calculations new file mode 120000 index 0000000000..fd4d1ba3d4 --- /dev/null +++ b/Lang/ALGOL-68/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Horners-rule-for-polynomial-evaluation b/Lang/ALGOL-68/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..33b2948b7d --- /dev/null +++ b/Lang/ALGOL-68/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Host-introspection b/Lang/ALGOL-68/Host-introspection new file mode 120000 index 0000000000..fc0b9cefea --- /dev/null +++ b/Lang/ALGOL-68/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Hostname b/Lang/ALGOL-68/Hostname new file mode 120000 index 0000000000..ce597e1dea --- /dev/null +++ b/Lang/ALGOL-68/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Increment-a-numerical-string b/Lang/ALGOL-68/Increment-a-numerical-string new file mode 120000 index 0000000000..4bc7870f0b --- /dev/null +++ b/Lang/ALGOL-68/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Input-loop b/Lang/ALGOL-68/Input-loop new file mode 120000 index 0000000000..60d1fe5b83 --- /dev/null +++ b/Lang/ALGOL-68/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Integer-comparison b/Lang/ALGOL-68/Integer-comparison new file mode 120000 index 0000000000..06ed10ff4b --- /dev/null +++ b/Lang/ALGOL-68/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Integer-sequence b/Lang/ALGOL-68/Integer-sequence new file mode 120000 index 0000000000..bd8f98dc4b --- /dev/null +++ b/Lang/ALGOL-68/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Introspection b/Lang/ALGOL-68/Introspection new file mode 120000 index 0000000000..bab2a050a3 --- /dev/null +++ b/Lang/ALGOL-68/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Jensens-Device b/Lang/ALGOL-68/Jensens-Device new file mode 120000 index 0000000000..68917b6815 --- /dev/null +++ b/Lang/ALGOL-68/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Knapsack-problem-Unbounded b/Lang/ALGOL-68/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..ddc2f7104d --- /dev/null +++ b/Lang/ALGOL-68/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Leap-year b/Lang/ALGOL-68/Leap-year new file mode 120000 index 0000000000..3a43765fc7 --- /dev/null +++ b/Lang/ALGOL-68/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/List-comprehensions b/Lang/ALGOL-68/List-comprehensions new file mode 120000 index 0000000000..7e8449eb3a --- /dev/null +++ b/Lang/ALGOL-68/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Literals-Integer b/Lang/ALGOL-68/Literals-Integer new file mode 120000 index 0000000000..a8b770a519 --- /dev/null +++ b/Lang/ALGOL-68/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Literals-String b/Lang/ALGOL-68/Literals-String new file mode 120000 index 0000000000..c54006a695 --- /dev/null +++ b/Lang/ALGOL-68/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Logical-operations b/Lang/ALGOL-68/Logical-operations new file mode 120000 index 0000000000..fa4df14c48 --- /dev/null +++ b/Lang/ALGOL-68/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Long-multiplication b/Lang/ALGOL-68/Long-multiplication new file mode 120000 index 0000000000..9a1de533eb --- /dev/null +++ b/Lang/ALGOL-68/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Longest-common-subsequence b/Lang/ALGOL-68/Longest-common-subsequence new file mode 120000 index 0000000000..1b4310180b --- /dev/null +++ b/Lang/ALGOL-68/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Look-and-say-sequence b/Lang/ALGOL-68/Look-and-say-sequence new file mode 120000 index 0000000000..935075b504 --- /dev/null +++ b/Lang/ALGOL-68/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loop-over-multiple-arrays-simultaneously b/Lang/ALGOL-68/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..f266d103f2 --- /dev/null +++ b/Lang/ALGOL-68/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Break b/Lang/ALGOL-68/Loops-Break new file mode 120000 index 0000000000..fcbdec079d --- /dev/null +++ b/Lang/ALGOL-68/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Continue b/Lang/ALGOL-68/Loops-Continue new file mode 120000 index 0000000000..3143b9ec97 --- /dev/null +++ b/Lang/ALGOL-68/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Do-while b/Lang/ALGOL-68/Loops-Do-while new file mode 120000 index 0000000000..e028bb631a --- /dev/null +++ b/Lang/ALGOL-68/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Downward-for b/Lang/ALGOL-68/Loops-Downward-for new file mode 120000 index 0000000000..b6102725bf --- /dev/null +++ b/Lang/ALGOL-68/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-For b/Lang/ALGOL-68/Loops-For new file mode 120000 index 0000000000..21e5bfa6aa --- /dev/null +++ b/Lang/ALGOL-68/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Foreach b/Lang/ALGOL-68/Loops-Foreach new file mode 120000 index 0000000000..6ba33c8d29 --- /dev/null +++ b/Lang/ALGOL-68/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Infinite b/Lang/ALGOL-68/Loops-Infinite new file mode 120000 index 0000000000..1b0478e2b8 --- /dev/null +++ b/Lang/ALGOL-68/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-N-plus-one-half b/Lang/ALGOL-68/Loops-N-plus-one-half new file mode 120000 index 0000000000..82fa91805e --- /dev/null +++ b/Lang/ALGOL-68/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-Nested b/Lang/ALGOL-68/Loops-Nested new file mode 120000 index 0000000000..84271069fb --- /dev/null +++ b/Lang/ALGOL-68/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Loops-While b/Lang/ALGOL-68/Loops-While new file mode 120000 index 0000000000..025865df1a --- /dev/null +++ b/Lang/ALGOL-68/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Lucas-Lehmer-test b/Lang/ALGOL-68/Lucas-Lehmer-test new file mode 120000 index 0000000000..24df31e301 --- /dev/null +++ b/Lang/ALGOL-68/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Luhn-test-of-credit-card-numbers b/Lang/ALGOL-68/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..7c46a20c5f --- /dev/null +++ b/Lang/ALGOL-68/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Man-or-boy-test b/Lang/ALGOL-68/Man-or-boy-test new file mode 120000 index 0000000000..fe17256b26 --- /dev/null +++ b/Lang/ALGOL-68/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Mandelbrot-set b/Lang/ALGOL-68/Mandelbrot-set new file mode 120000 index 0000000000..ae77f017b8 --- /dev/null +++ b/Lang/ALGOL-68/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Matrix-exponentiation-operator b/Lang/ALGOL-68/Matrix-exponentiation-operator new file mode 120000 index 0000000000..22f32f9f2c --- /dev/null +++ b/Lang/ALGOL-68/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Matrix-multiplication b/Lang/ALGOL-68/Matrix-multiplication new file mode 120000 index 0000000000..c8e8fdb0e2 --- /dev/null +++ b/Lang/ALGOL-68/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Matrix-transposition b/Lang/ALGOL-68/Matrix-transposition new file mode 120000 index 0000000000..4354b8eb26 --- /dev/null +++ b/Lang/ALGOL-68/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Memory-allocation b/Lang/ALGOL-68/Memory-allocation new file mode 120000 index 0000000000..9e143000b0 --- /dev/null +++ b/Lang/ALGOL-68/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Memory-layout-of-a-data-structure b/Lang/ALGOL-68/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..3e6b7ac6fc --- /dev/null +++ b/Lang/ALGOL-68/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Menu b/Lang/ALGOL-68/Menu new file mode 120000 index 0000000000..8b729cfd0d --- /dev/null +++ b/Lang/ALGOL-68/Menu @@ -0,0 +1 @@ +../../Task/Menu/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Metered-concurrency b/Lang/ALGOL-68/Metered-concurrency new file mode 120000 index 0000000000..1fd4c259df --- /dev/null +++ b/Lang/ALGOL-68/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Miller-Rabin-primality-test b/Lang/ALGOL-68/Miller-Rabin-primality-test new file mode 120000 index 0000000000..c0a1c115c4 --- /dev/null +++ b/Lang/ALGOL-68/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Monte-Carlo-methods b/Lang/ALGOL-68/Monte-Carlo-methods new file mode 120000 index 0000000000..267a4353a3 --- /dev/null +++ b/Lang/ALGOL-68/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Monty-Hall-problem b/Lang/ALGOL-68/Monty-Hall-problem new file mode 120000 index 0000000000..3bec3778ff --- /dev/null +++ b/Lang/ALGOL-68/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Multiple-distinct-objects b/Lang/ALGOL-68/Multiple-distinct-objects new file mode 120000 index 0000000000..1d03bc500a --- /dev/null +++ b/Lang/ALGOL-68/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Multiplication-tables b/Lang/ALGOL-68/Multiplication-tables new file mode 120000 index 0000000000..39a3d5946c --- /dev/null +++ b/Lang/ALGOL-68/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Multiplicative-order b/Lang/ALGOL-68/Multiplicative-order new file mode 120000 index 0000000000..a948c1bfdf --- /dev/null +++ b/Lang/ALGOL-68/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Mutual-recursion b/Lang/ALGOL-68/Mutual-recursion new file mode 120000 index 0000000000..4173ba104a --- /dev/null +++ b/Lang/ALGOL-68/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/ALGOL-68 \ No newline at end of file diff --git a/Lang/APL/Forward-difference b/Lang/APL/Forward-difference new file mode 120000 index 0000000000..8e946b0e94 --- /dev/null +++ b/Lang/APL/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/APL \ No newline at end of file diff --git a/Lang/APL/Function-definition b/Lang/APL/Function-definition new file mode 120000 index 0000000000..c050d37619 --- /dev/null +++ b/Lang/APL/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/APL \ No newline at end of file diff --git a/Lang/APL/Greatest-element-of-a-list b/Lang/APL/Greatest-element-of-a-list new file mode 120000 index 0000000000..82630c511b --- /dev/null +++ b/Lang/APL/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/APL \ No newline at end of file diff --git a/Lang/APL/Hailstone-sequence b/Lang/APL/Hailstone-sequence new file mode 120000 index 0000000000..6837e5f3dc --- /dev/null +++ b/Lang/APL/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/APL \ No newline at end of file diff --git a/Lang/APL/Happy-numbers b/Lang/APL/Happy-numbers new file mode 120000 index 0000000000..34d7368e94 --- /dev/null +++ b/Lang/APL/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/APL \ No newline at end of file diff --git a/Lang/APL/Identity-matrix b/Lang/APL/Identity-matrix new file mode 120000 index 0000000000..e8d64f478e --- /dev/null +++ b/Lang/APL/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/APL \ No newline at end of file diff --git a/Lang/APL/Knapsack-problem-0-1 b/Lang/APL/Knapsack-problem-0-1 new file mode 120000 index 0000000000..5d2030818e --- /dev/null +++ b/Lang/APL/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/APL \ No newline at end of file diff --git a/Lang/APL/Letter-frequency b/Lang/APL/Letter-frequency new file mode 120000 index 0000000000..34db9d3cc4 --- /dev/null +++ b/Lang/APL/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/APL \ No newline at end of file diff --git a/Lang/APL/Luhn-test-of-credit-card-numbers b/Lang/APL/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..5f57daed14 --- /dev/null +++ b/Lang/APL/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/APL \ No newline at end of file diff --git a/Lang/APL/Matrix-multiplication b/Lang/APL/Matrix-multiplication new file mode 120000 index 0000000000..308c9d1924 --- /dev/null +++ b/Lang/APL/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/APL \ No newline at end of file diff --git a/Lang/APL/Matrix-transposition b/Lang/APL/Matrix-transposition new file mode 120000 index 0000000000..055df41705 --- /dev/null +++ b/Lang/APL/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/APL \ No newline at end of file diff --git a/Lang/APL/Monty-Hall-problem b/Lang/APL/Monty-Hall-problem new file mode 120000 index 0000000000..67dc778b81 --- /dev/null +++ b/Lang/APL/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/APL \ No newline at end of file diff --git a/Lang/ATS/Hello-world-Graphical b/Lang/ATS/Hello-world-Graphical new file mode 120000 index 0000000000..96e7ec1de4 --- /dev/null +++ b/Lang/ATS/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/ATS \ No newline at end of file diff --git a/Lang/ATS/Hello-world-Newline-omission b/Lang/ATS/Hello-world-Newline-omission new file mode 120000 index 0000000000..eaf63d1a8c --- /dev/null +++ b/Lang/ATS/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/ATS \ No newline at end of file diff --git a/Lang/ATS/Hello-world-Standard-error b/Lang/ATS/Hello-world-Standard-error new file mode 120000 index 0000000000..49d680a80f --- /dev/null +++ b/Lang/ATS/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/ATS \ No newline at end of file diff --git a/Lang/ATS/Hello-world-Text b/Lang/ATS/Hello-world-Text new file mode 120000 index 0000000000..4ed653aaf3 --- /dev/null +++ b/Lang/ATS/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ATS \ No newline at end of file diff --git a/Lang/ATS/Horners-rule-for-polynomial-evaluation b/Lang/ATS/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..4c3b279420 --- /dev/null +++ b/Lang/ATS/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/ATS \ No newline at end of file diff --git a/Lang/AWK/Factorial b/Lang/AWK/Factorial new file mode 120000 index 0000000000..107e6a2553 --- /dev/null +++ b/Lang/AWK/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/AWK \ No newline at end of file diff --git a/Lang/AWK/Fibonacci-sequence b/Lang/AWK/Fibonacci-sequence new file mode 120000 index 0000000000..1889739458 --- /dev/null +++ b/Lang/AWK/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/AWK \ No newline at end of file diff --git a/Lang/AWK/File-IO b/Lang/AWK/File-IO new file mode 120000 index 0000000000..f969ee76a9 --- /dev/null +++ b/Lang/AWK/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/AWK \ No newline at end of file diff --git a/Lang/AWK/Filter b/Lang/AWK/Filter new file mode 120000 index 0000000000..6576bc21ef --- /dev/null +++ b/Lang/AWK/Filter @@ -0,0 +1 @@ +../../Task/Filter/AWK \ No newline at end of file diff --git a/Lang/AWK/Find-common-directory-path b/Lang/AWK/Find-common-directory-path new file mode 120000 index 0000000000..732fe772ff --- /dev/null +++ b/Lang/AWK/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/AWK \ No newline at end of file diff --git a/Lang/AWK/Find-limit-of-recursion b/Lang/AWK/Find-limit-of-recursion new file mode 120000 index 0000000000..eca5f1f4ce --- /dev/null +++ b/Lang/AWK/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/AWK \ No newline at end of file diff --git a/Lang/AWK/Flow-control-structures b/Lang/AWK/Flow-control-structures new file mode 120000 index 0000000000..3c01122cc7 --- /dev/null +++ b/Lang/AWK/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/AWK \ No newline at end of file diff --git a/Lang/AWK/Floyds-triangle b/Lang/AWK/Floyds-triangle new file mode 120000 index 0000000000..40aae1e7e7 --- /dev/null +++ b/Lang/AWK/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/AWK \ No newline at end of file diff --git a/Lang/AWK/Formatted-numeric-output b/Lang/AWK/Formatted-numeric-output new file mode 120000 index 0000000000..ddebbe5aa7 --- /dev/null +++ b/Lang/AWK/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/AWK \ No newline at end of file diff --git a/Lang/AWK/Forward-difference b/Lang/AWK/Forward-difference new file mode 120000 index 0000000000..031bd2bbbd --- /dev/null +++ b/Lang/AWK/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/AWK \ No newline at end of file diff --git a/Lang/AWK/Function-definition b/Lang/AWK/Function-definition new file mode 120000 index 0000000000..d2532fffc3 --- /dev/null +++ b/Lang/AWK/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/AWK \ No newline at end of file diff --git a/Lang/AWK/Globally-replace-text-in-several-files b/Lang/AWK/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..5ea2f2a154 --- /dev/null +++ b/Lang/AWK/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/AWK \ No newline at end of file diff --git a/Lang/AWK/Greatest-common-divisor b/Lang/AWK/Greatest-common-divisor new file mode 120000 index 0000000000..6cd6c8757c --- /dev/null +++ b/Lang/AWK/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/AWK \ No newline at end of file diff --git a/Lang/AWK/Greatest-element-of-a-list b/Lang/AWK/Greatest-element-of-a-list new file mode 120000 index 0000000000..3bd699143f --- /dev/null +++ b/Lang/AWK/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/AWK \ No newline at end of file diff --git a/Lang/AWK/Greatest-subsequential-sum b/Lang/AWK/Greatest-subsequential-sum new file mode 120000 index 0000000000..af1d8c9ef9 --- /dev/null +++ b/Lang/AWK/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/AWK \ No newline at end of file diff --git a/Lang/AWK/Happy-numbers b/Lang/AWK/Happy-numbers new file mode 120000 index 0000000000..e9559deb74 --- /dev/null +++ b/Lang/AWK/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Hash-from-two-arrays b/Lang/AWK/Hash-from-two-arrays new file mode 120000 index 0000000000..74a72a171f --- /dev/null +++ b/Lang/AWK/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/AWK \ No newline at end of file diff --git a/Lang/AWK/Haversine-formula b/Lang/AWK/Haversine-formula new file mode 120000 index 0000000000..15b58f1964 --- /dev/null +++ b/Lang/AWK/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/AWK \ No newline at end of file diff --git a/Lang/AWK/Hello-world-Line-printer b/Lang/AWK/Hello-world-Line-printer new file mode 120000 index 0000000000..3d4b679ce8 --- /dev/null +++ b/Lang/AWK/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/AWK \ No newline at end of file diff --git a/Lang/AWK/Hello-world-Newline-omission b/Lang/AWK/Hello-world-Newline-omission new file mode 120000 index 0000000000..954337f064 --- /dev/null +++ b/Lang/AWK/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/AWK \ No newline at end of file diff --git a/Lang/AWK/Hello-world-Standard-error b/Lang/AWK/Hello-world-Standard-error new file mode 120000 index 0000000000..c4b77bff1f --- /dev/null +++ b/Lang/AWK/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/AWK \ No newline at end of file diff --git a/Lang/AWK/Hello-world-Text b/Lang/AWK/Hello-world-Text new file mode 120000 index 0000000000..eeb93314e1 --- /dev/null +++ b/Lang/AWK/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AWK \ No newline at end of file diff --git a/Lang/AWK/Hello-world-Web-server b/Lang/AWK/Hello-world-Web-server new file mode 120000 index 0000000000..6197dae130 --- /dev/null +++ b/Lang/AWK/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/AWK \ No newline at end of file diff --git a/Lang/AWK/Hofstadter-Conway-$10,000-sequence b/Lang/AWK/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..e790b53ead --- /dev/null +++ b/Lang/AWK/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/AWK \ No newline at end of file diff --git a/Lang/AWK/Hofstadter-Q-sequence b/Lang/AWK/Hofstadter-Q-sequence new file mode 120000 index 0000000000..a27f25332a --- /dev/null +++ b/Lang/AWK/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/AWK \ No newline at end of file diff --git a/Lang/AWK/Hostname b/Lang/AWK/Hostname new file mode 120000 index 0000000000..349070442f --- /dev/null +++ b/Lang/AWK/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/AWK \ No newline at end of file diff --git a/Lang/AWK/Identity-matrix b/Lang/AWK/Identity-matrix new file mode 120000 index 0000000000..18ea8734d8 --- /dev/null +++ b/Lang/AWK/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/AWK \ No newline at end of file diff --git a/Lang/AWK/Include-a-file b/Lang/AWK/Include-a-file new file mode 120000 index 0000000000..e9ddb5c451 --- /dev/null +++ b/Lang/AWK/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Increment-a-numerical-string b/Lang/AWK/Increment-a-numerical-string new file mode 120000 index 0000000000..20d27eb4f8 --- /dev/null +++ b/Lang/AWK/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Input-loop b/Lang/AWK/Input-loop new file mode 120000 index 0000000000..82ff6db16c --- /dev/null +++ b/Lang/AWK/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/AWK \ No newline at end of file diff --git a/Lang/AWK/Integer-comparison b/Lang/AWK/Integer-comparison new file mode 120000 index 0000000000..db65abf3f7 --- /dev/null +++ b/Lang/AWK/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/AWK \ No newline at end of file diff --git a/Lang/AWK/Integer-sequence b/Lang/AWK/Integer-sequence new file mode 120000 index 0000000000..7cd5ef60da --- /dev/null +++ b/Lang/AWK/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/AWK \ No newline at end of file diff --git a/Lang/AWK/Leap-year b/Lang/AWK/Leap-year new file mode 120000 index 0000000000..98340f7ab9 --- /dev/null +++ b/Lang/AWK/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/AWK \ No newline at end of file diff --git a/Lang/AWK/Least-common-multiple b/Lang/AWK/Least-common-multiple new file mode 120000 index 0000000000..eb07dfd9fb --- /dev/null +++ b/Lang/AWK/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/AWK \ No newline at end of file diff --git a/Lang/AWK/Letter-frequency b/Lang/AWK/Letter-frequency new file mode 120000 index 0000000000..e006bf486e --- /dev/null +++ b/Lang/AWK/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/AWK \ No newline at end of file diff --git a/Lang/AWK/Levenshtein-distance b/Lang/AWK/Levenshtein-distance new file mode 120000 index 0000000000..377bece9aa --- /dev/null +++ b/Lang/AWK/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/AWK \ No newline at end of file diff --git a/Lang/AWK/Literals-Floating-point b/Lang/AWK/Literals-Floating-point new file mode 120000 index 0000000000..b796d9ff0b --- /dev/null +++ b/Lang/AWK/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/AWK \ No newline at end of file diff --git a/Lang/AWK/Literals-Integer b/Lang/AWK/Literals-Integer new file mode 120000 index 0000000000..1ac80e35ab --- /dev/null +++ b/Lang/AWK/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/AWK \ No newline at end of file diff --git a/Lang/AWK/Literals-String b/Lang/AWK/Literals-String new file mode 120000 index 0000000000..3b64fcbde3 --- /dev/null +++ b/Lang/AWK/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/AWK \ No newline at end of file diff --git a/Lang/AWK/Logical-operations b/Lang/AWK/Logical-operations new file mode 120000 index 0000000000..547d6dcb8b --- /dev/null +++ b/Lang/AWK/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/AWK \ No newline at end of file diff --git a/Lang/AWK/Long-multiplication b/Lang/AWK/Long-multiplication new file mode 120000 index 0000000000..7c86ade0cd --- /dev/null +++ b/Lang/AWK/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/AWK \ No newline at end of file diff --git a/Lang/AWK/Longest-string-challenge b/Lang/AWK/Longest-string-challenge new file mode 120000 index 0000000000..983d8ca074 --- /dev/null +++ b/Lang/AWK/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/AWK \ No newline at end of file diff --git a/Lang/AWK/Look-and-say-sequence b/Lang/AWK/Look-and-say-sequence new file mode 120000 index 0000000000..3058dca9a1 --- /dev/null +++ b/Lang/AWK/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/AWK \ No newline at end of file diff --git a/Lang/AWK/Loop-over-multiple-arrays-simultaneously b/Lang/AWK/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..35e9988bbd --- /dev/null +++ b/Lang/AWK/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Break b/Lang/AWK/Loops-Break new file mode 120000 index 0000000000..f9c3d04526 --- /dev/null +++ b/Lang/AWK/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Continue b/Lang/AWK/Loops-Continue new file mode 120000 index 0000000000..a52cbd2048 --- /dev/null +++ b/Lang/AWK/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Do-while b/Lang/AWK/Loops-Do-while new file mode 120000 index 0000000000..640a18ee39 --- /dev/null +++ b/Lang/AWK/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Downward-for b/Lang/AWK/Loops-Downward-for new file mode 120000 index 0000000000..47b9bfc053 --- /dev/null +++ b/Lang/AWK/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-For b/Lang/AWK/Loops-For new file mode 120000 index 0000000000..5370121b9e --- /dev/null +++ b/Lang/AWK/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-For-with-a-specified-step b/Lang/AWK/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..df3ab52bed --- /dev/null +++ b/Lang/AWK/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Foreach b/Lang/AWK/Loops-Foreach new file mode 120000 index 0000000000..c7273a8921 --- /dev/null +++ b/Lang/AWK/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Infinite b/Lang/AWK/Loops-Infinite new file mode 120000 index 0000000000..a429bb6529 --- /dev/null +++ b/Lang/AWK/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-N-plus-one-half b/Lang/AWK/Loops-N-plus-one-half new file mode 120000 index 0000000000..34d9a32b66 --- /dev/null +++ b/Lang/AWK/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-Nested b/Lang/AWK/Loops-Nested new file mode 120000 index 0000000000..84b79907bd --- /dev/null +++ b/Lang/AWK/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/AWK \ No newline at end of file diff --git a/Lang/AWK/Loops-While b/Lang/AWK/Loops-While new file mode 120000 index 0000000000..5bbb5a915d --- /dev/null +++ b/Lang/AWK/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/AWK \ No newline at end of file diff --git a/Lang/AWK/Luhn-test-of-credit-card-numbers b/Lang/AWK/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..0057545201 --- /dev/null +++ b/Lang/AWK/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Mandelbrot-set b/Lang/AWK/Mandelbrot-set new file mode 120000 index 0000000000..da90f94f11 --- /dev/null +++ b/Lang/AWK/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/AWK \ No newline at end of file diff --git a/Lang/AWK/Matrix-transposition b/Lang/AWK/Matrix-transposition new file mode 120000 index 0000000000..c4cb7ef646 --- /dev/null +++ b/Lang/AWK/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/AWK \ No newline at end of file diff --git a/Lang/AWK/Maze-generation b/Lang/AWK/Maze-generation new file mode 120000 index 0000000000..4172858969 --- /dev/null +++ b/Lang/AWK/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/AWK \ No newline at end of file diff --git a/Lang/AWK/Menu b/Lang/AWK/Menu new file mode 120000 index 0000000000..4e4391deff --- /dev/null +++ b/Lang/AWK/Menu @@ -0,0 +1 @@ +../../Task/Menu/AWK \ No newline at end of file diff --git a/Lang/AWK/Monte-Carlo-methods b/Lang/AWK/Monte-Carlo-methods new file mode 120000 index 0000000000..2cc1047d21 --- /dev/null +++ b/Lang/AWK/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/AWK \ No newline at end of file diff --git a/Lang/AWK/Monty-Hall-problem b/Lang/AWK/Monty-Hall-problem new file mode 120000 index 0000000000..c80212e23b --- /dev/null +++ b/Lang/AWK/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/AWK \ No newline at end of file diff --git a/Lang/AWK/Morse-code b/Lang/AWK/Morse-code new file mode 120000 index 0000000000..4ed647d6d3 --- /dev/null +++ b/Lang/AWK/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/AWK \ No newline at end of file diff --git a/Lang/AWK/Multiplication-tables b/Lang/AWK/Multiplication-tables new file mode 120000 index 0000000000..e4386fb59f --- /dev/null +++ b/Lang/AWK/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/AWK \ No newline at end of file diff --git a/Lang/AWK/Mutual-recursion b/Lang/AWK/Mutual-recursion new file mode 120000 index 0000000000..67a99313c5 --- /dev/null +++ b/Lang/AWK/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/AWK \ No newline at end of file diff --git a/Lang/ActionScript/Factorial b/Lang/ActionScript/Factorial new file mode 120000 index 0000000000..ab905e1ff9 --- /dev/null +++ b/Lang/ActionScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Factors-of-an-integer b/Lang/ActionScript/Factors-of-an-integer new file mode 120000 index 0000000000..26d3b03bb5 --- /dev/null +++ b/Lang/ActionScript/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Fibonacci-sequence b/Lang/ActionScript/Fibonacci-sequence new file mode 120000 index 0000000000..eaf8681647 --- /dev/null +++ b/Lang/ActionScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Filter b/Lang/ActionScript/Filter new file mode 120000 index 0000000000..48fabfb145 --- /dev/null +++ b/Lang/ActionScript/Filter @@ -0,0 +1 @@ +../../Task/Filter/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/First-class-functions b/Lang/ActionScript/First-class-functions new file mode 120000 index 0000000000..7d8d541a6e --- /dev/null +++ b/Lang/ActionScript/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Flatten-a-list b/Lang/ActionScript/Flatten-a-list new file mode 120000 index 0000000000..967d48f31e --- /dev/null +++ b/Lang/ActionScript/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Function-composition b/Lang/ActionScript/Function-composition new file mode 120000 index 0000000000..1a6de6f149 --- /dev/null +++ b/Lang/ActionScript/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Function-definition b/Lang/ActionScript/Function-definition new file mode 120000 index 0000000000..f64eba699f --- /dev/null +++ b/Lang/ActionScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Greatest-common-divisor b/Lang/ActionScript/Greatest-common-divisor new file mode 120000 index 0000000000..d023e09e91 --- /dev/null +++ b/Lang/ActionScript/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Greatest-element-of-a-list b/Lang/ActionScript/Greatest-element-of-a-list new file mode 120000 index 0000000000..7d99d0c758 --- /dev/null +++ b/Lang/ActionScript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Greyscale-bars-Display b/Lang/ActionScript/Greyscale-bars-Display new file mode 120000 index 0000000000..645ba13854 --- /dev/null +++ b/Lang/ActionScript/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/HTTP b/Lang/ActionScript/HTTP new file mode 120000 index 0000000000..e59938ed80 --- /dev/null +++ b/Lang/ActionScript/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Happy-numbers b/Lang/ActionScript/Happy-numbers new file mode 120000 index 0000000000..a2993da330 --- /dev/null +++ b/Lang/ActionScript/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Hash-from-two-arrays b/Lang/ActionScript/Hash-from-two-arrays new file mode 120000 index 0000000000..8377c1a9e8 --- /dev/null +++ b/Lang/ActionScript/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Hello-world-Graphical b/Lang/ActionScript/Hello-world-Graphical new file mode 120000 index 0000000000..37d3b8c086 --- /dev/null +++ b/Lang/ActionScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Hello-world-Text b/Lang/ActionScript/Hello-world-Text new file mode 120000 index 0000000000..d519aede28 --- /dev/null +++ b/Lang/ActionScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Higher-order-functions b/Lang/ActionScript/Higher-order-functions new file mode 120000 index 0000000000..df9cd67b45 --- /dev/null +++ b/Lang/ActionScript/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Increment-a-numerical-string b/Lang/ActionScript/Increment-a-numerical-string new file mode 120000 index 0000000000..4b85d3aacc --- /dev/null +++ b/Lang/ActionScript/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Inheritance-Single b/Lang/ActionScript/Inheritance-Single new file mode 120000 index 0000000000..cdd1731a89 --- /dev/null +++ b/Lang/ActionScript/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Leap-year b/Lang/ActionScript/Leap-year new file mode 120000 index 0000000000..63d553e282 --- /dev/null +++ b/Lang/ActionScript/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Loops-Do-while b/Lang/ActionScript/Loops-Do-while new file mode 120000 index 0000000000..ea99e9fc22 --- /dev/null +++ b/Lang/ActionScript/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Loops-For b/Lang/ActionScript/Loops-For new file mode 120000 index 0000000000..802553ea41 --- /dev/null +++ b/Lang/ActionScript/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Loops-Infinite b/Lang/ActionScript/Loops-Infinite new file mode 120000 index 0000000000..4638f8c137 --- /dev/null +++ b/Lang/ActionScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Loops-While b/Lang/ActionScript/Loops-While new file mode 120000 index 0000000000..1bd0682e94 --- /dev/null +++ b/Lang/ActionScript/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Luhn-test-of-credit-card-numbers b/Lang/ActionScript/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..bfa1d56f28 --- /dev/null +++ b/Lang/ActionScript/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Matrix-transposition b/Lang/ActionScript/Matrix-transposition new file mode 120000 index 0000000000..ce20469e91 --- /dev/null +++ b/Lang/ActionScript/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Monty-Hall-problem b/Lang/ActionScript/Monty-Hall-problem new file mode 120000 index 0000000000..6b16ea0b15 --- /dev/null +++ b/Lang/ActionScript/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/ActionScript \ No newline at end of file diff --git a/Lang/Ada/Arbitrary-precision-integers-included b/Lang/Ada/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..eb30af14b8 --- /dev/null +++ b/Lang/Ada/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Ada \ No newline at end of file diff --git a/Lang/Ada/Factorial b/Lang/Ada/Factorial new file mode 120000 index 0000000000..c09e0c1e57 --- /dev/null +++ b/Lang/Ada/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Ada \ No newline at end of file diff --git a/Lang/Ada/Factors-of-a-Mersenne-number b/Lang/Ada/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..1f76b8ba18 --- /dev/null +++ b/Lang/Ada/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Ada \ No newline at end of file diff --git a/Lang/Ada/Factors-of-an-integer b/Lang/Ada/Factors-of-an-integer new file mode 120000 index 0000000000..b1be403f28 --- /dev/null +++ b/Lang/Ada/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Ada \ No newline at end of file diff --git a/Lang/Ada/Fast-Fourier-transform b/Lang/Ada/Fast-Fourier-transform new file mode 120000 index 0000000000..4213262fe0 --- /dev/null +++ b/Lang/Ada/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Ada \ No newline at end of file diff --git a/Lang/Ada/Fibonacci-n-step-number-sequences b/Lang/Ada/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..a3ebf7f67b --- /dev/null +++ b/Lang/Ada/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Ada \ No newline at end of file diff --git a/Lang/Ada/Fibonacci-sequence b/Lang/Ada/Fibonacci-sequence new file mode 120000 index 0000000000..6f4f783d50 --- /dev/null +++ b/Lang/Ada/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/File-IO b/Lang/Ada/File-IO new file mode 120000 index 0000000000..a1bb43fdee --- /dev/null +++ b/Lang/Ada/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Ada \ No newline at end of file diff --git a/Lang/Ada/File-modification-time b/Lang/Ada/File-modification-time new file mode 120000 index 0000000000..2d1d5e967c --- /dev/null +++ b/Lang/Ada/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Ada \ No newline at end of file diff --git a/Lang/Ada/File-size b/Lang/Ada/File-size new file mode 120000 index 0000000000..12b7bae542 --- /dev/null +++ b/Lang/Ada/File-size @@ -0,0 +1 @@ +../../Task/File-size/Ada \ No newline at end of file diff --git a/Lang/Ada/Filter b/Lang/Ada/Filter new file mode 120000 index 0000000000..68f6c45d70 --- /dev/null +++ b/Lang/Ada/Filter @@ -0,0 +1 @@ +../../Task/Filter/Ada \ No newline at end of file diff --git a/Lang/Ada/Find-common-directory-path b/Lang/Ada/Find-common-directory-path new file mode 120000 index 0000000000..7df7bc0ee6 --- /dev/null +++ b/Lang/Ada/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Ada \ No newline at end of file diff --git a/Lang/Ada/Find-limit-of-recursion b/Lang/Ada/Find-limit-of-recursion new file mode 120000 index 0000000000..9a82d45da9 --- /dev/null +++ b/Lang/Ada/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Ada \ No newline at end of file diff --git a/Lang/Ada/Find-the-missing-permutation b/Lang/Ada/Find-the-missing-permutation new file mode 120000 index 0000000000..4be2dfbb9e --- /dev/null +++ b/Lang/Ada/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Ada \ No newline at end of file diff --git a/Lang/Ada/First-class-functions b/Lang/Ada/First-class-functions new file mode 120000 index 0000000000..ddf43127ed --- /dev/null +++ b/Lang/Ada/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Ada \ No newline at end of file diff --git a/Lang/Ada/First-class-functions-Use-numbers-analogously b/Lang/Ada/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..f47f9660f6 --- /dev/null +++ b/Lang/Ada/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Ada \ No newline at end of file diff --git a/Lang/Ada/Five-weekends b/Lang/Ada/Five-weekends new file mode 120000 index 0000000000..4ecee3f70e --- /dev/null +++ b/Lang/Ada/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Ada \ No newline at end of file diff --git a/Lang/Ada/Flow-control-structures b/Lang/Ada/Flow-control-structures new file mode 120000 index 0000000000..54a91513fa --- /dev/null +++ b/Lang/Ada/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Ada \ No newline at end of file diff --git a/Lang/Ada/Floyds-triangle b/Lang/Ada/Floyds-triangle new file mode 120000 index 0000000000..9a5aed25c0 --- /dev/null +++ b/Lang/Ada/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Ada \ No newline at end of file diff --git a/Lang/Ada/Fork b/Lang/Ada/Fork new file mode 120000 index 0000000000..a92ae02c32 --- /dev/null +++ b/Lang/Ada/Fork @@ -0,0 +1 @@ +../../Task/Fork/Ada \ No newline at end of file diff --git a/Lang/Ada/Formal-power-series b/Lang/Ada/Formal-power-series new file mode 120000 index 0000000000..90ab557e45 --- /dev/null +++ b/Lang/Ada/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Ada \ No newline at end of file diff --git a/Lang/Ada/Formatted-numeric-output b/Lang/Ada/Formatted-numeric-output new file mode 120000 index 0000000000..a654d24309 --- /dev/null +++ b/Lang/Ada/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Ada \ No newline at end of file diff --git a/Lang/Ada/Forward-difference b/Lang/Ada/Forward-difference new file mode 120000 index 0000000000..2726dec37b --- /dev/null +++ b/Lang/Ada/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Ada \ No newline at end of file diff --git a/Lang/Ada/Four-bit-adder b/Lang/Ada/Four-bit-adder new file mode 120000 index 0000000000..8bd50f9a51 --- /dev/null +++ b/Lang/Ada/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Ada \ No newline at end of file diff --git a/Lang/Ada/Function-composition b/Lang/Ada/Function-composition new file mode 120000 index 0000000000..b7a669f7a5 --- /dev/null +++ b/Lang/Ada/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Ada \ No newline at end of file diff --git a/Lang/Ada/Function-definition b/Lang/Ada/Function-definition new file mode 120000 index 0000000000..6274bd1cc7 --- /dev/null +++ b/Lang/Ada/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Ada \ No newline at end of file diff --git a/Lang/Ada/Function-prototype b/Lang/Ada/Function-prototype new file mode 120000 index 0000000000..c83f685ced --- /dev/null +++ b/Lang/Ada/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/Ada \ No newline at end of file diff --git a/Lang/Ada/GUI-Maximum-window-dimensions b/Lang/Ada/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..38f1779c1f --- /dev/null +++ b/Lang/Ada/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Ada \ No newline at end of file diff --git a/Lang/Ada/GUI-component-interaction b/Lang/Ada/GUI-component-interaction new file mode 120000 index 0000000000..745fa69384 --- /dev/null +++ b/Lang/Ada/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Ada \ No newline at end of file diff --git a/Lang/Ada/GUI-enabling-disabling-of-controls b/Lang/Ada/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..f714450648 --- /dev/null +++ b/Lang/Ada/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Ada \ No newline at end of file diff --git a/Lang/Ada/Gamma-function b/Lang/Ada/Gamma-function new file mode 120000 index 0000000000..3588f997ba --- /dev/null +++ b/Lang/Ada/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Generator-Exponential b/Lang/Ada/Generator-Exponential new file mode 120000 index 0000000000..28f0e76e69 --- /dev/null +++ b/Lang/Ada/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Ada \ No newline at end of file diff --git a/Lang/Ada/Generic-swap b/Lang/Ada/Generic-swap new file mode 120000 index 0000000000..565d9e831e --- /dev/null +++ b/Lang/Ada/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Ada \ No newline at end of file diff --git a/Lang/Ada/Globally-replace-text-in-several-files b/Lang/Ada/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..9b1f8bc029 --- /dev/null +++ b/Lang/Ada/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Ada \ No newline at end of file diff --git a/Lang/Ada/Gray-code b/Lang/Ada/Gray-code new file mode 120000 index 0000000000..376bbb05fd --- /dev/null +++ b/Lang/Ada/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Ada \ No newline at end of file diff --git a/Lang/Ada/Grayscale-image b/Lang/Ada/Grayscale-image new file mode 120000 index 0000000000..a9074ef532 --- /dev/null +++ b/Lang/Ada/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Ada \ No newline at end of file diff --git a/Lang/Ada/Greatest-common-divisor b/Lang/Ada/Greatest-common-divisor new file mode 120000 index 0000000000..8a041baa13 --- /dev/null +++ b/Lang/Ada/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Ada \ No newline at end of file diff --git a/Lang/Ada/Greatest-element-of-a-list b/Lang/Ada/Greatest-element-of-a-list new file mode 120000 index 0000000000..d47440219f --- /dev/null +++ b/Lang/Ada/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Ada \ No newline at end of file diff --git a/Lang/Ada/Greatest-subsequential-sum b/Lang/Ada/Greatest-subsequential-sum new file mode 120000 index 0000000000..d7e89a5141 --- /dev/null +++ b/Lang/Ada/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Ada \ No newline at end of file diff --git a/Lang/Ada/Greyscale-bars-Display b/Lang/Ada/Greyscale-bars-Display new file mode 120000 index 0000000000..ae9af276df --- /dev/null +++ b/Lang/Ada/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Ada \ No newline at end of file diff --git a/Lang/Ada/Guess-the-number b/Lang/Ada/Guess-the-number new file mode 120000 index 0000000000..edb6ce45be --- /dev/null +++ b/Lang/Ada/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Ada \ No newline at end of file diff --git a/Lang/Ada/Guess-the-number-With-feedback b/Lang/Ada/Guess-the-number-With-feedback new file mode 120000 index 0000000000..caee070e34 --- /dev/null +++ b/Lang/Ada/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Ada \ No newline at end of file diff --git a/Lang/Ada/Guess-the-number-With-feedback-player b/Lang/Ada/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..b0baf7b5c4 --- /dev/null +++ b/Lang/Ada/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Ada \ No newline at end of file diff --git a/Lang/Ada/HTTP b/Lang/Ada/HTTP new file mode 120000 index 0000000000..9d77a46a47 --- /dev/null +++ b/Lang/Ada/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Ada \ No newline at end of file diff --git a/Lang/Ada/HTTPS b/Lang/Ada/HTTPS new file mode 120000 index 0000000000..422074d7ab --- /dev/null +++ b/Lang/Ada/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Ada \ No newline at end of file diff --git a/Lang/Ada/Hailstone-sequence b/Lang/Ada/Hailstone-sequence new file mode 120000 index 0000000000..fb980ca5a5 --- /dev/null +++ b/Lang/Ada/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Hamming-numbers b/Lang/Ada/Hamming-numbers new file mode 120000 index 0000000000..73ab04f193 --- /dev/null +++ b/Lang/Ada/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Handle-a-signal b/Lang/Ada/Handle-a-signal new file mode 120000 index 0000000000..168df285ae --- /dev/null +++ b/Lang/Ada/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Ada \ No newline at end of file diff --git a/Lang/Ada/Happy-numbers b/Lang/Ada/Happy-numbers new file mode 120000 index 0000000000..8ffde10d8c --- /dev/null +++ b/Lang/Ada/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Hash-from-two-arrays b/Lang/Ada/Hash-from-two-arrays new file mode 120000 index 0000000000..1e1488a9de --- /dev/null +++ b/Lang/Ada/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Ada \ No newline at end of file diff --git a/Lang/Ada/Haversine-formula b/Lang/Ada/Haversine-formula new file mode 120000 index 0000000000..d03c6ce576 --- /dev/null +++ b/Lang/Ada/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Graphical b/Lang/Ada/Hello-world-Graphical new file mode 120000 index 0000000000..896499fdf7 --- /dev/null +++ b/Lang/Ada/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Line-printer b/Lang/Ada/Hello-world-Line-printer new file mode 120000 index 0000000000..097027ea3c --- /dev/null +++ b/Lang/Ada/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Newline-omission b/Lang/Ada/Hello-world-Newline-omission new file mode 120000 index 0000000000..61bd49e151 --- /dev/null +++ b/Lang/Ada/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Standard-error b/Lang/Ada/Hello-world-Standard-error new file mode 120000 index 0000000000..e28e734e57 --- /dev/null +++ b/Lang/Ada/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Text b/Lang/Ada/Hello-world-Text new file mode 120000 index 0000000000..9547278e99 --- /dev/null +++ b/Lang/Ada/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Ada \ No newline at end of file diff --git a/Lang/Ada/Hello-world-Web-server b/Lang/Ada/Hello-world-Web-server new file mode 120000 index 0000000000..612e0d3fde --- /dev/null +++ b/Lang/Ada/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Ada \ No newline at end of file diff --git a/Lang/Ada/Here-document b/Lang/Ada/Here-document new file mode 120000 index 0000000000..8bd26f05af --- /dev/null +++ b/Lang/Ada/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Ada \ No newline at end of file diff --git a/Lang/Ada/Higher-order-functions b/Lang/Ada/Higher-order-functions new file mode 120000 index 0000000000..b3dbc378e6 --- /dev/null +++ b/Lang/Ada/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Ada \ No newline at end of file diff --git a/Lang/Ada/History-variables b/Lang/Ada/History-variables new file mode 120000 index 0000000000..b47dc46a4b --- /dev/null +++ b/Lang/Ada/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Ada \ No newline at end of file diff --git a/Lang/Ada/Hofstadter-Conway-$10,000-sequence b/Lang/Ada/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..5a6c5cb1a5 --- /dev/null +++ b/Lang/Ada/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Hofstadter-Figure-Figure-sequences b/Lang/Ada/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..08e45dfbf9 --- /dev/null +++ b/Lang/Ada/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Ada \ No newline at end of file diff --git a/Lang/Ada/Hofstadter-Q-sequence b/Lang/Ada/Hofstadter-Q-sequence new file mode 120000 index 0000000000..0d8e59f342 --- /dev/null +++ b/Lang/Ada/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Holidays-related-to-Easter b/Lang/Ada/Holidays-related-to-Easter new file mode 120000 index 0000000000..fdd9f53ee9 --- /dev/null +++ b/Lang/Ada/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Ada \ No newline at end of file diff --git a/Lang/Ada/Horizontal-sundial-calculations b/Lang/Ada/Horizontal-sundial-calculations new file mode 120000 index 0000000000..ad0158a5dd --- /dev/null +++ b/Lang/Ada/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Ada \ No newline at end of file diff --git a/Lang/Ada/Horners-rule-for-polynomial-evaluation b/Lang/Ada/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..7453d5902b --- /dev/null +++ b/Lang/Ada/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Ada \ No newline at end of file diff --git a/Lang/Ada/Host-introspection b/Lang/Ada/Host-introspection new file mode 120000 index 0000000000..73af74786a --- /dev/null +++ b/Lang/Ada/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Ada \ No newline at end of file diff --git a/Lang/Ada/Hostname b/Lang/Ada/Hostname new file mode 120000 index 0000000000..b49261a303 --- /dev/null +++ b/Lang/Ada/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Ada \ No newline at end of file diff --git a/Lang/Ada/Huffman-coding b/Lang/Ada/Huffman-coding new file mode 120000 index 0000000000..a041723478 --- /dev/null +++ b/Lang/Ada/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Ada \ No newline at end of file diff --git a/Lang/Ada/Identity-matrix b/Lang/Ada/Identity-matrix new file mode 120000 index 0000000000..a429c599e2 --- /dev/null +++ b/Lang/Ada/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Ada \ No newline at end of file diff --git a/Lang/Ada/Image-convolution b/Lang/Ada/Image-convolution new file mode 120000 index 0000000000..56c08abf8f --- /dev/null +++ b/Lang/Ada/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Ada \ No newline at end of file diff --git a/Lang/Ada/Image-noise b/Lang/Ada/Image-noise new file mode 120000 index 0000000000..3a94aeb901 --- /dev/null +++ b/Lang/Ada/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Ada \ No newline at end of file diff --git a/Lang/Ada/Include-a-file b/Lang/Ada/Include-a-file new file mode 120000 index 0000000000..b11778d395 --- /dev/null +++ b/Lang/Ada/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Increment-a-numerical-string b/Lang/Ada/Increment-a-numerical-string new file mode 120000 index 0000000000..edf69e58b3 --- /dev/null +++ b/Lang/Ada/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Inheritance-Multiple b/Lang/Ada/Inheritance-Multiple new file mode 120000 index 0000000000..b2f57ad7af --- /dev/null +++ b/Lang/Ada/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Ada \ No newline at end of file diff --git a/Lang/Ada/Inheritance-Single b/Lang/Ada/Inheritance-Single new file mode 120000 index 0000000000..299c60391d --- /dev/null +++ b/Lang/Ada/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Ada \ No newline at end of file diff --git a/Lang/Ada/Input-loop b/Lang/Ada/Input-loop new file mode 120000 index 0000000000..87929d005e --- /dev/null +++ b/Lang/Ada/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Ada \ No newline at end of file diff --git a/Lang/Ada/Integer-comparison b/Lang/Ada/Integer-comparison new file mode 120000 index 0000000000..4fa929393f --- /dev/null +++ b/Lang/Ada/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Ada \ No newline at end of file diff --git a/Lang/Ada/Integer-sequence b/Lang/Ada/Integer-sequence new file mode 120000 index 0000000000..f4e56b882b --- /dev/null +++ b/Lang/Ada/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Introspection b/Lang/Ada/Introspection new file mode 120000 index 0000000000..f41832fd5c --- /dev/null +++ b/Lang/Ada/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Ada \ No newline at end of file diff --git a/Lang/Ada/Inverted-index b/Lang/Ada/Inverted-index new file mode 120000 index 0000000000..0c75af27d8 --- /dev/null +++ b/Lang/Ada/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Ada \ No newline at end of file diff --git a/Lang/Ada/Inverted-syntax b/Lang/Ada/Inverted-syntax new file mode 120000 index 0000000000..eb88ed59ea --- /dev/null +++ b/Lang/Ada/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Ada \ No newline at end of file diff --git a/Lang/Ada/Jensens-Device b/Lang/Ada/Jensens-Device new file mode 120000 index 0000000000..805b7e6b4c --- /dev/null +++ b/Lang/Ada/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Ada \ No newline at end of file diff --git a/Lang/Ada/Josephus-problem b/Lang/Ada/Josephus-problem new file mode 120000 index 0000000000..54c1a39240 --- /dev/null +++ b/Lang/Ada/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Jump-anywhere b/Lang/Ada/Jump-anywhere new file mode 120000 index 0000000000..8caa223ab9 --- /dev/null +++ b/Lang/Ada/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/Ada \ No newline at end of file diff --git a/Lang/Ada/Kaprekar-numbers b/Lang/Ada/Kaprekar-numbers new file mode 120000 index 0000000000..65a58e369b --- /dev/null +++ b/Lang/Ada/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Ada/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..39a7ff598d --- /dev/null +++ b/Lang/Ada/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Ada \ No newline at end of file diff --git a/Lang/Ada/Keyboard-input-Keypress-check b/Lang/Ada/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..cf68327092 --- /dev/null +++ b/Lang/Ada/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Ada \ No newline at end of file diff --git a/Lang/Ada/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Ada/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..5b91ba7f6b --- /dev/null +++ b/Lang/Ada/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Ada \ No newline at end of file diff --git a/Lang/Ada/Knapsack-problem-0-1 b/Lang/Ada/Knapsack-problem-0-1 new file mode 120000 index 0000000000..191f0865b3 --- /dev/null +++ b/Lang/Ada/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Ada \ No newline at end of file diff --git a/Lang/Ada/Knapsack-problem-Continuous b/Lang/Ada/Knapsack-problem-Continuous new file mode 120000 index 0000000000..2f82747880 --- /dev/null +++ b/Lang/Ada/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Ada \ No newline at end of file diff --git a/Lang/Ada/Knapsack-problem-Unbounded b/Lang/Ada/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..550ca56da5 --- /dev/null +++ b/Lang/Ada/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Ada \ No newline at end of file diff --git a/Lang/Ada/Knights-tour b/Lang/Ada/Knights-tour new file mode 120000 index 0000000000..0a92ede799 --- /dev/null +++ b/Lang/Ada/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Ada \ No newline at end of file diff --git a/Lang/Ada/Knuths-algorithm-S b/Lang/Ada/Knuths-algorithm-S new file mode 120000 index 0000000000..c52846ab9f --- /dev/null +++ b/Lang/Ada/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Ada \ No newline at end of file diff --git a/Lang/Ada/LU-decomposition b/Lang/Ada/LU-decomposition new file mode 120000 index 0000000000..ee0143fcf5 --- /dev/null +++ b/Lang/Ada/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Ada \ No newline at end of file diff --git a/Lang/Ada/LZW-compression b/Lang/Ada/LZW-compression new file mode 120000 index 0000000000..eb8280ae34 --- /dev/null +++ b/Lang/Ada/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Ada \ No newline at end of file diff --git a/Lang/Ada/Langtons-ant b/Lang/Ada/Langtons-ant new file mode 120000 index 0000000000..2ad7b5f7a9 --- /dev/null +++ b/Lang/Ada/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Ada \ No newline at end of file diff --git a/Lang/Ada/Last-Friday-of-each-month b/Lang/Ada/Last-Friday-of-each-month new file mode 120000 index 0000000000..dd1e968cca --- /dev/null +++ b/Lang/Ada/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Ada \ No newline at end of file diff --git a/Lang/Ada/Last-letter-first-letter b/Lang/Ada/Last-letter-first-letter new file mode 120000 index 0000000000..8ba33e0b6f --- /dev/null +++ b/Lang/Ada/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Ada \ No newline at end of file diff --git a/Lang/Ada/Leap-year b/Lang/Ada/Leap-year new file mode 120000 index 0000000000..70ec8dba02 --- /dev/null +++ b/Lang/Ada/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Ada \ No newline at end of file diff --git a/Lang/Ada/Least-common-multiple b/Lang/Ada/Least-common-multiple new file mode 120000 index 0000000000..a935b024f1 --- /dev/null +++ b/Lang/Ada/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Ada \ No newline at end of file diff --git a/Lang/Ada/Letter-frequency b/Lang/Ada/Letter-frequency new file mode 120000 index 0000000000..871a268e1d --- /dev/null +++ b/Lang/Ada/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Ada \ No newline at end of file diff --git a/Lang/Ada/Levenshtein-distance b/Lang/Ada/Levenshtein-distance new file mode 120000 index 0000000000..618a679afc --- /dev/null +++ b/Lang/Ada/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Ada \ No newline at end of file diff --git a/Lang/Ada/Linear-congruential-generator b/Lang/Ada/Linear-congruential-generator new file mode 120000 index 0000000000..dc2508a1e5 --- /dev/null +++ b/Lang/Ada/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Ada \ No newline at end of file diff --git a/Lang/Ada/List-comprehensions b/Lang/Ada/List-comprehensions new file mode 120000 index 0000000000..52dbe4718d --- /dev/null +++ b/Lang/Ada/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Ada \ No newline at end of file diff --git a/Lang/Ada/Literals-Floating-point b/Lang/Ada/Literals-Floating-point new file mode 120000 index 0000000000..bb5f8ec4ea --- /dev/null +++ b/Lang/Ada/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Ada \ No newline at end of file diff --git a/Lang/Ada/Literals-Integer b/Lang/Ada/Literals-Integer new file mode 120000 index 0000000000..dcf551e48f --- /dev/null +++ b/Lang/Ada/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Ada \ No newline at end of file diff --git a/Lang/Ada/Literals-String b/Lang/Ada/Literals-String new file mode 120000 index 0000000000..2067a55bc9 --- /dev/null +++ b/Lang/Ada/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Ada \ No newline at end of file diff --git a/Lang/Ada/Logical-operations b/Lang/Ada/Logical-operations new file mode 120000 index 0000000000..c0c2dd60f5 --- /dev/null +++ b/Lang/Ada/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Ada \ No newline at end of file diff --git a/Lang/Ada/Long-multiplication b/Lang/Ada/Long-multiplication new file mode 120000 index 0000000000..25320879a6 --- /dev/null +++ b/Lang/Ada/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Ada \ No newline at end of file diff --git a/Lang/Ada/Longest-common-subsequence b/Lang/Ada/Longest-common-subsequence new file mode 120000 index 0000000000..76f380b2d2 --- /dev/null +++ b/Lang/Ada/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Longest-string-challenge b/Lang/Ada/Longest-string-challenge new file mode 120000 index 0000000000..dc269b20da --- /dev/null +++ b/Lang/Ada/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Ada \ No newline at end of file diff --git a/Lang/Ada/Look-and-say-sequence b/Lang/Ada/Look-and-say-sequence new file mode 120000 index 0000000000..f451b4ab08 --- /dev/null +++ b/Lang/Ada/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Loop-over-multiple-arrays-simultaneously b/Lang/Ada/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..646618f6f4 --- /dev/null +++ b/Lang/Ada/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Break b/Lang/Ada/Loops-Break new file mode 120000 index 0000000000..a1a21544bd --- /dev/null +++ b/Lang/Ada/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Continue b/Lang/Ada/Loops-Continue new file mode 120000 index 0000000000..b8f56ac7d2 --- /dev/null +++ b/Lang/Ada/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Do-while b/Lang/Ada/Loops-Do-while new file mode 120000 index 0000000000..bc412a2cab --- /dev/null +++ b/Lang/Ada/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Downward-for b/Lang/Ada/Loops-Downward-for new file mode 120000 index 0000000000..b4c8332397 --- /dev/null +++ b/Lang/Ada/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-For b/Lang/Ada/Loops-For new file mode 120000 index 0000000000..e335164c24 --- /dev/null +++ b/Lang/Ada/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-For-with-a-specified-step b/Lang/Ada/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..bf46e67e3c --- /dev/null +++ b/Lang/Ada/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Foreach b/Lang/Ada/Loops-Foreach new file mode 120000 index 0000000000..ecc225b49e --- /dev/null +++ b/Lang/Ada/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Infinite b/Lang/Ada/Loops-Infinite new file mode 120000 index 0000000000..38e448fac5 --- /dev/null +++ b/Lang/Ada/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-N-plus-one-half b/Lang/Ada/Loops-N-plus-one-half new file mode 120000 index 0000000000..c00dd7802c --- /dev/null +++ b/Lang/Ada/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-Nested b/Lang/Ada/Loops-Nested new file mode 120000 index 0000000000..de31bc468d --- /dev/null +++ b/Lang/Ada/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Ada \ No newline at end of file diff --git a/Lang/Ada/Loops-While b/Lang/Ada/Loops-While new file mode 120000 index 0000000000..b94621cb75 --- /dev/null +++ b/Lang/Ada/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Ada \ No newline at end of file diff --git a/Lang/Ada/Lucas-Lehmer-test b/Lang/Ada/Lucas-Lehmer-test new file mode 120000 index 0000000000..ccfa945234 --- /dev/null +++ b/Lang/Ada/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Ada \ No newline at end of file diff --git a/Lang/Ada/Luhn-test-of-credit-card-numbers b/Lang/Ada/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..b3a336ff85 --- /dev/null +++ b/Lang/Ada/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/MD5 b/Lang/Ada/MD5 new file mode 120000 index 0000000000..d63b4ea81a --- /dev/null +++ b/Lang/Ada/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Ada \ No newline at end of file diff --git a/Lang/Ada/MD5-Implementation b/Lang/Ada/MD5-Implementation new file mode 120000 index 0000000000..5d7e17efda --- /dev/null +++ b/Lang/Ada/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Ada \ No newline at end of file diff --git a/Lang/Ada/Man-or-boy-test b/Lang/Ada/Man-or-boy-test new file mode 120000 index 0000000000..de4f2289a0 --- /dev/null +++ b/Lang/Ada/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Ada \ No newline at end of file diff --git a/Lang/Ada/Mandelbrot-set b/Lang/Ada/Mandelbrot-set new file mode 120000 index 0000000000..d5399dd921 --- /dev/null +++ b/Lang/Ada/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Ada \ No newline at end of file diff --git a/Lang/Ada/Map-range b/Lang/Ada/Map-range new file mode 120000 index 0000000000..fd465011dc --- /dev/null +++ b/Lang/Ada/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Ada \ No newline at end of file diff --git a/Lang/Ada/Matrix-exponentiation-operator b/Lang/Ada/Matrix-exponentiation-operator new file mode 120000 index 0000000000..c98bd378c3 --- /dev/null +++ b/Lang/Ada/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Ada \ No newline at end of file diff --git a/Lang/Ada/Matrix-multiplication b/Lang/Ada/Matrix-multiplication new file mode 120000 index 0000000000..ee8b5fdacd --- /dev/null +++ b/Lang/Ada/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Ada \ No newline at end of file diff --git a/Lang/Ada/Matrix-transposition b/Lang/Ada/Matrix-transposition new file mode 120000 index 0000000000..8d29664544 --- /dev/null +++ b/Lang/Ada/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Ada \ No newline at end of file diff --git a/Lang/Ada/Maze-generation b/Lang/Ada/Maze-generation new file mode 120000 index 0000000000..ceb319c9e6 --- /dev/null +++ b/Lang/Ada/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Ada \ No newline at end of file diff --git a/Lang/Ada/Maze-solving b/Lang/Ada/Maze-solving new file mode 120000 index 0000000000..75fdc76394 --- /dev/null +++ b/Lang/Ada/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Ada \ No newline at end of file diff --git a/Lang/Ada/Median-filter b/Lang/Ada/Median-filter new file mode 120000 index 0000000000..6b682483a7 --- /dev/null +++ b/Lang/Ada/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Ada \ No newline at end of file diff --git a/Lang/Ada/Memory-allocation b/Lang/Ada/Memory-allocation new file mode 120000 index 0000000000..819c655d1f --- /dev/null +++ b/Lang/Ada/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Ada \ No newline at end of file diff --git a/Lang/Ada/Memory-layout-of-a-data-structure b/Lang/Ada/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..e4f5f63143 --- /dev/null +++ b/Lang/Ada/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Ada \ No newline at end of file diff --git a/Lang/Ada/Menu b/Lang/Ada/Menu new file mode 120000 index 0000000000..b83737e71d --- /dev/null +++ b/Lang/Ada/Menu @@ -0,0 +1 @@ +../../Task/Menu/Ada \ No newline at end of file diff --git a/Lang/Ada/Metered-concurrency b/Lang/Ada/Metered-concurrency new file mode 120000 index 0000000000..b4830d1a66 --- /dev/null +++ b/Lang/Ada/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Ada \ No newline at end of file diff --git a/Lang/Ada/Middle-three-digits b/Lang/Ada/Middle-three-digits new file mode 120000 index 0000000000..3e4eae8d29 --- /dev/null +++ b/Lang/Ada/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Ada \ No newline at end of file diff --git a/Lang/Ada/Miller-Rabin-primality-test b/Lang/Ada/Miller-Rabin-primality-test new file mode 120000 index 0000000000..79bf6fd437 --- /dev/null +++ b/Lang/Ada/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Ada \ No newline at end of file diff --git a/Lang/Ada/Minesweeper-game b/Lang/Ada/Minesweeper-game new file mode 120000 index 0000000000..bede4accf1 --- /dev/null +++ b/Lang/Ada/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Modular-exponentiation b/Lang/Ada/Modular-exponentiation new file mode 120000 index 0000000000..77b6343368 --- /dev/null +++ b/Lang/Ada/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Ada \ No newline at end of file diff --git a/Lang/Ada/Modular-inverse b/Lang/Ada/Modular-inverse new file mode 120000 index 0000000000..9c5f0d0a28 --- /dev/null +++ b/Lang/Ada/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Ada \ No newline at end of file diff --git a/Lang/Ada/Monte-Carlo-methods b/Lang/Ada/Monte-Carlo-methods new file mode 120000 index 0000000000..2d6ad919a0 --- /dev/null +++ b/Lang/Ada/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Ada \ No newline at end of file diff --git a/Lang/Ada/Monty-Hall-problem b/Lang/Ada/Monty-Hall-problem new file mode 120000 index 0000000000..7ffcbc09d5 --- /dev/null +++ b/Lang/Ada/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Morse-code b/Lang/Ada/Morse-code new file mode 120000 index 0000000000..9218a1154f --- /dev/null +++ b/Lang/Ada/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Ada \ No newline at end of file diff --git a/Lang/Ada/Mouse-position b/Lang/Ada/Mouse-position new file mode 120000 index 0000000000..5984bc1283 --- /dev/null +++ b/Lang/Ada/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Ada \ No newline at end of file diff --git a/Lang/Ada/Multifactorial b/Lang/Ada/Multifactorial new file mode 120000 index 0000000000..6fe6adfb2f --- /dev/null +++ b/Lang/Ada/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Ada \ No newline at end of file diff --git a/Lang/Ada/Multiple-distinct-objects b/Lang/Ada/Multiple-distinct-objects new file mode 120000 index 0000000000..47f7f235db --- /dev/null +++ b/Lang/Ada/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Ada \ No newline at end of file diff --git a/Lang/Ada/Multiple-regression b/Lang/Ada/Multiple-regression new file mode 120000 index 0000000000..7383b779bc --- /dev/null +++ b/Lang/Ada/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Ada \ No newline at end of file diff --git a/Lang/Ada/Multiplication-tables b/Lang/Ada/Multiplication-tables new file mode 120000 index 0000000000..02f36608db --- /dev/null +++ b/Lang/Ada/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Ada \ No newline at end of file diff --git a/Lang/Ada/Multiplicative-order b/Lang/Ada/Multiplicative-order new file mode 120000 index 0000000000..284ec502a6 --- /dev/null +++ b/Lang/Ada/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Ada \ No newline at end of file diff --git a/Lang/Ada/Multisplit b/Lang/Ada/Multisplit new file mode 120000 index 0000000000..00fb54119e --- /dev/null +++ b/Lang/Ada/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Ada \ No newline at end of file diff --git a/Lang/Ada/Mutex b/Lang/Ada/Mutex new file mode 120000 index 0000000000..e421aae300 --- /dev/null +++ b/Lang/Ada/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Ada \ No newline at end of file diff --git a/Lang/Ada/Mutual-recursion b/Lang/Ada/Mutual-recursion new file mode 120000 index 0000000000..d0d7a683e7 --- /dev/null +++ b/Lang/Ada/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Ada \ No newline at end of file diff --git a/Lang/Agda/Logical-operations b/Lang/Agda/Logical-operations new file mode 120000 index 0000000000..6001d83c06 --- /dev/null +++ b/Lang/Agda/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Agda \ No newline at end of file diff --git a/Lang/Agda/Matrix-transposition b/Lang/Agda/Matrix-transposition new file mode 120000 index 0000000000..fb6c233de7 --- /dev/null +++ b/Lang/Agda/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Agda \ No newline at end of file diff --git a/Lang/Agena/Lucas-Lehmer-test b/Lang/Agena/Lucas-Lehmer-test new file mode 120000 index 0000000000..afb6940791 --- /dev/null +++ b/Lang/Agena/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Agena \ No newline at end of file diff --git a/Lang/Aikido/Factors-of-an-integer b/Lang/Aikido/Factors-of-an-integer new file mode 120000 index 0000000000..b8a1f142eb --- /dev/null +++ b/Lang/Aikido/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Aikido \ No newline at end of file diff --git a/Lang/Aikido/First-class-functions b/Lang/Aikido/First-class-functions new file mode 120000 index 0000000000..9611647024 --- /dev/null +++ b/Lang/Aikido/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Flatten-a-list b/Lang/Aikido/Flatten-a-list new file mode 120000 index 0000000000..3f31085425 --- /dev/null +++ b/Lang/Aikido/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Fork b/Lang/Aikido/Fork new file mode 120000 index 0000000000..e5d7b4d375 --- /dev/null +++ b/Lang/Aikido/Fork @@ -0,0 +1 @@ +../../Task/Fork/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Function-composition b/Lang/Aikido/Function-composition new file mode 120000 index 0000000000..ea3e8a7cde --- /dev/null +++ b/Lang/Aikido/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Hostname b/Lang/Aikido/Hostname new file mode 120000 index 0000000000..eafa6397c6 --- /dev/null +++ b/Lang/Aikido/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Inheritance-Multiple b/Lang/Aikido/Inheritance-Multiple new file mode 120000 index 0000000000..86d830692a --- /dev/null +++ b/Lang/Aikido/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Inheritance-Single b/Lang/Aikido/Inheritance-Single new file mode 120000 index 0000000000..1fc92ff11c --- /dev/null +++ b/Lang/Aikido/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Introspection b/Lang/Aikido/Introspection new file mode 120000 index 0000000000..da177887ef --- /dev/null +++ b/Lang/Aikido/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Letter-frequency b/Lang/Aikido/Letter-frequency new file mode 120000 index 0000000000..16ea229e29 --- /dev/null +++ b/Lang/Aikido/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Logical-operations b/Lang/Aikido/Logical-operations new file mode 120000 index 0000000000..5f8805f307 --- /dev/null +++ b/Lang/Aikido/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Loops-Continue b/Lang/Aikido/Loops-Continue new file mode 120000 index 0000000000..c5e77cf948 --- /dev/null +++ b/Lang/Aikido/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Loops-Foreach b/Lang/Aikido/Loops-Foreach new file mode 120000 index 0000000000..30fe2ed1d6 --- /dev/null +++ b/Lang/Aikido/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Aikido \ No newline at end of file diff --git a/Lang/Aime/Factorial b/Lang/Aime/Factorial new file mode 120000 index 0000000000..8ae8c84dfa --- /dev/null +++ b/Lang/Aime/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Aime \ No newline at end of file diff --git a/Lang/Aime/Greatest-element-of-a-list b/Lang/Aime/Greatest-element-of-a-list new file mode 120000 index 0000000000..c8f2644a2b --- /dev/null +++ b/Lang/Aime/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Aime \ No newline at end of file diff --git a/Lang/Aime/Guess-the-number b/Lang/Aime/Guess-the-number new file mode 120000 index 0000000000..6b5009e0fb --- /dev/null +++ b/Lang/Aime/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Aime \ No newline at end of file diff --git a/Lang/Aime/Hello-world-Text b/Lang/Aime/Hello-world-Text new file mode 120000 index 0000000000..dcf938c1d9 --- /dev/null +++ b/Lang/Aime/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Aime \ No newline at end of file diff --git a/Lang/Aime/Higher-order-functions b/Lang/Aime/Higher-order-functions new file mode 120000 index 0000000000..39d0515625 --- /dev/null +++ b/Lang/Aime/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Aime \ No newline at end of file diff --git a/Lang/Aime/Horners-rule-for-polynomial-evaluation b/Lang/Aime/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..a7bf09c557 --- /dev/null +++ b/Lang/Aime/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Aime \ No newline at end of file diff --git a/Lang/Aime/Increment-a-numerical-string b/Lang/Aime/Increment-a-numerical-string new file mode 120000 index 0000000000..efdc62763d --- /dev/null +++ b/Lang/Aime/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Aime \ No newline at end of file diff --git a/Lang/Aime/Integer-comparison b/Lang/Aime/Integer-comparison new file mode 120000 index 0000000000..a053a32713 --- /dev/null +++ b/Lang/Aime/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Aime \ No newline at end of file diff --git a/Lang/Aime/Literals-Integer b/Lang/Aime/Literals-Integer new file mode 120000 index 0000000000..9bc2323027 --- /dev/null +++ b/Lang/Aime/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Aime \ No newline at end of file diff --git a/Lang/Aime/Literals-String b/Lang/Aime/Literals-String new file mode 120000 index 0000000000..dbfde60c9a --- /dev/null +++ b/Lang/Aime/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Aime \ No newline at end of file diff --git a/Lang/Aime/Logical-operations b/Lang/Aime/Logical-operations new file mode 120000 index 0000000000..1b7e361087 --- /dev/null +++ b/Lang/Aime/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Aime \ No newline at end of file diff --git a/Lang/Aime/Loops-Break b/Lang/Aime/Loops-Break new file mode 120000 index 0000000000..1af40ad86f --- /dev/null +++ b/Lang/Aime/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Aime \ No newline at end of file diff --git a/Lang/Aime/Loops-Do-while b/Lang/Aime/Loops-Do-while new file mode 120000 index 0000000000..5bc43df4de --- /dev/null +++ b/Lang/Aime/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Aime \ No newline at end of file diff --git a/Lang/Aime/Loops-Infinite b/Lang/Aime/Loops-Infinite new file mode 120000 index 0000000000..c10bcad462 --- /dev/null +++ b/Lang/Aime/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Aime \ No newline at end of file diff --git a/Lang/Aime/Man-or-boy-test b/Lang/Aime/Man-or-boy-test new file mode 120000 index 0000000000..3065cc6178 --- /dev/null +++ b/Lang/Aime/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Aime \ No newline at end of file diff --git a/Lang/Aime/Maze-generation b/Lang/Aime/Maze-generation new file mode 120000 index 0000000000..c781508713 --- /dev/null +++ b/Lang/Aime/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Aime \ No newline at end of file diff --git a/Lang/Aime/Mutual-recursion b/Lang/Aime/Mutual-recursion new file mode 120000 index 0000000000..4695d8e191 --- /dev/null +++ b/Lang/Aime/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Aime \ No newline at end of file diff --git a/Lang/Algae/Hello-world-Text b/Lang/Algae/Hello-world-Text new file mode 120000 index 0000000000..7b63fa6c2e --- /dev/null +++ b/Lang/Algae/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Algae \ No newline at end of file diff --git a/Lang/Alore/Arbitrary-precision-integers-included b/Lang/Alore/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..bff88f0ead --- /dev/null +++ b/Lang/Alore/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Alore \ No newline at end of file diff --git a/Lang/Alore/Fibonacci-sequence b/Lang/Alore/Fibonacci-sequence new file mode 120000 index 0000000000..6e8f45de33 --- /dev/null +++ b/Lang/Alore/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Alore \ No newline at end of file diff --git a/Lang/Alore/Greatest-common-divisor b/Lang/Alore/Greatest-common-divisor new file mode 120000 index 0000000000..2135cedc28 --- /dev/null +++ b/Lang/Alore/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Alore \ No newline at end of file diff --git a/Lang/Alore/Hello-world-Text b/Lang/Alore/Hello-world-Text new file mode 120000 index 0000000000..7bef716be6 --- /dev/null +++ b/Lang/Alore/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Alore \ No newline at end of file diff --git a/Lang/Alore/Loops-For b/Lang/Alore/Loops-For new file mode 120000 index 0000000000..dd36db8ff1 --- /dev/null +++ b/Lang/Alore/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Alore \ No newline at end of file diff --git a/Lang/AmbientTalk/Hello-world-Text b/Lang/AmbientTalk/Hello-world-Text new file mode 120000 index 0000000000..e11c2c0838 --- /dev/null +++ b/Lang/AmbientTalk/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AmbientTalk \ No newline at end of file diff --git a/Lang/AmbientTalk/Loops-While b/Lang/AmbientTalk/Loops-While new file mode 120000 index 0000000000..7d6c021bc3 --- /dev/null +++ b/Lang/AmbientTalk/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/AmbientTalk \ No newline at end of file diff --git a/Lang/AmigaE/Factorial b/Lang/AmigaE/Factorial new file mode 120000 index 0000000000..1de641100d --- /dev/null +++ b/Lang/AmigaE/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Filter b/Lang/AmigaE/Filter new file mode 120000 index 0000000000..668c35f544 --- /dev/null +++ b/Lang/AmigaE/Filter @@ -0,0 +1 @@ +../../Task/Filter/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Formatted-numeric-output b/Lang/AmigaE/Formatted-numeric-output new file mode 120000 index 0000000000..fdd6d1164a --- /dev/null +++ b/Lang/AmigaE/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Function-definition b/Lang/AmigaE/Function-definition new file mode 120000 index 0000000000..a7bf55942f --- /dev/null +++ b/Lang/AmigaE/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Generic-swap b/Lang/AmigaE/Generic-swap new file mode 120000 index 0000000000..9fb4f99183 --- /dev/null +++ b/Lang/AmigaE/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Hello-world-Text b/Lang/AmigaE/Hello-world-Text new file mode 120000 index 0000000000..f4e24128bf --- /dev/null +++ b/Lang/AmigaE/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Higher-order-functions b/Lang/AmigaE/Higher-order-functions new file mode 120000 index 0000000000..6790e4bd36 --- /dev/null +++ b/Lang/AmigaE/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Input-loop b/Lang/AmigaE/Input-loop new file mode 120000 index 0000000000..ceaf70b19d --- /dev/null +++ b/Lang/AmigaE/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Literals-Integer b/Lang/AmigaE/Literals-Integer new file mode 120000 index 0000000000..86ee299ff1 --- /dev/null +++ b/Lang/AmigaE/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-Do-while b/Lang/AmigaE/Loops-Do-while new file mode 120000 index 0000000000..be885e0b63 --- /dev/null +++ b/Lang/AmigaE/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-Downward-for b/Lang/AmigaE/Loops-Downward-for new file mode 120000 index 0000000000..48d48bea75 --- /dev/null +++ b/Lang/AmigaE/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-For b/Lang/AmigaE/Loops-For new file mode 120000 index 0000000000..6089386a98 --- /dev/null +++ b/Lang/AmigaE/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-Foreach b/Lang/AmigaE/Loops-Foreach new file mode 120000 index 0000000000..2154bd2f82 --- /dev/null +++ b/Lang/AmigaE/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-Infinite b/Lang/AmigaE/Loops-Infinite new file mode 120000 index 0000000000..2ddf45924d --- /dev/null +++ b/Lang/AmigaE/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-N-plus-one-half b/Lang/AmigaE/Loops-N-plus-one-half new file mode 120000 index 0000000000..aa8d384531 --- /dev/null +++ b/Lang/AmigaE/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/AmigaE \ No newline at end of file diff --git a/Lang/AmigaE/Loops-While b/Lang/AmigaE/Loops-While new file mode 120000 index 0000000000..afbad285c4 --- /dev/null +++ b/Lang/AmigaE/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/AmigaE \ No newline at end of file diff --git a/Lang/AppleScript/Factorial b/Lang/AppleScript/Factorial new file mode 120000 index 0000000000..4e7541c6a4 --- /dev/null +++ b/Lang/AppleScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Fibonacci-sequence b/Lang/AppleScript/Fibonacci-sequence new file mode 120000 index 0000000000..60e2398523 --- /dev/null +++ b/Lang/AppleScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/File-IO b/Lang/AppleScript/File-IO new file mode 120000 index 0000000000..e760928a7d --- /dev/null +++ b/Lang/AppleScript/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Filter b/Lang/AppleScript/Filter new file mode 120000 index 0000000000..4f90adcb71 --- /dev/null +++ b/Lang/AppleScript/Filter @@ -0,0 +1 @@ +../../Task/Filter/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Five-weekends b/Lang/AppleScript/Five-weekends new file mode 120000 index 0000000000..2d58d4004c --- /dev/null +++ b/Lang/AppleScript/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Flatten-a-list b/Lang/AppleScript/Flatten-a-list new file mode 120000 index 0000000000..965d4c503a --- /dev/null +++ b/Lang/AppleScript/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Function-definition b/Lang/AppleScript/Function-definition new file mode 120000 index 0000000000..4c7b2e5405 --- /dev/null +++ b/Lang/AppleScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Generic-swap b/Lang/AppleScript/Generic-swap new file mode 120000 index 0000000000..d9465ab058 --- /dev/null +++ b/Lang/AppleScript/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Greatest-element-of-a-list b/Lang/AppleScript/Greatest-element-of-a-list new file mode 120000 index 0000000000..a369188a48 --- /dev/null +++ b/Lang/AppleScript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Hello-world-Graphical b/Lang/AppleScript/Hello-world-Graphical new file mode 120000 index 0000000000..0b277c3170 --- /dev/null +++ b/Lang/AppleScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Hello-world-Text b/Lang/AppleScript/Hello-world-Text new file mode 120000 index 0000000000..ff62e13967 --- /dev/null +++ b/Lang/AppleScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Integer-comparison b/Lang/AppleScript/Integer-comparison new file mode 120000 index 0000000000..d75a697917 --- /dev/null +++ b/Lang/AppleScript/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Jensens-Device b/Lang/AppleScript/Jensens-Device new file mode 120000 index 0000000000..759d36876e --- /dev/null +++ b/Lang/AppleScript/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Leap-year b/Lang/AppleScript/Leap-year new file mode 120000 index 0000000000..3ad7969b6b --- /dev/null +++ b/Lang/AppleScript/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Loops-For b/Lang/AppleScript/Loops-For new file mode 120000 index 0000000000..5724839879 --- /dev/null +++ b/Lang/AppleScript/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Loops-Infinite b/Lang/AppleScript/Loops-Infinite new file mode 120000 index 0000000000..100cca7719 --- /dev/null +++ b/Lang/AppleScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Loops-While b/Lang/AppleScript/Loops-While new file mode 120000 index 0000000000..5a37be9471 --- /dev/null +++ b/Lang/AppleScript/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Man-or-boy-test b/Lang/AppleScript/Man-or-boy-test new file mode 120000 index 0000000000..8354992e28 --- /dev/null +++ b/Lang/AppleScript/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Multiplication-tables b/Lang/AppleScript/Multiplication-tables new file mode 120000 index 0000000000..504d94bbd5 --- /dev/null +++ b/Lang/AppleScript/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/AppleScript \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Function-definition b/Lang/Applesoft-BASIC/Function-definition new file mode 120000 index 0000000000..d918755f61 --- /dev/null +++ b/Lang/Applesoft-BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Hello-world-Graphical b/Lang/Applesoft-BASIC/Hello-world-Graphical new file mode 120000 index 0000000000..14b3ca08a6 --- /dev/null +++ b/Lang/Applesoft-BASIC/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Hello-world-Line-printer b/Lang/Applesoft-BASIC/Hello-world-Line-printer new file mode 120000 index 0000000000..5e20907c25 --- /dev/null +++ b/Lang/Applesoft-BASIC/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Hello-world-Text b/Lang/Applesoft-BASIC/Hello-world-Text new file mode 120000 index 0000000000..c1932e016e --- /dev/null +++ b/Lang/Applesoft-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Integer-sequence b/Lang/Applesoft-BASIC/Integer-sequence new file mode 120000 index 0000000000..452c664fe0 --- /dev/null +++ b/Lang/Applesoft-BASIC/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Loops-While b/Lang/Applesoft-BASIC/Loops-While new file mode 120000 index 0000000000..04d28d0617 --- /dev/null +++ b/Lang/Applesoft-BASIC/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Applesoft-BASIC/Mandelbrot-set b/Lang/Applesoft-BASIC/Mandelbrot-set new file mode 120000 index 0000000000..1e15510386 --- /dev/null +++ b/Lang/Applesoft-BASIC/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Applesoft-BASIC \ No newline at end of file diff --git a/Lang/Argile/24-game-Solve b/Lang/Argile/24-game-Solve new file mode 120000 index 0000000000..64ef133825 --- /dev/null +++ b/Lang/Argile/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Argile \ No newline at end of file diff --git a/Lang/Argile/Function-composition b/Lang/Argile/Function-composition new file mode 120000 index 0000000000..3dc25093d1 --- /dev/null +++ b/Lang/Argile/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Argile \ No newline at end of file diff --git a/Lang/Argile/Function-definition b/Lang/Argile/Function-definition new file mode 120000 index 0000000000..82ca80f9c8 --- /dev/null +++ b/Lang/Argile/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Argile \ No newline at end of file diff --git a/Lang/Argile/Hash-from-two-arrays b/Lang/Argile/Hash-from-two-arrays new file mode 120000 index 0000000000..f3092152a3 --- /dev/null +++ b/Lang/Argile/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Argile \ No newline at end of file diff --git a/Lang/Argile/Hello-world-Standard-error b/Lang/Argile/Hello-world-Standard-error new file mode 120000 index 0000000000..f16b011ba8 --- /dev/null +++ b/Lang/Argile/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Argile \ No newline at end of file diff --git a/Lang/Argile/Hello-world-Text b/Lang/Argile/Hello-world-Text new file mode 120000 index 0000000000..e4944613c9 --- /dev/null +++ b/Lang/Argile/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Argile \ No newline at end of file diff --git a/Lang/Asymptote/Hello-world-Text b/Lang/Asymptote/Hello-world-Text new file mode 120000 index 0000000000..fdc85d5310 --- /dev/null +++ b/Lang/Asymptote/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Asymptote \ No newline at end of file diff --git a/Lang/AutoHotkey/24-game-Solve b/Lang/AutoHotkey/24-game-Solve new file mode 120000 index 0000000000..99894d4143 --- /dev/null +++ b/Lang/AutoHotkey/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Factorial b/Lang/AutoHotkey/Factorial new file mode 120000 index 0000000000..f33cd101cb --- /dev/null +++ b/Lang/AutoHotkey/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Factors-of-a-Mersenne-number b/Lang/AutoHotkey/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..f2d5783c82 --- /dev/null +++ b/Lang/AutoHotkey/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Factors-of-an-integer b/Lang/AutoHotkey/Factors-of-an-integer new file mode 120000 index 0000000000..ded589d96b --- /dev/null +++ b/Lang/AutoHotkey/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Fibonacci-sequence b/Lang/AutoHotkey/Fibonacci-sequence new file mode 120000 index 0000000000..b9879cf3a5 --- /dev/null +++ b/Lang/AutoHotkey/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/File-IO b/Lang/AutoHotkey/File-IO new file mode 120000 index 0000000000..f32410efe5 --- /dev/null +++ b/Lang/AutoHotkey/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/File-modification-time b/Lang/AutoHotkey/File-modification-time new file mode 120000 index 0000000000..32ebb659ab --- /dev/null +++ b/Lang/AutoHotkey/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/File-size b/Lang/AutoHotkey/File-size new file mode 120000 index 0000000000..1c50adb1f3 --- /dev/null +++ b/Lang/AutoHotkey/File-size @@ -0,0 +1 @@ +../../Task/File-size/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Filter b/Lang/AutoHotkey/Filter new file mode 120000 index 0000000000..67fbd701ee --- /dev/null +++ b/Lang/AutoHotkey/Filter @@ -0,0 +1 @@ +../../Task/Filter/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Find-common-directory-path b/Lang/AutoHotkey/Find-common-directory-path new file mode 120000 index 0000000000..0273de837e --- /dev/null +++ b/Lang/AutoHotkey/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Find-limit-of-recursion b/Lang/AutoHotkey/Find-limit-of-recursion new file mode 120000 index 0000000000..8e0721cef1 --- /dev/null +++ b/Lang/AutoHotkey/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Find-the-missing-permutation b/Lang/AutoHotkey/Find-the-missing-permutation new file mode 120000 index 0000000000..d64dd33c26 --- /dev/null +++ b/Lang/AutoHotkey/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/First-class-functions b/Lang/AutoHotkey/First-class-functions new file mode 120000 index 0000000000..d800dc72c2 --- /dev/null +++ b/Lang/AutoHotkey/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Five-weekends b/Lang/AutoHotkey/Five-weekends new file mode 120000 index 0000000000..c4cdad45a3 --- /dev/null +++ b/Lang/AutoHotkey/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Flatten-a-list b/Lang/AutoHotkey/Flatten-a-list new file mode 120000 index 0000000000..b21dd57b28 --- /dev/null +++ b/Lang/AutoHotkey/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Flow-control-structures b/Lang/AutoHotkey/Flow-control-structures new file mode 120000 index 0000000000..90132c566f --- /dev/null +++ b/Lang/AutoHotkey/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Fork b/Lang/AutoHotkey/Fork new file mode 120000 index 0000000000..878e455cb9 --- /dev/null +++ b/Lang/AutoHotkey/Fork @@ -0,0 +1 @@ +../../Task/Fork/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Formatted-numeric-output b/Lang/AutoHotkey/Formatted-numeric-output new file mode 120000 index 0000000000..c2abd47154 --- /dev/null +++ b/Lang/AutoHotkey/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Forward-difference b/Lang/AutoHotkey/Forward-difference new file mode 120000 index 0000000000..e847038149 --- /dev/null +++ b/Lang/AutoHotkey/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Function-composition b/Lang/AutoHotkey/Function-composition new file mode 120000 index 0000000000..8ce486f97c --- /dev/null +++ b/Lang/AutoHotkey/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Function-definition b/Lang/AutoHotkey/Function-definition new file mode 120000 index 0000000000..205be6da96 --- /dev/null +++ b/Lang/AutoHotkey/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/GUI-component-interaction b/Lang/AutoHotkey/GUI-component-interaction new file mode 120000 index 0000000000..d87bdc1b38 --- /dev/null +++ b/Lang/AutoHotkey/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/GUI-enabling-disabling-of-controls b/Lang/AutoHotkey/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..db14afb1e1 --- /dev/null +++ b/Lang/AutoHotkey/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Galton-box-animation b/Lang/AutoHotkey/Galton-box-animation new file mode 120000 index 0000000000..06b051a059 --- /dev/null +++ b/Lang/AutoHotkey/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Gamma-function b/Lang/AutoHotkey/Gamma-function new file mode 120000 index 0000000000..a2450b8538 --- /dev/null +++ b/Lang/AutoHotkey/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Generic-swap b/Lang/AutoHotkey/Generic-swap new file mode 120000 index 0000000000..0b07fad9de --- /dev/null +++ b/Lang/AutoHotkey/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Globally-replace-text-in-several-files b/Lang/AutoHotkey/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..42b57b28f9 --- /dev/null +++ b/Lang/AutoHotkey/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Gray-code b/Lang/AutoHotkey/Gray-code new file mode 120000 index 0000000000..237265f7f5 --- /dev/null +++ b/Lang/AutoHotkey/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Greatest-common-divisor b/Lang/AutoHotkey/Greatest-common-divisor new file mode 120000 index 0000000000..906a655d7c --- /dev/null +++ b/Lang/AutoHotkey/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Greatest-element-of-a-list b/Lang/AutoHotkey/Greatest-element-of-a-list new file mode 120000 index 0000000000..9b374da6cc --- /dev/null +++ b/Lang/AutoHotkey/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Greatest-subsequential-sum b/Lang/AutoHotkey/Greatest-subsequential-sum new file mode 120000 index 0000000000..7d61d365a6 --- /dev/null +++ b/Lang/AutoHotkey/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Greyscale-bars-Display b/Lang/AutoHotkey/Greyscale-bars-Display new file mode 120000 index 0000000000..c15a4b966b --- /dev/null +++ b/Lang/AutoHotkey/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Guess-the-number b/Lang/AutoHotkey/Guess-the-number new file mode 120000 index 0000000000..d66b62909e --- /dev/null +++ b/Lang/AutoHotkey/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Guess-the-number-With-feedback b/Lang/AutoHotkey/Guess-the-number-With-feedback new file mode 120000 index 0000000000..f9ccea52c6 --- /dev/null +++ b/Lang/AutoHotkey/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Guess-the-number-With-feedback-player b/Lang/AutoHotkey/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..092a1b33f7 --- /dev/null +++ b/Lang/AutoHotkey/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/HTTP b/Lang/AutoHotkey/HTTP new file mode 120000 index 0000000000..f1b657f1b8 --- /dev/null +++ b/Lang/AutoHotkey/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/HTTPS b/Lang/AutoHotkey/HTTPS new file mode 120000 index 0000000000..63fdb48735 --- /dev/null +++ b/Lang/AutoHotkey/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/HTTPS-Authenticated b/Lang/AutoHotkey/HTTPS-Authenticated new file mode 120000 index 0000000000..c0b5ffcf10 --- /dev/null +++ b/Lang/AutoHotkey/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hailstone-sequence b/Lang/AutoHotkey/Hailstone-sequence new file mode 120000 index 0000000000..efe6256b6c --- /dev/null +++ b/Lang/AutoHotkey/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hamming-numbers b/Lang/AutoHotkey/Hamming-numbers new file mode 120000 index 0000000000..cdb6bba0f4 --- /dev/null +++ b/Lang/AutoHotkey/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Happy-numbers b/Lang/AutoHotkey/Happy-numbers new file mode 120000 index 0000000000..0639511770 --- /dev/null +++ b/Lang/AutoHotkey/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hash-from-two-arrays b/Lang/AutoHotkey/Hash-from-two-arrays new file mode 120000 index 0000000000..da51d2a926 --- /dev/null +++ b/Lang/AutoHotkey/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hello-world-Graphical b/Lang/AutoHotkey/Hello-world-Graphical new file mode 120000 index 0000000000..99685da1f9 --- /dev/null +++ b/Lang/AutoHotkey/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hello-world-Line-printer b/Lang/AutoHotkey/Hello-world-Line-printer new file mode 120000 index 0000000000..992e32e170 --- /dev/null +++ b/Lang/AutoHotkey/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hello-world-Newline-omission b/Lang/AutoHotkey/Hello-world-Newline-omission new file mode 120000 index 0000000000..be58375a26 --- /dev/null +++ b/Lang/AutoHotkey/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hello-world-Standard-error b/Lang/AutoHotkey/Hello-world-Standard-error new file mode 120000 index 0000000000..4cecea01c5 --- /dev/null +++ b/Lang/AutoHotkey/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hello-world-Text b/Lang/AutoHotkey/Hello-world-Text new file mode 120000 index 0000000000..9a4e19ba1c --- /dev/null +++ b/Lang/AutoHotkey/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Here-document b/Lang/AutoHotkey/Here-document new file mode 120000 index 0000000000..a70678f0d7 --- /dev/null +++ b/Lang/AutoHotkey/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Higher-order-functions b/Lang/AutoHotkey/Higher-order-functions new file mode 120000 index 0000000000..1f1b1b3463 --- /dev/null +++ b/Lang/AutoHotkey/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hofstadter-Conway-$10,000-sequence b/Lang/AutoHotkey/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..5336241032 --- /dev/null +++ b/Lang/AutoHotkey/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Horizontal-sundial-calculations b/Lang/AutoHotkey/Horizontal-sundial-calculations new file mode 120000 index 0000000000..7444246496 --- /dev/null +++ b/Lang/AutoHotkey/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Horners-rule-for-polynomial-evaluation b/Lang/AutoHotkey/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..673a245b5b --- /dev/null +++ b/Lang/AutoHotkey/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Hostname b/Lang/AutoHotkey/Hostname new file mode 120000 index 0000000000..2b831e56a9 --- /dev/null +++ b/Lang/AutoHotkey/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Include-a-file b/Lang/AutoHotkey/Include-a-file new file mode 120000 index 0000000000..a4ef04af18 --- /dev/null +++ b/Lang/AutoHotkey/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Increment-a-numerical-string b/Lang/AutoHotkey/Increment-a-numerical-string new file mode 120000 index 0000000000..18dca4f3bf --- /dev/null +++ b/Lang/AutoHotkey/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Inheritance-Single b/Lang/AutoHotkey/Inheritance-Single new file mode 120000 index 0000000000..a6237781d3 --- /dev/null +++ b/Lang/AutoHotkey/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Input-loop b/Lang/AutoHotkey/Input-loop new file mode 120000 index 0000000000..fd87fac758 --- /dev/null +++ b/Lang/AutoHotkey/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Integer-comparison b/Lang/AutoHotkey/Integer-comparison new file mode 120000 index 0000000000..2a9aaca0ff --- /dev/null +++ b/Lang/AutoHotkey/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Integer-sequence b/Lang/AutoHotkey/Integer-sequence new file mode 120000 index 0000000000..936559eef0 --- /dev/null +++ b/Lang/AutoHotkey/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Introspection b/Lang/AutoHotkey/Introspection new file mode 120000 index 0000000000..7c96014f75 --- /dev/null +++ b/Lang/AutoHotkey/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Inverted-index b/Lang/AutoHotkey/Inverted-index new file mode 120000 index 0000000000..0c67895de4 --- /dev/null +++ b/Lang/AutoHotkey/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Josephus-problem b/Lang/AutoHotkey/Josephus-problem new file mode 120000 index 0000000000..2ab86e2fdb --- /dev/null +++ b/Lang/AutoHotkey/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Jump-anywhere b/Lang/AutoHotkey/Jump-anywhere new file mode 120000 index 0000000000..7b730a4318 --- /dev/null +++ b/Lang/AutoHotkey/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/AutoHotkey/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..7f8b43fdb4 --- /dev/null +++ b/Lang/AutoHotkey/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Keyboard-macros b/Lang/AutoHotkey/Keyboard-macros new file mode 120000 index 0000000000..9e78614864 --- /dev/null +++ b/Lang/AutoHotkey/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Knapsack-problem-Bounded b/Lang/AutoHotkey/Knapsack-problem-Bounded new file mode 120000 index 0000000000..695e7684a0 --- /dev/null +++ b/Lang/AutoHotkey/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Knapsack-problem-Unbounded b/Lang/AutoHotkey/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..8c7d7f8dee --- /dev/null +++ b/Lang/AutoHotkey/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Langtons-ant b/Lang/AutoHotkey/Langtons-ant new file mode 120000 index 0000000000..212eb6649d --- /dev/null +++ b/Lang/AutoHotkey/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Last-Friday-of-each-month b/Lang/AutoHotkey/Last-Friday-of-each-month new file mode 120000 index 0000000000..bd94101a82 --- /dev/null +++ b/Lang/AutoHotkey/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Leap-year b/Lang/AutoHotkey/Leap-year new file mode 120000 index 0000000000..dbc921d08d --- /dev/null +++ b/Lang/AutoHotkey/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Least-common-multiple b/Lang/AutoHotkey/Least-common-multiple new file mode 120000 index 0000000000..9b4bd68f5c --- /dev/null +++ b/Lang/AutoHotkey/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Letter-frequency b/Lang/AutoHotkey/Letter-frequency new file mode 120000 index 0000000000..4ea1cdec60 --- /dev/null +++ b/Lang/AutoHotkey/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Levenshtein-distance b/Lang/AutoHotkey/Levenshtein-distance new file mode 120000 index 0000000000..549cd06370 --- /dev/null +++ b/Lang/AutoHotkey/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/List-comprehensions b/Lang/AutoHotkey/List-comprehensions new file mode 120000 index 0000000000..eedc2348d7 --- /dev/null +++ b/Lang/AutoHotkey/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Literals-Integer b/Lang/AutoHotkey/Literals-Integer new file mode 120000 index 0000000000..ac05ebfcbc --- /dev/null +++ b/Lang/AutoHotkey/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Literals-String b/Lang/AutoHotkey/Literals-String new file mode 120000 index 0000000000..413160422a --- /dev/null +++ b/Lang/AutoHotkey/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Logical-operations b/Lang/AutoHotkey/Logical-operations new file mode 120000 index 0000000000..128c8a3904 --- /dev/null +++ b/Lang/AutoHotkey/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Long-multiplication b/Lang/AutoHotkey/Long-multiplication new file mode 120000 index 0000000000..321d381631 --- /dev/null +++ b/Lang/AutoHotkey/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Longest-common-subsequence b/Lang/AutoHotkey/Longest-common-subsequence new file mode 120000 index 0000000000..588b8d58ad --- /dev/null +++ b/Lang/AutoHotkey/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Longest-string-challenge b/Lang/AutoHotkey/Longest-string-challenge new file mode 120000 index 0000000000..41b325e4e7 --- /dev/null +++ b/Lang/AutoHotkey/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Look-and-say-sequence b/Lang/AutoHotkey/Look-and-say-sequence new file mode 120000 index 0000000000..0f2d308923 --- /dev/null +++ b/Lang/AutoHotkey/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loop-over-multiple-arrays-simultaneously b/Lang/AutoHotkey/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..5ad761b82d --- /dev/null +++ b/Lang/AutoHotkey/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Break b/Lang/AutoHotkey/Loops-Break new file mode 120000 index 0000000000..e6dd20fe04 --- /dev/null +++ b/Lang/AutoHotkey/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Continue b/Lang/AutoHotkey/Loops-Continue new file mode 120000 index 0000000000..9748a19cae --- /dev/null +++ b/Lang/AutoHotkey/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Do-while b/Lang/AutoHotkey/Loops-Do-while new file mode 120000 index 0000000000..109a1c448a --- /dev/null +++ b/Lang/AutoHotkey/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Downward-for b/Lang/AutoHotkey/Loops-Downward-for new file mode 120000 index 0000000000..dcc1a82de2 --- /dev/null +++ b/Lang/AutoHotkey/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-For b/Lang/AutoHotkey/Loops-For new file mode 120000 index 0000000000..99fd0f9d45 --- /dev/null +++ b/Lang/AutoHotkey/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-For-with-a-specified-step b/Lang/AutoHotkey/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..1cc8c889f4 --- /dev/null +++ b/Lang/AutoHotkey/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Foreach b/Lang/AutoHotkey/Loops-Foreach new file mode 120000 index 0000000000..686c68e871 --- /dev/null +++ b/Lang/AutoHotkey/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Infinite b/Lang/AutoHotkey/Loops-Infinite new file mode 120000 index 0000000000..74b5ad1a7a --- /dev/null +++ b/Lang/AutoHotkey/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-N-plus-one-half b/Lang/AutoHotkey/Loops-N-plus-one-half new file mode 120000 index 0000000000..c891d2c2b5 --- /dev/null +++ b/Lang/AutoHotkey/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-Nested b/Lang/AutoHotkey/Loops-Nested new file mode 120000 index 0000000000..ba7ffb1fef --- /dev/null +++ b/Lang/AutoHotkey/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Loops-While b/Lang/AutoHotkey/Loops-While new file mode 120000 index 0000000000..12552e7195 --- /dev/null +++ b/Lang/AutoHotkey/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Luhn-test-of-credit-card-numbers b/Lang/AutoHotkey/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..c09cb5f3ad --- /dev/null +++ b/Lang/AutoHotkey/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/MD5 b/Lang/AutoHotkey/MD5 new file mode 120000 index 0000000000..e6983bbd67 --- /dev/null +++ b/Lang/AutoHotkey/MD5 @@ -0,0 +1 @@ +../../Task/MD5/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Mad-Libs b/Lang/AutoHotkey/Mad-Libs new file mode 120000 index 0000000000..dbee821285 --- /dev/null +++ b/Lang/AutoHotkey/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Mandelbrot-set b/Lang/AutoHotkey/Mandelbrot-set new file mode 120000 index 0000000000..8d0fecfd74 --- /dev/null +++ b/Lang/AutoHotkey/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Map-range b/Lang/AutoHotkey/Map-range new file mode 120000 index 0000000000..8a6d8c13f5 --- /dev/null +++ b/Lang/AutoHotkey/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Matrix-multiplication b/Lang/AutoHotkey/Matrix-multiplication new file mode 120000 index 0000000000..ab64d5265f --- /dev/null +++ b/Lang/AutoHotkey/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Matrix-transposition b/Lang/AutoHotkey/Matrix-transposition new file mode 120000 index 0000000000..b4d6e2da26 --- /dev/null +++ b/Lang/AutoHotkey/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Maze-generation b/Lang/AutoHotkey/Maze-generation new file mode 120000 index 0000000000..662e9c5931 --- /dev/null +++ b/Lang/AutoHotkey/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Memory-allocation b/Lang/AutoHotkey/Memory-allocation new file mode 120000 index 0000000000..c5891dce42 --- /dev/null +++ b/Lang/AutoHotkey/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Menu b/Lang/AutoHotkey/Menu new file mode 120000 index 0000000000..c59e6f36d6 --- /dev/null +++ b/Lang/AutoHotkey/Menu @@ -0,0 +1 @@ +../../Task/Menu/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Metronome b/Lang/AutoHotkey/Metronome new file mode 120000 index 0000000000..a5f1b52bfc --- /dev/null +++ b/Lang/AutoHotkey/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Miller-Rabin-primality-test b/Lang/AutoHotkey/Miller-Rabin-primality-test new file mode 120000 index 0000000000..518dd6b131 --- /dev/null +++ b/Lang/AutoHotkey/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Monte-Carlo-methods b/Lang/AutoHotkey/Monte-Carlo-methods new file mode 120000 index 0000000000..167b10b4c7 --- /dev/null +++ b/Lang/AutoHotkey/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Monty-Hall-problem b/Lang/AutoHotkey/Monty-Hall-problem new file mode 120000 index 0000000000..bc61657550 --- /dev/null +++ b/Lang/AutoHotkey/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Morse-code b/Lang/AutoHotkey/Morse-code new file mode 120000 index 0000000000..d1b2dba3f4 --- /dev/null +++ b/Lang/AutoHotkey/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Mouse-position b/Lang/AutoHotkey/Mouse-position new file mode 120000 index 0000000000..d282fd01d3 --- /dev/null +++ b/Lang/AutoHotkey/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Multiple-distinct-objects b/Lang/AutoHotkey/Multiple-distinct-objects new file mode 120000 index 0000000000..3e4c8c8abb --- /dev/null +++ b/Lang/AutoHotkey/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Multiplication-tables b/Lang/AutoHotkey/Multiplication-tables new file mode 120000 index 0000000000..bde79143a6 --- /dev/null +++ b/Lang/AutoHotkey/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Mutual-recursion b/Lang/AutoHotkey/Mutual-recursion new file mode 120000 index 0000000000..5df3bef8f9 --- /dev/null +++ b/Lang/AutoHotkey/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoIt/Factorial b/Lang/AutoIt/Factorial new file mode 120000 index 0000000000..089060e31a --- /dev/null +++ b/Lang/AutoIt/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Factors-of-an-integer b/Lang/AutoIt/Factors-of-an-integer new file mode 120000 index 0000000000..db83bb5b04 --- /dev/null +++ b/Lang/AutoIt/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Fibonacci-sequence b/Lang/AutoIt/Fibonacci-sequence new file mode 120000 index 0000000000..2877b5e0e7 --- /dev/null +++ b/Lang/AutoIt/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Find-limit-of-recursion b/Lang/AutoIt/Find-limit-of-recursion new file mode 120000 index 0000000000..87c4fc0ca9 --- /dev/null +++ b/Lang/AutoIt/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Five-weekends b/Lang/AutoIt/Five-weekends new file mode 120000 index 0000000000..ae9cc19d4d --- /dev/null +++ b/Lang/AutoIt/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Function-definition b/Lang/AutoIt/Function-definition new file mode 120000 index 0000000000..bb152aed7f --- /dev/null +++ b/Lang/AutoIt/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Greatest-subsequential-sum b/Lang/AutoIt/Greatest-subsequential-sum new file mode 120000 index 0000000000..d503fb83cd --- /dev/null +++ b/Lang/AutoIt/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Guess-the-number b/Lang/AutoIt/Guess-the-number new file mode 120000 index 0000000000..a7fa06f806 --- /dev/null +++ b/Lang/AutoIt/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Hailstone-sequence b/Lang/AutoIt/Hailstone-sequence new file mode 120000 index 0000000000..78143ac927 --- /dev/null +++ b/Lang/AutoIt/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Happy-numbers b/Lang/AutoIt/Happy-numbers new file mode 120000 index 0000000000..56b0c1f093 --- /dev/null +++ b/Lang/AutoIt/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Hello-world-Graphical b/Lang/AutoIt/Hello-world-Graphical new file mode 120000 index 0000000000..a05fd9ff90 --- /dev/null +++ b/Lang/AutoIt/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Hello-world-Standard-error b/Lang/AutoIt/Hello-world-Standard-error new file mode 120000 index 0000000000..1adc46b761 --- /dev/null +++ b/Lang/AutoIt/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Hello-world-Text b/Lang/AutoIt/Hello-world-Text new file mode 120000 index 0000000000..8900f4f3e7 --- /dev/null +++ b/Lang/AutoIt/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Increment-a-numerical-string b/Lang/AutoIt/Increment-a-numerical-string new file mode 120000 index 0000000000..a8b2bc8c03 --- /dev/null +++ b/Lang/AutoIt/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Leap-year b/Lang/AutoIt/Leap-year new file mode 120000 index 0000000000..940f56a219 --- /dev/null +++ b/Lang/AutoIt/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Letter-frequency b/Lang/AutoIt/Letter-frequency new file mode 120000 index 0000000000..a5aaf21846 --- /dev/null +++ b/Lang/AutoIt/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Luhn-test-of-credit-card-numbers b/Lang/AutoIt/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..fe57b0daa2 --- /dev/null +++ b/Lang/AutoIt/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Multiplication-tables b/Lang/AutoIt/Multiplication-tables new file mode 120000 index 0000000000..3a425ed7bb --- /dev/null +++ b/Lang/AutoIt/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/AutoIt \ No newline at end of file diff --git a/Lang/Axiom/First-class-functions b/Lang/Axiom/First-class-functions new file mode 120000 index 0000000000..94b57c0511 --- /dev/null +++ b/Lang/Axiom/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Axiom \ No newline at end of file diff --git a/Lang/Axiom/First-class-functions-Use-numbers-analogously b/Lang/Axiom/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..5e0f2476a5 --- /dev/null +++ b/Lang/Axiom/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Axiom \ No newline at end of file diff --git a/Lang/Axiom/Map-range b/Lang/Axiom/Map-range new file mode 120000 index 0000000000..b90ab1ce1f --- /dev/null +++ b/Lang/Axiom/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Axiom \ No newline at end of file diff --git a/Lang/BASIC/Factorial b/Lang/BASIC/Factorial new file mode 120000 index 0000000000..ef7a717912 --- /dev/null +++ b/Lang/BASIC/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Factors-of-an-integer b/Lang/BASIC/Factors-of-an-integer new file mode 120000 index 0000000000..2d4c9b955d --- /dev/null +++ b/Lang/BASIC/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Fibonacci-sequence b/Lang/BASIC/Fibonacci-sequence new file mode 120000 index 0000000000..401c412db3 --- /dev/null +++ b/Lang/BASIC/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/BASIC \ No newline at end of file diff --git a/Lang/BASIC/File-IO b/Lang/BASIC/File-IO new file mode 120000 index 0000000000..ab5bd448f1 --- /dev/null +++ b/Lang/BASIC/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Find-common-directory-path b/Lang/BASIC/Find-common-directory-path new file mode 120000 index 0000000000..bf7dc13f37 --- /dev/null +++ b/Lang/BASIC/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Find-limit-of-recursion b/Lang/BASIC/Find-limit-of-recursion new file mode 120000 index 0000000000..dae1c34743 --- /dev/null +++ b/Lang/BASIC/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Function-definition b/Lang/BASIC/Function-definition new file mode 120000 index 0000000000..a052c63292 --- /dev/null +++ b/Lang/BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Globally-replace-text-in-several-files b/Lang/BASIC/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..02150f29aa --- /dev/null +++ b/Lang/BASIC/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Greatest-common-divisor b/Lang/BASIC/Greatest-common-divisor new file mode 120000 index 0000000000..a3f8f409f2 --- /dev/null +++ b/Lang/BASIC/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Greatest-element-of-a-list b/Lang/BASIC/Greatest-element-of-a-list new file mode 120000 index 0000000000..f3d914be0c --- /dev/null +++ b/Lang/BASIC/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Guess-the-number b/Lang/BASIC/Guess-the-number new file mode 120000 index 0000000000..39a91accda --- /dev/null +++ b/Lang/BASIC/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Hello-world-Graphical b/Lang/BASIC/Hello-world-Graphical new file mode 120000 index 0000000000..0bf8f6fa28 --- /dev/null +++ b/Lang/BASIC/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Hello-world-Line-printer b/Lang/BASIC/Hello-world-Line-printer new file mode 120000 index 0000000000..e2eaa55c7c --- /dev/null +++ b/Lang/BASIC/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Hello-world-Newline-omission b/Lang/BASIC/Hello-world-Newline-omission new file mode 120000 index 0000000000..cb7ee80aa3 --- /dev/null +++ b/Lang/BASIC/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Hello-world-Standard-error b/Lang/BASIC/Hello-world-Standard-error new file mode 120000 index 0000000000..0f1d2ee08c --- /dev/null +++ b/Lang/BASIC/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Hello-world-Text b/Lang/BASIC/Hello-world-Text new file mode 120000 index 0000000000..eec1285c38 --- /dev/null +++ b/Lang/BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Increment-a-numerical-string b/Lang/BASIC/Increment-a-numerical-string new file mode 120000 index 0000000000..091eb15e1a --- /dev/null +++ b/Lang/BASIC/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Integer-comparison b/Lang/BASIC/Integer-comparison new file mode 120000 index 0000000000..9969e7e98e --- /dev/null +++ b/Lang/BASIC/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Integer-sequence b/Lang/BASIC/Integer-sequence new file mode 120000 index 0000000000..f5374a6b21 --- /dev/null +++ b/Lang/BASIC/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Interactive-programming b/Lang/BASIC/Interactive-programming new file mode 120000 index 0000000000..70956f7ff4 --- /dev/null +++ b/Lang/BASIC/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Jump-anywhere b/Lang/BASIC/Jump-anywhere new file mode 120000 index 0000000000..905eff75cc --- /dev/null +++ b/Lang/BASIC/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Keyboard-input-Flush-the-keyboard-buffer b/Lang/BASIC/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..8f743ace19 --- /dev/null +++ b/Lang/BASIC/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Keyboard-input-Keypress-check b/Lang/BASIC/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..eec454395e --- /dev/null +++ b/Lang/BASIC/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/BASIC/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..c00d82ccc9 --- /dev/null +++ b/Lang/BASIC/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Leap-year b/Lang/BASIC/Leap-year new file mode 120000 index 0000000000..819a2467ab --- /dev/null +++ b/Lang/BASIC/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Literals-Integer b/Lang/BASIC/Literals-Integer new file mode 120000 index 0000000000..c0dceacece --- /dev/null +++ b/Lang/BASIC/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Literals-String b/Lang/BASIC/Literals-String new file mode 120000 index 0000000000..e88ee60c04 --- /dev/null +++ b/Lang/BASIC/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Long-multiplication b/Lang/BASIC/Long-multiplication new file mode 120000 index 0000000000..09e3849733 --- /dev/null +++ b/Lang/BASIC/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Longest-common-subsequence b/Lang/BASIC/Longest-common-subsequence new file mode 120000 index 0000000000..9d2938f366 --- /dev/null +++ b/Lang/BASIC/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-Break b/Lang/BASIC/Loops-Break new file mode 120000 index 0000000000..98577e837f --- /dev/null +++ b/Lang/BASIC/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-Do-while b/Lang/BASIC/Loops-Do-while new file mode 120000 index 0000000000..866369821e --- /dev/null +++ b/Lang/BASIC/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-Downward-for b/Lang/BASIC/Loops-Downward-for new file mode 120000 index 0000000000..ec8c9825bc --- /dev/null +++ b/Lang/BASIC/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-For b/Lang/BASIC/Loops-For new file mode 120000 index 0000000000..cdbb61083d --- /dev/null +++ b/Lang/BASIC/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-For-with-a-specified-step b/Lang/BASIC/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..84fbed99d9 --- /dev/null +++ b/Lang/BASIC/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-Infinite b/Lang/BASIC/Loops-Infinite new file mode 120000 index 0000000000..361ad99eaf --- /dev/null +++ b/Lang/BASIC/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-N-plus-one-half b/Lang/BASIC/Loops-N-plus-one-half new file mode 120000 index 0000000000..c6b9be5b5d --- /dev/null +++ b/Lang/BASIC/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-Nested b/Lang/BASIC/Loops-Nested new file mode 120000 index 0000000000..1506fb6b9e --- /dev/null +++ b/Lang/BASIC/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Loops-While b/Lang/BASIC/Loops-While new file mode 120000 index 0000000000..7ea8e6bd7a --- /dev/null +++ b/Lang/BASIC/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Mandelbrot-set b/Lang/BASIC/Mandelbrot-set new file mode 120000 index 0000000000..9ced082a83 --- /dev/null +++ b/Lang/BASIC/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Menu b/Lang/BASIC/Menu new file mode 120000 index 0000000000..e18c93e579 --- /dev/null +++ b/Lang/BASIC/Menu @@ -0,0 +1 @@ +../../Task/Menu/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Monte-Carlo-methods b/Lang/BASIC/Monte-Carlo-methods new file mode 120000 index 0000000000..157152cba6 --- /dev/null +++ b/Lang/BASIC/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Monty-Hall-problem b/Lang/BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..ba5a5a279d --- /dev/null +++ b/Lang/BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Morse-code b/Lang/BASIC/Morse-code new file mode 120000 index 0000000000..bca3f9caaf --- /dev/null +++ b/Lang/BASIC/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Multiplication-tables b/Lang/BASIC/Multiplication-tables new file mode 120000 index 0000000000..1cbc96b872 --- /dev/null +++ b/Lang/BASIC/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Mutual-recursion b/Lang/BASIC/Mutual-recursion new file mode 120000 index 0000000000..6eb6141486 --- /dev/null +++ b/Lang/BASIC/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/Factorial b/Lang/BASIC256/Factorial new file mode 120000 index 0000000000..788901a16e --- /dev/null +++ b/Lang/BASIC256/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Fractal-tree b/Lang/BASIC256/Fractal-tree new file mode 120000 index 0000000000..d65bf79a8f --- /dev/null +++ b/Lang/BASIC256/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Galton-box-animation b/Lang/BASIC256/Galton-box-animation new file mode 120000 index 0000000000..e011432a89 --- /dev/null +++ b/Lang/BASIC256/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Grayscale-image b/Lang/BASIC256/Grayscale-image new file mode 120000 index 0000000000..c969f283a9 --- /dev/null +++ b/Lang/BASIC256/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Greyscale-bars-Display b/Lang/BASIC256/Greyscale-bars-Display new file mode 120000 index 0000000000..377a2c8de8 --- /dev/null +++ b/Lang/BASIC256/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Guess-the-number b/Lang/BASIC256/Guess-the-number new file mode 120000 index 0000000000..5a32b30464 --- /dev/null +++ b/Lang/BASIC256/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Guess-the-number-With-feedback b/Lang/BASIC256/Guess-the-number-With-feedback new file mode 120000 index 0000000000..3195f6ab08 --- /dev/null +++ b/Lang/BASIC256/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Hello-world-Graphical b/Lang/BASIC256/Hello-world-Graphical new file mode 120000 index 0000000000..c247e7513f --- /dev/null +++ b/Lang/BASIC256/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Hello-world-Newline-omission b/Lang/BASIC256/Hello-world-Newline-omission new file mode 120000 index 0000000000..b9bde8c5ff --- /dev/null +++ b/Lang/BASIC256/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Hello-world-Text b/Lang/BASIC256/Hello-world-Text new file mode 120000 index 0000000000..d4d2feaba4 --- /dev/null +++ b/Lang/BASIC256/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Last-letter-first-letter b/Lang/BASIC256/Last-letter-first-letter new file mode 120000 index 0000000000..c4a083d86b --- /dev/null +++ b/Lang/BASIC256/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Logical-operations b/Lang/BASIC256/Logical-operations new file mode 120000 index 0000000000..d5d5041322 --- /dev/null +++ b/Lang/BASIC256/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Loops-Foreach b/Lang/BASIC256/Loops-Foreach new file mode 120000 index 0000000000..cc72787530 --- /dev/null +++ b/Lang/BASIC256/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Mandelbrot-set b/Lang/BASIC256/Mandelbrot-set new file mode 120000 index 0000000000..b7754d3683 --- /dev/null +++ b/Lang/BASIC256/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Minesweeper-game b/Lang/BASIC256/Minesweeper-game new file mode 120000 index 0000000000..9493ad4ff0 --- /dev/null +++ b/Lang/BASIC256/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/BASIC256 \ No newline at end of file diff --git a/Lang/BBC-BASIC/24-game-Solve b/Lang/BBC-BASIC/24-game-Solve new file mode 120000 index 0000000000..76e04f87e0 --- /dev/null +++ b/Lang/BBC-BASIC/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Factorial b/Lang/BBC-BASIC/Factorial new file mode 120000 index 0000000000..c3a96c51d4 --- /dev/null +++ b/Lang/BBC-BASIC/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Factors-of-a-Mersenne-number b/Lang/BBC-BASIC/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..6cdc013ffc --- /dev/null +++ b/Lang/BBC-BASIC/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Factors-of-an-integer b/Lang/BBC-BASIC/Factors-of-an-integer new file mode 120000 index 0000000000..ee0ba71ff2 --- /dev/null +++ b/Lang/BBC-BASIC/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Fast-Fourier-transform b/Lang/BBC-BASIC/Fast-Fourier-transform new file mode 120000 index 0000000000..bc48049ba7 --- /dev/null +++ b/Lang/BBC-BASIC/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Fibonacci-n-step-number-sequences b/Lang/BBC-BASIC/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..c2e9a22326 --- /dev/null +++ b/Lang/BBC-BASIC/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Fibonacci-sequence b/Lang/BBC-BASIC/Fibonacci-sequence new file mode 120000 index 0000000000..c81f974a3d --- /dev/null +++ b/Lang/BBC-BASIC/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/File-IO b/Lang/BBC-BASIC/File-IO new file mode 120000 index 0000000000..3d789ec845 --- /dev/null +++ b/Lang/BBC-BASIC/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/File-modification-time b/Lang/BBC-BASIC/File-modification-time new file mode 120000 index 0000000000..34268f0706 --- /dev/null +++ b/Lang/BBC-BASIC/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/File-size b/Lang/BBC-BASIC/File-size new file mode 120000 index 0000000000..e11906f005 --- /dev/null +++ b/Lang/BBC-BASIC/File-size @@ -0,0 +1 @@ +../../Task/File-size/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Filter b/Lang/BBC-BASIC/Filter new file mode 120000 index 0000000000..0998d4b353 --- /dev/null +++ b/Lang/BBC-BASIC/Filter @@ -0,0 +1 @@ +../../Task/Filter/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Find-common-directory-path b/Lang/BBC-BASIC/Find-common-directory-path new file mode 120000 index 0000000000..15598a4442 --- /dev/null +++ b/Lang/BBC-BASIC/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/BBC-BASIC/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..51ec39c877 --- /dev/null +++ b/Lang/BBC-BASIC/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Find-limit-of-recursion b/Lang/BBC-BASIC/Find-limit-of-recursion new file mode 120000 index 0000000000..2ac2d26cb2 --- /dev/null +++ b/Lang/BBC-BASIC/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Find-the-missing-permutation b/Lang/BBC-BASIC/Find-the-missing-permutation new file mode 120000 index 0000000000..be30803a89 --- /dev/null +++ b/Lang/BBC-BASIC/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/First-class-environments b/Lang/BBC-BASIC/First-class-environments new file mode 120000 index 0000000000..18b793b162 --- /dev/null +++ b/Lang/BBC-BASIC/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/First-class-functions b/Lang/BBC-BASIC/First-class-functions new file mode 120000 index 0000000000..0421d27724 --- /dev/null +++ b/Lang/BBC-BASIC/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/First-class-functions-Use-numbers-analogously b/Lang/BBC-BASIC/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..bd48e13c6d --- /dev/null +++ b/Lang/BBC-BASIC/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Five-weekends b/Lang/BBC-BASIC/Five-weekends new file mode 120000 index 0000000000..631213c818 --- /dev/null +++ b/Lang/BBC-BASIC/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Flow-control-structures b/Lang/BBC-BASIC/Flow-control-structures new file mode 120000 index 0000000000..f46077a869 --- /dev/null +++ b/Lang/BBC-BASIC/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Floyds-triangle b/Lang/BBC-BASIC/Floyds-triangle new file mode 120000 index 0000000000..ab8ca4f949 --- /dev/null +++ b/Lang/BBC-BASIC/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Formatted-numeric-output b/Lang/BBC-BASIC/Formatted-numeric-output new file mode 120000 index 0000000000..6d60405ba9 --- /dev/null +++ b/Lang/BBC-BASIC/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Forward-difference b/Lang/BBC-BASIC/Forward-difference new file mode 120000 index 0000000000..f490728933 --- /dev/null +++ b/Lang/BBC-BASIC/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Four-bit-adder b/Lang/BBC-BASIC/Four-bit-adder new file mode 120000 index 0000000000..81f67c33aa --- /dev/null +++ b/Lang/BBC-BASIC/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Fractal-tree b/Lang/BBC-BASIC/Fractal-tree new file mode 120000 index 0000000000..8d6389c71b --- /dev/null +++ b/Lang/BBC-BASIC/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Function-composition b/Lang/BBC-BASIC/Function-composition new file mode 120000 index 0000000000..7e750406e4 --- /dev/null +++ b/Lang/BBC-BASIC/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Function-definition b/Lang/BBC-BASIC/Function-definition new file mode 120000 index 0000000000..bfbf65edd1 --- /dev/null +++ b/Lang/BBC-BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Function-frequency b/Lang/BBC-BASIC/Function-frequency new file mode 120000 index 0000000000..b520fb7387 --- /dev/null +++ b/Lang/BBC-BASIC/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/GUI-Maximum-window-dimensions b/Lang/BBC-BASIC/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..58349c16a5 --- /dev/null +++ b/Lang/BBC-BASIC/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/GUI-component-interaction b/Lang/BBC-BASIC/GUI-component-interaction new file mode 120000 index 0000000000..c7bae906d5 --- /dev/null +++ b/Lang/BBC-BASIC/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/GUI-enabling-disabling-of-controls b/Lang/BBC-BASIC/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..4b47a1a49e --- /dev/null +++ b/Lang/BBC-BASIC/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Galton-box-animation b/Lang/BBC-BASIC/Galton-box-animation new file mode 120000 index 0000000000..6cfec8fab2 --- /dev/null +++ b/Lang/BBC-BASIC/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Gamma-function b/Lang/BBC-BASIC/Gamma-function new file mode 120000 index 0000000000..8e60b5478b --- /dev/null +++ b/Lang/BBC-BASIC/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Generic-swap b/Lang/BBC-BASIC/Generic-swap new file mode 120000 index 0000000000..19448c9790 --- /dev/null +++ b/Lang/BBC-BASIC/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Globally-replace-text-in-several-files b/Lang/BBC-BASIC/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..6078167fe9 --- /dev/null +++ b/Lang/BBC-BASIC/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Gray-code b/Lang/BBC-BASIC/Gray-code new file mode 120000 index 0000000000..ac14a91bae --- /dev/null +++ b/Lang/BBC-BASIC/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Grayscale-image b/Lang/BBC-BASIC/Grayscale-image new file mode 120000 index 0000000000..af0022f123 --- /dev/null +++ b/Lang/BBC-BASIC/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Greatest-common-divisor b/Lang/BBC-BASIC/Greatest-common-divisor new file mode 120000 index 0000000000..7bcdc2d32a --- /dev/null +++ b/Lang/BBC-BASIC/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Greatest-element-of-a-list b/Lang/BBC-BASIC/Greatest-element-of-a-list new file mode 120000 index 0000000000..51063887c7 --- /dev/null +++ b/Lang/BBC-BASIC/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Greatest-subsequential-sum b/Lang/BBC-BASIC/Greatest-subsequential-sum new file mode 120000 index 0000000000..e842401528 --- /dev/null +++ b/Lang/BBC-BASIC/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Greyscale-bars-Display b/Lang/BBC-BASIC/Greyscale-bars-Display new file mode 120000 index 0000000000..d72144bec0 --- /dev/null +++ b/Lang/BBC-BASIC/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Guess-the-number b/Lang/BBC-BASIC/Guess-the-number new file mode 120000 index 0000000000..243042f182 --- /dev/null +++ b/Lang/BBC-BASIC/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Guess-the-number-With-feedback b/Lang/BBC-BASIC/Guess-the-number-With-feedback new file mode 120000 index 0000000000..2596a86a57 --- /dev/null +++ b/Lang/BBC-BASIC/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Guess-the-number-With-feedback-player b/Lang/BBC-BASIC/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..58dd634194 --- /dev/null +++ b/Lang/BBC-BASIC/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/HTTP b/Lang/BBC-BASIC/HTTP new file mode 120000 index 0000000000..12d30cfb8d --- /dev/null +++ b/Lang/BBC-BASIC/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hailstone-sequence b/Lang/BBC-BASIC/Hailstone-sequence new file mode 120000 index 0000000000..b25c2438d2 --- /dev/null +++ b/Lang/BBC-BASIC/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hamming-numbers b/Lang/BBC-BASIC/Hamming-numbers new file mode 120000 index 0000000000..8d107bd8c9 --- /dev/null +++ b/Lang/BBC-BASIC/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Handle-a-signal b/Lang/BBC-BASIC/Handle-a-signal new file mode 120000 index 0000000000..d3b69abb5e --- /dev/null +++ b/Lang/BBC-BASIC/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Happy-numbers b/Lang/BBC-BASIC/Happy-numbers new file mode 120000 index 0000000000..d28502a846 --- /dev/null +++ b/Lang/BBC-BASIC/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hash-from-two-arrays b/Lang/BBC-BASIC/Hash-from-two-arrays new file mode 120000 index 0000000000..14613b7072 --- /dev/null +++ b/Lang/BBC-BASIC/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Haversine-formula b/Lang/BBC-BASIC/Haversine-formula new file mode 120000 index 0000000000..66d1b14f5f --- /dev/null +++ b/Lang/BBC-BASIC/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Graphical b/Lang/BBC-BASIC/Hello-world-Graphical new file mode 120000 index 0000000000..6e212535b8 --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Line-printer b/Lang/BBC-BASIC/Hello-world-Line-printer new file mode 120000 index 0000000000..f8e874a25d --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Newline-omission b/Lang/BBC-BASIC/Hello-world-Newline-omission new file mode 120000 index 0000000000..f3dce1cd34 --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Standard-error b/Lang/BBC-BASIC/Hello-world-Standard-error new file mode 120000 index 0000000000..d9448304c8 --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Text b/Lang/BBC-BASIC/Hello-world-Text new file mode 120000 index 0000000000..318512041f --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hello-world-Web-server b/Lang/BBC-BASIC/Hello-world-Web-server new file mode 120000 index 0000000000..1ce1156222 --- /dev/null +++ b/Lang/BBC-BASIC/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Higher-order-functions b/Lang/BBC-BASIC/Higher-order-functions new file mode 120000 index 0000000000..c283807715 --- /dev/null +++ b/Lang/BBC-BASIC/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hofstadter-Conway-$10,000-sequence b/Lang/BBC-BASIC/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..a207f5427a --- /dev/null +++ b/Lang/BBC-BASIC/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hofstadter-Figure-Figure-sequences b/Lang/BBC-BASIC/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..2cd15a0fc7 --- /dev/null +++ b/Lang/BBC-BASIC/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hofstadter-Q-sequence b/Lang/BBC-BASIC/Hofstadter-Q-sequence new file mode 120000 index 0000000000..1cba3b29a5 --- /dev/null +++ b/Lang/BBC-BASIC/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Holidays-related-to-Easter b/Lang/BBC-BASIC/Holidays-related-to-Easter new file mode 120000 index 0000000000..e4ee5bd6ec --- /dev/null +++ b/Lang/BBC-BASIC/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Honeycombs b/Lang/BBC-BASIC/Honeycombs new file mode 120000 index 0000000000..4ff852bc8d --- /dev/null +++ b/Lang/BBC-BASIC/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Horizontal-sundial-calculations b/Lang/BBC-BASIC/Horizontal-sundial-calculations new file mode 120000 index 0000000000..f8f6bd0ea2 --- /dev/null +++ b/Lang/BBC-BASIC/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Horners-rule-for-polynomial-evaluation b/Lang/BBC-BASIC/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..ce9d353236 --- /dev/null +++ b/Lang/BBC-BASIC/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Host-introspection b/Lang/BBC-BASIC/Host-introspection new file mode 120000 index 0000000000..8c928f5a3a --- /dev/null +++ b/Lang/BBC-BASIC/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hostname b/Lang/BBC-BASIC/Hostname new file mode 120000 index 0000000000..f43a091eae --- /dev/null +++ b/Lang/BBC-BASIC/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Hough-transform b/Lang/BBC-BASIC/Hough-transform new file mode 120000 index 0000000000..6d816225c6 --- /dev/null +++ b/Lang/BBC-BASIC/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Huffman-coding b/Lang/BBC-BASIC/Huffman-coding new file mode 120000 index 0000000000..8865b49b1e --- /dev/null +++ b/Lang/BBC-BASIC/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Identity-matrix b/Lang/BBC-BASIC/Identity-matrix new file mode 120000 index 0000000000..ebd037a00e --- /dev/null +++ b/Lang/BBC-BASIC/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Image-convolution b/Lang/BBC-BASIC/Image-convolution new file mode 120000 index 0000000000..daff9ca211 --- /dev/null +++ b/Lang/BBC-BASIC/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Image-noise b/Lang/BBC-BASIC/Image-noise new file mode 120000 index 0000000000..73740e5770 --- /dev/null +++ b/Lang/BBC-BASIC/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Include-a-file b/Lang/BBC-BASIC/Include-a-file new file mode 120000 index 0000000000..49439ad055 --- /dev/null +++ b/Lang/BBC-BASIC/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Increment-a-numerical-string b/Lang/BBC-BASIC/Increment-a-numerical-string new file mode 120000 index 0000000000..ca25fcf9ba --- /dev/null +++ b/Lang/BBC-BASIC/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Inheritance-Multiple b/Lang/BBC-BASIC/Inheritance-Multiple new file mode 120000 index 0000000000..bb9844baea --- /dev/null +++ b/Lang/BBC-BASIC/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Inheritance-Single b/Lang/BBC-BASIC/Inheritance-Single new file mode 120000 index 0000000000..a0e7f77fda --- /dev/null +++ b/Lang/BBC-BASIC/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Input-loop b/Lang/BBC-BASIC/Input-loop new file mode 120000 index 0000000000..82a543578c --- /dev/null +++ b/Lang/BBC-BASIC/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Integer-comparison b/Lang/BBC-BASIC/Integer-comparison new file mode 120000 index 0000000000..bb2bb192bb --- /dev/null +++ b/Lang/BBC-BASIC/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Integer-sequence b/Lang/BBC-BASIC/Integer-sequence new file mode 120000 index 0000000000..670c116754 --- /dev/null +++ b/Lang/BBC-BASIC/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Introspection b/Lang/BBC-BASIC/Introspection new file mode 120000 index 0000000000..dec2556cf2 --- /dev/null +++ b/Lang/BBC-BASIC/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Inverted-index b/Lang/BBC-BASIC/Inverted-index new file mode 120000 index 0000000000..c6ee6ca9e1 --- /dev/null +++ b/Lang/BBC-BASIC/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Jensens-Device b/Lang/BBC-BASIC/Jensens-Device new file mode 120000 index 0000000000..167d7f1c91 --- /dev/null +++ b/Lang/BBC-BASIC/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Joystick-position b/Lang/BBC-BASIC/Joystick-position new file mode 120000 index 0000000000..2be34c5cb4 --- /dev/null +++ b/Lang/BBC-BASIC/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Kaprekar-numbers b/Lang/BBC-BASIC/Kaprekar-numbers new file mode 120000 index 0000000000..8e053ba9c2 --- /dev/null +++ b/Lang/BBC-BASIC/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Keyboard-input-Flush-the-keyboard-buffer b/Lang/BBC-BASIC/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..46974ca47c --- /dev/null +++ b/Lang/BBC-BASIC/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Keyboard-input-Keypress-check b/Lang/BBC-BASIC/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..318c8c58ca --- /dev/null +++ b/Lang/BBC-BASIC/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Keyboard-macros b/Lang/BBC-BASIC/Keyboard-macros new file mode 120000 index 0000000000..e7dbc8871a --- /dev/null +++ b/Lang/BBC-BASIC/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Knapsack-problem-0-1 b/Lang/BBC-BASIC/Knapsack-problem-0-1 new file mode 120000 index 0000000000..2fba046060 --- /dev/null +++ b/Lang/BBC-BASIC/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Knapsack-problem-Continuous b/Lang/BBC-BASIC/Knapsack-problem-Continuous new file mode 120000 index 0000000000..e581611ef1 --- /dev/null +++ b/Lang/BBC-BASIC/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Knights-tour b/Lang/BBC-BASIC/Knights-tour new file mode 120000 index 0000000000..b5db2ca453 --- /dev/null +++ b/Lang/BBC-BASIC/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Knuths-algorithm-S b/Lang/BBC-BASIC/Knuths-algorithm-S new file mode 120000 index 0000000000..8bdfe348bb --- /dev/null +++ b/Lang/BBC-BASIC/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/LU-decomposition b/Lang/BBC-BASIC/LU-decomposition new file mode 120000 index 0000000000..3f19121910 --- /dev/null +++ b/Lang/BBC-BASIC/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/LZW-compression b/Lang/BBC-BASIC/LZW-compression new file mode 120000 index 0000000000..3f35315a57 --- /dev/null +++ b/Lang/BBC-BASIC/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Langtons-ant b/Lang/BBC-BASIC/Langtons-ant new file mode 120000 index 0000000000..0bbf751eb1 --- /dev/null +++ b/Lang/BBC-BASIC/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Last-letter-first-letter b/Lang/BBC-BASIC/Last-letter-first-letter new file mode 120000 index 0000000000..c341d7170a --- /dev/null +++ b/Lang/BBC-BASIC/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Leap-year b/Lang/BBC-BASIC/Leap-year new file mode 120000 index 0000000000..2865d8e86e --- /dev/null +++ b/Lang/BBC-BASIC/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Least-common-multiple b/Lang/BBC-BASIC/Least-common-multiple new file mode 120000 index 0000000000..4fdd4d0d18 --- /dev/null +++ b/Lang/BBC-BASIC/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Letter-frequency b/Lang/BBC-BASIC/Letter-frequency new file mode 120000 index 0000000000..73f331375f --- /dev/null +++ b/Lang/BBC-BASIC/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Levenshtein-distance b/Lang/BBC-BASIC/Levenshtein-distance new file mode 120000 index 0000000000..1be57440cb --- /dev/null +++ b/Lang/BBC-BASIC/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Linear-congruential-generator b/Lang/BBC-BASIC/Linear-congruential-generator new file mode 120000 index 0000000000..7a5345a7b2 --- /dev/null +++ b/Lang/BBC-BASIC/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Literals-Floating-point b/Lang/BBC-BASIC/Literals-Floating-point new file mode 120000 index 0000000000..d7016ee17f --- /dev/null +++ b/Lang/BBC-BASIC/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Literals-Integer b/Lang/BBC-BASIC/Literals-Integer new file mode 120000 index 0000000000..9bacf10b9e --- /dev/null +++ b/Lang/BBC-BASIC/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Literals-String b/Lang/BBC-BASIC/Literals-String new file mode 120000 index 0000000000..69c52102ac --- /dev/null +++ b/Lang/BBC-BASIC/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Logical-operations b/Lang/BBC-BASIC/Logical-operations new file mode 120000 index 0000000000..21853a5e44 --- /dev/null +++ b/Lang/BBC-BASIC/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Long-multiplication b/Lang/BBC-BASIC/Long-multiplication new file mode 120000 index 0000000000..d267b3579e --- /dev/null +++ b/Lang/BBC-BASIC/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Longest-common-subsequence b/Lang/BBC-BASIC/Longest-common-subsequence new file mode 120000 index 0000000000..c6a8853252 --- /dev/null +++ b/Lang/BBC-BASIC/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Longest-string-challenge b/Lang/BBC-BASIC/Longest-string-challenge new file mode 120000 index 0000000000..32cd896a99 --- /dev/null +++ b/Lang/BBC-BASIC/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Look-and-say-sequence b/Lang/BBC-BASIC/Look-and-say-sequence new file mode 120000 index 0000000000..52b0c0b06f --- /dev/null +++ b/Lang/BBC-BASIC/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loop-over-multiple-arrays-simultaneously b/Lang/BBC-BASIC/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..7e3d3192e7 --- /dev/null +++ b/Lang/BBC-BASIC/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Break b/Lang/BBC-BASIC/Loops-Break new file mode 120000 index 0000000000..e4276c3403 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Continue b/Lang/BBC-BASIC/Loops-Continue new file mode 120000 index 0000000000..aaf229e600 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Do-while b/Lang/BBC-BASIC/Loops-Do-while new file mode 120000 index 0000000000..0c90456de3 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Downward-for b/Lang/BBC-BASIC/Loops-Downward-for new file mode 120000 index 0000000000..ffe9caf31b --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-For b/Lang/BBC-BASIC/Loops-For new file mode 120000 index 0000000000..4dba4d4cb0 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-For-with-a-specified-step b/Lang/BBC-BASIC/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..1e5ac7a1c3 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Foreach b/Lang/BBC-BASIC/Loops-Foreach new file mode 120000 index 0000000000..534b69b51c --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Infinite b/Lang/BBC-BASIC/Loops-Infinite new file mode 120000 index 0000000000..1da88d864e --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-N-plus-one-half b/Lang/BBC-BASIC/Loops-N-plus-one-half new file mode 120000 index 0000000000..308d2eb72e --- /dev/null +++ b/Lang/BBC-BASIC/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-Nested b/Lang/BBC-BASIC/Loops-Nested new file mode 120000 index 0000000000..00f19e3464 --- /dev/null +++ b/Lang/BBC-BASIC/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Loops-While b/Lang/BBC-BASIC/Loops-While new file mode 120000 index 0000000000..ab479b5d9f --- /dev/null +++ b/Lang/BBC-BASIC/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Lucas-Lehmer-test b/Lang/BBC-BASIC/Lucas-Lehmer-test new file mode 120000 index 0000000000..cb1941e97a --- /dev/null +++ b/Lang/BBC-BASIC/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Luhn-test-of-credit-card-numbers b/Lang/BBC-BASIC/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..635f214c5f --- /dev/null +++ b/Lang/BBC-BASIC/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/MD5 b/Lang/BBC-BASIC/MD5 new file mode 120000 index 0000000000..31976ebb4a --- /dev/null +++ b/Lang/BBC-BASIC/MD5 @@ -0,0 +1 @@ +../../Task/MD5/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/MD5-Implementation b/Lang/BBC-BASIC/MD5-Implementation new file mode 120000 index 0000000000..a25a1a2ec7 --- /dev/null +++ b/Lang/BBC-BASIC/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Main-step-of-GOST-28147-89 b/Lang/BBC-BASIC/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..a9e3fee59b --- /dev/null +++ b/Lang/BBC-BASIC/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Man-or-boy-test b/Lang/BBC-BASIC/Man-or-boy-test new file mode 120000 index 0000000000..544a06d311 --- /dev/null +++ b/Lang/BBC-BASIC/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Mandelbrot-set b/Lang/BBC-BASIC/Mandelbrot-set new file mode 120000 index 0000000000..4a47d7d008 --- /dev/null +++ b/Lang/BBC-BASIC/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Map-range b/Lang/BBC-BASIC/Map-range new file mode 120000 index 0000000000..e034afee6e --- /dev/null +++ b/Lang/BBC-BASIC/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Matrix-exponentiation-operator b/Lang/BBC-BASIC/Matrix-exponentiation-operator new file mode 120000 index 0000000000..3a66f0f940 --- /dev/null +++ b/Lang/BBC-BASIC/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Matrix-multiplication b/Lang/BBC-BASIC/Matrix-multiplication new file mode 120000 index 0000000000..11da7b85c2 --- /dev/null +++ b/Lang/BBC-BASIC/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Matrix-transposition b/Lang/BBC-BASIC/Matrix-transposition new file mode 120000 index 0000000000..22ab13b3ed --- /dev/null +++ b/Lang/BBC-BASIC/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Maze-generation b/Lang/BBC-BASIC/Maze-generation new file mode 120000 index 0000000000..783c2fe0ca --- /dev/null +++ b/Lang/BBC-BASIC/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Maze-solving b/Lang/BBC-BASIC/Maze-solving new file mode 120000 index 0000000000..fc71f3a7d9 --- /dev/null +++ b/Lang/BBC-BASIC/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Median-filter b/Lang/BBC-BASIC/Median-filter new file mode 120000 index 0000000000..db94ab96a3 --- /dev/null +++ b/Lang/BBC-BASIC/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Memory-allocation b/Lang/BBC-BASIC/Memory-allocation new file mode 120000 index 0000000000..ecc6c2ece4 --- /dev/null +++ b/Lang/BBC-BASIC/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Menu b/Lang/BBC-BASIC/Menu new file mode 120000 index 0000000000..d7c234e285 --- /dev/null +++ b/Lang/BBC-BASIC/Menu @@ -0,0 +1 @@ +../../Task/Menu/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Metered-concurrency b/Lang/BBC-BASIC/Metered-concurrency new file mode 120000 index 0000000000..a4a40ac52d --- /dev/null +++ b/Lang/BBC-BASIC/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Metronome b/Lang/BBC-BASIC/Metronome new file mode 120000 index 0000000000..ee4cd8f47b --- /dev/null +++ b/Lang/BBC-BASIC/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Modular-exponentiation b/Lang/BBC-BASIC/Modular-exponentiation new file mode 120000 index 0000000000..e257e4efad --- /dev/null +++ b/Lang/BBC-BASIC/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Monte-Carlo-methods b/Lang/BBC-BASIC/Monte-Carlo-methods new file mode 120000 index 0000000000..16cce91417 --- /dev/null +++ b/Lang/BBC-BASIC/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Monty-Hall-problem b/Lang/BBC-BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..7ba0980438 --- /dev/null +++ b/Lang/BBC-BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Morse-code b/Lang/BBC-BASIC/Morse-code new file mode 120000 index 0000000000..01bfcb685c --- /dev/null +++ b/Lang/BBC-BASIC/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Mouse-position b/Lang/BBC-BASIC/Mouse-position new file mode 120000 index 0000000000..296dddfbe2 --- /dev/null +++ b/Lang/BBC-BASIC/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multiple-distinct-objects b/Lang/BBC-BASIC/Multiple-distinct-objects new file mode 120000 index 0000000000..6abf48c8a6 --- /dev/null +++ b/Lang/BBC-BASIC/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multiple-regression b/Lang/BBC-BASIC/Multiple-regression new file mode 120000 index 0000000000..7fc4de22e2 --- /dev/null +++ b/Lang/BBC-BASIC/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multiplication-tables b/Lang/BBC-BASIC/Multiplication-tables new file mode 120000 index 0000000000..b2fc3e11f6 --- /dev/null +++ b/Lang/BBC-BASIC/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Multisplit b/Lang/BBC-BASIC/Multisplit new file mode 120000 index 0000000000..11ea552d71 --- /dev/null +++ b/Lang/BBC-BASIC/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Mutex b/Lang/BBC-BASIC/Mutex new file mode 120000 index 0000000000..2a321a371d --- /dev/null +++ b/Lang/BBC-BASIC/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Mutual-recursion b/Lang/BBC-BASIC/Mutual-recursion new file mode 120000 index 0000000000..6153f7bbfb --- /dev/null +++ b/Lang/BBC-BASIC/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BCPL/Hello-world-Text b/Lang/BCPL/Hello-world-Text new file mode 120000 index 0000000000..f2064b2f0c --- /dev/null +++ b/Lang/BCPL/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/BCPL \ No newline at end of file diff --git a/Lang/Babel/Factorial b/Lang/Babel/Factorial new file mode 120000 index 0000000000..2ee215bddf --- /dev/null +++ b/Lang/Babel/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Babel \ No newline at end of file diff --git a/Lang/Babel/Fibonacci-sequence b/Lang/Babel/Fibonacci-sequence new file mode 120000 index 0000000000..973ffbb208 --- /dev/null +++ b/Lang/Babel/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Babel \ No newline at end of file diff --git a/Lang/Babel/File-IO b/Lang/Babel/File-IO new file mode 120000 index 0000000000..b6fdd56a9c --- /dev/null +++ b/Lang/Babel/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Babel \ No newline at end of file diff --git a/Lang/Babel/Hello-world-Text b/Lang/Babel/Hello-world-Text new file mode 120000 index 0000000000..eb07b820fc --- /dev/null +++ b/Lang/Babel/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Babel \ No newline at end of file diff --git a/Lang/Babel/Host-introspection b/Lang/Babel/Host-introspection new file mode 120000 index 0000000000..a0d1af198a --- /dev/null +++ b/Lang/Babel/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Babel \ No newline at end of file diff --git a/Lang/Babel/Loop-over-multiple-arrays-simultaneously b/Lang/Babel/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..ab4491adcb --- /dev/null +++ b/Lang/Babel/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Babel \ No newline at end of file diff --git a/Lang/Babel/Loops-For b/Lang/Babel/Loops-For new file mode 120000 index 0000000000..8c3f4e36b6 --- /dev/null +++ b/Lang/Babel/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Babel \ No newline at end of file diff --git a/Lang/Batch-File/Factorial b/Lang/Batch-File/Factorial new file mode 120000 index 0000000000..1ecb207315 --- /dev/null +++ b/Lang/Batch-File/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Factors-of-an-integer b/Lang/Batch-File/Factors-of-an-integer new file mode 120000 index 0000000000..de85b2645c --- /dev/null +++ b/Lang/Batch-File/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Fibonacci-sequence b/Lang/Batch-File/Fibonacci-sequence new file mode 120000 index 0000000000..65ab81516b --- /dev/null +++ b/Lang/Batch-File/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/File-IO b/Lang/Batch-File/File-IO new file mode 120000 index 0000000000..15d020f16e --- /dev/null +++ b/Lang/Batch-File/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/File-modification-time b/Lang/Batch-File/File-modification-time new file mode 120000 index 0000000000..f3ee6cb9c1 --- /dev/null +++ b/Lang/Batch-File/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Find-limit-of-recursion b/Lang/Batch-File/Find-limit-of-recursion new file mode 120000 index 0000000000..63f7fa4137 --- /dev/null +++ b/Lang/Batch-File/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Function-definition b/Lang/Batch-File/Function-definition new file mode 120000 index 0000000000..cb61f34027 --- /dev/null +++ b/Lang/Batch-File/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Generic-swap b/Lang/Batch-File/Generic-swap new file mode 120000 index 0000000000..0b18a72e52 --- /dev/null +++ b/Lang/Batch-File/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Greatest-common-divisor b/Lang/Batch-File/Greatest-common-divisor new file mode 120000 index 0000000000..9ab3141a1a --- /dev/null +++ b/Lang/Batch-File/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Greatest-element-of-a-list b/Lang/Batch-File/Greatest-element-of-a-list new file mode 120000 index 0000000000..e218410102 --- /dev/null +++ b/Lang/Batch-File/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Guess-the-number b/Lang/Batch-File/Guess-the-number new file mode 120000 index 0000000000..93c965e239 --- /dev/null +++ b/Lang/Batch-File/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/HTTP b/Lang/Batch-File/HTTP new file mode 120000 index 0000000000..ea9657e134 --- /dev/null +++ b/Lang/Batch-File/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/HTTPS b/Lang/Batch-File/HTTPS new file mode 120000 index 0000000000..5ea08cc852 --- /dev/null +++ b/Lang/Batch-File/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hailstone-sequence b/Lang/Batch-File/Hailstone-sequence new file mode 120000 index 0000000000..b85fcac500 --- /dev/null +++ b/Lang/Batch-File/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Happy-numbers b/Lang/Batch-File/Happy-numbers new file mode 120000 index 0000000000..e46c83cf06 --- /dev/null +++ b/Lang/Batch-File/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hello-world-Line-printer b/Lang/Batch-File/Hello-world-Line-printer new file mode 120000 index 0000000000..afd6d6106c --- /dev/null +++ b/Lang/Batch-File/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hello-world-Newline-omission b/Lang/Batch-File/Hello-world-Newline-omission new file mode 120000 index 0000000000..52124171b3 --- /dev/null +++ b/Lang/Batch-File/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hello-world-Standard-error b/Lang/Batch-File/Hello-world-Standard-error new file mode 120000 index 0000000000..3d877aa692 --- /dev/null +++ b/Lang/Batch-File/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Hello-world-Text b/Lang/Batch-File/Hello-world-Text new file mode 120000 index 0000000000..b2db007c46 --- /dev/null +++ b/Lang/Batch-File/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Increment-a-numerical-string b/Lang/Batch-File/Increment-a-numerical-string new file mode 120000 index 0000000000..3f7e6d1070 --- /dev/null +++ b/Lang/Batch-File/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Interactive-programming b/Lang/Batch-File/Interactive-programming new file mode 120000 index 0000000000..e0ac767444 --- /dev/null +++ b/Lang/Batch-File/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Batch-File/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..dad4a2e352 --- /dev/null +++ b/Lang/Batch-File/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Loops-Break b/Lang/Batch-File/Loops-Break new file mode 120000 index 0000000000..fee7e04428 --- /dev/null +++ b/Lang/Batch-File/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Loops-For b/Lang/Batch-File/Loops-For new file mode 120000 index 0000000000..5908a43fbb --- /dev/null +++ b/Lang/Batch-File/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Loops-Infinite b/Lang/Batch-File/Loops-Infinite new file mode 120000 index 0000000000..66f3cce28c --- /dev/null +++ b/Lang/Batch-File/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Batch-File \ No newline at end of file diff --git a/Lang/Bc/Greatest-common-divisor b/Lang/Bc/Greatest-common-divisor new file mode 120000 index 0000000000..9e81b5d01f --- /dev/null +++ b/Lang/Bc/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Bc \ No newline at end of file diff --git a/Lang/Bc/Mutual-recursion b/Lang/Bc/Mutual-recursion new file mode 120000 index 0000000000..6d774bcb7c --- /dev/null +++ b/Lang/Bc/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Bc \ No newline at end of file diff --git a/Lang/Befunge/Factorial b/Lang/Befunge/Factorial new file mode 120000 index 0000000000..6437627057 --- /dev/null +++ b/Lang/Befunge/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Fibonacci-sequence b/Lang/Befunge/Fibonacci-sequence new file mode 120000 index 0000000000..5d5593c55e --- /dev/null +++ b/Lang/Befunge/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Befunge \ No newline at end of file diff --git a/Lang/Befunge/File-IO b/Lang/Befunge/File-IO new file mode 120000 index 0000000000..60bcbfd2af --- /dev/null +++ b/Lang/Befunge/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Greatest-common-divisor b/Lang/Befunge/Greatest-common-divisor new file mode 120000 index 0000000000..d78196e4fa --- /dev/null +++ b/Lang/Befunge/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Hailstone-sequence b/Lang/Befunge/Hailstone-sequence new file mode 120000 index 0000000000..62a4fdf9ac --- /dev/null +++ b/Lang/Befunge/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Hello-world-Text b/Lang/Befunge/Hello-world-Text new file mode 120000 index 0000000000..1fe4e1fcac --- /dev/null +++ b/Lang/Befunge/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Integer-comparison b/Lang/Befunge/Integer-comparison new file mode 120000 index 0000000000..b643bd92bb --- /dev/null +++ b/Lang/Befunge/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Literals-Integer b/Lang/Befunge/Literals-Integer new file mode 120000 index 0000000000..bff02f0ba1 --- /dev/null +++ b/Lang/Befunge/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Literals-String b/Lang/Befunge/Literals-String new file mode 120000 index 0000000000..db4835fad3 --- /dev/null +++ b/Lang/Befunge/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-Do-while b/Lang/Befunge/Loops-Do-while new file mode 120000 index 0000000000..f764d16857 --- /dev/null +++ b/Lang/Befunge/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-Downward-for b/Lang/Befunge/Loops-Downward-for new file mode 120000 index 0000000000..2f18a66e72 --- /dev/null +++ b/Lang/Befunge/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-For b/Lang/Befunge/Loops-For new file mode 120000 index 0000000000..2f3c967f9c --- /dev/null +++ b/Lang/Befunge/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-Infinite b/Lang/Befunge/Loops-Infinite new file mode 120000 index 0000000000..aa36d6357a --- /dev/null +++ b/Lang/Befunge/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-N-plus-one-half b/Lang/Befunge/Loops-N-plus-one-half new file mode 120000 index 0000000000..0054bf9f82 --- /dev/null +++ b/Lang/Befunge/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Loops-While b/Lang/Befunge/Loops-While new file mode 120000 index 0000000000..fafbef1104 --- /dev/null +++ b/Lang/Befunge/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Befunge \ No newline at end of file diff --git a/Lang/Biferno/HTTP b/Lang/Biferno/HTTP new file mode 120000 index 0000000000..ca672b7361 --- /dev/null +++ b/Lang/Biferno/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Biferno \ No newline at end of file diff --git a/Lang/Blast/Hello-world-Text b/Lang/Blast/Hello-world-Text new file mode 120000 index 0000000000..45ba1c819d --- /dev/null +++ b/Lang/Blast/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Blast \ No newline at end of file diff --git a/Lang/Boo/Function-definition b/Lang/Boo/Function-definition new file mode 120000 index 0000000000..6d28b7e5af --- /dev/null +++ b/Lang/Boo/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Boo \ No newline at end of file diff --git a/Lang/Boo/Hello-world-Text b/Lang/Boo/Hello-world-Text new file mode 120000 index 0000000000..2207628814 --- /dev/null +++ b/Lang/Boo/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Boo \ No newline at end of file diff --git a/Lang/Boo/Increment-a-numerical-string b/Lang/Boo/Increment-a-numerical-string new file mode 120000 index 0000000000..165b46fc2b --- /dev/null +++ b/Lang/Boo/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Boo \ No newline at end of file diff --git a/Lang/Bori/First-class-functions b/Lang/Bori/First-class-functions new file mode 120000 index 0000000000..e33eb57d30 --- /dev/null +++ b/Lang/Bori/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Bori \ No newline at end of file diff --git a/Lang/Bori/Function-composition b/Lang/Bori/Function-composition new file mode 120000 index 0000000000..7a769dd781 --- /dev/null +++ b/Lang/Bori/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Bori \ No newline at end of file diff --git a/Lang/Bori/Happy-numbers b/Lang/Bori/Happy-numbers new file mode 120000 index 0000000000..5c563c44e1 --- /dev/null +++ b/Lang/Bori/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Bori \ No newline at end of file diff --git a/Lang/Brace/Hello-world-Text b/Lang/Brace/Hello-world-Text new file mode 120000 index 0000000000..eb115c6a58 --- /dev/null +++ b/Lang/Brace/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Brace \ No newline at end of file diff --git a/Lang/Brace/Mandelbrot-set b/Lang/Brace/Mandelbrot-set new file mode 120000 index 0000000000..18203d0e1c --- /dev/null +++ b/Lang/Brace/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Brace \ No newline at end of file diff --git a/Lang/Bracmat/Arbitrary-precision-integers-included b/Lang/Bracmat/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..1f1f97afa1 --- /dev/null +++ b/Lang/Bracmat/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Factorial b/Lang/Bracmat/Factorial new file mode 120000 index 0000000000..ea19df57e3 --- /dev/null +++ b/Lang/Bracmat/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Fibonacci-sequence b/Lang/Bracmat/Fibonacci-sequence new file mode 120000 index 0000000000..654f490fa9 --- /dev/null +++ b/Lang/Bracmat/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/File-IO b/Lang/Bracmat/File-IO new file mode 120000 index 0000000000..67fec306c8 --- /dev/null +++ b/Lang/Bracmat/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/File-size b/Lang/Bracmat/File-size new file mode 120000 index 0000000000..65d5ef338e --- /dev/null +++ b/Lang/Bracmat/File-size @@ -0,0 +1 @@ +../../Task/File-size/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Filter b/Lang/Bracmat/Filter new file mode 120000 index 0000000000..0e1c23df6d --- /dev/null +++ b/Lang/Bracmat/Filter @@ -0,0 +1 @@ +../../Task/Filter/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Find-limit-of-recursion b/Lang/Bracmat/Find-limit-of-recursion new file mode 120000 index 0000000000..a664caa004 --- /dev/null +++ b/Lang/Bracmat/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/First-class-environments b/Lang/Bracmat/First-class-environments new file mode 120000 index 0000000000..5b1fde7b52 --- /dev/null +++ b/Lang/Bracmat/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Flatten-a-list b/Lang/Bracmat/Flatten-a-list new file mode 120000 index 0000000000..9444a99acb --- /dev/null +++ b/Lang/Bracmat/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Floyds-triangle b/Lang/Bracmat/Floyds-triangle new file mode 120000 index 0000000000..e34a225a0b --- /dev/null +++ b/Lang/Bracmat/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Function-definition b/Lang/Bracmat/Function-definition new file mode 120000 index 0000000000..32d2b358e9 --- /dev/null +++ b/Lang/Bracmat/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Generic-swap b/Lang/Bracmat/Generic-swap new file mode 120000 index 0000000000..04aa901f7f --- /dev/null +++ b/Lang/Bracmat/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Greatest-common-divisor b/Lang/Bracmat/Greatest-common-divisor new file mode 120000 index 0000000000..19c4e22efc --- /dev/null +++ b/Lang/Bracmat/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Greatest-subsequential-sum b/Lang/Bracmat/Greatest-subsequential-sum new file mode 120000 index 0000000000..43c3642e82 --- /dev/null +++ b/Lang/Bracmat/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Hailstone-sequence b/Lang/Bracmat/Hailstone-sequence new file mode 120000 index 0000000000..24fc3fe18e --- /dev/null +++ b/Lang/Bracmat/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Hash-from-two-arrays b/Lang/Bracmat/Hash-from-two-arrays new file mode 120000 index 0000000000..82f9d0af77 --- /dev/null +++ b/Lang/Bracmat/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Hello-world-Newline-omission b/Lang/Bracmat/Hello-world-Newline-omission new file mode 120000 index 0000000000..410c8020c2 --- /dev/null +++ b/Lang/Bracmat/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Hello-world-Text b/Lang/Bracmat/Hello-world-Text new file mode 120000 index 0000000000..8639e21eb1 --- /dev/null +++ b/Lang/Bracmat/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Higher-order-functions b/Lang/Bracmat/Higher-order-functions new file mode 120000 index 0000000000..df7ea0ad92 --- /dev/null +++ b/Lang/Bracmat/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Increment-a-numerical-string b/Lang/Bracmat/Increment-a-numerical-string new file mode 120000 index 0000000000..162e42a444 --- /dev/null +++ b/Lang/Bracmat/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Integer-comparison b/Lang/Bracmat/Integer-comparison new file mode 120000 index 0000000000..13fd9becc0 --- /dev/null +++ b/Lang/Bracmat/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Integer-sequence b/Lang/Bracmat/Integer-sequence new file mode 120000 index 0000000000..93ea2d4339 --- /dev/null +++ b/Lang/Bracmat/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Inverted-syntax b/Lang/Bracmat/Inverted-syntax new file mode 120000 index 0000000000..428df3e4c2 --- /dev/null +++ b/Lang/Bracmat/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Kaprekar-numbers b/Lang/Bracmat/Kaprekar-numbers new file mode 120000 index 0000000000..0be290f0ff --- /dev/null +++ b/Lang/Bracmat/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Knapsack-problem-0-1 b/Lang/Bracmat/Knapsack-problem-0-1 new file mode 120000 index 0000000000..7cb580bcd9 --- /dev/null +++ b/Lang/Bracmat/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Knapsack-problem-Bounded b/Lang/Bracmat/Knapsack-problem-Bounded new file mode 120000 index 0000000000..92a8546c10 --- /dev/null +++ b/Lang/Bracmat/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Knapsack-problem-Unbounded b/Lang/Bracmat/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..b43c6e4511 --- /dev/null +++ b/Lang/Bracmat/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Knights-tour b/Lang/Bracmat/Knights-tour new file mode 120000 index 0000000000..93d1733242 --- /dev/null +++ b/Lang/Bracmat/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Last-letter-first-letter b/Lang/Bracmat/Last-letter-first-letter new file mode 120000 index 0000000000..6735151444 --- /dev/null +++ b/Lang/Bracmat/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Leap-year b/Lang/Bracmat/Leap-year new file mode 120000 index 0000000000..93fa8812ae --- /dev/null +++ b/Lang/Bracmat/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Least-common-multiple b/Lang/Bracmat/Least-common-multiple new file mode 120000 index 0000000000..eb76a620a2 --- /dev/null +++ b/Lang/Bracmat/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Letter-frequency b/Lang/Bracmat/Letter-frequency new file mode 120000 index 0000000000..32aa2033c9 --- /dev/null +++ b/Lang/Bracmat/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Levenshtein-distance b/Lang/Bracmat/Levenshtein-distance new file mode 120000 index 0000000000..403505e20f --- /dev/null +++ b/Lang/Bracmat/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Linear-congruential-generator b/Lang/Bracmat/Linear-congruential-generator new file mode 120000 index 0000000000..18d1a95443 --- /dev/null +++ b/Lang/Bracmat/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/List-comprehensions b/Lang/Bracmat/List-comprehensions new file mode 120000 index 0000000000..83875fc302 --- /dev/null +++ b/Lang/Bracmat/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Longest-common-subsequence b/Lang/Bracmat/Longest-common-subsequence new file mode 120000 index 0000000000..a3b023b390 --- /dev/null +++ b/Lang/Bracmat/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Loops-Downward-for b/Lang/Bracmat/Loops-Downward-for new file mode 120000 index 0000000000..f75992feca --- /dev/null +++ b/Lang/Bracmat/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Loops-For b/Lang/Bracmat/Loops-For new file mode 120000 index 0000000000..88d8dbc1ad --- /dev/null +++ b/Lang/Bracmat/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Loops-Foreach b/Lang/Bracmat/Loops-Foreach new file mode 120000 index 0000000000..61824eacf9 --- /dev/null +++ b/Lang/Bracmat/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Lucas-Lehmer-test b/Lang/Bracmat/Lucas-Lehmer-test new file mode 120000 index 0000000000..8a0f22e9e7 --- /dev/null +++ b/Lang/Bracmat/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Luhn-test-of-credit-card-numbers b/Lang/Bracmat/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..10f08aad25 --- /dev/null +++ b/Lang/Bracmat/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Map-range b/Lang/Bracmat/Map-range new file mode 120000 index 0000000000..45525f2acc --- /dev/null +++ b/Lang/Bracmat/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Memory-allocation b/Lang/Bracmat/Memory-allocation new file mode 120000 index 0000000000..989dbbeaac --- /dev/null +++ b/Lang/Bracmat/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Miller-Rabin-primality-test b/Lang/Bracmat/Miller-Rabin-primality-test new file mode 120000 index 0000000000..7c953943cd --- /dev/null +++ b/Lang/Bracmat/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Modular-exponentiation b/Lang/Bracmat/Modular-exponentiation new file mode 120000 index 0000000000..44cded35cc --- /dev/null +++ b/Lang/Bracmat/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Multisplit b/Lang/Bracmat/Multisplit new file mode 120000 index 0000000000..b637bf27db --- /dev/null +++ b/Lang/Bracmat/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Mutual-recursion b/Lang/Bracmat/Mutual-recursion new file mode 120000 index 0000000000..a8934cdc90 --- /dev/null +++ b/Lang/Bracmat/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Bracmat \ No newline at end of file diff --git a/Lang/Brainf---/Factorial b/Lang/Brainf---/Factorial new file mode 120000 index 0000000000..b30feab17d --- /dev/null +++ b/Lang/Brainf---/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Fibonacci-sequence b/Lang/Brainf---/Fibonacci-sequence new file mode 120000 index 0000000000..09e612db33 --- /dev/null +++ b/Lang/Brainf---/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Hailstone-sequence b/Lang/Brainf---/Hailstone-sequence new file mode 120000 index 0000000000..1a6aa4929d --- /dev/null +++ b/Lang/Brainf---/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Hello-world-Text b/Lang/Brainf---/Hello-world-Text new file mode 120000 index 0000000000..a93d0f2a58 --- /dev/null +++ b/Lang/Brainf---/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Integer-sequence b/Lang/Brainf---/Integer-sequence new file mode 120000 index 0000000000..6d4697e8cd --- /dev/null +++ b/Lang/Brainf---/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Loops-For b/Lang/Brainf---/Loops-For new file mode 120000 index 0000000000..a127af360f --- /dev/null +++ b/Lang/Brainf---/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Loops-Infinite b/Lang/Brainf---/Loops-Infinite new file mode 120000 index 0000000000..fea407ca33 --- /dev/null +++ b/Lang/Brainf---/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Brainf--- \ No newline at end of file diff --git a/Lang/Brat/Factorial b/Lang/Brat/Factorial new file mode 120000 index 0000000000..7b5320c491 --- /dev/null +++ b/Lang/Brat/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Brat \ No newline at end of file diff --git a/Lang/Brat/Fibonacci-sequence b/Lang/Brat/Fibonacci-sequence new file mode 120000 index 0000000000..f341a7e944 --- /dev/null +++ b/Lang/Brat/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Brat \ No newline at end of file diff --git a/Lang/Brat/Filter b/Lang/Brat/Filter new file mode 120000 index 0000000000..4671029aad --- /dev/null +++ b/Lang/Brat/Filter @@ -0,0 +1 @@ +../../Task/Filter/Brat \ No newline at end of file diff --git a/Lang/Brat/Flatten-a-list b/Lang/Brat/Flatten-a-list new file mode 120000 index 0000000000..3a62017455 --- /dev/null +++ b/Lang/Brat/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Brat \ No newline at end of file diff --git a/Lang/Brat/Function-composition b/Lang/Brat/Function-composition new file mode 120000 index 0000000000..a69a256e79 --- /dev/null +++ b/Lang/Brat/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Brat \ No newline at end of file diff --git a/Lang/Brat/Function-definition b/Lang/Brat/Function-definition new file mode 120000 index 0000000000..fb0ba2523b --- /dev/null +++ b/Lang/Brat/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Brat \ No newline at end of file diff --git a/Lang/Brat/Guess-the-number b/Lang/Brat/Guess-the-number new file mode 120000 index 0000000000..0ce738fb6d --- /dev/null +++ b/Lang/Brat/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Brat \ No newline at end of file diff --git a/Lang/Brat/Guess-the-number-With-feedback b/Lang/Brat/Guess-the-number-With-feedback new file mode 120000 index 0000000000..f06bc3d867 --- /dev/null +++ b/Lang/Brat/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Brat \ No newline at end of file diff --git a/Lang/Brat/Hailstone-sequence b/Lang/Brat/Hailstone-sequence new file mode 120000 index 0000000000..83538fe73a --- /dev/null +++ b/Lang/Brat/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Brat \ No newline at end of file diff --git a/Lang/Brat/Happy-numbers b/Lang/Brat/Happy-numbers new file mode 120000 index 0000000000..f24e4b1243 --- /dev/null +++ b/Lang/Brat/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Brat \ No newline at end of file diff --git a/Lang/Brat/Hash-from-two-arrays b/Lang/Brat/Hash-from-two-arrays new file mode 120000 index 0000000000..888c88c73b --- /dev/null +++ b/Lang/Brat/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Brat \ No newline at end of file diff --git a/Lang/Brat/Hello-world-Text b/Lang/Brat/Hello-world-Text new file mode 120000 index 0000000000..b461a1eaec --- /dev/null +++ b/Lang/Brat/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Brat \ No newline at end of file diff --git a/Lang/Brat/Higher-order-functions b/Lang/Brat/Higher-order-functions new file mode 120000 index 0000000000..657b890e08 --- /dev/null +++ b/Lang/Brat/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Brat \ No newline at end of file diff --git a/Lang/Brat/Increment-a-numerical-string b/Lang/Brat/Increment-a-numerical-string new file mode 120000 index 0000000000..cfef129533 --- /dev/null +++ b/Lang/Brat/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Brat \ No newline at end of file diff --git a/Lang/Brat/Integer-sequence b/Lang/Brat/Integer-sequence new file mode 120000 index 0000000000..19b9c4fb98 --- /dev/null +++ b/Lang/Brat/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Brat \ No newline at end of file diff --git a/Lang/Brat/Interactive-programming b/Lang/Brat/Interactive-programming new file mode 120000 index 0000000000..ad0eeb0cf6 --- /dev/null +++ b/Lang/Brat/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Brat \ No newline at end of file diff --git a/Lang/Brat/Kaprekar-numbers b/Lang/Brat/Kaprekar-numbers new file mode 120000 index 0000000000..9574fc7173 --- /dev/null +++ b/Lang/Brat/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Brat \ No newline at end of file diff --git a/Lang/Brat/Logical-operations b/Lang/Brat/Logical-operations new file mode 120000 index 0000000000..64875a53d8 --- /dev/null +++ b/Lang/Brat/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Brat \ No newline at end of file diff --git a/Lang/Brat/Loops-Downward-for b/Lang/Brat/Loops-Downward-for new file mode 120000 index 0000000000..c046255e65 --- /dev/null +++ b/Lang/Brat/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Brat \ No newline at end of file diff --git a/Lang/Brat/Loops-For b/Lang/Brat/Loops-For new file mode 120000 index 0000000000..d6371ee0bf --- /dev/null +++ b/Lang/Brat/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Brat \ No newline at end of file diff --git a/Lang/Brat/Loops-Infinite b/Lang/Brat/Loops-Infinite new file mode 120000 index 0000000000..74cc3a78af --- /dev/null +++ b/Lang/Brat/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Brat \ No newline at end of file diff --git a/Lang/Brat/Loops-While b/Lang/Brat/Loops-While new file mode 120000 index 0000000000..bbe9af8946 --- /dev/null +++ b/Lang/Brat/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Brat \ No newline at end of file diff --git a/Lang/Brat/Menu b/Lang/Brat/Menu new file mode 120000 index 0000000000..af89405487 --- /dev/null +++ b/Lang/Brat/Menu @@ -0,0 +1 @@ +../../Task/Menu/Brat \ No newline at end of file diff --git a/Lang/Brat/Multiple-distinct-objects b/Lang/Brat/Multiple-distinct-objects new file mode 120000 index 0000000000..230e7c30d4 --- /dev/null +++ b/Lang/Brat/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Brat \ No newline at end of file diff --git a/Lang/Brat/Mutual-recursion b/Lang/Brat/Mutual-recursion new file mode 120000 index 0000000000..71257ce0cc --- /dev/null +++ b/Lang/Brat/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Brat \ No newline at end of file diff --git a/Lang/Brlcad/Hello-world-Text b/Lang/Brlcad/Hello-world-Text new file mode 120000 index 0000000000..6ad844035e --- /dev/null +++ b/Lang/Brlcad/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Brlcad \ No newline at end of file diff --git a/Lang/Burlesque/Factorial b/Lang/Burlesque/Factorial new file mode 120000 index 0000000000..7e6b2c0d0f --- /dev/null +++ b/Lang/Burlesque/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Fibonacci-sequence b/Lang/Burlesque/Fibonacci-sequence new file mode 120000 index 0000000000..7347f59f45 --- /dev/null +++ b/Lang/Burlesque/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Filter b/Lang/Burlesque/Filter new file mode 120000 index 0000000000..4d91630ad1 --- /dev/null +++ b/Lang/Burlesque/Filter @@ -0,0 +1 @@ +../../Task/Filter/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Find-the-missing-permutation b/Lang/Burlesque/Find-the-missing-permutation new file mode 120000 index 0000000000..350e55dd68 --- /dev/null +++ b/Lang/Burlesque/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Flatten-a-list b/Lang/Burlesque/Flatten-a-list new file mode 120000 index 0000000000..5b295657ac --- /dev/null +++ b/Lang/Burlesque/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Generic-swap b/Lang/Burlesque/Generic-swap new file mode 120000 index 0000000000..0c3999babe --- /dev/null +++ b/Lang/Burlesque/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Greatest-element-of-a-list b/Lang/Burlesque/Greatest-element-of-a-list new file mode 120000 index 0000000000..68b33a3dca --- /dev/null +++ b/Lang/Burlesque/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Hailstone-sequence b/Lang/Burlesque/Hailstone-sequence new file mode 120000 index 0000000000..4ac0e656ee --- /dev/null +++ b/Lang/Burlesque/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Hello-world-Text b/Lang/Burlesque/Hello-world-Text new file mode 120000 index 0000000000..22db9e71ba --- /dev/null +++ b/Lang/Burlesque/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Higher-order-functions b/Lang/Burlesque/Higher-order-functions new file mode 120000 index 0000000000..8576acaf3e --- /dev/null +++ b/Lang/Burlesque/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Identity-matrix b/Lang/Burlesque/Identity-matrix new file mode 120000 index 0000000000..790598cde4 --- /dev/null +++ b/Lang/Burlesque/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Increment-a-numerical-string b/Lang/Burlesque/Increment-a-numerical-string new file mode 120000 index 0000000000..89dddf07b1 --- /dev/null +++ b/Lang/Burlesque/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Integer-comparison b/Lang/Burlesque/Integer-comparison new file mode 120000 index 0000000000..2d53e139d3 --- /dev/null +++ b/Lang/Burlesque/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Integer-sequence b/Lang/Burlesque/Integer-sequence new file mode 120000 index 0000000000..6def9e655f --- /dev/null +++ b/Lang/Burlesque/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Interactive-programming b/Lang/Burlesque/Interactive-programming new file mode 120000 index 0000000000..f4e4708a9a --- /dev/null +++ b/Lang/Burlesque/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Matrix-multiplication b/Lang/Burlesque/Matrix-multiplication new file mode 120000 index 0000000000..efc4957bc6 --- /dev/null +++ b/Lang/Burlesque/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Matrix-transposition b/Lang/Burlesque/Matrix-transposition new file mode 120000 index 0000000000..ac6fa8dc29 --- /dev/null +++ b/Lang/Burlesque/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Burlesque \ No newline at end of file diff --git a/Lang/C++-CLI/Hello-world-Graphical b/Lang/C++-CLI/Hello-world-Graphical new file mode 120000 index 0000000000..0522f58317 --- /dev/null +++ b/Lang/C++-CLI/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/C++-CLI \ No newline at end of file diff --git a/Lang/C++-CLI/Hello-world-Text b/Lang/C++-CLI/Hello-world-Text new file mode 120000 index 0000000000..3df386c987 --- /dev/null +++ b/Lang/C++-CLI/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/C++-CLI \ No newline at end of file diff --git a/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N b/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N new file mode 120000 index 0000000000..db20267163 --- /dev/null +++ b/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++ \ No newline at end of file diff --git a/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 b/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 new file mode 120000 index 0000000000..dcff703dc9 --- /dev/null +++ b/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++ \ No newline at end of file diff --git a/Lang/C++/Factorial b/Lang/C++/Factorial new file mode 120000 index 0000000000..cfcebe39ee --- /dev/null +++ b/Lang/C++/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/C++ \ No newline at end of file diff --git a/Lang/C++/Factors-of-an-integer b/Lang/C++/Factors-of-an-integer new file mode 120000 index 0000000000..a0e6d9aaaf --- /dev/null +++ b/Lang/C++/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/C++ \ No newline at end of file diff --git a/Lang/C++/Fast-Fourier-transform b/Lang/C++/Fast-Fourier-transform new file mode 120000 index 0000000000..ba8de55849 --- /dev/null +++ b/Lang/C++/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/C++ \ No newline at end of file diff --git a/Lang/C++/Fibonacci-n-step-number-sequences b/Lang/C++/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..07d7a668b8 --- /dev/null +++ b/Lang/C++/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/C++ \ No newline at end of file diff --git a/Lang/C++/Fibonacci-sequence b/Lang/C++/Fibonacci-sequence new file mode 120000 index 0000000000..ec1e2bcfc3 --- /dev/null +++ b/Lang/C++/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/File-IO b/Lang/C++/File-IO new file mode 120000 index 0000000000..4c9a81c000 --- /dev/null +++ b/Lang/C++/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/C++ \ No newline at end of file diff --git a/Lang/C++/File-modification-time b/Lang/C++/File-modification-time new file mode 120000 index 0000000000..7e2fc4a13d --- /dev/null +++ b/Lang/C++/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/C++ \ No newline at end of file diff --git a/Lang/C++/File-size b/Lang/C++/File-size new file mode 120000 index 0000000000..e8cad7fe79 --- /dev/null +++ b/Lang/C++/File-size @@ -0,0 +1 @@ +../../Task/File-size/C++ \ No newline at end of file diff --git a/Lang/C++/Filter b/Lang/C++/Filter new file mode 120000 index 0000000000..366eb7636d --- /dev/null +++ b/Lang/C++/Filter @@ -0,0 +1 @@ +../../Task/Filter/C++ \ No newline at end of file diff --git a/Lang/C++/Find-common-directory-path b/Lang/C++/Find-common-directory-path new file mode 120000 index 0000000000..6b26b9f637 --- /dev/null +++ b/Lang/C++/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/C++ \ No newline at end of file diff --git a/Lang/C++/Find-the-missing-permutation b/Lang/C++/Find-the-missing-permutation new file mode 120000 index 0000000000..cf1128b2f0 --- /dev/null +++ b/Lang/C++/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/C++ \ No newline at end of file diff --git a/Lang/C++/First-class-functions b/Lang/C++/First-class-functions new file mode 120000 index 0000000000..83b2523e24 --- /dev/null +++ b/Lang/C++/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/C++ \ No newline at end of file diff --git a/Lang/C++/Five-weekends b/Lang/C++/Five-weekends new file mode 120000 index 0000000000..9cb3f8622a --- /dev/null +++ b/Lang/C++/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/C++ \ No newline at end of file diff --git a/Lang/C++/Flatten-a-list b/Lang/C++/Flatten-a-list new file mode 120000 index 0000000000..840a908e06 --- /dev/null +++ b/Lang/C++/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/C++ \ No newline at end of file diff --git a/Lang/C++/Flow-control-structures b/Lang/C++/Flow-control-structures new file mode 120000 index 0000000000..48d172775d --- /dev/null +++ b/Lang/C++/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/C++ \ No newline at end of file diff --git a/Lang/C++/Fork b/Lang/C++/Fork new file mode 120000 index 0000000000..a26490b5c1 --- /dev/null +++ b/Lang/C++/Fork @@ -0,0 +1 @@ +../../Task/Fork/C++ \ No newline at end of file diff --git a/Lang/C++/Formatted-numeric-output b/Lang/C++/Formatted-numeric-output new file mode 120000 index 0000000000..bbe4524145 --- /dev/null +++ b/Lang/C++/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/C++ \ No newline at end of file diff --git a/Lang/C++/Forward-difference b/Lang/C++/Forward-difference new file mode 120000 index 0000000000..b2a8e0e876 --- /dev/null +++ b/Lang/C++/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/C++ \ No newline at end of file diff --git a/Lang/C++/Function-composition b/Lang/C++/Function-composition new file mode 120000 index 0000000000..0282d4dc51 --- /dev/null +++ b/Lang/C++/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/C++ \ No newline at end of file diff --git a/Lang/C++/Function-definition b/Lang/C++/Function-definition new file mode 120000 index 0000000000..30b31bf442 --- /dev/null +++ b/Lang/C++/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/C++ \ No newline at end of file diff --git a/Lang/C++/GUI-component-interaction b/Lang/C++/GUI-component-interaction new file mode 120000 index 0000000000..deac39b468 --- /dev/null +++ b/Lang/C++/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/C++ \ No newline at end of file diff --git a/Lang/C++/GUI-enabling-disabling-of-controls b/Lang/C++/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..0a57da45f8 --- /dev/null +++ b/Lang/C++/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/C++ \ No newline at end of file diff --git a/Lang/C++/Generator-Exponential b/Lang/C++/Generator-Exponential new file mode 120000 index 0000000000..bd8f2a6bac --- /dev/null +++ b/Lang/C++/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/C++ \ No newline at end of file diff --git a/Lang/C++/Generic-swap b/Lang/C++/Generic-swap new file mode 120000 index 0000000000..574b5bd089 --- /dev/null +++ b/Lang/C++/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/C++ \ No newline at end of file diff --git a/Lang/C++/Globally-replace-text-in-several-files b/Lang/C++/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..ecd6c3a4e0 --- /dev/null +++ b/Lang/C++/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/C++ \ No newline at end of file diff --git a/Lang/C++/Gray-code b/Lang/C++/Gray-code new file mode 120000 index 0000000000..e808c59eb2 --- /dev/null +++ b/Lang/C++/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/C++ \ No newline at end of file diff --git a/Lang/C++/Greatest-element-of-a-list b/Lang/C++/Greatest-element-of-a-list new file mode 120000 index 0000000000..c33883828c --- /dev/null +++ b/Lang/C++/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/C++ \ No newline at end of file diff --git a/Lang/C++/Greatest-subsequential-sum b/Lang/C++/Greatest-subsequential-sum new file mode 120000 index 0000000000..4a6daaa89a --- /dev/null +++ b/Lang/C++/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/C++ \ No newline at end of file diff --git a/Lang/C++/Greyscale-bars-Display b/Lang/C++/Greyscale-bars-Display new file mode 120000 index 0000000000..b7cb279330 --- /dev/null +++ b/Lang/C++/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/C++ \ No newline at end of file diff --git a/Lang/C++/Guess-the-number b/Lang/C++/Guess-the-number new file mode 120000 index 0000000000..828bc51bc9 --- /dev/null +++ b/Lang/C++/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/C++ \ No newline at end of file diff --git a/Lang/C++/Guess-the-number-With-feedback b/Lang/C++/Guess-the-number-With-feedback new file mode 120000 index 0000000000..756ccc87f0 --- /dev/null +++ b/Lang/C++/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/C++ \ No newline at end of file diff --git a/Lang/C++/Guess-the-number-With-feedback-player b/Lang/C++/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..7cfb075480 --- /dev/null +++ b/Lang/C++/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/C++ \ No newline at end of file diff --git a/Lang/C++/HTTP b/Lang/C++/HTTP new file mode 120000 index 0000000000..c267e6916d --- /dev/null +++ b/Lang/C++/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/C++ \ No newline at end of file diff --git a/Lang/C++/Hailstone-sequence b/Lang/C++/Hailstone-sequence new file mode 120000 index 0000000000..cb2d40ff59 --- /dev/null +++ b/Lang/C++/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/Hamming-numbers b/Lang/C++/Hamming-numbers new file mode 120000 index 0000000000..cd49f14ba8 --- /dev/null +++ b/Lang/C++/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/Happy-numbers b/Lang/C++/Happy-numbers new file mode 120000 index 0000000000..8ff48555b6 --- /dev/null +++ b/Lang/C++/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/Hash-from-two-arrays b/Lang/C++/Hash-from-two-arrays new file mode 120000 index 0000000000..7e053fad0c --- /dev/null +++ b/Lang/C++/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/C++ \ No newline at end of file diff --git a/Lang/C++/Hello-world-Graphical b/Lang/C++/Hello-world-Graphical new file mode 120000 index 0000000000..b7404b8303 --- /dev/null +++ b/Lang/C++/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/C++ \ No newline at end of file diff --git a/Lang/C++/Hello-world-Line-printer b/Lang/C++/Hello-world-Line-printer new file mode 120000 index 0000000000..2dc75310d3 --- /dev/null +++ b/Lang/C++/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/C++ \ No newline at end of file diff --git a/Lang/C++/Hello-world-Newline-omission b/Lang/C++/Hello-world-Newline-omission new file mode 120000 index 0000000000..d65316cfaf --- /dev/null +++ b/Lang/C++/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/C++ \ No newline at end of file diff --git a/Lang/C++/Hello-world-Standard-error b/Lang/C++/Hello-world-Standard-error new file mode 120000 index 0000000000..1cc3b5024f --- /dev/null +++ b/Lang/C++/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/C++ \ No newline at end of file diff --git a/Lang/C++/Hello-world-Text b/Lang/C++/Hello-world-Text new file mode 120000 index 0000000000..f82813d2f8 --- /dev/null +++ b/Lang/C++/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/C++ \ No newline at end of file diff --git a/Lang/C++/Higher-order-functions b/Lang/C++/Higher-order-functions new file mode 120000 index 0000000000..a8e16fcd43 --- /dev/null +++ b/Lang/C++/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/C++ \ No newline at end of file diff --git a/Lang/C++/Hofstadter-Conway-$10,000-sequence b/Lang/C++/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..49419b8aaf --- /dev/null +++ b/Lang/C++/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/Hofstadter-Q-sequence b/Lang/C++/Hofstadter-Q-sequence new file mode 120000 index 0000000000..faaa088f65 --- /dev/null +++ b/Lang/C++/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/Horners-rule-for-polynomial-evaluation b/Lang/C++/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..53f977da4d --- /dev/null +++ b/Lang/C++/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/C++ \ No newline at end of file diff --git a/Lang/C++/Huffman-coding b/Lang/C++/Huffman-coding new file mode 120000 index 0000000000..3d3d5bf991 --- /dev/null +++ b/Lang/C++/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/C++ \ No newline at end of file diff --git a/Lang/C++/Increment-a-numerical-string b/Lang/C++/Increment-a-numerical-string new file mode 120000 index 0000000000..a0ffc3d227 --- /dev/null +++ b/Lang/C++/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/C++ \ No newline at end of file diff --git a/Lang/C++/Inheritance-Multiple b/Lang/C++/Inheritance-Multiple new file mode 120000 index 0000000000..f0b9660c02 --- /dev/null +++ b/Lang/C++/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/C++ \ No newline at end of file diff --git a/Lang/C++/Inheritance-Single b/Lang/C++/Inheritance-Single new file mode 120000 index 0000000000..ad279d9ea0 --- /dev/null +++ b/Lang/C++/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/C++ \ No newline at end of file diff --git a/Lang/C++/Input-loop b/Lang/C++/Input-loop new file mode 120000 index 0000000000..7029a15058 --- /dev/null +++ b/Lang/C++/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/C++ \ No newline at end of file diff --git a/Lang/C++/Integer-comparison b/Lang/C++/Integer-comparison new file mode 120000 index 0000000000..95464bb637 --- /dev/null +++ b/Lang/C++/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/C++ \ No newline at end of file diff --git a/Lang/C++/Integer-sequence b/Lang/C++/Integer-sequence new file mode 120000 index 0000000000..a4b29e0a94 --- /dev/null +++ b/Lang/C++/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/Jensens-Device b/Lang/C++/Jensens-Device new file mode 120000 index 0000000000..0f85774321 --- /dev/null +++ b/Lang/C++/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/C++ \ No newline at end of file diff --git a/Lang/C++/Kaprekar-numbers b/Lang/C++/Kaprekar-numbers new file mode 120000 index 0000000000..e3f6665d04 --- /dev/null +++ b/Lang/C++/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/Knapsack-problem-0-1 b/Lang/C++/Knapsack-problem-0-1 new file mode 120000 index 0000000000..c8229b8d6e --- /dev/null +++ b/Lang/C++/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/C++ \ No newline at end of file diff --git a/Lang/C++/Knapsack-problem-Bounded b/Lang/C++/Knapsack-problem-Bounded new file mode 120000 index 0000000000..2dc16ae325 --- /dev/null +++ b/Lang/C++/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/C++ \ No newline at end of file diff --git a/Lang/C++/Knapsack-problem-Continuous b/Lang/C++/Knapsack-problem-Continuous new file mode 120000 index 0000000000..b60e5b875b --- /dev/null +++ b/Lang/C++/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/C++ \ No newline at end of file diff --git a/Lang/C++/Knights-tour b/Lang/C++/Knights-tour new file mode 120000 index 0000000000..7b8a92a329 --- /dev/null +++ b/Lang/C++/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/C++ \ No newline at end of file diff --git a/Lang/C++/Knuths-algorithm-S b/Lang/C++/Knuths-algorithm-S new file mode 120000 index 0000000000..a32751ea80 --- /dev/null +++ b/Lang/C++/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/C++ \ No newline at end of file diff --git a/Lang/C++/LZW-compression b/Lang/C++/LZW-compression new file mode 120000 index 0000000000..dd5b09c333 --- /dev/null +++ b/Lang/C++/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/C++ \ No newline at end of file diff --git a/Lang/C++/Last-Friday-of-each-month b/Lang/C++/Last-Friday-of-each-month new file mode 120000 index 0000000000..4573236b48 --- /dev/null +++ b/Lang/C++/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/C++ \ No newline at end of file diff --git a/Lang/C++/Least-common-multiple b/Lang/C++/Least-common-multiple new file mode 120000 index 0000000000..6c9fc84721 --- /dev/null +++ b/Lang/C++/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/C++ \ No newline at end of file diff --git a/Lang/C++/Letter-frequency b/Lang/C++/Letter-frequency new file mode 120000 index 0000000000..0e88694a13 --- /dev/null +++ b/Lang/C++/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/C++ \ No newline at end of file diff --git a/Lang/C++/Levenshtein-distance b/Lang/C++/Levenshtein-distance new file mode 120000 index 0000000000..625244f6d7 --- /dev/null +++ b/Lang/C++/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/C++ \ No newline at end of file diff --git a/Lang/C++/List-comprehensions b/Lang/C++/List-comprehensions new file mode 120000 index 0000000000..7c59d3c7f0 --- /dev/null +++ b/Lang/C++/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/C++ \ No newline at end of file diff --git a/Lang/C++/Literals-Integer b/Lang/C++/Literals-Integer new file mode 120000 index 0000000000..5acbb1b351 --- /dev/null +++ b/Lang/C++/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/C++ \ No newline at end of file diff --git a/Lang/C++/Logical-operations b/Lang/C++/Logical-operations new file mode 120000 index 0000000000..ca905b5cf6 --- /dev/null +++ b/Lang/C++/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/C++ \ No newline at end of file diff --git a/Lang/C++/Long-multiplication b/Lang/C++/Long-multiplication new file mode 120000 index 0000000000..ccc7c4e2df --- /dev/null +++ b/Lang/C++/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/C++ \ No newline at end of file diff --git a/Lang/C++/Look-and-say-sequence b/Lang/C++/Look-and-say-sequence new file mode 120000 index 0000000000..0a3862a0df --- /dev/null +++ b/Lang/C++/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/C++ \ No newline at end of file diff --git a/Lang/C++/Loop-over-multiple-arrays-simultaneously b/Lang/C++/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..20e6de2736 --- /dev/null +++ b/Lang/C++/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Break b/Lang/C++/Loops-Break new file mode 120000 index 0000000000..63c4e54fec --- /dev/null +++ b/Lang/C++/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Continue b/Lang/C++/Loops-Continue new file mode 120000 index 0000000000..c46f25b1d0 --- /dev/null +++ b/Lang/C++/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Do-while b/Lang/C++/Loops-Do-while new file mode 120000 index 0000000000..03c3e1d9aa --- /dev/null +++ b/Lang/C++/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Downward-for b/Lang/C++/Loops-Downward-for new file mode 120000 index 0000000000..5cfc4507d3 --- /dev/null +++ b/Lang/C++/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-For b/Lang/C++/Loops-For new file mode 120000 index 0000000000..f769832829 --- /dev/null +++ b/Lang/C++/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-For-with-a-specified-step b/Lang/C++/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..3dd816b397 --- /dev/null +++ b/Lang/C++/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Foreach b/Lang/C++/Loops-Foreach new file mode 120000 index 0000000000..4ab637dbd3 --- /dev/null +++ b/Lang/C++/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Infinite b/Lang/C++/Loops-Infinite new file mode 120000 index 0000000000..268eeb996e --- /dev/null +++ b/Lang/C++/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-N-plus-one-half b/Lang/C++/Loops-N-plus-one-half new file mode 120000 index 0000000000..90b73d84d7 --- /dev/null +++ b/Lang/C++/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-Nested b/Lang/C++/Loops-Nested new file mode 120000 index 0000000000..c08d0c8339 --- /dev/null +++ b/Lang/C++/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/C++ \ No newline at end of file diff --git a/Lang/C++/Loops-While b/Lang/C++/Loops-While new file mode 120000 index 0000000000..6c2db1e189 --- /dev/null +++ b/Lang/C++/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/C++ \ No newline at end of file diff --git a/Lang/C++/Lucas-Lehmer-test b/Lang/C++/Lucas-Lehmer-test new file mode 120000 index 0000000000..6f9448bb89 --- /dev/null +++ b/Lang/C++/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/C++ \ No newline at end of file diff --git a/Lang/C++/Luhn-test-of-credit-card-numbers b/Lang/C++/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..25ad5d84f4 --- /dev/null +++ b/Lang/C++/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/MD5 b/Lang/C++/MD5 new file mode 120000 index 0000000000..5dbba4583d --- /dev/null +++ b/Lang/C++/MD5 @@ -0,0 +1 @@ +../../Task/MD5/C++ \ No newline at end of file diff --git a/Lang/C++/Main-step-of-GOST-28147-89 b/Lang/C++/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..fe8bb626fa --- /dev/null +++ b/Lang/C++/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/C++ \ No newline at end of file diff --git a/Lang/C++/Man-or-boy-test b/Lang/C++/Man-or-boy-test new file mode 120000 index 0000000000..c250001645 --- /dev/null +++ b/Lang/C++/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/C++ \ No newline at end of file diff --git a/Lang/C++/Mandelbrot-set b/Lang/C++/Mandelbrot-set new file mode 120000 index 0000000000..4d5ac169a8 --- /dev/null +++ b/Lang/C++/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/C++ \ No newline at end of file diff --git a/Lang/C++/Map-range b/Lang/C++/Map-range new file mode 120000 index 0000000000..6b0501fc88 --- /dev/null +++ b/Lang/C++/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/C++ \ No newline at end of file diff --git a/Lang/C++/Matrix-exponentiation-operator b/Lang/C++/Matrix-exponentiation-operator new file mode 120000 index 0000000000..c80e0e63b9 --- /dev/null +++ b/Lang/C++/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/C++ \ No newline at end of file diff --git a/Lang/C++/Matrix-multiplication b/Lang/C++/Matrix-multiplication new file mode 120000 index 0000000000..eae39b0df0 --- /dev/null +++ b/Lang/C++/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/C++ \ No newline at end of file diff --git a/Lang/C++/Matrix-transposition b/Lang/C++/Matrix-transposition new file mode 120000 index 0000000000..1241068c99 --- /dev/null +++ b/Lang/C++/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/C++ \ No newline at end of file diff --git a/Lang/C++/Memory-allocation b/Lang/C++/Memory-allocation new file mode 120000 index 0000000000..ace7e2fb11 --- /dev/null +++ b/Lang/C++/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/C++ \ No newline at end of file diff --git a/Lang/C++/Menu b/Lang/C++/Menu new file mode 120000 index 0000000000..0daa55cc8d --- /dev/null +++ b/Lang/C++/Menu @@ -0,0 +1 @@ +../../Task/Menu/C++ \ No newline at end of file diff --git a/Lang/C++/Middle-three-digits b/Lang/C++/Middle-three-digits new file mode 120000 index 0000000000..6cbdfbafa9 --- /dev/null +++ b/Lang/C++/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/C++ \ No newline at end of file diff --git a/Lang/C++/Monty-Hall-problem b/Lang/C++/Monty-Hall-problem new file mode 120000 index 0000000000..908e19f731 --- /dev/null +++ b/Lang/C++/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/C++ \ No newline at end of file diff --git a/Lang/C++/Multifactorial b/Lang/C++/Multifactorial new file mode 120000 index 0000000000..7024c5c9fe --- /dev/null +++ b/Lang/C++/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/C++ \ No newline at end of file diff --git a/Lang/C++/Multiple-distinct-objects b/Lang/C++/Multiple-distinct-objects new file mode 120000 index 0000000000..214eca5a6b --- /dev/null +++ b/Lang/C++/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/C++ \ No newline at end of file diff --git a/Lang/C++/Multiplication-tables b/Lang/C++/Multiplication-tables new file mode 120000 index 0000000000..eaa33c1f8b --- /dev/null +++ b/Lang/C++/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/C++ \ No newline at end of file diff --git a/Lang/C++/Multisplit b/Lang/C++/Multisplit new file mode 120000 index 0000000000..c9efa81bfb --- /dev/null +++ b/Lang/C++/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/C++ \ No newline at end of file diff --git a/Lang/C++/Mutual-recursion b/Lang/C++/Mutual-recursion new file mode 120000 index 0000000000..e3df71f1d3 --- /dev/null +++ b/Lang/C++/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/C++ \ No newline at end of file diff --git a/Lang/C-sharp/Arbitrary-precision-integers-included b/Lang/C-sharp/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..31bcb5946e --- /dev/null +++ b/Lang/C-sharp/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Factors-of-a-Mersenne-number b/Lang/C-sharp/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..03ebff1cc3 --- /dev/null +++ b/Lang/C-sharp/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Forward-difference b/Lang/C-sharp/Forward-difference new file mode 120000 index 0000000000..88039ef3d6 --- /dev/null +++ b/Lang/C-sharp/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Generator-Exponential b/Lang/C-sharp/Generator-Exponential new file mode 120000 index 0000000000..514951c593 --- /dev/null +++ b/Lang/C-sharp/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Gray-code b/Lang/C-sharp/Gray-code new file mode 120000 index 0000000000..1c366aedff --- /dev/null +++ b/Lang/C-sharp/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Guess-the-number b/Lang/C-sharp/Guess-the-number new file mode 120000 index 0000000000..9fbb06bf79 --- /dev/null +++ b/Lang/C-sharp/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Guess-the-number-With-feedback b/Lang/C-sharp/Guess-the-number-With-feedback new file mode 120000 index 0000000000..bcd79d225e --- /dev/null +++ b/Lang/C-sharp/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/HTTP b/Lang/C-sharp/HTTP new file mode 120000 index 0000000000..9310b34395 --- /dev/null +++ b/Lang/C-sharp/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Handle-a-signal b/Lang/C-sharp/Handle-a-signal new file mode 120000 index 0000000000..0421379b5c --- /dev/null +++ b/Lang/C-sharp/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Hash-from-two-arrays b/Lang/C-sharp/Hash-from-two-arrays new file mode 120000 index 0000000000..d6bdc70f31 --- /dev/null +++ b/Lang/C-sharp/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Here-document b/Lang/C-sharp/Here-document new file mode 120000 index 0000000000..c000a1f846 --- /dev/null +++ b/Lang/C-sharp/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Higher-order-functions b/Lang/C-sharp/Higher-order-functions new file mode 120000 index 0000000000..795a70e5ef --- /dev/null +++ b/Lang/C-sharp/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/History-variables b/Lang/C-sharp/History-variables new file mode 120000 index 0000000000..0720105c5b --- /dev/null +++ b/Lang/C-sharp/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Hofstadter-Q-sequence b/Lang/C-sharp/Hofstadter-Q-sequence new file mode 120000 index 0000000000..ee27e89e5c --- /dev/null +++ b/Lang/C-sharp/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Holidays-related-to-Easter b/Lang/C-sharp/Holidays-related-to-Easter new file mode 120000 index 0000000000..19c1f44c62 --- /dev/null +++ b/Lang/C-sharp/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Honeycombs b/Lang/C-sharp/Honeycombs new file mode 120000 index 0000000000..07efd2012c --- /dev/null +++ b/Lang/C-sharp/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Host-introspection b/Lang/C-sharp/Host-introspection new file mode 120000 index 0000000000..c6deb12c46 --- /dev/null +++ b/Lang/C-sharp/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Huffman-coding b/Lang/C-sharp/Huffman-coding new file mode 120000 index 0000000000..8c9e2bd45f --- /dev/null +++ b/Lang/C-sharp/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Identity-matrix b/Lang/C-sharp/Identity-matrix new file mode 120000 index 0000000000..ec2e1e92d1 --- /dev/null +++ b/Lang/C-sharp/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Include-a-file b/Lang/C-sharp/Include-a-file new file mode 120000 index 0000000000..054632acac --- /dev/null +++ b/Lang/C-sharp/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Jensens-Device b/Lang/C-sharp/Jensens-Device new file mode 120000 index 0000000000..7e991b6d0b --- /dev/null +++ b/Lang/C-sharp/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/C-sharp/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..445b9cbf04 --- /dev/null +++ b/Lang/C-sharp/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Knights-tour b/Lang/C-sharp/Knights-tour new file mode 120000 index 0000000000..6da098eb40 --- /dev/null +++ b/Lang/C-sharp/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/LZW-compression b/Lang/C-sharp/LZW-compression new file mode 120000 index 0000000000..48e0219d5f --- /dev/null +++ b/Lang/C-sharp/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Last-Friday-of-each-month b/Lang/C-sharp/Last-Friday-of-each-month new file mode 120000 index 0000000000..4f8986a65e --- /dev/null +++ b/Lang/C-sharp/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Last-letter-first-letter b/Lang/C-sharp/Last-letter-first-letter new file mode 120000 index 0000000000..9d1cf83747 --- /dev/null +++ b/Lang/C-sharp/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Letter-frequency b/Lang/C-sharp/Letter-frequency new file mode 120000 index 0000000000..c691d3fe4a --- /dev/null +++ b/Lang/C-sharp/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/MD5-Implementation b/Lang/C-sharp/MD5-Implementation new file mode 120000 index 0000000000..4d4c8b074d --- /dev/null +++ b/Lang/C-sharp/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Menu b/Lang/C-sharp/Menu new file mode 120000 index 0000000000..7134333845 --- /dev/null +++ b/Lang/C-sharp/Menu @@ -0,0 +1 @@ +../../Task/Menu/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Metered-concurrency b/Lang/C-sharp/Metered-concurrency new file mode 120000 index 0000000000..58fa58fc22 --- /dev/null +++ b/Lang/C-sharp/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Multiplication-tables b/Lang/C-sharp/Multiplication-tables new file mode 120000 index 0000000000..a6be8ccbcb --- /dev/null +++ b/Lang/C-sharp/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Multisplit b/Lang/C-sharp/Multisplit new file mode 120000 index 0000000000..8defea4618 --- /dev/null +++ b/Lang/C-sharp/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/C-sharp \ No newline at end of file diff --git a/Lang/C/24-game-Solve b/Lang/C/24-game-Solve new file mode 120000 index 0000000000..e455b96db6 --- /dev/null +++ b/Lang/C/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/C \ No newline at end of file diff --git a/Lang/C/Arbitrary-precision-integers-included b/Lang/C/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..d8ca326673 --- /dev/null +++ b/Lang/C/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/C \ No newline at end of file diff --git a/Lang/C/Factorial b/Lang/C/Factorial new file mode 120000 index 0000000000..79957abe03 --- /dev/null +++ b/Lang/C/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/C \ No newline at end of file diff --git a/Lang/C/Factors-of-a-Mersenne-number b/Lang/C/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..38268baa4f --- /dev/null +++ b/Lang/C/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/C \ No newline at end of file diff --git a/Lang/C/Factors-of-an-integer b/Lang/C/Factors-of-an-integer new file mode 120000 index 0000000000..2449780104 --- /dev/null +++ b/Lang/C/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/C \ No newline at end of file diff --git a/Lang/C/Fast-Fourier-transform b/Lang/C/Fast-Fourier-transform new file mode 120000 index 0000000000..0e4538f720 --- /dev/null +++ b/Lang/C/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/C \ No newline at end of file diff --git a/Lang/C/Fibonacci-n-step-number-sequences b/Lang/C/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..202fde09c2 --- /dev/null +++ b/Lang/C/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/C \ No newline at end of file diff --git a/Lang/C/Fibonacci-sequence b/Lang/C/Fibonacci-sequence new file mode 120000 index 0000000000..03e8299be8 --- /dev/null +++ b/Lang/C/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/C \ No newline at end of file diff --git a/Lang/C/File-IO b/Lang/C/File-IO new file mode 120000 index 0000000000..9281bf6c1e --- /dev/null +++ b/Lang/C/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/C \ No newline at end of file diff --git a/Lang/C/File-modification-time b/Lang/C/File-modification-time new file mode 120000 index 0000000000..ebcded4a96 --- /dev/null +++ b/Lang/C/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/C \ No newline at end of file diff --git a/Lang/C/File-size b/Lang/C/File-size new file mode 120000 index 0000000000..3fea0dc966 --- /dev/null +++ b/Lang/C/File-size @@ -0,0 +1 @@ +../../Task/File-size/C \ No newline at end of file diff --git a/Lang/C/Filter b/Lang/C/Filter new file mode 120000 index 0000000000..c382e51c42 --- /dev/null +++ b/Lang/C/Filter @@ -0,0 +1 @@ +../../Task/Filter/C \ No newline at end of file diff --git a/Lang/C/Find-common-directory-path b/Lang/C/Find-common-directory-path new file mode 120000 index 0000000000..6a173875b7 --- /dev/null +++ b/Lang/C/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/C \ No newline at end of file diff --git a/Lang/C/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/C/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..9093a96d9c --- /dev/null +++ b/Lang/C/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/C \ No newline at end of file diff --git a/Lang/C/Find-limit-of-recursion b/Lang/C/Find-limit-of-recursion new file mode 120000 index 0000000000..7a36898592 --- /dev/null +++ b/Lang/C/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/C \ No newline at end of file diff --git a/Lang/C/Find-the-missing-permutation b/Lang/C/Find-the-missing-permutation new file mode 120000 index 0000000000..c336e45278 --- /dev/null +++ b/Lang/C/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/C \ No newline at end of file diff --git a/Lang/C/First-class-environments b/Lang/C/First-class-environments new file mode 120000 index 0000000000..ee622bda32 --- /dev/null +++ b/Lang/C/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/C \ No newline at end of file diff --git a/Lang/C/First-class-functions b/Lang/C/First-class-functions new file mode 120000 index 0000000000..e20a26207b --- /dev/null +++ b/Lang/C/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/C \ No newline at end of file diff --git a/Lang/C/Five-weekends b/Lang/C/Five-weekends new file mode 120000 index 0000000000..7be24b3920 --- /dev/null +++ b/Lang/C/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/C \ No newline at end of file diff --git a/Lang/C/Flatten-a-list b/Lang/C/Flatten-a-list new file mode 120000 index 0000000000..5123ba399e --- /dev/null +++ b/Lang/C/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/C \ No newline at end of file diff --git a/Lang/C/Flow-control-structures b/Lang/C/Flow-control-structures new file mode 120000 index 0000000000..ed9b228659 --- /dev/null +++ b/Lang/C/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/C \ No newline at end of file diff --git a/Lang/C/Floyds-triangle b/Lang/C/Floyds-triangle new file mode 120000 index 0000000000..33b187b0c5 --- /dev/null +++ b/Lang/C/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/C \ No newline at end of file diff --git a/Lang/C/Fork b/Lang/C/Fork new file mode 120000 index 0000000000..26f35342d4 --- /dev/null +++ b/Lang/C/Fork @@ -0,0 +1 @@ +../../Task/Fork/C \ No newline at end of file diff --git a/Lang/C/Formal-power-series b/Lang/C/Formal-power-series new file mode 120000 index 0000000000..347806ee2c --- /dev/null +++ b/Lang/C/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/C \ No newline at end of file diff --git a/Lang/C/Formatted-numeric-output b/Lang/C/Formatted-numeric-output new file mode 120000 index 0000000000..fd6d0fefda --- /dev/null +++ b/Lang/C/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/C \ No newline at end of file diff --git a/Lang/C/Forward-difference b/Lang/C/Forward-difference new file mode 120000 index 0000000000..60f5398458 --- /dev/null +++ b/Lang/C/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/C \ No newline at end of file diff --git a/Lang/C/Four-bit-adder b/Lang/C/Four-bit-adder new file mode 120000 index 0000000000..ba94fc12f9 --- /dev/null +++ b/Lang/C/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/C \ No newline at end of file diff --git a/Lang/C/Fractal-tree b/Lang/C/Fractal-tree new file mode 120000 index 0000000000..c8548c73a0 --- /dev/null +++ b/Lang/C/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/C \ No newline at end of file diff --git a/Lang/C/Function-composition b/Lang/C/Function-composition new file mode 120000 index 0000000000..deac56a72a --- /dev/null +++ b/Lang/C/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/C \ No newline at end of file diff --git a/Lang/C/Function-definition b/Lang/C/Function-definition new file mode 120000 index 0000000000..d3658f9d03 --- /dev/null +++ b/Lang/C/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/C \ No newline at end of file diff --git a/Lang/C/Function-frequency b/Lang/C/Function-frequency new file mode 120000 index 0000000000..587452c9ad --- /dev/null +++ b/Lang/C/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/C \ No newline at end of file diff --git a/Lang/C/Function-prototype b/Lang/C/Function-prototype new file mode 120000 index 0000000000..8c126f0f36 --- /dev/null +++ b/Lang/C/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/C \ No newline at end of file diff --git a/Lang/C/Galton-box-animation b/Lang/C/Galton-box-animation new file mode 120000 index 0000000000..14de389006 --- /dev/null +++ b/Lang/C/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/C \ No newline at end of file diff --git a/Lang/C/Gamma-function b/Lang/C/Gamma-function new file mode 120000 index 0000000000..19aa8a355b --- /dev/null +++ b/Lang/C/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/C \ No newline at end of file diff --git a/Lang/C/Generator-Exponential b/Lang/C/Generator-Exponential new file mode 120000 index 0000000000..8fe2b0640f --- /dev/null +++ b/Lang/C/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/C \ No newline at end of file diff --git a/Lang/C/Generic-swap b/Lang/C/Generic-swap new file mode 120000 index 0000000000..9d0febaea7 --- /dev/null +++ b/Lang/C/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/C \ No newline at end of file diff --git a/Lang/C/Globally-replace-text-in-several-files b/Lang/C/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..785f3c3629 --- /dev/null +++ b/Lang/C/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/C \ No newline at end of file diff --git a/Lang/C/Gray-code b/Lang/C/Gray-code new file mode 120000 index 0000000000..b6cb39e74e --- /dev/null +++ b/Lang/C/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/C \ No newline at end of file diff --git a/Lang/C/Grayscale-image b/Lang/C/Grayscale-image new file mode 120000 index 0000000000..cacc26e8b5 --- /dev/null +++ b/Lang/C/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/C \ No newline at end of file diff --git a/Lang/C/Greatest-common-divisor b/Lang/C/Greatest-common-divisor new file mode 120000 index 0000000000..9eca3e8f09 --- /dev/null +++ b/Lang/C/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/C \ No newline at end of file diff --git a/Lang/C/Greatest-element-of-a-list b/Lang/C/Greatest-element-of-a-list new file mode 120000 index 0000000000..8457fe876a --- /dev/null +++ b/Lang/C/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/C \ No newline at end of file diff --git a/Lang/C/Greatest-subsequential-sum b/Lang/C/Greatest-subsequential-sum new file mode 120000 index 0000000000..b9f8b518b4 --- /dev/null +++ b/Lang/C/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/C \ No newline at end of file diff --git a/Lang/C/Greyscale-bars-Display b/Lang/C/Greyscale-bars-Display new file mode 120000 index 0000000000..7f304ff72f --- /dev/null +++ b/Lang/C/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/C \ No newline at end of file diff --git a/Lang/C/Guess-the-number b/Lang/C/Guess-the-number new file mode 120000 index 0000000000..7baa828f46 --- /dev/null +++ b/Lang/C/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/C \ No newline at end of file diff --git a/Lang/C/Guess-the-number-With-feedback b/Lang/C/Guess-the-number-With-feedback new file mode 120000 index 0000000000..acbf443a5a --- /dev/null +++ b/Lang/C/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/C \ No newline at end of file diff --git a/Lang/C/Guess-the-number-With-feedback-player b/Lang/C/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..9c42d1c8d0 --- /dev/null +++ b/Lang/C/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/C \ No newline at end of file diff --git a/Lang/C/HTTP b/Lang/C/HTTP new file mode 120000 index 0000000000..63e5d1bfe7 --- /dev/null +++ b/Lang/C/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/C \ No newline at end of file diff --git a/Lang/C/HTTPS b/Lang/C/HTTPS new file mode 120000 index 0000000000..5e98fb1860 --- /dev/null +++ b/Lang/C/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/C \ No newline at end of file diff --git a/Lang/C/HTTPS-Authenticated b/Lang/C/HTTPS-Authenticated new file mode 120000 index 0000000000..8a916c0a7c --- /dev/null +++ b/Lang/C/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/C \ No newline at end of file diff --git a/Lang/C/Hailstone-sequence b/Lang/C/Hailstone-sequence new file mode 120000 index 0000000000..c8f496395f --- /dev/null +++ b/Lang/C/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/C \ No newline at end of file diff --git a/Lang/C/Hamming-numbers b/Lang/C/Hamming-numbers new file mode 120000 index 0000000000..2ff1fe8f16 --- /dev/null +++ b/Lang/C/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/C \ No newline at end of file diff --git a/Lang/C/Handle-a-signal b/Lang/C/Handle-a-signal new file mode 120000 index 0000000000..52a24a9bca --- /dev/null +++ b/Lang/C/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/C \ No newline at end of file diff --git a/Lang/C/Happy-numbers b/Lang/C/Happy-numbers new file mode 120000 index 0000000000..749285f7ba --- /dev/null +++ b/Lang/C/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/C \ No newline at end of file diff --git a/Lang/C/Harshad-or-Niven-series b/Lang/C/Harshad-or-Niven-series new file mode 120000 index 0000000000..cdd348ae5a --- /dev/null +++ b/Lang/C/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/C \ No newline at end of file diff --git a/Lang/C/Hash-from-two-arrays b/Lang/C/Hash-from-two-arrays new file mode 120000 index 0000000000..ffd4eacdeb --- /dev/null +++ b/Lang/C/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/C \ No newline at end of file diff --git a/Lang/C/Haversine-formula b/Lang/C/Haversine-formula new file mode 120000 index 0000000000..8e27efa246 --- /dev/null +++ b/Lang/C/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Graphical b/Lang/C/Hello-world-Graphical new file mode 120000 index 0000000000..8431033228 --- /dev/null +++ b/Lang/C/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Line-printer b/Lang/C/Hello-world-Line-printer new file mode 120000 index 0000000000..72e8511a2f --- /dev/null +++ b/Lang/C/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Newline-omission b/Lang/C/Hello-world-Newline-omission new file mode 120000 index 0000000000..eb52f0f645 --- /dev/null +++ b/Lang/C/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Standard-error b/Lang/C/Hello-world-Standard-error new file mode 120000 index 0000000000..428588458e --- /dev/null +++ b/Lang/C/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Text b/Lang/C/Hello-world-Text new file mode 120000 index 0000000000..2abb3e37ab --- /dev/null +++ b/Lang/C/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/C \ No newline at end of file diff --git a/Lang/C/Hello-world-Web-server b/Lang/C/Hello-world-Web-server new file mode 120000 index 0000000000..d0d8da81a1 --- /dev/null +++ b/Lang/C/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/C \ No newline at end of file diff --git a/Lang/C/Higher-order-functions b/Lang/C/Higher-order-functions new file mode 120000 index 0000000000..94b7c2f0b3 --- /dev/null +++ b/Lang/C/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/C \ No newline at end of file diff --git a/Lang/C/Hofstadter-Conway-$10,000-sequence b/Lang/C/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..bcf002fa8d --- /dev/null +++ b/Lang/C/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/C \ No newline at end of file diff --git a/Lang/C/Hofstadter-Figure-Figure-sequences b/Lang/C/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..f2729fc7e4 --- /dev/null +++ b/Lang/C/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/C \ No newline at end of file diff --git a/Lang/C/Hofstadter-Q-sequence b/Lang/C/Hofstadter-Q-sequence new file mode 120000 index 0000000000..228c12fed7 --- /dev/null +++ b/Lang/C/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/C \ No newline at end of file diff --git a/Lang/C/Holidays-related-to-Easter b/Lang/C/Holidays-related-to-Easter new file mode 120000 index 0000000000..bfcd171df7 --- /dev/null +++ b/Lang/C/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/C \ No newline at end of file diff --git a/Lang/C/Honeycombs b/Lang/C/Honeycombs new file mode 120000 index 0000000000..f47af955f9 --- /dev/null +++ b/Lang/C/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/C \ No newline at end of file diff --git a/Lang/C/Horizontal-sundial-calculations b/Lang/C/Horizontal-sundial-calculations new file mode 120000 index 0000000000..608ea4395f --- /dev/null +++ b/Lang/C/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/C \ No newline at end of file diff --git a/Lang/C/Horners-rule-for-polynomial-evaluation b/Lang/C/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..c2f28cf7f9 --- /dev/null +++ b/Lang/C/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/C \ No newline at end of file diff --git a/Lang/C/Host-introspection b/Lang/C/Host-introspection new file mode 120000 index 0000000000..8c4532c030 --- /dev/null +++ b/Lang/C/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/C \ No newline at end of file diff --git a/Lang/C/Hostname b/Lang/C/Hostname new file mode 120000 index 0000000000..62eaa2c8bf --- /dev/null +++ b/Lang/C/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/C \ No newline at end of file diff --git a/Lang/C/Huffman-coding b/Lang/C/Huffman-coding new file mode 120000 index 0000000000..8557dba199 --- /dev/null +++ b/Lang/C/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/C \ No newline at end of file diff --git a/Lang/C/Identity-matrix b/Lang/C/Identity-matrix new file mode 120000 index 0000000000..be26dcd8d1 --- /dev/null +++ b/Lang/C/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/C \ No newline at end of file diff --git a/Lang/C/Image-convolution b/Lang/C/Image-convolution new file mode 120000 index 0000000000..f2b75adb86 --- /dev/null +++ b/Lang/C/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/C \ No newline at end of file diff --git a/Lang/C/Image-noise b/Lang/C/Image-noise new file mode 120000 index 0000000000..6d5a5c993d --- /dev/null +++ b/Lang/C/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/C \ No newline at end of file diff --git a/Lang/C/Include-a-file b/Lang/C/Include-a-file new file mode 120000 index 0000000000..8a77742433 --- /dev/null +++ b/Lang/C/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/C \ No newline at end of file diff --git a/Lang/C/Increment-a-numerical-string b/Lang/C/Increment-a-numerical-string new file mode 120000 index 0000000000..ae612db441 --- /dev/null +++ b/Lang/C/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/C \ No newline at end of file diff --git a/Lang/C/Input-loop b/Lang/C/Input-loop new file mode 120000 index 0000000000..02f42964ca --- /dev/null +++ b/Lang/C/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/C \ No newline at end of file diff --git a/Lang/C/Integer-comparison b/Lang/C/Integer-comparison new file mode 120000 index 0000000000..4d105f8a2c --- /dev/null +++ b/Lang/C/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/C \ No newline at end of file diff --git a/Lang/C/Integer-sequence b/Lang/C/Integer-sequence new file mode 120000 index 0000000000..ea407a8ec0 --- /dev/null +++ b/Lang/C/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/C \ No newline at end of file diff --git a/Lang/C/Introspection b/Lang/C/Introspection new file mode 120000 index 0000000000..2a3b3ff53a --- /dev/null +++ b/Lang/C/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/C \ No newline at end of file diff --git a/Lang/C/Inverted-index b/Lang/C/Inverted-index new file mode 120000 index 0000000000..b40b24962a --- /dev/null +++ b/Lang/C/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/C \ No newline at end of file diff --git a/Lang/C/Inverted-syntax b/Lang/C/Inverted-syntax new file mode 120000 index 0000000000..60e0171c4f --- /dev/null +++ b/Lang/C/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/C \ No newline at end of file diff --git a/Lang/C/Jensens-Device b/Lang/C/Jensens-Device new file mode 120000 index 0000000000..36bdfa3d60 --- /dev/null +++ b/Lang/C/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/C \ No newline at end of file diff --git a/Lang/C/Josephus-problem b/Lang/C/Josephus-problem new file mode 120000 index 0000000000..1a36ad4d46 --- /dev/null +++ b/Lang/C/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/C \ No newline at end of file diff --git a/Lang/C/Jump-anywhere b/Lang/C/Jump-anywhere new file mode 120000 index 0000000000..423135ad7d --- /dev/null +++ b/Lang/C/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/C \ No newline at end of file diff --git a/Lang/C/K-means++-clustering b/Lang/C/K-means++-clustering new file mode 120000 index 0000000000..a1be51f892 --- /dev/null +++ b/Lang/C/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/C \ No newline at end of file diff --git a/Lang/C/Kaprekar-numbers b/Lang/C/Kaprekar-numbers new file mode 120000 index 0000000000..eadb02afb1 --- /dev/null +++ b/Lang/C/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/C \ No newline at end of file diff --git a/Lang/C/Keyboard-input-Flush-the-keyboard-buffer b/Lang/C/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..8329b6079a --- /dev/null +++ b/Lang/C/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/C \ No newline at end of file diff --git a/Lang/C/Keyboard-input-Keypress-check b/Lang/C/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..449ed23e38 --- /dev/null +++ b/Lang/C/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/C \ No newline at end of file diff --git a/Lang/C/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/C/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..69a869399b --- /dev/null +++ b/Lang/C/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/C \ No newline at end of file diff --git a/Lang/C/Keyboard-macros b/Lang/C/Keyboard-macros new file mode 120000 index 0000000000..83f0253ab3 --- /dev/null +++ b/Lang/C/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/C \ No newline at end of file diff --git a/Lang/C/Knapsack-problem-0-1 b/Lang/C/Knapsack-problem-0-1 new file mode 120000 index 0000000000..1c639aecc1 --- /dev/null +++ b/Lang/C/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/C \ No newline at end of file diff --git a/Lang/C/Knapsack-problem-Bounded b/Lang/C/Knapsack-problem-Bounded new file mode 120000 index 0000000000..fb6b8b674c --- /dev/null +++ b/Lang/C/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/C \ No newline at end of file diff --git a/Lang/C/Knapsack-problem-Continuous b/Lang/C/Knapsack-problem-Continuous new file mode 120000 index 0000000000..31d6fa19aa --- /dev/null +++ b/Lang/C/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/C \ No newline at end of file diff --git a/Lang/C/Knapsack-problem-Unbounded b/Lang/C/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..f5fa65e16d --- /dev/null +++ b/Lang/C/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/C \ No newline at end of file diff --git a/Lang/C/Knights-tour b/Lang/C/Knights-tour new file mode 120000 index 0000000000..ed8bb16ca5 --- /dev/null +++ b/Lang/C/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/C \ No newline at end of file diff --git a/Lang/C/Knuths-algorithm-S b/Lang/C/Knuths-algorithm-S new file mode 120000 index 0000000000..1a81273957 --- /dev/null +++ b/Lang/C/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/C \ No newline at end of file diff --git a/Lang/C/LU-decomposition b/Lang/C/LU-decomposition new file mode 120000 index 0000000000..c7b496d169 --- /dev/null +++ b/Lang/C/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/C \ No newline at end of file diff --git a/Lang/C/LZW-compression b/Lang/C/LZW-compression new file mode 120000 index 0000000000..4097b3c0eb --- /dev/null +++ b/Lang/C/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/C \ No newline at end of file diff --git a/Lang/C/Langtons-ant b/Lang/C/Langtons-ant new file mode 120000 index 0000000000..9e5d342382 --- /dev/null +++ b/Lang/C/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/C \ No newline at end of file diff --git a/Lang/C/Largest-int-from-concatenated-ints b/Lang/C/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..897a465d90 --- /dev/null +++ b/Lang/C/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/C \ No newline at end of file diff --git a/Lang/C/Last-Friday-of-each-month b/Lang/C/Last-Friday-of-each-month new file mode 120000 index 0000000000..e79a41e07b --- /dev/null +++ b/Lang/C/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/C \ No newline at end of file diff --git a/Lang/C/Last-letter-first-letter b/Lang/C/Last-letter-first-letter new file mode 120000 index 0000000000..c6e124c64f --- /dev/null +++ b/Lang/C/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/C \ No newline at end of file diff --git a/Lang/C/Leap-year b/Lang/C/Leap-year new file mode 120000 index 0000000000..05126e8d94 --- /dev/null +++ b/Lang/C/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/C \ No newline at end of file diff --git a/Lang/C/Least-common-multiple b/Lang/C/Least-common-multiple new file mode 120000 index 0000000000..2d7de676f5 --- /dev/null +++ b/Lang/C/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/C \ No newline at end of file diff --git a/Lang/C/Letter-frequency b/Lang/C/Letter-frequency new file mode 120000 index 0000000000..094a286273 --- /dev/null +++ b/Lang/C/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/C \ No newline at end of file diff --git a/Lang/C/Levenshtein-distance b/Lang/C/Levenshtein-distance new file mode 120000 index 0000000000..cdc4e222e3 --- /dev/null +++ b/Lang/C/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/C \ No newline at end of file diff --git a/Lang/C/Linear-congruential-generator b/Lang/C/Linear-congruential-generator new file mode 120000 index 0000000000..aac65844d3 --- /dev/null +++ b/Lang/C/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/C \ No newline at end of file diff --git a/Lang/C/Literals-Integer b/Lang/C/Literals-Integer new file mode 120000 index 0000000000..a56bc3432f --- /dev/null +++ b/Lang/C/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/C \ No newline at end of file diff --git a/Lang/C/Literals-String b/Lang/C/Literals-String new file mode 120000 index 0000000000..0d2ceffa2a --- /dev/null +++ b/Lang/C/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/C \ No newline at end of file diff --git a/Lang/C/Logical-operations b/Lang/C/Logical-operations new file mode 120000 index 0000000000..1cf4343658 --- /dev/null +++ b/Lang/C/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/C \ No newline at end of file diff --git a/Lang/C/Long-multiplication b/Lang/C/Long-multiplication new file mode 120000 index 0000000000..9385be84ec --- /dev/null +++ b/Lang/C/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/C \ No newline at end of file diff --git a/Lang/C/Longest-common-subsequence b/Lang/C/Longest-common-subsequence new file mode 120000 index 0000000000..fb22b82cb4 --- /dev/null +++ b/Lang/C/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/C \ No newline at end of file diff --git a/Lang/C/Longest-string-challenge b/Lang/C/Longest-string-challenge new file mode 120000 index 0000000000..136fd58bb2 --- /dev/null +++ b/Lang/C/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/C \ No newline at end of file diff --git a/Lang/C/Look-and-say-sequence b/Lang/C/Look-and-say-sequence new file mode 120000 index 0000000000..9346df5c44 --- /dev/null +++ b/Lang/C/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/C \ No newline at end of file diff --git a/Lang/C/Loop-over-multiple-arrays-simultaneously b/Lang/C/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..1dfe208392 --- /dev/null +++ b/Lang/C/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/C \ No newline at end of file diff --git a/Lang/C/Loops-Break b/Lang/C/Loops-Break new file mode 120000 index 0000000000..abd98d5f3c --- /dev/null +++ b/Lang/C/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/C \ No newline at end of file diff --git a/Lang/C/Loops-Continue b/Lang/C/Loops-Continue new file mode 120000 index 0000000000..613c14fd1f --- /dev/null +++ b/Lang/C/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/C \ No newline at end of file diff --git a/Lang/C/Loops-Do-while b/Lang/C/Loops-Do-while new file mode 120000 index 0000000000..6432a2e60d --- /dev/null +++ b/Lang/C/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/C \ No newline at end of file diff --git a/Lang/C/Loops-Downward-for b/Lang/C/Loops-Downward-for new file mode 120000 index 0000000000..48a49ccb03 --- /dev/null +++ b/Lang/C/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/C \ No newline at end of file diff --git a/Lang/C/Loops-For b/Lang/C/Loops-For new file mode 120000 index 0000000000..f240094d15 --- /dev/null +++ b/Lang/C/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/C \ No newline at end of file diff --git a/Lang/C/Loops-For-with-a-specified-step b/Lang/C/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..f3bf67399c --- /dev/null +++ b/Lang/C/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/C \ No newline at end of file diff --git a/Lang/C/Loops-Foreach b/Lang/C/Loops-Foreach new file mode 120000 index 0000000000..81d747edbf --- /dev/null +++ b/Lang/C/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/C \ No newline at end of file diff --git a/Lang/C/Loops-Infinite b/Lang/C/Loops-Infinite new file mode 120000 index 0000000000..1d5c62c1fe --- /dev/null +++ b/Lang/C/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/C \ No newline at end of file diff --git a/Lang/C/Loops-N-plus-one-half b/Lang/C/Loops-N-plus-one-half new file mode 120000 index 0000000000..5e8937561e --- /dev/null +++ b/Lang/C/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/C \ No newline at end of file diff --git a/Lang/C/Loops-Nested b/Lang/C/Loops-Nested new file mode 120000 index 0000000000..0e3d873f96 --- /dev/null +++ b/Lang/C/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/C \ No newline at end of file diff --git a/Lang/C/Loops-While b/Lang/C/Loops-While new file mode 120000 index 0000000000..ec2e6e76e1 --- /dev/null +++ b/Lang/C/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/C \ No newline at end of file diff --git a/Lang/C/Lucas-Lehmer-test b/Lang/C/Lucas-Lehmer-test new file mode 120000 index 0000000000..7132b1ac63 --- /dev/null +++ b/Lang/C/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/C \ No newline at end of file diff --git a/Lang/C/Luhn-test-of-credit-card-numbers b/Lang/C/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..b95fc4fd23 --- /dev/null +++ b/Lang/C/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/C \ No newline at end of file diff --git a/Lang/C/MD5 b/Lang/C/MD5 new file mode 120000 index 0000000000..156e506aaa --- /dev/null +++ b/Lang/C/MD5 @@ -0,0 +1 @@ +../../Task/MD5/C \ No newline at end of file diff --git a/Lang/C/Main-step-of-GOST-28147-89 b/Lang/C/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..b60408d6cc --- /dev/null +++ b/Lang/C/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/C \ No newline at end of file diff --git a/Lang/C/Man-or-boy-test b/Lang/C/Man-or-boy-test new file mode 120000 index 0000000000..1582706429 --- /dev/null +++ b/Lang/C/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/C \ No newline at end of file diff --git a/Lang/C/Mandelbrot-set b/Lang/C/Mandelbrot-set new file mode 120000 index 0000000000..7528394c11 --- /dev/null +++ b/Lang/C/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/C \ No newline at end of file diff --git a/Lang/C/Map-range b/Lang/C/Map-range new file mode 120000 index 0000000000..6d6277a102 --- /dev/null +++ b/Lang/C/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/C \ No newline at end of file diff --git a/Lang/C/Matrix-arithmetic b/Lang/C/Matrix-arithmetic new file mode 120000 index 0000000000..b18826a2b1 --- /dev/null +++ b/Lang/C/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/C \ No newline at end of file diff --git a/Lang/C/Matrix-exponentiation-operator b/Lang/C/Matrix-exponentiation-operator new file mode 120000 index 0000000000..3f535ae709 --- /dev/null +++ b/Lang/C/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/C \ No newline at end of file diff --git a/Lang/C/Matrix-multiplication b/Lang/C/Matrix-multiplication new file mode 120000 index 0000000000..fd3b1d9c21 --- /dev/null +++ b/Lang/C/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/C \ No newline at end of file diff --git a/Lang/C/Matrix-transposition b/Lang/C/Matrix-transposition new file mode 120000 index 0000000000..e0a1458352 --- /dev/null +++ b/Lang/C/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/C \ No newline at end of file diff --git a/Lang/C/Maze-generation b/Lang/C/Maze-generation new file mode 120000 index 0000000000..0bf956a933 --- /dev/null +++ b/Lang/C/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/C \ No newline at end of file diff --git a/Lang/C/Median-filter b/Lang/C/Median-filter new file mode 120000 index 0000000000..968a861167 --- /dev/null +++ b/Lang/C/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/C \ No newline at end of file diff --git a/Lang/C/Memory-allocation b/Lang/C/Memory-allocation new file mode 120000 index 0000000000..24b3842349 --- /dev/null +++ b/Lang/C/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/C \ No newline at end of file diff --git a/Lang/C/Memory-layout-of-a-data-structure b/Lang/C/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..23a837e969 --- /dev/null +++ b/Lang/C/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/C \ No newline at end of file diff --git a/Lang/C/Menu b/Lang/C/Menu new file mode 120000 index 0000000000..6a1b29de73 --- /dev/null +++ b/Lang/C/Menu @@ -0,0 +1 @@ +../../Task/Menu/C \ No newline at end of file diff --git a/Lang/C/Metaprogramming b/Lang/C/Metaprogramming new file mode 120000 index 0000000000..b8132d5af6 --- /dev/null +++ b/Lang/C/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/C \ No newline at end of file diff --git a/Lang/C/Metered-concurrency b/Lang/C/Metered-concurrency new file mode 120000 index 0000000000..397f232200 --- /dev/null +++ b/Lang/C/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/C \ No newline at end of file diff --git a/Lang/C/Metronome b/Lang/C/Metronome new file mode 120000 index 0000000000..a46e6ea415 --- /dev/null +++ b/Lang/C/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/C \ No newline at end of file diff --git a/Lang/C/Middle-three-digits b/Lang/C/Middle-three-digits new file mode 120000 index 0000000000..e761c56960 --- /dev/null +++ b/Lang/C/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/C \ No newline at end of file diff --git a/Lang/C/Miller-Rabin-primality-test b/Lang/C/Miller-Rabin-primality-test new file mode 120000 index 0000000000..b9ab762a9c --- /dev/null +++ b/Lang/C/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/C \ No newline at end of file diff --git a/Lang/C/Minesweeper-game b/Lang/C/Minesweeper-game new file mode 120000 index 0000000000..b5de392cb8 --- /dev/null +++ b/Lang/C/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/C \ No newline at end of file diff --git a/Lang/C/Modular-exponentiation b/Lang/C/Modular-exponentiation new file mode 120000 index 0000000000..99fc8b15de --- /dev/null +++ b/Lang/C/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/C \ No newline at end of file diff --git a/Lang/C/Modular-inverse b/Lang/C/Modular-inverse new file mode 120000 index 0000000000..72d4a48afa --- /dev/null +++ b/Lang/C/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/C \ No newline at end of file diff --git a/Lang/C/Monte-Carlo-methods b/Lang/C/Monte-Carlo-methods new file mode 120000 index 0000000000..e3de11c8d2 --- /dev/null +++ b/Lang/C/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/C \ No newline at end of file diff --git a/Lang/C/Monty-Hall-problem b/Lang/C/Monty-Hall-problem new file mode 120000 index 0000000000..efd3aaf22e --- /dev/null +++ b/Lang/C/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/C \ No newline at end of file diff --git a/Lang/C/Morse-code b/Lang/C/Morse-code new file mode 120000 index 0000000000..e5ca3e1277 --- /dev/null +++ b/Lang/C/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/C \ No newline at end of file diff --git a/Lang/C/Mouse-position b/Lang/C/Mouse-position new file mode 120000 index 0000000000..7828b057f9 --- /dev/null +++ b/Lang/C/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/C \ No newline at end of file diff --git a/Lang/C/Multifactorial b/Lang/C/Multifactorial new file mode 120000 index 0000000000..597713ef9c --- /dev/null +++ b/Lang/C/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/C \ No newline at end of file diff --git a/Lang/C/Multiple-distinct-objects b/Lang/C/Multiple-distinct-objects new file mode 120000 index 0000000000..4e1af27603 --- /dev/null +++ b/Lang/C/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/C \ No newline at end of file diff --git a/Lang/C/Multiple-regression b/Lang/C/Multiple-regression new file mode 120000 index 0000000000..c13f69f9fb --- /dev/null +++ b/Lang/C/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/C \ No newline at end of file diff --git a/Lang/C/Multiplication-tables b/Lang/C/Multiplication-tables new file mode 120000 index 0000000000..9521ba4a1a --- /dev/null +++ b/Lang/C/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/C \ No newline at end of file diff --git a/Lang/C/Multiplicative-order b/Lang/C/Multiplicative-order new file mode 120000 index 0000000000..c0915f68da --- /dev/null +++ b/Lang/C/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/C \ No newline at end of file diff --git a/Lang/C/Multisplit b/Lang/C/Multisplit new file mode 120000 index 0000000000..335cd192fb --- /dev/null +++ b/Lang/C/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/C \ No newline at end of file diff --git a/Lang/C/Mutex b/Lang/C/Mutex new file mode 120000 index 0000000000..84410fc327 --- /dev/null +++ b/Lang/C/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/C \ No newline at end of file diff --git a/Lang/C/Mutual-recursion b/Lang/C/Mutual-recursion new file mode 120000 index 0000000000..91b67a571f --- /dev/null +++ b/Lang/C/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/C \ No newline at end of file diff --git a/Lang/C1R/Hello-world-Text b/Lang/C1R/Hello-world-Text new file mode 120000 index 0000000000..08e6366744 --- /dev/null +++ b/Lang/C1R/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/C1R \ No newline at end of file diff --git a/Lang/CLIPS/Factorial b/Lang/CLIPS/Factorial new file mode 120000 index 0000000000..d4e9e057d8 --- /dev/null +++ b/Lang/CLIPS/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/CLIPS \ No newline at end of file diff --git a/Lang/CLIPS/Hailstone-sequence b/Lang/CLIPS/Hailstone-sequence new file mode 120000 index 0000000000..1e02c8cbc9 --- /dev/null +++ b/Lang/CLIPS/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/CLIPS \ No newline at end of file diff --git a/Lang/CLIPS/Hello-world-Text b/Lang/CLIPS/Hello-world-Text new file mode 120000 index 0000000000..c78d1a1703 --- /dev/null +++ b/Lang/CLIPS/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/CLIPS \ No newline at end of file diff --git a/Lang/CMake/Factorial b/Lang/CMake/Factorial new file mode 120000 index 0000000000..eec2b72b48 --- /dev/null +++ b/Lang/CMake/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/CMake \ No newline at end of file diff --git a/Lang/CMake/Fibonacci-sequence b/Lang/CMake/Fibonacci-sequence new file mode 120000 index 0000000000..9cda58060e --- /dev/null +++ b/Lang/CMake/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/CMake \ No newline at end of file diff --git a/Lang/CMake/Generic-swap b/Lang/CMake/Generic-swap new file mode 120000 index 0000000000..692313873c --- /dev/null +++ b/Lang/CMake/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/CMake \ No newline at end of file diff --git a/Lang/CMake/Greatest-element-of-a-list b/Lang/CMake/Greatest-element-of-a-list new file mode 120000 index 0000000000..893d37acc1 --- /dev/null +++ b/Lang/CMake/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/CMake \ No newline at end of file diff --git a/Lang/CMake/Hello-world-Standard-error b/Lang/CMake/Hello-world-Standard-error new file mode 120000 index 0000000000..ef78c2f5e0 --- /dev/null +++ b/Lang/CMake/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/CMake \ No newline at end of file diff --git a/Lang/CMake/Hello-world-Text b/Lang/CMake/Hello-world-Text new file mode 120000 index 0000000000..b6edc96dae --- /dev/null +++ b/Lang/CMake/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/CMake \ No newline at end of file diff --git a/Lang/CMake/Increment-a-numerical-string b/Lang/CMake/Increment-a-numerical-string new file mode 120000 index 0000000000..1c5d98aadf --- /dev/null +++ b/Lang/CMake/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/CMake \ No newline at end of file diff --git a/Lang/CMake/Integer-comparison b/Lang/CMake/Integer-comparison new file mode 120000 index 0000000000..7091ae3523 --- /dev/null +++ b/Lang/CMake/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/CMake \ No newline at end of file diff --git a/Lang/CMake/Loops-Foreach b/Lang/CMake/Loops-Foreach new file mode 120000 index 0000000000..33394fe51a --- /dev/null +++ b/Lang/CMake/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/CMake \ No newline at end of file diff --git a/Lang/COBOL/Find-limit-of-recursion b/Lang/COBOL/Find-limit-of-recursion new file mode 120000 index 0000000000..34440df4c2 --- /dev/null +++ b/Lang/COBOL/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Function-definition b/Lang/COBOL/Function-definition new file mode 120000 index 0000000000..d65065ad45 --- /dev/null +++ b/Lang/COBOL/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Greatest-common-divisor b/Lang/COBOL/Greatest-common-divisor new file mode 120000 index 0000000000..e095f8cbf3 --- /dev/null +++ b/Lang/COBOL/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Hello-world-Graphical b/Lang/COBOL/Hello-world-Graphical new file mode 120000 index 0000000000..5dda8d05e0 --- /dev/null +++ b/Lang/COBOL/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Hello-world-Line-printer b/Lang/COBOL/Hello-world-Line-printer new file mode 120000 index 0000000000..0e45d27843 --- /dev/null +++ b/Lang/COBOL/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Hello-world-Newline-omission b/Lang/COBOL/Hello-world-Newline-omission new file mode 120000 index 0000000000..e9a40c0047 --- /dev/null +++ b/Lang/COBOL/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Hello-world-Standard-error b/Lang/COBOL/Hello-world-Standard-error new file mode 120000 index 0000000000..834bced88a --- /dev/null +++ b/Lang/COBOL/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Hello-world-Text b/Lang/COBOL/Hello-world-Text new file mode 120000 index 0000000000..656fad105e --- /dev/null +++ b/Lang/COBOL/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/COBOL \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/Luhn-test-of-credit-card-numbers b/Lang/Cache-ObjectScript/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..631a808e5f --- /dev/null +++ b/Lang/Cache-ObjectScript/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Cache-ObjectScript \ No newline at end of file diff --git a/Lang/Cat/Factorial b/Lang/Cat/Factorial new file mode 120000 index 0000000000..4daa7291c4 --- /dev/null +++ b/Lang/Cat/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Cat \ No newline at end of file diff --git a/Lang/Cat/Fibonacci-sequence b/Lang/Cat/Fibonacci-sequence new file mode 120000 index 0000000000..d724709ec8 --- /dev/null +++ b/Lang/Cat/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Cat \ No newline at end of file diff --git a/Lang/Cat/Hello-world-Text b/Lang/Cat/Hello-world-Text new file mode 120000 index 0000000000..12d8dfbd28 --- /dev/null +++ b/Lang/Cat/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Cat \ No newline at end of file diff --git a/Lang/Cduce/Hello-world-Text b/Lang/Cduce/Hello-world-Text new file mode 120000 index 0000000000..a5baa5e009 --- /dev/null +++ b/Lang/Cduce/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Cduce \ No newline at end of file diff --git a/Lang/Chef/Factorial b/Lang/Chef/Factorial new file mode 120000 index 0000000000..c8b71d8836 --- /dev/null +++ b/Lang/Chef/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Chef \ No newline at end of file diff --git a/Lang/Chef/Fibonacci-sequence b/Lang/Chef/Fibonacci-sequence new file mode 120000 index 0000000000..27cad1d7b9 --- /dev/null +++ b/Lang/Chef/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Chef \ No newline at end of file diff --git a/Lang/Chef/Hello-world-Text b/Lang/Chef/Hello-world-Text new file mode 120000 index 0000000000..e9366ccc37 --- /dev/null +++ b/Lang/Chef/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Chef \ No newline at end of file diff --git a/Lang/Chef/Loops-Break b/Lang/Chef/Loops-Break new file mode 120000 index 0000000000..9aabc1a262 --- /dev/null +++ b/Lang/Chef/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Chef \ No newline at end of file diff --git a/Lang/Chef/Loops-For b/Lang/Chef/Loops-For new file mode 120000 index 0000000000..cb624ee1d6 --- /dev/null +++ b/Lang/Chef/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Chef \ No newline at end of file diff --git a/Lang/Chef/Multiplication-tables b/Lang/Chef/Multiplication-tables new file mode 120000 index 0000000000..f0e2c776f7 --- /dev/null +++ b/Lang/Chef/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Chef \ No newline at end of file diff --git a/Lang/Clay/Factorial b/Lang/Clay/Factorial new file mode 120000 index 0000000000..83c626cf12 --- /dev/null +++ b/Lang/Clay/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Clay \ No newline at end of file diff --git a/Lang/Clay/Function-definition b/Lang/Clay/Function-definition new file mode 120000 index 0000000000..46b56cfeaa --- /dev/null +++ b/Lang/Clay/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Clay \ No newline at end of file diff --git a/Lang/Clay/Hello-world-Text b/Lang/Clay/Hello-world-Text new file mode 120000 index 0000000000..0eb8918cd6 --- /dev/null +++ b/Lang/Clay/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Clay \ No newline at end of file diff --git a/Lang/Clean/File-IO b/Lang/Clean/File-IO new file mode 120000 index 0000000000..b87dc87656 --- /dev/null +++ b/Lang/Clean/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Clean \ No newline at end of file diff --git a/Lang/Clean/File-size b/Lang/Clean/File-size new file mode 120000 index 0000000000..4a0f2d44ce --- /dev/null +++ b/Lang/Clean/File-size @@ -0,0 +1 @@ +../../Task/File-size/Clean \ No newline at end of file diff --git a/Lang/Clean/Filter b/Lang/Clean/Filter new file mode 120000 index 0000000000..3af4506294 --- /dev/null +++ b/Lang/Clean/Filter @@ -0,0 +1 @@ +../../Task/Filter/Clean \ No newline at end of file diff --git a/Lang/Clean/Hello-world-Graphical b/Lang/Clean/Hello-world-Graphical new file mode 120000 index 0000000000..c5fb41221e --- /dev/null +++ b/Lang/Clean/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Clean \ No newline at end of file diff --git a/Lang/Clean/Hello-world-Text b/Lang/Clean/Hello-world-Text new file mode 120000 index 0000000000..04d15ba060 --- /dev/null +++ b/Lang/Clean/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Clean \ No newline at end of file diff --git a/Lang/Clean/Higher-order-functions b/Lang/Clean/Higher-order-functions new file mode 120000 index 0000000000..8ac573774e --- /dev/null +++ b/Lang/Clean/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Clean \ No newline at end of file diff --git a/Lang/Clean/Integer-comparison b/Lang/Clean/Integer-comparison new file mode 120000 index 0000000000..b12c8c2720 --- /dev/null +++ b/Lang/Clean/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Clean \ No newline at end of file diff --git a/Lang/Clean/Integer-sequence b/Lang/Clean/Integer-sequence new file mode 120000 index 0000000000..265d424518 --- /dev/null +++ b/Lang/Clean/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Clean \ No newline at end of file diff --git a/Lang/Clipper/Jensens-Device b/Lang/Clipper/Jensens-Device new file mode 120000 index 0000000000..b29665eb47 --- /dev/null +++ b/Lang/Clipper/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Clipper \ No newline at end of file diff --git a/Lang/Clipper/Man-or-boy-test b/Lang/Clipper/Man-or-boy-test new file mode 120000 index 0000000000..a925b5aab8 --- /dev/null +++ b/Lang/Clipper/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Clipper \ No newline at end of file diff --git a/Lang/Clojure/24-game-Solve b/Lang/Clojure/24-game-Solve new file mode 120000 index 0000000000..c0f68605f0 --- /dev/null +++ b/Lang/Clojure/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Arbitrary-precision-integers-included b/Lang/Clojure/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..d219fdc615 --- /dev/null +++ b/Lang/Clojure/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Factorial b/Lang/Clojure/Factorial new file mode 120000 index 0000000000..6e83221f20 --- /dev/null +++ b/Lang/Clojure/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Factors-of-an-integer b/Lang/Clojure/Factors-of-an-integer new file mode 120000 index 0000000000..a72609dece --- /dev/null +++ b/Lang/Clojure/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Fibonacci-sequence b/Lang/Clojure/Fibonacci-sequence new file mode 120000 index 0000000000..f0817ee959 --- /dev/null +++ b/Lang/Clojure/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/File-IO b/Lang/Clojure/File-IO new file mode 120000 index 0000000000..aaeac25989 --- /dev/null +++ b/Lang/Clojure/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Clojure \ No newline at end of file diff --git a/Lang/Clojure/File-modification-time b/Lang/Clojure/File-modification-time new file mode 120000 index 0000000000..c29c98b044 --- /dev/null +++ b/Lang/Clojure/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Clojure \ No newline at end of file diff --git a/Lang/Clojure/File-size b/Lang/Clojure/File-size new file mode 120000 index 0000000000..781766b8a9 --- /dev/null +++ b/Lang/Clojure/File-size @@ -0,0 +1 @@ +../../Task/File-size/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Filter b/Lang/Clojure/Filter new file mode 120000 index 0000000000..67c6b23c4d --- /dev/null +++ b/Lang/Clojure/Filter @@ -0,0 +1 @@ +../../Task/Filter/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Find-common-directory-path b/Lang/Clojure/Find-common-directory-path new file mode 120000 index 0000000000..437c966d98 --- /dev/null +++ b/Lang/Clojure/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Find-limit-of-recursion b/Lang/Clojure/Find-limit-of-recursion new file mode 120000 index 0000000000..b934d50ea9 --- /dev/null +++ b/Lang/Clojure/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Find-the-missing-permutation b/Lang/Clojure/Find-the-missing-permutation new file mode 120000 index 0000000000..a933950969 --- /dev/null +++ b/Lang/Clojure/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/First-class-functions b/Lang/Clojure/First-class-functions new file mode 120000 index 0000000000..26be2bd4a7 --- /dev/null +++ b/Lang/Clojure/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/First-class-functions-Use-numbers-analogously b/Lang/Clojure/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..a7ce705ed3 --- /dev/null +++ b/Lang/Clojure/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Five-weekends b/Lang/Clojure/Five-weekends new file mode 120000 index 0000000000..bbadccb801 --- /dev/null +++ b/Lang/Clojure/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Flatten-a-list b/Lang/Clojure/Flatten-a-list new file mode 120000 index 0000000000..cff38ab6c0 --- /dev/null +++ b/Lang/Clojure/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Fork b/Lang/Clojure/Fork new file mode 120000 index 0000000000..570a2f1209 --- /dev/null +++ b/Lang/Clojure/Fork @@ -0,0 +1 @@ +../../Task/Fork/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Formal-power-series b/Lang/Clojure/Formal-power-series new file mode 120000 index 0000000000..fc634e317b --- /dev/null +++ b/Lang/Clojure/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Formatted-numeric-output b/Lang/Clojure/Formatted-numeric-output new file mode 120000 index 0000000000..1e27c8351b --- /dev/null +++ b/Lang/Clojure/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Forward-difference b/Lang/Clojure/Forward-difference new file mode 120000 index 0000000000..dc8630daec --- /dev/null +++ b/Lang/Clojure/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Four-bit-adder b/Lang/Clojure/Four-bit-adder new file mode 120000 index 0000000000..3994636afc --- /dev/null +++ b/Lang/Clojure/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Fractal-tree b/Lang/Clojure/Fractal-tree new file mode 120000 index 0000000000..cc8fab8af9 --- /dev/null +++ b/Lang/Clojure/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Function-composition b/Lang/Clojure/Function-composition new file mode 120000 index 0000000000..f27cfdb5b0 --- /dev/null +++ b/Lang/Clojure/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Function-definition b/Lang/Clojure/Function-definition new file mode 120000 index 0000000000..78180d551e --- /dev/null +++ b/Lang/Clojure/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Gamma-function b/Lang/Clojure/Gamma-function new file mode 120000 index 0000000000..c50775ccc7 --- /dev/null +++ b/Lang/Clojure/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Generic-swap b/Lang/Clojure/Generic-swap new file mode 120000 index 0000000000..705bba83dc --- /dev/null +++ b/Lang/Clojure/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Greatest-common-divisor b/Lang/Clojure/Greatest-common-divisor new file mode 120000 index 0000000000..2526a2fb8a --- /dev/null +++ b/Lang/Clojure/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Greatest-element-of-a-list b/Lang/Clojure/Greatest-element-of-a-list new file mode 120000 index 0000000000..ba0183e6a1 --- /dev/null +++ b/Lang/Clojure/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Greatest-subsequential-sum b/Lang/Clojure/Greatest-subsequential-sum new file mode 120000 index 0000000000..6f28fcd26d --- /dev/null +++ b/Lang/Clojure/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Guess-the-number b/Lang/Clojure/Guess-the-number new file mode 120000 index 0000000000..f279e2491a --- /dev/null +++ b/Lang/Clojure/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Guess-the-number-With-feedback b/Lang/Clojure/Guess-the-number-With-feedback new file mode 120000 index 0000000000..47150f43da --- /dev/null +++ b/Lang/Clojure/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Guess-the-number-With-feedback-player b/Lang/Clojure/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..4336a484b4 --- /dev/null +++ b/Lang/Clojure/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Clojure \ No newline at end of file diff --git a/Lang/Clojure/HTTP b/Lang/Clojure/HTTP new file mode 120000 index 0000000000..cfc252d2f3 --- /dev/null +++ b/Lang/Clojure/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Clojure \ No newline at end of file diff --git a/Lang/Clojure/HTTPS b/Lang/Clojure/HTTPS new file mode 120000 index 0000000000..82650ff30e --- /dev/null +++ b/Lang/Clojure/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hailstone-sequence b/Lang/Clojure/Hailstone-sequence new file mode 120000 index 0000000000..d6ef750225 --- /dev/null +++ b/Lang/Clojure/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hamming-numbers b/Lang/Clojure/Hamming-numbers new file mode 120000 index 0000000000..f143643d3d --- /dev/null +++ b/Lang/Clojure/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Handle-a-signal b/Lang/Clojure/Handle-a-signal new file mode 120000 index 0000000000..dd3903fa23 --- /dev/null +++ b/Lang/Clojure/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Happy-numbers b/Lang/Clojure/Happy-numbers new file mode 120000 index 0000000000..c76aa2bc80 --- /dev/null +++ b/Lang/Clojure/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Harshad-or-Niven-series b/Lang/Clojure/Harshad-or-Niven-series new file mode 120000 index 0000000000..33e80bebd5 --- /dev/null +++ b/Lang/Clojure/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hash-from-two-arrays b/Lang/Clojure/Hash-from-two-arrays new file mode 120000 index 0000000000..cf959d862c --- /dev/null +++ b/Lang/Clojure/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hello-world-Graphical b/Lang/Clojure/Hello-world-Graphical new file mode 120000 index 0000000000..bd948ab921 --- /dev/null +++ b/Lang/Clojure/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hello-world-Newline-omission b/Lang/Clojure/Hello-world-Newline-omission new file mode 120000 index 0000000000..260cc3e84b --- /dev/null +++ b/Lang/Clojure/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hello-world-Standard-error b/Lang/Clojure/Hello-world-Standard-error new file mode 120000 index 0000000000..daac409866 --- /dev/null +++ b/Lang/Clojure/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hello-world-Text b/Lang/Clojure/Hello-world-Text new file mode 120000 index 0000000000..a8dad79041 --- /dev/null +++ b/Lang/Clojure/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Higher-order-functions b/Lang/Clojure/Higher-order-functions new file mode 120000 index 0000000000..999e97f53c --- /dev/null +++ b/Lang/Clojure/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hofstadter-Conway-$10,000-sequence b/Lang/Clojure/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..dc0bb11e0a --- /dev/null +++ b/Lang/Clojure/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Horners-rule-for-polynomial-evaluation b/Lang/Clojure/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..94bca68123 --- /dev/null +++ b/Lang/Clojure/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Host-introspection b/Lang/Clojure/Host-introspection new file mode 120000 index 0000000000..c1e34d5f50 --- /dev/null +++ b/Lang/Clojure/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Hostname b/Lang/Clojure/Hostname new file mode 120000 index 0000000000..0360f37d26 --- /dev/null +++ b/Lang/Clojure/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Huffman-coding b/Lang/Clojure/Huffman-coding new file mode 120000 index 0000000000..5c9e41efad --- /dev/null +++ b/Lang/Clojure/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Identity-matrix b/Lang/Clojure/Identity-matrix new file mode 120000 index 0000000000..9a4f462774 --- /dev/null +++ b/Lang/Clojure/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Increment-a-numerical-string b/Lang/Clojure/Increment-a-numerical-string new file mode 120000 index 0000000000..e6eb6cea34 --- /dev/null +++ b/Lang/Clojure/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Inheritance-Multiple b/Lang/Clojure/Inheritance-Multiple new file mode 120000 index 0000000000..e77167600a --- /dev/null +++ b/Lang/Clojure/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Inheritance-Single b/Lang/Clojure/Inheritance-Single new file mode 120000 index 0000000000..de83703b50 --- /dev/null +++ b/Lang/Clojure/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Input-loop b/Lang/Clojure/Input-loop new file mode 120000 index 0000000000..fed7e8b46d --- /dev/null +++ b/Lang/Clojure/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Integer-comparison b/Lang/Clojure/Integer-comparison new file mode 120000 index 0000000000..b7b1dce75d --- /dev/null +++ b/Lang/Clojure/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Integer-sequence b/Lang/Clojure/Integer-sequence new file mode 120000 index 0000000000..f88e192404 --- /dev/null +++ b/Lang/Clojure/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Interactive-programming b/Lang/Clojure/Interactive-programming new file mode 120000 index 0000000000..cd7a1e6a5d --- /dev/null +++ b/Lang/Clojure/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Introspection b/Lang/Clojure/Introspection new file mode 120000 index 0000000000..12e38d7a16 --- /dev/null +++ b/Lang/Clojure/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Inverted-syntax b/Lang/Clojure/Inverted-syntax new file mode 120000 index 0000000000..3188822cf8 --- /dev/null +++ b/Lang/Clojure/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Knapsack-problem-0-1 b/Lang/Clojure/Knapsack-problem-0-1 new file mode 120000 index 0000000000..b9ecdf7d59 --- /dev/null +++ b/Lang/Clojure/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Knapsack-problem-Unbounded b/Lang/Clojure/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..24d6e64107 --- /dev/null +++ b/Lang/Clojure/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Clojure \ No newline at end of file diff --git a/Lang/Clojure/LZW-compression b/Lang/Clojure/LZW-compression new file mode 120000 index 0000000000..9c7e79c8f6 --- /dev/null +++ b/Lang/Clojure/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Langtons-ant b/Lang/Clojure/Langtons-ant new file mode 120000 index 0000000000..54c8694fd5 --- /dev/null +++ b/Lang/Clojure/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Largest-int-from-concatenated-ints b/Lang/Clojure/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..0bf3d3bd87 --- /dev/null +++ b/Lang/Clojure/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Leap-year b/Lang/Clojure/Leap-year new file mode 120000 index 0000000000..448c01facc --- /dev/null +++ b/Lang/Clojure/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Least-common-multiple b/Lang/Clojure/Least-common-multiple new file mode 120000 index 0000000000..5caf8efe13 --- /dev/null +++ b/Lang/Clojure/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Letter-frequency b/Lang/Clojure/Letter-frequency new file mode 120000 index 0000000000..413d936248 --- /dev/null +++ b/Lang/Clojure/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Levenshtein-distance b/Lang/Clojure/Levenshtein-distance new file mode 120000 index 0000000000..5b82eea7df --- /dev/null +++ b/Lang/Clojure/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Linear-congruential-generator b/Lang/Clojure/Linear-congruential-generator new file mode 120000 index 0000000000..04b8dccdc6 --- /dev/null +++ b/Lang/Clojure/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Clojure \ No newline at end of file diff --git a/Lang/Clojure/List-comprehensions b/Lang/Clojure/List-comprehensions new file mode 120000 index 0000000000..aa79b4f6b9 --- /dev/null +++ b/Lang/Clojure/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Literals-Integer b/Lang/Clojure/Literals-Integer new file mode 120000 index 0000000000..a97b5886fb --- /dev/null +++ b/Lang/Clojure/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Literals-String b/Lang/Clojure/Literals-String new file mode 120000 index 0000000000..0024c1dd21 --- /dev/null +++ b/Lang/Clojure/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Logical-operations b/Lang/Clojure/Logical-operations new file mode 120000 index 0000000000..d2161882d1 --- /dev/null +++ b/Lang/Clojure/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Longest-common-subsequence b/Lang/Clojure/Longest-common-subsequence new file mode 120000 index 0000000000..c944879944 --- /dev/null +++ b/Lang/Clojure/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Look-and-say-sequence b/Lang/Clojure/Look-and-say-sequence new file mode 120000 index 0000000000..48fcce6cac --- /dev/null +++ b/Lang/Clojure/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loop-over-multiple-arrays-simultaneously b/Lang/Clojure/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..835850890e --- /dev/null +++ b/Lang/Clojure/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Break b/Lang/Clojure/Loops-Break new file mode 120000 index 0000000000..aa3795b21f --- /dev/null +++ b/Lang/Clojure/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Continue b/Lang/Clojure/Loops-Continue new file mode 120000 index 0000000000..9fc83af06c --- /dev/null +++ b/Lang/Clojure/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Do-while b/Lang/Clojure/Loops-Do-while new file mode 120000 index 0000000000..712c261bf0 --- /dev/null +++ b/Lang/Clojure/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Downward-for b/Lang/Clojure/Loops-Downward-for new file mode 120000 index 0000000000..034cac994b --- /dev/null +++ b/Lang/Clojure/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-For b/Lang/Clojure/Loops-For new file mode 120000 index 0000000000..14ffd13833 --- /dev/null +++ b/Lang/Clojure/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-For-with-a-specified-step b/Lang/Clojure/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..590f123a54 --- /dev/null +++ b/Lang/Clojure/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Foreach b/Lang/Clojure/Loops-Foreach new file mode 120000 index 0000000000..a51b850fde --- /dev/null +++ b/Lang/Clojure/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Infinite b/Lang/Clojure/Loops-Infinite new file mode 120000 index 0000000000..0dbda72d56 --- /dev/null +++ b/Lang/Clojure/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-N-plus-one-half b/Lang/Clojure/Loops-N-plus-one-half new file mode 120000 index 0000000000..3cb530c5ca --- /dev/null +++ b/Lang/Clojure/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-Nested b/Lang/Clojure/Loops-Nested new file mode 120000 index 0000000000..d30cc20de4 --- /dev/null +++ b/Lang/Clojure/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Loops-While b/Lang/Clojure/Loops-While new file mode 120000 index 0000000000..c996c62449 --- /dev/null +++ b/Lang/Clojure/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Lucas-Lehmer-test b/Lang/Clojure/Lucas-Lehmer-test new file mode 120000 index 0000000000..eb55787909 --- /dev/null +++ b/Lang/Clojure/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Luhn-test-of-credit-card-numbers b/Lang/Clojure/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..2a29ecc7bb --- /dev/null +++ b/Lang/Clojure/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/MD5 b/Lang/Clojure/MD5 new file mode 120000 index 0000000000..4ab70256c1 --- /dev/null +++ b/Lang/Clojure/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Man-or-boy-test b/Lang/Clojure/Man-or-boy-test new file mode 120000 index 0000000000..bcc44544cb --- /dev/null +++ b/Lang/Clojure/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Mandelbrot-set b/Lang/Clojure/Mandelbrot-set new file mode 120000 index 0000000000..cda1a71ee6 --- /dev/null +++ b/Lang/Clojure/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Map-range b/Lang/Clojure/Map-range new file mode 120000 index 0000000000..581d88a532 --- /dev/null +++ b/Lang/Clojure/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Matrix-multiplication b/Lang/Clojure/Matrix-multiplication new file mode 120000 index 0000000000..39e09f5c61 --- /dev/null +++ b/Lang/Clojure/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Matrix-transposition b/Lang/Clojure/Matrix-transposition new file mode 120000 index 0000000000..9ed075df0a --- /dev/null +++ b/Lang/Clojure/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Menu b/Lang/Clojure/Menu new file mode 120000 index 0000000000..c1944d1f89 --- /dev/null +++ b/Lang/Clojure/Menu @@ -0,0 +1 @@ +../../Task/Menu/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Minesweeper-game b/Lang/Clojure/Minesweeper-game new file mode 120000 index 0000000000..8ef194e8b3 --- /dev/null +++ b/Lang/Clojure/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Monte-Carlo-methods b/Lang/Clojure/Monte-Carlo-methods new file mode 120000 index 0000000000..d2eb9664e6 --- /dev/null +++ b/Lang/Clojure/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Monty-Hall-problem b/Lang/Clojure/Monty-Hall-problem new file mode 120000 index 0000000000..6d990819b6 --- /dev/null +++ b/Lang/Clojure/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Morse-code b/Lang/Clojure/Morse-code new file mode 120000 index 0000000000..2f4d0cdf77 --- /dev/null +++ b/Lang/Clojure/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Mouse-position b/Lang/Clojure/Mouse-position new file mode 120000 index 0000000000..483e5b3f0c --- /dev/null +++ b/Lang/Clojure/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Multifactorial b/Lang/Clojure/Multifactorial new file mode 120000 index 0000000000..73a8767de0 --- /dev/null +++ b/Lang/Clojure/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Multiple-distinct-objects b/Lang/Clojure/Multiple-distinct-objects new file mode 120000 index 0000000000..8451744400 --- /dev/null +++ b/Lang/Clojure/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Multiplication-tables b/Lang/Clojure/Multiplication-tables new file mode 120000 index 0000000000..b0ca130380 --- /dev/null +++ b/Lang/Clojure/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Mutual-recursion b/Lang/Clojure/Mutual-recursion new file mode 120000 index 0000000000..293ad42556 --- /dev/null +++ b/Lang/Clojure/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Clojure \ No newline at end of file diff --git a/Lang/Cobra/Greatest-common-divisor b/Lang/Cobra/Greatest-common-divisor new file mode 120000 index 0000000000..dc6ab3141a --- /dev/null +++ b/Lang/Cobra/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Cobra \ No newline at end of file diff --git a/Lang/Cobra/Hello-world-Graphical b/Lang/Cobra/Hello-world-Graphical new file mode 120000 index 0000000000..de1adf80c4 --- /dev/null +++ b/Lang/Cobra/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Cobra \ No newline at end of file diff --git a/Lang/Cobra/Hello-world-Text b/Lang/Cobra/Hello-world-Text new file mode 120000 index 0000000000..a463a8396f --- /dev/null +++ b/Lang/Cobra/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Cobra \ No newline at end of file diff --git a/Lang/CoffeeScript/24-game-Solve b/Lang/CoffeeScript/24-game-Solve new file mode 120000 index 0000000000..1c7a24570f --- /dev/null +++ b/Lang/CoffeeScript/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Factorial b/Lang/CoffeeScript/Factorial new file mode 120000 index 0000000000..401b9cab2b --- /dev/null +++ b/Lang/CoffeeScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Factors-of-a-Mersenne-number b/Lang/CoffeeScript/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..ce092f2afe --- /dev/null +++ b/Lang/CoffeeScript/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Factors-of-an-integer b/Lang/CoffeeScript/Factors-of-an-integer new file mode 120000 index 0000000000..564e0dcef1 --- /dev/null +++ b/Lang/CoffeeScript/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Fibonacci-sequence b/Lang/CoffeeScript/Fibonacci-sequence new file mode 120000 index 0000000000..a6d9b4787e --- /dev/null +++ b/Lang/CoffeeScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Find-the-missing-permutation b/Lang/CoffeeScript/Find-the-missing-permutation new file mode 120000 index 0000000000..a9723129f5 --- /dev/null +++ b/Lang/CoffeeScript/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/First-class-functions b/Lang/CoffeeScript/First-class-functions new file mode 120000 index 0000000000..0069476b8f --- /dev/null +++ b/Lang/CoffeeScript/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Flatten-a-list b/Lang/CoffeeScript/Flatten-a-list new file mode 120000 index 0000000000..2cce9ae038 --- /dev/null +++ b/Lang/CoffeeScript/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Forward-difference b/Lang/CoffeeScript/Forward-difference new file mode 120000 index 0000000000..04a2325b68 --- /dev/null +++ b/Lang/CoffeeScript/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Four-bit-adder b/Lang/CoffeeScript/Four-bit-adder new file mode 120000 index 0000000000..b82ffc64c7 --- /dev/null +++ b/Lang/CoffeeScript/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Function-definition b/Lang/CoffeeScript/Function-definition new file mode 120000 index 0000000000..557236561d --- /dev/null +++ b/Lang/CoffeeScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Gray-code b/Lang/CoffeeScript/Gray-code new file mode 120000 index 0000000000..2bb845af26 --- /dev/null +++ b/Lang/CoffeeScript/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Greatest-common-divisor b/Lang/CoffeeScript/Greatest-common-divisor new file mode 120000 index 0000000000..aee88e6736 --- /dev/null +++ b/Lang/CoffeeScript/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Greatest-element-of-a-list b/Lang/CoffeeScript/Greatest-element-of-a-list new file mode 120000 index 0000000000..4ca67947e8 --- /dev/null +++ b/Lang/CoffeeScript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Greatest-subsequential-sum b/Lang/CoffeeScript/Greatest-subsequential-sum new file mode 120000 index 0000000000..c5134546ed --- /dev/null +++ b/Lang/CoffeeScript/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Guess-the-number b/Lang/CoffeeScript/Guess-the-number new file mode 120000 index 0000000000..09c726e6c2 --- /dev/null +++ b/Lang/CoffeeScript/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hailstone-sequence b/Lang/CoffeeScript/Hailstone-sequence new file mode 120000 index 0000000000..61db845462 --- /dev/null +++ b/Lang/CoffeeScript/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hamming-numbers b/Lang/CoffeeScript/Hamming-numbers new file mode 120000 index 0000000000..570bfaec39 --- /dev/null +++ b/Lang/CoffeeScript/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Happy-numbers b/Lang/CoffeeScript/Happy-numbers new file mode 120000 index 0000000000..ba733d177b --- /dev/null +++ b/Lang/CoffeeScript/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hash-from-two-arrays b/Lang/CoffeeScript/Hash-from-two-arrays new file mode 120000 index 0000000000..096cace0ac --- /dev/null +++ b/Lang/CoffeeScript/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hello-world-Graphical b/Lang/CoffeeScript/Hello-world-Graphical new file mode 120000 index 0000000000..31d265af65 --- /dev/null +++ b/Lang/CoffeeScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hello-world-Standard-error b/Lang/CoffeeScript/Hello-world-Standard-error new file mode 120000 index 0000000000..16d6c904a3 --- /dev/null +++ b/Lang/CoffeeScript/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hello-world-Text b/Lang/CoffeeScript/Hello-world-Text new file mode 120000 index 0000000000..3d403f6323 --- /dev/null +++ b/Lang/CoffeeScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Here-document b/Lang/CoffeeScript/Here-document new file mode 120000 index 0000000000..1c98d63c84 --- /dev/null +++ b/Lang/CoffeeScript/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Higher-order-functions b/Lang/CoffeeScript/Higher-order-functions new file mode 120000 index 0000000000..ea0afefe1a --- /dev/null +++ b/Lang/CoffeeScript/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Horners-rule-for-polynomial-evaluation b/Lang/CoffeeScript/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..a4562f63d1 --- /dev/null +++ b/Lang/CoffeeScript/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Hostname b/Lang/CoffeeScript/Hostname new file mode 120000 index 0000000000..ddc3275a54 --- /dev/null +++ b/Lang/CoffeeScript/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Huffman-coding b/Lang/CoffeeScript/Huffman-coding new file mode 120000 index 0000000000..b164e3b203 --- /dev/null +++ b/Lang/CoffeeScript/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Integer-sequence b/Lang/CoffeeScript/Integer-sequence new file mode 120000 index 0000000000..e71c60920b --- /dev/null +++ b/Lang/CoffeeScript/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Inverted-index b/Lang/CoffeeScript/Inverted-index new file mode 120000 index 0000000000..206dc6bed0 --- /dev/null +++ b/Lang/CoffeeScript/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Inverted-syntax b/Lang/CoffeeScript/Inverted-syntax new file mode 120000 index 0000000000..6cb1a775ba --- /dev/null +++ b/Lang/CoffeeScript/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Knights-tour b/Lang/CoffeeScript/Knights-tour new file mode 120000 index 0000000000..0ca691dc98 --- /dev/null +++ b/Lang/CoffeeScript/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Knuths-algorithm-S b/Lang/CoffeeScript/Knuths-algorithm-S new file mode 120000 index 0000000000..f08141e9f3 --- /dev/null +++ b/Lang/CoffeeScript/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/LZW-compression b/Lang/CoffeeScript/LZW-compression new file mode 120000 index 0000000000..2f6c1680c6 --- /dev/null +++ b/Lang/CoffeeScript/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Langtons-ant b/Lang/CoffeeScript/Langtons-ant new file mode 120000 index 0000000000..f76d49b6c4 --- /dev/null +++ b/Lang/CoffeeScript/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Last-Friday-of-each-month b/Lang/CoffeeScript/Last-Friday-of-each-month new file mode 120000 index 0000000000..53f5cd46d5 --- /dev/null +++ b/Lang/CoffeeScript/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Levenshtein-distance b/Lang/CoffeeScript/Levenshtein-distance new file mode 120000 index 0000000000..12edd7ec0a --- /dev/null +++ b/Lang/CoffeeScript/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/List-comprehensions b/Lang/CoffeeScript/List-comprehensions new file mode 120000 index 0000000000..bba9aa080a --- /dev/null +++ b/Lang/CoffeeScript/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Long-multiplication b/Lang/CoffeeScript/Long-multiplication new file mode 120000 index 0000000000..f90101c906 --- /dev/null +++ b/Lang/CoffeeScript/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Longest-common-subsequence b/Lang/CoffeeScript/Longest-common-subsequence new file mode 120000 index 0000000000..55a9ebc793 --- /dev/null +++ b/Lang/CoffeeScript/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Loops-Do-while b/Lang/CoffeeScript/Loops-Do-while new file mode 120000 index 0000000000..cc23aed8c9 --- /dev/null +++ b/Lang/CoffeeScript/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Loops-Downward-for b/Lang/CoffeeScript/Loops-Downward-for new file mode 120000 index 0000000000..4c2e2674ff --- /dev/null +++ b/Lang/CoffeeScript/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Loops-Infinite b/Lang/CoffeeScript/Loops-Infinite new file mode 120000 index 0000000000..33b8b392ea --- /dev/null +++ b/Lang/CoffeeScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Loops-N-plus-one-half b/Lang/CoffeeScript/Loops-N-plus-one-half new file mode 120000 index 0000000000..81f97d3954 --- /dev/null +++ b/Lang/CoffeeScript/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Matrix-transposition b/Lang/CoffeeScript/Matrix-transposition new file mode 120000 index 0000000000..39dc1e75e6 --- /dev/null +++ b/Lang/CoffeeScript/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Multiplication-tables b/Lang/CoffeeScript/Multiplication-tables new file mode 120000 index 0000000000..726cac68b6 --- /dev/null +++ b/Lang/CoffeeScript/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Multisplit b/Lang/CoffeeScript/Multisplit new file mode 120000 index 0000000000..7418130cec --- /dev/null +++ b/Lang/CoffeeScript/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Mutual-recursion b/Lang/CoffeeScript/Mutual-recursion new file mode 120000 index 0000000000..9df340c695 --- /dev/null +++ b/Lang/CoffeeScript/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/CoffeeScript \ No newline at end of file diff --git a/Lang/ColdFusion/File-IO b/Lang/ColdFusion/File-IO new file mode 120000 index 0000000000..5c79c3cb9b --- /dev/null +++ b/Lang/ColdFusion/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/File-size b/Lang/ColdFusion/File-size new file mode 120000 index 0000000000..b81e62b3b7 --- /dev/null +++ b/Lang/ColdFusion/File-size @@ -0,0 +1 @@ +../../Task/File-size/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Function-definition b/Lang/ColdFusion/Function-definition new file mode 120000 index 0000000000..aac92e5461 --- /dev/null +++ b/Lang/ColdFusion/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Generic-swap b/Lang/ColdFusion/Generic-swap new file mode 120000 index 0000000000..b8ea871788 --- /dev/null +++ b/Lang/ColdFusion/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/HTTP b/Lang/ColdFusion/HTTP new file mode 120000 index 0000000000..17dd4f54dc --- /dev/null +++ b/Lang/ColdFusion/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Hash-from-two-arrays b/Lang/ColdFusion/Hash-from-two-arrays new file mode 120000 index 0000000000..cdfd2c91d5 --- /dev/null +++ b/Lang/ColdFusion/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Hello-world-Text b/Lang/ColdFusion/Hello-world-Text new file mode 120000 index 0000000000..98e414760d --- /dev/null +++ b/Lang/ColdFusion/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Logical-operations b/Lang/ColdFusion/Logical-operations new file mode 120000 index 0000000000..43b27fff48 --- /dev/null +++ b/Lang/ColdFusion/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-Continue b/Lang/ColdFusion/Loops-Continue new file mode 120000 index 0000000000..bf4f7bdad1 --- /dev/null +++ b/Lang/ColdFusion/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-Do-while b/Lang/ColdFusion/Loops-Do-while new file mode 120000 index 0000000000..8cd6420222 --- /dev/null +++ b/Lang/ColdFusion/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-Downward-for b/Lang/ColdFusion/Loops-Downward-for new file mode 120000 index 0000000000..0aa743eac4 --- /dev/null +++ b/Lang/ColdFusion/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-For b/Lang/ColdFusion/Loops-For new file mode 120000 index 0000000000..5627081121 --- /dev/null +++ b/Lang/ColdFusion/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-Infinite b/Lang/ColdFusion/Loops-Infinite new file mode 120000 index 0000000000..fb0e633a4d --- /dev/null +++ b/Lang/ColdFusion/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-N-plus-one-half b/Lang/ColdFusion/Loops-N-plus-one-half new file mode 120000 index 0000000000..a51f6f0507 --- /dev/null +++ b/Lang/ColdFusion/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Loops-While b/Lang/ColdFusion/Loops-While new file mode 120000 index 0000000000..8ef1bea478 --- /dev/null +++ b/Lang/ColdFusion/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Monty-Hall-problem b/Lang/ColdFusion/Monty-Hall-problem new file mode 120000 index 0000000000..5dc721c533 --- /dev/null +++ b/Lang/ColdFusion/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/ColdFusion \ No newline at end of file diff --git a/Lang/Common-Lisp/24-game-Solve b/Lang/Common-Lisp/24-game-Solve new file mode 120000 index 0000000000..0503acceaf --- /dev/null +++ b/Lang/Common-Lisp/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Arbitrary-precision-integers-included b/Lang/Common-Lisp/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..c00b9cf409 --- /dev/null +++ b/Lang/Common-Lisp/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Factorial b/Lang/Common-Lisp/Factorial new file mode 120000 index 0000000000..2f5cfe678e --- /dev/null +++ b/Lang/Common-Lisp/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Factors-of-a-Mersenne-number b/Lang/Common-Lisp/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..4f93e72f70 --- /dev/null +++ b/Lang/Common-Lisp/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Factors-of-an-integer b/Lang/Common-Lisp/Factors-of-an-integer new file mode 120000 index 0000000000..b476be9ca4 --- /dev/null +++ b/Lang/Common-Lisp/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Fibonacci-sequence b/Lang/Common-Lisp/Fibonacci-sequence new file mode 120000 index 0000000000..f16a60516a --- /dev/null +++ b/Lang/Common-Lisp/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/File-IO b/Lang/Common-Lisp/File-IO new file mode 120000 index 0000000000..1ebbe1cc50 --- /dev/null +++ b/Lang/Common-Lisp/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/File-modification-time b/Lang/Common-Lisp/File-modification-time new file mode 120000 index 0000000000..25c000449f --- /dev/null +++ b/Lang/Common-Lisp/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/File-size b/Lang/Common-Lisp/File-size new file mode 120000 index 0000000000..a377edd2f4 --- /dev/null +++ b/Lang/Common-Lisp/File-size @@ -0,0 +1 @@ +../../Task/File-size/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Filter b/Lang/Common-Lisp/Filter new file mode 120000 index 0000000000..b5cd8ffcb7 --- /dev/null +++ b/Lang/Common-Lisp/Filter @@ -0,0 +1 @@ +../../Task/Filter/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Find-limit-of-recursion b/Lang/Common-Lisp/Find-limit-of-recursion new file mode 120000 index 0000000000..1603a6fb40 --- /dev/null +++ b/Lang/Common-Lisp/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Find-the-missing-permutation b/Lang/Common-Lisp/Find-the-missing-permutation new file mode 120000 index 0000000000..720bda3ec9 --- /dev/null +++ b/Lang/Common-Lisp/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/First-class-functions b/Lang/Common-Lisp/First-class-functions new file mode 120000 index 0000000000..3f5de8f1b1 --- /dev/null +++ b/Lang/Common-Lisp/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/First-class-functions-Use-numbers-analogously b/Lang/Common-Lisp/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..dc43d5c2ad --- /dev/null +++ b/Lang/Common-Lisp/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Flatten-a-list b/Lang/Common-Lisp/Flatten-a-list new file mode 120000 index 0000000000..73d4a38d2b --- /dev/null +++ b/Lang/Common-Lisp/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Fork b/Lang/Common-Lisp/Fork new file mode 120000 index 0000000000..e1a6ed94b2 --- /dev/null +++ b/Lang/Common-Lisp/Fork @@ -0,0 +1 @@ +../../Task/Fork/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Formal-power-series b/Lang/Common-Lisp/Formal-power-series new file mode 120000 index 0000000000..fbde2277cb --- /dev/null +++ b/Lang/Common-Lisp/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Formatted-numeric-output b/Lang/Common-Lisp/Formatted-numeric-output new file mode 120000 index 0000000000..eae3ebd958 --- /dev/null +++ b/Lang/Common-Lisp/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Forward-difference b/Lang/Common-Lisp/Forward-difference new file mode 120000 index 0000000000..e9267ec7cb --- /dev/null +++ b/Lang/Common-Lisp/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Function-composition b/Lang/Common-Lisp/Function-composition new file mode 120000 index 0000000000..b5b5eaa3fe --- /dev/null +++ b/Lang/Common-Lisp/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Function-definition b/Lang/Common-Lisp/Function-definition new file mode 120000 index 0000000000..32a97eb401 --- /dev/null +++ b/Lang/Common-Lisp/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Function-prototype b/Lang/Common-Lisp/Function-prototype new file mode 120000 index 0000000000..8b1c3644b1 --- /dev/null +++ b/Lang/Common-Lisp/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Gamma-function b/Lang/Common-Lisp/Gamma-function new file mode 120000 index 0000000000..71f1b18c3a --- /dev/null +++ b/Lang/Common-Lisp/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Generator-Exponential b/Lang/Common-Lisp/Generator-Exponential new file mode 120000 index 0000000000..94cd4cd840 --- /dev/null +++ b/Lang/Common-Lisp/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Generic-swap b/Lang/Common-Lisp/Generic-swap new file mode 120000 index 0000000000..3de0e29c67 --- /dev/null +++ b/Lang/Common-Lisp/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Gray-code b/Lang/Common-Lisp/Gray-code new file mode 120000 index 0000000000..b961eeb22a --- /dev/null +++ b/Lang/Common-Lisp/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Grayscale-image b/Lang/Common-Lisp/Grayscale-image new file mode 120000 index 0000000000..bb27fa36bd --- /dev/null +++ b/Lang/Common-Lisp/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Greatest-common-divisor b/Lang/Common-Lisp/Greatest-common-divisor new file mode 120000 index 0000000000..155ff606d4 --- /dev/null +++ b/Lang/Common-Lisp/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Greatest-element-of-a-list b/Lang/Common-Lisp/Greatest-element-of-a-list new file mode 120000 index 0000000000..f520e1f6e2 --- /dev/null +++ b/Lang/Common-Lisp/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Greatest-subsequential-sum b/Lang/Common-Lisp/Greatest-subsequential-sum new file mode 120000 index 0000000000..be1a208c17 --- /dev/null +++ b/Lang/Common-Lisp/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Guess-the-number b/Lang/Common-Lisp/Guess-the-number new file mode 120000 index 0000000000..57ce9469cf --- /dev/null +++ b/Lang/Common-Lisp/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Guess-the-number-With-feedback b/Lang/Common-Lisp/Guess-the-number-With-feedback new file mode 120000 index 0000000000..854ef85919 --- /dev/null +++ b/Lang/Common-Lisp/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/HTTP b/Lang/Common-Lisp/HTTP new file mode 120000 index 0000000000..fdf5abba88 --- /dev/null +++ b/Lang/Common-Lisp/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/HTTPS b/Lang/Common-Lisp/HTTPS new file mode 120000 index 0000000000..b4b0d25275 --- /dev/null +++ b/Lang/Common-Lisp/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hailstone-sequence b/Lang/Common-Lisp/Hailstone-sequence new file mode 120000 index 0000000000..0c462080f1 --- /dev/null +++ b/Lang/Common-Lisp/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hamming-numbers b/Lang/Common-Lisp/Hamming-numbers new file mode 120000 index 0000000000..7b190c0ce6 --- /dev/null +++ b/Lang/Common-Lisp/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Happy-numbers b/Lang/Common-Lisp/Happy-numbers new file mode 120000 index 0000000000..beb81e5d7b --- /dev/null +++ b/Lang/Common-Lisp/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hash-from-two-arrays b/Lang/Common-Lisp/Hash-from-two-arrays new file mode 120000 index 0000000000..7204ff429b --- /dev/null +++ b/Lang/Common-Lisp/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Haversine-formula b/Lang/Common-Lisp/Haversine-formula new file mode 120000 index 0000000000..b942bd5122 --- /dev/null +++ b/Lang/Common-Lisp/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hello-world-Graphical b/Lang/Common-Lisp/Hello-world-Graphical new file mode 120000 index 0000000000..8310639845 --- /dev/null +++ b/Lang/Common-Lisp/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hello-world-Newline-omission b/Lang/Common-Lisp/Hello-world-Newline-omission new file mode 120000 index 0000000000..088fedbd80 --- /dev/null +++ b/Lang/Common-Lisp/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hello-world-Standard-error b/Lang/Common-Lisp/Hello-world-Standard-error new file mode 120000 index 0000000000..54ee1a777e --- /dev/null +++ b/Lang/Common-Lisp/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hello-world-Text b/Lang/Common-Lisp/Hello-world-Text new file mode 120000 index 0000000000..abf0cf5881 --- /dev/null +++ b/Lang/Common-Lisp/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Higher-order-functions b/Lang/Common-Lisp/Higher-order-functions new file mode 120000 index 0000000000..013d858b83 --- /dev/null +++ b/Lang/Common-Lisp/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hofstadter-Conway-$10,000-sequence b/Lang/Common-Lisp/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..0d883943ae --- /dev/null +++ b/Lang/Common-Lisp/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hofstadter-Figure-Figure-sequences b/Lang/Common-Lisp/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..f402450ef9 --- /dev/null +++ b/Lang/Common-Lisp/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hofstadter-Q-sequence b/Lang/Common-Lisp/Hofstadter-Q-sequence new file mode 120000 index 0000000000..9ab97859fb --- /dev/null +++ b/Lang/Common-Lisp/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Holidays-related-to-Easter b/Lang/Common-Lisp/Holidays-related-to-Easter new file mode 120000 index 0000000000..ae46dd9202 --- /dev/null +++ b/Lang/Common-Lisp/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Horners-rule-for-polynomial-evaluation b/Lang/Common-Lisp/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..62658bf182 --- /dev/null +++ b/Lang/Common-Lisp/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Host-introspection b/Lang/Common-Lisp/Host-introspection new file mode 120000 index 0000000000..5083a7edca --- /dev/null +++ b/Lang/Common-Lisp/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Hostname b/Lang/Common-Lisp/Hostname new file mode 120000 index 0000000000..3d8c39936a --- /dev/null +++ b/Lang/Common-Lisp/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Huffman-coding b/Lang/Common-Lisp/Huffman-coding new file mode 120000 index 0000000000..a3832c19f4 --- /dev/null +++ b/Lang/Common-Lisp/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Identity-matrix b/Lang/Common-Lisp/Identity-matrix new file mode 120000 index 0000000000..50463dc08b --- /dev/null +++ b/Lang/Common-Lisp/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Increment-a-numerical-string b/Lang/Common-Lisp/Increment-a-numerical-string new file mode 120000 index 0000000000..6c86f5db2c --- /dev/null +++ b/Lang/Common-Lisp/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Inheritance-Multiple b/Lang/Common-Lisp/Inheritance-Multiple new file mode 120000 index 0000000000..010947221f --- /dev/null +++ b/Lang/Common-Lisp/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Input-loop b/Lang/Common-Lisp/Input-loop new file mode 120000 index 0000000000..e9276ca4ca --- /dev/null +++ b/Lang/Common-Lisp/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Integer-comparison b/Lang/Common-Lisp/Integer-comparison new file mode 120000 index 0000000000..11fcb6edd8 --- /dev/null +++ b/Lang/Common-Lisp/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Integer-sequence b/Lang/Common-Lisp/Integer-sequence new file mode 120000 index 0000000000..38ad0e7def --- /dev/null +++ b/Lang/Common-Lisp/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Interactive-programming b/Lang/Common-Lisp/Interactive-programming new file mode 120000 index 0000000000..40a12cb1c0 --- /dev/null +++ b/Lang/Common-Lisp/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Introspection b/Lang/Common-Lisp/Introspection new file mode 120000 index 0000000000..8a9bd83f24 --- /dev/null +++ b/Lang/Common-Lisp/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Inverted-index b/Lang/Common-Lisp/Inverted-index new file mode 120000 index 0000000000..c6357e95ea --- /dev/null +++ b/Lang/Common-Lisp/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Inverted-syntax b/Lang/Common-Lisp/Inverted-syntax new file mode 120000 index 0000000000..e401fb3ea5 --- /dev/null +++ b/Lang/Common-Lisp/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Jensens-Device b/Lang/Common-Lisp/Jensens-Device new file mode 120000 index 0000000000..a1f8c056c7 --- /dev/null +++ b/Lang/Common-Lisp/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Josephus-problem b/Lang/Common-Lisp/Josephus-problem new file mode 120000 index 0000000000..2eaaaa3f9d --- /dev/null +++ b/Lang/Common-Lisp/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Kaprekar-numbers b/Lang/Common-Lisp/Kaprekar-numbers new file mode 120000 index 0000000000..243aa33c6d --- /dev/null +++ b/Lang/Common-Lisp/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Common-Lisp/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..bea03fade5 --- /dev/null +++ b/Lang/Common-Lisp/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Knapsack-problem-0-1 b/Lang/Common-Lisp/Knapsack-problem-0-1 new file mode 120000 index 0000000000..8efe12f8ff --- /dev/null +++ b/Lang/Common-Lisp/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Knapsack-problem-Bounded b/Lang/Common-Lisp/Knapsack-problem-Bounded new file mode 120000 index 0000000000..9bf3bf50f3 --- /dev/null +++ b/Lang/Common-Lisp/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Knapsack-problem-Unbounded b/Lang/Common-Lisp/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..1a4a841069 --- /dev/null +++ b/Lang/Common-Lisp/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Knuths-algorithm-S b/Lang/Common-Lisp/Knuths-algorithm-S new file mode 120000 index 0000000000..373830e4be --- /dev/null +++ b/Lang/Common-Lisp/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/LU-decomposition b/Lang/Common-Lisp/LU-decomposition new file mode 120000 index 0000000000..27b59e0590 --- /dev/null +++ b/Lang/Common-Lisp/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/LZW-compression b/Lang/Common-Lisp/LZW-compression new file mode 120000 index 0000000000..4cbdf436bb --- /dev/null +++ b/Lang/Common-Lisp/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Langtons-ant b/Lang/Common-Lisp/Langtons-ant new file mode 120000 index 0000000000..496a988ef3 --- /dev/null +++ b/Lang/Common-Lisp/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Leap-year b/Lang/Common-Lisp/Leap-year new file mode 120000 index 0000000000..7420c3f522 --- /dev/null +++ b/Lang/Common-Lisp/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Least-common-multiple b/Lang/Common-Lisp/Least-common-multiple new file mode 120000 index 0000000000..4f2ed3c451 --- /dev/null +++ b/Lang/Common-Lisp/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Letter-frequency b/Lang/Common-Lisp/Letter-frequency new file mode 120000 index 0000000000..20a74426c8 --- /dev/null +++ b/Lang/Common-Lisp/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Levenshtein-distance b/Lang/Common-Lisp/Levenshtein-distance new file mode 120000 index 0000000000..8eb7fb7636 --- /dev/null +++ b/Lang/Common-Lisp/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Linear-congruential-generator b/Lang/Common-Lisp/Linear-congruential-generator new file mode 120000 index 0000000000..ec39d23a0b --- /dev/null +++ b/Lang/Common-Lisp/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/List-comprehensions b/Lang/Common-Lisp/List-comprehensions new file mode 120000 index 0000000000..117fac605b --- /dev/null +++ b/Lang/Common-Lisp/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Literals-Integer b/Lang/Common-Lisp/Literals-Integer new file mode 120000 index 0000000000..234ce69cb2 --- /dev/null +++ b/Lang/Common-Lisp/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Literals-String b/Lang/Common-Lisp/Literals-String new file mode 120000 index 0000000000..ff35ca5b53 --- /dev/null +++ b/Lang/Common-Lisp/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Logical-operations b/Lang/Common-Lisp/Logical-operations new file mode 120000 index 0000000000..e630c01d2c --- /dev/null +++ b/Lang/Common-Lisp/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Long-multiplication b/Lang/Common-Lisp/Long-multiplication new file mode 120000 index 0000000000..5963fda216 --- /dev/null +++ b/Lang/Common-Lisp/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Longest-common-subsequence b/Lang/Common-Lisp/Longest-common-subsequence new file mode 120000 index 0000000000..a35f4a23b1 --- /dev/null +++ b/Lang/Common-Lisp/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Look-and-say-sequence b/Lang/Common-Lisp/Look-and-say-sequence new file mode 120000 index 0000000000..e05ab59bbd --- /dev/null +++ b/Lang/Common-Lisp/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loop-over-multiple-arrays-simultaneously b/Lang/Common-Lisp/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..cef7bbb406 --- /dev/null +++ b/Lang/Common-Lisp/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Break b/Lang/Common-Lisp/Loops-Break new file mode 120000 index 0000000000..5f465ff4ad --- /dev/null +++ b/Lang/Common-Lisp/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Continue b/Lang/Common-Lisp/Loops-Continue new file mode 120000 index 0000000000..f4ab5a6ef0 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Do-while b/Lang/Common-Lisp/Loops-Do-while new file mode 120000 index 0000000000..bc6b5db349 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Downward-for b/Lang/Common-Lisp/Loops-Downward-for new file mode 120000 index 0000000000..5e69a773f0 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-For b/Lang/Common-Lisp/Loops-For new file mode 120000 index 0000000000..1e1e9d3da2 --- /dev/null +++ b/Lang/Common-Lisp/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-For-with-a-specified-step b/Lang/Common-Lisp/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..a434cd3c8e --- /dev/null +++ b/Lang/Common-Lisp/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Foreach b/Lang/Common-Lisp/Loops-Foreach new file mode 120000 index 0000000000..6aeab6f986 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Infinite b/Lang/Common-Lisp/Loops-Infinite new file mode 120000 index 0000000000..22c2b34e06 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-N-plus-one-half b/Lang/Common-Lisp/Loops-N-plus-one-half new file mode 120000 index 0000000000..de1670a5fb --- /dev/null +++ b/Lang/Common-Lisp/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-Nested b/Lang/Common-Lisp/Loops-Nested new file mode 120000 index 0000000000..66ec9a7180 --- /dev/null +++ b/Lang/Common-Lisp/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Loops-While b/Lang/Common-Lisp/Loops-While new file mode 120000 index 0000000000..71a9a7cc3c --- /dev/null +++ b/Lang/Common-Lisp/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Luhn-test-of-credit-card-numbers b/Lang/Common-Lisp/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..e9015b8856 --- /dev/null +++ b/Lang/Common-Lisp/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/MD5 b/Lang/Common-Lisp/MD5 new file mode 120000 index 0000000000..bb5cca322e --- /dev/null +++ b/Lang/Common-Lisp/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Man-or-boy-test b/Lang/Common-Lisp/Man-or-boy-test new file mode 120000 index 0000000000..ebe4865883 --- /dev/null +++ b/Lang/Common-Lisp/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Map-range b/Lang/Common-Lisp/Map-range new file mode 120000 index 0000000000..45ba373f86 --- /dev/null +++ b/Lang/Common-Lisp/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Matrix-exponentiation-operator b/Lang/Common-Lisp/Matrix-exponentiation-operator new file mode 120000 index 0000000000..792eedd005 --- /dev/null +++ b/Lang/Common-Lisp/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Matrix-multiplication b/Lang/Common-Lisp/Matrix-multiplication new file mode 120000 index 0000000000..05db649477 --- /dev/null +++ b/Lang/Common-Lisp/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Matrix-transposition b/Lang/Common-Lisp/Matrix-transposition new file mode 120000 index 0000000000..816c53ef75 --- /dev/null +++ b/Lang/Common-Lisp/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Maze-generation b/Lang/Common-Lisp/Maze-generation new file mode 120000 index 0000000000..4e5c9ba2ba --- /dev/null +++ b/Lang/Common-Lisp/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Memory-allocation b/Lang/Common-Lisp/Memory-allocation new file mode 120000 index 0000000000..c9eb7a6205 --- /dev/null +++ b/Lang/Common-Lisp/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Menu b/Lang/Common-Lisp/Menu new file mode 120000 index 0000000000..2641db923d --- /dev/null +++ b/Lang/Common-Lisp/Menu @@ -0,0 +1 @@ +../../Task/Menu/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Metaprogramming b/Lang/Common-Lisp/Metaprogramming new file mode 120000 index 0000000000..d47f0e264a --- /dev/null +++ b/Lang/Common-Lisp/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Miller-Rabin-primality-test b/Lang/Common-Lisp/Miller-Rabin-primality-test new file mode 120000 index 0000000000..4f8dbe695d --- /dev/null +++ b/Lang/Common-Lisp/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Minesweeper-game b/Lang/Common-Lisp/Minesweeper-game new file mode 120000 index 0000000000..2152e84b78 --- /dev/null +++ b/Lang/Common-Lisp/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Modular-exponentiation b/Lang/Common-Lisp/Modular-exponentiation new file mode 120000 index 0000000000..cbdb1bcc09 --- /dev/null +++ b/Lang/Common-Lisp/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Monte-Carlo-methods b/Lang/Common-Lisp/Monte-Carlo-methods new file mode 120000 index 0000000000..3f658f6f1a --- /dev/null +++ b/Lang/Common-Lisp/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Monty-Hall-problem b/Lang/Common-Lisp/Monty-Hall-problem new file mode 120000 index 0000000000..4ecfb21df7 --- /dev/null +++ b/Lang/Common-Lisp/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Multifactorial b/Lang/Common-Lisp/Multifactorial new file mode 120000 index 0000000000..5f3e20f43b --- /dev/null +++ b/Lang/Common-Lisp/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Multiple-distinct-objects b/Lang/Common-Lisp/Multiple-distinct-objects new file mode 120000 index 0000000000..38138d4e03 --- /dev/null +++ b/Lang/Common-Lisp/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Multiple-regression b/Lang/Common-Lisp/Multiple-regression new file mode 120000 index 0000000000..a6a572e1c9 --- /dev/null +++ b/Lang/Common-Lisp/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Multiplication-tables b/Lang/Common-Lisp/Multiplication-tables new file mode 120000 index 0000000000..1e9584a1c9 --- /dev/null +++ b/Lang/Common-Lisp/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Mutual-recursion b/Lang/Common-Lisp/Mutual-recursion new file mode 120000 index 0000000000..19a7c28076 --- /dev/null +++ b/Lang/Common-Lisp/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Common-Lisp \ No newline at end of file diff --git a/Lang/Component-Pascal/Hello-world-Text b/Lang/Component-Pascal/Hello-world-Text new file mode 120000 index 0000000000..4434154df9 --- /dev/null +++ b/Lang/Component-Pascal/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Component-Pascal \ No newline at end of file diff --git a/Lang/Crack/Hello-world-Text b/Lang/Crack/Hello-world-Text new file mode 120000 index 0000000000..14b5b41668 --- /dev/null +++ b/Lang/Crack/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Crack \ No newline at end of file diff --git a/Lang/Crack/Loops-While b/Lang/Crack/Loops-While new file mode 120000 index 0000000000..27ab015670 --- /dev/null +++ b/Lang/Crack/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Crack \ No newline at end of file diff --git a/Lang/D/24-game-Solve b/Lang/D/24-game-Solve new file mode 120000 index 0000000000..3d5aae3642 --- /dev/null +++ b/Lang/D/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/D \ No newline at end of file diff --git a/Lang/D/Arbitrary-precision-integers-included b/Lang/D/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..cb46f2eae2 --- /dev/null +++ b/Lang/D/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/D \ No newline at end of file diff --git a/Lang/D/Factorial b/Lang/D/Factorial new file mode 120000 index 0000000000..3c89deefb6 --- /dev/null +++ b/Lang/D/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/D \ No newline at end of file diff --git a/Lang/D/Factors-of-a-Mersenne-number b/Lang/D/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..48f9b31adc --- /dev/null +++ b/Lang/D/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/D \ No newline at end of file diff --git a/Lang/D/Factors-of-an-integer b/Lang/D/Factors-of-an-integer new file mode 120000 index 0000000000..9bf938831c --- /dev/null +++ b/Lang/D/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/D \ No newline at end of file diff --git a/Lang/D/Fast-Fourier-transform b/Lang/D/Fast-Fourier-transform new file mode 120000 index 0000000000..71a6681c62 --- /dev/null +++ b/Lang/D/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/D \ No newline at end of file diff --git a/Lang/D/Fibonacci-n-step-number-sequences b/Lang/D/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..2dd4ce4a83 --- /dev/null +++ b/Lang/D/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/D \ No newline at end of file diff --git a/Lang/D/Fibonacci-sequence b/Lang/D/Fibonacci-sequence new file mode 120000 index 0000000000..22849c6cd2 --- /dev/null +++ b/Lang/D/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/D \ No newline at end of file diff --git a/Lang/D/File-IO b/Lang/D/File-IO new file mode 120000 index 0000000000..fd653d7b4c --- /dev/null +++ b/Lang/D/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/D \ No newline at end of file diff --git a/Lang/D/File-modification-time b/Lang/D/File-modification-time new file mode 120000 index 0000000000..9ce7baa087 --- /dev/null +++ b/Lang/D/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/D \ No newline at end of file diff --git a/Lang/D/File-size b/Lang/D/File-size new file mode 120000 index 0000000000..7b08ce8c56 --- /dev/null +++ b/Lang/D/File-size @@ -0,0 +1 @@ +../../Task/File-size/D \ No newline at end of file diff --git a/Lang/D/Filter b/Lang/D/Filter new file mode 120000 index 0000000000..b7542904e5 --- /dev/null +++ b/Lang/D/Filter @@ -0,0 +1 @@ +../../Task/Filter/D \ No newline at end of file diff --git a/Lang/D/Find-common-directory-path b/Lang/D/Find-common-directory-path new file mode 120000 index 0000000000..3fc0e61b32 --- /dev/null +++ b/Lang/D/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/D \ No newline at end of file diff --git a/Lang/D/Find-limit-of-recursion b/Lang/D/Find-limit-of-recursion new file mode 120000 index 0000000000..a0c0952c73 --- /dev/null +++ b/Lang/D/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/D \ No newline at end of file diff --git a/Lang/D/Find-the-missing-permutation b/Lang/D/Find-the-missing-permutation new file mode 120000 index 0000000000..9bca7a9139 --- /dev/null +++ b/Lang/D/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/D \ No newline at end of file diff --git a/Lang/D/First-class-functions b/Lang/D/First-class-functions new file mode 120000 index 0000000000..98f0d5d20f --- /dev/null +++ b/Lang/D/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/D \ No newline at end of file diff --git a/Lang/D/First-class-functions-Use-numbers-analogously b/Lang/D/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..81229a40e5 --- /dev/null +++ b/Lang/D/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/D \ No newline at end of file diff --git a/Lang/D/Five-weekends b/Lang/D/Five-weekends new file mode 120000 index 0000000000..f808f8d317 --- /dev/null +++ b/Lang/D/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/D \ No newline at end of file diff --git a/Lang/D/Flatten-a-list b/Lang/D/Flatten-a-list new file mode 120000 index 0000000000..abd583c423 --- /dev/null +++ b/Lang/D/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/D \ No newline at end of file diff --git a/Lang/D/Flow-control-structures b/Lang/D/Flow-control-structures new file mode 120000 index 0000000000..895a822023 --- /dev/null +++ b/Lang/D/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/D \ No newline at end of file diff --git a/Lang/D/Floyds-triangle b/Lang/D/Floyds-triangle new file mode 120000 index 0000000000..db38e0987d --- /dev/null +++ b/Lang/D/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/D \ No newline at end of file diff --git a/Lang/D/Formatted-numeric-output b/Lang/D/Formatted-numeric-output new file mode 120000 index 0000000000..b28c6bb499 --- /dev/null +++ b/Lang/D/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/D \ No newline at end of file diff --git a/Lang/D/Forward-difference b/Lang/D/Forward-difference new file mode 120000 index 0000000000..129205adf6 --- /dev/null +++ b/Lang/D/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/D \ No newline at end of file diff --git a/Lang/D/Four-bit-adder b/Lang/D/Four-bit-adder new file mode 120000 index 0000000000..59d2fdd11b --- /dev/null +++ b/Lang/D/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/D \ No newline at end of file diff --git a/Lang/D/Fractal-tree b/Lang/D/Fractal-tree new file mode 120000 index 0000000000..0a1f45ae61 --- /dev/null +++ b/Lang/D/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/D \ No newline at end of file diff --git a/Lang/D/Function-composition b/Lang/D/Function-composition new file mode 120000 index 0000000000..6615c36a20 --- /dev/null +++ b/Lang/D/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/D \ No newline at end of file diff --git a/Lang/D/Function-definition b/Lang/D/Function-definition new file mode 120000 index 0000000000..91301cc529 --- /dev/null +++ b/Lang/D/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/D \ No newline at end of file diff --git a/Lang/D/Function-prototype b/Lang/D/Function-prototype new file mode 120000 index 0000000000..1a315cacd5 --- /dev/null +++ b/Lang/D/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/D \ No newline at end of file diff --git a/Lang/D/Galton-box-animation b/Lang/D/Galton-box-animation new file mode 120000 index 0000000000..b8238a251a --- /dev/null +++ b/Lang/D/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/D \ No newline at end of file diff --git a/Lang/D/Gamma-function b/Lang/D/Gamma-function new file mode 120000 index 0000000000..cdd3930ad7 --- /dev/null +++ b/Lang/D/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/D \ No newline at end of file diff --git a/Lang/D/Generator-Exponential b/Lang/D/Generator-Exponential new file mode 120000 index 0000000000..6d6dd55f4b --- /dev/null +++ b/Lang/D/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/D \ No newline at end of file diff --git a/Lang/D/Generic-swap b/Lang/D/Generic-swap new file mode 120000 index 0000000000..5830c1b273 --- /dev/null +++ b/Lang/D/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/D \ No newline at end of file diff --git a/Lang/D/Globally-replace-text-in-several-files b/Lang/D/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..80d532ee0d --- /dev/null +++ b/Lang/D/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/D \ No newline at end of file diff --git a/Lang/D/Gray-code b/Lang/D/Gray-code new file mode 120000 index 0000000000..459c267ee1 --- /dev/null +++ b/Lang/D/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/D \ No newline at end of file diff --git a/Lang/D/Grayscale-image b/Lang/D/Grayscale-image new file mode 120000 index 0000000000..a221bc7b5b --- /dev/null +++ b/Lang/D/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/D \ No newline at end of file diff --git a/Lang/D/Greatest-common-divisor b/Lang/D/Greatest-common-divisor new file mode 120000 index 0000000000..c5008445e6 --- /dev/null +++ b/Lang/D/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/D \ No newline at end of file diff --git a/Lang/D/Greatest-element-of-a-list b/Lang/D/Greatest-element-of-a-list new file mode 120000 index 0000000000..a8e2d807cf --- /dev/null +++ b/Lang/D/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/D \ No newline at end of file diff --git a/Lang/D/Greatest-subsequential-sum b/Lang/D/Greatest-subsequential-sum new file mode 120000 index 0000000000..a2a9e77deb --- /dev/null +++ b/Lang/D/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/D \ No newline at end of file diff --git a/Lang/D/Guess-the-number b/Lang/D/Guess-the-number new file mode 120000 index 0000000000..4059ccd356 --- /dev/null +++ b/Lang/D/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/D \ No newline at end of file diff --git a/Lang/D/Guess-the-number-With-feedback b/Lang/D/Guess-the-number-With-feedback new file mode 120000 index 0000000000..e8037d1499 --- /dev/null +++ b/Lang/D/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/D \ No newline at end of file diff --git a/Lang/D/Guess-the-number-With-feedback-player b/Lang/D/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..2b6db6ea5b --- /dev/null +++ b/Lang/D/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/D \ No newline at end of file diff --git a/Lang/D/HTTP b/Lang/D/HTTP new file mode 120000 index 0000000000..5f5d7a17b9 --- /dev/null +++ b/Lang/D/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/D \ No newline at end of file diff --git a/Lang/D/Hailstone-sequence b/Lang/D/Hailstone-sequence new file mode 120000 index 0000000000..ec8671cd8d --- /dev/null +++ b/Lang/D/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/D \ No newline at end of file diff --git a/Lang/D/Hamming-numbers b/Lang/D/Hamming-numbers new file mode 120000 index 0000000000..8def7646ef --- /dev/null +++ b/Lang/D/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/D \ No newline at end of file diff --git a/Lang/D/Happy-numbers b/Lang/D/Happy-numbers new file mode 120000 index 0000000000..9e5ec1241d --- /dev/null +++ b/Lang/D/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/D \ No newline at end of file diff --git a/Lang/D/Harshad-or-Niven-series b/Lang/D/Harshad-or-Niven-series new file mode 120000 index 0000000000..93d3b32e4b --- /dev/null +++ b/Lang/D/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/D \ No newline at end of file diff --git a/Lang/D/Hash-from-two-arrays b/Lang/D/Hash-from-two-arrays new file mode 120000 index 0000000000..3263fb3555 --- /dev/null +++ b/Lang/D/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/D \ No newline at end of file diff --git a/Lang/D/Haversine-formula b/Lang/D/Haversine-formula new file mode 120000 index 0000000000..51bf6f7692 --- /dev/null +++ b/Lang/D/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Graphical b/Lang/D/Hello-world-Graphical new file mode 120000 index 0000000000..3840617bde --- /dev/null +++ b/Lang/D/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Line-printer b/Lang/D/Hello-world-Line-printer new file mode 120000 index 0000000000..7e4bb71a2a --- /dev/null +++ b/Lang/D/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Newline-omission b/Lang/D/Hello-world-Newline-omission new file mode 120000 index 0000000000..cc27ac9ae6 --- /dev/null +++ b/Lang/D/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Standard-error b/Lang/D/Hello-world-Standard-error new file mode 120000 index 0000000000..d6c36c7440 --- /dev/null +++ b/Lang/D/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Text b/Lang/D/Hello-world-Text new file mode 120000 index 0000000000..7bc73e035f --- /dev/null +++ b/Lang/D/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/D \ No newline at end of file diff --git a/Lang/D/Hello-world-Web-server b/Lang/D/Hello-world-Web-server new file mode 120000 index 0000000000..8045c45eae --- /dev/null +++ b/Lang/D/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/D \ No newline at end of file diff --git a/Lang/D/Here-document b/Lang/D/Here-document new file mode 120000 index 0000000000..121f51ac54 --- /dev/null +++ b/Lang/D/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/D \ No newline at end of file diff --git a/Lang/D/Higher-order-functions b/Lang/D/Higher-order-functions new file mode 120000 index 0000000000..89004df697 --- /dev/null +++ b/Lang/D/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/D \ No newline at end of file diff --git a/Lang/D/History-variables b/Lang/D/History-variables new file mode 120000 index 0000000000..04557a7052 --- /dev/null +++ b/Lang/D/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/D \ No newline at end of file diff --git a/Lang/D/Hofstadter-Conway-$10,000-sequence b/Lang/D/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..972d7a6e70 --- /dev/null +++ b/Lang/D/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/D \ No newline at end of file diff --git a/Lang/D/Hofstadter-Figure-Figure-sequences b/Lang/D/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..f82b9cc254 --- /dev/null +++ b/Lang/D/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/D \ No newline at end of file diff --git a/Lang/D/Hofstadter-Q-sequence b/Lang/D/Hofstadter-Q-sequence new file mode 120000 index 0000000000..b730496bf5 --- /dev/null +++ b/Lang/D/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/D \ No newline at end of file diff --git a/Lang/D/Holidays-related-to-Easter b/Lang/D/Holidays-related-to-Easter new file mode 120000 index 0000000000..510699b2f7 --- /dev/null +++ b/Lang/D/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/D \ No newline at end of file diff --git a/Lang/D/Horizontal-sundial-calculations b/Lang/D/Horizontal-sundial-calculations new file mode 120000 index 0000000000..01f47821e1 --- /dev/null +++ b/Lang/D/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/D \ No newline at end of file diff --git a/Lang/D/Horners-rule-for-polynomial-evaluation b/Lang/D/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..b90edb369f --- /dev/null +++ b/Lang/D/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/D \ No newline at end of file diff --git a/Lang/D/Host-introspection b/Lang/D/Host-introspection new file mode 120000 index 0000000000..2c7de29d6f --- /dev/null +++ b/Lang/D/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/D \ No newline at end of file diff --git a/Lang/D/Hostname b/Lang/D/Hostname new file mode 120000 index 0000000000..818a71b6d6 --- /dev/null +++ b/Lang/D/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/D \ No newline at end of file diff --git a/Lang/D/Hough-transform b/Lang/D/Hough-transform new file mode 120000 index 0000000000..9aa1a818a3 --- /dev/null +++ b/Lang/D/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/D \ No newline at end of file diff --git a/Lang/D/Huffman-coding b/Lang/D/Huffman-coding new file mode 120000 index 0000000000..2c18b9966b --- /dev/null +++ b/Lang/D/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/D \ No newline at end of file diff --git a/Lang/D/Identity-matrix b/Lang/D/Identity-matrix new file mode 120000 index 0000000000..14c31847e7 --- /dev/null +++ b/Lang/D/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/D \ No newline at end of file diff --git a/Lang/D/Image-convolution b/Lang/D/Image-convolution new file mode 120000 index 0000000000..8360e482ed --- /dev/null +++ b/Lang/D/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/D \ No newline at end of file diff --git a/Lang/D/Image-noise b/Lang/D/Image-noise new file mode 120000 index 0000000000..e68381c498 --- /dev/null +++ b/Lang/D/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/D \ No newline at end of file diff --git a/Lang/D/Include-a-file b/Lang/D/Include-a-file new file mode 120000 index 0000000000..d8935c30f0 --- /dev/null +++ b/Lang/D/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/D \ No newline at end of file diff --git a/Lang/D/Increment-a-numerical-string b/Lang/D/Increment-a-numerical-string new file mode 120000 index 0000000000..d140ef0c98 --- /dev/null +++ b/Lang/D/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/D \ No newline at end of file diff --git a/Lang/D/Inheritance-Multiple b/Lang/D/Inheritance-Multiple new file mode 120000 index 0000000000..0a5250e4f9 --- /dev/null +++ b/Lang/D/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/D \ No newline at end of file diff --git a/Lang/D/Inheritance-Single b/Lang/D/Inheritance-Single new file mode 120000 index 0000000000..e62f08e0a7 --- /dev/null +++ b/Lang/D/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/D \ No newline at end of file diff --git a/Lang/D/Input-loop b/Lang/D/Input-loop new file mode 120000 index 0000000000..2ddaadf4cf --- /dev/null +++ b/Lang/D/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/D \ No newline at end of file diff --git a/Lang/D/Integer-comparison b/Lang/D/Integer-comparison new file mode 120000 index 0000000000..cba23d266d --- /dev/null +++ b/Lang/D/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/D \ No newline at end of file diff --git a/Lang/D/Integer-sequence b/Lang/D/Integer-sequence new file mode 120000 index 0000000000..e2ca067fda --- /dev/null +++ b/Lang/D/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/D \ No newline at end of file diff --git a/Lang/D/Introspection b/Lang/D/Introspection new file mode 120000 index 0000000000..0e5131487f --- /dev/null +++ b/Lang/D/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/D \ No newline at end of file diff --git a/Lang/D/Inverted-index b/Lang/D/Inverted-index new file mode 120000 index 0000000000..cd7037104d --- /dev/null +++ b/Lang/D/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/D \ No newline at end of file diff --git a/Lang/D/Jensens-Device b/Lang/D/Jensens-Device new file mode 120000 index 0000000000..8200ab7349 --- /dev/null +++ b/Lang/D/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/D \ No newline at end of file diff --git a/Lang/D/Josephus-problem b/Lang/D/Josephus-problem new file mode 120000 index 0000000000..a77caf4a33 --- /dev/null +++ b/Lang/D/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/D \ No newline at end of file diff --git a/Lang/D/K-means++-clustering b/Lang/D/K-means++-clustering new file mode 120000 index 0000000000..5629de8679 --- /dev/null +++ b/Lang/D/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/D \ No newline at end of file diff --git a/Lang/D/Kaprekar-numbers b/Lang/D/Kaprekar-numbers new file mode 120000 index 0000000000..09f2050704 --- /dev/null +++ b/Lang/D/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/D \ No newline at end of file diff --git a/Lang/D/Keyboard-input-Flush-the-keyboard-buffer b/Lang/D/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..a07d7b311a --- /dev/null +++ b/Lang/D/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/D \ No newline at end of file diff --git a/Lang/D/Keyboard-input-Keypress-check b/Lang/D/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..a43061fe11 --- /dev/null +++ b/Lang/D/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/D \ No newline at end of file diff --git a/Lang/D/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/D/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..06cc805531 --- /dev/null +++ b/Lang/D/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/D \ No newline at end of file diff --git a/Lang/D/Knapsack-problem-0-1 b/Lang/D/Knapsack-problem-0-1 new file mode 120000 index 0000000000..7f12271d91 --- /dev/null +++ b/Lang/D/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/D \ No newline at end of file diff --git a/Lang/D/Knapsack-problem-Bounded b/Lang/D/Knapsack-problem-Bounded new file mode 120000 index 0000000000..fbd0cf30f9 --- /dev/null +++ b/Lang/D/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/D \ No newline at end of file diff --git a/Lang/D/Knapsack-problem-Continuous b/Lang/D/Knapsack-problem-Continuous new file mode 120000 index 0000000000..c9905ecae1 --- /dev/null +++ b/Lang/D/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/D \ No newline at end of file diff --git a/Lang/D/Knapsack-problem-Unbounded b/Lang/D/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..d2f92fa6bb --- /dev/null +++ b/Lang/D/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/D \ No newline at end of file diff --git a/Lang/D/Knights-tour b/Lang/D/Knights-tour new file mode 120000 index 0000000000..0a1d436840 --- /dev/null +++ b/Lang/D/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/D \ No newline at end of file diff --git a/Lang/D/Knuths-algorithm-S b/Lang/D/Knuths-algorithm-S new file mode 120000 index 0000000000..7f7e1a83fa --- /dev/null +++ b/Lang/D/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/D \ No newline at end of file diff --git a/Lang/D/LU-decomposition b/Lang/D/LU-decomposition new file mode 120000 index 0000000000..05b661ef5e --- /dev/null +++ b/Lang/D/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/D \ No newline at end of file diff --git a/Lang/D/LZW-compression b/Lang/D/LZW-compression new file mode 120000 index 0000000000..d702a81db3 --- /dev/null +++ b/Lang/D/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/D \ No newline at end of file diff --git a/Lang/D/Langtons-ant b/Lang/D/Langtons-ant new file mode 120000 index 0000000000..56e946c7d8 --- /dev/null +++ b/Lang/D/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/D \ No newline at end of file diff --git a/Lang/D/Largest-int-from-concatenated-ints b/Lang/D/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..7b2a9d2f19 --- /dev/null +++ b/Lang/D/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/D \ No newline at end of file diff --git a/Lang/D/Last-Friday-of-each-month b/Lang/D/Last-Friday-of-each-month new file mode 120000 index 0000000000..025bd4a52e --- /dev/null +++ b/Lang/D/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/D \ No newline at end of file diff --git a/Lang/D/Last-letter-first-letter b/Lang/D/Last-letter-first-letter new file mode 120000 index 0000000000..4e59f50a0b --- /dev/null +++ b/Lang/D/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/D \ No newline at end of file diff --git a/Lang/D/Leap-year b/Lang/D/Leap-year new file mode 120000 index 0000000000..0c04082302 --- /dev/null +++ b/Lang/D/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/D \ No newline at end of file diff --git a/Lang/D/Least-common-multiple b/Lang/D/Least-common-multiple new file mode 120000 index 0000000000..7a1c51d462 --- /dev/null +++ b/Lang/D/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/D \ No newline at end of file diff --git a/Lang/D/Letter-frequency b/Lang/D/Letter-frequency new file mode 120000 index 0000000000..85beca3afb --- /dev/null +++ b/Lang/D/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/D \ No newline at end of file diff --git a/Lang/D/Levenshtein-distance b/Lang/D/Levenshtein-distance new file mode 120000 index 0000000000..f7d919af9e --- /dev/null +++ b/Lang/D/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/D \ No newline at end of file diff --git a/Lang/D/Linear-congruential-generator b/Lang/D/Linear-congruential-generator new file mode 120000 index 0000000000..15b83c3934 --- /dev/null +++ b/Lang/D/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/D \ No newline at end of file diff --git a/Lang/D/List-comprehensions b/Lang/D/List-comprehensions new file mode 120000 index 0000000000..f9fb7eaa4e --- /dev/null +++ b/Lang/D/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/D \ No newline at end of file diff --git a/Lang/D/Literals-Integer b/Lang/D/Literals-Integer new file mode 120000 index 0000000000..d0b5ab76bb --- /dev/null +++ b/Lang/D/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/D \ No newline at end of file diff --git a/Lang/D/Literals-String b/Lang/D/Literals-String new file mode 120000 index 0000000000..88300cb4a0 --- /dev/null +++ b/Lang/D/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/D \ No newline at end of file diff --git a/Lang/D/Logical-operations b/Lang/D/Logical-operations new file mode 120000 index 0000000000..ddc5e88504 --- /dev/null +++ b/Lang/D/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/D \ No newline at end of file diff --git a/Lang/D/Long-multiplication b/Lang/D/Long-multiplication new file mode 120000 index 0000000000..b601d0a601 --- /dev/null +++ b/Lang/D/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/D \ No newline at end of file diff --git a/Lang/D/Longest-common-subsequence b/Lang/D/Longest-common-subsequence new file mode 120000 index 0000000000..76640c1ddd --- /dev/null +++ b/Lang/D/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/D \ No newline at end of file diff --git a/Lang/D/Longest-string-challenge b/Lang/D/Longest-string-challenge new file mode 120000 index 0000000000..4df7555083 --- /dev/null +++ b/Lang/D/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/D \ No newline at end of file diff --git a/Lang/D/Look-and-say-sequence b/Lang/D/Look-and-say-sequence new file mode 120000 index 0000000000..5159263494 --- /dev/null +++ b/Lang/D/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/D \ No newline at end of file diff --git a/Lang/D/Loop-over-multiple-arrays-simultaneously b/Lang/D/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..3a70c5951b --- /dev/null +++ b/Lang/D/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/D \ No newline at end of file diff --git a/Lang/D/Loops-Break b/Lang/D/Loops-Break new file mode 120000 index 0000000000..7102d70cb7 --- /dev/null +++ b/Lang/D/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/D \ No newline at end of file diff --git a/Lang/D/Loops-Continue b/Lang/D/Loops-Continue new file mode 120000 index 0000000000..63152c0b73 --- /dev/null +++ b/Lang/D/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/D \ No newline at end of file diff --git a/Lang/D/Loops-Do-while b/Lang/D/Loops-Do-while new file mode 120000 index 0000000000..599cee430d --- /dev/null +++ b/Lang/D/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/D \ No newline at end of file diff --git a/Lang/D/Loops-Downward-for b/Lang/D/Loops-Downward-for new file mode 120000 index 0000000000..27e04820ed --- /dev/null +++ b/Lang/D/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/D \ No newline at end of file diff --git a/Lang/D/Loops-For b/Lang/D/Loops-For new file mode 120000 index 0000000000..958222aa55 --- /dev/null +++ b/Lang/D/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/D \ No newline at end of file diff --git a/Lang/D/Loops-For-with-a-specified-step b/Lang/D/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..7206a4b99e --- /dev/null +++ b/Lang/D/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/D \ No newline at end of file diff --git a/Lang/D/Loops-Foreach b/Lang/D/Loops-Foreach new file mode 120000 index 0000000000..72dbf5c1c5 --- /dev/null +++ b/Lang/D/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/D \ No newline at end of file diff --git a/Lang/D/Loops-Infinite b/Lang/D/Loops-Infinite new file mode 120000 index 0000000000..17ff72420a --- /dev/null +++ b/Lang/D/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/D \ No newline at end of file diff --git a/Lang/D/Loops-N-plus-one-half b/Lang/D/Loops-N-plus-one-half new file mode 120000 index 0000000000..ce3756253b --- /dev/null +++ b/Lang/D/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/D \ No newline at end of file diff --git a/Lang/D/Loops-Nested b/Lang/D/Loops-Nested new file mode 120000 index 0000000000..1d0bf68022 --- /dev/null +++ b/Lang/D/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/D \ No newline at end of file diff --git a/Lang/D/Loops-While b/Lang/D/Loops-While new file mode 120000 index 0000000000..6b446909ee --- /dev/null +++ b/Lang/D/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/D \ No newline at end of file diff --git a/Lang/D/Lucas-Lehmer-test b/Lang/D/Lucas-Lehmer-test new file mode 120000 index 0000000000..5b57068177 --- /dev/null +++ b/Lang/D/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/D \ No newline at end of file diff --git a/Lang/D/Luhn-test-of-credit-card-numbers b/Lang/D/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..98edaa19bf --- /dev/null +++ b/Lang/D/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/D \ No newline at end of file diff --git a/Lang/D/MD5 b/Lang/D/MD5 new file mode 120000 index 0000000000..cdf97a105a --- /dev/null +++ b/Lang/D/MD5 @@ -0,0 +1 @@ +../../Task/MD5/D \ No newline at end of file diff --git a/Lang/D/MD5-Implementation b/Lang/D/MD5-Implementation new file mode 120000 index 0000000000..a358741672 --- /dev/null +++ b/Lang/D/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/D \ No newline at end of file diff --git a/Lang/D/Mad-Libs b/Lang/D/Mad-Libs new file mode 120000 index 0000000000..85d9bc1a1c --- /dev/null +++ b/Lang/D/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/D \ No newline at end of file diff --git a/Lang/D/Main-step-of-GOST-28147-89 b/Lang/D/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..e73f518e35 --- /dev/null +++ b/Lang/D/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/D \ No newline at end of file diff --git a/Lang/D/Man-or-boy-test b/Lang/D/Man-or-boy-test new file mode 120000 index 0000000000..15e4b1c013 --- /dev/null +++ b/Lang/D/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/D \ No newline at end of file diff --git a/Lang/D/Mandelbrot-set b/Lang/D/Mandelbrot-set new file mode 120000 index 0000000000..3eade1866e --- /dev/null +++ b/Lang/D/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/D \ No newline at end of file diff --git a/Lang/D/Map-range b/Lang/D/Map-range new file mode 120000 index 0000000000..c0e012552d --- /dev/null +++ b/Lang/D/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/D \ No newline at end of file diff --git a/Lang/D/Matrix-arithmetic b/Lang/D/Matrix-arithmetic new file mode 120000 index 0000000000..766de00531 --- /dev/null +++ b/Lang/D/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/D \ No newline at end of file diff --git a/Lang/D/Matrix-exponentiation-operator b/Lang/D/Matrix-exponentiation-operator new file mode 120000 index 0000000000..15b86e6d39 --- /dev/null +++ b/Lang/D/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/D \ No newline at end of file diff --git a/Lang/D/Matrix-multiplication b/Lang/D/Matrix-multiplication new file mode 120000 index 0000000000..8db2ddf436 --- /dev/null +++ b/Lang/D/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/D \ No newline at end of file diff --git a/Lang/D/Matrix-transposition b/Lang/D/Matrix-transposition new file mode 120000 index 0000000000..0e87f95e14 --- /dev/null +++ b/Lang/D/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/D \ No newline at end of file diff --git a/Lang/D/Maze-generation b/Lang/D/Maze-generation new file mode 120000 index 0000000000..d54d0492af --- /dev/null +++ b/Lang/D/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/D \ No newline at end of file diff --git a/Lang/D/Maze-solving b/Lang/D/Maze-solving new file mode 120000 index 0000000000..bba4709fc3 --- /dev/null +++ b/Lang/D/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/D \ No newline at end of file diff --git a/Lang/D/Median-filter b/Lang/D/Median-filter new file mode 120000 index 0000000000..e17196cd49 --- /dev/null +++ b/Lang/D/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/D \ No newline at end of file diff --git a/Lang/D/Memory-layout-of-a-data-structure b/Lang/D/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..6a107b85d3 --- /dev/null +++ b/Lang/D/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/D \ No newline at end of file diff --git a/Lang/D/Menu b/Lang/D/Menu new file mode 120000 index 0000000000..f863d328a4 --- /dev/null +++ b/Lang/D/Menu @@ -0,0 +1 @@ +../../Task/Menu/D \ No newline at end of file diff --git a/Lang/D/Metaprogramming b/Lang/D/Metaprogramming new file mode 120000 index 0000000000..c6d275f9d7 --- /dev/null +++ b/Lang/D/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/D \ No newline at end of file diff --git a/Lang/D/Metered-concurrency b/Lang/D/Metered-concurrency new file mode 120000 index 0000000000..3ced4e3d54 --- /dev/null +++ b/Lang/D/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/D \ No newline at end of file diff --git a/Lang/D/Middle-three-digits b/Lang/D/Middle-three-digits new file mode 120000 index 0000000000..5584553fe0 --- /dev/null +++ b/Lang/D/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/D \ No newline at end of file diff --git a/Lang/D/Miller-Rabin-primality-test b/Lang/D/Miller-Rabin-primality-test new file mode 120000 index 0000000000..407bdbfce4 --- /dev/null +++ b/Lang/D/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/D \ No newline at end of file diff --git a/Lang/D/Modular-exponentiation b/Lang/D/Modular-exponentiation new file mode 120000 index 0000000000..2c989fd262 --- /dev/null +++ b/Lang/D/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/D \ No newline at end of file diff --git a/Lang/D/Modular-inverse b/Lang/D/Modular-inverse new file mode 120000 index 0000000000..835112bf3c --- /dev/null +++ b/Lang/D/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/D \ No newline at end of file diff --git a/Lang/D/Monte-Carlo-methods b/Lang/D/Monte-Carlo-methods new file mode 120000 index 0000000000..496c1ffe31 --- /dev/null +++ b/Lang/D/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/D \ No newline at end of file diff --git a/Lang/D/Monty-Hall-problem b/Lang/D/Monty-Hall-problem new file mode 120000 index 0000000000..bbc0f7d5af --- /dev/null +++ b/Lang/D/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/D \ No newline at end of file diff --git a/Lang/D/Multifactorial b/Lang/D/Multifactorial new file mode 120000 index 0000000000..16dafd88e9 --- /dev/null +++ b/Lang/D/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/D \ No newline at end of file diff --git a/Lang/D/Multiple-distinct-objects b/Lang/D/Multiple-distinct-objects new file mode 120000 index 0000000000..5b7fb131a9 --- /dev/null +++ b/Lang/D/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/D \ No newline at end of file diff --git a/Lang/D/Multiplication-tables b/Lang/D/Multiplication-tables new file mode 120000 index 0000000000..3a5349fbe7 --- /dev/null +++ b/Lang/D/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/D \ No newline at end of file diff --git a/Lang/D/Multisplit b/Lang/D/Multisplit new file mode 120000 index 0000000000..b149ce2ba1 --- /dev/null +++ b/Lang/D/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/D \ No newline at end of file diff --git a/Lang/D/Mutex b/Lang/D/Mutex new file mode 120000 index 0000000000..c782bbc880 --- /dev/null +++ b/Lang/D/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/D \ No newline at end of file diff --git a/Lang/D/Mutual-recursion b/Lang/D/Mutual-recursion new file mode 120000 index 0000000000..4c4d0bae27 --- /dev/null +++ b/Lang/D/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/D \ No newline at end of file diff --git a/Lang/DMS/Loops-For b/Lang/DMS/Loops-For new file mode 120000 index 0000000000..11ccb25c43 --- /dev/null +++ b/Lang/DMS/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/DMS \ No newline at end of file diff --git a/Lang/DWScript/Factorial b/Lang/DWScript/Factorial new file mode 120000 index 0000000000..6452f9a2b1 --- /dev/null +++ b/Lang/DWScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Fibonacci-sequence b/Lang/DWScript/Fibonacci-sequence new file mode 120000 index 0000000000..3b524f7af8 --- /dev/null +++ b/Lang/DWScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Find-limit-of-recursion b/Lang/DWScript/Find-limit-of-recursion new file mode 120000 index 0000000000..e22656ffa9 --- /dev/null +++ b/Lang/DWScript/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Function-definition b/Lang/DWScript/Function-definition new file mode 120000 index 0000000000..ec51aff769 --- /dev/null +++ b/Lang/DWScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Gray-code b/Lang/DWScript/Gray-code new file mode 120000 index 0000000000..45bc673c6e --- /dev/null +++ b/Lang/DWScript/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Greatest-common-divisor b/Lang/DWScript/Greatest-common-divisor new file mode 120000 index 0000000000..532f7a1877 --- /dev/null +++ b/Lang/DWScript/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Happy-numbers b/Lang/DWScript/Happy-numbers new file mode 120000 index 0000000000..dcde08bc67 --- /dev/null +++ b/Lang/DWScript/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Hello-world-Newline-omission b/Lang/DWScript/Hello-world-Newline-omission new file mode 120000 index 0000000000..cda3c55ef1 --- /dev/null +++ b/Lang/DWScript/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Hello-world-Text b/Lang/DWScript/Hello-world-Text new file mode 120000 index 0000000000..492dc5b442 --- /dev/null +++ b/Lang/DWScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Here-document b/Lang/DWScript/Here-document new file mode 120000 index 0000000000..eca9e5e636 --- /dev/null +++ b/Lang/DWScript/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Higher-order-functions b/Lang/DWScript/Higher-order-functions new file mode 120000 index 0000000000..68fe21122c --- /dev/null +++ b/Lang/DWScript/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Horizontal-sundial-calculations b/Lang/DWScript/Horizontal-sundial-calculations new file mode 120000 index 0000000000..b3240da456 --- /dev/null +++ b/Lang/DWScript/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Include-a-file b/Lang/DWScript/Include-a-file new file mode 120000 index 0000000000..e302684602 --- /dev/null +++ b/Lang/DWScript/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Increment-a-numerical-string b/Lang/DWScript/Increment-a-numerical-string new file mode 120000 index 0000000000..0969b0a7ed --- /dev/null +++ b/Lang/DWScript/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Inheritance-Single b/Lang/DWScript/Inheritance-Single new file mode 120000 index 0000000000..70337e5256 --- /dev/null +++ b/Lang/DWScript/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Integer-sequence b/Lang/DWScript/Integer-sequence new file mode 120000 index 0000000000..59a93e8993 --- /dev/null +++ b/Lang/DWScript/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Jensens-Device b/Lang/DWScript/Jensens-Device new file mode 120000 index 0000000000..9c05319602 --- /dev/null +++ b/Lang/DWScript/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Leap-year b/Lang/DWScript/Leap-year new file mode 120000 index 0000000000..e468450f2e --- /dev/null +++ b/Lang/DWScript/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Least-common-multiple b/Lang/DWScript/Least-common-multiple new file mode 120000 index 0000000000..f4c15df962 --- /dev/null +++ b/Lang/DWScript/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Levenshtein-distance b/Lang/DWScript/Levenshtein-distance new file mode 120000 index 0000000000..366d7b8ff7 --- /dev/null +++ b/Lang/DWScript/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Literals-Integer b/Lang/DWScript/Literals-Integer new file mode 120000 index 0000000000..a6ec7a1a06 --- /dev/null +++ b/Lang/DWScript/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Literals-String b/Lang/DWScript/Literals-String new file mode 120000 index 0000000000..37fee502bd --- /dev/null +++ b/Lang/DWScript/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Logical-operations b/Lang/DWScript/Logical-operations new file mode 120000 index 0000000000..ea2927cda1 --- /dev/null +++ b/Lang/DWScript/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loop-over-multiple-arrays-simultaneously b/Lang/DWScript/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..2c289860a8 --- /dev/null +++ b/Lang/DWScript/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-Break b/Lang/DWScript/Loops-Break new file mode 120000 index 0000000000..40121d07af --- /dev/null +++ b/Lang/DWScript/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-Continue b/Lang/DWScript/Loops-Continue new file mode 120000 index 0000000000..f68604f9a7 --- /dev/null +++ b/Lang/DWScript/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-Do-while b/Lang/DWScript/Loops-Do-while new file mode 120000 index 0000000000..982031b2fe --- /dev/null +++ b/Lang/DWScript/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-Downward-for b/Lang/DWScript/Loops-Downward-for new file mode 120000 index 0000000000..f8c7b2acb4 --- /dev/null +++ b/Lang/DWScript/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-For b/Lang/DWScript/Loops-For new file mode 120000 index 0000000000..6475bb0857 --- /dev/null +++ b/Lang/DWScript/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-For-with-a-specified-step b/Lang/DWScript/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..bcf46b83ed --- /dev/null +++ b/Lang/DWScript/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-Infinite b/Lang/DWScript/Loops-Infinite new file mode 120000 index 0000000000..1e88343310 --- /dev/null +++ b/Lang/DWScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-N-plus-one-half b/Lang/DWScript/Loops-N-plus-one-half new file mode 120000 index 0000000000..91c62236d5 --- /dev/null +++ b/Lang/DWScript/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Loops-While b/Lang/DWScript/Loops-While new file mode 120000 index 0000000000..b42fba4066 --- /dev/null +++ b/Lang/DWScript/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Lucas-Lehmer-test b/Lang/DWScript/Lucas-Lehmer-test new file mode 120000 index 0000000000..455954e671 --- /dev/null +++ b/Lang/DWScript/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Mandelbrot-set b/Lang/DWScript/Mandelbrot-set new file mode 120000 index 0000000000..b7dab4259b --- /dev/null +++ b/Lang/DWScript/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Multiplication-tables b/Lang/DWScript/Multiplication-tables new file mode 120000 index 0000000000..822de4733e --- /dev/null +++ b/Lang/DWScript/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/DWScript \ No newline at end of file diff --git a/Lang/Dao/Hello-world-Text b/Lang/Dao/Hello-world-Text new file mode 120000 index 0000000000..44f32aee5b --- /dev/null +++ b/Lang/Dao/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Dao \ No newline at end of file diff --git a/Lang/Dao/Loops-For b/Lang/Dao/Loops-For new file mode 120000 index 0000000000..97d3752c21 --- /dev/null +++ b/Lang/Dao/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Dao \ No newline at end of file diff --git a/Lang/Dao/Loops-For-with-a-specified-step b/Lang/Dao/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..b333ae5063 --- /dev/null +++ b/Lang/Dao/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Dao \ No newline at end of file diff --git a/Lang/Dao/Loops-Foreach b/Lang/Dao/Loops-Foreach new file mode 120000 index 0000000000..7a6892f56b --- /dev/null +++ b/Lang/Dao/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Dao \ No newline at end of file diff --git a/Lang/Dao/Loops-While b/Lang/Dao/Loops-While new file mode 120000 index 0000000000..a1ba5b4e5f --- /dev/null +++ b/Lang/Dao/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Dao \ No newline at end of file diff --git a/Lang/Dart/Factorial b/Lang/Dart/Factorial new file mode 120000 index 0000000000..6d8d4aac0a --- /dev/null +++ b/Lang/Dart/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Dart \ No newline at end of file diff --git a/Lang/Dart/Fibonacci-sequence b/Lang/Dart/Fibonacci-sequence new file mode 120000 index 0000000000..82673ddb03 --- /dev/null +++ b/Lang/Dart/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Dart \ No newline at end of file diff --git a/Lang/Dart/First-class-functions b/Lang/Dart/First-class-functions new file mode 120000 index 0000000000..dc6294a42f --- /dev/null +++ b/Lang/Dart/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Dart \ No newline at end of file diff --git a/Lang/Dart/Greatest-element-of-a-list b/Lang/Dart/Greatest-element-of-a-list new file mode 120000 index 0000000000..bb24435f84 --- /dev/null +++ b/Lang/Dart/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Dart \ No newline at end of file diff --git a/Lang/Dart/Hailstone-sequence b/Lang/Dart/Hailstone-sequence new file mode 120000 index 0000000000..f13ebd5453 --- /dev/null +++ b/Lang/Dart/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Dart \ No newline at end of file diff --git a/Lang/Dart/Happy-numbers b/Lang/Dart/Happy-numbers new file mode 120000 index 0000000000..215956a03e --- /dev/null +++ b/Lang/Dart/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Dart \ No newline at end of file diff --git a/Lang/Dart/Hello-world-Text b/Lang/Dart/Hello-world-Text new file mode 120000 index 0000000000..5899afa107 --- /dev/null +++ b/Lang/Dart/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Dart \ No newline at end of file diff --git a/Lang/Dart/Hofstadter-Q-sequence b/Lang/Dart/Hofstadter-Q-sequence new file mode 120000 index 0000000000..e3daa9f581 --- /dev/null +++ b/Lang/Dart/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Dart \ No newline at end of file diff --git a/Lang/Dart/Knapsack-problem-0-1 b/Lang/Dart/Knapsack-problem-0-1 new file mode 120000 index 0000000000..f93a0b46ca --- /dev/null +++ b/Lang/Dart/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Dart \ No newline at end of file diff --git a/Lang/Dart/Longest-common-subsequence b/Lang/Dart/Longest-common-subsequence new file mode 120000 index 0000000000..3742993b35 --- /dev/null +++ b/Lang/Dart/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Dart \ No newline at end of file diff --git a/Lang/Dart/Loops-For b/Lang/Dart/Loops-For new file mode 120000 index 0000000000..99a5562cbe --- /dev/null +++ b/Lang/Dart/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Dart \ No newline at end of file diff --git a/Lang/Dart/Mandelbrot-set b/Lang/Dart/Mandelbrot-set new file mode 120000 index 0000000000..e3d745b32e --- /dev/null +++ b/Lang/Dart/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Dart \ No newline at end of file diff --git a/Lang/Dart/Monty-Hall-problem b/Lang/Dart/Monty-Hall-problem new file mode 120000 index 0000000000..14ce75f7be --- /dev/null +++ b/Lang/Dart/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Dart \ No newline at end of file diff --git a/Lang/Dart/Mutual-recursion b/Lang/Dart/Mutual-recursion new file mode 120000 index 0000000000..56f65a4c25 --- /dev/null +++ b/Lang/Dart/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Dart \ No newline at end of file diff --git a/Lang/Dc/Greatest-common-divisor b/Lang/Dc/Greatest-common-divisor new file mode 120000 index 0000000000..43fbdfc83e --- /dev/null +++ b/Lang/Dc/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Dc \ No newline at end of file diff --git a/Lang/Dc/Hailstone-sequence b/Lang/Dc/Hailstone-sequence new file mode 120000 index 0000000000..7437e10722 --- /dev/null +++ b/Lang/Dc/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Dc \ No newline at end of file diff --git a/Lang/Dc/Integer-sequence b/Lang/Dc/Integer-sequence new file mode 120000 index 0000000000..5b9bd6be68 --- /dev/null +++ b/Lang/Dc/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Dc \ No newline at end of file diff --git a/Lang/Dc/Long-multiplication b/Lang/Dc/Long-multiplication new file mode 120000 index 0000000000..1435158725 --- /dev/null +++ b/Lang/Dc/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Dc \ No newline at end of file diff --git a/Lang/Dc/Loops-While b/Lang/Dc/Loops-While new file mode 120000 index 0000000000..448b825957 --- /dev/null +++ b/Lang/Dc/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Dc \ No newline at end of file diff --git a/Lang/Dc/Modular-exponentiation b/Lang/Dc/Modular-exponentiation new file mode 120000 index 0000000000..520a162a2a --- /dev/null +++ b/Lang/Dc/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Dc \ No newline at end of file diff --git a/Lang/Deja-Vu/Hello-world-Newline-omission b/Lang/Deja-Vu/Hello-world-Newline-omission new file mode 120000 index 0000000000..b3a7711793 --- /dev/null +++ b/Lang/Deja-Vu/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Hello-world-Text b/Lang/Deja-Vu/Hello-world-Text new file mode 120000 index 0000000000..cb083a5067 --- /dev/null +++ b/Lang/Deja-Vu/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Loops-Infinite b/Lang/Deja-Vu/Loops-Infinite new file mode 120000 index 0000000000..bcc052531f --- /dev/null +++ b/Lang/Deja-Vu/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Deja-Vu \ No newline at end of file diff --git a/Lang/Delphi/Factorial b/Lang/Delphi/Factorial new file mode 120000 index 0000000000..3e8ed0a1c4 --- /dev/null +++ b/Lang/Delphi/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Fibonacci-sequence b/Lang/Delphi/Fibonacci-sequence new file mode 120000 index 0000000000..755efb626f --- /dev/null +++ b/Lang/Delphi/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Delphi \ No newline at end of file diff --git a/Lang/Delphi/File-IO b/Lang/Delphi/File-IO new file mode 120000 index 0000000000..959676f5cc --- /dev/null +++ b/Lang/Delphi/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Delphi \ No newline at end of file diff --git a/Lang/Delphi/File-modification-time b/Lang/Delphi/File-modification-time new file mode 120000 index 0000000000..c283f010bc --- /dev/null +++ b/Lang/Delphi/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Delphi \ No newline at end of file diff --git a/Lang/Delphi/File-size b/Lang/Delphi/File-size new file mode 120000 index 0000000000..023121968c --- /dev/null +++ b/Lang/Delphi/File-size @@ -0,0 +1 @@ +../../Task/File-size/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Filter b/Lang/Delphi/Filter new file mode 120000 index 0000000000..563d01d656 --- /dev/null +++ b/Lang/Delphi/Filter @@ -0,0 +1 @@ +../../Task/Filter/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Find-limit-of-recursion b/Lang/Delphi/Find-limit-of-recursion new file mode 120000 index 0000000000..6431d1ae7e --- /dev/null +++ b/Lang/Delphi/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Five-weekends b/Lang/Delphi/Five-weekends new file mode 120000 index 0000000000..2a1cb9aa1c --- /dev/null +++ b/Lang/Delphi/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Formatted-numeric-output b/Lang/Delphi/Formatted-numeric-output new file mode 120000 index 0000000000..30d50c173d --- /dev/null +++ b/Lang/Delphi/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Function-composition b/Lang/Delphi/Function-composition new file mode 120000 index 0000000000..7f85404d2d --- /dev/null +++ b/Lang/Delphi/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Function-definition b/Lang/Delphi/Function-definition new file mode 120000 index 0000000000..698f896bdb --- /dev/null +++ b/Lang/Delphi/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Delphi \ No newline at end of file diff --git a/Lang/Delphi/GUI-component-interaction b/Lang/Delphi/GUI-component-interaction new file mode 120000 index 0000000000..d88cd91e43 --- /dev/null +++ b/Lang/Delphi/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Delphi \ No newline at end of file diff --git a/Lang/Delphi/GUI-enabling-disabling-of-controls b/Lang/Delphi/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..6e95a5274e --- /dev/null +++ b/Lang/Delphi/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Generic-swap b/Lang/Delphi/Generic-swap new file mode 120000 index 0000000000..2fef7ec8de --- /dev/null +++ b/Lang/Delphi/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Gray-code b/Lang/Delphi/Gray-code new file mode 120000 index 0000000000..38d275c063 --- /dev/null +++ b/Lang/Delphi/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Greatest-element-of-a-list b/Lang/Delphi/Greatest-element-of-a-list new file mode 120000 index 0000000000..5d16b34f34 --- /dev/null +++ b/Lang/Delphi/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Guess-the-number b/Lang/Delphi/Guess-the-number new file mode 120000 index 0000000000..37f8740191 --- /dev/null +++ b/Lang/Delphi/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Guess-the-number-With-feedback b/Lang/Delphi/Guess-the-number-With-feedback new file mode 120000 index 0000000000..0b410f9e05 --- /dev/null +++ b/Lang/Delphi/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Delphi \ No newline at end of file diff --git a/Lang/Delphi/HTTP b/Lang/Delphi/HTTP new file mode 120000 index 0000000000..2499a7e043 --- /dev/null +++ b/Lang/Delphi/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Delphi \ No newline at end of file diff --git a/Lang/Delphi/HTTPS b/Lang/Delphi/HTTPS new file mode 120000 index 0000000000..084920157c --- /dev/null +++ b/Lang/Delphi/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Delphi \ No newline at end of file diff --git a/Lang/Delphi/HTTPS-Authenticated b/Lang/Delphi/HTTPS-Authenticated new file mode 120000 index 0000000000..2eafd15a44 --- /dev/null +++ b/Lang/Delphi/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hailstone-sequence b/Lang/Delphi/Hailstone-sequence new file mode 120000 index 0000000000..00daef3473 --- /dev/null +++ b/Lang/Delphi/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Graphical b/Lang/Delphi/Hello-world-Graphical new file mode 120000 index 0000000000..8ae512066c --- /dev/null +++ b/Lang/Delphi/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Line-printer b/Lang/Delphi/Hello-world-Line-printer new file mode 120000 index 0000000000..3e8e7aad0d --- /dev/null +++ b/Lang/Delphi/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Newline-omission b/Lang/Delphi/Hello-world-Newline-omission new file mode 120000 index 0000000000..82c3b4048b --- /dev/null +++ b/Lang/Delphi/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Standard-error b/Lang/Delphi/Hello-world-Standard-error new file mode 120000 index 0000000000..e3c4bd84f1 --- /dev/null +++ b/Lang/Delphi/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Text b/Lang/Delphi/Hello-world-Text new file mode 120000 index 0000000000..ca382db233 --- /dev/null +++ b/Lang/Delphi/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hello-world-Web-server b/Lang/Delphi/Hello-world-Web-server new file mode 120000 index 0000000000..7e559f168e --- /dev/null +++ b/Lang/Delphi/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Host-introspection b/Lang/Delphi/Host-introspection new file mode 120000 index 0000000000..15cb0ce1b3 --- /dev/null +++ b/Lang/Delphi/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Hostname b/Lang/Delphi/Hostname new file mode 120000 index 0000000000..cc114a4ccf --- /dev/null +++ b/Lang/Delphi/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Include-a-file b/Lang/Delphi/Include-a-file new file mode 120000 index 0000000000..6f895a268b --- /dev/null +++ b/Lang/Delphi/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Increment-a-numerical-string b/Lang/Delphi/Increment-a-numerical-string new file mode 120000 index 0000000000..1e7f571811 --- /dev/null +++ b/Lang/Delphi/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Inheritance-Multiple b/Lang/Delphi/Inheritance-Multiple new file mode 120000 index 0000000000..eb2f76ab63 --- /dev/null +++ b/Lang/Delphi/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Inheritance-Single b/Lang/Delphi/Inheritance-Single new file mode 120000 index 0000000000..bb70cf2a3a --- /dev/null +++ b/Lang/Delphi/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Input-loop b/Lang/Delphi/Input-loop new file mode 120000 index 0000000000..5493b5a1bc --- /dev/null +++ b/Lang/Delphi/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Integer-comparison b/Lang/Delphi/Integer-comparison new file mode 120000 index 0000000000..b4e75f2b4c --- /dev/null +++ b/Lang/Delphi/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Integer-sequence b/Lang/Delphi/Integer-sequence new file mode 120000 index 0000000000..f27156ff32 --- /dev/null +++ b/Lang/Delphi/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Keyboard-input-Keypress-check b/Lang/Delphi/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..83be57bfa1 --- /dev/null +++ b/Lang/Delphi/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Last-letter-first-letter b/Lang/Delphi/Last-letter-first-letter new file mode 120000 index 0000000000..65c0b620e3 --- /dev/null +++ b/Lang/Delphi/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Leap-year b/Lang/Delphi/Leap-year new file mode 120000 index 0000000000..3e16ade638 --- /dev/null +++ b/Lang/Delphi/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Literals-Integer b/Lang/Delphi/Literals-Integer new file mode 120000 index 0000000000..18a2fb764d --- /dev/null +++ b/Lang/Delphi/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Literals-String b/Lang/Delphi/Literals-String new file mode 120000 index 0000000000..b154c551dc --- /dev/null +++ b/Lang/Delphi/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Logical-operations b/Lang/Delphi/Logical-operations new file mode 120000 index 0000000000..385e3db719 --- /dev/null +++ b/Lang/Delphi/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loop-over-multiple-arrays-simultaneously b/Lang/Delphi/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..6acebf3e66 --- /dev/null +++ b/Lang/Delphi/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Break b/Lang/Delphi/Loops-Break new file mode 120000 index 0000000000..6a47ef2387 --- /dev/null +++ b/Lang/Delphi/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Continue b/Lang/Delphi/Loops-Continue new file mode 120000 index 0000000000..5c3bcae20a --- /dev/null +++ b/Lang/Delphi/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Do-while b/Lang/Delphi/Loops-Do-while new file mode 120000 index 0000000000..d73fb892d6 --- /dev/null +++ b/Lang/Delphi/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-For b/Lang/Delphi/Loops-For new file mode 120000 index 0000000000..8ad17bdced --- /dev/null +++ b/Lang/Delphi/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-For-with-a-specified-step b/Lang/Delphi/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..3f39b65854 --- /dev/null +++ b/Lang/Delphi/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Foreach b/Lang/Delphi/Loops-Foreach new file mode 120000 index 0000000000..3d08a19234 --- /dev/null +++ b/Lang/Delphi/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Infinite b/Lang/Delphi/Loops-Infinite new file mode 120000 index 0000000000..afdac5b490 --- /dev/null +++ b/Lang/Delphi/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-N-plus-one-half b/Lang/Delphi/Loops-N-plus-one-half new file mode 120000 index 0000000000..8a863512b6 --- /dev/null +++ b/Lang/Delphi/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-Nested b/Lang/Delphi/Loops-Nested new file mode 120000 index 0000000000..b30ca68318 --- /dev/null +++ b/Lang/Delphi/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Loops-While b/Lang/Delphi/Loops-While new file mode 120000 index 0000000000..bed5bf10c8 --- /dev/null +++ b/Lang/Delphi/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Delphi \ No newline at end of file diff --git a/Lang/Delphi/MD5 b/Lang/Delphi/MD5 new file mode 120000 index 0000000000..4676e8ff18 --- /dev/null +++ b/Lang/Delphi/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Man-or-boy-test b/Lang/Delphi/Man-or-boy-test new file mode 120000 index 0000000000..2d1f581053 --- /dev/null +++ b/Lang/Delphi/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Mouse-position b/Lang/Delphi/Mouse-position new file mode 120000 index 0000000000..dcb2702897 --- /dev/null +++ b/Lang/Delphi/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Multiple-distinct-objects b/Lang/Delphi/Multiple-distinct-objects new file mode 120000 index 0000000000..7b462daa49 --- /dev/null +++ b/Lang/Delphi/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Multiplication-tables b/Lang/Delphi/Multiplication-tables new file mode 120000 index 0000000000..f85871bc48 --- /dev/null +++ b/Lang/Delphi/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Mutual-recursion b/Lang/Delphi/Mutual-recursion new file mode 120000 index 0000000000..6ca8d8503f --- /dev/null +++ b/Lang/Delphi/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Delphi \ No newline at end of file diff --git a/Lang/Dylan.NET/Hello-world-Newline-omission b/Lang/Dylan.NET/Hello-world-Newline-omission new file mode 120000 index 0000000000..d9200b0ea7 --- /dev/null +++ b/Lang/Dylan.NET/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Dylan.NET \ No newline at end of file diff --git a/Lang/Dylan.NET/Hello-world-Standard-error b/Lang/Dylan.NET/Hello-world-Standard-error new file mode 120000 index 0000000000..d56687b0d0 --- /dev/null +++ b/Lang/Dylan.NET/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Dylan.NET \ No newline at end of file diff --git a/Lang/Dylan.NET/Hello-world-Text b/Lang/Dylan.NET/Hello-world-Text new file mode 120000 index 0000000000..bf1fd0703c --- /dev/null +++ b/Lang/Dylan.NET/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Dylan.NET \ No newline at end of file diff --git a/Lang/Dylan/Factorial b/Lang/Dylan/Factorial new file mode 120000 index 0000000000..1459cdf60e --- /dev/null +++ b/Lang/Dylan/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Dylan \ No newline at end of file diff --git a/Lang/Dylan/Function-composition b/Lang/Dylan/Function-composition new file mode 120000 index 0000000000..cd160e10e5 --- /dev/null +++ b/Lang/Dylan/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Dylan \ No newline at end of file diff --git a/Lang/Dylan/Hello-world-Graphical b/Lang/Dylan/Hello-world-Graphical new file mode 120000 index 0000000000..31dbaf63ed --- /dev/null +++ b/Lang/Dylan/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Dylan \ No newline at end of file diff --git a/Lang/Dylan/Hello-world-Text b/Lang/Dylan/Hello-world-Text new file mode 120000 index 0000000000..b600122515 --- /dev/null +++ b/Lang/Dylan/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Dylan \ No newline at end of file diff --git a/Lang/Dylan/LZW-compression b/Lang/Dylan/LZW-compression new file mode 120000 index 0000000000..80a2f5e251 --- /dev/null +++ b/Lang/Dylan/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Dylan \ No newline at end of file diff --git a/Lang/E/Arbitrary-precision-integers-included b/Lang/E/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..fa66ba3bae --- /dev/null +++ b/Lang/E/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/E \ No newline at end of file diff --git a/Lang/E/Factorial b/Lang/E/Factorial new file mode 120000 index 0000000000..0bcc6865bf --- /dev/null +++ b/Lang/E/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/E \ No newline at end of file diff --git a/Lang/E/Factors-of-an-integer b/Lang/E/Factors-of-an-integer new file mode 120000 index 0000000000..ad433106e4 --- /dev/null +++ b/Lang/E/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/E \ No newline at end of file diff --git a/Lang/E/Fibonacci-sequence b/Lang/E/Fibonacci-sequence new file mode 120000 index 0000000000..9a92e561e1 --- /dev/null +++ b/Lang/E/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/E \ No newline at end of file diff --git a/Lang/E/File-IO b/Lang/E/File-IO new file mode 120000 index 0000000000..7176049a46 --- /dev/null +++ b/Lang/E/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/E \ No newline at end of file diff --git a/Lang/E/File-modification-time b/Lang/E/File-modification-time new file mode 120000 index 0000000000..b6870bf09c --- /dev/null +++ b/Lang/E/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/E \ No newline at end of file diff --git a/Lang/E/File-size b/Lang/E/File-size new file mode 120000 index 0000000000..acdfd32d6a --- /dev/null +++ b/Lang/E/File-size @@ -0,0 +1 @@ +../../Task/File-size/E \ No newline at end of file diff --git a/Lang/E/Filter b/Lang/E/Filter new file mode 120000 index 0000000000..d89168fda7 --- /dev/null +++ b/Lang/E/Filter @@ -0,0 +1 @@ +../../Task/Filter/E \ No newline at end of file diff --git a/Lang/E/First-class-functions b/Lang/E/First-class-functions new file mode 120000 index 0000000000..e270f3462e --- /dev/null +++ b/Lang/E/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/E \ No newline at end of file diff --git a/Lang/E/First-class-functions-Use-numbers-analogously b/Lang/E/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..d43071835f --- /dev/null +++ b/Lang/E/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/E \ No newline at end of file diff --git a/Lang/E/Flatten-a-list b/Lang/E/Flatten-a-list new file mode 120000 index 0000000000..34b98c7982 --- /dev/null +++ b/Lang/E/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/E \ No newline at end of file diff --git a/Lang/E/Forward-difference b/Lang/E/Forward-difference new file mode 120000 index 0000000000..1d319a70f5 --- /dev/null +++ b/Lang/E/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/E \ No newline at end of file diff --git a/Lang/E/Function-composition b/Lang/E/Function-composition new file mode 120000 index 0000000000..8a253ee8b0 --- /dev/null +++ b/Lang/E/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/E \ No newline at end of file diff --git a/Lang/E/Function-definition b/Lang/E/Function-definition new file mode 120000 index 0000000000..744f3cdb26 --- /dev/null +++ b/Lang/E/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/E \ No newline at end of file diff --git a/Lang/E/Generator-Exponential b/Lang/E/Generator-Exponential new file mode 120000 index 0000000000..acd7f49da2 --- /dev/null +++ b/Lang/E/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/E \ No newline at end of file diff --git a/Lang/E/Generic-swap b/Lang/E/Generic-swap new file mode 120000 index 0000000000..04f324ad32 --- /dev/null +++ b/Lang/E/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/E \ No newline at end of file diff --git a/Lang/E/Greatest-common-divisor b/Lang/E/Greatest-common-divisor new file mode 120000 index 0000000000..b89dbdd082 --- /dev/null +++ b/Lang/E/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/E \ No newline at end of file diff --git a/Lang/E/Greatest-element-of-a-list b/Lang/E/Greatest-element-of-a-list new file mode 120000 index 0000000000..8f0f98501d --- /dev/null +++ b/Lang/E/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/E \ No newline at end of file diff --git a/Lang/E/Greatest-subsequential-sum b/Lang/E/Greatest-subsequential-sum new file mode 120000 index 0000000000..1cf2a4b147 --- /dev/null +++ b/Lang/E/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/E \ No newline at end of file diff --git a/Lang/E/HTTP b/Lang/E/HTTP new file mode 120000 index 0000000000..2d37de2fc9 --- /dev/null +++ b/Lang/E/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/E \ No newline at end of file diff --git a/Lang/E/Happy-numbers b/Lang/E/Happy-numbers new file mode 120000 index 0000000000..5ad9aff18c --- /dev/null +++ b/Lang/E/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/E \ No newline at end of file diff --git a/Lang/E/Hash-from-two-arrays b/Lang/E/Hash-from-two-arrays new file mode 120000 index 0000000000..dd636c0422 --- /dev/null +++ b/Lang/E/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/E \ No newline at end of file diff --git a/Lang/E/Hello-world-Graphical b/Lang/E/Hello-world-Graphical new file mode 120000 index 0000000000..c390b9af5b --- /dev/null +++ b/Lang/E/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/E \ No newline at end of file diff --git a/Lang/E/Hello-world-Standard-error b/Lang/E/Hello-world-Standard-error new file mode 120000 index 0000000000..c1170e321b --- /dev/null +++ b/Lang/E/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/E \ No newline at end of file diff --git a/Lang/E/Hello-world-Text b/Lang/E/Hello-world-Text new file mode 120000 index 0000000000..611001f778 --- /dev/null +++ b/Lang/E/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/E \ No newline at end of file diff --git a/Lang/E/Higher-order-functions b/Lang/E/Higher-order-functions new file mode 120000 index 0000000000..2c3e03ca43 --- /dev/null +++ b/Lang/E/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/E \ No newline at end of file diff --git a/Lang/E/Horners-rule-for-polynomial-evaluation b/Lang/E/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..f19b41306b --- /dev/null +++ b/Lang/E/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/E \ No newline at end of file diff --git a/Lang/E/Hostname b/Lang/E/Hostname new file mode 120000 index 0000000000..62fd32308a --- /dev/null +++ b/Lang/E/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/E \ No newline at end of file diff --git a/Lang/E/Increment-a-numerical-string b/Lang/E/Increment-a-numerical-string new file mode 120000 index 0000000000..054f57e520 --- /dev/null +++ b/Lang/E/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/E \ No newline at end of file diff --git a/Lang/E/Inheritance-Multiple b/Lang/E/Inheritance-Multiple new file mode 120000 index 0000000000..8a670258e1 --- /dev/null +++ b/Lang/E/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/E \ No newline at end of file diff --git a/Lang/E/Inheritance-Single b/Lang/E/Inheritance-Single new file mode 120000 index 0000000000..157904d027 --- /dev/null +++ b/Lang/E/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/E \ No newline at end of file diff --git a/Lang/E/Integer-comparison b/Lang/E/Integer-comparison new file mode 120000 index 0000000000..1bfe179343 --- /dev/null +++ b/Lang/E/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/E \ No newline at end of file diff --git a/Lang/E/Integer-sequence b/Lang/E/Integer-sequence new file mode 120000 index 0000000000..94f727fd35 --- /dev/null +++ b/Lang/E/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/E \ No newline at end of file diff --git a/Lang/E/Interactive-programming b/Lang/E/Interactive-programming new file mode 120000 index 0000000000..d5652603e5 --- /dev/null +++ b/Lang/E/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/E \ No newline at end of file diff --git a/Lang/E/Introspection b/Lang/E/Introspection new file mode 120000 index 0000000000..f616968e5b --- /dev/null +++ b/Lang/E/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/E \ No newline at end of file diff --git a/Lang/E/Jensens-Device b/Lang/E/Jensens-Device new file mode 120000 index 0000000000..0039305ee1 --- /dev/null +++ b/Lang/E/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/E \ No newline at end of file diff --git a/Lang/E/Knapsack-problem-Unbounded b/Lang/E/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..ea6b1974f8 --- /dev/null +++ b/Lang/E/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/E \ No newline at end of file diff --git a/Lang/E/List-comprehensions b/Lang/E/List-comprehensions new file mode 120000 index 0000000000..1d5a89162b --- /dev/null +++ b/Lang/E/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/E \ No newline at end of file diff --git a/Lang/E/Literals-Integer b/Lang/E/Literals-Integer new file mode 120000 index 0000000000..e2d503e121 --- /dev/null +++ b/Lang/E/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/E \ No newline at end of file diff --git a/Lang/E/Literals-String b/Lang/E/Literals-String new file mode 120000 index 0000000000..e64f7f834d --- /dev/null +++ b/Lang/E/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/E \ No newline at end of file diff --git a/Lang/E/Logical-operations b/Lang/E/Logical-operations new file mode 120000 index 0000000000..098fc1f86a --- /dev/null +++ b/Lang/E/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/E \ No newline at end of file diff --git a/Lang/E/Look-and-say-sequence b/Lang/E/Look-and-say-sequence new file mode 120000 index 0000000000..ac81122e20 --- /dev/null +++ b/Lang/E/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/E \ No newline at end of file diff --git a/Lang/E/Loop-over-multiple-arrays-simultaneously b/Lang/E/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..9f00d490a9 --- /dev/null +++ b/Lang/E/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/E \ No newline at end of file diff --git a/Lang/E/Loops-Break b/Lang/E/Loops-Break new file mode 120000 index 0000000000..aa55d4ec21 --- /dev/null +++ b/Lang/E/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/E \ No newline at end of file diff --git a/Lang/E/Loops-Do-while b/Lang/E/Loops-Do-while new file mode 120000 index 0000000000..8e85cfb030 --- /dev/null +++ b/Lang/E/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/E \ No newline at end of file diff --git a/Lang/E/Loops-Downward-for b/Lang/E/Loops-Downward-for new file mode 120000 index 0000000000..60b693f0ac --- /dev/null +++ b/Lang/E/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/E \ No newline at end of file diff --git a/Lang/E/Loops-For b/Lang/E/Loops-For new file mode 120000 index 0000000000..7f94952b9f --- /dev/null +++ b/Lang/E/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/E \ No newline at end of file diff --git a/Lang/E/Loops-For-with-a-specified-step b/Lang/E/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..953dfbcf16 --- /dev/null +++ b/Lang/E/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/E \ No newline at end of file diff --git a/Lang/E/Loops-Foreach b/Lang/E/Loops-Foreach new file mode 120000 index 0000000000..d5b2ae9f2c --- /dev/null +++ b/Lang/E/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/E \ No newline at end of file diff --git a/Lang/E/Loops-Infinite b/Lang/E/Loops-Infinite new file mode 120000 index 0000000000..55550eaa03 --- /dev/null +++ b/Lang/E/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/E \ No newline at end of file diff --git a/Lang/E/Loops-N-plus-one-half b/Lang/E/Loops-N-plus-one-half new file mode 120000 index 0000000000..e09d093bce --- /dev/null +++ b/Lang/E/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/E \ No newline at end of file diff --git a/Lang/E/Loops-Nested b/Lang/E/Loops-Nested new file mode 120000 index 0000000000..5ae77adbc4 --- /dev/null +++ b/Lang/E/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/E \ No newline at end of file diff --git a/Lang/E/Loops-While b/Lang/E/Loops-While new file mode 120000 index 0000000000..986b1d2f4b --- /dev/null +++ b/Lang/E/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/E \ No newline at end of file diff --git a/Lang/E/MD5 b/Lang/E/MD5 new file mode 120000 index 0000000000..a088a417ab --- /dev/null +++ b/Lang/E/MD5 @@ -0,0 +1 @@ +../../Task/MD5/E \ No newline at end of file diff --git a/Lang/E/Man-or-boy-test b/Lang/E/Man-or-boy-test new file mode 120000 index 0000000000..4bfe5920d4 --- /dev/null +++ b/Lang/E/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/E \ No newline at end of file diff --git a/Lang/E/Memory-allocation b/Lang/E/Memory-allocation new file mode 120000 index 0000000000..7cd74b702f --- /dev/null +++ b/Lang/E/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/E \ No newline at end of file diff --git a/Lang/E/Metered-concurrency b/Lang/E/Metered-concurrency new file mode 120000 index 0000000000..e09d29ae53 --- /dev/null +++ b/Lang/E/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/E \ No newline at end of file diff --git a/Lang/E/Miller-Rabin-primality-test b/Lang/E/Miller-Rabin-primality-test new file mode 120000 index 0000000000..f586feb18b --- /dev/null +++ b/Lang/E/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/E \ No newline at end of file diff --git a/Lang/E/Monte-Carlo-methods b/Lang/E/Monte-Carlo-methods new file mode 120000 index 0000000000..b0a39566c7 --- /dev/null +++ b/Lang/E/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/E \ No newline at end of file diff --git a/Lang/E/Multiple-distinct-objects b/Lang/E/Multiple-distinct-objects new file mode 120000 index 0000000000..7d1ffb8178 --- /dev/null +++ b/Lang/E/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/E \ No newline at end of file diff --git a/Lang/E/Multiplication-tables b/Lang/E/Multiplication-tables new file mode 120000 index 0000000000..8dcbafb353 --- /dev/null +++ b/Lang/E/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/E \ No newline at end of file diff --git a/Lang/E/Mutex b/Lang/E/Mutex new file mode 120000 index 0000000000..b93f8c50c9 --- /dev/null +++ b/Lang/E/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/E \ No newline at end of file diff --git a/Lang/E/Mutual-recursion b/Lang/E/Mutual-recursion new file mode 120000 index 0000000000..0d5ede1da4 --- /dev/null +++ b/Lang/E/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/E \ No newline at end of file diff --git a/Lang/EGL/Factorial b/Lang/EGL/Factorial new file mode 120000 index 0000000000..c4b41e3eb6 --- /dev/null +++ b/Lang/EGL/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/EGL \ No newline at end of file diff --git a/Lang/EGL/GUI-Maximum-window-dimensions b/Lang/EGL/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..bd461dfb3e --- /dev/null +++ b/Lang/EGL/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/EGL \ No newline at end of file diff --git a/Lang/EGL/Hello-world-Graphical b/Lang/EGL/Hello-world-Graphical new file mode 120000 index 0000000000..c78e124f01 --- /dev/null +++ b/Lang/EGL/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/EGL \ No newline at end of file diff --git a/Lang/EGL/Hello-world-Text b/Lang/EGL/Hello-world-Text new file mode 120000 index 0000000000..33ed6f52b6 --- /dev/null +++ b/Lang/EGL/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/EGL \ No newline at end of file diff --git a/Lang/EGL/Increment-a-numerical-string b/Lang/EGL/Increment-a-numerical-string new file mode 120000 index 0000000000..9cb9f086d8 --- /dev/null +++ b/Lang/EGL/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/EGL \ No newline at end of file diff --git a/Lang/EGL/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/EGL/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..ae3dfd91cd --- /dev/null +++ b/Lang/EGL/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/EGL \ No newline at end of file diff --git a/Lang/EGL/Loops-Downward-for b/Lang/EGL/Loops-Downward-for new file mode 120000 index 0000000000..8e1204e92e --- /dev/null +++ b/Lang/EGL/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/EGL \ No newline at end of file diff --git a/Lang/EGL/Loops-For b/Lang/EGL/Loops-For new file mode 120000 index 0000000000..5d0d7be9b2 --- /dev/null +++ b/Lang/EGL/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/EGL \ No newline at end of file diff --git a/Lang/EGL/Loops-While b/Lang/EGL/Loops-While new file mode 120000 index 0000000000..d251ef8803 --- /dev/null +++ b/Lang/EGL/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/EGL \ No newline at end of file diff --git a/Lang/EGL/Matrix-multiplication b/Lang/EGL/Matrix-multiplication new file mode 120000 index 0000000000..f7daef0023 --- /dev/null +++ b/Lang/EGL/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/EGL \ No newline at end of file diff --git a/Lang/EGL/Maze-generation b/Lang/EGL/Maze-generation new file mode 120000 index 0000000000..f00e3984b1 --- /dev/null +++ b/Lang/EGL/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/EGL \ No newline at end of file diff --git a/Lang/EGL/Maze-solving b/Lang/EGL/Maze-solving new file mode 120000 index 0000000000..a02681bbae --- /dev/null +++ b/Lang/EGL/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/EGL \ No newline at end of file diff --git a/Lang/ELLA/Matrix-multiplication b/Lang/ELLA/Matrix-multiplication new file mode 120000 index 0000000000..112b171f75 --- /dev/null +++ b/Lang/ELLA/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/ELLA \ No newline at end of file diff --git a/Lang/ELLA/Matrix-transposition b/Lang/ELLA/Matrix-transposition new file mode 120000 index 0000000000..bf4980cb1f --- /dev/null +++ b/Lang/ELLA/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/ELLA \ No newline at end of file diff --git a/Lang/Efene/Function-definition b/Lang/Efene/Function-definition new file mode 120000 index 0000000000..de49cae2b9 --- /dev/null +++ b/Lang/Efene/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Efene \ No newline at end of file diff --git a/Lang/Efene/Greatest-element-of-a-list b/Lang/Efene/Greatest-element-of-a-list new file mode 120000 index 0000000000..f5da812628 --- /dev/null +++ b/Lang/Efene/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Efene \ No newline at end of file diff --git a/Lang/Efene/Hello-world-Text b/Lang/Efene/Hello-world-Text new file mode 120000 index 0000000000..113fc6b83d --- /dev/null +++ b/Lang/Efene/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Efene \ No newline at end of file diff --git a/Lang/Efene/Higher-order-functions b/Lang/Efene/Higher-order-functions new file mode 120000 index 0000000000..dbf100897d --- /dev/null +++ b/Lang/Efene/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Efene \ No newline at end of file diff --git a/Lang/Efene/Integer-comparison b/Lang/Efene/Integer-comparison new file mode 120000 index 0000000000..b4e425927b --- /dev/null +++ b/Lang/Efene/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Efene \ No newline at end of file diff --git a/Lang/Efene/List-comprehensions b/Lang/Efene/List-comprehensions new file mode 120000 index 0000000000..e30a4d7675 --- /dev/null +++ b/Lang/Efene/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Efene \ No newline at end of file diff --git a/Lang/Efene/Literals-Integer b/Lang/Efene/Literals-Integer new file mode 120000 index 0000000000..8ebd02cdb6 --- /dev/null +++ b/Lang/Efene/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Efene \ No newline at end of file diff --git a/Lang/Efene/Logical-operations b/Lang/Efene/Logical-operations new file mode 120000 index 0000000000..4d0b20ceb6 --- /dev/null +++ b/Lang/Efene/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Efene \ No newline at end of file diff --git a/Lang/Efene/Loop-over-multiple-arrays-simultaneously b/Lang/Efene/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..fdb923cc54 --- /dev/null +++ b/Lang/Efene/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Efene \ No newline at end of file diff --git a/Lang/Efene/Loops-Foreach b/Lang/Efene/Loops-Foreach new file mode 120000 index 0000000000..01e1a35578 --- /dev/null +++ b/Lang/Efene/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Efene \ No newline at end of file diff --git a/Lang/Eiffel/File-IO b/Lang/Eiffel/File-IO new file mode 120000 index 0000000000..675eaf7662 --- /dev/null +++ b/Lang/Eiffel/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/File-size b/Lang/Eiffel/File-size new file mode 120000 index 0000000000..dcbbf70be9 --- /dev/null +++ b/Lang/Eiffel/File-size @@ -0,0 +1 @@ +../../Task/File-size/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Formatted-numeric-output b/Lang/Eiffel/Formatted-numeric-output new file mode 120000 index 0000000000..ace90aa3d2 --- /dev/null +++ b/Lang/Eiffel/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Hamming-numbers b/Lang/Eiffel/Hamming-numbers new file mode 120000 index 0000000000..9c6771dbda --- /dev/null +++ b/Lang/Eiffel/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Hello-world-Text b/Lang/Eiffel/Hello-world-Text new file mode 120000 index 0000000000..6117d89876 --- /dev/null +++ b/Lang/Eiffel/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Inheritance-Multiple b/Lang/Eiffel/Inheritance-Multiple new file mode 120000 index 0000000000..39a6d7e2db --- /dev/null +++ b/Lang/Eiffel/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Inheritance-Single b/Lang/Eiffel/Inheritance-Single new file mode 120000 index 0000000000..a718653edb --- /dev/null +++ b/Lang/Eiffel/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Input-loop b/Lang/Eiffel/Input-loop new file mode 120000 index 0000000000..67e5579ebc --- /dev/null +++ b/Lang/Eiffel/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Integer-sequence b/Lang/Eiffel/Integer-sequence new file mode 120000 index 0000000000..c506eaf71d --- /dev/null +++ b/Lang/Eiffel/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Loops-Foreach b/Lang/Eiffel/Loops-Foreach new file mode 120000 index 0000000000..695f3d4f94 --- /dev/null +++ b/Lang/Eiffel/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Monty-Hall-problem b/Lang/Eiffel/Monty-Hall-problem new file mode 120000 index 0000000000..dcba43d598 --- /dev/null +++ b/Lang/Eiffel/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Eiffel \ No newline at end of file diff --git a/Lang/Ela/Factorial b/Lang/Ela/Factorial new file mode 120000 index 0000000000..86a5704d5d --- /dev/null +++ b/Lang/Ela/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Ela \ No newline at end of file diff --git a/Lang/Ela/Factors-of-an-integer b/Lang/Ela/Factors-of-an-integer new file mode 120000 index 0000000000..1518ebbef9 --- /dev/null +++ b/Lang/Ela/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Ela \ No newline at end of file diff --git a/Lang/Ela/Fibonacci-sequence b/Lang/Ela/Fibonacci-sequence new file mode 120000 index 0000000000..a6894a6cde --- /dev/null +++ b/Lang/Ela/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Ela \ No newline at end of file diff --git a/Lang/Ela/Filter b/Lang/Ela/Filter new file mode 120000 index 0000000000..f6d88c644c --- /dev/null +++ b/Lang/Ela/Filter @@ -0,0 +1 @@ +../../Task/Filter/Ela \ No newline at end of file diff --git a/Lang/Ela/First-class-functions b/Lang/Ela/First-class-functions new file mode 120000 index 0000000000..73bfbd023f --- /dev/null +++ b/Lang/Ela/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Ela \ No newline at end of file diff --git a/Lang/Ela/Flatten-a-list b/Lang/Ela/Flatten-a-list new file mode 120000 index 0000000000..bf2f653a77 --- /dev/null +++ b/Lang/Ela/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Ela \ No newline at end of file diff --git a/Lang/Ela/Function-composition b/Lang/Ela/Function-composition new file mode 120000 index 0000000000..21ccf27552 --- /dev/null +++ b/Lang/Ela/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Ela \ No newline at end of file diff --git a/Lang/Ela/Function-definition b/Lang/Ela/Function-definition new file mode 120000 index 0000000000..69bfd51fab --- /dev/null +++ b/Lang/Ela/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Ela \ No newline at end of file diff --git a/Lang/Ela/Greatest-element-of-a-list b/Lang/Ela/Greatest-element-of-a-list new file mode 120000 index 0000000000..e259a4d90c --- /dev/null +++ b/Lang/Ela/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Ela \ No newline at end of file diff --git a/Lang/Ela/Guess-the-number-With-feedback b/Lang/Ela/Guess-the-number-With-feedback new file mode 120000 index 0000000000..a4b01c121a --- /dev/null +++ b/Lang/Ela/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Ela \ No newline at end of file diff --git a/Lang/Ela/Hello-world-Text b/Lang/Ela/Hello-world-Text new file mode 120000 index 0000000000..3a9245fe74 --- /dev/null +++ b/Lang/Ela/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Ela \ No newline at end of file diff --git a/Lang/Ela/Langtons-ant b/Lang/Ela/Langtons-ant new file mode 120000 index 0000000000..d54547f84a --- /dev/null +++ b/Lang/Ela/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Ela \ No newline at end of file diff --git a/Lang/Ela/Leap-year b/Lang/Ela/Leap-year new file mode 120000 index 0000000000..1451a0b4d0 --- /dev/null +++ b/Lang/Ela/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Ela \ No newline at end of file diff --git a/Lang/Ela/Levenshtein-distance b/Lang/Ela/Levenshtein-distance new file mode 120000 index 0000000000..1470dcceac --- /dev/null +++ b/Lang/Ela/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Ela \ No newline at end of file diff --git a/Lang/Ela/List-comprehensions b/Lang/Ela/List-comprehensions new file mode 120000 index 0000000000..2ce1785e8a --- /dev/null +++ b/Lang/Ela/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Ela \ No newline at end of file diff --git a/Lang/Ela/Loop-over-multiple-arrays-simultaneously b/Lang/Ela/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..a00289b2f9 --- /dev/null +++ b/Lang/Ela/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Break b/Lang/Ela/Loops-Break new file mode 120000 index 0000000000..ff4c9dcf94 --- /dev/null +++ b/Lang/Ela/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Continue b/Lang/Ela/Loops-Continue new file mode 120000 index 0000000000..1b7f265e6d --- /dev/null +++ b/Lang/Ela/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Do-while b/Lang/Ela/Loops-Do-while new file mode 120000 index 0000000000..c97e8c49cb --- /dev/null +++ b/Lang/Ela/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Downward-for b/Lang/Ela/Loops-Downward-for new file mode 120000 index 0000000000..d318e5cbe1 --- /dev/null +++ b/Lang/Ela/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-For b/Lang/Ela/Loops-For new file mode 120000 index 0000000000..4ca5b1e212 --- /dev/null +++ b/Lang/Ela/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-For-with-a-specified-step b/Lang/Ela/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..4bd4b0e94a --- /dev/null +++ b/Lang/Ela/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Foreach b/Lang/Ela/Loops-Foreach new file mode 120000 index 0000000000..3bf74b7695 --- /dev/null +++ b/Lang/Ela/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Ela \ No newline at end of file diff --git a/Lang/Ela/Loops-Infinite b/Lang/Ela/Loops-Infinite new file mode 120000 index 0000000000..d8abc82aa1 --- /dev/null +++ b/Lang/Ela/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Ela \ No newline at end of file diff --git a/Lang/Ela/Man-or-boy-test b/Lang/Ela/Man-or-boy-test new file mode 120000 index 0000000000..3006fc2ee0 --- /dev/null +++ b/Lang/Ela/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Ela \ No newline at end of file diff --git a/Lang/Elena/Hello-world-Text b/Lang/Elena/Hello-world-Text new file mode 120000 index 0000000000..e3d614297b --- /dev/null +++ b/Lang/Elena/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Elena \ No newline at end of file diff --git a/Lang/Elisa/Formal-power-series b/Lang/Elisa/Formal-power-series new file mode 120000 index 0000000000..933f379e16 --- /dev/null +++ b/Lang/Elisa/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Elisa \ No newline at end of file diff --git a/Lang/Elisa/Hello-world-Text b/Lang/Elisa/Hello-world-Text new file mode 120000 index 0000000000..4a2bff6bf3 --- /dev/null +++ b/Lang/Elisa/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Elisa \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Arbitrary-precision-integers-included b/Lang/Emacs-Lisp/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..4d9c0aa09a --- /dev/null +++ b/Lang/Emacs-Lisp/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Factorial b/Lang/Emacs-Lisp/Factorial new file mode 120000 index 0000000000..e3e2dd2f5e --- /dev/null +++ b/Lang/Emacs-Lisp/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Find-limit-of-recursion b/Lang/Emacs-Lisp/Find-limit-of-recursion new file mode 120000 index 0000000000..78bc7fb3c3 --- /dev/null +++ b/Lang/Emacs-Lisp/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Flatten-a-list b/Lang/Emacs-Lisp/Flatten-a-list new file mode 120000 index 0000000000..773e4e684a --- /dev/null +++ b/Lang/Emacs-Lisp/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Greatest-common-divisor b/Lang/Emacs-Lisp/Greatest-common-divisor new file mode 120000 index 0000000000..6ef34ef142 --- /dev/null +++ b/Lang/Emacs-Lisp/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Greatest-element-of-a-list b/Lang/Emacs-Lisp/Greatest-element-of-a-list new file mode 120000 index 0000000000..ff453f97d9 --- /dev/null +++ b/Lang/Emacs-Lisp/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Hello-world-Text b/Lang/Emacs-Lisp/Hello-world-Text new file mode 120000 index 0000000000..c8c3e102f1 --- /dev/null +++ b/Lang/Emacs-Lisp/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Increment-a-numerical-string b/Lang/Emacs-Lisp/Increment-a-numerical-string new file mode 120000 index 0000000000..1a117a201d --- /dev/null +++ b/Lang/Emacs-Lisp/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Integer-sequence b/Lang/Emacs-Lisp/Integer-sequence new file mode 120000 index 0000000000..6672c46bd9 --- /dev/null +++ b/Lang/Emacs-Lisp/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Interactive-programming b/Lang/Emacs-Lisp/Interactive-programming new file mode 120000 index 0000000000..39ef9e1544 --- /dev/null +++ b/Lang/Emacs-Lisp/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Knapsack-problem-0-1 b/Lang/Emacs-Lisp/Knapsack-problem-0-1 new file mode 120000 index 0000000000..fb829576d5 --- /dev/null +++ b/Lang/Emacs-Lisp/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Map-range b/Lang/Emacs-Lisp/Map-range new file mode 120000 index 0000000000..e446ae21b6 --- /dev/null +++ b/Lang/Emacs-Lisp/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Modular-exponentiation b/Lang/Emacs-Lisp/Modular-exponentiation new file mode 120000 index 0000000000..069993d379 --- /dev/null +++ b/Lang/Emacs-Lisp/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Monty-Hall-problem b/Lang/Emacs-Lisp/Monty-Hall-problem new file mode 120000 index 0000000000..35d8232583 --- /dev/null +++ b/Lang/Emacs-Lisp/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Erlang/Arbitrary-precision-integers-included b/Lang/Erlang/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..cd2d4cb2a3 --- /dev/null +++ b/Lang/Erlang/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Factorial b/Lang/Erlang/Factorial new file mode 120000 index 0000000000..d311642ceb --- /dev/null +++ b/Lang/Erlang/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Factors-of-an-integer b/Lang/Erlang/Factors-of-an-integer new file mode 120000 index 0000000000..ccaae857a9 --- /dev/null +++ b/Lang/Erlang/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Fibonacci-sequence b/Lang/Erlang/Fibonacci-sequence new file mode 120000 index 0000000000..69e004684d --- /dev/null +++ b/Lang/Erlang/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/File-IO b/Lang/Erlang/File-IO new file mode 120000 index 0000000000..3030796e13 --- /dev/null +++ b/Lang/Erlang/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Erlang \ No newline at end of file diff --git a/Lang/Erlang/File-size b/Lang/Erlang/File-size new file mode 120000 index 0000000000..9104dde07e --- /dev/null +++ b/Lang/Erlang/File-size @@ -0,0 +1 @@ +../../Task/File-size/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Filter b/Lang/Erlang/Filter new file mode 120000 index 0000000000..da0e542aba --- /dev/null +++ b/Lang/Erlang/Filter @@ -0,0 +1 @@ +../../Task/Filter/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Five-weekends b/Lang/Erlang/Five-weekends new file mode 120000 index 0000000000..d2b6b1b862 --- /dev/null +++ b/Lang/Erlang/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Flatten-a-list b/Lang/Erlang/Flatten-a-list new file mode 120000 index 0000000000..e9834afd06 --- /dev/null +++ b/Lang/Erlang/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Fork b/Lang/Erlang/Fork new file mode 120000 index 0000000000..f562444504 --- /dev/null +++ b/Lang/Erlang/Fork @@ -0,0 +1 @@ +../../Task/Fork/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Function-composition b/Lang/Erlang/Function-composition new file mode 120000 index 0000000000..1dd0f9a4c0 --- /dev/null +++ b/Lang/Erlang/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Function-definition b/Lang/Erlang/Function-definition new file mode 120000 index 0000000000..bc106a179d --- /dev/null +++ b/Lang/Erlang/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Generic-swap b/Lang/Erlang/Generic-swap new file mode 120000 index 0000000000..7d5e4b22c5 --- /dev/null +++ b/Lang/Erlang/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Gray-code b/Lang/Erlang/Gray-code new file mode 120000 index 0000000000..d9e678f20f --- /dev/null +++ b/Lang/Erlang/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Greatest-common-divisor b/Lang/Erlang/Greatest-common-divisor new file mode 120000 index 0000000000..f4726ac5f6 --- /dev/null +++ b/Lang/Erlang/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Greatest-element-of-a-list b/Lang/Erlang/Greatest-element-of-a-list new file mode 120000 index 0000000000..f961990812 --- /dev/null +++ b/Lang/Erlang/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Erlang \ No newline at end of file diff --git a/Lang/Erlang/HTTP b/Lang/Erlang/HTTP new file mode 120000 index 0000000000..f8d99aeed0 --- /dev/null +++ b/Lang/Erlang/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Erlang \ No newline at end of file diff --git a/Lang/Erlang/HTTPS b/Lang/Erlang/HTTPS new file mode 120000 index 0000000000..a407e4270f --- /dev/null +++ b/Lang/Erlang/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hailstone-sequence b/Lang/Erlang/Hailstone-sequence new file mode 120000 index 0000000000..738c07c72c --- /dev/null +++ b/Lang/Erlang/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Happy-numbers b/Lang/Erlang/Happy-numbers new file mode 120000 index 0000000000..d5d44e6421 --- /dev/null +++ b/Lang/Erlang/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hello-world-Newline-omission b/Lang/Erlang/Hello-world-Newline-omission new file mode 120000 index 0000000000..cf79f4e2cf --- /dev/null +++ b/Lang/Erlang/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hello-world-Standard-error b/Lang/Erlang/Hello-world-Standard-error new file mode 120000 index 0000000000..becd863e61 --- /dev/null +++ b/Lang/Erlang/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hello-world-Text b/Lang/Erlang/Hello-world-Text new file mode 120000 index 0000000000..ee98f1eb4b --- /dev/null +++ b/Lang/Erlang/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hello-world-Web-server b/Lang/Erlang/Hello-world-Web-server new file mode 120000 index 0000000000..7aaa76b99c --- /dev/null +++ b/Lang/Erlang/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Higher-order-functions b/Lang/Erlang/Higher-order-functions new file mode 120000 index 0000000000..0219b356e3 --- /dev/null +++ b/Lang/Erlang/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hofstadter-Q-sequence b/Lang/Erlang/Hofstadter-Q-sequence new file mode 120000 index 0000000000..fa6717f3f6 --- /dev/null +++ b/Lang/Erlang/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Horners-rule-for-polynomial-evaluation b/Lang/Erlang/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..3cd90cbfd1 --- /dev/null +++ b/Lang/Erlang/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Host-introspection b/Lang/Erlang/Host-introspection new file mode 120000 index 0000000000..2c3d5cbd2e --- /dev/null +++ b/Lang/Erlang/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Hostname b/Lang/Erlang/Hostname new file mode 120000 index 0000000000..883b328006 --- /dev/null +++ b/Lang/Erlang/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Include-a-file b/Lang/Erlang/Include-a-file new file mode 120000 index 0000000000..4bc301d95a --- /dev/null +++ b/Lang/Erlang/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Increment-a-numerical-string b/Lang/Erlang/Increment-a-numerical-string new file mode 120000 index 0000000000..d0cfd2e8f8 --- /dev/null +++ b/Lang/Erlang/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Integer-comparison b/Lang/Erlang/Integer-comparison new file mode 120000 index 0000000000..82c622e6c6 --- /dev/null +++ b/Lang/Erlang/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Integer-sequence b/Lang/Erlang/Integer-sequence new file mode 120000 index 0000000000..fe8cfe5cd8 --- /dev/null +++ b/Lang/Erlang/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Interactive-programming b/Lang/Erlang/Interactive-programming new file mode 120000 index 0000000000..329217ab65 --- /dev/null +++ b/Lang/Erlang/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Erlang \ No newline at end of file diff --git a/Lang/Erlang/LZW-compression b/Lang/Erlang/LZW-compression new file mode 120000 index 0000000000..de55014ee4 --- /dev/null +++ b/Lang/Erlang/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Leap-year b/Lang/Erlang/Leap-year new file mode 120000 index 0000000000..98d39d84bf --- /dev/null +++ b/Lang/Erlang/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Levenshtein-distance b/Lang/Erlang/Levenshtein-distance new file mode 120000 index 0000000000..96d3947adf --- /dev/null +++ b/Lang/Erlang/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Erlang \ No newline at end of file diff --git a/Lang/Erlang/List-comprehensions b/Lang/Erlang/List-comprehensions new file mode 120000 index 0000000000..95ef15025c --- /dev/null +++ b/Lang/Erlang/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Literals-Integer b/Lang/Erlang/Literals-Integer new file mode 120000 index 0000000000..dd2a3df388 --- /dev/null +++ b/Lang/Erlang/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Literals-String b/Lang/Erlang/Literals-String new file mode 120000 index 0000000000..14ab252414 --- /dev/null +++ b/Lang/Erlang/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Logical-operations b/Lang/Erlang/Logical-operations new file mode 120000 index 0000000000..c986ba1dcf --- /dev/null +++ b/Lang/Erlang/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Longest-common-subsequence b/Lang/Erlang/Longest-common-subsequence new file mode 120000 index 0000000000..a90447813a --- /dev/null +++ b/Lang/Erlang/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Look-and-say-sequence b/Lang/Erlang/Look-and-say-sequence new file mode 120000 index 0000000000..9c19e00f13 --- /dev/null +++ b/Lang/Erlang/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Loop-over-multiple-arrays-simultaneously b/Lang/Erlang/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..4b428d2bb5 --- /dev/null +++ b/Lang/Erlang/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Loops-Do-while b/Lang/Erlang/Loops-Do-while new file mode 120000 index 0000000000..31a3af9b40 --- /dev/null +++ b/Lang/Erlang/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Loops-Foreach b/Lang/Erlang/Loops-Foreach new file mode 120000 index 0000000000..0df5c92042 --- /dev/null +++ b/Lang/Erlang/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Loops-Infinite b/Lang/Erlang/Loops-Infinite new file mode 120000 index 0000000000..c56d97209f --- /dev/null +++ b/Lang/Erlang/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Lucas-Lehmer-test b/Lang/Erlang/Lucas-Lehmer-test new file mode 120000 index 0000000000..1cdb8bed2e --- /dev/null +++ b/Lang/Erlang/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Erlang \ No newline at end of file diff --git a/Lang/Erlang/MD4 b/Lang/Erlang/MD4 new file mode 120000 index 0000000000..b97664804d --- /dev/null +++ b/Lang/Erlang/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Erlang \ No newline at end of file diff --git a/Lang/Erlang/MD5 b/Lang/Erlang/MD5 new file mode 120000 index 0000000000..f164f41b23 --- /dev/null +++ b/Lang/Erlang/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Mad-Libs b/Lang/Erlang/Mad-Libs new file mode 120000 index 0000000000..fbf9c7193f --- /dev/null +++ b/Lang/Erlang/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Map-range b/Lang/Erlang/Map-range new file mode 120000 index 0000000000..0a8887286c --- /dev/null +++ b/Lang/Erlang/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Metered-concurrency b/Lang/Erlang/Metered-concurrency new file mode 120000 index 0000000000..1d9a76e3eb --- /dev/null +++ b/Lang/Erlang/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Miller-Rabin-primality-test b/Lang/Erlang/Miller-Rabin-primality-test new file mode 120000 index 0000000000..5bdd377694 --- /dev/null +++ b/Lang/Erlang/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Multifactorial b/Lang/Erlang/Multifactorial new file mode 120000 index 0000000000..4756982cc4 --- /dev/null +++ b/Lang/Erlang/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Mutual-recursion b/Lang/Erlang/Mutual-recursion new file mode 120000 index 0000000000..3a801d57fb --- /dev/null +++ b/Lang/Erlang/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Erlang \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/24-game-Solve b/Lang/Euler-Math-Toolbox/24-game-Solve new file mode 120000 index 0000000000..cb3e11b4e1 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Greatest-common-divisor b/Lang/Euler-Math-Toolbox/Greatest-common-divisor new file mode 120000 index 0000000000..243d11fbf6 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Greatest-element-of-a-list b/Lang/Euler-Math-Toolbox/Greatest-element-of-a-list new file mode 120000 index 0000000000..7f6e89996c --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Greatest-subsequential-sum b/Lang/Euler-Math-Toolbox/Greatest-subsequential-sum new file mode 120000 index 0000000000..cf1b5f263e --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Greyscale-bars-Display b/Lang/Euler-Math-Toolbox/Greyscale-bars-Display new file mode 120000 index 0000000000..60017d6fcc --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Hailstone-sequence b/Lang/Euler-Math-Toolbox/Hailstone-sequence new file mode 120000 index 0000000000..9e3ab79bb0 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Higher-order-functions b/Lang/Euler-Math-Toolbox/Higher-order-functions new file mode 120000 index 0000000000..52bb3b9438 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Hofstadter-Conway-$10,000-sequence b/Lang/Euler-Math-Toolbox/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..2d06bc4c8b --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Hofstadter-Figure-Figure-sequences b/Lang/Euler-Math-Toolbox/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..e8d349adc4 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Horners-rule-for-polynomial-evaluation b/Lang/Euler-Math-Toolbox/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..856c643959 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Identity-matrix b/Lang/Euler-Math-Toolbox/Identity-matrix new file mode 120000 index 0000000000..3a2980029b --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Image-noise b/Lang/Euler-Math-Toolbox/Image-noise new file mode 120000 index 0000000000..fd3ce8117d --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/K-means++-clustering b/Lang/Euler-Math-Toolbox/K-means++-clustering new file mode 120000 index 0000000000..2687dbea7a --- /dev/null +++ b/Lang/Euler-Math-Toolbox/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Kaprekar-numbers b/Lang/Euler-Math-Toolbox/Kaprekar-numbers new file mode 120000 index 0000000000..ffc414f164 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Knapsack-problem-0-1 b/Lang/Euler-Math-Toolbox/Knapsack-problem-0-1 new file mode 120000 index 0000000000..9b590f5915 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Monte-Carlo-methods b/Lang/Euler-Math-Toolbox/Monte-Carlo-methods new file mode 120000 index 0000000000..d8a6f38bc4 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euphoria/Factorial b/Lang/Euphoria/Factorial new file mode 120000 index 0000000000..7dbfd29bae --- /dev/null +++ b/Lang/Euphoria/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Fibonacci-sequence b/Lang/Euphoria/Fibonacci-sequence new file mode 120000 index 0000000000..7e3c9febee --- /dev/null +++ b/Lang/Euphoria/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/File-IO b/Lang/Euphoria/File-IO new file mode 120000 index 0000000000..c64f9ffb27 --- /dev/null +++ b/Lang/Euphoria/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/File-size b/Lang/Euphoria/File-size new file mode 120000 index 0000000000..0187a5e409 --- /dev/null +++ b/Lang/Euphoria/File-size @@ -0,0 +1 @@ +../../Task/File-size/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Filter b/Lang/Euphoria/Filter new file mode 120000 index 0000000000..678e9a9629 --- /dev/null +++ b/Lang/Euphoria/Filter @@ -0,0 +1 @@ +../../Task/Filter/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Five-weekends b/Lang/Euphoria/Five-weekends new file mode 120000 index 0000000000..da7abed888 --- /dev/null +++ b/Lang/Euphoria/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Flatten-a-list b/Lang/Euphoria/Flatten-a-list new file mode 120000 index 0000000000..825bb4f761 --- /dev/null +++ b/Lang/Euphoria/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Formatted-numeric-output b/Lang/Euphoria/Formatted-numeric-output new file mode 120000 index 0000000000..2180270d5a --- /dev/null +++ b/Lang/Euphoria/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Function-definition b/Lang/Euphoria/Function-definition new file mode 120000 index 0000000000..5744a778d0 --- /dev/null +++ b/Lang/Euphoria/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Gray-code b/Lang/Euphoria/Gray-code new file mode 120000 index 0000000000..b9b0ad0661 --- /dev/null +++ b/Lang/Euphoria/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Grayscale-image b/Lang/Euphoria/Grayscale-image new file mode 120000 index 0000000000..3a39d748d0 --- /dev/null +++ b/Lang/Euphoria/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Greatest-common-divisor b/Lang/Euphoria/Greatest-common-divisor new file mode 120000 index 0000000000..e61751dd03 --- /dev/null +++ b/Lang/Euphoria/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Greatest-element-of-a-list b/Lang/Euphoria/Greatest-element-of-a-list new file mode 120000 index 0000000000..03c6e60e10 --- /dev/null +++ b/Lang/Euphoria/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Greatest-subsequential-sum b/Lang/Euphoria/Greatest-subsequential-sum new file mode 120000 index 0000000000..5957d6fb33 --- /dev/null +++ b/Lang/Euphoria/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Guess-the-number b/Lang/Euphoria/Guess-the-number new file mode 120000 index 0000000000..606e111247 --- /dev/null +++ b/Lang/Euphoria/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Guess-the-number-With-feedback b/Lang/Euphoria/Guess-the-number-With-feedback new file mode 120000 index 0000000000..b508879ea5 --- /dev/null +++ b/Lang/Euphoria/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Guess-the-number-With-feedback-player b/Lang/Euphoria/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..808118f582 --- /dev/null +++ b/Lang/Euphoria/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Hailstone-sequence b/Lang/Euphoria/Hailstone-sequence new file mode 120000 index 0000000000..462007c991 --- /dev/null +++ b/Lang/Euphoria/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Happy-numbers b/Lang/Euphoria/Happy-numbers new file mode 120000 index 0000000000..3c5ed0a709 --- /dev/null +++ b/Lang/Euphoria/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Hello-world-Graphical b/Lang/Euphoria/Hello-world-Graphical new file mode 120000 index 0000000000..40e18128b8 --- /dev/null +++ b/Lang/Euphoria/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Hello-world-Newline-omission b/Lang/Euphoria/Hello-world-Newline-omission new file mode 120000 index 0000000000..ded1a12e01 --- /dev/null +++ b/Lang/Euphoria/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Hello-world-Standard-error b/Lang/Euphoria/Hello-world-Standard-error new file mode 120000 index 0000000000..39e3827808 --- /dev/null +++ b/Lang/Euphoria/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Hello-world-Text b/Lang/Euphoria/Hello-world-Text new file mode 120000 index 0000000000..a9e631687a --- /dev/null +++ b/Lang/Euphoria/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Higher-order-functions b/Lang/Euphoria/Higher-order-functions new file mode 120000 index 0000000000..0c94c991f1 --- /dev/null +++ b/Lang/Euphoria/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Increment-a-numerical-string b/Lang/Euphoria/Increment-a-numerical-string new file mode 120000 index 0000000000..ecc6db9389 --- /dev/null +++ b/Lang/Euphoria/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Input-loop b/Lang/Euphoria/Input-loop new file mode 120000 index 0000000000..c1a6b85521 --- /dev/null +++ b/Lang/Euphoria/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Integer-comparison b/Lang/Euphoria/Integer-comparison new file mode 120000 index 0000000000..0e71ebfe86 --- /dev/null +++ b/Lang/Euphoria/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Integer-sequence b/Lang/Euphoria/Integer-sequence new file mode 120000 index 0000000000..9b9bf19702 --- /dev/null +++ b/Lang/Euphoria/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Euphoria/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..587a760854 --- /dev/null +++ b/Lang/Euphoria/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Keyboard-input-Keypress-check b/Lang/Euphoria/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..e4250cb76d --- /dev/null +++ b/Lang/Euphoria/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Euphoria/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..f93982b2a2 --- /dev/null +++ b/Lang/Euphoria/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Langtons-ant b/Lang/Euphoria/Langtons-ant new file mode 120000 index 0000000000..8bf1f2c9ca --- /dev/null +++ b/Lang/Euphoria/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Leap-year b/Lang/Euphoria/Leap-year new file mode 120000 index 0000000000..e04a4e50fc --- /dev/null +++ b/Lang/Euphoria/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Least-common-multiple b/Lang/Euphoria/Least-common-multiple new file mode 120000 index 0000000000..3733ad7d3e --- /dev/null +++ b/Lang/Euphoria/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Levenshtein-distance b/Lang/Euphoria/Levenshtein-distance new file mode 120000 index 0000000000..fd7f3595c6 --- /dev/null +++ b/Lang/Euphoria/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Logical-operations b/Lang/Euphoria/Logical-operations new file mode 120000 index 0000000000..74e291e526 --- /dev/null +++ b/Lang/Euphoria/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Long-multiplication b/Lang/Euphoria/Long-multiplication new file mode 120000 index 0000000000..05ebac050a --- /dev/null +++ b/Lang/Euphoria/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loop-over-multiple-arrays-simultaneously b/Lang/Euphoria/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..2174ad01bc --- /dev/null +++ b/Lang/Euphoria/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-Break b/Lang/Euphoria/Loops-Break new file mode 120000 index 0000000000..6c14f7748d --- /dev/null +++ b/Lang/Euphoria/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-Continue b/Lang/Euphoria/Loops-Continue new file mode 120000 index 0000000000..3b6308cf11 --- /dev/null +++ b/Lang/Euphoria/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-Downward-for b/Lang/Euphoria/Loops-Downward-for new file mode 120000 index 0000000000..1adc7e2994 --- /dev/null +++ b/Lang/Euphoria/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-For b/Lang/Euphoria/Loops-For new file mode 120000 index 0000000000..4f83c155e5 --- /dev/null +++ b/Lang/Euphoria/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-For-with-a-specified-step b/Lang/Euphoria/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..8b9046fd7f --- /dev/null +++ b/Lang/Euphoria/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-Infinite b/Lang/Euphoria/Loops-Infinite new file mode 120000 index 0000000000..c4ac336d38 --- /dev/null +++ b/Lang/Euphoria/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-N-plus-one-half b/Lang/Euphoria/Loops-N-plus-one-half new file mode 120000 index 0000000000..32a5ecc684 --- /dev/null +++ b/Lang/Euphoria/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-Nested b/Lang/Euphoria/Loops-Nested new file mode 120000 index 0000000000..3e4feac7f0 --- /dev/null +++ b/Lang/Euphoria/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Loops-While b/Lang/Euphoria/Loops-While new file mode 120000 index 0000000000..f9a7b55ebc --- /dev/null +++ b/Lang/Euphoria/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Luhn-test-of-credit-card-numbers b/Lang/Euphoria/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..8649f9bb74 --- /dev/null +++ b/Lang/Euphoria/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Map-range b/Lang/Euphoria/Map-range new file mode 120000 index 0000000000..997d2af4c5 --- /dev/null +++ b/Lang/Euphoria/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Matrix-multiplication b/Lang/Euphoria/Matrix-multiplication new file mode 120000 index 0000000000..81ded1c053 --- /dev/null +++ b/Lang/Euphoria/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Matrix-transposition b/Lang/Euphoria/Matrix-transposition new file mode 120000 index 0000000000..701e7de01d --- /dev/null +++ b/Lang/Euphoria/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Menu b/Lang/Euphoria/Menu new file mode 120000 index 0000000000..a8bdc60fb2 --- /dev/null +++ b/Lang/Euphoria/Menu @@ -0,0 +1 @@ +../../Task/Menu/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Metered-concurrency b/Lang/Euphoria/Metered-concurrency new file mode 120000 index 0000000000..4cf73b10b0 --- /dev/null +++ b/Lang/Euphoria/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Monty-Hall-problem b/Lang/Euphoria/Monty-Hall-problem new file mode 120000 index 0000000000..60844ac854 --- /dev/null +++ b/Lang/Euphoria/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Multiplication-tables b/Lang/Euphoria/Multiplication-tables new file mode 120000 index 0000000000..9236b2e262 --- /dev/null +++ b/Lang/Euphoria/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Mutual-recursion b/Lang/Euphoria/Mutual-recursion new file mode 120000 index 0000000000..140efd5042 --- /dev/null +++ b/Lang/Euphoria/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Euphoria \ No newline at end of file diff --git a/Lang/F-Sharp/0DESCRIPTION b/Lang/F-Sharp/0DESCRIPTION new file mode 100644 index 0000000000..eba646c0a8 --- /dev/null +++ b/Lang/F-Sharp/0DESCRIPTION @@ -0,0 +1,15 @@ +
Due to technical limitations, the link [[F sharp|F#]] points to the [[F]] [[programming language]] in some articles. To correct this issue, replace [[F#]] with [[F Sharp|F#]], and {{header|F#}} with {{header|F Sharp|F#}}
+{{language +|tags=fsharp +|hopl id=3716 +}}[[runs on vm::common language runtime| ]] +'''F#''' is a multi-paradigm ([[functional programming|functional]] and [[object-oriented programming|object-oriented]]), strongly typed language created by Don Syme at Microsoft Research for Microsoft's [[.NET]] platform. +It is based on the [[Caml]] language, and resembles it in syntax. + +F# is included as an 'official' .NET language in [[Visual Studio]] 2010. + +==External Links== +* [http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/default.aspx F# Website at Microsoft] +* [http://blogs.msdn.com/dsyme/ Don Syme's F# Weblog] + +[[Category:Caml Implementations]] \ No newline at end of file diff --git a/Lang/F/0DESCRIPTION b/Lang/F/0DESCRIPTION new file mode 100644 index 0000000000..e836ff79bb --- /dev/null +++ b/Lang/F/0DESCRIPTION @@ -0,0 +1,9 @@ +
Due to technical limitations, the link [[F Sharp|F#]] points to here in some articles. To correct this issue, replace [[F#]] with [[F Sharp|F#]], and {{header|F#}} with {{header|F Sharp|F#}}.
+{{language +|hopl id=3460 +}}F is a structured, array based language created by Walter Brainerd, Richard Hendrickson, and David Epstein. +It is a subset of [[Fortran|Fortran 95]], designed to be simpler than Fortran and suitable for teaching. + +==External Links== +* [http://www.fortran.com/F/ F Programming Language Homepage] +* [[wp:F_programming_language|Wikipedia: F Programming Language]] \ No newline at end of file diff --git a/Lang/FALSE/0DESCRIPTION b/Lang/FALSE/0DESCRIPTION new file mode 100644 index 0000000000..89f23d6d64 --- /dev/null +++ b/Lang/FALSE/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language|FALSE}} +'''FALSE''' is a [[Forth]]-like esoteric programming language invented by Wouter van Oortmerssen in 1993, originally written for the Amiga to see how small one could make a compiler (1K) for a language that was still powerful enough to write applications. FALSE directly inspired the creation of [[Brainf***]] and [[Befunge]]. + +* [[eso:FALSE|FALSE on Esolangs]] + +[[Category:Esoteric Languages]] \ No newline at end of file diff --git a/Lang/FALSE/99-Bottles-of-Beer b/Lang/FALSE/99-Bottles-of-Beer new file mode 120000 index 0000000000..167e034e74 --- /dev/null +++ b/Lang/FALSE/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/FALSE \ No newline at end of file diff --git a/Lang/FALSE/A+B b/Lang/FALSE/A+B new file mode 120000 index 0000000000..ae898092c1 --- /dev/null +++ b/Lang/FALSE/A+B @@ -0,0 +1 @@ +../../Task/A+B/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Ackermann-function b/Lang/FALSE/Ackermann-function new file mode 120000 index 0000000000..0a09d77b96 --- /dev/null +++ b/Lang/FALSE/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Arithmetic-Integer b/Lang/FALSE/Arithmetic-Integer new file mode 120000 index 0000000000..67fa22dbf2 --- /dev/null +++ b/Lang/FALSE/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Bitwise-operations b/Lang/FALSE/Bitwise-operations new file mode 120000 index 0000000000..1a58170c9d --- /dev/null +++ b/Lang/FALSE/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Character-codes b/Lang/FALSE/Character-codes new file mode 120000 index 0000000000..70aed5611f --- /dev/null +++ b/Lang/FALSE/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Comments b/Lang/FALSE/Comments new file mode 120000 index 0000000000..ef4b948d5a --- /dev/null +++ b/Lang/FALSE/Comments @@ -0,0 +1 @@ +../../Task/Comments/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Conditional-structures b/Lang/FALSE/Conditional-structures new file mode 120000 index 0000000000..62832ed4fc --- /dev/null +++ b/Lang/FALSE/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Dot-product b/Lang/FALSE/Dot-product new file mode 120000 index 0000000000..9a5f3843bb --- /dev/null +++ b/Lang/FALSE/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Empty-program b/Lang/FALSE/Empty-program new file mode 120000 index 0000000000..35445789cd --- /dev/null +++ b/Lang/FALSE/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Ethiopian-multiplication b/Lang/FALSE/Ethiopian-multiplication new file mode 120000 index 0000000000..615a792478 --- /dev/null +++ b/Lang/FALSE/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Factorial b/Lang/FALSE/Factorial new file mode 120000 index 0000000000..6488007805 --- /dev/null +++ b/Lang/FALSE/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Factors-of-an-integer b/Lang/FALSE/Factors-of-an-integer new file mode 120000 index 0000000000..8f601bfefc --- /dev/null +++ b/Lang/FALSE/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Fibonacci-sequence b/Lang/FALSE/Fibonacci-sequence new file mode 120000 index 0000000000..da2c2bfab8 --- /dev/null +++ b/Lang/FALSE/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/FALSE \ No newline at end of file diff --git a/Lang/FALSE/FizzBuzz b/Lang/FALSE/FizzBuzz new file mode 120000 index 0000000000..49383bbfd7 --- /dev/null +++ b/Lang/FALSE/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Function-definition b/Lang/FALSE/Function-definition new file mode 120000 index 0000000000..fd93df6627 --- /dev/null +++ b/Lang/FALSE/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Greatest-common-divisor b/Lang/FALSE/Greatest-common-divisor new file mode 120000 index 0000000000..1c93f5ef6a --- /dev/null +++ b/Lang/FALSE/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Hailstone-sequence b/Lang/FALSE/Hailstone-sequence new file mode 120000 index 0000000000..37414dc612 --- /dev/null +++ b/Lang/FALSE/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Hello-world-Text b/Lang/FALSE/Hello-world-Text new file mode 120000 index 0000000000..79107239b1 --- /dev/null +++ b/Lang/FALSE/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Higher-order-functions b/Lang/FALSE/Higher-order-functions new file mode 120000 index 0000000000..7bf8a96a0d --- /dev/null +++ b/Lang/FALSE/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Integer-comparison b/Lang/FALSE/Integer-comparison new file mode 120000 index 0000000000..d74f58a821 --- /dev/null +++ b/Lang/FALSE/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Logical-operations b/Lang/FALSE/Logical-operations new file mode 120000 index 0000000000..7ade85eea5 --- /dev/null +++ b/Lang/FALSE/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-Downward-for b/Lang/FALSE/Loops-Downward-for new file mode 120000 index 0000000000..54b2c02f42 --- /dev/null +++ b/Lang/FALSE/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-For b/Lang/FALSE/Loops-For new file mode 120000 index 0000000000..0f7e0b1d0c --- /dev/null +++ b/Lang/FALSE/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-For-with-a-specified-step b/Lang/FALSE/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..f66af0d26b --- /dev/null +++ b/Lang/FALSE/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-Infinite b/Lang/FALSE/Loops-Infinite new file mode 120000 index 0000000000..325b428bc3 --- /dev/null +++ b/Lang/FALSE/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-N-plus-one-half b/Lang/FALSE/Loops-N-plus-one-half new file mode 120000 index 0000000000..69df2e2972 --- /dev/null +++ b/Lang/FALSE/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Loops-While b/Lang/FALSE/Loops-While new file mode 120000 index 0000000000..99f9a5306a --- /dev/null +++ b/Lang/FALSE/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Multiplication-tables b/Lang/FALSE/Multiplication-tables new file mode 120000 index 0000000000..19d93005ee --- /dev/null +++ b/Lang/FALSE/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Mutual-recursion b/Lang/FALSE/Mutual-recursion new file mode 120000 index 0000000000..6678f81af7 --- /dev/null +++ b/Lang/FALSE/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/FALSE \ No newline at end of file diff --git a/Lang/FAUST/0DESCRIPTION b/Lang/FAUST/0DESCRIPTION new file mode 100644 index 0000000000..73980e50b0 --- /dev/null +++ b/Lang/FAUST/0DESCRIPTION @@ -0,0 +1,10 @@ +{{stub}} +{{language +|site=http://faust.grame.fr/ +}} + +FAUST is a compiled language for real-time audio signal processing. + +The name FAUST stands for Functional AUdio STream. Its programming model combines two approaches : functional programming and block diagram composition. You can think of FAUST as a structured block diagram language with a textual syntax. + +FAUST is intended for developers who need to develop efficient C/C++ audio plugins for existing systems or full standalone audio applications. Thanks to some specific compilation techniques and powerful optimizations, the [[C++]] code generated by the Faust compiler is usually very fast. It can generally compete with (and sometimes outperform) hand-written [[C]] code. \ No newline at end of file diff --git a/Lang/FBSL/0DESCRIPTION b/Lang/FBSL/0DESCRIPTION new file mode 100644 index 0000000000..84c5375c3b --- /dev/null +++ b/Lang/FBSL/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language +|site=http://www.fbsl.net/base/preview.html}} +FBSL means “Freestyle BASIC Language Script”. +Like many modern programming languages +contains flavours of [[Visual BASIC]], [[QBasic]], [[PHP]], [[Pascal]] and [[C++]]. +It is a kind of hybrid language hence the “Freestyle”. +It is especially designed for the [[win32]] platform ([[Windows 95 SR2]] to [[Windows VISTA]]). +It is compatible with, and completely functional under, [[LINUX]] [[Wine]]. \ No newline at end of file diff --git a/Lang/FBSL/99-Bottles-of-Beer b/Lang/FBSL/99-Bottles-of-Beer new file mode 120000 index 0000000000..94e389590c --- /dev/null +++ b/Lang/FBSL/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/FBSL \ No newline at end of file diff --git a/Lang/FLORA-2/0DESCRIPTION b/Lang/FLORA-2/0DESCRIPTION new file mode 100644 index 0000000000..f9cab061fe --- /dev/null +++ b/Lang/FLORA-2/0DESCRIPTION @@ -0,0 +1,3 @@ +{{stub}}{{language|FLORA-2 +|site=http://flora.sourceforge.net/}} +FLORA-2 is an advanced object-oriented knowledge base language and application development environment. The language of FLORA-2 is a dialect of [[wp:FLogic|F-logic]] with numerous extensions, including meta-programming in the style of HiLog and logical updates in the style of Transaction Logic. FLORA-2 was designed with extensibility and flexibility in mind, and it provides strong support for modular software design through its unique feature of dynamic modules. \ No newline at end of file diff --git a/Lang/FP/0DESCRIPTION b/Lang/FP/0DESCRIPTION new file mode 100644 index 0000000000..28b4e5c992 --- /dev/null +++ b/Lang/FP/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language|FP}}'''FP''' (short for '''F'''unction '''P'''rogramming) is a programming language created by John Backus to support the function-level programming paradigm. This allows for the elimination of named variables. + +==Citations== +* [http://en.wikipedia.org/wiki/FP_programming_language Wikipedia:FP programming language] \ No newline at end of file diff --git a/Lang/FP/Apply-a-callback-to-an-array b/Lang/FP/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..88baa01504 --- /dev/null +++ b/Lang/FP/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/FP \ No newline at end of file diff --git a/Lang/FPI/0DESCRIPTION b/Lang/FPI/0DESCRIPTION new file mode 100644 index 0000000000..e8fa7e2367 --- /dev/null +++ b/Lang/FPI/0DESCRIPTION @@ -0,0 +1,6 @@ +{{stub}} +{{language|FPI +|site= +|tags=fpi}} + +FPI is the scripting language used by First Person Shooter Creator. \ No newline at end of file diff --git a/Lang/Factor/0DESCRIPTION b/Lang/Factor/0DESCRIPTION new file mode 100644 index 0000000000..a16654ee74 --- /dev/null +++ b/Lang/Factor/0DESCRIPTION @@ -0,0 +1,19 @@ +{{stub}} +{{language +|exec=machine +|site=http://factorcode.org +|gc=yes +|parampass=reference +|safety=safe +|strenght=weak +|compat=duck +|express=implicit +|checking=dynamic +|tags=factor +|LCT=yes}} +Factor is a stack language similar to, but of a higher level than, [[Forth]]. + +==Links== +*[http://planet.factorcode.org Planet Factor] + +{{Language programming paradigm|Concatenative}} \ No newline at end of file diff --git a/Lang/Factor/100-doors b/Lang/Factor/100-doors new file mode 120000 index 0000000000..f4baddcf6b --- /dev/null +++ b/Lang/Factor/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Factor \ No newline at end of file diff --git a/Lang/Factor/99-Bottles-of-Beer b/Lang/Factor/99-Bottles-of-Beer new file mode 120000 index 0000000000..c7c548c1a2 --- /dev/null +++ b/Lang/Factor/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Factor \ No newline at end of file diff --git a/Lang/Factor/A+B b/Lang/Factor/A+B new file mode 120000 index 0000000000..ad3ffae179 --- /dev/null +++ b/Lang/Factor/A+B @@ -0,0 +1 @@ +../../Task/A+B/Factor \ No newline at end of file diff --git a/Lang/Factor/Accumulator-factory b/Lang/Factor/Accumulator-factory new file mode 120000 index 0000000000..190f3807d1 --- /dev/null +++ b/Lang/Factor/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Factor \ No newline at end of file diff --git a/Lang/Factor/Ackermann-function b/Lang/Factor/Ackermann-function new file mode 120000 index 0000000000..934609d4a7 --- /dev/null +++ b/Lang/Factor/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Factor \ No newline at end of file diff --git a/Lang/Factor/Active-object b/Lang/Factor/Active-object new file mode 120000 index 0000000000..e225680e43 --- /dev/null +++ b/Lang/Factor/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Factor \ No newline at end of file diff --git a/Lang/Factor/Align-columns b/Lang/Factor/Align-columns new file mode 120000 index 0000000000..bb11f9a5ee --- /dev/null +++ b/Lang/Factor/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Factor \ No newline at end of file diff --git a/Lang/Factor/Anagrams-Deranged-anagrams b/Lang/Factor/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..be74f15428 --- /dev/null +++ b/Lang/Factor/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Factor \ No newline at end of file diff --git a/Lang/Factor/Animate-a-pendulum b/Lang/Factor/Animate-a-pendulum new file mode 120000 index 0000000000..60a9523c85 --- /dev/null +++ b/Lang/Factor/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/Factor \ No newline at end of file diff --git a/Lang/Factor/Animation b/Lang/Factor/Animation new file mode 120000 index 0000000000..71f7cc812a --- /dev/null +++ b/Lang/Factor/Animation @@ -0,0 +1 @@ +../../Task/Animation/Factor \ No newline at end of file diff --git a/Lang/Factor/Anonymous-recursion b/Lang/Factor/Anonymous-recursion new file mode 120000 index 0000000000..7b3198f759 --- /dev/null +++ b/Lang/Factor/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Factor \ No newline at end of file diff --git a/Lang/Factor/Apply-a-callback-to-an-array b/Lang/Factor/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..0be3fe465c --- /dev/null +++ b/Lang/Factor/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Factor \ No newline at end of file diff --git a/Lang/Factor/Arbitrary-precision-integers-included b/Lang/Factor/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..ddb3ab07e8 --- /dev/null +++ b/Lang/Factor/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Factor \ No newline at end of file diff --git a/Lang/Factor/Arithmetic-Complex b/Lang/Factor/Arithmetic-Complex new file mode 120000 index 0000000000..bf673804c7 --- /dev/null +++ b/Lang/Factor/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Factor \ No newline at end of file diff --git a/Lang/Factor/Arithmetic-Integer b/Lang/Factor/Arithmetic-Integer new file mode 120000 index 0000000000..9b39678fe4 --- /dev/null +++ b/Lang/Factor/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Factor \ No newline at end of file diff --git a/Lang/Factor/Arithmetic-evaluation b/Lang/Factor/Arithmetic-evaluation new file mode 120000 index 0000000000..06830a4c69 --- /dev/null +++ b/Lang/Factor/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Factor \ No newline at end of file diff --git a/Lang/Factor/Array-concatenation b/Lang/Factor/Array-concatenation new file mode 120000 index 0000000000..986db42396 --- /dev/null +++ b/Lang/Factor/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Factor \ No newline at end of file diff --git a/Lang/Factor/Arrays b/Lang/Factor/Arrays new file mode 120000 index 0000000000..8e38b05dcd --- /dev/null +++ b/Lang/Factor/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Factor \ No newline at end of file diff --git a/Lang/Factor/Assertions b/Lang/Factor/Assertions new file mode 120000 index 0000000000..54fd1eea51 --- /dev/null +++ b/Lang/Factor/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Factor \ No newline at end of file diff --git a/Lang/Factor/Associative-array-Creation b/Lang/Factor/Associative-array-Creation new file mode 120000 index 0000000000..1d78e19840 --- /dev/null +++ b/Lang/Factor/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Factor \ No newline at end of file diff --git a/Lang/Factor/Associative-array-Iteration b/Lang/Factor/Associative-array-Iteration new file mode 120000 index 0000000000..f242c1e02a --- /dev/null +++ b/Lang/Factor/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Factor \ No newline at end of file diff --git a/Lang/Factor/Averages-Arithmetic-mean b/Lang/Factor/Averages-Arithmetic-mean new file mode 120000 index 0000000000..219f7ad287 --- /dev/null +++ b/Lang/Factor/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Factor \ No newline at end of file diff --git a/Lang/Factor/Averages-Median b/Lang/Factor/Averages-Median new file mode 120000 index 0000000000..eeafe7924a --- /dev/null +++ b/Lang/Factor/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Factor \ No newline at end of file diff --git a/Lang/Factor/Averages-Mode b/Lang/Factor/Averages-Mode new file mode 120000 index 0000000000..5c0e5bdffd --- /dev/null +++ b/Lang/Factor/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Factor \ No newline at end of file diff --git a/Lang/Factor/Averages-Pythagorean-means b/Lang/Factor/Averages-Pythagorean-means new file mode 120000 index 0000000000..d5fa85665e --- /dev/null +++ b/Lang/Factor/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Factor \ No newline at end of file diff --git a/Lang/Factor/Averages-Root-mean-square b/Lang/Factor/Averages-Root-mean-square new file mode 120000 index 0000000000..c735d49f68 --- /dev/null +++ b/Lang/Factor/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Factor \ No newline at end of file diff --git a/Lang/Factor/Balanced-brackets b/Lang/Factor/Balanced-brackets new file mode 120000 index 0000000000..d94ec7aa66 --- /dev/null +++ b/Lang/Factor/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Factor \ No newline at end of file diff --git a/Lang/Factor/Binary-search b/Lang/Factor/Binary-search new file mode 120000 index 0000000000..58b8b51a69 --- /dev/null +++ b/Lang/Factor/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Factor \ No newline at end of file diff --git a/Lang/Factor/Binary-strings b/Lang/Factor/Binary-strings new file mode 120000 index 0000000000..9fa1734ee7 --- /dev/null +++ b/Lang/Factor/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/Factor \ No newline at end of file diff --git a/Lang/Factor/Bitmap b/Lang/Factor/Bitmap new file mode 120000 index 0000000000..e4a25126ad --- /dev/null +++ b/Lang/Factor/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Factor \ No newline at end of file diff --git a/Lang/Factor/Bitmap-B-zier-curves-Cubic b/Lang/Factor/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..3be01c3f74 --- /dev/null +++ b/Lang/Factor/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Factor \ No newline at end of file diff --git a/Lang/Factor/Bitmap-B-zier-curves-Quadratic b/Lang/Factor/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..0e4b5c9827 --- /dev/null +++ b/Lang/Factor/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Factor \ No newline at end of file diff --git a/Lang/Factor/Bitmap-Bresenhams-line-algorithm b/Lang/Factor/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..1eba1b01f5 --- /dev/null +++ b/Lang/Factor/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Factor \ No newline at end of file diff --git a/Lang/Factor/Bitwise-operations b/Lang/Factor/Bitwise-operations new file mode 120000 index 0000000000..ad3c6f51a6 --- /dev/null +++ b/Lang/Factor/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Factor \ No newline at end of file diff --git a/Lang/Factor/Break-OO-privacy b/Lang/Factor/Break-OO-privacy new file mode 120000 index 0000000000..5effc139db --- /dev/null +++ b/Lang/Factor/Break-OO-privacy @@ -0,0 +1 @@ +../../Task/Break-OO-privacy/Factor \ No newline at end of file diff --git a/Lang/Factor/Bulls-and-cows b/Lang/Factor/Bulls-and-cows new file mode 120000 index 0000000000..9f7e5f650d --- /dev/null +++ b/Lang/Factor/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Factor \ No newline at end of file diff --git a/Lang/Factor/Call-a-foreign-language-function b/Lang/Factor/Call-a-foreign-language-function new file mode 120000 index 0000000000..6b4fd57054 --- /dev/null +++ b/Lang/Factor/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Factor \ No newline at end of file diff --git a/Lang/Factor/Character-codes b/Lang/Factor/Character-codes new file mode 120000 index 0000000000..744639424a --- /dev/null +++ b/Lang/Factor/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Factor \ No newline at end of file diff --git a/Lang/Factor/Check-that-file-exists b/Lang/Factor/Check-that-file-exists new file mode 120000 index 0000000000..c9c8f561b1 --- /dev/null +++ b/Lang/Factor/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Factor \ No newline at end of file diff --git a/Lang/Factor/Classes b/Lang/Factor/Classes new file mode 120000 index 0000000000..6c9bb0efc3 --- /dev/null +++ b/Lang/Factor/Classes @@ -0,0 +1 @@ +../../Task/Classes/Factor \ No newline at end of file diff --git a/Lang/Factor/Combinations b/Lang/Factor/Combinations new file mode 120000 index 0000000000..edbfc82520 --- /dev/null +++ b/Lang/Factor/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Factor \ No newline at end of file diff --git a/Lang/Factor/Comments b/Lang/Factor/Comments new file mode 120000 index 0000000000..f49362dfaa --- /dev/null +++ b/Lang/Factor/Comments @@ -0,0 +1 @@ +../../Task/Comments/Factor \ No newline at end of file diff --git a/Lang/Factor/Compile-time-calculation b/Lang/Factor/Compile-time-calculation new file mode 120000 index 0000000000..36a1b6efac --- /dev/null +++ b/Lang/Factor/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Factor \ No newline at end of file diff --git a/Lang/Factor/Compound-data-type b/Lang/Factor/Compound-data-type new file mode 120000 index 0000000000..690b2627a3 --- /dev/null +++ b/Lang/Factor/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Factor \ No newline at end of file diff --git a/Lang/Factor/Concurrent-computing b/Lang/Factor/Concurrent-computing new file mode 120000 index 0000000000..0e0a5c0f03 --- /dev/null +++ b/Lang/Factor/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Factor \ No newline at end of file diff --git a/Lang/Factor/Conditional-structures b/Lang/Factor/Conditional-structures new file mode 120000 index 0000000000..ad90a44e8f --- /dev/null +++ b/Lang/Factor/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Factor \ No newline at end of file diff --git a/Lang/Factor/Continued-fraction b/Lang/Factor/Continued-fraction new file mode 120000 index 0000000000..058a597f70 --- /dev/null +++ b/Lang/Factor/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Factor \ No newline at end of file diff --git a/Lang/Factor/Count-the-coins b/Lang/Factor/Count-the-coins new file mode 120000 index 0000000000..5376e3169a --- /dev/null +++ b/Lang/Factor/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Factor \ No newline at end of file diff --git a/Lang/Factor/Create-a-file b/Lang/Factor/Create-a-file new file mode 120000 index 0000000000..03cfec3587 --- /dev/null +++ b/Lang/Factor/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Factor \ No newline at end of file diff --git a/Lang/Factor/Create-a-two-dimensional-array-at-runtime b/Lang/Factor/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..94ab5d89ed --- /dev/null +++ b/Lang/Factor/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Factor \ No newline at end of file diff --git a/Lang/Factor/Date-format b/Lang/Factor/Date-format new file mode 120000 index 0000000000..4487ab2cdc --- /dev/null +++ b/Lang/Factor/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Factor \ No newline at end of file diff --git a/Lang/Factor/Day-of-the-week b/Lang/Factor/Day-of-the-week new file mode 120000 index 0000000000..367627249e --- /dev/null +++ b/Lang/Factor/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Factor \ No newline at end of file diff --git a/Lang/Factor/Delete-a-file b/Lang/Factor/Delete-a-file new file mode 120000 index 0000000000..b5685fc3f5 --- /dev/null +++ b/Lang/Factor/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Factor \ No newline at end of file diff --git a/Lang/Factor/Detect-division-by-zero b/Lang/Factor/Detect-division-by-zero new file mode 120000 index 0000000000..8401e3ae4d --- /dev/null +++ b/Lang/Factor/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Factor \ No newline at end of file diff --git a/Lang/Factor/Determine-if-a-string-is-numeric b/Lang/Factor/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..15fd2e12e1 --- /dev/null +++ b/Lang/Factor/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Factor \ No newline at end of file diff --git a/Lang/Factor/Dot-product b/Lang/Factor/Dot-product new file mode 120000 index 0000000000..34e3e1d403 --- /dev/null +++ b/Lang/Factor/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Factor \ No newline at end of file diff --git a/Lang/Factor/Echo-server b/Lang/Factor/Echo-server new file mode 120000 index 0000000000..ba4b274349 --- /dev/null +++ b/Lang/Factor/Echo-server @@ -0,0 +1 @@ +../../Task/Echo-server/Factor \ No newline at end of file diff --git a/Lang/Factor/Empty-program b/Lang/Factor/Empty-program new file mode 120000 index 0000000000..452f5281f1 --- /dev/null +++ b/Lang/Factor/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Factor \ No newline at end of file diff --git a/Lang/Factor/Equilibrium-index b/Lang/Factor/Equilibrium-index new file mode 120000 index 0000000000..d15b624ea8 --- /dev/null +++ b/Lang/Factor/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Factor \ No newline at end of file diff --git a/Lang/Factor/Ethiopian-multiplication b/Lang/Factor/Ethiopian-multiplication new file mode 120000 index 0000000000..b5fd9aada2 --- /dev/null +++ b/Lang/Factor/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Factor \ No newline at end of file diff --git a/Lang/Factor/Exceptions b/Lang/Factor/Exceptions new file mode 120000 index 0000000000..83f921994f --- /dev/null +++ b/Lang/Factor/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Factor \ No newline at end of file diff --git a/Lang/Factor/Executable-library b/Lang/Factor/Executable-library new file mode 120000 index 0000000000..be1e6428ab --- /dev/null +++ b/Lang/Factor/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/Factor \ No newline at end of file diff --git a/Lang/Factor/Execute-a-system-command b/Lang/Factor/Execute-a-system-command new file mode 120000 index 0000000000..8c320afa0d --- /dev/null +++ b/Lang/Factor/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Factor \ No newline at end of file diff --git a/Lang/Factor/Exponentiation-operator b/Lang/Factor/Exponentiation-operator new file mode 120000 index 0000000000..593ab1f50c --- /dev/null +++ b/Lang/Factor/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Factor \ No newline at end of file diff --git a/Lang/Factor/Extend-your-language b/Lang/Factor/Extend-your-language new file mode 120000 index 0000000000..485d9cd50d --- /dev/null +++ b/Lang/Factor/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Factor \ No newline at end of file diff --git a/Lang/Factor/Factorial b/Lang/Factor/Factorial new file mode 120000 index 0000000000..32476769d8 --- /dev/null +++ b/Lang/Factor/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Factor \ No newline at end of file diff --git a/Lang/Factor/Fibonacci-sequence b/Lang/Factor/Fibonacci-sequence new file mode 120000 index 0000000000..841e420d2f --- /dev/null +++ b/Lang/Factor/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Factor \ No newline at end of file diff --git a/Lang/Factor/File-IO b/Lang/Factor/File-IO new file mode 120000 index 0000000000..345143b246 --- /dev/null +++ b/Lang/Factor/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Factor \ No newline at end of file diff --git a/Lang/Factor/File-modification-time b/Lang/Factor/File-modification-time new file mode 120000 index 0000000000..7725640811 --- /dev/null +++ b/Lang/Factor/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Factor \ No newline at end of file diff --git a/Lang/Factor/File-size b/Lang/Factor/File-size new file mode 120000 index 0000000000..1a2c4c6a81 --- /dev/null +++ b/Lang/Factor/File-size @@ -0,0 +1 @@ +../../Task/File-size/Factor \ No newline at end of file diff --git a/Lang/Factor/Filter b/Lang/Factor/Filter new file mode 120000 index 0000000000..83a0ff028d --- /dev/null +++ b/Lang/Factor/Filter @@ -0,0 +1 @@ +../../Task/Filter/Factor \ No newline at end of file diff --git a/Lang/Factor/Find-common-directory-path b/Lang/Factor/Find-common-directory-path new file mode 120000 index 0000000000..6f2e6ee157 --- /dev/null +++ b/Lang/Factor/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Factor \ No newline at end of file diff --git a/Lang/Factor/First-class-functions b/Lang/Factor/First-class-functions new file mode 120000 index 0000000000..3e559ac40f --- /dev/null +++ b/Lang/Factor/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Factor \ No newline at end of file diff --git a/Lang/Factor/First-class-functions-Use-numbers-analogously b/Lang/Factor/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..c6508e4975 --- /dev/null +++ b/Lang/Factor/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Factor \ No newline at end of file diff --git a/Lang/Factor/FizzBuzz b/Lang/Factor/FizzBuzz new file mode 120000 index 0000000000..fdb37385bf --- /dev/null +++ b/Lang/Factor/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Factor \ No newline at end of file diff --git a/Lang/Factor/Fork b/Lang/Factor/Fork new file mode 120000 index 0000000000..933b0f46e6 --- /dev/null +++ b/Lang/Factor/Fork @@ -0,0 +1 @@ +../../Task/Fork/Factor \ No newline at end of file diff --git a/Lang/Factor/Forward-difference b/Lang/Factor/Forward-difference new file mode 120000 index 0000000000..10d0a8bb6d --- /dev/null +++ b/Lang/Factor/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Factor \ No newline at end of file diff --git a/Lang/Factor/Function-composition b/Lang/Factor/Function-composition new file mode 120000 index 0000000000..8c4348b366 --- /dev/null +++ b/Lang/Factor/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Factor \ No newline at end of file diff --git a/Lang/Factor/Function-definition b/Lang/Factor/Function-definition new file mode 120000 index 0000000000..c5959859de --- /dev/null +++ b/Lang/Factor/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Factor \ No newline at end of file diff --git a/Lang/Factor/Generic-swap b/Lang/Factor/Generic-swap new file mode 120000 index 0000000000..20a9e9c04f --- /dev/null +++ b/Lang/Factor/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Factor \ No newline at end of file diff --git a/Lang/Factor/Gray-code b/Lang/Factor/Gray-code new file mode 120000 index 0000000000..0c2baca444 --- /dev/null +++ b/Lang/Factor/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Factor \ No newline at end of file diff --git a/Lang/Factor/Greatest-common-divisor b/Lang/Factor/Greatest-common-divisor new file mode 120000 index 0000000000..4bbf579668 --- /dev/null +++ b/Lang/Factor/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Factor \ No newline at end of file diff --git a/Lang/Factor/Greatest-element-of-a-list b/Lang/Factor/Greatest-element-of-a-list new file mode 120000 index 0000000000..52192d4a4b --- /dev/null +++ b/Lang/Factor/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Factor \ No newline at end of file diff --git a/Lang/Factor/Greatest-subsequential-sum b/Lang/Factor/Greatest-subsequential-sum new file mode 120000 index 0000000000..8c6359bc3b --- /dev/null +++ b/Lang/Factor/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Factor \ No newline at end of file diff --git a/Lang/Factor/HTTP b/Lang/Factor/HTTP new file mode 120000 index 0000000000..0055979c38 --- /dev/null +++ b/Lang/Factor/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Factor \ No newline at end of file diff --git a/Lang/Factor/Hailstone-sequence b/Lang/Factor/Hailstone-sequence new file mode 120000 index 0000000000..496af251b6 --- /dev/null +++ b/Lang/Factor/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Factor \ No newline at end of file diff --git a/Lang/Factor/Hamming-numbers b/Lang/Factor/Hamming-numbers new file mode 120000 index 0000000000..4c3e941da9 --- /dev/null +++ b/Lang/Factor/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Happy-numbers b/Lang/Factor/Happy-numbers new file mode 120000 index 0000000000..50c0e76d8f --- /dev/null +++ b/Lang/Factor/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Hash-from-two-arrays b/Lang/Factor/Hash-from-two-arrays new file mode 120000 index 0000000000..c428655b29 --- /dev/null +++ b/Lang/Factor/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Factor \ No newline at end of file diff --git a/Lang/Factor/Haversine-formula b/Lang/Factor/Haversine-formula new file mode 120000 index 0000000000..d8257d6139 --- /dev/null +++ b/Lang/Factor/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Factor \ No newline at end of file diff --git a/Lang/Factor/Hello-world-Line-printer b/Lang/Factor/Hello-world-Line-printer new file mode 120000 index 0000000000..1f6303f7cc --- /dev/null +++ b/Lang/Factor/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Factor \ No newline at end of file diff --git a/Lang/Factor/Hello-world-Newline-omission b/Lang/Factor/Hello-world-Newline-omission new file mode 120000 index 0000000000..a93a7bb61c --- /dev/null +++ b/Lang/Factor/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Factor \ No newline at end of file diff --git a/Lang/Factor/Hello-world-Standard-error b/Lang/Factor/Hello-world-Standard-error new file mode 120000 index 0000000000..2f9575a9bd --- /dev/null +++ b/Lang/Factor/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Factor \ No newline at end of file diff --git a/Lang/Factor/Hello-world-Text b/Lang/Factor/Hello-world-Text new file mode 120000 index 0000000000..c61a8b563e --- /dev/null +++ b/Lang/Factor/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Factor \ No newline at end of file diff --git a/Lang/Factor/Higher-order-functions b/Lang/Factor/Higher-order-functions new file mode 120000 index 0000000000..db8b37ef99 --- /dev/null +++ b/Lang/Factor/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Factor \ No newline at end of file diff --git a/Lang/Factor/Hofstadter-Figure-Figure-sequences b/Lang/Factor/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..5ceffc1755 --- /dev/null +++ b/Lang/Factor/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Factor \ No newline at end of file diff --git a/Lang/Factor/Hofstadter-Q-sequence b/Lang/Factor/Hofstadter-Q-sequence new file mode 120000 index 0000000000..1f8855fb01 --- /dev/null +++ b/Lang/Factor/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Factor \ No newline at end of file diff --git a/Lang/Factor/Horners-rule-for-polynomial-evaluation b/Lang/Factor/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..05cb463e56 --- /dev/null +++ b/Lang/Factor/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Factor \ No newline at end of file diff --git a/Lang/Factor/Host-introspection b/Lang/Factor/Host-introspection new file mode 120000 index 0000000000..03e50f092c --- /dev/null +++ b/Lang/Factor/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Factor \ No newline at end of file diff --git a/Lang/Factor/Hostname b/Lang/Factor/Hostname new file mode 120000 index 0000000000..aa91b05313 --- /dev/null +++ b/Lang/Factor/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Factor \ No newline at end of file diff --git a/Lang/Factor/Image-noise b/Lang/Factor/Image-noise new file mode 120000 index 0000000000..7271cb0929 --- /dev/null +++ b/Lang/Factor/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Factor \ No newline at end of file diff --git a/Lang/Factor/Increment-a-numerical-string b/Lang/Factor/Increment-a-numerical-string new file mode 120000 index 0000000000..0892be466c --- /dev/null +++ b/Lang/Factor/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Factor \ No newline at end of file diff --git a/Lang/Factor/Infinity b/Lang/Factor/Infinity new file mode 120000 index 0000000000..bafccc6968 --- /dev/null +++ b/Lang/Factor/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Factor \ No newline at end of file diff --git a/Lang/Factor/Inheritance-Single b/Lang/Factor/Inheritance-Single new file mode 120000 index 0000000000..b1f3689e1a --- /dev/null +++ b/Lang/Factor/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Factor \ No newline at end of file diff --git a/Lang/Factor/Input-loop b/Lang/Factor/Input-loop new file mode 120000 index 0000000000..d61ea05f11 --- /dev/null +++ b/Lang/Factor/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Factor \ No newline at end of file diff --git a/Lang/Factor/Integer-comparison b/Lang/Factor/Integer-comparison new file mode 120000 index 0000000000..288224ec6b --- /dev/null +++ b/Lang/Factor/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Factor \ No newline at end of file diff --git a/Lang/Factor/Integer-sequence b/Lang/Factor/Integer-sequence new file mode 120000 index 0000000000..6bc66430cb --- /dev/null +++ b/Lang/Factor/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Factor \ No newline at end of file diff --git a/Lang/Factor/Interactive-programming b/Lang/Factor/Interactive-programming new file mode 120000 index 0000000000..c7b5891586 --- /dev/null +++ b/Lang/Factor/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Factor \ No newline at end of file diff --git a/Lang/Factor/Introspection b/Lang/Factor/Introspection new file mode 120000 index 0000000000..f4d604abfb --- /dev/null +++ b/Lang/Factor/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Factor \ No newline at end of file diff --git a/Lang/Factor/Inverted-index b/Lang/Factor/Inverted-index new file mode 120000 index 0000000000..56690afe33 --- /dev/null +++ b/Lang/Factor/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Factor \ No newline at end of file diff --git a/Lang/Factor/JSON b/Lang/Factor/JSON new file mode 120000 index 0000000000..cf5622b8a6 --- /dev/null +++ b/Lang/Factor/JSON @@ -0,0 +1 @@ +../../Task/JSON/Factor \ No newline at end of file diff --git a/Lang/Factor/Knapsack-problem-0-1 b/Lang/Factor/Knapsack-problem-0-1 new file mode 120000 index 0000000000..c2671bbed7 --- /dev/null +++ b/Lang/Factor/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Factor \ No newline at end of file diff --git a/Lang/Factor/Knapsack-problem-Unbounded b/Lang/Factor/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..b65d07de06 --- /dev/null +++ b/Lang/Factor/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Factor \ No newline at end of file diff --git a/Lang/Factor/Knuth-shuffle b/Lang/Factor/Knuth-shuffle new file mode 120000 index 0000000000..89ad4d012e --- /dev/null +++ b/Lang/Factor/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Factor \ No newline at end of file diff --git a/Lang/Factor/Leap-year b/Lang/Factor/Leap-year new file mode 120000 index 0000000000..c00b52da79 --- /dev/null +++ b/Lang/Factor/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Factor \ No newline at end of file diff --git a/Lang/Factor/Least-common-multiple b/Lang/Factor/Least-common-multiple new file mode 120000 index 0000000000..78c91aec72 --- /dev/null +++ b/Lang/Factor/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Factor \ No newline at end of file diff --git a/Lang/Factor/Logical-operations b/Lang/Factor/Logical-operations new file mode 120000 index 0000000000..d75bd9d24d --- /dev/null +++ b/Lang/Factor/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Factor \ No newline at end of file diff --git a/Lang/Factor/Long-multiplication b/Lang/Factor/Long-multiplication new file mode 120000 index 0000000000..a535214420 --- /dev/null +++ b/Lang/Factor/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Factor \ No newline at end of file diff --git a/Lang/Factor/Look-and-say-sequence b/Lang/Factor/Look-and-say-sequence new file mode 120000 index 0000000000..bfe0ba4937 --- /dev/null +++ b/Lang/Factor/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Factor \ No newline at end of file diff --git a/Lang/Factor/Loop-over-multiple-arrays-simultaneously b/Lang/Factor/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..99138825a0 --- /dev/null +++ b/Lang/Factor/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Break b/Lang/Factor/Loops-Break new file mode 120000 index 0000000000..8b09e8bf83 --- /dev/null +++ b/Lang/Factor/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Continue b/Lang/Factor/Loops-Continue new file mode 120000 index 0000000000..69931273e2 --- /dev/null +++ b/Lang/Factor/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Do-while b/Lang/Factor/Loops-Do-while new file mode 120000 index 0000000000..a86840fb30 --- /dev/null +++ b/Lang/Factor/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Downward-for b/Lang/Factor/Loops-Downward-for new file mode 120000 index 0000000000..ec79792448 --- /dev/null +++ b/Lang/Factor/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-For b/Lang/Factor/Loops-For new file mode 120000 index 0000000000..baf863de41 --- /dev/null +++ b/Lang/Factor/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-For-with-a-specified-step b/Lang/Factor/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..ef20bea434 --- /dev/null +++ b/Lang/Factor/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Foreach b/Lang/Factor/Loops-Foreach new file mode 120000 index 0000000000..d3dc049d27 --- /dev/null +++ b/Lang/Factor/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-Infinite b/Lang/Factor/Loops-Infinite new file mode 120000 index 0000000000..23b36f1ed6 --- /dev/null +++ b/Lang/Factor/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-N-plus-one-half b/Lang/Factor/Loops-N-plus-one-half new file mode 120000 index 0000000000..8b6fe863bc --- /dev/null +++ b/Lang/Factor/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Factor \ No newline at end of file diff --git a/Lang/Factor/Loops-While b/Lang/Factor/Loops-While new file mode 120000 index 0000000000..982c8b6e8a --- /dev/null +++ b/Lang/Factor/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Factor \ No newline at end of file diff --git a/Lang/Factor/Luhn-test-of-credit-card-numbers b/Lang/Factor/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..300d5bae99 --- /dev/null +++ b/Lang/Factor/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Map-range b/Lang/Factor/Map-range new file mode 120000 index 0000000000..34c59aa51c --- /dev/null +++ b/Lang/Factor/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Factor \ No newline at end of file diff --git a/Lang/Factor/Matrix-exponentiation-operator b/Lang/Factor/Matrix-exponentiation-operator new file mode 120000 index 0000000000..322449c9ad --- /dev/null +++ b/Lang/Factor/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Factor \ No newline at end of file diff --git a/Lang/Factor/Matrix-transposition b/Lang/Factor/Matrix-transposition new file mode 120000 index 0000000000..e4b5d70c4c --- /dev/null +++ b/Lang/Factor/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Factor \ No newline at end of file diff --git a/Lang/Factor/Memory-allocation b/Lang/Factor/Memory-allocation new file mode 120000 index 0000000000..88807a4b36 --- /dev/null +++ b/Lang/Factor/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Factor \ No newline at end of file diff --git a/Lang/Factor/Menu b/Lang/Factor/Menu new file mode 120000 index 0000000000..24f3e82db9 --- /dev/null +++ b/Lang/Factor/Menu @@ -0,0 +1 @@ +../../Task/Menu/Factor \ No newline at end of file diff --git a/Lang/Factor/Monte-Carlo-methods b/Lang/Factor/Monte-Carlo-methods new file mode 120000 index 0000000000..8d605cdc29 --- /dev/null +++ b/Lang/Factor/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Factor \ No newline at end of file diff --git a/Lang/Factor/Mouse-position b/Lang/Factor/Mouse-position new file mode 120000 index 0000000000..b649cf5594 --- /dev/null +++ b/Lang/Factor/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Factor \ No newline at end of file diff --git a/Lang/Factor/Multiple-distinct-objects b/Lang/Factor/Multiple-distinct-objects new file mode 120000 index 0000000000..e14ba1b62e --- /dev/null +++ b/Lang/Factor/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Factor \ No newline at end of file diff --git a/Lang/Factor/Multiplication-tables b/Lang/Factor/Multiplication-tables new file mode 120000 index 0000000000..555dc7ca36 --- /dev/null +++ b/Lang/Factor/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Factor \ No newline at end of file diff --git a/Lang/Factor/Mutual-recursion b/Lang/Factor/Mutual-recursion new file mode 120000 index 0000000000..9685c61a7f --- /dev/null +++ b/Lang/Factor/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Factor \ No newline at end of file diff --git a/Lang/Factor/Ordered-words b/Lang/Factor/Ordered-words new file mode 120000 index 0000000000..31fc31b9c3 --- /dev/null +++ b/Lang/Factor/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Factor \ No newline at end of file diff --git a/Lang/Factor/Quine b/Lang/Factor/Quine new file mode 120000 index 0000000000..d7803b7607 --- /dev/null +++ b/Lang/Factor/Quine @@ -0,0 +1 @@ +../../Task/Quine/Factor \ No newline at end of file diff --git a/Lang/Factor/Search-a-list b/Lang/Factor/Search-a-list new file mode 120000 index 0000000000..ee3126c387 --- /dev/null +++ b/Lang/Factor/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Factor \ No newline at end of file diff --git a/Lang/Falcon/0DESCRIPTION b/Lang/Falcon/0DESCRIPTION new file mode 100644 index 0000000000..4a72512e17 --- /dev/null +++ b/Lang/Falcon/0DESCRIPTION @@ -0,0 +1,32 @@ +{{language|Falcon +exec=interpreted +|site=http://www.falconpl.org/ +}} +Falcon is an [[open source]], simple, fast, and powerful programming language, easy to learn and to feel comfortable with, and a scripting engine ready to empower mission-critical multi-threaded applications. + +Falcon provides six integrated [[programming paradigms]]: procedural, [[object-oriented]], prototype-oriented, functional, tabular, and message-oriented. And you don't have to master all of them; you just need to pick the ingredients you prefer, and let the code follow your inspiration. + +Falcon was created by Giancarlo Niccolai in 2001. The initial version of the language was called Haste Advanced Simple Text Evaluator (HASTE) and was developed to address a number of technical issues he did not find easy solutions for in various other languages. On May 23, 2002 he changed the name into Falcon (named after Giovanni Falcone, the Italian judge killed by the Mafia) and took the language open source. + +Key goals of the language: +* Integration with the surrounding environment (libraries, servers, systems). +* Abstraction of the underlying system / cross-platform / international development. +* Text manipulation. +* (non-statistical) data analysis. +* System maintenance. +* File dumping. +* Embedding into application (for real-time data control/flexible manipulation). +* Application of high level logic to computing problems. +{{language programming paradigm|procedural}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|prototype-oriented}} +{{language programming paradigm|functional}} +{{language programming paradigm|tabular}} +{{language programming paradigm|message-oriented}} + +You can try it at [http://ideone.com/ Ideone]. + +==See Also== +* [[wp:Falcon (programming language)|Wikipedia: Falcon]] +* [http://www.freesoftwaremagazine.com/articles/falcon_programming_language_brief_tutorial a brief tutorial] +* [http://www.linuxjournal.com/magazine/falcon-programming-language-nutshell The Falcon Programming Language in a Nutshell] \ No newline at end of file diff --git a/Lang/Falcon/100-doors b/Lang/Falcon/100-doors new file mode 120000 index 0000000000..671d94d585 --- /dev/null +++ b/Lang/Falcon/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Falcon \ No newline at end of file diff --git a/Lang/Falcon/24-game b/Lang/Falcon/24-game new file mode 120000 index 0000000000..5aaf4dd13e --- /dev/null +++ b/Lang/Falcon/24-game @@ -0,0 +1 @@ +../../Task/24-game/Falcon \ No newline at end of file diff --git a/Lang/Falcon/99-Bottles-of-Beer b/Lang/Falcon/99-Bottles-of-Beer new file mode 120000 index 0000000000..8fac21b456 --- /dev/null +++ b/Lang/Falcon/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Ackermann-function b/Lang/Falcon/Ackermann-function new file mode 120000 index 0000000000..4dbc2026a9 --- /dev/null +++ b/Lang/Falcon/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Falcon/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..1a73a6a37f --- /dev/null +++ b/Lang/Falcon/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Anonymous-recursion b/Lang/Falcon/Anonymous-recursion new file mode 120000 index 0000000000..944168fe07 --- /dev/null +++ b/Lang/Falcon/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Classes b/Lang/Falcon/Classes new file mode 120000 index 0000000000..0a2b4403ac --- /dev/null +++ b/Lang/Falcon/Classes @@ -0,0 +1 @@ +../../Task/Classes/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Comments b/Lang/Falcon/Comments new file mode 120000 index 0000000000..a0613a3ed8 --- /dev/null +++ b/Lang/Falcon/Comments @@ -0,0 +1 @@ +../../Task/Comments/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Fibonacci-sequence b/Lang/Falcon/Fibonacci-sequence new file mode 120000 index 0000000000..837f0a2b47 --- /dev/null +++ b/Lang/Falcon/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Falcon \ No newline at end of file diff --git a/Lang/Falcon/FizzBuzz b/Lang/Falcon/FizzBuzz new file mode 120000 index 0000000000..c3ad674a3e --- /dev/null +++ b/Lang/Falcon/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Function-definition b/Lang/Falcon/Function-definition new file mode 120000 index 0000000000..aa22f1c33d --- /dev/null +++ b/Lang/Falcon/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Generic-swap b/Lang/Falcon/Generic-swap new file mode 120000 index 0000000000..69605bc5f4 --- /dev/null +++ b/Lang/Falcon/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Hash-from-two-arrays b/Lang/Falcon/Hash-from-two-arrays new file mode 120000 index 0000000000..78b573d02c --- /dev/null +++ b/Lang/Falcon/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Falcon \ No newline at end of file diff --git a/Lang/Falcon/Hello-world-Text b/Lang/Falcon/Hello-world-Text new file mode 120000 index 0000000000..eb033be9eb --- /dev/null +++ b/Lang/Falcon/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Falcon \ No newline at end of file diff --git a/Lang/Fan/0DESCRIPTION b/Lang/Fan/0DESCRIPTION new file mode 100644 index 0000000000..11d47020e8 --- /dev/null +++ b/Lang/Fan/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}} +{{language|Fan}}[[runs on vm::java virtual machine| ]][[runs on vm::common language runtime| ]] +[http://www.fandev.org Fan] is a high-level language that runs on both the [[JVM|Java VM]] and [[.NET]] CLR. + +[[:Category:Fan|Fan]] is now called [[:Category:Fantom|Fantom]] \ No newline at end of file diff --git a/Lang/Fan/Bulls-and-cows b/Lang/Fan/Bulls-and-cows new file mode 120000 index 0000000000..df452ef1f7 --- /dev/null +++ b/Lang/Fan/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Fan \ No newline at end of file diff --git a/Lang/Fancy/0DESCRIPTION b/Lang/Fancy/0DESCRIPTION new file mode 100644 index 0000000000..24bf2e847c --- /dev/null +++ b/Lang/Fancy/0DESCRIPTION @@ -0,0 +1,26 @@ +{{stub}} +{{language +|site=http://www.fancy-lang.org/ +|checking=dynamic +|gc=yes +|parampass=reference +|safety=safe +|strenght=weak +|compat=duck +|tags=fancy +}} +{{language programming paradigm|object-oriented}} + +Fancy is a new (pure) [[object-oriented]] programming language that tries to meet the following goals: + +* Be reasonably fast +* Be a dynamic language (as in [[Smalltalk]] or [[Ruby]]) +* Be truly object oriented (as in Smalltalk or Ruby) +* Be concurrent (via the Actor Model) +* Be easy to understand +* Be portable and possibly run on multiple runtimes (this isn’t the case yet) + +At the moment, Fancy follows most of the goals above. Its current implementation is an interpreter written in [[implemented in language::C++]]. + +== See Also == +[http://www.adztec-independent.de/2010/03/new-project-the-fancy-programming-language/ Adztec Independent – Blog] \ No newline at end of file diff --git a/Lang/Fancy/Classes b/Lang/Fancy/Classes new file mode 120000 index 0000000000..2c9a184ed8 --- /dev/null +++ b/Lang/Fancy/Classes @@ -0,0 +1 @@ +../../Task/Classes/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Collections b/Lang/Fancy/Collections new file mode 120000 index 0000000000..9f689a89fe --- /dev/null +++ b/Lang/Fancy/Collections @@ -0,0 +1 @@ +../../Task/Collections/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Command-line-arguments b/Lang/Fancy/Command-line-arguments new file mode 120000 index 0000000000..5fbed0f1b2 --- /dev/null +++ b/Lang/Fancy/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Comments b/Lang/Fancy/Comments new file mode 120000 index 0000000000..9aa4f6924e --- /dev/null +++ b/Lang/Fancy/Comments @@ -0,0 +1 @@ +../../Task/Comments/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Conditional-structures b/Lang/Fancy/Conditional-structures new file mode 120000 index 0000000000..4f06b90d70 --- /dev/null +++ b/Lang/Fancy/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Create-a-file b/Lang/Fancy/Create-a-file new file mode 120000 index 0000000000..d71f33107c --- /dev/null +++ b/Lang/Fancy/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Detect-division-by-zero b/Lang/Fancy/Detect-division-by-zero new file mode 120000 index 0000000000..63904a9872 --- /dev/null +++ b/Lang/Fancy/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Documentation b/Lang/Fancy/Documentation new file mode 120000 index 0000000000..ef206a59c7 --- /dev/null +++ b/Lang/Fancy/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Exceptions b/Lang/Fancy/Exceptions new file mode 120000 index 0000000000..6b42ecd6ce --- /dev/null +++ b/Lang/Fancy/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Factorial b/Lang/Fancy/Factorial new file mode 120000 index 0000000000..e757dc103f --- /dev/null +++ b/Lang/Fancy/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Fibonacci-sequence b/Lang/Fancy/Fibonacci-sequence new file mode 120000 index 0000000000..4d7a7e6209 --- /dev/null +++ b/Lang/Fancy/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Greatest-element-of-a-list b/Lang/Fancy/Greatest-element-of-a-list new file mode 120000 index 0000000000..1f7d651f48 --- /dev/null +++ b/Lang/Fancy/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Inheritance-Single b/Lang/Fancy/Inheritance-Single new file mode 120000 index 0000000000..b57a1bdcce --- /dev/null +++ b/Lang/Fancy/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Fancy \ No newline at end of file diff --git a/Lang/Fantom/0DESCRIPTION b/Lang/Fantom/0DESCRIPTION new file mode 100644 index 0000000000..223fcc0a51 --- /dev/null +++ b/Lang/Fantom/0DESCRIPTION @@ -0,0 +1,14 @@ +{{wikipedia|Fantom (programming language)}} +{{language +|site=http://www.fantom.org/ +|checking=both +}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|functional}} + +Fantom is a general purpose [[:Category:Programming paradigm/Object-oriented|object-oriented]] programming language that runs on the [[runs on vm::Java Virtual Machine|JRE]], [[.Net Framework|.NET]] [[runs on vm::Common Language Runtime|CLR]], and [[:Category:Javascript|Javascript]]. The language supports [[:Category:Programming paradigm/Functional|functional programming]] through closures and concurrency through the [[wp:Actor model|Actor model]]. Fantom takes a "middle of the road" approach to its type system, blending together aspects of both [[:Category:Typing/Checking/Static|static]] and [[:Category:Typing/Checking/Dynamic|dynamic typing]]. Like [[:Category:C sharp|C#]] and [[:Category:Java|Java]], Fantom uses a curly brace syntax. + +==See also== +*[http://www.fantom.org/ Fantom homepage] +*[[wp:Fantom_(programming_language)|Fantom on Wikipedia]] +*[http://fanzy.net/ Fantom online] \ No newline at end of file diff --git a/Lang/Fantom/100-doors b/Lang/Fantom/100-doors new file mode 120000 index 0000000000..d5b73b2e37 --- /dev/null +++ b/Lang/Fantom/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Fantom \ No newline at end of file diff --git a/Lang/Fantom/A+B b/Lang/Fantom/A+B new file mode 120000 index 0000000000..28048812cb --- /dev/null +++ b/Lang/Fantom/A+B @@ -0,0 +1 @@ +../../Task/A+B/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Abstract-type b/Lang/Fantom/Abstract-type new file mode 120000 index 0000000000..bafbc49fab --- /dev/null +++ b/Lang/Fantom/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Accumulator-factory b/Lang/Fantom/Accumulator-factory new file mode 120000 index 0000000000..b50cf2b48a --- /dev/null +++ b/Lang/Fantom/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Ackermann-function b/Lang/Fantom/Ackermann-function new file mode 120000 index 0000000000..41be634c09 --- /dev/null +++ b/Lang/Fantom/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Anagrams b/Lang/Fantom/Anagrams new file mode 120000 index 0000000000..69f96062eb --- /dev/null +++ b/Lang/Fantom/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Animation b/Lang/Fantom/Animation new file mode 120000 index 0000000000..4502e4c135 --- /dev/null +++ b/Lang/Fantom/Animation @@ -0,0 +1 @@ +../../Task/Animation/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Apply-a-callback-to-an-array b/Lang/Fantom/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..72f3cbf022 --- /dev/null +++ b/Lang/Fantom/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Array-concatenation b/Lang/Fantom/Array-concatenation new file mode 120000 index 0000000000..3ae1dec7f3 --- /dev/null +++ b/Lang/Fantom/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Associative-array-Creation b/Lang/Fantom/Associative-array-Creation new file mode 120000 index 0000000000..64fb1331f9 --- /dev/null +++ b/Lang/Fantom/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Associative-array-Iteration b/Lang/Fantom/Associative-array-Iteration new file mode 120000 index 0000000000..13b0142496 --- /dev/null +++ b/Lang/Fantom/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Averages-Arithmetic-mean b/Lang/Fantom/Averages-Arithmetic-mean new file mode 120000 index 0000000000..25f84692b3 --- /dev/null +++ b/Lang/Fantom/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Averages-Pythagorean-means b/Lang/Fantom/Averages-Pythagorean-means new file mode 120000 index 0000000000..16f5bec1b0 --- /dev/null +++ b/Lang/Fantom/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Averages-Root-mean-square b/Lang/Fantom/Averages-Root-mean-square new file mode 120000 index 0000000000..f1f5b0568d --- /dev/null +++ b/Lang/Fantom/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Averages-Simple-moving-average b/Lang/Fantom/Averages-Simple-moving-average new file mode 120000 index 0000000000..6244f56f76 --- /dev/null +++ b/Lang/Fantom/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Balanced-brackets b/Lang/Fantom/Balanced-brackets new file mode 120000 index 0000000000..47fafaf82e --- /dev/null +++ b/Lang/Fantom/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Caesar-cipher b/Lang/Fantom/Caesar-cipher new file mode 120000 index 0000000000..2ff17e4ef4 --- /dev/null +++ b/Lang/Fantom/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Character-codes b/Lang/Fantom/Character-codes new file mode 120000 index 0000000000..32881a37e5 --- /dev/null +++ b/Lang/Fantom/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Character-matching b/Lang/Fantom/Character-matching new file mode 120000 index 0000000000..9196d744a7 --- /dev/null +++ b/Lang/Fantom/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Cholesky-decomposition b/Lang/Fantom/Cholesky-decomposition new file mode 120000 index 0000000000..5417324f78 --- /dev/null +++ b/Lang/Fantom/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Classes b/Lang/Fantom/Classes new file mode 120000 index 0000000000..de84549ec8 --- /dev/null +++ b/Lang/Fantom/Classes @@ -0,0 +1 @@ +../../Task/Classes/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Closest-pair-problem b/Lang/Fantom/Closest-pair-problem new file mode 120000 index 0000000000..2c9ddbc110 --- /dev/null +++ b/Lang/Fantom/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Command-line-arguments b/Lang/Fantom/Command-line-arguments new file mode 120000 index 0000000000..61e7c0c0a4 --- /dev/null +++ b/Lang/Fantom/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Compound-data-type b/Lang/Fantom/Compound-data-type new file mode 120000 index 0000000000..d89a01aa06 --- /dev/null +++ b/Lang/Fantom/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Date-format b/Lang/Fantom/Date-format new file mode 120000 index 0000000000..e12d4a6114 --- /dev/null +++ b/Lang/Fantom/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Date-manipulation b/Lang/Fantom/Date-manipulation new file mode 120000 index 0000000000..5eabc043ac --- /dev/null +++ b/Lang/Fantom/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Determine-if-a-string-is-numeric b/Lang/Fantom/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..d13187af93 --- /dev/null +++ b/Lang/Fantom/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Dot-product b/Lang/Fantom/Dot-product new file mode 120000 index 0000000000..517c5e49fc --- /dev/null +++ b/Lang/Fantom/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Empty-program b/Lang/Fantom/Empty-program new file mode 120000 index 0000000000..22407336a1 --- /dev/null +++ b/Lang/Fantom/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Empty-string b/Lang/Fantom/Empty-string new file mode 120000 index 0000000000..306b5e81b7 --- /dev/null +++ b/Lang/Fantom/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Enumerations b/Lang/Fantom/Enumerations new file mode 120000 index 0000000000..5c9bfb9a57 --- /dev/null +++ b/Lang/Fantom/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Evolutionary-algorithm b/Lang/Fantom/Evolutionary-algorithm new file mode 120000 index 0000000000..56bb961a4e --- /dev/null +++ b/Lang/Fantom/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Exceptions b/Lang/Fantom/Exceptions new file mode 120000 index 0000000000..0b1f6aaf4b --- /dev/null +++ b/Lang/Fantom/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Fantom/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..29dbc3c2e4 --- /dev/null +++ b/Lang/Fantom/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Execute-a-system-command b/Lang/Fantom/Execute-a-system-command new file mode 120000 index 0000000000..3ba8c1794e --- /dev/null +++ b/Lang/Fantom/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Factorial b/Lang/Fantom/Factorial new file mode 120000 index 0000000000..15e17567c9 --- /dev/null +++ b/Lang/Fantom/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Fibonacci-sequence b/Lang/Fantom/Fibonacci-sequence new file mode 120000 index 0000000000..c069df002d --- /dev/null +++ b/Lang/Fantom/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Filter b/Lang/Fantom/Filter new file mode 120000 index 0000000000..b0f692ab6b --- /dev/null +++ b/Lang/Fantom/Filter @@ -0,0 +1 @@ +../../Task/Filter/Fantom \ No newline at end of file diff --git a/Lang/Fantom/First-class-functions b/Lang/Fantom/First-class-functions new file mode 120000 index 0000000000..eba5a213de --- /dev/null +++ b/Lang/Fantom/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Fantom \ No newline at end of file diff --git a/Lang/Fantom/First-class-functions-Use-numbers-analogously b/Lang/Fantom/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..1bfb323c48 --- /dev/null +++ b/Lang/Fantom/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Fantom \ No newline at end of file diff --git a/Lang/Fantom/FizzBuzz b/Lang/Fantom/FizzBuzz new file mode 120000 index 0000000000..8362550382 --- /dev/null +++ b/Lang/Fantom/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Flatten-a-list b/Lang/Fantom/Flatten-a-list new file mode 120000 index 0000000000..c4e5805f4e --- /dev/null +++ b/Lang/Fantom/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Formatted-numeric-output b/Lang/Fantom/Formatted-numeric-output new file mode 120000 index 0000000000..ffc2399c78 --- /dev/null +++ b/Lang/Fantom/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Fractal-tree b/Lang/Fantom/Fractal-tree new file mode 120000 index 0000000000..54c6b3138c --- /dev/null +++ b/Lang/Fantom/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Function-composition b/Lang/Fantom/Function-composition new file mode 120000 index 0000000000..17e4eb4126 --- /dev/null +++ b/Lang/Fantom/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Function-definition b/Lang/Fantom/Function-definition new file mode 120000 index 0000000000..b4ca6f95c8 --- /dev/null +++ b/Lang/Fantom/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Fantom \ No newline at end of file diff --git a/Lang/Fantom/GUI-component-interaction b/Lang/Fantom/GUI-component-interaction new file mode 120000 index 0000000000..825e064cc5 --- /dev/null +++ b/Lang/Fantom/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Fantom \ No newline at end of file diff --git a/Lang/Fantom/GUI-enabling-disabling-of-controls b/Lang/Fantom/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..de0807b56d --- /dev/null +++ b/Lang/Fantom/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Generator-Exponential b/Lang/Fantom/Generator-Exponential new file mode 120000 index 0000000000..5a874b54c7 --- /dev/null +++ b/Lang/Fantom/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Greatest-common-divisor b/Lang/Fantom/Greatest-common-divisor new file mode 120000 index 0000000000..353d4b17fb --- /dev/null +++ b/Lang/Fantom/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Greatest-element-of-a-list b/Lang/Fantom/Greatest-element-of-a-list new file mode 120000 index 0000000000..8b7cfd040e --- /dev/null +++ b/Lang/Fantom/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Guess-the-number b/Lang/Fantom/Guess-the-number new file mode 120000 index 0000000000..38765f26dd --- /dev/null +++ b/Lang/Fantom/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Guess-the-number-With-feedback b/Lang/Fantom/Guess-the-number-With-feedback new file mode 120000 index 0000000000..9a993851f4 --- /dev/null +++ b/Lang/Fantom/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Guess-the-number-With-feedback-player b/Lang/Fantom/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..75f3d69892 --- /dev/null +++ b/Lang/Fantom/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Happy-numbers b/Lang/Fantom/Happy-numbers new file mode 120000 index 0000000000..a0b1a0c7d3 --- /dev/null +++ b/Lang/Fantom/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hash-from-two-arrays b/Lang/Fantom/Hash-from-two-arrays new file mode 120000 index 0000000000..975d2fd698 --- /dev/null +++ b/Lang/Fantom/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hello-world-Graphical b/Lang/Fantom/Hello-world-Graphical new file mode 120000 index 0000000000..d80dd0cceb --- /dev/null +++ b/Lang/Fantom/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hello-world-Newline-omission b/Lang/Fantom/Hello-world-Newline-omission new file mode 120000 index 0000000000..3cf425a7ea --- /dev/null +++ b/Lang/Fantom/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hello-world-Standard-error b/Lang/Fantom/Hello-world-Standard-error new file mode 120000 index 0000000000..a690172448 --- /dev/null +++ b/Lang/Fantom/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hello-world-Text b/Lang/Fantom/Hello-world-Text new file mode 120000 index 0000000000..a2683203f9 --- /dev/null +++ b/Lang/Fantom/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Hello-world-Web-server b/Lang/Fantom/Hello-world-Web-server new file mode 120000 index 0000000000..be62294ff8 --- /dev/null +++ b/Lang/Fantom/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Higher-order-functions b/Lang/Fantom/Higher-order-functions new file mode 120000 index 0000000000..9164f0b85c --- /dev/null +++ b/Lang/Fantom/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Huffman-coding b/Lang/Fantom/Huffman-coding new file mode 120000 index 0000000000..80dc74e7bc --- /dev/null +++ b/Lang/Fantom/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Increment-a-numerical-string b/Lang/Fantom/Increment-a-numerical-string new file mode 120000 index 0000000000..bc2f63a5b5 --- /dev/null +++ b/Lang/Fantom/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Infinity b/Lang/Fantom/Infinity new file mode 120000 index 0000000000..b734886194 --- /dev/null +++ b/Lang/Fantom/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Inheritance-Multiple b/Lang/Fantom/Inheritance-Multiple new file mode 120000 index 0000000000..c68930c8d7 --- /dev/null +++ b/Lang/Fantom/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Inheritance-Single b/Lang/Fantom/Inheritance-Single new file mode 120000 index 0000000000..1a9b315e9b --- /dev/null +++ b/Lang/Fantom/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Input-loop b/Lang/Fantom/Input-loop new file mode 120000 index 0000000000..cd5f59165d --- /dev/null +++ b/Lang/Fantom/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Integer-comparison b/Lang/Fantom/Integer-comparison new file mode 120000 index 0000000000..f71edc7194 --- /dev/null +++ b/Lang/Fantom/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Integer-sequence b/Lang/Fantom/Integer-sequence new file mode 120000 index 0000000000..c726ecc9a0 --- /dev/null +++ b/Lang/Fantom/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Fantom \ No newline at end of file diff --git a/Lang/Fantom/JSON b/Lang/Fantom/JSON new file mode 120000 index 0000000000..583afad5da --- /dev/null +++ b/Lang/Fantom/JSON @@ -0,0 +1 @@ +../../Task/JSON/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Knuth-shuffle b/Lang/Fantom/Knuth-shuffle new file mode 120000 index 0000000000..1a6ddf2008 --- /dev/null +++ b/Lang/Fantom/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Langtons-ant b/Lang/Fantom/Langtons-ant new file mode 120000 index 0000000000..a8c26d38d2 --- /dev/null +++ b/Lang/Fantom/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Logical-operations b/Lang/Fantom/Logical-operations new file mode 120000 index 0000000000..26a121502f --- /dev/null +++ b/Lang/Fantom/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loop-over-multiple-arrays-simultaneously b/Lang/Fantom/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..dd3dc3c7b7 --- /dev/null +++ b/Lang/Fantom/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Break b/Lang/Fantom/Loops-Break new file mode 120000 index 0000000000..e3f42f9902 --- /dev/null +++ b/Lang/Fantom/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Continue b/Lang/Fantom/Loops-Continue new file mode 120000 index 0000000000..77bc72b07e --- /dev/null +++ b/Lang/Fantom/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Do-while b/Lang/Fantom/Loops-Do-while new file mode 120000 index 0000000000..c39d49f438 --- /dev/null +++ b/Lang/Fantom/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Downward-for b/Lang/Fantom/Loops-Downward-for new file mode 120000 index 0000000000..7d91691ca8 --- /dev/null +++ b/Lang/Fantom/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-For b/Lang/Fantom/Loops-For new file mode 120000 index 0000000000..1c50be334a --- /dev/null +++ b/Lang/Fantom/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-For-with-a-specified-step b/Lang/Fantom/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..68ce20ddf7 --- /dev/null +++ b/Lang/Fantom/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Foreach b/Lang/Fantom/Loops-Foreach new file mode 120000 index 0000000000..5e2fdd6cc4 --- /dev/null +++ b/Lang/Fantom/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Infinite b/Lang/Fantom/Loops-Infinite new file mode 120000 index 0000000000..15392a402c --- /dev/null +++ b/Lang/Fantom/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-N-plus-one-half b/Lang/Fantom/Loops-N-plus-one-half new file mode 120000 index 0000000000..26d9943294 --- /dev/null +++ b/Lang/Fantom/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-Nested b/Lang/Fantom/Loops-Nested new file mode 120000 index 0000000000..32f5187060 --- /dev/null +++ b/Lang/Fantom/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Loops-While b/Lang/Fantom/Loops-While new file mode 120000 index 0000000000..c6f84a9c5c --- /dev/null +++ b/Lang/Fantom/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Man-or-boy-test b/Lang/Fantom/Man-or-boy-test new file mode 120000 index 0000000000..290956369f --- /dev/null +++ b/Lang/Fantom/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Map-range b/Lang/Fantom/Map-range new file mode 120000 index 0000000000..d34e6aebf2 --- /dev/null +++ b/Lang/Fantom/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Matrix-multiplication b/Lang/Fantom/Matrix-multiplication new file mode 120000 index 0000000000..3494f130b0 --- /dev/null +++ b/Lang/Fantom/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Menu b/Lang/Fantom/Menu new file mode 120000 index 0000000000..bfcaa49bbb --- /dev/null +++ b/Lang/Fantom/Menu @@ -0,0 +1 @@ +../../Task/Menu/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Monte-Carlo-methods b/Lang/Fantom/Monte-Carlo-methods new file mode 120000 index 0000000000..29cc42c3a7 --- /dev/null +++ b/Lang/Fantom/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Multiplication-tables b/Lang/Fantom/Multiplication-tables new file mode 120000 index 0000000000..b3bf71c0d1 --- /dev/null +++ b/Lang/Fantom/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Mutual-recursion b/Lang/Fantom/Mutual-recursion new file mode 120000 index 0000000000..5582cc3a7f --- /dev/null +++ b/Lang/Fantom/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Ordered-words b/Lang/Fantom/Ordered-words new file mode 120000 index 0000000000..438150baaa --- /dev/null +++ b/Lang/Fantom/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Fantom \ No newline at end of file diff --git a/Lang/FeatureC++/0DESCRIPTION b/Lang/FeatureC++/0DESCRIPTION new file mode 100644 index 0000000000..45919a3c0a --- /dev/null +++ b/Lang/FeatureC++/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language|FeatureC++ +|site=http://wwwiti.cs.uni-magdeburg.de/iti_db/fcc/ +}} + +FeatureC++ is a [[C++]] language extension to support Feature-Oriented Programming (FOP). FOP is the study of feature modularity in program families. FeatureC++ enables a programmer to express features in a modular way. It supports easy derivation and composition of program family members based on declarative specifications in form of algebraic equations. FeatureC++ also adopts language concepts of Aspect-Oriented Programming (AOP) to further increase modularity of cross-cutting concerns. Currently, it supports Aspectual Mixin Layers (AML). AML combine the advantages of Mixins and Aspects to increase the crosscutting modularity. +FeatureC++ comes in form of a [[C++]] preprocesser that transforms FeatureC++ code into native C++ code. \ No newline at end of file diff --git a/Lang/Felix/0DESCRIPTION b/Lang/Felix/0DESCRIPTION new file mode 100644 index 0000000000..25d8b5762b --- /dev/null +++ b/Lang/Felix/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|Felix +|site=http://felix.sourceforge.net/ +}} + +Felix is an advanced Algol like procedural programming language with a strong functional subsystem. It features ML style static typing, first class functions, pattern matching, garbage collection, polymorphism, and has built in support for high performance microthreading, regular expressions and context free parsing. + +==See also== +*[[wp:Felix_(programming_language)|Wikipedia: Felix Pgramming Lguage]] \ No newline at end of file diff --git a/Lang/Ferite/0DESCRIPTION b/Lang/Ferite/0DESCRIPTION new file mode 100644 index 0000000000..5d1c158fad --- /dev/null +++ b/Lang/Ferite/0DESCRIPTION @@ -0,0 +1,9 @@ +{{stub}} +{{language| +site=http://www.ferite.org/ +}} + +Ferite is a small robust scripting language providing a straightforward application integration, the ability for the API to be extended very easily. The design goals of Ferite are to make a clean, cross-platform language which is easy to embed and easy to extend and provides support for standards. + +== See Also == +[[wp:Ferite|Wikipedia:Ferite]] \ No newline at end of file diff --git a/Lang/Fexl/0DESCRIPTION b/Lang/Fexl/0DESCRIPTION new file mode 100644 index 0000000000..05630421ff --- /dev/null +++ b/Lang/Fexl/0DESCRIPTION @@ -0,0 +1,34 @@ +{{language}} +[http://fexl.com Fexl] is a [[functional programming]] language designed to be compact, efficient, and customizable in embedded environments. Its implementation aims to be the thinnest possible functional programming layer built on top of [[C]]. + +Fexl has no keywords, so whenever you see a symbol in a Fexl program, that symbol always refers to a function. + +A symbol may be defined within a Fexl program, or its definition may be left entirely open. The definitions of all open symbols are supplied by a ''context''. A context is a function which supplies definitions for symbols. A context function is itself written in Fexl. + +A Fexl program may therefore be resolved inside an arbitrary context, giving whatever meanings you like to all its open symbols. This makes it easy to wrap a Fexl program in an enhanced or restricted context. For example, in a web context you probably don't want "delete_file" to be defined at all, at least not in its normal sense. So you would resolve the program in a highly restricted context which only provides a handful of safe functions, omitting all the dangerous ones. + +Ultimately the core functions of Fexl are written in the [[C]] programming language. To write a new core function named "X" within Fexl, you simply create an appropriate C routine named "fexl_X". It automatically becomes available as a built-in Fexl function. + +For example, here is the C routine which implements the classic '''S''' combinator (fusion), where (S x y z) = (x z) (y z): + +value fexl_S(value f) + { + if (!f->L || !f->L->L || !f->L->L->L) return f; + return A( A(f->L->L->R, f->R), A(f->L->R, f->R) ); + } + +Fexl functions may have side effects -- after all, they've gotta happen '''somewhere'''. For example here's the implementation of the char_put function, called as (char_put ch next), which prints the single character ch to stdout and then continues with next: + +value fexl_char_put(value f) + { + if (!f->L || !f->L->L) return f; + value x = f->L->R; + if (!arg(type_long,x)) return f; + + putchar(get_long(x)); + return f->R; + } + +Fexl is very free-wheeling about side effects, because of course they must happen '''somewhere'''. But you the Fexl programmer can easily isolate and confine side effects as diligently as you like, factoring them out systematically, applying monadic techniques, or whatever. + +Fexl has no built-in type inference system. You can check types at run-time however you like. Fexl also has reflective features which allow you to examine types and the internal data structures at run-time, for example if you want to print a value for testing or debugging purposes. \ No newline at end of file diff --git a/Lang/Fexl/99-Bottles-of-Beer b/Lang/Fexl/99-Bottles-of-Beer new file mode 120000 index 0000000000..0c2750fec5 --- /dev/null +++ b/Lang/Fexl/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Fexl \ No newline at end of file diff --git a/Lang/Fexl/Fibonacci-sequence b/Lang/Fexl/Fibonacci-sequence new file mode 120000 index 0000000000..82f7d73705 --- /dev/null +++ b/Lang/Fexl/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Fexl \ No newline at end of file diff --git a/Lang/Fexl/Fork b/Lang/Fexl/Fork new file mode 120000 index 0000000000..0b57a3acf2 --- /dev/null +++ b/Lang/Fexl/Fork @@ -0,0 +1 @@ +../../Task/Fork/Fexl \ No newline at end of file diff --git a/Lang/Fexl/Function-definition b/Lang/Fexl/Function-definition new file mode 120000 index 0000000000..5fd3022164 --- /dev/null +++ b/Lang/Fexl/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Fexl \ No newline at end of file diff --git a/Lang/Fexl/Hello-world-Text b/Lang/Fexl/Hello-world-Text new file mode 120000 index 0000000000..0ce17ade88 --- /dev/null +++ b/Lang/Fexl/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Fexl \ No newline at end of file diff --git a/Lang/Fish/0DESCRIPTION b/Lang/Fish/0DESCRIPTION new file mode 100644 index 0000000000..ae84e9d381 --- /dev/null +++ b/Lang/Fish/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language}}Fish is an Funge-like esoteric language, consisting of the traditional Funge one-character commands. +A complete specification with a list of implementations can be found at [[eso:Fish|esolangs]]. + +[[Category:Esoteric_Languages]] \ No newline at end of file diff --git a/Lang/Fish/A+B b/Lang/Fish/A+B new file mode 120000 index 0000000000..a5eddea3a1 --- /dev/null +++ b/Lang/Fish/A+B @@ -0,0 +1 @@ +../../Task/A+B/Fish \ No newline at end of file diff --git a/Lang/Fish/Averages-Arithmetic-mean b/Lang/Fish/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f22ce51394 --- /dev/null +++ b/Lang/Fish/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Fish \ No newline at end of file diff --git a/Lang/Fish/Comments b/Lang/Fish/Comments new file mode 120000 index 0000000000..55e98280f7 --- /dev/null +++ b/Lang/Fish/Comments @@ -0,0 +1 @@ +../../Task/Comments/Fish \ No newline at end of file diff --git a/Lang/Fish/Empty-program b/Lang/Fish/Empty-program new file mode 120000 index 0000000000..e1b532e343 --- /dev/null +++ b/Lang/Fish/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Fish \ No newline at end of file diff --git a/Lang/Fish/Even-or-odd b/Lang/Fish/Even-or-odd new file mode 120000 index 0000000000..0c6c87f969 --- /dev/null +++ b/Lang/Fish/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Fish \ No newline at end of file diff --git a/Lang/Fish/Hello-world-Text b/Lang/Fish/Hello-world-Text new file mode 120000 index 0000000000..8b21cc1f43 --- /dev/null +++ b/Lang/Fish/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Fish \ No newline at end of file diff --git a/Lang/Fish/Integer-comparison b/Lang/Fish/Integer-comparison new file mode 120000 index 0000000000..424093d764 --- /dev/null +++ b/Lang/Fish/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Fish \ No newline at end of file diff --git a/Lang/Fish/Integer-sequence b/Lang/Fish/Integer-sequence new file mode 120000 index 0000000000..6b3588df65 --- /dev/null +++ b/Lang/Fish/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Fish \ No newline at end of file diff --git a/Lang/Florid/0DESCRIPTION b/Lang/Florid/0DESCRIPTION new file mode 100644 index 0000000000..1da632b50a --- /dev/null +++ b/Lang/Florid/0DESCRIPTION @@ -0,0 +1,3 @@ +{{stub}}{{language|Florid +|site=http://dbis.informatik.uni-freiburg.de/index.php?project=Florid}} +FLORID (F-LOgic Reasoning In Databases) is a deductive object-oriented database system employing [[wp:FLogic|F-Logic]] as data definition and query language. With the increasing interest in semistructured data, Florid has been extended for handling semistructured data in the context of Information Integration from the Semantic Web. \ No newline at end of file diff --git a/Lang/Forth/Factorial b/Lang/Forth/Factorial new file mode 120000 index 0000000000..baa538f1f3 --- /dev/null +++ b/Lang/Forth/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Forth \ No newline at end of file diff --git a/Lang/Forth/Factors-of-a-Mersenne-number b/Lang/Forth/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..21000f0cf5 --- /dev/null +++ b/Lang/Forth/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Forth \ No newline at end of file diff --git a/Lang/Forth/Factors-of-an-integer b/Lang/Forth/Factors-of-an-integer new file mode 120000 index 0000000000..7b7d736cd5 --- /dev/null +++ b/Lang/Forth/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Forth \ No newline at end of file diff --git a/Lang/Forth/Fibonacci-sequence b/Lang/Forth/Fibonacci-sequence new file mode 120000 index 0000000000..7ef9a95109 --- /dev/null +++ b/Lang/Forth/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Forth \ No newline at end of file diff --git a/Lang/Forth/File-IO b/Lang/Forth/File-IO new file mode 120000 index 0000000000..b284707897 --- /dev/null +++ b/Lang/Forth/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Forth \ No newline at end of file diff --git a/Lang/Forth/File-size b/Lang/Forth/File-size new file mode 120000 index 0000000000..a35d8b4ed7 --- /dev/null +++ b/Lang/Forth/File-size @@ -0,0 +1 @@ +../../Task/File-size/Forth \ No newline at end of file diff --git a/Lang/Forth/Filter b/Lang/Forth/Filter new file mode 120000 index 0000000000..0d0e43c9e5 --- /dev/null +++ b/Lang/Forth/Filter @@ -0,0 +1 @@ +../../Task/Filter/Forth \ No newline at end of file diff --git a/Lang/Forth/Find-limit-of-recursion b/Lang/Forth/Find-limit-of-recursion new file mode 120000 index 0000000000..f81304b08a --- /dev/null +++ b/Lang/Forth/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Forth \ No newline at end of file diff --git a/Lang/Forth/First-class-functions b/Lang/Forth/First-class-functions new file mode 120000 index 0000000000..e09610c877 --- /dev/null +++ b/Lang/Forth/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Forth \ No newline at end of file diff --git a/Lang/Forth/Flow-control-structures b/Lang/Forth/Flow-control-structures new file mode 120000 index 0000000000..8cc44f62ad --- /dev/null +++ b/Lang/Forth/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Forth \ No newline at end of file diff --git a/Lang/Forth/Formatted-numeric-output b/Lang/Forth/Formatted-numeric-output new file mode 120000 index 0000000000..3bea0d91d5 --- /dev/null +++ b/Lang/Forth/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Forth \ No newline at end of file diff --git a/Lang/Forth/Forward-difference b/Lang/Forth/Forward-difference new file mode 120000 index 0000000000..80f85db398 --- /dev/null +++ b/Lang/Forth/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Forth \ No newline at end of file diff --git a/Lang/Forth/Function-composition b/Lang/Forth/Function-composition new file mode 120000 index 0000000000..26b387d624 --- /dev/null +++ b/Lang/Forth/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Forth \ No newline at end of file diff --git a/Lang/Forth/Function-definition b/Lang/Forth/Function-definition new file mode 120000 index 0000000000..63766da191 --- /dev/null +++ b/Lang/Forth/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Forth \ No newline at end of file diff --git a/Lang/Forth/Function-frequency b/Lang/Forth/Function-frequency new file mode 120000 index 0000000000..4735771ae6 --- /dev/null +++ b/Lang/Forth/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/Forth \ No newline at end of file diff --git a/Lang/Forth/Generic-swap b/Lang/Forth/Generic-swap new file mode 120000 index 0000000000..eae87e4f4c --- /dev/null +++ b/Lang/Forth/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Forth \ No newline at end of file diff --git a/Lang/Forth/Gray-code b/Lang/Forth/Gray-code new file mode 120000 index 0000000000..7f96984b9f --- /dev/null +++ b/Lang/Forth/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Forth \ No newline at end of file diff --git a/Lang/Forth/Grayscale-image b/Lang/Forth/Grayscale-image new file mode 120000 index 0000000000..a3921d2b56 --- /dev/null +++ b/Lang/Forth/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Forth \ No newline at end of file diff --git a/Lang/Forth/Greatest-common-divisor b/Lang/Forth/Greatest-common-divisor new file mode 120000 index 0000000000..ec81b24d64 --- /dev/null +++ b/Lang/Forth/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Forth \ No newline at end of file diff --git a/Lang/Forth/Greatest-element-of-a-list b/Lang/Forth/Greatest-element-of-a-list new file mode 120000 index 0000000000..cf6245d7b8 --- /dev/null +++ b/Lang/Forth/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Forth \ No newline at end of file diff --git a/Lang/Forth/Greatest-subsequential-sum b/Lang/Forth/Greatest-subsequential-sum new file mode 120000 index 0000000000..53efdd43f0 --- /dev/null +++ b/Lang/Forth/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Forth \ No newline at end of file diff --git a/Lang/Forth/HTTP b/Lang/Forth/HTTP new file mode 120000 index 0000000000..e35252502f --- /dev/null +++ b/Lang/Forth/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Forth \ No newline at end of file diff --git a/Lang/Forth/Hailstone-sequence b/Lang/Forth/Hailstone-sequence new file mode 120000 index 0000000000..65b2fcfb1f --- /dev/null +++ b/Lang/Forth/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Forth \ No newline at end of file diff --git a/Lang/Forth/Hamming-numbers b/Lang/Forth/Hamming-numbers new file mode 120000 index 0000000000..6ac7a0ca37 --- /dev/null +++ b/Lang/Forth/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Handle-a-signal b/Lang/Forth/Handle-a-signal new file mode 120000 index 0000000000..4f0c316350 --- /dev/null +++ b/Lang/Forth/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Forth \ No newline at end of file diff --git a/Lang/Forth/Happy-numbers b/Lang/Forth/Happy-numbers new file mode 120000 index 0000000000..6f7d32a2bb --- /dev/null +++ b/Lang/Forth/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Haversine-formula b/Lang/Forth/Haversine-formula new file mode 120000 index 0000000000..822312b78b --- /dev/null +++ b/Lang/Forth/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Forth \ No newline at end of file diff --git a/Lang/Forth/Hello-world-Graphical b/Lang/Forth/Hello-world-Graphical new file mode 120000 index 0000000000..3869897656 --- /dev/null +++ b/Lang/Forth/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Forth \ No newline at end of file diff --git a/Lang/Forth/Hello-world-Newline-omission b/Lang/Forth/Hello-world-Newline-omission new file mode 120000 index 0000000000..5c03fca6f6 --- /dev/null +++ b/Lang/Forth/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Forth \ No newline at end of file diff --git a/Lang/Forth/Hello-world-Standard-error b/Lang/Forth/Hello-world-Standard-error new file mode 120000 index 0000000000..32233ddc4d --- /dev/null +++ b/Lang/Forth/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Forth \ No newline at end of file diff --git a/Lang/Forth/Hello-world-Text b/Lang/Forth/Hello-world-Text new file mode 120000 index 0000000000..b77a31a587 --- /dev/null +++ b/Lang/Forth/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Forth \ No newline at end of file diff --git a/Lang/Forth/Here-document b/Lang/Forth/Here-document new file mode 120000 index 0000000000..91542f7863 --- /dev/null +++ b/Lang/Forth/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Forth \ No newline at end of file diff --git a/Lang/Forth/Higher-order-functions b/Lang/Forth/Higher-order-functions new file mode 120000 index 0000000000..da80a579b2 --- /dev/null +++ b/Lang/Forth/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Forth \ No newline at end of file diff --git a/Lang/Forth/Horizontal-sundial-calculations b/Lang/Forth/Horizontal-sundial-calculations new file mode 120000 index 0000000000..bdb2c76a9d --- /dev/null +++ b/Lang/Forth/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Forth \ No newline at end of file diff --git a/Lang/Forth/Horners-rule-for-polynomial-evaluation b/Lang/Forth/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..5098378e3a --- /dev/null +++ b/Lang/Forth/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Forth \ No newline at end of file diff --git a/Lang/Forth/Host-introspection b/Lang/Forth/Host-introspection new file mode 120000 index 0000000000..48bd2198ac --- /dev/null +++ b/Lang/Forth/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Forth \ No newline at end of file diff --git a/Lang/Forth/Hostname b/Lang/Forth/Hostname new file mode 120000 index 0000000000..42fa995a9e --- /dev/null +++ b/Lang/Forth/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Forth \ No newline at end of file diff --git a/Lang/Forth/Include-a-file b/Lang/Forth/Include-a-file new file mode 120000 index 0000000000..73dd0a0de8 --- /dev/null +++ b/Lang/Forth/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Increment-a-numerical-string b/Lang/Forth/Increment-a-numerical-string new file mode 120000 index 0000000000..a28cce639e --- /dev/null +++ b/Lang/Forth/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Forth \ No newline at end of file diff --git a/Lang/Forth/Inheritance-Single b/Lang/Forth/Inheritance-Single new file mode 120000 index 0000000000..fb48b4d793 --- /dev/null +++ b/Lang/Forth/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Forth \ No newline at end of file diff --git a/Lang/Forth/Input-loop b/Lang/Forth/Input-loop new file mode 120000 index 0000000000..b3ab6d11bc --- /dev/null +++ b/Lang/Forth/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Forth \ No newline at end of file diff --git a/Lang/Forth/Integer-comparison b/Lang/Forth/Integer-comparison new file mode 120000 index 0000000000..693336a979 --- /dev/null +++ b/Lang/Forth/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Forth \ No newline at end of file diff --git a/Lang/Forth/Integer-sequence b/Lang/Forth/Integer-sequence new file mode 120000 index 0000000000..41a2276da5 --- /dev/null +++ b/Lang/Forth/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Forth \ No newline at end of file diff --git a/Lang/Forth/Interactive-programming b/Lang/Forth/Interactive-programming new file mode 120000 index 0000000000..8ac6a4b85d --- /dev/null +++ b/Lang/Forth/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Forth \ No newline at end of file diff --git a/Lang/Forth/Introspection b/Lang/Forth/Introspection new file mode 120000 index 0000000000..460ab19162 --- /dev/null +++ b/Lang/Forth/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Forth \ No newline at end of file diff --git a/Lang/Forth/Jensens-Device b/Lang/Forth/Jensens-Device new file mode 120000 index 0000000000..5d92cc07b4 --- /dev/null +++ b/Lang/Forth/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Forth \ No newline at end of file diff --git a/Lang/Forth/Kaprekar-numbers b/Lang/Forth/Kaprekar-numbers new file mode 120000 index 0000000000..1cc481beb2 --- /dev/null +++ b/Lang/Forth/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Keyboard-input-Keypress-check b/Lang/Forth/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..95f2f5c7c1 --- /dev/null +++ b/Lang/Forth/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Forth \ No newline at end of file diff --git a/Lang/Forth/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Forth/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..d246bb82d8 --- /dev/null +++ b/Lang/Forth/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Forth \ No newline at end of file diff --git a/Lang/Forth/Knapsack-problem-Continuous b/Lang/Forth/Knapsack-problem-Continuous new file mode 120000 index 0000000000..14ae7f3355 --- /dev/null +++ b/Lang/Forth/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Forth \ No newline at end of file diff --git a/Lang/Forth/Knapsack-problem-Unbounded b/Lang/Forth/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..12bb8fc231 --- /dev/null +++ b/Lang/Forth/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Forth \ No newline at end of file diff --git a/Lang/Forth/LZW-compression b/Lang/Forth/LZW-compression new file mode 120000 index 0000000000..f63bd96a7d --- /dev/null +++ b/Lang/Forth/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Forth \ No newline at end of file diff --git a/Lang/Forth/Leap-year b/Lang/Forth/Leap-year new file mode 120000 index 0000000000..0454b54556 --- /dev/null +++ b/Lang/Forth/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Forth \ No newline at end of file diff --git a/Lang/Forth/Least-common-multiple b/Lang/Forth/Least-common-multiple new file mode 120000 index 0000000000..276a462eba --- /dev/null +++ b/Lang/Forth/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Forth \ No newline at end of file diff --git a/Lang/Forth/Letter-frequency b/Lang/Forth/Letter-frequency new file mode 120000 index 0000000000..1b62e8b14b --- /dev/null +++ b/Lang/Forth/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Forth \ No newline at end of file diff --git a/Lang/Forth/Levenshtein-distance b/Lang/Forth/Levenshtein-distance new file mode 120000 index 0000000000..42228bd820 --- /dev/null +++ b/Lang/Forth/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Forth \ No newline at end of file diff --git a/Lang/Forth/Linear-congruential-generator b/Lang/Forth/Linear-congruential-generator new file mode 120000 index 0000000000..8a74721eff --- /dev/null +++ b/Lang/Forth/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Forth \ No newline at end of file diff --git a/Lang/Forth/Literals-Integer b/Lang/Forth/Literals-Integer new file mode 120000 index 0000000000..c097679c93 --- /dev/null +++ b/Lang/Forth/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Forth \ No newline at end of file diff --git a/Lang/Forth/Literals-String b/Lang/Forth/Literals-String new file mode 120000 index 0000000000..dce914b69f --- /dev/null +++ b/Lang/Forth/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Forth \ No newline at end of file diff --git a/Lang/Forth/Logical-operations b/Lang/Forth/Logical-operations new file mode 120000 index 0000000000..3ffefd5fc0 --- /dev/null +++ b/Lang/Forth/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Forth \ No newline at end of file diff --git a/Lang/Forth/Look-and-say-sequence b/Lang/Forth/Look-and-say-sequence new file mode 120000 index 0000000000..d831742173 --- /dev/null +++ b/Lang/Forth/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Forth \ No newline at end of file diff --git a/Lang/Forth/Loop-over-multiple-arrays-simultaneously b/Lang/Forth/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..2d7e93874f --- /dev/null +++ b/Lang/Forth/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Break b/Lang/Forth/Loops-Break new file mode 120000 index 0000000000..392dc9fbcf --- /dev/null +++ b/Lang/Forth/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Continue b/Lang/Forth/Loops-Continue new file mode 120000 index 0000000000..1b6b2e88e9 --- /dev/null +++ b/Lang/Forth/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Do-while b/Lang/Forth/Loops-Do-while new file mode 120000 index 0000000000..a5503ad3e0 --- /dev/null +++ b/Lang/Forth/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Downward-for b/Lang/Forth/Loops-Downward-for new file mode 120000 index 0000000000..98bc1f2235 --- /dev/null +++ b/Lang/Forth/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-For b/Lang/Forth/Loops-For new file mode 120000 index 0000000000..e423213b2e --- /dev/null +++ b/Lang/Forth/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-For-with-a-specified-step b/Lang/Forth/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..f257ee59fb --- /dev/null +++ b/Lang/Forth/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Foreach b/Lang/Forth/Loops-Foreach new file mode 120000 index 0000000000..107b75a927 --- /dev/null +++ b/Lang/Forth/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Infinite b/Lang/Forth/Loops-Infinite new file mode 120000 index 0000000000..a277dbacd0 --- /dev/null +++ b/Lang/Forth/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-N-plus-one-half b/Lang/Forth/Loops-N-plus-one-half new file mode 120000 index 0000000000..8ab0eae841 --- /dev/null +++ b/Lang/Forth/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-Nested b/Lang/Forth/Loops-Nested new file mode 120000 index 0000000000..1348391453 --- /dev/null +++ b/Lang/Forth/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Forth \ No newline at end of file diff --git a/Lang/Forth/Loops-While b/Lang/Forth/Loops-While new file mode 120000 index 0000000000..ff2f496cf7 --- /dev/null +++ b/Lang/Forth/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Forth \ No newline at end of file diff --git a/Lang/Forth/Luhn-test-of-credit-card-numbers b/Lang/Forth/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..a43d081cbb --- /dev/null +++ b/Lang/Forth/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/MD5 b/Lang/Forth/MD5 new file mode 120000 index 0000000000..2b52c5cd36 --- /dev/null +++ b/Lang/Forth/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Forth \ No newline at end of file diff --git a/Lang/Forth/Mandelbrot-set b/Lang/Forth/Mandelbrot-set new file mode 120000 index 0000000000..539f6cf724 --- /dev/null +++ b/Lang/Forth/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Forth \ No newline at end of file diff --git a/Lang/Forth/Map-range b/Lang/Forth/Map-range new file mode 120000 index 0000000000..9eaa62b336 --- /dev/null +++ b/Lang/Forth/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Forth \ No newline at end of file diff --git a/Lang/Forth/Matrix-multiplication b/Lang/Forth/Matrix-multiplication new file mode 120000 index 0000000000..ef6c072062 --- /dev/null +++ b/Lang/Forth/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Forth \ No newline at end of file diff --git a/Lang/Forth/Memory-allocation b/Lang/Forth/Memory-allocation new file mode 120000 index 0000000000..b17aad0b6e --- /dev/null +++ b/Lang/Forth/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Forth \ No newline at end of file diff --git a/Lang/Forth/Memory-layout-of-a-data-structure b/Lang/Forth/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..5aac3d4afe --- /dev/null +++ b/Lang/Forth/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Forth \ No newline at end of file diff --git a/Lang/Forth/Monty-Hall-problem b/Lang/Forth/Monty-Hall-problem new file mode 120000 index 0000000000..634fee6e0e --- /dev/null +++ b/Lang/Forth/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Forth \ No newline at end of file diff --git a/Lang/Forth/Multiplication-tables b/Lang/Forth/Multiplication-tables new file mode 120000 index 0000000000..197508a333 --- /dev/null +++ b/Lang/Forth/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Forth \ No newline at end of file diff --git a/Lang/Forth/Mutual-recursion b/Lang/Forth/Mutual-recursion new file mode 120000 index 0000000000..897a7b077b --- /dev/null +++ b/Lang/Forth/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Forth \ No newline at end of file diff --git a/Lang/Fortran/24-game-Solve b/Lang/Fortran/24-game-Solve new file mode 120000 index 0000000000..f2423136dc --- /dev/null +++ b/Lang/Fortran/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Factorial b/Lang/Fortran/Factorial new file mode 120000 index 0000000000..9e02cfe42c --- /dev/null +++ b/Lang/Fortran/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Factors-of-a-Mersenne-number b/Lang/Fortran/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..3acfc8097e --- /dev/null +++ b/Lang/Fortran/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Factors-of-an-integer b/Lang/Fortran/Factors-of-an-integer new file mode 120000 index 0000000000..f00c956c16 --- /dev/null +++ b/Lang/Fortran/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Fast-Fourier-transform b/Lang/Fortran/Fast-Fourier-transform new file mode 120000 index 0000000000..87deeb39ac --- /dev/null +++ b/Lang/Fortran/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Fibonacci-sequence b/Lang/Fortran/Fibonacci-sequence new file mode 120000 index 0000000000..0f840862d8 --- /dev/null +++ b/Lang/Fortran/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/File-IO b/Lang/Fortran/File-IO new file mode 120000 index 0000000000..d77546cac9 --- /dev/null +++ b/Lang/Fortran/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Filter b/Lang/Fortran/Filter new file mode 120000 index 0000000000..d56597056e --- /dev/null +++ b/Lang/Fortran/Filter @@ -0,0 +1 @@ +../../Task/Filter/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Find-limit-of-recursion b/Lang/Fortran/Find-limit-of-recursion new file mode 120000 index 0000000000..8abe02e78c --- /dev/null +++ b/Lang/Fortran/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Find-the-missing-permutation b/Lang/Fortran/Find-the-missing-permutation new file mode 120000 index 0000000000..f6003f8847 --- /dev/null +++ b/Lang/Fortran/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Five-weekends b/Lang/Fortran/Five-weekends new file mode 120000 index 0000000000..b1e5a0f02c --- /dev/null +++ b/Lang/Fortran/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Formatted-numeric-output b/Lang/Fortran/Formatted-numeric-output new file mode 120000 index 0000000000..8777cf65f0 --- /dev/null +++ b/Lang/Fortran/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Forward-difference b/Lang/Fortran/Forward-difference new file mode 120000 index 0000000000..373bfcf338 --- /dev/null +++ b/Lang/Fortran/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Four-bit-adder b/Lang/Fortran/Four-bit-adder new file mode 120000 index 0000000000..e8f00f3de2 --- /dev/null +++ b/Lang/Fortran/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Function-definition b/Lang/Fortran/Function-definition new file mode 120000 index 0000000000..4c17083f63 --- /dev/null +++ b/Lang/Fortran/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Gamma-function b/Lang/Fortran/Gamma-function new file mode 120000 index 0000000000..6b9fa3ee93 --- /dev/null +++ b/Lang/Fortran/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Generic-swap b/Lang/Fortran/Generic-swap new file mode 120000 index 0000000000..c2b4d8abef --- /dev/null +++ b/Lang/Fortran/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Gray-code b/Lang/Fortran/Gray-code new file mode 120000 index 0000000000..c6558a53b0 --- /dev/null +++ b/Lang/Fortran/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Grayscale-image b/Lang/Fortran/Grayscale-image new file mode 120000 index 0000000000..17cf4f75d3 --- /dev/null +++ b/Lang/Fortran/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Greatest-common-divisor b/Lang/Fortran/Greatest-common-divisor new file mode 120000 index 0000000000..78b8f08488 --- /dev/null +++ b/Lang/Fortran/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Greatest-element-of-a-list b/Lang/Fortran/Greatest-element-of-a-list new file mode 120000 index 0000000000..3859c8aeae --- /dev/null +++ b/Lang/Fortran/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Greatest-subsequential-sum b/Lang/Fortran/Greatest-subsequential-sum new file mode 120000 index 0000000000..0ca09f26b5 --- /dev/null +++ b/Lang/Fortran/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Guess-the-number b/Lang/Fortran/Guess-the-number new file mode 120000 index 0000000000..ef32749cd4 --- /dev/null +++ b/Lang/Fortran/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Guess-the-number-With-feedback b/Lang/Fortran/Guess-the-number-With-feedback new file mode 120000 index 0000000000..0a46f3f8b1 --- /dev/null +++ b/Lang/Fortran/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Guess-the-number-With-feedback-player b/Lang/Fortran/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..9d1fd8ae65 --- /dev/null +++ b/Lang/Fortran/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hailstone-sequence b/Lang/Fortran/Hailstone-sequence new file mode 120000 index 0000000000..b0adf2a5ca --- /dev/null +++ b/Lang/Fortran/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hamming-numbers b/Lang/Fortran/Hamming-numbers new file mode 120000 index 0000000000..1ef196b6cb --- /dev/null +++ b/Lang/Fortran/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Happy-numbers b/Lang/Fortran/Happy-numbers new file mode 120000 index 0000000000..99a530420d --- /dev/null +++ b/Lang/Fortran/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Haversine-formula b/Lang/Fortran/Haversine-formula new file mode 120000 index 0000000000..bed65e9bb7 --- /dev/null +++ b/Lang/Fortran/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hello-world-Newline-omission b/Lang/Fortran/Hello-world-Newline-omission new file mode 120000 index 0000000000..96707cba41 --- /dev/null +++ b/Lang/Fortran/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hello-world-Standard-error b/Lang/Fortran/Hello-world-Standard-error new file mode 120000 index 0000000000..4893d56180 --- /dev/null +++ b/Lang/Fortran/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hello-world-Text b/Lang/Fortran/Hello-world-Text new file mode 120000 index 0000000000..9866a807a8 --- /dev/null +++ b/Lang/Fortran/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Higher-order-functions b/Lang/Fortran/Higher-order-functions new file mode 120000 index 0000000000..06bd1b13fd --- /dev/null +++ b/Lang/Fortran/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hofstadter-Conway-$10,000-sequence b/Lang/Fortran/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..4d8c2314ec --- /dev/null +++ b/Lang/Fortran/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Holidays-related-to-Easter b/Lang/Fortran/Holidays-related-to-Easter new file mode 120000 index 0000000000..8a9e3d80bc --- /dev/null +++ b/Lang/Fortran/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Horizontal-sundial-calculations b/Lang/Fortran/Horizontal-sundial-calculations new file mode 120000 index 0000000000..d3ad29b2ef --- /dev/null +++ b/Lang/Fortran/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Horners-rule-for-polynomial-evaluation b/Lang/Fortran/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..1313a6cd47 --- /dev/null +++ b/Lang/Fortran/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Host-introspection b/Lang/Fortran/Host-introspection new file mode 120000 index 0000000000..6577aa6bd4 --- /dev/null +++ b/Lang/Fortran/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Hostname b/Lang/Fortran/Hostname new file mode 120000 index 0000000000..185ae3be8a --- /dev/null +++ b/Lang/Fortran/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Identity-matrix b/Lang/Fortran/Identity-matrix new file mode 120000 index 0000000000..0d439f686d --- /dev/null +++ b/Lang/Fortran/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Include-a-file b/Lang/Fortran/Include-a-file new file mode 120000 index 0000000000..35d93494c9 --- /dev/null +++ b/Lang/Fortran/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Increment-a-numerical-string b/Lang/Fortran/Increment-a-numerical-string new file mode 120000 index 0000000000..bd359d216a --- /dev/null +++ b/Lang/Fortran/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Inheritance-Single b/Lang/Fortran/Inheritance-Single new file mode 120000 index 0000000000..f666f7f37e --- /dev/null +++ b/Lang/Fortran/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Input-loop b/Lang/Fortran/Input-loop new file mode 120000 index 0000000000..befe105376 --- /dev/null +++ b/Lang/Fortran/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Integer-comparison b/Lang/Fortran/Integer-comparison new file mode 120000 index 0000000000..2b507fa3ab --- /dev/null +++ b/Lang/Fortran/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Integer-sequence b/Lang/Fortran/Integer-sequence new file mode 120000 index 0000000000..c08c270240 --- /dev/null +++ b/Lang/Fortran/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Kaprekar-numbers b/Lang/Fortran/Kaprekar-numbers new file mode 120000 index 0000000000..f72ae67a0b --- /dev/null +++ b/Lang/Fortran/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Knapsack-problem-Continuous b/Lang/Fortran/Knapsack-problem-Continuous new file mode 120000 index 0000000000..0f58b220e8 --- /dev/null +++ b/Lang/Fortran/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Knapsack-problem-Unbounded b/Lang/Fortran/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..1ac9d97cda --- /dev/null +++ b/Lang/Fortran/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Leap-year b/Lang/Fortran/Leap-year new file mode 120000 index 0000000000..4a67d24d46 --- /dev/null +++ b/Lang/Fortran/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Linear-congruential-generator b/Lang/Fortran/Linear-congruential-generator new file mode 120000 index 0000000000..1f781ca2c1 --- /dev/null +++ b/Lang/Fortran/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Literals-Integer b/Lang/Fortran/Literals-Integer new file mode 120000 index 0000000000..adfa31cbee --- /dev/null +++ b/Lang/Fortran/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Logical-operations b/Lang/Fortran/Logical-operations new file mode 120000 index 0000000000..009d285749 --- /dev/null +++ b/Lang/Fortran/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Long-multiplication b/Lang/Fortran/Long-multiplication new file mode 120000 index 0000000000..5d8f0dd74d --- /dev/null +++ b/Lang/Fortran/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Longest-common-subsequence b/Lang/Fortran/Longest-common-subsequence new file mode 120000 index 0000000000..7bd13a577c --- /dev/null +++ b/Lang/Fortran/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Look-and-say-sequence b/Lang/Fortran/Look-and-say-sequence new file mode 120000 index 0000000000..2af7af52e1 --- /dev/null +++ b/Lang/Fortran/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loop-over-multiple-arrays-simultaneously b/Lang/Fortran/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..cb4ed928cf --- /dev/null +++ b/Lang/Fortran/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Break b/Lang/Fortran/Loops-Break new file mode 120000 index 0000000000..7c2b4631fc --- /dev/null +++ b/Lang/Fortran/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Continue b/Lang/Fortran/Loops-Continue new file mode 120000 index 0000000000..72bb1bbf0d --- /dev/null +++ b/Lang/Fortran/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Do-while b/Lang/Fortran/Loops-Do-while new file mode 120000 index 0000000000..2c380f1f9a --- /dev/null +++ b/Lang/Fortran/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Downward-for b/Lang/Fortran/Loops-Downward-for new file mode 120000 index 0000000000..e2defbc628 --- /dev/null +++ b/Lang/Fortran/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-For b/Lang/Fortran/Loops-For new file mode 120000 index 0000000000..d9d3315789 --- /dev/null +++ b/Lang/Fortran/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-For-with-a-specified-step b/Lang/Fortran/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..3f8e78bda5 --- /dev/null +++ b/Lang/Fortran/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Foreach b/Lang/Fortran/Loops-Foreach new file mode 120000 index 0000000000..c14e006cd5 --- /dev/null +++ b/Lang/Fortran/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Infinite b/Lang/Fortran/Loops-Infinite new file mode 120000 index 0000000000..7bc3c59d49 --- /dev/null +++ b/Lang/Fortran/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-N-plus-one-half b/Lang/Fortran/Loops-N-plus-one-half new file mode 120000 index 0000000000..8da81bc1de --- /dev/null +++ b/Lang/Fortran/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-Nested b/Lang/Fortran/Loops-Nested new file mode 120000 index 0000000000..80c0c1fa7d --- /dev/null +++ b/Lang/Fortran/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Loops-While b/Lang/Fortran/Loops-While new file mode 120000 index 0000000000..8faa3412e9 --- /dev/null +++ b/Lang/Fortran/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Lucas-Lehmer-test b/Lang/Fortran/Lucas-Lehmer-test new file mode 120000 index 0000000000..60a864c017 --- /dev/null +++ b/Lang/Fortran/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Luhn-test-of-credit-card-numbers b/Lang/Fortran/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..9245d40071 --- /dev/null +++ b/Lang/Fortran/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Man-or-boy-test b/Lang/Fortran/Man-or-boy-test new file mode 120000 index 0000000000..5c0f4c547a --- /dev/null +++ b/Lang/Fortran/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Mandelbrot-set b/Lang/Fortran/Mandelbrot-set new file mode 120000 index 0000000000..4b899b9318 --- /dev/null +++ b/Lang/Fortran/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Map-range b/Lang/Fortran/Map-range new file mode 120000 index 0000000000..bb5ddbeab3 --- /dev/null +++ b/Lang/Fortran/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Matrix-exponentiation-operator b/Lang/Fortran/Matrix-exponentiation-operator new file mode 120000 index 0000000000..de70dc6176 --- /dev/null +++ b/Lang/Fortran/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Matrix-multiplication b/Lang/Fortran/Matrix-multiplication new file mode 120000 index 0000000000..301cdeaa8a --- /dev/null +++ b/Lang/Fortran/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Matrix-transposition b/Lang/Fortran/Matrix-transposition new file mode 120000 index 0000000000..729e65ed56 --- /dev/null +++ b/Lang/Fortran/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Memory-allocation b/Lang/Fortran/Memory-allocation new file mode 120000 index 0000000000..563e5bf193 --- /dev/null +++ b/Lang/Fortran/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Miller-Rabin-primality-test b/Lang/Fortran/Miller-Rabin-primality-test new file mode 120000 index 0000000000..6d501f45e9 --- /dev/null +++ b/Lang/Fortran/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Monte-Carlo-methods b/Lang/Fortran/Monte-Carlo-methods new file mode 120000 index 0000000000..efa3d06966 --- /dev/null +++ b/Lang/Fortran/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Monty-Hall-problem b/Lang/Fortran/Monty-Hall-problem new file mode 120000 index 0000000000..ab667ab0c6 --- /dev/null +++ b/Lang/Fortran/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Multiple-distinct-objects b/Lang/Fortran/Multiple-distinct-objects new file mode 120000 index 0000000000..1a230565a9 --- /dev/null +++ b/Lang/Fortran/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Multiplication-tables b/Lang/Fortran/Multiplication-tables new file mode 120000 index 0000000000..c7c769ccb5 --- /dev/null +++ b/Lang/Fortran/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Mutual-recursion b/Lang/Fortran/Mutual-recursion new file mode 120000 index 0000000000..faa50dc48d --- /dev/null +++ b/Lang/Fortran/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Fortran \ No newline at end of file diff --git a/Lang/Fortress/0DESCRIPTION b/Lang/Fortress/0DESCRIPTION new file mode 100644 index 0000000000..fd4e17a8a5 --- /dev/null +++ b/Lang/Fortress/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language|Fortress +|site=http://projectfortress.sun.com/Projects/Community +}} + +Fortress is a new programming language designed for high-performance computing (HPC) with high programmability. The name "Fortress" is intended to connote a secure Fortran, i.e., "a language for high-performance computation that provides abstraction and type safety on par with modern programming language principles."[[#Citation|[1]]] Fortress is designed to be both highly parallel and have rich functionality contained within libraries, drawing from Java but taken to a higher degree. + +==Citation== +#[http://research.sun.com/projects/plrg/Publications/fortress.1.0.pdf The Fortress Language Specification] + +==See Also== +* [[wp:Fortress_(programming_language)|Wikipedia: Fortress]] \ No newline at end of file diff --git a/Lang/Fortress/Hello-world-Text b/Lang/Fortress/Hello-world-Text new file mode 120000 index 0000000000..c514f6e828 --- /dev/null +++ b/Lang/Fortress/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Fortress \ No newline at end of file diff --git a/Lang/Free-Pascal-Lazarus/0DESCRIPTION b/Lang/Free-Pascal-Lazarus/0DESCRIPTION new file mode 100644 index 0000000000..e0ac540fa7 --- /dev/null +++ b/Lang/Free-Pascal-Lazarus/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language|Free Pascal / Lazarus +|site=http://wiki.lazarus.freepascal.org/ +}} \ No newline at end of file diff --git a/Lang/FreeMat/0DESCRIPTION b/Lang/FreeMat/0DESCRIPTION new file mode 100644 index 0000000000..0150a85e18 --- /dev/null +++ b/Lang/FreeMat/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}} +{{language +|site=http://freemat.sourceforge.net/ +}} +FreeMat is a free environment for rapid engineering and scientific prototyping and data processing. It is similar to commercial systems such as [[MATLAB]] from Mathworks, and [[IDL]] from Research Systems, but is Open Source. FreeMat is available under the GPL license. \ No newline at end of file diff --git a/Lang/Frege/0DESCRIPTION b/Lang/Frege/0DESCRIPTION new file mode 100644 index 0000000000..2fb3a845a1 --- /dev/null +++ b/Lang/Frege/0DESCRIPTION @@ -0,0 +1,24 @@ +{{language|Frege +|strength=strong +|safety=safe +|compat=structural +|checking=static +|gc=yes +|LCT=no +|hopl=no +|site=http://www.frege-lang.org/}} +{{language programming paradigm|Declarative}} +{{language programming paradigm|functional}} + +{{infobox_begin}}[http://try.frege-lang.org/ Try] this language on [http://try.frege-lang.org/ frege-lang.org].{{infobox_end}} + +'''Frege''' is a purely [[functional programming]] language with [[lazy evaluation|non-strict]] semantics, strongly influenced by [[Haskell]], but targeting the [[runs on vm::Java Virtual Machine|JVM]], and deviates from Haskell in ways which make it easier to interoperate with [[Java]]. + +Frege source files use the extension .fr. Frege is similar enough to Haskell that haskell-mode can be used for editing Frege source files, for example by putting this line in your .emacs: + +
+(add-to-list 'auto-mode-alist '("\\.fr$" . haskell-mode))
+
+ +==Citations== +* [[wp:Frege_%28programming_language%29|Wikipedia:Frege (programming language)]] \ No newline at end of file diff --git a/Lang/Frege/99-Bottles-of-Beer b/Lang/Frege/99-Bottles-of-Beer new file mode 120000 index 0000000000..cf10df2af5 --- /dev/null +++ b/Lang/Frege/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Frege \ No newline at end of file diff --git a/Lang/Frege/Hailstone-sequence b/Lang/Frege/Hailstone-sequence new file mode 120000 index 0000000000..70c3309477 --- /dev/null +++ b/Lang/Frege/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Frege \ No newline at end of file diff --git a/Lang/Frege/Happy-numbers b/Lang/Frege/Happy-numbers new file mode 120000 index 0000000000..e3b292e3d5 --- /dev/null +++ b/Lang/Frege/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Frege \ No newline at end of file diff --git a/Lang/Frege/Hello-world-Text b/Lang/Frege/Hello-world-Text new file mode 120000 index 0000000000..cb0192f4c2 --- /dev/null +++ b/Lang/Frege/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Frege \ No newline at end of file diff --git a/Lang/Frege/Maze-solving b/Lang/Frege/Maze-solving new file mode 120000 index 0000000000..f42f91c41e --- /dev/null +++ b/Lang/Frege/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Frege \ No newline at end of file diff --git a/Lang/Friendly-interactive-shell/0DESCRIPTION b/Lang/Friendly-interactive-shell/0DESCRIPTION new file mode 100644 index 0000000000..02ed8ddca3 --- /dev/null +++ b/Lang/Friendly-interactive-shell/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language}} +'''friendly interactive shell''' is an user-friendly UNIX shell, incompatible by design with [[Bourne Shell]]. It's mostly used interactively, but it's possible to write scripts in it too. \ No newline at end of file diff --git a/Lang/Frink/0DESCRIPTION b/Lang/Frink/0DESCRIPTION new file mode 100644 index 0000000000..9297297384 --- /dev/null +++ b/Lang/Frink/0DESCRIPTION @@ -0,0 +1,20 @@ +{{language|Frink +|site=http://futureboy.us/frinkdocs/ +|gc=yes +}}[[runs on vm::java virtual machine| ]] + +Frink is a programming language designed and implemented by Alan Eliasen. It is designed to be a general-purpose, multi-paradigm language. + +One of the most obvious differentiating features of Frink is that it tracks units of measure (feet, meters, tons, watts, etc.) through all calculations, helping ensure that physical calculations make sense. Frink understands how different units of measure interrelate, such as a length cubed is a volume, or power multiplied by time is energy. Different units of measure can be mixed in calculations, and Frink automatically ensures that the calculations lead to a result with the expected dimensions. It attempts to follow standard mathematical notation as closely as possible, and makes a strong effort to do the right thing with numeric types. + +Frink runs on the JVM and on Android, and is available in the Android Market. + +==See Also== + +*[http://futureboy.homeip.net/frinkdocs/ Frink] homepage, including full documentation. +*[http://futureboy.us/frink/ Frink web-based interface] +*[http://futureboy.us/frinkdocs/faq.html Frequently Asked Questions] +*[http://futureboy.us/frinkdocs/fspdocs.html Frink Server Pages Documentation] +*[http://futureboy.us/fsp/samples.fsp Sample Programs] +*[http://futureboy.us/frinkdocs/LL4.html Presentation at Lightweight Languages 4, MIT] +*[http://confreaks.net/videos/120-elcamp2010-frink Presentation at Emerging Languages Camp, 2010] \ No newline at end of file diff --git a/Lang/Frink/99-Bottles-of-Beer b/Lang/Frink/99-Bottles-of-Beer new file mode 120000 index 0000000000..54ba5f19c9 --- /dev/null +++ b/Lang/Frink/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Frink \ No newline at end of file diff --git a/Lang/Frink/Arbitrary-precision-integers-included b/Lang/Frink/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..0485370d60 --- /dev/null +++ b/Lang/Frink/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Frink \ No newline at end of file diff --git a/Lang/Frink/Arithmetic-Integer b/Lang/Frink/Arithmetic-Integer new file mode 120000 index 0000000000..ab8753d0e4 --- /dev/null +++ b/Lang/Frink/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Frink \ No newline at end of file diff --git a/Lang/Frink/Case-sensitivity-of-identifiers b/Lang/Frink/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..57266b48f4 --- /dev/null +++ b/Lang/Frink/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Frink \ No newline at end of file diff --git a/Lang/Frink/Character-codes b/Lang/Frink/Character-codes new file mode 120000 index 0000000000..912c797f43 --- /dev/null +++ b/Lang/Frink/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Frink \ No newline at end of file diff --git a/Lang/Frink/Date-format b/Lang/Frink/Date-format new file mode 120000 index 0000000000..63cb5e7dd4 --- /dev/null +++ b/Lang/Frink/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Frink \ No newline at end of file diff --git a/Lang/Frink/Date-manipulation b/Lang/Frink/Date-manipulation new file mode 120000 index 0000000000..4ede7b8ba6 --- /dev/null +++ b/Lang/Frink/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Frink \ No newline at end of file diff --git a/Lang/Frink/Empty-program b/Lang/Frink/Empty-program new file mode 120000 index 0000000000..3544530d73 --- /dev/null +++ b/Lang/Frink/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Frink \ No newline at end of file diff --git a/Lang/Frink/Evaluate-binomial-coefficients b/Lang/Frink/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..ee48a621c6 --- /dev/null +++ b/Lang/Frink/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Frink \ No newline at end of file diff --git a/Lang/Frink/FizzBuzz b/Lang/Frink/FizzBuzz new file mode 120000 index 0000000000..f5e489f33a --- /dev/null +++ b/Lang/Frink/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Frink \ No newline at end of file diff --git a/Lang/Frink/Flatten-a-list b/Lang/Frink/Flatten-a-list new file mode 120000 index 0000000000..266141ed1f --- /dev/null +++ b/Lang/Frink/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Frink \ No newline at end of file diff --git a/Lang/Frink/Function-definition b/Lang/Frink/Function-definition new file mode 120000 index 0000000000..6e908fcf24 --- /dev/null +++ b/Lang/Frink/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Frink \ No newline at end of file diff --git a/Lang/Frink/Generic-swap b/Lang/Frink/Generic-swap new file mode 120000 index 0000000000..e614abf23d --- /dev/null +++ b/Lang/Frink/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Frink \ No newline at end of file diff --git a/Lang/Frink/Gray-code b/Lang/Frink/Gray-code new file mode 120000 index 0000000000..14dfb839c3 --- /dev/null +++ b/Lang/Frink/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Frink \ No newline at end of file diff --git a/Lang/Frink/Greatest-common-divisor b/Lang/Frink/Greatest-common-divisor new file mode 120000 index 0000000000..c77a047771 --- /dev/null +++ b/Lang/Frink/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Frink \ No newline at end of file diff --git a/Lang/Frink/Greatest-element-of-a-list b/Lang/Frink/Greatest-element-of-a-list new file mode 120000 index 0000000000..68e145d8b4 --- /dev/null +++ b/Lang/Frink/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Frink \ No newline at end of file diff --git a/Lang/Frink/Haversine-formula b/Lang/Frink/Haversine-formula new file mode 120000 index 0000000000..3bbb706521 --- /dev/null +++ b/Lang/Frink/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Frink \ No newline at end of file diff --git a/Lang/Frink/Hello-world-Graphical b/Lang/Frink/Hello-world-Graphical new file mode 120000 index 0000000000..f2034a2027 --- /dev/null +++ b/Lang/Frink/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Frink \ No newline at end of file diff --git a/Lang/Frink/Hello-world-Newline-omission b/Lang/Frink/Hello-world-Newline-omission new file mode 120000 index 0000000000..ccd1f7ab13 --- /dev/null +++ b/Lang/Frink/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Frink \ No newline at end of file diff --git a/Lang/Frink/Hello-world-Text b/Lang/Frink/Hello-world-Text new file mode 120000 index 0000000000..382fbe9d45 --- /dev/null +++ b/Lang/Frink/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Frink \ No newline at end of file diff --git a/Lang/Frink/Here-document b/Lang/Frink/Here-document new file mode 120000 index 0000000000..67727ec7c3 --- /dev/null +++ b/Lang/Frink/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Frink \ No newline at end of file diff --git a/Lang/Frink/Integer-comparison b/Lang/Frink/Integer-comparison new file mode 120000 index 0000000000..9110e8c90a --- /dev/null +++ b/Lang/Frink/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Frink \ No newline at end of file diff --git a/Lang/Frink/Least-common-multiple b/Lang/Frink/Least-common-multiple new file mode 120000 index 0000000000..8a32d2cff2 --- /dev/null +++ b/Lang/Frink/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Frink \ No newline at end of file diff --git a/Lang/Frink/Levenshtein-distance b/Lang/Frink/Levenshtein-distance new file mode 120000 index 0000000000..7177bfde0e --- /dev/null +++ b/Lang/Frink/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Frink \ No newline at end of file diff --git a/Lang/Frink/Literals-Integer b/Lang/Frink/Literals-Integer new file mode 120000 index 0000000000..15eb1be285 --- /dev/null +++ b/Lang/Frink/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Frink \ No newline at end of file diff --git a/Lang/Frink/Loops-While b/Lang/Frink/Loops-While new file mode 120000 index 0000000000..7c558fef4f --- /dev/null +++ b/Lang/Frink/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Frink \ No newline at end of file diff --git a/Lang/Frink/MD5 b/Lang/Frink/MD5 new file mode 120000 index 0000000000..f52185bfee --- /dev/null +++ b/Lang/Frink/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Frink \ No newline at end of file diff --git a/Lang/Frink/Matrix-multiplication b/Lang/Frink/Matrix-multiplication new file mode 120000 index 0000000000..389dd3f334 --- /dev/null +++ b/Lang/Frink/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Frink \ No newline at end of file diff --git a/Lang/GAP/0DESCRIPTION b/Lang/GAP/0DESCRIPTION new file mode 100644 index 0000000000..e9712731b1 --- /dev/null +++ b/Lang/GAP/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language|GAP}}GAP is the language used in the computer algebra system of the same name. See http://www.gap-system.org/ for more information. + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/GAP/100-doors b/Lang/GAP/100-doors new file mode 120000 index 0000000000..fae957790b --- /dev/null +++ b/Lang/GAP/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/GAP \ No newline at end of file diff --git a/Lang/GAP/24-game b/Lang/GAP/24-game new file mode 120000 index 0000000000..e74d47709b --- /dev/null +++ b/Lang/GAP/24-game @@ -0,0 +1 @@ +../../Task/24-game/GAP \ No newline at end of file diff --git a/Lang/GAP/24-game-Solve b/Lang/GAP/24-game-Solve new file mode 120000 index 0000000000..2e8e893cb8 --- /dev/null +++ b/Lang/GAP/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/GAP \ No newline at end of file diff --git a/Lang/GAP/99-Bottles-of-Beer b/Lang/GAP/99-Bottles-of-Beer new file mode 120000 index 0000000000..0357250522 --- /dev/null +++ b/Lang/GAP/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/GAP \ No newline at end of file diff --git a/Lang/GAP/Accumulator-factory b/Lang/GAP/Accumulator-factory new file mode 120000 index 0000000000..9d39b78368 --- /dev/null +++ b/Lang/GAP/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/GAP \ No newline at end of file diff --git a/Lang/GAP/Ackermann-function b/Lang/GAP/Ackermann-function new file mode 120000 index 0000000000..37d3188c98 --- /dev/null +++ b/Lang/GAP/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/GAP \ No newline at end of file diff --git a/Lang/GAP/Anagrams b/Lang/GAP/Anagrams new file mode 120000 index 0000000000..b00220a911 --- /dev/null +++ b/Lang/GAP/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/GAP \ No newline at end of file diff --git a/Lang/GAP/Anagrams-Deranged-anagrams b/Lang/GAP/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..8e4cef82b1 --- /dev/null +++ b/Lang/GAP/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/GAP \ No newline at end of file diff --git a/Lang/GAP/Apply-a-callback-to-an-array b/Lang/GAP/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..43abfd81c5 --- /dev/null +++ b/Lang/GAP/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/GAP \ No newline at end of file diff --git a/Lang/GAP/Arbitrary-precision-integers-included b/Lang/GAP/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..4c2035fa64 --- /dev/null +++ b/Lang/GAP/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/GAP \ No newline at end of file diff --git a/Lang/GAP/Arithmetic-Complex b/Lang/GAP/Arithmetic-Complex new file mode 120000 index 0000000000..9cdd6ac89d --- /dev/null +++ b/Lang/GAP/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/GAP \ No newline at end of file diff --git a/Lang/GAP/Arithmetic-Integer b/Lang/GAP/Arithmetic-Integer new file mode 120000 index 0000000000..3847e507d7 --- /dev/null +++ b/Lang/GAP/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/GAP \ No newline at end of file diff --git a/Lang/GAP/Arithmetic-Rational b/Lang/GAP/Arithmetic-Rational new file mode 120000 index 0000000000..f4126c6cdd --- /dev/null +++ b/Lang/GAP/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/GAP \ No newline at end of file diff --git a/Lang/GAP/Array-concatenation b/Lang/GAP/Array-concatenation new file mode 120000 index 0000000000..7429ad1ea7 --- /dev/null +++ b/Lang/GAP/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/GAP \ No newline at end of file diff --git a/Lang/GAP/Arrays b/Lang/GAP/Arrays new file mode 120000 index 0000000000..56b0cf6991 --- /dev/null +++ b/Lang/GAP/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/GAP \ No newline at end of file diff --git a/Lang/GAP/Assertions b/Lang/GAP/Assertions new file mode 120000 index 0000000000..e08245e8ce --- /dev/null +++ b/Lang/GAP/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/GAP \ No newline at end of file diff --git a/Lang/GAP/Averages-Arithmetic-mean b/Lang/GAP/Averages-Arithmetic-mean new file mode 120000 index 0000000000..80fcd2e2e9 --- /dev/null +++ b/Lang/GAP/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/GAP \ No newline at end of file diff --git a/Lang/GAP/Averages-Median b/Lang/GAP/Averages-Median new file mode 120000 index 0000000000..15b2581844 --- /dev/null +++ b/Lang/GAP/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/GAP \ No newline at end of file diff --git a/Lang/GAP/Averages-Mode b/Lang/GAP/Averages-Mode new file mode 120000 index 0000000000..cbdf100c83 --- /dev/null +++ b/Lang/GAP/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/GAP \ No newline at end of file diff --git a/Lang/GAP/Averages-Pythagorean-means b/Lang/GAP/Averages-Pythagorean-means new file mode 120000 index 0000000000..bb3ceda418 --- /dev/null +++ b/Lang/GAP/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/GAP \ No newline at end of file diff --git a/Lang/GAP/Averages-Simple-moving-average b/Lang/GAP/Averages-Simple-moving-average new file mode 120000 index 0000000000..5410788e2b --- /dev/null +++ b/Lang/GAP/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/GAP \ No newline at end of file diff --git a/Lang/GAP/Balanced-brackets b/Lang/GAP/Balanced-brackets new file mode 120000 index 0000000000..8bb49469f9 --- /dev/null +++ b/Lang/GAP/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/GAP \ No newline at end of file diff --git a/Lang/GAP/Binary-search b/Lang/GAP/Binary-search new file mode 120000 index 0000000000..62433e514a --- /dev/null +++ b/Lang/GAP/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/GAP \ No newline at end of file diff --git a/Lang/GAP/Bitmap-Write-a-PPM-file b/Lang/GAP/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..155be93c36 --- /dev/null +++ b/Lang/GAP/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/GAP \ No newline at end of file diff --git a/Lang/GAP/Boolean-values b/Lang/GAP/Boolean-values new file mode 120000 index 0000000000..3c088e1e45 --- /dev/null +++ b/Lang/GAP/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/GAP \ No newline at end of file diff --git a/Lang/GAP/Caesar-cipher b/Lang/GAP/Caesar-cipher new file mode 120000 index 0000000000..37a18e75b4 --- /dev/null +++ b/Lang/GAP/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/GAP \ No newline at end of file diff --git a/Lang/GAP/Case-sensitivity-of-identifiers b/Lang/GAP/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..7c38835ddf --- /dev/null +++ b/Lang/GAP/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/GAP \ No newline at end of file diff --git a/Lang/GAP/Character-codes b/Lang/GAP/Character-codes new file mode 120000 index 0000000000..ff4a3d2754 --- /dev/null +++ b/Lang/GAP/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/GAP \ No newline at end of file diff --git a/Lang/GAP/Check-that-file-exists b/Lang/GAP/Check-that-file-exists new file mode 120000 index 0000000000..7d479ca5de --- /dev/null +++ b/Lang/GAP/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/GAP \ No newline at end of file diff --git a/Lang/GAP/Combinations b/Lang/GAP/Combinations new file mode 120000 index 0000000000..f912889f98 --- /dev/null +++ b/Lang/GAP/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/GAP \ No newline at end of file diff --git a/Lang/GAP/Comments b/Lang/GAP/Comments new file mode 120000 index 0000000000..1da48c3363 --- /dev/null +++ b/Lang/GAP/Comments @@ -0,0 +1 @@ +../../Task/Comments/GAP \ No newline at end of file diff --git a/Lang/GAP/Create-a-two-dimensional-array-at-runtime b/Lang/GAP/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..46c6a44fd7 --- /dev/null +++ b/Lang/GAP/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/GAP \ No newline at end of file diff --git a/Lang/GAP/Day-of-the-week b/Lang/GAP/Day-of-the-week new file mode 120000 index 0000000000..86689b236f --- /dev/null +++ b/Lang/GAP/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/GAP \ No newline at end of file diff --git a/Lang/GAP/Delete-a-file b/Lang/GAP/Delete-a-file new file mode 120000 index 0000000000..5ffdbc3446 --- /dev/null +++ b/Lang/GAP/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/GAP \ No newline at end of file diff --git a/Lang/GAP/Dot-product b/Lang/GAP/Dot-product new file mode 120000 index 0000000000..53ee0704fc --- /dev/null +++ b/Lang/GAP/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/GAP \ No newline at end of file diff --git a/Lang/GAP/Dynamic-variable-names b/Lang/GAP/Dynamic-variable-names new file mode 120000 index 0000000000..fccea171a9 --- /dev/null +++ b/Lang/GAP/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/GAP \ No newline at end of file diff --git a/Lang/GAP/Evaluate-binomial-coefficients b/Lang/GAP/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..2120f9d6b3 --- /dev/null +++ b/Lang/GAP/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/GAP \ No newline at end of file diff --git a/Lang/GAP/Exponentiation-operator b/Lang/GAP/Exponentiation-operator new file mode 120000 index 0000000000..46e9bb7fda --- /dev/null +++ b/Lang/GAP/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/GAP \ No newline at end of file diff --git a/Lang/GAP/Factorial b/Lang/GAP/Factorial new file mode 120000 index 0000000000..e85be335c6 --- /dev/null +++ b/Lang/GAP/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/GAP \ No newline at end of file diff --git a/Lang/GAP/Factors-of-a-Mersenne-number b/Lang/GAP/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..0b84d28449 --- /dev/null +++ b/Lang/GAP/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/GAP \ No newline at end of file diff --git a/Lang/GAP/Factors-of-an-integer b/Lang/GAP/Factors-of-an-integer new file mode 120000 index 0000000000..c662895662 --- /dev/null +++ b/Lang/GAP/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/GAP \ No newline at end of file diff --git a/Lang/GAP/Fast-Fourier-transform b/Lang/GAP/Fast-Fourier-transform new file mode 120000 index 0000000000..1433c558a9 --- /dev/null +++ b/Lang/GAP/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/GAP \ No newline at end of file diff --git a/Lang/GAP/Fibonacci-sequence b/Lang/GAP/Fibonacci-sequence new file mode 120000 index 0000000000..6640898d2d --- /dev/null +++ b/Lang/GAP/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/GAP \ No newline at end of file diff --git a/Lang/GAP/File-IO b/Lang/GAP/File-IO new file mode 120000 index 0000000000..b4ed31b3c9 --- /dev/null +++ b/Lang/GAP/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/GAP \ No newline at end of file diff --git a/Lang/GAP/Filter b/Lang/GAP/Filter new file mode 120000 index 0000000000..fc280c70e7 --- /dev/null +++ b/Lang/GAP/Filter @@ -0,0 +1 @@ +../../Task/Filter/GAP \ No newline at end of file diff --git a/Lang/GAP/Find-limit-of-recursion b/Lang/GAP/Find-limit-of-recursion new file mode 120000 index 0000000000..807e04cfe6 --- /dev/null +++ b/Lang/GAP/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/GAP \ No newline at end of file diff --git a/Lang/GAP/Find-the-missing-permutation b/Lang/GAP/Find-the-missing-permutation new file mode 120000 index 0000000000..df9a6676b4 --- /dev/null +++ b/Lang/GAP/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/GAP \ No newline at end of file diff --git a/Lang/GAP/First-class-functions b/Lang/GAP/First-class-functions new file mode 120000 index 0000000000..f3eb52b0d3 --- /dev/null +++ b/Lang/GAP/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/GAP \ No newline at end of file diff --git a/Lang/GAP/Five-weekends b/Lang/GAP/Five-weekends new file mode 120000 index 0000000000..5f9241399d --- /dev/null +++ b/Lang/GAP/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/GAP \ No newline at end of file diff --git a/Lang/GAP/FizzBuzz b/Lang/GAP/FizzBuzz new file mode 120000 index 0000000000..6fa1f23379 --- /dev/null +++ b/Lang/GAP/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/GAP \ No newline at end of file diff --git a/Lang/GAP/Flatten-a-list b/Lang/GAP/Flatten-a-list new file mode 120000 index 0000000000..d47e224399 --- /dev/null +++ b/Lang/GAP/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/GAP \ No newline at end of file diff --git a/Lang/GAP/Function-composition b/Lang/GAP/Function-composition new file mode 120000 index 0000000000..b336080433 --- /dev/null +++ b/Lang/GAP/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/GAP \ No newline at end of file diff --git a/Lang/GAP/Greatest-element-of-a-list b/Lang/GAP/Greatest-element-of-a-list new file mode 120000 index 0000000000..3998bf3c07 --- /dev/null +++ b/Lang/GAP/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/GAP \ No newline at end of file diff --git a/Lang/GAP/Hailstone-sequence b/Lang/GAP/Hailstone-sequence new file mode 120000 index 0000000000..7b8e68f1dd --- /dev/null +++ b/Lang/GAP/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/GAP \ No newline at end of file diff --git a/Lang/GAP/Hello-world-Text b/Lang/GAP/Hello-world-Text new file mode 120000 index 0000000000..2f11cb9a84 --- /dev/null +++ b/Lang/GAP/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/GAP \ No newline at end of file diff --git a/Lang/GAP/Higher-order-functions b/Lang/GAP/Higher-order-functions new file mode 120000 index 0000000000..d9bce9bab7 --- /dev/null +++ b/Lang/GAP/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/GAP \ No newline at end of file diff --git a/Lang/GAP/Horners-rule-for-polynomial-evaluation b/Lang/GAP/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..a0bfc0ebb1 --- /dev/null +++ b/Lang/GAP/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/GAP \ No newline at end of file diff --git a/Lang/GAP/Include-a-file b/Lang/GAP/Include-a-file new file mode 120000 index 0000000000..391113e3b2 --- /dev/null +++ b/Lang/GAP/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/GAP \ No newline at end of file diff --git a/Lang/GAP/Increment-a-numerical-string b/Lang/GAP/Increment-a-numerical-string new file mode 120000 index 0000000000..62d4ce2d55 --- /dev/null +++ b/Lang/GAP/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/GAP \ No newline at end of file diff --git a/Lang/GAP/Infinity b/Lang/GAP/Infinity new file mode 120000 index 0000000000..8322bad7db --- /dev/null +++ b/Lang/GAP/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/GAP \ No newline at end of file diff --git a/Lang/GAP/Integer-sequence b/Lang/GAP/Integer-sequence new file mode 120000 index 0000000000..b4345ac4c3 --- /dev/null +++ b/Lang/GAP/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/GAP \ No newline at end of file diff --git a/Lang/GAP/Interactive-programming b/Lang/GAP/Interactive-programming new file mode 120000 index 0000000000..417d59c08b --- /dev/null +++ b/Lang/GAP/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/GAP \ No newline at end of file diff --git a/Lang/GAP/Introspection b/Lang/GAP/Introspection new file mode 120000 index 0000000000..72dad5092c --- /dev/null +++ b/Lang/GAP/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/GAP \ No newline at end of file diff --git a/Lang/GAP/Kaprekar-numbers b/Lang/GAP/Kaprekar-numbers new file mode 120000 index 0000000000..592c0e025b --- /dev/null +++ b/Lang/GAP/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/GAP \ No newline at end of file diff --git a/Lang/GAP/Knuth-shuffle b/Lang/GAP/Knuth-shuffle new file mode 120000 index 0000000000..0841a87996 --- /dev/null +++ b/Lang/GAP/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/GAP \ No newline at end of file diff --git a/Lang/GAP/Leap-year b/Lang/GAP/Leap-year new file mode 120000 index 0000000000..0174ee7b67 --- /dev/null +++ b/Lang/GAP/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/GAP \ No newline at end of file diff --git a/Lang/GAP/Least-common-multiple b/Lang/GAP/Least-common-multiple new file mode 120000 index 0000000000..d1029b88d5 --- /dev/null +++ b/Lang/GAP/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/GAP \ No newline at end of file diff --git a/Lang/GAP/List-comprehensions b/Lang/GAP/List-comprehensions new file mode 120000 index 0000000000..78e7f64102 --- /dev/null +++ b/Lang/GAP/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/GAP \ No newline at end of file diff --git a/Lang/GAP/Literals-String b/Lang/GAP/Literals-String new file mode 120000 index 0000000000..ed066b8820 --- /dev/null +++ b/Lang/GAP/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/GAP \ No newline at end of file diff --git a/Lang/GAP/Logical-operations b/Lang/GAP/Logical-operations new file mode 120000 index 0000000000..c0457eb566 --- /dev/null +++ b/Lang/GAP/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/GAP \ No newline at end of file diff --git a/Lang/GAP/Look-and-say-sequence b/Lang/GAP/Look-and-say-sequence new file mode 120000 index 0000000000..5fad059877 --- /dev/null +++ b/Lang/GAP/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/GAP \ No newline at end of file diff --git a/Lang/GAP/Loops-Break b/Lang/GAP/Loops-Break new file mode 120000 index 0000000000..52506f00d6 --- /dev/null +++ b/Lang/GAP/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/GAP \ No newline at end of file diff --git a/Lang/GAP/Loops-Continue b/Lang/GAP/Loops-Continue new file mode 120000 index 0000000000..e775bcf132 --- /dev/null +++ b/Lang/GAP/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/GAP \ No newline at end of file diff --git a/Lang/GAP/Loops-For b/Lang/GAP/Loops-For new file mode 120000 index 0000000000..ff6a65e1b4 --- /dev/null +++ b/Lang/GAP/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/GAP \ No newline at end of file diff --git a/Lang/GAP/Luhn-test-of-credit-card-numbers b/Lang/GAP/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..7cc844bb07 --- /dev/null +++ b/Lang/GAP/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/GAP \ No newline at end of file diff --git a/Lang/GAP/Matrix-exponentiation-operator b/Lang/GAP/Matrix-exponentiation-operator new file mode 120000 index 0000000000..6c68340edb --- /dev/null +++ b/Lang/GAP/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/GAP \ No newline at end of file diff --git a/Lang/GAP/Matrix-multiplication b/Lang/GAP/Matrix-multiplication new file mode 120000 index 0000000000..ea9ecd819f --- /dev/null +++ b/Lang/GAP/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/GAP \ No newline at end of file diff --git a/Lang/GAP/Matrix-transposition b/Lang/GAP/Matrix-transposition new file mode 120000 index 0000000000..46150afb36 --- /dev/null +++ b/Lang/GAP/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/GAP \ No newline at end of file diff --git a/Lang/GAP/Search-a-list b/Lang/GAP/Search-a-list new file mode 120000 index 0000000000..7b059efb7f --- /dev/null +++ b/Lang/GAP/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/GAP \ No newline at end of file diff --git a/Lang/GLBasic/0DESCRIPTION b/Lang/GLBasic/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/GLBasic/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/GLBasic/Hello-world-Text b/Lang/GLBasic/Hello-world-Text new file mode 120000 index 0000000000..4f9768b67e --- /dev/null +++ b/Lang/GLBasic/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/GLBasic \ No newline at end of file diff --git a/Lang/GML/0DESCRIPTION b/Lang/GML/0DESCRIPTION new file mode 100644 index 0000000000..2776d94c37 --- /dev/null +++ b/Lang/GML/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language +|hopl=no +|express=implicit +|tags=gml}} +{{wikipedia|Game Maker Language}} +'''Game Maker Language (GML)''' is a scripting language developed for use with a computer game creation application called [[wp:Game Maker|Game Maker]]. It was originally created by [[wp:Mark Overmars|Mark Overmars]] to supplement the drag-and-drop action system used in Game Maker. However, in the latest versions, all the drag-and-drop actions translate to GML rather than being separate from it. + +GML is heavily integrated with the Game Maker environment. Usually, elements such as sprites and sounds are all organized within the Game Maker [[IDE]] (though they can also be loaded from external files). Game Maker's architecture is designed to handle such things as event detection, level design, and object configuration without the need to code them manually, minimizing code verbosity with intuitive interface features. + +A common misconception is that languages such as [[Pascal]] and [[C++]] can be directly used in GML. This is incorrect, and is a common mistake due to GML's ability to utilize Pascal and C++ style syntax (e.g. "&&" is interchangeable with "and"). \ No newline at end of file diff --git a/Lang/GML/100-doors b/Lang/GML/100-doors new file mode 120000 index 0000000000..ce2b3a0cbd --- /dev/null +++ b/Lang/GML/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/GML \ No newline at end of file diff --git a/Lang/GML/A+B b/Lang/GML/A+B new file mode 120000 index 0000000000..77e3201201 --- /dev/null +++ b/Lang/GML/A+B @@ -0,0 +1 @@ +../../Task/A+B/GML \ No newline at end of file diff --git a/Lang/GML/Ackermann-function b/Lang/GML/Ackermann-function new file mode 120000 index 0000000000..e460c3940b --- /dev/null +++ b/Lang/GML/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/GML \ No newline at end of file diff --git a/Lang/GML/Arrays b/Lang/GML/Arrays new file mode 120000 index 0000000000..46237bb1f7 --- /dev/null +++ b/Lang/GML/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/GML \ No newline at end of file diff --git a/Lang/GML/Character-matching b/Lang/GML/Character-matching new file mode 120000 index 0000000000..1d66029918 --- /dev/null +++ b/Lang/GML/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/GML \ No newline at end of file diff --git a/Lang/GML/Comments b/Lang/GML/Comments new file mode 120000 index 0000000000..33ec08c5aa --- /dev/null +++ b/Lang/GML/Comments @@ -0,0 +1 @@ +../../Task/Comments/GML \ No newline at end of file diff --git a/Lang/GML/Factorial b/Lang/GML/Factorial new file mode 120000 index 0000000000..8feeaf65fa --- /dev/null +++ b/Lang/GML/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/GML \ No newline at end of file diff --git a/Lang/GML/File-IO b/Lang/GML/File-IO new file mode 120000 index 0000000000..fc44b342bd --- /dev/null +++ b/Lang/GML/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/GML \ No newline at end of file diff --git a/Lang/GML/Function-definition b/Lang/GML/Function-definition new file mode 120000 index 0000000000..f5a5ac6daa --- /dev/null +++ b/Lang/GML/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/GML \ No newline at end of file diff --git a/Lang/GML/Guess-the-number b/Lang/GML/Guess-the-number new file mode 120000 index 0000000000..bc29989c24 --- /dev/null +++ b/Lang/GML/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/GML \ No newline at end of file diff --git a/Lang/GML/Loops-Break b/Lang/GML/Loops-Break new file mode 120000 index 0000000000..5b1ade3985 --- /dev/null +++ b/Lang/GML/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/GML \ No newline at end of file diff --git a/Lang/GML/Loops-Continue b/Lang/GML/Loops-Continue new file mode 120000 index 0000000000..0808563b14 --- /dev/null +++ b/Lang/GML/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/GML \ No newline at end of file diff --git a/Lang/GML/Loops-Do-while b/Lang/GML/Loops-Do-while new file mode 120000 index 0000000000..c554b64260 --- /dev/null +++ b/Lang/GML/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/GML \ No newline at end of file diff --git a/Lang/GML/Loops-Downward-for b/Lang/GML/Loops-Downward-for new file mode 120000 index 0000000000..7962782e0b --- /dev/null +++ b/Lang/GML/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/GML \ No newline at end of file diff --git a/Lang/GML/Loops-For b/Lang/GML/Loops-For new file mode 120000 index 0000000000..4ccb875808 --- /dev/null +++ b/Lang/GML/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/GML \ No newline at end of file diff --git a/Lang/GML/Loops-For-with-a-specified-step b/Lang/GML/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..0cce434c14 --- /dev/null +++ b/Lang/GML/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/GML \ No newline at end of file diff --git a/Lang/GML/Loops-Infinite b/Lang/GML/Loops-Infinite new file mode 120000 index 0000000000..fd420edd72 --- /dev/null +++ b/Lang/GML/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/GML \ No newline at end of file diff --git a/Lang/GML/Loops-N-plus-one-half b/Lang/GML/Loops-N-plus-one-half new file mode 120000 index 0000000000..4e187a4582 --- /dev/null +++ b/Lang/GML/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/GML \ No newline at end of file diff --git a/Lang/GML/Loops-While b/Lang/GML/Loops-While new file mode 120000 index 0000000000..9fed0ffa4e --- /dev/null +++ b/Lang/GML/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/GML \ No newline at end of file diff --git a/Lang/GUISS/0DESCRIPTION b/Lang/GUISS/0DESCRIPTION new file mode 100644 index 0000000000..a705605fb9 --- /dev/null +++ b/Lang/GUISS/0DESCRIPTION @@ -0,0 +1,10 @@ +{{stub}}{{language|Graphical User Interface Support Script|exec=interpreted +|site=http://markhobley.yi.org/gui/supportscript/ (This is offline at the moment).}} + +== History == + +Graphical User Interface Support Script was originally called "Windows Support Script". On 16th January 2010, it was renamed to "Graphical User Interface Support Script" to reflect the fact that it can be used to describle the operation of graphical user interface systems other than Microsoft Windows. The project started in 1996 and its purpose was to provide a standard means of representing graphical user interface operations and interactions through written or spoken word. This would enable telephone support or written instructions to be given to end using coherent standardized language and terminology that could be understood by the end user. + +== Interpreter == + +There is no official interpreter for Graphical User Interface Support Script. However, the specifications are public, so it is theoretically possible to implement an interpreter that handles the written form of the instructions. The language is still undergoing evolution at this time. \ No newline at end of file diff --git a/Lang/GUISS/99-Bottles-of-Beer b/Lang/GUISS/99-Bottles-of-Beer new file mode 120000 index 0000000000..b572973101 --- /dev/null +++ b/Lang/GUISS/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/GUISS \ No newline at end of file diff --git a/Lang/GUISS/A+B b/Lang/GUISS/A+B new file mode 120000 index 0000000000..04fcec582c --- /dev/null +++ b/Lang/GUISS/A+B @@ -0,0 +1 @@ +../../Task/A+B/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Arrays b/Lang/GUISS/Arrays new file mode 120000 index 0000000000..71b6c98c48 --- /dev/null +++ b/Lang/GUISS/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Calendar-for-real-programmers b/Lang/GUISS/Calendar-for-real-programmers new file mode 120000 index 0000000000..f45128fad9 --- /dev/null +++ b/Lang/GUISS/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Execute-a-system-command b/Lang/GUISS/Execute-a-system-command new file mode 120000 index 0000000000..2b02572f4a --- /dev/null +++ b/Lang/GUISS/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/GUISS \ No newline at end of file diff --git a/Lang/GUISS/File-IO b/Lang/GUISS/File-IO new file mode 120000 index 0000000000..153d444a46 --- /dev/null +++ b/Lang/GUISS/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/GUISS \ No newline at end of file diff --git a/Lang/GUISS/File-modification-time b/Lang/GUISS/File-modification-time new file mode 120000 index 0000000000..16d7ad74b9 --- /dev/null +++ b/Lang/GUISS/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/GUISS \ No newline at end of file diff --git a/Lang/GUISS/HTTP b/Lang/GUISS/HTTP new file mode 120000 index 0000000000..250f195d64 --- /dev/null +++ b/Lang/GUISS/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Hello-world-Graphical b/Lang/GUISS/Hello-world-Graphical new file mode 120000 index 0000000000..f3974129a1 --- /dev/null +++ b/Lang/GUISS/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Hello-world-Line-printer b/Lang/GUISS/Hello-world-Line-printer new file mode 120000 index 0000000000..fdda019645 --- /dev/null +++ b/Lang/GUISS/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Hello-world-Newline-omission b/Lang/GUISS/Hello-world-Newline-omission new file mode 120000 index 0000000000..4ff2eb5e63 --- /dev/null +++ b/Lang/GUISS/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Integer-sequence b/Lang/GUISS/Integer-sequence new file mode 120000 index 0000000000..4a536fe8e3 --- /dev/null +++ b/Lang/GUISS/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Joystick-position b/Lang/GUISS/Joystick-position new file mode 120000 index 0000000000..c2b25db0e4 --- /dev/null +++ b/Lang/GUISS/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Minesweeper-game b/Lang/GUISS/Minesweeper-game new file mode 120000 index 0000000000..fc8449a28d --- /dev/null +++ b/Lang/GUISS/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/GUISS \ No newline at end of file diff --git a/Lang/GW-BASIC/0DESCRIPTION b/Lang/GW-BASIC/0DESCRIPTION new file mode 100644 index 0000000000..75d647db22 --- /dev/null +++ b/Lang/GW-BASIC/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|GW-BASIC +|LCT=yes}} +{{implementation|BASIC}} +{{language programming paradigm|Imperative}} +GW-BASIC is a dialect of the programming language BASIC that was supplied with some versions of MSDOS. It replaced [[BASICA]] and was in turn replaced by [[QBasic]]. + +==See also== +* [[wp:GW-BASIC|GW-BASIC on Wikipedia]] +* [http://www.chebucto.ns.ca/~af380/GW-BASIC-tokens.html Discussion of GW-BASIC's tokenised program format] \ No newline at end of file diff --git a/Lang/GW-BASIC/Comments b/Lang/GW-BASIC/Comments new file mode 120000 index 0000000000..4936eeb542 --- /dev/null +++ b/Lang/GW-BASIC/Comments @@ -0,0 +1 @@ +../../Task/Comments/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Ethiopian-multiplication b/Lang/GW-BASIC/Ethiopian-multiplication new file mode 120000 index 0000000000..3bfccbddc4 --- /dev/null +++ b/Lang/GW-BASIC/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Find-common-directory-path b/Lang/GW-BASIC/Find-common-directory-path new file mode 120000 index 0000000000..8dfbd82a1f --- /dev/null +++ b/Lang/GW-BASIC/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Flow-control-structures b/Lang/GW-BASIC/Flow-control-structures new file mode 120000 index 0000000000..e67ddc884e --- /dev/null +++ b/Lang/GW-BASIC/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Guess-the-number b/Lang/GW-BASIC/Guess-the-number new file mode 120000 index 0000000000..04862b971d --- /dev/null +++ b/Lang/GW-BASIC/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Hello-world-Text b/Lang/GW-BASIC/Hello-world-Text new file mode 120000 index 0000000000..6f238d0f2d --- /dev/null +++ b/Lang/GW-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/GW-BASIC/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..77b73d8ca1 --- /dev/null +++ b/Lang/GW-BASIC/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Loops-For b/Lang/GW-BASIC/Loops-For new file mode 120000 index 0000000000..5767da5545 --- /dev/null +++ b/Lang/GW-BASIC/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Quine b/Lang/GW-BASIC/Quine new file mode 120000 index 0000000000..412a68197f --- /dev/null +++ b/Lang/GW-BASIC/Quine @@ -0,0 +1 @@ +../../Task/Quine/GW-BASIC \ No newline at end of file diff --git a/Lang/Gambas/0DESCRIPTION b/Lang/Gambas/0DESCRIPTION new file mode 100644 index 0000000000..1801824bc0 --- /dev/null +++ b/Lang/Gambas/0DESCRIPTION @@ -0,0 +1,14 @@ +{{language +|exec=bytecode +|site=http://gambas.sf.net +|parampass=value +|safety=safe +|express=explicit +|strength=strong +|tags=basic, gambas, gambas2, gambas3 +|gc=no +|LCT=yes}} + +Gambas is a free development environment based on a [[Basic]] interpreter with object extensions, a bit like Visual Basic™ (but it is NOT a clone !). + +With Gambas, you can quickly design your program [[GUI]] with QT or GTK+, access [[MySQL]], [[PostgreSQL]], Firebird, ODBC and [[SQLite]] databases, pilot KDE applications with DCOP, translate your program into any language, create network applications easily, make 3D [[OpenGL]] applications, make CGI web applications, and so on... \ No newline at end of file diff --git a/Lang/Gambas/Arrays b/Lang/Gambas/Arrays new file mode 120000 index 0000000000..0d96263845 --- /dev/null +++ b/Lang/Gambas/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Command-line-arguments b/Lang/Gambas/Command-line-arguments new file mode 120000 index 0000000000..b02d7c00c5 --- /dev/null +++ b/Lang/Gambas/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Comments b/Lang/Gambas/Comments new file mode 120000 index 0000000000..c9ff971ac2 --- /dev/null +++ b/Lang/Gambas/Comments @@ -0,0 +1 @@ +../../Task/Comments/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Hello-world-Graphical b/Lang/Gambas/Hello-world-Graphical new file mode 120000 index 0000000000..c0b6e1935f --- /dev/null +++ b/Lang/Gambas/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Hello-world-Text b/Lang/Gambas/Hello-world-Text new file mode 120000 index 0000000000..08c8b99920 --- /dev/null +++ b/Lang/Gambas/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Loops-For b/Lang/Gambas/Loops-For new file mode 120000 index 0000000000..de2e65379c --- /dev/null +++ b/Lang/Gambas/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Gambas \ No newline at end of file diff --git a/Lang/Gambas/Mouse-position b/Lang/Gambas/Mouse-position new file mode 120000 index 0000000000..b5400054a3 --- /dev/null +++ b/Lang/Gambas/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Gambas \ No newline at end of file diff --git a/Lang/Gdl/0DESCRIPTION b/Lang/Gdl/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Gdl/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/Gecho/0DESCRIPTION b/Lang/Gecho/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Gecho/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/Gecho/Empty-program b/Lang/Gecho/Empty-program new file mode 120000 index 0000000000..af6397d2b4 --- /dev/null +++ b/Lang/Gecho/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Gecho \ No newline at end of file diff --git a/Lang/Gecho/Fibonacci-sequence b/Lang/Gecho/Fibonacci-sequence new file mode 120000 index 0000000000..21c43b024b --- /dev/null +++ b/Lang/Gecho/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Gecho \ No newline at end of file diff --git a/Lang/Gecho/Generic-swap b/Lang/Gecho/Generic-swap new file mode 120000 index 0000000000..1e7eff78ba --- /dev/null +++ b/Lang/Gecho/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Gecho \ No newline at end of file diff --git a/Lang/Gema/0DESCRIPTION b/Lang/Gema/0DESCRIPTION new file mode 100644 index 0000000000..2579cbf667 --- /dev/null +++ b/Lang/Gema/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|gema +|site=http://gema.sourceforge.net/new/index.shtml +}} + + +gema is a general purpose text processing utility based on the concept of pattern matching. In general, it reads an input file and copies it to an output file, while performing certain transformations to the data as specified by a set of patterns defined by the user. It can be used to do the sorts of things that are done by Unix utilities such as cpp, grep, [[sed]], [[AWK]], or strings. It can be used as a macro processor, but it is much more general than cpp or [[m4]] because it does not impose any particular syntax for what a macro call looks like. Unlike utilities like [[sed]] or [[AWK]], gema can deal with patterns that span multiple lines and with nested constructs. It is also distinguished by being able to use multiple sets of rules to be used in different contexts. + +gema has been extended with a binding to the scripting language [[Lua]], named GeL, that provides the ability of executing piece of [[Lua]] code in gema actions. It also may be used to add gema powerful matching capabilities to any Lua-enabled software. \ No newline at end of file diff --git a/Lang/Gema/Comments b/Lang/Gema/Comments new file mode 120000 index 0000000000..fe9c885087 --- /dev/null +++ b/Lang/Gema/Comments @@ -0,0 +1 @@ +../../Task/Comments/Gema \ No newline at end of file diff --git a/Lang/Gema/Empty-program b/Lang/Gema/Empty-program new file mode 120000 index 0000000000..7a04078e8e --- /dev/null +++ b/Lang/Gema/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Gema \ No newline at end of file diff --git a/Lang/Gema/Hello-world-Text b/Lang/Gema/Hello-world-Text new file mode 120000 index 0000000000..f5586161df --- /dev/null +++ b/Lang/Gema/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Gema \ No newline at end of file diff --git a/Lang/Gema/Quine b/Lang/Gema/Quine new file mode 120000 index 0000000000..9fa2590f10 --- /dev/null +++ b/Lang/Gema/Quine @@ -0,0 +1 @@ +../../Task/Quine/Gema \ No newline at end of file diff --git a/Lang/Gentee/0DESCRIPTION b/Lang/Gentee/0DESCRIPTION new file mode 100644 index 0000000000..ad2cc89ad4 --- /dev/null +++ b/Lang/Gentee/0DESCRIPTION @@ -0,0 +1,8 @@ +{{Stub}} +{{language +|exec=bytecode +|site=http://www.gentee.com/ +|tags=gentee, Gentee +}} +{{language programming paradigm|procedural}} +The Gentee programming language can be classified as a [[:Category:Programming paradigm/Procedural|procedure-oriented]] language with some features typical of [[object-oriented]] programming. It has no complicated constructions and is easy to use, but at the same time it is a powerful tool for solving all kinds of tasks. The syntax of the language is based on the syntax of [[C]] and it has a lot in common with other C-like languages like [[C++]], [[Java]], [[C sharp|C#]]. Gentee has the same numeric types int, uint, byte, ubyte, long, double, float, ... and can perform the same operations with them +, ==, <, >, -, /, +=, ++, --, /=,... as in other similar programming languages. When you write programs, you can use all basic constructions that you come across in other languages. For instance, such as while, if, for, with, foreach, switch, include . \ No newline at end of file diff --git a/Lang/Genyris/0DESCRIPTION b/Lang/Genyris/0DESCRIPTION new file mode 100644 index 0000000000..cfa8c135f6 --- /dev/null +++ b/Lang/Genyris/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|Genyris +|site=http://sourceforge.net/projects/genyris/}} +A new language inspired by the Semantic Web. Based on [[Scheme]], different because it is +* Fully [[Object-oriented]] +* Objects may be members of multiple classes +* Classes are assigned and re-assigned to objects after construction +* Indentation syntax reduces parentheses. +{{language programming paradigm|object-oriented}} \ No newline at end of file diff --git a/Lang/Genyris/Abstract-type b/Lang/Genyris/Abstract-type new file mode 120000 index 0000000000..f79f5fa100 --- /dev/null +++ b/Lang/Genyris/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Genyris \ No newline at end of file diff --git a/Lang/Genyris/Ackermann-function b/Lang/Genyris/Ackermann-function new file mode 120000 index 0000000000..fb1b83ced2 --- /dev/null +++ b/Lang/Genyris/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Genyris \ No newline at end of file diff --git a/Lang/Genyris/Dynamic-variable-names b/Lang/Genyris/Dynamic-variable-names new file mode 120000 index 0000000000..56d984cc69 --- /dev/null +++ b/Lang/Genyris/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Genyris \ No newline at end of file diff --git a/Lang/Genyris/Factorial b/Lang/Genyris/Factorial new file mode 120000 index 0000000000..998d3be7f8 --- /dev/null +++ b/Lang/Genyris/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Genyris \ No newline at end of file diff --git a/Lang/Genyris/Greatest-common-divisor b/Lang/Genyris/Greatest-common-divisor new file mode 120000 index 0000000000..9c9a9b2eeb --- /dev/null +++ b/Lang/Genyris/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Genyris \ No newline at end of file diff --git a/Lang/Glee/0DESCRIPTION b/Lang/Glee/0DESCRIPTION new file mode 100644 index 0000000000..635dd6bd5b --- /dev/null +++ b/Lang/Glee/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|Glee +|site=http://withglee.com/ +}} +Glee is an experimental array programming language that attempts to deliver stronger string/text manipulation capabilities than those currently offered in languages such as [[APL]], [[J]], and [[K]], while maintaining their capabilities at manipulating numeric data. + +Glee is targeted at applications where scripting languages such as [[Perl]] and [[Python]] are currently the first choice. The designer of Glee expects that it will be able to carve a niche for itself thanks to Glee's vector processing capabilities, as all the competitors are scalar language.[[#Citation|[1]]] + +==Citation== +#[http://www.fact-archive.com/encyclopedia/Glee_programming_language Glee programming language at Fact-Archive.com] \ No newline at end of file diff --git a/Lang/Glee/Hello-world-Text b/Lang/Glee/Hello-world-Text new file mode 120000 index 0000000000..5278ccc894 --- /dev/null +++ b/Lang/Glee/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Glee \ No newline at end of file diff --git a/Lang/Gnuplot/0DESCRIPTION b/Lang/Gnuplot/0DESCRIPTION new file mode 100644 index 0000000000..264a1193f9 --- /dev/null +++ b/Lang/Gnuplot/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language|gnuplot}}"Gnuplot is a portable command-line driven interactive data and function plotting utility for [[UNIX]], [[IBM]] [[OS/2]], MS [[Windows]], [[DOS]], [[Macintosh]], VMS, Atari and many other platforms." — [http://gnuplot.info/] + +Gnuplot is not associated with the GNU Project. \ No newline at end of file diff --git a/Lang/Go/24-game-Solve b/Lang/Go/24-game-Solve new file mode 120000 index 0000000000..1098a50ac5 --- /dev/null +++ b/Lang/Go/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Go \ No newline at end of file diff --git a/Lang/Go/Arbitrary-precision-integers-included b/Lang/Go/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..d4f44f5c8f --- /dev/null +++ b/Lang/Go/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Go \ No newline at end of file diff --git a/Lang/Go/Factorial b/Lang/Go/Factorial new file mode 120000 index 0000000000..b4bc764269 --- /dev/null +++ b/Lang/Go/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Go \ No newline at end of file diff --git a/Lang/Go/Factors-of-a-Mersenne-number b/Lang/Go/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..542eb8b208 --- /dev/null +++ b/Lang/Go/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Go \ No newline at end of file diff --git a/Lang/Go/Factors-of-an-integer b/Lang/Go/Factors-of-an-integer new file mode 120000 index 0000000000..0a48bded42 --- /dev/null +++ b/Lang/Go/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Go \ No newline at end of file diff --git a/Lang/Go/Fast-Fourier-transform b/Lang/Go/Fast-Fourier-transform new file mode 120000 index 0000000000..f6da073b78 --- /dev/null +++ b/Lang/Go/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Go \ No newline at end of file diff --git a/Lang/Go/Fibonacci-n-step-number-sequences b/Lang/Go/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..614167845d --- /dev/null +++ b/Lang/Go/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Go \ No newline at end of file diff --git a/Lang/Go/Fibonacci-sequence b/Lang/Go/Fibonacci-sequence new file mode 120000 index 0000000000..0b40e84b38 --- /dev/null +++ b/Lang/Go/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Go \ No newline at end of file diff --git a/Lang/Go/File-IO b/Lang/Go/File-IO new file mode 120000 index 0000000000..d8c3c8d610 --- /dev/null +++ b/Lang/Go/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Go \ No newline at end of file diff --git a/Lang/Go/File-modification-time b/Lang/Go/File-modification-time new file mode 120000 index 0000000000..de88affa69 --- /dev/null +++ b/Lang/Go/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Go \ No newline at end of file diff --git a/Lang/Go/File-size b/Lang/Go/File-size new file mode 120000 index 0000000000..19085b6821 --- /dev/null +++ b/Lang/Go/File-size @@ -0,0 +1 @@ +../../Task/File-size/Go \ No newline at end of file diff --git a/Lang/Go/Filter b/Lang/Go/Filter new file mode 120000 index 0000000000..8f1804a6ea --- /dev/null +++ b/Lang/Go/Filter @@ -0,0 +1 @@ +../../Task/Filter/Go \ No newline at end of file diff --git a/Lang/Go/Find-common-directory-path b/Lang/Go/Find-common-directory-path new file mode 120000 index 0000000000..6761b46428 --- /dev/null +++ b/Lang/Go/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Go \ No newline at end of file diff --git a/Lang/Go/Find-limit-of-recursion b/Lang/Go/Find-limit-of-recursion new file mode 120000 index 0000000000..b3eab30712 --- /dev/null +++ b/Lang/Go/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Go \ No newline at end of file diff --git a/Lang/Go/Find-the-missing-permutation b/Lang/Go/Find-the-missing-permutation new file mode 120000 index 0000000000..29690165e9 --- /dev/null +++ b/Lang/Go/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Go \ No newline at end of file diff --git a/Lang/Go/First-class-functions b/Lang/Go/First-class-functions new file mode 120000 index 0000000000..c25659d23f --- /dev/null +++ b/Lang/Go/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Go \ No newline at end of file diff --git a/Lang/Go/First-class-functions-Use-numbers-analogously b/Lang/Go/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..02f4c258f8 --- /dev/null +++ b/Lang/Go/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Go \ No newline at end of file diff --git a/Lang/Go/Five-weekends b/Lang/Go/Five-weekends new file mode 120000 index 0000000000..c473195f4d --- /dev/null +++ b/Lang/Go/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Go \ No newline at end of file diff --git a/Lang/Go/Flatten-a-list b/Lang/Go/Flatten-a-list new file mode 120000 index 0000000000..28373aa5af --- /dev/null +++ b/Lang/Go/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Go \ No newline at end of file diff --git a/Lang/Go/Flow-control-structures b/Lang/Go/Flow-control-structures new file mode 120000 index 0000000000..d535fea2b5 --- /dev/null +++ b/Lang/Go/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Go \ No newline at end of file diff --git a/Lang/Go/Floyds-triangle b/Lang/Go/Floyds-triangle new file mode 120000 index 0000000000..fab59b2e2b --- /dev/null +++ b/Lang/Go/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Go \ No newline at end of file diff --git a/Lang/Go/Fork b/Lang/Go/Fork new file mode 120000 index 0000000000..ca7984b257 --- /dev/null +++ b/Lang/Go/Fork @@ -0,0 +1 @@ +../../Task/Fork/Go \ No newline at end of file diff --git a/Lang/Go/Formal-power-series b/Lang/Go/Formal-power-series new file mode 120000 index 0000000000..8a8f1208db --- /dev/null +++ b/Lang/Go/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Go \ No newline at end of file diff --git a/Lang/Go/Formatted-numeric-output b/Lang/Go/Formatted-numeric-output new file mode 120000 index 0000000000..489a6c1d80 --- /dev/null +++ b/Lang/Go/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Go \ No newline at end of file diff --git a/Lang/Go/Forward-difference b/Lang/Go/Forward-difference new file mode 120000 index 0000000000..f9838085d9 --- /dev/null +++ b/Lang/Go/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Go \ No newline at end of file diff --git a/Lang/Go/Four-bit-adder b/Lang/Go/Four-bit-adder new file mode 120000 index 0000000000..9eba8215bb --- /dev/null +++ b/Lang/Go/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Go \ No newline at end of file diff --git a/Lang/Go/Fractal-tree b/Lang/Go/Fractal-tree new file mode 120000 index 0000000000..1eaa16902e --- /dev/null +++ b/Lang/Go/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Go \ No newline at end of file diff --git a/Lang/Go/Function-composition b/Lang/Go/Function-composition new file mode 120000 index 0000000000..009bbe99da --- /dev/null +++ b/Lang/Go/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Go \ No newline at end of file diff --git a/Lang/Go/Function-definition b/Lang/Go/Function-definition new file mode 120000 index 0000000000..2ec2111956 --- /dev/null +++ b/Lang/Go/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Go \ No newline at end of file diff --git a/Lang/Go/Function-frequency b/Lang/Go/Function-frequency new file mode 120000 index 0000000000..4119a6e939 --- /dev/null +++ b/Lang/Go/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/Go \ No newline at end of file diff --git a/Lang/Go/Gamma-function b/Lang/Go/Gamma-function new file mode 120000 index 0000000000..15df75213e --- /dev/null +++ b/Lang/Go/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Go \ No newline at end of file diff --git a/Lang/Go/Generator-Exponential b/Lang/Go/Generator-Exponential new file mode 120000 index 0000000000..02b8c0fdc5 --- /dev/null +++ b/Lang/Go/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Go \ No newline at end of file diff --git a/Lang/Go/Generic-swap b/Lang/Go/Generic-swap new file mode 120000 index 0000000000..b142a279d4 --- /dev/null +++ b/Lang/Go/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Go \ No newline at end of file diff --git a/Lang/Go/Globally-replace-text-in-several-files b/Lang/Go/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..39b9c0ccaf --- /dev/null +++ b/Lang/Go/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Go \ No newline at end of file diff --git a/Lang/Go/Gray-code b/Lang/Go/Gray-code new file mode 120000 index 0000000000..c0a7c0114d --- /dev/null +++ b/Lang/Go/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Go \ No newline at end of file diff --git a/Lang/Go/Grayscale-image b/Lang/Go/Grayscale-image new file mode 120000 index 0000000000..a8766f242a --- /dev/null +++ b/Lang/Go/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Go \ No newline at end of file diff --git a/Lang/Go/Greatest-common-divisor b/Lang/Go/Greatest-common-divisor new file mode 120000 index 0000000000..6f19599bd3 --- /dev/null +++ b/Lang/Go/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Go \ No newline at end of file diff --git a/Lang/Go/Greatest-element-of-a-list b/Lang/Go/Greatest-element-of-a-list new file mode 120000 index 0000000000..227cd40498 --- /dev/null +++ b/Lang/Go/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Go \ No newline at end of file diff --git a/Lang/Go/Greatest-subsequential-sum b/Lang/Go/Greatest-subsequential-sum new file mode 120000 index 0000000000..5255211f31 --- /dev/null +++ b/Lang/Go/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Go \ No newline at end of file diff --git a/Lang/Go/Guess-the-number b/Lang/Go/Guess-the-number new file mode 120000 index 0000000000..201c9c7d60 --- /dev/null +++ b/Lang/Go/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Go \ No newline at end of file diff --git a/Lang/Go/Guess-the-number-With-feedback b/Lang/Go/Guess-the-number-With-feedback new file mode 120000 index 0000000000..6e9e607f56 --- /dev/null +++ b/Lang/Go/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Go \ No newline at end of file diff --git a/Lang/Go/Guess-the-number-With-feedback-player b/Lang/Go/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..a1dc313ac4 --- /dev/null +++ b/Lang/Go/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Go \ No newline at end of file diff --git a/Lang/Go/HTTP b/Lang/Go/HTTP new file mode 120000 index 0000000000..cf9f9ae708 --- /dev/null +++ b/Lang/Go/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Go \ No newline at end of file diff --git a/Lang/Go/HTTPS b/Lang/Go/HTTPS new file mode 120000 index 0000000000..d252740a6f --- /dev/null +++ b/Lang/Go/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Go \ No newline at end of file diff --git a/Lang/Go/HTTPS-Authenticated b/Lang/Go/HTTPS-Authenticated new file mode 120000 index 0000000000..1599bee29a --- /dev/null +++ b/Lang/Go/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Go \ No newline at end of file diff --git a/Lang/Go/Hailstone-sequence b/Lang/Go/Hailstone-sequence new file mode 120000 index 0000000000..95fb323a6b --- /dev/null +++ b/Lang/Go/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Hamming-numbers b/Lang/Go/Hamming-numbers new file mode 120000 index 0000000000..726e3dbfb9 --- /dev/null +++ b/Lang/Go/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Handle-a-signal b/Lang/Go/Handle-a-signal new file mode 120000 index 0000000000..364d1dc81e --- /dev/null +++ b/Lang/Go/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Go \ No newline at end of file diff --git a/Lang/Go/Happy-numbers b/Lang/Go/Happy-numbers new file mode 120000 index 0000000000..1a6d7ecce2 --- /dev/null +++ b/Lang/Go/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Hash-from-two-arrays b/Lang/Go/Hash-from-two-arrays new file mode 120000 index 0000000000..c79471798b --- /dev/null +++ b/Lang/Go/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Go \ No newline at end of file diff --git a/Lang/Go/Haversine-formula b/Lang/Go/Haversine-formula new file mode 120000 index 0000000000..1ba9b9be62 --- /dev/null +++ b/Lang/Go/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Graphical b/Lang/Go/Hello-world-Graphical new file mode 120000 index 0000000000..54ca1ee706 --- /dev/null +++ b/Lang/Go/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Line-printer b/Lang/Go/Hello-world-Line-printer new file mode 120000 index 0000000000..f0659a714f --- /dev/null +++ b/Lang/Go/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Newline-omission b/Lang/Go/Hello-world-Newline-omission new file mode 120000 index 0000000000..a788dd5b57 --- /dev/null +++ b/Lang/Go/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Standard-error b/Lang/Go/Hello-world-Standard-error new file mode 120000 index 0000000000..b09be58093 --- /dev/null +++ b/Lang/Go/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Text b/Lang/Go/Hello-world-Text new file mode 120000 index 0000000000..5d4ee9d8f0 --- /dev/null +++ b/Lang/Go/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Go \ No newline at end of file diff --git a/Lang/Go/Hello-world-Web-server b/Lang/Go/Hello-world-Web-server new file mode 120000 index 0000000000..f7bfbea1ef --- /dev/null +++ b/Lang/Go/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Go \ No newline at end of file diff --git a/Lang/Go/Here-document b/Lang/Go/Here-document new file mode 120000 index 0000000000..79236c5951 --- /dev/null +++ b/Lang/Go/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Go \ No newline at end of file diff --git a/Lang/Go/Higher-order-functions b/Lang/Go/Higher-order-functions new file mode 120000 index 0000000000..62afed797d --- /dev/null +++ b/Lang/Go/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Go \ No newline at end of file diff --git a/Lang/Go/History-variables b/Lang/Go/History-variables new file mode 120000 index 0000000000..9500d6af3a --- /dev/null +++ b/Lang/Go/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Go \ No newline at end of file diff --git a/Lang/Go/Hofstadter-Conway-$10,000-sequence b/Lang/Go/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..794fb3edc7 --- /dev/null +++ b/Lang/Go/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Hofstadter-Figure-Figure-sequences b/Lang/Go/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..1b722243a3 --- /dev/null +++ b/Lang/Go/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Go \ No newline at end of file diff --git a/Lang/Go/Hofstadter-Q-sequence b/Lang/Go/Hofstadter-Q-sequence new file mode 120000 index 0000000000..4f21b708c9 --- /dev/null +++ b/Lang/Go/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Holidays-related-to-Easter b/Lang/Go/Holidays-related-to-Easter new file mode 120000 index 0000000000..2e6b6aa216 --- /dev/null +++ b/Lang/Go/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Go \ No newline at end of file diff --git a/Lang/Go/Horizontal-sundial-calculations b/Lang/Go/Horizontal-sundial-calculations new file mode 120000 index 0000000000..464c2e0e4e --- /dev/null +++ b/Lang/Go/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Go \ No newline at end of file diff --git a/Lang/Go/Horners-rule-for-polynomial-evaluation b/Lang/Go/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..dc28eb9763 --- /dev/null +++ b/Lang/Go/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Go \ No newline at end of file diff --git a/Lang/Go/Host-introspection b/Lang/Go/Host-introspection new file mode 120000 index 0000000000..781b60b60c --- /dev/null +++ b/Lang/Go/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Go \ No newline at end of file diff --git a/Lang/Go/Hostname b/Lang/Go/Hostname new file mode 120000 index 0000000000..ed9ce08033 --- /dev/null +++ b/Lang/Go/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Go \ No newline at end of file diff --git a/Lang/Go/Hough-transform b/Lang/Go/Hough-transform new file mode 120000 index 0000000000..2910f940cb --- /dev/null +++ b/Lang/Go/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/Go \ No newline at end of file diff --git a/Lang/Go/Huffman-coding b/Lang/Go/Huffman-coding new file mode 120000 index 0000000000..8b809dcf6b --- /dev/null +++ b/Lang/Go/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Go \ No newline at end of file diff --git a/Lang/Go/Identity-matrix b/Lang/Go/Identity-matrix new file mode 120000 index 0000000000..26d8ba3870 --- /dev/null +++ b/Lang/Go/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Go \ No newline at end of file diff --git a/Lang/Go/Image-convolution b/Lang/Go/Image-convolution new file mode 120000 index 0000000000..5ca256bca3 --- /dev/null +++ b/Lang/Go/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Go \ No newline at end of file diff --git a/Lang/Go/Image-noise b/Lang/Go/Image-noise new file mode 120000 index 0000000000..c4925d8ee6 --- /dev/null +++ b/Lang/Go/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Go \ No newline at end of file diff --git a/Lang/Go/Increment-a-numerical-string b/Lang/Go/Increment-a-numerical-string new file mode 120000 index 0000000000..07a1066466 --- /dev/null +++ b/Lang/Go/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Go \ No newline at end of file diff --git a/Lang/Go/Inheritance-Multiple b/Lang/Go/Inheritance-Multiple new file mode 120000 index 0000000000..be4a15b8f2 --- /dev/null +++ b/Lang/Go/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Go \ No newline at end of file diff --git a/Lang/Go/Inheritance-Single b/Lang/Go/Inheritance-Single new file mode 120000 index 0000000000..12a22253a7 --- /dev/null +++ b/Lang/Go/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Go \ No newline at end of file diff --git a/Lang/Go/Input-loop b/Lang/Go/Input-loop new file mode 120000 index 0000000000..ad37924828 --- /dev/null +++ b/Lang/Go/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Go \ No newline at end of file diff --git a/Lang/Go/Integer-comparison b/Lang/Go/Integer-comparison new file mode 120000 index 0000000000..17263d5fa5 --- /dev/null +++ b/Lang/Go/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Go \ No newline at end of file diff --git a/Lang/Go/Integer-sequence b/Lang/Go/Integer-sequence new file mode 120000 index 0000000000..e780596209 --- /dev/null +++ b/Lang/Go/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Interactive-programming b/Lang/Go/Interactive-programming new file mode 120000 index 0000000000..efb5f39796 --- /dev/null +++ b/Lang/Go/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Go \ No newline at end of file diff --git a/Lang/Go/Introspection b/Lang/Go/Introspection new file mode 120000 index 0000000000..940489a93a --- /dev/null +++ b/Lang/Go/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Go \ No newline at end of file diff --git a/Lang/Go/Inverted-index b/Lang/Go/Inverted-index new file mode 120000 index 0000000000..72992a650a --- /dev/null +++ b/Lang/Go/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Go \ No newline at end of file diff --git a/Lang/Go/Josephus-problem b/Lang/Go/Josephus-problem new file mode 120000 index 0000000000..096a180f49 --- /dev/null +++ b/Lang/Go/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Go \ No newline at end of file diff --git a/Lang/Go/K-means++-clustering b/Lang/Go/K-means++-clustering new file mode 120000 index 0000000000..c4b9b778d6 --- /dev/null +++ b/Lang/Go/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/Go \ No newline at end of file diff --git a/Lang/Go/Kaprekar-numbers b/Lang/Go/Kaprekar-numbers new file mode 120000 index 0000000000..1877d2f97a --- /dev/null +++ b/Lang/Go/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Knapsack-problem-0-1 b/Lang/Go/Knapsack-problem-0-1 new file mode 120000 index 0000000000..048d26d9d9 --- /dev/null +++ b/Lang/Go/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Go \ No newline at end of file diff --git a/Lang/Go/Knapsack-problem-Bounded b/Lang/Go/Knapsack-problem-Bounded new file mode 120000 index 0000000000..27fc44e00e --- /dev/null +++ b/Lang/Go/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Go \ No newline at end of file diff --git a/Lang/Go/Knapsack-problem-Continuous b/Lang/Go/Knapsack-problem-Continuous new file mode 120000 index 0000000000..c9dec1e735 --- /dev/null +++ b/Lang/Go/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Go \ No newline at end of file diff --git a/Lang/Go/Knapsack-problem-Unbounded b/Lang/Go/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..64a8b8cbba --- /dev/null +++ b/Lang/Go/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Go \ No newline at end of file diff --git a/Lang/Go/Knights-tour b/Lang/Go/Knights-tour new file mode 120000 index 0000000000..998bcd698c --- /dev/null +++ b/Lang/Go/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Go \ No newline at end of file diff --git a/Lang/Go/Knuths-algorithm-S b/Lang/Go/Knuths-algorithm-S new file mode 120000 index 0000000000..897df32874 --- /dev/null +++ b/Lang/Go/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Go \ No newline at end of file diff --git a/Lang/Go/LU-decomposition b/Lang/Go/LU-decomposition new file mode 120000 index 0000000000..98062fc93a --- /dev/null +++ b/Lang/Go/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Go \ No newline at end of file diff --git a/Lang/Go/LZW-compression b/Lang/Go/LZW-compression new file mode 120000 index 0000000000..48aeebb7a3 --- /dev/null +++ b/Lang/Go/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Go \ No newline at end of file diff --git a/Lang/Go/Langtons-ant b/Lang/Go/Langtons-ant new file mode 120000 index 0000000000..a15145c86b --- /dev/null +++ b/Lang/Go/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Go \ No newline at end of file diff --git a/Lang/Go/Last-Friday-of-each-month b/Lang/Go/Last-Friday-of-each-month new file mode 120000 index 0000000000..7933fa3578 --- /dev/null +++ b/Lang/Go/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Go \ No newline at end of file diff --git a/Lang/Go/Last-letter-first-letter b/Lang/Go/Last-letter-first-letter new file mode 120000 index 0000000000..f8685c04e6 --- /dev/null +++ b/Lang/Go/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Go \ No newline at end of file diff --git a/Lang/Go/Leap-year b/Lang/Go/Leap-year new file mode 120000 index 0000000000..5e0e31a24d --- /dev/null +++ b/Lang/Go/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Go \ No newline at end of file diff --git a/Lang/Go/Least-common-multiple b/Lang/Go/Least-common-multiple new file mode 120000 index 0000000000..14fed17b82 --- /dev/null +++ b/Lang/Go/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Go \ No newline at end of file diff --git a/Lang/Go/Letter-frequency b/Lang/Go/Letter-frequency new file mode 120000 index 0000000000..d20f2902d3 --- /dev/null +++ b/Lang/Go/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Go \ No newline at end of file diff --git a/Lang/Go/Levenshtein-distance b/Lang/Go/Levenshtein-distance new file mode 120000 index 0000000000..a4be3857bf --- /dev/null +++ b/Lang/Go/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Go \ No newline at end of file diff --git a/Lang/Go/Linear-congruential-generator b/Lang/Go/Linear-congruential-generator new file mode 120000 index 0000000000..6de0c60d61 --- /dev/null +++ b/Lang/Go/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Go \ No newline at end of file diff --git a/Lang/Go/Literals-Integer b/Lang/Go/Literals-Integer new file mode 120000 index 0000000000..85fe51bf16 --- /dev/null +++ b/Lang/Go/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Go \ No newline at end of file diff --git a/Lang/Go/Literals-String b/Lang/Go/Literals-String new file mode 120000 index 0000000000..19b380a439 --- /dev/null +++ b/Lang/Go/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Go \ No newline at end of file diff --git a/Lang/Go/Logical-operations b/Lang/Go/Logical-operations new file mode 120000 index 0000000000..e977aafe01 --- /dev/null +++ b/Lang/Go/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Go \ No newline at end of file diff --git a/Lang/Go/Long-multiplication b/Lang/Go/Long-multiplication new file mode 120000 index 0000000000..f26c0c5166 --- /dev/null +++ b/Lang/Go/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Go \ No newline at end of file diff --git a/Lang/Go/Longest-common-subsequence b/Lang/Go/Longest-common-subsequence new file mode 120000 index 0000000000..8c60d738ea --- /dev/null +++ b/Lang/Go/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Go \ No newline at end of file diff --git a/Lang/Go/Longest-string-challenge b/Lang/Go/Longest-string-challenge new file mode 120000 index 0000000000..96ba9af282 --- /dev/null +++ b/Lang/Go/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Go \ No newline at end of file diff --git a/Lang/Go/Look-and-say-sequence b/Lang/Go/Look-and-say-sequence new file mode 120000 index 0000000000..45b615a235 --- /dev/null +++ b/Lang/Go/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Loop-over-multiple-arrays-simultaneously b/Lang/Go/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..9fbea6aed0 --- /dev/null +++ b/Lang/Go/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Break b/Lang/Go/Loops-Break new file mode 120000 index 0000000000..a6c8b718a2 --- /dev/null +++ b/Lang/Go/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Continue b/Lang/Go/Loops-Continue new file mode 120000 index 0000000000..3842f7d7b4 --- /dev/null +++ b/Lang/Go/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Do-while b/Lang/Go/Loops-Do-while new file mode 120000 index 0000000000..04035ae60a --- /dev/null +++ b/Lang/Go/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Downward-for b/Lang/Go/Loops-Downward-for new file mode 120000 index 0000000000..4269c9459d --- /dev/null +++ b/Lang/Go/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Go \ No newline at end of file diff --git a/Lang/Go/Loops-For b/Lang/Go/Loops-For new file mode 120000 index 0000000000..cb5389a0b1 --- /dev/null +++ b/Lang/Go/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Go \ No newline at end of file diff --git a/Lang/Go/Loops-For-with-a-specified-step b/Lang/Go/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..8e250eea89 --- /dev/null +++ b/Lang/Go/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Foreach b/Lang/Go/Loops-Foreach new file mode 120000 index 0000000000..d9df048410 --- /dev/null +++ b/Lang/Go/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Infinite b/Lang/Go/Loops-Infinite new file mode 120000 index 0000000000..73f6234528 --- /dev/null +++ b/Lang/Go/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Go \ No newline at end of file diff --git a/Lang/Go/Loops-N-plus-one-half b/Lang/Go/Loops-N-plus-one-half new file mode 120000 index 0000000000..ff8e38c0e0 --- /dev/null +++ b/Lang/Go/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Go \ No newline at end of file diff --git a/Lang/Go/Loops-Nested b/Lang/Go/Loops-Nested new file mode 120000 index 0000000000..2005e88092 --- /dev/null +++ b/Lang/Go/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Go \ No newline at end of file diff --git a/Lang/Go/Loops-While b/Lang/Go/Loops-While new file mode 120000 index 0000000000..b4727dc871 --- /dev/null +++ b/Lang/Go/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Go \ No newline at end of file diff --git a/Lang/Go/Lucas-Lehmer-test b/Lang/Go/Lucas-Lehmer-test new file mode 120000 index 0000000000..9d7812e50a --- /dev/null +++ b/Lang/Go/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Go \ No newline at end of file diff --git a/Lang/Go/Luhn-test-of-credit-card-numbers b/Lang/Go/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..58766c2290 --- /dev/null +++ b/Lang/Go/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Go \ No newline at end of file diff --git a/Lang/Go/MD4 b/Lang/Go/MD4 new file mode 120000 index 0000000000..322107e92c --- /dev/null +++ b/Lang/Go/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Go \ No newline at end of file diff --git a/Lang/Go/MD5 b/Lang/Go/MD5 new file mode 120000 index 0000000000..e5185c1e7a --- /dev/null +++ b/Lang/Go/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Go \ No newline at end of file diff --git a/Lang/Go/MD5-Implementation b/Lang/Go/MD5-Implementation new file mode 120000 index 0000000000..a0b7a1f3d4 --- /dev/null +++ b/Lang/Go/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Go \ No newline at end of file diff --git a/Lang/Go/Mad-Libs b/Lang/Go/Mad-Libs new file mode 120000 index 0000000000..33f7913dfd --- /dev/null +++ b/Lang/Go/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Go \ No newline at end of file diff --git a/Lang/Go/Main-step-of-GOST-28147-89 b/Lang/Go/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..a3f7755d83 --- /dev/null +++ b/Lang/Go/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/Go \ No newline at end of file diff --git a/Lang/Go/Man-or-boy-test b/Lang/Go/Man-or-boy-test new file mode 120000 index 0000000000..63bb3dcdb3 --- /dev/null +++ b/Lang/Go/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Go \ No newline at end of file diff --git a/Lang/Go/Mandelbrot-set b/Lang/Go/Mandelbrot-set new file mode 120000 index 0000000000..bb665709b2 --- /dev/null +++ b/Lang/Go/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Go \ No newline at end of file diff --git a/Lang/Go/Map-range b/Lang/Go/Map-range new file mode 120000 index 0000000000..1a8461a60b --- /dev/null +++ b/Lang/Go/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Go \ No newline at end of file diff --git a/Lang/Go/Matrix-multiplication b/Lang/Go/Matrix-multiplication new file mode 120000 index 0000000000..0e8bea6337 --- /dev/null +++ b/Lang/Go/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Go \ No newline at end of file diff --git a/Lang/Go/Matrix-transposition b/Lang/Go/Matrix-transposition new file mode 120000 index 0000000000..fb38b673b6 --- /dev/null +++ b/Lang/Go/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Go \ No newline at end of file diff --git a/Lang/Go/Maze-generation b/Lang/Go/Maze-generation new file mode 120000 index 0000000000..904ec53169 --- /dev/null +++ b/Lang/Go/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Go \ No newline at end of file diff --git a/Lang/Go/Maze-solving b/Lang/Go/Maze-solving new file mode 120000 index 0000000000..3d9e088ad6 --- /dev/null +++ b/Lang/Go/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Go \ No newline at end of file diff --git a/Lang/Go/Median-filter b/Lang/Go/Median-filter new file mode 120000 index 0000000000..4932ccc5f8 --- /dev/null +++ b/Lang/Go/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Go \ No newline at end of file diff --git a/Lang/Go/Memory-allocation b/Lang/Go/Memory-allocation new file mode 120000 index 0000000000..04bc817a73 --- /dev/null +++ b/Lang/Go/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Go \ No newline at end of file diff --git a/Lang/Go/Memory-layout-of-a-data-structure b/Lang/Go/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..7f23e347ef --- /dev/null +++ b/Lang/Go/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Go \ No newline at end of file diff --git a/Lang/Go/Menu b/Lang/Go/Menu new file mode 120000 index 0000000000..585996b3de --- /dev/null +++ b/Lang/Go/Menu @@ -0,0 +1 @@ +../../Task/Menu/Go \ No newline at end of file diff --git a/Lang/Go/Metered-concurrency b/Lang/Go/Metered-concurrency new file mode 120000 index 0000000000..3109c8ec0f --- /dev/null +++ b/Lang/Go/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Go \ No newline at end of file diff --git a/Lang/Go/Miller-Rabin-primality-test b/Lang/Go/Miller-Rabin-primality-test new file mode 120000 index 0000000000..c9da74462b --- /dev/null +++ b/Lang/Go/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Go \ No newline at end of file diff --git a/Lang/Go/Modular-exponentiation b/Lang/Go/Modular-exponentiation new file mode 120000 index 0000000000..3acbce74da --- /dev/null +++ b/Lang/Go/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Go \ No newline at end of file diff --git a/Lang/Go/Modular-inverse b/Lang/Go/Modular-inverse new file mode 120000 index 0000000000..7b7371e434 --- /dev/null +++ b/Lang/Go/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Go \ No newline at end of file diff --git a/Lang/Go/Monte-Carlo-methods b/Lang/Go/Monte-Carlo-methods new file mode 120000 index 0000000000..b4cb85c05d --- /dev/null +++ b/Lang/Go/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Go \ No newline at end of file diff --git a/Lang/Go/Monty-Hall-problem b/Lang/Go/Monty-Hall-problem new file mode 120000 index 0000000000..d76b7d6513 --- /dev/null +++ b/Lang/Go/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Go \ No newline at end of file diff --git a/Lang/Go/Multifactorial b/Lang/Go/Multifactorial new file mode 120000 index 0000000000..e9e35e6464 --- /dev/null +++ b/Lang/Go/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Go \ No newline at end of file diff --git a/Lang/Go/Multiple-distinct-objects b/Lang/Go/Multiple-distinct-objects new file mode 120000 index 0000000000..1efaeac697 --- /dev/null +++ b/Lang/Go/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Go \ No newline at end of file diff --git a/Lang/Go/Multiple-regression b/Lang/Go/Multiple-regression new file mode 120000 index 0000000000..ac2cc82ee4 --- /dev/null +++ b/Lang/Go/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Go \ No newline at end of file diff --git a/Lang/Go/Multiplication-tables b/Lang/Go/Multiplication-tables new file mode 120000 index 0000000000..426072ca03 --- /dev/null +++ b/Lang/Go/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Go \ No newline at end of file diff --git a/Lang/Go/Multiplicative-order b/Lang/Go/Multiplicative-order new file mode 120000 index 0000000000..4436f30fde --- /dev/null +++ b/Lang/Go/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Go \ No newline at end of file diff --git a/Lang/Go/Multisplit b/Lang/Go/Multisplit new file mode 120000 index 0000000000..77f6664410 --- /dev/null +++ b/Lang/Go/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Go \ No newline at end of file diff --git a/Lang/Go/Mutex b/Lang/Go/Mutex new file mode 120000 index 0000000000..ae1d58ef7b --- /dev/null +++ b/Lang/Go/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Go \ No newline at end of file diff --git a/Lang/Go/Mutual-recursion b/Lang/Go/Mutual-recursion new file mode 120000 index 0000000000..71f90c2a0f --- /dev/null +++ b/Lang/Go/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Go \ No newline at end of file diff --git a/Lang/Golfscript/0DESCRIPTION b/Lang/Golfscript/0DESCRIPTION new file mode 100644 index 0000000000..67be1df4fd --- /dev/null +++ b/Lang/Golfscript/0DESCRIPTION @@ -0,0 +1,5 @@ +{{language|GolfScript +|site=http://www.golfscript.com/golfscript/index.html +}} +{{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 diff --git a/Lang/Golfscript/100-doors b/Lang/Golfscript/100-doors new file mode 120000 index 0000000000..7a75d3f95c --- /dev/null +++ b/Lang/Golfscript/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/99-Bottles-of-Beer b/Lang/Golfscript/99-Bottles-of-Beer new file mode 120000 index 0000000000..000ddc7af6 --- /dev/null +++ b/Lang/Golfscript/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/A+B b/Lang/Golfscript/A+B new file mode 120000 index 0000000000..c8c1dfba3d --- /dev/null +++ b/Lang/Golfscript/A+B @@ -0,0 +1 @@ +../../Task/A+B/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Ackermann-function b/Lang/Golfscript/Ackermann-function new file mode 120000 index 0000000000..1232677539 --- /dev/null +++ b/Lang/Golfscript/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Arbitrary-precision-integers-included b/Lang/Golfscript/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..be39ca4ea0 --- /dev/null +++ b/Lang/Golfscript/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Arrays b/Lang/Golfscript/Arrays new file mode 120000 index 0000000000..273a4614e6 --- /dev/null +++ b/Lang/Golfscript/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Character-codes b/Lang/Golfscript/Character-codes new file mode 120000 index 0000000000..5081c93911 --- /dev/null +++ b/Lang/Golfscript/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Comments b/Lang/Golfscript/Comments new file mode 120000 index 0000000000..13a01b604a --- /dev/null +++ b/Lang/Golfscript/Comments @@ -0,0 +1 @@ +../../Task/Comments/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Evaluate-binomial-coefficients b/Lang/Golfscript/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..bbeab99f17 --- /dev/null +++ b/Lang/Golfscript/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Factorial b/Lang/Golfscript/Factorial new file mode 120000 index 0000000000..36cdb08396 --- /dev/null +++ b/Lang/Golfscript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Function-definition b/Lang/Golfscript/Function-definition new file mode 120000 index 0000000000..e01f2cc46e --- /dev/null +++ b/Lang/Golfscript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Greatest-element-of-a-list b/Lang/Golfscript/Greatest-element-of-a-list new file mode 120000 index 0000000000..cb4d6fdd68 --- /dev/null +++ b/Lang/Golfscript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Hello-world-Text b/Lang/Golfscript/Hello-world-Text new file mode 120000 index 0000000000..4903162ba3 --- /dev/null +++ b/Lang/Golfscript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Increment-a-numerical-string b/Lang/Golfscript/Increment-a-numerical-string new file mode 120000 index 0000000000..c47d9fcb73 --- /dev/null +++ b/Lang/Golfscript/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Loop-over-multiple-arrays-simultaneously b/Lang/Golfscript/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..fc5e07e269 --- /dev/null +++ b/Lang/Golfscript/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Golfscript \ No newline at end of file diff --git a/Lang/Goo/0DESCRIPTION b/Lang/Goo/0DESCRIPTION new file mode 100644 index 0000000000..a5f449ee5a --- /dev/null +++ b/Lang/Goo/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|Goo +|site=http://people.csail.mit.edu/jrb/goo/ +}} + +GOO is a new type-based prefix syntaxed language that is simple, powerful and extensible. GOO is an acronym for Generic Object Orientator. + +==See Also== +* [[wp:Goo_(programming_language)|Wikipedea: Goo]] \ No newline at end of file diff --git a/Lang/Gosu/0DESCRIPTION b/Lang/Gosu/0DESCRIPTION new file mode 100644 index 0000000000..fd83f91c6d --- /dev/null +++ b/Lang/Gosu/0DESCRIPTION @@ -0,0 +1,9 @@ +{{Language +|site=http://gosu-lang.org/ +|checking=static}} +{{Language programming paradigm|imperative}} +{{Language programming paradigm|object-oriented}} +'''Gosu''' is [[runs on vm::JVM]]-based an imperative statically-typed object-oriented programming language that is designed to be expressive, easy-to-read, and reasonably fast. It started in 2002 in company called [http://guidewire.com/ Guidewire] as a internal language and was released in 2010 to the opensource world. + +* [http://lazygosu.org/ LazyGosu.org - nice community tutorial] +* [http://developers.slashdot.org/story/10/11/09/0510258/Gosu-Programming-Language-Released-To-Public Slashdot finds Gosu] \ No newline at end of file diff --git a/Lang/Gosu/100-doors b/Lang/Gosu/100-doors new file mode 120000 index 0000000000..c7b1def06d --- /dev/null +++ b/Lang/Gosu/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Gosu \ No newline at end of file diff --git a/Lang/Gosu/24-game b/Lang/Gosu/24-game new file mode 120000 index 0000000000..0ed3f95405 --- /dev/null +++ b/Lang/Gosu/24-game @@ -0,0 +1 @@ +../../Task/24-game/Gosu \ No newline at end of file diff --git a/Lang/Gosu/24-game-Solve b/Lang/Gosu/24-game-Solve new file mode 120000 index 0000000000..053047720c --- /dev/null +++ b/Lang/Gosu/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Gosu \ No newline at end of file diff --git a/Lang/Gosu/99-Bottles-of-Beer b/Lang/Gosu/99-Bottles-of-Beer new file mode 120000 index 0000000000..5cfb19faf4 --- /dev/null +++ b/Lang/Gosu/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Gosu \ No newline at end of file diff --git a/Lang/Gosu/A+B b/Lang/Gosu/A+B new file mode 120000 index 0000000000..394d22b59f --- /dev/null +++ b/Lang/Gosu/A+B @@ -0,0 +1 @@ +../../Task/A+B/Gosu \ No newline at end of file diff --git a/Lang/Gosu/Array-concatenation b/Lang/Gosu/Array-concatenation new file mode 120000 index 0000000000..6f9a4b9a06 --- /dev/null +++ b/Lang/Gosu/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Gosu \ No newline at end of file diff --git a/Lang/Gosu/FizzBuzz b/Lang/Gosu/FizzBuzz new file mode 120000 index 0000000000..6c6e3f17fd --- /dev/null +++ b/Lang/Gosu/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Gosu \ No newline at end of file diff --git a/Lang/Gosu/Hello-world-Text b/Lang/Gosu/Hello-world-Text new file mode 120000 index 0000000000..302b244ba8 --- /dev/null +++ b/Lang/Gosu/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Gosu \ No newline at end of file diff --git a/Lang/Groovy/0DESCRIPTION b/Lang/Groovy/0DESCRIPTION new file mode 100644 index 0000000000..9f4b9842e2 --- /dev/null +++ b/Lang/Groovy/0DESCRIPTION @@ -0,0 +1,28 @@ +{{language|Groovy +|strength=strong +|safety=safe +|express=implicit +|compat=nominative +|checking=dynamic +|gc=yes +|site=http://groovy.codehaus.org +|LCT=yes}}{{language programming paradigm|Object-oriented}}[[runs on vm::java virtual machine| ]] +'''Groovy''' is an [[object-oriented]] programming language for the [[Java]] platform as an alternative to the Java programming language. It can be viewed as a scripting language for the Java platform, as it has features similar to those of [[Python]], [[Ruby]], [[Perl]], and [[Smalltalk]]. In some contexts, the name JSR 241 is used as an alternate identifier for Groovy. + +'''Groovy''' ... +* is an agile and dynamic language for the [[Java Virtual Machine]] +* builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk +* makes modern programming features available to Java developers with almost-zero learning curve +* supports Domain Specific Languages and other compact syntax so your code becomes easy to read and maintain +* makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL +* increases developer productivity by reducing scaffolding code when developing web, [[GUI]], database, or console applications +* simplifies testing by supporting unit testing and mocking out-of-the-box +* seamlessly integrates with all existing Java objects and libraries +* compiles straight to Java [[bytecode]] so you can use it anywhere you can use Java + + +Useful Groovy links: +* [[wp:Groovy_(programming_language)|Wikipedia]] +* [http://groovy.codehaus.org/Articles Groovy articles] +* [http://www.jcp.org/en/jsr/detail?id=241 JSR 241] +* [http://snipplr.com/all/language/groovy Code Snippet Repository] \ No newline at end of file diff --git a/Lang/Groovy/100-doors b/Lang/Groovy/100-doors new file mode 120000 index 0000000000..fb8fdf417e --- /dev/null +++ b/Lang/Groovy/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Groovy \ No newline at end of file diff --git a/Lang/Groovy/24-game b/Lang/Groovy/24-game new file mode 120000 index 0000000000..c5fa2419ad --- /dev/null +++ b/Lang/Groovy/24-game @@ -0,0 +1 @@ +../../Task/24-game/Groovy \ No newline at end of file diff --git a/Lang/Groovy/99-Bottles-of-Beer b/Lang/Groovy/99-Bottles-of-Beer new file mode 120000 index 0000000000..3e0810a19a --- /dev/null +++ b/Lang/Groovy/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Groovy \ No newline at end of file diff --git a/Lang/Groovy/A+B b/Lang/Groovy/A+B new file mode 120000 index 0000000000..d0d1c11136 --- /dev/null +++ b/Lang/Groovy/A+B @@ -0,0 +1 @@ +../../Task/A+B/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Abstract-type b/Lang/Groovy/Abstract-type new file mode 120000 index 0000000000..96e91c415b --- /dev/null +++ b/Lang/Groovy/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Accumulator-factory b/Lang/Groovy/Accumulator-factory new file mode 120000 index 0000000000..ee9eb9c83c --- /dev/null +++ b/Lang/Groovy/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Ackermann-function b/Lang/Groovy/Ackermann-function new file mode 120000 index 0000000000..4585e19414 --- /dev/null +++ b/Lang/Groovy/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Groovy/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..bac333c5c6 --- /dev/null +++ b/Lang/Groovy/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Align-columns b/Lang/Groovy/Align-columns new file mode 120000 index 0000000000..38ced99e75 --- /dev/null +++ b/Lang/Groovy/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Anonymous-recursion b/Lang/Groovy/Anonymous-recursion new file mode 120000 index 0000000000..3ed69811a7 --- /dev/null +++ b/Lang/Groovy/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Apply-a-callback-to-an-array b/Lang/Groovy/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..e7103fac30 --- /dev/null +++ b/Lang/Groovy/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arbitrary-precision-integers-included b/Lang/Groovy/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..735c25c2a8 --- /dev/null +++ b/Lang/Groovy/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arithmetic-Complex b/Lang/Groovy/Arithmetic-Complex new file mode 120000 index 0000000000..c62ac63bb7 --- /dev/null +++ b/Lang/Groovy/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arithmetic-Integer b/Lang/Groovy/Arithmetic-Integer new file mode 120000 index 0000000000..86c9e9c237 --- /dev/null +++ b/Lang/Groovy/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arithmetic-Rational b/Lang/Groovy/Arithmetic-Rational new file mode 120000 index 0000000000..cb8106967d --- /dev/null +++ b/Lang/Groovy/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arithmetic-evaluation b/Lang/Groovy/Arithmetic-evaluation new file mode 120000 index 0000000000..ba4dd3b541 --- /dev/null +++ b/Lang/Groovy/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Array-concatenation b/Lang/Groovy/Array-concatenation new file mode 120000 index 0000000000..737a0cf74b --- /dev/null +++ b/Lang/Groovy/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arrays b/Lang/Groovy/Arrays new file mode 120000 index 0000000000..70003db503 --- /dev/null +++ b/Lang/Groovy/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Assertions b/Lang/Groovy/Assertions new file mode 120000 index 0000000000..fb89febd1f --- /dev/null +++ b/Lang/Groovy/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Associative-array-Creation b/Lang/Groovy/Associative-array-Creation new file mode 120000 index 0000000000..0393cdbf4d --- /dev/null +++ b/Lang/Groovy/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Associative-array-Iteration b/Lang/Groovy/Associative-array-Iteration new file mode 120000 index 0000000000..267e5e3004 --- /dev/null +++ b/Lang/Groovy/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Atomic-updates b/Lang/Groovy/Atomic-updates new file mode 120000 index 0000000000..9d488b088b --- /dev/null +++ b/Lang/Groovy/Atomic-updates @@ -0,0 +1 @@ +../../Task/Atomic-updates/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Arithmetic-mean b/Lang/Groovy/Averages-Arithmetic-mean new file mode 120000 index 0000000000..a8bd0d95e9 --- /dev/null +++ b/Lang/Groovy/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Median b/Lang/Groovy/Averages-Median new file mode 120000 index 0000000000..eb57616096 --- /dev/null +++ b/Lang/Groovy/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Mode b/Lang/Groovy/Averages-Mode new file mode 120000 index 0000000000..80ee69afc4 --- /dev/null +++ b/Lang/Groovy/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Pythagorean-means b/Lang/Groovy/Averages-Pythagorean-means new file mode 120000 index 0000000000..e74025f54c --- /dev/null +++ b/Lang/Groovy/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Root-mean-square b/Lang/Groovy/Averages-Root-mean-square new file mode 120000 index 0000000000..c7deefb7bc --- /dev/null +++ b/Lang/Groovy/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Averages-Simple-moving-average b/Lang/Groovy/Averages-Simple-moving-average new file mode 120000 index 0000000000..bcdf0732b5 --- /dev/null +++ b/Lang/Groovy/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Balanced-brackets b/Lang/Groovy/Balanced-brackets new file mode 120000 index 0000000000..b55760563a --- /dev/null +++ b/Lang/Groovy/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Best-shuffle b/Lang/Groovy/Best-shuffle new file mode 120000 index 0000000000..563e75f9ce --- /dev/null +++ b/Lang/Groovy/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Binary-search b/Lang/Groovy/Binary-search new file mode 120000 index 0000000000..5c9e213bbe --- /dev/null +++ b/Lang/Groovy/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Bitwise-operations b/Lang/Groovy/Bitwise-operations new file mode 120000 index 0000000000..2295cdf2b5 --- /dev/null +++ b/Lang/Groovy/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Box-the-compass b/Lang/Groovy/Box-the-compass new file mode 120000 index 0000000000..845f57a350 --- /dev/null +++ b/Lang/Groovy/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Groovy \ No newline at end of file diff --git a/Lang/Groovy/CSV-to-HTML-translation b/Lang/Groovy/CSV-to-HTML-translation new file mode 120000 index 0000000000..f4507ff3d7 --- /dev/null +++ b/Lang/Groovy/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Caesar-cipher b/Lang/Groovy/Caesar-cipher new file mode 120000 index 0000000000..4bbe978a91 --- /dev/null +++ b/Lang/Groovy/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Case-sensitivity-of-identifiers b/Lang/Groovy/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..3bd69147e8 --- /dev/null +++ b/Lang/Groovy/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Character-codes b/Lang/Groovy/Character-codes new file mode 120000 index 0000000000..09e11752a3 --- /dev/null +++ b/Lang/Groovy/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Check-that-file-exists b/Lang/Groovy/Check-that-file-exists new file mode 120000 index 0000000000..65ef29e485 --- /dev/null +++ b/Lang/Groovy/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Classes b/Lang/Groovy/Classes new file mode 120000 index 0000000000..df5b878155 --- /dev/null +++ b/Lang/Groovy/Classes @@ -0,0 +1 @@ +../../Task/Classes/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Closest-pair-problem b/Lang/Groovy/Closest-pair-problem new file mode 120000 index 0000000000..790ae22bd1 --- /dev/null +++ b/Lang/Groovy/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Collections b/Lang/Groovy/Collections new file mode 120000 index 0000000000..4081b04423 --- /dev/null +++ b/Lang/Groovy/Collections @@ -0,0 +1 @@ +../../Task/Collections/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Combinations b/Lang/Groovy/Combinations new file mode 120000 index 0000000000..4e201e49cd --- /dev/null +++ b/Lang/Groovy/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Command-line-arguments b/Lang/Groovy/Command-line-arguments new file mode 120000 index 0000000000..2604fb4920 --- /dev/null +++ b/Lang/Groovy/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Compound-data-type b/Lang/Groovy/Compound-data-type new file mode 120000 index 0000000000..bdce0d9961 --- /dev/null +++ b/Lang/Groovy/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Concurrent-computing b/Lang/Groovy/Concurrent-computing new file mode 120000 index 0000000000..ac45135ef9 --- /dev/null +++ b/Lang/Groovy/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Count-in-factors b/Lang/Groovy/Count-in-factors new file mode 120000 index 0000000000..6e6d39b714 --- /dev/null +++ b/Lang/Groovy/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Count-in-octal b/Lang/Groovy/Count-in-octal new file mode 120000 index 0000000000..7f2d3a05cf --- /dev/null +++ b/Lang/Groovy/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Count-occurrences-of-a-substring b/Lang/Groovy/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..8b3d002e8b --- /dev/null +++ b/Lang/Groovy/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Count-the-coins b/Lang/Groovy/Count-the-coins new file mode 120000 index 0000000000..701c9027eb --- /dev/null +++ b/Lang/Groovy/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Create-a-file b/Lang/Groovy/Create-a-file new file mode 120000 index 0000000000..bfcf632355 --- /dev/null +++ b/Lang/Groovy/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Create-a-two-dimensional-array-at-runtime b/Lang/Groovy/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..556bf2de84 --- /dev/null +++ b/Lang/Groovy/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Create-an-HTML-table b/Lang/Groovy/Create-an-HTML-table new file mode 120000 index 0000000000..9b3fdc3426 --- /dev/null +++ b/Lang/Groovy/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Date-format b/Lang/Groovy/Date-format new file mode 120000 index 0000000000..3f7b8bfbf2 --- /dev/null +++ b/Lang/Groovy/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Date-manipulation b/Lang/Groovy/Date-manipulation new file mode 120000 index 0000000000..ce87c48d25 --- /dev/null +++ b/Lang/Groovy/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Day-of-the-week b/Lang/Groovy/Day-of-the-week new file mode 120000 index 0000000000..5270ace7f1 --- /dev/null +++ b/Lang/Groovy/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Detect-division-by-zero b/Lang/Groovy/Detect-division-by-zero new file mode 120000 index 0000000000..717093f13b --- /dev/null +++ b/Lang/Groovy/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Determine-if-a-string-is-numeric b/Lang/Groovy/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..de8e77e40e --- /dev/null +++ b/Lang/Groovy/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Dot-product b/Lang/Groovy/Dot-product new file mode 120000 index 0000000000..8966b5653e --- /dev/null +++ b/Lang/Groovy/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Dynamic-variable-names b/Lang/Groovy/Dynamic-variable-names new file mode 120000 index 0000000000..78d937a4dd --- /dev/null +++ b/Lang/Groovy/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Empty-directory b/Lang/Groovy/Empty-directory new file mode 120000 index 0000000000..f750e2e616 --- /dev/null +++ b/Lang/Groovy/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Empty-program b/Lang/Groovy/Empty-program new file mode 120000 index 0000000000..8d1c7a42ae --- /dev/null +++ b/Lang/Groovy/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Empty-string b/Lang/Groovy/Empty-string new file mode 120000 index 0000000000..6e39f04df3 --- /dev/null +++ b/Lang/Groovy/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Enumerations b/Lang/Groovy/Enumerations new file mode 120000 index 0000000000..93872e653f --- /dev/null +++ b/Lang/Groovy/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Euler-method b/Lang/Groovy/Euler-method new file mode 120000 index 0000000000..dc1705287b --- /dev/null +++ b/Lang/Groovy/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Evaluate-binomial-coefficients b/Lang/Groovy/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..78e38d6cb1 --- /dev/null +++ b/Lang/Groovy/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Even-or-odd b/Lang/Groovy/Even-or-odd new file mode 120000 index 0000000000..efda6510c3 --- /dev/null +++ b/Lang/Groovy/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Extreme-floating-point-values b/Lang/Groovy/Extreme-floating-point-values new file mode 120000 index 0000000000..f39c2f2185 --- /dev/null +++ b/Lang/Groovy/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Factorial b/Lang/Groovy/Factorial new file mode 120000 index 0000000000..9aedf2c9f2 --- /dev/null +++ b/Lang/Groovy/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Factors-of-an-integer b/Lang/Groovy/Factors-of-an-integer new file mode 120000 index 0000000000..e1a693f3d1 --- /dev/null +++ b/Lang/Groovy/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Fibonacci-sequence b/Lang/Groovy/Fibonacci-sequence new file mode 120000 index 0000000000..787bdf43d8 --- /dev/null +++ b/Lang/Groovy/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Groovy \ No newline at end of file diff --git a/Lang/Groovy/File-IO b/Lang/Groovy/File-IO new file mode 120000 index 0000000000..1947155e88 --- /dev/null +++ b/Lang/Groovy/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Groovy \ No newline at end of file diff --git a/Lang/Groovy/File-size b/Lang/Groovy/File-size new file mode 120000 index 0000000000..5f5cdf6875 --- /dev/null +++ b/Lang/Groovy/File-size @@ -0,0 +1 @@ +../../Task/File-size/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Filter b/Lang/Groovy/Filter new file mode 120000 index 0000000000..16abca4155 --- /dev/null +++ b/Lang/Groovy/Filter @@ -0,0 +1 @@ +../../Task/Filter/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Find-common-directory-path b/Lang/Groovy/Find-common-directory-path new file mode 120000 index 0000000000..8c94ea67e0 --- /dev/null +++ b/Lang/Groovy/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Find-limit-of-recursion b/Lang/Groovy/Find-limit-of-recursion new file mode 120000 index 0000000000..28e661ac30 --- /dev/null +++ b/Lang/Groovy/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Find-the-missing-permutation b/Lang/Groovy/Find-the-missing-permutation new file mode 120000 index 0000000000..730a0132a7 --- /dev/null +++ b/Lang/Groovy/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/First-class-functions b/Lang/Groovy/First-class-functions new file mode 120000 index 0000000000..10352d5b45 --- /dev/null +++ b/Lang/Groovy/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/FizzBuzz b/Lang/Groovy/FizzBuzz new file mode 120000 index 0000000000..9e1c90c673 --- /dev/null +++ b/Lang/Groovy/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Flatten-a-list b/Lang/Groovy/Flatten-a-list new file mode 120000 index 0000000000..1e769793d7 --- /dev/null +++ b/Lang/Groovy/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Fork b/Lang/Groovy/Fork new file mode 120000 index 0000000000..07f6acd250 --- /dev/null +++ b/Lang/Groovy/Fork @@ -0,0 +1 @@ +../../Task/Fork/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Formatted-numeric-output b/Lang/Groovy/Formatted-numeric-output new file mode 120000 index 0000000000..d6073e5f90 --- /dev/null +++ b/Lang/Groovy/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Function-composition b/Lang/Groovy/Function-composition new file mode 120000 index 0000000000..8fc7346a83 --- /dev/null +++ b/Lang/Groovy/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Function-definition b/Lang/Groovy/Function-definition new file mode 120000 index 0000000000..8f2dec0d8e --- /dev/null +++ b/Lang/Groovy/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Gamma-function b/Lang/Groovy/Gamma-function new file mode 120000 index 0000000000..731d70b765 --- /dev/null +++ b/Lang/Groovy/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Generic-swap b/Lang/Groovy/Generic-swap new file mode 120000 index 0000000000..2167770176 --- /dev/null +++ b/Lang/Groovy/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Gray-code b/Lang/Groovy/Gray-code new file mode 120000 index 0000000000..1254953600 --- /dev/null +++ b/Lang/Groovy/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Greatest-common-divisor b/Lang/Groovy/Greatest-common-divisor new file mode 120000 index 0000000000..f72741944a --- /dev/null +++ b/Lang/Groovy/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Greatest-element-of-a-list b/Lang/Groovy/Greatest-element-of-a-list new file mode 120000 index 0000000000..a292841fcc --- /dev/null +++ b/Lang/Groovy/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Guess-the-number b/Lang/Groovy/Guess-the-number new file mode 120000 index 0000000000..6a2473f6f2 --- /dev/null +++ b/Lang/Groovy/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Groovy \ No newline at end of file diff --git a/Lang/Groovy/HTTP b/Lang/Groovy/HTTP new file mode 120000 index 0000000000..b4e3624f91 --- /dev/null +++ b/Lang/Groovy/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Groovy \ No newline at end of file diff --git a/Lang/Groovy/HTTPS b/Lang/Groovy/HTTPS new file mode 120000 index 0000000000..4ec4a4d722 --- /dev/null +++ b/Lang/Groovy/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hailstone-sequence b/Lang/Groovy/Hailstone-sequence new file mode 120000 index 0000000000..b69e0e10cc --- /dev/null +++ b/Lang/Groovy/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hash-from-two-arrays b/Lang/Groovy/Hash-from-two-arrays new file mode 120000 index 0000000000..7026ad9d92 --- /dev/null +++ b/Lang/Groovy/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Haversine-formula b/Lang/Groovy/Haversine-formula new file mode 120000 index 0000000000..fbd3d4b1a4 --- /dev/null +++ b/Lang/Groovy/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hello-world-Graphical b/Lang/Groovy/Hello-world-Graphical new file mode 120000 index 0000000000..24af84b780 --- /dev/null +++ b/Lang/Groovy/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hello-world-Line-printer b/Lang/Groovy/Hello-world-Line-printer new file mode 120000 index 0000000000..8f851f81c6 --- /dev/null +++ b/Lang/Groovy/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hello-world-Newline-omission b/Lang/Groovy/Hello-world-Newline-omission new file mode 120000 index 0000000000..3ce7f57495 --- /dev/null +++ b/Lang/Groovy/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hello-world-Standard-error b/Lang/Groovy/Hello-world-Standard-error new file mode 120000 index 0000000000..bab21d5751 --- /dev/null +++ b/Lang/Groovy/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hello-world-Text b/Lang/Groovy/Hello-world-Text new file mode 120000 index 0000000000..6c3dc12d77 --- /dev/null +++ b/Lang/Groovy/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Here-document b/Lang/Groovy/Here-document new file mode 120000 index 0000000000..6e3e672e86 --- /dev/null +++ b/Lang/Groovy/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Higher-order-functions b/Lang/Groovy/Higher-order-functions new file mode 120000 index 0000000000..a30327669f --- /dev/null +++ b/Lang/Groovy/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Horners-rule-for-polynomial-evaluation b/Lang/Groovy/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..cee82048f4 --- /dev/null +++ b/Lang/Groovy/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Host-introspection b/Lang/Groovy/Host-introspection new file mode 120000 index 0000000000..a9625333b8 --- /dev/null +++ b/Lang/Groovy/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Hostname b/Lang/Groovy/Hostname new file mode 120000 index 0000000000..b937166c69 --- /dev/null +++ b/Lang/Groovy/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Identity-matrix b/Lang/Groovy/Identity-matrix new file mode 120000 index 0000000000..fcbbe71869 --- /dev/null +++ b/Lang/Groovy/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Increment-a-numerical-string b/Lang/Groovy/Increment-a-numerical-string new file mode 120000 index 0000000000..aaf7ad72a8 --- /dev/null +++ b/Lang/Groovy/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Infinity b/Lang/Groovy/Infinity new file mode 120000 index 0000000000..c3e9cb0e72 --- /dev/null +++ b/Lang/Groovy/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Inheritance-Single b/Lang/Groovy/Inheritance-Single new file mode 120000 index 0000000000..917c3a2534 --- /dev/null +++ b/Lang/Groovy/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Input-loop b/Lang/Groovy/Input-loop new file mode 120000 index 0000000000..63d7c50f96 --- /dev/null +++ b/Lang/Groovy/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Integer-comparison b/Lang/Groovy/Integer-comparison new file mode 120000 index 0000000000..740b294d0c --- /dev/null +++ b/Lang/Groovy/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Integer-sequence b/Lang/Groovy/Integer-sequence new file mode 120000 index 0000000000..84cfa7f843 --- /dev/null +++ b/Lang/Groovy/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Interactive-programming b/Lang/Groovy/Interactive-programming new file mode 120000 index 0000000000..a3c727a611 --- /dev/null +++ b/Lang/Groovy/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Groovy \ No newline at end of file diff --git a/Lang/Groovy/JSON b/Lang/Groovy/JSON new file mode 120000 index 0000000000..ac448be025 --- /dev/null +++ b/Lang/Groovy/JSON @@ -0,0 +1 @@ +../../Task/JSON/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Knapsack-problem-0-1 b/Lang/Groovy/Knapsack-problem-0-1 new file mode 120000 index 0000000000..86e63031ab --- /dev/null +++ b/Lang/Groovy/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Knapsack-problem-Bounded b/Lang/Groovy/Knapsack-problem-Bounded new file mode 120000 index 0000000000..edd588b42e --- /dev/null +++ b/Lang/Groovy/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Knapsack-problem-Continuous b/Lang/Groovy/Knapsack-problem-Continuous new file mode 120000 index 0000000000..d21b2f88a9 --- /dev/null +++ b/Lang/Groovy/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Knapsack-problem-Unbounded b/Lang/Groovy/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..bd3ff2aad7 --- /dev/null +++ b/Lang/Groovy/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Knuth-shuffle b/Lang/Groovy/Knuth-shuffle new file mode 120000 index 0000000000..e3c4aa1063 --- /dev/null +++ b/Lang/Groovy/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Leap-year b/Lang/Groovy/Leap-year new file mode 120000 index 0000000000..e3a361b71e --- /dev/null +++ b/Lang/Groovy/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Letter-frequency b/Lang/Groovy/Letter-frequency new file mode 120000 index 0000000000..ed9ed96e43 --- /dev/null +++ b/Lang/Groovy/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Levenshtein-distance b/Lang/Groovy/Levenshtein-distance new file mode 120000 index 0000000000..c22afc0ec5 --- /dev/null +++ b/Lang/Groovy/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Literals-Floating-point b/Lang/Groovy/Literals-Floating-point new file mode 120000 index 0000000000..436919c6e4 --- /dev/null +++ b/Lang/Groovy/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Literals-Integer b/Lang/Groovy/Literals-Integer new file mode 120000 index 0000000000..eb4111c872 --- /dev/null +++ b/Lang/Groovy/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Literals-String b/Lang/Groovy/Literals-String new file mode 120000 index 0000000000..6e06a27c8e --- /dev/null +++ b/Lang/Groovy/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Logical-operations b/Lang/Groovy/Logical-operations new file mode 120000 index 0000000000..2a2838fa17 --- /dev/null +++ b/Lang/Groovy/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Long-multiplication b/Lang/Groovy/Long-multiplication new file mode 120000 index 0000000000..77c4e16299 --- /dev/null +++ b/Lang/Groovy/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Longest-string-challenge b/Lang/Groovy/Longest-string-challenge new file mode 120000 index 0000000000..dd3888f7af --- /dev/null +++ b/Lang/Groovy/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Look-and-say-sequence b/Lang/Groovy/Look-and-say-sequence new file mode 120000 index 0000000000..7c832c9c66 --- /dev/null +++ b/Lang/Groovy/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loop-over-multiple-arrays-simultaneously b/Lang/Groovy/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..e725c43ba2 --- /dev/null +++ b/Lang/Groovy/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Break b/Lang/Groovy/Loops-Break new file mode 120000 index 0000000000..e83e496657 --- /dev/null +++ b/Lang/Groovy/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Continue b/Lang/Groovy/Loops-Continue new file mode 120000 index 0000000000..f9f96012ae --- /dev/null +++ b/Lang/Groovy/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Do-while b/Lang/Groovy/Loops-Do-while new file mode 120000 index 0000000000..c13a2d9b8d --- /dev/null +++ b/Lang/Groovy/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Downward-for b/Lang/Groovy/Loops-Downward-for new file mode 120000 index 0000000000..2c142b1133 --- /dev/null +++ b/Lang/Groovy/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-For b/Lang/Groovy/Loops-For new file mode 120000 index 0000000000..926a224476 --- /dev/null +++ b/Lang/Groovy/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-For-with-a-specified-step b/Lang/Groovy/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..a884ab4dd7 --- /dev/null +++ b/Lang/Groovy/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Foreach b/Lang/Groovy/Loops-Foreach new file mode 120000 index 0000000000..8ff25a17f0 --- /dev/null +++ b/Lang/Groovy/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Infinite b/Lang/Groovy/Loops-Infinite new file mode 120000 index 0000000000..0f228d5765 --- /dev/null +++ b/Lang/Groovy/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-N-plus-one-half b/Lang/Groovy/Loops-N-plus-one-half new file mode 120000 index 0000000000..0a4f908450 --- /dev/null +++ b/Lang/Groovy/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-Nested b/Lang/Groovy/Loops-Nested new file mode 120000 index 0000000000..c9c966ecd6 --- /dev/null +++ b/Lang/Groovy/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Loops-While b/Lang/Groovy/Loops-While new file mode 120000 index 0000000000..d489492306 --- /dev/null +++ b/Lang/Groovy/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Luhn-test-of-credit-card-numbers b/Lang/Groovy/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..29cdad9362 --- /dev/null +++ b/Lang/Groovy/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Groovy \ No newline at end of file diff --git a/Lang/Groovy/MD5 b/Lang/Groovy/MD5 new file mode 120000 index 0000000000..4e2ea0f4a6 --- /dev/null +++ b/Lang/Groovy/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Map-range b/Lang/Groovy/Map-range new file mode 120000 index 0000000000..baf885aa41 --- /dev/null +++ b/Lang/Groovy/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Matrix-multiplication b/Lang/Groovy/Matrix-multiplication new file mode 120000 index 0000000000..1f848c3656 --- /dev/null +++ b/Lang/Groovy/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Matrix-transposition b/Lang/Groovy/Matrix-transposition new file mode 120000 index 0000000000..98143afce9 --- /dev/null +++ b/Lang/Groovy/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Mouse-position b/Lang/Groovy/Mouse-position new file mode 120000 index 0000000000..ef5b1b75ed --- /dev/null +++ b/Lang/Groovy/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Multiplication-tables b/Lang/Groovy/Multiplication-tables new file mode 120000 index 0000000000..fdd807f54a --- /dev/null +++ b/Lang/Groovy/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Mutual-recursion b/Lang/Groovy/Mutual-recursion new file mode 120000 index 0000000000..83d1e9eed2 --- /dev/null +++ b/Lang/Groovy/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Ordered-words b/Lang/Groovy/Ordered-words new file mode 120000 index 0000000000..23e5062e42 --- /dev/null +++ b/Lang/Groovy/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Pi b/Lang/Groovy/Pi new file mode 120000 index 0000000000..e64cee7ab9 --- /dev/null +++ b/Lang/Groovy/Pi @@ -0,0 +1 @@ +../../Task/Pi/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Quine b/Lang/Groovy/Quine new file mode 120000 index 0000000000..d1ec77f4aa --- /dev/null +++ b/Lang/Groovy/Quine @@ -0,0 +1 @@ +../../Task/Quine/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Search-a-list b/Lang/Groovy/Search-a-list new file mode 120000 index 0000000000..bc82829286 --- /dev/null +++ b/Lang/Groovy/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Groovy \ No newline at end of file diff --git a/Lang/HLA/0DESCRIPTION b/Lang/HLA/0DESCRIPTION new file mode 100644 index 0000000000..dcd7d7bafe --- /dev/null +++ b/Lang/HLA/0DESCRIPTION @@ -0,0 +1,13 @@ +{{language|HLA +|site=http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/HighLevelAsm/index.html +|exec=machine +|gc=no +|parampass=value +|safety=unsafe +|strength=weak +}} + +High Level Assembler (HLA) is a front-end for several x86 assemblers developed by Randall Hyde. It allows the use of higher-level language constructs to aid both beginners and advanced assembly developers. It fully supports advanced data types and object-oriented assembly language programming. It uses a syntax loosely based on several high-level languages (HLL), such as Pascal, Ada, Modula-2, and C++, to allow the creation of readable assembly language programs, and to allow HLL programmers to learn HLA as rapidly as possible. + +==See Also== +* [[wp:High Level Assembly|Wikipedia: High Level Assembly]] \ No newline at end of file diff --git a/Lang/HLA/Hello-world-Text b/Lang/HLA/Hello-world-Text new file mode 120000 index 0000000000..fb852cd3b8 --- /dev/null +++ b/Lang/HLA/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/HLA \ No newline at end of file diff --git a/Lang/HQ9+/0DESCRIPTION b/Lang/HQ9+/0DESCRIPTION new file mode 100644 index 0000000000..0148cdc443 --- /dev/null +++ b/Lang/HQ9+/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language +|tags=hq9plus +|hopl=no +}}[[Category:Esoteric Languages]] +External description: [http://www.cliff.biffle.org/esoterica/hq9plus.html http://www.cliff.biffle.org/esoterica/hq9plus.html] (broken?) + +External description 2: [[eso:HQ9_Plus]] + +This language is notable in the context of Rosetta Code in that [[RCHQ9+]] is a task for implementing it. + +{{stub}} \ No newline at end of file diff --git a/Lang/HQ9+/99-Bottles-of-Beer b/Lang/HQ9+/99-Bottles-of-Beer new file mode 120000 index 0000000000..af94471f5e --- /dev/null +++ b/Lang/HQ9+/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/HQ9+ \ No newline at end of file diff --git a/Lang/HQ9+/Hello-world-Text b/Lang/HQ9+/Hello-world-Text new file mode 120000 index 0000000000..0501048ca1 --- /dev/null +++ b/Lang/HQ9+/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/HQ9+ \ No newline at end of file diff --git a/Lang/HQ9+/Quine b/Lang/HQ9+/Quine new file mode 120000 index 0000000000..79b808ff26 --- /dev/null +++ b/Lang/HQ9+/Quine @@ -0,0 +1 @@ +../../Task/Quine/HQ9+ \ No newline at end of file diff --git a/Lang/Haskell/24-game-Solve b/Lang/Haskell/24-game-Solve new file mode 120000 index 0000000000..986fe972ca --- /dev/null +++ b/Lang/Haskell/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arbitrary-precision-integers-included b/Lang/Haskell/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..0b8fc3144b --- /dev/null +++ b/Lang/Haskell/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Factorial b/Lang/Haskell/Factorial new file mode 120000 index 0000000000..c6e474fc27 --- /dev/null +++ b/Lang/Haskell/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Factors-of-a-Mersenne-number b/Lang/Haskell/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..9111cd3a57 --- /dev/null +++ b/Lang/Haskell/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Factors-of-an-integer b/Lang/Haskell/Factors-of-an-integer new file mode 120000 index 0000000000..de6c30a882 --- /dev/null +++ b/Lang/Haskell/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Fast-Fourier-transform b/Lang/Haskell/Fast-Fourier-transform new file mode 120000 index 0000000000..ece081b469 --- /dev/null +++ b/Lang/Haskell/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Fibonacci-n-step-number-sequences b/Lang/Haskell/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..e7e60cc3d2 --- /dev/null +++ b/Lang/Haskell/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Fibonacci-sequence b/Lang/Haskell/Fibonacci-sequence new file mode 120000 index 0000000000..2c8c9d6c3a --- /dev/null +++ b/Lang/Haskell/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/File-IO b/Lang/Haskell/File-IO new file mode 120000 index 0000000000..081caec161 --- /dev/null +++ b/Lang/Haskell/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Haskell \ No newline at end of file diff --git a/Lang/Haskell/File-modification-time b/Lang/Haskell/File-modification-time new file mode 120000 index 0000000000..25faab35b1 --- /dev/null +++ b/Lang/Haskell/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Haskell \ No newline at end of file diff --git a/Lang/Haskell/File-size b/Lang/Haskell/File-size new file mode 120000 index 0000000000..7f1402a08a --- /dev/null +++ b/Lang/Haskell/File-size @@ -0,0 +1 @@ +../../Task/File-size/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Filter b/Lang/Haskell/Filter new file mode 120000 index 0000000000..7a25b44fba --- /dev/null +++ b/Lang/Haskell/Filter @@ -0,0 +1 @@ +../../Task/Filter/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Find-common-directory-path b/Lang/Haskell/Find-common-directory-path new file mode 120000 index 0000000000..9742beea2e --- /dev/null +++ b/Lang/Haskell/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/Haskell/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..a67941195e --- /dev/null +++ b/Lang/Haskell/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Find-the-missing-permutation b/Lang/Haskell/Find-the-missing-permutation new file mode 120000 index 0000000000..de13ae7e63 --- /dev/null +++ b/Lang/Haskell/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/First-class-functions b/Lang/Haskell/First-class-functions new file mode 120000 index 0000000000..4de0c23e2b --- /dev/null +++ b/Lang/Haskell/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/First-class-functions-Use-numbers-analogously b/Lang/Haskell/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..bb22869d8b --- /dev/null +++ b/Lang/Haskell/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Five-weekends b/Lang/Haskell/Five-weekends new file mode 120000 index 0000000000..678bec4852 --- /dev/null +++ b/Lang/Haskell/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Flatten-a-list b/Lang/Haskell/Flatten-a-list new file mode 120000 index 0000000000..af280791f6 --- /dev/null +++ b/Lang/Haskell/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Flow-control-structures b/Lang/Haskell/Flow-control-structures new file mode 120000 index 0000000000..e9b63cf48e --- /dev/null +++ b/Lang/Haskell/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Floyds-triangle b/Lang/Haskell/Floyds-triangle new file mode 120000 index 0000000000..5b7cd095d0 --- /dev/null +++ b/Lang/Haskell/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Fork b/Lang/Haskell/Fork new file mode 120000 index 0000000000..76bac36341 --- /dev/null +++ b/Lang/Haskell/Fork @@ -0,0 +1 @@ +../../Task/Fork/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Formal-power-series b/Lang/Haskell/Formal-power-series new file mode 120000 index 0000000000..7784057bb8 --- /dev/null +++ b/Lang/Haskell/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Formatted-numeric-output b/Lang/Haskell/Formatted-numeric-output new file mode 120000 index 0000000000..21d94afa85 --- /dev/null +++ b/Lang/Haskell/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Forward-difference b/Lang/Haskell/Forward-difference new file mode 120000 index 0000000000..20986c62b3 --- /dev/null +++ b/Lang/Haskell/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Four-bit-adder b/Lang/Haskell/Four-bit-adder new file mode 120000 index 0000000000..7773945d60 --- /dev/null +++ b/Lang/Haskell/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Fractal-tree b/Lang/Haskell/Fractal-tree new file mode 120000 index 0000000000..69c9e88c32 --- /dev/null +++ b/Lang/Haskell/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Function-composition b/Lang/Haskell/Function-composition new file mode 120000 index 0000000000..37892fe162 --- /dev/null +++ b/Lang/Haskell/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Function-definition b/Lang/Haskell/Function-definition new file mode 120000 index 0000000000..649c934561 --- /dev/null +++ b/Lang/Haskell/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/GUI-Maximum-window-dimensions b/Lang/Haskell/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..e8b74c12ec --- /dev/null +++ b/Lang/Haskell/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/GUI-component-interaction b/Lang/Haskell/GUI-component-interaction new file mode 120000 index 0000000000..bae05e0eee --- /dev/null +++ b/Lang/Haskell/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Gamma-function b/Lang/Haskell/Gamma-function new file mode 120000 index 0000000000..96ce3d1905 --- /dev/null +++ b/Lang/Haskell/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Generator-Exponential b/Lang/Haskell/Generator-Exponential new file mode 120000 index 0000000000..1fa2ea46b0 --- /dev/null +++ b/Lang/Haskell/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Generic-swap b/Lang/Haskell/Generic-swap new file mode 120000 index 0000000000..f6eae60cc0 --- /dev/null +++ b/Lang/Haskell/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Globally-replace-text-in-several-files b/Lang/Haskell/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..f11a6c23d3 --- /dev/null +++ b/Lang/Haskell/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Gray-code b/Lang/Haskell/Gray-code new file mode 120000 index 0000000000..4f41971144 --- /dev/null +++ b/Lang/Haskell/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Grayscale-image b/Lang/Haskell/Grayscale-image new file mode 120000 index 0000000000..02abfde469 --- /dev/null +++ b/Lang/Haskell/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Greatest-common-divisor b/Lang/Haskell/Greatest-common-divisor new file mode 120000 index 0000000000..3e0b5e3a07 --- /dev/null +++ b/Lang/Haskell/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Greatest-element-of-a-list b/Lang/Haskell/Greatest-element-of-a-list new file mode 120000 index 0000000000..5bae117660 --- /dev/null +++ b/Lang/Haskell/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Greatest-subsequential-sum b/Lang/Haskell/Greatest-subsequential-sum new file mode 120000 index 0000000000..d13ae0a424 --- /dev/null +++ b/Lang/Haskell/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Greyscale-bars-Display b/Lang/Haskell/Greyscale-bars-Display new file mode 120000 index 0000000000..6027cf1db0 --- /dev/null +++ b/Lang/Haskell/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Guess-the-number b/Lang/Haskell/Guess-the-number new file mode 120000 index 0000000000..3851b3995c --- /dev/null +++ b/Lang/Haskell/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Guess-the-number-With-feedback b/Lang/Haskell/Guess-the-number-With-feedback new file mode 120000 index 0000000000..5dfae90c31 --- /dev/null +++ b/Lang/Haskell/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Haskell \ No newline at end of file diff --git a/Lang/Haskell/HTTP b/Lang/Haskell/HTTP new file mode 120000 index 0000000000..34e8fa46e3 --- /dev/null +++ b/Lang/Haskell/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Haskell \ No newline at end of file diff --git a/Lang/Haskell/HTTPS b/Lang/Haskell/HTTPS new file mode 120000 index 0000000000..b03652160e --- /dev/null +++ b/Lang/Haskell/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hailstone-sequence b/Lang/Haskell/Hailstone-sequence new file mode 120000 index 0000000000..d849bc27ff --- /dev/null +++ b/Lang/Haskell/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hamming-numbers b/Lang/Haskell/Hamming-numbers new file mode 120000 index 0000000000..bdf7510f57 --- /dev/null +++ b/Lang/Haskell/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Handle-a-signal b/Lang/Haskell/Handle-a-signal new file mode 120000 index 0000000000..9a78c65a3e --- /dev/null +++ b/Lang/Haskell/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Happy-numbers b/Lang/Haskell/Happy-numbers new file mode 120000 index 0000000000..bf1437419c --- /dev/null +++ b/Lang/Haskell/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Harshad-or-Niven-series b/Lang/Haskell/Harshad-or-Niven-series new file mode 120000 index 0000000000..a4594257ed --- /dev/null +++ b/Lang/Haskell/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hash-from-two-arrays b/Lang/Haskell/Hash-from-two-arrays new file mode 120000 index 0000000000..ffac159b40 --- /dev/null +++ b/Lang/Haskell/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Haversine-formula b/Lang/Haskell/Haversine-formula new file mode 120000 index 0000000000..02b79fcf53 --- /dev/null +++ b/Lang/Haskell/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Graphical b/Lang/Haskell/Hello-world-Graphical new file mode 120000 index 0000000000..c51770d300 --- /dev/null +++ b/Lang/Haskell/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Line-printer b/Lang/Haskell/Hello-world-Line-printer new file mode 120000 index 0000000000..8a86d25880 --- /dev/null +++ b/Lang/Haskell/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Newline-omission b/Lang/Haskell/Hello-world-Newline-omission new file mode 120000 index 0000000000..1dc5e84b6e --- /dev/null +++ b/Lang/Haskell/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Standard-error b/Lang/Haskell/Hello-world-Standard-error new file mode 120000 index 0000000000..014edfc18a --- /dev/null +++ b/Lang/Haskell/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Text b/Lang/Haskell/Hello-world-Text new file mode 120000 index 0000000000..2faf390aa1 --- /dev/null +++ b/Lang/Haskell/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hello-world-Web-server b/Lang/Haskell/Hello-world-Web-server new file mode 120000 index 0000000000..49ba2c08f0 --- /dev/null +++ b/Lang/Haskell/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Higher-order-functions b/Lang/Haskell/Higher-order-functions new file mode 120000 index 0000000000..2bbf9bb692 --- /dev/null +++ b/Lang/Haskell/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/History-variables b/Lang/Haskell/History-variables new file mode 120000 index 0000000000..2d24c662c7 --- /dev/null +++ b/Lang/Haskell/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hofstadter-Conway-$10,000-sequence b/Lang/Haskell/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..cd36547dea --- /dev/null +++ b/Lang/Haskell/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hofstadter-Figure-Figure-sequences b/Lang/Haskell/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..86abd361ac --- /dev/null +++ b/Lang/Haskell/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hofstadter-Q-sequence b/Lang/Haskell/Hofstadter-Q-sequence new file mode 120000 index 0000000000..62174bc948 --- /dev/null +++ b/Lang/Haskell/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Horizontal-sundial-calculations b/Lang/Haskell/Horizontal-sundial-calculations new file mode 120000 index 0000000000..fa0baf4855 --- /dev/null +++ b/Lang/Haskell/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Horners-rule-for-polynomial-evaluation b/Lang/Haskell/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..46154d3e18 --- /dev/null +++ b/Lang/Haskell/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Host-introspection b/Lang/Haskell/Host-introspection new file mode 120000 index 0000000000..f65f17f272 --- /dev/null +++ b/Lang/Haskell/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Hostname b/Lang/Haskell/Hostname new file mode 120000 index 0000000000..02758ef4e5 --- /dev/null +++ b/Lang/Haskell/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Huffman-coding b/Lang/Haskell/Huffman-coding new file mode 120000 index 0000000000..0a445f1f72 --- /dev/null +++ b/Lang/Haskell/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Identity-matrix b/Lang/Haskell/Identity-matrix new file mode 120000 index 0000000000..1717e75894 --- /dev/null +++ b/Lang/Haskell/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Include-a-file b/Lang/Haskell/Include-a-file new file mode 120000 index 0000000000..cea4c59a27 --- /dev/null +++ b/Lang/Haskell/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Increment-a-numerical-string b/Lang/Haskell/Increment-a-numerical-string new file mode 120000 index 0000000000..6f35d7265e --- /dev/null +++ b/Lang/Haskell/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Inheritance-Multiple b/Lang/Haskell/Inheritance-Multiple new file mode 120000 index 0000000000..0c01461935 --- /dev/null +++ b/Lang/Haskell/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Inheritance-Single b/Lang/Haskell/Inheritance-Single new file mode 120000 index 0000000000..5e8ff4f769 --- /dev/null +++ b/Lang/Haskell/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Input-loop b/Lang/Haskell/Input-loop new file mode 120000 index 0000000000..73103f0678 --- /dev/null +++ b/Lang/Haskell/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Integer-comparison b/Lang/Haskell/Integer-comparison new file mode 120000 index 0000000000..d0888fca16 --- /dev/null +++ b/Lang/Haskell/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Integer-sequence b/Lang/Haskell/Integer-sequence new file mode 120000 index 0000000000..e414b249f1 --- /dev/null +++ b/Lang/Haskell/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Interactive-programming b/Lang/Haskell/Interactive-programming new file mode 120000 index 0000000000..8575cf7ceb --- /dev/null +++ b/Lang/Haskell/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Introspection b/Lang/Haskell/Introspection new file mode 120000 index 0000000000..3b7f0e09dd --- /dev/null +++ b/Lang/Haskell/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Inverted-index b/Lang/Haskell/Inverted-index new file mode 120000 index 0000000000..e82be7f6ce --- /dev/null +++ b/Lang/Haskell/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Inverted-syntax b/Lang/Haskell/Inverted-syntax new file mode 120000 index 0000000000..8242aa297d --- /dev/null +++ b/Lang/Haskell/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Jensens-Device b/Lang/Haskell/Jensens-Device new file mode 120000 index 0000000000..a94cf00a38 --- /dev/null +++ b/Lang/Haskell/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Kaprekar-numbers b/Lang/Haskell/Kaprekar-numbers new file mode 120000 index 0000000000..e06558cc7d --- /dev/null +++ b/Lang/Haskell/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Haskell/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..497da746db --- /dev/null +++ b/Lang/Haskell/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Knapsack-problem-0-1 b/Lang/Haskell/Knapsack-problem-0-1 new file mode 120000 index 0000000000..dbb0192cbd --- /dev/null +++ b/Lang/Haskell/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Knapsack-problem-Bounded b/Lang/Haskell/Knapsack-problem-Bounded new file mode 120000 index 0000000000..4c391517ce --- /dev/null +++ b/Lang/Haskell/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Knapsack-problem-Continuous b/Lang/Haskell/Knapsack-problem-Continuous new file mode 120000 index 0000000000..ab4252a788 --- /dev/null +++ b/Lang/Haskell/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Knapsack-problem-Unbounded b/Lang/Haskell/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..3c3079d52f --- /dev/null +++ b/Lang/Haskell/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Knights-tour b/Lang/Haskell/Knights-tour new file mode 120000 index 0000000000..8b17ec952a --- /dev/null +++ b/Lang/Haskell/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Haskell \ No newline at end of file diff --git a/Lang/Haskell/LZW-compression b/Lang/Haskell/LZW-compression new file mode 120000 index 0000000000..1212f0f19a --- /dev/null +++ b/Lang/Haskell/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Langtons-ant b/Lang/Haskell/Langtons-ant new file mode 120000 index 0000000000..6a4366216b --- /dev/null +++ b/Lang/Haskell/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Largest-int-from-concatenated-ints b/Lang/Haskell/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..9b43c66fbf --- /dev/null +++ b/Lang/Haskell/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Last-letter-first-letter b/Lang/Haskell/Last-letter-first-letter new file mode 120000 index 0000000000..28334f4ae7 --- /dev/null +++ b/Lang/Haskell/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Leap-year b/Lang/Haskell/Leap-year new file mode 120000 index 0000000000..cae5583456 --- /dev/null +++ b/Lang/Haskell/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Least-common-multiple b/Lang/Haskell/Least-common-multiple new file mode 120000 index 0000000000..051d0ad911 --- /dev/null +++ b/Lang/Haskell/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Letter-frequency b/Lang/Haskell/Letter-frequency new file mode 120000 index 0000000000..0d6497cec4 --- /dev/null +++ b/Lang/Haskell/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Levenshtein-distance b/Lang/Haskell/Levenshtein-distance new file mode 120000 index 0000000000..918d4db9ec --- /dev/null +++ b/Lang/Haskell/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Linear-congruential-generator b/Lang/Haskell/Linear-congruential-generator new file mode 120000 index 0000000000..34daac7acc --- /dev/null +++ b/Lang/Haskell/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Haskell \ No newline at end of file diff --git a/Lang/Haskell/List-comprehensions b/Lang/Haskell/List-comprehensions new file mode 120000 index 0000000000..949e85a9c3 --- /dev/null +++ b/Lang/Haskell/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Literals-Floating-point b/Lang/Haskell/Literals-Floating-point new file mode 120000 index 0000000000..9b67c83948 --- /dev/null +++ b/Lang/Haskell/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Literals-Integer b/Lang/Haskell/Literals-Integer new file mode 120000 index 0000000000..fddbc7c783 --- /dev/null +++ b/Lang/Haskell/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Literals-String b/Lang/Haskell/Literals-String new file mode 120000 index 0000000000..5f6f363802 --- /dev/null +++ b/Lang/Haskell/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Logical-operations b/Lang/Haskell/Logical-operations new file mode 120000 index 0000000000..0d45f35b2c --- /dev/null +++ b/Lang/Haskell/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Long-multiplication b/Lang/Haskell/Long-multiplication new file mode 120000 index 0000000000..c3a8d7c837 --- /dev/null +++ b/Lang/Haskell/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Longest-common-subsequence b/Lang/Haskell/Longest-common-subsequence new file mode 120000 index 0000000000..52262c4c11 --- /dev/null +++ b/Lang/Haskell/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Look-and-say-sequence b/Lang/Haskell/Look-and-say-sequence new file mode 120000 index 0000000000..f4a5a8a499 --- /dev/null +++ b/Lang/Haskell/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loop-over-multiple-arrays-simultaneously b/Lang/Haskell/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..1b22614161 --- /dev/null +++ b/Lang/Haskell/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Break b/Lang/Haskell/Loops-Break new file mode 120000 index 0000000000..6d83d8ceac --- /dev/null +++ b/Lang/Haskell/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Continue b/Lang/Haskell/Loops-Continue new file mode 120000 index 0000000000..aaef94bde1 --- /dev/null +++ b/Lang/Haskell/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Do-while b/Lang/Haskell/Loops-Do-while new file mode 120000 index 0000000000..1048a34ddb --- /dev/null +++ b/Lang/Haskell/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Downward-for b/Lang/Haskell/Loops-Downward-for new file mode 120000 index 0000000000..49d105c82e --- /dev/null +++ b/Lang/Haskell/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-For b/Lang/Haskell/Loops-For new file mode 120000 index 0000000000..74b6fe74a0 --- /dev/null +++ b/Lang/Haskell/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-For-with-a-specified-step b/Lang/Haskell/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..cd22e35bd9 --- /dev/null +++ b/Lang/Haskell/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Foreach b/Lang/Haskell/Loops-Foreach new file mode 120000 index 0000000000..bb1fd5ce27 --- /dev/null +++ b/Lang/Haskell/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Infinite b/Lang/Haskell/Loops-Infinite new file mode 120000 index 0000000000..7152643e82 --- /dev/null +++ b/Lang/Haskell/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-N-plus-one-half b/Lang/Haskell/Loops-N-plus-one-half new file mode 120000 index 0000000000..d17fb8f566 --- /dev/null +++ b/Lang/Haskell/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-Nested b/Lang/Haskell/Loops-Nested new file mode 120000 index 0000000000..859abb8f05 --- /dev/null +++ b/Lang/Haskell/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Loops-While b/Lang/Haskell/Loops-While new file mode 120000 index 0000000000..d1339498d7 --- /dev/null +++ b/Lang/Haskell/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Lucas-Lehmer-test b/Lang/Haskell/Lucas-Lehmer-test new file mode 120000 index 0000000000..4b405deef7 --- /dev/null +++ b/Lang/Haskell/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Luhn-test-of-credit-card-numbers b/Lang/Haskell/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..266140f148 --- /dev/null +++ b/Lang/Haskell/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/MD5 b/Lang/Haskell/MD5 new file mode 120000 index 0000000000..fff486783a --- /dev/null +++ b/Lang/Haskell/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Man-or-boy-test b/Lang/Haskell/Man-or-boy-test new file mode 120000 index 0000000000..37f9abb121 --- /dev/null +++ b/Lang/Haskell/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Mandelbrot-set b/Lang/Haskell/Mandelbrot-set new file mode 120000 index 0000000000..f925915de0 --- /dev/null +++ b/Lang/Haskell/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Map-range b/Lang/Haskell/Map-range new file mode 120000 index 0000000000..f67e34d827 --- /dev/null +++ b/Lang/Haskell/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Matrix-exponentiation-operator b/Lang/Haskell/Matrix-exponentiation-operator new file mode 120000 index 0000000000..7adb11712e --- /dev/null +++ b/Lang/Haskell/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Matrix-multiplication b/Lang/Haskell/Matrix-multiplication new file mode 120000 index 0000000000..e0dc28f5d9 --- /dev/null +++ b/Lang/Haskell/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Matrix-transposition b/Lang/Haskell/Matrix-transposition new file mode 120000 index 0000000000..bc8a7be452 --- /dev/null +++ b/Lang/Haskell/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Maze-generation b/Lang/Haskell/Maze-generation new file mode 120000 index 0000000000..a655e9853a --- /dev/null +++ b/Lang/Haskell/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Maze-solving b/Lang/Haskell/Maze-solving new file mode 120000 index 0000000000..5c227ca446 --- /dev/null +++ b/Lang/Haskell/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Memory-allocation b/Lang/Haskell/Memory-allocation new file mode 120000 index 0000000000..3a55f28b16 --- /dev/null +++ b/Lang/Haskell/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Menu b/Lang/Haskell/Menu new file mode 120000 index 0000000000..74dfb81e14 --- /dev/null +++ b/Lang/Haskell/Menu @@ -0,0 +1 @@ +../../Task/Menu/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Metered-concurrency b/Lang/Haskell/Metered-concurrency new file mode 120000 index 0000000000..96b4159aa6 --- /dev/null +++ b/Lang/Haskell/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Metronome b/Lang/Haskell/Metronome new file mode 120000 index 0000000000..6422a9f23a --- /dev/null +++ b/Lang/Haskell/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Middle-three-digits b/Lang/Haskell/Middle-three-digits new file mode 120000 index 0000000000..4041ee1ff9 --- /dev/null +++ b/Lang/Haskell/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Miller-Rabin-primality-test b/Lang/Haskell/Miller-Rabin-primality-test new file mode 120000 index 0000000000..c41f1ba06c --- /dev/null +++ b/Lang/Haskell/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Modular-exponentiation b/Lang/Haskell/Modular-exponentiation new file mode 120000 index 0000000000..23d6b032bb --- /dev/null +++ b/Lang/Haskell/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Modular-inverse b/Lang/Haskell/Modular-inverse new file mode 120000 index 0000000000..fa8e7af5a4 --- /dev/null +++ b/Lang/Haskell/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Monte-Carlo-methods b/Lang/Haskell/Monte-Carlo-methods new file mode 120000 index 0000000000..3379744eec --- /dev/null +++ b/Lang/Haskell/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Monty-Hall-problem b/Lang/Haskell/Monty-Hall-problem new file mode 120000 index 0000000000..53a35d740b --- /dev/null +++ b/Lang/Haskell/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Morse-code b/Lang/Haskell/Morse-code new file mode 120000 index 0000000000..7f8e9cee63 --- /dev/null +++ b/Lang/Haskell/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Multifactorial b/Lang/Haskell/Multifactorial new file mode 120000 index 0000000000..017d1ece48 --- /dev/null +++ b/Lang/Haskell/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Multiple-distinct-objects b/Lang/Haskell/Multiple-distinct-objects new file mode 120000 index 0000000000..f494d56de0 --- /dev/null +++ b/Lang/Haskell/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Multiple-regression b/Lang/Haskell/Multiple-regression new file mode 120000 index 0000000000..9d9ea189a7 --- /dev/null +++ b/Lang/Haskell/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Multiplication-tables b/Lang/Haskell/Multiplication-tables new file mode 120000 index 0000000000..aefbf0cd98 --- /dev/null +++ b/Lang/Haskell/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Multiplicative-order b/Lang/Haskell/Multiplicative-order new file mode 120000 index 0000000000..481be79320 --- /dev/null +++ b/Lang/Haskell/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Mutex b/Lang/Haskell/Mutex new file mode 120000 index 0000000000..da903a20b5 --- /dev/null +++ b/Lang/Haskell/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Mutual-recursion b/Lang/Haskell/Mutual-recursion new file mode 120000 index 0000000000..8d1f951903 --- /dev/null +++ b/Lang/Haskell/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Haskell \ No newline at end of file diff --git a/Lang/Haxe/0DESCRIPTION b/Lang/Haxe/0DESCRIPTION new file mode 100644 index 0000000000..a4c86ecfa3 --- /dev/null +++ b/Lang/Haxe/0DESCRIPTION @@ -0,0 +1,5 @@ +{{Stub}}{{language +|strength=strong +|compat=duck +|site=http://haxe.org}} +'''Haxe''' is a programming language designed for creating interactive web applications. There are several official compiler targets - Adobe Flash, [[JavaScript]], Neko VM, [[PHP]], [[C++]], [[Java]], [[C sharp]]. \ No newline at end of file diff --git a/Lang/Haxe/100-doors b/Lang/Haxe/100-doors new file mode 120000 index 0000000000..1a539ba508 --- /dev/null +++ b/Lang/Haxe/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Haxe \ No newline at end of file diff --git a/Lang/Haxe/99-Bottles-of-Beer b/Lang/Haxe/99-Bottles-of-Beer new file mode 120000 index 0000000000..685212f8ab --- /dev/null +++ b/Lang/Haxe/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Ackermann-function b/Lang/Haxe/Ackermann-function new file mode 120000 index 0000000000..c7668f053e --- /dev/null +++ b/Lang/Haxe/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Arithmetic-Integer b/Lang/Haxe/Arithmetic-Integer new file mode 120000 index 0000000000..2e18298a7f --- /dev/null +++ b/Lang/Haxe/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Comments b/Lang/Haxe/Comments new file mode 120000 index 0000000000..fa92d776e1 --- /dev/null +++ b/Lang/Haxe/Comments @@ -0,0 +1 @@ +../../Task/Comments/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Empty-program b/Lang/Haxe/Empty-program new file mode 120000 index 0000000000..6a688d8844 --- /dev/null +++ b/Lang/Haxe/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Fibonacci-sequence b/Lang/Haxe/Fibonacci-sequence new file mode 120000 index 0000000000..699c26cde8 --- /dev/null +++ b/Lang/Haxe/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Function-definition b/Lang/Haxe/Function-definition new file mode 120000 index 0000000000..f11eb8f7e0 --- /dev/null +++ b/Lang/Haxe/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Inheritance-Single b/Lang/Haxe/Inheritance-Single new file mode 120000 index 0000000000..50764f0025 --- /dev/null +++ b/Lang/Haxe/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Look-and-say-sequence b/Lang/Haxe/Look-and-say-sequence new file mode 120000 index 0000000000..e2c139a439 --- /dev/null +++ b/Lang/Haxe/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Loop-over-multiple-arrays-simultaneously b/Lang/Haxe/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..e1fe4a75c2 --- /dev/null +++ b/Lang/Haxe/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Loops-For b/Lang/Haxe/Loops-For new file mode 120000 index 0000000000..b5d77ffe45 --- /dev/null +++ b/Lang/Haxe/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Loops-Foreach b/Lang/Haxe/Loops-Foreach new file mode 120000 index 0000000000..549fdd22c3 --- /dev/null +++ b/Lang/Haxe/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Haxe \ No newline at end of file diff --git a/Lang/Haxe/Mandelbrot-set b/Lang/Haxe/Mandelbrot-set new file mode 120000 index 0000000000..88a6e9980a --- /dev/null +++ b/Lang/Haxe/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Haxe \ No newline at end of file diff --git a/Lang/Heron/0DESCRIPTION b/Lang/Heron/0DESCRIPTION new file mode 100644 index 0000000000..75f3935fc6 --- /dev/null +++ b/Lang/Heron/0DESCRIPTION @@ -0,0 +1,17 @@ +{{stub}} +{{language +|site=http://www.heron-language.com/ +}} +Heron is a general-purpose object-oriented language, designed by Christopher Diggins, that strives to be appropriate for large scale project development (at least once it is mature). Heron borrows a number of ideas from functional languages, and offers some new twists on object-oriented programming.[[#Citation|[1]]] + +Heron is influenced by the [[C++]], [[Java]] and [[Pascal]] programming languages. Heron has built-in support for object-oriented programming, generic programming, metaprogramming, aspect-oriented programming and design by contract techniques. The Heron language design goals include improving reusability of software and reduction of possibility of programmer error. Heron performance is tuned towards heavily polymorphic object-oriented designs.[[#Citation|[2]]] + +Heron is effectively a combination of programming language and modeling language. It is designed to allow seamless transitioning between textual and diagrammatic representiation of executable UML (xUML) models. Heron is the first programming language designed specifically to support the model-driven architecture (MDA) paradigm.[[#Citation|[3]]] + +Heron has a syntax which resembles [[Java]], [[C#]], [[ECMAScript]], and [[Scala]]. Heron is primarily an object-oriented language, but borrows many ideas from functional languages, and even some from array-oriented languages.[[#Citation|[4]]] + +==Citations== +# [http://www.artima.com/weblogs/viewpost.jsp?thread=284558 (Re-)Introducing the Heron Programming Language] +# [http://www.all-science-fair-projects.com/science_fair_projects_encyclopedia/Heron_programming_language Heron programming language] +# [http://www.heron-language.com/spec.html Heron Language Specification] +# [http://code.google.com/p/heron-language/ heron-language] \ No newline at end of file diff --git a/Lang/HicEst/0DESCRIPTION b/Lang/HicEst/0DESCRIPTION new file mode 100644 index 0000000000..bd1f075e2c --- /dev/null +++ b/Lang/HicEst/0DESCRIPTION @@ -0,0 +1,7 @@ +{{language +|site= http://www.HicEst.com}} +{{IDE}} +HicEst is a [[Windows]] [[IDE]] with editor, interpreter, and incremental compiler.
+It is designed for immediate results.
+Applications are numerics, technic/scientific graphics, and text applications.
+Scripts are in a [[Fortran]] 90 subset-superset. \ No newline at end of file diff --git a/Lang/HicEst/100-doors b/Lang/HicEst/100-doors new file mode 120000 index 0000000000..738cf7fbf7 --- /dev/null +++ b/Lang/HicEst/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/HicEst \ No newline at end of file diff --git a/Lang/HicEst/24-game b/Lang/HicEst/24-game new file mode 120000 index 0000000000..158021b2e3 --- /dev/null +++ b/Lang/HicEst/24-game @@ -0,0 +1 @@ +../../Task/24-game/HicEst \ No newline at end of file diff --git a/Lang/HicEst/99-Bottles-of-Beer b/Lang/HicEst/99-Bottles-of-Beer new file mode 120000 index 0000000000..98968da6c8 --- /dev/null +++ b/Lang/HicEst/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/HicEst \ No newline at end of file diff --git a/Lang/HicEst/A+B b/Lang/HicEst/A+B new file mode 120000 index 0000000000..38714b4739 --- /dev/null +++ b/Lang/HicEst/A+B @@ -0,0 +1 @@ +../../Task/A+B/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Align-columns b/Lang/HicEst/Align-columns new file mode 120000 index 0000000000..05e62a40a3 --- /dev/null +++ b/Lang/HicEst/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Animate-a-pendulum b/Lang/HicEst/Animate-a-pendulum new file mode 120000 index 0000000000..b4ac87fee3 --- /dev/null +++ b/Lang/HicEst/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Animation b/Lang/HicEst/Animation new file mode 120000 index 0000000000..6598725916 --- /dev/null +++ b/Lang/HicEst/Animation @@ -0,0 +1 @@ +../../Task/Animation/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Arithmetic-Integer b/Lang/HicEst/Arithmetic-Integer new file mode 120000 index 0000000000..72faa2c17c --- /dev/null +++ b/Lang/HicEst/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Array-concatenation b/Lang/HicEst/Array-concatenation new file mode 120000 index 0000000000..31f2ca0884 --- /dev/null +++ b/Lang/HicEst/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Arrays b/Lang/HicEst/Arrays new file mode 120000 index 0000000000..3397e07c95 --- /dev/null +++ b/Lang/HicEst/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Averages-Arithmetic-mean b/Lang/HicEst/Averages-Arithmetic-mean new file mode 120000 index 0000000000..de0b7729e5 --- /dev/null +++ b/Lang/HicEst/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Averages-Median b/Lang/HicEst/Averages-Median new file mode 120000 index 0000000000..9ed07e01f4 --- /dev/null +++ b/Lang/HicEst/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Averages-Pythagorean-means b/Lang/HicEst/Averages-Pythagorean-means new file mode 120000 index 0000000000..4e457599a3 --- /dev/null +++ b/Lang/HicEst/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Averages-Root-mean-square b/Lang/HicEst/Averages-Root-mean-square new file mode 120000 index 0000000000..df52de065b --- /dev/null +++ b/Lang/HicEst/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Averages-Simple-moving-average b/Lang/HicEst/Averages-Simple-moving-average new file mode 120000 index 0000000000..b01e368037 --- /dev/null +++ b/Lang/HicEst/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Binary-search b/Lang/HicEst/Binary-search new file mode 120000 index 0000000000..f7c6f82728 --- /dev/null +++ b/Lang/HicEst/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Bitmap-Flood-fill b/Lang/HicEst/Bitmap-Flood-fill new file mode 120000 index 0000000000..f5debe5ef2 --- /dev/null +++ b/Lang/HicEst/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Bitwise-operations b/Lang/HicEst/Bitwise-operations new file mode 120000 index 0000000000..58cbc4a968 --- /dev/null +++ b/Lang/HicEst/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Character-codes b/Lang/HicEst/Character-codes new file mode 120000 index 0000000000..f7d8318602 --- /dev/null +++ b/Lang/HicEst/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Check-that-file-exists b/Lang/HicEst/Check-that-file-exists new file mode 120000 index 0000000000..4ec37a5810 --- /dev/null +++ b/Lang/HicEst/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Command-line-arguments b/Lang/HicEst/Command-line-arguments new file mode 120000 index 0000000000..d2752e1df8 --- /dev/null +++ b/Lang/HicEst/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Comments b/Lang/HicEst/Comments new file mode 120000 index 0000000000..3da03d4086 --- /dev/null +++ b/Lang/HicEst/Comments @@ -0,0 +1 @@ +../../Task/Comments/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Conditional-structures b/Lang/HicEst/Conditional-structures new file mode 120000 index 0000000000..d872b89962 --- /dev/null +++ b/Lang/HicEst/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Create-a-file b/Lang/HicEst/Create-a-file new file mode 120000 index 0000000000..5ecf0d1986 --- /dev/null +++ b/Lang/HicEst/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Create-a-two-dimensional-array-at-runtime b/Lang/HicEst/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..e014021595 --- /dev/null +++ b/Lang/HicEst/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Date-format b/Lang/HicEst/Date-format new file mode 120000 index 0000000000..340a1b40ca --- /dev/null +++ b/Lang/HicEst/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Date-manipulation b/Lang/HicEst/Date-manipulation new file mode 120000 index 0000000000..32358faa62 --- /dev/null +++ b/Lang/HicEst/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Day-of-the-week b/Lang/HicEst/Day-of-the-week new file mode 120000 index 0000000000..b54c1e53aa --- /dev/null +++ b/Lang/HicEst/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Delete-a-file b/Lang/HicEst/Delete-a-file new file mode 120000 index 0000000000..d9d1ab3737 --- /dev/null +++ b/Lang/HicEst/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Detect-division-by-zero b/Lang/HicEst/Detect-division-by-zero new file mode 120000 index 0000000000..76ea539b65 --- /dev/null +++ b/Lang/HicEst/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Determine-if-a-string-is-numeric b/Lang/HicEst/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..34c6014ffb --- /dev/null +++ b/Lang/HicEst/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Empty-program b/Lang/HicEst/Empty-program new file mode 120000 index 0000000000..1d24845caf --- /dev/null +++ b/Lang/HicEst/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Ethiopian-multiplication b/Lang/HicEst/Ethiopian-multiplication new file mode 120000 index 0000000000..ee10e4db59 --- /dev/null +++ b/Lang/HicEst/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Evaluate-binomial-coefficients b/Lang/HicEst/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..52e8b1b0c5 --- /dev/null +++ b/Lang/HicEst/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Execute-a-system-command b/Lang/HicEst/Execute-a-system-command new file mode 120000 index 0000000000..cc32180665 --- /dev/null +++ b/Lang/HicEst/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Exponentiation-operator b/Lang/HicEst/Exponentiation-operator new file mode 120000 index 0000000000..114d75beb1 --- /dev/null +++ b/Lang/HicEst/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Factorial b/Lang/HicEst/Factorial new file mode 120000 index 0000000000..c17ec0d14c --- /dev/null +++ b/Lang/HicEst/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Factors-of-an-integer b/Lang/HicEst/Factors-of-an-integer new file mode 120000 index 0000000000..9092120e58 --- /dev/null +++ b/Lang/HicEst/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Fibonacci-sequence b/Lang/HicEst/Fibonacci-sequence new file mode 120000 index 0000000000..2d01640f33 --- /dev/null +++ b/Lang/HicEst/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/HicEst \ No newline at end of file diff --git a/Lang/HicEst/File-IO b/Lang/HicEst/File-IO new file mode 120000 index 0000000000..15ffb36980 --- /dev/null +++ b/Lang/HicEst/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/HicEst \ No newline at end of file diff --git a/Lang/HicEst/File-modification-time b/Lang/HicEst/File-modification-time new file mode 120000 index 0000000000..6c5e17ffbb --- /dev/null +++ b/Lang/HicEst/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/HicEst \ No newline at end of file diff --git a/Lang/HicEst/File-size b/Lang/HicEst/File-size new file mode 120000 index 0000000000..74de0ce097 --- /dev/null +++ b/Lang/HicEst/File-size @@ -0,0 +1 @@ +../../Task/File-size/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Find-common-directory-path b/Lang/HicEst/Find-common-directory-path new file mode 120000 index 0000000000..677102741c --- /dev/null +++ b/Lang/HicEst/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/HicEst \ No newline at end of file diff --git a/Lang/HicEst/FizzBuzz b/Lang/HicEst/FizzBuzz new file mode 120000 index 0000000000..b369245231 --- /dev/null +++ b/Lang/HicEst/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Flow-control-structures b/Lang/HicEst/Flow-control-structures new file mode 120000 index 0000000000..fb94751505 --- /dev/null +++ b/Lang/HicEst/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Fork b/Lang/HicEst/Fork new file mode 120000 index 0000000000..704333497f --- /dev/null +++ b/Lang/HicEst/Fork @@ -0,0 +1 @@ +../../Task/Fork/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Formatted-numeric-output b/Lang/HicEst/Formatted-numeric-output new file mode 120000 index 0000000000..238ce9aea1 --- /dev/null +++ b/Lang/HicEst/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Forward-difference b/Lang/HicEst/Forward-difference new file mode 120000 index 0000000000..02daf42eb7 --- /dev/null +++ b/Lang/HicEst/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Function-definition b/Lang/HicEst/Function-definition new file mode 120000 index 0000000000..cd5f7b726f --- /dev/null +++ b/Lang/HicEst/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Greatest-common-divisor b/Lang/HicEst/Greatest-common-divisor new file mode 120000 index 0000000000..526c23837c --- /dev/null +++ b/Lang/HicEst/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Greatest-element-of-a-list b/Lang/HicEst/Greatest-element-of-a-list new file mode 120000 index 0000000000..e6df72472e --- /dev/null +++ b/Lang/HicEst/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Hailstone-sequence b/Lang/HicEst/Hailstone-sequence new file mode 120000 index 0000000000..ae7a9bf9b2 --- /dev/null +++ b/Lang/HicEst/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Handle-a-signal b/Lang/HicEst/Handle-a-signal new file mode 120000 index 0000000000..f6dc95843c --- /dev/null +++ b/Lang/HicEst/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Hello-world-Graphical b/Lang/HicEst/Hello-world-Graphical new file mode 120000 index 0000000000..bca185b940 --- /dev/null +++ b/Lang/HicEst/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Hello-world-Text b/Lang/HicEst/Hello-world-Text new file mode 120000 index 0000000000..e27240caa4 --- /dev/null +++ b/Lang/HicEst/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Horners-rule-for-polynomial-evaluation b/Lang/HicEst/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..3a8ead18ae --- /dev/null +++ b/Lang/HicEst/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Increment-a-numerical-string b/Lang/HicEst/Increment-a-numerical-string new file mode 120000 index 0000000000..5a0041b76f --- /dev/null +++ b/Lang/HicEst/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Input-loop b/Lang/HicEst/Input-loop new file mode 120000 index 0000000000..806f5f35e6 --- /dev/null +++ b/Lang/HicEst/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Integer-comparison b/Lang/HicEst/Integer-comparison new file mode 120000 index 0000000000..78d37cacba --- /dev/null +++ b/Lang/HicEst/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Interactive-programming b/Lang/HicEst/Interactive-programming new file mode 120000 index 0000000000..48d1ef3a18 --- /dev/null +++ b/Lang/HicEst/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Keyboard-macros b/Lang/HicEst/Keyboard-macros new file mode 120000 index 0000000000..f072b4603a --- /dev/null +++ b/Lang/HicEst/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Knapsack-problem-Unbounded b/Lang/HicEst/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..a9399a6da7 --- /dev/null +++ b/Lang/HicEst/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Literals-String b/Lang/HicEst/Literals-String new file mode 120000 index 0000000000..cad1c0f9c0 --- /dev/null +++ b/Lang/HicEst/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Logical-operations b/Lang/HicEst/Logical-operations new file mode 120000 index 0000000000..2b41cf4e8a --- /dev/null +++ b/Lang/HicEst/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loop-over-multiple-arrays-simultaneously b/Lang/HicEst/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..1b9d42d7f2 --- /dev/null +++ b/Lang/HicEst/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Break b/Lang/HicEst/Loops-Break new file mode 120000 index 0000000000..b74ea82ce8 --- /dev/null +++ b/Lang/HicEst/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Continue b/Lang/HicEst/Loops-Continue new file mode 120000 index 0000000000..9ccda42af3 --- /dev/null +++ b/Lang/HicEst/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Downward-for b/Lang/HicEst/Loops-Downward-for new file mode 120000 index 0000000000..5bc08a3863 --- /dev/null +++ b/Lang/HicEst/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-For b/Lang/HicEst/Loops-For new file mode 120000 index 0000000000..4a1920ac27 --- /dev/null +++ b/Lang/HicEst/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-For-with-a-specified-step b/Lang/HicEst/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..c563d49edc --- /dev/null +++ b/Lang/HicEst/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Foreach b/Lang/HicEst/Loops-Foreach new file mode 120000 index 0000000000..377f188726 --- /dev/null +++ b/Lang/HicEst/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Infinite b/Lang/HicEst/Loops-Infinite new file mode 120000 index 0000000000..47324834d2 --- /dev/null +++ b/Lang/HicEst/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-N-plus-one-half b/Lang/HicEst/Loops-N-plus-one-half new file mode 120000 index 0000000000..bab9442893 --- /dev/null +++ b/Lang/HicEst/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Loops-Nested b/Lang/HicEst/Loops-Nested new file mode 120000 index 0000000000..2cc18a18bf --- /dev/null +++ b/Lang/HicEst/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Lucas-Lehmer-test b/Lang/HicEst/Lucas-Lehmer-test new file mode 120000 index 0000000000..3dd025731b --- /dev/null +++ b/Lang/HicEst/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Luhn-test-of-credit-card-numbers b/Lang/HicEst/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..1951a82e61 --- /dev/null +++ b/Lang/HicEst/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Matrix-multiplication b/Lang/HicEst/Matrix-multiplication new file mode 120000 index 0000000000..c65b70038c --- /dev/null +++ b/Lang/HicEst/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Matrix-transposition b/Lang/HicEst/Matrix-transposition new file mode 120000 index 0000000000..d7e0f2a872 --- /dev/null +++ b/Lang/HicEst/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Menu b/Lang/HicEst/Menu new file mode 120000 index 0000000000..8411ac9177 --- /dev/null +++ b/Lang/HicEst/Menu @@ -0,0 +1 @@ +../../Task/Menu/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Monte-Carlo-methods b/Lang/HicEst/Monte-Carlo-methods new file mode 120000 index 0000000000..c8c9a1b53c --- /dev/null +++ b/Lang/HicEst/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Monty-Hall-problem b/Lang/HicEst/Monty-Hall-problem new file mode 120000 index 0000000000..6ed4c11a1d --- /dev/null +++ b/Lang/HicEst/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Mouse-position b/Lang/HicEst/Mouse-position new file mode 120000 index 0000000000..3d582bd71d --- /dev/null +++ b/Lang/HicEst/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Multiplication-tables b/Lang/HicEst/Multiplication-tables new file mode 120000 index 0000000000..d3cca400dc --- /dev/null +++ b/Lang/HicEst/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Search-a-list b/Lang/HicEst/Search-a-list new file mode 120000 index 0000000000..ed073d9fcb --- /dev/null +++ b/Lang/HicEst/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/HicEst \ No newline at end of file diff --git a/Lang/Hope/0DESCRIPTION b/Lang/Hope/0DESCRIPTION new file mode 100644 index 0000000000..939b91ecd3 --- /dev/null +++ b/Lang/Hope/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language|Hope +|strength=strong +|safety=safe +|compat=structural +|checking=static +|gc=yes +|bnf=http://www.soi.city.ac.uk/~ross/Hope/}} +{{language programming paradigm|functional}} +'''Hope''' is a purely [[functional programming]] language from 1970s, which predates Miranda and [[Haskell]]. It is the first language with call-by-pattern evaluation and algebraic data types, and its most used interpreter is fully [[lazy evaluation|lazy evaluated]]. + +==Citations== +* [[wp:Hope_%28programming_language%29|Wikipedia:Hope (programming language)]] \ No newline at end of file diff --git a/Lang/Hope/Fibonacci-sequence b/Lang/Hope/Fibonacci-sequence new file mode 120000 index 0000000000..2cde7c0fb8 --- /dev/null +++ b/Lang/Hope/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Hope \ No newline at end of file diff --git a/Lang/Hope/Matrix-transposition b/Lang/Hope/Matrix-transposition new file mode 120000 index 0000000000..93bcff5a36 --- /dev/null +++ b/Lang/Hope/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Hope \ No newline at end of file diff --git a/Lang/HyperTalk/0DESCRIPTION b/Lang/HyperTalk/0DESCRIPTION new file mode 100644 index 0000000000..b05353548d --- /dev/null +++ b/Lang/HyperTalk/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language}} +[[ppr:HyperTalk|HyperTalk]] was the proprietary scripting language from Apple's [[ppr:HyperCard|HyperCard]]. This language is the ancestor of [[AppleScript]]. + +HyperCard and HyperTalk come from the era of the black-and-white Macintosh. HyperTalk scripts are plain text, but embedded inside some stack. A ''HyperCard stack'' is the user interface to a HyperTalk program. Each stack appears in a window and displays one card from the stack. A card might include text, images, hyperlinks to other cards, and interactive buttons. These stacks look obsolete because of the small size of each card, and the black and white graphics. + +HyperCard only works with Mac OS Classic, and Apple stopped selling copies. HyperCard's surviving relatives include [http://www.supercard.us/hypercard/index.html SuperCard] and [http://www.runrev.com/developers/lessons-and-tutorials/moving-to-rev/hypercard/ LiveCode]. \ No newline at end of file diff --git a/Lang/IDL/0DESCRIPTION b/Lang/IDL/0DESCRIPTION new file mode 100644 index 0000000000..0018694f03 --- /dev/null +++ b/Lang/IDL/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language|IDL}}{{stub}} +IDL (Interactive Data Language) is an [[array]] programming language designed by David Stern. +[[wp:IDL_%28programming_language%29|Wikipedia article]] +(free implementation: GDL - GNU Data Language http://gnudatalanguage.sourceforge.net) \ No newline at end of file diff --git a/Lang/IDL/99-Bottles-of-Beer b/Lang/IDL/99-Bottles-of-Beer new file mode 120000 index 0000000000..aa40039116 --- /dev/null +++ b/Lang/IDL/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/IDL \ No newline at end of file diff --git a/Lang/IDL/Apply-a-callback-to-an-array b/Lang/IDL/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..a4a5dd6c7e --- /dev/null +++ b/Lang/IDL/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/IDL \ No newline at end of file diff --git a/Lang/IDL/Arithmetic-Complex b/Lang/IDL/Arithmetic-Complex new file mode 120000 index 0000000000..5e2cfd1b65 --- /dev/null +++ b/Lang/IDL/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/IDL \ No newline at end of file diff --git a/Lang/IDL/Array-concatenation b/Lang/IDL/Array-concatenation new file mode 120000 index 0000000000..aa8be9c9f5 --- /dev/null +++ b/Lang/IDL/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/IDL \ No newline at end of file diff --git a/Lang/IDL/Averages-Arithmetic-mean b/Lang/IDL/Averages-Arithmetic-mean new file mode 120000 index 0000000000..a150682f4f --- /dev/null +++ b/Lang/IDL/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/IDL \ No newline at end of file diff --git a/Lang/IDL/Comments b/Lang/IDL/Comments new file mode 120000 index 0000000000..51a07e63c0 --- /dev/null +++ b/Lang/IDL/Comments @@ -0,0 +1 @@ +../../Task/Comments/IDL \ No newline at end of file diff --git a/Lang/IDL/Compound-data-type b/Lang/IDL/Compound-data-type new file mode 120000 index 0000000000..8450090a9e --- /dev/null +++ b/Lang/IDL/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/IDL \ No newline at end of file diff --git a/Lang/IDL/Conditional-structures b/Lang/IDL/Conditional-structures new file mode 120000 index 0000000000..65b0687a18 --- /dev/null +++ b/Lang/IDL/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/IDL \ No newline at end of file diff --git a/Lang/IDL/Create-a-two-dimensional-array-at-runtime b/Lang/IDL/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..bdf09b8119 --- /dev/null +++ b/Lang/IDL/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/IDL \ No newline at end of file diff --git a/Lang/IDL/Detect-division-by-zero b/Lang/IDL/Detect-division-by-zero new file mode 120000 index 0000000000..af7bbd5476 --- /dev/null +++ b/Lang/IDL/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/IDL \ No newline at end of file diff --git a/Lang/IDL/Determine-if-a-string-is-numeric b/Lang/IDL/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..6630e51b83 --- /dev/null +++ b/Lang/IDL/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/IDL \ No newline at end of file diff --git a/Lang/IDL/Empty-program b/Lang/IDL/Empty-program new file mode 120000 index 0000000000..80e5265b25 --- /dev/null +++ b/Lang/IDL/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/IDL \ No newline at end of file diff --git a/Lang/IDL/Execute-a-system-command b/Lang/IDL/Execute-a-system-command new file mode 120000 index 0000000000..20ad15f076 --- /dev/null +++ b/Lang/IDL/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/IDL \ No newline at end of file diff --git a/Lang/IDL/Factorial b/Lang/IDL/Factorial new file mode 120000 index 0000000000..32c5bc5b53 --- /dev/null +++ b/Lang/IDL/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/IDL \ No newline at end of file diff --git a/Lang/IDL/Fibonacci-sequence b/Lang/IDL/Fibonacci-sequence new file mode 120000 index 0000000000..2f751ab79a --- /dev/null +++ b/Lang/IDL/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/IDL \ No newline at end of file diff --git a/Lang/IDL/File-IO b/Lang/IDL/File-IO new file mode 120000 index 0000000000..1b19879ca3 --- /dev/null +++ b/Lang/IDL/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/IDL \ No newline at end of file diff --git a/Lang/IDL/Filter b/Lang/IDL/Filter new file mode 120000 index 0000000000..57dbcf55c8 --- /dev/null +++ b/Lang/IDL/Filter @@ -0,0 +1 @@ +../../Task/Filter/IDL \ No newline at end of file diff --git a/Lang/IDL/Flow-control-structures b/Lang/IDL/Flow-control-structures new file mode 120000 index 0000000000..8eace9d3f1 --- /dev/null +++ b/Lang/IDL/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/IDL \ No newline at end of file diff --git a/Lang/IDL/Formatted-numeric-output b/Lang/IDL/Formatted-numeric-output new file mode 120000 index 0000000000..e67016d8a8 --- /dev/null +++ b/Lang/IDL/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/IDL \ No newline at end of file diff --git a/Lang/IDL/Forward-difference b/Lang/IDL/Forward-difference new file mode 120000 index 0000000000..003a8b5b48 --- /dev/null +++ b/Lang/IDL/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/IDL \ No newline at end of file diff --git a/Lang/IDL/Function-definition b/Lang/IDL/Function-definition new file mode 120000 index 0000000000..7952cf19eb --- /dev/null +++ b/Lang/IDL/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/IDL \ No newline at end of file diff --git a/Lang/IDL/Generic-swap b/Lang/IDL/Generic-swap new file mode 120000 index 0000000000..483957e112 --- /dev/null +++ b/Lang/IDL/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/IDL \ No newline at end of file diff --git a/Lang/IDL/Hello-world-Text b/Lang/IDL/Hello-world-Text new file mode 120000 index 0000000000..0911f9ab87 --- /dev/null +++ b/Lang/IDL/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/IDL \ No newline at end of file diff --git a/Lang/IDL/Hostname b/Lang/IDL/Hostname new file mode 120000 index 0000000000..f396305067 --- /dev/null +++ b/Lang/IDL/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/IDL \ No newline at end of file diff --git a/Lang/IDL/Increment-a-numerical-string b/Lang/IDL/Increment-a-numerical-string new file mode 120000 index 0000000000..0a9f0e30fb --- /dev/null +++ b/Lang/IDL/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/IDL \ No newline at end of file diff --git a/Lang/IDL/Infinity b/Lang/IDL/Infinity new file mode 120000 index 0000000000..1e8bca9aea --- /dev/null +++ b/Lang/IDL/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/IDL \ No newline at end of file diff --git a/Lang/IDL/Literals-String b/Lang/IDL/Literals-String new file mode 120000 index 0000000000..528ac9b6fa --- /dev/null +++ b/Lang/IDL/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/IDL \ No newline at end of file diff --git a/Lang/IDL/Loops-Downward-for b/Lang/IDL/Loops-Downward-for new file mode 120000 index 0000000000..a410b48033 --- /dev/null +++ b/Lang/IDL/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/IDL \ No newline at end of file diff --git a/Lang/IDL/Loops-Infinite b/Lang/IDL/Loops-Infinite new file mode 120000 index 0000000000..18bb998ad2 --- /dev/null +++ b/Lang/IDL/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/IDL \ No newline at end of file diff --git a/Lang/IDL/Loops-N-plus-one-half b/Lang/IDL/Loops-N-plus-one-half new file mode 120000 index 0000000000..c4284011a9 --- /dev/null +++ b/Lang/IDL/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/IDL \ No newline at end of file diff --git a/Lang/IDL/Mandelbrot-set b/Lang/IDL/Mandelbrot-set new file mode 120000 index 0000000000..410fce7700 --- /dev/null +++ b/Lang/IDL/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/IDL \ No newline at end of file diff --git a/Lang/IDL/Matrix-multiplication b/Lang/IDL/Matrix-multiplication new file mode 120000 index 0000000000..dd86fc3caa --- /dev/null +++ b/Lang/IDL/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/IDL \ No newline at end of file diff --git a/Lang/IDL/Matrix-transposition b/Lang/IDL/Matrix-transposition new file mode 120000 index 0000000000..3707fe3fb6 --- /dev/null +++ b/Lang/IDL/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/IDL \ No newline at end of file diff --git a/Lang/Icon/0DESCRIPTION b/Lang/Icon/0DESCRIPTION new file mode 100644 index 0000000000..e5d20cb8b3 --- /dev/null +++ b/Lang/Icon/0DESCRIPTION @@ -0,0 +1,42 @@ +{{language|Icon +|site=http://www.cs.arizona.edu/icon/index.htm +|exec=bytecode +|parampass=value +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|gc=yes +|LCT=yes +}} +{{virtual machine}} +{{language programming paradigm|Procedural}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|Logic_Programming}} +Icon is a descendant of [[SNOBOL4]] incorporating similar excellent string processing capabilities, built-in hash tables, success/failure based controls, dynamic storage, automatic type casting and coercion of values. Icon added more conventional procedural syntax, generator expressions, goal-directed evaluation that automatically searches for successful results. String scanning and matching superseded the pattern matching functionality of SNOBOL4. + +Several extensions of Icon were developed to improve functionality. Many of these were unified with [[Unicon]] + +==Related/Variants== +* [[Jcon]] +* [[ObjectIcon]] +* [[Unicon]] + +==See Also== +* [[wp:Icon_(programming_language)|Wikipedia: Icon]] +* [http://www.cs.arizona.edu/icon/index.htm Icon homepage] +* [[wp:Unicon_(programming_language)|Wikipedia: Unicon]] +* [http://www.cs.arizona.edu/icon/ftp/doc/lb1up.pdf Book: The Icon Programming Language, 3rd Edition] +* [http://www.cs.arizona.edu/icon/ftp/doc/gb1up.pdf Book: Graphics Programming in Icon] +* [http://www2.cs.uidaho.edu/~jeffery/icon/humanists/humanist.pdf Book: Icon Programming for Humanists] +* [http://www.mitchellsoftwareengineering.com/icon/icon.sli.pdf Presentation: Fundamentals of Icon Programming] +* [http://www.cs.arizona.edu/icon/inl/inl.htm Archived issues of the Icon Newsletter from 1979-2000 discussing Icon programming] +* [http://www.cs.arizona.edu/icon/analyst/ia.htm Archived issues of the Icon Analysts from 1990-2001 discussing advanced Icon programming] +* [http://www.cs.arizona.edu/icon/library/ipl.htm The Icon Programming Library and index] + +== Wiki Links == +* [[Icon%2BUnicon/Intro|An introduction to Icon and Unicon for Rosetta Code]] +* [[:Category:Icon/Omit|Unimplementable tasks]] +* [[:Category:Icon_examples_needing_attention|Tasks requiring attention]] +* [[Reports:Tasks_not_implemented_in_Icon|Tasks not yet implemented]] +* [[:Category:Icon_Programming_Library|The Icon Programming Library]] \ No newline at end of file diff --git a/Lang/Icon/100-doors b/Lang/Icon/100-doors new file mode 120000 index 0000000000..877a6c424d --- /dev/null +++ b/Lang/Icon/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Icon \ No newline at end of file diff --git a/Lang/Icon/24-game b/Lang/Icon/24-game new file mode 120000 index 0000000000..4dec2871fb --- /dev/null +++ b/Lang/Icon/24-game @@ -0,0 +1 @@ +../../Task/24-game/Icon \ No newline at end of file diff --git a/Lang/Icon/99-Bottles-of-Beer b/Lang/Icon/99-Bottles-of-Beer new file mode 120000 index 0000000000..93d2bd9753 --- /dev/null +++ b/Lang/Icon/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Icon \ No newline at end of file diff --git a/Lang/Icon/A+B b/Lang/Icon/A+B new file mode 120000 index 0000000000..81d2c8c1ed --- /dev/null +++ b/Lang/Icon/A+B @@ -0,0 +1 @@ +../../Task/A+B/Icon \ No newline at end of file diff --git a/Lang/Icon/Accumulator-factory b/Lang/Icon/Accumulator-factory new file mode 120000 index 0000000000..6ea9fc6e31 --- /dev/null +++ b/Lang/Icon/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Icon \ No newline at end of file diff --git a/Lang/Icon/Ackermann-function b/Lang/Icon/Ackermann-function new file mode 120000 index 0000000000..a454cf895c --- /dev/null +++ b/Lang/Icon/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Icon \ No newline at end of file diff --git a/Lang/Icon/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Icon/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..5d3a256ba1 --- /dev/null +++ b/Lang/Icon/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Icon \ No newline at end of file diff --git a/Lang/Icon/Align-columns b/Lang/Icon/Align-columns new file mode 120000 index 0000000000..c72f134ac9 --- /dev/null +++ b/Lang/Icon/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Icon \ No newline at end of file diff --git a/Lang/Icon/Anagrams b/Lang/Icon/Anagrams new file mode 120000 index 0000000000..b9dd9e87fd --- /dev/null +++ b/Lang/Icon/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Icon \ No newline at end of file diff --git a/Lang/Icon/Anagrams-Deranged-anagrams b/Lang/Icon/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..a75d716c5d --- /dev/null +++ b/Lang/Icon/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Icon \ No newline at end of file diff --git a/Lang/Icon/Anonymous-recursion b/Lang/Icon/Anonymous-recursion new file mode 120000 index 0000000000..576a17d415 --- /dev/null +++ b/Lang/Icon/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Icon \ No newline at end of file diff --git a/Lang/Icon/Apply-a-callback-to-an-array b/Lang/Icon/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..b8f09f3e8c --- /dev/null +++ b/Lang/Icon/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Icon \ No newline at end of file diff --git a/Lang/Icon/Arbitrary-precision-integers-included b/Lang/Icon/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..8c434fc8d1 --- /dev/null +++ b/Lang/Icon/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Icon \ No newline at end of file diff --git a/Lang/Icon/Arithmetic-Complex b/Lang/Icon/Arithmetic-Complex new file mode 120000 index 0000000000..7d36be5dba --- /dev/null +++ b/Lang/Icon/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Icon \ No newline at end of file diff --git a/Lang/Icon/Arithmetic-Integer b/Lang/Icon/Arithmetic-Integer new file mode 120000 index 0000000000..358afbc8e8 --- /dev/null +++ b/Lang/Icon/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Icon \ No newline at end of file diff --git a/Lang/Icon/Arithmetic-Rational b/Lang/Icon/Arithmetic-Rational new file mode 120000 index 0000000000..66557a8e39 --- /dev/null +++ b/Lang/Icon/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Icon \ No newline at end of file diff --git a/Lang/Icon/Arithmetic-evaluation b/Lang/Icon/Arithmetic-evaluation new file mode 120000 index 0000000000..4aebe64f79 --- /dev/null +++ b/Lang/Icon/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Icon \ No newline at end of file diff --git a/Lang/Icon/Array-concatenation b/Lang/Icon/Array-concatenation new file mode 120000 index 0000000000..7cc6550563 --- /dev/null +++ b/Lang/Icon/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Icon \ No newline at end of file diff --git a/Lang/Icon/Assertions b/Lang/Icon/Assertions new file mode 120000 index 0000000000..bba792e0d1 --- /dev/null +++ b/Lang/Icon/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Icon \ No newline at end of file diff --git a/Lang/Icon/Associative-array-Creation b/Lang/Icon/Associative-array-Creation new file mode 120000 index 0000000000..6e983a08b6 --- /dev/null +++ b/Lang/Icon/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Icon \ No newline at end of file diff --git a/Lang/Icon/Associative-array-Iteration b/Lang/Icon/Associative-array-Iteration new file mode 120000 index 0000000000..1e6c27f52b --- /dev/null +++ b/Lang/Icon/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Icon \ No newline at end of file diff --git a/Lang/Icon/Averages-Arithmetic-mean b/Lang/Icon/Averages-Arithmetic-mean new file mode 120000 index 0000000000..198e13254a --- /dev/null +++ b/Lang/Icon/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Icon \ No newline at end of file diff --git a/Lang/Icon/Averages-Median b/Lang/Icon/Averages-Median new file mode 120000 index 0000000000..d8ca4ef9ac --- /dev/null +++ b/Lang/Icon/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Icon \ No newline at end of file diff --git a/Lang/Icon/Averages-Mode b/Lang/Icon/Averages-Mode new file mode 120000 index 0000000000..344a635c3e --- /dev/null +++ b/Lang/Icon/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Icon \ No newline at end of file diff --git a/Lang/Icon/Averages-Pythagorean-means b/Lang/Icon/Averages-Pythagorean-means new file mode 120000 index 0000000000..1afe152f3d --- /dev/null +++ b/Lang/Icon/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Icon \ No newline at end of file diff --git a/Lang/Icon/Averages-Root-mean-square b/Lang/Icon/Averages-Root-mean-square new file mode 120000 index 0000000000..e9648d8fc1 --- /dev/null +++ b/Lang/Icon/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Icon \ No newline at end of file diff --git a/Lang/Icon/Balanced-brackets b/Lang/Icon/Balanced-brackets new file mode 120000 index 0000000000..2dee475dbf --- /dev/null +++ b/Lang/Icon/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Icon \ No newline at end of file diff --git a/Lang/Icon/Best-shuffle b/Lang/Icon/Best-shuffle new file mode 120000 index 0000000000..f4bf2ba100 --- /dev/null +++ b/Lang/Icon/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Icon \ No newline at end of file diff --git a/Lang/Icon/Binary-search b/Lang/Icon/Binary-search new file mode 120000 index 0000000000..a075ff8ad2 --- /dev/null +++ b/Lang/Icon/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Icon \ No newline at end of file diff --git a/Lang/Icon/Binary-strings b/Lang/Icon/Binary-strings new file mode 120000 index 0000000000..9d35c93988 --- /dev/null +++ b/Lang/Icon/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/Icon \ No newline at end of file diff --git a/Lang/Icon/Bitmap b/Lang/Icon/Bitmap new file mode 120000 index 0000000000..9618fb1ce5 --- /dev/null +++ b/Lang/Icon/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Icon \ No newline at end of file diff --git a/Lang/Icon/Bitwise-operations b/Lang/Icon/Bitwise-operations new file mode 120000 index 0000000000..28cb81d19f --- /dev/null +++ b/Lang/Icon/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Icon \ No newline at end of file diff --git a/Lang/Icon/Box-the-compass b/Lang/Icon/Box-the-compass new file mode 120000 index 0000000000..2360140e3c --- /dev/null +++ b/Lang/Icon/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Icon \ No newline at end of file diff --git a/Lang/Icon/Bulls-and-cows b/Lang/Icon/Bulls-and-cows new file mode 120000 index 0000000000..e1d44cfc73 --- /dev/null +++ b/Lang/Icon/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Icon \ No newline at end of file diff --git a/Lang/Icon/CRC-32 b/Lang/Icon/CRC-32 new file mode 120000 index 0000000000..b5ebdeacb0 --- /dev/null +++ b/Lang/Icon/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Icon \ No newline at end of file diff --git a/Lang/Icon/CSV-to-HTML-translation b/Lang/Icon/CSV-to-HTML-translation new file mode 120000 index 0000000000..c093c35678 --- /dev/null +++ b/Lang/Icon/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Icon \ No newline at end of file diff --git a/Lang/Icon/Caesar-cipher b/Lang/Icon/Caesar-cipher new file mode 120000 index 0000000000..c8fbf8c510 --- /dev/null +++ b/Lang/Icon/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Icon \ No newline at end of file diff --git a/Lang/Icon/Calendar b/Lang/Icon/Calendar new file mode 120000 index 0000000000..b116a28d88 --- /dev/null +++ b/Lang/Icon/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/Icon \ No newline at end of file diff --git a/Lang/Icon/Calendar-for-real-programmers b/Lang/Icon/Calendar-for-real-programmers new file mode 120000 index 0000000000..57f8c378c9 --- /dev/null +++ b/Lang/Icon/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/Icon \ No newline at end of file diff --git a/Lang/Icon/Call-a-function b/Lang/Icon/Call-a-function new file mode 120000 index 0000000000..7f11e4175b --- /dev/null +++ b/Lang/Icon/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Icon \ No newline at end of file diff --git a/Lang/Icon/Case-sensitivity-of-identifiers b/Lang/Icon/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..03bfd7e61d --- /dev/null +++ b/Lang/Icon/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Icon \ No newline at end of file diff --git a/Lang/Icon/Character-codes b/Lang/Icon/Character-codes new file mode 120000 index 0000000000..a00ef2332f --- /dev/null +++ b/Lang/Icon/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Icon \ No newline at end of file diff --git a/Lang/Icon/Check-that-file-exists b/Lang/Icon/Check-that-file-exists new file mode 120000 index 0000000000..2a7daf6f69 --- /dev/null +++ b/Lang/Icon/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Icon \ No newline at end of file diff --git a/Lang/Icon/Cholesky-decomposition b/Lang/Icon/Cholesky-decomposition new file mode 120000 index 0000000000..3bafac6aa8 --- /dev/null +++ b/Lang/Icon/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Icon \ No newline at end of file diff --git a/Lang/Icon/Closest-pair-problem b/Lang/Icon/Closest-pair-problem new file mode 120000 index 0000000000..27bc3c7f89 --- /dev/null +++ b/Lang/Icon/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Icon \ No newline at end of file diff --git a/Lang/Icon/Collections b/Lang/Icon/Collections new file mode 120000 index 0000000000..90cb1bfe8e --- /dev/null +++ b/Lang/Icon/Collections @@ -0,0 +1 @@ +../../Task/Collections/Icon \ No newline at end of file diff --git a/Lang/Icon/Color-of-a-screen-pixel b/Lang/Icon/Color-of-a-screen-pixel new file mode 120000 index 0000000000..690638ee02 --- /dev/null +++ b/Lang/Icon/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/Icon \ No newline at end of file diff --git a/Lang/Icon/Colour-bars-Display b/Lang/Icon/Colour-bars-Display new file mode 120000 index 0000000000..aa7c890230 --- /dev/null +++ b/Lang/Icon/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Icon \ No newline at end of file diff --git a/Lang/Icon/Colour-pinstripe-Display b/Lang/Icon/Colour-pinstripe-Display new file mode 120000 index 0000000000..dd6f783874 --- /dev/null +++ b/Lang/Icon/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/Icon \ No newline at end of file diff --git a/Lang/Icon/Combinations b/Lang/Icon/Combinations new file mode 120000 index 0000000000..af41980c1e --- /dev/null +++ b/Lang/Icon/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Icon \ No newline at end of file diff --git a/Lang/Icon/Combinations-with-repetitions b/Lang/Icon/Combinations-with-repetitions new file mode 120000 index 0000000000..1618d6d287 --- /dev/null +++ b/Lang/Icon/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Icon \ No newline at end of file diff --git a/Lang/Icon/Command-line-arguments b/Lang/Icon/Command-line-arguments new file mode 120000 index 0000000000..b2d3202c8e --- /dev/null +++ b/Lang/Icon/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Icon \ No newline at end of file diff --git a/Lang/Icon/Comments b/Lang/Icon/Comments new file mode 120000 index 0000000000..28aa0f3bc7 --- /dev/null +++ b/Lang/Icon/Comments @@ -0,0 +1 @@ +../../Task/Comments/Icon \ No newline at end of file diff --git a/Lang/Icon/Compound-data-type b/Lang/Icon/Compound-data-type new file mode 120000 index 0000000000..e9c4d69ec2 --- /dev/null +++ b/Lang/Icon/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Icon \ No newline at end of file diff --git a/Lang/Icon/Conditional-structures b/Lang/Icon/Conditional-structures new file mode 120000 index 0000000000..4f59aab3af --- /dev/null +++ b/Lang/Icon/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Icon \ No newline at end of file diff --git a/Lang/Icon/Constrained-random-points-on-a-circle b/Lang/Icon/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..c9db614c88 --- /dev/null +++ b/Lang/Icon/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Icon \ No newline at end of file diff --git a/Lang/Icon/Conways-Game-of-Life b/Lang/Icon/Conways-Game-of-Life new file mode 120000 index 0000000000..adbd1dfd26 --- /dev/null +++ b/Lang/Icon/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Icon \ No newline at end of file diff --git a/Lang/Icon/Count-in-factors b/Lang/Icon/Count-in-factors new file mode 120000 index 0000000000..2c7fbc97bc --- /dev/null +++ b/Lang/Icon/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Icon \ No newline at end of file diff --git a/Lang/Icon/Count-in-octal b/Lang/Icon/Count-in-octal new file mode 120000 index 0000000000..06de942087 --- /dev/null +++ b/Lang/Icon/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Icon \ No newline at end of file diff --git a/Lang/Icon/Count-occurrences-of-a-substring b/Lang/Icon/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..1b53c9e3c9 --- /dev/null +++ b/Lang/Icon/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Icon \ No newline at end of file diff --git a/Lang/Icon/Count-the-coins b/Lang/Icon/Count-the-coins new file mode 120000 index 0000000000..6b470387b5 --- /dev/null +++ b/Lang/Icon/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Icon \ No newline at end of file diff --git a/Lang/Icon/Create-a-file b/Lang/Icon/Create-a-file new file mode 120000 index 0000000000..4b279f8141 --- /dev/null +++ b/Lang/Icon/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Create-a-two-dimensional-array-at-runtime b/Lang/Icon/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..13db75a8f1 --- /dev/null +++ b/Lang/Icon/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Icon \ No newline at end of file diff --git a/Lang/Icon/Create-an-HTML-table b/Lang/Icon/Create-an-HTML-table new file mode 120000 index 0000000000..5b4ab09d9a --- /dev/null +++ b/Lang/Icon/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Icon \ No newline at end of file diff --git a/Lang/Icon/Date-manipulation b/Lang/Icon/Date-manipulation new file mode 120000 index 0000000000..661299227e --- /dev/null +++ b/Lang/Icon/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Icon \ No newline at end of file diff --git a/Lang/Icon/Deal-cards-for-FreeCell b/Lang/Icon/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..cafcc2086a --- /dev/null +++ b/Lang/Icon/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/Icon \ No newline at end of file diff --git a/Lang/Icon/Deepcopy b/Lang/Icon/Deepcopy new file mode 120000 index 0000000000..cc75e804d0 --- /dev/null +++ b/Lang/Icon/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/Icon \ No newline at end of file diff --git a/Lang/Icon/Delete-a-file b/Lang/Icon/Delete-a-file new file mode 120000 index 0000000000..8e89b67ad9 --- /dev/null +++ b/Lang/Icon/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Detect-division-by-zero b/Lang/Icon/Detect-division-by-zero new file mode 120000 index 0000000000..6a0ade7b60 --- /dev/null +++ b/Lang/Icon/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Icon \ No newline at end of file diff --git a/Lang/Icon/Determine-if-a-string-is-numeric b/Lang/Icon/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..6985ffb490 --- /dev/null +++ b/Lang/Icon/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Icon \ No newline at end of file diff --git a/Lang/Icon/Dinesmans-multiple-dwelling-problem b/Lang/Icon/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..1303d45268 --- /dev/null +++ b/Lang/Icon/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Icon \ No newline at end of file diff --git a/Lang/Icon/Discordian-date b/Lang/Icon/Discordian-date new file mode 120000 index 0000000000..bc9132385b --- /dev/null +++ b/Lang/Icon/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Icon \ No newline at end of file diff --git a/Lang/Icon/Dot-product b/Lang/Icon/Dot-product new file mode 120000 index 0000000000..477e857a58 --- /dev/null +++ b/Lang/Icon/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Icon \ No newline at end of file diff --git a/Lang/Icon/Dynamic-variable-names b/Lang/Icon/Dynamic-variable-names new file mode 120000 index 0000000000..59e49f39c6 --- /dev/null +++ b/Lang/Icon/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Icon \ No newline at end of file diff --git a/Lang/Icon/Empty-program b/Lang/Icon/Empty-program new file mode 120000 index 0000000000..29c7962f6e --- /dev/null +++ b/Lang/Icon/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Icon \ No newline at end of file diff --git a/Lang/Icon/Empty-string b/Lang/Icon/Empty-string new file mode 120000 index 0000000000..40b9d00b33 --- /dev/null +++ b/Lang/Icon/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Icon \ No newline at end of file diff --git a/Lang/Icon/Enforced-immutability b/Lang/Icon/Enforced-immutability new file mode 120000 index 0000000000..ba5d06ec1a --- /dev/null +++ b/Lang/Icon/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Icon \ No newline at end of file diff --git a/Lang/Icon/Enumerations b/Lang/Icon/Enumerations new file mode 120000 index 0000000000..8b3ae74a1e --- /dev/null +++ b/Lang/Icon/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Icon \ No newline at end of file diff --git a/Lang/Icon/Equilibrium-index b/Lang/Icon/Equilibrium-index new file mode 120000 index 0000000000..9784a3cade --- /dev/null +++ b/Lang/Icon/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Icon \ No newline at end of file diff --git a/Lang/Icon/Ethiopian-multiplication b/Lang/Icon/Ethiopian-multiplication new file mode 120000 index 0000000000..77649c7876 --- /dev/null +++ b/Lang/Icon/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Icon \ No newline at end of file diff --git a/Lang/Icon/Euler-method b/Lang/Icon/Euler-method new file mode 120000 index 0000000000..45d8798aad --- /dev/null +++ b/Lang/Icon/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Icon \ No newline at end of file diff --git a/Lang/Icon/Evaluate-binomial-coefficients b/Lang/Icon/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..60dc1ddf7b --- /dev/null +++ b/Lang/Icon/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Icon \ No newline at end of file diff --git a/Lang/Icon/Even-or-odd b/Lang/Icon/Even-or-odd new file mode 120000 index 0000000000..f77088f4bb --- /dev/null +++ b/Lang/Icon/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Icon \ No newline at end of file diff --git a/Lang/Icon/Evolutionary-algorithm b/Lang/Icon/Evolutionary-algorithm new file mode 120000 index 0000000000..2a52c331d8 --- /dev/null +++ b/Lang/Icon/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Icon \ No newline at end of file diff --git a/Lang/Icon/Execute-HQ9+ b/Lang/Icon/Execute-HQ9+ new file mode 120000 index 0000000000..82e8075d5b --- /dev/null +++ b/Lang/Icon/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Icon \ No newline at end of file diff --git a/Lang/Icon/Execute-a-system-command b/Lang/Icon/Execute-a-system-command new file mode 120000 index 0000000000..16a1a375e8 --- /dev/null +++ b/Lang/Icon/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Icon \ No newline at end of file diff --git a/Lang/Icon/Exponentiation-operator b/Lang/Icon/Exponentiation-operator new file mode 120000 index 0000000000..05abc05e7d --- /dev/null +++ b/Lang/Icon/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Icon \ No newline at end of file diff --git a/Lang/Icon/Extend-your-language b/Lang/Icon/Extend-your-language new file mode 120000 index 0000000000..a5263355f8 --- /dev/null +++ b/Lang/Icon/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Icon \ No newline at end of file diff --git a/Lang/Icon/Factorial b/Lang/Icon/Factorial new file mode 120000 index 0000000000..9f66f0a594 --- /dev/null +++ b/Lang/Icon/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Icon \ No newline at end of file diff --git a/Lang/Icon/Factors-of-an-integer b/Lang/Icon/Factors-of-an-integer new file mode 120000 index 0000000000..71cd9a5483 --- /dev/null +++ b/Lang/Icon/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Icon \ No newline at end of file diff --git a/Lang/Icon/Fibonacci-sequence b/Lang/Icon/Fibonacci-sequence new file mode 120000 index 0000000000..de7322372a --- /dev/null +++ b/Lang/Icon/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/File-IO b/Lang/Icon/File-IO new file mode 120000 index 0000000000..a383c301d6 --- /dev/null +++ b/Lang/Icon/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Icon \ No newline at end of file diff --git a/Lang/Icon/File-modification-time b/Lang/Icon/File-modification-time new file mode 120000 index 0000000000..3da5eb29ad --- /dev/null +++ b/Lang/Icon/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Icon \ No newline at end of file diff --git a/Lang/Icon/File-size b/Lang/Icon/File-size new file mode 120000 index 0000000000..31f07e096e --- /dev/null +++ b/Lang/Icon/File-size @@ -0,0 +1 @@ +../../Task/File-size/Icon \ No newline at end of file diff --git a/Lang/Icon/Filter b/Lang/Icon/Filter new file mode 120000 index 0000000000..a3745938d4 --- /dev/null +++ b/Lang/Icon/Filter @@ -0,0 +1 @@ +../../Task/Filter/Icon \ No newline at end of file diff --git a/Lang/Icon/Find-common-directory-path b/Lang/Icon/Find-common-directory-path new file mode 120000 index 0000000000..11a25daefa --- /dev/null +++ b/Lang/Icon/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Icon \ No newline at end of file diff --git a/Lang/Icon/Find-limit-of-recursion b/Lang/Icon/Find-limit-of-recursion new file mode 120000 index 0000000000..4740f68571 --- /dev/null +++ b/Lang/Icon/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Icon \ No newline at end of file diff --git a/Lang/Icon/Find-the-missing-permutation b/Lang/Icon/Find-the-missing-permutation new file mode 120000 index 0000000000..7344020783 --- /dev/null +++ b/Lang/Icon/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Icon \ No newline at end of file diff --git a/Lang/Icon/First-class-environments b/Lang/Icon/First-class-environments new file mode 120000 index 0000000000..573461b82e --- /dev/null +++ b/Lang/Icon/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/Icon \ No newline at end of file diff --git a/Lang/Icon/First-class-functions b/Lang/Icon/First-class-functions new file mode 120000 index 0000000000..6007d459c1 --- /dev/null +++ b/Lang/Icon/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Icon \ No newline at end of file diff --git a/Lang/Icon/First-class-functions-Use-numbers-analogously b/Lang/Icon/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..d5c6cc1623 --- /dev/null +++ b/Lang/Icon/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Icon \ No newline at end of file diff --git a/Lang/Icon/Five-weekends b/Lang/Icon/Five-weekends new file mode 120000 index 0000000000..781f13a780 --- /dev/null +++ b/Lang/Icon/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Icon \ No newline at end of file diff --git a/Lang/Icon/FizzBuzz b/Lang/Icon/FizzBuzz new file mode 120000 index 0000000000..56f97e0778 --- /dev/null +++ b/Lang/Icon/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Icon \ No newline at end of file diff --git a/Lang/Icon/Flatten-a-list b/Lang/Icon/Flatten-a-list new file mode 120000 index 0000000000..97ec0ca2c7 --- /dev/null +++ b/Lang/Icon/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Icon \ No newline at end of file diff --git a/Lang/Icon/Flow-control-structures b/Lang/Icon/Flow-control-structures new file mode 120000 index 0000000000..c8bae5260a --- /dev/null +++ b/Lang/Icon/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Icon \ No newline at end of file diff --git a/Lang/Icon/Forest-fire b/Lang/Icon/Forest-fire new file mode 120000 index 0000000000..f25d7ba4fe --- /dev/null +++ b/Lang/Icon/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/Icon \ No newline at end of file diff --git a/Lang/Icon/Fork b/Lang/Icon/Fork new file mode 120000 index 0000000000..6dfece981d --- /dev/null +++ b/Lang/Icon/Fork @@ -0,0 +1 @@ +../../Task/Fork/Icon \ No newline at end of file diff --git a/Lang/Icon/Formatted-numeric-output b/Lang/Icon/Formatted-numeric-output new file mode 120000 index 0000000000..395630cf17 --- /dev/null +++ b/Lang/Icon/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Icon \ No newline at end of file diff --git a/Lang/Icon/Forward-difference b/Lang/Icon/Forward-difference new file mode 120000 index 0000000000..0f4e260c5d --- /dev/null +++ b/Lang/Icon/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Icon \ No newline at end of file diff --git a/Lang/Icon/Fractal-tree b/Lang/Icon/Fractal-tree new file mode 120000 index 0000000000..176eabfcca --- /dev/null +++ b/Lang/Icon/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Icon \ No newline at end of file diff --git a/Lang/Icon/Function-composition b/Lang/Icon/Function-composition new file mode 120000 index 0000000000..e28951b345 --- /dev/null +++ b/Lang/Icon/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Icon \ No newline at end of file diff --git a/Lang/Icon/Function-definition b/Lang/Icon/Function-definition new file mode 120000 index 0000000000..513091104f --- /dev/null +++ b/Lang/Icon/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Icon \ No newline at end of file diff --git a/Lang/Icon/GUI-Maximum-window-dimensions b/Lang/Icon/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..b884e4bc30 --- /dev/null +++ b/Lang/Icon/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Icon \ No newline at end of file diff --git a/Lang/Icon/Galton-box-animation b/Lang/Icon/Galton-box-animation new file mode 120000 index 0000000000..719a1f5ff0 --- /dev/null +++ b/Lang/Icon/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/Icon \ No newline at end of file diff --git a/Lang/Icon/Generator-Exponential b/Lang/Icon/Generator-Exponential new file mode 120000 index 0000000000..382200b237 --- /dev/null +++ b/Lang/Icon/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Icon \ No newline at end of file diff --git a/Lang/Icon/Generic-swap b/Lang/Icon/Generic-swap new file mode 120000 index 0000000000..e5d2223cf3 --- /dev/null +++ b/Lang/Icon/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Icon \ No newline at end of file diff --git a/Lang/Icon/Globally-replace-text-in-several-files b/Lang/Icon/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..90f286799a --- /dev/null +++ b/Lang/Icon/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Icon \ No newline at end of file diff --git a/Lang/Icon/Greatest-common-divisor b/Lang/Icon/Greatest-common-divisor new file mode 120000 index 0000000000..07ab957944 --- /dev/null +++ b/Lang/Icon/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Icon \ No newline at end of file diff --git a/Lang/Icon/Greatest-element-of-a-list b/Lang/Icon/Greatest-element-of-a-list new file mode 120000 index 0000000000..1feceb83fe --- /dev/null +++ b/Lang/Icon/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Icon \ No newline at end of file diff --git a/Lang/Icon/Greatest-subsequential-sum b/Lang/Icon/Greatest-subsequential-sum new file mode 120000 index 0000000000..04c87c665b --- /dev/null +++ b/Lang/Icon/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Icon \ No newline at end of file diff --git a/Lang/Icon/Greyscale-bars-Display b/Lang/Icon/Greyscale-bars-Display new file mode 120000 index 0000000000..845ff8af92 --- /dev/null +++ b/Lang/Icon/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Icon \ No newline at end of file diff --git a/Lang/Icon/Guess-the-number b/Lang/Icon/Guess-the-number new file mode 120000 index 0000000000..7beef2bfc5 --- /dev/null +++ b/Lang/Icon/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Icon \ No newline at end of file diff --git a/Lang/Icon/Guess-the-number-With-feedback b/Lang/Icon/Guess-the-number-With-feedback new file mode 120000 index 0000000000..cec2dbb93c --- /dev/null +++ b/Lang/Icon/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Icon \ No newline at end of file diff --git a/Lang/Icon/Guess-the-number-With-feedback-player b/Lang/Icon/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..cfd8c80db1 --- /dev/null +++ b/Lang/Icon/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Icon \ No newline at end of file diff --git a/Lang/Icon/Hailstone-sequence b/Lang/Icon/Hailstone-sequence new file mode 120000 index 0000000000..43b574a999 --- /dev/null +++ b/Lang/Icon/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Hamming-numbers b/Lang/Icon/Hamming-numbers new file mode 120000 index 0000000000..ece10debbf --- /dev/null +++ b/Lang/Icon/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Happy-numbers b/Lang/Icon/Happy-numbers new file mode 120000 index 0000000000..20b9c15138 --- /dev/null +++ b/Lang/Icon/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Hash-from-two-arrays b/Lang/Icon/Hash-from-two-arrays new file mode 120000 index 0000000000..9b204acaab --- /dev/null +++ b/Lang/Icon/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Icon \ No newline at end of file diff --git a/Lang/Icon/Haversine-formula b/Lang/Icon/Haversine-formula new file mode 120000 index 0000000000..8a1210912b --- /dev/null +++ b/Lang/Icon/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Icon \ No newline at end of file diff --git a/Lang/Icon/Hello-world-Newline-omission b/Lang/Icon/Hello-world-Newline-omission new file mode 120000 index 0000000000..3fb9920ab1 --- /dev/null +++ b/Lang/Icon/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Icon \ No newline at end of file diff --git a/Lang/Icon/Hello-world-Standard-error b/Lang/Icon/Hello-world-Standard-error new file mode 120000 index 0000000000..edb7d2cb5f --- /dev/null +++ b/Lang/Icon/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Icon \ No newline at end of file diff --git a/Lang/Icon/Hello-world-Text b/Lang/Icon/Hello-world-Text new file mode 120000 index 0000000000..c7a2181e37 --- /dev/null +++ b/Lang/Icon/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Icon \ No newline at end of file diff --git a/Lang/Icon/Higher-order-functions b/Lang/Icon/Higher-order-functions new file mode 120000 index 0000000000..e4b17a025f --- /dev/null +++ b/Lang/Icon/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Icon \ No newline at end of file diff --git a/Lang/Icon/Hofstadter-Conway-$10,000-sequence b/Lang/Icon/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..de8200228c --- /dev/null +++ b/Lang/Icon/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Hofstadter-Figure-Figure-sequences b/Lang/Icon/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..993770e68a --- /dev/null +++ b/Lang/Icon/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Icon \ No newline at end of file diff --git a/Lang/Icon/Hofstadter-Q-sequence b/Lang/Icon/Hofstadter-Q-sequence new file mode 120000 index 0000000000..a348790770 --- /dev/null +++ b/Lang/Icon/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Holidays-related-to-Easter b/Lang/Icon/Holidays-related-to-Easter new file mode 120000 index 0000000000..d6aae00fa2 --- /dev/null +++ b/Lang/Icon/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Icon \ No newline at end of file diff --git a/Lang/Icon/Honeycombs b/Lang/Icon/Honeycombs new file mode 120000 index 0000000000..9c857330b3 --- /dev/null +++ b/Lang/Icon/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/Icon \ No newline at end of file diff --git a/Lang/Icon/Horizontal-sundial-calculations b/Lang/Icon/Horizontal-sundial-calculations new file mode 120000 index 0000000000..35df84cc58 --- /dev/null +++ b/Lang/Icon/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Icon \ No newline at end of file diff --git a/Lang/Icon/Horners-rule-for-polynomial-evaluation b/Lang/Icon/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..94f2a0b67d --- /dev/null +++ b/Lang/Icon/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Icon \ No newline at end of file diff --git a/Lang/Icon/Hostname b/Lang/Icon/Hostname new file mode 120000 index 0000000000..923e070064 --- /dev/null +++ b/Lang/Icon/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Icon \ No newline at end of file diff --git a/Lang/Icon/Huffman-coding b/Lang/Icon/Huffman-coding new file mode 120000 index 0000000000..8c4e948445 --- /dev/null +++ b/Lang/Icon/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Icon \ No newline at end of file diff --git a/Lang/Icon/Image-noise b/Lang/Icon/Image-noise new file mode 120000 index 0000000000..ec485ea7bf --- /dev/null +++ b/Lang/Icon/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Icon \ No newline at end of file diff --git a/Lang/Icon/Include-a-file b/Lang/Icon/Include-a-file new file mode 120000 index 0000000000..3cd9a4ec6a --- /dev/null +++ b/Lang/Icon/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Increment-a-numerical-string b/Lang/Icon/Increment-a-numerical-string new file mode 120000 index 0000000000..2bbd2f91a3 --- /dev/null +++ b/Lang/Icon/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Icon \ No newline at end of file diff --git a/Lang/Icon/Input-loop b/Lang/Icon/Input-loop new file mode 120000 index 0000000000..02d27fe3d6 --- /dev/null +++ b/Lang/Icon/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Icon \ No newline at end of file diff --git a/Lang/Icon/Integer-comparison b/Lang/Icon/Integer-comparison new file mode 120000 index 0000000000..34eb2e074e --- /dev/null +++ b/Lang/Icon/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Icon \ No newline at end of file diff --git a/Lang/Icon/Integer-sequence b/Lang/Icon/Integer-sequence new file mode 120000 index 0000000000..ea08387c14 --- /dev/null +++ b/Lang/Icon/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Introspection b/Lang/Icon/Introspection new file mode 120000 index 0000000000..122fed0a33 --- /dev/null +++ b/Lang/Icon/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Icon \ No newline at end of file diff --git a/Lang/Icon/Inverted-index b/Lang/Icon/Inverted-index new file mode 120000 index 0000000000..f78276308c --- /dev/null +++ b/Lang/Icon/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Icon \ No newline at end of file diff --git a/Lang/Icon/Inverted-syntax b/Lang/Icon/Inverted-syntax new file mode 120000 index 0000000000..846dee28b7 --- /dev/null +++ b/Lang/Icon/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Icon \ No newline at end of file diff --git a/Lang/Icon/Jensens-Device b/Lang/Icon/Jensens-Device new file mode 120000 index 0000000000..12f1387f50 --- /dev/null +++ b/Lang/Icon/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Icon \ No newline at end of file diff --git a/Lang/Icon/Kaprekar-numbers b/Lang/Icon/Kaprekar-numbers new file mode 120000 index 0000000000..18fd39d460 --- /dev/null +++ b/Lang/Icon/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Icon/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..d46b1b086d --- /dev/null +++ b/Lang/Icon/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Icon \ No newline at end of file diff --git a/Lang/Icon/Keyboard-input-Keypress-check b/Lang/Icon/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..d70f40c0f2 --- /dev/null +++ b/Lang/Icon/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Icon \ No newline at end of file diff --git a/Lang/Icon/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Icon/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..6ac75cb6e4 --- /dev/null +++ b/Lang/Icon/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Icon \ No newline at end of file diff --git a/Lang/Icon/Knapsack-problem-0-1 b/Lang/Icon/Knapsack-problem-0-1 new file mode 120000 index 0000000000..58097b3990 --- /dev/null +++ b/Lang/Icon/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Icon \ No newline at end of file diff --git a/Lang/Icon/Knapsack-problem-Continuous b/Lang/Icon/Knapsack-problem-Continuous new file mode 120000 index 0000000000..484f731859 --- /dev/null +++ b/Lang/Icon/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Icon \ No newline at end of file diff --git a/Lang/Icon/Knights-tour b/Lang/Icon/Knights-tour new file mode 120000 index 0000000000..3a5c57edf5 --- /dev/null +++ b/Lang/Icon/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Icon \ No newline at end of file diff --git a/Lang/Icon/Knuth-shuffle b/Lang/Icon/Knuth-shuffle new file mode 120000 index 0000000000..a32af19171 --- /dev/null +++ b/Lang/Icon/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Icon \ No newline at end of file diff --git a/Lang/Icon/Knuths-algorithm-S b/Lang/Icon/Knuths-algorithm-S new file mode 120000 index 0000000000..7467c6ef84 --- /dev/null +++ b/Lang/Icon/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Icon \ No newline at end of file diff --git a/Lang/Icon/Langtons-ant b/Lang/Icon/Langtons-ant new file mode 120000 index 0000000000..0f14c4a2ac --- /dev/null +++ b/Lang/Icon/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Icon \ No newline at end of file diff --git a/Lang/Icon/Last-Friday-of-each-month b/Lang/Icon/Last-Friday-of-each-month new file mode 120000 index 0000000000..092361d8df --- /dev/null +++ b/Lang/Icon/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Icon \ No newline at end of file diff --git a/Lang/Icon/Leap-year b/Lang/Icon/Leap-year new file mode 120000 index 0000000000..757aa36b49 --- /dev/null +++ b/Lang/Icon/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Icon \ No newline at end of file diff --git a/Lang/Icon/Least-common-multiple b/Lang/Icon/Least-common-multiple new file mode 120000 index 0000000000..63aa6d09cd --- /dev/null +++ b/Lang/Icon/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Icon \ No newline at end of file diff --git a/Lang/Icon/Letter-frequency b/Lang/Icon/Letter-frequency new file mode 120000 index 0000000000..4f4978e8b1 --- /dev/null +++ b/Lang/Icon/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Icon \ No newline at end of file diff --git a/Lang/Icon/Levenshtein-distance b/Lang/Icon/Levenshtein-distance new file mode 120000 index 0000000000..5825762502 --- /dev/null +++ b/Lang/Icon/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Icon \ No newline at end of file diff --git a/Lang/Icon/Linear-congruential-generator b/Lang/Icon/Linear-congruential-generator new file mode 120000 index 0000000000..1e5e250963 --- /dev/null +++ b/Lang/Icon/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Icon \ No newline at end of file diff --git a/Lang/Icon/Literals-Floating-point b/Lang/Icon/Literals-Floating-point new file mode 120000 index 0000000000..1f27ff2b99 --- /dev/null +++ b/Lang/Icon/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Icon \ No newline at end of file diff --git a/Lang/Icon/Literals-Integer b/Lang/Icon/Literals-Integer new file mode 120000 index 0000000000..c53d2703b1 --- /dev/null +++ b/Lang/Icon/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Icon \ No newline at end of file diff --git a/Lang/Icon/Literals-String b/Lang/Icon/Literals-String new file mode 120000 index 0000000000..92d8006ade --- /dev/null +++ b/Lang/Icon/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Icon \ No newline at end of file diff --git a/Lang/Icon/Logical-operations b/Lang/Icon/Logical-operations new file mode 120000 index 0000000000..88904057a4 --- /dev/null +++ b/Lang/Icon/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Icon \ No newline at end of file diff --git a/Lang/Icon/Longest-common-subsequence b/Lang/Icon/Longest-common-subsequence new file mode 120000 index 0000000000..2aa5da77b4 --- /dev/null +++ b/Lang/Icon/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Longest-string-challenge b/Lang/Icon/Longest-string-challenge new file mode 120000 index 0000000000..bf132337d5 --- /dev/null +++ b/Lang/Icon/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Icon \ No newline at end of file diff --git a/Lang/Icon/Look-and-say-sequence b/Lang/Icon/Look-and-say-sequence new file mode 120000 index 0000000000..a83fd22138 --- /dev/null +++ b/Lang/Icon/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Loop-over-multiple-arrays-simultaneously b/Lang/Icon/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..8efde25284 --- /dev/null +++ b/Lang/Icon/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Break b/Lang/Icon/Loops-Break new file mode 120000 index 0000000000..98343761aa --- /dev/null +++ b/Lang/Icon/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Do-while b/Lang/Icon/Loops-Do-while new file mode 120000 index 0000000000..f3f0082290 --- /dev/null +++ b/Lang/Icon/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Downward-for b/Lang/Icon/Loops-Downward-for new file mode 120000 index 0000000000..025e7f8ee2 --- /dev/null +++ b/Lang/Icon/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-For-with-a-specified-step b/Lang/Icon/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..d788e318ee --- /dev/null +++ b/Lang/Icon/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Foreach b/Lang/Icon/Loops-Foreach new file mode 120000 index 0000000000..f34f83836e --- /dev/null +++ b/Lang/Icon/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Infinite b/Lang/Icon/Loops-Infinite new file mode 120000 index 0000000000..e3f38bb6d4 --- /dev/null +++ b/Lang/Icon/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-N-plus-one-half b/Lang/Icon/Loops-N-plus-one-half new file mode 120000 index 0000000000..0569397ca5 --- /dev/null +++ b/Lang/Icon/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-Nested b/Lang/Icon/Loops-Nested new file mode 120000 index 0000000000..875211d0cc --- /dev/null +++ b/Lang/Icon/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Icon \ No newline at end of file diff --git a/Lang/Icon/Loops-While b/Lang/Icon/Loops-While new file mode 120000 index 0000000000..7afe206637 --- /dev/null +++ b/Lang/Icon/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Icon \ No newline at end of file diff --git a/Lang/Icon/Luhn-test-of-credit-card-numbers b/Lang/Icon/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..4c3da03cb4 --- /dev/null +++ b/Lang/Icon/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/MD5 b/Lang/Icon/MD5 new file mode 120000 index 0000000000..00359e8866 --- /dev/null +++ b/Lang/Icon/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Icon \ No newline at end of file diff --git a/Lang/Icon/MD5-Implementation b/Lang/Icon/MD5-Implementation new file mode 120000 index 0000000000..5b87e07dbf --- /dev/null +++ b/Lang/Icon/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Icon \ No newline at end of file diff --git a/Lang/Icon/Mad-Libs b/Lang/Icon/Mad-Libs new file mode 120000 index 0000000000..ae1f99d347 --- /dev/null +++ b/Lang/Icon/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Icon \ No newline at end of file diff --git a/Lang/Icon/Man-or-boy-test b/Lang/Icon/Man-or-boy-test new file mode 120000 index 0000000000..b5fd390071 --- /dev/null +++ b/Lang/Icon/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Icon \ No newline at end of file diff --git a/Lang/Icon/Mandelbrot-set b/Lang/Icon/Mandelbrot-set new file mode 120000 index 0000000000..a300a8ef2d --- /dev/null +++ b/Lang/Icon/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Icon \ No newline at end of file diff --git a/Lang/Icon/Map-range b/Lang/Icon/Map-range new file mode 120000 index 0000000000..b350dba5d3 --- /dev/null +++ b/Lang/Icon/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Icon \ No newline at end of file diff --git a/Lang/Icon/Matrix-multiplication b/Lang/Icon/Matrix-multiplication new file mode 120000 index 0000000000..b8360c338e --- /dev/null +++ b/Lang/Icon/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Icon \ No newline at end of file diff --git a/Lang/Icon/Matrix-transposition b/Lang/Icon/Matrix-transposition new file mode 120000 index 0000000000..d19e4c670f --- /dev/null +++ b/Lang/Icon/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Icon \ No newline at end of file diff --git a/Lang/Icon/Maze-generation b/Lang/Icon/Maze-generation new file mode 120000 index 0000000000..24d76fab9a --- /dev/null +++ b/Lang/Icon/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Icon \ No newline at end of file diff --git a/Lang/Icon/Maze-solving b/Lang/Icon/Maze-solving new file mode 120000 index 0000000000..cf2985fa73 --- /dev/null +++ b/Lang/Icon/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Icon \ No newline at end of file diff --git a/Lang/Icon/Menu b/Lang/Icon/Menu new file mode 120000 index 0000000000..59b237b5c1 --- /dev/null +++ b/Lang/Icon/Menu @@ -0,0 +1 @@ +../../Task/Menu/Icon \ No newline at end of file diff --git a/Lang/Icon/Miller-Rabin-primality-test b/Lang/Icon/Miller-Rabin-primality-test new file mode 120000 index 0000000000..0a9d526a8b --- /dev/null +++ b/Lang/Icon/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Icon \ No newline at end of file diff --git a/Lang/Icon/Minesweeper-game b/Lang/Icon/Minesweeper-game new file mode 120000 index 0000000000..ded6cdc61b --- /dev/null +++ b/Lang/Icon/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Icon \ No newline at end of file diff --git a/Lang/Icon/Modular-exponentiation b/Lang/Icon/Modular-exponentiation new file mode 120000 index 0000000000..1eb2282718 --- /dev/null +++ b/Lang/Icon/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Icon \ No newline at end of file diff --git a/Lang/Icon/Modular-inverse b/Lang/Icon/Modular-inverse new file mode 120000 index 0000000000..ec050879d9 --- /dev/null +++ b/Lang/Icon/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Icon \ No newline at end of file diff --git a/Lang/Icon/Monte-Carlo-methods b/Lang/Icon/Monte-Carlo-methods new file mode 120000 index 0000000000..013ff999f6 --- /dev/null +++ b/Lang/Icon/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Icon \ No newline at end of file diff --git a/Lang/Icon/Monty-Hall-problem b/Lang/Icon/Monty-Hall-problem new file mode 120000 index 0000000000..f3ad2ee43b --- /dev/null +++ b/Lang/Icon/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Icon \ No newline at end of file diff --git a/Lang/Icon/Mouse-position b/Lang/Icon/Mouse-position new file mode 120000 index 0000000000..78bd8d9798 --- /dev/null +++ b/Lang/Icon/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Icon \ No newline at end of file diff --git a/Lang/Icon/Multiple-distinct-objects b/Lang/Icon/Multiple-distinct-objects new file mode 120000 index 0000000000..34c87062e4 --- /dev/null +++ b/Lang/Icon/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Icon \ No newline at end of file diff --git a/Lang/Icon/Multiplication-tables b/Lang/Icon/Multiplication-tables new file mode 120000 index 0000000000..66290a41a2 --- /dev/null +++ b/Lang/Icon/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Icon \ No newline at end of file diff --git a/Lang/Icon/Multisplit b/Lang/Icon/Multisplit new file mode 120000 index 0000000000..9cb8c323bd --- /dev/null +++ b/Lang/Icon/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Icon \ No newline at end of file diff --git a/Lang/Icon/Mutual-recursion b/Lang/Icon/Mutual-recursion new file mode 120000 index 0000000000..26578c801b --- /dev/null +++ b/Lang/Icon/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Icon \ No newline at end of file diff --git a/Lang/Icon/Narcissist b/Lang/Icon/Narcissist new file mode 120000 index 0000000000..02091a456d --- /dev/null +++ b/Lang/Icon/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/Icon \ No newline at end of file diff --git a/Lang/Icon/Ordered-words b/Lang/Icon/Ordered-words new file mode 120000 index 0000000000..f251ed6b6a --- /dev/null +++ b/Lang/Icon/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Icon \ No newline at end of file diff --git a/Lang/Icon/Pi b/Lang/Icon/Pi new file mode 120000 index 0000000000..cffd47102f --- /dev/null +++ b/Lang/Icon/Pi @@ -0,0 +1 @@ +../../Task/Pi/Icon \ No newline at end of file diff --git a/Lang/Icon/Quine b/Lang/Icon/Quine new file mode 120000 index 0000000000..23d5175e32 --- /dev/null +++ b/Lang/Icon/Quine @@ -0,0 +1 @@ +../../Task/Quine/Icon \ No newline at end of file diff --git a/Lang/Icon/Search-a-list b/Lang/Icon/Search-a-list new file mode 120000 index 0000000000..5d56da223d --- /dev/null +++ b/Lang/Icon/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Icon \ No newline at end of file diff --git a/Lang/Inform-6/0DESCRIPTION b/Lang/Inform-6/0DESCRIPTION new file mode 100644 index 0000000000..730a74881a --- /dev/null +++ b/Lang/Inform-6/0DESCRIPTION @@ -0,0 +1,4 @@ +{{stub}}{{language +|site=http://www.inform-fiction.org/inform6.html +}} +'''Inform 6''' is a language designed with the purpose of creating [[wp:Interactive Fiction|Interactive Fiction]]. It has a somewhat C-like syntax. Although the language is meant to build Interactive Fiction, it is general purpose enough to perform other tasks. \ No newline at end of file diff --git a/Lang/Inform-6/99-Bottles-of-Beer b/Lang/Inform-6/99-Bottles-of-Beer new file mode 120000 index 0000000000..3f9974b559 --- /dev/null +++ b/Lang/Inform-6/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Bitwise-operations b/Lang/Inform-6/Bitwise-operations new file mode 120000 index 0000000000..0c426766df --- /dev/null +++ b/Lang/Inform-6/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Factorial b/Lang/Inform-6/Factorial new file mode 120000 index 0000000000..6cae768eb8 --- /dev/null +++ b/Lang/Inform-6/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/FizzBuzz b/Lang/Inform-6/FizzBuzz new file mode 120000 index 0000000000..4ad3ea6595 --- /dev/null +++ b/Lang/Inform-6/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Function-definition b/Lang/Inform-6/Function-definition new file mode 120000 index 0000000000..44a231cd3a --- /dev/null +++ b/Lang/Inform-6/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Hello-world-Text b/Lang/Inform-6/Hello-world-Text new file mode 120000 index 0000000000..97e0b0bd1c --- /dev/null +++ b/Lang/Inform-6/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Higher-order-functions b/Lang/Inform-6/Higher-order-functions new file mode 120000 index 0000000000..a4c5eac9bd --- /dev/null +++ b/Lang/Inform-6/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Knuth-shuffle b/Lang/Inform-6/Knuth-shuffle new file mode 120000 index 0000000000..47736ea17a --- /dev/null +++ b/Lang/Inform-6/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-6/Loops-Downward-for b/Lang/Inform-6/Loops-Downward-for new file mode 120000 index 0000000000..a49305a2d7 --- /dev/null +++ b/Lang/Inform-6/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Inform-6 \ No newline at end of file diff --git a/Lang/Inform-7/0DESCRIPTION b/Lang/Inform-7/0DESCRIPTION new file mode 100644 index 0000000000..2c9548ae94 --- /dev/null +++ b/Lang/Inform-7/0DESCRIPTION @@ -0,0 +1,15 @@ +{{stub}}{{language +|exec=bytecode +|site=http://inform7.com/ +|parampass=value +|safety=both +|strength=strong +|express=both +|compat=nominative +|checking=both +|tags=inform7 +}} + +'''Inform 7''' is a language for creating [[wp:interactive fiction|interactive fiction]], with a syntax similar to English. Although it has some [[object-oriented programming|object-oriented]] features, it is primarily [[rule-based programming|rule-based]]: most code takes the form of "rules", which are placed into rulebooks, which are invoked by the library in response to player commands and other events. + +An Inform 7 program also contains a set of initially constructed objects, called the world model. These objects are organized into a hierarchy of classes (called "kinds"), although there is no method invocation; objects only contain data. The relations between objects are modeled at a high level: physical relationships such as containment (the water is in the glass) and supporting (the glass is on the table) are predefined, and new relationships such as desire (the troll wants the diamond) or lock-fitting (the bronze key fits the bronze lock) can be created. \ No newline at end of file diff --git a/Lang/Inform-7/100-doors b/Lang/Inform-7/100-doors new file mode 120000 index 0000000000..420c797b60 --- /dev/null +++ b/Lang/Inform-7/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/99-Bottles-of-Beer b/Lang/Inform-7/99-Bottles-of-Beer new file mode 120000 index 0000000000..3d2904c1c7 --- /dev/null +++ b/Lang/Inform-7/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Arithmetic-Integer b/Lang/Inform-7/Arithmetic-Integer new file mode 120000 index 0000000000..b8ffda1fe3 --- /dev/null +++ b/Lang/Inform-7/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Array-concatenation b/Lang/Inform-7/Array-concatenation new file mode 120000 index 0000000000..31319ac2f3 --- /dev/null +++ b/Lang/Inform-7/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Associative-array-Creation b/Lang/Inform-7/Associative-array-Creation new file mode 120000 index 0000000000..d7e47ecb69 --- /dev/null +++ b/Lang/Inform-7/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Boolean-values b/Lang/Inform-7/Boolean-values new file mode 120000 index 0000000000..cc18b75f34 --- /dev/null +++ b/Lang/Inform-7/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Comments b/Lang/Inform-7/Comments new file mode 120000 index 0000000000..4ad2fc20c2 --- /dev/null +++ b/Lang/Inform-7/Comments @@ -0,0 +1 @@ +../../Task/Comments/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Conditional-structures b/Lang/Inform-7/Conditional-structures new file mode 120000 index 0000000000..f9e35a96b1 --- /dev/null +++ b/Lang/Inform-7/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Enumerations b/Lang/Inform-7/Enumerations new file mode 120000 index 0000000000..b6e6be6c05 --- /dev/null +++ b/Lang/Inform-7/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Execute-HQ9+ b/Lang/Inform-7/Execute-HQ9+ new file mode 120000 index 0000000000..90f17e4001 --- /dev/null +++ b/Lang/Inform-7/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Extend-your-language b/Lang/Inform-7/Extend-your-language new file mode 120000 index 0000000000..8063283ed7 --- /dev/null +++ b/Lang/Inform-7/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Find-limit-of-recursion b/Lang/Inform-7/Find-limit-of-recursion new file mode 120000 index 0000000000..d9baceca68 --- /dev/null +++ b/Lang/Inform-7/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Five-weekends b/Lang/Inform-7/Five-weekends new file mode 120000 index 0000000000..780257c818 --- /dev/null +++ b/Lang/Inform-7/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/FizzBuzz b/Lang/Inform-7/FizzBuzz new file mode 120000 index 0000000000..2529a8ca62 --- /dev/null +++ b/Lang/Inform-7/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Function-definition b/Lang/Inform-7/Function-definition new file mode 120000 index 0000000000..14d22ff987 --- /dev/null +++ b/Lang/Inform-7/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Hailstone-sequence b/Lang/Inform-7/Hailstone-sequence new file mode 120000 index 0000000000..65190cdf02 --- /dev/null +++ b/Lang/Inform-7/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Higher-order-functions b/Lang/Inform-7/Higher-order-functions new file mode 120000 index 0000000000..b2dd13dc42 --- /dev/null +++ b/Lang/Inform-7/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Increment-a-numerical-string b/Lang/Inform-7/Increment-a-numerical-string new file mode 120000 index 0000000000..ec96538e24 --- /dev/null +++ b/Lang/Inform-7/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Inheritance-Single b/Lang/Inform-7/Inheritance-Single new file mode 120000 index 0000000000..41b47d8796 --- /dev/null +++ b/Lang/Inform-7/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Introspection b/Lang/Inform-7/Introspection new file mode 120000 index 0000000000..2dd8567a7f --- /dev/null +++ b/Lang/Inform-7/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Inform-7/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..070da248fc --- /dev/null +++ b/Lang/Inform-7/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Literals-String b/Lang/Inform-7/Literals-String new file mode 120000 index 0000000000..3334f03320 --- /dev/null +++ b/Lang/Inform-7/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Loops-For b/Lang/Inform-7/Loops-For new file mode 120000 index 0000000000..a076695986 --- /dev/null +++ b/Lang/Inform-7/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Loops-While b/Lang/Inform-7/Loops-While new file mode 120000 index 0000000000..f67daa7dfe --- /dev/null +++ b/Lang/Inform-7/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Mandelbrot-set b/Lang/Inform-7/Mandelbrot-set new file mode 120000 index 0000000000..409af31e00 --- /dev/null +++ b/Lang/Inform-7/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Quine b/Lang/Inform-7/Quine new file mode 120000 index 0000000000..ffd7e29f4c --- /dev/null +++ b/Lang/Inform-7/Quine @@ -0,0 +1 @@ +../../Task/Quine/Inform-7 \ No newline at end of file diff --git a/Lang/Informix-4GL/0DESCRIPTION b/Lang/Informix-4GL/0DESCRIPTION new file mode 100644 index 0000000000..f66cf163bf --- /dev/null +++ b/Lang/Informix-4GL/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{stub}} \ No newline at end of file diff --git a/Lang/Informix-4GL/100-doors b/Lang/Informix-4GL/100-doors new file mode 120000 index 0000000000..723816649a --- /dev/null +++ b/Lang/Informix-4GL/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Informix-4GL \ No newline at end of file diff --git a/Lang/Integer-BASIC/0DESCRIPTION b/Lang/Integer-BASIC/0DESCRIPTION new file mode 100644 index 0000000000..234e8e8849 --- /dev/null +++ b/Lang/Integer-BASIC/0DESCRIPTION @@ -0,0 +1,9 @@ +{{stub}}{{language|Integer BASIC +|exec=interpreted}} +{{implementation|BASIC}} + +Integer BASIC, written by [[wp:Steve Wozniak|Steve Wozniak]], was the [[BASIC]] interpreter of the [[wp:Apple I|Apple I]] and original [[wp:Apple II|Apple II]] computers. Originally available on cassette, then included in ROM on the original [[wp:Apple II|Apple II]] computer at release in 1977. + +==See Also== +* [[wp:Integer BASIC|Wikipedia: Integer BASIC]] +* [http://www.landsnail.com/a2ref2.htm Apple II Programmer's Reference] from ][ In a Mac, via [http://www.landsnail.com/ Landsnail.com] \ No newline at end of file diff --git a/Lang/Integer-BASIC/99-Bottles-of-Beer b/Lang/Integer-BASIC/99-Bottles-of-Beer new file mode 120000 index 0000000000..707b176715 --- /dev/null +++ b/Lang/Integer-BASIC/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Integer-BASIC \ No newline at end of file diff --git a/Lang/Integer-BASIC/Hello-world-Graphical b/Lang/Integer-BASIC/Hello-world-Graphical new file mode 120000 index 0000000000..cba5b63800 --- /dev/null +++ b/Lang/Integer-BASIC/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Integer-BASIC \ No newline at end of file diff --git a/Lang/Integer-BASIC/Hello-world-Text b/Lang/Integer-BASIC/Hello-world-Text new file mode 120000 index 0000000000..66e9c07572 --- /dev/null +++ b/Lang/Integer-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Integer-BASIC \ No newline at end of file diff --git a/Lang/Intercal/0DESCRIPTION b/Lang/Intercal/0DESCRIPTION new file mode 100644 index 0000000000..294a1aa93c --- /dev/null +++ b/Lang/Intercal/0DESCRIPTION @@ -0,0 +1,21 @@ +{{language|Intercal +|site=http://www.catb.org/~esr/intercal/ +}} + +The language designed to be Turing-complete but as fundamentally unlike any existing language as possible. Expressions that look like line noise. Control constructs that will make you gasp, make you laugh, and possibly make you hurl. Data structures? We don't need no steenking data structures![[#Citation|[1]]] + +INTERCAL's main advantage over other programming languages is its strict simplicity. It has few capabilities, and thus there are few restrictions to be kept in mind. Since it is an exceedingly easy language to learn, one might expect it would be a good language for initiating novice programmers. Perhaps surprising, then, is the fact that it would be more likely to initiate a novice into a search for another line of work. As it turns out, INTERCAL is more useful (which isn't saying much) as a challenge to professional programmers. Those who doubt this need only refer back to the sample program in section 2.1. This 22-statement program took somewhere from 15 to 30 minutes to write, whereas the same objectives can be achieved by single-statement programs in either [[SNOBOL]] or [[APL]].[[#Citation|[2]]] + +"INTERCAL" is an acronym for "Compiler Language With No Pronounceable Acronym." + +==Citations== +#[http://www.catb.org/~esr/intercal/ The INTERCAL Resources Page] +#[http://www.ofb.net/~jlm/intercal.html Overview from The INTERCAL Programming Language Reference Manual by Donand R. Woods and James M. Lyon] + +==See Also== +*[[wp:INTERCAL|Wikipedia: Intercal]] +*[http://catb.org/~esr/intercal/stross.html Intercal -- the Language From Hell] +*[http://www.muppetlabs.com/~breadbox/intercal-man/ The INTERCAL Programming Language Revised Reference Manual] +*[http://www.muppetlabs.com/~breadbox/intercal/ INTERCAL "The Performance Art of Programming"] +[[Category:Esoteric Languages]] +*[[eso:INTERCAL|INTERCAL on Esolangs]] \ No newline at end of file diff --git a/Lang/Intercal/Empty-program b/Lang/Intercal/Empty-program new file mode 120000 index 0000000000..7211b48d47 --- /dev/null +++ b/Lang/Intercal/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Intercal \ No newline at end of file diff --git a/Lang/Io/0DESCRIPTION b/Lang/Io/0DESCRIPTION new file mode 100644 index 0000000000..18d1e4dbc7 --- /dev/null +++ b/Lang/Io/0DESCRIPTION @@ -0,0 +1,7 @@ +{{language|Io +|strength=strong +|checking=dynamic +|gc=yes +|site=http://iolanguage.com/ +|LCT=yes}}Io is an embeddable, prototype-based, scripting language. Its syntax is simple and expressive. It is executed by a small virtual machine. +
\ No newline at end of file diff --git a/Lang/Io/100-doors b/Lang/Io/100-doors new file mode 120000 index 0000000000..c8b3d32469 --- /dev/null +++ b/Lang/Io/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Io \ No newline at end of file diff --git a/Lang/Io/99-Bottles-of-Beer b/Lang/Io/99-Bottles-of-Beer new file mode 120000 index 0000000000..be67a71459 --- /dev/null +++ b/Lang/Io/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Io \ No newline at end of file diff --git a/Lang/Io/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Io/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..56e8c154a5 --- /dev/null +++ b/Lang/Io/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Io \ No newline at end of file diff --git a/Lang/Io/Apply-a-callback-to-an-array b/Lang/Io/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..6843d8a4ba --- /dev/null +++ b/Lang/Io/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Io \ No newline at end of file diff --git a/Lang/Io/Arrays b/Lang/Io/Arrays new file mode 120000 index 0000000000..a5f00ceb4c --- /dev/null +++ b/Lang/Io/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Io \ No newline at end of file diff --git a/Lang/Io/Averages-Root-mean-square b/Lang/Io/Averages-Root-mean-square new file mode 120000 index 0000000000..46d90609b1 --- /dev/null +++ b/Lang/Io/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Io \ No newline at end of file diff --git a/Lang/Io/Command-line-arguments b/Lang/Io/Command-line-arguments new file mode 120000 index 0000000000..d73f776c6c --- /dev/null +++ b/Lang/Io/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Io \ No newline at end of file diff --git a/Lang/Io/Comments b/Lang/Io/Comments new file mode 120000 index 0000000000..1a24e8a6df --- /dev/null +++ b/Lang/Io/Comments @@ -0,0 +1 @@ +../../Task/Comments/Io \ No newline at end of file diff --git a/Lang/Io/Delete-a-file b/Lang/Io/Delete-a-file new file mode 120000 index 0000000000..9f7a2551f4 --- /dev/null +++ b/Lang/Io/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Io \ No newline at end of file diff --git a/Lang/Io/Execute-a-system-command b/Lang/Io/Execute-a-system-command new file mode 120000 index 0000000000..3afcf4a04b --- /dev/null +++ b/Lang/Io/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Io \ No newline at end of file diff --git a/Lang/Io/Factorial b/Lang/Io/Factorial new file mode 120000 index 0000000000..a92e6cd6b8 --- /dev/null +++ b/Lang/Io/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Io \ No newline at end of file diff --git a/Lang/Io/File-IO b/Lang/Io/File-IO new file mode 120000 index 0000000000..b3b0e02224 --- /dev/null +++ b/Lang/Io/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Io \ No newline at end of file diff --git a/Lang/Io/FizzBuzz b/Lang/Io/FizzBuzz new file mode 120000 index 0000000000..4447b63862 --- /dev/null +++ b/Lang/Io/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Io \ No newline at end of file diff --git a/Lang/Io/Function-definition b/Lang/Io/Function-definition new file mode 120000 index 0000000000..db6f9c7099 --- /dev/null +++ b/Lang/Io/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Io \ No newline at end of file diff --git a/Lang/Io/Hello-world-Text b/Lang/Io/Hello-world-Text new file mode 120000 index 0000000000..c88f63cb18 --- /dev/null +++ b/Lang/Io/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Io \ No newline at end of file diff --git a/Lang/Io/Infinity b/Lang/Io/Infinity new file mode 120000 index 0000000000..d8af748949 --- /dev/null +++ b/Lang/Io/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Io \ No newline at end of file diff --git a/Lang/Io/Inheritance-Single b/Lang/Io/Inheritance-Single new file mode 120000 index 0000000000..71d79ea183 --- /dev/null +++ b/Lang/Io/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Io \ No newline at end of file diff --git a/Lang/Io/Introspection b/Lang/Io/Introspection new file mode 120000 index 0000000000..9229f20137 --- /dev/null +++ b/Lang/Io/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Io \ No newline at end of file diff --git a/Lang/Io/Logical-operations b/Lang/Io/Logical-operations new file mode 120000 index 0000000000..d62bf38614 --- /dev/null +++ b/Lang/Io/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Io \ No newline at end of file diff --git a/Lang/Io/Loops-Foreach b/Lang/Io/Loops-Foreach new file mode 120000 index 0000000000..af33aadeeb --- /dev/null +++ b/Lang/Io/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Io \ No newline at end of file diff --git a/Lang/Io/Loops-Infinite b/Lang/Io/Loops-Infinite new file mode 120000 index 0000000000..8da7585d62 --- /dev/null +++ b/Lang/Io/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Io \ No newline at end of file diff --git a/Lang/Io/MD5 b/Lang/Io/MD5 new file mode 120000 index 0000000000..3bea968bd3 --- /dev/null +++ b/Lang/Io/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Io \ No newline at end of file diff --git a/Lang/Io/Quine b/Lang/Io/Quine new file mode 120000 index 0000000000..7a34a286b1 --- /dev/null +++ b/Lang/Io/Quine @@ -0,0 +1 @@ +../../Task/Quine/Io \ No newline at end of file diff --git a/Lang/Ioke/0DESCRIPTION b/Lang/Ioke/0DESCRIPTION new file mode 100644 index 0000000000..b043640666 --- /dev/null +++ b/Lang/Ioke/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language|Ioke +|site=http://ioke.org/ +|exec=bytecode +|gc=yes +|safety=safe +|checking=both +|strength=strong}}[[runs on vm::java virtual machine| ]][[runs on vm::common language runtime| ]] +{{language programming paradigm|functional}} +{{language programming paradigm|concurrent}} +Ioke is a folding language. It allows you to write highly expressive code that writes code. Ioke allows you to create abstractions at any level, and expressiveness is the ultimate goal of the language. + +Ioke is a dynamic language targeted at virtual machines, currently the [[Java Virtual Machine]] and the [[Common Language Runtime]]. It's been designed from scratch to be a highly flexible general purpose language. It is a prototype-based programming language that is inspired by [[Io]], [[Smalltalk]], [[Lisp]] and [[Ruby]]. \ No newline at end of file diff --git a/Lang/Ioke/100-doors b/Lang/Ioke/100-doors new file mode 120000 index 0000000000..4354832f85 --- /dev/null +++ b/Lang/Ioke/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Ioke \ No newline at end of file diff --git a/Lang/Ioke/99-Bottles-of-Beer b/Lang/Ioke/99-Bottles-of-Beer new file mode 120000 index 0000000000..4aac2aa348 --- /dev/null +++ b/Lang/Ioke/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Ackermann-function b/Lang/Ioke/Ackermann-function new file mode 120000 index 0000000000..c3cacae86b --- /dev/null +++ b/Lang/Ioke/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Array-concatenation b/Lang/Ioke/Array-concatenation new file mode 120000 index 0000000000..2628abdace --- /dev/null +++ b/Lang/Ioke/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Associative-array-Creation b/Lang/Ioke/Associative-array-Creation new file mode 120000 index 0000000000..b50c19ab2d --- /dev/null +++ b/Lang/Ioke/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Command-line-arguments b/Lang/Ioke/Command-line-arguments new file mode 120000 index 0000000000..55a900ef29 --- /dev/null +++ b/Lang/Ioke/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Ioke \ No newline at end of file diff --git a/Lang/Ioke/FizzBuzz b/Lang/Ioke/FizzBuzz new file mode 120000 index 0000000000..f2862b8618 --- /dev/null +++ b/Lang/Ioke/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Flatten-a-list b/Lang/Ioke/Flatten-a-list new file mode 120000 index 0000000000..7adf9fef87 --- /dev/null +++ b/Lang/Ioke/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Ioke \ No newline at end of file diff --git a/Lang/Ioke/HTTPS b/Lang/Ioke/HTTPS new file mode 120000 index 0000000000..42e42ddf65 --- /dev/null +++ b/Lang/Ioke/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Hailstone-sequence b/Lang/Ioke/Hailstone-sequence new file mode 120000 index 0000000000..097db427ed --- /dev/null +++ b/Lang/Ioke/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Hash-from-two-arrays b/Lang/Ioke/Hash-from-two-arrays new file mode 120000 index 0000000000..d4ff3a2093 --- /dev/null +++ b/Lang/Ioke/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Hello-world-Graphical b/Lang/Ioke/Hello-world-Graphical new file mode 120000 index 0000000000..023114f9ee --- /dev/null +++ b/Lang/Ioke/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Hello-world-Text b/Lang/Ioke/Hello-world-Text new file mode 120000 index 0000000000..46e56b92d5 --- /dev/null +++ b/Lang/Ioke/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Inheritance-Multiple b/Lang/Ioke/Inheritance-Multiple new file mode 120000 index 0000000000..9a7bbacfac --- /dev/null +++ b/Lang/Ioke/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Ioke \ No newline at end of file diff --git a/Lang/Ioke/List-comprehensions b/Lang/Ioke/List-comprehensions new file mode 120000 index 0000000000..bfc74ce6be --- /dev/null +++ b/Lang/Ioke/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Ioke \ No newline at end of file diff --git a/Lang/Iptscrae/0DESCRIPTION b/Lang/Iptscrae/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Iptscrae/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/Iptscrae/FizzBuzz b/Lang/Iptscrae/FizzBuzz new file mode 120000 index 0000000000..888b993767 --- /dev/null +++ b/Lang/Iptscrae/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Iptscrae \ No newline at end of file diff --git a/Lang/J/0DESCRIPTION b/Lang/J/0DESCRIPTION new file mode 100644 index 0000000000..41d0c83465 --- /dev/null +++ b/Lang/J/0DESCRIPTION @@ -0,0 +1,86 @@ +{{language|J +|exec=bytecode +|exec=interpreted +|site=http://www.jsoftware.com +|strength=strong (but regular) +|safety=safe +|checking=dynamic +|tags=j +|hopl id=1558 +|LCT=yes +|bnf=http://www.jsoftware.com/jwiki/Backus%E2%80%93Naur_Form}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|functional}} +{{language programming paradigm|imperative}} +{{language programming paradigm|procedural}} +{{language programming paradigm|Reflective}} +{{language programming paradigm|Tacit}} + +== the J language == + +J is a notational programming language designed for interactive use. + +It is an array language; data is universally structured as rectangular arrays. + +It is a functional language; creation and composition of functions is emphasized. + +Object-module and imperative techniques are supported, but not required. + +The J programming language was designed and developed by [http://en.wikipedia.org/wiki/Kenneth_E._Iverson Ken Iverson] and Roger Hui. It is a closely related successor to [[APL]], also by Iverson which itself was a successor to the notation Ken Iverson used to teach his classes about computers in the 1950s. +
+ +== Reading J == + +J is meant to be read with the aid of a computer. J sentences are single lines and trying variations and simplifications of an expression is common practice. The first step in understanding any J sentence is to understand the data you started with and the data which resulted. When learning how a J sentence works, you can also try simpler sentences which the same data or perhaps related data. + +Unless you attend an institution which has made a J interpreter available to you through your web browser, if you want to see how J works you should probably [http://www.jsoftware.com/stable.htm install] a copy of J -- or you can try one of the "try me" links, below. If you want to understand how to experiment with alternative expressions you should probably study some of its [[j:Guides/Getting%20Started#Documentation|documentation]]. + +For example, the phrase (+/ % #) finds the average of a list of numbers. + + (+/ % #) 1 2 3 +2 + +To understand how this works, you might try working with simpler sentences and their variations. + + +/ 1 2 3 +6 + +/4 5 6 +15 + # 1 2 3 +3 + # 2 3 4 +3 + 6 % 3 +2 + 15 % 3 +5 + (+/ % #) 4 5 6 +5 + +By themselves, these experiments mean nothing, but if you know that +/ was finding the sum of a list and # was finding the length of a list and that % was dividing the two quantities (and looks almost like one of the classical division symbols) then these experiments might help confirm that you have understood things properly. + +== J on RosettaCode == + +Discussion of the goals of the J community on RC and general guidelines for presenting J solutions takes place at [[J/HouseStyle|House Style]]. + + +== Jers on RosettaCode == +*[[User:Roger_Hui|Roger Hui]]: [[Special:Contributions/Roger_Hui|contributions]], [[j:RogerHui|J wiki]] +*[[User:TBH|Tracy Harms]]: [[Special:Contributions/TBH|contributions]], [[j:TracyHarms|J wiki]] +*[[User:DanBron|Dan Bron]]: [[Special:Contributions/DanBron|contributions]], [[j:DanBron|J wiki]] +*[[User:Gaaijz|Arie Groeneveld]]: [[Special:Contributions/Gaaijz|contributions]] +*[[User:Rdm|Raul Miller]]: [[Special:Contributions/Rdm|contributions]], [[j:Raul_Miller|J wiki]] +*[[User:96.57.161.34|Jose Quintana]]: [[Special:Contributions/96.57.161.34|contributions]], [[j:Stories/JoseQuintana|J wiki]] +*[[User:tikkanz|Ric Sherlock]]: [[Special:Contributions/tikkanz|contributions]], [[j:RicSherlock|J wiki]] +*[[User:Avmich|Avmich]]: [[Special:Contributions/Avmich|contributions]] +*[[User:VZC|VZC]]: [[Special:Contributions/VZC|contributions]] +*[[User:Bathala|Alex 'bathala' Rufon]]: [[Special:Contributions/Bathala|contributions]], [[j:bathala|J wiki]] +*[[User:Lambertdw|David Lambert]]:[[Special:Contributions/Lambertdw|contributions]] + +== try me == + +Want to try one of those cryptic J lines you see peppered through RC? Try pasting it into the [http://erxz.com:10080/ web interface for buubot '''(broken link)'''] (a [[Perl]] IRC bot which has a J evaluation mode: just prefix your line with '''''jeval'''''). + +If you want to be a bit more interactive, and get some guidance from J gurus, you can join the actual J IRC channel on Freenode, #jsoftware. Buubot and several other J eval bots run there. If you don't have an IRC client you can try [http://webchat.freenode.net/?randomnick=1&channels=jsoftware freenode's web interface] (or just [http://webchat.freenode.net/?channels=jsoftware&randomnick=1 give it a quick spin]). More [[j:Community/IRC|details about the J IRC community]] is available. + +If any of that piques your interest, and you want to explore a little more, you can [http://www.jsoftware.com/stable.htm download J] and [http://www.jsoftware.com/forums.htm join the J forums]. \ No newline at end of file diff --git a/Lang/J/100-doors b/Lang/J/100-doors new file mode 120000 index 0000000000..cd10b80d46 --- /dev/null +++ b/Lang/J/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/J \ No newline at end of file diff --git a/Lang/J/24-game b/Lang/J/24-game new file mode 120000 index 0000000000..57d5b08d35 --- /dev/null +++ b/Lang/J/24-game @@ -0,0 +1 @@ +../../Task/24-game/J \ No newline at end of file diff --git a/Lang/J/24-game-Solve b/Lang/J/24-game-Solve new file mode 120000 index 0000000000..8be80dd893 --- /dev/null +++ b/Lang/J/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/J \ No newline at end of file diff --git a/Lang/J/99-Bottles-of-Beer b/Lang/J/99-Bottles-of-Beer new file mode 120000 index 0000000000..56aabf342d --- /dev/null +++ b/Lang/J/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/J \ No newline at end of file diff --git a/Lang/J/A+B b/Lang/J/A+B new file mode 120000 index 0000000000..e49bdd2dbd --- /dev/null +++ b/Lang/J/A+B @@ -0,0 +1 @@ +../../Task/A+B/J \ No newline at end of file diff --git a/Lang/J/Accumulator-factory b/Lang/J/Accumulator-factory new file mode 120000 index 0000000000..013fe785ad --- /dev/null +++ b/Lang/J/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/J \ No newline at end of file diff --git a/Lang/J/Ackermann-function b/Lang/J/Ackermann-function new file mode 120000 index 0000000000..96ec399392 --- /dev/null +++ b/Lang/J/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/J \ No newline at end of file diff --git a/Lang/J/Add-a-variable-to-a-class-instance-at-runtime b/Lang/J/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..af6af78e98 --- /dev/null +++ b/Lang/J/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/J \ No newline at end of file diff --git a/Lang/J/Align-columns b/Lang/J/Align-columns new file mode 120000 index 0000000000..4de9e1cd24 --- /dev/null +++ b/Lang/J/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/J \ No newline at end of file diff --git a/Lang/J/Anagrams-Deranged-anagrams b/Lang/J/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..3e39aa49fa --- /dev/null +++ b/Lang/J/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/J \ No newline at end of file diff --git a/Lang/J/Animate-a-pendulum b/Lang/J/Animate-a-pendulum new file mode 120000 index 0000000000..29effa3f1d --- /dev/null +++ b/Lang/J/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/J \ No newline at end of file diff --git a/Lang/J/Animation b/Lang/J/Animation new file mode 120000 index 0000000000..b826f64ed9 --- /dev/null +++ b/Lang/J/Animation @@ -0,0 +1 @@ +../../Task/Animation/J \ No newline at end of file diff --git a/Lang/J/Anonymous-recursion b/Lang/J/Anonymous-recursion new file mode 120000 index 0000000000..633416015e --- /dev/null +++ b/Lang/J/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/J \ No newline at end of file diff --git a/Lang/J/Apply-a-callback-to-an-array b/Lang/J/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..ace594ae10 --- /dev/null +++ b/Lang/J/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/J \ No newline at end of file diff --git a/Lang/J/Arbitrary-precision-integers-included b/Lang/J/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..117a4a0f52 --- /dev/null +++ b/Lang/J/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/J \ No newline at end of file diff --git a/Lang/J/Arena-storage-pool b/Lang/J/Arena-storage-pool new file mode 120000 index 0000000000..cc1437b816 --- /dev/null +++ b/Lang/J/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/J \ No newline at end of file diff --git a/Lang/J/Arithmetic-Complex b/Lang/J/Arithmetic-Complex new file mode 120000 index 0000000000..3536cd305e --- /dev/null +++ b/Lang/J/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/J \ No newline at end of file diff --git a/Lang/J/Arithmetic-Integer b/Lang/J/Arithmetic-Integer new file mode 120000 index 0000000000..24e400b815 --- /dev/null +++ b/Lang/J/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/J \ No newline at end of file diff --git a/Lang/J/Arithmetic-Rational b/Lang/J/Arithmetic-Rational new file mode 120000 index 0000000000..5081e7c2b5 --- /dev/null +++ b/Lang/J/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/J \ No newline at end of file diff --git a/Lang/J/Arithmetic-evaluation b/Lang/J/Arithmetic-evaluation new file mode 120000 index 0000000000..780eb402c4 --- /dev/null +++ b/Lang/J/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/J \ No newline at end of file diff --git a/Lang/J/Arithmetic-geometric-mean b/Lang/J/Arithmetic-geometric-mean new file mode 120000 index 0000000000..a4dc09e8b8 --- /dev/null +++ b/Lang/J/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/J \ No newline at end of file diff --git a/Lang/J/Array-concatenation b/Lang/J/Array-concatenation new file mode 120000 index 0000000000..a65ecbd9c2 --- /dev/null +++ b/Lang/J/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/J \ No newline at end of file diff --git a/Lang/J/Arrays b/Lang/J/Arrays new file mode 120000 index 0000000000..777bb701c7 --- /dev/null +++ b/Lang/J/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/J \ No newline at end of file diff --git a/Lang/J/Assertions b/Lang/J/Assertions new file mode 120000 index 0000000000..c7a068327b --- /dev/null +++ b/Lang/J/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/J \ No newline at end of file diff --git a/Lang/J/Associative-array-Creation b/Lang/J/Associative-array-Creation new file mode 120000 index 0000000000..a0da6b6506 --- /dev/null +++ b/Lang/J/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/J \ No newline at end of file diff --git a/Lang/J/Associative-array-Iteration b/Lang/J/Associative-array-Iteration new file mode 120000 index 0000000000..e0914db06e --- /dev/null +++ b/Lang/J/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/J \ No newline at end of file diff --git a/Lang/J/Average-loop-length b/Lang/J/Average-loop-length new file mode 120000 index 0000000000..eea7b11d5d --- /dev/null +++ b/Lang/J/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/J \ No newline at end of file diff --git a/Lang/J/Averages-Arithmetic-mean b/Lang/J/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f3a8440d0a --- /dev/null +++ b/Lang/J/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/J \ No newline at end of file diff --git a/Lang/J/Averages-Mean-angle b/Lang/J/Averages-Mean-angle new file mode 120000 index 0000000000..1bb037abc9 --- /dev/null +++ b/Lang/J/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/J \ No newline at end of file diff --git a/Lang/J/Averages-Mean-time-of-day b/Lang/J/Averages-Mean-time-of-day new file mode 120000 index 0000000000..a49dad33c8 --- /dev/null +++ b/Lang/J/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/J \ No newline at end of file diff --git a/Lang/J/Averages-Median b/Lang/J/Averages-Median new file mode 120000 index 0000000000..07ee86dfb3 --- /dev/null +++ b/Lang/J/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/J \ No newline at end of file diff --git a/Lang/J/Averages-Mode b/Lang/J/Averages-Mode new file mode 120000 index 0000000000..8436bfa761 --- /dev/null +++ b/Lang/J/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/J \ No newline at end of file diff --git a/Lang/J/Averages-Pythagorean-means b/Lang/J/Averages-Pythagorean-means new file mode 120000 index 0000000000..4c682cf06a --- /dev/null +++ b/Lang/J/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/J \ No newline at end of file diff --git a/Lang/J/Averages-Root-mean-square b/Lang/J/Averages-Root-mean-square new file mode 120000 index 0000000000..8e4dabe7d5 --- /dev/null +++ b/Lang/J/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/J \ No newline at end of file diff --git a/Lang/J/Averages-Simple-moving-average b/Lang/J/Averages-Simple-moving-average new file mode 120000 index 0000000000..357211ea06 --- /dev/null +++ b/Lang/J/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/J \ No newline at end of file diff --git a/Lang/J/Balanced-brackets b/Lang/J/Balanced-brackets new file mode 120000 index 0000000000..b57dc8c36c --- /dev/null +++ b/Lang/J/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/J \ No newline at end of file diff --git a/Lang/J/Balanced-ternary b/Lang/J/Balanced-ternary new file mode 120000 index 0000000000..2fe33347fb --- /dev/null +++ b/Lang/J/Balanced-ternary @@ -0,0 +1 @@ +../../Task/Balanced-ternary/J \ No newline at end of file diff --git a/Lang/J/Best-shuffle b/Lang/J/Best-shuffle new file mode 120000 index 0000000000..381d32135f --- /dev/null +++ b/Lang/J/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/J \ No newline at end of file diff --git a/Lang/J/Binary-search b/Lang/J/Binary-search new file mode 120000 index 0000000000..1560a1521f --- /dev/null +++ b/Lang/J/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/J \ No newline at end of file diff --git a/Lang/J/Binary-strings b/Lang/J/Binary-strings new file mode 120000 index 0000000000..c433b039e6 --- /dev/null +++ b/Lang/J/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/J \ No newline at end of file diff --git a/Lang/J/Bitmap b/Lang/J/Bitmap new file mode 120000 index 0000000000..951215757d --- /dev/null +++ b/Lang/J/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/J \ No newline at end of file diff --git a/Lang/J/Bitmap-B-zier-curves-Cubic b/Lang/J/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..9a3a3f3f9c --- /dev/null +++ b/Lang/J/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Bresenhams-line-algorithm b/Lang/J/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..354f47eee3 --- /dev/null +++ b/Lang/J/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Flood-fill b/Lang/J/Bitmap-Flood-fill new file mode 120000 index 0000000000..7ea6f2998f --- /dev/null +++ b/Lang/J/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Histogram b/Lang/J/Bitmap-Histogram new file mode 120000 index 0000000000..c41f565cac --- /dev/null +++ b/Lang/J/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Midpoint-circle-algorithm b/Lang/J/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..f0ac705746 --- /dev/null +++ b/Lang/J/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Read-a-PPM-file b/Lang/J/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..57a2163606 --- /dev/null +++ b/Lang/J/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/J \ No newline at end of file diff --git a/Lang/J/Bitmap-Write-a-PPM-file b/Lang/J/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..e9dac4a178 --- /dev/null +++ b/Lang/J/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/J \ No newline at end of file diff --git a/Lang/J/Bitwise-IO b/Lang/J/Bitwise-IO new file mode 120000 index 0000000000..8d57d91630 --- /dev/null +++ b/Lang/J/Bitwise-IO @@ -0,0 +1 @@ +../../Task/Bitwise-IO/J \ No newline at end of file diff --git a/Lang/J/Bitwise-operations b/Lang/J/Bitwise-operations new file mode 120000 index 0000000000..4055df40f6 --- /dev/null +++ b/Lang/J/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/J \ No newline at end of file diff --git a/Lang/J/Box-the-compass b/Lang/J/Box-the-compass new file mode 120000 index 0000000000..1ffe50d0b4 --- /dev/null +++ b/Lang/J/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/J \ No newline at end of file diff --git a/Lang/J/Bulls-and-cows b/Lang/J/Bulls-and-cows new file mode 120000 index 0000000000..47daf3c886 --- /dev/null +++ b/Lang/J/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/J \ No newline at end of file diff --git a/Lang/J/Bulls-and-cows-Player b/Lang/J/Bulls-and-cows-Player new file mode 120000 index 0000000000..4360897064 --- /dev/null +++ b/Lang/J/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/J \ No newline at end of file diff --git a/Lang/J/CRC-32 b/Lang/J/CRC-32 new file mode 120000 index 0000000000..cb74b3933b --- /dev/null +++ b/Lang/J/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/J \ No newline at end of file diff --git a/Lang/J/CSV-to-HTML-translation b/Lang/J/CSV-to-HTML-translation new file mode 120000 index 0000000000..979c356e6d --- /dev/null +++ b/Lang/J/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/J \ No newline at end of file diff --git a/Lang/J/Caesar-cipher b/Lang/J/Caesar-cipher new file mode 120000 index 0000000000..f3e57f8f14 --- /dev/null +++ b/Lang/J/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/J \ No newline at end of file diff --git a/Lang/J/Calendar b/Lang/J/Calendar new file mode 120000 index 0000000000..e6e62a5b51 --- /dev/null +++ b/Lang/J/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/J \ No newline at end of file diff --git a/Lang/J/Calendar-for-real-programmers b/Lang/J/Calendar-for-real-programmers new file mode 120000 index 0000000000..e1a87250b6 --- /dev/null +++ b/Lang/J/Calendar-for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar-for-real-programmers/J \ No newline at end of file diff --git a/Lang/J/Call-a-foreign-language-function b/Lang/J/Call-a-foreign-language-function new file mode 120000 index 0000000000..d5f81865b8 --- /dev/null +++ b/Lang/J/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/J \ No newline at end of file diff --git a/Lang/J/Call-a-function b/Lang/J/Call-a-function new file mode 120000 index 0000000000..02a4ab1e05 --- /dev/null +++ b/Lang/J/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/J \ No newline at end of file diff --git a/Lang/J/Call-a-function-in-a-shared-library b/Lang/J/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..0e696de92c --- /dev/null +++ b/Lang/J/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/J \ No newline at end of file diff --git a/Lang/J/Call-an-object-method b/Lang/J/Call-an-object-method new file mode 120000 index 0000000000..b4a9a5a573 --- /dev/null +++ b/Lang/J/Call-an-object-method @@ -0,0 +1 @@ +../../Task/Call-an-object-method/J \ No newline at end of file diff --git a/Lang/J/Case-sensitivity-of-identifiers b/Lang/J/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..faf7d11a65 --- /dev/null +++ b/Lang/J/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/J \ No newline at end of file diff --git a/Lang/J/Catmull-Clark-subdivision-surface b/Lang/J/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..05a66cc21e --- /dev/null +++ b/Lang/J/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/J \ No newline at end of file diff --git a/Lang/J/Character-codes b/Lang/J/Character-codes new file mode 120000 index 0000000000..444fdb3a1e --- /dev/null +++ b/Lang/J/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/J \ No newline at end of file diff --git a/Lang/J/Character-matching b/Lang/J/Character-matching new file mode 120000 index 0000000000..602547d09b --- /dev/null +++ b/Lang/J/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/J \ No newline at end of file diff --git a/Lang/J/Check-Machin-like-formulas b/Lang/J/Check-Machin-like-formulas new file mode 120000 index 0000000000..c315785d8b --- /dev/null +++ b/Lang/J/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/J \ No newline at end of file diff --git a/Lang/J/Check-that-file-exists b/Lang/J/Check-that-file-exists new file mode 120000 index 0000000000..87b2e9a543 --- /dev/null +++ b/Lang/J/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/J \ No newline at end of file diff --git a/Lang/J/Cholesky-decomposition b/Lang/J/Cholesky-decomposition new file mode 120000 index 0000000000..c1ff2bc999 --- /dev/null +++ b/Lang/J/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/J \ No newline at end of file diff --git a/Lang/J/Classes b/Lang/J/Classes new file mode 120000 index 0000000000..980684af30 --- /dev/null +++ b/Lang/J/Classes @@ -0,0 +1 @@ +../../Task/Classes/J \ No newline at end of file diff --git a/Lang/J/Closest-pair-problem b/Lang/J/Closest-pair-problem new file mode 120000 index 0000000000..68507b53ca --- /dev/null +++ b/Lang/J/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/J \ No newline at end of file diff --git a/Lang/J/Collections b/Lang/J/Collections new file mode 120000 index 0000000000..49e1dd7110 --- /dev/null +++ b/Lang/J/Collections @@ -0,0 +1 @@ +../../Task/Collections/J \ No newline at end of file diff --git a/Lang/J/Color-quantization b/Lang/J/Color-quantization new file mode 120000 index 0000000000..a4700f272c --- /dev/null +++ b/Lang/J/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/J \ No newline at end of file diff --git a/Lang/J/Colour-bars-Display b/Lang/J/Colour-bars-Display new file mode 120000 index 0000000000..4341878ed1 --- /dev/null +++ b/Lang/J/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/J \ No newline at end of file diff --git a/Lang/J/Colour-pinstripe-Display b/Lang/J/Colour-pinstripe-Display new file mode 120000 index 0000000000..05d5bfb2ba --- /dev/null +++ b/Lang/J/Colour-pinstripe-Display @@ -0,0 +1 @@ +../../Task/Colour-pinstripe-Display/J \ No newline at end of file diff --git a/Lang/J/Combinations b/Lang/J/Combinations new file mode 120000 index 0000000000..cf5e4db0a6 --- /dev/null +++ b/Lang/J/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/J \ No newline at end of file diff --git a/Lang/J/Combinations-with-repetitions b/Lang/J/Combinations-with-repetitions new file mode 120000 index 0000000000..53e0b3a898 --- /dev/null +++ b/Lang/J/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/J \ No newline at end of file diff --git a/Lang/J/Command-line-arguments b/Lang/J/Command-line-arguments new file mode 120000 index 0000000000..31448b1bbd --- /dev/null +++ b/Lang/J/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/J \ No newline at end of file diff --git a/Lang/J/Comments b/Lang/J/Comments new file mode 120000 index 0000000000..64bdc23bf4 --- /dev/null +++ b/Lang/J/Comments @@ -0,0 +1 @@ +../../Task/Comments/J \ No newline at end of file diff --git a/Lang/J/Compare-sorting-algorithms-performance b/Lang/J/Compare-sorting-algorithms-performance new file mode 120000 index 0000000000..093367d052 --- /dev/null +++ b/Lang/J/Compare-sorting-algorithms-performance @@ -0,0 +1 @@ +../../Task/Compare-sorting-algorithms-performance/J \ No newline at end of file diff --git a/Lang/J/Compile-time-calculation b/Lang/J/Compile-time-calculation new file mode 120000 index 0000000000..ccf014e6df --- /dev/null +++ b/Lang/J/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/J \ No newline at end of file diff --git a/Lang/J/Compound-data-type b/Lang/J/Compound-data-type new file mode 120000 index 0000000000..34c2286d9b --- /dev/null +++ b/Lang/J/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/J \ No newline at end of file diff --git a/Lang/J/Concurrent-computing b/Lang/J/Concurrent-computing new file mode 120000 index 0000000000..efbfb72a08 --- /dev/null +++ b/Lang/J/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/J \ No newline at end of file diff --git a/Lang/J/Constrained-genericity b/Lang/J/Constrained-genericity new file mode 120000 index 0000000000..6a2dbca754 --- /dev/null +++ b/Lang/J/Constrained-genericity @@ -0,0 +1 @@ +../../Task/Constrained-genericity/J \ No newline at end of file diff --git a/Lang/J/Constrained-random-points-on-a-circle b/Lang/J/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..db7d694279 --- /dev/null +++ b/Lang/J/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/J \ No newline at end of file diff --git a/Lang/J/Continued-fraction b/Lang/J/Continued-fraction new file mode 120000 index 0000000000..ad74986175 --- /dev/null +++ b/Lang/J/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/J \ No newline at end of file diff --git a/Lang/J/Conways-Game-of-Life b/Lang/J/Conways-Game-of-Life new file mode 120000 index 0000000000..db5b16f6a3 --- /dev/null +++ b/Lang/J/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/J \ No newline at end of file diff --git a/Lang/J/Count-in-factors b/Lang/J/Count-in-factors new file mode 120000 index 0000000000..9e9c3b07b3 --- /dev/null +++ b/Lang/J/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/J \ No newline at end of file diff --git a/Lang/J/Count-in-octal b/Lang/J/Count-in-octal new file mode 120000 index 0000000000..34e6b1c112 --- /dev/null +++ b/Lang/J/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/J \ No newline at end of file diff --git a/Lang/J/Count-occurrences-of-a-substring b/Lang/J/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..7d811dffac --- /dev/null +++ b/Lang/J/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/J \ No newline at end of file diff --git a/Lang/J/Count-the-coins b/Lang/J/Count-the-coins new file mode 120000 index 0000000000..38d3ced70f --- /dev/null +++ b/Lang/J/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/J \ No newline at end of file diff --git a/Lang/J/Create-a-file b/Lang/J/Create-a-file new file mode 120000 index 0000000000..6fa468cbc2 --- /dev/null +++ b/Lang/J/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/J \ No newline at end of file diff --git a/Lang/J/Create-a-two-dimensional-array-at-runtime b/Lang/J/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..0fcbc5ae49 --- /dev/null +++ b/Lang/J/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/J \ No newline at end of file diff --git a/Lang/J/Create-an-HTML-table b/Lang/J/Create-an-HTML-table new file mode 120000 index 0000000000..d4418170d0 --- /dev/null +++ b/Lang/J/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/J \ No newline at end of file diff --git a/Lang/J/Cut-a-rectangle b/Lang/J/Cut-a-rectangle new file mode 120000 index 0000000000..9ad4635188 --- /dev/null +++ b/Lang/J/Cut-a-rectangle @@ -0,0 +1 @@ +../../Task/Cut-a-rectangle/J \ No newline at end of file diff --git a/Lang/J/Date-format b/Lang/J/Date-format new file mode 120000 index 0000000000..a38eb4763f --- /dev/null +++ b/Lang/J/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/J \ No newline at end of file diff --git a/Lang/J/Day-of-the-week b/Lang/J/Day-of-the-week new file mode 120000 index 0000000000..3fc531c455 --- /dev/null +++ b/Lang/J/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/J \ No newline at end of file diff --git a/Lang/J/Deal-cards-for-FreeCell b/Lang/J/Deal-cards-for-FreeCell new file mode 120000 index 0000000000..b43513580b --- /dev/null +++ b/Lang/J/Deal-cards-for-FreeCell @@ -0,0 +1 @@ +../../Task/Deal-cards-for-FreeCell/J \ No newline at end of file diff --git a/Lang/J/Death-Star b/Lang/J/Death-Star new file mode 120000 index 0000000000..e6801c41d7 --- /dev/null +++ b/Lang/J/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/J \ No newline at end of file diff --git a/Lang/J/Deconvolution-1D b/Lang/J/Deconvolution-1D new file mode 120000 index 0000000000..d14445db32 --- /dev/null +++ b/Lang/J/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/J \ No newline at end of file diff --git a/Lang/J/Deconvolution-2D+ b/Lang/J/Deconvolution-2D+ new file mode 120000 index 0000000000..8e8bc0d8fb --- /dev/null +++ b/Lang/J/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/J \ No newline at end of file diff --git a/Lang/J/Deepcopy b/Lang/J/Deepcopy new file mode 120000 index 0000000000..6f3da411eb --- /dev/null +++ b/Lang/J/Deepcopy @@ -0,0 +1 @@ +../../Task/Deepcopy/J \ No newline at end of file diff --git a/Lang/J/Delegates b/Lang/J/Delegates new file mode 120000 index 0000000000..b7cd6c942b --- /dev/null +++ b/Lang/J/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/J \ No newline at end of file diff --git a/Lang/J/Delete-a-file b/Lang/J/Delete-a-file new file mode 120000 index 0000000000..180255025c --- /dev/null +++ b/Lang/J/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/J \ No newline at end of file diff --git a/Lang/J/Detect-division-by-zero b/Lang/J/Detect-division-by-zero new file mode 120000 index 0000000000..1cf48e83c7 --- /dev/null +++ b/Lang/J/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/J \ No newline at end of file diff --git a/Lang/J/Determine-if-a-string-is-numeric b/Lang/J/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..09b29100c0 --- /dev/null +++ b/Lang/J/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/J \ No newline at end of file diff --git a/Lang/J/Digital-root b/Lang/J/Digital-root new file mode 120000 index 0000000000..4ec168c586 --- /dev/null +++ b/Lang/J/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/J \ No newline at end of file diff --git a/Lang/J/Dinesmans-multiple-dwelling-problem b/Lang/J/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..0b48fe7729 --- /dev/null +++ b/Lang/J/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/J \ No newline at end of file diff --git a/Lang/J/Discordian-date b/Lang/J/Discordian-date new file mode 120000 index 0000000000..5ca5f7bb42 --- /dev/null +++ b/Lang/J/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/J \ No newline at end of file diff --git a/Lang/J/Documentation b/Lang/J/Documentation new file mode 120000 index 0000000000..63ebf91a1a --- /dev/null +++ b/Lang/J/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/J \ No newline at end of file diff --git a/Lang/J/Dot-product b/Lang/J/Dot-product new file mode 120000 index 0000000000..d8f4d1de80 --- /dev/null +++ b/Lang/J/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/J \ No newline at end of file diff --git a/Lang/J/Doubly-linked-list-Element-definition b/Lang/J/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..cdb2d55a24 --- /dev/null +++ b/Lang/J/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/J \ No newline at end of file diff --git a/Lang/J/Doubly-linked-list-Traversal b/Lang/J/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..4586fe7098 --- /dev/null +++ b/Lang/J/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/J \ No newline at end of file diff --git a/Lang/J/Draw-a-cuboid b/Lang/J/Draw-a-cuboid new file mode 120000 index 0000000000..adbc1c85e0 --- /dev/null +++ b/Lang/J/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/J \ No newline at end of file diff --git a/Lang/J/Draw-a-sphere b/Lang/J/Draw-a-sphere new file mode 120000 index 0000000000..a6dc07431f --- /dev/null +++ b/Lang/J/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/J \ No newline at end of file diff --git a/Lang/J/Dutch-national-flag-problem b/Lang/J/Dutch-national-flag-problem new file mode 120000 index 0000000000..a83800e7d0 --- /dev/null +++ b/Lang/J/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/J \ No newline at end of file diff --git a/Lang/J/Dynamic-variable-names b/Lang/J/Dynamic-variable-names new file mode 120000 index 0000000000..6bbe1b96b1 --- /dev/null +++ b/Lang/J/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/J \ No newline at end of file diff --git a/Lang/J/Element-wise-operations b/Lang/J/Element-wise-operations new file mode 120000 index 0000000000..372c31e359 --- /dev/null +++ b/Lang/J/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/J \ No newline at end of file diff --git a/Lang/J/Empty-directory b/Lang/J/Empty-directory new file mode 120000 index 0000000000..d30a0be86b --- /dev/null +++ b/Lang/J/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/J \ No newline at end of file diff --git a/Lang/J/Empty-program b/Lang/J/Empty-program new file mode 120000 index 0000000000..0c864feecb --- /dev/null +++ b/Lang/J/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/J \ No newline at end of file diff --git a/Lang/J/Empty-string b/Lang/J/Empty-string new file mode 120000 index 0000000000..575d2b309c --- /dev/null +++ b/Lang/J/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/J \ No newline at end of file diff --git a/Lang/J/Enforced-immutability b/Lang/J/Enforced-immutability new file mode 120000 index 0000000000..f7ed9ebc4c --- /dev/null +++ b/Lang/J/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/J \ No newline at end of file diff --git a/Lang/J/Entropy b/Lang/J/Entropy new file mode 120000 index 0000000000..ad11630f4f --- /dev/null +++ b/Lang/J/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/J \ No newline at end of file diff --git a/Lang/J/Enumerations b/Lang/J/Enumerations new file mode 120000 index 0000000000..99f6ac7321 --- /dev/null +++ b/Lang/J/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/J \ No newline at end of file diff --git a/Lang/J/Equilibrium-index b/Lang/J/Equilibrium-index new file mode 120000 index 0000000000..60bb9f2036 --- /dev/null +++ b/Lang/J/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/J \ No newline at end of file diff --git a/Lang/J/Ethiopian-multiplication b/Lang/J/Ethiopian-multiplication new file mode 120000 index 0000000000..c63eebfa37 --- /dev/null +++ b/Lang/J/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/J \ No newline at end of file diff --git a/Lang/J/Euler-method b/Lang/J/Euler-method new file mode 120000 index 0000000000..160605f56e --- /dev/null +++ b/Lang/J/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/J \ No newline at end of file diff --git a/Lang/J/Evaluate-binomial-coefficients b/Lang/J/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..766a36469e --- /dev/null +++ b/Lang/J/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/J \ No newline at end of file diff --git a/Lang/J/Even-or-odd b/Lang/J/Even-or-odd new file mode 120000 index 0000000000..ea6078ee11 --- /dev/null +++ b/Lang/J/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/J \ No newline at end of file diff --git a/Lang/J/Evolutionary-algorithm b/Lang/J/Evolutionary-algorithm new file mode 120000 index 0000000000..d70fbd8885 --- /dev/null +++ b/Lang/J/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/J \ No newline at end of file diff --git a/Lang/J/Exceptions b/Lang/J/Exceptions new file mode 120000 index 0000000000..399e576bad --- /dev/null +++ b/Lang/J/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/J \ No newline at end of file diff --git a/Lang/J/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/J/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..265d56df83 --- /dev/null +++ b/Lang/J/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J \ No newline at end of file diff --git a/Lang/J/Executable-library b/Lang/J/Executable-library new file mode 120000 index 0000000000..120c0430fc --- /dev/null +++ b/Lang/J/Executable-library @@ -0,0 +1 @@ +../../Task/Executable-library/J \ No newline at end of file diff --git a/Lang/J/Execute-HQ9+ b/Lang/J/Execute-HQ9+ new file mode 120000 index 0000000000..9f7fae34be --- /dev/null +++ b/Lang/J/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/J \ No newline at end of file diff --git a/Lang/J/Execute-a-system-command b/Lang/J/Execute-a-system-command new file mode 120000 index 0000000000..d9d6faece3 --- /dev/null +++ b/Lang/J/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/J \ No newline at end of file diff --git a/Lang/J/Exponentiation-operator b/Lang/J/Exponentiation-operator new file mode 120000 index 0000000000..ab0d1e8426 --- /dev/null +++ b/Lang/J/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/J \ No newline at end of file diff --git a/Lang/J/Extend-your-language b/Lang/J/Extend-your-language new file mode 120000 index 0000000000..e2fe71c093 --- /dev/null +++ b/Lang/J/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/J \ No newline at end of file diff --git a/Lang/J/Extreme-floating-point-values b/Lang/J/Extreme-floating-point-values new file mode 120000 index 0000000000..573bd7b3d1 --- /dev/null +++ b/Lang/J/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/J \ No newline at end of file diff --git a/Lang/J/Factorial b/Lang/J/Factorial new file mode 120000 index 0000000000..4e4690ab92 --- /dev/null +++ b/Lang/J/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/J \ No newline at end of file diff --git a/Lang/J/Factors-of-a-Mersenne-number b/Lang/J/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..88fc2af9b0 --- /dev/null +++ b/Lang/J/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/J \ No newline at end of file diff --git a/Lang/J/Factors-of-an-integer b/Lang/J/Factors-of-an-integer new file mode 120000 index 0000000000..846ac8481a --- /dev/null +++ b/Lang/J/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/J \ No newline at end of file diff --git a/Lang/J/Fast-Fourier-transform b/Lang/J/Fast-Fourier-transform new file mode 120000 index 0000000000..7678933a7b --- /dev/null +++ b/Lang/J/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/J \ No newline at end of file diff --git a/Lang/J/Fibonacci-n-step-number-sequences b/Lang/J/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..3739279b30 --- /dev/null +++ b/Lang/J/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/J \ No newline at end of file diff --git a/Lang/J/Fibonacci-sequence b/Lang/J/Fibonacci-sequence new file mode 120000 index 0000000000..e9b0aba458 --- /dev/null +++ b/Lang/J/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/J \ No newline at end of file diff --git a/Lang/J/File-IO b/Lang/J/File-IO new file mode 120000 index 0000000000..602773ed27 --- /dev/null +++ b/Lang/J/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/J \ No newline at end of file diff --git a/Lang/J/File-modification-time b/Lang/J/File-modification-time new file mode 120000 index 0000000000..21e8659358 --- /dev/null +++ b/Lang/J/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/J \ No newline at end of file diff --git a/Lang/J/File-size b/Lang/J/File-size new file mode 120000 index 0000000000..8796a0fcbe --- /dev/null +++ b/Lang/J/File-size @@ -0,0 +1 @@ +../../Task/File-size/J \ No newline at end of file diff --git a/Lang/J/Filter b/Lang/J/Filter new file mode 120000 index 0000000000..7a725882e1 --- /dev/null +++ b/Lang/J/Filter @@ -0,0 +1 @@ +../../Task/Filter/J \ No newline at end of file diff --git a/Lang/J/Find-common-directory-path b/Lang/J/Find-common-directory-path new file mode 120000 index 0000000000..29caaf33b6 --- /dev/null +++ b/Lang/J/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/J \ No newline at end of file diff --git a/Lang/J/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/J/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..96199971f8 --- /dev/null +++ b/Lang/J/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/J \ No newline at end of file diff --git a/Lang/J/Find-limit-of-recursion b/Lang/J/Find-limit-of-recursion new file mode 120000 index 0000000000..8b38a0410c --- /dev/null +++ b/Lang/J/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/J \ No newline at end of file diff --git a/Lang/J/Find-the-missing-permutation b/Lang/J/Find-the-missing-permutation new file mode 120000 index 0000000000..4d5dbc8a24 --- /dev/null +++ b/Lang/J/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/J \ No newline at end of file diff --git a/Lang/J/First-class-environments b/Lang/J/First-class-environments new file mode 120000 index 0000000000..3530096f2e --- /dev/null +++ b/Lang/J/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/J \ No newline at end of file diff --git a/Lang/J/First-class-functions b/Lang/J/First-class-functions new file mode 120000 index 0000000000..a6df6b6f1e --- /dev/null +++ b/Lang/J/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/J \ No newline at end of file diff --git a/Lang/J/First-class-functions-Use-numbers-analogously b/Lang/J/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..8a86660a62 --- /dev/null +++ b/Lang/J/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/J \ No newline at end of file diff --git a/Lang/J/Five-weekends b/Lang/J/Five-weekends new file mode 120000 index 0000000000..3da568cfc8 --- /dev/null +++ b/Lang/J/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/J \ No newline at end of file diff --git a/Lang/J/FizzBuzz b/Lang/J/FizzBuzz new file mode 120000 index 0000000000..ecff906185 --- /dev/null +++ b/Lang/J/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/J \ No newline at end of file diff --git a/Lang/J/Flatten-a-list b/Lang/J/Flatten-a-list new file mode 120000 index 0000000000..65d9ffd3d6 --- /dev/null +++ b/Lang/J/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/J \ No newline at end of file diff --git a/Lang/J/Flow-control-structures b/Lang/J/Flow-control-structures new file mode 120000 index 0000000000..829fc3e079 --- /dev/null +++ b/Lang/J/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/J \ No newline at end of file diff --git a/Lang/J/Floyds-triangle b/Lang/J/Floyds-triangle new file mode 120000 index 0000000000..3f12a5b8cb --- /dev/null +++ b/Lang/J/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/J \ No newline at end of file diff --git a/Lang/J/Forest-fire b/Lang/J/Forest-fire new file mode 120000 index 0000000000..c64c5d89f8 --- /dev/null +++ b/Lang/J/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/J \ No newline at end of file diff --git a/Lang/J/Formal-power-series b/Lang/J/Formal-power-series new file mode 120000 index 0000000000..57c962b0f1 --- /dev/null +++ b/Lang/J/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/J \ No newline at end of file diff --git a/Lang/J/Formatted-numeric-output b/Lang/J/Formatted-numeric-output new file mode 120000 index 0000000000..f4afdc2553 --- /dev/null +++ b/Lang/J/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/J \ No newline at end of file diff --git a/Lang/J/Forward-difference b/Lang/J/Forward-difference new file mode 120000 index 0000000000..3cb5e22aed --- /dev/null +++ b/Lang/J/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/J \ No newline at end of file diff --git a/Lang/J/Four-bit-adder b/Lang/J/Four-bit-adder new file mode 120000 index 0000000000..1b40b30a02 --- /dev/null +++ b/Lang/J/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/J \ No newline at end of file diff --git a/Lang/J/Fractal-tree b/Lang/J/Fractal-tree new file mode 120000 index 0000000000..efecd558c4 --- /dev/null +++ b/Lang/J/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/J \ No newline at end of file diff --git a/Lang/J/Function-composition b/Lang/J/Function-composition new file mode 120000 index 0000000000..f8c21342bf --- /dev/null +++ b/Lang/J/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/J \ No newline at end of file diff --git a/Lang/J/Function-definition b/Lang/J/Function-definition new file mode 120000 index 0000000000..2ba74120f0 --- /dev/null +++ b/Lang/J/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/J \ No newline at end of file diff --git a/Lang/J/Function-frequency b/Lang/J/Function-frequency new file mode 120000 index 0000000000..a91bd8adf1 --- /dev/null +++ b/Lang/J/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/J \ No newline at end of file diff --git a/Lang/J/GUI-component-interaction b/Lang/J/GUI-component-interaction new file mode 120000 index 0000000000..b189017ec5 --- /dev/null +++ b/Lang/J/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/J \ No newline at end of file diff --git a/Lang/J/GUI-enabling-disabling-of-controls b/Lang/J/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..a2357cd475 --- /dev/null +++ b/Lang/J/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/J \ No newline at end of file diff --git a/Lang/J/Galton-box-animation b/Lang/J/Galton-box-animation new file mode 120000 index 0000000000..fdd9e74767 --- /dev/null +++ b/Lang/J/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/J \ No newline at end of file diff --git a/Lang/J/Gamma-function b/Lang/J/Gamma-function new file mode 120000 index 0000000000..f6db3a853a --- /dev/null +++ b/Lang/J/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/J \ No newline at end of file diff --git a/Lang/J/Generator-Exponential b/Lang/J/Generator-Exponential new file mode 120000 index 0000000000..a706e84eeb --- /dev/null +++ b/Lang/J/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/J \ No newline at end of file diff --git a/Lang/J/Generic-swap b/Lang/J/Generic-swap new file mode 120000 index 0000000000..4b34aefd95 --- /dev/null +++ b/Lang/J/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/J \ No newline at end of file diff --git a/Lang/J/Globally-replace-text-in-several-files b/Lang/J/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..bf0e79fe7f --- /dev/null +++ b/Lang/J/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/J \ No newline at end of file diff --git a/Lang/J/Gray-code b/Lang/J/Gray-code new file mode 120000 index 0000000000..20909bec2b --- /dev/null +++ b/Lang/J/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/J \ No newline at end of file diff --git a/Lang/J/Grayscale-image b/Lang/J/Grayscale-image new file mode 120000 index 0000000000..895e2f7a47 --- /dev/null +++ b/Lang/J/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/J \ No newline at end of file diff --git a/Lang/J/Greatest-common-divisor b/Lang/J/Greatest-common-divisor new file mode 120000 index 0000000000..d5a3123f9d --- /dev/null +++ b/Lang/J/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/J \ No newline at end of file diff --git a/Lang/J/Greatest-element-of-a-list b/Lang/J/Greatest-element-of-a-list new file mode 120000 index 0000000000..047a66379c --- /dev/null +++ b/Lang/J/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/J \ No newline at end of file diff --git a/Lang/J/Greatest-subsequential-sum b/Lang/J/Greatest-subsequential-sum new file mode 120000 index 0000000000..ead8abdbad --- /dev/null +++ b/Lang/J/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/J \ No newline at end of file diff --git a/Lang/J/Greyscale-bars-Display b/Lang/J/Greyscale-bars-Display new file mode 120000 index 0000000000..b904a24ec8 --- /dev/null +++ b/Lang/J/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/J \ No newline at end of file diff --git a/Lang/J/Guess-the-number b/Lang/J/Guess-the-number new file mode 120000 index 0000000000..eafef7f1cf --- /dev/null +++ b/Lang/J/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/J \ No newline at end of file diff --git a/Lang/J/Guess-the-number-With-feedback b/Lang/J/Guess-the-number-With-feedback new file mode 120000 index 0000000000..b1231c4910 --- /dev/null +++ b/Lang/J/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/J \ No newline at end of file diff --git a/Lang/J/Guess-the-number-With-feedback-player b/Lang/J/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..2a98134f4d --- /dev/null +++ b/Lang/J/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/J \ No newline at end of file diff --git a/Lang/J/HTTP b/Lang/J/HTTP new file mode 120000 index 0000000000..e1e09a77cc --- /dev/null +++ b/Lang/J/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/J \ No newline at end of file diff --git a/Lang/J/HTTPS b/Lang/J/HTTPS new file mode 120000 index 0000000000..88eb676c7b --- /dev/null +++ b/Lang/J/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/J \ No newline at end of file diff --git a/Lang/J/Hailstone-sequence b/Lang/J/Hailstone-sequence new file mode 120000 index 0000000000..4ac431edc6 --- /dev/null +++ b/Lang/J/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/J \ No newline at end of file diff --git a/Lang/J/Hamming-numbers b/Lang/J/Hamming-numbers new file mode 120000 index 0000000000..70743db37a --- /dev/null +++ b/Lang/J/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/J \ No newline at end of file diff --git a/Lang/J/Happy-numbers b/Lang/J/Happy-numbers new file mode 120000 index 0000000000..17b5a65b42 --- /dev/null +++ b/Lang/J/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/J \ No newline at end of file diff --git a/Lang/J/Hash-from-two-arrays b/Lang/J/Hash-from-two-arrays new file mode 120000 index 0000000000..7796b1a15c --- /dev/null +++ b/Lang/J/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/J \ No newline at end of file diff --git a/Lang/J/Haversine-formula b/Lang/J/Haversine-formula new file mode 120000 index 0000000000..31cea3679b --- /dev/null +++ b/Lang/J/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/J \ No newline at end of file diff --git a/Lang/J/Hello-world-Graphical b/Lang/J/Hello-world-Graphical new file mode 120000 index 0000000000..165adf2b67 --- /dev/null +++ b/Lang/J/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/J \ No newline at end of file diff --git a/Lang/J/Hello-world-Line-printer b/Lang/J/Hello-world-Line-printer new file mode 120000 index 0000000000..b9efa4c83e --- /dev/null +++ b/Lang/J/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/J \ No newline at end of file diff --git a/Lang/J/Hello-world-Standard-error b/Lang/J/Hello-world-Standard-error new file mode 120000 index 0000000000..88524c739a --- /dev/null +++ b/Lang/J/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/J \ No newline at end of file diff --git a/Lang/J/Hello-world-Text b/Lang/J/Hello-world-Text new file mode 120000 index 0000000000..5bf8e8ad98 --- /dev/null +++ b/Lang/J/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/J \ No newline at end of file diff --git a/Lang/J/Hello-world-Web-server b/Lang/J/Hello-world-Web-server new file mode 120000 index 0000000000..e93fb358ea --- /dev/null +++ b/Lang/J/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/J \ No newline at end of file diff --git a/Lang/J/Here-document b/Lang/J/Here-document new file mode 120000 index 0000000000..cee5e0c874 --- /dev/null +++ b/Lang/J/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/J \ No newline at end of file diff --git a/Lang/J/Higher-order-functions b/Lang/J/Higher-order-functions new file mode 120000 index 0000000000..74ba7fdfa2 --- /dev/null +++ b/Lang/J/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/J \ No newline at end of file diff --git a/Lang/J/History-variables b/Lang/J/History-variables new file mode 120000 index 0000000000..a20aed314c --- /dev/null +++ b/Lang/J/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/J \ No newline at end of file diff --git a/Lang/J/Hofstadter-Conway-$10,000-sequence b/Lang/J/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..0254c6ec99 --- /dev/null +++ b/Lang/J/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/J \ No newline at end of file diff --git a/Lang/J/Hofstadter-Figure-Figure-sequences b/Lang/J/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..71d6ab2245 --- /dev/null +++ b/Lang/J/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/J \ No newline at end of file diff --git a/Lang/J/Hofstadter-Q-sequence b/Lang/J/Hofstadter-Q-sequence new file mode 120000 index 0000000000..0ebf7d4859 --- /dev/null +++ b/Lang/J/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/J \ No newline at end of file diff --git a/Lang/J/Holidays-related-to-Easter b/Lang/J/Holidays-related-to-Easter new file mode 120000 index 0000000000..3e06e7edb3 --- /dev/null +++ b/Lang/J/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/J \ No newline at end of file diff --git a/Lang/J/Horizontal-sundial-calculations b/Lang/J/Horizontal-sundial-calculations new file mode 120000 index 0000000000..5ca5c0eb2f --- /dev/null +++ b/Lang/J/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/J \ No newline at end of file diff --git a/Lang/J/Horners-rule-for-polynomial-evaluation b/Lang/J/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..569f3d5bc4 --- /dev/null +++ b/Lang/J/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/J \ No newline at end of file diff --git a/Lang/J/Host-introspection b/Lang/J/Host-introspection new file mode 120000 index 0000000000..f453fefa5e --- /dev/null +++ b/Lang/J/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/J \ No newline at end of file diff --git a/Lang/J/Hostname b/Lang/J/Hostname new file mode 120000 index 0000000000..66345ae82c --- /dev/null +++ b/Lang/J/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/J \ No newline at end of file diff --git a/Lang/J/Hough-transform b/Lang/J/Hough-transform new file mode 120000 index 0000000000..18f891eb1e --- /dev/null +++ b/Lang/J/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/J \ No newline at end of file diff --git a/Lang/J/Huffman-coding b/Lang/J/Huffman-coding new file mode 120000 index 0000000000..24141994b0 --- /dev/null +++ b/Lang/J/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/J \ No newline at end of file diff --git a/Lang/J/I-before-E-except-after-C b/Lang/J/I-before-E-except-after-C new file mode 120000 index 0000000000..f5ba8d7c97 --- /dev/null +++ b/Lang/J/I-before-E-except-after-C @@ -0,0 +1 @@ +../../Task/I-before-E-except-after-C/J \ No newline at end of file diff --git a/Lang/J/Identity-matrix b/Lang/J/Identity-matrix new file mode 120000 index 0000000000..497b0e37ee --- /dev/null +++ b/Lang/J/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/J \ No newline at end of file diff --git a/Lang/J/Image-convolution b/Lang/J/Image-convolution new file mode 120000 index 0000000000..5a12b33816 --- /dev/null +++ b/Lang/J/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/J \ No newline at end of file diff --git a/Lang/J/Image-noise b/Lang/J/Image-noise new file mode 120000 index 0000000000..259bec4a3a --- /dev/null +++ b/Lang/J/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/J \ No newline at end of file diff --git a/Lang/J/Include-a-file b/Lang/J/Include-a-file new file mode 120000 index 0000000000..9ec1e27fa3 --- /dev/null +++ b/Lang/J/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/J \ No newline at end of file diff --git a/Lang/J/Increment-a-numerical-string b/Lang/J/Increment-a-numerical-string new file mode 120000 index 0000000000..a9d1e96c8b --- /dev/null +++ b/Lang/J/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/J \ No newline at end of file diff --git a/Lang/J/Infinity b/Lang/J/Infinity new file mode 120000 index 0000000000..1c90266695 --- /dev/null +++ b/Lang/J/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/J \ No newline at end of file diff --git a/Lang/J/Inheritance-Multiple b/Lang/J/Inheritance-Multiple new file mode 120000 index 0000000000..64d0798c31 --- /dev/null +++ b/Lang/J/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/J \ No newline at end of file diff --git a/Lang/J/Inheritance-Single b/Lang/J/Inheritance-Single new file mode 120000 index 0000000000..8cdd2fc34d --- /dev/null +++ b/Lang/J/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/J \ No newline at end of file diff --git a/Lang/J/Input-loop b/Lang/J/Input-loop new file mode 120000 index 0000000000..c8cca746c5 --- /dev/null +++ b/Lang/J/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/J \ No newline at end of file diff --git a/Lang/J/Integer-comparison b/Lang/J/Integer-comparison new file mode 120000 index 0000000000..3c68666cdf --- /dev/null +++ b/Lang/J/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/J \ No newline at end of file diff --git a/Lang/J/Integer-sequence b/Lang/J/Integer-sequence new file mode 120000 index 0000000000..91e376ee21 --- /dev/null +++ b/Lang/J/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/J \ No newline at end of file diff --git a/Lang/J/Interactive-programming b/Lang/J/Interactive-programming new file mode 120000 index 0000000000..4306bf18a0 --- /dev/null +++ b/Lang/J/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/J \ No newline at end of file diff --git a/Lang/J/Introspection b/Lang/J/Introspection new file mode 120000 index 0000000000..3af9939ade --- /dev/null +++ b/Lang/J/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/J \ No newline at end of file diff --git a/Lang/J/Inverted-index b/Lang/J/Inverted-index new file mode 120000 index 0000000000..0bcdbc8e38 --- /dev/null +++ b/Lang/J/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/J \ No newline at end of file diff --git a/Lang/J/JSON b/Lang/J/JSON new file mode 120000 index 0000000000..1673d6b774 --- /dev/null +++ b/Lang/J/JSON @@ -0,0 +1 @@ +../../Task/JSON/J \ No newline at end of file diff --git a/Lang/J/Jensens-Device b/Lang/J/Jensens-Device new file mode 120000 index 0000000000..8a5919fe81 --- /dev/null +++ b/Lang/J/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/J \ No newline at end of file diff --git a/Lang/J/Jump-anywhere b/Lang/J/Jump-anywhere new file mode 120000 index 0000000000..f310f95d9a --- /dev/null +++ b/Lang/J/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/J \ No newline at end of file diff --git a/Lang/J/K-means++-clustering b/Lang/J/K-means++-clustering new file mode 120000 index 0000000000..5cb176b57c --- /dev/null +++ b/Lang/J/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/J \ No newline at end of file diff --git a/Lang/J/Kaprekar-numbers b/Lang/J/Kaprekar-numbers new file mode 120000 index 0000000000..bb51201ce2 --- /dev/null +++ b/Lang/J/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/J \ No newline at end of file diff --git a/Lang/J/Knapsack-problem-0-1 b/Lang/J/Knapsack-problem-0-1 new file mode 120000 index 0000000000..947ac01cd4 --- /dev/null +++ b/Lang/J/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/J \ No newline at end of file diff --git a/Lang/J/Knapsack-problem-Bounded b/Lang/J/Knapsack-problem-Bounded new file mode 120000 index 0000000000..dab25aea04 --- /dev/null +++ b/Lang/J/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/J \ No newline at end of file diff --git a/Lang/J/Knapsack-problem-Continuous b/Lang/J/Knapsack-problem-Continuous new file mode 120000 index 0000000000..0b85307736 --- /dev/null +++ b/Lang/J/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/J \ No newline at end of file diff --git a/Lang/J/Knapsack-problem-Unbounded b/Lang/J/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..cffc824898 --- /dev/null +++ b/Lang/J/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/J \ No newline at end of file diff --git a/Lang/J/Knights-tour b/Lang/J/Knights-tour new file mode 120000 index 0000000000..3bc42b32ad --- /dev/null +++ b/Lang/J/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/J \ No newline at end of file diff --git a/Lang/J/Knuth-shuffle b/Lang/J/Knuth-shuffle new file mode 120000 index 0000000000..536b24e9e7 --- /dev/null +++ b/Lang/J/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/J \ No newline at end of file diff --git a/Lang/J/Knuths-algorithm-S b/Lang/J/Knuths-algorithm-S new file mode 120000 index 0000000000..cefec3affb --- /dev/null +++ b/Lang/J/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/J \ No newline at end of file diff --git a/Lang/J/LU-decomposition b/Lang/J/LU-decomposition new file mode 120000 index 0000000000..7b65f3b795 --- /dev/null +++ b/Lang/J/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/J \ No newline at end of file diff --git a/Lang/J/LZW-compression b/Lang/J/LZW-compression new file mode 120000 index 0000000000..d6ca2fdca0 --- /dev/null +++ b/Lang/J/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/J \ No newline at end of file diff --git a/Lang/J/Langtons-ant b/Lang/J/Langtons-ant new file mode 120000 index 0000000000..a83c702223 --- /dev/null +++ b/Lang/J/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/J \ No newline at end of file diff --git a/Lang/J/Largest-int-from-concatenated-ints b/Lang/J/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..560bb2d380 --- /dev/null +++ b/Lang/J/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/J \ No newline at end of file diff --git a/Lang/J/Last-Friday-of-each-month b/Lang/J/Last-Friday-of-each-month new file mode 120000 index 0000000000..3b799a45ff --- /dev/null +++ b/Lang/J/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/J \ No newline at end of file diff --git a/Lang/J/Last-letter-first-letter b/Lang/J/Last-letter-first-letter new file mode 120000 index 0000000000..afcd7d7734 --- /dev/null +++ b/Lang/J/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/J \ No newline at end of file diff --git a/Lang/J/Leap-year b/Lang/J/Leap-year new file mode 120000 index 0000000000..8757fea598 --- /dev/null +++ b/Lang/J/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/J \ No newline at end of file diff --git a/Lang/J/Least-common-multiple b/Lang/J/Least-common-multiple new file mode 120000 index 0000000000..2dcea35d81 --- /dev/null +++ b/Lang/J/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/J \ No newline at end of file diff --git a/Lang/J/Letter-frequency b/Lang/J/Letter-frequency new file mode 120000 index 0000000000..e687128f3f --- /dev/null +++ b/Lang/J/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/J \ No newline at end of file diff --git a/Lang/J/Levenshtein-distance b/Lang/J/Levenshtein-distance new file mode 120000 index 0000000000..9d21ac7b31 --- /dev/null +++ b/Lang/J/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/J \ No newline at end of file diff --git a/Lang/J/Linear-congruential-generator b/Lang/J/Linear-congruential-generator new file mode 120000 index 0000000000..7dd6f31d2e --- /dev/null +++ b/Lang/J/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/J \ No newline at end of file diff --git a/Lang/J/List-comprehensions b/Lang/J/List-comprehensions new file mode 120000 index 0000000000..656e8c51c0 --- /dev/null +++ b/Lang/J/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/J \ No newline at end of file diff --git a/Lang/J/Literals-Floating-point b/Lang/J/Literals-Floating-point new file mode 120000 index 0000000000..cfc4bd697a --- /dev/null +++ b/Lang/J/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/J \ No newline at end of file diff --git a/Lang/J/Literals-Integer b/Lang/J/Literals-Integer new file mode 120000 index 0000000000..2c5ea55be7 --- /dev/null +++ b/Lang/J/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/J \ No newline at end of file diff --git a/Lang/J/Literals-String b/Lang/J/Literals-String new file mode 120000 index 0000000000..433d8f069d --- /dev/null +++ b/Lang/J/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/J \ No newline at end of file diff --git a/Lang/J/Logical-operations b/Lang/J/Logical-operations new file mode 120000 index 0000000000..72f9766dc1 --- /dev/null +++ b/Lang/J/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/J \ No newline at end of file diff --git a/Lang/J/Long-multiplication b/Lang/J/Long-multiplication new file mode 120000 index 0000000000..aa06349c17 --- /dev/null +++ b/Lang/J/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/J \ No newline at end of file diff --git a/Lang/J/Longest-common-subsequence b/Lang/J/Longest-common-subsequence new file mode 120000 index 0000000000..5ba7a9844b --- /dev/null +++ b/Lang/J/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/J \ No newline at end of file diff --git a/Lang/J/Longest-string-challenge b/Lang/J/Longest-string-challenge new file mode 120000 index 0000000000..b72d90de67 --- /dev/null +++ b/Lang/J/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/J \ No newline at end of file diff --git a/Lang/J/Look-and-say-sequence b/Lang/J/Look-and-say-sequence new file mode 120000 index 0000000000..b5df48c0bb --- /dev/null +++ b/Lang/J/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/J \ No newline at end of file diff --git a/Lang/J/Loop-over-multiple-arrays-simultaneously b/Lang/J/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..05d99bdd7f --- /dev/null +++ b/Lang/J/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/J \ No newline at end of file diff --git a/Lang/J/Loops-Break b/Lang/J/Loops-Break new file mode 120000 index 0000000000..552802cfec --- /dev/null +++ b/Lang/J/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/J \ No newline at end of file diff --git a/Lang/J/Loops-Continue b/Lang/J/Loops-Continue new file mode 120000 index 0000000000..f3f68bc7de --- /dev/null +++ b/Lang/J/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/J \ No newline at end of file diff --git a/Lang/J/Loops-Do-while b/Lang/J/Loops-Do-while new file mode 120000 index 0000000000..f35f962cf8 --- /dev/null +++ b/Lang/J/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/J \ No newline at end of file diff --git a/Lang/J/Loops-Downward-for b/Lang/J/Loops-Downward-for new file mode 120000 index 0000000000..4254c2b487 --- /dev/null +++ b/Lang/J/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/J \ No newline at end of file diff --git a/Lang/J/Loops-For b/Lang/J/Loops-For new file mode 120000 index 0000000000..67ac6a5133 --- /dev/null +++ b/Lang/J/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/J \ No newline at end of file diff --git a/Lang/J/Loops-For-with-a-specified-step b/Lang/J/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..9701876666 --- /dev/null +++ b/Lang/J/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/J \ No newline at end of file diff --git a/Lang/J/Loops-Foreach b/Lang/J/Loops-Foreach new file mode 120000 index 0000000000..fe108325d7 --- /dev/null +++ b/Lang/J/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/J \ No newline at end of file diff --git a/Lang/J/Loops-Infinite b/Lang/J/Loops-Infinite new file mode 120000 index 0000000000..f1b52b0dfd --- /dev/null +++ b/Lang/J/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/J \ No newline at end of file diff --git a/Lang/J/Loops-N-plus-one-half b/Lang/J/Loops-N-plus-one-half new file mode 120000 index 0000000000..50e9251541 --- /dev/null +++ b/Lang/J/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/J \ No newline at end of file diff --git a/Lang/J/Loops-Nested b/Lang/J/Loops-Nested new file mode 120000 index 0000000000..f1d127bf8e --- /dev/null +++ b/Lang/J/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/J \ No newline at end of file diff --git a/Lang/J/Loops-While b/Lang/J/Loops-While new file mode 120000 index 0000000000..494cc42a69 --- /dev/null +++ b/Lang/J/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/J \ No newline at end of file diff --git a/Lang/J/Luhn-test-of-credit-card-numbers b/Lang/J/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..f07ad8f964 --- /dev/null +++ b/Lang/J/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/J \ No newline at end of file diff --git a/Lang/J/MD5 b/Lang/J/MD5 new file mode 120000 index 0000000000..0f5e18ffa1 --- /dev/null +++ b/Lang/J/MD5 @@ -0,0 +1 @@ +../../Task/MD5/J \ No newline at end of file diff --git a/Lang/J/MD5-Implementation b/Lang/J/MD5-Implementation new file mode 120000 index 0000000000..7077740f35 --- /dev/null +++ b/Lang/J/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/J \ No newline at end of file diff --git a/Lang/J/Man-or-boy-test b/Lang/J/Man-or-boy-test new file mode 120000 index 0000000000..acf1021cf2 --- /dev/null +++ b/Lang/J/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/J \ No newline at end of file diff --git a/Lang/J/Mandelbrot-set b/Lang/J/Mandelbrot-set new file mode 120000 index 0000000000..3dc597b6f0 --- /dev/null +++ b/Lang/J/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/J \ No newline at end of file diff --git a/Lang/J/Map-range b/Lang/J/Map-range new file mode 120000 index 0000000000..a62d8b8d37 --- /dev/null +++ b/Lang/J/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/J \ No newline at end of file diff --git a/Lang/J/Matrix-arithmetic b/Lang/J/Matrix-arithmetic new file mode 120000 index 0000000000..2c24c6d819 --- /dev/null +++ b/Lang/J/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/J \ No newline at end of file diff --git a/Lang/J/Matrix-exponentiation-operator b/Lang/J/Matrix-exponentiation-operator new file mode 120000 index 0000000000..975f402a1c --- /dev/null +++ b/Lang/J/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/J \ No newline at end of file diff --git a/Lang/J/Matrix-multiplication b/Lang/J/Matrix-multiplication new file mode 120000 index 0000000000..e3c9723a71 --- /dev/null +++ b/Lang/J/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/J \ No newline at end of file diff --git a/Lang/J/Matrix-transposition b/Lang/J/Matrix-transposition new file mode 120000 index 0000000000..ad420e3cd7 --- /dev/null +++ b/Lang/J/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/J \ No newline at end of file diff --git a/Lang/J/Maze-generation b/Lang/J/Maze-generation new file mode 120000 index 0000000000..29b9439783 --- /dev/null +++ b/Lang/J/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/J \ No newline at end of file diff --git a/Lang/J/Maze-solving b/Lang/J/Maze-solving new file mode 120000 index 0000000000..55b29c19a7 --- /dev/null +++ b/Lang/J/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/J \ No newline at end of file diff --git a/Lang/J/Median-filter b/Lang/J/Median-filter new file mode 120000 index 0000000000..1dc93cfafd --- /dev/null +++ b/Lang/J/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/J \ No newline at end of file diff --git a/Lang/J/Memory-allocation b/Lang/J/Memory-allocation new file mode 120000 index 0000000000..47662cb110 --- /dev/null +++ b/Lang/J/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/J \ No newline at end of file diff --git a/Lang/J/Memory-layout-of-a-data-structure b/Lang/J/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..8a1ec30446 --- /dev/null +++ b/Lang/J/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/J \ No newline at end of file diff --git a/Lang/J/Menu b/Lang/J/Menu new file mode 120000 index 0000000000..5c3196ba95 --- /dev/null +++ b/Lang/J/Menu @@ -0,0 +1 @@ +../../Task/Menu/J \ No newline at end of file diff --git a/Lang/J/Middle-three-digits b/Lang/J/Middle-three-digits new file mode 120000 index 0000000000..2fcf439cc2 --- /dev/null +++ b/Lang/J/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/J \ No newline at end of file diff --git a/Lang/J/Minesweeper-game b/Lang/J/Minesweeper-game new file mode 120000 index 0000000000..2abc420886 --- /dev/null +++ b/Lang/J/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/J \ No newline at end of file diff --git a/Lang/J/Modular-exponentiation b/Lang/J/Modular-exponentiation new file mode 120000 index 0000000000..86b988446c --- /dev/null +++ b/Lang/J/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/J \ No newline at end of file diff --git a/Lang/J/Modular-inverse b/Lang/J/Modular-inverse new file mode 120000 index 0000000000..b5db447b6c --- /dev/null +++ b/Lang/J/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/J \ No newline at end of file diff --git a/Lang/J/Monte-Carlo-methods b/Lang/J/Monte-Carlo-methods new file mode 120000 index 0000000000..966cc70c35 --- /dev/null +++ b/Lang/J/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/J \ No newline at end of file diff --git a/Lang/J/Monty-Hall-problem b/Lang/J/Monty-Hall-problem new file mode 120000 index 0000000000..b5d6f48128 --- /dev/null +++ b/Lang/J/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/J \ No newline at end of file diff --git a/Lang/J/Morse-code b/Lang/J/Morse-code new file mode 120000 index 0000000000..287540ec5e --- /dev/null +++ b/Lang/J/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/J \ No newline at end of file diff --git a/Lang/J/Multifactorial b/Lang/J/Multifactorial new file mode 120000 index 0000000000..6cc3ff0280 --- /dev/null +++ b/Lang/J/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/J \ No newline at end of file diff --git a/Lang/J/Multiple-distinct-objects b/Lang/J/Multiple-distinct-objects new file mode 120000 index 0000000000..c50ac5ab36 --- /dev/null +++ b/Lang/J/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/J \ No newline at end of file diff --git a/Lang/J/Multiple-regression b/Lang/J/Multiple-regression new file mode 120000 index 0000000000..d3e538e082 --- /dev/null +++ b/Lang/J/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/J \ No newline at end of file diff --git a/Lang/J/Multiplication-tables b/Lang/J/Multiplication-tables new file mode 120000 index 0000000000..059e6e100e --- /dev/null +++ b/Lang/J/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/J \ No newline at end of file diff --git a/Lang/J/Multiplicative-order b/Lang/J/Multiplicative-order new file mode 120000 index 0000000000..b956f9a957 --- /dev/null +++ b/Lang/J/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/J \ No newline at end of file diff --git a/Lang/J/Multisplit b/Lang/J/Multisplit new file mode 120000 index 0000000000..9a51e93721 --- /dev/null +++ b/Lang/J/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/J \ No newline at end of file diff --git a/Lang/J/Mutual-recursion b/Lang/J/Mutual-recursion new file mode 120000 index 0000000000..996e981ef1 --- /dev/null +++ b/Lang/J/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/J \ No newline at end of file diff --git a/Lang/J/Narcissist b/Lang/J/Narcissist new file mode 120000 index 0000000000..ed0b9754a1 --- /dev/null +++ b/Lang/J/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/J \ No newline at end of file diff --git a/Lang/J/Ordered-words b/Lang/J/Ordered-words new file mode 120000 index 0000000000..7e18146f6f --- /dev/null +++ b/Lang/J/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/J \ No newline at end of file diff --git a/Lang/J/Pi b/Lang/J/Pi new file mode 120000 index 0000000000..2110ab1d7b --- /dev/null +++ b/Lang/J/Pi @@ -0,0 +1 @@ +../../Task/Pi/J \ No newline at end of file diff --git a/Lang/J/Quine b/Lang/J/Quine new file mode 120000 index 0000000000..2a66b80a09 --- /dev/null +++ b/Lang/J/Quine @@ -0,0 +1 @@ +../../Task/Quine/J \ No newline at end of file diff --git a/Lang/J/Search-a-list b/Lang/J/Search-a-list new file mode 120000 index 0000000000..61d8a3ec1d --- /dev/null +++ b/Lang/J/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/J \ No newline at end of file diff --git a/Lang/JAMES-II-Rule-based-Cellular-Automata/0DESCRIPTION b/Lang/JAMES-II-Rule-based-Cellular-Automata/0DESCRIPTION new file mode 100644 index 0000000000..3e5a44ffb1 --- /dev/null +++ b/Lang/JAMES-II-Rule-based-Cellular-Automata/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}Implemented as part of the [[JAMES II]] framework.{{stub}} \ No newline at end of file diff --git a/Lang/JAMES-II-Rule-based-Cellular-Automata/Conways-Game-of-Life b/Lang/JAMES-II-Rule-based-Cellular-Automata/Conways-Game-of-Life new file mode 120000 index 0000000000..d8dd614160 --- /dev/null +++ b/Lang/JAMES-II-Rule-based-Cellular-Automata/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/JAMES-II-Rule-based-Cellular-Automata \ No newline at end of file diff --git a/Lang/JAMES-II-Rule-based-Cellular-Automata/Forest-fire b/Lang/JAMES-II-Rule-based-Cellular-Automata/Forest-fire new file mode 120000 index 0000000000..7dcb024b0c --- /dev/null +++ b/Lang/JAMES-II-Rule-based-Cellular-Automata/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/JAMES-II-Rule-based-Cellular-Automata \ No newline at end of file diff --git a/Lang/JCL/0DESCRIPTION b/Lang/JCL/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/JCL/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/JCL/Comments b/Lang/JCL/Comments new file mode 120000 index 0000000000..59d2f6a88f --- /dev/null +++ b/Lang/JCL/Comments @@ -0,0 +1 @@ +../../Task/Comments/JCL \ No newline at end of file diff --git a/Lang/JCL/Create-a-file b/Lang/JCL/Create-a-file new file mode 120000 index 0000000000..c884428ecf --- /dev/null +++ b/Lang/JCL/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/JCL \ No newline at end of file diff --git a/Lang/JCL/Create-a-file-on-magnetic-tape b/Lang/JCL/Create-a-file-on-magnetic-tape new file mode 120000 index 0000000000..3946e62267 --- /dev/null +++ b/Lang/JCL/Create-a-file-on-magnetic-tape @@ -0,0 +1 @@ +../../Task/Create-a-file-on-magnetic-tape/JCL \ No newline at end of file diff --git a/Lang/JCL/Hello-world-Text b/Lang/JCL/Hello-world-Text new file mode 120000 index 0000000000..5a9d73bc89 --- /dev/null +++ b/Lang/JCL/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/JCL \ No newline at end of file diff --git a/Lang/JScript.NET/0DESCRIPTION b/Lang/JScript.NET/0DESCRIPTION new file mode 100644 index 0000000000..b66cc8052a --- /dev/null +++ b/Lang/JScript.NET/0DESCRIPTION @@ -0,0 +1 @@ +{{language|JScript.NET}}{{stub}} \ No newline at end of file diff --git a/Lang/JScript.NET/Enumerations b/Lang/JScript.NET/Enumerations new file mode 120000 index 0000000000..07692a398a --- /dev/null +++ b/Lang/JScript.NET/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/JScript.NET \ No newline at end of file diff --git a/Lang/Jabaco/0DESCRIPTION b/Lang/Jabaco/0DESCRIPTION new file mode 100644 index 0000000000..96b8bf005c --- /dev/null +++ b/Lang/Jabaco/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{Stub}} \ No newline at end of file diff --git a/Lang/Jacquard-Loom/0DESCRIPTION b/Lang/Jacquard-Loom/0DESCRIPTION new file mode 100644 index 0000000000..2a7b789441 --- /dev/null +++ b/Lang/Jacquard-Loom/0DESCRIPTION @@ -0,0 +1,6 @@ +{{stub}}{{language|Jacquard Loom|exec=mechanical +|site=http://en.wikipedia.org/wiki/Jacquard_loom}} + +The Jacquard loom is a mechanical loom, invented by Joseph Marie Jacquard, that simplifies the process of manufacturing patterned textiles by using punched cards to control the patterning sequence. + +Tasks in this category use patterns to solve programming related tasks on the loom. \ No newline at end of file diff --git a/Lang/Jacquard-Loom/Hello-world-Text b/Lang/Jacquard-Loom/Hello-world-Text new file mode 120000 index 0000000000..d1ff9c6db3 --- /dev/null +++ b/Lang/Jacquard-Loom/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Jacquard-Loom \ No newline at end of file diff --git a/Lang/Java/Arbitrary-precision-integers-included b/Lang/Java/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..abe7ace75c --- /dev/null +++ b/Lang/Java/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Java \ No newline at end of file diff --git a/Lang/Java/Factorial b/Lang/Java/Factorial new file mode 120000 index 0000000000..4cb230dcb2 --- /dev/null +++ b/Lang/Java/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Java \ No newline at end of file diff --git a/Lang/Java/Factors-of-a-Mersenne-number b/Lang/Java/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..53c2bbeb0a --- /dev/null +++ b/Lang/Java/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Java \ No newline at end of file diff --git a/Lang/Java/Factors-of-an-integer b/Lang/Java/Factors-of-an-integer new file mode 120000 index 0000000000..622c84dbbb --- /dev/null +++ b/Lang/Java/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Java \ No newline at end of file diff --git a/Lang/Java/Fibonacci-n-step-number-sequences b/Lang/Java/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..a21b38214a --- /dev/null +++ b/Lang/Java/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Java \ No newline at end of file diff --git a/Lang/Java/Fibonacci-sequence b/Lang/Java/Fibonacci-sequence new file mode 120000 index 0000000000..7863117651 --- /dev/null +++ b/Lang/Java/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Java \ No newline at end of file diff --git a/Lang/Java/File-IO b/Lang/Java/File-IO new file mode 120000 index 0000000000..5f5de7b3e6 --- /dev/null +++ b/Lang/Java/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Java \ No newline at end of file diff --git a/Lang/Java/File-modification-time b/Lang/Java/File-modification-time new file mode 120000 index 0000000000..527507db4e --- /dev/null +++ b/Lang/Java/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Java \ No newline at end of file diff --git a/Lang/Java/File-size b/Lang/Java/File-size new file mode 120000 index 0000000000..f04b421d64 --- /dev/null +++ b/Lang/Java/File-size @@ -0,0 +1 @@ +../../Task/File-size/Java \ No newline at end of file diff --git a/Lang/Java/Filter b/Lang/Java/Filter new file mode 120000 index 0000000000..843a6df133 --- /dev/null +++ b/Lang/Java/Filter @@ -0,0 +1 @@ +../../Task/Filter/Java \ No newline at end of file diff --git a/Lang/Java/Find-common-directory-path b/Lang/Java/Find-common-directory-path new file mode 120000 index 0000000000..ae408dd74b --- /dev/null +++ b/Lang/Java/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Java \ No newline at end of file diff --git a/Lang/Java/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/Java/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..04159a26a8 --- /dev/null +++ b/Lang/Java/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/Java \ No newline at end of file diff --git a/Lang/Java/Find-limit-of-recursion b/Lang/Java/Find-limit-of-recursion new file mode 120000 index 0000000000..f776b5b77a --- /dev/null +++ b/Lang/Java/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Java \ No newline at end of file diff --git a/Lang/Java/Find-the-missing-permutation b/Lang/Java/Find-the-missing-permutation new file mode 120000 index 0000000000..cb642de3f6 --- /dev/null +++ b/Lang/Java/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Java \ No newline at end of file diff --git a/Lang/Java/First-class-functions b/Lang/Java/First-class-functions new file mode 120000 index 0000000000..0c21a2c846 --- /dev/null +++ b/Lang/Java/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Java \ No newline at end of file diff --git a/Lang/Java/Five-weekends b/Lang/Java/Five-weekends new file mode 120000 index 0000000000..65bbc13faf --- /dev/null +++ b/Lang/Java/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Java \ No newline at end of file diff --git a/Lang/Java/Flatten-a-list b/Lang/Java/Flatten-a-list new file mode 120000 index 0000000000..72918de5b7 --- /dev/null +++ b/Lang/Java/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Java \ No newline at end of file diff --git a/Lang/Java/Flow-control-structures b/Lang/Java/Flow-control-structures new file mode 120000 index 0000000000..34c9ab2437 --- /dev/null +++ b/Lang/Java/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Java \ No newline at end of file diff --git a/Lang/Java/Floyds-triangle b/Lang/Java/Floyds-triangle new file mode 120000 index 0000000000..c8eb164a7f --- /dev/null +++ b/Lang/Java/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Java \ No newline at end of file diff --git a/Lang/Java/Formatted-numeric-output b/Lang/Java/Formatted-numeric-output new file mode 120000 index 0000000000..2dbe192ce3 --- /dev/null +++ b/Lang/Java/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Java \ No newline at end of file diff --git a/Lang/Java/Forward-difference b/Lang/Java/Forward-difference new file mode 120000 index 0000000000..343a71580e --- /dev/null +++ b/Lang/Java/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Java \ No newline at end of file diff --git a/Lang/Java/Four-bit-adder b/Lang/Java/Four-bit-adder new file mode 120000 index 0000000000..6d04cb67a9 --- /dev/null +++ b/Lang/Java/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Java \ No newline at end of file diff --git a/Lang/Java/Fractal-tree b/Lang/Java/Fractal-tree new file mode 120000 index 0000000000..42f790de3b --- /dev/null +++ b/Lang/Java/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Java \ No newline at end of file diff --git a/Lang/Java/Function-composition b/Lang/Java/Function-composition new file mode 120000 index 0000000000..3f5075bd50 --- /dev/null +++ b/Lang/Java/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Java \ No newline at end of file diff --git a/Lang/Java/Function-definition b/Lang/Java/Function-definition new file mode 120000 index 0000000000..85df9737d8 --- /dev/null +++ b/Lang/Java/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Java \ No newline at end of file diff --git a/Lang/Java/GUI-component-interaction b/Lang/Java/GUI-component-interaction new file mode 120000 index 0000000000..0ce58ccfa2 --- /dev/null +++ b/Lang/Java/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Java \ No newline at end of file diff --git a/Lang/Java/GUI-enabling-disabling-of-controls b/Lang/Java/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..b5e470c0d8 --- /dev/null +++ b/Lang/Java/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Java \ No newline at end of file diff --git a/Lang/Java/Gamma-function b/Lang/Java/Gamma-function new file mode 120000 index 0000000000..128f627f88 --- /dev/null +++ b/Lang/Java/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Java \ No newline at end of file diff --git a/Lang/Java/Generic-swap b/Lang/Java/Generic-swap new file mode 120000 index 0000000000..51bfaeacc3 --- /dev/null +++ b/Lang/Java/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Java \ No newline at end of file diff --git a/Lang/Java/Gray-code b/Lang/Java/Gray-code new file mode 120000 index 0000000000..df12de5e84 --- /dev/null +++ b/Lang/Java/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Java \ No newline at end of file diff --git a/Lang/Java/Grayscale-image b/Lang/Java/Grayscale-image new file mode 120000 index 0000000000..738a838788 --- /dev/null +++ b/Lang/Java/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Java \ No newline at end of file diff --git a/Lang/Java/Greatest-common-divisor b/Lang/Java/Greatest-common-divisor new file mode 120000 index 0000000000..b0b2b758f6 --- /dev/null +++ b/Lang/Java/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Java \ No newline at end of file diff --git a/Lang/Java/Greatest-element-of-a-list b/Lang/Java/Greatest-element-of-a-list new file mode 120000 index 0000000000..52272106c6 --- /dev/null +++ b/Lang/Java/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Java \ No newline at end of file diff --git a/Lang/Java/Greatest-subsequential-sum b/Lang/Java/Greatest-subsequential-sum new file mode 120000 index 0000000000..7961b48d8d --- /dev/null +++ b/Lang/Java/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Java \ No newline at end of file diff --git a/Lang/Java/Greyscale-bars-Display b/Lang/Java/Greyscale-bars-Display new file mode 120000 index 0000000000..ce8d1348a0 --- /dev/null +++ b/Lang/Java/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Java \ No newline at end of file diff --git a/Lang/Java/Guess-the-number b/Lang/Java/Guess-the-number new file mode 120000 index 0000000000..dce4c47eee --- /dev/null +++ b/Lang/Java/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Java \ No newline at end of file diff --git a/Lang/Java/Guess-the-number-With-feedback b/Lang/Java/Guess-the-number-With-feedback new file mode 120000 index 0000000000..5ca17fba62 --- /dev/null +++ b/Lang/Java/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Java \ No newline at end of file diff --git a/Lang/Java/Guess-the-number-With-feedback-player b/Lang/Java/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..c0f79efb5e --- /dev/null +++ b/Lang/Java/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Java \ No newline at end of file diff --git a/Lang/Java/HTTP b/Lang/Java/HTTP new file mode 120000 index 0000000000..6c56dbdd64 --- /dev/null +++ b/Lang/Java/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Java \ No newline at end of file diff --git a/Lang/Java/HTTPS b/Lang/Java/HTTPS new file mode 120000 index 0000000000..c6b1b8f406 --- /dev/null +++ b/Lang/Java/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Java \ No newline at end of file diff --git a/Lang/Java/Hailstone-sequence b/Lang/Java/Hailstone-sequence new file mode 120000 index 0000000000..186002b442 --- /dev/null +++ b/Lang/Java/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Java \ No newline at end of file diff --git a/Lang/Java/Hamming-numbers b/Lang/Java/Hamming-numbers new file mode 120000 index 0000000000..6a4eb7bd7c --- /dev/null +++ b/Lang/Java/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Handle-a-signal b/Lang/Java/Handle-a-signal new file mode 120000 index 0000000000..5e9cc7507a --- /dev/null +++ b/Lang/Java/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Java \ No newline at end of file diff --git a/Lang/Java/Happy-numbers b/Lang/Java/Happy-numbers new file mode 120000 index 0000000000..091931441f --- /dev/null +++ b/Lang/Java/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Harshad-or-Niven-series b/Lang/Java/Harshad-or-Niven-series new file mode 120000 index 0000000000..d0f7302ede --- /dev/null +++ b/Lang/Java/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Java \ No newline at end of file diff --git a/Lang/Java/Hash-from-two-arrays b/Lang/Java/Hash-from-two-arrays new file mode 120000 index 0000000000..2d93066e3e --- /dev/null +++ b/Lang/Java/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Java \ No newline at end of file diff --git a/Lang/Java/Haversine-formula b/Lang/Java/Haversine-formula new file mode 120000 index 0000000000..dd13799d9a --- /dev/null +++ b/Lang/Java/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Graphical b/Lang/Java/Hello-world-Graphical new file mode 120000 index 0000000000..3e1bd1b252 --- /dev/null +++ b/Lang/Java/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Line-printer b/Lang/Java/Hello-world-Line-printer new file mode 120000 index 0000000000..2d6feb09d0 --- /dev/null +++ b/Lang/Java/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Newline-omission b/Lang/Java/Hello-world-Newline-omission new file mode 120000 index 0000000000..abea3c23b5 --- /dev/null +++ b/Lang/Java/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Standard-error b/Lang/Java/Hello-world-Standard-error new file mode 120000 index 0000000000..a4c25e32ab --- /dev/null +++ b/Lang/Java/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Text b/Lang/Java/Hello-world-Text new file mode 120000 index 0000000000..cb71b84489 --- /dev/null +++ b/Lang/Java/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Java \ No newline at end of file diff --git a/Lang/Java/Hello-world-Web-server b/Lang/Java/Hello-world-Web-server new file mode 120000 index 0000000000..2cc3312c42 --- /dev/null +++ b/Lang/Java/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Java \ No newline at end of file diff --git a/Lang/Java/Higher-order-functions b/Lang/Java/Higher-order-functions new file mode 120000 index 0000000000..ace2b593c6 --- /dev/null +++ b/Lang/Java/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Java \ No newline at end of file diff --git a/Lang/Java/Hofstadter-Conway-$10,000-sequence b/Lang/Java/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..f6d272acc5 --- /dev/null +++ b/Lang/Java/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Java \ No newline at end of file diff --git a/Lang/Java/Hofstadter-Figure-Figure-sequences b/Lang/Java/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..e2425f3178 --- /dev/null +++ b/Lang/Java/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Java \ No newline at end of file diff --git a/Lang/Java/Hofstadter-Q-sequence b/Lang/Java/Hofstadter-Q-sequence new file mode 120000 index 0000000000..f3f162d649 --- /dev/null +++ b/Lang/Java/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Java \ No newline at end of file diff --git a/Lang/Java/Horizontal-sundial-calculations b/Lang/Java/Horizontal-sundial-calculations new file mode 120000 index 0000000000..1f1a67eb90 --- /dev/null +++ b/Lang/Java/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Java \ No newline at end of file diff --git a/Lang/Java/Horners-rule-for-polynomial-evaluation b/Lang/Java/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..7fb994172b --- /dev/null +++ b/Lang/Java/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Java \ No newline at end of file diff --git a/Lang/Java/Host-introspection b/Lang/Java/Host-introspection new file mode 120000 index 0000000000..fbc695329d --- /dev/null +++ b/Lang/Java/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Java \ No newline at end of file diff --git a/Lang/Java/Hostname b/Lang/Java/Hostname new file mode 120000 index 0000000000..4731cd434a --- /dev/null +++ b/Lang/Java/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Java \ No newline at end of file diff --git a/Lang/Java/Hough-transform b/Lang/Java/Hough-transform new file mode 120000 index 0000000000..7ed2938860 --- /dev/null +++ b/Lang/Java/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/Java \ No newline at end of file diff --git a/Lang/Java/Huffman-coding b/Lang/Java/Huffman-coding new file mode 120000 index 0000000000..c8b4df6702 --- /dev/null +++ b/Lang/Java/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Java \ No newline at end of file diff --git a/Lang/Java/Identity-matrix b/Lang/Java/Identity-matrix new file mode 120000 index 0000000000..3cf870dd56 --- /dev/null +++ b/Lang/Java/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Java \ No newline at end of file diff --git a/Lang/Java/Image-convolution b/Lang/Java/Image-convolution new file mode 120000 index 0000000000..8d03f7d0d6 --- /dev/null +++ b/Lang/Java/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Java \ No newline at end of file diff --git a/Lang/Java/Image-noise b/Lang/Java/Image-noise new file mode 120000 index 0000000000..6e1ffd829f --- /dev/null +++ b/Lang/Java/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Java \ No newline at end of file diff --git a/Lang/Java/Increment-a-numerical-string b/Lang/Java/Increment-a-numerical-string new file mode 120000 index 0000000000..389cfb855c --- /dev/null +++ b/Lang/Java/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Java \ No newline at end of file diff --git a/Lang/Java/Inheritance-Multiple b/Lang/Java/Inheritance-Multiple new file mode 120000 index 0000000000..8f6ddee15b --- /dev/null +++ b/Lang/Java/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Java \ No newline at end of file diff --git a/Lang/Java/Inheritance-Single b/Lang/Java/Inheritance-Single new file mode 120000 index 0000000000..e36ef9ed2e --- /dev/null +++ b/Lang/Java/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Java \ No newline at end of file diff --git a/Lang/Java/Input-loop b/Lang/Java/Input-loop new file mode 120000 index 0000000000..98b01f19b8 --- /dev/null +++ b/Lang/Java/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Java \ No newline at end of file diff --git a/Lang/Java/Integer-comparison b/Lang/Java/Integer-comparison new file mode 120000 index 0000000000..252b229745 --- /dev/null +++ b/Lang/Java/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Java \ No newline at end of file diff --git a/Lang/Java/Integer-sequence b/Lang/Java/Integer-sequence new file mode 120000 index 0000000000..99a82157d0 --- /dev/null +++ b/Lang/Java/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Java \ No newline at end of file diff --git a/Lang/Java/Introspection b/Lang/Java/Introspection new file mode 120000 index 0000000000..2768adc8de --- /dev/null +++ b/Lang/Java/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Java \ No newline at end of file diff --git a/Lang/Java/Inverted-index b/Lang/Java/Inverted-index new file mode 120000 index 0000000000..9f58807b5e --- /dev/null +++ b/Lang/Java/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Java \ No newline at end of file diff --git a/Lang/Java/Josephus-problem b/Lang/Java/Josephus-problem new file mode 120000 index 0000000000..5d641ee72d --- /dev/null +++ b/Lang/Java/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Java \ No newline at end of file diff --git a/Lang/Java/Jump-anywhere b/Lang/Java/Jump-anywhere new file mode 120000 index 0000000000..cb291ff527 --- /dev/null +++ b/Lang/Java/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/Java \ No newline at end of file diff --git a/Lang/Java/Kaprekar-numbers b/Lang/Java/Kaprekar-numbers new file mode 120000 index 0000000000..84f22ec839 --- /dev/null +++ b/Lang/Java/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Keyboard-macros b/Lang/Java/Keyboard-macros new file mode 120000 index 0000000000..773473c37f --- /dev/null +++ b/Lang/Java/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/Java \ No newline at end of file diff --git a/Lang/Java/Knapsack-problem-0-1 b/Lang/Java/Knapsack-problem-0-1 new file mode 120000 index 0000000000..8e31aa64de --- /dev/null +++ b/Lang/Java/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Java \ No newline at end of file diff --git a/Lang/Java/Knapsack-problem-Bounded b/Lang/Java/Knapsack-problem-Bounded new file mode 120000 index 0000000000..c92362f690 --- /dev/null +++ b/Lang/Java/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Java \ No newline at end of file diff --git a/Lang/Java/Knapsack-problem-Continuous b/Lang/Java/Knapsack-problem-Continuous new file mode 120000 index 0000000000..c7269e4d09 --- /dev/null +++ b/Lang/Java/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Java \ No newline at end of file diff --git a/Lang/Java/Knapsack-problem-Unbounded b/Lang/Java/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..0d2ecc17b3 --- /dev/null +++ b/Lang/Java/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Java \ No newline at end of file diff --git a/Lang/Java/Knights-tour b/Lang/Java/Knights-tour new file mode 120000 index 0000000000..58153f72e0 --- /dev/null +++ b/Lang/Java/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Java \ No newline at end of file diff --git a/Lang/Java/Knuths-algorithm-S b/Lang/Java/Knuths-algorithm-S new file mode 120000 index 0000000000..6c6936cf66 --- /dev/null +++ b/Lang/Java/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Java \ No newline at end of file diff --git a/Lang/Java/LZW-compression b/Lang/Java/LZW-compression new file mode 120000 index 0000000000..a16ef21ad3 --- /dev/null +++ b/Lang/Java/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Java \ No newline at end of file diff --git a/Lang/Java/Langtons-ant b/Lang/Java/Langtons-ant new file mode 120000 index 0000000000..09432eb9ce --- /dev/null +++ b/Lang/Java/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Java \ No newline at end of file diff --git a/Lang/Java/Largest-int-from-concatenated-ints b/Lang/Java/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..499b0cd7ea --- /dev/null +++ b/Lang/Java/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Java \ No newline at end of file diff --git a/Lang/Java/Last-Friday-of-each-month b/Lang/Java/Last-Friday-of-each-month new file mode 120000 index 0000000000..ce5e120d8f --- /dev/null +++ b/Lang/Java/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Java \ No newline at end of file diff --git a/Lang/Java/Last-letter-first-letter b/Lang/Java/Last-letter-first-letter new file mode 120000 index 0000000000..ccf2c10a79 --- /dev/null +++ b/Lang/Java/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Java \ No newline at end of file diff --git a/Lang/Java/Leap-year b/Lang/Java/Leap-year new file mode 120000 index 0000000000..aee9ac606b --- /dev/null +++ b/Lang/Java/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Java \ No newline at end of file diff --git a/Lang/Java/Least-common-multiple b/Lang/Java/Least-common-multiple new file mode 120000 index 0000000000..3b4294c6bf --- /dev/null +++ b/Lang/Java/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Java \ No newline at end of file diff --git a/Lang/Java/Letter-frequency b/Lang/Java/Letter-frequency new file mode 120000 index 0000000000..710d6b3474 --- /dev/null +++ b/Lang/Java/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Java \ No newline at end of file diff --git a/Lang/Java/Levenshtein-distance b/Lang/Java/Levenshtein-distance new file mode 120000 index 0000000000..5607e3d1f1 --- /dev/null +++ b/Lang/Java/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Java \ No newline at end of file diff --git a/Lang/Java/Literals-Floating-point b/Lang/Java/Literals-Floating-point new file mode 120000 index 0000000000..9af0f10aa8 --- /dev/null +++ b/Lang/Java/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Java \ No newline at end of file diff --git a/Lang/Java/Literals-Integer b/Lang/Java/Literals-Integer new file mode 120000 index 0000000000..a19162b0b1 --- /dev/null +++ b/Lang/Java/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Java \ No newline at end of file diff --git a/Lang/Java/Literals-String b/Lang/Java/Literals-String new file mode 120000 index 0000000000..eaea2f2368 --- /dev/null +++ b/Lang/Java/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Java \ No newline at end of file diff --git a/Lang/Java/Logical-operations b/Lang/Java/Logical-operations new file mode 120000 index 0000000000..c588a6e623 --- /dev/null +++ b/Lang/Java/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Java \ No newline at end of file diff --git a/Lang/Java/Long-multiplication b/Lang/Java/Long-multiplication new file mode 120000 index 0000000000..a938a3a7c1 --- /dev/null +++ b/Lang/Java/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Java \ No newline at end of file diff --git a/Lang/Java/Longest-common-subsequence b/Lang/Java/Longest-common-subsequence new file mode 120000 index 0000000000..945d23514e --- /dev/null +++ b/Lang/Java/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Java \ No newline at end of file diff --git a/Lang/Java/Look-and-say-sequence b/Lang/Java/Look-and-say-sequence new file mode 120000 index 0000000000..e9cf00a92f --- /dev/null +++ b/Lang/Java/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Java \ No newline at end of file diff --git a/Lang/Java/Loop-over-multiple-arrays-simultaneously b/Lang/Java/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..85a8871ec2 --- /dev/null +++ b/Lang/Java/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Break b/Lang/Java/Loops-Break new file mode 120000 index 0000000000..28eef03e1e --- /dev/null +++ b/Lang/Java/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Continue b/Lang/Java/Loops-Continue new file mode 120000 index 0000000000..05db34e5fc --- /dev/null +++ b/Lang/Java/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Do-while b/Lang/Java/Loops-Do-while new file mode 120000 index 0000000000..9fa00bd6a7 --- /dev/null +++ b/Lang/Java/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Downward-for b/Lang/Java/Loops-Downward-for new file mode 120000 index 0000000000..5ff14756c9 --- /dev/null +++ b/Lang/Java/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Java \ No newline at end of file diff --git a/Lang/Java/Loops-For b/Lang/Java/Loops-For new file mode 120000 index 0000000000..b9f3da22fe --- /dev/null +++ b/Lang/Java/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Java \ No newline at end of file diff --git a/Lang/Java/Loops-For-with-a-specified-step b/Lang/Java/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..17c2ba231c --- /dev/null +++ b/Lang/Java/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Foreach b/Lang/Java/Loops-Foreach new file mode 120000 index 0000000000..51a9b8589b --- /dev/null +++ b/Lang/Java/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Infinite b/Lang/Java/Loops-Infinite new file mode 120000 index 0000000000..a51c6224d4 --- /dev/null +++ b/Lang/Java/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Java \ No newline at end of file diff --git a/Lang/Java/Loops-N-plus-one-half b/Lang/Java/Loops-N-plus-one-half new file mode 120000 index 0000000000..0b1e612532 --- /dev/null +++ b/Lang/Java/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Java \ No newline at end of file diff --git a/Lang/Java/Loops-Nested b/Lang/Java/Loops-Nested new file mode 120000 index 0000000000..8ae865bf7f --- /dev/null +++ b/Lang/Java/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Java \ No newline at end of file diff --git a/Lang/Java/Loops-While b/Lang/Java/Loops-While new file mode 120000 index 0000000000..3aa5e98cbf --- /dev/null +++ b/Lang/Java/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Java \ No newline at end of file diff --git a/Lang/Java/Lucas-Lehmer-test b/Lang/Java/Lucas-Lehmer-test new file mode 120000 index 0000000000..045153ff9d --- /dev/null +++ b/Lang/Java/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Java \ No newline at end of file diff --git a/Lang/Java/Luhn-test-of-credit-card-numbers b/Lang/Java/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..fd0a6644d9 --- /dev/null +++ b/Lang/Java/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Java \ No newline at end of file diff --git a/Lang/Java/MD4 b/Lang/Java/MD4 new file mode 120000 index 0000000000..af30951c02 --- /dev/null +++ b/Lang/Java/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Java \ No newline at end of file diff --git a/Lang/Java/MD5 b/Lang/Java/MD5 new file mode 120000 index 0000000000..819ffe3947 --- /dev/null +++ b/Lang/Java/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Java \ No newline at end of file diff --git a/Lang/Java/MD5-Implementation b/Lang/Java/MD5-Implementation new file mode 120000 index 0000000000..881635478c --- /dev/null +++ b/Lang/Java/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Java \ No newline at end of file diff --git a/Lang/Java/Man-or-boy-test b/Lang/Java/Man-or-boy-test new file mode 120000 index 0000000000..24809760ab --- /dev/null +++ b/Lang/Java/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Java \ No newline at end of file diff --git a/Lang/Java/Mandelbrot-set b/Lang/Java/Mandelbrot-set new file mode 120000 index 0000000000..eae0defd38 --- /dev/null +++ b/Lang/Java/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Java \ No newline at end of file diff --git a/Lang/Java/Map-range b/Lang/Java/Map-range new file mode 120000 index 0000000000..82cc09f809 --- /dev/null +++ b/Lang/Java/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Java \ No newline at end of file diff --git a/Lang/Java/Matrix-multiplication b/Lang/Java/Matrix-multiplication new file mode 120000 index 0000000000..a74eb2661d --- /dev/null +++ b/Lang/Java/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Java \ No newline at end of file diff --git a/Lang/Java/Matrix-transposition b/Lang/Java/Matrix-transposition new file mode 120000 index 0000000000..dade8b01cd --- /dev/null +++ b/Lang/Java/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Java \ No newline at end of file diff --git a/Lang/Java/Maze-generation b/Lang/Java/Maze-generation new file mode 120000 index 0000000000..377959b057 --- /dev/null +++ b/Lang/Java/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Java \ No newline at end of file diff --git a/Lang/Java/Maze-solving b/Lang/Java/Maze-solving new file mode 120000 index 0000000000..f317f777fa --- /dev/null +++ b/Lang/Java/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Java \ No newline at end of file diff --git a/Lang/Java/Memory-allocation b/Lang/Java/Memory-allocation new file mode 120000 index 0000000000..7d2c9cec84 --- /dev/null +++ b/Lang/Java/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Java \ No newline at end of file diff --git a/Lang/Java/Menu b/Lang/Java/Menu new file mode 120000 index 0000000000..b32f557b61 --- /dev/null +++ b/Lang/Java/Menu @@ -0,0 +1 @@ +../../Task/Menu/Java \ No newline at end of file diff --git a/Lang/Java/Metered-concurrency b/Lang/Java/Metered-concurrency new file mode 120000 index 0000000000..3c068fc11f --- /dev/null +++ b/Lang/Java/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Java \ No newline at end of file diff --git a/Lang/Java/Middle-three-digits b/Lang/Java/Middle-three-digits new file mode 120000 index 0000000000..eb30aa63d3 --- /dev/null +++ b/Lang/Java/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Java \ No newline at end of file diff --git a/Lang/Java/Miller-Rabin-primality-test b/Lang/Java/Miller-Rabin-primality-test new file mode 120000 index 0000000000..5708188da1 --- /dev/null +++ b/Lang/Java/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Java \ No newline at end of file diff --git a/Lang/Java/Modular-exponentiation b/Lang/Java/Modular-exponentiation new file mode 120000 index 0000000000..ac0f003f53 --- /dev/null +++ b/Lang/Java/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Java \ No newline at end of file diff --git a/Lang/Java/Modular-inverse b/Lang/Java/Modular-inverse new file mode 120000 index 0000000000..a95a30b02a --- /dev/null +++ b/Lang/Java/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Java \ No newline at end of file diff --git a/Lang/Java/Monte-Carlo-methods b/Lang/Java/Monte-Carlo-methods new file mode 120000 index 0000000000..1e4b02b724 --- /dev/null +++ b/Lang/Java/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Java \ No newline at end of file diff --git a/Lang/Java/Monty-Hall-problem b/Lang/Java/Monty-Hall-problem new file mode 120000 index 0000000000..2889c8d64e --- /dev/null +++ b/Lang/Java/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Java \ No newline at end of file diff --git a/Lang/Java/Mouse-position b/Lang/Java/Mouse-position new file mode 120000 index 0000000000..877db50163 --- /dev/null +++ b/Lang/Java/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Java \ No newline at end of file diff --git a/Lang/Java/Multiple-distinct-objects b/Lang/Java/Multiple-distinct-objects new file mode 120000 index 0000000000..c29a465390 --- /dev/null +++ b/Lang/Java/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Java \ No newline at end of file diff --git a/Lang/Java/Multiplication-tables b/Lang/Java/Multiplication-tables new file mode 120000 index 0000000000..d35171599f --- /dev/null +++ b/Lang/Java/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Java \ No newline at end of file diff --git a/Lang/Java/Mutex b/Lang/Java/Mutex new file mode 120000 index 0000000000..5c0eaa6809 --- /dev/null +++ b/Lang/Java/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Java \ No newline at end of file diff --git a/Lang/Java/Mutual-recursion b/Lang/Java/Mutual-recursion new file mode 120000 index 0000000000..4da144719a --- /dev/null +++ b/Lang/Java/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Java \ No newline at end of file diff --git a/Lang/JavaFX-Script/0DESCRIPTION b/Lang/JavaFX-Script/0DESCRIPTION new file mode 100644 index 0000000000..d446a53c67 --- /dev/null +++ b/Lang/JavaFX-Script/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}} +{{language}} \ No newline at end of file diff --git a/Lang/JavaFX-Script/Filter b/Lang/JavaFX-Script/Filter new file mode 120000 index 0000000000..71e54d7c5d --- /dev/null +++ b/Lang/JavaFX-Script/Filter @@ -0,0 +1 @@ +../../Task/Filter/JavaFX-Script \ No newline at end of file diff --git a/Lang/JavaScript/24-game-Solve b/Lang/JavaScript/24-game-Solve new file mode 120000 index 0000000000..c10ceabd96 --- /dev/null +++ b/Lang/JavaScript/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Factorial b/Lang/JavaScript/Factorial new file mode 120000 index 0000000000..fc8242f06a --- /dev/null +++ b/Lang/JavaScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Factors-of-a-Mersenne-number b/Lang/JavaScript/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..60b4ecaf8a --- /dev/null +++ b/Lang/JavaScript/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Factors-of-an-integer b/Lang/JavaScript/Factors-of-an-integer new file mode 120000 index 0000000000..ff6615a37f --- /dev/null +++ b/Lang/JavaScript/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Fibonacci-n-step-number-sequences b/Lang/JavaScript/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..10d3c11287 --- /dev/null +++ b/Lang/JavaScript/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Fibonacci-sequence b/Lang/JavaScript/Fibonacci-sequence new file mode 120000 index 0000000000..7f3a7360b4 --- /dev/null +++ b/Lang/JavaScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/File-IO b/Lang/JavaScript/File-IO new file mode 120000 index 0000000000..69bc1dbc43 --- /dev/null +++ b/Lang/JavaScript/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/File-modification-time b/Lang/JavaScript/File-modification-time new file mode 120000 index 0000000000..050d43e066 --- /dev/null +++ b/Lang/JavaScript/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/File-size b/Lang/JavaScript/File-size new file mode 120000 index 0000000000..97c116d657 --- /dev/null +++ b/Lang/JavaScript/File-size @@ -0,0 +1 @@ +../../Task/File-size/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Filter b/Lang/JavaScript/Filter new file mode 120000 index 0000000000..4417c69cb1 --- /dev/null +++ b/Lang/JavaScript/Filter @@ -0,0 +1 @@ +../../Task/Filter/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Find-limit-of-recursion b/Lang/JavaScript/Find-limit-of-recursion new file mode 120000 index 0000000000..9c7803afb9 --- /dev/null +++ b/Lang/JavaScript/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Find-the-missing-permutation b/Lang/JavaScript/Find-the-missing-permutation new file mode 120000 index 0000000000..aadfb2392c --- /dev/null +++ b/Lang/JavaScript/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/First-class-functions b/Lang/JavaScript/First-class-functions new file mode 120000 index 0000000000..0ac9122856 --- /dev/null +++ b/Lang/JavaScript/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Five-weekends b/Lang/JavaScript/Five-weekends new file mode 120000 index 0000000000..4ea938b64a --- /dev/null +++ b/Lang/JavaScript/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Flatten-a-list b/Lang/JavaScript/Flatten-a-list new file mode 120000 index 0000000000..d8906893fb --- /dev/null +++ b/Lang/JavaScript/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Floyds-triangle b/Lang/JavaScript/Floyds-triangle new file mode 120000 index 0000000000..8ec53db6dd --- /dev/null +++ b/Lang/JavaScript/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Formatted-numeric-output b/Lang/JavaScript/Formatted-numeric-output new file mode 120000 index 0000000000..de3d7c58ec --- /dev/null +++ b/Lang/JavaScript/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Four-bit-adder b/Lang/JavaScript/Four-bit-adder new file mode 120000 index 0000000000..4734611ba9 --- /dev/null +++ b/Lang/JavaScript/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Fractal-tree b/Lang/JavaScript/Fractal-tree new file mode 120000 index 0000000000..d84ad14500 --- /dev/null +++ b/Lang/JavaScript/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Function-composition b/Lang/JavaScript/Function-composition new file mode 120000 index 0000000000..7a14459150 --- /dev/null +++ b/Lang/JavaScript/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Function-definition b/Lang/JavaScript/Function-definition new file mode 120000 index 0000000000..578ba2de2e --- /dev/null +++ b/Lang/JavaScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Generator-Exponential b/Lang/JavaScript/Generator-Exponential new file mode 120000 index 0000000000..8c5b0f426f --- /dev/null +++ b/Lang/JavaScript/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Generic-swap b/Lang/JavaScript/Generic-swap new file mode 120000 index 0000000000..f4801be406 --- /dev/null +++ b/Lang/JavaScript/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Grayscale-image b/Lang/JavaScript/Grayscale-image new file mode 120000 index 0000000000..48a69977d2 --- /dev/null +++ b/Lang/JavaScript/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Greatest-common-divisor b/Lang/JavaScript/Greatest-common-divisor new file mode 120000 index 0000000000..5aefc6a04d --- /dev/null +++ b/Lang/JavaScript/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Greatest-element-of-a-list b/Lang/JavaScript/Greatest-element-of-a-list new file mode 120000 index 0000000000..e1bf905f5d --- /dev/null +++ b/Lang/JavaScript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Greatest-subsequential-sum b/Lang/JavaScript/Greatest-subsequential-sum new file mode 120000 index 0000000000..650a8022ca --- /dev/null +++ b/Lang/JavaScript/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Greyscale-bars-Display b/Lang/JavaScript/Greyscale-bars-Display new file mode 120000 index 0000000000..2427492a31 --- /dev/null +++ b/Lang/JavaScript/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Guess-the-number b/Lang/JavaScript/Guess-the-number new file mode 120000 index 0000000000..bfa7d93a34 --- /dev/null +++ b/Lang/JavaScript/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Guess-the-number-With-feedback b/Lang/JavaScript/Guess-the-number-With-feedback new file mode 120000 index 0000000000..d04e7ea929 --- /dev/null +++ b/Lang/JavaScript/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Guess-the-number-With-feedback-player b/Lang/JavaScript/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..9eda3dd737 --- /dev/null +++ b/Lang/JavaScript/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hailstone-sequence b/Lang/JavaScript/Hailstone-sequence new file mode 120000 index 0000000000..ef577bd588 --- /dev/null +++ b/Lang/JavaScript/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hamming-numbers b/Lang/JavaScript/Hamming-numbers new file mode 120000 index 0000000000..d7d63725e0 --- /dev/null +++ b/Lang/JavaScript/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Happy-numbers b/Lang/JavaScript/Happy-numbers new file mode 120000 index 0000000000..c4b42f0b3b --- /dev/null +++ b/Lang/JavaScript/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hash-from-two-arrays b/Lang/JavaScript/Hash-from-two-arrays new file mode 120000 index 0000000000..3c23500fa7 --- /dev/null +++ b/Lang/JavaScript/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hello-world-Graphical b/Lang/JavaScript/Hello-world-Graphical new file mode 120000 index 0000000000..470103f364 --- /dev/null +++ b/Lang/JavaScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hello-world-Line-printer b/Lang/JavaScript/Hello-world-Line-printer new file mode 120000 index 0000000000..e57dd398b7 --- /dev/null +++ b/Lang/JavaScript/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hello-world-Standard-error b/Lang/JavaScript/Hello-world-Standard-error new file mode 120000 index 0000000000..a1169ffbbe --- /dev/null +++ b/Lang/JavaScript/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hello-world-Text b/Lang/JavaScript/Hello-world-Text new file mode 120000 index 0000000000..f1f27d2c67 --- /dev/null +++ b/Lang/JavaScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hello-world-Web-server b/Lang/JavaScript/Hello-world-Web-server new file mode 120000 index 0000000000..cbc7b513a5 --- /dev/null +++ b/Lang/JavaScript/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Higher-order-functions b/Lang/JavaScript/Higher-order-functions new file mode 120000 index 0000000000..16b0b5a72c --- /dev/null +++ b/Lang/JavaScript/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hofstadter-Conway-$10,000-sequence b/Lang/JavaScript/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..da7e8b0ff0 --- /dev/null +++ b/Lang/JavaScript/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hofstadter-Figure-Figure-sequences b/Lang/JavaScript/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..a83c3a5939 --- /dev/null +++ b/Lang/JavaScript/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hofstadter-Q-sequence b/Lang/JavaScript/Hofstadter-Q-sequence new file mode 120000 index 0000000000..d5fd5dd20d --- /dev/null +++ b/Lang/JavaScript/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Horners-rule-for-polynomial-evaluation b/Lang/JavaScript/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..43d759bf0e --- /dev/null +++ b/Lang/JavaScript/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Hostname b/Lang/JavaScript/Hostname new file mode 120000 index 0000000000..9237f2e063 --- /dev/null +++ b/Lang/JavaScript/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Huffman-coding b/Lang/JavaScript/Huffman-coding new file mode 120000 index 0000000000..70e1aa5a78 --- /dev/null +++ b/Lang/JavaScript/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Image-noise b/Lang/JavaScript/Image-noise new file mode 120000 index 0000000000..8bd18ab7c4 --- /dev/null +++ b/Lang/JavaScript/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Include-a-file b/Lang/JavaScript/Include-a-file new file mode 120000 index 0000000000..bac141c9c0 --- /dev/null +++ b/Lang/JavaScript/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Increment-a-numerical-string b/Lang/JavaScript/Increment-a-numerical-string new file mode 120000 index 0000000000..c9924e0a29 --- /dev/null +++ b/Lang/JavaScript/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Inheritance-Single b/Lang/JavaScript/Inheritance-Single new file mode 120000 index 0000000000..e024cb761e --- /dev/null +++ b/Lang/JavaScript/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Input-loop b/Lang/JavaScript/Input-loop new file mode 120000 index 0000000000..4da69011d9 --- /dev/null +++ b/Lang/JavaScript/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Integer-comparison b/Lang/JavaScript/Integer-comparison new file mode 120000 index 0000000000..3595894035 --- /dev/null +++ b/Lang/JavaScript/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Integer-sequence b/Lang/JavaScript/Integer-sequence new file mode 120000 index 0000000000..21477e5cc1 --- /dev/null +++ b/Lang/JavaScript/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Interactive-programming b/Lang/JavaScript/Interactive-programming new file mode 120000 index 0000000000..7d8bff426c --- /dev/null +++ b/Lang/JavaScript/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Introspection b/Lang/JavaScript/Introspection new file mode 120000 index 0000000000..772c670521 --- /dev/null +++ b/Lang/JavaScript/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Jensens-Device b/Lang/JavaScript/Jensens-Device new file mode 120000 index 0000000000..0d182bdc22 --- /dev/null +++ b/Lang/JavaScript/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Keyboard-macros b/Lang/JavaScript/Keyboard-macros new file mode 120000 index 0000000000..fa7a9a3335 --- /dev/null +++ b/Lang/JavaScript/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Knapsack-problem-Bounded b/Lang/JavaScript/Knapsack-problem-Bounded new file mode 120000 index 0000000000..6e9d165a8d --- /dev/null +++ b/Lang/JavaScript/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Knapsack-problem-Unbounded b/Lang/JavaScript/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..bda6e155a8 --- /dev/null +++ b/Lang/JavaScript/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/LZW-compression b/Lang/JavaScript/LZW-compression new file mode 120000 index 0000000000..4b161769e3 --- /dev/null +++ b/Lang/JavaScript/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Langtons-ant b/Lang/JavaScript/Langtons-ant new file mode 120000 index 0000000000..68e9eab656 --- /dev/null +++ b/Lang/JavaScript/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Leap-year b/Lang/JavaScript/Leap-year new file mode 120000 index 0000000000..c2541f42a5 --- /dev/null +++ b/Lang/JavaScript/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Levenshtein-distance b/Lang/JavaScript/Levenshtein-distance new file mode 120000 index 0000000000..80af1a22f5 --- /dev/null +++ b/Lang/JavaScript/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/List-comprehensions b/Lang/JavaScript/List-comprehensions new file mode 120000 index 0000000000..1a5d86e570 --- /dev/null +++ b/Lang/JavaScript/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Literals-Integer b/Lang/JavaScript/Literals-Integer new file mode 120000 index 0000000000..f11aadbb4b --- /dev/null +++ b/Lang/JavaScript/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Logical-operations b/Lang/JavaScript/Logical-operations new file mode 120000 index 0000000000..d1e8f9114d --- /dev/null +++ b/Lang/JavaScript/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Long-multiplication b/Lang/JavaScript/Long-multiplication new file mode 120000 index 0000000000..a9bac1da52 --- /dev/null +++ b/Lang/JavaScript/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Longest-common-subsequence b/Lang/JavaScript/Longest-common-subsequence new file mode 120000 index 0000000000..42ec21d2e1 --- /dev/null +++ b/Lang/JavaScript/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Look-and-say-sequence b/Lang/JavaScript/Look-and-say-sequence new file mode 120000 index 0000000000..6293cd9784 --- /dev/null +++ b/Lang/JavaScript/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loop-over-multiple-arrays-simultaneously b/Lang/JavaScript/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..a2482755a0 --- /dev/null +++ b/Lang/JavaScript/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Break b/Lang/JavaScript/Loops-Break new file mode 120000 index 0000000000..29f9e46d2c --- /dev/null +++ b/Lang/JavaScript/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Continue b/Lang/JavaScript/Loops-Continue new file mode 120000 index 0000000000..4a5e311ce9 --- /dev/null +++ b/Lang/JavaScript/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Do-while b/Lang/JavaScript/Loops-Do-while new file mode 120000 index 0000000000..3cbd94e8c3 --- /dev/null +++ b/Lang/JavaScript/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Downward-for b/Lang/JavaScript/Loops-Downward-for new file mode 120000 index 0000000000..9f59d5ebc9 --- /dev/null +++ b/Lang/JavaScript/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-For b/Lang/JavaScript/Loops-For new file mode 120000 index 0000000000..41a05fe763 --- /dev/null +++ b/Lang/JavaScript/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-For-with-a-specified-step b/Lang/JavaScript/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..b8d5193587 --- /dev/null +++ b/Lang/JavaScript/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Foreach b/Lang/JavaScript/Loops-Foreach new file mode 120000 index 0000000000..e3f7b731cd --- /dev/null +++ b/Lang/JavaScript/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Infinite b/Lang/JavaScript/Loops-Infinite new file mode 120000 index 0000000000..b2b4f5efd2 --- /dev/null +++ b/Lang/JavaScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-N-plus-one-half b/Lang/JavaScript/Loops-N-plus-one-half new file mode 120000 index 0000000000..935a67a7da --- /dev/null +++ b/Lang/JavaScript/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-Nested b/Lang/JavaScript/Loops-Nested new file mode 120000 index 0000000000..9214b3aee7 --- /dev/null +++ b/Lang/JavaScript/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Loops-While b/Lang/JavaScript/Loops-While new file mode 120000 index 0000000000..1680acc343 --- /dev/null +++ b/Lang/JavaScript/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Luhn-test-of-credit-card-numbers b/Lang/JavaScript/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..d8df1bb84c --- /dev/null +++ b/Lang/JavaScript/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Main-step-of-GOST-28147-89 b/Lang/JavaScript/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..770ead033c --- /dev/null +++ b/Lang/JavaScript/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Man-or-boy-test b/Lang/JavaScript/Man-or-boy-test new file mode 120000 index 0000000000..d1237031ec --- /dev/null +++ b/Lang/JavaScript/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Mandelbrot-set b/Lang/JavaScript/Mandelbrot-set new file mode 120000 index 0000000000..b9f7a49d88 --- /dev/null +++ b/Lang/JavaScript/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Map-range b/Lang/JavaScript/Map-range new file mode 120000 index 0000000000..7b64a6e895 --- /dev/null +++ b/Lang/JavaScript/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Matrix-exponentiation-operator b/Lang/JavaScript/Matrix-exponentiation-operator new file mode 120000 index 0000000000..6b937df393 --- /dev/null +++ b/Lang/JavaScript/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Matrix-multiplication b/Lang/JavaScript/Matrix-multiplication new file mode 120000 index 0000000000..437f4bb453 --- /dev/null +++ b/Lang/JavaScript/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Matrix-transposition b/Lang/JavaScript/Matrix-transposition new file mode 120000 index 0000000000..b108022acd --- /dev/null +++ b/Lang/JavaScript/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Maze-generation b/Lang/JavaScript/Maze-generation new file mode 120000 index 0000000000..eb204ee963 --- /dev/null +++ b/Lang/JavaScript/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Menu b/Lang/JavaScript/Menu new file mode 120000 index 0000000000..759f12431f --- /dev/null +++ b/Lang/JavaScript/Menu @@ -0,0 +1 @@ +../../Task/Menu/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Middle-three-digits b/Lang/JavaScript/Middle-three-digits new file mode 120000 index 0000000000..97aec8a3f4 --- /dev/null +++ b/Lang/JavaScript/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Miller-Rabin-primality-test b/Lang/JavaScript/Miller-Rabin-primality-test new file mode 120000 index 0000000000..41f625032e --- /dev/null +++ b/Lang/JavaScript/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Monte-Carlo-methods b/Lang/JavaScript/Monte-Carlo-methods new file mode 120000 index 0000000000..fc1d833264 --- /dev/null +++ b/Lang/JavaScript/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Monty-Hall-problem b/Lang/JavaScript/Monty-Hall-problem new file mode 120000 index 0000000000..952fdc677c --- /dev/null +++ b/Lang/JavaScript/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Morse-code b/Lang/JavaScript/Morse-code new file mode 120000 index 0000000000..a22cd714de --- /dev/null +++ b/Lang/JavaScript/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Mouse-position b/Lang/JavaScript/Mouse-position new file mode 120000 index 0000000000..362cb4d93a --- /dev/null +++ b/Lang/JavaScript/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Multifactorial b/Lang/JavaScript/Multifactorial new file mode 120000 index 0000000000..b341322137 --- /dev/null +++ b/Lang/JavaScript/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Multiple-distinct-objects b/Lang/JavaScript/Multiple-distinct-objects new file mode 120000 index 0000000000..a018859a54 --- /dev/null +++ b/Lang/JavaScript/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Multiple-regression b/Lang/JavaScript/Multiple-regression new file mode 120000 index 0000000000..73a363e1ba --- /dev/null +++ b/Lang/JavaScript/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Multiplication-tables b/Lang/JavaScript/Multiplication-tables new file mode 120000 index 0000000000..4fd65d54f5 --- /dev/null +++ b/Lang/JavaScript/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Multisplit b/Lang/JavaScript/Multisplit new file mode 120000 index 0000000000..ea73449ef0 --- /dev/null +++ b/Lang/JavaScript/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Mutual-recursion b/Lang/JavaScript/Mutual-recursion new file mode 120000 index 0000000000..cda025011e --- /dev/null +++ b/Lang/JavaScript/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/JavaScript \ No newline at end of file diff --git a/Lang/Jcon/0DESCRIPTION b/Lang/Jcon/0DESCRIPTION new file mode 100644 index 0000000000..3323aaf226 --- /dev/null +++ b/Lang/Jcon/0DESCRIPTION @@ -0,0 +1,28 @@ +{{Stub}} +{{language|Jcon +|site=http://www.cs.arizona.edu/icon/jcon/ +|exec=bytecode +|parampass=value +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|gc=yes +|LCT=yes +}} +{{virtual machine}} +{{language programming paradigm|Procedural}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|Object-oriented}} +{{language programming paradigm|Logic_Programming}} + +Jcon is a Java-based implementation of the Icon programming language. The Jcon translator, written in Icon, generates Java class files that execute in conjunction with a run-time system written in Java. + +Version 2 of Jcon is an essentially complete implementation of Icon, including graphics and large integers. A few minor features are missing -- mostly things like chdir() that cannot be done in Java. + +Jcon is currently not being developed. + +== Related == +* [[:Icon]] +* [[:ObjectIcon]] +* [[:Unicon]] \ No newline at end of file diff --git a/Lang/JoCaml/0DESCRIPTION b/Lang/JoCaml/0DESCRIPTION new file mode 100644 index 0000000000..3ff5c821ee --- /dev/null +++ b/Lang/JoCaml/0DESCRIPTION @@ -0,0 +1,2 @@ +{{Merge language|OCaml}} +{{language|JoCaml}} \ No newline at end of file diff --git a/Lang/JoCaml/Dining-philosophers b/Lang/JoCaml/Dining-philosophers new file mode 120000 index 0000000000..90f57ddd73 --- /dev/null +++ b/Lang/JoCaml/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/JoCaml \ No newline at end of file diff --git a/Lang/Joy/0DESCRIPTION b/Lang/Joy/0DESCRIPTION new file mode 100644 index 0000000000..e2565a3c6f --- /dev/null +++ b/Lang/Joy/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language +|strength=strong +|safety=safe +|checking=dynamic +|site=http://www.latrobe.edu.au/phimvt/joy.html +|hopl id=2137 +|LCT=yes}} +{{language programming paradigm|concatenative}} +{{language programming paradigm|functional}} +'''Joy''' is a [[functional programming]] language based on combinators rather than lambda expressions. This gives it a postfix syntax, similar to [[Forth]], although the semantics are quite different. \ No newline at end of file diff --git a/Lang/Joy/99-Bottles-of-Beer b/Lang/Joy/99-Bottles-of-Beer new file mode 120000 index 0000000000..0953610dd4 --- /dev/null +++ b/Lang/Joy/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Joy \ No newline at end of file diff --git a/Lang/Joy/A+B b/Lang/Joy/A+B new file mode 120000 index 0000000000..faabf208d1 --- /dev/null +++ b/Lang/Joy/A+B @@ -0,0 +1 @@ +../../Task/A+B/Joy \ No newline at end of file diff --git a/Lang/Joy/Ackermann-function b/Lang/Joy/Ackermann-function new file mode 120000 index 0000000000..9f8f4ce1ff --- /dev/null +++ b/Lang/Joy/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Joy \ No newline at end of file diff --git a/Lang/Joy/Apply-a-callback-to-an-array b/Lang/Joy/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..394ef7d86b --- /dev/null +++ b/Lang/Joy/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Joy \ No newline at end of file diff --git a/Lang/Joy/Character-codes b/Lang/Joy/Character-codes new file mode 120000 index 0000000000..e6557d77e0 --- /dev/null +++ b/Lang/Joy/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Joy \ No newline at end of file diff --git a/Lang/Joy/Comments b/Lang/Joy/Comments new file mode 120000 index 0000000000..38a5c89357 --- /dev/null +++ b/Lang/Joy/Comments @@ -0,0 +1 @@ +../../Task/Comments/Joy \ No newline at end of file diff --git a/Lang/Joy/Date-format b/Lang/Joy/Date-format new file mode 120000 index 0000000000..c116617c9b --- /dev/null +++ b/Lang/Joy/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Joy \ No newline at end of file diff --git a/Lang/Joy/Empty-program b/Lang/Joy/Empty-program new file mode 120000 index 0000000000..dc7934e455 --- /dev/null +++ b/Lang/Joy/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Joy \ No newline at end of file diff --git a/Lang/Joy/Execute-a-system-command b/Lang/Joy/Execute-a-system-command new file mode 120000 index 0000000000..fe2d93d4cd --- /dev/null +++ b/Lang/Joy/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Joy \ No newline at end of file diff --git a/Lang/Joy/Factorial b/Lang/Joy/Factorial new file mode 120000 index 0000000000..811981d2a4 --- /dev/null +++ b/Lang/Joy/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Joy \ No newline at end of file diff --git a/Lang/Joy/Fibonacci-sequence b/Lang/Joy/Fibonacci-sequence new file mode 120000 index 0000000000..e4b2ef9a93 --- /dev/null +++ b/Lang/Joy/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Joy \ No newline at end of file diff --git a/Lang/Joy/FizzBuzz b/Lang/Joy/FizzBuzz new file mode 120000 index 0000000000..188ec40de0 --- /dev/null +++ b/Lang/Joy/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Joy \ No newline at end of file diff --git a/Lang/Joy/Function-composition b/Lang/Joy/Function-composition new file mode 120000 index 0000000000..d331629463 --- /dev/null +++ b/Lang/Joy/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Joy \ No newline at end of file diff --git a/Lang/Joy/Function-definition b/Lang/Joy/Function-definition new file mode 120000 index 0000000000..35f014a096 --- /dev/null +++ b/Lang/Joy/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Joy \ No newline at end of file diff --git a/Lang/Joy/Generic-swap b/Lang/Joy/Generic-swap new file mode 120000 index 0000000000..85743745c8 --- /dev/null +++ b/Lang/Joy/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Joy \ No newline at end of file diff --git a/Lang/Joy/Greatest-common-divisor b/Lang/Joy/Greatest-common-divisor new file mode 120000 index 0000000000..dd7933fd12 --- /dev/null +++ b/Lang/Joy/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Joy \ No newline at end of file diff --git a/Lang/Joy/Hello-world-Text b/Lang/Joy/Hello-world-Text new file mode 120000 index 0000000000..3343d17255 --- /dev/null +++ b/Lang/Joy/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Joy \ No newline at end of file diff --git a/Lang/Joy/Higher-order-functions b/Lang/Joy/Higher-order-functions new file mode 120000 index 0000000000..12ce35e429 --- /dev/null +++ b/Lang/Joy/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Joy \ No newline at end of file diff --git a/Lang/Joy/Integer-comparison b/Lang/Joy/Integer-comparison new file mode 120000 index 0000000000..9f191f9f61 --- /dev/null +++ b/Lang/Joy/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Joy \ No newline at end of file diff --git a/Lang/Joy/Integer-sequence b/Lang/Joy/Integer-sequence new file mode 120000 index 0000000000..d4f3ef8a25 --- /dev/null +++ b/Lang/Joy/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Joy \ No newline at end of file diff --git a/Lang/Joy/Jensens-Device b/Lang/Joy/Jensens-Device new file mode 120000 index 0000000000..5dda010815 --- /dev/null +++ b/Lang/Joy/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Joy \ No newline at end of file diff --git a/Lang/Joy/Knuth-shuffle b/Lang/Joy/Knuth-shuffle new file mode 120000 index 0000000000..78c89a9ace --- /dev/null +++ b/Lang/Joy/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Joy \ No newline at end of file diff --git a/Lang/Joy/Loops-Infinite b/Lang/Joy/Loops-Infinite new file mode 120000 index 0000000000..b11607e617 --- /dev/null +++ b/Lang/Joy/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Joy \ No newline at end of file diff --git a/Lang/Joy/Loops-While b/Lang/Joy/Loops-While new file mode 120000 index 0000000000..038116fa9a --- /dev/null +++ b/Lang/Joy/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Joy \ No newline at end of file diff --git a/Lang/Joy/Matrix-transposition b/Lang/Joy/Matrix-transposition new file mode 120000 index 0000000000..18a782ce6f --- /dev/null +++ b/Lang/Joy/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Joy \ No newline at end of file diff --git a/Lang/Joy/Quine b/Lang/Joy/Quine new file mode 120000 index 0000000000..dbc089e816 --- /dev/null +++ b/Lang/Joy/Quine @@ -0,0 +1 @@ +../../Task/Quine/Joy \ No newline at end of file diff --git a/Lang/JudoScript/0DESCRIPTION b/Lang/JudoScript/0DESCRIPTION new file mode 100644 index 0000000000..c3cf39cc64 --- /dev/null +++ b/Lang/JudoScript/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|JudoScript}}[[runs on vm::java virtual machine| ]] +'''JudoScript''' is a scripting language based atop of [[Java]]. + +From the website: + +:''Judo is a practical, functional scripting language. It is designed to cover the use cases of not only algorithmic/object-oriented/multi-threaded programming and Java scripting but also a number of major application domain tasks, such as scripting for JDBC, WSDL, ActiveX, OS, multiple file/data formats, etc. Despite its rich functionality, the base language is extremely simple, and domain support syntax is totally intuitive to domain experts, so that even though you have never programmed in Judo, you would have little trouble figuring out what the code does.'' + +==Citations== +* [http://www.judoscript.com/judo.html judoscript.com] \ No newline at end of file diff --git a/Lang/Julia/0DESCRIPTION b/Lang/Julia/0DESCRIPTION new file mode 100644 index 0000000000..06f7875a8f --- /dev/null +++ b/Lang/Julia/0DESCRIPTION @@ -0,0 +1,4 @@ +{{stub}} +{{language | Julia | site=http://julialang.org/ }} + +Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax silimar to [[MATLAB]]'s. It provides a sophisticated compiler, distributed parallel execution, numerical accuracy, and an extensive mathematical function library. \ No newline at end of file diff --git a/Lang/Julia/100-doors b/Lang/Julia/100-doors new file mode 120000 index 0000000000..8db7836189 --- /dev/null +++ b/Lang/Julia/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Julia \ No newline at end of file diff --git a/Lang/Julia/99-Bottles-of-Beer b/Lang/Julia/99-Bottles-of-Beer new file mode 120000 index 0000000000..e675777278 --- /dev/null +++ b/Lang/Julia/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Julia \ No newline at end of file diff --git a/Lang/Julia/A+B b/Lang/Julia/A+B new file mode 120000 index 0000000000..35be6a9649 --- /dev/null +++ b/Lang/Julia/A+B @@ -0,0 +1 @@ +../../Task/A+B/Julia \ No newline at end of file diff --git a/Lang/Julia/Abstract-type b/Lang/Julia/Abstract-type new file mode 120000 index 0000000000..2e66630a8a --- /dev/null +++ b/Lang/Julia/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Julia \ No newline at end of file diff --git a/Lang/Julia/Accumulator-factory b/Lang/Julia/Accumulator-factory new file mode 120000 index 0000000000..03dc95844b --- /dev/null +++ b/Lang/Julia/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Julia \ No newline at end of file diff --git a/Lang/Julia/Ackermann-function b/Lang/Julia/Ackermann-function new file mode 120000 index 0000000000..f0919686e3 --- /dev/null +++ b/Lang/Julia/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Julia \ No newline at end of file diff --git a/Lang/Julia/Apply-a-callback-to-an-array b/Lang/Julia/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..cc07b9c24a --- /dev/null +++ b/Lang/Julia/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Julia \ No newline at end of file diff --git a/Lang/Julia/Arbitrary-precision-integers-included b/Lang/Julia/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..6d0033eafb --- /dev/null +++ b/Lang/Julia/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Julia \ No newline at end of file diff --git a/Lang/Julia/Arithmetic-evaluation b/Lang/Julia/Arithmetic-evaluation new file mode 120000 index 0000000000..b5cb5155a0 --- /dev/null +++ b/Lang/Julia/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Julia \ No newline at end of file diff --git a/Lang/Julia/Array-concatenation b/Lang/Julia/Array-concatenation new file mode 120000 index 0000000000..c45274ee74 --- /dev/null +++ b/Lang/Julia/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Julia \ No newline at end of file diff --git a/Lang/Julia/Assertions b/Lang/Julia/Assertions new file mode 120000 index 0000000000..4a8a3e53e6 --- /dev/null +++ b/Lang/Julia/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Julia \ No newline at end of file diff --git a/Lang/Julia/Averages-Arithmetic-mean b/Lang/Julia/Averages-Arithmetic-mean new file mode 120000 index 0000000000..550cda0812 --- /dev/null +++ b/Lang/Julia/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Julia \ No newline at end of file diff --git a/Lang/Julia/Averages-Median b/Lang/Julia/Averages-Median new file mode 120000 index 0000000000..270510744f --- /dev/null +++ b/Lang/Julia/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Julia \ No newline at end of file diff --git a/Lang/Julia/Boolean-values b/Lang/Julia/Boolean-values new file mode 120000 index 0000000000..3324856d7b --- /dev/null +++ b/Lang/Julia/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Julia \ No newline at end of file diff --git a/Lang/Julia/Bulls-and-cows b/Lang/Julia/Bulls-and-cows new file mode 120000 index 0000000000..39647f23b8 --- /dev/null +++ b/Lang/Julia/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Julia \ No newline at end of file diff --git a/Lang/Julia/Call-a-function-in-a-shared-library b/Lang/Julia/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..2cc94c3d59 --- /dev/null +++ b/Lang/Julia/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Julia \ No newline at end of file diff --git a/Lang/Julia/Character-matching b/Lang/Julia/Character-matching new file mode 120000 index 0000000000..5fd1bd4f85 --- /dev/null +++ b/Lang/Julia/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Julia \ No newline at end of file diff --git a/Lang/Julia/Combinations b/Lang/Julia/Combinations new file mode 120000 index 0000000000..a142042a08 --- /dev/null +++ b/Lang/Julia/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Julia \ No newline at end of file diff --git a/Lang/Julia/Dot-product b/Lang/Julia/Dot-product new file mode 120000 index 0000000000..d1b385b3df --- /dev/null +++ b/Lang/Julia/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Julia \ No newline at end of file diff --git a/Lang/Julia/Factorial b/Lang/Julia/Factorial new file mode 120000 index 0000000000..7f530b098c --- /dev/null +++ b/Lang/Julia/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Julia \ No newline at end of file diff --git a/Lang/Julia/Fibonacci-sequence b/Lang/Julia/Fibonacci-sequence new file mode 120000 index 0000000000..8b8744bfe4 --- /dev/null +++ b/Lang/Julia/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Julia \ No newline at end of file diff --git a/Lang/Julia/FizzBuzz b/Lang/Julia/FizzBuzz new file mode 120000 index 0000000000..d639f17f58 --- /dev/null +++ b/Lang/Julia/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Julia \ No newline at end of file diff --git a/Lang/Julia/Flatten-a-list b/Lang/Julia/Flatten-a-list new file mode 120000 index 0000000000..205942a073 --- /dev/null +++ b/Lang/Julia/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Julia \ No newline at end of file diff --git a/Lang/Julia/Floyds-triangle b/Lang/Julia/Floyds-triangle new file mode 120000 index 0000000000..05c8aba408 --- /dev/null +++ b/Lang/Julia/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Julia \ No newline at end of file diff --git a/Lang/Julia/Function-definition b/Lang/Julia/Function-definition new file mode 120000 index 0000000000..35e2023822 --- /dev/null +++ b/Lang/Julia/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Julia \ No newline at end of file diff --git a/Lang/Julia/Greatest-element-of-a-list b/Lang/Julia/Greatest-element-of-a-list new file mode 120000 index 0000000000..ccd57a562a --- /dev/null +++ b/Lang/Julia/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Julia \ No newline at end of file diff --git a/Lang/Julia/Hailstone-sequence b/Lang/Julia/Hailstone-sequence new file mode 120000 index 0000000000..3d67ebea9b --- /dev/null +++ b/Lang/Julia/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Julia \ No newline at end of file diff --git a/Lang/Julia/Happy-numbers b/Lang/Julia/Happy-numbers new file mode 120000 index 0000000000..dd98f6b1f5 --- /dev/null +++ b/Lang/Julia/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Julia \ No newline at end of file diff --git a/Lang/Julia/Harshad-or-Niven-series b/Lang/Julia/Harshad-or-Niven-series new file mode 120000 index 0000000000..0859d4b512 --- /dev/null +++ b/Lang/Julia/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Julia \ No newline at end of file diff --git a/Lang/Julia/Haversine-formula b/Lang/Julia/Haversine-formula new file mode 120000 index 0000000000..29af8f4afc --- /dev/null +++ b/Lang/Julia/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Julia \ No newline at end of file diff --git a/Lang/Julia/Hello-world-Text b/Lang/Julia/Hello-world-Text new file mode 120000 index 0000000000..24e528aa1e --- /dev/null +++ b/Lang/Julia/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Julia \ No newline at end of file diff --git a/Lang/Julia/Mandelbrot-set b/Lang/Julia/Mandelbrot-set new file mode 120000 index 0000000000..207405d4f5 --- /dev/null +++ b/Lang/Julia/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Julia \ No newline at end of file diff --git a/Lang/Julia/Middle-three-digits b/Lang/Julia/Middle-three-digits new file mode 120000 index 0000000000..419a27261c --- /dev/null +++ b/Lang/Julia/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Julia \ No newline at end of file diff --git a/Lang/K/0DESCRIPTION b/Lang/K/0DESCRIPTION new file mode 100644 index 0000000000..0e3ab06ec9 --- /dev/null +++ b/Lang/K/0DESCRIPTION @@ -0,0 +1,12 @@ +{{language|K +|site=http://www.kx.com/index.php +}} + +K is a proprietary array processing language developed by Arthur Whitney and commercialized by Kx Systems. The language serves as the foundation for kdb, an in-memory, column-based database, and other related financial products. The language, originally developed in 1993, is a variant of [[APL]] and contains elements of [[Scheme]]. Advocates of the language emphasize its speed, facility in handling arrays and its expressive syntax.[[#Citations|[1]]] + +==Citations== +#[[wp:K_(programming_language)|Wikipedia K Programming Language]] + +==See Also== +*[http://vrabi.web.elte.hu/k/ K Programming Language] +*[https://github.com/kevinlawler/kona Kona an open source implementation of K] \ No newline at end of file diff --git a/Lang/K/100-doors b/Lang/K/100-doors new file mode 120000 index 0000000000..3169e5b61b --- /dev/null +++ b/Lang/K/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/K \ No newline at end of file diff --git a/Lang/K/99-Bottles-of-Beer b/Lang/K/99-Bottles-of-Beer new file mode 120000 index 0000000000..0e25224bc7 --- /dev/null +++ b/Lang/K/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/K \ No newline at end of file diff --git a/Lang/K/Ackermann-function b/Lang/K/Ackermann-function new file mode 120000 index 0000000000..21a50c18d1 --- /dev/null +++ b/Lang/K/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/K \ No newline at end of file diff --git a/Lang/K/Anagrams b/Lang/K/Anagrams new file mode 120000 index 0000000000..c9682e2db4 --- /dev/null +++ b/Lang/K/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/K \ No newline at end of file diff --git a/Lang/K/Anagrams-Deranged-anagrams b/Lang/K/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..799f236ffb --- /dev/null +++ b/Lang/K/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/K \ No newline at end of file diff --git a/Lang/K/Anonymous-recursion b/Lang/K/Anonymous-recursion new file mode 120000 index 0000000000..5df80848e2 --- /dev/null +++ b/Lang/K/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/K \ No newline at end of file diff --git a/Lang/K/Array-concatenation b/Lang/K/Array-concatenation new file mode 120000 index 0000000000..5ae9b795fa --- /dev/null +++ b/Lang/K/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/K \ No newline at end of file diff --git a/Lang/K/Associative-array-Creation b/Lang/K/Associative-array-Creation new file mode 120000 index 0000000000..4240ddc7a7 --- /dev/null +++ b/Lang/K/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/K \ No newline at end of file diff --git a/Lang/K/Associative-array-Iteration b/Lang/K/Associative-array-Iteration new file mode 120000 index 0000000000..20974222e2 --- /dev/null +++ b/Lang/K/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/K \ No newline at end of file diff --git a/Lang/K/Averages-Arithmetic-mean b/Lang/K/Averages-Arithmetic-mean new file mode 120000 index 0000000000..9f047371e6 --- /dev/null +++ b/Lang/K/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/K \ No newline at end of file diff --git a/Lang/K/Averages-Mode b/Lang/K/Averages-Mode new file mode 120000 index 0000000000..029ca85cde --- /dev/null +++ b/Lang/K/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/K \ No newline at end of file diff --git a/Lang/K/Box-the-compass b/Lang/K/Box-the-compass new file mode 120000 index 0000000000..4c62a4f5a5 --- /dev/null +++ b/Lang/K/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/K \ No newline at end of file diff --git a/Lang/K/Case-sensitivity-of-identifiers b/Lang/K/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..7fa1820e0d --- /dev/null +++ b/Lang/K/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/K \ No newline at end of file diff --git a/Lang/K/Character-codes b/Lang/K/Character-codes new file mode 120000 index 0000000000..ed3a2f2346 --- /dev/null +++ b/Lang/K/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/K \ No newline at end of file diff --git a/Lang/K/Character-matching b/Lang/K/Character-matching new file mode 120000 index 0000000000..c87d021c77 --- /dev/null +++ b/Lang/K/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/K \ No newline at end of file diff --git a/Lang/K/Comments b/Lang/K/Comments new file mode 120000 index 0000000000..484fad56aa --- /dev/null +++ b/Lang/K/Comments @@ -0,0 +1 @@ +../../Task/Comments/K \ No newline at end of file diff --git a/Lang/K/Count-occurrences-of-a-substring b/Lang/K/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..9228357873 --- /dev/null +++ b/Lang/K/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/K \ No newline at end of file diff --git a/Lang/K/Create-a-file b/Lang/K/Create-a-file new file mode 120000 index 0000000000..be414bb0c7 --- /dev/null +++ b/Lang/K/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/K \ No newline at end of file diff --git a/Lang/K/Day-of-the-week b/Lang/K/Day-of-the-week new file mode 120000 index 0000000000..e2f41c2e1d --- /dev/null +++ b/Lang/K/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/K \ No newline at end of file diff --git a/Lang/K/Dot-product b/Lang/K/Dot-product new file mode 120000 index 0000000000..29d2d2e7e9 --- /dev/null +++ b/Lang/K/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/K \ No newline at end of file diff --git a/Lang/K/Element-wise-operations b/Lang/K/Element-wise-operations new file mode 120000 index 0000000000..a6f23fd928 --- /dev/null +++ b/Lang/K/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/K \ No newline at end of file diff --git a/Lang/K/Empty-program b/Lang/K/Empty-program new file mode 120000 index 0000000000..f255a9c6f6 --- /dev/null +++ b/Lang/K/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/K \ No newline at end of file diff --git a/Lang/K/Empty-string b/Lang/K/Empty-string new file mode 120000 index 0000000000..c276f737a6 --- /dev/null +++ b/Lang/K/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/K \ No newline at end of file diff --git a/Lang/K/Equilibrium-index b/Lang/K/Equilibrium-index new file mode 120000 index 0000000000..cc85e607e5 --- /dev/null +++ b/Lang/K/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/K \ No newline at end of file diff --git a/Lang/K/Evaluate-binomial-coefficients b/Lang/K/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..eb340ee95b --- /dev/null +++ b/Lang/K/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/K \ No newline at end of file diff --git a/Lang/K/Execute-a-system-command b/Lang/K/Execute-a-system-command new file mode 120000 index 0000000000..8001ab0a3b --- /dev/null +++ b/Lang/K/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/K \ No newline at end of file diff --git a/Lang/K/Factorial b/Lang/K/Factorial new file mode 120000 index 0000000000..4e6daede74 --- /dev/null +++ b/Lang/K/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/K \ No newline at end of file diff --git a/Lang/K/Factors-of-an-integer b/Lang/K/Factors-of-an-integer new file mode 120000 index 0000000000..b5267d6c8c --- /dev/null +++ b/Lang/K/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/K \ No newline at end of file diff --git a/Lang/K/Fibonacci-sequence b/Lang/K/Fibonacci-sequence new file mode 120000 index 0000000000..d59c4fe4a2 --- /dev/null +++ b/Lang/K/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/K \ No newline at end of file diff --git a/Lang/K/File-IO b/Lang/K/File-IO new file mode 120000 index 0000000000..c6b944d183 --- /dev/null +++ b/Lang/K/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/K \ No newline at end of file diff --git a/Lang/K/File-size b/Lang/K/File-size new file mode 120000 index 0000000000..3be2281923 --- /dev/null +++ b/Lang/K/File-size @@ -0,0 +1 @@ +../../Task/File-size/K \ No newline at end of file diff --git a/Lang/K/Filter b/Lang/K/Filter new file mode 120000 index 0000000000..5bb7073a49 --- /dev/null +++ b/Lang/K/Filter @@ -0,0 +1 @@ +../../Task/Filter/K \ No newline at end of file diff --git a/Lang/K/Find-the-missing-permutation b/Lang/K/Find-the-missing-permutation new file mode 120000 index 0000000000..f87ee00084 --- /dev/null +++ b/Lang/K/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/K \ No newline at end of file diff --git a/Lang/K/FizzBuzz b/Lang/K/FizzBuzz new file mode 120000 index 0000000000..1331cdf976 --- /dev/null +++ b/Lang/K/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/K \ No newline at end of file diff --git a/Lang/K/Flatten-a-list b/Lang/K/Flatten-a-list new file mode 120000 index 0000000000..a10349c6fc --- /dev/null +++ b/Lang/K/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/K \ No newline at end of file diff --git a/Lang/K/Function-composition b/Lang/K/Function-composition new file mode 120000 index 0000000000..f7e961ab1e --- /dev/null +++ b/Lang/K/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/K \ No newline at end of file diff --git a/Lang/K/Gray-code b/Lang/K/Gray-code new file mode 120000 index 0000000000..37d15ff72d --- /dev/null +++ b/Lang/K/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/K \ No newline at end of file diff --git a/Lang/K/Greatest-common-divisor b/Lang/K/Greatest-common-divisor new file mode 120000 index 0000000000..a9ae23a386 --- /dev/null +++ b/Lang/K/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/K \ No newline at end of file diff --git a/Lang/K/Greatest-element-of-a-list b/Lang/K/Greatest-element-of-a-list new file mode 120000 index 0000000000..bfa38fac17 --- /dev/null +++ b/Lang/K/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/K \ No newline at end of file diff --git a/Lang/K/Hailstone-sequence b/Lang/K/Hailstone-sequence new file mode 120000 index 0000000000..a0bc037b6f --- /dev/null +++ b/Lang/K/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/K \ No newline at end of file diff --git a/Lang/K/Happy-numbers b/Lang/K/Happy-numbers new file mode 120000 index 0000000000..8c8b324948 --- /dev/null +++ b/Lang/K/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/K \ No newline at end of file diff --git a/Lang/K/Hash-from-two-arrays b/Lang/K/Hash-from-two-arrays new file mode 120000 index 0000000000..2e0efd62f8 --- /dev/null +++ b/Lang/K/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/K \ No newline at end of file diff --git a/Lang/K/Horners-rule-for-polynomial-evaluation b/Lang/K/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..746f539fb9 --- /dev/null +++ b/Lang/K/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/K \ No newline at end of file diff --git a/Lang/K/Increment-a-numerical-string b/Lang/K/Increment-a-numerical-string new file mode 120000 index 0000000000..67028c2690 --- /dev/null +++ b/Lang/K/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/K \ No newline at end of file diff --git a/Lang/K/Infinity b/Lang/K/Infinity new file mode 120000 index 0000000000..f31ac4bd4b --- /dev/null +++ b/Lang/K/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/K \ No newline at end of file diff --git a/Lang/K/Integer-sequence b/Lang/K/Integer-sequence new file mode 120000 index 0000000000..5da9958157 --- /dev/null +++ b/Lang/K/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/K \ No newline at end of file diff --git a/Lang/K/Interactive-programming b/Lang/K/Interactive-programming new file mode 120000 index 0000000000..f1d50b9760 --- /dev/null +++ b/Lang/K/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/K \ No newline at end of file diff --git a/Lang/K/Leap-year b/Lang/K/Leap-year new file mode 120000 index 0000000000..df494d91da --- /dev/null +++ b/Lang/K/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/K \ No newline at end of file diff --git a/Lang/K/Least-common-multiple b/Lang/K/Least-common-multiple new file mode 120000 index 0000000000..1cc047736d --- /dev/null +++ b/Lang/K/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/K \ No newline at end of file diff --git a/Lang/K/Letter-frequency b/Lang/K/Letter-frequency new file mode 120000 index 0000000000..f0648e2f4c --- /dev/null +++ b/Lang/K/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/K \ No newline at end of file diff --git a/Lang/K/Linear-congruential-generator b/Lang/K/Linear-congruential-generator new file mode 120000 index 0000000000..9bc9f59949 --- /dev/null +++ b/Lang/K/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/K \ No newline at end of file diff --git a/Lang/K/Look-and-say-sequence b/Lang/K/Look-and-say-sequence new file mode 120000 index 0000000000..963388ed16 --- /dev/null +++ b/Lang/K/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/K \ No newline at end of file diff --git a/Lang/K/Loop-over-multiple-arrays-simultaneously b/Lang/K/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..1d40821b7c --- /dev/null +++ b/Lang/K/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/K \ No newline at end of file diff --git a/Lang/K/Loops-Foreach b/Lang/K/Loops-Foreach new file mode 120000 index 0000000000..674035f168 --- /dev/null +++ b/Lang/K/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/K \ No newline at end of file diff --git a/Lang/K/Loops-Infinite b/Lang/K/Loops-Infinite new file mode 120000 index 0000000000..a4f6b517c6 --- /dev/null +++ b/Lang/K/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/K \ No newline at end of file diff --git a/Lang/K/Loops-N-plus-one-half b/Lang/K/Loops-N-plus-one-half new file mode 120000 index 0000000000..9f89e61276 --- /dev/null +++ b/Lang/K/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/K \ No newline at end of file diff --git a/Lang/K/Luhn-test-of-credit-card-numbers b/Lang/K/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..f72bf67639 --- /dev/null +++ b/Lang/K/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/K \ No newline at end of file diff --git a/Lang/K/Map-range b/Lang/K/Map-range new file mode 120000 index 0000000000..277f10e807 --- /dev/null +++ b/Lang/K/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/K \ No newline at end of file diff --git a/Lang/K/Matrix-multiplication b/Lang/K/Matrix-multiplication new file mode 120000 index 0000000000..d907eea39e --- /dev/null +++ b/Lang/K/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/K \ No newline at end of file diff --git a/Lang/K/Matrix-transposition b/Lang/K/Matrix-transposition new file mode 120000 index 0000000000..8aaf7d1df2 --- /dev/null +++ b/Lang/K/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/K \ No newline at end of file diff --git a/Lang/K/Monte-Carlo-methods b/Lang/K/Monte-Carlo-methods new file mode 120000 index 0000000000..bf7c3a0f57 --- /dev/null +++ b/Lang/K/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/K \ No newline at end of file diff --git a/Lang/K/Ordered-words b/Lang/K/Ordered-words new file mode 120000 index 0000000000..0d44a4f5a6 --- /dev/null +++ b/Lang/K/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/K \ No newline at end of file diff --git a/Lang/K/Search-a-list b/Lang/K/Search-a-list new file mode 120000 index 0000000000..9839239507 --- /dev/null +++ b/Lang/K/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/K \ No newline at end of file diff --git a/Lang/K3d/0DESCRIPTION b/Lang/K3d/0DESCRIPTION new file mode 100644 index 0000000000..bca513bbcf --- /dev/null +++ b/Lang/K3d/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language}} +The k3d cad system supports the use of scripts (typically written in python) for its operation. \ No newline at end of file diff --git a/Lang/Kaya/0DESCRIPTION b/Lang/Kaya/0DESCRIPTION new file mode 100644 index 0000000000..b4b996157d --- /dev/null +++ b/Lang/Kaya/0DESCRIPTION @@ -0,0 +1,8 @@ +{{stub}}{{language +|exec=machine +|site=http://kayalang.org/ +|gc=yes +|safety=safe +|strength=strong +|checking=static +}} \ No newline at end of file diff --git a/Lang/Kaya/FizzBuzz b/Lang/Kaya/FizzBuzz new file mode 120000 index 0000000000..cd8f0b5d66 --- /dev/null +++ b/Lang/Kaya/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Kaya \ No newline at end of file diff --git a/Lang/Kaya/Function-definition b/Lang/Kaya/Function-definition new file mode 120000 index 0000000000..021c7c0c31 --- /dev/null +++ b/Lang/Kaya/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Kaya \ No newline at end of file diff --git a/Lang/Kaya/Hello-world-Text b/Lang/Kaya/Hello-world-Text new file mode 120000 index 0000000000..24fa89d926 --- /dev/null +++ b/Lang/Kaya/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Kaya \ No newline at end of file diff --git a/Lang/KeyList-Databasing/0DESCRIPTION b/Lang/KeyList-Databasing/0DESCRIPTION new file mode 100644 index 0000000000..d49d3bd063 --- /dev/null +++ b/Lang/KeyList-Databasing/0DESCRIPTION @@ -0,0 +1,51 @@ +{{language}} +'''KeyList Databasing''' is the language used by the BrailleNote (a computer for the blind) to create databases. The BrailleNote is a multipurpose mobile computer (it is commonly classified as a notetaker) with audio and refreshable Braille output. In the BrailleNote, there are databases installed in it, with .klt file extensions. When a .klt database program (written in the KeyList Databasing language) is selected with the "select KeyList file" option in the "KeyList" settings menu in the KeyList menu. (KeyList is an address-list and database program for the BrailleNote). For more info on BrailleNotes, see the company's website, humanware.com. +==Examples== +The following KeyList Databasing program is a perfect example of how the language works. What the commands mean is described below the code. A program like this would be created on a BrailleNote using a klt file-extension, for example, "phonebook.klt". It doesn't work if you just add a .klt file extension, (unlike most files such as .htm). When you are creating the document (in KeySoft 6.2), you would tab over to "create a KeyList Definition File" and type in ''Phonebook''. In the KeyWord word processor in KeySoft, you would type (as code): + +database Phone Book +21 +10001, name, autocap, "Last Name" +10002, name, autocap, "First Name" +10003, name, autocap, "Middle Name" +10004, phone, autonum, "Home Phone Number" +10005, phone, autonum, "Mobile Phone Number" +10006, phone, autonum, "Work Phone Number" +10007, address, "Street Address" +10008, autocap, "City" +10009, allcaps, "State, Province or Territory" +10010, autocap, "Country" +10011, email, G0, "E-mail address" +We will review this code one line at a time: +#Database programs in KeyList Databasing begin with the word "database" followed by the internal database name. Database records created with a KeyList program get exported into .cdb databases when the .klt program runs in KeyList. The user can re-export it into a .csv file if they want to, which can be re-imported into the .klt program's application system, and into the .cdb. If your file is called "phonebook.klt", the .cdb will be called (according to the source code) "phone book.cdb" because the command said "database Phone Book", two words. A database name has to begin with a capital letter. +#The next line, a usually two-digit number, uniquely identifies it from the other database programs in the machine. For example, "24" is not recommended for KeySoft 6.2 on the BrailleNote mPower, because the built in "address list" application (obviously written in KeyList Databasing) is database #24. +This is where we start numbering lines. +#Line 1, which is "10001", will display the word "Last Name" (with a box to fill in the field) to the user. name, autocap, means that it's telling the computer that it is a name, and that the first letter is automatically capitalized, for name convenience. Same with "First Name" and "Middle Name", each with a unique line number. +#The next three lines, which ask the user for a home, mobile and work phone number respectively, say "phone, autonum". Most BrailleNotes have the user type in Braille. In Braille, 1 through 9 are just the dot combinations for A through I, with a number sign combination before it. The autonum command tells the BrailleNote that when a letter is typed in, it automatically becomes a number (A is 1, J is 0, I is 9, and everything in between). The phone part of phone, autonum, just tells the computer that it's a phone number. +#The next line has the "address" command in it. This just allows use of normal Braille text, but should only be used for addresses. +#City and Country both use autocap, but State uses allcaps. This implies that they want an abbreviation (CA for California, or MI for Michigan, etc.). Allcaps is a kind of field that pretty much keeps the caps-lock on no matter what you do. +#Email address field uses the G0 command, which is used by the BrailleNote to tell the user that ASCII computer Braille, not plain Braille (like in the other fields), is used. The email, g0 syntax tells the BrailleNote to prompt the user if it is an invalid email-address. If you type something in an email, G0, field without an at '''@''' sign, it will ask the user if it is okay that it doesn't have an at sign. Regular G0, as in: + +10001, G0, "Product Key Code" +just allows the user to type computer-Braille commands. There is also: +10002, password, G0, "Email Password" +As you may have guessed, password, G0, replaces the typed letters with asterisks (for security). The password is stored in the .cdb (or .csv) file unsecured, but when the .klt is running, (or the .csv gets installed back into the .klt), it's secured. + +==Miscellaneous commands== +There are other commands in KeyList Databasing you just might want to know about: +The boolean command returns a yes or no value, similar to other, more widely-known programming schemes where boolean objects return "true or false" or "1 or 0". Here is an example of a KeyList Databasing boolean object: +11000, boolean, "Are you an experienced programmer" +This command asks the BrailleNote user the question (in quotes). The user has to hit Y or N (yes or no). +The spell command tells the BrailleNote that the speech output system on the BrailleNote should spell it letter-by-letter. For example: +18000, spell, "Zip Code" +If the zip-code were a G0 or autonum command, it would say 49505 as words, like "fourty-nine thousand five hundred five". The spell command tells the speech synthesizer to say "four nine five zero five" (or O five, in some synthesizers). It also spells out what you type into the database field, instead of just waiting until you're done to say it. +The device command is not very common, but it is used in databases that store connection configuration information. For example: +12000, device, "What kind of Internet connection" +This unusual command presents the user with a pre-programmed pull-down menu of Internet connection types, such as "internal modem" (dial-up), "ethernet network connection" (for LAN), "wireless ethernet network connection", (for LAN routed through WiFi) and many others. The only time you will ever see this command is if you read the source code for the database application "Connection Configurations", the second-most popular pre-programmed KeyList database, "Address List" being more commonly used, even though both are on all KeySoft 6.2 systems. Therefor, it is an unnecessary command, unless you are working with the database code that is linked to your BrailleNote's connection configuration file. +Another connection configuration-type command is ssid: +13001, ssid, "Wireless SSID" +This is used by configuration applications so that they know the SSID (name) of a WiFi network. +The file command is used for full-length documents. +15001, file, "Biography" +This command is unusual (but more common than commands like device), in the sense that it doesn't present the user with a box. The word "biography" in this case, gets clicked (technically, Enter is hit) and a word-processing document opens. You have a size limit for these documents, but their contents are saved in the database. +Fields are usually automatically optional in a KeyList database. When you close the database program in KeyList (by hitting Exit), KeyList will ask the user if he/she wants to add the record to the database. At this point, you either hit Y, N or Exit. N deletes what you did, Y saves it in the .cdb database that the program created, and Exit returns you to the database fields. \ No newline at end of file diff --git a/Lang/Kite/0DESCRIPTION b/Lang/Kite/0DESCRIPTION new file mode 100644 index 0000000000..2c17a10618 --- /dev/null +++ b/Lang/Kite/0DESCRIPTION @@ -0,0 +1,5 @@ +{{Stub}}{{language +|site=http://www.kite-language.org}} +'''Kite''' is a programming language started in 2006. Its aim is to be quick and small in developement and run time. The pipe character (|) is used to indicate function calls, unlike other languages that use periods (.). +The language is rather new to the programming community but hold high hopes. If your interested in poking around in this language Documentation is located Here [http://www.kite-language.org/docs/kite-1.0.3-docs/]. +Kites File extension is .kt and requires its own compiler which comes in source and .deb. All located on the official site. \ No newline at end of file diff --git a/Lang/Kite/A+B b/Lang/Kite/A+B new file mode 120000 index 0000000000..a78075e919 --- /dev/null +++ b/Lang/Kite/A+B @@ -0,0 +1 @@ +../../Task/A+B/Kite \ No newline at end of file diff --git a/Lang/Kite/Hello-world-Text b/Lang/Kite/Hello-world-Text new file mode 120000 index 0000000000..2d4aef30c2 --- /dev/null +++ b/Lang/Kite/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Kite \ No newline at end of file diff --git a/Lang/Kite/Inheritance-Single b/Lang/Kite/Inheritance-Single new file mode 120000 index 0000000000..81cc6a31a4 --- /dev/null +++ b/Lang/Kite/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Kite \ No newline at end of file diff --git a/Lang/KonsolScript/0DESCRIPTION b/Lang/KonsolScript/0DESCRIPTION new file mode 100644 index 0000000000..fa341049ac --- /dev/null +++ b/Lang/KonsolScript/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}}{{language +|site=http://www.konsolscript.org|exec=bytecode|express=explicit|parampass=value}} +'''KonsolScript''' is a cross-platform scripting language available under Windows and GNU/Linux. It was intentionally developed on 2005 as the scripting language in writing games with KAGE (Alternative Game Engine) but its interpreter, Quixie, can also be used as common gateway interface for serving web pages. + +Language design is greatly inspired by C programming language. Together with KAGE, KonsolScript was distributed as freeware until it was released as free software in SourceForge on April 2006. KonsolScript is licensed under GNU General Public License. \ No newline at end of file diff --git a/Lang/KonsolScript/Arrays b/Lang/KonsolScript/Arrays new file mode 120000 index 0000000000..018a78feef --- /dev/null +++ b/Lang/KonsolScript/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Bitmap b/Lang/KonsolScript/Bitmap new file mode 120000 index 0000000000..38f19ca566 --- /dev/null +++ b/Lang/KonsolScript/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Comments b/Lang/KonsolScript/Comments new file mode 120000 index 0000000000..02ee677174 --- /dev/null +++ b/Lang/KonsolScript/Comments @@ -0,0 +1 @@ +../../Task/Comments/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Compound-data-type b/Lang/KonsolScript/Compound-data-type new file mode 120000 index 0000000000..535701ee26 --- /dev/null +++ b/Lang/KonsolScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Empty-program b/Lang/KonsolScript/Empty-program new file mode 120000 index 0000000000..25c1124016 --- /dev/null +++ b/Lang/KonsolScript/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Factorial b/Lang/KonsolScript/Factorial new file mode 120000 index 0000000000..da1e757a4d --- /dev/null +++ b/Lang/KonsolScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Hello-world-Graphical b/Lang/KonsolScript/Hello-world-Graphical new file mode 120000 index 0000000000..20422e3893 --- /dev/null +++ b/Lang/KonsolScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/KonsolScript \ No newline at end of file diff --git a/Lang/KonsolScript/Hello-world-Text b/Lang/KonsolScript/Hello-world-Text new file mode 120000 index 0000000000..c66bbca1b9 --- /dev/null +++ b/Lang/KonsolScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/KonsolScript \ No newline at end of file diff --git a/Lang/Kotlin/0DESCRIPTION b/Lang/Kotlin/0DESCRIPTION new file mode 100644 index 0000000000..202a571401 --- /dev/null +++ b/Lang/Kotlin/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language +|checking=static +|site=http://confluence.jetbrains.net/display/Kotlin/Welcome}}Kotlin is the codename for a statically-typed [[JVM]]-targeted programming language developed by JetBrains and intended for industrial use. \ No newline at end of file diff --git a/Lang/Kotlin/99-Bottles-of-Beer b/Lang/Kotlin/99-Bottles-of-Beer new file mode 120000 index 0000000000..164c8af1fb --- /dev/null +++ b/Lang/Kotlin/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Kotlin \ No newline at end of file diff --git a/Lang/L.in.oleum/0DESCRIPTION b/Lang/L.in.oleum/0DESCRIPTION new file mode 100644 index 0000000000..e96284db96 --- /dev/null +++ b/Lang/L.in.oleum/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|L.in.oleum +|site=http://anynowhere.com/bb/posts.php?f=15&t=408&p= +}} + + +L.in.oleum is an unstructured, untyped, procedural programming language. And more specifically, it's a form of cross-platform assembly language. It is oriented to the developement of general-purpose applications, especially when 100% portability, execution speed and module compactness is requested. This language has an almost 1:1 source-to-CPU instruction ratio, allows direct access to five general-purpose registers (performing basic operations from a theoretical 2 up to a pratical of even 10 times faster than memory-held variables), and if used well, is averagely twice as fast as C in pure computational power. Those who are familiar with Java, could imagine L.in.oleum to be based on similar concepts of hardware abstraction, but from a low-level standpoint. Other important highlights concern the inner coherence, clarity and simplicity of its syntax. The (admittedly cryptic) acronym stands for Low-level INterfaced OverLanguage for Extremely Universal Machine-coding, but nevermind it and just friendly call it Lino, like many do... + +==See Also== +*[[wp:Linoleum_(programming_language)|Wikipedia: L.in.oleum(programming_language)]] +*[http://en.allexperts.com/e/l/li/linoleum_programming_language.htm Linoleum programming language: Encyclopedia] \ No newline at end of file diff --git a/Lang/LLP/0DESCRIPTION b/Lang/LLP/0DESCRIPTION new file mode 100644 index 0000000000..8a975aadd6 --- /dev/null +++ b/Lang/LLP/0DESCRIPTION @@ -0,0 +1,4 @@ +{{stub}}{{language|LLP +|site=http://bach.istc.kobe-u.ac.jp/llp/}} +{{language programming paradigm|Declarative}}{{language programming paradigm|Logic_Programming}} +LLP is a logic programming language based on intuitionistic linear logic. LLP is a superset of [[Prolog]] and a subset of [[Lolli]] developed by Josh Hodas and Dale Miller. \ No newline at end of file diff --git a/Lang/LLVM/0DESCRIPTION b/Lang/LLVM/0DESCRIPTION new file mode 100644 index 0000000000..ac6cd653a0 --- /dev/null +++ b/Lang/LLVM/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language|LLVM|site=http://llvm.org/}} \ No newline at end of file diff --git a/Lang/LLVM/99-Bottles-of-Beer b/Lang/LLVM/99-Bottles-of-Beer new file mode 120000 index 0000000000..99d7ba0e35 --- /dev/null +++ b/Lang/LLVM/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/LLVM \ No newline at end of file diff --git a/Lang/LLVM/Bitwise-operations b/Lang/LLVM/Bitwise-operations new file mode 120000 index 0000000000..95a38d1114 --- /dev/null +++ b/Lang/LLVM/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/LLVM \ No newline at end of file diff --git a/Lang/LLVM/Integer-comparison b/Lang/LLVM/Integer-comparison new file mode 120000 index 0000000000..7e70d1227a --- /dev/null +++ b/Lang/LLVM/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/LLVM \ No newline at end of file diff --git a/Lang/LOLCODE/0DESCRIPTION b/Lang/LOLCODE/0DESCRIPTION new file mode 100644 index 0000000000..2dd339db6b --- /dev/null +++ b/Lang/LOLCODE/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language|site=http://lolcode.com/}} +[[Category:Esoteric Languages]] \ No newline at end of file diff --git a/Lang/LOLCODE/100-doors b/Lang/LOLCODE/100-doors new file mode 120000 index 0000000000..145593e902 --- /dev/null +++ b/Lang/LOLCODE/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/99-Bottles-of-Beer b/Lang/LOLCODE/99-Bottles-of-Beer new file mode 120000 index 0000000000..51a01cce6f --- /dev/null +++ b/Lang/LOLCODE/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Ackermann-function b/Lang/LOLCODE/Ackermann-function new file mode 120000 index 0000000000..881b18d231 --- /dev/null +++ b/Lang/LOLCODE/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Add-a-variable-to-a-class-instance-at-runtime b/Lang/LOLCODE/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..01388cdce8 --- /dev/null +++ b/Lang/LOLCODE/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Anonymous-recursion b/Lang/LOLCODE/Anonymous-recursion new file mode 120000 index 0000000000..eab579d7c3 --- /dev/null +++ b/Lang/LOLCODE/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Count-in-octal b/Lang/LOLCODE/Count-in-octal new file mode 120000 index 0000000000..392ee78b2d --- /dev/null +++ b/Lang/LOLCODE/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Empty-string b/Lang/LOLCODE/Empty-string new file mode 120000 index 0000000000..687c6aa5dc --- /dev/null +++ b/Lang/LOLCODE/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/FizzBuzz b/Lang/LOLCODE/FizzBuzz new file mode 120000 index 0000000000..f80c1cd2ee --- /dev/null +++ b/Lang/LOLCODE/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Function-composition b/Lang/LOLCODE/Function-composition new file mode 120000 index 0000000000..614dff03e1 --- /dev/null +++ b/Lang/LOLCODE/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Generic-swap b/Lang/LOLCODE/Generic-swap new file mode 120000 index 0000000000..658a53ba3d --- /dev/null +++ b/Lang/LOLCODE/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Guess-the-number b/Lang/LOLCODE/Guess-the-number new file mode 120000 index 0000000000..d08936cd9e --- /dev/null +++ b/Lang/LOLCODE/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Hailstone-sequence b/Lang/LOLCODE/Hailstone-sequence new file mode 120000 index 0000000000..0c8d34abe0 --- /dev/null +++ b/Lang/LOLCODE/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Harshad-or-Niven-series b/Lang/LOLCODE/Harshad-or-Niven-series new file mode 120000 index 0000000000..bcb68655fe --- /dev/null +++ b/Lang/LOLCODE/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Increment-a-numerical-string b/Lang/LOLCODE/Increment-a-numerical-string new file mode 120000 index 0000000000..0cdc089dc5 --- /dev/null +++ b/Lang/LOLCODE/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Langtons-ant b/Lang/LOLCODE/Langtons-ant new file mode 120000 index 0000000000..37d74720e9 --- /dev/null +++ b/Lang/LOLCODE/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/LOLCODE \ No newline at end of file diff --git a/Lang/LOLCODE/Loops-While b/Lang/LOLCODE/Loops-While new file mode 120000 index 0000000000..fff358dd60 --- /dev/null +++ b/Lang/LOLCODE/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/LOLCODE \ No newline at end of file diff --git a/Lang/LSE64/0DESCRIPTION b/Lang/LSE64/0DESCRIPTION new file mode 100644 index 0000000000..f01d0dcb4c --- /dev/null +++ b/Lang/LSE64/0DESCRIPTION @@ -0,0 +1 @@ +{{language|LSE64}}LSE64 is a simple, easy to use environment for laboratory data acquisition, based on Bob Goeke's LSE, a stripped-down [[Forth]] dialect inspired by Jon Sachs' STOIC. It lacks the miserable complexities of Standard Forth. Download a GNU tar file of the software [http://www.noqsi.com/images/lse64-0.3.zip here]. \ No newline at end of file diff --git a/Lang/LSE64/Arithmetic-Integer b/Lang/LSE64/Arithmetic-Integer new file mode 120000 index 0000000000..48fb199252 --- /dev/null +++ b/Lang/LSE64/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Arrays b/Lang/LSE64/Arrays new file mode 120000 index 0000000000..b7d41d57bc --- /dev/null +++ b/Lang/LSE64/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Bitwise-operations b/Lang/LSE64/Bitwise-operations new file mode 120000 index 0000000000..01ca3376bb --- /dev/null +++ b/Lang/LSE64/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Command-line-arguments b/Lang/LSE64/Command-line-arguments new file mode 120000 index 0000000000..83ebe821d0 --- /dev/null +++ b/Lang/LSE64/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Comments b/Lang/LSE64/Comments new file mode 120000 index 0000000000..8d45bf120c --- /dev/null +++ b/Lang/LSE64/Comments @@ -0,0 +1 @@ +../../Task/Comments/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Conditional-structures b/Lang/LSE64/Conditional-structures new file mode 120000 index 0000000000..1f56b2f583 --- /dev/null +++ b/Lang/LSE64/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Function-definition b/Lang/LSE64/Function-definition new file mode 120000 index 0000000000..7e8b6cf6de --- /dev/null +++ b/Lang/LSE64/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Hello-world-Text b/Lang/LSE64/Hello-world-Text new file mode 120000 index 0000000000..efe0801c07 --- /dev/null +++ b/Lang/LSE64/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/LSE64 \ No newline at end of file diff --git a/Lang/LSE64/Integer-comparison b/Lang/LSE64/Integer-comparison new file mode 120000 index 0000000000..c3fa3a6480 --- /dev/null +++ b/Lang/LSE64/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/LSE64 \ No newline at end of file diff --git a/Lang/LSL/0DESCRIPTION b/Lang/LSL/0DESCRIPTION new file mode 100644 index 0000000000..2bb0296008 --- /dev/null +++ b/Lang/LSL/0DESCRIPTION @@ -0,0 +1,22 @@ +{{language}}The [[wp:Linden_Scripting_Language|'''Linden Scripting Language''']], usually just called '''LSL''' for short, is a language developed by [http://en.wikipedia.org/wiki/Linden_Lab Linden Labs] for their [[wp:Second_Life|Second Life]] virtual world. LSL allows Second Life objects to sense, respond to events, and interact with the (virtual) world around them, and the Avatars in that world. + +==Flavors of LSL== +There are currently three flavors of the LSL language +# LSL compiled under [[wp:Mono_(software)|Mono]] (the most recent) +# The original interpreted version (no longer being developed and only exists for backward compatibility) +# A largely compatible version of LSL that can run in the [[wp:OpenSimulator|OpenSimulator]] virtual world. + +==Documentation== +There are two popular web sites documenting LSL +# Second Life's own [http://wiki.secondlife.com/wiki/LSL_Portal LSL Portal] +# a user supported [http://lslwiki.net/lslwiki/wakka.php LSL Wiki] + +==Libraries== +There exists several open source libraries where users share code +* [http://community.secondlife.com/t5/LSL-Scripting-Library/bd-p/LSLScriptingLibrary LSL Scripting Library] +* [http://wiki.secondlife.com/wiki/Category:LSL_Examples LSL Examples] +* [http://www.free-lsl-scripts.com/cgi/freescripts.plx Free LSL Scripts] +* [http://community.secondlife.com/t5/LSL-Scripting/bd-p/LSLScripting LSL Scripting] + +==External Editors== +There are also many [http://wiki.secondlife.com/wiki/LSL_Alternate_Editors external editors] for LSL allowing you to write, syntax check, and (to a limited extent) execute LSL outside of the Second Life environment. You will need to sign up at [http://secondlife.com Second Life] and have a Second Life account to execute LSL in the virtual world. Your scripts can exist by themselves in a folder of your inventory, or in an Object in your inventory, but need to be in an Object that is in-world to execute (if an Object containing scripts is taken in to your inventory, the scripts will be suspended and will resume when brought out in to the world again.) \ No newline at end of file diff --git a/Lang/LSL/Arrays b/Lang/LSL/Arrays new file mode 120000 index 0000000000..b83607d01c --- /dev/null +++ b/Lang/LSL/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/LSL \ No newline at end of file diff --git a/Lang/LSL/Averages-Arithmetic-mean b/Lang/LSL/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b64794bc20 --- /dev/null +++ b/Lang/LSL/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/LSL \ No newline at end of file diff --git a/Lang/LSL/Averages-Median b/Lang/LSL/Averages-Median new file mode 120000 index 0000000000..c8e1573f4a --- /dev/null +++ b/Lang/LSL/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/LSL \ No newline at end of file diff --git a/Lang/LSL/Death-Star b/Lang/LSL/Death-Star new file mode 120000 index 0000000000..fea962a841 --- /dev/null +++ b/Lang/LSL/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/LSL \ No newline at end of file diff --git a/Lang/LSL/Draw-a-cuboid b/Lang/LSL/Draw-a-cuboid new file mode 120000 index 0000000000..992d64cd8f --- /dev/null +++ b/Lang/LSL/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/LSL \ No newline at end of file diff --git a/Lang/LSL/Fibonacci-sequence b/Lang/LSL/Fibonacci-sequence new file mode 120000 index 0000000000..402c7ed39b --- /dev/null +++ b/Lang/LSL/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/LSL \ No newline at end of file diff --git a/Lang/LSL/Find-limit-of-recursion b/Lang/LSL/Find-limit-of-recursion new file mode 120000 index 0000000000..73ae0b69b0 --- /dev/null +++ b/Lang/LSL/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/LSL \ No newline at end of file diff --git a/Lang/LSL/HTTP b/Lang/LSL/HTTP new file mode 120000 index 0000000000..bf81b69d69 --- /dev/null +++ b/Lang/LSL/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/LSL \ No newline at end of file diff --git a/Lang/LSL/HTTPS b/Lang/LSL/HTTPS new file mode 120000 index 0000000000..f8ddca7e29 --- /dev/null +++ b/Lang/LSL/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/LSL \ No newline at end of file diff --git a/Lang/LSL/Identity-matrix b/Lang/LSL/Identity-matrix new file mode 120000 index 0000000000..ff7f9d9d01 --- /dev/null +++ b/Lang/LSL/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/LSL \ No newline at end of file diff --git a/Lang/LSL/Increment-a-numerical-string b/Lang/LSL/Increment-a-numerical-string new file mode 120000 index 0000000000..800a1cbabc --- /dev/null +++ b/Lang/LSL/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/LSL \ No newline at end of file diff --git a/Lang/LSL/Input-loop b/Lang/LSL/Input-loop new file mode 120000 index 0000000000..abb983cea0 --- /dev/null +++ b/Lang/LSL/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/LSL \ No newline at end of file diff --git a/Lang/LSL/Knapsack-problem-0-1 b/Lang/LSL/Knapsack-problem-0-1 new file mode 120000 index 0000000000..76ee95ae2f --- /dev/null +++ b/Lang/LSL/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/LSL \ No newline at end of file diff --git a/Lang/LSL/Monte-Carlo-methods b/Lang/LSL/Monte-Carlo-methods new file mode 120000 index 0000000000..5794e05d99 --- /dev/null +++ b/Lang/LSL/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/LSL \ No newline at end of file diff --git a/Lang/LSL/Mutual-recursion b/Lang/LSL/Mutual-recursion new file mode 120000 index 0000000000..ab27872194 --- /dev/null +++ b/Lang/LSL/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/LSL \ No newline at end of file diff --git a/Lang/LaTeX/Increment-a-numerical-string b/Lang/LaTeX/Increment-a-numerical-string new file mode 120000 index 0000000000..35598f04ef --- /dev/null +++ b/Lang/LaTeX/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/LaTeX \ No newline at end of file diff --git a/Lang/LaTeX/Literals-String b/Lang/LaTeX/Literals-String new file mode 120000 index 0000000000..f9d7a52669 --- /dev/null +++ b/Lang/LaTeX/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/LaTeX \ No newline at end of file diff --git a/Lang/LabVIEW/0DESCRIPTION b/Lang/LabVIEW/0DESCRIPTION new file mode 100644 index 0000000000..3f26cc9159 --- /dev/null +++ b/Lang/LabVIEW/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language +|site=http://www.ni.com/labview/}}LabVIEW is a proprietary graphical programming language produced by National Instruments that is used mainly for data acquisition, instrument control, test automation and industrial control. +The basic building block of a LabVIEW application is a VI(virtual instrument), which consists of a front panel, where you design a user interface, and a block diagram, where you create graphical code. + +==See also== +* [[wp:Labview|Wikipedia article]] \ No newline at end of file diff --git a/Lang/Lang5/0DESCRIPTION b/Lang/Lang5/0DESCRIPTION new file mode 100644 index 0000000000..15366ffe07 --- /dev/null +++ b/Lang/Lang5/0DESCRIPTION @@ -0,0 +1,21 @@ +{{language|lang5 +|exec=interpreted +|site=http://lang5.sf.net +|strength=strong +|safety=safe +|checking=dynamic +|tags=lang5 +}} +{{language programming paradigm|Dynamic}} +{{language programming paradigm|functional}} +{{language programming paradigm|Tacit}} +{{language programming paradigm|Array}} +{{language programming paradigm|Concatenative}} + +== lang5 language == + +Lang5 is a stack based array language with roots in [[APL]] and [[Forth]]. + +== Documents == + +A [http://archive.vector.org.uk/art10500710 paper] about lang5 in Vector the journal of the British APL Association. \ No newline at end of file diff --git a/Lang/Lang5/A+B b/Lang/Lang5/A+B new file mode 120000 index 0000000000..794732cdf9 --- /dev/null +++ b/Lang/Lang5/A+B @@ -0,0 +1 @@ +../../Task/A+B/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Apply-a-callback-to-an-array b/Lang/Lang5/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..a4fb4b89e7 --- /dev/null +++ b/Lang/Lang5/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Array-concatenation b/Lang/Lang5/Array-concatenation new file mode 120000 index 0000000000..2df5d0b3fe --- /dev/null +++ b/Lang/Lang5/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Associative-array-Creation b/Lang/Lang5/Associative-array-Creation new file mode 120000 index 0000000000..683cd5afd8 --- /dev/null +++ b/Lang/Lang5/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Associative-array-Iteration b/Lang/Lang5/Associative-array-Iteration new file mode 120000 index 0000000000..2992c152d8 --- /dev/null +++ b/Lang/Lang5/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Character-codes b/Lang/Lang5/Character-codes new file mode 120000 index 0000000000..5cce8b7a19 --- /dev/null +++ b/Lang/Lang5/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Character-matching b/Lang/Lang5/Character-matching new file mode 120000 index 0000000000..3afce4254a --- /dev/null +++ b/Lang/Lang5/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Comments b/Lang/Lang5/Comments new file mode 120000 index 0000000000..eba0b2f3b0 --- /dev/null +++ b/Lang/Lang5/Comments @@ -0,0 +1 @@ +../../Task/Comments/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Count-in-octal b/Lang/Lang5/Count-in-octal new file mode 120000 index 0000000000..7e34661057 --- /dev/null +++ b/Lang/Lang5/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Empty-program b/Lang/Lang5/Empty-program new file mode 120000 index 0000000000..69497b033c --- /dev/null +++ b/Lang/Lang5/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Entropy b/Lang/Lang5/Entropy new file mode 120000 index 0000000000..1ef92abc23 --- /dev/null +++ b/Lang/Lang5/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Even-or-odd b/Lang/Lang5/Even-or-odd new file mode 120000 index 0000000000..ca3aa20ac6 --- /dev/null +++ b/Lang/Lang5/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Execute-a-system-command b/Lang/Lang5/Execute-a-system-command new file mode 120000 index 0000000000..ecbb3db11c --- /dev/null +++ b/Lang/Lang5/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Factorial b/Lang/Lang5/Factorial new file mode 120000 index 0000000000..648ca2cac1 --- /dev/null +++ b/Lang/Lang5/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Fibonacci-sequence b/Lang/Lang5/Fibonacci-sequence new file mode 120000 index 0000000000..0931c2f0fc --- /dev/null +++ b/Lang/Lang5/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/File-IO b/Lang/Lang5/File-IO new file mode 120000 index 0000000000..160dec5803 --- /dev/null +++ b/Lang/Lang5/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Filter b/Lang/Lang5/Filter new file mode 120000 index 0000000000..b4b6c10a51 --- /dev/null +++ b/Lang/Lang5/Filter @@ -0,0 +1 @@ +../../Task/Filter/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Generic-swap b/Lang/Lang5/Generic-swap new file mode 120000 index 0000000000..e1fb231c12 --- /dev/null +++ b/Lang/Lang5/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Hash-from-two-arrays b/Lang/Lang5/Hash-from-two-arrays new file mode 120000 index 0000000000..26d29e3444 --- /dev/null +++ b/Lang/Lang5/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Hello-world-Text b/Lang/Lang5/Hello-world-Text new file mode 120000 index 0000000000..73856a75a8 --- /dev/null +++ b/Lang/Lang5/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Identity-matrix b/Lang/Lang5/Identity-matrix new file mode 120000 index 0000000000..5959e037e1 --- /dev/null +++ b/Lang/Lang5/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Input-loop b/Lang/Lang5/Input-loop new file mode 120000 index 0000000000..1f1715e751 --- /dev/null +++ b/Lang/Lang5/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Integer-sequence b/Lang/Lang5/Integer-sequence new file mode 120000 index 0000000000..743ac2c7a9 --- /dev/null +++ b/Lang/Lang5/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-Break b/Lang/Lang5/Loops-Break new file mode 120000 index 0000000000..f43085922b --- /dev/null +++ b/Lang/Lang5/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-For b/Lang/Lang5/Loops-For new file mode 120000 index 0000000000..42a57e2f55 --- /dev/null +++ b/Lang/Lang5/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-For-with-a-specified-step b/Lang/Lang5/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..e7556f07ff --- /dev/null +++ b/Lang/Lang5/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-Foreach b/Lang/Lang5/Loops-Foreach new file mode 120000 index 0000000000..0218d39f29 --- /dev/null +++ b/Lang/Lang5/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-Infinite b/Lang/Lang5/Loops-Infinite new file mode 120000 index 0000000000..d5f0f1ac34 --- /dev/null +++ b/Lang/Lang5/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-N-plus-one-half b/Lang/Lang5/Loops-N-plus-one-half new file mode 120000 index 0000000000..a42051f147 --- /dev/null +++ b/Lang/Lang5/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Loops-While b/Lang/Lang5/Loops-While new file mode 120000 index 0000000000..fd59bbf801 --- /dev/null +++ b/Lang/Lang5/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Matrix-multiplication b/Lang/Lang5/Matrix-multiplication new file mode 120000 index 0000000000..59f4fbb767 --- /dev/null +++ b/Lang/Lang5/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Matrix-transposition b/Lang/Lang5/Matrix-transposition new file mode 120000 index 0000000000..02df2da71e --- /dev/null +++ b/Lang/Lang5/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Ordered-words b/Lang/Lang5/Ordered-words new file mode 120000 index 0000000000..82ab0fe269 --- /dev/null +++ b/Lang/Lang5/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Search-a-list b/Lang/Lang5/Search-a-list new file mode 120000 index 0000000000..7ce1d5d81f --- /dev/null +++ b/Lang/Lang5/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Lang5 \ No newline at end of file diff --git a/Lang/Lhogho/0DESCRIPTION b/Lang/Lhogho/0DESCRIPTION new file mode 100644 index 0000000000..1c5184a044 --- /dev/null +++ b/Lang/Lhogho/0DESCRIPTION @@ -0,0 +1,13 @@ +{{language|Lhogho +|strength=strong +|safety=safe +|express=implicit +|compat=structural +|checking=dynamic +|gc=yes +|LCT=yes}} +Lhogho is one of the hundreds implementations of the Logo language. However, unlike most other Logos, Lhogho is a compiler. + +We wanted a name which sounds like Logo, but is written in a way which noone else has ever seen before. We did search "Lhogho" in the major search machines (back in 2005) and we got 0 hits. + +Lhogho is developed by an independent team. The team leader is Assoc. Prof. Pavel Boytchev, PhD, Sofia University, Bulgaria. As an open source project we expect that other professionals will join us. \ No newline at end of file diff --git a/Lang/Lhogho/100-doors b/Lang/Lhogho/100-doors new file mode 120000 index 0000000000..fc27d65d36 --- /dev/null +++ b/Lang/Lhogho/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Lhogho \ No newline at end of file diff --git a/Lang/Lhogho/Empty-string b/Lang/Lhogho/Empty-string new file mode 120000 index 0000000000..30445eb07c --- /dev/null +++ b/Lang/Lhogho/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Lhogho \ No newline at end of file diff --git a/Lang/Lhogho/Generic-swap b/Lang/Lhogho/Generic-swap new file mode 120000 index 0000000000..6907d1239e --- /dev/null +++ b/Lang/Lhogho/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Lhogho \ No newline at end of file diff --git a/Lang/Liberty-BASIC/0DESCRIPTION b/Lang/Liberty-BASIC/0DESCRIPTION new file mode 100644 index 0000000000..c91b1c5b3e --- /dev/null +++ b/Lang/Liberty-BASIC/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|Liberty_basic +|exec=interpreted +|site=http://www.libertybasic.com +|parampass=both +|tags=lb}} +{{language programming paradigm|procedural}} +{{implementation|BASIC}} +Liberty BASIC is a procedural programming language for [[Windows]] PCs, created by Shoptalk Systems. It was intended as a simple way to create professional programs, with full [[GUI]] ability, while still keeping a very simple [[BASIC]] syntax. While the current version only supports Windows, the next major release will support [[Mac OS X]] and [[Linux]] as well. Liberty BASIC runs under Wine on Linux at present. + +All tasks on this page are completed by the wonderful [http://libertybasic.conforums.com Liberty BASIC Community], at the [http://libertybasic.conforums.com/index.cgi?board=open&action=display&num=1278868236 Liberty BASIC Rosetta Code Project] \ No newline at end of file diff --git a/Lang/Liberty-BASIC/100-doors b/Lang/Liberty-BASIC/100-doors new file mode 120000 index 0000000000..764ac190bb --- /dev/null +++ b/Lang/Liberty-BASIC/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/24-game b/Lang/Liberty-BASIC/24-game new file mode 120000 index 0000000000..ffe12ea8ff --- /dev/null +++ b/Lang/Liberty-BASIC/24-game @@ -0,0 +1 @@ +../../Task/24-game/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/24-game-Solve b/Lang/Liberty-BASIC/24-game-Solve new file mode 120000 index 0000000000..c949e95480 --- /dev/null +++ b/Lang/Liberty-BASIC/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/99-Bottles-of-Beer b/Lang/Liberty-BASIC/99-Bottles-of-Beer new file mode 120000 index 0000000000..f6b7c0c518 --- /dev/null +++ b/Lang/Liberty-BASIC/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/A+B b/Lang/Liberty-BASIC/A+B new file mode 120000 index 0000000000..c921701f1e --- /dev/null +++ b/Lang/Liberty-BASIC/A+B @@ -0,0 +1 @@ +../../Task/A+B/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Ackermann-function b/Lang/Liberty-BASIC/Ackermann-function new file mode 120000 index 0000000000..a786639abc --- /dev/null +++ b/Lang/Liberty-BASIC/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Align-columns b/Lang/Liberty-BASIC/Align-columns new file mode 120000 index 0000000000..2837e342a6 --- /dev/null +++ b/Lang/Liberty-BASIC/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Anagrams b/Lang/Liberty-BASIC/Anagrams new file mode 120000 index 0000000000..d4b3070fe9 --- /dev/null +++ b/Lang/Liberty-BASIC/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Anagrams-Deranged-anagrams b/Lang/Liberty-BASIC/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..81531a5454 --- /dev/null +++ b/Lang/Liberty-BASIC/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Animate-a-pendulum b/Lang/Liberty-BASIC/Animate-a-pendulum new file mode 120000 index 0000000000..11259291fa --- /dev/null +++ b/Lang/Liberty-BASIC/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Animation b/Lang/Liberty-BASIC/Animation new file mode 120000 index 0000000000..0c68dae2db --- /dev/null +++ b/Lang/Liberty-BASIC/Animation @@ -0,0 +1 @@ +../../Task/Animation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arbitrary-precision-integers-included b/Lang/Liberty-BASIC/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..9fbe0b1f05 --- /dev/null +++ b/Lang/Liberty-BASIC/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arithmetic-Complex b/Lang/Liberty-BASIC/Arithmetic-Complex new file mode 120000 index 0000000000..169125033e --- /dev/null +++ b/Lang/Liberty-BASIC/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arithmetic-Integer b/Lang/Liberty-BASIC/Arithmetic-Integer new file mode 120000 index 0000000000..c11af59522 --- /dev/null +++ b/Lang/Liberty-BASIC/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arithmetic-Rational b/Lang/Liberty-BASIC/Arithmetic-Rational new file mode 120000 index 0000000000..be579dc28f --- /dev/null +++ b/Lang/Liberty-BASIC/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arithmetic-geometric-mean b/Lang/Liberty-BASIC/Arithmetic-geometric-mean new file mode 120000 index 0000000000..edd317d86b --- /dev/null +++ b/Lang/Liberty-BASIC/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Array-concatenation b/Lang/Liberty-BASIC/Array-concatenation new file mode 120000 index 0000000000..cfee53e361 --- /dev/null +++ b/Lang/Liberty-BASIC/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arrays b/Lang/Liberty-BASIC/Arrays new file mode 120000 index 0000000000..6862dd2dcc --- /dev/null +++ b/Lang/Liberty-BASIC/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Associative-array-Creation b/Lang/Liberty-BASIC/Associative-array-Creation new file mode 120000 index 0000000000..7cff5d7c49 --- /dev/null +++ b/Lang/Liberty-BASIC/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Associative-array-Iteration b/Lang/Liberty-BASIC/Associative-array-Iteration new file mode 120000 index 0000000000..60fe75a995 --- /dev/null +++ b/Lang/Liberty-BASIC/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Arithmetic-mean b/Lang/Liberty-BASIC/Averages-Arithmetic-mean new file mode 120000 index 0000000000..2a2205daef --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Mean-angle b/Lang/Liberty-BASIC/Averages-Mean-angle new file mode 120000 index 0000000000..03e96d331b --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Median b/Lang/Liberty-BASIC/Averages-Median new file mode 120000 index 0000000000..d8e92d70b7 --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Pythagorean-means b/Lang/Liberty-BASIC/Averages-Pythagorean-means new file mode 120000 index 0000000000..c37754b709 --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Root-mean-square b/Lang/Liberty-BASIC/Averages-Root-mean-square new file mode 120000 index 0000000000..88f5eb0f2e --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Averages-Simple-moving-average b/Lang/Liberty-BASIC/Averages-Simple-moving-average new file mode 120000 index 0000000000..f40a5159cf --- /dev/null +++ b/Lang/Liberty-BASIC/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Balanced-brackets b/Lang/Liberty-BASIC/Balanced-brackets new file mode 120000 index 0000000000..fddc023ded --- /dev/null +++ b/Lang/Liberty-BASIC/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Best-shuffle b/Lang/Liberty-BASIC/Best-shuffle new file mode 120000 index 0000000000..1e52706d22 --- /dev/null +++ b/Lang/Liberty-BASIC/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Binary-search b/Lang/Liberty-BASIC/Binary-search new file mode 120000 index 0000000000..fd50635b3e --- /dev/null +++ b/Lang/Liberty-BASIC/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Binary-strings b/Lang/Liberty-BASIC/Binary-strings new file mode 120000 index 0000000000..d5a299a551 --- /dev/null +++ b/Lang/Liberty-BASIC/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Bitmap-Flood-fill b/Lang/Liberty-BASIC/Bitmap-Flood-fill new file mode 120000 index 0000000000..4b8311e655 --- /dev/null +++ b/Lang/Liberty-BASIC/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Bitwise-operations b/Lang/Liberty-BASIC/Bitwise-operations new file mode 120000 index 0000000000..ff30a66fd4 --- /dev/null +++ b/Lang/Liberty-BASIC/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Box-the-compass b/Lang/Liberty-BASIC/Box-the-compass new file mode 120000 index 0000000000..38aee1ea04 --- /dev/null +++ b/Lang/Liberty-BASIC/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Bulls-and-cows b/Lang/Liberty-BASIC/Bulls-and-cows new file mode 120000 index 0000000000..b9a137da2d --- /dev/null +++ b/Lang/Liberty-BASIC/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Bulls-and-cows-Player b/Lang/Liberty-BASIC/Bulls-and-cows-Player new file mode 120000 index 0000000000..0bfbdb3c71 --- /dev/null +++ b/Lang/Liberty-BASIC/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/CSV-to-HTML-translation b/Lang/Liberty-BASIC/CSV-to-HTML-translation new file mode 120000 index 0000000000..94a9091196 --- /dev/null +++ b/Lang/Liberty-BASIC/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Caesar-cipher b/Lang/Liberty-BASIC/Caesar-cipher new file mode 120000 index 0000000000..1a4bd8fd90 --- /dev/null +++ b/Lang/Liberty-BASIC/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Case-sensitivity-of-identifiers b/Lang/Liberty-BASIC/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..9fc5aff3c2 --- /dev/null +++ b/Lang/Liberty-BASIC/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Character-codes b/Lang/Liberty-BASIC/Character-codes new file mode 120000 index 0000000000..1b2b8bb981 --- /dev/null +++ b/Lang/Liberty-BASIC/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Character-matching b/Lang/Liberty-BASIC/Character-matching new file mode 120000 index 0000000000..befb5ee97f --- /dev/null +++ b/Lang/Liberty-BASIC/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Check-that-file-exists b/Lang/Liberty-BASIC/Check-that-file-exists new file mode 120000 index 0000000000..e7388ac76a --- /dev/null +++ b/Lang/Liberty-BASIC/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Closest-pair-problem b/Lang/Liberty-BASIC/Closest-pair-problem new file mode 120000 index 0000000000..31750edd10 --- /dev/null +++ b/Lang/Liberty-BASIC/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Color-of-a-screen-pixel b/Lang/Liberty-BASIC/Color-of-a-screen-pixel new file mode 120000 index 0000000000..3d0fb2dd28 --- /dev/null +++ b/Lang/Liberty-BASIC/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Colour-bars-Display b/Lang/Liberty-BASIC/Colour-bars-Display new file mode 120000 index 0000000000..7edc974d47 --- /dev/null +++ b/Lang/Liberty-BASIC/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Command-line-arguments b/Lang/Liberty-BASIC/Command-line-arguments new file mode 120000 index 0000000000..1e13ed5ec2 --- /dev/null +++ b/Lang/Liberty-BASIC/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Comments b/Lang/Liberty-BASIC/Comments new file mode 120000 index 0000000000..b5c3ab8a0d --- /dev/null +++ b/Lang/Liberty-BASIC/Comments @@ -0,0 +1 @@ +../../Task/Comments/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Constrained-random-points-on-a-circle b/Lang/Liberty-BASIC/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..7610fafc80 --- /dev/null +++ b/Lang/Liberty-BASIC/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Conways-Game-of-Life b/Lang/Liberty-BASIC/Conways-Game-of-Life new file mode 120000 index 0000000000..32522deed2 --- /dev/null +++ b/Lang/Liberty-BASIC/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Count-in-factors b/Lang/Liberty-BASIC/Count-in-factors new file mode 120000 index 0000000000..ffee7357de --- /dev/null +++ b/Lang/Liberty-BASIC/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Count-in-octal b/Lang/Liberty-BASIC/Count-in-octal new file mode 120000 index 0000000000..4b5a06d89c --- /dev/null +++ b/Lang/Liberty-BASIC/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Count-occurrences-of-a-substring b/Lang/Liberty-BASIC/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..a82a11dbed --- /dev/null +++ b/Lang/Liberty-BASIC/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Create-a-file b/Lang/Liberty-BASIC/Create-a-file new file mode 120000 index 0000000000..9c96cf4b22 --- /dev/null +++ b/Lang/Liberty-BASIC/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Create-a-two-dimensional-array-at-runtime b/Lang/Liberty-BASIC/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..2722188861 --- /dev/null +++ b/Lang/Liberty-BASIC/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Create-an-HTML-table b/Lang/Liberty-BASIC/Create-an-HTML-table new file mode 120000 index 0000000000..b181155fd1 --- /dev/null +++ b/Lang/Liberty-BASIC/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Date-format b/Lang/Liberty-BASIC/Date-format new file mode 120000 index 0000000000..98bd4b4af5 --- /dev/null +++ b/Lang/Liberty-BASIC/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Day-of-the-week b/Lang/Liberty-BASIC/Day-of-the-week new file mode 120000 index 0000000000..5736548b82 --- /dev/null +++ b/Lang/Liberty-BASIC/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Delete-a-file b/Lang/Liberty-BASIC/Delete-a-file new file mode 120000 index 0000000000..603552768c --- /dev/null +++ b/Lang/Liberty-BASIC/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Detect-division-by-zero b/Lang/Liberty-BASIC/Detect-division-by-zero new file mode 120000 index 0000000000..2ea9f120df --- /dev/null +++ b/Lang/Liberty-BASIC/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Determine-if-a-string-is-numeric b/Lang/Liberty-BASIC/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..b0280c3e63 --- /dev/null +++ b/Lang/Liberty-BASIC/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Determine-if-only-one-instance-is-running b/Lang/Liberty-BASIC/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..9438c87cc9 --- /dev/null +++ b/Lang/Liberty-BASIC/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Dot-product b/Lang/Liberty-BASIC/Dot-product new file mode 120000 index 0000000000..0db371b585 --- /dev/null +++ b/Lang/Liberty-BASIC/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Doubly-linked-list-Traversal b/Lang/Liberty-BASIC/Doubly-linked-list-Traversal new file mode 120000 index 0000000000..dcb915e009 --- /dev/null +++ b/Lang/Liberty-BASIC/Doubly-linked-list-Traversal @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Traversal/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Draw-a-sphere b/Lang/Liberty-BASIC/Draw-a-sphere new file mode 120000 index 0000000000..a68e88e8e3 --- /dev/null +++ b/Lang/Liberty-BASIC/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Empty-directory b/Lang/Liberty-BASIC/Empty-directory new file mode 120000 index 0000000000..78eeb29c6e --- /dev/null +++ b/Lang/Liberty-BASIC/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Empty-program b/Lang/Liberty-BASIC/Empty-program new file mode 120000 index 0000000000..08b6695a71 --- /dev/null +++ b/Lang/Liberty-BASIC/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Empty-string b/Lang/Liberty-BASIC/Empty-string new file mode 120000 index 0000000000..820d99fd70 --- /dev/null +++ b/Lang/Liberty-BASIC/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Equilibrium-index b/Lang/Liberty-BASIC/Equilibrium-index new file mode 120000 index 0000000000..65095eb99c --- /dev/null +++ b/Lang/Liberty-BASIC/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Ethiopian-multiplication b/Lang/Liberty-BASIC/Ethiopian-multiplication new file mode 120000 index 0000000000..b75f5ee193 --- /dev/null +++ b/Lang/Liberty-BASIC/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Evaluate-binomial-coefficients b/Lang/Liberty-BASIC/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..f303552273 --- /dev/null +++ b/Lang/Liberty-BASIC/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Even-or-odd b/Lang/Liberty-BASIC/Even-or-odd new file mode 120000 index 0000000000..d8b5c42073 --- /dev/null +++ b/Lang/Liberty-BASIC/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Evolutionary-algorithm b/Lang/Liberty-BASIC/Evolutionary-algorithm new file mode 120000 index 0000000000..7f06d0f3cf --- /dev/null +++ b/Lang/Liberty-BASIC/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Execute-HQ9+ b/Lang/Liberty-BASIC/Execute-HQ9+ new file mode 120000 index 0000000000..eb7c322181 --- /dev/null +++ b/Lang/Liberty-BASIC/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Execute-a-system-command b/Lang/Liberty-BASIC/Execute-a-system-command new file mode 120000 index 0000000000..14a5c63c54 --- /dev/null +++ b/Lang/Liberty-BASIC/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Exponentiation-operator b/Lang/Liberty-BASIC/Exponentiation-operator new file mode 120000 index 0000000000..e9bcefecd9 --- /dev/null +++ b/Lang/Liberty-BASIC/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Factorial b/Lang/Liberty-BASIC/Factorial new file mode 120000 index 0000000000..346056711e --- /dev/null +++ b/Lang/Liberty-BASIC/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Factors-of-an-integer b/Lang/Liberty-BASIC/Factors-of-an-integer new file mode 120000 index 0000000000..15152af482 --- /dev/null +++ b/Lang/Liberty-BASIC/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Fast-Fourier-transform b/Lang/Liberty-BASIC/Fast-Fourier-transform new file mode 120000 index 0000000000..27e4fb3c94 --- /dev/null +++ b/Lang/Liberty-BASIC/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Fibonacci-sequence b/Lang/Liberty-BASIC/Fibonacci-sequence new file mode 120000 index 0000000000..7d0aa37c04 --- /dev/null +++ b/Lang/Liberty-BASIC/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/File-IO b/Lang/Liberty-BASIC/File-IO new file mode 120000 index 0000000000..6ecdf5c8df --- /dev/null +++ b/Lang/Liberty-BASIC/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/File-size b/Lang/Liberty-BASIC/File-size new file mode 120000 index 0000000000..4f1a23f2c1 --- /dev/null +++ b/Lang/Liberty-BASIC/File-size @@ -0,0 +1 @@ +../../Task/File-size/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Filter b/Lang/Liberty-BASIC/Filter new file mode 120000 index 0000000000..183ba44530 --- /dev/null +++ b/Lang/Liberty-BASIC/Filter @@ -0,0 +1 @@ +../../Task/Filter/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Find-common-directory-path b/Lang/Liberty-BASIC/Find-common-directory-path new file mode 120000 index 0000000000..c07e43540f --- /dev/null +++ b/Lang/Liberty-BASIC/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Find-limit-of-recursion b/Lang/Liberty-BASIC/Find-limit-of-recursion new file mode 120000 index 0000000000..f99f5737d3 --- /dev/null +++ b/Lang/Liberty-BASIC/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/FizzBuzz b/Lang/Liberty-BASIC/FizzBuzz new file mode 120000 index 0000000000..faba02a746 --- /dev/null +++ b/Lang/Liberty-BASIC/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Floyds-triangle b/Lang/Liberty-BASIC/Floyds-triangle new file mode 120000 index 0000000000..ab761ecf5a --- /dev/null +++ b/Lang/Liberty-BASIC/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Forest-fire b/Lang/Liberty-BASIC/Forest-fire new file mode 120000 index 0000000000..e001ce5626 --- /dev/null +++ b/Lang/Liberty-BASIC/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Formatted-numeric-output b/Lang/Liberty-BASIC/Formatted-numeric-output new file mode 120000 index 0000000000..2411117ed5 --- /dev/null +++ b/Lang/Liberty-BASIC/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Fractal-tree b/Lang/Liberty-BASIC/Fractal-tree new file mode 120000 index 0000000000..c9e8df4054 --- /dev/null +++ b/Lang/Liberty-BASIC/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Function-definition b/Lang/Liberty-BASIC/Function-definition new file mode 120000 index 0000000000..38d59597ac --- /dev/null +++ b/Lang/Liberty-BASIC/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/GUI-component-interaction b/Lang/Liberty-BASIC/GUI-component-interaction new file mode 120000 index 0000000000..7af606566d --- /dev/null +++ b/Lang/Liberty-BASIC/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/GUI-enabling-disabling-of-controls b/Lang/Liberty-BASIC/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..462456939a --- /dev/null +++ b/Lang/Liberty-BASIC/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Globally-replace-text-in-several-files b/Lang/Liberty-BASIC/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..3bcf9226e3 --- /dev/null +++ b/Lang/Liberty-BASIC/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Gray-code b/Lang/Liberty-BASIC/Gray-code new file mode 120000 index 0000000000..b81e4a4c99 --- /dev/null +++ b/Lang/Liberty-BASIC/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Greatest-common-divisor b/Lang/Liberty-BASIC/Greatest-common-divisor new file mode 120000 index 0000000000..4fce3f1371 --- /dev/null +++ b/Lang/Liberty-BASIC/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Greatest-element-of-a-list b/Lang/Liberty-BASIC/Greatest-element-of-a-list new file mode 120000 index 0000000000..e6668e0f55 --- /dev/null +++ b/Lang/Liberty-BASIC/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Greatest-subsequential-sum b/Lang/Liberty-BASIC/Greatest-subsequential-sum new file mode 120000 index 0000000000..d2c3520699 --- /dev/null +++ b/Lang/Liberty-BASIC/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Greyscale-bars-Display b/Lang/Liberty-BASIC/Greyscale-bars-Display new file mode 120000 index 0000000000..9ee5c9eb61 --- /dev/null +++ b/Lang/Liberty-BASIC/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Guess-the-number b/Lang/Liberty-BASIC/Guess-the-number new file mode 120000 index 0000000000..5956d0b95e --- /dev/null +++ b/Lang/Liberty-BASIC/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Guess-the-number-With-feedback b/Lang/Liberty-BASIC/Guess-the-number-With-feedback new file mode 120000 index 0000000000..e22dabb79e --- /dev/null +++ b/Lang/Liberty-BASIC/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player b/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..4470f16418 --- /dev/null +++ b/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/HTTP b/Lang/Liberty-BASIC/HTTP new file mode 120000 index 0000000000..e5a0c3c6f3 --- /dev/null +++ b/Lang/Liberty-BASIC/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hailstone-sequence b/Lang/Liberty-BASIC/Hailstone-sequence new file mode 120000 index 0000000000..e510bfe068 --- /dev/null +++ b/Lang/Liberty-BASIC/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hamming-numbers b/Lang/Liberty-BASIC/Hamming-numbers new file mode 120000 index 0000000000..a9bbf415bb --- /dev/null +++ b/Lang/Liberty-BASIC/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Handle-a-signal b/Lang/Liberty-BASIC/Handle-a-signal new file mode 120000 index 0000000000..994811ba8f --- /dev/null +++ b/Lang/Liberty-BASIC/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Happy-numbers b/Lang/Liberty-BASIC/Happy-numbers new file mode 120000 index 0000000000..b7ffc6c574 --- /dev/null +++ b/Lang/Liberty-BASIC/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Haversine-formula b/Lang/Liberty-BASIC/Haversine-formula new file mode 120000 index 0000000000..f7f9670a06 --- /dev/null +++ b/Lang/Liberty-BASIC/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hello-world-Graphical b/Lang/Liberty-BASIC/Hello-world-Graphical new file mode 120000 index 0000000000..a7a0e1e7e8 --- /dev/null +++ b/Lang/Liberty-BASIC/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hello-world-Newline-omission b/Lang/Liberty-BASIC/Hello-world-Newline-omission new file mode 120000 index 0000000000..1257d37605 --- /dev/null +++ b/Lang/Liberty-BASIC/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hello-world-Text b/Lang/Liberty-BASIC/Hello-world-Text new file mode 120000 index 0000000000..7aba2f9d48 --- /dev/null +++ b/Lang/Liberty-BASIC/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hello-world-Web-server b/Lang/Liberty-BASIC/Hello-world-Web-server new file mode 120000 index 0000000000..a4a0d6aea1 --- /dev/null +++ b/Lang/Liberty-BASIC/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Horizontal-sundial-calculations b/Lang/Liberty-BASIC/Horizontal-sundial-calculations new file mode 120000 index 0000000000..37d493ee0b --- /dev/null +++ b/Lang/Liberty-BASIC/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Horners-rule-for-polynomial-evaluation b/Lang/Liberty-BASIC/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..bc2e005976 --- /dev/null +++ b/Lang/Liberty-BASIC/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Hostname b/Lang/Liberty-BASIC/Hostname new file mode 120000 index 0000000000..e2ed0c4f98 --- /dev/null +++ b/Lang/Liberty-BASIC/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Image-convolution b/Lang/Liberty-BASIC/Image-convolution new file mode 120000 index 0000000000..3d5d66fa51 --- /dev/null +++ b/Lang/Liberty-BASIC/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Image-noise b/Lang/Liberty-BASIC/Image-noise new file mode 120000 index 0000000000..1fce412898 --- /dev/null +++ b/Lang/Liberty-BASIC/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Increment-a-numerical-string b/Lang/Liberty-BASIC/Increment-a-numerical-string new file mode 120000 index 0000000000..4f0ce7d321 --- /dev/null +++ b/Lang/Liberty-BASIC/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Input-loop b/Lang/Liberty-BASIC/Input-loop new file mode 120000 index 0000000000..51778332bd --- /dev/null +++ b/Lang/Liberty-BASIC/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Integer-comparison b/Lang/Liberty-BASIC/Integer-comparison new file mode 120000 index 0000000000..fbe8bf89b2 --- /dev/null +++ b/Lang/Liberty-BASIC/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Integer-sequence b/Lang/Liberty-BASIC/Integer-sequence new file mode 120000 index 0000000000..9ddb7e9bca --- /dev/null +++ b/Lang/Liberty-BASIC/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Joystick-position b/Lang/Liberty-BASIC/Joystick-position new file mode 120000 index 0000000000..1cbfc14621 --- /dev/null +++ b/Lang/Liberty-BASIC/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Kaprekar-numbers b/Lang/Liberty-BASIC/Kaprekar-numbers new file mode 120000 index 0000000000..a842be7240 --- /dev/null +++ b/Lang/Liberty-BASIC/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Liberty-BASIC/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..e8a50aa961 --- /dev/null +++ b/Lang/Liberty-BASIC/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Knuth-shuffle b/Lang/Liberty-BASIC/Knuth-shuffle new file mode 120000 index 0000000000..8a58771cd4 --- /dev/null +++ b/Lang/Liberty-BASIC/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Langtons-ant b/Lang/Liberty-BASIC/Langtons-ant new file mode 120000 index 0000000000..36a5e2715c --- /dev/null +++ b/Lang/Liberty-BASIC/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Leap-year b/Lang/Liberty-BASIC/Leap-year new file mode 120000 index 0000000000..f6ecde384e --- /dev/null +++ b/Lang/Liberty-BASIC/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Least-common-multiple b/Lang/Liberty-BASIC/Least-common-multiple new file mode 120000 index 0000000000..592716f634 --- /dev/null +++ b/Lang/Liberty-BASIC/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Letter-frequency b/Lang/Liberty-BASIC/Letter-frequency new file mode 120000 index 0000000000..d97f5450ba --- /dev/null +++ b/Lang/Liberty-BASIC/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Levenshtein-distance b/Lang/Liberty-BASIC/Levenshtein-distance new file mode 120000 index 0000000000..e2a96d7401 --- /dev/null +++ b/Lang/Liberty-BASIC/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Linear-congruential-generator b/Lang/Liberty-BASIC/Linear-congruential-generator new file mode 120000 index 0000000000..5d204c5cbe --- /dev/null +++ b/Lang/Liberty-BASIC/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Literals-String b/Lang/Liberty-BASIC/Literals-String new file mode 120000 index 0000000000..5a6aaeee55 --- /dev/null +++ b/Lang/Liberty-BASIC/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Logical-operations b/Lang/Liberty-BASIC/Logical-operations new file mode 120000 index 0000000000..740dd266fe --- /dev/null +++ b/Lang/Liberty-BASIC/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Long-multiplication b/Lang/Liberty-BASIC/Long-multiplication new file mode 120000 index 0000000000..8c0ac03e29 --- /dev/null +++ b/Lang/Liberty-BASIC/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Longest-common-subsequence b/Lang/Liberty-BASIC/Longest-common-subsequence new file mode 120000 index 0000000000..74fe15da36 --- /dev/null +++ b/Lang/Liberty-BASIC/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loop-over-multiple-arrays-simultaneously b/Lang/Liberty-BASIC/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..53580113a6 --- /dev/null +++ b/Lang/Liberty-BASIC/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Break b/Lang/Liberty-BASIC/Loops-Break new file mode 120000 index 0000000000..4268cfea68 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Continue b/Lang/Liberty-BASIC/Loops-Continue new file mode 120000 index 0000000000..290bbeca43 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Do-while b/Lang/Liberty-BASIC/Loops-Do-while new file mode 120000 index 0000000000..c3bd1c7f76 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Downward-for b/Lang/Liberty-BASIC/Loops-Downward-for new file mode 120000 index 0000000000..c5165a8630 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-For b/Lang/Liberty-BASIC/Loops-For new file mode 120000 index 0000000000..abe2a517a2 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-For-with-a-specified-step b/Lang/Liberty-BASIC/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..874acf87eb --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Foreach b/Lang/Liberty-BASIC/Loops-Foreach new file mode 120000 index 0000000000..3a170b605d --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Infinite b/Lang/Liberty-BASIC/Loops-Infinite new file mode 120000 index 0000000000..1f58845b72 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-N-plus-one-half b/Lang/Liberty-BASIC/Loops-N-plus-one-half new file mode 120000 index 0000000000..7dd0fe8ec6 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-Nested b/Lang/Liberty-BASIC/Loops-Nested new file mode 120000 index 0000000000..aa0c153dee --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Loops-While b/Lang/Liberty-BASIC/Loops-While new file mode 120000 index 0000000000..63419ac926 --- /dev/null +++ b/Lang/Liberty-BASIC/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Luhn-test-of-credit-card-numbers b/Lang/Liberty-BASIC/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..d061468ab5 --- /dev/null +++ b/Lang/Liberty-BASIC/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/MD5 b/Lang/Liberty-BASIC/MD5 new file mode 120000 index 0000000000..2b459d4d81 --- /dev/null +++ b/Lang/Liberty-BASIC/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Mad-Libs b/Lang/Liberty-BASIC/Mad-Libs new file mode 120000 index 0000000000..0f9a1ead2a --- /dev/null +++ b/Lang/Liberty-BASIC/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Mandelbrot-set b/Lang/Liberty-BASIC/Mandelbrot-set new file mode 120000 index 0000000000..0c87cd4c2d --- /dev/null +++ b/Lang/Liberty-BASIC/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Matrix-exponentiation-operator b/Lang/Liberty-BASIC/Matrix-exponentiation-operator new file mode 120000 index 0000000000..6ff958f34f --- /dev/null +++ b/Lang/Liberty-BASIC/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Matrix-multiplication b/Lang/Liberty-BASIC/Matrix-multiplication new file mode 120000 index 0000000000..97dd282ac9 --- /dev/null +++ b/Lang/Liberty-BASIC/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Matrix-transposition b/Lang/Liberty-BASIC/Matrix-transposition new file mode 120000 index 0000000000..98588d90f5 --- /dev/null +++ b/Lang/Liberty-BASIC/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Metronome b/Lang/Liberty-BASIC/Metronome new file mode 120000 index 0000000000..a95a7c7b52 --- /dev/null +++ b/Lang/Liberty-BASIC/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Monte-Carlo-methods b/Lang/Liberty-BASIC/Monte-Carlo-methods new file mode 120000 index 0000000000..08c6a9b371 --- /dev/null +++ b/Lang/Liberty-BASIC/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Monty-Hall-problem b/Lang/Liberty-BASIC/Monty-Hall-problem new file mode 120000 index 0000000000..49a78e809c --- /dev/null +++ b/Lang/Liberty-BASIC/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Morse-code b/Lang/Liberty-BASIC/Morse-code new file mode 120000 index 0000000000..1afa0a2cb4 --- /dev/null +++ b/Lang/Liberty-BASIC/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Mouse-position b/Lang/Liberty-BASIC/Mouse-position new file mode 120000 index 0000000000..10c5753d4c --- /dev/null +++ b/Lang/Liberty-BASIC/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Multiplication-tables b/Lang/Liberty-BASIC/Multiplication-tables new file mode 120000 index 0000000000..36c835b30d --- /dev/null +++ b/Lang/Liberty-BASIC/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Mutual-recursion b/Lang/Liberty-BASIC/Mutual-recursion new file mode 120000 index 0000000000..3e5a9065ba --- /dev/null +++ b/Lang/Liberty-BASIC/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Narcissist b/Lang/Liberty-BASIC/Narcissist new file mode 120000 index 0000000000..f36c9dcf69 --- /dev/null +++ b/Lang/Liberty-BASIC/Narcissist @@ -0,0 +1 @@ +../../Task/Narcissist/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Ordered-words b/Lang/Liberty-BASIC/Ordered-words new file mode 120000 index 0000000000..eabaa18798 --- /dev/null +++ b/Lang/Liberty-BASIC/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pi b/Lang/Liberty-BASIC/Pi new file mode 120000 index 0000000000..51ea0a7b75 --- /dev/null +++ b/Lang/Liberty-BASIC/Pi @@ -0,0 +1 @@ +../../Task/Pi/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Quine b/Lang/Liberty-BASIC/Quine new file mode 120000 index 0000000000..b82897096d --- /dev/null +++ b/Lang/Liberty-BASIC/Quine @@ -0,0 +1 @@ +../../Task/Quine/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Search-a-list b/Lang/Liberty-BASIC/Search-a-list new file mode 120000 index 0000000000..9346fc29e6 --- /dev/null +++ b/Lang/Liberty-BASIC/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Lilypond/0DESCRIPTION b/Lang/Lilypond/0DESCRIPTION new file mode 100644 index 0000000000..d911dad6a0 --- /dev/null +++ b/Lang/Lilypond/0DESCRIPTION @@ -0,0 +1,6 @@ +{{stub}}{{language|lilypond +|site=http://www.lilypond.org/}} + +The lilypond language is used by the lilypond score production software for describing the layout of musical score sheets. + +[[Category:Musical Notation]] \ No newline at end of file diff --git a/Lang/Lilypond/Comments b/Lang/Lilypond/Comments new file mode 120000 index 0000000000..ddcf204264 --- /dev/null +++ b/Lang/Lilypond/Comments @@ -0,0 +1 @@ +../../Task/Comments/Lilypond \ No newline at end of file diff --git a/Lang/Lilypond/Empty-program b/Lang/Lilypond/Empty-program new file mode 120000 index 0000000000..7f42f3ec9a --- /dev/null +++ b/Lang/Lilypond/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Lilypond \ No newline at end of file diff --git a/Lang/Limbo/0DESCRIPTION b/Lang/Limbo/0DESCRIPTION new file mode 100644 index 0000000000..2d485ae370 --- /dev/null +++ b/Lang/Limbo/0DESCRIPTION @@ -0,0 +1,16 @@ +{{language|limbo +|site=http://www.vitanuova.com/inferno/limbo.html +|gc=yes +}} + +Limbo is the application programming language for Inferno. Syntactically similar to [[C]], it has several features that make it simpler, safer and yet more powerful and better suited to the development of concurrent, distributed systems. The Limbo compiler generates architecture independent object code which is then interpreted by the Inferno Virtual Machine or compiled just before runtime to improve performance. This ensures that Limbo applications are completely portable across all Inferno platforms.[[#Citation|[1]]] + +Limbo's approach to concurrency was inspired by Hoare's Communicating Sequential Processes ([[CSP]]).[[#Citation|[2]]] + +==Citations== +#[http://www.vitanuova.com/inferno/papers/limbo.html The Limbo Programming Language by Dennis M. Ritchie] +#[[wp:Limbo_(programming_language)|Wikipedia: Limbo Programming Language]] + +==See Also== +* [http://www.cs.rit.edu/~ats/inferno/limbo/ The Limbo Programming Language] +* [http://doc.cat-v.org/inferno/4th_edition/limbo_language/descent A Descent into Limbo by Brian W. Kernighan] \ No newline at end of file diff --git a/Lang/Limbo/Hello-world-Text b/Lang/Limbo/Hello-world-Text new file mode 120000 index 0000000000..78b823bfc6 --- /dev/null +++ b/Lang/Limbo/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Limbo \ No newline at end of file diff --git a/Lang/Lisaac/0DESCRIPTION b/Lang/Lisaac/0DESCRIPTION new file mode 100644 index 0000000000..cc56375d89 --- /dev/null +++ b/Lang/Lisaac/0DESCRIPTION @@ -0,0 +1,7 @@ +{{language}} + +[http://isaacproject.u-strasbg.fr/index.html Lisaac] is a small [[object-oriented language|object]] prototype-based programming language created to enable the implementation of the Isaac [[operating system]] as part of Benoit Sonntag's thesis. Since Lisaac was created to support the development of an operating system, it has strong support for implementing low level features even though it is itself a high level language. The language was inspired by [[Smalltalk]] (everything is an object), [[Self]] (prototype based programming), and [[Eiffel]] (design by contract), but it has the distinction of being suitable to systems level programming through many techniques such as optimization of type predictions and code specialization. + +In the performance benchmark [http://shootout.alioth.debian.org/ The Computer Language Benchmarks Game], [http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all Lisaac currently places #5], essentially neck-and-neck with [[C]] and [[C++]]. + +Lisaac compiles '.li' Lisaac source files into [[ISO]] standard C code, which can then be compiled to native machine code by any C compiler. The current 'lisaac' compiler implementation also automatically compiles the generated '.c' file with gcc by default. \ No newline at end of file diff --git a/Lang/Lisaac/A+B b/Lang/Lisaac/A+B new file mode 120000 index 0000000000..3af661ca32 --- /dev/null +++ b/Lang/Lisaac/A+B @@ -0,0 +1 @@ +../../Task/A+B/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Apply-a-callback-to-an-array b/Lang/Lisaac/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..337fac07e7 --- /dev/null +++ b/Lang/Lisaac/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Arrays b/Lang/Lisaac/Arrays new file mode 120000 index 0000000000..8025eefdfb --- /dev/null +++ b/Lang/Lisaac/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Assertions b/Lang/Lisaac/Assertions new file mode 120000 index 0000000000..ef318694c1 --- /dev/null +++ b/Lang/Lisaac/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Call-a-foreign-language-function b/Lang/Lisaac/Call-a-foreign-language-function new file mode 120000 index 0000000000..429ab143a5 --- /dev/null +++ b/Lang/Lisaac/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Classes b/Lang/Lisaac/Classes new file mode 120000 index 0000000000..c5790cab88 --- /dev/null +++ b/Lang/Lisaac/Classes @@ -0,0 +1 @@ +../../Task/Classes/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Collections b/Lang/Lisaac/Collections new file mode 120000 index 0000000000..773b1f1d02 --- /dev/null +++ b/Lang/Lisaac/Collections @@ -0,0 +1 @@ +../../Task/Collections/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Conditional-structures b/Lang/Lisaac/Conditional-structures new file mode 120000 index 0000000000..20b1cddb0f --- /dev/null +++ b/Lang/Lisaac/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Determine-if-a-string-is-numeric b/Lang/Lisaac/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..f236ef4907 --- /dev/null +++ b/Lang/Lisaac/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Factorial b/Lang/Lisaac/Factorial new file mode 120000 index 0000000000..b35161f0ec --- /dev/null +++ b/Lang/Lisaac/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Fibonacci-sequence b/Lang/Lisaac/Fibonacci-sequence new file mode 120000 index 0000000000..d2856edde7 --- /dev/null +++ b/Lang/Lisaac/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/File-IO b/Lang/Lisaac/File-IO new file mode 120000 index 0000000000..157d6f4d92 --- /dev/null +++ b/Lang/Lisaac/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Filter b/Lang/Lisaac/Filter new file mode 120000 index 0000000000..cb2afc8214 --- /dev/null +++ b/Lang/Lisaac/Filter @@ -0,0 +1 @@ +../../Task/Filter/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Generic-swap b/Lang/Lisaac/Generic-swap new file mode 120000 index 0000000000..50f1459ee0 --- /dev/null +++ b/Lang/Lisaac/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Hello-world-Text b/Lang/Lisaac/Hello-world-Text new file mode 120000 index 0000000000..07964949ad --- /dev/null +++ b/Lang/Lisaac/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Inheritance-Single b/Lang/Lisaac/Inheritance-Single new file mode 120000 index 0000000000..c8e52dd7cd --- /dev/null +++ b/Lang/Lisaac/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Literals-String b/Lang/Lisaac/Literals-String new file mode 120000 index 0000000000..90049d9a0c --- /dev/null +++ b/Lang/Lisaac/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loop-over-multiple-arrays-simultaneously b/Lang/Lisaac/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..3c937136aa --- /dev/null +++ b/Lang/Lisaac/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Break b/Lang/Lisaac/Loops-Break new file mode 120000 index 0000000000..b389fc71d9 --- /dev/null +++ b/Lang/Lisaac/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Continue b/Lang/Lisaac/Loops-Continue new file mode 120000 index 0000000000..af7c709d6f --- /dev/null +++ b/Lang/Lisaac/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Do-while b/Lang/Lisaac/Loops-Do-while new file mode 120000 index 0000000000..3e8b5721f5 --- /dev/null +++ b/Lang/Lisaac/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Downward-for b/Lang/Lisaac/Loops-Downward-for new file mode 120000 index 0000000000..162db6bbbc --- /dev/null +++ b/Lang/Lisaac/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-For b/Lang/Lisaac/Loops-For new file mode 120000 index 0000000000..a03deb04f4 --- /dev/null +++ b/Lang/Lisaac/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-For-with-a-specified-step b/Lang/Lisaac/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..66fa93fead --- /dev/null +++ b/Lang/Lisaac/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Foreach b/Lang/Lisaac/Loops-Foreach new file mode 120000 index 0000000000..a6244310da --- /dev/null +++ b/Lang/Lisaac/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-N-plus-one-half b/Lang/Lisaac/Loops-N-plus-one-half new file mode 120000 index 0000000000..94184dbff3 --- /dev/null +++ b/Lang/Lisaac/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-Nested b/Lang/Lisaac/Loops-Nested new file mode 120000 index 0000000000..d13de13ca0 --- /dev/null +++ b/Lang/Lisaac/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Loops-While b/Lang/Lisaac/Loops-While new file mode 120000 index 0000000000..b40b6b5106 --- /dev/null +++ b/Lang/Lisaac/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Lisaac \ No newline at end of file diff --git a/Lang/Lisaac/Search-a-list b/Lang/Lisaac/Search-a-list new file mode 120000 index 0000000000..ea0c54c11e --- /dev/null +++ b/Lang/Lisaac/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Lisaac \ No newline at end of file diff --git a/Lang/Lisp/0DESCRIPTION b/Lang/Lisp/0DESCRIPTION new file mode 100644 index 0000000000..2ced8262f7 --- /dev/null +++ b/Lang/Lisp/0DESCRIPTION @@ -0,0 +1,16 @@ +{{language|Lisp +|strength=strong +|checking=dynamic +|gc=yes +|LCT=yes +|bnf=http://cui.unige.ch/db-research/Enseignement/analyseinfo/LISP/BNFindex.html}} +'''Lisp''' or '''LISP''' (originally an acronym for '''LIS'''t '''P'''rocessing) was one of the first high-level languages, invented in 1958 by John McCarthy. It had many descendants: major freestanding dialects still in use today are [[Common Lisp]], [[Scheme]] & [[Clojure]]. Other dialects of Lisp are used as scripting languages in applications, most notably [[Emacs Lisp]], [[AutoLISP]], and [[Guile]]. + +(Today, the name is usually written "Lisp" rather than “LISP” among advocates, both because "we have lowercase letters now”, and to make a distinction between modern practical Lisp systems and the popular notion of “oh, LISP, that's where everything is a list or a symbol and you have to use recursion, right?”) +
+==How to categorize examples== +This category is for solutions in archaic dialects or solutions valid in any dialect of Lisp. Please note the dialect used when adding examples. + +If the solution is also valid in the dialects separately listed in Rosetta Code, such as Common Lisp and Scheme, then use the {{header|''dialect''}} template so that the task will be listed as solved for that dialect. For example: + + =={{header|Lisp}} (MacLisp, {{header|Common Lisp}}, {{header|Emacs Lisp}})== \ No newline at end of file diff --git a/Lang/Lisp/Empty-program b/Lang/Lisp/Empty-program new file mode 120000 index 0000000000..340383f72d --- /dev/null +++ b/Lang/Lisp/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Lisp \ No newline at end of file diff --git a/Lang/Lisp/Quine b/Lang/Lisp/Quine new file mode 120000 index 0000000000..24d3383620 --- /dev/null +++ b/Lang/Lisp/Quine @@ -0,0 +1 @@ +../../Task/Quine/Lisp \ No newline at end of file diff --git a/Lang/Locomotive-Basic/0DESCRIPTION b/Lang/Locomotive-Basic/0DESCRIPTION new file mode 100644 index 0000000000..69a68e9534 --- /dev/null +++ b/Lang/Locomotive-Basic/0DESCRIPTION @@ -0,0 +1,54 @@ +{{language|Locomotive Basic +|exec=interpreted +|site=http://www.grimware.org/doku.php/documentations/software/locomotive.basic/}} +{{implementation|BASIC}} + +'''Locomotive BASIC''' is a variant of BASIC that is built into the ROM of the [[wp:Amstrad CPC|Amstrad CPC]] series of Z80-based home computers introduced in 1984. In the 1980s, CPCs were a popular, slightly more expensive alternative to the Commodore C64/C128 and were not just suited for games but also office work because of their high resolution displays and [[wp:CP/M|CP/M]] support. They came with a built-in cassette deck (CPC 464 and 664) or 3" disk drive (CPC 6128) as storage devices and a "green screen" or color monitor which also housed the power supply. Sales were particularly strong in the UK, Germany, France, and Spain. Today, Locomotive BASIC can be used via CPC emulators such as [http://www.winape.net/ WinAPE] or [http://sourceforge.net/projects/javacpc/ JavaCPC]—which is perfectly legal because Amstrad has given their permission for distributing CPC ROM images with emulators. + +==Features== + +Locomotive BASIC was comparatively advanced for its time (with e.g. software interrupts and comprehensive graphics and audio commands) and is very cleanly implemented, just like the rest of the Amstrad CPC ROM. No doubt this was partly because the CPC debuted relatively late during the era of 8-bit machines, so Locomotive Software had more of an opportunity to consider the good and bad software design decisions in existing home computers. System calls are made with CALL via dedicated jump blocks in RAM, so they are unaffected by changes to the ROM between CPC models. This makes software very compatible between the original three CPC models and ''mostly'' compatible for the later, considerably less popular "Plus" models that came out in 1990. Together with AMSDOS, the '''Ams'''trad '''D'''isk '''O'''perating '''S'''ystem, Locomotive BASIC is also used for disk and tape operations. (Some commands however, e.g. disckit3 for formatting disks, are only available under CP/M.) + +==Z80 Extensions== + +As on many other 8-bit machines of the era, BASIC programs are often extended with [[Z80 Assembly|Z80]] machine code which is READ from DATA statements, [[wp:PEEK and POKE|POKE]]-d to RAM, and then CALL-ed—an approach that was especially popular with type-in games in CPC magazines. The CPC also has a more convenient form of BASIC extensions, RSXhttp://www.cpcwiki.eu/index.php/RSX commands ('''r'''esident '''s'''ystem e'''x'''tensions). They are easily recognized by being prefixed with a pipe character and have the advantage of being freely relocatable in memory. Some RSX commands, such as "|ren" to rename files, are part of the AMSDOS ROM, but RSX routines can also reside in RAM, e.g. to provide new graphics primitives or other new capabilities to BASIC. + +==Memory management== + +Memory on the CPC 464 and 664 is subdivided into four 16 kB blocks (0 to 3), with block 3 at &c000 normally reserved for the screen. The CPC 6128 features a second 64 kB bank (blocks 4 to 7) which can be accessed from BASIC with [[wp:Bank switching|bank switching]] in block 1 (&4000 and &7fff), e.g. + +out &7fff,&x11000100 + +would make block 4 accessible in the address space of block 1.http://k1.dyndns.org/Vintage/Schneider%20CPC/Das%20Schneider%20CPC%20Systembuch/z87.htm This way, the entire 128 kB of memory can be used by BASIC. Alternatively, RSX commands for bank switching and copying between banks are included on the system discs and discussed in chapter 8 of the CPC user manual.http://www.cpcwiki.eu/index.php/User_Manual Even on the 64 kB models, it is possible to do [[wp:Multiple buffering|double buffering]] in BASIC by reserving another RAM block for the screen, drawing into the hidden screen, and then setting the CRTC screen address to the currently hidden screen with the BASIC [[wp:I/o port|port I/O]] command OUT. + +==Language versions and user manual== + +Version 1.0 of Locomotive BASIC shipped with the CPC 464, later models included Locomotive Basic v1.1 which brought some important improvements. Despite the fact that all later BASIC versions call themselves v1.1, ROM headers show that e.g. the Amstrad Plus version is actually v1.40.http://www.grimware.org/doku.php/documentations/software/locomotive.basic/start#basic.1.1 Amstrad CPC emulators usually default to a CPC 6128 with a color monitor and BASIC 1.1. + +The extensive CPC user manual features a finely written introduction to BASIC that does not feel as rushed or dumbed-down as in some other manuals of the time. Obviously Amstrad expected many customers would want to program their CPCs themselves, not just use them with off-the-shelf software. There are even some pretty decent BASIC type-in games in appendix 3, such as clones of the arcade classics ''[[wp:Breakout (video game)|Breakout]]'' and ''[[wp:Pong|Pong]]''. + +==Getting started with Locomotive BASIC== + +Either use a browser-based CPC emulator (http://www.cpcbox.com/) or download a binary for your platform. A list of emulators is available at http://cpcwiki.eu/index.php/Emulators. JavaCPC (http://sourceforge.net/projects/javacpc/) or WinAPE (http://www.winape.net/) are particularly recommended. An advantage of native emulators is that they tend to have copy-and-paste functionality, so you can edit programs in external editors. + +In the emulator, type + +10 print "Goodbye, World!" +run + +to run your first Locomotive BASIC program. + +==References== + + + +==See Also== +* Locomotive BASIC documentation: +** [[wp:Locomotive BASIC|Locomotive BASIC]] at Wikipedia +** [http://www.grimware.org/doku.php/documentations/software/locomotive.basic/ Locomotive BASIC command reference with code examples] (based on the official documentation) +** [http://www.cpcwiki.eu/index.php/User_Manual Scanned CPC user manuals] +** [http://www.cpcwiki.eu/index.php/Locomotive_BASIC Locomotive BASIC] at the [http://www.cpcwiki.eu/ Amstrad CPC Wiki] +* CPC emulators: +** [http://sourceforge.net/projects/javacpc/ JavaCPC emulator] +** [http://cpcbox.com/ Online CPC emulator in JavaScript] (best performance in Firefox, but also works in Chrome) +** [http://www.cpcwiki.eu/index.php/Emulators List of CPC emulators] \ No newline at end of file diff --git a/Lang/Locomotive-Basic/24-game b/Lang/Locomotive-Basic/24-game new file mode 120000 index 0000000000..53fbff5d61 --- /dev/null +++ b/Lang/Locomotive-Basic/24-game @@ -0,0 +1 @@ +../../Task/24-game/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Color-of-a-screen-pixel b/Lang/Locomotive-Basic/Color-of-a-screen-pixel new file mode 120000 index 0000000000..e9c299539e --- /dev/null +++ b/Lang/Locomotive-Basic/Color-of-a-screen-pixel @@ -0,0 +1 @@ +../../Task/Color-of-a-screen-pixel/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Colour-bars-Display b/Lang/Locomotive-Basic/Colour-bars-Display new file mode 120000 index 0000000000..defbfc4e84 --- /dev/null +++ b/Lang/Locomotive-Basic/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Constrained-random-points-on-a-circle b/Lang/Locomotive-Basic/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..cfeabd2826 --- /dev/null +++ b/Lang/Locomotive-Basic/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Delete-a-file b/Lang/Locomotive-Basic/Delete-a-file new file mode 120000 index 0000000000..c953b42db7 --- /dev/null +++ b/Lang/Locomotive-Basic/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Detect-division-by-zero b/Lang/Locomotive-Basic/Detect-division-by-zero new file mode 120000 index 0000000000..9b5c8050a9 --- /dev/null +++ b/Lang/Locomotive-Basic/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Ethiopian-multiplication b/Lang/Locomotive-Basic/Ethiopian-multiplication new file mode 120000 index 0000000000..904dd54340 --- /dev/null +++ b/Lang/Locomotive-Basic/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Execute-a-system-command b/Lang/Locomotive-Basic/Execute-a-system-command new file mode 120000 index 0000000000..de3f2158dd --- /dev/null +++ b/Lang/Locomotive-Basic/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Function-definition b/Lang/Locomotive-Basic/Function-definition new file mode 120000 index 0000000000..71dc1205fc --- /dev/null +++ b/Lang/Locomotive-Basic/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Guess-the-number b/Lang/Locomotive-Basic/Guess-the-number new file mode 120000 index 0000000000..c79d891412 --- /dev/null +++ b/Lang/Locomotive-Basic/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Guess-the-number-With-feedback b/Lang/Locomotive-Basic/Guess-the-number-With-feedback new file mode 120000 index 0000000000..5135899de0 --- /dev/null +++ b/Lang/Locomotive-Basic/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Happy-numbers b/Lang/Locomotive-Basic/Happy-numbers new file mode 120000 index 0000000000..8d05d0fb7c --- /dev/null +++ b/Lang/Locomotive-Basic/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Hello-world-Line-printer b/Lang/Locomotive-Basic/Hello-world-Line-printer new file mode 120000 index 0000000000..eddc434616 --- /dev/null +++ b/Lang/Locomotive-Basic/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Introspection b/Lang/Locomotive-Basic/Introspection new file mode 120000 index 0000000000..36a5d6eaad --- /dev/null +++ b/Lang/Locomotive-Basic/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Joystick-position b/Lang/Locomotive-Basic/Joystick-position new file mode 120000 index 0000000000..487183292f --- /dev/null +++ b/Lang/Locomotive-Basic/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Knights-tour b/Lang/Locomotive-Basic/Knights-tour new file mode 120000 index 0000000000..463508d04c --- /dev/null +++ b/Lang/Locomotive-Basic/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Langtons-ant b/Lang/Locomotive-Basic/Langtons-ant new file mode 120000 index 0000000000..a0c232b674 --- /dev/null +++ b/Lang/Locomotive-Basic/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Minesweeper-game b/Lang/Locomotive-Basic/Minesweeper-game new file mode 120000 index 0000000000..e5b37bb51d --- /dev/null +++ b/Lang/Locomotive-Basic/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Monte-Carlo-methods b/Lang/Locomotive-Basic/Monte-Carlo-methods new file mode 120000 index 0000000000..e553f049ae --- /dev/null +++ b/Lang/Locomotive-Basic/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Logo/0DESCRIPTION b/Lang/Logo/0DESCRIPTION new file mode 100644 index 0000000000..6deea15712 --- /dev/null +++ b/Lang/Logo/0DESCRIPTION @@ -0,0 +1,13 @@ +{{language|Logo +|strength=strong +|safety=safe +|express=implicit +|compat=structural +|checking=dynamic +|gc=yes +|LCT=yes}}'''Logo''' is a language invented by Seymour Papert in the 1960's designed expressly for teaching programming to children. It is well known for its built-in [[wp:turtle graphics|turtle graphics]]. Unlike other languages which attempt to fill the educational niche, like [[BASIC]], Logo has [[Lisp]]-like underpinnings, and can be used to teach structured, recursive, and functional programming. + +==See Also== +*[http://logo.twentygototen.org/ papert - a Logo interpreter written in JavaScript] +*[http://www.calormen.com/Logo/ Another Logo interpreter written in JavaScript by Joshua Bell] +*[http://lhogho.sourceforge.net/ Lhogho - a Logo compiler written in C by Pavel Boytchev] \ No newline at end of file diff --git a/Lang/Logo/100-doors b/Lang/Logo/100-doors new file mode 120000 index 0000000000..252e9df499 --- /dev/null +++ b/Lang/Logo/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Logo \ No newline at end of file diff --git a/Lang/Logo/24-game b/Lang/Logo/24-game new file mode 120000 index 0000000000..cda32b9336 --- /dev/null +++ b/Lang/Logo/24-game @@ -0,0 +1 @@ +../../Task/24-game/Logo \ No newline at end of file diff --git a/Lang/Logo/99-Bottles-of-Beer b/Lang/Logo/99-Bottles-of-Beer new file mode 120000 index 0000000000..28d4510355 --- /dev/null +++ b/Lang/Logo/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Logo \ No newline at end of file diff --git a/Lang/Logo/A+B b/Lang/Logo/A+B new file mode 120000 index 0000000000..c3814e04b4 --- /dev/null +++ b/Lang/Logo/A+B @@ -0,0 +1 @@ +../../Task/A+B/Logo \ No newline at end of file diff --git a/Lang/Logo/Ackermann-function b/Lang/Logo/Ackermann-function new file mode 120000 index 0000000000..6762554dc5 --- /dev/null +++ b/Lang/Logo/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Logo \ No newline at end of file diff --git a/Lang/Logo/Animate-a-pendulum b/Lang/Logo/Animate-a-pendulum new file mode 120000 index 0000000000..ab94ea3ea0 --- /dev/null +++ b/Lang/Logo/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/Logo \ No newline at end of file diff --git a/Lang/Logo/Animation b/Lang/Logo/Animation new file mode 120000 index 0000000000..ef9590d465 --- /dev/null +++ b/Lang/Logo/Animation @@ -0,0 +1 @@ +../../Task/Animation/Logo \ No newline at end of file diff --git a/Lang/Logo/Apply-a-callback-to-an-array b/Lang/Logo/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..54db2ad72a --- /dev/null +++ b/Lang/Logo/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Logo \ No newline at end of file diff --git a/Lang/Logo/Arithmetic-Integer b/Lang/Logo/Arithmetic-Integer new file mode 120000 index 0000000000..172350a4b1 --- /dev/null +++ b/Lang/Logo/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Logo \ No newline at end of file diff --git a/Lang/Logo/Array-concatenation b/Lang/Logo/Array-concatenation new file mode 120000 index 0000000000..3b9dc2cd45 --- /dev/null +++ b/Lang/Logo/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Logo \ No newline at end of file diff --git a/Lang/Logo/Arrays b/Lang/Logo/Arrays new file mode 120000 index 0000000000..0082db4afd --- /dev/null +++ b/Lang/Logo/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Logo \ No newline at end of file diff --git a/Lang/Logo/Associative-array-Creation b/Lang/Logo/Associative-array-Creation new file mode 120000 index 0000000000..3776b1b4e9 --- /dev/null +++ b/Lang/Logo/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Logo \ No newline at end of file diff --git a/Lang/Logo/Averages-Arithmetic-mean b/Lang/Logo/Averages-Arithmetic-mean new file mode 120000 index 0000000000..e914a9bf0e --- /dev/null +++ b/Lang/Logo/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Logo \ No newline at end of file diff --git a/Lang/Logo/Averages-Pythagorean-means b/Lang/Logo/Averages-Pythagorean-means new file mode 120000 index 0000000000..102f196b48 --- /dev/null +++ b/Lang/Logo/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Logo \ No newline at end of file diff --git a/Lang/Logo/Averages-Root-mean-square b/Lang/Logo/Averages-Root-mean-square new file mode 120000 index 0000000000..cde9867dad --- /dev/null +++ b/Lang/Logo/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Logo \ No newline at end of file diff --git a/Lang/Logo/Averages-Simple-moving-average b/Lang/Logo/Averages-Simple-moving-average new file mode 120000 index 0000000000..a7380aaef9 --- /dev/null +++ b/Lang/Logo/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Logo \ No newline at end of file diff --git a/Lang/Logo/Binary-search b/Lang/Logo/Binary-search new file mode 120000 index 0000000000..55f7f19c74 --- /dev/null +++ b/Lang/Logo/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Logo \ No newline at end of file diff --git a/Lang/Logo/Bitwise-operations b/Lang/Logo/Bitwise-operations new file mode 120000 index 0000000000..386cd67606 --- /dev/null +++ b/Lang/Logo/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Logo \ No newline at end of file diff --git a/Lang/Logo/Boolean-values b/Lang/Logo/Boolean-values new file mode 120000 index 0000000000..c96dc1c555 --- /dev/null +++ b/Lang/Logo/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Logo \ No newline at end of file diff --git a/Lang/Logo/Box-the-compass b/Lang/Logo/Box-the-compass new file mode 120000 index 0000000000..e36983d6fa --- /dev/null +++ b/Lang/Logo/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Logo \ No newline at end of file diff --git a/Lang/Logo/Bulls-and-cows b/Lang/Logo/Bulls-and-cows new file mode 120000 index 0000000000..9bd16b3680 --- /dev/null +++ b/Lang/Logo/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Logo \ No newline at end of file diff --git a/Lang/Logo/Caesar-cipher b/Lang/Logo/Caesar-cipher new file mode 120000 index 0000000000..832617f0ed --- /dev/null +++ b/Lang/Logo/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Logo \ No newline at end of file diff --git a/Lang/Logo/Character-codes b/Lang/Logo/Character-codes new file mode 120000 index 0000000000..826498a59c --- /dev/null +++ b/Lang/Logo/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Logo \ No newline at end of file diff --git a/Lang/Logo/Character-matching b/Lang/Logo/Character-matching new file mode 120000 index 0000000000..08ecf5beb6 --- /dev/null +++ b/Lang/Logo/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Logo \ No newline at end of file diff --git a/Lang/Logo/Check-that-file-exists b/Lang/Logo/Check-that-file-exists new file mode 120000 index 0000000000..820fdd878c --- /dev/null +++ b/Lang/Logo/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Logo \ No newline at end of file diff --git a/Lang/Logo/Combinations b/Lang/Logo/Combinations new file mode 120000 index 0000000000..fcc7c40eec --- /dev/null +++ b/Lang/Logo/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Logo \ No newline at end of file diff --git a/Lang/Logo/Command-line-arguments b/Lang/Logo/Command-line-arguments new file mode 120000 index 0000000000..8086a50eb5 --- /dev/null +++ b/Lang/Logo/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Logo \ No newline at end of file diff --git a/Lang/Logo/Comments b/Lang/Logo/Comments new file mode 120000 index 0000000000..692a4077bf --- /dev/null +++ b/Lang/Logo/Comments @@ -0,0 +1 @@ +../../Task/Comments/Logo \ No newline at end of file diff --git a/Lang/Logo/Compound-data-type b/Lang/Logo/Compound-data-type new file mode 120000 index 0000000000..53de9ed7d2 --- /dev/null +++ b/Lang/Logo/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Logo \ No newline at end of file diff --git a/Lang/Logo/Conditional-structures b/Lang/Logo/Conditional-structures new file mode 120000 index 0000000000..ecf28f6c10 --- /dev/null +++ b/Lang/Logo/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Logo \ No newline at end of file diff --git a/Lang/Logo/Count-in-octal b/Lang/Logo/Count-in-octal new file mode 120000 index 0000000000..ad4a42beca --- /dev/null +++ b/Lang/Logo/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Logo \ No newline at end of file diff --git a/Lang/Logo/Create-a-two-dimensional-array-at-runtime b/Lang/Logo/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..6c21a59360 --- /dev/null +++ b/Lang/Logo/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Logo \ No newline at end of file diff --git a/Lang/Logo/Delete-a-file b/Lang/Logo/Delete-a-file new file mode 120000 index 0000000000..a0a8e7e21e --- /dev/null +++ b/Lang/Logo/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Logo \ No newline at end of file diff --git a/Lang/Logo/Determine-if-a-string-is-numeric b/Lang/Logo/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..3098c254bc --- /dev/null +++ b/Lang/Logo/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Logo \ No newline at end of file diff --git a/Lang/Logo/Dot-product b/Lang/Logo/Dot-product new file mode 120000 index 0000000000..5f50539276 --- /dev/null +++ b/Lang/Logo/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Logo \ No newline at end of file diff --git a/Lang/Logo/Draw-a-cuboid b/Lang/Logo/Draw-a-cuboid new file mode 120000 index 0000000000..abfd75f7ce --- /dev/null +++ b/Lang/Logo/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Logo \ No newline at end of file diff --git a/Lang/Logo/Draw-a-sphere b/Lang/Logo/Draw-a-sphere new file mode 120000 index 0000000000..4be1605293 --- /dev/null +++ b/Lang/Logo/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Logo \ No newline at end of file diff --git a/Lang/Logo/Dutch-national-flag-problem b/Lang/Logo/Dutch-national-flag-problem new file mode 120000 index 0000000000..20c6783358 --- /dev/null +++ b/Lang/Logo/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Logo \ No newline at end of file diff --git a/Lang/Logo/Dynamic-variable-names b/Lang/Logo/Dynamic-variable-names new file mode 120000 index 0000000000..14ac96b7cf --- /dev/null +++ b/Lang/Logo/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Logo \ No newline at end of file diff --git a/Lang/Logo/Empty-program b/Lang/Logo/Empty-program new file mode 120000 index 0000000000..b6a5834801 --- /dev/null +++ b/Lang/Logo/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Logo \ No newline at end of file diff --git a/Lang/Logo/Ethiopian-multiplication b/Lang/Logo/Ethiopian-multiplication new file mode 120000 index 0000000000..d0d759ff82 --- /dev/null +++ b/Lang/Logo/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Logo \ No newline at end of file diff --git a/Lang/Logo/Evaluate-binomial-coefficients b/Lang/Logo/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..9f4b598bdd --- /dev/null +++ b/Lang/Logo/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Logo \ No newline at end of file diff --git a/Lang/Logo/Evolutionary-algorithm b/Lang/Logo/Evolutionary-algorithm new file mode 120000 index 0000000000..da2433bb1d --- /dev/null +++ b/Lang/Logo/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Logo \ No newline at end of file diff --git a/Lang/Logo/Exceptions b/Lang/Logo/Exceptions new file mode 120000 index 0000000000..06bb731fd4 --- /dev/null +++ b/Lang/Logo/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Logo \ No newline at end of file diff --git a/Lang/Logo/Execute-a-system-command b/Lang/Logo/Execute-a-system-command new file mode 120000 index 0000000000..ae489d9f15 --- /dev/null +++ b/Lang/Logo/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Logo \ No newline at end of file diff --git a/Lang/Logo/Exponentiation-operator b/Lang/Logo/Exponentiation-operator new file mode 120000 index 0000000000..6a7aade540 --- /dev/null +++ b/Lang/Logo/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Logo \ No newline at end of file diff --git a/Lang/Logo/Factorial b/Lang/Logo/Factorial new file mode 120000 index 0000000000..0aab23531d --- /dev/null +++ b/Lang/Logo/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Logo \ No newline at end of file diff --git a/Lang/Logo/Factors-of-an-integer b/Lang/Logo/Factors-of-an-integer new file mode 120000 index 0000000000..31641039cd --- /dev/null +++ b/Lang/Logo/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Logo \ No newline at end of file diff --git a/Lang/Logo/Fibonacci-sequence b/Lang/Logo/Fibonacci-sequence new file mode 120000 index 0000000000..b85cd3f32e --- /dev/null +++ b/Lang/Logo/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Logo \ No newline at end of file diff --git a/Lang/Logo/File-IO b/Lang/Logo/File-IO new file mode 120000 index 0000000000..45d94372d1 --- /dev/null +++ b/Lang/Logo/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Logo \ No newline at end of file diff --git a/Lang/Logo/Filter b/Lang/Logo/Filter new file mode 120000 index 0000000000..8f83304b98 --- /dev/null +++ b/Lang/Logo/Filter @@ -0,0 +1 @@ +../../Task/Filter/Logo \ No newline at end of file diff --git a/Lang/Logo/Find-limit-of-recursion b/Lang/Logo/Find-limit-of-recursion new file mode 120000 index 0000000000..116854f61d --- /dev/null +++ b/Lang/Logo/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Logo \ No newline at end of file diff --git a/Lang/Logo/FizzBuzz b/Lang/Logo/FizzBuzz new file mode 120000 index 0000000000..3b98aadb84 --- /dev/null +++ b/Lang/Logo/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Logo \ No newline at end of file diff --git a/Lang/Logo/Flatten-a-list b/Lang/Logo/Flatten-a-list new file mode 120000 index 0000000000..1f2d4e893f --- /dev/null +++ b/Lang/Logo/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Logo \ No newline at end of file diff --git a/Lang/Logo/Formatted-numeric-output b/Lang/Logo/Formatted-numeric-output new file mode 120000 index 0000000000..4b3f200af3 --- /dev/null +++ b/Lang/Logo/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Logo \ No newline at end of file diff --git a/Lang/Logo/Forward-difference b/Lang/Logo/Forward-difference new file mode 120000 index 0000000000..20d99ffd5c --- /dev/null +++ b/Lang/Logo/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Logo \ No newline at end of file diff --git a/Lang/Logo/Fractal-tree b/Lang/Logo/Fractal-tree new file mode 120000 index 0000000000..45fcb16fbb --- /dev/null +++ b/Lang/Logo/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Logo \ No newline at end of file diff --git a/Lang/Logo/Function-definition b/Lang/Logo/Function-definition new file mode 120000 index 0000000000..b2d78d48ee --- /dev/null +++ b/Lang/Logo/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Logo \ No newline at end of file diff --git a/Lang/Logo/Generic-swap b/Lang/Logo/Generic-swap new file mode 120000 index 0000000000..bc49d57952 --- /dev/null +++ b/Lang/Logo/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Logo \ No newline at end of file diff --git a/Lang/Logo/Gray-code b/Lang/Logo/Gray-code new file mode 120000 index 0000000000..72a386e7e7 --- /dev/null +++ b/Lang/Logo/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Logo \ No newline at end of file diff --git a/Lang/Logo/Greatest-common-divisor b/Lang/Logo/Greatest-common-divisor new file mode 120000 index 0000000000..c153d89281 --- /dev/null +++ b/Lang/Logo/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Logo \ No newline at end of file diff --git a/Lang/Logo/Greatest-element-of-a-list b/Lang/Logo/Greatest-element-of-a-list new file mode 120000 index 0000000000..7dba1f0f93 --- /dev/null +++ b/Lang/Logo/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Logo \ No newline at end of file diff --git a/Lang/Logo/Guess-the-number-With-feedback b/Lang/Logo/Guess-the-number-With-feedback new file mode 120000 index 0000000000..cfe7d01029 --- /dev/null +++ b/Lang/Logo/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Logo \ No newline at end of file diff --git a/Lang/Logo/Hailstone-sequence b/Lang/Logo/Hailstone-sequence new file mode 120000 index 0000000000..b91bd1bb07 --- /dev/null +++ b/Lang/Logo/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Logo \ No newline at end of file diff --git a/Lang/Logo/Hamming-numbers b/Lang/Logo/Hamming-numbers new file mode 120000 index 0000000000..733021a1c4 --- /dev/null +++ b/Lang/Logo/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Happy-numbers b/Lang/Logo/Happy-numbers new file mode 120000 index 0000000000..b10de5e859 --- /dev/null +++ b/Lang/Logo/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Hello-world-Graphical b/Lang/Logo/Hello-world-Graphical new file mode 120000 index 0000000000..3bec743cf2 --- /dev/null +++ b/Lang/Logo/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Logo \ No newline at end of file diff --git a/Lang/Logo/Hello-world-Text b/Lang/Logo/Hello-world-Text new file mode 120000 index 0000000000..f8ab61856a --- /dev/null +++ b/Lang/Logo/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Logo \ No newline at end of file diff --git a/Lang/Logo/Higher-order-functions b/Lang/Logo/Higher-order-functions new file mode 120000 index 0000000000..563711c3c1 --- /dev/null +++ b/Lang/Logo/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Logo \ No newline at end of file diff --git a/Lang/Logo/Horizontal-sundial-calculations b/Lang/Logo/Horizontal-sundial-calculations new file mode 120000 index 0000000000..ebc56d7805 --- /dev/null +++ b/Lang/Logo/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Logo \ No newline at end of file diff --git a/Lang/Logo/Horners-rule-for-polynomial-evaluation b/Lang/Logo/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..a338a17d1d --- /dev/null +++ b/Lang/Logo/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Logo \ No newline at end of file diff --git a/Lang/Logo/Increment-a-numerical-string b/Lang/Logo/Increment-a-numerical-string new file mode 120000 index 0000000000..cc71663cad --- /dev/null +++ b/Lang/Logo/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Logo \ No newline at end of file diff --git a/Lang/Logo/Input-loop b/Lang/Logo/Input-loop new file mode 120000 index 0000000000..8b5d45e2a4 --- /dev/null +++ b/Lang/Logo/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Logo \ No newline at end of file diff --git a/Lang/Logo/Integer-comparison b/Lang/Logo/Integer-comparison new file mode 120000 index 0000000000..5da30c14ab --- /dev/null +++ b/Lang/Logo/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Logo \ No newline at end of file diff --git a/Lang/Logo/Interactive-programming b/Lang/Logo/Interactive-programming new file mode 120000 index 0000000000..050bd50056 --- /dev/null +++ b/Lang/Logo/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Logo \ No newline at end of file diff --git a/Lang/Logo/Introspection b/Lang/Logo/Introspection new file mode 120000 index 0000000000..5d038e669f --- /dev/null +++ b/Lang/Logo/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Logo \ No newline at end of file diff --git a/Lang/Logo/Keyboard-input-Keypress-check b/Lang/Logo/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..c1c35b60a0 --- /dev/null +++ b/Lang/Logo/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Logo \ No newline at end of file diff --git a/Lang/Logo/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Logo/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..2f0ccabedf --- /dev/null +++ b/Lang/Logo/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Logo \ No newline at end of file diff --git a/Lang/Logo/Knuth-shuffle b/Lang/Logo/Knuth-shuffle new file mode 120000 index 0000000000..1deb81ae15 --- /dev/null +++ b/Lang/Logo/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Logo \ No newline at end of file diff --git a/Lang/Logo/Leap-year b/Lang/Logo/Leap-year new file mode 120000 index 0000000000..758116454e --- /dev/null +++ b/Lang/Logo/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Logo \ No newline at end of file diff --git a/Lang/Logo/Least-common-multiple b/Lang/Logo/Least-common-multiple new file mode 120000 index 0000000000..fef421f31e --- /dev/null +++ b/Lang/Logo/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Logo \ No newline at end of file diff --git a/Lang/Logo/Linear-congruential-generator b/Lang/Logo/Linear-congruential-generator new file mode 120000 index 0000000000..58aa1a6698 --- /dev/null +++ b/Lang/Logo/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Logo \ No newline at end of file diff --git a/Lang/Logo/Literals-String b/Lang/Logo/Literals-String new file mode 120000 index 0000000000..87cebcdb14 --- /dev/null +++ b/Lang/Logo/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Logo \ No newline at end of file diff --git a/Lang/Logo/Logical-operations b/Lang/Logo/Logical-operations new file mode 120000 index 0000000000..db3d9ec800 --- /dev/null +++ b/Lang/Logo/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Logo \ No newline at end of file diff --git a/Lang/Logo/Longest-common-subsequence b/Lang/Logo/Longest-common-subsequence new file mode 120000 index 0000000000..788eb70d2f --- /dev/null +++ b/Lang/Logo/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Logo \ No newline at end of file diff --git a/Lang/Logo/Look-and-say-sequence b/Lang/Logo/Look-and-say-sequence new file mode 120000 index 0000000000..3a102f6831 --- /dev/null +++ b/Lang/Logo/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Logo \ No newline at end of file diff --git a/Lang/Logo/Loop-over-multiple-arrays-simultaneously b/Lang/Logo/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..6b45b4334e --- /dev/null +++ b/Lang/Logo/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-Do-while b/Lang/Logo/Loops-Do-while new file mode 120000 index 0000000000..eab560a36f --- /dev/null +++ b/Lang/Logo/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-Downward-for b/Lang/Logo/Loops-Downward-for new file mode 120000 index 0000000000..6cc0a40687 --- /dev/null +++ b/Lang/Logo/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-For b/Lang/Logo/Loops-For new file mode 120000 index 0000000000..9f0d80cf0b --- /dev/null +++ b/Lang/Logo/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-For-with-a-specified-step b/Lang/Logo/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..91f566cd7b --- /dev/null +++ b/Lang/Logo/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-Foreach b/Lang/Logo/Loops-Foreach new file mode 120000 index 0000000000..93ada2f83d --- /dev/null +++ b/Lang/Logo/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-Infinite b/Lang/Logo/Loops-Infinite new file mode 120000 index 0000000000..2e7b4dd9dc --- /dev/null +++ b/Lang/Logo/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-N-plus-one-half b/Lang/Logo/Loops-N-plus-one-half new file mode 120000 index 0000000000..e4337e412d --- /dev/null +++ b/Lang/Logo/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-Nested b/Lang/Logo/Loops-Nested new file mode 120000 index 0000000000..f0bfae3c65 --- /dev/null +++ b/Lang/Logo/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Logo \ No newline at end of file diff --git a/Lang/Logo/Loops-While b/Lang/Logo/Loops-While new file mode 120000 index 0000000000..ce82d22b8d --- /dev/null +++ b/Lang/Logo/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Logo \ No newline at end of file diff --git a/Lang/Logo/Luhn-test-of-credit-card-numbers b/Lang/Logo/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..992409e235 --- /dev/null +++ b/Lang/Logo/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Mandelbrot-set b/Lang/Logo/Mandelbrot-set new file mode 120000 index 0000000000..e9cb4e687f --- /dev/null +++ b/Lang/Logo/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Logo \ No newline at end of file diff --git a/Lang/Logo/Map-range b/Lang/Logo/Map-range new file mode 120000 index 0000000000..516f2a5baf --- /dev/null +++ b/Lang/Logo/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Logo \ No newline at end of file diff --git a/Lang/Logo/Matrix-multiplication b/Lang/Logo/Matrix-multiplication new file mode 120000 index 0000000000..216805e219 --- /dev/null +++ b/Lang/Logo/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Logo \ No newline at end of file diff --git a/Lang/Logo/Menu b/Lang/Logo/Menu new file mode 120000 index 0000000000..b29326750a --- /dev/null +++ b/Lang/Logo/Menu @@ -0,0 +1 @@ +../../Task/Menu/Logo \ No newline at end of file diff --git a/Lang/Logo/Monte-Carlo-methods b/Lang/Logo/Monte-Carlo-methods new file mode 120000 index 0000000000..915bb35728 --- /dev/null +++ b/Lang/Logo/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Logo \ No newline at end of file diff --git a/Lang/Logo/Mouse-position b/Lang/Logo/Mouse-position new file mode 120000 index 0000000000..c47b33f190 --- /dev/null +++ b/Lang/Logo/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Logo \ No newline at end of file diff --git a/Lang/Logo/Multiplication-tables b/Lang/Logo/Multiplication-tables new file mode 120000 index 0000000000..70e91be921 --- /dev/null +++ b/Lang/Logo/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Logo \ No newline at end of file diff --git a/Lang/Logo/Mutual-recursion b/Lang/Logo/Mutual-recursion new file mode 120000 index 0000000000..f3c6b27158 --- /dev/null +++ b/Lang/Logo/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Logo \ No newline at end of file diff --git a/Lang/Logo/Search-a-list b/Lang/Logo/Search-a-list new file mode 120000 index 0000000000..2410e675c3 --- /dev/null +++ b/Lang/Logo/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Logo \ No newline at end of file diff --git a/Lang/Logtalk/0DESCRIPTION b/Lang/Logtalk/0DESCRIPTION new file mode 100644 index 0000000000..4b8c11cd09 --- /dev/null +++ b/Lang/Logtalk/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|Logtalk +|site=http://logtalk.org/ +}} + +Logtalk is an object-oriented logic programming language that extends the [[Prolog]] language with a feature set suitable for programming in the large. As a multi-paradigm language, it includes support for encapsulation and data hiding, separation of concerns and enhanced code reuse, both prototypes and classes, protocols (interfaces), component-based programming through category-based composition, event-driven programming, and high-level multi-threading programming. +Logtalk uses standard Prolog syntax with the addition of a few operators and directives. + +==See Also== +*[[wp:Logtalk|Wikipedia: Logtalk]] \ No newline at end of file diff --git a/Lang/Logtalk/99-Bottles-of-Beer b/Lang/Logtalk/99-Bottles-of-Beer new file mode 120000 index 0000000000..a7d6d0cafd --- /dev/null +++ b/Lang/Logtalk/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Abstract-type b/Lang/Logtalk/Abstract-type new file mode 120000 index 0000000000..7cd7ed1efb --- /dev/null +++ b/Lang/Logtalk/Abstract-type @@ -0,0 +1 @@ +../../Task/Abstract-type/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Ackermann-function b/Lang/Logtalk/Ackermann-function new file mode 120000 index 0000000000..6c736947ae --- /dev/null +++ b/Lang/Logtalk/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Character-codes b/Lang/Logtalk/Character-codes new file mode 120000 index 0000000000..0ca05691c6 --- /dev/null +++ b/Lang/Logtalk/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Classes b/Lang/Logtalk/Classes new file mode 120000 index 0000000000..ecf2a41265 --- /dev/null +++ b/Lang/Logtalk/Classes @@ -0,0 +1 @@ +../../Task/Classes/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Comments b/Lang/Logtalk/Comments new file mode 120000 index 0000000000..4f0d62e944 --- /dev/null +++ b/Lang/Logtalk/Comments @@ -0,0 +1 @@ +../../Task/Comments/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Concurrent-computing b/Lang/Logtalk/Concurrent-computing new file mode 120000 index 0000000000..f398b9f8d2 --- /dev/null +++ b/Lang/Logtalk/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Delegates b/Lang/Logtalk/Delegates new file mode 120000 index 0000000000..b426c8db18 --- /dev/null +++ b/Lang/Logtalk/Delegates @@ -0,0 +1 @@ +../../Task/Delegates/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Dining-philosophers b/Lang/Logtalk/Dining-philosophers new file mode 120000 index 0000000000..fcad83a0b6 --- /dev/null +++ b/Lang/Logtalk/Dining-philosophers @@ -0,0 +1 @@ +../../Task/Dining-philosophers/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Dot-product b/Lang/Logtalk/Dot-product new file mode 120000 index 0000000000..9f315e676b --- /dev/null +++ b/Lang/Logtalk/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Flatten-a-list b/Lang/Logtalk/Flatten-a-list new file mode 120000 index 0000000000..dc671abf3a --- /dev/null +++ b/Lang/Logtalk/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Generic-swap b/Lang/Logtalk/Generic-swap new file mode 120000 index 0000000000..a46dfdf473 --- /dev/null +++ b/Lang/Logtalk/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Greatest-element-of-a-list b/Lang/Logtalk/Greatest-element-of-a-list new file mode 120000 index 0000000000..c8cc518e5a --- /dev/null +++ b/Lang/Logtalk/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Hailstone-sequence b/Lang/Logtalk/Hailstone-sequence new file mode 120000 index 0000000000..56455dd46f --- /dev/null +++ b/Lang/Logtalk/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Hello-world-Text b/Lang/Logtalk/Hello-world-Text new file mode 120000 index 0000000000..1cfcea4a9e --- /dev/null +++ b/Lang/Logtalk/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Increment-a-numerical-string b/Lang/Logtalk/Increment-a-numerical-string new file mode 120000 index 0000000000..deabd2c81e --- /dev/null +++ b/Lang/Logtalk/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Inheritance-Multiple b/Lang/Logtalk/Inheritance-Multiple new file mode 120000 index 0000000000..a7d614df12 --- /dev/null +++ b/Lang/Logtalk/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Inheritance-Single b/Lang/Logtalk/Inheritance-Single new file mode 120000 index 0000000000..3d21fbb338 --- /dev/null +++ b/Lang/Logtalk/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Leap-year b/Lang/Logtalk/Leap-year new file mode 120000 index 0000000000..124c86d39e --- /dev/null +++ b/Lang/Logtalk/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Logtalk \ No newline at end of file diff --git a/Lang/Lolli/0DESCRIPTION b/Lang/Lolli/0DESCRIPTION new file mode 100644 index 0000000000..f25af69549 --- /dev/null +++ b/Lang/Lolli/0DESCRIPTION @@ -0,0 +1,3 @@ +{{stub}}{{language|Lolli +|site=http://www.lix.polytechnique.fr/~dale/lolli/}} +Lolli is a logic programming language based on a fragment of linear logic. \ No newline at end of file diff --git a/Lang/Lotus-123-Macro-Scripting/0DESCRIPTION b/Lang/Lotus-123-Macro-Scripting/0DESCRIPTION new file mode 100644 index 0000000000..555d0e6a4a --- /dev/null +++ b/Lang/Lotus-123-Macro-Scripting/0DESCRIPTION @@ -0,0 +1 @@ +{{Stub}}{{language}}This is the language used to create macros in Lotus 123. \ No newline at end of file diff --git a/Lang/LotusScript/0DESCRIPTION b/Lang/LotusScript/0DESCRIPTION new file mode 100644 index 0000000000..182ab5d28b --- /dev/null +++ b/Lang/LotusScript/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language|LotusScript}}LotusScript is a programming language used in Lotus Notes and other [[IBM]]/Lotus products. It is very similar to [[Visual Basic]] (code can usually be copied between languages with little modification), but has many specific built-in classes for accessing objects within the Lotus Notes/Domino environment. + +The Lotus Domino Designer application is the primary [[:Category:Integrated Development Environments|IDE]] used for developing programs in LotusScript, and also allows development in [[Java]]/[[JavaScript]] and Formula language. + +==External links== +*[http://www-128.ibm.com/developerworks/lotus/documentation/dominodesigner/ Lotus Domino Designer documentation] \ No newline at end of file diff --git a/Lang/LotusScript/Comments b/Lang/LotusScript/Comments new file mode 120000 index 0000000000..80d1b986c2 --- /dev/null +++ b/Lang/LotusScript/Comments @@ -0,0 +1 @@ +../../Task/Comments/LotusScript \ No newline at end of file diff --git a/Lang/LotusScript/Hello-world-Text b/Lang/LotusScript/Hello-world-Text new file mode 120000 index 0000000000..4dbb2f17ff --- /dev/null +++ b/Lang/LotusScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/LotusScript \ No newline at end of file diff --git a/Lang/Lout/0DESCRIPTION b/Lang/Lout/0DESCRIPTION new file mode 100644 index 0000000000..690278da2a --- /dev/null +++ b/Lang/Lout/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language +|site=http://lout.wiki.sourceforge.net/ +}} +Lout is a high-level language for document formatting. It includes facilities for typesetting complex documents containing floating figures, tables, diagrams, rotated and scaled text or graphics, footnotes, running headers, footers, an index, table of contents and bibliography, cross-references, mathematical equations and statistical graphs. Lout's capabilities can be extended with definitions which are easier to write than similar markup languages. + +Lout is multilingual, supporting (with hyphenation) Czech, Danish, Dutch, English, Finnish, French, German, Norwegian, Russia, Slovenian, Spanish and Swedish. Some of these languages are available as separate packages because they need more than the 13 standard Adobe fonts. Further languages can be added easily. + +== See Also == +[[wp:Lout_(software)|Wikipedia:Lout (software)]] \ No newline at end of file diff --git a/Lang/Lua/24-game-Solve b/Lang/Lua/24-game-Solve new file mode 120000 index 0000000000..b8178cd788 --- /dev/null +++ b/Lang/Lua/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Lua \ No newline at end of file diff --git a/Lang/Lua/Factorial b/Lang/Lua/Factorial new file mode 120000 index 0000000000..6bc657e2e0 --- /dev/null +++ b/Lang/Lua/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Lua \ No newline at end of file diff --git a/Lang/Lua/Factors-of-an-integer b/Lang/Lua/Factors-of-an-integer new file mode 120000 index 0000000000..19eb9737e1 --- /dev/null +++ b/Lang/Lua/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Lua \ No newline at end of file diff --git a/Lang/Lua/Fibonacci-sequence b/Lang/Lua/Fibonacci-sequence new file mode 120000 index 0000000000..6cddf4a04c --- /dev/null +++ b/Lang/Lua/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Lua \ No newline at end of file diff --git a/Lang/Lua/File-IO b/Lang/Lua/File-IO new file mode 120000 index 0000000000..d516c392aa --- /dev/null +++ b/Lang/Lua/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Lua \ No newline at end of file diff --git a/Lang/Lua/File-modification-time b/Lang/Lua/File-modification-time new file mode 120000 index 0000000000..7922c702d1 --- /dev/null +++ b/Lang/Lua/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Lua \ No newline at end of file diff --git a/Lang/Lua/File-size b/Lang/Lua/File-size new file mode 120000 index 0000000000..ffe935406b --- /dev/null +++ b/Lang/Lua/File-size @@ -0,0 +1 @@ +../../Task/File-size/Lua \ No newline at end of file diff --git a/Lang/Lua/Filter b/Lang/Lua/Filter new file mode 120000 index 0000000000..facc67d07f --- /dev/null +++ b/Lang/Lua/Filter @@ -0,0 +1 @@ +../../Task/Filter/Lua \ No newline at end of file diff --git a/Lang/Lua/Find-limit-of-recursion b/Lang/Lua/Find-limit-of-recursion new file mode 120000 index 0000000000..56068f207b --- /dev/null +++ b/Lang/Lua/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Lua \ No newline at end of file diff --git a/Lang/Lua/First-class-functions b/Lang/Lua/First-class-functions new file mode 120000 index 0000000000..67bc700bd5 --- /dev/null +++ b/Lang/Lua/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Lua \ No newline at end of file diff --git a/Lang/Lua/Flatten-a-list b/Lang/Lua/Flatten-a-list new file mode 120000 index 0000000000..846d1803de --- /dev/null +++ b/Lang/Lua/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Lua \ No newline at end of file diff --git a/Lang/Lua/Flow-control-structures b/Lang/Lua/Flow-control-structures new file mode 120000 index 0000000000..f1a3fcd069 --- /dev/null +++ b/Lang/Lua/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Lua \ No newline at end of file diff --git a/Lang/Lua/Floyds-triangle b/Lang/Lua/Floyds-triangle new file mode 120000 index 0000000000..4d9722274d --- /dev/null +++ b/Lang/Lua/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Lua \ No newline at end of file diff --git a/Lang/Lua/Fork b/Lang/Lua/Fork new file mode 120000 index 0000000000..1078846d8f --- /dev/null +++ b/Lang/Lua/Fork @@ -0,0 +1 @@ +../../Task/Fork/Lua \ No newline at end of file diff --git a/Lang/Lua/Formal-power-series b/Lang/Lua/Formal-power-series new file mode 120000 index 0000000000..a01a1c2ddb --- /dev/null +++ b/Lang/Lua/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Lua \ No newline at end of file diff --git a/Lang/Lua/Formatted-numeric-output b/Lang/Lua/Formatted-numeric-output new file mode 120000 index 0000000000..b642dd012c --- /dev/null +++ b/Lang/Lua/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Lua \ No newline at end of file diff --git a/Lang/Lua/Forward-difference b/Lang/Lua/Forward-difference new file mode 120000 index 0000000000..757dcac3c2 --- /dev/null +++ b/Lang/Lua/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Lua \ No newline at end of file diff --git a/Lang/Lua/Function-composition b/Lang/Lua/Function-composition new file mode 120000 index 0000000000..c9f2aae91e --- /dev/null +++ b/Lang/Lua/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Lua \ No newline at end of file diff --git a/Lang/Lua/Function-definition b/Lang/Lua/Function-definition new file mode 120000 index 0000000000..359f5a722c --- /dev/null +++ b/Lang/Lua/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Lua \ No newline at end of file diff --git a/Lang/Lua/Gamma-function b/Lang/Lua/Gamma-function new file mode 120000 index 0000000000..554969f7e9 --- /dev/null +++ b/Lang/Lua/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Lua \ No newline at end of file diff --git a/Lang/Lua/Generator-Exponential b/Lang/Lua/Generator-Exponential new file mode 120000 index 0000000000..cbf63774ea --- /dev/null +++ b/Lang/Lua/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Lua \ No newline at end of file diff --git a/Lang/Lua/Generic-swap b/Lang/Lua/Generic-swap new file mode 120000 index 0000000000..80b3702868 --- /dev/null +++ b/Lang/Lua/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Lua \ No newline at end of file diff --git a/Lang/Lua/Globally-replace-text-in-several-files b/Lang/Lua/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..97485331b5 --- /dev/null +++ b/Lang/Lua/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Lua \ No newline at end of file diff --git a/Lang/Lua/Gray-code b/Lang/Lua/Gray-code new file mode 120000 index 0000000000..85f0b98fed --- /dev/null +++ b/Lang/Lua/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Lua \ No newline at end of file diff --git a/Lang/Lua/Grayscale-image b/Lang/Lua/Grayscale-image new file mode 120000 index 0000000000..1d03f10090 --- /dev/null +++ b/Lang/Lua/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Lua \ No newline at end of file diff --git a/Lang/Lua/Greatest-common-divisor b/Lang/Lua/Greatest-common-divisor new file mode 120000 index 0000000000..5b0e9a9589 --- /dev/null +++ b/Lang/Lua/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Lua \ No newline at end of file diff --git a/Lang/Lua/Greatest-element-of-a-list b/Lang/Lua/Greatest-element-of-a-list new file mode 120000 index 0000000000..d9583996ca --- /dev/null +++ b/Lang/Lua/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Lua \ No newline at end of file diff --git a/Lang/Lua/Greatest-subsequential-sum b/Lang/Lua/Greatest-subsequential-sum new file mode 120000 index 0000000000..0e3a282cfa --- /dev/null +++ b/Lang/Lua/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Lua \ No newline at end of file diff --git a/Lang/Lua/Guess-the-number b/Lang/Lua/Guess-the-number new file mode 120000 index 0000000000..ed561de2dc --- /dev/null +++ b/Lang/Lua/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Lua \ No newline at end of file diff --git a/Lang/Lua/Guess-the-number-With-feedback b/Lang/Lua/Guess-the-number-With-feedback new file mode 120000 index 0000000000..a310b29ab8 --- /dev/null +++ b/Lang/Lua/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Lua \ No newline at end of file diff --git a/Lang/Lua/HTTP b/Lang/Lua/HTTP new file mode 120000 index 0000000000..66a0b2a5e4 --- /dev/null +++ b/Lang/Lua/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Lua \ No newline at end of file diff --git a/Lang/Lua/Hailstone-sequence b/Lang/Lua/Hailstone-sequence new file mode 120000 index 0000000000..1e09f1efa9 --- /dev/null +++ b/Lang/Lua/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Lua \ No newline at end of file diff --git a/Lang/Lua/Hamming-numbers b/Lang/Lua/Hamming-numbers new file mode 120000 index 0000000000..5082c8d06c --- /dev/null +++ b/Lang/Lua/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Happy-numbers b/Lang/Lua/Happy-numbers new file mode 120000 index 0000000000..57534a4837 --- /dev/null +++ b/Lang/Lua/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Hash-from-two-arrays b/Lang/Lua/Hash-from-two-arrays new file mode 120000 index 0000000000..91c695c628 --- /dev/null +++ b/Lang/Lua/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Lua \ No newline at end of file diff --git a/Lang/Lua/Hello-world-Graphical b/Lang/Lua/Hello-world-Graphical new file mode 120000 index 0000000000..2e91b69298 --- /dev/null +++ b/Lang/Lua/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Lua \ No newline at end of file diff --git a/Lang/Lua/Hello-world-Newline-omission b/Lang/Lua/Hello-world-Newline-omission new file mode 120000 index 0000000000..1c5de2fd6e --- /dev/null +++ b/Lang/Lua/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Lua \ No newline at end of file diff --git a/Lang/Lua/Hello-world-Standard-error b/Lang/Lua/Hello-world-Standard-error new file mode 120000 index 0000000000..7db814f89a --- /dev/null +++ b/Lang/Lua/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Lua \ No newline at end of file diff --git a/Lang/Lua/Hello-world-Text b/Lang/Lua/Hello-world-Text new file mode 120000 index 0000000000..5f2ec8bea2 --- /dev/null +++ b/Lang/Lua/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Lua \ No newline at end of file diff --git a/Lang/Lua/Here-document b/Lang/Lua/Here-document new file mode 120000 index 0000000000..8aa71e69cc --- /dev/null +++ b/Lang/Lua/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Lua \ No newline at end of file diff --git a/Lang/Lua/Higher-order-functions b/Lang/Lua/Higher-order-functions new file mode 120000 index 0000000000..70d3d3abe9 --- /dev/null +++ b/Lang/Lua/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Lua \ No newline at end of file diff --git a/Lang/Lua/Horners-rule-for-polynomial-evaluation b/Lang/Lua/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..387e5df306 --- /dev/null +++ b/Lang/Lua/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Lua \ No newline at end of file diff --git a/Lang/Lua/Hostname b/Lang/Lua/Hostname new file mode 120000 index 0000000000..7800669b6d --- /dev/null +++ b/Lang/Lua/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Lua \ No newline at end of file diff --git a/Lang/Lua/Identity-matrix b/Lang/Lua/Identity-matrix new file mode 120000 index 0000000000..489af3dcea --- /dev/null +++ b/Lang/Lua/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Lua \ No newline at end of file diff --git a/Lang/Lua/Include-a-file b/Lang/Lua/Include-a-file new file mode 120000 index 0000000000..b0bdb5d629 --- /dev/null +++ b/Lang/Lua/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Increment-a-numerical-string b/Lang/Lua/Increment-a-numerical-string new file mode 120000 index 0000000000..755583ac16 --- /dev/null +++ b/Lang/Lua/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Lua \ No newline at end of file diff --git a/Lang/Lua/Inheritance-Multiple b/Lang/Lua/Inheritance-Multiple new file mode 120000 index 0000000000..57c53a7899 --- /dev/null +++ b/Lang/Lua/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Lua \ No newline at end of file diff --git a/Lang/Lua/Input-loop b/Lang/Lua/Input-loop new file mode 120000 index 0000000000..6d69949409 --- /dev/null +++ b/Lang/Lua/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Lua \ No newline at end of file diff --git a/Lang/Lua/Integer-comparison b/Lang/Lua/Integer-comparison new file mode 120000 index 0000000000..14006bca0e --- /dev/null +++ b/Lang/Lua/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Lua \ No newline at end of file diff --git a/Lang/Lua/Integer-sequence b/Lang/Lua/Integer-sequence new file mode 120000 index 0000000000..7298f7e3d9 --- /dev/null +++ b/Lang/Lua/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Lua \ No newline at end of file diff --git a/Lang/Lua/Interactive-programming b/Lang/Lua/Interactive-programming new file mode 120000 index 0000000000..805ec0b8da --- /dev/null +++ b/Lang/Lua/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Lua \ No newline at end of file diff --git a/Lang/Lua/Introspection b/Lang/Lua/Introspection new file mode 120000 index 0000000000..683e8f8dc4 --- /dev/null +++ b/Lang/Lua/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Lua \ No newline at end of file diff --git a/Lang/Lua/Jensens-Device b/Lang/Lua/Jensens-Device new file mode 120000 index 0000000000..52c6b29641 --- /dev/null +++ b/Lang/Lua/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Lua \ No newline at end of file diff --git a/Lang/Lua/Knapsack-problem-Unbounded b/Lang/Lua/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..7a15f3d3a3 --- /dev/null +++ b/Lang/Lua/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Lua \ No newline at end of file diff --git a/Lang/Lua/Knights-tour b/Lang/Lua/Knights-tour new file mode 120000 index 0000000000..462d9b1c87 --- /dev/null +++ b/Lang/Lua/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Lua \ No newline at end of file diff --git a/Lang/Lua/Leap-year b/Lang/Lua/Leap-year new file mode 120000 index 0000000000..c7874b8370 --- /dev/null +++ b/Lang/Lua/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Lua \ No newline at end of file diff --git a/Lang/Lua/Least-common-multiple b/Lang/Lua/Least-common-multiple new file mode 120000 index 0000000000..587bc7cb09 --- /dev/null +++ b/Lang/Lua/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Lua \ No newline at end of file diff --git a/Lang/Lua/Letter-frequency b/Lang/Lua/Letter-frequency new file mode 120000 index 0000000000..3cbb51f7a0 --- /dev/null +++ b/Lang/Lua/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Lua \ No newline at end of file diff --git a/Lang/Lua/Levenshtein-distance b/Lang/Lua/Levenshtein-distance new file mode 120000 index 0000000000..63bd950fd5 --- /dev/null +++ b/Lang/Lua/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Lua \ No newline at end of file diff --git a/Lang/Lua/List-comprehensions b/Lang/Lua/List-comprehensions new file mode 120000 index 0000000000..83409d689d --- /dev/null +++ b/Lang/Lua/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Lua \ No newline at end of file diff --git a/Lang/Lua/Literals-Floating-point b/Lang/Lua/Literals-Floating-point new file mode 120000 index 0000000000..192edec601 --- /dev/null +++ b/Lang/Lua/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Lua \ No newline at end of file diff --git a/Lang/Lua/Literals-Integer b/Lang/Lua/Literals-Integer new file mode 120000 index 0000000000..68b0205022 --- /dev/null +++ b/Lang/Lua/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Lua \ No newline at end of file diff --git a/Lang/Lua/Literals-String b/Lang/Lua/Literals-String new file mode 120000 index 0000000000..8aedfd2412 --- /dev/null +++ b/Lang/Lua/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Lua \ No newline at end of file diff --git a/Lang/Lua/Logical-operations b/Lang/Lua/Logical-operations new file mode 120000 index 0000000000..bc7f6a23e6 --- /dev/null +++ b/Lang/Lua/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Lua \ No newline at end of file diff --git a/Lang/Lua/Longest-common-subsequence b/Lang/Lua/Longest-common-subsequence new file mode 120000 index 0000000000..510d99b364 --- /dev/null +++ b/Lang/Lua/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Lua \ No newline at end of file diff --git a/Lang/Lua/Look-and-say-sequence b/Lang/Lua/Look-and-say-sequence new file mode 120000 index 0000000000..322cf3156f --- /dev/null +++ b/Lang/Lua/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Lua \ No newline at end of file diff --git a/Lang/Lua/Loop-over-multiple-arrays-simultaneously b/Lang/Lua/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..8f10bb2d29 --- /dev/null +++ b/Lang/Lua/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Break b/Lang/Lua/Loops-Break new file mode 120000 index 0000000000..1b3ea7faef --- /dev/null +++ b/Lang/Lua/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Continue b/Lang/Lua/Loops-Continue new file mode 120000 index 0000000000..d4653fc48d --- /dev/null +++ b/Lang/Lua/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Do-while b/Lang/Lua/Loops-Do-while new file mode 120000 index 0000000000..4f7133a672 --- /dev/null +++ b/Lang/Lua/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Downward-for b/Lang/Lua/Loops-Downward-for new file mode 120000 index 0000000000..28bd39ecf0 --- /dev/null +++ b/Lang/Lua/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-For b/Lang/Lua/Loops-For new file mode 120000 index 0000000000..6f748922ce --- /dev/null +++ b/Lang/Lua/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-For-with-a-specified-step b/Lang/Lua/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..5d944e3c42 --- /dev/null +++ b/Lang/Lua/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Foreach b/Lang/Lua/Loops-Foreach new file mode 120000 index 0000000000..cb677b01f1 --- /dev/null +++ b/Lang/Lua/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Infinite b/Lang/Lua/Loops-Infinite new file mode 120000 index 0000000000..4315e5eb90 --- /dev/null +++ b/Lang/Lua/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-N-plus-one-half b/Lang/Lua/Loops-N-plus-one-half new file mode 120000 index 0000000000..d2e6395892 --- /dev/null +++ b/Lang/Lua/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-Nested b/Lang/Lua/Loops-Nested new file mode 120000 index 0000000000..442e9c74b3 --- /dev/null +++ b/Lang/Lua/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Lua \ No newline at end of file diff --git a/Lang/Lua/Loops-While b/Lang/Lua/Loops-While new file mode 120000 index 0000000000..97d52c6080 --- /dev/null +++ b/Lang/Lua/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Lua \ No newline at end of file diff --git a/Lang/Lua/Luhn-test-of-credit-card-numbers b/Lang/Lua/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..d3fb588456 --- /dev/null +++ b/Lang/Lua/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/MD5 b/Lang/Lua/MD5 new file mode 120000 index 0000000000..9ed11d698e --- /dev/null +++ b/Lang/Lua/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Lua \ No newline at end of file diff --git a/Lang/Lua/Man-or-boy-test b/Lang/Lua/Man-or-boy-test new file mode 120000 index 0000000000..ca7f689958 --- /dev/null +++ b/Lang/Lua/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Lua \ No newline at end of file diff --git a/Lang/Lua/Map-range b/Lang/Lua/Map-range new file mode 120000 index 0000000000..5b0bdff4e7 --- /dev/null +++ b/Lang/Lua/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Lua \ No newline at end of file diff --git a/Lang/Lua/Matrix-exponentiation-operator b/Lang/Lua/Matrix-exponentiation-operator new file mode 120000 index 0000000000..f186767436 --- /dev/null +++ b/Lang/Lua/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Lua \ No newline at end of file diff --git a/Lang/Lua/Matrix-multiplication b/Lang/Lua/Matrix-multiplication new file mode 120000 index 0000000000..a728a608b1 --- /dev/null +++ b/Lang/Lua/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Lua \ No newline at end of file diff --git a/Lang/Lua/Matrix-transposition b/Lang/Lua/Matrix-transposition new file mode 120000 index 0000000000..856dc270c1 --- /dev/null +++ b/Lang/Lua/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Lua \ No newline at end of file diff --git a/Lang/Lua/Menu b/Lang/Lua/Menu new file mode 120000 index 0000000000..cfd70ac959 --- /dev/null +++ b/Lang/Lua/Menu @@ -0,0 +1 @@ +../../Task/Menu/Lua \ No newline at end of file diff --git a/Lang/Lua/Metaprogramming b/Lang/Lua/Metaprogramming new file mode 120000 index 0000000000..2c2ad56748 --- /dev/null +++ b/Lang/Lua/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/Lua \ No newline at end of file diff --git a/Lang/Lua/Middle-three-digits b/Lang/Lua/Middle-three-digits new file mode 120000 index 0000000000..fb5a494075 --- /dev/null +++ b/Lang/Lua/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Lua \ No newline at end of file diff --git a/Lang/Lua/Monte-Carlo-methods b/Lang/Lua/Monte-Carlo-methods new file mode 120000 index 0000000000..b99eff3558 --- /dev/null +++ b/Lang/Lua/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Lua \ No newline at end of file diff --git a/Lang/Lua/Monty-Hall-problem b/Lang/Lua/Monty-Hall-problem new file mode 120000 index 0000000000..16c9a5b5ce --- /dev/null +++ b/Lang/Lua/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Lua \ No newline at end of file diff --git a/Lang/Lua/Multiplication-tables b/Lang/Lua/Multiplication-tables new file mode 120000 index 0000000000..1b7058e3be --- /dev/null +++ b/Lang/Lua/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Lua \ No newline at end of file diff --git a/Lang/Lua/Mutual-recursion b/Lang/Lua/Mutual-recursion new file mode 120000 index 0000000000..295d45a2f1 --- /dev/null +++ b/Lang/Lua/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Lua \ No newline at end of file diff --git a/Lang/Lucid/0DESCRIPTION b/Lang/Lucid/0DESCRIPTION new file mode 100644 index 0000000000..77c793dd37 --- /dev/null +++ b/Lang/Lucid/0DESCRIPTION @@ -0,0 +1,5 @@ +{{language|Lucid +|strength=strong +|safety=safe +|checking=dynamic +|LCT=yes}}The oldest dataflow programming language. It belongs to the ISWIM family of languages. The computations are expressed as manipulations of sequences (much like the [[Unix pipes]] model of computation.). \ No newline at end of file diff --git a/Lang/Lucid/99-Bottles-of-Beer b/Lang/Lucid/99-Bottles-of-Beer new file mode 120000 index 0000000000..9857bc9cf7 --- /dev/null +++ b/Lang/Lucid/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Lucid \ No newline at end of file diff --git a/Lang/Lucid/Ackermann-function b/Lang/Lucid/Ackermann-function new file mode 120000 index 0000000000..ec64374c10 --- /dev/null +++ b/Lang/Lucid/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Lucid \ No newline at end of file diff --git a/Lang/Lucid/Averages-Arithmetic-mean b/Lang/Lucid/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b7d9d1767b --- /dev/null +++ b/Lang/Lucid/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Lucid \ No newline at end of file diff --git a/Lang/Lucid/Exponentiation-operator b/Lang/Lucid/Exponentiation-operator new file mode 120000 index 0000000000..050f902f20 --- /dev/null +++ b/Lang/Lucid/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Lucid \ No newline at end of file diff --git a/Lang/Lucid/Function-definition b/Lang/Lucid/Function-definition new file mode 120000 index 0000000000..1f8668ca80 --- /dev/null +++ b/Lang/Lucid/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Lucid \ No newline at end of file diff --git a/Lang/Lucid/Greatest-common-divisor b/Lang/Lucid/Greatest-common-divisor new file mode 120000 index 0000000000..88d17b8f4b --- /dev/null +++ b/Lang/Lucid/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Lucid \ No newline at end of file diff --git a/Lang/Lush/0DESCRIPTION b/Lang/Lush/0DESCRIPTION new file mode 100644 index 0000000000..f593389b79 --- /dev/null +++ b/Lang/Lush/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|lush +|site=http://lush.sourceforge.net/ +}} + +Lush, ([[Lisp]] Universal Shell), is an object-oriented dialect of the [[Lisp]] programming language that was initially developed as a scripting language for machine learning applications, as well as numerical and graphical applications, but can also be used for general purpose, systems, and network programming or administration tasks. It compiles to native [[C]] code and includes a multidimensional-array processing engine.[[#Citation|[1]]] + +==Citations== +#[[wp:Lush_(programming_language)|Wikipedea : Lush]] \ No newline at end of file diff --git a/Lang/Lygon/0DESCRIPTION b/Lang/Lygon/0DESCRIPTION new file mode 100644 index 0000000000..92911e75e1 --- /dev/null +++ b/Lang/Lygon/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}}{{language|Lygon +|site=http://www.cs.rmit.edu.au/lygon/}} +Lygon is a logic programming language that is based on linear logic. It can be viewed as [[Prolog]] extended with features derived from linear logic. These features include a declarative notion of state and the ability to express problems involving concurrency. Also, the availability of use once predicates allows simple solutions to problems such as graph manipulation. Although the design of Lygon relies on a delicate proof-theoretic analysis of linear logic, programmers need have no knowledge of proof theory. + +Linear logic can be used to model the consumption of resources. Whereas clauses in Prolog, based on classical logic, can be used many times during the execution of a program, clauses in Lygon, based on linear logic, must (by default) be used exactly once. Since both classical and intuitionistic logic can be embedded in linear logic, Lygon generalizes pure Prolog. Indeed, pure Prolog code (Edinburgh syntax) can be executed by Lygon's interpreter. \ No newline at end of file diff --git a/Lang/M4/0DESCRIPTION b/Lang/M4/0DESCRIPTION new file mode 100644 index 0000000000..0606c24af4 --- /dev/null +++ b/Lang/M4/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|exec=interpreted}} +‘m4’ is a macro processor, in the sense that it copies its input to the output, expanding macros as it goes. Macros are either builtin or user-defined, and can take any number of arguments. Besides just doing macro expansion, ‘m4’ has builtin functions for including named files, running shell commands, doing integer arithmetic, manipulating text in various ways, performing recursion, etc.... ‘m4’ can be used either as a front-end to a compiler, or as a macro processor in its own right. + +(Excerpt from the GNU info page of m4) + +One implementation of this Unix macro processor m4 is the GNU m4 + +* [[wp:m4 (computer language)|m4 on wikipedia]] +* [http://www.gnu.org/software/m4/ GNU m4] \ No newline at end of file diff --git a/Lang/M4/100-doors b/Lang/M4/100-doors new file mode 120000 index 0000000000..c5bbced3c8 --- /dev/null +++ b/Lang/M4/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/M4 \ No newline at end of file diff --git a/Lang/M4/99-Bottles-of-Beer b/Lang/M4/99-Bottles-of-Beer new file mode 120000 index 0000000000..2d1f8196ff --- /dev/null +++ b/Lang/M4/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/M4 \ No newline at end of file diff --git a/Lang/M4/Ackermann-function b/Lang/M4/Ackermann-function new file mode 120000 index 0000000000..7ece3fd573 --- /dev/null +++ b/Lang/M4/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/M4 \ No newline at end of file diff --git a/Lang/M4/Anagrams b/Lang/M4/Anagrams new file mode 120000 index 0000000000..8d72b5f808 --- /dev/null +++ b/Lang/M4/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/M4 \ No newline at end of file diff --git a/Lang/M4/Apply-a-callback-to-an-array b/Lang/M4/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..24719cf49a --- /dev/null +++ b/Lang/M4/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/M4 \ No newline at end of file diff --git a/Lang/M4/Arithmetic-Integer b/Lang/M4/Arithmetic-Integer new file mode 120000 index 0000000000..2c7401c1b7 --- /dev/null +++ b/Lang/M4/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/M4 \ No newline at end of file diff --git a/Lang/M4/Associative-array-Iteration b/Lang/M4/Associative-array-Iteration new file mode 120000 index 0000000000..3f6451f56f --- /dev/null +++ b/Lang/M4/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/M4 \ No newline at end of file diff --git a/Lang/M4/Averages-Arithmetic-mean b/Lang/M4/Averages-Arithmetic-mean new file mode 120000 index 0000000000..1e19c42f34 --- /dev/null +++ b/Lang/M4/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/M4 \ No newline at end of file diff --git a/Lang/M4/Binary-search b/Lang/M4/Binary-search new file mode 120000 index 0000000000..04e489eb7f --- /dev/null +++ b/Lang/M4/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/M4 \ No newline at end of file diff --git a/Lang/M4/Combinations b/Lang/M4/Combinations new file mode 120000 index 0000000000..357419f955 --- /dev/null +++ b/Lang/M4/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/M4 \ No newline at end of file diff --git a/Lang/M4/Comments b/Lang/M4/Comments new file mode 120000 index 0000000000..0e57679d42 --- /dev/null +++ b/Lang/M4/Comments @@ -0,0 +1 @@ +../../Task/Comments/M4 \ No newline at end of file diff --git a/Lang/M4/Day-of-the-week b/Lang/M4/Day-of-the-week new file mode 120000 index 0000000000..4c93017b50 --- /dev/null +++ b/Lang/M4/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/M4 \ No newline at end of file diff --git a/Lang/M4/Detect-division-by-zero b/Lang/M4/Detect-division-by-zero new file mode 120000 index 0000000000..aece2852bd --- /dev/null +++ b/Lang/M4/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/M4 \ No newline at end of file diff --git a/Lang/M4/Dynamic-variable-names b/Lang/M4/Dynamic-variable-names new file mode 120000 index 0000000000..16135ae00f --- /dev/null +++ b/Lang/M4/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/M4 \ No newline at end of file diff --git a/Lang/M4/Empty-program b/Lang/M4/Empty-program new file mode 120000 index 0000000000..3ce502532c --- /dev/null +++ b/Lang/M4/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/M4 \ No newline at end of file diff --git a/Lang/M4/Enumerations b/Lang/M4/Enumerations new file mode 120000 index 0000000000..b68926985e --- /dev/null +++ b/Lang/M4/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/M4 \ No newline at end of file diff --git a/Lang/M4/Execute-a-system-command b/Lang/M4/Execute-a-system-command new file mode 120000 index 0000000000..917022d555 --- /dev/null +++ b/Lang/M4/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/M4 \ No newline at end of file diff --git a/Lang/M4/Exponentiation-operator b/Lang/M4/Exponentiation-operator new file mode 120000 index 0000000000..abfcb0ecdd --- /dev/null +++ b/Lang/M4/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/M4 \ No newline at end of file diff --git a/Lang/M4/Factorial b/Lang/M4/Factorial new file mode 120000 index 0000000000..8ad354b60a --- /dev/null +++ b/Lang/M4/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/M4 \ No newline at end of file diff --git a/Lang/M4/Fibonacci-sequence b/Lang/M4/Fibonacci-sequence new file mode 120000 index 0000000000..c93477f9cc --- /dev/null +++ b/Lang/M4/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/M4 \ No newline at end of file diff --git a/Lang/M4/FizzBuzz b/Lang/M4/FizzBuzz new file mode 120000 index 0000000000..ffd7735c08 --- /dev/null +++ b/Lang/M4/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/M4 \ No newline at end of file diff --git a/Lang/M4/Function-definition b/Lang/M4/Function-definition new file mode 120000 index 0000000000..87ebb440e8 --- /dev/null +++ b/Lang/M4/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/M4 \ No newline at end of file diff --git a/Lang/M4/Generic-swap b/Lang/M4/Generic-swap new file mode 120000 index 0000000000..26223a51d7 --- /dev/null +++ b/Lang/M4/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/M4 \ No newline at end of file diff --git a/Lang/M4/Greatest-subsequential-sum b/Lang/M4/Greatest-subsequential-sum new file mode 120000 index 0000000000..b89d565637 --- /dev/null +++ b/Lang/M4/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/M4 \ No newline at end of file diff --git a/Lang/M4/Hello-world-Text b/Lang/M4/Hello-world-Text new file mode 120000 index 0000000000..3aada0248b --- /dev/null +++ b/Lang/M4/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/M4 \ No newline at end of file diff --git a/Lang/M4/Increment-a-numerical-string b/Lang/M4/Increment-a-numerical-string new file mode 120000 index 0000000000..0dd6e57ece --- /dev/null +++ b/Lang/M4/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/M4 \ No newline at end of file diff --git a/Lang/M4/Interactive-programming b/Lang/M4/Interactive-programming new file mode 120000 index 0000000000..4fc6aa12b6 --- /dev/null +++ b/Lang/M4/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/M4 \ No newline at end of file diff --git a/Lang/M4/Jensens-Device b/Lang/M4/Jensens-Device new file mode 120000 index 0000000000..e538214422 --- /dev/null +++ b/Lang/M4/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/M4 \ No newline at end of file diff --git a/Lang/M4/Knapsack-problem-Unbounded b/Lang/M4/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..06b25a41f4 --- /dev/null +++ b/Lang/M4/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/M4 \ No newline at end of file diff --git a/Lang/M4/Knuth-shuffle b/Lang/M4/Knuth-shuffle new file mode 120000 index 0000000000..486b37260b --- /dev/null +++ b/Lang/M4/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/M4 \ No newline at end of file diff --git a/Lang/M4/Literals-Integer b/Lang/M4/Literals-Integer new file mode 120000 index 0000000000..12c5149a10 --- /dev/null +++ b/Lang/M4/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/M4 \ No newline at end of file diff --git a/Lang/M4/Literals-String b/Lang/M4/Literals-String new file mode 120000 index 0000000000..d07f63abf6 --- /dev/null +++ b/Lang/M4/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/M4 \ No newline at end of file diff --git a/Lang/M4/Logical-operations b/Lang/M4/Logical-operations new file mode 120000 index 0000000000..67c8167bb5 --- /dev/null +++ b/Lang/M4/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/M4 \ No newline at end of file diff --git a/Lang/M4/Longest-common-subsequence b/Lang/M4/Longest-common-subsequence new file mode 120000 index 0000000000..b0f248be40 --- /dev/null +++ b/Lang/M4/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/M4 \ No newline at end of file diff --git a/Lang/M4/Look-and-say-sequence b/Lang/M4/Look-and-say-sequence new file mode 120000 index 0000000000..9e0b830629 --- /dev/null +++ b/Lang/M4/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-Break b/Lang/M4/Loops-Break new file mode 120000 index 0000000000..f3201eb012 --- /dev/null +++ b/Lang/M4/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-Downward-for b/Lang/M4/Loops-Downward-for new file mode 120000 index 0000000000..730e230187 --- /dev/null +++ b/Lang/M4/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-For b/Lang/M4/Loops-For new file mode 120000 index 0000000000..b9974b4e82 --- /dev/null +++ b/Lang/M4/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-For-with-a-specified-step b/Lang/M4/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..9a65c8ce0c --- /dev/null +++ b/Lang/M4/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-Infinite b/Lang/M4/Loops-Infinite new file mode 120000 index 0000000000..ad3d7b6a99 --- /dev/null +++ b/Lang/M4/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/M4 \ No newline at end of file diff --git a/Lang/M4/Loops-N-plus-one-half b/Lang/M4/Loops-N-plus-one-half new file mode 120000 index 0000000000..fe1aff0792 --- /dev/null +++ b/Lang/M4/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/M4 \ No newline at end of file diff --git a/Lang/M4/Mutual-recursion b/Lang/M4/Mutual-recursion new file mode 120000 index 0000000000..a2caf754c0 --- /dev/null +++ b/Lang/M4/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/M4 \ No newline at end of file diff --git a/Lang/M4/Quine b/Lang/M4/Quine new file mode 120000 index 0000000000..3c8bb1aa7a --- /dev/null +++ b/Lang/M4/Quine @@ -0,0 +1 @@ +../../Task/Quine/M4 \ No newline at end of file diff --git a/Lang/M680x0/0DESCRIPTION b/Lang/M680x0/0DESCRIPTION new file mode 100644 index 0000000000..160782dc7d --- /dev/null +++ b/Lang/M680x0/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{stub}}[[Category:Assembly]] \ No newline at end of file diff --git a/Lang/MAPPER/0DESCRIPTION b/Lang/MAPPER/0DESCRIPTION new file mode 100644 index 0000000000..917d77c8ef --- /dev/null +++ b/Lang/MAPPER/0DESCRIPTION @@ -0,0 +1,46 @@ +{{language|MAPPER +|site=http://www.unisys.com/unisys/product/productdetail.jsp?id=1120000160000010000&pid=1120000970018210161&sid=2800008 +|parampass=both +|strength=weak +|safety=weak +|gc=no +|checking=dynamic +|LCT=no +|exec=interpreted}} + + +MAPPER (also more recently known as BIS) was originally a product of the Sperry Corporation and was a mainframe product implemented on the Sperry 1100 systems. + +After the merger of Sperry and Burroughs to create the Unisys Corporation, MAPPER was implemented on additional platforms, and is today available on + +#Unisys 2200 mainframe +#[[Windows]] Server +#[[Sun]] [[Solaris]] +#[[Linux]] + +At various times MAPPER has been available on a number of Unix implementations, including [[IBM]] AIX, and on the Unisys A-Series mainframes. + +MAPPER was initially created for the Sperry engineers' internal use. +The first commercial customer was the Aitcheson, Topeka and Santa Fe Railroad Company. + +During the early 90s, Windows MAPPER was given an optional web-enablement layer, called CoolICE (where ICE means ''I''nternet ''C''ommerce ''E''nabler), +today generally just abbreviated to ICE. + +'''See Also:''' +*http://www.unisys.com/unisys/product/productdetail.jsp?id=1120000160000010000&pid=1120000970018210161&sid=2800008 + +MAPPER is a 4GL based on a "filing cabinet" paradigm. Data is organised into a series of numbered "cabinets", each of which contains up to 8 "drawers" (B to I), each of which may contain up to 5,000 "reports". Drawer "A" is special- it is a shared area, conceptually present in all cabinets simultaneously. Cabinets are referenced in pairs, e.g. cabinet 0 and cabinet 1 are the same dataset, but if referenced as the "odd" cabinet, the view of the data is read-only. + +A report is a column-oriented grid of fixed-length fields, similar in some ways to a spreadsheet, in that there are columns and rows and a set of headers. + +Many operations on reports create a result, which is a non-permanent report with the same structure as a report. In manual functions, there is only one result possible, but runs (scripts) can support up to 17 results, which are referenced the same way as reports but with a negative report-ID. The result created by an operation is "-0", but these can be saved to -1 to -16 inclusive by the "rename" (@rnm) function. This allows runs to perform powerful match, blend and reformat instructions. + +The MAPPER language is an interpreted scripting language, and is held within the MAPPER database, in reports. An application in MAPPER is commonly held in reports, within drawers, within a cabinet, or within a series of consecutive cabinets. + +While an interpreted language, MAPPER is reasonably quick as the atoms themselves are quite powerful- sort, search, match, count etc are all atoms of the language (which are written in C++ or MASM, depending on platform). + +The typing in MAPPER script is very simple: the types are primitive (integer, real, string) and no constructs or similar complex classes are supported. One-dimensional arrays are supported, arrays of higher dimension would have to simulated in code. + +Complex data structures would need to be held in reports or results. + +As an alternative, MAPPER may be scripted using JavaScript, and the environment contains its own embedded JavaScript interpreter, with some extensions to reference reports etc as recordset objects, and methods which map onto the atoms of the native scripting language. \ No newline at end of file diff --git a/Lang/MATLAB/Arbitrary-precision-integers-included b/Lang/MATLAB/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..cf35fb8cd2 --- /dev/null +++ b/Lang/MATLAB/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Factorial b/Lang/MATLAB/Factorial new file mode 120000 index 0000000000..d968e761f3 --- /dev/null +++ b/Lang/MATLAB/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Factors-of-an-integer b/Lang/MATLAB/Factors-of-an-integer new file mode 120000 index 0000000000..fe3293b6b8 --- /dev/null +++ b/Lang/MATLAB/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Fast-Fourier-transform b/Lang/MATLAB/Fast-Fourier-transform new file mode 120000 index 0000000000..2533371827 --- /dev/null +++ b/Lang/MATLAB/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Fibonacci-sequence b/Lang/MATLAB/Fibonacci-sequence new file mode 120000 index 0000000000..8d1091553a --- /dev/null +++ b/Lang/MATLAB/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/File-modification-time b/Lang/MATLAB/File-modification-time new file mode 120000 index 0000000000..c03885b5a5 --- /dev/null +++ b/Lang/MATLAB/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/File-size b/Lang/MATLAB/File-size new file mode 120000 index 0000000000..21de674198 --- /dev/null +++ b/Lang/MATLAB/File-size @@ -0,0 +1 @@ +../../Task/File-size/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Filter b/Lang/MATLAB/Filter new file mode 120000 index 0000000000..0da23f0132 --- /dev/null +++ b/Lang/MATLAB/Filter @@ -0,0 +1 @@ +../../Task/Filter/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Find-limit-of-recursion b/Lang/MATLAB/Find-limit-of-recursion new file mode 120000 index 0000000000..0a6243ef54 --- /dev/null +++ b/Lang/MATLAB/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Find-the-missing-permutation b/Lang/MATLAB/Find-the-missing-permutation new file mode 120000 index 0000000000..c0f1b66d73 --- /dev/null +++ b/Lang/MATLAB/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Formatted-numeric-output b/Lang/MATLAB/Formatted-numeric-output new file mode 120000 index 0000000000..4c11dee1f4 --- /dev/null +++ b/Lang/MATLAB/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Forward-difference b/Lang/MATLAB/Forward-difference new file mode 120000 index 0000000000..34db9097e9 --- /dev/null +++ b/Lang/MATLAB/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Four-bit-adder b/Lang/MATLAB/Four-bit-adder new file mode 120000 index 0000000000..eeedf4f9c5 --- /dev/null +++ b/Lang/MATLAB/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Function-definition b/Lang/MATLAB/Function-definition new file mode 120000 index 0000000000..007258e587 --- /dev/null +++ b/Lang/MATLAB/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Generic-swap b/Lang/MATLAB/Generic-swap new file mode 120000 index 0000000000..4ba5de8754 --- /dev/null +++ b/Lang/MATLAB/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Grayscale-image b/Lang/MATLAB/Grayscale-image new file mode 120000 index 0000000000..4907f526d7 --- /dev/null +++ b/Lang/MATLAB/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Greatest-common-divisor b/Lang/MATLAB/Greatest-common-divisor new file mode 120000 index 0000000000..8239171556 --- /dev/null +++ b/Lang/MATLAB/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Greatest-element-of-a-list b/Lang/MATLAB/Greatest-element-of-a-list new file mode 120000 index 0000000000..4c53849e3d --- /dev/null +++ b/Lang/MATLAB/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Guess-the-number b/Lang/MATLAB/Guess-the-number new file mode 120000 index 0000000000..1411f074ad --- /dev/null +++ b/Lang/MATLAB/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/HTTP b/Lang/MATLAB/HTTP new file mode 120000 index 0000000000..ef2489fd79 --- /dev/null +++ b/Lang/MATLAB/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hailstone-sequence b/Lang/MATLAB/Hailstone-sequence new file mode 120000 index 0000000000..ff97443386 --- /dev/null +++ b/Lang/MATLAB/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Haversine-formula b/Lang/MATLAB/Haversine-formula new file mode 120000 index 0000000000..4f57677927 --- /dev/null +++ b/Lang/MATLAB/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hello-world-Graphical b/Lang/MATLAB/Hello-world-Graphical new file mode 120000 index 0000000000..4e9ce280c5 --- /dev/null +++ b/Lang/MATLAB/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hello-world-Line-printer b/Lang/MATLAB/Hello-world-Line-printer new file mode 120000 index 0000000000..386f7e4c7f --- /dev/null +++ b/Lang/MATLAB/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hello-world-Standard-error b/Lang/MATLAB/Hello-world-Standard-error new file mode 120000 index 0000000000..691d7468ce --- /dev/null +++ b/Lang/MATLAB/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hello-world-Text b/Lang/MATLAB/Hello-world-Text new file mode 120000 index 0000000000..b65753b386 --- /dev/null +++ b/Lang/MATLAB/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hofstadter-Conway-$10,000-sequence b/Lang/MATLAB/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..4b26ba2874 --- /dev/null +++ b/Lang/MATLAB/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hofstadter-Figure-Figure-sequences b/Lang/MATLAB/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..11a3970e09 --- /dev/null +++ b/Lang/MATLAB/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hofstadter-Q-sequence b/Lang/MATLAB/Hofstadter-Q-sequence new file mode 120000 index 0000000000..da2cdc9fa2 --- /dev/null +++ b/Lang/MATLAB/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Horners-rule-for-polynomial-evaluation b/Lang/MATLAB/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..df202c2c04 --- /dev/null +++ b/Lang/MATLAB/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Host-introspection b/Lang/MATLAB/Host-introspection new file mode 120000 index 0000000000..a3993af2fd --- /dev/null +++ b/Lang/MATLAB/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Hostname b/Lang/MATLAB/Hostname new file mode 120000 index 0000000000..46610869b0 --- /dev/null +++ b/Lang/MATLAB/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Increment-a-numerical-string b/Lang/MATLAB/Increment-a-numerical-string new file mode 120000 index 0000000000..20fdf250c4 --- /dev/null +++ b/Lang/MATLAB/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Integer-sequence b/Lang/MATLAB/Integer-sequence new file mode 120000 index 0000000000..c1172ad0dd --- /dev/null +++ b/Lang/MATLAB/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Interactive-programming b/Lang/MATLAB/Interactive-programming new file mode 120000 index 0000000000..53469ba09d --- /dev/null +++ b/Lang/MATLAB/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Introspection b/Lang/MATLAB/Introspection new file mode 120000 index 0000000000..3a16af5d4f --- /dev/null +++ b/Lang/MATLAB/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/LU-decomposition b/Lang/MATLAB/LU-decomposition new file mode 120000 index 0000000000..30d63f34b9 --- /dev/null +++ b/Lang/MATLAB/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Last-Friday-of-each-month b/Lang/MATLAB/Last-Friday-of-each-month new file mode 120000 index 0000000000..a68bb43ca9 --- /dev/null +++ b/Lang/MATLAB/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Leap-year b/Lang/MATLAB/Leap-year new file mode 120000 index 0000000000..3698705bf7 --- /dev/null +++ b/Lang/MATLAB/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Least-common-multiple b/Lang/MATLAB/Least-common-multiple new file mode 120000 index 0000000000..e06db4b416 --- /dev/null +++ b/Lang/MATLAB/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/List-comprehensions b/Lang/MATLAB/List-comprehensions new file mode 120000 index 0000000000..59e87d33a2 --- /dev/null +++ b/Lang/MATLAB/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Literals-String b/Lang/MATLAB/Literals-String new file mode 120000 index 0000000000..2568cafab4 --- /dev/null +++ b/Lang/MATLAB/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Longest-string-challenge b/Lang/MATLAB/Longest-string-challenge new file mode 120000 index 0000000000..a8b3d3b914 --- /dev/null +++ b/Lang/MATLAB/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Continue b/Lang/MATLAB/Loops-Continue new file mode 120000 index 0000000000..adea1dd2f8 --- /dev/null +++ b/Lang/MATLAB/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Do-while b/Lang/MATLAB/Loops-Do-while new file mode 120000 index 0000000000..4bd92f2f54 --- /dev/null +++ b/Lang/MATLAB/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Downward-for b/Lang/MATLAB/Loops-Downward-for new file mode 120000 index 0000000000..f22fde2b1b --- /dev/null +++ b/Lang/MATLAB/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-For b/Lang/MATLAB/Loops-For new file mode 120000 index 0000000000..559a6c5da4 --- /dev/null +++ b/Lang/MATLAB/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-For-with-a-specified-step b/Lang/MATLAB/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..36e378d2cd --- /dev/null +++ b/Lang/MATLAB/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Foreach b/Lang/MATLAB/Loops-Foreach new file mode 120000 index 0000000000..cbe0d64bb5 --- /dev/null +++ b/Lang/MATLAB/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Infinite b/Lang/MATLAB/Loops-Infinite new file mode 120000 index 0000000000..d6f70de399 --- /dev/null +++ b/Lang/MATLAB/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-N-plus-one-half b/Lang/MATLAB/Loops-N-plus-one-half new file mode 120000 index 0000000000..0abfc1fa16 --- /dev/null +++ b/Lang/MATLAB/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-Nested b/Lang/MATLAB/Loops-Nested new file mode 120000 index 0000000000..cbdfaba352 --- /dev/null +++ b/Lang/MATLAB/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Loops-While b/Lang/MATLAB/Loops-While new file mode 120000 index 0000000000..96373e88e8 --- /dev/null +++ b/Lang/MATLAB/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Lucas-Lehmer-test b/Lang/MATLAB/Lucas-Lehmer-test new file mode 120000 index 0000000000..116ec240b4 --- /dev/null +++ b/Lang/MATLAB/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Luhn-test-of-credit-card-numbers b/Lang/MATLAB/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..6daa7c6263 --- /dev/null +++ b/Lang/MATLAB/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/MD5 b/Lang/MATLAB/MD5 new file mode 120000 index 0000000000..89397ab9ef --- /dev/null +++ b/Lang/MATLAB/MD5 @@ -0,0 +1 @@ +../../Task/MD5/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Mandelbrot-set b/Lang/MATLAB/Mandelbrot-set new file mode 120000 index 0000000000..62d4b8e13e --- /dev/null +++ b/Lang/MATLAB/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Matrix-exponentiation-operator b/Lang/MATLAB/Matrix-exponentiation-operator new file mode 120000 index 0000000000..8671ab725c --- /dev/null +++ b/Lang/MATLAB/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Matrix-multiplication b/Lang/MATLAB/Matrix-multiplication new file mode 120000 index 0000000000..323ce7f523 --- /dev/null +++ b/Lang/MATLAB/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Matrix-transposition b/Lang/MATLAB/Matrix-transposition new file mode 120000 index 0000000000..cfe7333119 --- /dev/null +++ b/Lang/MATLAB/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Maze-generation b/Lang/MATLAB/Maze-generation new file mode 120000 index 0000000000..dbf7a69a44 --- /dev/null +++ b/Lang/MATLAB/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Memory-allocation b/Lang/MATLAB/Memory-allocation new file mode 120000 index 0000000000..d8e24b5777 --- /dev/null +++ b/Lang/MATLAB/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Memory-layout-of-a-data-structure b/Lang/MATLAB/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..a5291fae17 --- /dev/null +++ b/Lang/MATLAB/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Menu b/Lang/MATLAB/Menu new file mode 120000 index 0000000000..e06831afb6 --- /dev/null +++ b/Lang/MATLAB/Menu @@ -0,0 +1 @@ +../../Task/Menu/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Monte-Carlo-methods b/Lang/MATLAB/Monte-Carlo-methods new file mode 120000 index 0000000000..64e1e03eb6 --- /dev/null +++ b/Lang/MATLAB/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Monty-Hall-problem b/Lang/MATLAB/Monty-Hall-problem new file mode 120000 index 0000000000..e84ccc83eb --- /dev/null +++ b/Lang/MATLAB/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Morse-code b/Lang/MATLAB/Morse-code new file mode 120000 index 0000000000..b8dcc01e52 --- /dev/null +++ b/Lang/MATLAB/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Mouse-position b/Lang/MATLAB/Mouse-position new file mode 120000 index 0000000000..344caaca9b --- /dev/null +++ b/Lang/MATLAB/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Multiple-regression b/Lang/MATLAB/Multiple-regression new file mode 120000 index 0000000000..26b90e6728 --- /dev/null +++ b/Lang/MATLAB/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Multiplication-tables b/Lang/MATLAB/Multiplication-tables new file mode 120000 index 0000000000..a017ea0850 --- /dev/null +++ b/Lang/MATLAB/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Mutual-recursion b/Lang/MATLAB/Mutual-recursion new file mode 120000 index 0000000000..a437b83d3b --- /dev/null +++ b/Lang/MATLAB/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/MATLAB \ No newline at end of file diff --git a/Lang/MAXScript/0DESCRIPTION b/Lang/MAXScript/0DESCRIPTION new file mode 100644 index 0000000000..d13c7b94cf --- /dev/null +++ b/Lang/MAXScript/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|MAXScript +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|parampass=both +|LCT=yes}}'''MAXScript''' is a built-in scripting language, and is used for a myriad of functions in 3D Studio Max. Plugin modules can be created entirely in MAXScript. + +==Citations== +* [[wp:Maxscript|Wikipedia:3ds Max]] \ No newline at end of file diff --git a/Lang/MAXScript/100-doors b/Lang/MAXScript/100-doors new file mode 120000 index 0000000000..e32537ade1 --- /dev/null +++ b/Lang/MAXScript/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/99-Bottles-of-Beer b/Lang/MAXScript/99-Bottles-of-Beer new file mode 120000 index 0000000000..2bd0224c31 --- /dev/null +++ b/Lang/MAXScript/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Ackermann-function b/Lang/MAXScript/Ackermann-function new file mode 120000 index 0000000000..656d247701 --- /dev/null +++ b/Lang/MAXScript/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Arithmetic-Integer b/Lang/MAXScript/Arithmetic-Integer new file mode 120000 index 0000000000..0c6018e8e2 --- /dev/null +++ b/Lang/MAXScript/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Averages-Arithmetic-mean b/Lang/MAXScript/Averages-Arithmetic-mean new file mode 120000 index 0000000000..b558696544 --- /dev/null +++ b/Lang/MAXScript/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Binary-search b/Lang/MAXScript/Binary-search new file mode 120000 index 0000000000..0409ebf7eb --- /dev/null +++ b/Lang/MAXScript/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Bitmap b/Lang/MAXScript/Bitmap new file mode 120000 index 0000000000..6155d15c0c --- /dev/null +++ b/Lang/MAXScript/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Bitmap-Bresenhams-line-algorithm b/Lang/MAXScript/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..18c687063a --- /dev/null +++ b/Lang/MAXScript/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Bitwise-operations b/Lang/MAXScript/Bitwise-operations new file mode 120000 index 0000000000..0c656d3574 --- /dev/null +++ b/Lang/MAXScript/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Check-that-file-exists b/Lang/MAXScript/Check-that-file-exists new file mode 120000 index 0000000000..8505270a06 --- /dev/null +++ b/Lang/MAXScript/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Comments b/Lang/MAXScript/Comments new file mode 120000 index 0000000000..4ab765f504 --- /dev/null +++ b/Lang/MAXScript/Comments @@ -0,0 +1 @@ +../../Task/Comments/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Compound-data-type b/Lang/MAXScript/Compound-data-type new file mode 120000 index 0000000000..f5163db254 --- /dev/null +++ b/Lang/MAXScript/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Conditional-structures b/Lang/MAXScript/Conditional-structures new file mode 120000 index 0000000000..b58118af24 --- /dev/null +++ b/Lang/MAXScript/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Create-a-file b/Lang/MAXScript/Create-a-file new file mode 120000 index 0000000000..cec3194233 --- /dev/null +++ b/Lang/MAXScript/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Create-a-two-dimensional-array-at-runtime b/Lang/MAXScript/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..27e899ffdc --- /dev/null +++ b/Lang/MAXScript/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Delete-a-file b/Lang/MAXScript/Delete-a-file new file mode 120000 index 0000000000..677153433a --- /dev/null +++ b/Lang/MAXScript/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Detect-division-by-zero b/Lang/MAXScript/Detect-division-by-zero new file mode 120000 index 0000000000..f84a870581 --- /dev/null +++ b/Lang/MAXScript/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Determine-if-a-string-is-numeric b/Lang/MAXScript/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..951c2d9c8e --- /dev/null +++ b/Lang/MAXScript/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Execute-a-system-command b/Lang/MAXScript/Execute-a-system-command new file mode 120000 index 0000000000..80454f063e --- /dev/null +++ b/Lang/MAXScript/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Factorial b/Lang/MAXScript/Factorial new file mode 120000 index 0000000000..371211604b --- /dev/null +++ b/Lang/MAXScript/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Fibonacci-sequence b/Lang/MAXScript/Fibonacci-sequence new file mode 120000 index 0000000000..0dafa2a90d --- /dev/null +++ b/Lang/MAXScript/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/File-IO b/Lang/MAXScript/File-IO new file mode 120000 index 0000000000..ba70cd75eb --- /dev/null +++ b/Lang/MAXScript/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/File-modification-time b/Lang/MAXScript/File-modification-time new file mode 120000 index 0000000000..ff1c42e45e --- /dev/null +++ b/Lang/MAXScript/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/File-size b/Lang/MAXScript/File-size new file mode 120000 index 0000000000..0ca201e248 --- /dev/null +++ b/Lang/MAXScript/File-size @@ -0,0 +1 @@ +../../Task/File-size/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Filter b/Lang/MAXScript/Filter new file mode 120000 index 0000000000..a9e0df2c29 --- /dev/null +++ b/Lang/MAXScript/Filter @@ -0,0 +1 @@ +../../Task/Filter/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/FizzBuzz b/Lang/MAXScript/FizzBuzz new file mode 120000 index 0000000000..7168096abd --- /dev/null +++ b/Lang/MAXScript/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Function-definition b/Lang/MAXScript/Function-definition new file mode 120000 index 0000000000..749b126819 --- /dev/null +++ b/Lang/MAXScript/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Generic-swap b/Lang/MAXScript/Generic-swap new file mode 120000 index 0000000000..2bfdd5996e --- /dev/null +++ b/Lang/MAXScript/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Greatest-common-divisor b/Lang/MAXScript/Greatest-common-divisor new file mode 120000 index 0000000000..c918c2a9ec --- /dev/null +++ b/Lang/MAXScript/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Greatest-element-of-a-list b/Lang/MAXScript/Greatest-element-of-a-list new file mode 120000 index 0000000000..7ae8cb1730 --- /dev/null +++ b/Lang/MAXScript/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Hello-world-Graphical b/Lang/MAXScript/Hello-world-Graphical new file mode 120000 index 0000000000..7be7c17da3 --- /dev/null +++ b/Lang/MAXScript/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Hello-world-Text b/Lang/MAXScript/Hello-world-Text new file mode 120000 index 0000000000..4fa51f52c1 --- /dev/null +++ b/Lang/MAXScript/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Higher-order-functions b/Lang/MAXScript/Higher-order-functions new file mode 120000 index 0000000000..504fb34657 --- /dev/null +++ b/Lang/MAXScript/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Increment-a-numerical-string b/Lang/MAXScript/Increment-a-numerical-string new file mode 120000 index 0000000000..1e9c849ef4 --- /dev/null +++ b/Lang/MAXScript/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Input-loop b/Lang/MAXScript/Input-loop new file mode 120000 index 0000000000..b5b4b82219 --- /dev/null +++ b/Lang/MAXScript/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Integer-comparison b/Lang/MAXScript/Integer-comparison new file mode 120000 index 0000000000..12ed60c6a1 --- /dev/null +++ b/Lang/MAXScript/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Introspection b/Lang/MAXScript/Introspection new file mode 120000 index 0000000000..90fe236de5 --- /dev/null +++ b/Lang/MAXScript/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Logical-operations b/Lang/MAXScript/Logical-operations new file mode 120000 index 0000000000..0792e9ad0e --- /dev/null +++ b/Lang/MAXScript/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Look-and-say-sequence b/Lang/MAXScript/Look-and-say-sequence new file mode 120000 index 0000000000..ba8407af9f --- /dev/null +++ b/Lang/MAXScript/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-Continue b/Lang/MAXScript/Loops-Continue new file mode 120000 index 0000000000..99e97ddd10 --- /dev/null +++ b/Lang/MAXScript/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-Do-while b/Lang/MAXScript/Loops-Do-while new file mode 120000 index 0000000000..5f8e538a0f --- /dev/null +++ b/Lang/MAXScript/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-Downward-for b/Lang/MAXScript/Loops-Downward-for new file mode 120000 index 0000000000..f277681bc8 --- /dev/null +++ b/Lang/MAXScript/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-For b/Lang/MAXScript/Loops-For new file mode 120000 index 0000000000..88b2ff5cf2 --- /dev/null +++ b/Lang/MAXScript/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-Foreach b/Lang/MAXScript/Loops-Foreach new file mode 120000 index 0000000000..6cd9d74582 --- /dev/null +++ b/Lang/MAXScript/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-Infinite b/Lang/MAXScript/Loops-Infinite new file mode 120000 index 0000000000..5d580f26e9 --- /dev/null +++ b/Lang/MAXScript/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-N-plus-one-half b/Lang/MAXScript/Loops-N-plus-one-half new file mode 120000 index 0000000000..d3789814ac --- /dev/null +++ b/Lang/MAXScript/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Loops-While b/Lang/MAXScript/Loops-While new file mode 120000 index 0000000000..7231c5bc9b --- /dev/null +++ b/Lang/MAXScript/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Matrix-transposition b/Lang/MAXScript/Matrix-transposition new file mode 120000 index 0000000000..3497db4418 --- /dev/null +++ b/Lang/MAXScript/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Monty-Hall-problem b/Lang/MAXScript/Monty-Hall-problem new file mode 120000 index 0000000000..4de4f5cae8 --- /dev/null +++ b/Lang/MAXScript/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Search-a-list b/Lang/MAXScript/Search-a-list new file mode 120000 index 0000000000..6ca73b51f5 --- /dev/null +++ b/Lang/MAXScript/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/MAXScript \ No newline at end of file diff --git a/Lang/MBS/0DESCRIPTION b/Lang/MBS/0DESCRIPTION new file mode 100644 index 0000000000..683109f1e2 --- /dev/null +++ b/Lang/MBS/0DESCRIPTION @@ -0,0 +1,5 @@ +{{language +|site=http://www.varkon.org/ +}} + +MBS is a general purpose programming language that supports generic parametric constructs for design and product modelling. \ No newline at end of file diff --git a/Lang/MBS/Comments b/Lang/MBS/Comments new file mode 120000 index 0000000000..e60e884652 --- /dev/null +++ b/Lang/MBS/Comments @@ -0,0 +1 @@ +../../Task/Comments/MBS \ No newline at end of file diff --git a/Lang/MBS/Conditional-structures b/Lang/MBS/Conditional-structures new file mode 120000 index 0000000000..a5e5fa08d9 --- /dev/null +++ b/Lang/MBS/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/MBS \ No newline at end of file diff --git a/Lang/MBS/Enforced-immutability b/Lang/MBS/Enforced-immutability new file mode 120000 index 0000000000..cbfd598983 --- /dev/null +++ b/Lang/MBS/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/MBS \ No newline at end of file diff --git a/Lang/MBS/Jump-anywhere b/Lang/MBS/Jump-anywhere new file mode 120000 index 0000000000..9fdf666a1f --- /dev/null +++ b/Lang/MBS/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/MBS \ No newline at end of file diff --git a/Lang/ME10-macro/0DESCRIPTION b/Lang/ME10-macro/0DESCRIPTION new file mode 100644 index 0000000000..f66cf163bf --- /dev/null +++ b/Lang/ME10-macro/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{stub}} \ No newline at end of file diff --git a/Lang/MEL/0DESCRIPTION b/Lang/MEL/0DESCRIPTION new file mode 100644 index 0000000000..f1bda76969 --- /dev/null +++ b/Lang/MEL/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language|Melscript +|strength=strong +|safety=safe +|checking=static +|parampass=value}}'''MEL''' is a built-in scripting language used by Autodesk Maya. + +==Citations== +* [[wp:Maya_Embedded_Language|Wikipedia:MEL]] \ No newline at end of file diff --git a/Lang/MEL/FizzBuzz b/Lang/MEL/FizzBuzz new file mode 120000 index 0000000000..e38cb34d99 --- /dev/null +++ b/Lang/MEL/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/MEL \ No newline at end of file diff --git a/Lang/MGS/0DESCRIPTION b/Lang/MGS/0DESCRIPTION new file mode 100644 index 0000000000..9c164a62a0 --- /dev/null +++ b/Lang/MGS/0DESCRIPTION @@ -0,0 +1,5 @@ +{{language +|site=http://mgs.spatial-computing.org/ +}} +MGS is a domain specific language (DSL) for the simulation of biological processes. +It is a untyped functionnal language that enables the case-based definition of functions on collections. These functions are called transformation. The language includes also imperatives features like globale variables. \ No newline at end of file diff --git a/Lang/MIPS-Assembly/0DESCRIPTION b/Lang/MIPS-Assembly/0DESCRIPTION new file mode 100644 index 0000000000..e01aa608b2 --- /dev/null +++ b/Lang/MIPS-Assembly/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language}}{{assembler language}}[[Category:Assembly]] +[[wp:MIPS_architecture|MIPS architecture]] \ No newline at end of file diff --git a/Lang/MIPS-Assembly/100-doors b/Lang/MIPS-Assembly/100-doors new file mode 120000 index 0000000000..b548888274 --- /dev/null +++ b/Lang/MIPS-Assembly/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/MIPS-Assembly \ No newline at end of file diff --git a/Lang/MIPS-Assembly/Greatest-common-divisor b/Lang/MIPS-Assembly/Greatest-common-divisor new file mode 120000 index 0000000000..6c2145173c --- /dev/null +++ b/Lang/MIPS-Assembly/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/MIPS-Assembly \ No newline at end of file diff --git a/Lang/MIPS-Assembly/Hello-world-Text b/Lang/MIPS-Assembly/Hello-world-Text new file mode 120000 index 0000000000..f451891efa --- /dev/null +++ b/Lang/MIPS-Assembly/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/MIPS-Assembly \ No newline at end of file diff --git a/Lang/MIRC-Scripting-Language/0DESCRIPTION b/Lang/MIRC-Scripting-Language/0DESCRIPTION new file mode 100644 index 0000000000..50414d3cf1 --- /dev/null +++ b/Lang/MIRC-Scripting-Language/0DESCRIPTION @@ -0,0 +1,9 @@ +{{language|MIRC Scripting Language}} +''The real name is mIRC Scripting Language. Due to technical limitations, the first letter is capitalized'' + +The '''mIRC Scripting Language''' is a [[programming language]] interpreted by the well known '''mIRC''' IRC client for [[Microsoft]] [[Windows]]. + +* Official Website: http://www.mirc.com/ +* Plugins Website: http://www.mircscripts.org/ + +
\ No newline at end of file diff --git a/Lang/MIRC-Scripting-Language/Loops-While b/Lang/MIRC-Scripting-Language/Loops-While new file mode 120000 index 0000000000..8482c1e447 --- /dev/null +++ b/Lang/MIRC-Scripting-Language/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/MIRC-Scripting-Language \ No newline at end of file diff --git a/Lang/ML-I/0DESCRIPTION b/Lang/ML-I/0DESCRIPTION new file mode 100644 index 0000000000..b5244bacab --- /dev/null +++ b/Lang/ML-I/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|ML/I}} +ML/I is a general, stand alone, programmable macro processor. It is general in the sense that it can be used to process any kind of text. The text may be in any programming language or natural language, or it may be numerical data. It is stand alone in that it depends on no other program for its operation. It is programmable in that it can be programmed to carry out fairly complex operations when faced with varying kinds of input. In short, it is a very powerful tool. + +Historically, the most important use of ML/I has been to provide users with a simple means of adding extra statements (or other syntactic forms) to an existing programming language in order to make the language more suitable for their own field of application. This process of extension may be carried to the level where the extended language could be regarded as a new language in its own right. Other possible uses of ML/I are program parameterisation (e.g. a parameter might determine whether debugging statements are to be included in a program) and various applications in text editing or correction and in data format conversion. It has been used, for instance, to format and convert files marked up with HTML. It has also been used as part of a microprogam translator for a bit slice computer implementation. + +However, these are just a few applications. ML/I is very flexible, and there are many, many other uses for it. + +ML/I is an exceedingly long-lived language. It was first implemented in 1966, and is still in use. + +The official ML/I web site can be found at [http://www.ml1.org.uk http://www.ml1.org.uk] \ No newline at end of file diff --git a/Lang/ML-I/100-doors b/Lang/ML-I/100-doors new file mode 120000 index 0000000000..35cd5bb619 --- /dev/null +++ b/Lang/ML-I/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ML-I \ No newline at end of file diff --git a/Lang/ML-I/99-Bottles-of-Beer b/Lang/ML-I/99-Bottles-of-Beer new file mode 120000 index 0000000000..c3e3198e3c --- /dev/null +++ b/Lang/ML-I/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/ML-I \ No newline at end of file diff --git a/Lang/ML-I/A+B b/Lang/ML-I/A+B new file mode 120000 index 0000000000..c38ffc06ca --- /dev/null +++ b/Lang/ML-I/A+B @@ -0,0 +1 @@ +../../Task/A+B/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Ackermann-function b/Lang/ML-I/Ackermann-function new file mode 120000 index 0000000000..79af94b071 --- /dev/null +++ b/Lang/ML-I/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Align-columns b/Lang/ML-I/Align-columns new file mode 120000 index 0000000000..f8e79c2c50 --- /dev/null +++ b/Lang/ML-I/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Arithmetic-Integer b/Lang/ML-I/Arithmetic-Integer new file mode 120000 index 0000000000..748d3ee9d8 --- /dev/null +++ b/Lang/ML-I/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Bitwise-operations b/Lang/ML-I/Bitwise-operations new file mode 120000 index 0000000000..46606ecad6 --- /dev/null +++ b/Lang/ML-I/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/ML-I \ No newline at end of file diff --git a/Lang/ML-I/CSV-to-HTML-translation b/Lang/ML-I/CSV-to-HTML-translation new file mode 120000 index 0000000000..c0a9ecd6c4 --- /dev/null +++ b/Lang/ML-I/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Empty-program b/Lang/ML-I/Empty-program new file mode 120000 index 0000000000..48b06f2449 --- /dev/null +++ b/Lang/ML-I/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Factorial b/Lang/ML-I/Factorial new file mode 120000 index 0000000000..9401792850 --- /dev/null +++ b/Lang/ML-I/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Fibonacci-sequence b/Lang/ML-I/Fibonacci-sequence new file mode 120000 index 0000000000..c862c0d411 --- /dev/null +++ b/Lang/ML-I/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Hello-world-Newline-omission b/Lang/ML-I/Hello-world-Newline-omission new file mode 120000 index 0000000000..017d14975f --- /dev/null +++ b/Lang/ML-I/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Hello-world-Standard-error b/Lang/ML-I/Hello-world-Standard-error new file mode 120000 index 0000000000..4ea7a51124 --- /dev/null +++ b/Lang/ML-I/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Hello-world-Text b/Lang/ML-I/Hello-world-Text new file mode 120000 index 0000000000..75cf5a9507 --- /dev/null +++ b/Lang/ML-I/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Input-loop b/Lang/ML-I/Input-loop new file mode 120000 index 0000000000..41eb16eb74 --- /dev/null +++ b/Lang/ML-I/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Integer-comparison b/Lang/ML-I/Integer-comparison new file mode 120000 index 0000000000..155fd0aa6a --- /dev/null +++ b/Lang/ML-I/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Integer-sequence b/Lang/ML-I/Integer-sequence new file mode 120000 index 0000000000..10e647ab7f --- /dev/null +++ b/Lang/ML-I/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Interactive-programming b/Lang/ML-I/Interactive-programming new file mode 120000 index 0000000000..b2180821fe --- /dev/null +++ b/Lang/ML-I/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/ML-I \ No newline at end of file diff --git a/Lang/ML-I/Literals-String b/Lang/ML-I/Literals-String new file mode 120000 index 0000000000..4884155744 --- /dev/null +++ b/Lang/ML-I/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/ML-I \ No newline at end of file diff --git a/Lang/MMIX/0DESCRIPTION b/Lang/MMIX/0DESCRIPTION new file mode 100644 index 0000000000..69e8597b3e --- /dev/null +++ b/Lang/MMIX/0DESCRIPTION @@ -0,0 +1,18 @@ +==MMIX 2009== + +A RISC computer for the third millennium + +{{language}} [[Category:Assembly]] + +Knuth's home page about MMIX says: + +:''MMIX is a machine that operates primarily on 64-bit words. It has 256 general-purpose 64-bit registers that each can hold either fixed-point or floating-point numbers. Most instructions have the 4-byte form ‘OP X Y Z’, where each of OP, X, Y, and Z is a single 8-bit byte. For example, if OP is the code for ADD the meaning is “X=Y+Z”; i.e., “Set register X to the contents of register Y plus the contents of register Z.” The 256 possible OP codes fall into a dozen or so easily remembered categories.'' + +==Playing with MMIX== + +In order to work with MMIX you'll have to download and install [http://www-cs-faculty.stanford.edu/~knuth/programs/mmix-20090321.tar.gz MMIXware] . This provides you with a simple simulator, assembler, test programs, and full documentation, plus the meta-simulator. + +==Information== +Everything you need to know about MMIX can be found at Donald Knuth's home page [http://www-cs-faculty.stanford.edu/~knuth/mmix.html] + +Visit also [http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html Knuth's MMIX News] \ No newline at end of file diff --git a/Lang/MMIX/Command-line-arguments b/Lang/MMIX/Command-line-arguments new file mode 120000 index 0000000000..fba8bd398a --- /dev/null +++ b/Lang/MMIX/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Empty-program b/Lang/MMIX/Empty-program new file mode 120000 index 0000000000..0c3e35a8ba --- /dev/null +++ b/Lang/MMIX/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Ethiopian-multiplication b/Lang/MMIX/Ethiopian-multiplication new file mode 120000 index 0000000000..f8f0c41760 --- /dev/null +++ b/Lang/MMIX/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/MMIX \ No newline at end of file diff --git a/Lang/MMIX/FizzBuzz b/Lang/MMIX/FizzBuzz new file mode 120000 index 0000000000..74844d370e --- /dev/null +++ b/Lang/MMIX/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Integer-comparison b/Lang/MMIX/Integer-comparison new file mode 120000 index 0000000000..27422d8aea --- /dev/null +++ b/Lang/MMIX/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Mutual-recursion b/Lang/MMIX/Mutual-recursion new file mode 120000 index 0000000000..a2913c8eb0 --- /dev/null +++ b/Lang/MMIX/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/MMIX \ No newline at end of file diff --git a/Lang/MOO/0DESCRIPTION b/Lang/MOO/0DESCRIPTION new file mode 100644 index 0000000000..b95d5f0b43 --- /dev/null +++ b/Lang/MOO/0DESCRIPTION @@ -0,0 +1,2 @@ +{{stub}}{{language +|checking=dynamic}} \ No newline at end of file diff --git a/Lang/MOO/100-doors b/Lang/MOO/100-doors new file mode 120000 index 0000000000..bc94fec60c --- /dev/null +++ b/Lang/MOO/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/MOO \ No newline at end of file diff --git a/Lang/MOO/99-Bottles-of-Beer b/Lang/MOO/99-Bottles-of-Beer new file mode 120000 index 0000000000..085de5b159 --- /dev/null +++ b/Lang/MOO/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/MOO \ No newline at end of file diff --git a/Lang/MOO/Comments b/Lang/MOO/Comments new file mode 120000 index 0000000000..1a96210986 --- /dev/null +++ b/Lang/MOO/Comments @@ -0,0 +1 @@ +../../Task/Comments/MOO \ No newline at end of file diff --git a/Lang/MOO/Exceptions b/Lang/MOO/Exceptions new file mode 120000 index 0000000000..9fcf7b5e2c --- /dev/null +++ b/Lang/MOO/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-Break b/Lang/MOO/Loops-Break new file mode 120000 index 0000000000..8899664144 --- /dev/null +++ b/Lang/MOO/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-Continue b/Lang/MOO/Loops-Continue new file mode 120000 index 0000000000..c6c81e1ad5 --- /dev/null +++ b/Lang/MOO/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-For b/Lang/MOO/Loops-For new file mode 120000 index 0000000000..908250b210 --- /dev/null +++ b/Lang/MOO/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-Foreach b/Lang/MOO/Loops-Foreach new file mode 120000 index 0000000000..02f3becd73 --- /dev/null +++ b/Lang/MOO/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-Infinite b/Lang/MOO/Loops-Infinite new file mode 120000 index 0000000000..b138d97e2a --- /dev/null +++ b/Lang/MOO/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-Nested b/Lang/MOO/Loops-Nested new file mode 120000 index 0000000000..148c824978 --- /dev/null +++ b/Lang/MOO/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/MOO \ No newline at end of file diff --git a/Lang/MOO/Loops-While b/Lang/MOO/Loops-While new file mode 120000 index 0000000000..67e157d301 --- /dev/null +++ b/Lang/MOO/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/MOO \ No newline at end of file diff --git a/Lang/MOO/MD5 b/Lang/MOO/MD5 new file mode 120000 index 0000000000..a98f8f5df5 --- /dev/null +++ b/Lang/MOO/MD5 @@ -0,0 +1 @@ +../../Task/MD5/MOO \ No newline at end of file diff --git a/Lang/MOO/Multiplication-tables b/Lang/MOO/Multiplication-tables new file mode 120000 index 0000000000..b0045dcdca --- /dev/null +++ b/Lang/MOO/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/MOO \ No newline at end of file diff --git a/Lang/MPIF90/0DESCRIPTION b/Lang/MPIF90/0DESCRIPTION new file mode 100644 index 0000000000..50cb6ba6d4 --- /dev/null +++ b/Lang/MPIF90/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}MPIf90 is the Message-passing interface for [[Fortran]] 90. See also mpif77, mpicc, etc. \ No newline at end of file diff --git a/Lang/MPIF90/99-Bottles-of-Beer b/Lang/MPIF90/99-Bottles-of-Beer new file mode 120000 index 0000000000..c6f1a276d8 --- /dev/null +++ b/Lang/MPIF90/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/MPIF90 \ No newline at end of file diff --git a/Lang/MS-SQL/0DESCRIPTION b/Lang/MS-SQL/0DESCRIPTION new file mode 100644 index 0000000000..f66cf163bf --- /dev/null +++ b/Lang/MS-SQL/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{stub}} \ No newline at end of file diff --git a/Lang/MSSQL/0DESCRIPTION b/Lang/MSSQL/0DESCRIPTION new file mode 100644 index 0000000000..f66cf163bf --- /dev/null +++ b/Lang/MSSQL/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}{{stub}} \ No newline at end of file diff --git a/Lang/MUF/0DESCRIPTION b/Lang/MUF/0DESCRIPTION new file mode 100644 index 0000000000..78a0a54842 --- /dev/null +++ b/Lang/MUF/0DESCRIPTION @@ -0,0 +1,6 @@ +{{language}} +'''MUF''' (Multi-User Forth) is the [[Forth]]-like programming language invented in 1990 for multi-user role playing system TinyMUCK. Each MUF program can access and manipulate in-game objects (items, locations, exits, players, programs). MUF programs can be invoked through global or local aliases or executed when an in-game object is examined or otherwise manipulated. The concept of user-programmable virtual world was later reimplemented with programming language [[LSL]] in the MMO game Second Life. + +==Citations== +* [[wp:MUF (programming language)|Wikipedia:MUF (programming language)]] +{{stub}} \ No newline at end of file diff --git a/Lang/MUF/Hello-world-Text b/Lang/MUF/Hello-world-Text new file mode 120000 index 0000000000..887e0870d4 --- /dev/null +++ b/Lang/MUF/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/MUF \ No newline at end of file diff --git a/Lang/MUMPS/0DESCRIPTION b/Lang/MUMPS/0DESCRIPTION new file mode 100644 index 0000000000..cfb6ac9800 --- /dev/null +++ b/Lang/MUMPS/0DESCRIPTION @@ -0,0 +1,14 @@ +{{language +|untyped=yes}} +{{language programming paradigm|procedural}} + +

Visit the Google group comp.lang.mumps for discussions about this language.

+ +

Visit [[wp:MUMPS|Wikipedia]] for a general description.

+ +

See http://71.174.62.16/Demo/AnnoStd for details about the language.

+ +

Standard MUMPS has one data types (strings) and some dialects (Cache, MSM) add a second data type (objects). A variable can be unsubscripted or not, and the subscripted variables form a +sparse n-tree. MUMPS doesn't have traditional arrays, but has an array syntax that manipulates trees as if they were arrays, using indexing to access nodes of the tree. You can create a tree that can have unlimited levels of branching, with keys and values associated with each node in the tree. Similarly, while the language doesn't have lists, you can mimic lists by creating strings with a consistent character (or string) as a delimiter separating the entries. +The Cache dialect also supports explicit List operations and data structures. +

\ No newline at end of file diff --git a/Lang/MUMPS/100-doors b/Lang/MUMPS/100-doors new file mode 120000 index 0000000000..31e732e055 --- /dev/null +++ b/Lang/MUMPS/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/99-Bottles-of-Beer b/Lang/MUMPS/99-Bottles-of-Beer new file mode 120000 index 0000000000..0cdf1c958b --- /dev/null +++ b/Lang/MUMPS/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/A+B b/Lang/MUMPS/A+B new file mode 120000 index 0000000000..193876ec5a --- /dev/null +++ b/Lang/MUMPS/A+B @@ -0,0 +1 @@ +../../Task/A+B/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Ackermann-function b/Lang/MUMPS/Ackermann-function new file mode 120000 index 0000000000..b8a1c549a7 --- /dev/null +++ b/Lang/MUMPS/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Align-columns b/Lang/MUMPS/Align-columns new file mode 120000 index 0000000000..697d2a28dc --- /dev/null +++ b/Lang/MUMPS/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Anagrams b/Lang/MUMPS/Anagrams new file mode 120000 index 0000000000..a8c358e414 --- /dev/null +++ b/Lang/MUMPS/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Arithmetic-Integer b/Lang/MUMPS/Arithmetic-Integer new file mode 120000 index 0000000000..b4f79f1ee0 --- /dev/null +++ b/Lang/MUMPS/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Averages-Arithmetic-mean b/Lang/MUMPS/Averages-Arithmetic-mean new file mode 120000 index 0000000000..2765e556f4 --- /dev/null +++ b/Lang/MUMPS/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Averages-Median b/Lang/MUMPS/Averages-Median new file mode 120000 index 0000000000..9d3d8f7b95 --- /dev/null +++ b/Lang/MUMPS/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Averages-Mode b/Lang/MUMPS/Averages-Mode new file mode 120000 index 0000000000..abff2fbcb7 --- /dev/null +++ b/Lang/MUMPS/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Averages-Pythagorean-means b/Lang/MUMPS/Averages-Pythagorean-means new file mode 120000 index 0000000000..4fcacca35f --- /dev/null +++ b/Lang/MUMPS/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Box-the-compass b/Lang/MUMPS/Box-the-compass new file mode 120000 index 0000000000..4b59458594 --- /dev/null +++ b/Lang/MUMPS/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Bulls-and-cows b/Lang/MUMPS/Bulls-and-cows new file mode 120000 index 0000000000..e4eea0953d --- /dev/null +++ b/Lang/MUMPS/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Character-codes b/Lang/MUMPS/Character-codes new file mode 120000 index 0000000000..bb8257b183 --- /dev/null +++ b/Lang/MUMPS/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Conditional-structures b/Lang/MUMPS/Conditional-structures new file mode 120000 index 0000000000..9bb785274c --- /dev/null +++ b/Lang/MUMPS/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Create-a-two-dimensional-array-at-runtime b/Lang/MUMPS/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..c8582989dc --- /dev/null +++ b/Lang/MUMPS/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Date-format b/Lang/MUMPS/Date-format new file mode 120000 index 0000000000..deb24299a8 --- /dev/null +++ b/Lang/MUMPS/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Day-of-the-week b/Lang/MUMPS/Day-of-the-week new file mode 120000 index 0000000000..b6d32e960b --- /dev/null +++ b/Lang/MUMPS/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Detect-division-by-zero b/Lang/MUMPS/Detect-division-by-zero new file mode 120000 index 0000000000..b74e21699f --- /dev/null +++ b/Lang/MUMPS/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Dot-product b/Lang/MUMPS/Dot-product new file mode 120000 index 0000000000..9b2ada6dc0 --- /dev/null +++ b/Lang/MUMPS/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Dynamic-variable-names b/Lang/MUMPS/Dynamic-variable-names new file mode 120000 index 0000000000..89613e9e65 --- /dev/null +++ b/Lang/MUMPS/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Ethiopian-multiplication b/Lang/MUMPS/Ethiopian-multiplication new file mode 120000 index 0000000000..b7e8029377 --- /dev/null +++ b/Lang/MUMPS/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Execute-a-system-command b/Lang/MUMPS/Execute-a-system-command new file mode 120000 index 0000000000..4f302c3e8f --- /dev/null +++ b/Lang/MUMPS/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Extreme-floating-point-values b/Lang/MUMPS/Extreme-floating-point-values new file mode 120000 index 0000000000..2f51be59d3 --- /dev/null +++ b/Lang/MUMPS/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Factorial b/Lang/MUMPS/Factorial new file mode 120000 index 0000000000..3f3bdba666 --- /dev/null +++ b/Lang/MUMPS/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Factors-of-an-integer b/Lang/MUMPS/Factors-of-an-integer new file mode 120000 index 0000000000..b5fa7f0260 --- /dev/null +++ b/Lang/MUMPS/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Fibonacci-sequence b/Lang/MUMPS/Fibonacci-sequence new file mode 120000 index 0000000000..712f8d5b9d --- /dev/null +++ b/Lang/MUMPS/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Filter b/Lang/MUMPS/Filter new file mode 120000 index 0000000000..1ab91cdfc4 --- /dev/null +++ b/Lang/MUMPS/Filter @@ -0,0 +1 @@ +../../Task/Filter/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Find-common-directory-path b/Lang/MUMPS/Find-common-directory-path new file mode 120000 index 0000000000..c9bde32740 --- /dev/null +++ b/Lang/MUMPS/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Find-limit-of-recursion b/Lang/MUMPS/Find-limit-of-recursion new file mode 120000 index 0000000000..146c80c593 --- /dev/null +++ b/Lang/MUMPS/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Five-weekends b/Lang/MUMPS/Five-weekends new file mode 120000 index 0000000000..f7202548c4 --- /dev/null +++ b/Lang/MUMPS/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/FizzBuzz b/Lang/MUMPS/FizzBuzz new file mode 120000 index 0000000000..8f7569f570 --- /dev/null +++ b/Lang/MUMPS/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Flow-control-structures b/Lang/MUMPS/Flow-control-structures new file mode 120000 index 0000000000..ace3fb5024 --- /dev/null +++ b/Lang/MUMPS/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Four-bit-adder b/Lang/MUMPS/Four-bit-adder new file mode 120000 index 0000000000..9f9e7ca2e9 --- /dev/null +++ b/Lang/MUMPS/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Function-definition b/Lang/MUMPS/Function-definition new file mode 120000 index 0000000000..e3208f1583 --- /dev/null +++ b/Lang/MUMPS/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Greatest-common-divisor b/Lang/MUMPS/Greatest-common-divisor new file mode 120000 index 0000000000..1bd2237697 --- /dev/null +++ b/Lang/MUMPS/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Greatest-element-of-a-list b/Lang/MUMPS/Greatest-element-of-a-list new file mode 120000 index 0000000000..89ec97332a --- /dev/null +++ b/Lang/MUMPS/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Hailstone-sequence b/Lang/MUMPS/Hailstone-sequence new file mode 120000 index 0000000000..4b5925b167 --- /dev/null +++ b/Lang/MUMPS/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Hamming-numbers b/Lang/MUMPS/Hamming-numbers new file mode 120000 index 0000000000..1d069ac878 --- /dev/null +++ b/Lang/MUMPS/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Happy-numbers b/Lang/MUMPS/Happy-numbers new file mode 120000 index 0000000000..d9ed7cc69f --- /dev/null +++ b/Lang/MUMPS/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Hello-world-Text b/Lang/MUMPS/Hello-world-Text new file mode 120000 index 0000000000..da6be3ac3f --- /dev/null +++ b/Lang/MUMPS/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Hostname b/Lang/MUMPS/Hostname new file mode 120000 index 0000000000..d0dd3686ca --- /dev/null +++ b/Lang/MUMPS/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Increment-a-numerical-string b/Lang/MUMPS/Increment-a-numerical-string new file mode 120000 index 0000000000..0326997739 --- /dev/null +++ b/Lang/MUMPS/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Integer-comparison b/Lang/MUMPS/Integer-comparison new file mode 120000 index 0000000000..e462a4ac32 --- /dev/null +++ b/Lang/MUMPS/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Jump-anywhere b/Lang/MUMPS/Jump-anywhere new file mode 120000 index 0000000000..c526567a14 --- /dev/null +++ b/Lang/MUMPS/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Knuth-shuffle b/Lang/MUMPS/Knuth-shuffle new file mode 120000 index 0000000000..e83083d1da --- /dev/null +++ b/Lang/MUMPS/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Leap-year b/Lang/MUMPS/Leap-year new file mode 120000 index 0000000000..7c2f09de11 --- /dev/null +++ b/Lang/MUMPS/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Logical-operations b/Lang/MUMPS/Logical-operations new file mode 120000 index 0000000000..059214dfd8 --- /dev/null +++ b/Lang/MUMPS/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loop-over-multiple-arrays-simultaneously b/Lang/MUMPS/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..bee737ea3d --- /dev/null +++ b/Lang/MUMPS/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-Break b/Lang/MUMPS/Loops-Break new file mode 120000 index 0000000000..9d113699f3 --- /dev/null +++ b/Lang/MUMPS/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-Downward-for b/Lang/MUMPS/Loops-Downward-for new file mode 120000 index 0000000000..5da822e610 --- /dev/null +++ b/Lang/MUMPS/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-For b/Lang/MUMPS/Loops-For new file mode 120000 index 0000000000..0b37b00a27 --- /dev/null +++ b/Lang/MUMPS/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-For-with-a-specified-step b/Lang/MUMPS/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..510a7fef3f --- /dev/null +++ b/Lang/MUMPS/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-Infinite b/Lang/MUMPS/Loops-Infinite new file mode 120000 index 0000000000..b9ee14eb82 --- /dev/null +++ b/Lang/MUMPS/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-N-plus-one-half b/Lang/MUMPS/Loops-N-plus-one-half new file mode 120000 index 0000000000..f54d71ebc8 --- /dev/null +++ b/Lang/MUMPS/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Loops-Nested b/Lang/MUMPS/Loops-Nested new file mode 120000 index 0000000000..1d96f0e46b --- /dev/null +++ b/Lang/MUMPS/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Luhn-test-of-credit-card-numbers b/Lang/MUMPS/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..6a9fdd38b8 --- /dev/null +++ b/Lang/MUMPS/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Menu b/Lang/MUMPS/Menu new file mode 120000 index 0000000000..e9b86505e7 --- /dev/null +++ b/Lang/MUMPS/Menu @@ -0,0 +1 @@ +../../Task/Menu/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Multiplication-tables b/Lang/MUMPS/Multiplication-tables new file mode 120000 index 0000000000..370d3151e3 --- /dev/null +++ b/Lang/MUMPS/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Quine b/Lang/MUMPS/Quine new file mode 120000 index 0000000000..e3fd4522d1 --- /dev/null +++ b/Lang/MUMPS/Quine @@ -0,0 +1 @@ +../../Task/Quine/MUMPS \ No newline at end of file diff --git a/Lang/Make/0DESCRIPTION b/Lang/Make/0DESCRIPTION new file mode 100644 index 0000000000..e141acd329 --- /dev/null +++ b/Lang/Make/0DESCRIPTION @@ -0,0 +1 @@ +{{language}}One of the mini-languages of [[UNIX]]. It is Turing complete if recursive invocation is allowed. \ No newline at end of file diff --git a/Lang/Make/Conditional-structures b/Lang/Make/Conditional-structures new file mode 120000 index 0000000000..c4cef9c9ce --- /dev/null +++ b/Lang/Make/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Make \ No newline at end of file diff --git a/Lang/Make/Exceptions b/Lang/Make/Exceptions new file mode 120000 index 0000000000..636aa3867b --- /dev/null +++ b/Lang/Make/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Make \ No newline at end of file diff --git a/Lang/Make/Execute-a-system-command b/Lang/Make/Execute-a-system-command new file mode 120000 index 0000000000..f1fa06a689 --- /dev/null +++ b/Lang/Make/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Make \ No newline at end of file diff --git a/Lang/Make/Function-definition b/Lang/Make/Function-definition new file mode 120000 index 0000000000..7c615739ca --- /dev/null +++ b/Lang/Make/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Make \ No newline at end of file diff --git a/Lang/Make/Loops-Infinite b/Lang/Make/Loops-Infinite new file mode 120000 index 0000000000..0bc87667e7 --- /dev/null +++ b/Lang/Make/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Make \ No newline at end of file diff --git a/Lang/Make/Loops-N-plus-one-half b/Lang/Make/Loops-N-plus-one-half new file mode 120000 index 0000000000..c3ab8ab938 --- /dev/null +++ b/Lang/Make/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Make \ No newline at end of file diff --git a/Lang/Make/Loops-While b/Lang/Make/Loops-While new file mode 120000 index 0000000000..d391103ea9 --- /dev/null +++ b/Lang/Make/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Make \ No newline at end of file diff --git a/Lang/Maple/0DESCRIPTION b/Lang/Maple/0DESCRIPTION new file mode 100644 index 0000000000..36301ff907 --- /dev/null +++ b/Lang/Maple/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language}}{{stub}} + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Maple/100-doors b/Lang/Maple/100-doors new file mode 120000 index 0000000000..a3e9059c5a --- /dev/null +++ b/Lang/Maple/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Maple \ No newline at end of file diff --git a/Lang/Maple/A+B b/Lang/Maple/A+B new file mode 120000 index 0000000000..5b8d28fbd7 --- /dev/null +++ b/Lang/Maple/A+B @@ -0,0 +1 @@ +../../Task/A+B/Maple \ No newline at end of file diff --git a/Lang/Maple/Accumulator-factory b/Lang/Maple/Accumulator-factory new file mode 120000 index 0000000000..ca6adfadf9 --- /dev/null +++ b/Lang/Maple/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Maple \ No newline at end of file diff --git a/Lang/Maple/Ackermann-function b/Lang/Maple/Ackermann-function new file mode 120000 index 0000000000..50221f0931 --- /dev/null +++ b/Lang/Maple/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Maple \ No newline at end of file diff --git a/Lang/Maple/Align-columns b/Lang/Maple/Align-columns new file mode 120000 index 0000000000..961fe1e310 --- /dev/null +++ b/Lang/Maple/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Maple \ No newline at end of file diff --git a/Lang/Maple/Anagrams b/Lang/Maple/Anagrams new file mode 120000 index 0000000000..cee7749efc --- /dev/null +++ b/Lang/Maple/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Maple \ No newline at end of file diff --git a/Lang/Maple/Anonymous-recursion b/Lang/Maple/Anonymous-recursion new file mode 120000 index 0000000000..11718bdc47 --- /dev/null +++ b/Lang/Maple/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Maple \ No newline at end of file diff --git a/Lang/Maple/Apply-a-callback-to-an-array b/Lang/Maple/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..430a47be53 --- /dev/null +++ b/Lang/Maple/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Maple \ No newline at end of file diff --git a/Lang/Maple/Arbitrary-precision-integers-included b/Lang/Maple/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..4e0aba7d23 --- /dev/null +++ b/Lang/Maple/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Maple \ No newline at end of file diff --git a/Lang/Maple/Arithmetic-Complex b/Lang/Maple/Arithmetic-Complex new file mode 120000 index 0000000000..01f42b20a0 --- /dev/null +++ b/Lang/Maple/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Maple \ No newline at end of file diff --git a/Lang/Maple/Arithmetic-Integer b/Lang/Maple/Arithmetic-Integer new file mode 120000 index 0000000000..2edd64b05c --- /dev/null +++ b/Lang/Maple/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Maple \ No newline at end of file diff --git a/Lang/Maple/Arithmetic-Rational b/Lang/Maple/Arithmetic-Rational new file mode 120000 index 0000000000..6a04045b3b --- /dev/null +++ b/Lang/Maple/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Maple \ No newline at end of file diff --git a/Lang/Maple/Arithmetic-geometric-mean b/Lang/Maple/Arithmetic-geometric-mean new file mode 120000 index 0000000000..5020928627 --- /dev/null +++ b/Lang/Maple/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Maple \ No newline at end of file diff --git a/Lang/Maple/Array-concatenation b/Lang/Maple/Array-concatenation new file mode 120000 index 0000000000..1bc5c85e27 --- /dev/null +++ b/Lang/Maple/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Maple \ No newline at end of file diff --git a/Lang/Maple/Assertions b/Lang/Maple/Assertions new file mode 120000 index 0000000000..1e713fa727 --- /dev/null +++ b/Lang/Maple/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Maple \ No newline at end of file diff --git a/Lang/Maple/Associative-array-Creation b/Lang/Maple/Associative-array-Creation new file mode 120000 index 0000000000..2c3c4e5097 --- /dev/null +++ b/Lang/Maple/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Maple \ No newline at end of file diff --git a/Lang/Maple/Associative-array-Iteration b/Lang/Maple/Associative-array-Iteration new file mode 120000 index 0000000000..7df8058978 --- /dev/null +++ b/Lang/Maple/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Maple \ No newline at end of file diff --git a/Lang/Maple/Averages-Arithmetic-mean b/Lang/Maple/Averages-Arithmetic-mean new file mode 120000 index 0000000000..aa4bc28f43 --- /dev/null +++ b/Lang/Maple/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Maple \ No newline at end of file diff --git a/Lang/Maple/Averages-Mean-angle b/Lang/Maple/Averages-Mean-angle new file mode 120000 index 0000000000..ae899dc225 --- /dev/null +++ b/Lang/Maple/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Maple \ No newline at end of file diff --git a/Lang/Maple/Averages-Median b/Lang/Maple/Averages-Median new file mode 120000 index 0000000000..9c280305d6 --- /dev/null +++ b/Lang/Maple/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Maple \ No newline at end of file diff --git a/Lang/Maple/Balanced-brackets b/Lang/Maple/Balanced-brackets new file mode 120000 index 0000000000..a9d80b970c --- /dev/null +++ b/Lang/Maple/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Maple \ No newline at end of file diff --git a/Lang/Maple/Binary-search b/Lang/Maple/Binary-search new file mode 120000 index 0000000000..9f7b34acb7 --- /dev/null +++ b/Lang/Maple/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Maple \ No newline at end of file diff --git a/Lang/Maple/Bitmap-Bresenhams-line-algorithm b/Lang/Maple/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..ab532a8270 --- /dev/null +++ b/Lang/Maple/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Maple \ No newline at end of file diff --git a/Lang/Maple/Caesar-cipher b/Lang/Maple/Caesar-cipher new file mode 120000 index 0000000000..80e8104396 --- /dev/null +++ b/Lang/Maple/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Maple \ No newline at end of file diff --git a/Lang/Maple/Call-a-foreign-language-function b/Lang/Maple/Call-a-foreign-language-function new file mode 120000 index 0000000000..995dda9558 --- /dev/null +++ b/Lang/Maple/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Maple \ No newline at end of file diff --git a/Lang/Maple/Call-a-function-in-a-shared-library b/Lang/Maple/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..2ceb5b10fe --- /dev/null +++ b/Lang/Maple/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Maple \ No newline at end of file diff --git a/Lang/Maple/Case-sensitivity-of-identifiers b/Lang/Maple/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..b0ce075544 --- /dev/null +++ b/Lang/Maple/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Maple \ No newline at end of file diff --git a/Lang/Maple/Character-codes b/Lang/Maple/Character-codes new file mode 120000 index 0000000000..2f4eac6c87 --- /dev/null +++ b/Lang/Maple/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Maple \ No newline at end of file diff --git a/Lang/Maple/Character-matching b/Lang/Maple/Character-matching new file mode 120000 index 0000000000..a64bf87ae2 --- /dev/null +++ b/Lang/Maple/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Maple \ No newline at end of file diff --git a/Lang/Maple/Cholesky-decomposition b/Lang/Maple/Cholesky-decomposition new file mode 120000 index 0000000000..4e1e446114 --- /dev/null +++ b/Lang/Maple/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Maple \ No newline at end of file diff --git a/Lang/Maple/Create-a-two-dimensional-array-at-runtime b/Lang/Maple/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..5f5e6f54a4 --- /dev/null +++ b/Lang/Maple/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Maple \ No newline at end of file diff --git a/Lang/Maple/Empty-program b/Lang/Maple/Empty-program new file mode 120000 index 0000000000..f9fceb04a1 --- /dev/null +++ b/Lang/Maple/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Maple \ No newline at end of file diff --git a/Lang/Maple/Factorial b/Lang/Maple/Factorial new file mode 120000 index 0000000000..b9a796cfa5 --- /dev/null +++ b/Lang/Maple/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Maple \ No newline at end of file diff --git a/Lang/Maple/First-class-functions b/Lang/Maple/First-class-functions new file mode 120000 index 0000000000..296d74ea29 --- /dev/null +++ b/Lang/Maple/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Maple \ No newline at end of file diff --git a/Lang/Maple/Generic-swap b/Lang/Maple/Generic-swap new file mode 120000 index 0000000000..f80a0b36a9 --- /dev/null +++ b/Lang/Maple/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Maple \ No newline at end of file diff --git a/Lang/Maple/Greatest-common-divisor b/Lang/Maple/Greatest-common-divisor new file mode 120000 index 0000000000..b232d1d14d --- /dev/null +++ b/Lang/Maple/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Maple \ No newline at end of file diff --git a/Lang/Maple/Greatest-element-of-a-list b/Lang/Maple/Greatest-element-of-a-list new file mode 120000 index 0000000000..1061aafcbf --- /dev/null +++ b/Lang/Maple/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Maple \ No newline at end of file diff --git a/Lang/Maple/HTTP b/Lang/Maple/HTTP new file mode 120000 index 0000000000..7d78c8713a --- /dev/null +++ b/Lang/Maple/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Maple \ No newline at end of file diff --git a/Lang/Maple/Happy-numbers b/Lang/Maple/Happy-numbers new file mode 120000 index 0000000000..04980ae82e --- /dev/null +++ b/Lang/Maple/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Maple \ No newline at end of file diff --git a/Lang/Maple/Hello-world-Graphical b/Lang/Maple/Hello-world-Graphical new file mode 120000 index 0000000000..0799aa716f --- /dev/null +++ b/Lang/Maple/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Maple \ No newline at end of file diff --git a/Lang/Maple/Hello-world-Newline-omission b/Lang/Maple/Hello-world-Newline-omission new file mode 120000 index 0000000000..04fcdc6e24 --- /dev/null +++ b/Lang/Maple/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Maple \ No newline at end of file diff --git a/Lang/Maple/Hello-world-Text b/Lang/Maple/Hello-world-Text new file mode 120000 index 0000000000..215bad8810 --- /dev/null +++ b/Lang/Maple/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Maple \ No newline at end of file diff --git a/Lang/Maple/Hofstadter-Q-sequence b/Lang/Maple/Hofstadter-Q-sequence new file mode 120000 index 0000000000..d89c6fec0b --- /dev/null +++ b/Lang/Maple/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Maple \ No newline at end of file diff --git a/Lang/Maple/Hostname b/Lang/Maple/Hostname new file mode 120000 index 0000000000..16d1ec82de --- /dev/null +++ b/Lang/Maple/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Maple \ No newline at end of file diff --git a/Lang/Maple/Identity-matrix b/Lang/Maple/Identity-matrix new file mode 120000 index 0000000000..786bb2c2c1 --- /dev/null +++ b/Lang/Maple/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Maple \ No newline at end of file diff --git a/Lang/Maple/Include-a-file b/Lang/Maple/Include-a-file new file mode 120000 index 0000000000..cb5edc17ae --- /dev/null +++ b/Lang/Maple/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Maple \ No newline at end of file diff --git a/Lang/Maple/Infinity b/Lang/Maple/Infinity new file mode 120000 index 0000000000..492619bce1 --- /dev/null +++ b/Lang/Maple/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Maple \ No newline at end of file diff --git a/Lang/Maple/Introspection b/Lang/Maple/Introspection new file mode 120000 index 0000000000..fa25c1b8f6 --- /dev/null +++ b/Lang/Maple/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Maple \ No newline at end of file diff --git a/Lang/Maple/Least-common-multiple b/Lang/Maple/Least-common-multiple new file mode 120000 index 0000000000..eab4b6c094 --- /dev/null +++ b/Lang/Maple/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Maple \ No newline at end of file diff --git a/Lang/Maple/Letter-frequency b/Lang/Maple/Letter-frequency new file mode 120000 index 0000000000..d91a01912c --- /dev/null +++ b/Lang/Maple/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Maple \ No newline at end of file diff --git a/Lang/Maple/Levenshtein-distance b/Lang/Maple/Levenshtein-distance new file mode 120000 index 0000000000..4115557b31 --- /dev/null +++ b/Lang/Maple/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Maple \ No newline at end of file diff --git a/Lang/Maple/Literals-Floating-point b/Lang/Maple/Literals-Floating-point new file mode 120000 index 0000000000..e03cf0214a --- /dev/null +++ b/Lang/Maple/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Maple \ No newline at end of file diff --git a/Lang/Maple/Literals-String b/Lang/Maple/Literals-String new file mode 120000 index 0000000000..4430f4dd0a --- /dev/null +++ b/Lang/Maple/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Maple \ No newline at end of file diff --git a/Lang/Maple/Longest-common-subsequence b/Lang/Maple/Longest-common-subsequence new file mode 120000 index 0000000000..99d09a8e79 --- /dev/null +++ b/Lang/Maple/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-Break b/Lang/Maple/Loops-Break new file mode 120000 index 0000000000..9caa97fc3e --- /dev/null +++ b/Lang/Maple/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-Continue b/Lang/Maple/Loops-Continue new file mode 120000 index 0000000000..69e6086c49 --- /dev/null +++ b/Lang/Maple/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-Do-while b/Lang/Maple/Loops-Do-while new file mode 120000 index 0000000000..0c2adfcf17 --- /dev/null +++ b/Lang/Maple/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-Downward-for b/Lang/Maple/Loops-Downward-for new file mode 120000 index 0000000000..bbaacb6727 --- /dev/null +++ b/Lang/Maple/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-For b/Lang/Maple/Loops-For new file mode 120000 index 0000000000..bb797ef329 --- /dev/null +++ b/Lang/Maple/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-Infinite b/Lang/Maple/Loops-Infinite new file mode 120000 index 0000000000..fb5edf8591 --- /dev/null +++ b/Lang/Maple/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Maple \ No newline at end of file diff --git a/Lang/Maple/Loops-While b/Lang/Maple/Loops-While new file mode 120000 index 0000000000..fac9403e3c --- /dev/null +++ b/Lang/Maple/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Maple \ No newline at end of file diff --git a/Lang/Maple/Modular-exponentiation b/Lang/Maple/Modular-exponentiation new file mode 120000 index 0000000000..f6f0c777bd --- /dev/null +++ b/Lang/Maple/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Maple \ No newline at end of file diff --git a/Lang/Mathematica/0DESCRIPTION b/Lang/Mathematica/0DESCRIPTION new file mode 100644 index 0000000000..604a261a34 --- /dev/null +++ b/Lang/Mathematica/0DESCRIPTION @@ -0,0 +1,10 @@ +{{language|Mathematica +|strength=strong +|checking=dynamic +|gc=yes +|LCT=yes}}{{implementation|Mathematica}}{{language programming paradigm|Declarative}}{{language programming paradigm|Functional}} +[[Mathematica]] is the name of Wolfram Research's mathematics analysis tool, as well as the name of the principal language used to control it. + +
+ +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Mathematica/100-doors b/Lang/Mathematica/100-doors new file mode 120000 index 0000000000..2529ddd297 --- /dev/null +++ b/Lang/Mathematica/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/24-game b/Lang/Mathematica/24-game new file mode 120000 index 0000000000..f21bb62d98 --- /dev/null +++ b/Lang/Mathematica/24-game @@ -0,0 +1 @@ +../../Task/24-game/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/24-game-Solve b/Lang/Mathematica/24-game-Solve new file mode 120000 index 0000000000..3fff8d1d5f --- /dev/null +++ b/Lang/Mathematica/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/99-Bottles-of-Beer b/Lang/Mathematica/99-Bottles-of-Beer new file mode 120000 index 0000000000..2705b15271 --- /dev/null +++ b/Lang/Mathematica/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/A+B b/Lang/Mathematica/A+B new file mode 120000 index 0000000000..957a3e48db --- /dev/null +++ b/Lang/Mathematica/A+B @@ -0,0 +1 @@ +../../Task/A+B/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Accumulator-factory b/Lang/Mathematica/Accumulator-factory new file mode 120000 index 0000000000..1cc9b13948 --- /dev/null +++ b/Lang/Mathematica/Accumulator-factory @@ -0,0 +1 @@ +../../Task/Accumulator-factory/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Ackermann-function b/Lang/Mathematica/Ackermann-function new file mode 120000 index 0000000000..f2342ed85c --- /dev/null +++ b/Lang/Mathematica/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Active-object b/Lang/Mathematica/Active-object new file mode 120000 index 0000000000..b4d6dd8ef1 --- /dev/null +++ b/Lang/Mathematica/Active-object @@ -0,0 +1 @@ +../../Task/Active-object/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Add-a-variable-to-a-class-instance-at-runtime b/Lang/Mathematica/Add-a-variable-to-a-class-instance-at-runtime new file mode 120000 index 0000000000..b475430d27 --- /dev/null +++ b/Lang/Mathematica/Add-a-variable-to-a-class-instance-at-runtime @@ -0,0 +1 @@ +../../Task/Add-a-variable-to-a-class-instance-at-runtime/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Align-columns b/Lang/Mathematica/Align-columns new file mode 120000 index 0000000000..df857a0345 --- /dev/null +++ b/Lang/Mathematica/Align-columns @@ -0,0 +1 @@ +../../Task/Align-columns/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Anagrams b/Lang/Mathematica/Anagrams new file mode 120000 index 0000000000..b63aa214fb --- /dev/null +++ b/Lang/Mathematica/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Anagrams-Deranged-anagrams b/Lang/Mathematica/Anagrams-Deranged-anagrams new file mode 120000 index 0000000000..69d8b63d3f --- /dev/null +++ b/Lang/Mathematica/Anagrams-Deranged-anagrams @@ -0,0 +1 @@ +../../Task/Anagrams-Deranged-anagrams/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Animate-a-pendulum b/Lang/Mathematica/Animate-a-pendulum new file mode 120000 index 0000000000..d59f0d7d92 --- /dev/null +++ b/Lang/Mathematica/Animate-a-pendulum @@ -0,0 +1 @@ +../../Task/Animate-a-pendulum/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Animation b/Lang/Mathematica/Animation new file mode 120000 index 0000000000..7a38363ab2 --- /dev/null +++ b/Lang/Mathematica/Animation @@ -0,0 +1 @@ +../../Task/Animation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Anonymous-recursion b/Lang/Mathematica/Anonymous-recursion new file mode 120000 index 0000000000..3e73ac26a7 --- /dev/null +++ b/Lang/Mathematica/Anonymous-recursion @@ -0,0 +1 @@ +../../Task/Anonymous-recursion/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Apply-a-callback-to-an-array b/Lang/Mathematica/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..cb8fcaf36f --- /dev/null +++ b/Lang/Mathematica/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arbitrary-precision-integers-included b/Lang/Mathematica/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..7fcf201d66 --- /dev/null +++ b/Lang/Mathematica/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arena-storage-pool b/Lang/Mathematica/Arena-storage-pool new file mode 120000 index 0000000000..c58fbf03c1 --- /dev/null +++ b/Lang/Mathematica/Arena-storage-pool @@ -0,0 +1 @@ +../../Task/Arena-storage-pool/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arithmetic-Complex b/Lang/Mathematica/Arithmetic-Complex new file mode 120000 index 0000000000..fce66e2098 --- /dev/null +++ b/Lang/Mathematica/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arithmetic-Integer b/Lang/Mathematica/Arithmetic-Integer new file mode 120000 index 0000000000..f1716d8075 --- /dev/null +++ b/Lang/Mathematica/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arithmetic-Rational b/Lang/Mathematica/Arithmetic-Rational new file mode 120000 index 0000000000..9e16f59ae5 --- /dev/null +++ b/Lang/Mathematica/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arithmetic-evaluation b/Lang/Mathematica/Arithmetic-evaluation new file mode 120000 index 0000000000..2e124e9662 --- /dev/null +++ b/Lang/Mathematica/Arithmetic-evaluation @@ -0,0 +1 @@ +../../Task/Arithmetic-evaluation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arithmetic-geometric-mean b/Lang/Mathematica/Arithmetic-geometric-mean new file mode 120000 index 0000000000..bc76c58ace --- /dev/null +++ b/Lang/Mathematica/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Array-concatenation b/Lang/Mathematica/Array-concatenation new file mode 120000 index 0000000000..dfad5c2cef --- /dev/null +++ b/Lang/Mathematica/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arrays b/Lang/Mathematica/Arrays new file mode 120000 index 0000000000..52541db690 --- /dev/null +++ b/Lang/Mathematica/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Assertions b/Lang/Mathematica/Assertions new file mode 120000 index 0000000000..010cbcc63b --- /dev/null +++ b/Lang/Mathematica/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Associative-array-Creation b/Lang/Mathematica/Associative-array-Creation new file mode 120000 index 0000000000..aaa5d9d170 --- /dev/null +++ b/Lang/Mathematica/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Associative-array-Iteration b/Lang/Mathematica/Associative-array-Iteration new file mode 120000 index 0000000000..4091a2db7c --- /dev/null +++ b/Lang/Mathematica/Associative-array-Iteration @@ -0,0 +1 @@ +../../Task/Associative-array-Iteration/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Average-loop-length b/Lang/Mathematica/Average-loop-length new file mode 120000 index 0000000000..166962b379 --- /dev/null +++ b/Lang/Mathematica/Average-loop-length @@ -0,0 +1 @@ +../../Task/Average-loop-length/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Arithmetic-mean b/Lang/Mathematica/Averages-Arithmetic-mean new file mode 120000 index 0000000000..ff9eefa1ce --- /dev/null +++ b/Lang/Mathematica/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Mean-angle b/Lang/Mathematica/Averages-Mean-angle new file mode 120000 index 0000000000..cad2d170c6 --- /dev/null +++ b/Lang/Mathematica/Averages-Mean-angle @@ -0,0 +1 @@ +../../Task/Averages-Mean-angle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Mean-time-of-day b/Lang/Mathematica/Averages-Mean-time-of-day new file mode 120000 index 0000000000..9b0bbc68a3 --- /dev/null +++ b/Lang/Mathematica/Averages-Mean-time-of-day @@ -0,0 +1 @@ +../../Task/Averages-Mean-time-of-day/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Median b/Lang/Mathematica/Averages-Median new file mode 120000 index 0000000000..a687a0cc04 --- /dev/null +++ b/Lang/Mathematica/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Mode b/Lang/Mathematica/Averages-Mode new file mode 120000 index 0000000000..9e3b957d87 --- /dev/null +++ b/Lang/Mathematica/Averages-Mode @@ -0,0 +1 @@ +../../Task/Averages-Mode/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Pythagorean-means b/Lang/Mathematica/Averages-Pythagorean-means new file mode 120000 index 0000000000..de24cd6c11 --- /dev/null +++ b/Lang/Mathematica/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Root-mean-square b/Lang/Mathematica/Averages-Root-mean-square new file mode 120000 index 0000000000..70501e4703 --- /dev/null +++ b/Lang/Mathematica/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Averages-Simple-moving-average b/Lang/Mathematica/Averages-Simple-moving-average new file mode 120000 index 0000000000..dd305f9faf --- /dev/null +++ b/Lang/Mathematica/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Balanced-brackets b/Lang/Mathematica/Balanced-brackets new file mode 120000 index 0000000000..2b9a7c240e --- /dev/null +++ b/Lang/Mathematica/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Balanced-ternary b/Lang/Mathematica/Balanced-ternary new file mode 120000 index 0000000000..160b1c5293 --- /dev/null +++ b/Lang/Mathematica/Balanced-ternary @@ -0,0 +1 @@ +../../Task/Balanced-ternary/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Best-shuffle b/Lang/Mathematica/Best-shuffle new file mode 120000 index 0000000000..b64c90323d --- /dev/null +++ b/Lang/Mathematica/Best-shuffle @@ -0,0 +1 @@ +../../Task/Best-shuffle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Binary-search b/Lang/Mathematica/Binary-search new file mode 120000 index 0000000000..52f098f254 --- /dev/null +++ b/Lang/Mathematica/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Binary-strings b/Lang/Mathematica/Binary-strings new file mode 120000 index 0000000000..cd3a3343d0 --- /dev/null +++ b/Lang/Mathematica/Binary-strings @@ -0,0 +1 @@ +../../Task/Binary-strings/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap b/Lang/Mathematica/Bitmap new file mode 120000 index 0000000000..3f6ec69b48 --- /dev/null +++ b/Lang/Mathematica/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-B-zier-curves-Cubic b/Lang/Mathematica/Bitmap-B-zier-curves-Cubic new file mode 120000 index 0000000000..885a4c15a6 --- /dev/null +++ b/Lang/Mathematica/Bitmap-B-zier-curves-Cubic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Cubic/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-B-zier-curves-Quadratic b/Lang/Mathematica/Bitmap-B-zier-curves-Quadratic new file mode 120000 index 0000000000..8bd25afb11 --- /dev/null +++ b/Lang/Mathematica/Bitmap-B-zier-curves-Quadratic @@ -0,0 +1 @@ +../../Task/Bitmap-B-zier-curves-Quadratic/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Bresenhams-line-algorithm b/Lang/Mathematica/Bitmap-Bresenhams-line-algorithm new file mode 120000 index 0000000000..dab6601255 --- /dev/null +++ b/Lang/Mathematica/Bitmap-Bresenhams-line-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Bresenhams-line-algorithm/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Flood-fill b/Lang/Mathematica/Bitmap-Flood-fill new file mode 120000 index 0000000000..ca339b5664 --- /dev/null +++ b/Lang/Mathematica/Bitmap-Flood-fill @@ -0,0 +1 @@ +../../Task/Bitmap-Flood-fill/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Histogram b/Lang/Mathematica/Bitmap-Histogram new file mode 120000 index 0000000000..ed2706b1f8 --- /dev/null +++ b/Lang/Mathematica/Bitmap-Histogram @@ -0,0 +1 @@ +../../Task/Bitmap-Histogram/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Midpoint-circle-algorithm b/Lang/Mathematica/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..462167ea17 --- /dev/null +++ b/Lang/Mathematica/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Read-a-PPM-file b/Lang/Mathematica/Bitmap-Read-a-PPM-file new file mode 120000 index 0000000000..d797574a35 --- /dev/null +++ b/Lang/Mathematica/Bitmap-Read-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Read-a-PPM-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitmap-Write-a-PPM-file b/Lang/Mathematica/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..223a4fa4cc --- /dev/null +++ b/Lang/Mathematica/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bitwise-operations b/Lang/Mathematica/Bitwise-operations new file mode 120000 index 0000000000..d294e29903 --- /dev/null +++ b/Lang/Mathematica/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Box-the-compass b/Lang/Mathematica/Box-the-compass new file mode 120000 index 0000000000..e5fa4667d4 --- /dev/null +++ b/Lang/Mathematica/Box-the-compass @@ -0,0 +1 @@ +../../Task/Box-the-compass/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bulls-and-cows b/Lang/Mathematica/Bulls-and-cows new file mode 120000 index 0000000000..0d119e60d3 --- /dev/null +++ b/Lang/Mathematica/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Bulls-and-cows-Player b/Lang/Mathematica/Bulls-and-cows-Player new file mode 120000 index 0000000000..eef9554bcb --- /dev/null +++ b/Lang/Mathematica/Bulls-and-cows-Player @@ -0,0 +1 @@ +../../Task/Bulls-and-cows-Player/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/CRC-32 b/Lang/Mathematica/CRC-32 new file mode 120000 index 0000000000..24d363d46d --- /dev/null +++ b/Lang/Mathematica/CRC-32 @@ -0,0 +1 @@ +../../Task/CRC-32/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/CSV-to-HTML-translation b/Lang/Mathematica/CSV-to-HTML-translation new file mode 120000 index 0000000000..6f42bff1e7 --- /dev/null +++ b/Lang/Mathematica/CSV-to-HTML-translation @@ -0,0 +1 @@ +../../Task/CSV-to-HTML-translation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Caesar-cipher b/Lang/Mathematica/Caesar-cipher new file mode 120000 index 0000000000..bb94f0a517 --- /dev/null +++ b/Lang/Mathematica/Caesar-cipher @@ -0,0 +1 @@ +../../Task/Caesar-cipher/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Calendar b/Lang/Mathematica/Calendar new file mode 120000 index 0000000000..98920a2600 --- /dev/null +++ b/Lang/Mathematica/Calendar @@ -0,0 +1 @@ +../../Task/Calendar/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Call-a-foreign-language-function b/Lang/Mathematica/Call-a-foreign-language-function new file mode 120000 index 0000000000..934c7bd4e3 --- /dev/null +++ b/Lang/Mathematica/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Call-a-function b/Lang/Mathematica/Call-a-function new file mode 120000 index 0000000000..f3a1d42e86 --- /dev/null +++ b/Lang/Mathematica/Call-a-function @@ -0,0 +1 @@ +../../Task/Call-a-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Call-a-function-in-a-shared-library b/Lang/Mathematica/Call-a-function-in-a-shared-library new file mode 120000 index 0000000000..ffb6e1e157 --- /dev/null +++ b/Lang/Mathematica/Call-a-function-in-a-shared-library @@ -0,0 +1 @@ +../../Task/Call-a-function-in-a-shared-library/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Carmichael-3-strong-pseudoprimes b/Lang/Mathematica/Carmichael-3-strong-pseudoprimes new file mode 120000 index 0000000000..bcae2481d7 --- /dev/null +++ b/Lang/Mathematica/Carmichael-3-strong-pseudoprimes @@ -0,0 +1 @@ +../../Task/Carmichael-3-strong-pseudoprimes/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Case-sensitivity-of-identifiers b/Lang/Mathematica/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..8e3e8abd7a --- /dev/null +++ b/Lang/Mathematica/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Catmull-Clark-subdivision-surface b/Lang/Mathematica/Catmull-Clark-subdivision-surface new file mode 120000 index 0000000000..8b83e320d1 --- /dev/null +++ b/Lang/Mathematica/Catmull-Clark-subdivision-surface @@ -0,0 +1 @@ +../../Task/Catmull-Clark-subdivision-surface/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Character-codes b/Lang/Mathematica/Character-codes new file mode 120000 index 0000000000..cb577e55a0 --- /dev/null +++ b/Lang/Mathematica/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Character-matching b/Lang/Mathematica/Character-matching new file mode 120000 index 0000000000..7e5b6b44bc --- /dev/null +++ b/Lang/Mathematica/Character-matching @@ -0,0 +1 @@ +../../Task/Character-matching/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Check-Machin-like-formulas b/Lang/Mathematica/Check-Machin-like-formulas new file mode 120000 index 0000000000..b5438b6f10 --- /dev/null +++ b/Lang/Mathematica/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Check-that-file-exists b/Lang/Mathematica/Check-that-file-exists new file mode 120000 index 0000000000..c5a19efea9 --- /dev/null +++ b/Lang/Mathematica/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Cholesky-decomposition b/Lang/Mathematica/Cholesky-decomposition new file mode 120000 index 0000000000..241634050d --- /dev/null +++ b/Lang/Mathematica/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Closest-pair-problem b/Lang/Mathematica/Closest-pair-problem new file mode 120000 index 0000000000..780d73aead --- /dev/null +++ b/Lang/Mathematica/Closest-pair-problem @@ -0,0 +1 @@ +../../Task/Closest-pair-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Collections b/Lang/Mathematica/Collections new file mode 120000 index 0000000000..923e4e4d31 --- /dev/null +++ b/Lang/Mathematica/Collections @@ -0,0 +1 @@ +../../Task/Collections/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Color-quantization b/Lang/Mathematica/Color-quantization new file mode 120000 index 0000000000..3b6a1574f2 --- /dev/null +++ b/Lang/Mathematica/Color-quantization @@ -0,0 +1 @@ +../../Task/Color-quantization/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Colour-bars-Display b/Lang/Mathematica/Colour-bars-Display new file mode 120000 index 0000000000..7eca91da90 --- /dev/null +++ b/Lang/Mathematica/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Combinations b/Lang/Mathematica/Combinations new file mode 120000 index 0000000000..0d932e3fde --- /dev/null +++ b/Lang/Mathematica/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Combinations-with-repetitions b/Lang/Mathematica/Combinations-with-repetitions new file mode 120000 index 0000000000..faf8b7aa96 --- /dev/null +++ b/Lang/Mathematica/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Command-line-arguments b/Lang/Mathematica/Command-line-arguments new file mode 120000 index 0000000000..a51c336537 --- /dev/null +++ b/Lang/Mathematica/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Comments b/Lang/Mathematica/Comments new file mode 120000 index 0000000000..c853e80199 --- /dev/null +++ b/Lang/Mathematica/Comments @@ -0,0 +1 @@ +../../Task/Comments/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Compile-time-calculation b/Lang/Mathematica/Compile-time-calculation new file mode 120000 index 0000000000..8c41334b88 --- /dev/null +++ b/Lang/Mathematica/Compile-time-calculation @@ -0,0 +1 @@ +../../Task/Compile-time-calculation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Compound-data-type b/Lang/Mathematica/Compound-data-type new file mode 120000 index 0000000000..d321aee88e --- /dev/null +++ b/Lang/Mathematica/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Concurrent-computing b/Lang/Mathematica/Concurrent-computing new file mode 120000 index 0000000000..b83db4c960 --- /dev/null +++ b/Lang/Mathematica/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Constrained-random-points-on-a-circle b/Lang/Mathematica/Constrained-random-points-on-a-circle new file mode 120000 index 0000000000..5de0a00375 --- /dev/null +++ b/Lang/Mathematica/Constrained-random-points-on-a-circle @@ -0,0 +1 @@ +../../Task/Constrained-random-points-on-a-circle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Continued-fraction b/Lang/Mathematica/Continued-fraction new file mode 120000 index 0000000000..d1be4f6051 --- /dev/null +++ b/Lang/Mathematica/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Continued-fraction-Arithmetic-Construct-from-rational-number b/Lang/Mathematica/Continued-fraction-Arithmetic-Construct-from-rational-number new file mode 120000 index 0000000000..cbbedaa641 --- /dev/null +++ b/Lang/Mathematica/Continued-fraction-Arithmetic-Construct-from-rational-number @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Conways-Game-of-Life b/Lang/Mathematica/Conways-Game-of-Life new file mode 120000 index 0000000000..484767ca5d --- /dev/null +++ b/Lang/Mathematica/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Count-in-factors b/Lang/Mathematica/Count-in-factors new file mode 120000 index 0000000000..c964d2cab3 --- /dev/null +++ b/Lang/Mathematica/Count-in-factors @@ -0,0 +1 @@ +../../Task/Count-in-factors/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Count-in-octal b/Lang/Mathematica/Count-in-octal new file mode 120000 index 0000000000..4d5e9819d6 --- /dev/null +++ b/Lang/Mathematica/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Count-occurrences-of-a-substring b/Lang/Mathematica/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..5dd6a4d93a --- /dev/null +++ b/Lang/Mathematica/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Count-the-coins b/Lang/Mathematica/Count-the-coins new file mode 120000 index 0000000000..0bba79f7d9 --- /dev/null +++ b/Lang/Mathematica/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Create-a-file b/Lang/Mathematica/Create-a-file new file mode 120000 index 0000000000..e871a603b3 --- /dev/null +++ b/Lang/Mathematica/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Create-a-two-dimensional-array-at-runtime b/Lang/Mathematica/Create-a-two-dimensional-array-at-runtime new file mode 120000 index 0000000000..bd4e87662c --- /dev/null +++ b/Lang/Mathematica/Create-a-two-dimensional-array-at-runtime @@ -0,0 +1 @@ +../../Task/Create-a-two-dimensional-array-at-runtime/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Create-an-HTML-table b/Lang/Mathematica/Create-an-HTML-table new file mode 120000 index 0000000000..783f865c21 --- /dev/null +++ b/Lang/Mathematica/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Date-format b/Lang/Mathematica/Date-format new file mode 120000 index 0000000000..aa1c3f3d98 --- /dev/null +++ b/Lang/Mathematica/Date-format @@ -0,0 +1 @@ +../../Task/Date-format/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Date-manipulation b/Lang/Mathematica/Date-manipulation new file mode 120000 index 0000000000..333163422f --- /dev/null +++ b/Lang/Mathematica/Date-manipulation @@ -0,0 +1 @@ +../../Task/Date-manipulation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Day-of-the-week b/Lang/Mathematica/Day-of-the-week new file mode 120000 index 0000000000..3f2226c6e5 --- /dev/null +++ b/Lang/Mathematica/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Death-Star b/Lang/Mathematica/Death-Star new file mode 120000 index 0000000000..24a627f643 --- /dev/null +++ b/Lang/Mathematica/Death-Star @@ -0,0 +1 @@ +../../Task/Death-Star/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Deconvolution-1D b/Lang/Mathematica/Deconvolution-1D new file mode 120000 index 0000000000..32dbb08636 --- /dev/null +++ b/Lang/Mathematica/Deconvolution-1D @@ -0,0 +1 @@ +../../Task/Deconvolution-1D/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Deconvolution-2D+ b/Lang/Mathematica/Deconvolution-2D+ new file mode 120000 index 0000000000..ea05a28d22 --- /dev/null +++ b/Lang/Mathematica/Deconvolution-2D+ @@ -0,0 +1 @@ +../../Task/Deconvolution-2D+/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Delete-a-file b/Lang/Mathematica/Delete-a-file new file mode 120000 index 0000000000..611b2caf16 --- /dev/null +++ b/Lang/Mathematica/Delete-a-file @@ -0,0 +1 @@ +../../Task/Delete-a-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Detect-division-by-zero b/Lang/Mathematica/Detect-division-by-zero new file mode 120000 index 0000000000..cf98622be8 --- /dev/null +++ b/Lang/Mathematica/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Determine-if-a-string-is-numeric b/Lang/Mathematica/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..0c5289e9e0 --- /dev/null +++ b/Lang/Mathematica/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Determine-if-only-one-instance-is-running b/Lang/Mathematica/Determine-if-only-one-instance-is-running new file mode 120000 index 0000000000..7ad4796cd2 --- /dev/null +++ b/Lang/Mathematica/Determine-if-only-one-instance-is-running @@ -0,0 +1 @@ +../../Task/Determine-if-only-one-instance-is-running/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Digital-root b/Lang/Mathematica/Digital-root new file mode 120000 index 0000000000..c1e5c62832 --- /dev/null +++ b/Lang/Mathematica/Digital-root @@ -0,0 +1 @@ +../../Task/Digital-root/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Dinesmans-multiple-dwelling-problem b/Lang/Mathematica/Dinesmans-multiple-dwelling-problem new file mode 120000 index 0000000000..07cbe8dfe5 --- /dev/null +++ b/Lang/Mathematica/Dinesmans-multiple-dwelling-problem @@ -0,0 +1 @@ +../../Task/Dinesmans-multiple-dwelling-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Discordian-date b/Lang/Mathematica/Discordian-date new file mode 120000 index 0000000000..fb620d9bdf --- /dev/null +++ b/Lang/Mathematica/Discordian-date @@ -0,0 +1 @@ +../../Task/Discordian-date/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Distributed-programming b/Lang/Mathematica/Distributed-programming new file mode 120000 index 0000000000..8169bbbccb --- /dev/null +++ b/Lang/Mathematica/Distributed-programming @@ -0,0 +1 @@ +../../Task/Distributed-programming/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Documentation b/Lang/Mathematica/Documentation new file mode 120000 index 0000000000..c3520ae684 --- /dev/null +++ b/Lang/Mathematica/Documentation @@ -0,0 +1 @@ +../../Task/Documentation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Dot-product b/Lang/Mathematica/Dot-product new file mode 120000 index 0000000000..30f94f82a7 --- /dev/null +++ b/Lang/Mathematica/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Draw-a-cuboid b/Lang/Mathematica/Draw-a-cuboid new file mode 120000 index 0000000000..80796b0efe --- /dev/null +++ b/Lang/Mathematica/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Draw-a-sphere b/Lang/Mathematica/Draw-a-sphere new file mode 120000 index 0000000000..ce83daa3c0 --- /dev/null +++ b/Lang/Mathematica/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Dutch-national-flag-problem b/Lang/Mathematica/Dutch-national-flag-problem new file mode 120000 index 0000000000..16f6e69c30 --- /dev/null +++ b/Lang/Mathematica/Dutch-national-flag-problem @@ -0,0 +1 @@ +../../Task/Dutch-national-flag-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Dynamic-variable-names b/Lang/Mathematica/Dynamic-variable-names new file mode 120000 index 0000000000..57e4cfc51e --- /dev/null +++ b/Lang/Mathematica/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Element-wise-operations b/Lang/Mathematica/Element-wise-operations new file mode 120000 index 0000000000..79072bc929 --- /dev/null +++ b/Lang/Mathematica/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Empty-directory b/Lang/Mathematica/Empty-directory new file mode 120000 index 0000000000..7caa41f078 --- /dev/null +++ b/Lang/Mathematica/Empty-directory @@ -0,0 +1 @@ +../../Task/Empty-directory/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Empty-program b/Lang/Mathematica/Empty-program new file mode 120000 index 0000000000..7445caa973 --- /dev/null +++ b/Lang/Mathematica/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Empty-string b/Lang/Mathematica/Empty-string new file mode 120000 index 0000000000..9d919269ff --- /dev/null +++ b/Lang/Mathematica/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Enforced-immutability b/Lang/Mathematica/Enforced-immutability new file mode 120000 index 0000000000..d823de4194 --- /dev/null +++ b/Lang/Mathematica/Enforced-immutability @@ -0,0 +1 @@ +../../Task/Enforced-immutability/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Entropy b/Lang/Mathematica/Entropy new file mode 120000 index 0000000000..7398649cf3 --- /dev/null +++ b/Lang/Mathematica/Entropy @@ -0,0 +1 @@ +../../Task/Entropy/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Enumerations b/Lang/Mathematica/Enumerations new file mode 120000 index 0000000000..12b22192e9 --- /dev/null +++ b/Lang/Mathematica/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Equilibrium-index b/Lang/Mathematica/Equilibrium-index new file mode 120000 index 0000000000..1bfa9a521c --- /dev/null +++ b/Lang/Mathematica/Equilibrium-index @@ -0,0 +1 @@ +../../Task/Equilibrium-index/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Ethiopian-multiplication b/Lang/Mathematica/Ethiopian-multiplication new file mode 120000 index 0000000000..73a2ccc91e --- /dev/null +++ b/Lang/Mathematica/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Euler-method b/Lang/Mathematica/Euler-method new file mode 120000 index 0000000000..6adbb466d0 --- /dev/null +++ b/Lang/Mathematica/Euler-method @@ -0,0 +1 @@ +../../Task/Euler-method/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Evaluate-binomial-coefficients b/Lang/Mathematica/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..58544e4bc5 --- /dev/null +++ b/Lang/Mathematica/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Even-or-odd b/Lang/Mathematica/Even-or-odd new file mode 120000 index 0000000000..14f84b700c --- /dev/null +++ b/Lang/Mathematica/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Events b/Lang/Mathematica/Events new file mode 120000 index 0000000000..68524994f4 --- /dev/null +++ b/Lang/Mathematica/Events @@ -0,0 +1 @@ +../../Task/Events/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Evolutionary-algorithm b/Lang/Mathematica/Evolutionary-algorithm new file mode 120000 index 0000000000..6d2fbe8ba6 --- /dev/null +++ b/Lang/Mathematica/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Exceptions b/Lang/Mathematica/Exceptions new file mode 120000 index 0000000000..41c54ae93a --- /dev/null +++ b/Lang/Mathematica/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Exceptions-Catch-an-exception-thrown-in-a-nested-call b/Lang/Mathematica/Exceptions-Catch-an-exception-thrown-in-a-nested-call new file mode 120000 index 0000000000..cb80094ed2 --- /dev/null +++ b/Lang/Mathematica/Exceptions-Catch-an-exception-thrown-in-a-nested-call @@ -0,0 +1 @@ +../../Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Execute-HQ9+ b/Lang/Mathematica/Execute-HQ9+ new file mode 120000 index 0000000000..8af4009b00 --- /dev/null +++ b/Lang/Mathematica/Execute-HQ9+ @@ -0,0 +1 @@ +../../Task/Execute-HQ9+/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Execute-a-system-command b/Lang/Mathematica/Execute-a-system-command new file mode 120000 index 0000000000..9e6e9661c5 --- /dev/null +++ b/Lang/Mathematica/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Exponentiation-operator b/Lang/Mathematica/Exponentiation-operator new file mode 120000 index 0000000000..6f5d42938c --- /dev/null +++ b/Lang/Mathematica/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Extend-your-language b/Lang/Mathematica/Extend-your-language new file mode 120000 index 0000000000..3d61a49bfb --- /dev/null +++ b/Lang/Mathematica/Extend-your-language @@ -0,0 +1 @@ +../../Task/Extend-your-language/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Extreme-floating-point-values b/Lang/Mathematica/Extreme-floating-point-values new file mode 120000 index 0000000000..9eb874774f --- /dev/null +++ b/Lang/Mathematica/Extreme-floating-point-values @@ -0,0 +1 @@ +../../Task/Extreme-floating-point-values/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Factorial b/Lang/Mathematica/Factorial new file mode 120000 index 0000000000..4fb05123c7 --- /dev/null +++ b/Lang/Mathematica/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Factors-of-a-Mersenne-number b/Lang/Mathematica/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..f67601376b --- /dev/null +++ b/Lang/Mathematica/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Factors-of-an-integer b/Lang/Mathematica/Factors-of-an-integer new file mode 120000 index 0000000000..50fa8d2be4 --- /dev/null +++ b/Lang/Mathematica/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Fast-Fourier-transform b/Lang/Mathematica/Fast-Fourier-transform new file mode 120000 index 0000000000..dab128dd91 --- /dev/null +++ b/Lang/Mathematica/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Fibonacci-n-step-number-sequences b/Lang/Mathematica/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..04470972e1 --- /dev/null +++ b/Lang/Mathematica/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Fibonacci-sequence b/Lang/Mathematica/Fibonacci-sequence new file mode 120000 index 0000000000..b941b657db --- /dev/null +++ b/Lang/Mathematica/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/File-IO b/Lang/Mathematica/File-IO new file mode 120000 index 0000000000..166d039ba5 --- /dev/null +++ b/Lang/Mathematica/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/File-modification-time b/Lang/Mathematica/File-modification-time new file mode 120000 index 0000000000..0d12bb2435 --- /dev/null +++ b/Lang/Mathematica/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/File-size b/Lang/Mathematica/File-size new file mode 120000 index 0000000000..9f033a3cb3 --- /dev/null +++ b/Lang/Mathematica/File-size @@ -0,0 +1 @@ +../../Task/File-size/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Filter b/Lang/Mathematica/Filter new file mode 120000 index 0000000000..c53aa4d1bc --- /dev/null +++ b/Lang/Mathematica/Filter @@ -0,0 +1 @@ +../../Task/Filter/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Find-common-directory-path b/Lang/Mathematica/Find-common-directory-path new file mode 120000 index 0000000000..dd01c871ba --- /dev/null +++ b/Lang/Mathematica/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/Mathematica/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..e94fdadc2d --- /dev/null +++ b/Lang/Mathematica/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Find-limit-of-recursion b/Lang/Mathematica/Find-limit-of-recursion new file mode 120000 index 0000000000..4d401bc9d4 --- /dev/null +++ b/Lang/Mathematica/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Find-the-missing-permutation b/Lang/Mathematica/Find-the-missing-permutation new file mode 120000 index 0000000000..a66a4e753f --- /dev/null +++ b/Lang/Mathematica/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/First-class-functions b/Lang/Mathematica/First-class-functions new file mode 120000 index 0000000000..f9d3abaa1c --- /dev/null +++ b/Lang/Mathematica/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/First-class-functions-Use-numbers-analogously b/Lang/Mathematica/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..f6a23f5f1a --- /dev/null +++ b/Lang/Mathematica/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Five-weekends b/Lang/Mathematica/Five-weekends new file mode 120000 index 0000000000..2c360d3f89 --- /dev/null +++ b/Lang/Mathematica/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/FizzBuzz b/Lang/Mathematica/FizzBuzz new file mode 120000 index 0000000000..ce6d8dc54f --- /dev/null +++ b/Lang/Mathematica/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Flatten-a-list b/Lang/Mathematica/Flatten-a-list new file mode 120000 index 0000000000..86a7dbf8b2 --- /dev/null +++ b/Lang/Mathematica/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Floyds-triangle b/Lang/Mathematica/Floyds-triangle new file mode 120000 index 0000000000..219f80241f --- /dev/null +++ b/Lang/Mathematica/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Forest-fire b/Lang/Mathematica/Forest-fire new file mode 120000 index 0000000000..f5706f1246 --- /dev/null +++ b/Lang/Mathematica/Forest-fire @@ -0,0 +1 @@ +../../Task/Forest-fire/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Fork b/Lang/Mathematica/Fork new file mode 120000 index 0000000000..13ad57386c --- /dev/null +++ b/Lang/Mathematica/Fork @@ -0,0 +1 @@ +../../Task/Fork/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Formatted-numeric-output b/Lang/Mathematica/Formatted-numeric-output new file mode 120000 index 0000000000..882c23773f --- /dev/null +++ b/Lang/Mathematica/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Forward-difference b/Lang/Mathematica/Forward-difference new file mode 120000 index 0000000000..079fb6e1b4 --- /dev/null +++ b/Lang/Mathematica/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Four-bit-adder b/Lang/Mathematica/Four-bit-adder new file mode 120000 index 0000000000..84496f4b45 --- /dev/null +++ b/Lang/Mathematica/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Fractal-tree b/Lang/Mathematica/Fractal-tree new file mode 120000 index 0000000000..8aabe331b5 --- /dev/null +++ b/Lang/Mathematica/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Function-composition b/Lang/Mathematica/Function-composition new file mode 120000 index 0000000000..edddbb8874 --- /dev/null +++ b/Lang/Mathematica/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Function-definition b/Lang/Mathematica/Function-definition new file mode 120000 index 0000000000..1f148cf789 --- /dev/null +++ b/Lang/Mathematica/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Function-frequency b/Lang/Mathematica/Function-frequency new file mode 120000 index 0000000000..f7a2eb71b0 --- /dev/null +++ b/Lang/Mathematica/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/GUI-Maximum-window-dimensions b/Lang/Mathematica/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..8ced3fe070 --- /dev/null +++ b/Lang/Mathematica/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/GUI-component-interaction b/Lang/Mathematica/GUI-component-interaction new file mode 120000 index 0000000000..059840bf60 --- /dev/null +++ b/Lang/Mathematica/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/GUI-enabling-disabling-of-controls b/Lang/Mathematica/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..694f0e705b --- /dev/null +++ b/Lang/Mathematica/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Gamma-function b/Lang/Mathematica/Gamma-function new file mode 120000 index 0000000000..4a2bb81f42 --- /dev/null +++ b/Lang/Mathematica/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Generic-swap b/Lang/Mathematica/Generic-swap new file mode 120000 index 0000000000..3c109ddc5a --- /dev/null +++ b/Lang/Mathematica/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Gray-code b/Lang/Mathematica/Gray-code new file mode 120000 index 0000000000..c10c8eb06a --- /dev/null +++ b/Lang/Mathematica/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Grayscale-image b/Lang/Mathematica/Grayscale-image new file mode 120000 index 0000000000..a26326d2c3 --- /dev/null +++ b/Lang/Mathematica/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Greatest-common-divisor b/Lang/Mathematica/Greatest-common-divisor new file mode 120000 index 0000000000..acccdad8e7 --- /dev/null +++ b/Lang/Mathematica/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Greatest-element-of-a-list b/Lang/Mathematica/Greatest-element-of-a-list new file mode 120000 index 0000000000..09ddf7ee5c --- /dev/null +++ b/Lang/Mathematica/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Greatest-subsequential-sum b/Lang/Mathematica/Greatest-subsequential-sum new file mode 120000 index 0000000000..9ed30c2540 --- /dev/null +++ b/Lang/Mathematica/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Greyscale-bars-Display b/Lang/Mathematica/Greyscale-bars-Display new file mode 120000 index 0000000000..19875f3023 --- /dev/null +++ b/Lang/Mathematica/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Guess-the-number b/Lang/Mathematica/Guess-the-number new file mode 120000 index 0000000000..f8f0611372 --- /dev/null +++ b/Lang/Mathematica/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Guess-the-number-With-feedback b/Lang/Mathematica/Guess-the-number-With-feedback new file mode 120000 index 0000000000..31d042a3cb --- /dev/null +++ b/Lang/Mathematica/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Guess-the-number-With-feedback-player b/Lang/Mathematica/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..56824819ff --- /dev/null +++ b/Lang/Mathematica/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/HTTP b/Lang/Mathematica/HTTP new file mode 120000 index 0000000000..14d2ba4223 --- /dev/null +++ b/Lang/Mathematica/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/HTTPS b/Lang/Mathematica/HTTPS new file mode 120000 index 0000000000..486b74f474 --- /dev/null +++ b/Lang/Mathematica/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/HTTPS-Authenticated b/Lang/Mathematica/HTTPS-Authenticated new file mode 120000 index 0000000000..cfd208b248 --- /dev/null +++ b/Lang/Mathematica/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/HTTPS-Client-authenticated b/Lang/Mathematica/HTTPS-Client-authenticated new file mode 120000 index 0000000000..fafdebc629 --- /dev/null +++ b/Lang/Mathematica/HTTPS-Client-authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Client-authenticated/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hailstone-sequence b/Lang/Mathematica/Hailstone-sequence new file mode 120000 index 0000000000..95b4bdefeb --- /dev/null +++ b/Lang/Mathematica/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hamming-numbers b/Lang/Mathematica/Hamming-numbers new file mode 120000 index 0000000000..cd0587bad5 --- /dev/null +++ b/Lang/Mathematica/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Happy-numbers b/Lang/Mathematica/Happy-numbers new file mode 120000 index 0000000000..6bb7e2dbcf --- /dev/null +++ b/Lang/Mathematica/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hash-from-two-arrays b/Lang/Mathematica/Hash-from-two-arrays new file mode 120000 index 0000000000..54703631b3 --- /dev/null +++ b/Lang/Mathematica/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Haversine-formula b/Lang/Mathematica/Haversine-formula new file mode 120000 index 0000000000..d7c56578b3 --- /dev/null +++ b/Lang/Mathematica/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hello-world-Graphical b/Lang/Mathematica/Hello-world-Graphical new file mode 120000 index 0000000000..7740c8ce08 --- /dev/null +++ b/Lang/Mathematica/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hello-world-Line-printer b/Lang/Mathematica/Hello-world-Line-printer new file mode 120000 index 0000000000..017b86a358 --- /dev/null +++ b/Lang/Mathematica/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hello-world-Newline-omission b/Lang/Mathematica/Hello-world-Newline-omission new file mode 120000 index 0000000000..c44cdc81ea --- /dev/null +++ b/Lang/Mathematica/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hello-world-Standard-error b/Lang/Mathematica/Hello-world-Standard-error new file mode 120000 index 0000000000..7c7635de0b --- /dev/null +++ b/Lang/Mathematica/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hello-world-Text b/Lang/Mathematica/Hello-world-Text new file mode 120000 index 0000000000..4a6e45498e --- /dev/null +++ b/Lang/Mathematica/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Higher-order-functions b/Lang/Mathematica/Higher-order-functions new file mode 120000 index 0000000000..a41498c867 --- /dev/null +++ b/Lang/Mathematica/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hofstadter-Conway-$10,000-sequence b/Lang/Mathematica/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..22c4b8a588 --- /dev/null +++ b/Lang/Mathematica/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hofstadter-Figure-Figure-sequences b/Lang/Mathematica/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..c033267823 --- /dev/null +++ b/Lang/Mathematica/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hofstadter-Q-sequence b/Lang/Mathematica/Hofstadter-Q-sequence new file mode 120000 index 0000000000..6a94d80dcf --- /dev/null +++ b/Lang/Mathematica/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Holidays-related-to-Easter b/Lang/Mathematica/Holidays-related-to-Easter new file mode 120000 index 0000000000..8c7b3239d7 --- /dev/null +++ b/Lang/Mathematica/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Horners-rule-for-polynomial-evaluation b/Lang/Mathematica/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..599ccf4809 --- /dev/null +++ b/Lang/Mathematica/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Host-introspection b/Lang/Mathematica/Host-introspection new file mode 120000 index 0000000000..6695d64238 --- /dev/null +++ b/Lang/Mathematica/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hostname b/Lang/Mathematica/Hostname new file mode 120000 index 0000000000..2c424ac650 --- /dev/null +++ b/Lang/Mathematica/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Hough-transform b/Lang/Mathematica/Hough-transform new file mode 120000 index 0000000000..c65ab3097f --- /dev/null +++ b/Lang/Mathematica/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Identity-matrix b/Lang/Mathematica/Identity-matrix new file mode 120000 index 0000000000..67a14f9f47 --- /dev/null +++ b/Lang/Mathematica/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Image-convolution b/Lang/Mathematica/Image-convolution new file mode 120000 index 0000000000..3afa746c9e --- /dev/null +++ b/Lang/Mathematica/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Image-noise b/Lang/Mathematica/Image-noise new file mode 120000 index 0000000000..6601b154db --- /dev/null +++ b/Lang/Mathematica/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Include-a-file b/Lang/Mathematica/Include-a-file new file mode 120000 index 0000000000..7dcd1b9e0e --- /dev/null +++ b/Lang/Mathematica/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Increment-a-numerical-string b/Lang/Mathematica/Increment-a-numerical-string new file mode 120000 index 0000000000..cf2e5c1755 --- /dev/null +++ b/Lang/Mathematica/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Infinity b/Lang/Mathematica/Infinity new file mode 120000 index 0000000000..20127ed91f --- /dev/null +++ b/Lang/Mathematica/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Input-loop b/Lang/Mathematica/Input-loop new file mode 120000 index 0000000000..0f07599a25 --- /dev/null +++ b/Lang/Mathematica/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Integer-comparison b/Lang/Mathematica/Integer-comparison new file mode 120000 index 0000000000..401cd4d504 --- /dev/null +++ b/Lang/Mathematica/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Integer-sequence b/Lang/Mathematica/Integer-sequence new file mode 120000 index 0000000000..da13120004 --- /dev/null +++ b/Lang/Mathematica/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Interactive-programming b/Lang/Mathematica/Interactive-programming new file mode 120000 index 0000000000..a91a298010 --- /dev/null +++ b/Lang/Mathematica/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Introspection b/Lang/Mathematica/Introspection new file mode 120000 index 0000000000..317a1f18f3 --- /dev/null +++ b/Lang/Mathematica/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Inverted-syntax b/Lang/Mathematica/Inverted-syntax new file mode 120000 index 0000000000..03a839dad3 --- /dev/null +++ b/Lang/Mathematica/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/JSON b/Lang/Mathematica/JSON new file mode 120000 index 0000000000..ebfb21333b --- /dev/null +++ b/Lang/Mathematica/JSON @@ -0,0 +1 @@ +../../Task/JSON/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Jensens-Device b/Lang/Mathematica/Jensens-Device new file mode 120000 index 0000000000..6ee8666568 --- /dev/null +++ b/Lang/Mathematica/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Josephus-problem b/Lang/Mathematica/Josephus-problem new file mode 120000 index 0000000000..f45cd3aad3 --- /dev/null +++ b/Lang/Mathematica/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Joystick-position b/Lang/Mathematica/Joystick-position new file mode 120000 index 0000000000..98a7cc8437 --- /dev/null +++ b/Lang/Mathematica/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Kaprekar-numbers b/Lang/Mathematica/Kaprekar-numbers new file mode 120000 index 0000000000..d7c9c60a8f --- /dev/null +++ b/Lang/Mathematica/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Keyboard-macros b/Lang/Mathematica/Keyboard-macros new file mode 120000 index 0000000000..c05d5842e6 --- /dev/null +++ b/Lang/Mathematica/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knapsack-problem-0-1 b/Lang/Mathematica/Knapsack-problem-0-1 new file mode 120000 index 0000000000..8df415e76c --- /dev/null +++ b/Lang/Mathematica/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knapsack-problem-Bounded b/Lang/Mathematica/Knapsack-problem-Bounded new file mode 120000 index 0000000000..857e0f998e --- /dev/null +++ b/Lang/Mathematica/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knapsack-problem-Continuous b/Lang/Mathematica/Knapsack-problem-Continuous new file mode 120000 index 0000000000..99ded607b4 --- /dev/null +++ b/Lang/Mathematica/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knapsack-problem-Unbounded b/Lang/Mathematica/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..c5ac2234a1 --- /dev/null +++ b/Lang/Mathematica/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knights-tour b/Lang/Mathematica/Knights-tour new file mode 120000 index 0000000000..821c463084 --- /dev/null +++ b/Lang/Mathematica/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Knuth-shuffle b/Lang/Mathematica/Knuth-shuffle new file mode 120000 index 0000000000..179edf2d7a --- /dev/null +++ b/Lang/Mathematica/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/LU-decomposition b/Lang/Mathematica/LU-decomposition new file mode 120000 index 0000000000..b790d949fd --- /dev/null +++ b/Lang/Mathematica/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/LZW-compression b/Lang/Mathematica/LZW-compression new file mode 120000 index 0000000000..f59f4f116c --- /dev/null +++ b/Lang/Mathematica/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Langtons-ant b/Lang/Mathematica/Langtons-ant new file mode 120000 index 0000000000..7f8a026500 --- /dev/null +++ b/Lang/Mathematica/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Last-Friday-of-each-month b/Lang/Mathematica/Last-Friday-of-each-month new file mode 120000 index 0000000000..18ff15c05c --- /dev/null +++ b/Lang/Mathematica/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Leap-year b/Lang/Mathematica/Leap-year new file mode 120000 index 0000000000..ebebc6f05e --- /dev/null +++ b/Lang/Mathematica/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Least-common-multiple b/Lang/Mathematica/Least-common-multiple new file mode 120000 index 0000000000..00c19191ce --- /dev/null +++ b/Lang/Mathematica/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Letter-frequency b/Lang/Mathematica/Letter-frequency new file mode 120000 index 0000000000..7d60f21d17 --- /dev/null +++ b/Lang/Mathematica/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Levenshtein-distance b/Lang/Mathematica/Levenshtein-distance new file mode 120000 index 0000000000..d5c95a917f --- /dev/null +++ b/Lang/Mathematica/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Linear-congruential-generator b/Lang/Mathematica/Linear-congruential-generator new file mode 120000 index 0000000000..60b3e52e08 --- /dev/null +++ b/Lang/Mathematica/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/List-comprehensions b/Lang/Mathematica/List-comprehensions new file mode 120000 index 0000000000..4dc7c47a47 --- /dev/null +++ b/Lang/Mathematica/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Literals-Floating-point b/Lang/Mathematica/Literals-Floating-point new file mode 120000 index 0000000000..a5c74da2f4 --- /dev/null +++ b/Lang/Mathematica/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Literals-Integer b/Lang/Mathematica/Literals-Integer new file mode 120000 index 0000000000..98e8162cdd --- /dev/null +++ b/Lang/Mathematica/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Literals-String b/Lang/Mathematica/Literals-String new file mode 120000 index 0000000000..5563ac1e2e --- /dev/null +++ b/Lang/Mathematica/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Logical-operations b/Lang/Mathematica/Logical-operations new file mode 120000 index 0000000000..fdccb843d1 --- /dev/null +++ b/Lang/Mathematica/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Long-multiplication b/Lang/Mathematica/Long-multiplication new file mode 120000 index 0000000000..52db583a21 --- /dev/null +++ b/Lang/Mathematica/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Longest-common-subsequence b/Lang/Mathematica/Longest-common-subsequence new file mode 120000 index 0000000000..13b08241b8 --- /dev/null +++ b/Lang/Mathematica/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Longest-string-challenge b/Lang/Mathematica/Longest-string-challenge new file mode 120000 index 0000000000..8574670b53 --- /dev/null +++ b/Lang/Mathematica/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Look-and-say-sequence b/Lang/Mathematica/Look-and-say-sequence new file mode 120000 index 0000000000..288e49fcc8 --- /dev/null +++ b/Lang/Mathematica/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loop-over-multiple-arrays-simultaneously b/Lang/Mathematica/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..d2309a7d4c --- /dev/null +++ b/Lang/Mathematica/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Break b/Lang/Mathematica/Loops-Break new file mode 120000 index 0000000000..1c8d855592 --- /dev/null +++ b/Lang/Mathematica/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Continue b/Lang/Mathematica/Loops-Continue new file mode 120000 index 0000000000..063bdda72e --- /dev/null +++ b/Lang/Mathematica/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Do-while b/Lang/Mathematica/Loops-Do-while new file mode 120000 index 0000000000..722c0e2487 --- /dev/null +++ b/Lang/Mathematica/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Downward-for b/Lang/Mathematica/Loops-Downward-for new file mode 120000 index 0000000000..f1f13e264a --- /dev/null +++ b/Lang/Mathematica/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-For b/Lang/Mathematica/Loops-For new file mode 120000 index 0000000000..aa49c3a20a --- /dev/null +++ b/Lang/Mathematica/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-For-with-a-specified-step b/Lang/Mathematica/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..0ef710adea --- /dev/null +++ b/Lang/Mathematica/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Foreach b/Lang/Mathematica/Loops-Foreach new file mode 120000 index 0000000000..d50116a769 --- /dev/null +++ b/Lang/Mathematica/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Infinite b/Lang/Mathematica/Loops-Infinite new file mode 120000 index 0000000000..61b624a577 --- /dev/null +++ b/Lang/Mathematica/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-N-plus-one-half b/Lang/Mathematica/Loops-N-plus-one-half new file mode 120000 index 0000000000..a150a57c2e --- /dev/null +++ b/Lang/Mathematica/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-Nested b/Lang/Mathematica/Loops-Nested new file mode 120000 index 0000000000..6850b68cb9 --- /dev/null +++ b/Lang/Mathematica/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Loops-While b/Lang/Mathematica/Loops-While new file mode 120000 index 0000000000..408c633631 --- /dev/null +++ b/Lang/Mathematica/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Lucas-Lehmer-test b/Lang/Mathematica/Lucas-Lehmer-test new file mode 120000 index 0000000000..5046c111cd --- /dev/null +++ b/Lang/Mathematica/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Luhn-test-of-credit-card-numbers b/Lang/Mathematica/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..2b2057a310 --- /dev/null +++ b/Lang/Mathematica/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/MD5 b/Lang/Mathematica/MD5 new file mode 120000 index 0000000000..1d6094f966 --- /dev/null +++ b/Lang/Mathematica/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/MD5-Implementation b/Lang/Mathematica/MD5-Implementation new file mode 120000 index 0000000000..bc8cc1782f --- /dev/null +++ b/Lang/Mathematica/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Mandelbrot-set b/Lang/Mathematica/Mandelbrot-set new file mode 120000 index 0000000000..1adae2869e --- /dev/null +++ b/Lang/Mathematica/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Map-range b/Lang/Mathematica/Map-range new file mode 120000 index 0000000000..31b57d2869 --- /dev/null +++ b/Lang/Mathematica/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Matrix-arithmetic b/Lang/Mathematica/Matrix-arithmetic new file mode 120000 index 0000000000..7ab6855e7a --- /dev/null +++ b/Lang/Mathematica/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Matrix-exponentiation-operator b/Lang/Mathematica/Matrix-exponentiation-operator new file mode 120000 index 0000000000..bd5ff7ad05 --- /dev/null +++ b/Lang/Mathematica/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Matrix-multiplication b/Lang/Mathematica/Matrix-multiplication new file mode 120000 index 0000000000..ce870feaf2 --- /dev/null +++ b/Lang/Mathematica/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Matrix-transposition b/Lang/Mathematica/Matrix-transposition new file mode 120000 index 0000000000..b157249622 --- /dev/null +++ b/Lang/Mathematica/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Maze-generation b/Lang/Mathematica/Maze-generation new file mode 120000 index 0000000000..53b24affa2 --- /dev/null +++ b/Lang/Mathematica/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Maze-solving b/Lang/Mathematica/Maze-solving new file mode 120000 index 0000000000..69137fe3d4 --- /dev/null +++ b/Lang/Mathematica/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Median-filter b/Lang/Mathematica/Median-filter new file mode 120000 index 0000000000..fb023e3837 --- /dev/null +++ b/Lang/Mathematica/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Menu b/Lang/Mathematica/Menu new file mode 120000 index 0000000000..3196864d9c --- /dev/null +++ b/Lang/Mathematica/Menu @@ -0,0 +1 @@ +../../Task/Menu/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Middle-three-digits b/Lang/Mathematica/Middle-three-digits new file mode 120000 index 0000000000..696224fc27 --- /dev/null +++ b/Lang/Mathematica/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Miller-Rabin-primality-test b/Lang/Mathematica/Miller-Rabin-primality-test new file mode 120000 index 0000000000..400d0fb0e3 --- /dev/null +++ b/Lang/Mathematica/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Minesweeper-game b/Lang/Mathematica/Minesweeper-game new file mode 120000 index 0000000000..a7c92e035d --- /dev/null +++ b/Lang/Mathematica/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Modular-exponentiation b/Lang/Mathematica/Modular-exponentiation new file mode 120000 index 0000000000..c39c855d98 --- /dev/null +++ b/Lang/Mathematica/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Modular-inverse b/Lang/Mathematica/Modular-inverse new file mode 120000 index 0000000000..c5b3825196 --- /dev/null +++ b/Lang/Mathematica/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Monte-Carlo-methods b/Lang/Mathematica/Monte-Carlo-methods new file mode 120000 index 0000000000..25a787add8 --- /dev/null +++ b/Lang/Mathematica/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Monty-Hall-problem b/Lang/Mathematica/Monty-Hall-problem new file mode 120000 index 0000000000..fe43f7f2fb --- /dev/null +++ b/Lang/Mathematica/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Morse-code b/Lang/Mathematica/Morse-code new file mode 120000 index 0000000000..8bee646a30 --- /dev/null +++ b/Lang/Mathematica/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Mouse-position b/Lang/Mathematica/Mouse-position new file mode 120000 index 0000000000..50cc9c9c6d --- /dev/null +++ b/Lang/Mathematica/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multifactorial b/Lang/Mathematica/Multifactorial new file mode 120000 index 0000000000..3aaf3d8a46 --- /dev/null +++ b/Lang/Mathematica/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multiple-distinct-objects b/Lang/Mathematica/Multiple-distinct-objects new file mode 120000 index 0000000000..c2c8812459 --- /dev/null +++ b/Lang/Mathematica/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multiple-regression b/Lang/Mathematica/Multiple-regression new file mode 120000 index 0000000000..9bb9bb3a9f --- /dev/null +++ b/Lang/Mathematica/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multiplication-tables b/Lang/Mathematica/Multiplication-tables new file mode 120000 index 0000000000..e912a93f04 --- /dev/null +++ b/Lang/Mathematica/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multiplicative-order b/Lang/Mathematica/Multiplicative-order new file mode 120000 index 0000000000..33778f412e --- /dev/null +++ b/Lang/Mathematica/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Multisplit b/Lang/Mathematica/Multisplit new file mode 120000 index 0000000000..7eb7e1a93d --- /dev/null +++ b/Lang/Mathematica/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Mutual-recursion b/Lang/Mathematica/Mutual-recursion new file mode 120000 index 0000000000..8d667d99c0 --- /dev/null +++ b/Lang/Mathematica/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Ordered-words b/Lang/Mathematica/Ordered-words new file mode 120000 index 0000000000..256853473b --- /dev/null +++ b/Lang/Mathematica/Ordered-words @@ -0,0 +1 @@ +../../Task/Ordered-words/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pi b/Lang/Mathematica/Pi new file mode 120000 index 0000000000..0990ddaefd --- /dev/null +++ b/Lang/Mathematica/Pi @@ -0,0 +1 @@ +../../Task/Pi/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Quine b/Lang/Mathematica/Quine new file mode 120000 index 0000000000..9c89845289 --- /dev/null +++ b/Lang/Mathematica/Quine @@ -0,0 +1 @@ +../../Task/Quine/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Search-a-list b/Lang/Mathematica/Search-a-list new file mode 120000 index 0000000000..d01de53266 --- /dev/null +++ b/Lang/Mathematica/Search-a-list @@ -0,0 +1 @@ +../../Task/Search-a-list/Mathematica \ No newline at end of file diff --git a/Lang/Mathprog/0DESCRIPTION b/Lang/Mathprog/0DESCRIPTION new file mode 100644 index 0000000000..342ebd46f7 --- /dev/null +++ b/Lang/Mathprog/0DESCRIPTION @@ -0,0 +1,8 @@ +{{language}} +GNU MathProg is a modeling language intended for describing linear mathematical programming models. + +Model descriptions written in the GNU MathProg language consist of a set of +statements and data blocks constructed by the user from the language elements. + +The language syntax and use is described in gmpl.pdf which is available in the +glpk download at http://ftp.gnu.org/gnu/glpk/ \ No newline at end of file diff --git a/Lang/Mathprog/Averages-Arithmetic-mean b/Lang/Mathprog/Averages-Arithmetic-mean new file mode 120000 index 0000000000..5b4b0d1353 --- /dev/null +++ b/Lang/Mathprog/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Greatest-subsequential-sum b/Lang/Mathprog/Greatest-subsequential-sum new file mode 120000 index 0000000000..2919ae9aaa --- /dev/null +++ b/Lang/Mathprog/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Knapsack-problem-0-1 b/Lang/Mathprog/Knapsack-problem-0-1 new file mode 120000 index 0000000000..185e172fa1 --- /dev/null +++ b/Lang/Mathprog/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Knapsack-problem-Bounded b/Lang/Mathprog/Knapsack-problem-Bounded new file mode 120000 index 0000000000..e20562ba5f --- /dev/null +++ b/Lang/Mathprog/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Knapsack-problem-Continuous b/Lang/Mathprog/Knapsack-problem-Continuous new file mode 120000 index 0000000000..159e5aa3ab --- /dev/null +++ b/Lang/Mathprog/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Knapsack-problem-Unbounded b/Lang/Mathprog/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..9bd7901f0d --- /dev/null +++ b/Lang/Mathprog/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Mathprog \ No newline at end of file diff --git a/Lang/Mathprog/Knights-tour b/Lang/Mathprog/Knights-tour new file mode 120000 index 0000000000..0f1e83f20f --- /dev/null +++ b/Lang/Mathprog/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Mathprog \ No newline at end of file diff --git a/Lang/Maxima/0DESCRIPTION b/Lang/Maxima/0DESCRIPTION new file mode 100644 index 0000000000..2085f90dad --- /dev/null +++ b/Lang/Maxima/0DESCRIPTION @@ -0,0 +1,3 @@ +{{language|Maxima}}Maxima is the language used in the computer algebra system of the same name. See http://maxima.sourceforge.net/ + +[[Category:Mathematical programming languages]] \ No newline at end of file diff --git a/Lang/Maxima/100-doors b/Lang/Maxima/100-doors new file mode 120000 index 0000000000..78dd5fb037 --- /dev/null +++ b/Lang/Maxima/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Maxima \ No newline at end of file diff --git a/Lang/Maxima/99-Bottles-of-Beer b/Lang/Maxima/99-Bottles-of-Beer new file mode 120000 index 0000000000..8212ef7690 --- /dev/null +++ b/Lang/Maxima/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Ackermann-function b/Lang/Maxima/Ackermann-function new file mode 120000 index 0000000000..db1795c47a --- /dev/null +++ b/Lang/Maxima/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Anagrams b/Lang/Maxima/Anagrams new file mode 120000 index 0000000000..7184fbbeba --- /dev/null +++ b/Lang/Maxima/Anagrams @@ -0,0 +1 @@ +../../Task/Anagrams/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Apply-a-callback-to-an-array b/Lang/Maxima/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..3437965ea0 --- /dev/null +++ b/Lang/Maxima/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arbitrary-precision-integers-included b/Lang/Maxima/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..e9c03bae2c --- /dev/null +++ b/Lang/Maxima/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arithmetic-Complex b/Lang/Maxima/Arithmetic-Complex new file mode 120000 index 0000000000..579df094dc --- /dev/null +++ b/Lang/Maxima/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arithmetic-Integer b/Lang/Maxima/Arithmetic-Integer new file mode 120000 index 0000000000..1537b9976f --- /dev/null +++ b/Lang/Maxima/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arithmetic-Rational b/Lang/Maxima/Arithmetic-Rational new file mode 120000 index 0000000000..1c3195668b --- /dev/null +++ b/Lang/Maxima/Arithmetic-Rational @@ -0,0 +1 @@ +../../Task/Arithmetic-Rational/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arithmetic-geometric-mean b/Lang/Maxima/Arithmetic-geometric-mean new file mode 120000 index 0000000000..0bc7add9d5 --- /dev/null +++ b/Lang/Maxima/Arithmetic-geometric-mean @@ -0,0 +1 @@ +../../Task/Arithmetic-geometric-mean/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Array-concatenation b/Lang/Maxima/Array-concatenation new file mode 120000 index 0000000000..6b04af74bf --- /dev/null +++ b/Lang/Maxima/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arrays b/Lang/Maxima/Arrays new file mode 120000 index 0000000000..d7c65d6706 --- /dev/null +++ b/Lang/Maxima/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Associative-array-Creation b/Lang/Maxima/Associative-array-Creation new file mode 120000 index 0000000000..53967cd7fb --- /dev/null +++ b/Lang/Maxima/Associative-array-Creation @@ -0,0 +1 @@ +../../Task/Associative-array-Creation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Averages-Arithmetic-mean b/Lang/Maxima/Averages-Arithmetic-mean new file mode 120000 index 0000000000..f9c5d245c2 --- /dev/null +++ b/Lang/Maxima/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Averages-Median b/Lang/Maxima/Averages-Median new file mode 120000 index 0000000000..cc5c68921b --- /dev/null +++ b/Lang/Maxima/Averages-Median @@ -0,0 +1 @@ +../../Task/Averages-Median/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Averages-Pythagorean-means b/Lang/Maxima/Averages-Pythagorean-means new file mode 120000 index 0000000000..81b52352dd --- /dev/null +++ b/Lang/Maxima/Averages-Pythagorean-means @@ -0,0 +1 @@ +../../Task/Averages-Pythagorean-means/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Averages-Root-mean-square b/Lang/Maxima/Averages-Root-mean-square new file mode 120000 index 0000000000..5516430ed0 --- /dev/null +++ b/Lang/Maxima/Averages-Root-mean-square @@ -0,0 +1 @@ +../../Task/Averages-Root-mean-square/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Balanced-brackets b/Lang/Maxima/Balanced-brackets new file mode 120000 index 0000000000..487fa0df1c --- /dev/null +++ b/Lang/Maxima/Balanced-brackets @@ -0,0 +1 @@ +../../Task/Balanced-brackets/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Binary-search b/Lang/Maxima/Binary-search new file mode 120000 index 0000000000..2a84257f50 --- /dev/null +++ b/Lang/Maxima/Binary-search @@ -0,0 +1 @@ +../../Task/Binary-search/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Bitwise-operations b/Lang/Maxima/Bitwise-operations new file mode 120000 index 0000000000..a4e9e2b83d --- /dev/null +++ b/Lang/Maxima/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Boolean-values b/Lang/Maxima/Boolean-values new file mode 120000 index 0000000000..75c7eb8b61 --- /dev/null +++ b/Lang/Maxima/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Call-a-foreign-language-function b/Lang/Maxima/Call-a-foreign-language-function new file mode 120000 index 0000000000..adb0234597 --- /dev/null +++ b/Lang/Maxima/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Case-sensitivity-of-identifiers b/Lang/Maxima/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..e43c099899 --- /dev/null +++ b/Lang/Maxima/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Character-codes b/Lang/Maxima/Character-codes new file mode 120000 index 0000000000..5f8c4b28dc --- /dev/null +++ b/Lang/Maxima/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Check-Machin-like-formulas b/Lang/Maxima/Check-Machin-like-formulas new file mode 120000 index 0000000000..1804e1bf00 --- /dev/null +++ b/Lang/Maxima/Check-Machin-like-formulas @@ -0,0 +1 @@ +../../Task/Check-Machin-like-formulas/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Cholesky-decomposition b/Lang/Maxima/Cholesky-decomposition new file mode 120000 index 0000000000..3441ca5c7c --- /dev/null +++ b/Lang/Maxima/Cholesky-decomposition @@ -0,0 +1 @@ +../../Task/Cholesky-decomposition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Combinations b/Lang/Maxima/Combinations new file mode 120000 index 0000000000..a473a1065e --- /dev/null +++ b/Lang/Maxima/Combinations @@ -0,0 +1 @@ +../../Task/Combinations/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Comments b/Lang/Maxima/Comments new file mode 120000 index 0000000000..18114dcbed --- /dev/null +++ b/Lang/Maxima/Comments @@ -0,0 +1 @@ +../../Task/Comments/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Compound-data-type b/Lang/Maxima/Compound-data-type new file mode 120000 index 0000000000..f56c906f31 --- /dev/null +++ b/Lang/Maxima/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Conditional-structures b/Lang/Maxima/Conditional-structures new file mode 120000 index 0000000000..39c297e84e --- /dev/null +++ b/Lang/Maxima/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Continued-fraction b/Lang/Maxima/Continued-fraction new file mode 120000 index 0000000000..19dcb26365 --- /dev/null +++ b/Lang/Maxima/Continued-fraction @@ -0,0 +1 @@ +../../Task/Continued-fraction/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Conways-Game-of-Life b/Lang/Maxima/Conways-Game-of-Life new file mode 120000 index 0000000000..efafa53616 --- /dev/null +++ b/Lang/Maxima/Conways-Game-of-Life @@ -0,0 +1 @@ +../../Task/Conways-Game-of-Life/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Count-occurrences-of-a-substring b/Lang/Maxima/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..0250c861b4 --- /dev/null +++ b/Lang/Maxima/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Create-a-file b/Lang/Maxima/Create-a-file new file mode 120000 index 0000000000..c118e5f745 --- /dev/null +++ b/Lang/Maxima/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Day-of-the-week b/Lang/Maxima/Day-of-the-week new file mode 120000 index 0000000000..a6d6763924 --- /dev/null +++ b/Lang/Maxima/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Detect-division-by-zero b/Lang/Maxima/Detect-division-by-zero new file mode 120000 index 0000000000..d8320a75bd --- /dev/null +++ b/Lang/Maxima/Detect-division-by-zero @@ -0,0 +1 @@ +../../Task/Detect-division-by-zero/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Determine-if-a-string-is-numeric b/Lang/Maxima/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..ca58c93c5f --- /dev/null +++ b/Lang/Maxima/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Dot-product b/Lang/Maxima/Dot-product new file mode 120000 index 0000000000..332b9bba11 --- /dev/null +++ b/Lang/Maxima/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Draw-a-cuboid b/Lang/Maxima/Draw-a-cuboid new file mode 120000 index 0000000000..51c8b37696 --- /dev/null +++ b/Lang/Maxima/Draw-a-cuboid @@ -0,0 +1 @@ +../../Task/Draw-a-cuboid/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Draw-a-sphere b/Lang/Maxima/Draw-a-sphere new file mode 120000 index 0000000000..62beca9a57 --- /dev/null +++ b/Lang/Maxima/Draw-a-sphere @@ -0,0 +1 @@ +../../Task/Draw-a-sphere/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Dynamic-variable-names b/Lang/Maxima/Dynamic-variable-names new file mode 120000 index 0000000000..b837f3d520 --- /dev/null +++ b/Lang/Maxima/Dynamic-variable-names @@ -0,0 +1 @@ +../../Task/Dynamic-variable-names/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Element-wise-operations b/Lang/Maxima/Element-wise-operations new file mode 120000 index 0000000000..4a076985c2 --- /dev/null +++ b/Lang/Maxima/Element-wise-operations @@ -0,0 +1 @@ +../../Task/Element-wise-operations/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Empty-program b/Lang/Maxima/Empty-program new file mode 120000 index 0000000000..6dc2e0f1b8 --- /dev/null +++ b/Lang/Maxima/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Empty-string b/Lang/Maxima/Empty-string new file mode 120000 index 0000000000..fec36e98bc --- /dev/null +++ b/Lang/Maxima/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Evaluate-binomial-coefficients b/Lang/Maxima/Evaluate-binomial-coefficients new file mode 120000 index 0000000000..cd50a50ef3 --- /dev/null +++ b/Lang/Maxima/Evaluate-binomial-coefficients @@ -0,0 +1 @@ +../../Task/Evaluate-binomial-coefficients/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Even-or-odd b/Lang/Maxima/Even-or-odd new file mode 120000 index 0000000000..a17263db4a --- /dev/null +++ b/Lang/Maxima/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Execute-a-system-command b/Lang/Maxima/Execute-a-system-command new file mode 120000 index 0000000000..9df96ddf67 --- /dev/null +++ b/Lang/Maxima/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Exponentiation-operator b/Lang/Maxima/Exponentiation-operator new file mode 120000 index 0000000000..e192976ce8 --- /dev/null +++ b/Lang/Maxima/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Factorial b/Lang/Maxima/Factorial new file mode 120000 index 0000000000..53ea5548f2 --- /dev/null +++ b/Lang/Maxima/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Factors-of-a-Mersenne-number b/Lang/Maxima/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..a6d7a73fe9 --- /dev/null +++ b/Lang/Maxima/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Factors-of-an-integer b/Lang/Maxima/Factors-of-an-integer new file mode 120000 index 0000000000..50ab91e28c --- /dev/null +++ b/Lang/Maxima/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Fast-Fourier-transform b/Lang/Maxima/Fast-Fourier-transform new file mode 120000 index 0000000000..ae78e00c4e --- /dev/null +++ b/Lang/Maxima/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Fibonacci-sequence b/Lang/Maxima/Fibonacci-sequence new file mode 120000 index 0000000000..0f9d442d3d --- /dev/null +++ b/Lang/Maxima/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Filter b/Lang/Maxima/Filter new file mode 120000 index 0000000000..a39d0063e7 --- /dev/null +++ b/Lang/Maxima/Filter @@ -0,0 +1 @@ +../../Task/Filter/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Find-common-directory-path b/Lang/Maxima/Find-common-directory-path new file mode 120000 index 0000000000..94272fc6eb --- /dev/null +++ b/Lang/Maxima/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Find-limit-of-recursion b/Lang/Maxima/Find-limit-of-recursion new file mode 120000 index 0000000000..0dc5b09371 --- /dev/null +++ b/Lang/Maxima/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Maxima \ No newline at end of file diff --git a/Lang/Maxima/First-class-functions b/Lang/Maxima/First-class-functions new file mode 120000 index 0000000000..8b37ef3bcf --- /dev/null +++ b/Lang/Maxima/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Five-weekends b/Lang/Maxima/Five-weekends new file mode 120000 index 0000000000..a46c9102b9 --- /dev/null +++ b/Lang/Maxima/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Maxima \ No newline at end of file diff --git a/Lang/Maxima/FizzBuzz b/Lang/Maxima/FizzBuzz new file mode 120000 index 0000000000..bfc128a07a --- /dev/null +++ b/Lang/Maxima/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Flatten-a-list b/Lang/Maxima/Flatten-a-list new file mode 120000 index 0000000000..75eaa681ef --- /dev/null +++ b/Lang/Maxima/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Flow-control-structures b/Lang/Maxima/Flow-control-structures new file mode 120000 index 0000000000..d3b1acaeca --- /dev/null +++ b/Lang/Maxima/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Formal-power-series b/Lang/Maxima/Formal-power-series new file mode 120000 index 0000000000..e4382b0295 --- /dev/null +++ b/Lang/Maxima/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Forward-difference b/Lang/Maxima/Forward-difference new file mode 120000 index 0000000000..fec1c10552 --- /dev/null +++ b/Lang/Maxima/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Function-composition b/Lang/Maxima/Function-composition new file mode 120000 index 0000000000..e170ceeda4 --- /dev/null +++ b/Lang/Maxima/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Gamma-function b/Lang/Maxima/Gamma-function new file mode 120000 index 0000000000..24dd7733cf --- /dev/null +++ b/Lang/Maxima/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Generic-swap b/Lang/Maxima/Generic-swap new file mode 120000 index 0000000000..b3ea7924bc --- /dev/null +++ b/Lang/Maxima/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Greatest-common-divisor b/Lang/Maxima/Greatest-common-divisor new file mode 120000 index 0000000000..08bf245c7b --- /dev/null +++ b/Lang/Maxima/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Greatest-element-of-a-list b/Lang/Maxima/Greatest-element-of-a-list new file mode 120000 index 0000000000..34181dc6e1 --- /dev/null +++ b/Lang/Maxima/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Hailstone-sequence b/Lang/Maxima/Hailstone-sequence new file mode 120000 index 0000000000..2482b114dc --- /dev/null +++ b/Lang/Maxima/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Haversine-formula b/Lang/Maxima/Haversine-formula new file mode 120000 index 0000000000..8eed3bd664 --- /dev/null +++ b/Lang/Maxima/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Hello-world-Text b/Lang/Maxima/Hello-world-Text new file mode 120000 index 0000000000..b3c90a14f1 --- /dev/null +++ b/Lang/Maxima/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Higher-order-functions b/Lang/Maxima/Higher-order-functions new file mode 120000 index 0000000000..ed922d83b1 --- /dev/null +++ b/Lang/Maxima/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Holidays-related-to-Easter b/Lang/Maxima/Holidays-related-to-Easter new file mode 120000 index 0000000000..9cee609263 --- /dev/null +++ b/Lang/Maxima/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Horners-rule-for-polynomial-evaluation b/Lang/Maxima/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..e1d829a176 --- /dev/null +++ b/Lang/Maxima/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Identity-matrix b/Lang/Maxima/Identity-matrix new file mode 120000 index 0000000000..fe0e071e21 --- /dev/null +++ b/Lang/Maxima/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Include-a-file b/Lang/Maxima/Include-a-file new file mode 120000 index 0000000000..4ad70bc01c --- /dev/null +++ b/Lang/Maxima/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Infinity b/Lang/Maxima/Infinity new file mode 120000 index 0000000000..09930d1d2c --- /dev/null +++ b/Lang/Maxima/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Integer-comparison b/Lang/Maxima/Integer-comparison new file mode 120000 index 0000000000..f172ac6f6a --- /dev/null +++ b/Lang/Maxima/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Integer-sequence b/Lang/Maxima/Integer-sequence new file mode 120000 index 0000000000..b633634f5d --- /dev/null +++ b/Lang/Maxima/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Interactive-programming b/Lang/Maxima/Interactive-programming new file mode 120000 index 0000000000..301c4156ad --- /dev/null +++ b/Lang/Maxima/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Introspection b/Lang/Maxima/Introspection new file mode 120000 index 0000000000..05e54c255c --- /dev/null +++ b/Lang/Maxima/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Jensens-Device b/Lang/Maxima/Jensens-Device new file mode 120000 index 0000000000..64dcc9526d --- /dev/null +++ b/Lang/Maxima/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Kaprekar-numbers b/Lang/Maxima/Kaprekar-numbers new file mode 120000 index 0000000000..61bdec2310 --- /dev/null +++ b/Lang/Maxima/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Knuth-shuffle b/Lang/Maxima/Knuth-shuffle new file mode 120000 index 0000000000..c0d019ec7b --- /dev/null +++ b/Lang/Maxima/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Maxima \ No newline at end of file diff --git a/Lang/Maxima/LU-decomposition b/Lang/Maxima/LU-decomposition new file mode 120000 index 0000000000..35775139b7 --- /dev/null +++ b/Lang/Maxima/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Last-Friday-of-each-month b/Lang/Maxima/Last-Friday-of-each-month new file mode 120000 index 0000000000..efaa5bb106 --- /dev/null +++ b/Lang/Maxima/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Leap-year b/Lang/Maxima/Leap-year new file mode 120000 index 0000000000..f7e6d033c4 --- /dev/null +++ b/Lang/Maxima/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Least-common-multiple b/Lang/Maxima/Least-common-multiple new file mode 120000 index 0000000000..bcf4386536 --- /dev/null +++ b/Lang/Maxima/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Linear-congruential-generator b/Lang/Maxima/Linear-congruential-generator new file mode 120000 index 0000000000..f2c3f395a2 --- /dev/null +++ b/Lang/Maxima/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Literals-Floating-point b/Lang/Maxima/Literals-Floating-point new file mode 120000 index 0000000000..6452d34c57 --- /dev/null +++ b/Lang/Maxima/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Literals-Integer b/Lang/Maxima/Literals-Integer new file mode 120000 index 0000000000..34b788262c --- /dev/null +++ b/Lang/Maxima/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Literals-String b/Lang/Maxima/Literals-String new file mode 120000 index 0000000000..796aaa404f --- /dev/null +++ b/Lang/Maxima/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Logical-operations b/Lang/Maxima/Logical-operations new file mode 120000 index 0000000000..8cedd5e3db --- /dev/null +++ b/Lang/Maxima/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Look-and-say-sequence b/Lang/Maxima/Look-and-say-sequence new file mode 120000 index 0000000000..e25c41876a --- /dev/null +++ b/Lang/Maxima/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Break b/Lang/Maxima/Loops-Break new file mode 120000 index 0000000000..20c8bc678b --- /dev/null +++ b/Lang/Maxima/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Continue b/Lang/Maxima/Loops-Continue new file mode 120000 index 0000000000..222d97d2ff --- /dev/null +++ b/Lang/Maxima/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Do-while b/Lang/Maxima/Loops-Do-while new file mode 120000 index 0000000000..34dcfb4d9c --- /dev/null +++ b/Lang/Maxima/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Downward-for b/Lang/Maxima/Loops-Downward-for new file mode 120000 index 0000000000..09a6068908 --- /dev/null +++ b/Lang/Maxima/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-For b/Lang/Maxima/Loops-For new file mode 120000 index 0000000000..5aea921627 --- /dev/null +++ b/Lang/Maxima/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-For-with-a-specified-step b/Lang/Maxima/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..efdcddf4de --- /dev/null +++ b/Lang/Maxima/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Foreach b/Lang/Maxima/Loops-Foreach new file mode 120000 index 0000000000..47e7e67bc0 --- /dev/null +++ b/Lang/Maxima/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Infinite b/Lang/Maxima/Loops-Infinite new file mode 120000 index 0000000000..91df4d0c55 --- /dev/null +++ b/Lang/Maxima/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-Nested b/Lang/Maxima/Loops-Nested new file mode 120000 index 0000000000..4b43a9eb96 --- /dev/null +++ b/Lang/Maxima/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Loops-While b/Lang/Maxima/Loops-While new file mode 120000 index 0000000000..0840540b57 --- /dev/null +++ b/Lang/Maxima/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Lucas-Lehmer-test b/Lang/Maxima/Lucas-Lehmer-test new file mode 120000 index 0000000000..53a79f6df2 --- /dev/null +++ b/Lang/Maxima/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Map-range b/Lang/Maxima/Map-range new file mode 120000 index 0000000000..32cbc91120 --- /dev/null +++ b/Lang/Maxima/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Matrix-arithmetic b/Lang/Maxima/Matrix-arithmetic new file mode 120000 index 0000000000..158b8e432b --- /dev/null +++ b/Lang/Maxima/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Matrix-exponentiation-operator b/Lang/Maxima/Matrix-exponentiation-operator new file mode 120000 index 0000000000..f5659a65ac --- /dev/null +++ b/Lang/Maxima/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Matrix-multiplication b/Lang/Maxima/Matrix-multiplication new file mode 120000 index 0000000000..d25f001e2a --- /dev/null +++ b/Lang/Maxima/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Matrix-transposition b/Lang/Maxima/Matrix-transposition new file mode 120000 index 0000000000..e2ba199784 --- /dev/null +++ b/Lang/Maxima/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Memory-allocation b/Lang/Maxima/Memory-allocation new file mode 120000 index 0000000000..382dd23b8e --- /dev/null +++ b/Lang/Maxima/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Miller-Rabin-primality-test b/Lang/Maxima/Miller-Rabin-primality-test new file mode 120000 index 0000000000..331b953779 --- /dev/null +++ b/Lang/Maxima/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Modular-exponentiation b/Lang/Maxima/Modular-exponentiation new file mode 120000 index 0000000000..fe30199212 --- /dev/null +++ b/Lang/Maxima/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Multiple-distinct-objects b/Lang/Maxima/Multiple-distinct-objects new file mode 120000 index 0000000000..7727d806cf --- /dev/null +++ b/Lang/Maxima/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Multiplicative-order b/Lang/Maxima/Multiplicative-order new file mode 120000 index 0000000000..4ac3bec2c1 --- /dev/null +++ b/Lang/Maxima/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Mutual-recursion b/Lang/Maxima/Mutual-recursion new file mode 120000 index 0000000000..5798e0794d --- /dev/null +++ b/Lang/Maxima/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Quine b/Lang/Maxima/Quine new file mode 120000 index 0000000000..2b0d2d753b --- /dev/null +++ b/Lang/Maxima/Quine @@ -0,0 +1 @@ +../../Task/Quine/Maxima \ No newline at end of file diff --git a/Lang/Mercury/0DESCRIPTION b/Lang/Mercury/0DESCRIPTION new file mode 100644 index 0000000000..46480cc7aa --- /dev/null +++ b/Lang/Mercury/0DESCRIPTION @@ -0,0 +1,12 @@ +{{stub}}{{language +|strength=strong +|site=http://www.mercury.csse.unimelb.edu.au/ +|checking=static}}[[runs on vm::java virtual machine| ]][[runs on vm::common language runtime| ]] +{{language programming paradigm|Declarative}} +{{language programming paradigm|functional}} +{{language programming paradigm|Logic_Programming}} + +Mercury is a purely declarative functional logic programming language geared towards real-world applications. It is related to both [[Prolog]] and [[Haskell]]. It features a strong, static, polymorphic type system, as well as a strong mode +and determinism system. + +Mercury has several back-ends, Low-level [[C]], High-level [[C]], [[Java]], [[Erlang]], and [[C sharp|C#]]. \ No newline at end of file diff --git a/Lang/Mercury/100-doors b/Lang/Mercury/100-doors new file mode 120000 index 0000000000..0a899dd26a --- /dev/null +++ b/Lang/Mercury/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Mercury \ No newline at end of file diff --git a/Lang/Mercury/A+B b/Lang/Mercury/A+B new file mode 120000 index 0000000000..46b90b6130 --- /dev/null +++ b/Lang/Mercury/A+B @@ -0,0 +1 @@ +../../Task/A+B/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Ackermann-function b/Lang/Mercury/Ackermann-function new file mode 120000 index 0000000000..5f4024320c --- /dev/null +++ b/Lang/Mercury/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Arithmetic-Integer b/Lang/Mercury/Arithmetic-Integer new file mode 120000 index 0000000000..f6dea7ad8f --- /dev/null +++ b/Lang/Mercury/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Array-concatenation b/Lang/Mercury/Array-concatenation new file mode 120000 index 0000000000..35bd6fe4d9 --- /dev/null +++ b/Lang/Mercury/Array-concatenation @@ -0,0 +1 @@ +../../Task/Array-concatenation/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Averages-Simple-moving-average b/Lang/Mercury/Averages-Simple-moving-average new file mode 120000 index 0000000000..fe9fa27500 --- /dev/null +++ b/Lang/Mercury/Averages-Simple-moving-average @@ -0,0 +1 @@ +../../Task/Averages-Simple-moving-average/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Combinations-with-repetitions b/Lang/Mercury/Combinations-with-repetitions new file mode 120000 index 0000000000..8af9afd065 --- /dev/null +++ b/Lang/Mercury/Combinations-with-repetitions @@ -0,0 +1 @@ +../../Task/Combinations-with-repetitions/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Command-line-arguments b/Lang/Mercury/Command-line-arguments new file mode 120000 index 0000000000..fff19dbd85 --- /dev/null +++ b/Lang/Mercury/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Concurrent-computing b/Lang/Mercury/Concurrent-computing new file mode 120000 index 0000000000..6e20d38f81 --- /dev/null +++ b/Lang/Mercury/Concurrent-computing @@ -0,0 +1 @@ +../../Task/Concurrent-computing/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Count-in-octal b/Lang/Mercury/Count-in-octal new file mode 120000 index 0000000000..ffb4dcc002 --- /dev/null +++ b/Lang/Mercury/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Count-the-coins b/Lang/Mercury/Count-the-coins new file mode 120000 index 0000000000..78999a4f78 --- /dev/null +++ b/Lang/Mercury/Count-the-coins @@ -0,0 +1 @@ +../../Task/Count-the-coins/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Dot-product b/Lang/Mercury/Dot-product new file mode 120000 index 0000000000..cea6d324f6 --- /dev/null +++ b/Lang/Mercury/Dot-product @@ -0,0 +1 @@ +../../Task/Dot-product/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Even-or-odd b/Lang/Mercury/Even-or-odd new file mode 120000 index 0000000000..931227656c --- /dev/null +++ b/Lang/Mercury/Even-or-odd @@ -0,0 +1 @@ +../../Task/Even-or-odd/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Execute-a-system-command b/Lang/Mercury/Execute-a-system-command new file mode 120000 index 0000000000..2ec12e67ae --- /dev/null +++ b/Lang/Mercury/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Factors-of-an-integer b/Lang/Mercury/Factors-of-an-integer new file mode 120000 index 0000000000..baac73cf9f --- /dev/null +++ b/Lang/Mercury/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Fibonacci-sequence b/Lang/Mercury/Fibonacci-sequence new file mode 120000 index 0000000000..e7e65c4b31 --- /dev/null +++ b/Lang/Mercury/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Mercury \ No newline at end of file diff --git a/Lang/Mercury/First-class-functions b/Lang/Mercury/First-class-functions new file mode 120000 index 0000000000..e2e7836c10 --- /dev/null +++ b/Lang/Mercury/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Mercury \ No newline at end of file diff --git a/Lang/Mercury/FizzBuzz b/Lang/Mercury/FizzBuzz new file mode 120000 index 0000000000..b6f5049d9b --- /dev/null +++ b/Lang/Mercury/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Formatted-numeric-output b/Lang/Mercury/Formatted-numeric-output new file mode 120000 index 0000000000..60bddea9b3 --- /dev/null +++ b/Lang/Mercury/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Guess-the-number b/Lang/Mercury/Guess-the-number new file mode 120000 index 0000000000..8e6a3c2c74 --- /dev/null +++ b/Lang/Mercury/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Hello-world-Standard-error b/Lang/Mercury/Hello-world-Standard-error new file mode 120000 index 0000000000..f20dac8516 --- /dev/null +++ b/Lang/Mercury/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Hello-world-Text b/Lang/Mercury/Hello-world-Text new file mode 120000 index 0000000000..0c2d011014 --- /dev/null +++ b/Lang/Mercury/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Horners-rule-for-polynomial-evaluation b/Lang/Mercury/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..f2912575d0 --- /dev/null +++ b/Lang/Mercury/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Input-loop b/Lang/Mercury/Input-loop new file mode 120000 index 0000000000..278387dfa7 --- /dev/null +++ b/Lang/Mercury/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Inverted-syntax b/Lang/Mercury/Inverted-syntax new file mode 120000 index 0000000000..98377428d7 --- /dev/null +++ b/Lang/Mercury/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Loop-over-multiple-arrays-simultaneously b/Lang/Mercury/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..db6df4ba0e --- /dev/null +++ b/Lang/Mercury/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Loops-Downward-for b/Lang/Mercury/Loops-Downward-for new file mode 120000 index 0000000000..eed9ae0622 --- /dev/null +++ b/Lang/Mercury/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Loops-For b/Lang/Mercury/Loops-For new file mode 120000 index 0000000000..ad380092cd --- /dev/null +++ b/Lang/Mercury/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Memory-layout-of-a-data-structure b/Lang/Mercury/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..52a6fc5c1b --- /dev/null +++ b/Lang/Mercury/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Mutual-recursion b/Lang/Mercury/Mutual-recursion new file mode 120000 index 0000000000..c050c918c4 --- /dev/null +++ b/Lang/Mercury/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Mercury \ No newline at end of file diff --git a/Lang/Metafont/0DESCRIPTION b/Lang/Metafont/0DESCRIPTION new file mode 100644 index 0000000000..d9d39714cb --- /dev/null +++ b/Lang/Metafont/0DESCRIPTION @@ -0,0 +1,4 @@ +{{language|Metafont}}{{stub}} +Metafont is a programming language used to define vector fonts. It is also the name of the interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into e.g. PostScript. Metafont was devised by Donald Knuth as counterpart to his [[TeX]] typesetting system. (Text excerpt from [[wp:Metafont|Wikipedia]]). + +The language can be used also outside its main purpose and field (like Postscript or TeX). \ No newline at end of file diff --git a/Lang/Metafont/100-doors b/Lang/Metafont/100-doors new file mode 120000 index 0000000000..c4d0a38f8e --- /dev/null +++ b/Lang/Metafont/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Arithmetic-Integer b/Lang/Metafont/Arithmetic-Integer new file mode 120000 index 0000000000..276691d9f5 --- /dev/null +++ b/Lang/Metafont/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Assertions b/Lang/Metafont/Assertions new file mode 120000 index 0000000000..252e38f3df --- /dev/null +++ b/Lang/Metafont/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Character-codes b/Lang/Metafont/Character-codes new file mode 120000 index 0000000000..b47aaa746d --- /dev/null +++ b/Lang/Metafont/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Comments b/Lang/Metafont/Comments new file mode 120000 index 0000000000..e5886c44f3 --- /dev/null +++ b/Lang/Metafont/Comments @@ -0,0 +1 @@ +../../Task/Comments/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Conditional-structures b/Lang/Metafont/Conditional-structures new file mode 120000 index 0000000000..e6464379ce --- /dev/null +++ b/Lang/Metafont/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Empty-program b/Lang/Metafont/Empty-program new file mode 120000 index 0000000000..7ea1c5d9ae --- /dev/null +++ b/Lang/Metafont/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Enumerations b/Lang/Metafont/Enumerations new file mode 120000 index 0000000000..e67dd522d8 --- /dev/null +++ b/Lang/Metafont/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Ethiopian-multiplication b/Lang/Metafont/Ethiopian-multiplication new file mode 120000 index 0000000000..d213138c35 --- /dev/null +++ b/Lang/Metafont/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Fibonacci-sequence b/Lang/Metafont/Fibonacci-sequence new file mode 120000 index 0000000000..6c30a012b4 --- /dev/null +++ b/Lang/Metafont/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Metafont \ No newline at end of file diff --git a/Lang/Metafont/FizzBuzz b/Lang/Metafont/FizzBuzz new file mode 120000 index 0000000000..272346fd00 --- /dev/null +++ b/Lang/Metafont/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Function-definition b/Lang/Metafont/Function-definition new file mode 120000 index 0000000000..9ee9df4ce6 --- /dev/null +++ b/Lang/Metafont/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Generic-swap b/Lang/Metafont/Generic-swap new file mode 120000 index 0000000000..9199e5904c --- /dev/null +++ b/Lang/Metafont/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Greatest-element-of-a-list b/Lang/Metafont/Greatest-element-of-a-list new file mode 120000 index 0000000000..a00b8b74cf --- /dev/null +++ b/Lang/Metafont/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Hello-world-Standard-error b/Lang/Metafont/Hello-world-Standard-error new file mode 120000 index 0000000000..054d35bc81 --- /dev/null +++ b/Lang/Metafont/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Hello-world-Text b/Lang/Metafont/Hello-world-Text new file mode 120000 index 0000000000..d0bf8f7aca --- /dev/null +++ b/Lang/Metafont/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Higher-order-functions b/Lang/Metafont/Higher-order-functions new file mode 120000 index 0000000000..5cc870c816 --- /dev/null +++ b/Lang/Metafont/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Increment-a-numerical-string b/Lang/Metafont/Increment-a-numerical-string new file mode 120000 index 0000000000..5f7b049e5e --- /dev/null +++ b/Lang/Metafont/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Infinity b/Lang/Metafont/Infinity new file mode 120000 index 0000000000..e991fa6855 --- /dev/null +++ b/Lang/Metafont/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Integer-comparison b/Lang/Metafont/Integer-comparison new file mode 120000 index 0000000000..9787231d4e --- /dev/null +++ b/Lang/Metafont/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Literals-Integer b/Lang/Metafont/Literals-Integer new file mode 120000 index 0000000000..dab9ec57d0 --- /dev/null +++ b/Lang/Metafont/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Literals-String b/Lang/Metafont/Literals-String new file mode 120000 index 0000000000..2c3f75b4e7 --- /dev/null +++ b/Lang/Metafont/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Logical-operations b/Lang/Metafont/Logical-operations new file mode 120000 index 0000000000..ea144473f7 --- /dev/null +++ b/Lang/Metafont/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Look-and-say-sequence b/Lang/Metafont/Look-and-say-sequence new file mode 120000 index 0000000000..630cebed95 --- /dev/null +++ b/Lang/Metafont/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-Continue b/Lang/Metafont/Loops-Continue new file mode 120000 index 0000000000..5fbbe5409c --- /dev/null +++ b/Lang/Metafont/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-Do-while b/Lang/Metafont/Loops-Do-while new file mode 120000 index 0000000000..c1a4c7c422 --- /dev/null +++ b/Lang/Metafont/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-Downward-for b/Lang/Metafont/Loops-Downward-for new file mode 120000 index 0000000000..955e3ad365 --- /dev/null +++ b/Lang/Metafont/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-Foreach b/Lang/Metafont/Loops-Foreach new file mode 120000 index 0000000000..075020b511 --- /dev/null +++ b/Lang/Metafont/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-Infinite b/Lang/Metafont/Loops-Infinite new file mode 120000 index 0000000000..150de96ae1 --- /dev/null +++ b/Lang/Metafont/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-N-plus-one-half b/Lang/Metafont/Loops-N-plus-one-half new file mode 120000 index 0000000000..2ed35fbb8f --- /dev/null +++ b/Lang/Metafont/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Loops-While b/Lang/Metafont/Loops-While new file mode 120000 index 0000000000..0db907294f --- /dev/null +++ b/Lang/Metafont/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Metafont \ No newline at end of file diff --git a/Lang/Metapost/0DESCRIPTION b/Lang/Metapost/0DESCRIPTION new file mode 100644 index 0000000000..1c9a92fa8e --- /dev/null +++ b/Lang/Metapost/0DESCRIPTION @@ -0,0 +1,2 @@ +{{language|Metapont}}{{stub}} +Metapost is a programming language derived from D.E.Knuth's [[Metafont]] language, but its output is [[PostScript]] (hence the name) and therefore has extensions to the parent language, e.g. supports RGB colors; however, it has inherited some limitation of Metafont; the [[Asymptote]] language is another language in the "family", but without those limitations. \ No newline at end of file diff --git a/Lang/Mirah/0DESCRIPTION b/Lang/Mirah/0DESCRIPTION new file mode 100644 index 0000000000..c18bdf83eb --- /dev/null +++ b/Lang/Mirah/0DESCRIPTION @@ -0,0 +1,15 @@ +{{language +|tags=mirah +|express=implicit +|strength=strong +|checking=static +|site=http://www.mirah.org/}} +Mirah is a new way of looking at [[runs on vm::JVM]] languages. In attempting to build a replacement for [[Java]], we have followed a few guiding principals: +* No runtime library +Mirah does not impose any jar files upon you. YOU decide what your application's dependencies should be. +* Clean, simple syntax +We have borrowed heavily from [[derived from::Ruby]], but added static typing and minor syntax changes to support the JVM's type system. The result is pleasing to the eye, but as powerful as Java. +* [[Metaprogramming]] and macros +Mirah supports various mechanisms for compile-time metaprogramming and macros. Much of the "open class" feel of dynamic languages is possible in Mirah. +* No performance penalty +Because Mirah directly targets the JVM's type system and JVM [[bytecode]], it performs exactly as well as Java. \ No newline at end of file diff --git a/Lang/Mirah/100-doors b/Lang/Mirah/100-doors new file mode 120000 index 0000000000..2b43ae3c09 --- /dev/null +++ b/Lang/Mirah/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Mirah \ No newline at end of file diff --git a/Lang/Mirah/99-Bottles-of-Beer b/Lang/Mirah/99-Bottles-of-Beer new file mode 120000 index 0000000000..c4169f1f9a --- /dev/null +++ b/Lang/Mirah/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Boolean-values b/Lang/Mirah/Boolean-values new file mode 120000 index 0000000000..a8d2fbfaa9 --- /dev/null +++ b/Lang/Mirah/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Comments b/Lang/Mirah/Comments new file mode 120000 index 0000000000..3447a0d20d --- /dev/null +++ b/Lang/Mirah/Comments @@ -0,0 +1 @@ +../../Task/Comments/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Count-occurrences-of-a-substring b/Lang/Mirah/Count-occurrences-of-a-substring new file mode 120000 index 0000000000..e2597ab02d --- /dev/null +++ b/Lang/Mirah/Count-occurrences-of-a-substring @@ -0,0 +1 @@ +../../Task/Count-occurrences-of-a-substring/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Create-a-file b/Lang/Mirah/Create-a-file new file mode 120000 index 0000000000..f87d598b6d --- /dev/null +++ b/Lang/Mirah/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Determine-if-a-string-is-numeric b/Lang/Mirah/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..2ff65daf41 --- /dev/null +++ b/Lang/Mirah/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Empty-string b/Lang/Mirah/Empty-string new file mode 120000 index 0000000000..826b0a2edc --- /dev/null +++ b/Lang/Mirah/Empty-string @@ -0,0 +1 @@ +../../Task/Empty-string/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Factorial b/Lang/Mirah/Factorial new file mode 120000 index 0000000000..e986aa5f4f --- /dev/null +++ b/Lang/Mirah/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Fibonacci-sequence b/Lang/Mirah/Fibonacci-sequence new file mode 120000 index 0000000000..ff4c2b152f --- /dev/null +++ b/Lang/Mirah/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Mirah \ No newline at end of file diff --git a/Lang/Mirah/File-size b/Lang/Mirah/File-size new file mode 120000 index 0000000000..1c4a2b8a35 --- /dev/null +++ b/Lang/Mirah/File-size @@ -0,0 +1 @@ +../../Task/File-size/Mirah \ No newline at end of file diff --git a/Lang/Mirah/FizzBuzz b/Lang/Mirah/FizzBuzz new file mode 120000 index 0000000000..eb680cf8c5 --- /dev/null +++ b/Lang/Mirah/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Flatten-a-list b/Lang/Mirah/Flatten-a-list new file mode 120000 index 0000000000..ceba8076bd --- /dev/null +++ b/Lang/Mirah/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Guess-the-number-With-feedback b/Lang/Mirah/Guess-the-number-With-feedback new file mode 120000 index 0000000000..31762a0584 --- /dev/null +++ b/Lang/Mirah/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Mirah \ No newline at end of file diff --git a/Lang/Mirelle/0DESCRIPTION b/Lang/Mirelle/0DESCRIPTION new file mode 100644 index 0000000000..03f03ada58 --- /dev/null +++ b/Lang/Mirelle/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language +|strength=strong +|checking=static +|site=http://mirelle.codeplex.com +}} +{{language programming paradigm|object-oriented}} +{{language programming paradigm|imperative}}Mirelle is a programming / scripting language for the [[.NET]] platform. It is designed to be strongly statically typed, imperative, object-oriented and keyboard-friendly. + +It features a lightweight and clear syntax, inspired by [[Python]] and [[Ruby]], built-in abilities for graph plotting, matrix handling, and discrete-event simulation modelling. + +Mirelle is implemented as a compiler which emits .exe files in the format of .NET assemblies. While not being very powerful yet, it can be extended by other .NET-compliant code. \ No newline at end of file diff --git a/Lang/Modula-2/0DESCRIPTION b/Lang/Modula-2/0DESCRIPTION new file mode 100644 index 0000000000..deca3c5fbc --- /dev/null +++ b/Lang/Modula-2/0DESCRIPTION @@ -0,0 +1,29 @@ +{{stub}}{{language +|bnf=http://cui.unige.ch/db-research/Enseignement/analyseinfo/Modula2/BNFindex.html +|site=http://www.modula2.net/ +|tags=modula2}} +Modula-2 was designed by Niklaus Wirth at ETH Zurich as a systems implementation language for the operating system of the Lilith workstation, a project inspired by the Alto which Wirth had used during his sabbatical year at Xerox PARC in 1976. Modula-2 is a strongly typed language of the Pascal family and its predecessors are Mesa and Pascal. In Modula-2, Wirth had addressed most of the criticisms against Pascal. The most important concepts introduced were modularity and information hiding but also system access and concurrent programming. There are two main variants of Modula-2, the language described in Wirth's book "Programming in Modula-2" also known as PIM or classical Modula-2 and the revised and extended version produced by the ISO standards committee, known as ISO Modula-2. + +==Modula-2 FAQ== +[http://faq.modula2.net Modula-2 FAQ] + +==Modula-2 Compilers== +[http://www.modula2.net/resources/compilers.shtml List of Modula-2 Compilers] + +==Modula-2 Books & Tutorials== +[http://www.modula2.net/resources/books.shtml List of Modula-2 Books & Tutorials] + +==Modula-2 Grammars== +* [http://modula2.net/resources/m2pim4.g PIM Modula-2, original version] +* [http://modula2.net/resources/m2pim4_LL1.g PIM Modula-2, LL(1) version] +* [http://modula2.net/resources/m2iso.g ISO Modula-2, original version] + +==Modula-2 Open Source Projects== +* [http://www.nongnu.org/gm2 GNU Modula-2] +* [http://objective.modula2.net Objective Modula-2] +* [http://code.google.com/p/modula2jcc Modula2JCC] +* [http://sourceforge.net/projects/modulipse Modulipse] +* [http://sourceforge.net/projects/schwarzerkaffee Schwarzer Kaffee] + +==Modula-2 on IRC== +* [irc://irc.freenode.net/#modula-2 irc://irc.freenode.net/#modula-2] \ No newline at end of file diff --git a/Lang/Modula-2/100-doors b/Lang/Modula-2/100-doors new file mode 120000 index 0000000000..e6964646de --- /dev/null +++ b/Lang/Modula-2/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/24-game b/Lang/Modula-2/24-game new file mode 120000 index 0000000000..41b25318be --- /dev/null +++ b/Lang/Modula-2/24-game @@ -0,0 +1 @@ +../../Task/24-game/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/99-Bottles-of-Beer b/Lang/Modula-2/99-Bottles-of-Beer new file mode 120000 index 0000000000..8423cb0942 --- /dev/null +++ b/Lang/Modula-2/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/A+B b/Lang/Modula-2/A+B new file mode 120000 index 0000000000..03448a86a1 --- /dev/null +++ b/Lang/Modula-2/A+B @@ -0,0 +1 @@ +../../Task/A+B/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Ackermann-function b/Lang/Modula-2/Ackermann-function new file mode 120000 index 0000000000..697ad6b989 --- /dev/null +++ b/Lang/Modula-2/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Address-of-a-variable b/Lang/Modula-2/Address-of-a-variable new file mode 120000 index 0000000000..63035204c2 --- /dev/null +++ b/Lang/Modula-2/Address-of-a-variable @@ -0,0 +1 @@ +../../Task/Address-of-a-variable/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Arithmetic-Complex b/Lang/Modula-2/Arithmetic-Complex new file mode 120000 index 0000000000..94559c7fb4 --- /dev/null +++ b/Lang/Modula-2/Arithmetic-Complex @@ -0,0 +1 @@ +../../Task/Arithmetic-Complex/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Arithmetic-Integer b/Lang/Modula-2/Arithmetic-Integer new file mode 120000 index 0000000000..0b9af5a1b1 --- /dev/null +++ b/Lang/Modula-2/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Averages-Arithmetic-mean b/Lang/Modula-2/Averages-Arithmetic-mean new file mode 120000 index 0000000000..903f695c8d --- /dev/null +++ b/Lang/Modula-2/Averages-Arithmetic-mean @@ -0,0 +1 @@ +../../Task/Averages-Arithmetic-mean/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Boolean-values b/Lang/Modula-2/Boolean-values new file mode 120000 index 0000000000..f72081d002 --- /dev/null +++ b/Lang/Modula-2/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Call-a-foreign-language-function b/Lang/Modula-2/Call-a-foreign-language-function new file mode 120000 index 0000000000..fd7d30b91e --- /dev/null +++ b/Lang/Modula-2/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Case-sensitivity-of-identifiers b/Lang/Modula-2/Case-sensitivity-of-identifiers new file mode 120000 index 0000000000..b11c2491b2 --- /dev/null +++ b/Lang/Modula-2/Case-sensitivity-of-identifiers @@ -0,0 +1 @@ +../../Task/Case-sensitivity-of-identifiers/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Character-codes b/Lang/Modula-2/Character-codes new file mode 120000 index 0000000000..52a4a81664 --- /dev/null +++ b/Lang/Modula-2/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Command-line-arguments b/Lang/Modula-2/Command-line-arguments new file mode 120000 index 0000000000..956bfedd20 --- /dev/null +++ b/Lang/Modula-2/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Comments b/Lang/Modula-2/Comments new file mode 120000 index 0000000000..a554e5ad02 --- /dev/null +++ b/Lang/Modula-2/Comments @@ -0,0 +1 @@ +../../Task/Comments/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Compound-data-type b/Lang/Modula-2/Compound-data-type new file mode 120000 index 0000000000..4f3ee36beb --- /dev/null +++ b/Lang/Modula-2/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Conditional-structures b/Lang/Modula-2/Conditional-structures new file mode 120000 index 0000000000..9f192ccb01 --- /dev/null +++ b/Lang/Modula-2/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Count-in-octal b/Lang/Modula-2/Count-in-octal new file mode 120000 index 0000000000..9ec0f89808 --- /dev/null +++ b/Lang/Modula-2/Count-in-octal @@ -0,0 +1 @@ +../../Task/Count-in-octal/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Create-an-HTML-table b/Lang/Modula-2/Create-an-HTML-table new file mode 120000 index 0000000000..f104140411 --- /dev/null +++ b/Lang/Modula-2/Create-an-HTML-table @@ -0,0 +1 @@ +../../Task/Create-an-HTML-table/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Doubly-linked-list-Element-definition b/Lang/Modula-2/Doubly-linked-list-Element-definition new file mode 120000 index 0000000000..d5b966552b --- /dev/null +++ b/Lang/Modula-2/Doubly-linked-list-Element-definition @@ -0,0 +1 @@ +../../Task/Doubly-linked-list-Element-definition/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Empty-program b/Lang/Modula-2/Empty-program new file mode 120000 index 0000000000..3fd5c6c5fd --- /dev/null +++ b/Lang/Modula-2/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Execute-a-system-command b/Lang/Modula-2/Execute-a-system-command new file mode 120000 index 0000000000..c654362559 --- /dev/null +++ b/Lang/Modula-2/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Exponentiation-operator b/Lang/Modula-2/Exponentiation-operator new file mode 120000 index 0000000000..4fdf6447a6 --- /dev/null +++ b/Lang/Modula-2/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Find-limit-of-recursion b/Lang/Modula-2/Find-limit-of-recursion new file mode 120000 index 0000000000..e01c2efbe6 --- /dev/null +++ b/Lang/Modula-2/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Function-definition b/Lang/Modula-2/Function-definition new file mode 120000 index 0000000000..356ce1d0ea --- /dev/null +++ b/Lang/Modula-2/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Greatest-common-divisor b/Lang/Modula-2/Greatest-common-divisor new file mode 120000 index 0000000000..160c55392f --- /dev/null +++ b/Lang/Modula-2/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Guess-the-number-With-feedback b/Lang/Modula-2/Guess-the-number-With-feedback new file mode 120000 index 0000000000..d4c242c8db --- /dev/null +++ b/Lang/Modula-2/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Guess-the-number-With-feedback-player b/Lang/Modula-2/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..264b7bb2d8 --- /dev/null +++ b/Lang/Modula-2/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Hailstone-sequence b/Lang/Modula-2/Hailstone-sequence new file mode 120000 index 0000000000..a44b6ead32 --- /dev/null +++ b/Lang/Modula-2/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Hello-world-Standard-error b/Lang/Modula-2/Hello-world-Standard-error new file mode 120000 index 0000000000..1292fd2ba7 --- /dev/null +++ b/Lang/Modula-2/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Hello-world-Text b/Lang/Modula-2/Hello-world-Text new file mode 120000 index 0000000000..f9a0282740 --- /dev/null +++ b/Lang/Modula-2/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Include-a-file b/Lang/Modula-2/Include-a-file new file mode 120000 index 0000000000..211003a11b --- /dev/null +++ b/Lang/Modula-2/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Increment-a-numerical-string b/Lang/Modula-2/Increment-a-numerical-string new file mode 120000 index 0000000000..8c8df2b401 --- /dev/null +++ b/Lang/Modula-2/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Infinity b/Lang/Modula-2/Infinity new file mode 120000 index 0000000000..8b0bbdbed3 --- /dev/null +++ b/Lang/Modula-2/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Input-loop b/Lang/Modula-2/Input-loop new file mode 120000 index 0000000000..e4f79443be --- /dev/null +++ b/Lang/Modula-2/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Integer-comparison b/Lang/Modula-2/Integer-comparison new file mode 120000 index 0000000000..d67bf6249e --- /dev/null +++ b/Lang/Modula-2/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-Do-while b/Lang/Modula-2/Loops-Do-while new file mode 120000 index 0000000000..d8a0c04044 --- /dev/null +++ b/Lang/Modula-2/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-Downward-for b/Lang/Modula-2/Loops-Downward-for new file mode 120000 index 0000000000..4996231cfb --- /dev/null +++ b/Lang/Modula-2/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-For b/Lang/Modula-2/Loops-For new file mode 120000 index 0000000000..077d0a229d --- /dev/null +++ b/Lang/Modula-2/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-For-with-a-specified-step b/Lang/Modula-2/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..779d1e4e2e --- /dev/null +++ b/Lang/Modula-2/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-Infinite b/Lang/Modula-2/Loops-Infinite new file mode 120000 index 0000000000..183f399fda --- /dev/null +++ b/Lang/Modula-2/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Loops-While b/Lang/Modula-2/Loops-While new file mode 120000 index 0000000000..c3c669cb52 --- /dev/null +++ b/Lang/Modula-2/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Menu b/Lang/Modula-2/Menu new file mode 120000 index 0000000000..23ebcda4b1 --- /dev/null +++ b/Lang/Modula-2/Menu @@ -0,0 +1 @@ +../../Task/Menu/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-3/0DESCRIPTION b/Lang/Modula-3/0DESCRIPTION new file mode 100644 index 0000000000..2101b2d969 --- /dev/null +++ b/Lang/Modula-3/0DESCRIPTION @@ -0,0 +1,24 @@ +{{language|Modula-3 +|exec=machine +|safety=both +|strength=strong +|express=explicit +|compat=structural +|checking=static +|parampass=both +|gc=yes +|tags=modula3 +|LCT=yes}} +'''Modula-3''' is a programming language created jointly at DEC and Olivetti by Luca Cardelli and others as an extension to Modula-2+, an extension of Niklaus Wirth's Modula-2 programming language. + +Modula-3 is imperative, structured, modular, object oriented, generic, garbage collected, and type safe. + +It contains a very nice threading syntax and implementation. + +Its main implementation is [[Critical Mass Modula-3]]. + +Modula-3 influenced a few languages such as [[C Sharp|C#]], [[Java]], [[Ocaml]] and [[Python]]. + +==Links== +* [http://www.modula3.org/ Modula-3 Resource Site] +* [http://en.wikipedia.org/wiki/Modula-3 Modula-3 at Wikipedia] \ No newline at end of file diff --git a/Lang/Modula-3/100-doors b/Lang/Modula-3/100-doors new file mode 120000 index 0000000000..ad14f3df5c --- /dev/null +++ b/Lang/Modula-3/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/99-Bottles-of-Beer b/Lang/Modula-3/99-Bottles-of-Beer new file mode 120000 index 0000000000..7d451f645d --- /dev/null +++ b/Lang/Modula-3/99-Bottles-of-Beer @@ -0,0 +1 @@ +../../Task/99-Bottles-of-Beer/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Ackermann-function b/Lang/Modula-3/Ackermann-function new file mode 120000 index 0000000000..27d2927a6a --- /dev/null +++ b/Lang/Modula-3/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Apply-a-callback-to-an-array b/Lang/Modula-3/Apply-a-callback-to-an-array new file mode 120000 index 0000000000..8601bef7fe --- /dev/null +++ b/Lang/Modula-3/Apply-a-callback-to-an-array @@ -0,0 +1 @@ +../../Task/Apply-a-callback-to-an-array/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Arithmetic-Integer b/Lang/Modula-3/Arithmetic-Integer new file mode 120000 index 0000000000..0d002e15cc --- /dev/null +++ b/Lang/Modula-3/Arithmetic-Integer @@ -0,0 +1 @@ +../../Task/Arithmetic-Integer/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Arrays b/Lang/Modula-3/Arrays new file mode 120000 index 0000000000..2c950b02e0 --- /dev/null +++ b/Lang/Modula-3/Arrays @@ -0,0 +1 @@ +../../Task/Arrays/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Assertions b/Lang/Modula-3/Assertions new file mode 120000 index 0000000000..4d9c250fa1 --- /dev/null +++ b/Lang/Modula-3/Assertions @@ -0,0 +1 @@ +../../Task/Assertions/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Bitmap b/Lang/Modula-3/Bitmap new file mode 120000 index 0000000000..52a82b6fcc --- /dev/null +++ b/Lang/Modula-3/Bitmap @@ -0,0 +1 @@ +../../Task/Bitmap/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Bitmap-Midpoint-circle-algorithm b/Lang/Modula-3/Bitmap-Midpoint-circle-algorithm new file mode 120000 index 0000000000..065f1c116d --- /dev/null +++ b/Lang/Modula-3/Bitmap-Midpoint-circle-algorithm @@ -0,0 +1 @@ +../../Task/Bitmap-Midpoint-circle-algorithm/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Bitmap-Write-a-PPM-file b/Lang/Modula-3/Bitmap-Write-a-PPM-file new file mode 120000 index 0000000000..72721b39c9 --- /dev/null +++ b/Lang/Modula-3/Bitmap-Write-a-PPM-file @@ -0,0 +1 @@ +../../Task/Bitmap-Write-a-PPM-file/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Bitwise-operations b/Lang/Modula-3/Bitwise-operations new file mode 120000 index 0000000000..07a4e38152 --- /dev/null +++ b/Lang/Modula-3/Bitwise-operations @@ -0,0 +1 @@ +../../Task/Bitwise-operations/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Boolean-values b/Lang/Modula-3/Boolean-values new file mode 120000 index 0000000000..4f1fdf220c --- /dev/null +++ b/Lang/Modula-3/Boolean-values @@ -0,0 +1 @@ +../../Task/Boolean-values/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Call-a-foreign-language-function b/Lang/Modula-3/Call-a-foreign-language-function new file mode 120000 index 0000000000..ac7feee232 --- /dev/null +++ b/Lang/Modula-3/Call-a-foreign-language-function @@ -0,0 +1 @@ +../../Task/Call-a-foreign-language-function/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Character-codes b/Lang/Modula-3/Character-codes new file mode 120000 index 0000000000..b5deb1e327 --- /dev/null +++ b/Lang/Modula-3/Character-codes @@ -0,0 +1 @@ +../../Task/Character-codes/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Check-that-file-exists b/Lang/Modula-3/Check-that-file-exists new file mode 120000 index 0000000000..eb874e3381 --- /dev/null +++ b/Lang/Modula-3/Check-that-file-exists @@ -0,0 +1 @@ +../../Task/Check-that-file-exists/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Command-line-arguments b/Lang/Modula-3/Command-line-arguments new file mode 120000 index 0000000000..f23bb03604 --- /dev/null +++ b/Lang/Modula-3/Command-line-arguments @@ -0,0 +1 @@ +../../Task/Command-line-arguments/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Comments b/Lang/Modula-3/Comments new file mode 120000 index 0000000000..8c3489c305 --- /dev/null +++ b/Lang/Modula-3/Comments @@ -0,0 +1 @@ +../../Task/Comments/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Compound-data-type b/Lang/Modula-3/Compound-data-type new file mode 120000 index 0000000000..d8e62a2302 --- /dev/null +++ b/Lang/Modula-3/Compound-data-type @@ -0,0 +1 @@ +../../Task/Compound-data-type/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Conditional-structures b/Lang/Modula-3/Conditional-structures new file mode 120000 index 0000000000..58e9d3e4e5 --- /dev/null +++ b/Lang/Modula-3/Conditional-structures @@ -0,0 +1 @@ +../../Task/Conditional-structures/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Create-a-file b/Lang/Modula-3/Create-a-file new file mode 120000 index 0000000000..e1aca13c3e --- /dev/null +++ b/Lang/Modula-3/Create-a-file @@ -0,0 +1 @@ +../../Task/Create-a-file/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Day-of-the-week b/Lang/Modula-3/Day-of-the-week new file mode 120000 index 0000000000..6426fc342b --- /dev/null +++ b/Lang/Modula-3/Day-of-the-week @@ -0,0 +1 @@ +../../Task/Day-of-the-week/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Define-a-primitive-data-type b/Lang/Modula-3/Define-a-primitive-data-type new file mode 120000 index 0000000000..7a7cdf701d --- /dev/null +++ b/Lang/Modula-3/Define-a-primitive-data-type @@ -0,0 +1 @@ +../../Task/Define-a-primitive-data-type/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Determine-if-a-string-is-numeric b/Lang/Modula-3/Determine-if-a-string-is-numeric new file mode 120000 index 0000000000..1b9b52b985 --- /dev/null +++ b/Lang/Modula-3/Determine-if-a-string-is-numeric @@ -0,0 +1 @@ +../../Task/Determine-if-a-string-is-numeric/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Empty-program b/Lang/Modula-3/Empty-program new file mode 120000 index 0000000000..526586f646 --- /dev/null +++ b/Lang/Modula-3/Empty-program @@ -0,0 +1 @@ +../../Task/Empty-program/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Enumerations b/Lang/Modula-3/Enumerations new file mode 120000 index 0000000000..5db6086d84 --- /dev/null +++ b/Lang/Modula-3/Enumerations @@ -0,0 +1 @@ +../../Task/Enumerations/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Ethiopian-multiplication b/Lang/Modula-3/Ethiopian-multiplication new file mode 120000 index 0000000000..201a9f32fd --- /dev/null +++ b/Lang/Modula-3/Ethiopian-multiplication @@ -0,0 +1 @@ +../../Task/Ethiopian-multiplication/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Exceptions b/Lang/Modula-3/Exceptions new file mode 120000 index 0000000000..e2ddec5902 --- /dev/null +++ b/Lang/Modula-3/Exceptions @@ -0,0 +1 @@ +../../Task/Exceptions/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Execute-a-system-command b/Lang/Modula-3/Execute-a-system-command new file mode 120000 index 0000000000..b8564bf7f3 --- /dev/null +++ b/Lang/Modula-3/Execute-a-system-command @@ -0,0 +1 @@ +../../Task/Execute-a-system-command/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Exponentiation-operator b/Lang/Modula-3/Exponentiation-operator new file mode 120000 index 0000000000..e304e27441 --- /dev/null +++ b/Lang/Modula-3/Exponentiation-operator @@ -0,0 +1 @@ +../../Task/Exponentiation-operator/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Factorial b/Lang/Modula-3/Factorial new file mode 120000 index 0000000000..392fdd65c0 --- /dev/null +++ b/Lang/Modula-3/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Fibonacci-sequence b/Lang/Modula-3/Fibonacci-sequence new file mode 120000 index 0000000000..ab68ddfb5a --- /dev/null +++ b/Lang/Modula-3/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/File-IO b/Lang/Modula-3/File-IO new file mode 120000 index 0000000000..c976bb8e68 --- /dev/null +++ b/Lang/Modula-3/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/File-modification-time b/Lang/Modula-3/File-modification-time new file mode 120000 index 0000000000..33aded4568 --- /dev/null +++ b/Lang/Modula-3/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/File-size b/Lang/Modula-3/File-size new file mode 120000 index 0000000000..a11995b930 --- /dev/null +++ b/Lang/Modula-3/File-size @@ -0,0 +1 @@ +../../Task/File-size/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/FizzBuzz b/Lang/Modula-3/FizzBuzz new file mode 120000 index 0000000000..ce39fd44c3 --- /dev/null +++ b/Lang/Modula-3/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Formatted-numeric-output b/Lang/Modula-3/Formatted-numeric-output new file mode 120000 index 0000000000..9fba8d17c7 --- /dev/null +++ b/Lang/Modula-3/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Function-definition b/Lang/Modula-3/Function-definition new file mode 120000 index 0000000000..cb288aa97a --- /dev/null +++ b/Lang/Modula-3/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Gamma-function b/Lang/Modula-3/Gamma-function new file mode 120000 index 0000000000..50f4aed779 --- /dev/null +++ b/Lang/Modula-3/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Generic-swap b/Lang/Modula-3/Generic-swap new file mode 120000 index 0000000000..2bb1149225 --- /dev/null +++ b/Lang/Modula-3/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Greatest-common-divisor b/Lang/Modula-3/Greatest-common-divisor new file mode 120000 index 0000000000..06a96c08a4 --- /dev/null +++ b/Lang/Modula-3/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Greatest-element-of-a-list b/Lang/Modula-3/Greatest-element-of-a-list new file mode 120000 index 0000000000..b8b9e0065b --- /dev/null +++ b/Lang/Modula-3/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Hello-world-Graphical b/Lang/Modula-3/Hello-world-Graphical new file mode 120000 index 0000000000..7d8819006b --- /dev/null +++ b/Lang/Modula-3/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Hello-world-Standard-error b/Lang/Modula-3/Hello-world-Standard-error new file mode 120000 index 0000000000..4af343996a --- /dev/null +++ b/Lang/Modula-3/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Hello-world-Text b/Lang/Modula-3/Hello-world-Text new file mode 120000 index 0000000000..fde9bcd87f --- /dev/null +++ b/Lang/Modula-3/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Higher-order-functions b/Lang/Modula-3/Higher-order-functions new file mode 120000 index 0000000000..990409d18f --- /dev/null +++ b/Lang/Modula-3/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Host-introspection b/Lang/Modula-3/Host-introspection new file mode 120000 index 0000000000..6c091e970a --- /dev/null +++ b/Lang/Modula-3/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Hostname b/Lang/Modula-3/Hostname new file mode 120000 index 0000000000..39423782ac --- /dev/null +++ b/Lang/Modula-3/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Increment-a-numerical-string b/Lang/Modula-3/Increment-a-numerical-string new file mode 120000 index 0000000000..680dd9b9ac --- /dev/null +++ b/Lang/Modula-3/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Infinity b/Lang/Modula-3/Infinity new file mode 120000 index 0000000000..c4854836d1 --- /dev/null +++ b/Lang/Modula-3/Infinity @@ -0,0 +1 @@ +../../Task/Infinity/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Input-loop b/Lang/Modula-3/Input-loop new file mode 120000 index 0000000000..930c5eb892 --- /dev/null +++ b/Lang/Modula-3/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Integer-comparison b/Lang/Modula-3/Integer-comparison new file mode 120000 index 0000000000..e3ff1d85f5 --- /dev/null +++ b/Lang/Modula-3/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Knapsack-problem-Unbounded b/Lang/Modula-3/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..f4e97e8d87 --- /dev/null +++ b/Lang/Modula-3/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Knuth-shuffle b/Lang/Modula-3/Knuth-shuffle new file mode 120000 index 0000000000..dd8ce30aa0 --- /dev/null +++ b/Lang/Modula-3/Knuth-shuffle @@ -0,0 +1 @@ +../../Task/Knuth-shuffle/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Literals-Integer b/Lang/Modula-3/Literals-Integer new file mode 120000 index 0000000000..39afbcbb8d --- /dev/null +++ b/Lang/Modula-3/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Literals-String b/Lang/Modula-3/Literals-String new file mode 120000 index 0000000000..8a4206b8a6 --- /dev/null +++ b/Lang/Modula-3/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Logical-operations b/Lang/Modula-3/Logical-operations new file mode 120000 index 0000000000..0242fa8e1a --- /dev/null +++ b/Lang/Modula-3/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loop-over-multiple-arrays-simultaneously b/Lang/Modula-3/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..8021873a4f --- /dev/null +++ b/Lang/Modula-3/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-Break b/Lang/Modula-3/Loops-Break new file mode 120000 index 0000000000..dc85852fd2 --- /dev/null +++ b/Lang/Modula-3/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-Continue b/Lang/Modula-3/Loops-Continue new file mode 120000 index 0000000000..da0de4ca71 --- /dev/null +++ b/Lang/Modula-3/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-Do-while b/Lang/Modula-3/Loops-Do-while new file mode 120000 index 0000000000..6042d655a2 --- /dev/null +++ b/Lang/Modula-3/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-Downward-for b/Lang/Modula-3/Loops-Downward-for new file mode 120000 index 0000000000..588b7dedc6 --- /dev/null +++ b/Lang/Modula-3/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-For b/Lang/Modula-3/Loops-For new file mode 120000 index 0000000000..69b46bd19c --- /dev/null +++ b/Lang/Modula-3/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-For-with-a-specified-step b/Lang/Modula-3/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..42fe29cc97 --- /dev/null +++ b/Lang/Modula-3/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-Infinite b/Lang/Modula-3/Loops-Infinite new file mode 120000 index 0000000000..0b25cf5a29 --- /dev/null +++ b/Lang/Modula-3/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-N-plus-one-half b/Lang/Modula-3/Loops-N-plus-one-half new file mode 120000 index 0000000000..5d74c530f2 --- /dev/null +++ b/Lang/Modula-3/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Loops-While b/Lang/Modula-3/Loops-While new file mode 120000 index 0000000000..490d066bd3 --- /dev/null +++ b/Lang/Modula-3/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Lucas-Lehmer-test b/Lang/Modula-3/Lucas-Lehmer-test new file mode 120000 index 0000000000..517cbbbe92 --- /dev/null +++ b/Lang/Modula-3/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/MD5-Implementation b/Lang/Modula-3/MD5-Implementation new file mode 120000 index 0000000000..f0b6dfd3ea --- /dev/null +++ b/Lang/Modula-3/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Man-or-boy-test b/Lang/Modula-3/Man-or-boy-test new file mode 120000 index 0000000000..6ef12822c5 --- /dev/null +++ b/Lang/Modula-3/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Mandelbrot-set b/Lang/Modula-3/Mandelbrot-set new file mode 120000 index 0000000000..3d98d3fd1b --- /dev/null +++ b/Lang/Modula-3/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Multiple-distinct-objects b/Lang/Modula-3/Multiple-distinct-objects new file mode 120000 index 0000000000..7ea12dbc1a --- /dev/null +++ b/Lang/Modula-3/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Modula-3 \ No newline at end of file diff --git a/Lang/Moonscript/0DESCRIPTION b/Lang/Moonscript/0DESCRIPTION new file mode 100644 index 0000000000..4d3d27c049 --- /dev/null +++ b/Lang/Moonscript/0DESCRIPTION @@ -0,0 +1 @@ +{{stub}}{{language}} \ No newline at end of file diff --git a/Lang/MySQL/0DESCRIPTION b/Lang/MySQL/0DESCRIPTION new file mode 100644 index 0000000000..9f2e3a69fb --- /dev/null +++ b/Lang/MySQL/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language}} +'''MySQL''' is a multithreaded, multi-user, SQL Database Management System (DBMS) with more than six million installations. + +'''MySQL''' is owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, which holds the copyright to most of the codebase. This is similar to the JBoss model and how the Free Software Foundation handles copyright in its projects, and dissimilar to how the Apache project does it, where the software is developed by a public community, and the copyright to the codebase is owned by its individual authors. + +The company develops and maintains the system, selling support and service contracts, as well as proprietary-licensed copies of MySQL, and employing people all over the world who collaborate via the Internet. MySQL AB was founded by David Axmark, Allan Larsson, and Michael "Monty" Widenius. + +==Citations== +* [http://en.wikipedia.org/wiki/Mysql Wikipedia:MySQL] + +[[Category:SQL Derivatives]] \ No newline at end of file diff --git a/Lang/Mython/0DESCRIPTION b/Lang/Mython/0DESCRIPTION new file mode 100644 index 0000000000..63b90c31b3 --- /dev/null +++ b/Lang/Mython/0DESCRIPTION @@ -0,0 +1,5 @@ +{{stub}} +{{language +|site=http://mython.org/ +}} +Mython is an extensible variant of the [[Python]] programming language. Mython makes Python extensible by adding two things: parametric quotation statement, and compile-time metaprogramming. The parametric quote statement is simply syntactic sugar for saying "run some function on this embedded string". Compile-time metaprogramming allows you to evaluate that function on the embedded string at compile time. This gives you added choice, both in terms of what your code looks like, and when you want to evaluate that code \ No newline at end of file diff --git a/Lang/Mythryl/0DESCRIPTION b/Lang/Mythryl/0DESCRIPTION new file mode 100644 index 0000000000..e697ad22c3 --- /dev/null +++ b/Lang/Mythryl/0DESCRIPTION @@ -0,0 +1,11 @@ +{{language|Mythryl +|site=http://mythryl.org/ +}} + +Mythryl is a general-purpose, modular, functional programming language with compile-time type checking and type inference supporting both scripting and application development. Mythryl is self-hosting, that is to say the Mythryl compiler is written in Mythryl. + +Mythryl is derived from [[derived from::SML/NJ]], a compiler and programming environment for [[Standard ML]]. It differs in that SML/NJ is a platform-neutral research testbed with an idiosyncratic syntax derived from Robin Milner's work with the logic framework LF, whereas Mythryl is a Linux-centric production-oriented software development platform with a C-flavored syntax.[[#Citation|[1]]] + + +==Citations== +*[[wp:Mythryl|Wikipedia entry on Mythryl]] \ No newline at end of file diff --git a/Lang/Mythryl/Hello-world-Text b/Lang/Mythryl/Hello-world-Text new file mode 120000 index 0000000000..fd4ad5c07a --- /dev/null +++ b/Lang/Mythryl/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Mythryl \ No newline at end of file diff --git a/Lang/PHP/Arbitrary-precision-integers-included b/Lang/PHP/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..31b0bc7c61 --- /dev/null +++ b/Lang/PHP/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/PHP \ No newline at end of file diff --git a/Lang/PHP/Factorial b/Lang/PHP/Factorial new file mode 120000 index 0000000000..13909ae562 --- /dev/null +++ b/Lang/PHP/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/PHP \ No newline at end of file diff --git a/Lang/PHP/Factors-of-a-Mersenne-number b/Lang/PHP/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..1b1eeea1bc --- /dev/null +++ b/Lang/PHP/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/PHP \ No newline at end of file diff --git a/Lang/PHP/Factors-of-an-integer b/Lang/PHP/Factors-of-an-integer new file mode 120000 index 0000000000..d72e96f41a --- /dev/null +++ b/Lang/PHP/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/PHP \ No newline at end of file diff --git a/Lang/PHP/Fibonacci-n-step-number-sequences b/Lang/PHP/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..73c2223fd5 --- /dev/null +++ b/Lang/PHP/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/PHP \ No newline at end of file diff --git a/Lang/PHP/Fibonacci-sequence b/Lang/PHP/Fibonacci-sequence new file mode 120000 index 0000000000..e53d0508bb --- /dev/null +++ b/Lang/PHP/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/PHP \ No newline at end of file diff --git a/Lang/PHP/File-IO b/Lang/PHP/File-IO new file mode 120000 index 0000000000..76eb48478c --- /dev/null +++ b/Lang/PHP/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/PHP \ No newline at end of file diff --git a/Lang/PHP/File-modification-time b/Lang/PHP/File-modification-time new file mode 120000 index 0000000000..e68457f0e7 --- /dev/null +++ b/Lang/PHP/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/PHP \ No newline at end of file diff --git a/Lang/PHP/File-size b/Lang/PHP/File-size new file mode 120000 index 0000000000..f7a0faabe8 --- /dev/null +++ b/Lang/PHP/File-size @@ -0,0 +1 @@ +../../Task/File-size/PHP \ No newline at end of file diff --git a/Lang/PHP/Filter b/Lang/PHP/Filter new file mode 120000 index 0000000000..6ffb6420cd --- /dev/null +++ b/Lang/PHP/Filter @@ -0,0 +1 @@ +../../Task/Filter/PHP \ No newline at end of file diff --git a/Lang/PHP/Find-common-directory-path b/Lang/PHP/Find-common-directory-path new file mode 120000 index 0000000000..44b44733b6 --- /dev/null +++ b/Lang/PHP/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/PHP \ No newline at end of file diff --git a/Lang/PHP/Find-limit-of-recursion b/Lang/PHP/Find-limit-of-recursion new file mode 120000 index 0000000000..b320d1b111 --- /dev/null +++ b/Lang/PHP/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/PHP \ No newline at end of file diff --git a/Lang/PHP/Find-the-missing-permutation b/Lang/PHP/Find-the-missing-permutation new file mode 120000 index 0000000000..14ab8d8cc5 --- /dev/null +++ b/Lang/PHP/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/PHP \ No newline at end of file diff --git a/Lang/PHP/First-class-functions b/Lang/PHP/First-class-functions new file mode 120000 index 0000000000..1e6bd930e8 --- /dev/null +++ b/Lang/PHP/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/PHP \ No newline at end of file diff --git a/Lang/PHP/Flatten-a-list b/Lang/PHP/Flatten-a-list new file mode 120000 index 0000000000..f1e27b5ef3 --- /dev/null +++ b/Lang/PHP/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/PHP \ No newline at end of file diff --git a/Lang/PHP/Flow-control-structures b/Lang/PHP/Flow-control-structures new file mode 120000 index 0000000000..c87b69ff83 --- /dev/null +++ b/Lang/PHP/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/PHP \ No newline at end of file diff --git a/Lang/PHP/Fork b/Lang/PHP/Fork new file mode 120000 index 0000000000..f39b02412e --- /dev/null +++ b/Lang/PHP/Fork @@ -0,0 +1 @@ +../../Task/Fork/PHP \ No newline at end of file diff --git a/Lang/PHP/Formatted-numeric-output b/Lang/PHP/Formatted-numeric-output new file mode 120000 index 0000000000..af75c5d118 --- /dev/null +++ b/Lang/PHP/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/PHP \ No newline at end of file diff --git a/Lang/PHP/Forward-difference b/Lang/PHP/Forward-difference new file mode 120000 index 0000000000..8f2a9f3166 --- /dev/null +++ b/Lang/PHP/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/PHP \ No newline at end of file diff --git a/Lang/PHP/Fractal-tree b/Lang/PHP/Fractal-tree new file mode 120000 index 0000000000..5eac50a176 --- /dev/null +++ b/Lang/PHP/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/PHP \ No newline at end of file diff --git a/Lang/PHP/Function-composition b/Lang/PHP/Function-composition new file mode 120000 index 0000000000..6cf5dd7f03 --- /dev/null +++ b/Lang/PHP/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/PHP \ No newline at end of file diff --git a/Lang/PHP/Function-definition b/Lang/PHP/Function-definition new file mode 120000 index 0000000000..c9a6e53052 --- /dev/null +++ b/Lang/PHP/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/PHP \ No newline at end of file diff --git a/Lang/PHP/Generic-swap b/Lang/PHP/Generic-swap new file mode 120000 index 0000000000..9a3d67b07f --- /dev/null +++ b/Lang/PHP/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/PHP \ No newline at end of file diff --git a/Lang/PHP/Grayscale-image b/Lang/PHP/Grayscale-image new file mode 120000 index 0000000000..aa897be760 --- /dev/null +++ b/Lang/PHP/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/PHP \ No newline at end of file diff --git a/Lang/PHP/Greatest-common-divisor b/Lang/PHP/Greatest-common-divisor new file mode 120000 index 0000000000..f3d97a6645 --- /dev/null +++ b/Lang/PHP/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/PHP \ No newline at end of file diff --git a/Lang/PHP/Greatest-element-of-a-list b/Lang/PHP/Greatest-element-of-a-list new file mode 120000 index 0000000000..ba130e3569 --- /dev/null +++ b/Lang/PHP/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/PHP \ No newline at end of file diff --git a/Lang/PHP/Greatest-subsequential-sum b/Lang/PHP/Greatest-subsequential-sum new file mode 120000 index 0000000000..601807aec8 --- /dev/null +++ b/Lang/PHP/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/PHP \ No newline at end of file diff --git a/Lang/PHP/Guess-the-number b/Lang/PHP/Guess-the-number new file mode 120000 index 0000000000..fa829d1f1a --- /dev/null +++ b/Lang/PHP/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/PHP \ No newline at end of file diff --git a/Lang/PHP/Guess-the-number-With-feedback b/Lang/PHP/Guess-the-number-With-feedback new file mode 120000 index 0000000000..19f5a920ed --- /dev/null +++ b/Lang/PHP/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/PHP \ No newline at end of file diff --git a/Lang/PHP/HTTP b/Lang/PHP/HTTP new file mode 120000 index 0000000000..ad59a88be7 --- /dev/null +++ b/Lang/PHP/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/PHP \ No newline at end of file diff --git a/Lang/PHP/HTTPS b/Lang/PHP/HTTPS new file mode 120000 index 0000000000..cf3d6f53af --- /dev/null +++ b/Lang/PHP/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/PHP \ No newline at end of file diff --git a/Lang/PHP/Hailstone-sequence b/Lang/PHP/Hailstone-sequence new file mode 120000 index 0000000000..fc44a945f3 --- /dev/null +++ b/Lang/PHP/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/PHP \ No newline at end of file diff --git a/Lang/PHP/Handle-a-signal b/Lang/PHP/Handle-a-signal new file mode 120000 index 0000000000..a2ceaa019e --- /dev/null +++ b/Lang/PHP/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/PHP \ No newline at end of file diff --git a/Lang/PHP/Happy-numbers b/Lang/PHP/Happy-numbers new file mode 120000 index 0000000000..69b6818616 --- /dev/null +++ b/Lang/PHP/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/Hash-from-two-arrays b/Lang/PHP/Hash-from-two-arrays new file mode 120000 index 0000000000..52a43d4d9b --- /dev/null +++ b/Lang/PHP/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/PHP \ No newline at end of file diff --git a/Lang/PHP/Haversine-formula b/Lang/PHP/Haversine-formula new file mode 120000 index 0000000000..819d68f3b9 --- /dev/null +++ b/Lang/PHP/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/PHP \ No newline at end of file diff --git a/Lang/PHP/Hello-world-Graphical b/Lang/PHP/Hello-world-Graphical new file mode 120000 index 0000000000..a5e565f9b1 --- /dev/null +++ b/Lang/PHP/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/PHP \ No newline at end of file diff --git a/Lang/PHP/Hello-world-Line-printer b/Lang/PHP/Hello-world-Line-printer new file mode 120000 index 0000000000..ad583719b6 --- /dev/null +++ b/Lang/PHP/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/PHP \ No newline at end of file diff --git a/Lang/PHP/Hello-world-Standard-error b/Lang/PHP/Hello-world-Standard-error new file mode 120000 index 0000000000..27f14bc5c9 --- /dev/null +++ b/Lang/PHP/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/PHP \ No newline at end of file diff --git a/Lang/PHP/Hello-world-Text b/Lang/PHP/Hello-world-Text new file mode 120000 index 0000000000..ff81d3daf8 --- /dev/null +++ b/Lang/PHP/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/PHP \ No newline at end of file diff --git a/Lang/PHP/Hello-world-Web-server b/Lang/PHP/Hello-world-Web-server new file mode 120000 index 0000000000..c6722c46c3 --- /dev/null +++ b/Lang/PHP/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/PHP \ No newline at end of file diff --git a/Lang/PHP/Here-document b/Lang/PHP/Here-document new file mode 120000 index 0000000000..55c9daa894 --- /dev/null +++ b/Lang/PHP/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/PHP \ No newline at end of file diff --git a/Lang/PHP/Higher-order-functions b/Lang/PHP/Higher-order-functions new file mode 120000 index 0000000000..1904ef047d --- /dev/null +++ b/Lang/PHP/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/PHP \ No newline at end of file diff --git a/Lang/PHP/Horners-rule-for-polynomial-evaluation b/Lang/PHP/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..c93125dac6 --- /dev/null +++ b/Lang/PHP/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/PHP \ No newline at end of file diff --git a/Lang/PHP/Hostname b/Lang/PHP/Hostname new file mode 120000 index 0000000000..da9f1181e4 --- /dev/null +++ b/Lang/PHP/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/PHP \ No newline at end of file diff --git a/Lang/PHP/Huffman-coding b/Lang/PHP/Huffman-coding new file mode 120000 index 0000000000..ad189eb1f7 --- /dev/null +++ b/Lang/PHP/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/PHP \ No newline at end of file diff --git a/Lang/PHP/Identity-matrix b/Lang/PHP/Identity-matrix new file mode 120000 index 0000000000..1cbfb95536 --- /dev/null +++ b/Lang/PHP/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/PHP \ No newline at end of file diff --git a/Lang/PHP/Include-a-file b/Lang/PHP/Include-a-file new file mode 120000 index 0000000000..053adceb0b --- /dev/null +++ b/Lang/PHP/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Increment-a-numerical-string b/Lang/PHP/Increment-a-numerical-string new file mode 120000 index 0000000000..b25772a777 --- /dev/null +++ b/Lang/PHP/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/PHP \ No newline at end of file diff --git a/Lang/PHP/Inheritance-Single b/Lang/PHP/Inheritance-Single new file mode 120000 index 0000000000..9aacbe431a --- /dev/null +++ b/Lang/PHP/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/PHP \ No newline at end of file diff --git a/Lang/PHP/Input-loop b/Lang/PHP/Input-loop new file mode 120000 index 0000000000..b4a43d09b1 --- /dev/null +++ b/Lang/PHP/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/PHP \ No newline at end of file diff --git a/Lang/PHP/Integer-comparison b/Lang/PHP/Integer-comparison new file mode 120000 index 0000000000..05fa87d9e5 --- /dev/null +++ b/Lang/PHP/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/PHP \ No newline at end of file diff --git a/Lang/PHP/Introspection b/Lang/PHP/Introspection new file mode 120000 index 0000000000..2ae40c8ea8 --- /dev/null +++ b/Lang/PHP/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/PHP \ No newline at end of file diff --git a/Lang/PHP/Jensens-Device b/Lang/PHP/Jensens-Device new file mode 120000 index 0000000000..f83eefd973 --- /dev/null +++ b/Lang/PHP/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/PHP \ No newline at end of file diff --git a/Lang/PHP/Kaprekar-numbers b/Lang/PHP/Kaprekar-numbers new file mode 120000 index 0000000000..7c796e9843 --- /dev/null +++ b/Lang/PHP/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/Knapsack-problem-0-1 b/Lang/PHP/Knapsack-problem-0-1 new file mode 120000 index 0000000000..b75cec902e --- /dev/null +++ b/Lang/PHP/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/PHP \ No newline at end of file diff --git a/Lang/PHP/Knuths-algorithm-S b/Lang/PHP/Knuths-algorithm-S new file mode 120000 index 0000000000..e1037e13e2 --- /dev/null +++ b/Lang/PHP/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/PHP \ No newline at end of file diff --git a/Lang/PHP/Langtons-ant b/Lang/PHP/Langtons-ant new file mode 120000 index 0000000000..b2c6fe4e0f --- /dev/null +++ b/Lang/PHP/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/PHP \ No newline at end of file diff --git a/Lang/PHP/Largest-int-from-concatenated-ints b/Lang/PHP/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..4fbf238934 --- /dev/null +++ b/Lang/PHP/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/PHP \ No newline at end of file diff --git a/Lang/PHP/Last-Friday-of-each-month b/Lang/PHP/Last-Friday-of-each-month new file mode 120000 index 0000000000..8e8203a05c --- /dev/null +++ b/Lang/PHP/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/PHP \ No newline at end of file diff --git a/Lang/PHP/Leap-year b/Lang/PHP/Leap-year new file mode 120000 index 0000000000..58acae8ae7 --- /dev/null +++ b/Lang/PHP/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/PHP \ No newline at end of file diff --git a/Lang/PHP/Least-common-multiple b/Lang/PHP/Least-common-multiple new file mode 120000 index 0000000000..e4af7c8e1f --- /dev/null +++ b/Lang/PHP/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/PHP \ No newline at end of file diff --git a/Lang/PHP/Letter-frequency b/Lang/PHP/Letter-frequency new file mode 120000 index 0000000000..0f0841f10b --- /dev/null +++ b/Lang/PHP/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/PHP \ No newline at end of file diff --git a/Lang/PHP/Levenshtein-distance b/Lang/PHP/Levenshtein-distance new file mode 120000 index 0000000000..adc9528456 --- /dev/null +++ b/Lang/PHP/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/PHP \ No newline at end of file diff --git a/Lang/PHP/Linear-congruential-generator b/Lang/PHP/Linear-congruential-generator new file mode 120000 index 0000000000..f0989611a8 --- /dev/null +++ b/Lang/PHP/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/PHP \ No newline at end of file diff --git a/Lang/PHP/Literals-Floating-point b/Lang/PHP/Literals-Floating-point new file mode 120000 index 0000000000..d5c872cad9 --- /dev/null +++ b/Lang/PHP/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/PHP \ No newline at end of file diff --git a/Lang/PHP/Literals-Integer b/Lang/PHP/Literals-Integer new file mode 120000 index 0000000000..3d390d1654 --- /dev/null +++ b/Lang/PHP/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/PHP \ No newline at end of file diff --git a/Lang/PHP/Literals-String b/Lang/PHP/Literals-String new file mode 120000 index 0000000000..eeb902f4bd --- /dev/null +++ b/Lang/PHP/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/PHP \ No newline at end of file diff --git a/Lang/PHP/Logical-operations b/Lang/PHP/Logical-operations new file mode 120000 index 0000000000..0b0916de17 --- /dev/null +++ b/Lang/PHP/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/PHP \ No newline at end of file diff --git a/Lang/PHP/Long-multiplication b/Lang/PHP/Long-multiplication new file mode 120000 index 0000000000..dd2d586b3b --- /dev/null +++ b/Lang/PHP/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/PHP \ No newline at end of file diff --git a/Lang/PHP/Look-and-say-sequence b/Lang/PHP/Look-and-say-sequence new file mode 120000 index 0000000000..d8a11bbff3 --- /dev/null +++ b/Lang/PHP/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/PHP \ No newline at end of file diff --git a/Lang/PHP/Loop-over-multiple-arrays-simultaneously b/Lang/PHP/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..a9b58d0923 --- /dev/null +++ b/Lang/PHP/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Break b/Lang/PHP/Loops-Break new file mode 120000 index 0000000000..a08b71849e --- /dev/null +++ b/Lang/PHP/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Continue b/Lang/PHP/Loops-Continue new file mode 120000 index 0000000000..0f49047306 --- /dev/null +++ b/Lang/PHP/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Do-while b/Lang/PHP/Loops-Do-while new file mode 120000 index 0000000000..d94c8f3cef --- /dev/null +++ b/Lang/PHP/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Downward-for b/Lang/PHP/Loops-Downward-for new file mode 120000 index 0000000000..b7de8d064e --- /dev/null +++ b/Lang/PHP/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-For b/Lang/PHP/Loops-For new file mode 120000 index 0000000000..fb6ab31bf5 --- /dev/null +++ b/Lang/PHP/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-For-with-a-specified-step b/Lang/PHP/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..28bd79560b --- /dev/null +++ b/Lang/PHP/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Foreach b/Lang/PHP/Loops-Foreach new file mode 120000 index 0000000000..43cf8c19e2 --- /dev/null +++ b/Lang/PHP/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Infinite b/Lang/PHP/Loops-Infinite new file mode 120000 index 0000000000..8cb7d9ab48 --- /dev/null +++ b/Lang/PHP/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-N-plus-one-half b/Lang/PHP/Loops-N-plus-one-half new file mode 120000 index 0000000000..9825690925 --- /dev/null +++ b/Lang/PHP/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-Nested b/Lang/PHP/Loops-Nested new file mode 120000 index 0000000000..a042a1c77d --- /dev/null +++ b/Lang/PHP/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/PHP \ No newline at end of file diff --git a/Lang/PHP/Loops-While b/Lang/PHP/Loops-While new file mode 120000 index 0000000000..965c25054d --- /dev/null +++ b/Lang/PHP/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/PHP \ No newline at end of file diff --git a/Lang/PHP/Luhn-test-of-credit-card-numbers b/Lang/PHP/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..7353fe4752 --- /dev/null +++ b/Lang/PHP/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/MD5 b/Lang/PHP/MD5 new file mode 120000 index 0000000000..fbb0f3acfe --- /dev/null +++ b/Lang/PHP/MD5 @@ -0,0 +1 @@ +../../Task/MD5/PHP \ No newline at end of file diff --git a/Lang/PHP/Man-or-boy-test b/Lang/PHP/Man-or-boy-test new file mode 120000 index 0000000000..52b3d463e7 --- /dev/null +++ b/Lang/PHP/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/PHP \ No newline at end of file diff --git a/Lang/PHP/Mandelbrot-set b/Lang/PHP/Mandelbrot-set new file mode 120000 index 0000000000..6a97e891ea --- /dev/null +++ b/Lang/PHP/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/PHP \ No newline at end of file diff --git a/Lang/PHP/Matrix-transposition b/Lang/PHP/Matrix-transposition new file mode 120000 index 0000000000..1572bdff2e --- /dev/null +++ b/Lang/PHP/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/PHP \ No newline at end of file diff --git a/Lang/PHP/Menu b/Lang/PHP/Menu new file mode 120000 index 0000000000..d7cccceae2 --- /dev/null +++ b/Lang/PHP/Menu @@ -0,0 +1 @@ +../../Task/Menu/PHP \ No newline at end of file diff --git a/Lang/PHP/Miller-Rabin-primality-test b/Lang/PHP/Miller-Rabin-primality-test new file mode 120000 index 0000000000..bff04d1a83 --- /dev/null +++ b/Lang/PHP/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/PHP \ No newline at end of file diff --git a/Lang/PHP/Minesweeper-game b/Lang/PHP/Minesweeper-game new file mode 120000 index 0000000000..46f1e95106 --- /dev/null +++ b/Lang/PHP/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/PHP \ No newline at end of file diff --git a/Lang/PHP/Modular-exponentiation b/Lang/PHP/Modular-exponentiation new file mode 120000 index 0000000000..1ef192d989 --- /dev/null +++ b/Lang/PHP/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/PHP \ No newline at end of file diff --git a/Lang/PHP/Monte-Carlo-methods b/Lang/PHP/Monte-Carlo-methods new file mode 120000 index 0000000000..813591ab1b --- /dev/null +++ b/Lang/PHP/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/PHP \ No newline at end of file diff --git a/Lang/PHP/Monty-Hall-problem b/Lang/PHP/Monty-Hall-problem new file mode 120000 index 0000000000..b0dd6095be --- /dev/null +++ b/Lang/PHP/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/PHP \ No newline at end of file diff --git a/Lang/PHP/Mutual-recursion b/Lang/PHP/Mutual-recursion new file mode 120000 index 0000000000..13a10254dc --- /dev/null +++ b/Lang/PHP/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/PHP \ No newline at end of file diff --git a/Lang/PIR/Fibonacci-sequence b/Lang/PIR/Fibonacci-sequence new file mode 120000 index 0000000000..b87ac3d740 --- /dev/null +++ b/Lang/PIR/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/PIR \ No newline at end of file diff --git a/Lang/PIR/Hello-world-Text b/Lang/PIR/Hello-world-Text new file mode 120000 index 0000000000..db00df1a33 --- /dev/null +++ b/Lang/PIR/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/PIR \ No newline at end of file diff --git a/Lang/Perl/24-game-Solve b/Lang/Perl/24-game-Solve new file mode 120000 index 0000000000..c09db57d7d --- /dev/null +++ b/Lang/Perl/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Perl \ No newline at end of file diff --git a/Lang/Perl/Arbitrary-precision-integers-included b/Lang/Perl/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..b499abc9be --- /dev/null +++ b/Lang/Perl/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Perl \ No newline at end of file diff --git a/Lang/Perl/Factorial b/Lang/Perl/Factorial new file mode 120000 index 0000000000..6eaba55ae6 --- /dev/null +++ b/Lang/Perl/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Perl \ No newline at end of file diff --git a/Lang/Perl/Factors-of-a-Mersenne-number b/Lang/Perl/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..1a9c63cc5e --- /dev/null +++ b/Lang/Perl/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Perl \ No newline at end of file diff --git a/Lang/Perl/Factors-of-an-integer b/Lang/Perl/Factors-of-an-integer new file mode 120000 index 0000000000..21adaec744 --- /dev/null +++ b/Lang/Perl/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Perl \ No newline at end of file diff --git a/Lang/Perl/Fibonacci-n-step-number-sequences b/Lang/Perl/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..bca6076323 --- /dev/null +++ b/Lang/Perl/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Perl \ No newline at end of file diff --git a/Lang/Perl/Fibonacci-sequence b/Lang/Perl/Fibonacci-sequence new file mode 120000 index 0000000000..59e8db6c57 --- /dev/null +++ b/Lang/Perl/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/File-IO b/Lang/Perl/File-IO new file mode 120000 index 0000000000..3f7e0d3a6c --- /dev/null +++ b/Lang/Perl/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Perl \ No newline at end of file diff --git a/Lang/Perl/File-modification-time b/Lang/Perl/File-modification-time new file mode 120000 index 0000000000..d3baddaf6c --- /dev/null +++ b/Lang/Perl/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Perl \ No newline at end of file diff --git a/Lang/Perl/File-size b/Lang/Perl/File-size new file mode 120000 index 0000000000..e517b914a1 --- /dev/null +++ b/Lang/Perl/File-size @@ -0,0 +1 @@ +../../Task/File-size/Perl \ No newline at end of file diff --git a/Lang/Perl/Filter b/Lang/Perl/Filter new file mode 120000 index 0000000000..c6cd0b560f --- /dev/null +++ b/Lang/Perl/Filter @@ -0,0 +1 @@ +../../Task/Filter/Perl \ No newline at end of file diff --git a/Lang/Perl/Find-common-directory-path b/Lang/Perl/Find-common-directory-path new file mode 120000 index 0000000000..7ebc296b81 --- /dev/null +++ b/Lang/Perl/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Perl \ No newline at end of file diff --git a/Lang/Perl/Find-limit-of-recursion b/Lang/Perl/Find-limit-of-recursion new file mode 120000 index 0000000000..f06f147004 --- /dev/null +++ b/Lang/Perl/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Perl \ No newline at end of file diff --git a/Lang/Perl/Find-the-missing-permutation b/Lang/Perl/Find-the-missing-permutation new file mode 120000 index 0000000000..12bd26d4a1 --- /dev/null +++ b/Lang/Perl/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Perl \ No newline at end of file diff --git a/Lang/Perl/First-class-functions b/Lang/Perl/First-class-functions new file mode 120000 index 0000000000..a08977ed0c --- /dev/null +++ b/Lang/Perl/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Perl \ No newline at end of file diff --git a/Lang/Perl/Five-weekends b/Lang/Perl/Five-weekends new file mode 120000 index 0000000000..60f06d8dc5 --- /dev/null +++ b/Lang/Perl/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Perl \ No newline at end of file diff --git a/Lang/Perl/Flatten-a-list b/Lang/Perl/Flatten-a-list new file mode 120000 index 0000000000..3d8d98e752 --- /dev/null +++ b/Lang/Perl/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Perl \ No newline at end of file diff --git a/Lang/Perl/Flow-control-structures b/Lang/Perl/Flow-control-structures new file mode 120000 index 0000000000..ea0cccf3bb --- /dev/null +++ b/Lang/Perl/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Perl \ No newline at end of file diff --git a/Lang/Perl/Floyds-triangle b/Lang/Perl/Floyds-triangle new file mode 120000 index 0000000000..ca116130a1 --- /dev/null +++ b/Lang/Perl/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Perl \ No newline at end of file diff --git a/Lang/Perl/Fork b/Lang/Perl/Fork new file mode 120000 index 0000000000..7a6bce6e9a --- /dev/null +++ b/Lang/Perl/Fork @@ -0,0 +1 @@ +../../Task/Fork/Perl \ No newline at end of file diff --git a/Lang/Perl/Formatted-numeric-output b/Lang/Perl/Formatted-numeric-output new file mode 120000 index 0000000000..a97d6a61fb --- /dev/null +++ b/Lang/Perl/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Perl \ No newline at end of file diff --git a/Lang/Perl/Forward-difference b/Lang/Perl/Forward-difference new file mode 120000 index 0000000000..c872906600 --- /dev/null +++ b/Lang/Perl/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Perl \ No newline at end of file diff --git a/Lang/Perl/Fractal-tree b/Lang/Perl/Fractal-tree new file mode 120000 index 0000000000..f83ac1ad0c --- /dev/null +++ b/Lang/Perl/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Perl \ No newline at end of file diff --git a/Lang/Perl/Function-composition b/Lang/Perl/Function-composition new file mode 120000 index 0000000000..56686df595 --- /dev/null +++ b/Lang/Perl/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Perl \ No newline at end of file diff --git a/Lang/Perl/Function-definition b/Lang/Perl/Function-definition new file mode 120000 index 0000000000..50d2530e68 --- /dev/null +++ b/Lang/Perl/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Perl \ No newline at end of file diff --git a/Lang/Perl/Function-prototype b/Lang/Perl/Function-prototype new file mode 120000 index 0000000000..bad6c65c69 --- /dev/null +++ b/Lang/Perl/Function-prototype @@ -0,0 +1 @@ +../../Task/Function-prototype/Perl \ No newline at end of file diff --git a/Lang/Perl/GUI-Maximum-window-dimensions b/Lang/Perl/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..556368b29c --- /dev/null +++ b/Lang/Perl/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Perl \ No newline at end of file diff --git a/Lang/Perl/Gamma-function b/Lang/Perl/Gamma-function new file mode 120000 index 0000000000..6d9a4d6c9d --- /dev/null +++ b/Lang/Perl/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Perl \ No newline at end of file diff --git a/Lang/Perl/Generator-Exponential b/Lang/Perl/Generator-Exponential new file mode 120000 index 0000000000..1ddb9fe3e1 --- /dev/null +++ b/Lang/Perl/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Perl \ No newline at end of file diff --git a/Lang/Perl/Generic-swap b/Lang/Perl/Generic-swap new file mode 120000 index 0000000000..d1151f250d --- /dev/null +++ b/Lang/Perl/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Perl \ No newline at end of file diff --git a/Lang/Perl/Globally-replace-text-in-several-files b/Lang/Perl/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..88bfee583f --- /dev/null +++ b/Lang/Perl/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Perl \ No newline at end of file diff --git a/Lang/Perl/Gray-code b/Lang/Perl/Gray-code new file mode 120000 index 0000000000..37ea5a45c9 --- /dev/null +++ b/Lang/Perl/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Perl \ No newline at end of file diff --git a/Lang/Perl/Grayscale-image b/Lang/Perl/Grayscale-image new file mode 120000 index 0000000000..543f6a6351 --- /dev/null +++ b/Lang/Perl/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Perl \ No newline at end of file diff --git a/Lang/Perl/Greatest-common-divisor b/Lang/Perl/Greatest-common-divisor new file mode 120000 index 0000000000..d3ec6d5293 --- /dev/null +++ b/Lang/Perl/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Perl \ No newline at end of file diff --git a/Lang/Perl/Greatest-element-of-a-list b/Lang/Perl/Greatest-element-of-a-list new file mode 120000 index 0000000000..a784aec62d --- /dev/null +++ b/Lang/Perl/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Perl \ No newline at end of file diff --git a/Lang/Perl/Greatest-subsequential-sum b/Lang/Perl/Greatest-subsequential-sum new file mode 120000 index 0000000000..6f37188b12 --- /dev/null +++ b/Lang/Perl/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Perl \ No newline at end of file diff --git a/Lang/Perl/Guess-the-number b/Lang/Perl/Guess-the-number new file mode 120000 index 0000000000..963d58b36b --- /dev/null +++ b/Lang/Perl/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Perl \ No newline at end of file diff --git a/Lang/Perl/Guess-the-number-With-feedback b/Lang/Perl/Guess-the-number-With-feedback new file mode 120000 index 0000000000..79d1154c96 --- /dev/null +++ b/Lang/Perl/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Perl \ No newline at end of file diff --git a/Lang/Perl/Guess-the-number-With-feedback-player b/Lang/Perl/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..4445655734 --- /dev/null +++ b/Lang/Perl/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Perl \ No newline at end of file diff --git a/Lang/Perl/HTTP b/Lang/Perl/HTTP new file mode 120000 index 0000000000..1535ddee4a --- /dev/null +++ b/Lang/Perl/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Perl \ No newline at end of file diff --git a/Lang/Perl/HTTPS b/Lang/Perl/HTTPS new file mode 120000 index 0000000000..0eed6e6d66 --- /dev/null +++ b/Lang/Perl/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Perl \ No newline at end of file diff --git a/Lang/Perl/HTTPS-Authenticated b/Lang/Perl/HTTPS-Authenticated new file mode 120000 index 0000000000..a8afeb329d --- /dev/null +++ b/Lang/Perl/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Perl \ No newline at end of file diff --git a/Lang/Perl/Hailstone-sequence b/Lang/Perl/Hailstone-sequence new file mode 120000 index 0000000000..ed0c363a2c --- /dev/null +++ b/Lang/Perl/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Hamming-numbers b/Lang/Perl/Hamming-numbers new file mode 120000 index 0000000000..0295fc3583 --- /dev/null +++ b/Lang/Perl/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Handle-a-signal b/Lang/Perl/Handle-a-signal new file mode 120000 index 0000000000..8633697ab4 --- /dev/null +++ b/Lang/Perl/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Perl \ No newline at end of file diff --git a/Lang/Perl/Happy-numbers b/Lang/Perl/Happy-numbers new file mode 120000 index 0000000000..fb44bf9cce --- /dev/null +++ b/Lang/Perl/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Harshad-or-Niven-series b/Lang/Perl/Harshad-or-Niven-series new file mode 120000 index 0000000000..d1d0801c41 --- /dev/null +++ b/Lang/Perl/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Perl \ No newline at end of file diff --git a/Lang/Perl/Hash-from-two-arrays b/Lang/Perl/Hash-from-two-arrays new file mode 120000 index 0000000000..d24675a6b8 --- /dev/null +++ b/Lang/Perl/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Graphical b/Lang/Perl/Hello-world-Graphical new file mode 120000 index 0000000000..efa37874b2 --- /dev/null +++ b/Lang/Perl/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Line-printer b/Lang/Perl/Hello-world-Line-printer new file mode 120000 index 0000000000..e010be568d --- /dev/null +++ b/Lang/Perl/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Newline-omission b/Lang/Perl/Hello-world-Newline-omission new file mode 120000 index 0000000000..85ba826573 --- /dev/null +++ b/Lang/Perl/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Standard-error b/Lang/Perl/Hello-world-Standard-error new file mode 120000 index 0000000000..97be0e7f48 --- /dev/null +++ b/Lang/Perl/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Text b/Lang/Perl/Hello-world-Text new file mode 120000 index 0000000000..6018c87676 --- /dev/null +++ b/Lang/Perl/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Perl \ No newline at end of file diff --git a/Lang/Perl/Hello-world-Web-server b/Lang/Perl/Hello-world-Web-server new file mode 120000 index 0000000000..1fdb46a9d3 --- /dev/null +++ b/Lang/Perl/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Perl \ No newline at end of file diff --git a/Lang/Perl/Here-document b/Lang/Perl/Here-document new file mode 120000 index 0000000000..4a5a339210 --- /dev/null +++ b/Lang/Perl/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Perl \ No newline at end of file diff --git a/Lang/Perl/Higher-order-functions b/Lang/Perl/Higher-order-functions new file mode 120000 index 0000000000..7a9c679d94 --- /dev/null +++ b/Lang/Perl/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Perl \ No newline at end of file diff --git a/Lang/Perl/History-variables b/Lang/Perl/History-variables new file mode 120000 index 0000000000..1aad5ff4a5 --- /dev/null +++ b/Lang/Perl/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Perl \ No newline at end of file diff --git a/Lang/Perl/Hofstadter-Conway-$10,000-sequence b/Lang/Perl/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..58a3e23bb5 --- /dev/null +++ b/Lang/Perl/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Hofstadter-Q-sequence b/Lang/Perl/Hofstadter-Q-sequence new file mode 120000 index 0000000000..99cc139720 --- /dev/null +++ b/Lang/Perl/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Holidays-related-to-Easter b/Lang/Perl/Holidays-related-to-Easter new file mode 120000 index 0000000000..4e35afc797 --- /dev/null +++ b/Lang/Perl/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Perl \ No newline at end of file diff --git a/Lang/Perl/Horners-rule-for-polynomial-evaluation b/Lang/Perl/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..2ad53d134c --- /dev/null +++ b/Lang/Perl/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Perl \ No newline at end of file diff --git a/Lang/Perl/Host-introspection b/Lang/Perl/Host-introspection new file mode 120000 index 0000000000..742351a598 --- /dev/null +++ b/Lang/Perl/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Perl \ No newline at end of file diff --git a/Lang/Perl/Hostname b/Lang/Perl/Hostname new file mode 120000 index 0000000000..709a50d5cb --- /dev/null +++ b/Lang/Perl/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Perl \ No newline at end of file diff --git a/Lang/Perl/Huffman-coding b/Lang/Perl/Huffman-coding new file mode 120000 index 0000000000..4971d423af --- /dev/null +++ b/Lang/Perl/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Perl \ No newline at end of file diff --git a/Lang/Perl/Identity-matrix b/Lang/Perl/Identity-matrix new file mode 120000 index 0000000000..d526a829ca --- /dev/null +++ b/Lang/Perl/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Perl \ No newline at end of file diff --git a/Lang/Perl/Include-a-file b/Lang/Perl/Include-a-file new file mode 120000 index 0000000000..d079fa0f11 --- /dev/null +++ b/Lang/Perl/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Increment-a-numerical-string b/Lang/Perl/Increment-a-numerical-string new file mode 120000 index 0000000000..f87cc258c5 --- /dev/null +++ b/Lang/Perl/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Perl \ No newline at end of file diff --git a/Lang/Perl/Inheritance-Multiple b/Lang/Perl/Inheritance-Multiple new file mode 120000 index 0000000000..62f7b621b3 --- /dev/null +++ b/Lang/Perl/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Perl \ No newline at end of file diff --git a/Lang/Perl/Inheritance-Single b/Lang/Perl/Inheritance-Single new file mode 120000 index 0000000000..406023175e --- /dev/null +++ b/Lang/Perl/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Perl \ No newline at end of file diff --git a/Lang/Perl/Input-loop b/Lang/Perl/Input-loop new file mode 120000 index 0000000000..dc8ea92bf2 --- /dev/null +++ b/Lang/Perl/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Perl \ No newline at end of file diff --git a/Lang/Perl/Integer-comparison b/Lang/Perl/Integer-comparison new file mode 120000 index 0000000000..91951c1593 --- /dev/null +++ b/Lang/Perl/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Perl \ No newline at end of file diff --git a/Lang/Perl/Integer-sequence b/Lang/Perl/Integer-sequence new file mode 120000 index 0000000000..017936f1b5 --- /dev/null +++ b/Lang/Perl/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Interactive-programming b/Lang/Perl/Interactive-programming new file mode 120000 index 0000000000..3b18838ab0 --- /dev/null +++ b/Lang/Perl/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Perl \ No newline at end of file diff --git a/Lang/Perl/Introspection b/Lang/Perl/Introspection new file mode 120000 index 0000000000..b855266d48 --- /dev/null +++ b/Lang/Perl/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Perl \ No newline at end of file diff --git a/Lang/Perl/Inverted-index b/Lang/Perl/Inverted-index new file mode 120000 index 0000000000..df31a3bece --- /dev/null +++ b/Lang/Perl/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Perl \ No newline at end of file diff --git a/Lang/Perl/Inverted-syntax b/Lang/Perl/Inverted-syntax new file mode 120000 index 0000000000..9dff3ea847 --- /dev/null +++ b/Lang/Perl/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Perl \ No newline at end of file diff --git a/Lang/Perl/Jensens-Device b/Lang/Perl/Jensens-Device new file mode 120000 index 0000000000..101f08bf73 --- /dev/null +++ b/Lang/Perl/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Perl \ No newline at end of file diff --git a/Lang/Perl/Josephus-problem b/Lang/Perl/Josephus-problem new file mode 120000 index 0000000000..524a653851 --- /dev/null +++ b/Lang/Perl/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Perl \ No newline at end of file diff --git a/Lang/Perl/Jump-anywhere b/Lang/Perl/Jump-anywhere new file mode 120000 index 0000000000..59ebe44633 --- /dev/null +++ b/Lang/Perl/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/Perl \ No newline at end of file diff --git a/Lang/Perl/Kaprekar-numbers b/Lang/Perl/Kaprekar-numbers new file mode 120000 index 0000000000..be7406fd01 --- /dev/null +++ b/Lang/Perl/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Perl/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..6bd973bdca --- /dev/null +++ b/Lang/Perl/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Perl \ No newline at end of file diff --git a/Lang/Perl/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Perl/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..d02127a329 --- /dev/null +++ b/Lang/Perl/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Perl \ No newline at end of file diff --git a/Lang/Perl/Knapsack-problem-0-1 b/Lang/Perl/Knapsack-problem-0-1 new file mode 120000 index 0000000000..02f108559c --- /dev/null +++ b/Lang/Perl/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Perl \ No newline at end of file diff --git a/Lang/Perl/Knapsack-problem-Bounded b/Lang/Perl/Knapsack-problem-Bounded new file mode 120000 index 0000000000..28ed2415c6 --- /dev/null +++ b/Lang/Perl/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Perl \ No newline at end of file diff --git a/Lang/Perl/Knapsack-problem-Continuous b/Lang/Perl/Knapsack-problem-Continuous new file mode 120000 index 0000000000..3c119ffef2 --- /dev/null +++ b/Lang/Perl/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Perl \ No newline at end of file diff --git a/Lang/Perl/Knapsack-problem-Unbounded b/Lang/Perl/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..8d5dc21399 --- /dev/null +++ b/Lang/Perl/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Perl \ No newline at end of file diff --git a/Lang/Perl/Knights-tour b/Lang/Perl/Knights-tour new file mode 120000 index 0000000000..55a24dd569 --- /dev/null +++ b/Lang/Perl/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Perl \ No newline at end of file diff --git a/Lang/Perl/Knuths-algorithm-S b/Lang/Perl/Knuths-algorithm-S new file mode 120000 index 0000000000..a74c76524a --- /dev/null +++ b/Lang/Perl/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Perl \ No newline at end of file diff --git a/Lang/Perl/LZW-compression b/Lang/Perl/LZW-compression new file mode 120000 index 0000000000..d3a5f44fbf --- /dev/null +++ b/Lang/Perl/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Perl \ No newline at end of file diff --git a/Lang/Perl/Langtons-ant b/Lang/Perl/Langtons-ant new file mode 120000 index 0000000000..dec1078ba3 --- /dev/null +++ b/Lang/Perl/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Perl \ No newline at end of file diff --git a/Lang/Perl/Largest-int-from-concatenated-ints b/Lang/Perl/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..cf1fcc77cb --- /dev/null +++ b/Lang/Perl/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Perl \ No newline at end of file diff --git a/Lang/Perl/Last-Friday-of-each-month b/Lang/Perl/Last-Friday-of-each-month new file mode 120000 index 0000000000..daaf0400e4 --- /dev/null +++ b/Lang/Perl/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Perl \ No newline at end of file diff --git a/Lang/Perl/Last-letter-first-letter b/Lang/Perl/Last-letter-first-letter new file mode 120000 index 0000000000..7a82e02e26 --- /dev/null +++ b/Lang/Perl/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Perl \ No newline at end of file diff --git a/Lang/Perl/Leap-year b/Lang/Perl/Leap-year new file mode 120000 index 0000000000..56541f9f11 --- /dev/null +++ b/Lang/Perl/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Perl \ No newline at end of file diff --git a/Lang/Perl/Least-common-multiple b/Lang/Perl/Least-common-multiple new file mode 120000 index 0000000000..c4631030b5 --- /dev/null +++ b/Lang/Perl/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Perl \ No newline at end of file diff --git a/Lang/Perl/Letter-frequency b/Lang/Perl/Letter-frequency new file mode 120000 index 0000000000..9d788a745c --- /dev/null +++ b/Lang/Perl/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Perl \ No newline at end of file diff --git a/Lang/Perl/Levenshtein-distance b/Lang/Perl/Levenshtein-distance new file mode 120000 index 0000000000..2eb466d586 --- /dev/null +++ b/Lang/Perl/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Perl \ No newline at end of file diff --git a/Lang/Perl/Linear-congruential-generator b/Lang/Perl/Linear-congruential-generator new file mode 120000 index 0000000000..50d930dc0c --- /dev/null +++ b/Lang/Perl/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Perl \ No newline at end of file diff --git a/Lang/Perl/List-comprehensions b/Lang/Perl/List-comprehensions new file mode 120000 index 0000000000..76e5f2797d --- /dev/null +++ b/Lang/Perl/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Perl \ No newline at end of file diff --git a/Lang/Perl/Literals-Floating-point b/Lang/Perl/Literals-Floating-point new file mode 120000 index 0000000000..04d4e4e875 --- /dev/null +++ b/Lang/Perl/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Perl \ No newline at end of file diff --git a/Lang/Perl/Literals-Integer b/Lang/Perl/Literals-Integer new file mode 120000 index 0000000000..9001f3598d --- /dev/null +++ b/Lang/Perl/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Perl \ No newline at end of file diff --git a/Lang/Perl/Literals-String b/Lang/Perl/Literals-String new file mode 120000 index 0000000000..a16944f381 --- /dev/null +++ b/Lang/Perl/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Perl \ No newline at end of file diff --git a/Lang/Perl/Logical-operations b/Lang/Perl/Logical-operations new file mode 120000 index 0000000000..8c79ee7bd7 --- /dev/null +++ b/Lang/Perl/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Perl \ No newline at end of file diff --git a/Lang/Perl/Long-multiplication b/Lang/Perl/Long-multiplication new file mode 120000 index 0000000000..6925a1c1c5 --- /dev/null +++ b/Lang/Perl/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Perl \ No newline at end of file diff --git a/Lang/Perl/Longest-common-subsequence b/Lang/Perl/Longest-common-subsequence new file mode 120000 index 0000000000..42d77ec2a6 --- /dev/null +++ b/Lang/Perl/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Longest-string-challenge b/Lang/Perl/Longest-string-challenge new file mode 120000 index 0000000000..37fdc4fe81 --- /dev/null +++ b/Lang/Perl/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Perl \ No newline at end of file diff --git a/Lang/Perl/Look-and-say-sequence b/Lang/Perl/Look-and-say-sequence new file mode 120000 index 0000000000..2eb82fabde --- /dev/null +++ b/Lang/Perl/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Loop-over-multiple-arrays-simultaneously b/Lang/Perl/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..be4f725ce9 --- /dev/null +++ b/Lang/Perl/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Break b/Lang/Perl/Loops-Break new file mode 120000 index 0000000000..512fdc3a94 --- /dev/null +++ b/Lang/Perl/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Continue b/Lang/Perl/Loops-Continue new file mode 120000 index 0000000000..d779c44ca7 --- /dev/null +++ b/Lang/Perl/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Do-while b/Lang/Perl/Loops-Do-while new file mode 120000 index 0000000000..f336ca9fb2 --- /dev/null +++ b/Lang/Perl/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Downward-for b/Lang/Perl/Loops-Downward-for new file mode 120000 index 0000000000..fedb9503f6 --- /dev/null +++ b/Lang/Perl/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-For b/Lang/Perl/Loops-For new file mode 120000 index 0000000000..f4ab3e63bc --- /dev/null +++ b/Lang/Perl/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-For-with-a-specified-step b/Lang/Perl/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..09503f638d --- /dev/null +++ b/Lang/Perl/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Foreach b/Lang/Perl/Loops-Foreach new file mode 120000 index 0000000000..57d49aaeca --- /dev/null +++ b/Lang/Perl/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Infinite b/Lang/Perl/Loops-Infinite new file mode 120000 index 0000000000..eaac01dacf --- /dev/null +++ b/Lang/Perl/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-N-plus-one-half b/Lang/Perl/Loops-N-plus-one-half new file mode 120000 index 0000000000..5f9579d9ec --- /dev/null +++ b/Lang/Perl/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-Nested b/Lang/Perl/Loops-Nested new file mode 120000 index 0000000000..98043ee0f7 --- /dev/null +++ b/Lang/Perl/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Perl \ No newline at end of file diff --git a/Lang/Perl/Loops-While b/Lang/Perl/Loops-While new file mode 120000 index 0000000000..0185e0804e --- /dev/null +++ b/Lang/Perl/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Perl \ No newline at end of file diff --git a/Lang/Perl/Lucas-Lehmer-test b/Lang/Perl/Lucas-Lehmer-test new file mode 120000 index 0000000000..51812a822e --- /dev/null +++ b/Lang/Perl/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Perl \ No newline at end of file diff --git a/Lang/Perl/Luhn-test-of-credit-card-numbers b/Lang/Perl/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..601ace245a --- /dev/null +++ b/Lang/Perl/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/MD5 b/Lang/Perl/MD5 new file mode 120000 index 0000000000..99686fb019 --- /dev/null +++ b/Lang/Perl/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Perl \ No newline at end of file diff --git a/Lang/Perl/Man-or-boy-test b/Lang/Perl/Man-or-boy-test new file mode 120000 index 0000000000..cf12e2a901 --- /dev/null +++ b/Lang/Perl/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Perl \ No newline at end of file diff --git a/Lang/Perl/Mandelbrot-set b/Lang/Perl/Mandelbrot-set new file mode 120000 index 0000000000..e286830a6f --- /dev/null +++ b/Lang/Perl/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Perl \ No newline at end of file diff --git a/Lang/Perl/Map-range b/Lang/Perl/Map-range new file mode 120000 index 0000000000..d8a5376b5f --- /dev/null +++ b/Lang/Perl/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Perl \ No newline at end of file diff --git a/Lang/Perl/Matrix-exponentiation-operator b/Lang/Perl/Matrix-exponentiation-operator new file mode 120000 index 0000000000..730173a445 --- /dev/null +++ b/Lang/Perl/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Perl \ No newline at end of file diff --git a/Lang/Perl/Matrix-multiplication b/Lang/Perl/Matrix-multiplication new file mode 120000 index 0000000000..0b14e36c88 --- /dev/null +++ b/Lang/Perl/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Perl \ No newline at end of file diff --git a/Lang/Perl/Matrix-transposition b/Lang/Perl/Matrix-transposition new file mode 120000 index 0000000000..ef67d88c27 --- /dev/null +++ b/Lang/Perl/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Perl \ No newline at end of file diff --git a/Lang/Perl/Maze-generation b/Lang/Perl/Maze-generation new file mode 120000 index 0000000000..6cff4a1058 --- /dev/null +++ b/Lang/Perl/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Perl \ No newline at end of file diff --git a/Lang/Perl/Memory-layout-of-a-data-structure b/Lang/Perl/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..ca722d85b9 --- /dev/null +++ b/Lang/Perl/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Perl \ No newline at end of file diff --git a/Lang/Perl/Menu b/Lang/Perl/Menu new file mode 120000 index 0000000000..8ae635b49a --- /dev/null +++ b/Lang/Perl/Menu @@ -0,0 +1 @@ +../../Task/Menu/Perl \ No newline at end of file diff --git a/Lang/Perl/Metaprogramming b/Lang/Perl/Metaprogramming new file mode 120000 index 0000000000..743a104fec --- /dev/null +++ b/Lang/Perl/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/Perl \ No newline at end of file diff --git a/Lang/Perl/Middle-three-digits b/Lang/Perl/Middle-three-digits new file mode 120000 index 0000000000..fd6779495b --- /dev/null +++ b/Lang/Perl/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Perl \ No newline at end of file diff --git a/Lang/Perl/Miller-Rabin-primality-test b/Lang/Perl/Miller-Rabin-primality-test new file mode 120000 index 0000000000..f2d8f376aa --- /dev/null +++ b/Lang/Perl/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Perl \ No newline at end of file diff --git a/Lang/Perl/Modular-exponentiation b/Lang/Perl/Modular-exponentiation new file mode 120000 index 0000000000..393a5c76cd --- /dev/null +++ b/Lang/Perl/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Perl \ No newline at end of file diff --git a/Lang/Perl/Modular-inverse b/Lang/Perl/Modular-inverse new file mode 120000 index 0000000000..81d6514a3a --- /dev/null +++ b/Lang/Perl/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Perl \ No newline at end of file diff --git a/Lang/Perl/Monte-Carlo-methods b/Lang/Perl/Monte-Carlo-methods new file mode 120000 index 0000000000..2e4827cc04 --- /dev/null +++ b/Lang/Perl/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Perl \ No newline at end of file diff --git a/Lang/Perl/Monty-Hall-problem b/Lang/Perl/Monty-Hall-problem new file mode 120000 index 0000000000..a986bac84e --- /dev/null +++ b/Lang/Perl/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Perl \ No newline at end of file diff --git a/Lang/Perl/Morse-code b/Lang/Perl/Morse-code new file mode 120000 index 0000000000..5db42635b0 --- /dev/null +++ b/Lang/Perl/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Perl \ No newline at end of file diff --git a/Lang/Perl/Mouse-position b/Lang/Perl/Mouse-position new file mode 120000 index 0000000000..b1c15895d0 --- /dev/null +++ b/Lang/Perl/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Perl \ No newline at end of file diff --git a/Lang/Perl/Multifactorial b/Lang/Perl/Multifactorial new file mode 120000 index 0000000000..8478c1eec5 --- /dev/null +++ b/Lang/Perl/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Perl \ No newline at end of file diff --git a/Lang/Perl/Multiple-distinct-objects b/Lang/Perl/Multiple-distinct-objects new file mode 120000 index 0000000000..c185b05543 --- /dev/null +++ b/Lang/Perl/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Perl \ No newline at end of file diff --git a/Lang/Perl/Multiplication-tables b/Lang/Perl/Multiplication-tables new file mode 120000 index 0000000000..4214aee9c8 --- /dev/null +++ b/Lang/Perl/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Perl \ No newline at end of file diff --git a/Lang/Perl/Multisplit b/Lang/Perl/Multisplit new file mode 120000 index 0000000000..6adb864f14 --- /dev/null +++ b/Lang/Perl/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Perl \ No newline at end of file diff --git a/Lang/Perl/Mutex b/Lang/Perl/Mutex new file mode 120000 index 0000000000..37318a2941 --- /dev/null +++ b/Lang/Perl/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Perl \ No newline at end of file diff --git a/Lang/Perl/Mutual-recursion b/Lang/Perl/Mutual-recursion new file mode 120000 index 0000000000..f595cb4d4a --- /dev/null +++ b/Lang/Perl/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Perl \ No newline at end of file diff --git a/Lang/PicoLisp/24-game-Solve b/Lang/PicoLisp/24-game-Solve new file mode 120000 index 0000000000..7e49f4bc6a --- /dev/null +++ b/Lang/PicoLisp/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arbitrary-precision-integers-included b/Lang/PicoLisp/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..39a922253a --- /dev/null +++ b/Lang/PicoLisp/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Factorial b/Lang/PicoLisp/Factorial new file mode 120000 index 0000000000..4d113340a4 --- /dev/null +++ b/Lang/PicoLisp/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Factors-of-a-Mersenne-number b/Lang/PicoLisp/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..79b13590af --- /dev/null +++ b/Lang/PicoLisp/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Factors-of-an-integer b/Lang/PicoLisp/Factors-of-an-integer new file mode 120000 index 0000000000..9b914faf24 --- /dev/null +++ b/Lang/PicoLisp/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Fast-Fourier-transform b/Lang/PicoLisp/Fast-Fourier-transform new file mode 120000 index 0000000000..769d770d50 --- /dev/null +++ b/Lang/PicoLisp/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Fibonacci-n-step-number-sequences b/Lang/PicoLisp/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..e84656ad6f --- /dev/null +++ b/Lang/PicoLisp/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Fibonacci-sequence b/Lang/PicoLisp/Fibonacci-sequence new file mode 120000 index 0000000000..7b01f93706 --- /dev/null +++ b/Lang/PicoLisp/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/File-IO b/Lang/PicoLisp/File-IO new file mode 120000 index 0000000000..e04416c8f8 --- /dev/null +++ b/Lang/PicoLisp/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/File-modification-time b/Lang/PicoLisp/File-modification-time new file mode 120000 index 0000000000..c37e8a2f22 --- /dev/null +++ b/Lang/PicoLisp/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/File-size b/Lang/PicoLisp/File-size new file mode 120000 index 0000000000..dd49eada82 --- /dev/null +++ b/Lang/PicoLisp/File-size @@ -0,0 +1 @@ +../../Task/File-size/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Filter b/Lang/PicoLisp/Filter new file mode 120000 index 0000000000..a3cfeb595b --- /dev/null +++ b/Lang/PicoLisp/Filter @@ -0,0 +1 @@ +../../Task/Filter/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Find-common-directory-path b/Lang/PicoLisp/Find-common-directory-path new file mode 120000 index 0000000000..53d7da0d38 --- /dev/null +++ b/Lang/PicoLisp/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Find-the-missing-permutation b/Lang/PicoLisp/Find-the-missing-permutation new file mode 120000 index 0000000000..6c9e0bf1b7 --- /dev/null +++ b/Lang/PicoLisp/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/First-class-environments b/Lang/PicoLisp/First-class-environments new file mode 120000 index 0000000000..416754a1a7 --- /dev/null +++ b/Lang/PicoLisp/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/First-class-functions b/Lang/PicoLisp/First-class-functions new file mode 120000 index 0000000000..92d37d0fe7 --- /dev/null +++ b/Lang/PicoLisp/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/First-class-functions-Use-numbers-analogously b/Lang/PicoLisp/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..de8518b1d5 --- /dev/null +++ b/Lang/PicoLisp/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Five-weekends b/Lang/PicoLisp/Five-weekends new file mode 120000 index 0000000000..c613f15523 --- /dev/null +++ b/Lang/PicoLisp/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Flatten-a-list b/Lang/PicoLisp/Flatten-a-list new file mode 120000 index 0000000000..1d3f81a819 --- /dev/null +++ b/Lang/PicoLisp/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Floyds-triangle b/Lang/PicoLisp/Floyds-triangle new file mode 120000 index 0000000000..d1da1edbab --- /dev/null +++ b/Lang/PicoLisp/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Fork b/Lang/PicoLisp/Fork new file mode 120000 index 0000000000..4e8d9450ce --- /dev/null +++ b/Lang/PicoLisp/Fork @@ -0,0 +1 @@ +../../Task/Fork/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Formal-power-series b/Lang/PicoLisp/Formal-power-series new file mode 120000 index 0000000000..4becf836d1 --- /dev/null +++ b/Lang/PicoLisp/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Formatted-numeric-output b/Lang/PicoLisp/Formatted-numeric-output new file mode 120000 index 0000000000..e5336bccb8 --- /dev/null +++ b/Lang/PicoLisp/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Forward-difference b/Lang/PicoLisp/Forward-difference new file mode 120000 index 0000000000..7d2628731d --- /dev/null +++ b/Lang/PicoLisp/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Four-bit-adder b/Lang/PicoLisp/Four-bit-adder new file mode 120000 index 0000000000..413b953cb4 --- /dev/null +++ b/Lang/PicoLisp/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Fractal-tree b/Lang/PicoLisp/Fractal-tree new file mode 120000 index 0000000000..1e31e67087 --- /dev/null +++ b/Lang/PicoLisp/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Function-composition b/Lang/PicoLisp/Function-composition new file mode 120000 index 0000000000..facdfa73e7 --- /dev/null +++ b/Lang/PicoLisp/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Function-definition b/Lang/PicoLisp/Function-definition new file mode 120000 index 0000000000..6b5946cc14 --- /dev/null +++ b/Lang/PicoLisp/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Function-frequency b/Lang/PicoLisp/Function-frequency new file mode 120000 index 0000000000..af9c4c1e5c --- /dev/null +++ b/Lang/PicoLisp/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/GUI-Maximum-window-dimensions b/Lang/PicoLisp/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..4990380ef1 --- /dev/null +++ b/Lang/PicoLisp/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/GUI-component-interaction b/Lang/PicoLisp/GUI-component-interaction new file mode 120000 index 0000000000..9f19fd5311 --- /dev/null +++ b/Lang/PicoLisp/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/GUI-enabling-disabling-of-controls b/Lang/PicoLisp/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..9e90984d24 --- /dev/null +++ b/Lang/PicoLisp/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Galton-box-animation b/Lang/PicoLisp/Galton-box-animation new file mode 120000 index 0000000000..eafc747720 --- /dev/null +++ b/Lang/PicoLisp/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Gamma-function b/Lang/PicoLisp/Gamma-function new file mode 120000 index 0000000000..62f9bb13f9 --- /dev/null +++ b/Lang/PicoLisp/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Generator-Exponential b/Lang/PicoLisp/Generator-Exponential new file mode 120000 index 0000000000..1ee0d96050 --- /dev/null +++ b/Lang/PicoLisp/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Generic-swap b/Lang/PicoLisp/Generic-swap new file mode 120000 index 0000000000..7049e60d4f --- /dev/null +++ b/Lang/PicoLisp/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Globally-replace-text-in-several-files b/Lang/PicoLisp/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..c149b9dc68 --- /dev/null +++ b/Lang/PicoLisp/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Gray-code b/Lang/PicoLisp/Gray-code new file mode 120000 index 0000000000..ebd7feee7b --- /dev/null +++ b/Lang/PicoLisp/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Grayscale-image b/Lang/PicoLisp/Grayscale-image new file mode 120000 index 0000000000..0cac81e7a4 --- /dev/null +++ b/Lang/PicoLisp/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Greatest-common-divisor b/Lang/PicoLisp/Greatest-common-divisor new file mode 120000 index 0000000000..45cf91c69c --- /dev/null +++ b/Lang/PicoLisp/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Greatest-element-of-a-list b/Lang/PicoLisp/Greatest-element-of-a-list new file mode 120000 index 0000000000..c9fa9fe3e2 --- /dev/null +++ b/Lang/PicoLisp/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Greatest-subsequential-sum b/Lang/PicoLisp/Greatest-subsequential-sum new file mode 120000 index 0000000000..8fd88a2d9c --- /dev/null +++ b/Lang/PicoLisp/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Greyscale-bars-Display b/Lang/PicoLisp/Greyscale-bars-Display new file mode 120000 index 0000000000..5236ffa00d --- /dev/null +++ b/Lang/PicoLisp/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Guess-the-number b/Lang/PicoLisp/Guess-the-number new file mode 120000 index 0000000000..ceb9723c60 --- /dev/null +++ b/Lang/PicoLisp/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Guess-the-number-With-feedback b/Lang/PicoLisp/Guess-the-number-With-feedback new file mode 120000 index 0000000000..d5320b82b1 --- /dev/null +++ b/Lang/PicoLisp/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Guess-the-number-With-feedback-player b/Lang/PicoLisp/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..a0372b7f9a --- /dev/null +++ b/Lang/PicoLisp/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/HTTP b/Lang/PicoLisp/HTTP new file mode 120000 index 0000000000..944f1daf20 --- /dev/null +++ b/Lang/PicoLisp/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/HTTPS b/Lang/PicoLisp/HTTPS new file mode 120000 index 0000000000..cffb808eed --- /dev/null +++ b/Lang/PicoLisp/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/HTTPS-Authenticated b/Lang/PicoLisp/HTTPS-Authenticated new file mode 120000 index 0000000000..0ab13c2303 --- /dev/null +++ b/Lang/PicoLisp/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/HTTPS-Client-authenticated b/Lang/PicoLisp/HTTPS-Client-authenticated new file mode 120000 index 0000000000..18841524d3 --- /dev/null +++ b/Lang/PicoLisp/HTTPS-Client-authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Client-authenticated/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hailstone-sequence b/Lang/PicoLisp/Hailstone-sequence new file mode 120000 index 0000000000..0e539718ad --- /dev/null +++ b/Lang/PicoLisp/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hamming-numbers b/Lang/PicoLisp/Hamming-numbers new file mode 120000 index 0000000000..93898fb503 --- /dev/null +++ b/Lang/PicoLisp/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Handle-a-signal b/Lang/PicoLisp/Handle-a-signal new file mode 120000 index 0000000000..d5af5ac83a --- /dev/null +++ b/Lang/PicoLisp/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Happy-numbers b/Lang/PicoLisp/Happy-numbers new file mode 120000 index 0000000000..f96da2d626 --- /dev/null +++ b/Lang/PicoLisp/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hash-from-two-arrays b/Lang/PicoLisp/Hash-from-two-arrays new file mode 120000 index 0000000000..c239e44af3 --- /dev/null +++ b/Lang/PicoLisp/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Haversine-formula b/Lang/PicoLisp/Haversine-formula new file mode 120000 index 0000000000..8b31fe6232 --- /dev/null +++ b/Lang/PicoLisp/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Graphical b/Lang/PicoLisp/Hello-world-Graphical new file mode 120000 index 0000000000..7a014f9aa7 --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Line-printer b/Lang/PicoLisp/Hello-world-Line-printer new file mode 120000 index 0000000000..088ee76d4b --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Newline-omission b/Lang/PicoLisp/Hello-world-Newline-omission new file mode 120000 index 0000000000..7765bddd84 --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Standard-error b/Lang/PicoLisp/Hello-world-Standard-error new file mode 120000 index 0000000000..a0ca4660e2 --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Text b/Lang/PicoLisp/Hello-world-Text new file mode 120000 index 0000000000..9e5f121d43 --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hello-world-Web-server b/Lang/PicoLisp/Hello-world-Web-server new file mode 120000 index 0000000000..d943aebfa3 --- /dev/null +++ b/Lang/PicoLisp/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Here-document b/Lang/PicoLisp/Here-document new file mode 120000 index 0000000000..cf411df4f0 --- /dev/null +++ b/Lang/PicoLisp/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Higher-order-functions b/Lang/PicoLisp/Higher-order-functions new file mode 120000 index 0000000000..7de3a8fbfb --- /dev/null +++ b/Lang/PicoLisp/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/History-variables b/Lang/PicoLisp/History-variables new file mode 120000 index 0000000000..7d900a29a1 --- /dev/null +++ b/Lang/PicoLisp/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hofstadter-Conway-$10,000-sequence b/Lang/PicoLisp/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..7116805224 --- /dev/null +++ b/Lang/PicoLisp/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hofstadter-Figure-Figure-sequences b/Lang/PicoLisp/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..b15430fff0 --- /dev/null +++ b/Lang/PicoLisp/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hofstadter-Q-sequence b/Lang/PicoLisp/Hofstadter-Q-sequence new file mode 120000 index 0000000000..2de83bf81e --- /dev/null +++ b/Lang/PicoLisp/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Holidays-related-to-Easter b/Lang/PicoLisp/Holidays-related-to-Easter new file mode 120000 index 0000000000..e82fd55705 --- /dev/null +++ b/Lang/PicoLisp/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Horizontal-sundial-calculations b/Lang/PicoLisp/Horizontal-sundial-calculations new file mode 120000 index 0000000000..2ba0822d05 --- /dev/null +++ b/Lang/PicoLisp/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Horners-rule-for-polynomial-evaluation b/Lang/PicoLisp/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..615db70c62 --- /dev/null +++ b/Lang/PicoLisp/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Host-introspection b/Lang/PicoLisp/Host-introspection new file mode 120000 index 0000000000..a988b4b29f --- /dev/null +++ b/Lang/PicoLisp/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Hostname b/Lang/PicoLisp/Hostname new file mode 120000 index 0000000000..b618d453a6 --- /dev/null +++ b/Lang/PicoLisp/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Huffman-coding b/Lang/PicoLisp/Huffman-coding new file mode 120000 index 0000000000..db27a335ed --- /dev/null +++ b/Lang/PicoLisp/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Identity-matrix b/Lang/PicoLisp/Identity-matrix new file mode 120000 index 0000000000..001684e990 --- /dev/null +++ b/Lang/PicoLisp/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Image-convolution b/Lang/PicoLisp/Image-convolution new file mode 120000 index 0000000000..42837d9275 --- /dev/null +++ b/Lang/PicoLisp/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Image-noise b/Lang/PicoLisp/Image-noise new file mode 120000 index 0000000000..913552963a --- /dev/null +++ b/Lang/PicoLisp/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Include-a-file b/Lang/PicoLisp/Include-a-file new file mode 120000 index 0000000000..85d3fa0be7 --- /dev/null +++ b/Lang/PicoLisp/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Increment-a-numerical-string b/Lang/PicoLisp/Increment-a-numerical-string new file mode 120000 index 0000000000..be0c2f4b8a --- /dev/null +++ b/Lang/PicoLisp/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Inheritance-Multiple b/Lang/PicoLisp/Inheritance-Multiple new file mode 120000 index 0000000000..15de08801d --- /dev/null +++ b/Lang/PicoLisp/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Inheritance-Single b/Lang/PicoLisp/Inheritance-Single new file mode 120000 index 0000000000..4bd56aef98 --- /dev/null +++ b/Lang/PicoLisp/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Input-loop b/Lang/PicoLisp/Input-loop new file mode 120000 index 0000000000..fcce850c4d --- /dev/null +++ b/Lang/PicoLisp/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Integer-comparison b/Lang/PicoLisp/Integer-comparison new file mode 120000 index 0000000000..8df930ab7b --- /dev/null +++ b/Lang/PicoLisp/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Integer-sequence b/Lang/PicoLisp/Integer-sequence new file mode 120000 index 0000000000..7ec480b054 --- /dev/null +++ b/Lang/PicoLisp/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Interactive-programming b/Lang/PicoLisp/Interactive-programming new file mode 120000 index 0000000000..63d61c59dc --- /dev/null +++ b/Lang/PicoLisp/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Introspection b/Lang/PicoLisp/Introspection new file mode 120000 index 0000000000..9e48ca20f7 --- /dev/null +++ b/Lang/PicoLisp/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Inverted-index b/Lang/PicoLisp/Inverted-index new file mode 120000 index 0000000000..84754936d9 --- /dev/null +++ b/Lang/PicoLisp/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Inverted-syntax b/Lang/PicoLisp/Inverted-syntax new file mode 120000 index 0000000000..5fb32b3d87 --- /dev/null +++ b/Lang/PicoLisp/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Jensens-Device b/Lang/PicoLisp/Jensens-Device new file mode 120000 index 0000000000..548dcd9ee0 --- /dev/null +++ b/Lang/PicoLisp/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Joystick-position b/Lang/PicoLisp/Joystick-position new file mode 120000 index 0000000000..e94eaa870f --- /dev/null +++ b/Lang/PicoLisp/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Jump-anywhere b/Lang/PicoLisp/Jump-anywhere new file mode 120000 index 0000000000..fccd859019 --- /dev/null +++ b/Lang/PicoLisp/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Kaprekar-numbers b/Lang/PicoLisp/Kaprekar-numbers new file mode 120000 index 0000000000..911a2ab98e --- /dev/null +++ b/Lang/PicoLisp/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Keyboard-input-Flush-the-keyboard-buffer b/Lang/PicoLisp/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..bc369113b2 --- /dev/null +++ b/Lang/PicoLisp/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Keyboard-input-Keypress-check b/Lang/PicoLisp/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..8bc953d9c1 --- /dev/null +++ b/Lang/PicoLisp/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/PicoLisp/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..e97f415a27 --- /dev/null +++ b/Lang/PicoLisp/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Keyboard-macros b/Lang/PicoLisp/Keyboard-macros new file mode 120000 index 0000000000..954738423f --- /dev/null +++ b/Lang/PicoLisp/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knapsack-problem-0-1 b/Lang/PicoLisp/Knapsack-problem-0-1 new file mode 120000 index 0000000000..304553c08b --- /dev/null +++ b/Lang/PicoLisp/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knapsack-problem-Bounded b/Lang/PicoLisp/Knapsack-problem-Bounded new file mode 120000 index 0000000000..0dd847bad5 --- /dev/null +++ b/Lang/PicoLisp/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knapsack-problem-Continuous b/Lang/PicoLisp/Knapsack-problem-Continuous new file mode 120000 index 0000000000..5618d54f4b --- /dev/null +++ b/Lang/PicoLisp/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knapsack-problem-Unbounded b/Lang/PicoLisp/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..843f7f7aae --- /dev/null +++ b/Lang/PicoLisp/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knights-tour b/Lang/PicoLisp/Knights-tour new file mode 120000 index 0000000000..3aa5d19a0a --- /dev/null +++ b/Lang/PicoLisp/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Knuths-algorithm-S b/Lang/PicoLisp/Knuths-algorithm-S new file mode 120000 index 0000000000..a9740dfdac --- /dev/null +++ b/Lang/PicoLisp/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/LZW-compression b/Lang/PicoLisp/LZW-compression new file mode 120000 index 0000000000..bcb817df29 --- /dev/null +++ b/Lang/PicoLisp/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Langtons-ant b/Lang/PicoLisp/Langtons-ant new file mode 120000 index 0000000000..0d016cb352 --- /dev/null +++ b/Lang/PicoLisp/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Last-Friday-of-each-month b/Lang/PicoLisp/Last-Friday-of-each-month new file mode 120000 index 0000000000..6c48fb4fd6 --- /dev/null +++ b/Lang/PicoLisp/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Last-letter-first-letter b/Lang/PicoLisp/Last-letter-first-letter new file mode 120000 index 0000000000..c9e0aa206f --- /dev/null +++ b/Lang/PicoLisp/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Leap-year b/Lang/PicoLisp/Leap-year new file mode 120000 index 0000000000..758837a371 --- /dev/null +++ b/Lang/PicoLisp/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Least-common-multiple b/Lang/PicoLisp/Least-common-multiple new file mode 120000 index 0000000000..ae6b068878 --- /dev/null +++ b/Lang/PicoLisp/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Letter-frequency b/Lang/PicoLisp/Letter-frequency new file mode 120000 index 0000000000..7fdec9ae1d --- /dev/null +++ b/Lang/PicoLisp/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Levenshtein-distance b/Lang/PicoLisp/Levenshtein-distance new file mode 120000 index 0000000000..13564e21bc --- /dev/null +++ b/Lang/PicoLisp/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Linear-congruential-generator b/Lang/PicoLisp/Linear-congruential-generator new file mode 120000 index 0000000000..f727ed31af --- /dev/null +++ b/Lang/PicoLisp/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/List-comprehensions b/Lang/PicoLisp/List-comprehensions new file mode 120000 index 0000000000..c7c599c256 --- /dev/null +++ b/Lang/PicoLisp/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Literals-Integer b/Lang/PicoLisp/Literals-Integer new file mode 120000 index 0000000000..2e2d37f00c --- /dev/null +++ b/Lang/PicoLisp/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Literals-String b/Lang/PicoLisp/Literals-String new file mode 120000 index 0000000000..7378fa7848 --- /dev/null +++ b/Lang/PicoLisp/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Logical-operations b/Lang/PicoLisp/Logical-operations new file mode 120000 index 0000000000..1f38602ba1 --- /dev/null +++ b/Lang/PicoLisp/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Long-multiplication b/Lang/PicoLisp/Long-multiplication new file mode 120000 index 0000000000..e9907e5bc3 --- /dev/null +++ b/Lang/PicoLisp/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Longest-common-subsequence b/Lang/PicoLisp/Longest-common-subsequence new file mode 120000 index 0000000000..5d872c5837 --- /dev/null +++ b/Lang/PicoLisp/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Longest-string-challenge b/Lang/PicoLisp/Longest-string-challenge new file mode 120000 index 0000000000..767bb324b0 --- /dev/null +++ b/Lang/PicoLisp/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Look-and-say-sequence b/Lang/PicoLisp/Look-and-say-sequence new file mode 120000 index 0000000000..351fb3136d --- /dev/null +++ b/Lang/PicoLisp/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loop-over-multiple-arrays-simultaneously b/Lang/PicoLisp/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..b52e244ac6 --- /dev/null +++ b/Lang/PicoLisp/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Break b/Lang/PicoLisp/Loops-Break new file mode 120000 index 0000000000..59296cef66 --- /dev/null +++ b/Lang/PicoLisp/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Continue b/Lang/PicoLisp/Loops-Continue new file mode 120000 index 0000000000..995598c1c0 --- /dev/null +++ b/Lang/PicoLisp/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Do-while b/Lang/PicoLisp/Loops-Do-while new file mode 120000 index 0000000000..89f63986a7 --- /dev/null +++ b/Lang/PicoLisp/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Downward-for b/Lang/PicoLisp/Loops-Downward-for new file mode 120000 index 0000000000..3023c0b99a --- /dev/null +++ b/Lang/PicoLisp/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-For b/Lang/PicoLisp/Loops-For new file mode 120000 index 0000000000..31d8565f51 --- /dev/null +++ b/Lang/PicoLisp/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-For-with-a-specified-step b/Lang/PicoLisp/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..106e1b07ef --- /dev/null +++ b/Lang/PicoLisp/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Foreach b/Lang/PicoLisp/Loops-Foreach new file mode 120000 index 0000000000..9ad7aa1172 --- /dev/null +++ b/Lang/PicoLisp/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Infinite b/Lang/PicoLisp/Loops-Infinite new file mode 120000 index 0000000000..5f409be349 --- /dev/null +++ b/Lang/PicoLisp/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-N-plus-one-half b/Lang/PicoLisp/Loops-N-plus-one-half new file mode 120000 index 0000000000..7bd082c755 --- /dev/null +++ b/Lang/PicoLisp/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-Nested b/Lang/PicoLisp/Loops-Nested new file mode 120000 index 0000000000..97bb5619cf --- /dev/null +++ b/Lang/PicoLisp/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Loops-While b/Lang/PicoLisp/Loops-While new file mode 120000 index 0000000000..e2195b9ca5 --- /dev/null +++ b/Lang/PicoLisp/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Lucas-Lehmer-test b/Lang/PicoLisp/Lucas-Lehmer-test new file mode 120000 index 0000000000..5d104f755e --- /dev/null +++ b/Lang/PicoLisp/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Luhn-test-of-credit-card-numbers b/Lang/PicoLisp/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..a0e08a270c --- /dev/null +++ b/Lang/PicoLisp/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/MD5 b/Lang/PicoLisp/MD5 new file mode 120000 index 0000000000..18b9786f6d --- /dev/null +++ b/Lang/PicoLisp/MD5 @@ -0,0 +1 @@ +../../Task/MD5/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/MD5-Implementation b/Lang/PicoLisp/MD5-Implementation new file mode 120000 index 0000000000..909bd605d3 --- /dev/null +++ b/Lang/PicoLisp/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Mad-Libs b/Lang/PicoLisp/Mad-Libs new file mode 120000 index 0000000000..f421d4b4b5 --- /dev/null +++ b/Lang/PicoLisp/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Man-or-boy-test b/Lang/PicoLisp/Man-or-boy-test new file mode 120000 index 0000000000..cc978658d5 --- /dev/null +++ b/Lang/PicoLisp/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Mandelbrot-set b/Lang/PicoLisp/Mandelbrot-set new file mode 120000 index 0000000000..0b753f84c2 --- /dev/null +++ b/Lang/PicoLisp/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Map-range b/Lang/PicoLisp/Map-range new file mode 120000 index 0000000000..3f3d5c0c7b --- /dev/null +++ b/Lang/PicoLisp/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Matrix-exponentiation-operator b/Lang/PicoLisp/Matrix-exponentiation-operator new file mode 120000 index 0000000000..767f992385 --- /dev/null +++ b/Lang/PicoLisp/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Matrix-multiplication b/Lang/PicoLisp/Matrix-multiplication new file mode 120000 index 0000000000..f4f492e677 --- /dev/null +++ b/Lang/PicoLisp/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Matrix-transposition b/Lang/PicoLisp/Matrix-transposition new file mode 120000 index 0000000000..0b09c34f5d --- /dev/null +++ b/Lang/PicoLisp/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Maze-generation b/Lang/PicoLisp/Maze-generation new file mode 120000 index 0000000000..ceb359a5c6 --- /dev/null +++ b/Lang/PicoLisp/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Maze-solving b/Lang/PicoLisp/Maze-solving new file mode 120000 index 0000000000..88d059e9b4 --- /dev/null +++ b/Lang/PicoLisp/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Median-filter b/Lang/PicoLisp/Median-filter new file mode 120000 index 0000000000..c5f898488d --- /dev/null +++ b/Lang/PicoLisp/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Memory-layout-of-a-data-structure b/Lang/PicoLisp/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..1c9ac82f07 --- /dev/null +++ b/Lang/PicoLisp/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Menu b/Lang/PicoLisp/Menu new file mode 120000 index 0000000000..fc75d0a35c --- /dev/null +++ b/Lang/PicoLisp/Menu @@ -0,0 +1 @@ +../../Task/Menu/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Metered-concurrency b/Lang/PicoLisp/Metered-concurrency new file mode 120000 index 0000000000..297e8d950a --- /dev/null +++ b/Lang/PicoLisp/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Metronome b/Lang/PicoLisp/Metronome new file mode 120000 index 0000000000..026ae08d92 --- /dev/null +++ b/Lang/PicoLisp/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Miller-Rabin-primality-test b/Lang/PicoLisp/Miller-Rabin-primality-test new file mode 120000 index 0000000000..eae524ec57 --- /dev/null +++ b/Lang/PicoLisp/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Minesweeper-game b/Lang/PicoLisp/Minesweeper-game new file mode 120000 index 0000000000..44f603b3e4 --- /dev/null +++ b/Lang/PicoLisp/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Modular-exponentiation b/Lang/PicoLisp/Modular-exponentiation new file mode 120000 index 0000000000..a2cf79a1ae --- /dev/null +++ b/Lang/PicoLisp/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Monte-Carlo-methods b/Lang/PicoLisp/Monte-Carlo-methods new file mode 120000 index 0000000000..5b21c6cb7f --- /dev/null +++ b/Lang/PicoLisp/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Monty-Hall-problem b/Lang/PicoLisp/Monty-Hall-problem new file mode 120000 index 0000000000..2d9cda2048 --- /dev/null +++ b/Lang/PicoLisp/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Morse-code b/Lang/PicoLisp/Morse-code new file mode 120000 index 0000000000..9d78124f1f --- /dev/null +++ b/Lang/PicoLisp/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Mouse-position b/Lang/PicoLisp/Mouse-position new file mode 120000 index 0000000000..4994052a75 --- /dev/null +++ b/Lang/PicoLisp/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Multiple-distinct-objects b/Lang/PicoLisp/Multiple-distinct-objects new file mode 120000 index 0000000000..4c63036965 --- /dev/null +++ b/Lang/PicoLisp/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Multiple-regression b/Lang/PicoLisp/Multiple-regression new file mode 120000 index 0000000000..70d1ced8f4 --- /dev/null +++ b/Lang/PicoLisp/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Multiplication-tables b/Lang/PicoLisp/Multiplication-tables new file mode 120000 index 0000000000..97b1b1afb9 --- /dev/null +++ b/Lang/PicoLisp/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Multisplit b/Lang/PicoLisp/Multisplit new file mode 120000 index 0000000000..d2e26e78c0 --- /dev/null +++ b/Lang/PicoLisp/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Mutual-recursion b/Lang/PicoLisp/Mutual-recursion new file mode 120000 index 0000000000..08a20f9eae --- /dev/null +++ b/Lang/PicoLisp/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/PicoLisp \ No newline at end of file diff --git a/Lang/Prolog/24-game-Solve b/Lang/Prolog/24-game-Solve new file mode 120000 index 0000000000..4537cf035b --- /dev/null +++ b/Lang/Prolog/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Factorial b/Lang/Prolog/Factorial new file mode 120000 index 0000000000..b3d80deb8f --- /dev/null +++ b/Lang/Prolog/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Factors-of-an-integer b/Lang/Prolog/Factors-of-an-integer new file mode 120000 index 0000000000..cce625c381 --- /dev/null +++ b/Lang/Prolog/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Fibonacci-sequence b/Lang/Prolog/Fibonacci-sequence new file mode 120000 index 0000000000..65c2af7bd7 --- /dev/null +++ b/Lang/Prolog/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Filter b/Lang/Prolog/Filter new file mode 120000 index 0000000000..cb71e8133a --- /dev/null +++ b/Lang/Prolog/Filter @@ -0,0 +1 @@ +../../Task/Filter/Prolog \ No newline at end of file diff --git a/Lang/Prolog/First-class-functions b/Lang/Prolog/First-class-functions new file mode 120000 index 0000000000..45ea7893a4 --- /dev/null +++ b/Lang/Prolog/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Flatten-a-list b/Lang/Prolog/Flatten-a-list new file mode 120000 index 0000000000..9ef24e494e --- /dev/null +++ b/Lang/Prolog/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Fractal-tree b/Lang/Prolog/Fractal-tree new file mode 120000 index 0000000000..f056104194 --- /dev/null +++ b/Lang/Prolog/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Function-composition b/Lang/Prolog/Function-composition new file mode 120000 index 0000000000..61654f16e4 --- /dev/null +++ b/Lang/Prolog/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Prolog \ No newline at end of file diff --git a/Lang/Prolog/GUI-component-interaction b/Lang/Prolog/GUI-component-interaction new file mode 120000 index 0000000000..4cedf22280 --- /dev/null +++ b/Lang/Prolog/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Prolog \ No newline at end of file diff --git a/Lang/Prolog/GUI-enabling-disabling-of-controls b/Lang/Prolog/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..ec9286d09d --- /dev/null +++ b/Lang/Prolog/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Galton-box-animation b/Lang/Prolog/Galton-box-animation new file mode 120000 index 0000000000..c8c85f2cdb --- /dev/null +++ b/Lang/Prolog/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Generic-swap b/Lang/Prolog/Generic-swap new file mode 120000 index 0000000000..85e4884cfc --- /dev/null +++ b/Lang/Prolog/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Greatest-common-divisor b/Lang/Prolog/Greatest-common-divisor new file mode 120000 index 0000000000..e4fac8912a --- /dev/null +++ b/Lang/Prolog/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Greatest-element-of-a-list b/Lang/Prolog/Greatest-element-of-a-list new file mode 120000 index 0000000000..1a177d8133 --- /dev/null +++ b/Lang/Prolog/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Greatest-subsequential-sum b/Lang/Prolog/Greatest-subsequential-sum new file mode 120000 index 0000000000..6dacbf47a2 --- /dev/null +++ b/Lang/Prolog/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Prolog \ No newline at end of file diff --git a/Lang/Prolog/HTTP b/Lang/Prolog/HTTP new file mode 120000 index 0000000000..3a5859f222 --- /dev/null +++ b/Lang/Prolog/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hailstone-sequence b/Lang/Prolog/Hailstone-sequence new file mode 120000 index 0000000000..d165658c3b --- /dev/null +++ b/Lang/Prolog/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hamming-numbers b/Lang/Prolog/Hamming-numbers new file mode 120000 index 0000000000..365ff3e85b --- /dev/null +++ b/Lang/Prolog/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Happy-numbers b/Lang/Prolog/Happy-numbers new file mode 120000 index 0000000000..c7bfb8e467 --- /dev/null +++ b/Lang/Prolog/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hash-from-two-arrays b/Lang/Prolog/Hash-from-two-arrays new file mode 120000 index 0000000000..57a9e65634 --- /dev/null +++ b/Lang/Prolog/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hello-world-Graphical b/Lang/Prolog/Hello-world-Graphical new file mode 120000 index 0000000000..a5b2c6c2c6 --- /dev/null +++ b/Lang/Prolog/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hello-world-Text b/Lang/Prolog/Hello-world-Text new file mode 120000 index 0000000000..24b9d17333 --- /dev/null +++ b/Lang/Prolog/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Higher-order-functions b/Lang/Prolog/Higher-order-functions new file mode 120000 index 0000000000..97d713fbf7 --- /dev/null +++ b/Lang/Prolog/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Hofstadter-Figure-Figure-sequences b/Lang/Prolog/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..1ecafaea16 --- /dev/null +++ b/Lang/Prolog/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Honeycombs b/Lang/Prolog/Honeycombs new file mode 120000 index 0000000000..ea3da352c5 --- /dev/null +++ b/Lang/Prolog/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Horners-rule-for-polynomial-evaluation b/Lang/Prolog/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..776a42ef62 --- /dev/null +++ b/Lang/Prolog/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Huffman-coding b/Lang/Prolog/Huffman-coding new file mode 120000 index 0000000000..b20d6d9d1c --- /dev/null +++ b/Lang/Prolog/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Include-a-file b/Lang/Prolog/Include-a-file new file mode 120000 index 0000000000..e7590898da --- /dev/null +++ b/Lang/Prolog/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Increment-a-numerical-string b/Lang/Prolog/Increment-a-numerical-string new file mode 120000 index 0000000000..10b098cef3 --- /dev/null +++ b/Lang/Prolog/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Integer-sequence b/Lang/Prolog/Integer-sequence new file mode 120000 index 0000000000..f4e3a7529d --- /dev/null +++ b/Lang/Prolog/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Interactive-programming b/Lang/Prolog/Interactive-programming new file mode 120000 index 0000000000..194f9f8b83 --- /dev/null +++ b/Lang/Prolog/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Kaprekar-numbers b/Lang/Prolog/Kaprekar-numbers new file mode 120000 index 0000000000..07fadcf924 --- /dev/null +++ b/Lang/Prolog/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Knapsack-problem-0-1 b/Lang/Prolog/Knapsack-problem-0-1 new file mode 120000 index 0000000000..f264b897b9 --- /dev/null +++ b/Lang/Prolog/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Knapsack-problem-Bounded b/Lang/Prolog/Knapsack-problem-Bounded new file mode 120000 index 0000000000..5b53e995ab --- /dev/null +++ b/Lang/Prolog/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Knapsack-problem-Continuous b/Lang/Prolog/Knapsack-problem-Continuous new file mode 120000 index 0000000000..d0da5be822 --- /dev/null +++ b/Lang/Prolog/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Knapsack-problem-Unbounded b/Lang/Prolog/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..6e0720e816 --- /dev/null +++ b/Lang/Prolog/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Knights-tour b/Lang/Prolog/Knights-tour new file mode 120000 index 0000000000..4b92bf052a --- /dev/null +++ b/Lang/Prolog/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Last-letter-first-letter b/Lang/Prolog/Last-letter-first-letter new file mode 120000 index 0000000000..6665b83430 --- /dev/null +++ b/Lang/Prolog/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Leap-year b/Lang/Prolog/Leap-year new file mode 120000 index 0000000000..8204e2f9be --- /dev/null +++ b/Lang/Prolog/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Least-common-multiple b/Lang/Prolog/Least-common-multiple new file mode 120000 index 0000000000..37a4f6dfbb --- /dev/null +++ b/Lang/Prolog/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Letter-frequency b/Lang/Prolog/Letter-frequency new file mode 120000 index 0000000000..a33c88b6c0 --- /dev/null +++ b/Lang/Prolog/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Levenshtein-distance b/Lang/Prolog/Levenshtein-distance new file mode 120000 index 0000000000..88d6aa7992 --- /dev/null +++ b/Lang/Prolog/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Prolog \ No newline at end of file diff --git a/Lang/Prolog/List-comprehensions b/Lang/Prolog/List-comprehensions new file mode 120000 index 0000000000..21395e44b0 --- /dev/null +++ b/Lang/Prolog/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Long-multiplication b/Lang/Prolog/Long-multiplication new file mode 120000 index 0000000000..b1f89c901f --- /dev/null +++ b/Lang/Prolog/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Longest-common-subsequence b/Lang/Prolog/Longest-common-subsequence new file mode 120000 index 0000000000..537340fc8e --- /dev/null +++ b/Lang/Prolog/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Look-and-say-sequence b/Lang/Prolog/Look-and-say-sequence new file mode 120000 index 0000000000..a130fd03c2 --- /dev/null +++ b/Lang/Prolog/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Loop-over-multiple-arrays-simultaneously b/Lang/Prolog/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..7d54a780a6 --- /dev/null +++ b/Lang/Prolog/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Loops-Do-while b/Lang/Prolog/Loops-Do-while new file mode 120000 index 0000000000..2dd34b9419 --- /dev/null +++ b/Lang/Prolog/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Loops-Infinite b/Lang/Prolog/Loops-Infinite new file mode 120000 index 0000000000..8067a3b18d --- /dev/null +++ b/Lang/Prolog/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Loops-While b/Lang/Prolog/Loops-While new file mode 120000 index 0000000000..c1f962e413 --- /dev/null +++ b/Lang/Prolog/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Mandelbrot-set b/Lang/Prolog/Mandelbrot-set new file mode 120000 index 0000000000..107eb8f9bf --- /dev/null +++ b/Lang/Prolog/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Matrix-multiplication b/Lang/Prolog/Matrix-multiplication new file mode 120000 index 0000000000..61c59d8bcd --- /dev/null +++ b/Lang/Prolog/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Matrix-transposition b/Lang/Prolog/Matrix-transposition new file mode 120000 index 0000000000..0e3772335a --- /dev/null +++ b/Lang/Prolog/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Maze-generation b/Lang/Prolog/Maze-generation new file mode 120000 index 0000000000..7a9aadfa19 --- /dev/null +++ b/Lang/Prolog/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Maze-solving b/Lang/Prolog/Maze-solving new file mode 120000 index 0000000000..a0eef1d3a5 --- /dev/null +++ b/Lang/Prolog/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Multisplit b/Lang/Prolog/Multisplit new file mode 120000 index 0000000000..92cbc5584d --- /dev/null +++ b/Lang/Prolog/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Mutual-recursion b/Lang/Prolog/Mutual-recursion new file mode 120000 index 0000000000..ef3f385c78 --- /dev/null +++ b/Lang/Prolog/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Prolog \ No newline at end of file diff --git a/Lang/Python/24-game-Solve b/Lang/Python/24-game-Solve new file mode 120000 index 0000000000..a4d88a47a1 --- /dev/null +++ b/Lang/Python/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Python \ No newline at end of file diff --git a/Lang/Python/Arbitrary-precision-integers-included b/Lang/Python/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..df9f38070c --- /dev/null +++ b/Lang/Python/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Python \ No newline at end of file diff --git a/Lang/Python/Factorial b/Lang/Python/Factorial new file mode 120000 index 0000000000..b41c7d1314 --- /dev/null +++ b/Lang/Python/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Python \ No newline at end of file diff --git a/Lang/Python/Factors-of-a-Mersenne-number b/Lang/Python/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..f96f5aacd7 --- /dev/null +++ b/Lang/Python/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Python \ No newline at end of file diff --git a/Lang/Python/Factors-of-an-integer b/Lang/Python/Factors-of-an-integer new file mode 120000 index 0000000000..47d1af2897 --- /dev/null +++ b/Lang/Python/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Python \ No newline at end of file diff --git a/Lang/Python/Fast-Fourier-transform b/Lang/Python/Fast-Fourier-transform new file mode 120000 index 0000000000..285b913d88 --- /dev/null +++ b/Lang/Python/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Python \ No newline at end of file diff --git a/Lang/Python/Fibonacci-n-step-number-sequences b/Lang/Python/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..2c4e4f1c15 --- /dev/null +++ b/Lang/Python/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Python \ No newline at end of file diff --git a/Lang/Python/Fibonacci-sequence b/Lang/Python/Fibonacci-sequence new file mode 120000 index 0000000000..cf446d38a4 --- /dev/null +++ b/Lang/Python/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Python \ No newline at end of file diff --git a/Lang/Python/File-IO b/Lang/Python/File-IO new file mode 120000 index 0000000000..5e68fa1bf3 --- /dev/null +++ b/Lang/Python/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Python \ No newline at end of file diff --git a/Lang/Python/File-modification-time b/Lang/Python/File-modification-time new file mode 120000 index 0000000000..c39979e214 --- /dev/null +++ b/Lang/Python/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Python \ No newline at end of file diff --git a/Lang/Python/File-size b/Lang/Python/File-size new file mode 120000 index 0000000000..6eb112a306 --- /dev/null +++ b/Lang/Python/File-size @@ -0,0 +1 @@ +../../Task/File-size/Python \ No newline at end of file diff --git a/Lang/Python/Filter b/Lang/Python/Filter new file mode 120000 index 0000000000..68e8bcf7b9 --- /dev/null +++ b/Lang/Python/Filter @@ -0,0 +1 @@ +../../Task/Filter/Python \ No newline at end of file diff --git a/Lang/Python/Find-common-directory-path b/Lang/Python/Find-common-directory-path new file mode 120000 index 0000000000..26e4f2bfd1 --- /dev/null +++ b/Lang/Python/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Python \ No newline at end of file diff --git a/Lang/Python/Find-limit-of-recursion b/Lang/Python/Find-limit-of-recursion new file mode 120000 index 0000000000..5c460fbe79 --- /dev/null +++ b/Lang/Python/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Python \ No newline at end of file diff --git a/Lang/Python/Find-the-missing-permutation b/Lang/Python/Find-the-missing-permutation new file mode 120000 index 0000000000..8696d66c0a --- /dev/null +++ b/Lang/Python/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Python \ No newline at end of file diff --git a/Lang/Python/First-class-environments b/Lang/Python/First-class-environments new file mode 120000 index 0000000000..d0bc90d282 --- /dev/null +++ b/Lang/Python/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/Python \ No newline at end of file diff --git a/Lang/Python/First-class-functions b/Lang/Python/First-class-functions new file mode 120000 index 0000000000..cc79164151 --- /dev/null +++ b/Lang/Python/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Python \ No newline at end of file diff --git a/Lang/Python/First-class-functions-Use-numbers-analogously b/Lang/Python/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..f0721da024 --- /dev/null +++ b/Lang/Python/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Python \ No newline at end of file diff --git a/Lang/Python/Five-weekends b/Lang/Python/Five-weekends new file mode 120000 index 0000000000..228ee010ba --- /dev/null +++ b/Lang/Python/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Python \ No newline at end of file diff --git a/Lang/Python/Flatten-a-list b/Lang/Python/Flatten-a-list new file mode 120000 index 0000000000..61ca8bea4f --- /dev/null +++ b/Lang/Python/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Python \ No newline at end of file diff --git a/Lang/Python/Flow-control-structures b/Lang/Python/Flow-control-structures new file mode 120000 index 0000000000..54753ec5bb --- /dev/null +++ b/Lang/Python/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Python \ No newline at end of file diff --git a/Lang/Python/Floyds-triangle b/Lang/Python/Floyds-triangle new file mode 120000 index 0000000000..7048720756 --- /dev/null +++ b/Lang/Python/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Python \ No newline at end of file diff --git a/Lang/Python/Fork b/Lang/Python/Fork new file mode 120000 index 0000000000..8e68c5df5a --- /dev/null +++ b/Lang/Python/Fork @@ -0,0 +1 @@ +../../Task/Fork/Python \ No newline at end of file diff --git a/Lang/Python/Formal-power-series b/Lang/Python/Formal-power-series new file mode 120000 index 0000000000..f32110b38c --- /dev/null +++ b/Lang/Python/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Python \ No newline at end of file diff --git a/Lang/Python/Formatted-numeric-output b/Lang/Python/Formatted-numeric-output new file mode 120000 index 0000000000..3deb3ec760 --- /dev/null +++ b/Lang/Python/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Python \ No newline at end of file diff --git a/Lang/Python/Forward-difference b/Lang/Python/Forward-difference new file mode 120000 index 0000000000..a0be77f77b --- /dev/null +++ b/Lang/Python/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Python \ No newline at end of file diff --git a/Lang/Python/Four-bit-adder b/Lang/Python/Four-bit-adder new file mode 120000 index 0000000000..d63c7f2cc1 --- /dev/null +++ b/Lang/Python/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Python \ No newline at end of file diff --git a/Lang/Python/Fractal-tree b/Lang/Python/Fractal-tree new file mode 120000 index 0000000000..d386eef683 --- /dev/null +++ b/Lang/Python/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Python \ No newline at end of file diff --git a/Lang/Python/Function-composition b/Lang/Python/Function-composition new file mode 120000 index 0000000000..043b1fd559 --- /dev/null +++ b/Lang/Python/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Python \ No newline at end of file diff --git a/Lang/Python/Function-definition b/Lang/Python/Function-definition new file mode 120000 index 0000000000..369cf7807e --- /dev/null +++ b/Lang/Python/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Python \ No newline at end of file diff --git a/Lang/Python/Function-frequency b/Lang/Python/Function-frequency new file mode 120000 index 0000000000..ca43b86d1d --- /dev/null +++ b/Lang/Python/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/Python \ No newline at end of file diff --git a/Lang/Python/Gamma-function b/Lang/Python/Gamma-function new file mode 120000 index 0000000000..97224048fb --- /dev/null +++ b/Lang/Python/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Python \ No newline at end of file diff --git a/Lang/Python/Generator-Exponential b/Lang/Python/Generator-Exponential new file mode 120000 index 0000000000..47c9c0c219 --- /dev/null +++ b/Lang/Python/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Python \ No newline at end of file diff --git a/Lang/Python/Generic-swap b/Lang/Python/Generic-swap new file mode 120000 index 0000000000..e1168ea80d --- /dev/null +++ b/Lang/Python/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Python \ No newline at end of file diff --git a/Lang/Python/Globally-replace-text-in-several-files b/Lang/Python/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..f4fd797402 --- /dev/null +++ b/Lang/Python/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Python \ No newline at end of file diff --git a/Lang/Python/Gray-code b/Lang/Python/Gray-code new file mode 120000 index 0000000000..61984c38ae --- /dev/null +++ b/Lang/Python/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Python \ No newline at end of file diff --git a/Lang/Python/Grayscale-image b/Lang/Python/Grayscale-image new file mode 120000 index 0000000000..1c89f778ec --- /dev/null +++ b/Lang/Python/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Python \ No newline at end of file diff --git a/Lang/Python/Greatest-common-divisor b/Lang/Python/Greatest-common-divisor new file mode 120000 index 0000000000..ba4d1c8a8d --- /dev/null +++ b/Lang/Python/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Python \ No newline at end of file diff --git a/Lang/Python/Greatest-element-of-a-list b/Lang/Python/Greatest-element-of-a-list new file mode 120000 index 0000000000..25eb1d39d9 --- /dev/null +++ b/Lang/Python/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Python \ No newline at end of file diff --git a/Lang/Python/Greatest-subsequential-sum b/Lang/Python/Greatest-subsequential-sum new file mode 120000 index 0000000000..8b28c7f950 --- /dev/null +++ b/Lang/Python/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Python \ No newline at end of file diff --git a/Lang/Python/Greyscale-bars-Display b/Lang/Python/Greyscale-bars-Display new file mode 120000 index 0000000000..9f56ae6fc6 --- /dev/null +++ b/Lang/Python/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Python \ No newline at end of file diff --git a/Lang/Python/Guess-the-number b/Lang/Python/Guess-the-number new file mode 120000 index 0000000000..d7e288ec6a --- /dev/null +++ b/Lang/Python/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Python \ No newline at end of file diff --git a/Lang/Python/Guess-the-number-With-feedback b/Lang/Python/Guess-the-number-With-feedback new file mode 120000 index 0000000000..64bdd0359c --- /dev/null +++ b/Lang/Python/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Python \ No newline at end of file diff --git a/Lang/Python/Guess-the-number-With-feedback-player b/Lang/Python/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..4163c2bb98 --- /dev/null +++ b/Lang/Python/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Python \ No newline at end of file diff --git a/Lang/Python/HTTP b/Lang/Python/HTTP new file mode 120000 index 0000000000..e757c9403f --- /dev/null +++ b/Lang/Python/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Python \ No newline at end of file diff --git a/Lang/Python/HTTPS b/Lang/Python/HTTPS new file mode 120000 index 0000000000..ab9a1f065d --- /dev/null +++ b/Lang/Python/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Python \ No newline at end of file diff --git a/Lang/Python/HTTPS-Authenticated b/Lang/Python/HTTPS-Authenticated new file mode 120000 index 0000000000..0951159ed7 --- /dev/null +++ b/Lang/Python/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Python \ No newline at end of file diff --git a/Lang/Python/Hailstone-sequence b/Lang/Python/Hailstone-sequence new file mode 120000 index 0000000000..1a7cec8d75 --- /dev/null +++ b/Lang/Python/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Hamming-numbers b/Lang/Python/Hamming-numbers new file mode 120000 index 0000000000..1769169956 --- /dev/null +++ b/Lang/Python/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Handle-a-signal b/Lang/Python/Handle-a-signal new file mode 120000 index 0000000000..4c80a542d0 --- /dev/null +++ b/Lang/Python/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Python \ No newline at end of file diff --git a/Lang/Python/Happy-numbers b/Lang/Python/Happy-numbers new file mode 120000 index 0000000000..15b0d6c688 --- /dev/null +++ b/Lang/Python/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Harshad-or-Niven-series b/Lang/Python/Harshad-or-Niven-series new file mode 120000 index 0000000000..73292733ae --- /dev/null +++ b/Lang/Python/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Python \ No newline at end of file diff --git a/Lang/Python/Hash-from-two-arrays b/Lang/Python/Hash-from-two-arrays new file mode 120000 index 0000000000..17ef1d9475 --- /dev/null +++ b/Lang/Python/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Python \ No newline at end of file diff --git a/Lang/Python/Haversine-formula b/Lang/Python/Haversine-formula new file mode 120000 index 0000000000..87b0ab8d85 --- /dev/null +++ b/Lang/Python/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Graphical b/Lang/Python/Hello-world-Graphical new file mode 120000 index 0000000000..35fd0bd6b1 --- /dev/null +++ b/Lang/Python/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Line-printer b/Lang/Python/Hello-world-Line-printer new file mode 120000 index 0000000000..80bcc4c5b0 --- /dev/null +++ b/Lang/Python/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Newline-omission b/Lang/Python/Hello-world-Newline-omission new file mode 120000 index 0000000000..9bc9014cf4 --- /dev/null +++ b/Lang/Python/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Standard-error b/Lang/Python/Hello-world-Standard-error new file mode 120000 index 0000000000..4269b47a3c --- /dev/null +++ b/Lang/Python/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Text b/Lang/Python/Hello-world-Text new file mode 120000 index 0000000000..7b858747b5 --- /dev/null +++ b/Lang/Python/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Python \ No newline at end of file diff --git a/Lang/Python/Hello-world-Web-server b/Lang/Python/Hello-world-Web-server new file mode 120000 index 0000000000..a64e3e4692 --- /dev/null +++ b/Lang/Python/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Python \ No newline at end of file diff --git a/Lang/Python/Here-document b/Lang/Python/Here-document new file mode 120000 index 0000000000..d62a7a6f33 --- /dev/null +++ b/Lang/Python/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Python \ No newline at end of file diff --git a/Lang/Python/Higher-order-functions b/Lang/Python/Higher-order-functions new file mode 120000 index 0000000000..5b62cae1e1 --- /dev/null +++ b/Lang/Python/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Python \ No newline at end of file diff --git a/Lang/Python/History-variables b/Lang/Python/History-variables new file mode 120000 index 0000000000..59d2709f6f --- /dev/null +++ b/Lang/Python/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Python \ No newline at end of file diff --git a/Lang/Python/Hofstadter-Conway-$10,000-sequence b/Lang/Python/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..f357778bfd --- /dev/null +++ b/Lang/Python/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Hofstadter-Figure-Figure-sequences b/Lang/Python/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..8b9095c544 --- /dev/null +++ b/Lang/Python/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Python \ No newline at end of file diff --git a/Lang/Python/Hofstadter-Q-sequence b/Lang/Python/Hofstadter-Q-sequence new file mode 120000 index 0000000000..6d691d1ff4 --- /dev/null +++ b/Lang/Python/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Holidays-related-to-Easter b/Lang/Python/Holidays-related-to-Easter new file mode 120000 index 0000000000..9432123c8a --- /dev/null +++ b/Lang/Python/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Python \ No newline at end of file diff --git a/Lang/Python/Horizontal-sundial-calculations b/Lang/Python/Horizontal-sundial-calculations new file mode 120000 index 0000000000..9dfc838ecc --- /dev/null +++ b/Lang/Python/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Python \ No newline at end of file diff --git a/Lang/Python/Horners-rule-for-polynomial-evaluation b/Lang/Python/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..9cc92e3ebd --- /dev/null +++ b/Lang/Python/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Python \ No newline at end of file diff --git a/Lang/Python/Host-introspection b/Lang/Python/Host-introspection new file mode 120000 index 0000000000..0f7e799171 --- /dev/null +++ b/Lang/Python/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Python \ No newline at end of file diff --git a/Lang/Python/Hostname b/Lang/Python/Hostname new file mode 120000 index 0000000000..9199bb7664 --- /dev/null +++ b/Lang/Python/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Python \ No newline at end of file diff --git a/Lang/Python/Hough-transform b/Lang/Python/Hough-transform new file mode 120000 index 0000000000..a89dd224b5 --- /dev/null +++ b/Lang/Python/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/Python \ No newline at end of file diff --git a/Lang/Python/Huffman-coding b/Lang/Python/Huffman-coding new file mode 120000 index 0000000000..2bd71a298b --- /dev/null +++ b/Lang/Python/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Python \ No newline at end of file diff --git a/Lang/Python/I-before-E-except-after-C b/Lang/Python/I-before-E-except-after-C new file mode 120000 index 0000000000..7892b0e062 --- /dev/null +++ b/Lang/Python/I-before-E-except-after-C @@ -0,0 +1 @@ +../../Task/I-before-E-except-after-C/Python \ No newline at end of file diff --git a/Lang/Python/Identity-matrix b/Lang/Python/Identity-matrix new file mode 120000 index 0000000000..1d05722cbc --- /dev/null +++ b/Lang/Python/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Python \ No newline at end of file diff --git a/Lang/Python/Image-noise b/Lang/Python/Image-noise new file mode 120000 index 0000000000..3c1aaaf140 --- /dev/null +++ b/Lang/Python/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Python \ No newline at end of file diff --git a/Lang/Python/Include-a-file b/Lang/Python/Include-a-file new file mode 120000 index 0000000000..a3b3f53346 --- /dev/null +++ b/Lang/Python/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Python \ No newline at end of file diff --git a/Lang/Python/Increment-a-numerical-string b/Lang/Python/Increment-a-numerical-string new file mode 120000 index 0000000000..a5d8867054 --- /dev/null +++ b/Lang/Python/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Python \ No newline at end of file diff --git a/Lang/Python/Inheritance-Multiple b/Lang/Python/Inheritance-Multiple new file mode 120000 index 0000000000..13d9166709 --- /dev/null +++ b/Lang/Python/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Python \ No newline at end of file diff --git a/Lang/Python/Inheritance-Single b/Lang/Python/Inheritance-Single new file mode 120000 index 0000000000..20f5445832 --- /dev/null +++ b/Lang/Python/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Python \ No newline at end of file diff --git a/Lang/Python/Input-loop b/Lang/Python/Input-loop new file mode 120000 index 0000000000..f5f51e53fc --- /dev/null +++ b/Lang/Python/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Python \ No newline at end of file diff --git a/Lang/Python/Integer-comparison b/Lang/Python/Integer-comparison new file mode 120000 index 0000000000..45f8765f7e --- /dev/null +++ b/Lang/Python/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Python \ No newline at end of file diff --git a/Lang/Python/Integer-sequence b/Lang/Python/Integer-sequence new file mode 120000 index 0000000000..bdd12b1cad --- /dev/null +++ b/Lang/Python/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Interactive-programming b/Lang/Python/Interactive-programming new file mode 120000 index 0000000000..6de90e9837 --- /dev/null +++ b/Lang/Python/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Python \ No newline at end of file diff --git a/Lang/Python/Introspection b/Lang/Python/Introspection new file mode 120000 index 0000000000..8b2ff9def2 --- /dev/null +++ b/Lang/Python/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Python \ No newline at end of file diff --git a/Lang/Python/Inverted-index b/Lang/Python/Inverted-index new file mode 120000 index 0000000000..0883962162 --- /dev/null +++ b/Lang/Python/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Python \ No newline at end of file diff --git a/Lang/Python/Inverted-syntax b/Lang/Python/Inverted-syntax new file mode 120000 index 0000000000..367687b2a9 --- /dev/null +++ b/Lang/Python/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Python \ No newline at end of file diff --git a/Lang/Python/Jensens-Device b/Lang/Python/Jensens-Device new file mode 120000 index 0000000000..f46778716e --- /dev/null +++ b/Lang/Python/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Python \ No newline at end of file diff --git a/Lang/Python/Josephus-problem b/Lang/Python/Josephus-problem new file mode 120000 index 0000000000..2b40171ebf --- /dev/null +++ b/Lang/Python/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Python \ No newline at end of file diff --git a/Lang/Python/Joystick-position b/Lang/Python/Joystick-position new file mode 120000 index 0000000000..c496ae88db --- /dev/null +++ b/Lang/Python/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/Python \ No newline at end of file diff --git a/Lang/Python/Jump-anywhere b/Lang/Python/Jump-anywhere new file mode 120000 index 0000000000..5e5b4461c8 --- /dev/null +++ b/Lang/Python/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/Python \ No newline at end of file diff --git a/Lang/Python/K-means++-clustering b/Lang/Python/K-means++-clustering new file mode 120000 index 0000000000..47f012c9ea --- /dev/null +++ b/Lang/Python/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/Python \ No newline at end of file diff --git a/Lang/Python/Kaprekar-numbers b/Lang/Python/Kaprekar-numbers new file mode 120000 index 0000000000..23596104ed --- /dev/null +++ b/Lang/Python/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Python/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..b08a7b7520 --- /dev/null +++ b/Lang/Python/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Python \ No newline at end of file diff --git a/Lang/Python/Keyboard-input-Keypress-check b/Lang/Python/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..1ea14bbb93 --- /dev/null +++ b/Lang/Python/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Python \ No newline at end of file diff --git a/Lang/Python/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Python/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..fd45a92b8f --- /dev/null +++ b/Lang/Python/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Python \ No newline at end of file diff --git a/Lang/Python/Keyboard-macros b/Lang/Python/Keyboard-macros new file mode 120000 index 0000000000..cd8dd29821 --- /dev/null +++ b/Lang/Python/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/Python \ No newline at end of file diff --git a/Lang/Python/Knapsack-problem-0-1 b/Lang/Python/Knapsack-problem-0-1 new file mode 120000 index 0000000000..27be04a2d5 --- /dev/null +++ b/Lang/Python/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Python \ No newline at end of file diff --git a/Lang/Python/Knapsack-problem-Bounded b/Lang/Python/Knapsack-problem-Bounded new file mode 120000 index 0000000000..2c420890d4 --- /dev/null +++ b/Lang/Python/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Python \ No newline at end of file diff --git a/Lang/Python/Knapsack-problem-Continuous b/Lang/Python/Knapsack-problem-Continuous new file mode 120000 index 0000000000..25d769eeba --- /dev/null +++ b/Lang/Python/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Python \ No newline at end of file diff --git a/Lang/Python/Knights-tour b/Lang/Python/Knights-tour new file mode 120000 index 0000000000..521c2dd292 --- /dev/null +++ b/Lang/Python/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Python \ No newline at end of file diff --git a/Lang/Python/Knuths-algorithm-S b/Lang/Python/Knuths-algorithm-S new file mode 120000 index 0000000000..25ca66804a --- /dev/null +++ b/Lang/Python/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Python \ No newline at end of file diff --git a/Lang/Python/LU-decomposition b/Lang/Python/LU-decomposition new file mode 120000 index 0000000000..7a0a788cc7 --- /dev/null +++ b/Lang/Python/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Python \ No newline at end of file diff --git a/Lang/Python/LZW-compression b/Lang/Python/LZW-compression new file mode 120000 index 0000000000..e16f067b87 --- /dev/null +++ b/Lang/Python/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Python \ No newline at end of file diff --git a/Lang/Python/Langtons-ant b/Lang/Python/Langtons-ant new file mode 120000 index 0000000000..a39c83230c --- /dev/null +++ b/Lang/Python/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Python \ No newline at end of file diff --git a/Lang/Python/Largest-int-from-concatenated-ints b/Lang/Python/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..98260f6742 --- /dev/null +++ b/Lang/Python/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Python \ No newline at end of file diff --git a/Lang/Python/Last-Friday-of-each-month b/Lang/Python/Last-Friday-of-each-month new file mode 120000 index 0000000000..d12e054f36 --- /dev/null +++ b/Lang/Python/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Python \ No newline at end of file diff --git a/Lang/Python/Last-letter-first-letter b/Lang/Python/Last-letter-first-letter new file mode 120000 index 0000000000..298a0d8947 --- /dev/null +++ b/Lang/Python/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Python \ No newline at end of file diff --git a/Lang/Python/Leap-year b/Lang/Python/Leap-year new file mode 120000 index 0000000000..100640eb04 --- /dev/null +++ b/Lang/Python/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Python \ No newline at end of file diff --git a/Lang/Python/Least-common-multiple b/Lang/Python/Least-common-multiple new file mode 120000 index 0000000000..678d8d7a0c --- /dev/null +++ b/Lang/Python/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Python \ No newline at end of file diff --git a/Lang/Python/Letter-frequency b/Lang/Python/Letter-frequency new file mode 120000 index 0000000000..b5048fb44f --- /dev/null +++ b/Lang/Python/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Python \ No newline at end of file diff --git a/Lang/Python/Levenshtein-distance b/Lang/Python/Levenshtein-distance new file mode 120000 index 0000000000..a8e575c4ae --- /dev/null +++ b/Lang/Python/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Python \ No newline at end of file diff --git a/Lang/Python/Linear-congruential-generator b/Lang/Python/Linear-congruential-generator new file mode 120000 index 0000000000..9c6a203e58 --- /dev/null +++ b/Lang/Python/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Python \ No newline at end of file diff --git a/Lang/Python/List-comprehensions b/Lang/Python/List-comprehensions new file mode 120000 index 0000000000..129f12bb39 --- /dev/null +++ b/Lang/Python/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Python \ No newline at end of file diff --git a/Lang/Python/Literals-Floating-point b/Lang/Python/Literals-Floating-point new file mode 120000 index 0000000000..59f7bcf2f3 --- /dev/null +++ b/Lang/Python/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Python \ No newline at end of file diff --git a/Lang/Python/Literals-Integer b/Lang/Python/Literals-Integer new file mode 120000 index 0000000000..96a857ed5b --- /dev/null +++ b/Lang/Python/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Python \ No newline at end of file diff --git a/Lang/Python/Literals-String b/Lang/Python/Literals-String new file mode 120000 index 0000000000..bd476de3bf --- /dev/null +++ b/Lang/Python/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Python \ No newline at end of file diff --git a/Lang/Python/Logical-operations b/Lang/Python/Logical-operations new file mode 120000 index 0000000000..be0fb001d5 --- /dev/null +++ b/Lang/Python/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Python \ No newline at end of file diff --git a/Lang/Python/Long-multiplication b/Lang/Python/Long-multiplication new file mode 120000 index 0000000000..09d9363c6e --- /dev/null +++ b/Lang/Python/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Python \ No newline at end of file diff --git a/Lang/Python/Longest-common-subsequence b/Lang/Python/Longest-common-subsequence new file mode 120000 index 0000000000..be7c720f11 --- /dev/null +++ b/Lang/Python/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Python \ No newline at end of file diff --git a/Lang/Python/Longest-string-challenge b/Lang/Python/Longest-string-challenge new file mode 120000 index 0000000000..4df11b81bf --- /dev/null +++ b/Lang/Python/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Python \ No newline at end of file diff --git a/Lang/Python/Look-and-say-sequence b/Lang/Python/Look-and-say-sequence new file mode 120000 index 0000000000..5f52896800 --- /dev/null +++ b/Lang/Python/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Loop-over-multiple-arrays-simultaneously b/Lang/Python/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..31d7bc83d3 --- /dev/null +++ b/Lang/Python/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Break b/Lang/Python/Loops-Break new file mode 120000 index 0000000000..ee2255af3a --- /dev/null +++ b/Lang/Python/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Continue b/Lang/Python/Loops-Continue new file mode 120000 index 0000000000..cae4ab1287 --- /dev/null +++ b/Lang/Python/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Do-while b/Lang/Python/Loops-Do-while new file mode 120000 index 0000000000..e34b3ab227 --- /dev/null +++ b/Lang/Python/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Downward-for b/Lang/Python/Loops-Downward-for new file mode 120000 index 0000000000..f7aab774a8 --- /dev/null +++ b/Lang/Python/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Python \ No newline at end of file diff --git a/Lang/Python/Loops-For b/Lang/Python/Loops-For new file mode 120000 index 0000000000..31a721b0d8 --- /dev/null +++ b/Lang/Python/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Python \ No newline at end of file diff --git a/Lang/Python/Loops-For-with-a-specified-step b/Lang/Python/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..9905557e2b --- /dev/null +++ b/Lang/Python/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Foreach b/Lang/Python/Loops-Foreach new file mode 120000 index 0000000000..d229fc665a --- /dev/null +++ b/Lang/Python/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Infinite b/Lang/Python/Loops-Infinite new file mode 120000 index 0000000000..90706c5a59 --- /dev/null +++ b/Lang/Python/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Python \ No newline at end of file diff --git a/Lang/Python/Loops-N-plus-one-half b/Lang/Python/Loops-N-plus-one-half new file mode 120000 index 0000000000..2500a2dba9 --- /dev/null +++ b/Lang/Python/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Python \ No newline at end of file diff --git a/Lang/Python/Loops-Nested b/Lang/Python/Loops-Nested new file mode 120000 index 0000000000..1590cbdcef --- /dev/null +++ b/Lang/Python/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Python \ No newline at end of file diff --git a/Lang/Python/Loops-While b/Lang/Python/Loops-While new file mode 120000 index 0000000000..0e754d93de --- /dev/null +++ b/Lang/Python/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Python \ No newline at end of file diff --git a/Lang/Python/Lucas-Lehmer-test b/Lang/Python/Lucas-Lehmer-test new file mode 120000 index 0000000000..77fcf26987 --- /dev/null +++ b/Lang/Python/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Python \ No newline at end of file diff --git a/Lang/Python/Luhn-test-of-credit-card-numbers b/Lang/Python/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..ca61a7cda3 --- /dev/null +++ b/Lang/Python/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Python \ No newline at end of file diff --git a/Lang/Python/MD4 b/Lang/Python/MD4 new file mode 120000 index 0000000000..cfb1faf18b --- /dev/null +++ b/Lang/Python/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Python \ No newline at end of file diff --git a/Lang/Python/MD5 b/Lang/Python/MD5 new file mode 120000 index 0000000000..bfb98dd8e9 --- /dev/null +++ b/Lang/Python/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Python \ No newline at end of file diff --git a/Lang/Python/MD5-Implementation b/Lang/Python/MD5-Implementation new file mode 120000 index 0000000000..85979b2be0 --- /dev/null +++ b/Lang/Python/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Python \ No newline at end of file diff --git a/Lang/Python/Mad-Libs b/Lang/Python/Mad-Libs new file mode 120000 index 0000000000..8d402d0f48 --- /dev/null +++ b/Lang/Python/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Python \ No newline at end of file diff --git a/Lang/Python/Main-step-of-GOST-28147-89 b/Lang/Python/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..65bd4b1b12 --- /dev/null +++ b/Lang/Python/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/Python \ No newline at end of file diff --git a/Lang/Python/Man-or-boy-test b/Lang/Python/Man-or-boy-test new file mode 120000 index 0000000000..14e9436973 --- /dev/null +++ b/Lang/Python/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Python \ No newline at end of file diff --git a/Lang/Python/Mandelbrot-set b/Lang/Python/Mandelbrot-set new file mode 120000 index 0000000000..ed6b63096b --- /dev/null +++ b/Lang/Python/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Python \ No newline at end of file diff --git a/Lang/Python/Map-range b/Lang/Python/Map-range new file mode 120000 index 0000000000..271028301c --- /dev/null +++ b/Lang/Python/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Python \ No newline at end of file diff --git a/Lang/Python/Matrix-arithmetic b/Lang/Python/Matrix-arithmetic new file mode 120000 index 0000000000..56deda8508 --- /dev/null +++ b/Lang/Python/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/Python \ No newline at end of file diff --git a/Lang/Python/Matrix-exponentiation-operator b/Lang/Python/Matrix-exponentiation-operator new file mode 120000 index 0000000000..643ea15a22 --- /dev/null +++ b/Lang/Python/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Python \ No newline at end of file diff --git a/Lang/Python/Matrix-multiplication b/Lang/Python/Matrix-multiplication new file mode 120000 index 0000000000..9767ae559b --- /dev/null +++ b/Lang/Python/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Python \ No newline at end of file diff --git a/Lang/Python/Matrix-transposition b/Lang/Python/Matrix-transposition new file mode 120000 index 0000000000..d8c48f92d0 --- /dev/null +++ b/Lang/Python/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Python \ No newline at end of file diff --git a/Lang/Python/Maze-generation b/Lang/Python/Maze-generation new file mode 120000 index 0000000000..fe21a323fc --- /dev/null +++ b/Lang/Python/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Python \ No newline at end of file diff --git a/Lang/Python/Maze-solving b/Lang/Python/Maze-solving new file mode 120000 index 0000000000..a111b2b8ae --- /dev/null +++ b/Lang/Python/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Python \ No newline at end of file diff --git a/Lang/Python/Median-filter b/Lang/Python/Median-filter new file mode 120000 index 0000000000..c79f5e5781 --- /dev/null +++ b/Lang/Python/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Python \ No newline at end of file diff --git a/Lang/Python/Memory-allocation b/Lang/Python/Memory-allocation new file mode 120000 index 0000000000..c951fa5570 --- /dev/null +++ b/Lang/Python/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Python \ No newline at end of file diff --git a/Lang/Python/Memory-layout-of-a-data-structure b/Lang/Python/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..34c7c776bd --- /dev/null +++ b/Lang/Python/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Python \ No newline at end of file diff --git a/Lang/Python/Menu b/Lang/Python/Menu new file mode 120000 index 0000000000..1d3a9e9250 --- /dev/null +++ b/Lang/Python/Menu @@ -0,0 +1 @@ +../../Task/Menu/Python \ No newline at end of file diff --git a/Lang/Python/Metered-concurrency b/Lang/Python/Metered-concurrency new file mode 120000 index 0000000000..b9c94166af --- /dev/null +++ b/Lang/Python/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Python \ No newline at end of file diff --git a/Lang/Python/Middle-three-digits b/Lang/Python/Middle-three-digits new file mode 120000 index 0000000000..0cfdebb40e --- /dev/null +++ b/Lang/Python/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Python \ No newline at end of file diff --git a/Lang/Python/Miller-Rabin-primality-test b/Lang/Python/Miller-Rabin-primality-test new file mode 120000 index 0000000000..4ec507954a --- /dev/null +++ b/Lang/Python/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Python \ No newline at end of file diff --git a/Lang/Python/Minesweeper-game b/Lang/Python/Minesweeper-game new file mode 120000 index 0000000000..782b01d7e9 --- /dev/null +++ b/Lang/Python/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Python \ No newline at end of file diff --git a/Lang/Python/Modular-exponentiation b/Lang/Python/Modular-exponentiation new file mode 120000 index 0000000000..8a85af5363 --- /dev/null +++ b/Lang/Python/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Python \ No newline at end of file diff --git a/Lang/Python/Modular-inverse b/Lang/Python/Modular-inverse new file mode 120000 index 0000000000..39fe551d9c --- /dev/null +++ b/Lang/Python/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Python \ No newline at end of file diff --git a/Lang/Python/Monte-Carlo-methods b/Lang/Python/Monte-Carlo-methods new file mode 120000 index 0000000000..1eedb15bd1 --- /dev/null +++ b/Lang/Python/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Python \ No newline at end of file diff --git a/Lang/Python/Monty-Hall-problem b/Lang/Python/Monty-Hall-problem new file mode 120000 index 0000000000..66acba097e --- /dev/null +++ b/Lang/Python/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Python \ No newline at end of file diff --git a/Lang/Python/Morse-code b/Lang/Python/Morse-code new file mode 120000 index 0000000000..7e3e327621 --- /dev/null +++ b/Lang/Python/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Python \ No newline at end of file diff --git a/Lang/Python/Mouse-position b/Lang/Python/Mouse-position new file mode 120000 index 0000000000..71a83dfcd6 --- /dev/null +++ b/Lang/Python/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Python \ No newline at end of file diff --git a/Lang/Python/Multifactorial b/Lang/Python/Multifactorial new file mode 120000 index 0000000000..e8ab43892b --- /dev/null +++ b/Lang/Python/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Python \ No newline at end of file diff --git a/Lang/Python/Multiple-distinct-objects b/Lang/Python/Multiple-distinct-objects new file mode 120000 index 0000000000..63eecc45b2 --- /dev/null +++ b/Lang/Python/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Python \ No newline at end of file diff --git a/Lang/Python/Multiple-regression b/Lang/Python/Multiple-regression new file mode 120000 index 0000000000..94718cb3fe --- /dev/null +++ b/Lang/Python/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Python \ No newline at end of file diff --git a/Lang/Python/Multiplication-tables b/Lang/Python/Multiplication-tables new file mode 120000 index 0000000000..9b12e80aa0 --- /dev/null +++ b/Lang/Python/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Python \ No newline at end of file diff --git a/Lang/Python/Multiplicative-order b/Lang/Python/Multiplicative-order new file mode 120000 index 0000000000..15aacebeea --- /dev/null +++ b/Lang/Python/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Python \ No newline at end of file diff --git a/Lang/Python/Multisplit b/Lang/Python/Multisplit new file mode 120000 index 0000000000..9f0036760b --- /dev/null +++ b/Lang/Python/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Python \ No newline at end of file diff --git a/Lang/Python/Mutex b/Lang/Python/Mutex new file mode 120000 index 0000000000..70d0a13dac --- /dev/null +++ b/Lang/Python/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Python \ No newline at end of file diff --git a/Lang/Python/Mutual-recursion b/Lang/Python/Mutual-recursion new file mode 120000 index 0000000000..4794be79a7 --- /dev/null +++ b/Lang/Python/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Python \ No newline at end of file diff --git a/Lang/R/24-game-Solve b/Lang/R/24-game-Solve new file mode 120000 index 0000000000..25a8748414 --- /dev/null +++ b/Lang/R/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/R \ No newline at end of file diff --git a/Lang/R/Arbitrary-precision-integers-included b/Lang/R/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..171de676d6 --- /dev/null +++ b/Lang/R/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/R \ No newline at end of file diff --git a/Lang/R/Factorial b/Lang/R/Factorial new file mode 120000 index 0000000000..cf84e89e0d --- /dev/null +++ b/Lang/R/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/R \ No newline at end of file diff --git a/Lang/R/Factors-of-an-integer b/Lang/R/Factors-of-an-integer new file mode 120000 index 0000000000..e0908cde04 --- /dev/null +++ b/Lang/R/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/R \ No newline at end of file diff --git a/Lang/R/Fast-Fourier-transform b/Lang/R/Fast-Fourier-transform new file mode 120000 index 0000000000..51ef6ffd97 --- /dev/null +++ b/Lang/R/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/R \ No newline at end of file diff --git a/Lang/R/Fibonacci-sequence b/Lang/R/Fibonacci-sequence new file mode 120000 index 0000000000..795ebdc198 --- /dev/null +++ b/Lang/R/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/R \ No newline at end of file diff --git a/Lang/R/File-IO b/Lang/R/File-IO new file mode 120000 index 0000000000..cdd069101e --- /dev/null +++ b/Lang/R/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/R \ No newline at end of file diff --git a/Lang/R/File-modification-time b/Lang/R/File-modification-time new file mode 120000 index 0000000000..a7be2c0d42 --- /dev/null +++ b/Lang/R/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/R \ No newline at end of file diff --git a/Lang/R/File-size b/Lang/R/File-size new file mode 120000 index 0000000000..d2337c3a22 --- /dev/null +++ b/Lang/R/File-size @@ -0,0 +1 @@ +../../Task/File-size/R \ No newline at end of file diff --git a/Lang/R/Filter b/Lang/R/Filter new file mode 120000 index 0000000000..7772496cad --- /dev/null +++ b/Lang/R/Filter @@ -0,0 +1 @@ +../../Task/Filter/R \ No newline at end of file diff --git a/Lang/R/Find-common-directory-path b/Lang/R/Find-common-directory-path new file mode 120000 index 0000000000..9fea70cff3 --- /dev/null +++ b/Lang/R/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/R \ No newline at end of file diff --git a/Lang/R/Find-limit-of-recursion b/Lang/R/Find-limit-of-recursion new file mode 120000 index 0000000000..aed1e9edb7 --- /dev/null +++ b/Lang/R/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/R \ No newline at end of file diff --git a/Lang/R/Find-the-missing-permutation b/Lang/R/Find-the-missing-permutation new file mode 120000 index 0000000000..2d6754b394 --- /dev/null +++ b/Lang/R/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/R \ No newline at end of file diff --git a/Lang/R/First-class-environments b/Lang/R/First-class-environments new file mode 120000 index 0000000000..f9d458da96 --- /dev/null +++ b/Lang/R/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/R \ No newline at end of file diff --git a/Lang/R/First-class-functions b/Lang/R/First-class-functions new file mode 120000 index 0000000000..7cfe696498 --- /dev/null +++ b/Lang/R/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/R \ No newline at end of file diff --git a/Lang/R/First-class-functions-Use-numbers-analogously b/Lang/R/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..44db999a06 --- /dev/null +++ b/Lang/R/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/R \ No newline at end of file diff --git a/Lang/R/Flatten-a-list b/Lang/R/Flatten-a-list new file mode 120000 index 0000000000..99732c1543 --- /dev/null +++ b/Lang/R/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/R \ No newline at end of file diff --git a/Lang/R/Formatted-numeric-output b/Lang/R/Formatted-numeric-output new file mode 120000 index 0000000000..dd77953225 --- /dev/null +++ b/Lang/R/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/R \ No newline at end of file diff --git a/Lang/R/Forward-difference b/Lang/R/Forward-difference new file mode 120000 index 0000000000..8137b9adac --- /dev/null +++ b/Lang/R/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/R \ No newline at end of file diff --git a/Lang/R/Function-composition b/Lang/R/Function-composition new file mode 120000 index 0000000000..d890b80d6b --- /dev/null +++ b/Lang/R/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/R \ No newline at end of file diff --git a/Lang/R/Function-definition b/Lang/R/Function-definition new file mode 120000 index 0000000000..672367b608 --- /dev/null +++ b/Lang/R/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/R \ No newline at end of file diff --git a/Lang/R/GUI-component-interaction b/Lang/R/GUI-component-interaction new file mode 120000 index 0000000000..737fb3344e --- /dev/null +++ b/Lang/R/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/R \ No newline at end of file diff --git a/Lang/R/GUI-enabling-disabling-of-controls b/Lang/R/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..4f14631d24 --- /dev/null +++ b/Lang/R/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/R \ No newline at end of file diff --git a/Lang/R/Gamma-function b/Lang/R/Gamma-function new file mode 120000 index 0000000000..894e49d603 --- /dev/null +++ b/Lang/R/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/R \ No newline at end of file diff --git a/Lang/R/Generic-swap b/Lang/R/Generic-swap new file mode 120000 index 0000000000..e93cb357bd --- /dev/null +++ b/Lang/R/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/R \ No newline at end of file diff --git a/Lang/R/Grayscale-image b/Lang/R/Grayscale-image new file mode 120000 index 0000000000..1d672a609b --- /dev/null +++ b/Lang/R/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/R \ No newline at end of file diff --git a/Lang/R/Greatest-common-divisor b/Lang/R/Greatest-common-divisor new file mode 120000 index 0000000000..a6459dc095 --- /dev/null +++ b/Lang/R/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/R \ No newline at end of file diff --git a/Lang/R/Greatest-element-of-a-list b/Lang/R/Greatest-element-of-a-list new file mode 120000 index 0000000000..18692799c0 --- /dev/null +++ b/Lang/R/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/R \ No newline at end of file diff --git a/Lang/R/Greatest-subsequential-sum b/Lang/R/Greatest-subsequential-sum new file mode 120000 index 0000000000..bb0a36968d --- /dev/null +++ b/Lang/R/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/R \ No newline at end of file diff --git a/Lang/R/Greyscale-bars-Display b/Lang/R/Greyscale-bars-Display new file mode 120000 index 0000000000..fe3fc1d600 --- /dev/null +++ b/Lang/R/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/R \ No newline at end of file diff --git a/Lang/R/Guess-the-number b/Lang/R/Guess-the-number new file mode 120000 index 0000000000..d1f86c0c42 --- /dev/null +++ b/Lang/R/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/R \ No newline at end of file diff --git a/Lang/R/HTTP b/Lang/R/HTTP new file mode 120000 index 0000000000..47e2f5c977 --- /dev/null +++ b/Lang/R/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/R \ No newline at end of file diff --git a/Lang/R/HTTPS b/Lang/R/HTTPS new file mode 120000 index 0000000000..f11e111114 --- /dev/null +++ b/Lang/R/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/R \ No newline at end of file diff --git a/Lang/R/Hailstone-sequence b/Lang/R/Hailstone-sequence new file mode 120000 index 0000000000..239d9b2e87 --- /dev/null +++ b/Lang/R/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/R \ No newline at end of file diff --git a/Lang/R/Hamming-numbers b/Lang/R/Hamming-numbers new file mode 120000 index 0000000000..3a8d739f0d --- /dev/null +++ b/Lang/R/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/R \ No newline at end of file diff --git a/Lang/R/Happy-numbers b/Lang/R/Happy-numbers new file mode 120000 index 0000000000..4d29ad5e71 --- /dev/null +++ b/Lang/R/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/R \ No newline at end of file diff --git a/Lang/R/Hash-from-two-arrays b/Lang/R/Hash-from-two-arrays new file mode 120000 index 0000000000..548b8c7f19 --- /dev/null +++ b/Lang/R/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/R \ No newline at end of file diff --git a/Lang/R/Haversine-formula b/Lang/R/Haversine-formula new file mode 120000 index 0000000000..197567ad1c --- /dev/null +++ b/Lang/R/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/R \ No newline at end of file diff --git a/Lang/R/Hello-world-Graphical b/Lang/R/Hello-world-Graphical new file mode 120000 index 0000000000..3fe48d3909 --- /dev/null +++ b/Lang/R/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/R \ No newline at end of file diff --git a/Lang/R/Hello-world-Standard-error b/Lang/R/Hello-world-Standard-error new file mode 120000 index 0000000000..202e8d6d86 --- /dev/null +++ b/Lang/R/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/R \ No newline at end of file diff --git a/Lang/R/Hello-world-Text b/Lang/R/Hello-world-Text new file mode 120000 index 0000000000..8a450305b1 --- /dev/null +++ b/Lang/R/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/R \ No newline at end of file diff --git a/Lang/R/Higher-order-functions b/Lang/R/Higher-order-functions new file mode 120000 index 0000000000..b3ff69f2e4 --- /dev/null +++ b/Lang/R/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/R \ No newline at end of file diff --git a/Lang/R/Hofstadter-Conway-$10,000-sequence b/Lang/R/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..a64fe1f57e --- /dev/null +++ b/Lang/R/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/R \ No newline at end of file diff --git a/Lang/R/Horners-rule-for-polynomial-evaluation b/Lang/R/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..9813a4e194 --- /dev/null +++ b/Lang/R/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/R \ No newline at end of file diff --git a/Lang/R/Host-introspection b/Lang/R/Host-introspection new file mode 120000 index 0000000000..605a31043b --- /dev/null +++ b/Lang/R/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/R \ No newline at end of file diff --git a/Lang/R/Hostname b/Lang/R/Hostname new file mode 120000 index 0000000000..59f5bd0ebe --- /dev/null +++ b/Lang/R/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/R \ No newline at end of file diff --git a/Lang/R/Identity-matrix b/Lang/R/Identity-matrix new file mode 120000 index 0000000000..42f6e5781a --- /dev/null +++ b/Lang/R/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/R \ No newline at end of file diff --git a/Lang/R/Include-a-file b/Lang/R/Include-a-file new file mode 120000 index 0000000000..4072e96a1d --- /dev/null +++ b/Lang/R/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/R \ No newline at end of file diff --git a/Lang/R/Increment-a-numerical-string b/Lang/R/Increment-a-numerical-string new file mode 120000 index 0000000000..ece01980bc --- /dev/null +++ b/Lang/R/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/R \ No newline at end of file diff --git a/Lang/R/Inheritance-Single b/Lang/R/Inheritance-Single new file mode 120000 index 0000000000..e5f644ed75 --- /dev/null +++ b/Lang/R/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/R \ No newline at end of file diff --git a/Lang/R/Input-loop b/Lang/R/Input-loop new file mode 120000 index 0000000000..ccb5e5e6ae --- /dev/null +++ b/Lang/R/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/R \ No newline at end of file diff --git a/Lang/R/Integer-comparison b/Lang/R/Integer-comparison new file mode 120000 index 0000000000..2872288387 --- /dev/null +++ b/Lang/R/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/R \ No newline at end of file diff --git a/Lang/R/Interactive-programming b/Lang/R/Interactive-programming new file mode 120000 index 0000000000..d768f7a8b9 --- /dev/null +++ b/Lang/R/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/R \ No newline at end of file diff --git a/Lang/R/Introspection b/Lang/R/Introspection new file mode 120000 index 0000000000..4debdd43a5 --- /dev/null +++ b/Lang/R/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/R \ No newline at end of file diff --git a/Lang/R/Inverted-syntax b/Lang/R/Inverted-syntax new file mode 120000 index 0000000000..e263a9e180 --- /dev/null +++ b/Lang/R/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/R \ No newline at end of file diff --git a/Lang/R/Jensens-Device b/Lang/R/Jensens-Device new file mode 120000 index 0000000000..6ca77ed0a8 --- /dev/null +++ b/Lang/R/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/R \ No newline at end of file diff --git a/Lang/R/Knapsack-problem-Unbounded b/Lang/R/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..9989140c42 --- /dev/null +++ b/Lang/R/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/R \ No newline at end of file diff --git a/Lang/R/Leap-year b/Lang/R/Leap-year new file mode 120000 index 0000000000..b9bf15b717 --- /dev/null +++ b/Lang/R/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/R \ No newline at end of file diff --git a/Lang/R/Letter-frequency b/Lang/R/Letter-frequency new file mode 120000 index 0000000000..72db01414a --- /dev/null +++ b/Lang/R/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/R \ No newline at end of file diff --git a/Lang/R/List-comprehensions b/Lang/R/List-comprehensions new file mode 120000 index 0000000000..9f837b8e51 --- /dev/null +++ b/Lang/R/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/R \ No newline at end of file diff --git a/Lang/R/Literals-Integer b/Lang/R/Literals-Integer new file mode 120000 index 0000000000..9133561d5c --- /dev/null +++ b/Lang/R/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/R \ No newline at end of file diff --git a/Lang/R/Literals-String b/Lang/R/Literals-String new file mode 120000 index 0000000000..330b7d226d --- /dev/null +++ b/Lang/R/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/R \ No newline at end of file diff --git a/Lang/R/Logical-operations b/Lang/R/Logical-operations new file mode 120000 index 0000000000..edaa807931 --- /dev/null +++ b/Lang/R/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/R \ No newline at end of file diff --git a/Lang/R/Long-multiplication b/Lang/R/Long-multiplication new file mode 120000 index 0000000000..2fe84716af --- /dev/null +++ b/Lang/R/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/R \ No newline at end of file diff --git a/Lang/R/Look-and-say-sequence b/Lang/R/Look-and-say-sequence new file mode 120000 index 0000000000..df6ed1711c --- /dev/null +++ b/Lang/R/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/R \ No newline at end of file diff --git a/Lang/R/Loop-over-multiple-arrays-simultaneously b/Lang/R/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..3c78320d69 --- /dev/null +++ b/Lang/R/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/R \ No newline at end of file diff --git a/Lang/R/Loops-Break b/Lang/R/Loops-Break new file mode 120000 index 0000000000..324dc780b7 --- /dev/null +++ b/Lang/R/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/R \ No newline at end of file diff --git a/Lang/R/Loops-Continue b/Lang/R/Loops-Continue new file mode 120000 index 0000000000..6e181cd293 --- /dev/null +++ b/Lang/R/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/R \ No newline at end of file diff --git a/Lang/R/Loops-Do-while b/Lang/R/Loops-Do-while new file mode 120000 index 0000000000..f89e60b21b --- /dev/null +++ b/Lang/R/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/R \ No newline at end of file diff --git a/Lang/R/Loops-Downward-for b/Lang/R/Loops-Downward-for new file mode 120000 index 0000000000..872e3b1552 --- /dev/null +++ b/Lang/R/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/R \ No newline at end of file diff --git a/Lang/R/Loops-For b/Lang/R/Loops-For new file mode 120000 index 0000000000..69fe8047bf --- /dev/null +++ b/Lang/R/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/R \ No newline at end of file diff --git a/Lang/R/Loops-For-with-a-specified-step b/Lang/R/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..8ae4d18f81 --- /dev/null +++ b/Lang/R/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/R \ No newline at end of file diff --git a/Lang/R/Loops-Foreach b/Lang/R/Loops-Foreach new file mode 120000 index 0000000000..986b468ab6 --- /dev/null +++ b/Lang/R/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/R \ No newline at end of file diff --git a/Lang/R/Loops-Infinite b/Lang/R/Loops-Infinite new file mode 120000 index 0000000000..031f4776a7 --- /dev/null +++ b/Lang/R/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/R \ No newline at end of file diff --git a/Lang/R/Loops-N-plus-one-half b/Lang/R/Loops-N-plus-one-half new file mode 120000 index 0000000000..67133e98db --- /dev/null +++ b/Lang/R/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/R \ No newline at end of file diff --git a/Lang/R/Loops-Nested b/Lang/R/Loops-Nested new file mode 120000 index 0000000000..b0f802b0ed --- /dev/null +++ b/Lang/R/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/R \ No newline at end of file diff --git a/Lang/R/Loops-While b/Lang/R/Loops-While new file mode 120000 index 0000000000..19c974de4d --- /dev/null +++ b/Lang/R/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/R \ No newline at end of file diff --git a/Lang/R/Luhn-test-of-credit-card-numbers b/Lang/R/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..67d5d6d053 --- /dev/null +++ b/Lang/R/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/R \ No newline at end of file diff --git a/Lang/R/MD5 b/Lang/R/MD5 new file mode 120000 index 0000000000..963cc3d33f --- /dev/null +++ b/Lang/R/MD5 @@ -0,0 +1 @@ +../../Task/MD5/R \ No newline at end of file diff --git a/Lang/R/Man-or-boy-test b/Lang/R/Man-or-boy-test new file mode 120000 index 0000000000..58f2f95faf --- /dev/null +++ b/Lang/R/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/R \ No newline at end of file diff --git a/Lang/R/Mandelbrot-set b/Lang/R/Mandelbrot-set new file mode 120000 index 0000000000..8f863a450e --- /dev/null +++ b/Lang/R/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/R \ No newline at end of file diff --git a/Lang/R/Matrix-exponentiation-operator b/Lang/R/Matrix-exponentiation-operator new file mode 120000 index 0000000000..ad2433f215 --- /dev/null +++ b/Lang/R/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/R \ No newline at end of file diff --git a/Lang/R/Matrix-multiplication b/Lang/R/Matrix-multiplication new file mode 120000 index 0000000000..f424d65be9 --- /dev/null +++ b/Lang/R/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/R \ No newline at end of file diff --git a/Lang/R/Matrix-transposition b/Lang/R/Matrix-transposition new file mode 120000 index 0000000000..d3ce23448e --- /dev/null +++ b/Lang/R/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/R \ No newline at end of file diff --git a/Lang/R/Memory-allocation b/Lang/R/Memory-allocation new file mode 120000 index 0000000000..358ce2c512 --- /dev/null +++ b/Lang/R/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/R \ No newline at end of file diff --git a/Lang/R/Menu b/Lang/R/Menu new file mode 120000 index 0000000000..d672bd0eef --- /dev/null +++ b/Lang/R/Menu @@ -0,0 +1 @@ +../../Task/Menu/R \ No newline at end of file diff --git a/Lang/R/Monte-Carlo-methods b/Lang/R/Monte-Carlo-methods new file mode 120000 index 0000000000..359f105760 --- /dev/null +++ b/Lang/R/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/R \ No newline at end of file diff --git a/Lang/R/Monty-Hall-problem b/Lang/R/Monty-Hall-problem new file mode 120000 index 0000000000..6bae55b213 --- /dev/null +++ b/Lang/R/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/R \ No newline at end of file diff --git a/Lang/R/Multiple-distinct-objects b/Lang/R/Multiple-distinct-objects new file mode 120000 index 0000000000..48b0dea45f --- /dev/null +++ b/Lang/R/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/R \ No newline at end of file diff --git a/Lang/R/Multiple-regression b/Lang/R/Multiple-regression new file mode 120000 index 0000000000..b36f819b2f --- /dev/null +++ b/Lang/R/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/R \ No newline at end of file diff --git a/Lang/R/Multiplication-tables b/Lang/R/Multiplication-tables new file mode 120000 index 0000000000..7fa3c52665 --- /dev/null +++ b/Lang/R/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/R \ No newline at end of file diff --git a/Lang/R/Mutual-recursion b/Lang/R/Mutual-recursion new file mode 120000 index 0000000000..d0a4f4e44c --- /dev/null +++ b/Lang/R/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/R \ No newline at end of file diff --git a/Lang/REXX/24-game-Solve b/Lang/REXX/24-game-Solve new file mode 120000 index 0000000000..0b1a318228 --- /dev/null +++ b/Lang/REXX/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/REXX \ No newline at end of file diff --git a/Lang/REXX/Arbitrary-precision-integers-included b/Lang/REXX/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..fdedb62758 --- /dev/null +++ b/Lang/REXX/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/REXX \ No newline at end of file diff --git a/Lang/REXX/Factorial b/Lang/REXX/Factorial new file mode 120000 index 0000000000..8f0b77883a --- /dev/null +++ b/Lang/REXX/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/REXX \ No newline at end of file diff --git a/Lang/REXX/Factors-of-a-Mersenne-number b/Lang/REXX/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..d76ed264c3 --- /dev/null +++ b/Lang/REXX/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/REXX \ No newline at end of file diff --git a/Lang/REXX/Factors-of-an-integer b/Lang/REXX/Factors-of-an-integer new file mode 120000 index 0000000000..6d1f88089c --- /dev/null +++ b/Lang/REXX/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/REXX \ No newline at end of file diff --git a/Lang/REXX/Fast-Fourier-transform b/Lang/REXX/Fast-Fourier-transform new file mode 120000 index 0000000000..274730d635 --- /dev/null +++ b/Lang/REXX/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/REXX \ No newline at end of file diff --git a/Lang/REXX/Fibonacci-n-step-number-sequences b/Lang/REXX/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..1179ba3464 --- /dev/null +++ b/Lang/REXX/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/REXX \ No newline at end of file diff --git a/Lang/REXX/Fibonacci-sequence b/Lang/REXX/Fibonacci-sequence new file mode 120000 index 0000000000..feb38a4158 --- /dev/null +++ b/Lang/REXX/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/File-IO b/Lang/REXX/File-IO new file mode 120000 index 0000000000..3903999609 --- /dev/null +++ b/Lang/REXX/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/REXX \ No newline at end of file diff --git a/Lang/REXX/File-size b/Lang/REXX/File-size new file mode 120000 index 0000000000..eef4e53b80 --- /dev/null +++ b/Lang/REXX/File-size @@ -0,0 +1 @@ +../../Task/File-size/REXX \ No newline at end of file diff --git a/Lang/REXX/Filter b/Lang/REXX/Filter new file mode 120000 index 0000000000..6f331eb2d3 --- /dev/null +++ b/Lang/REXX/Filter @@ -0,0 +1 @@ +../../Task/Filter/REXX \ No newline at end of file diff --git a/Lang/REXX/Find-common-directory-path b/Lang/REXX/Find-common-directory-path new file mode 120000 index 0000000000..ef12d8ab84 --- /dev/null +++ b/Lang/REXX/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/REXX \ No newline at end of file diff --git a/Lang/REXX/Find-limit-of-recursion b/Lang/REXX/Find-limit-of-recursion new file mode 120000 index 0000000000..b2dd50c02b --- /dev/null +++ b/Lang/REXX/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/REXX \ No newline at end of file diff --git a/Lang/REXX/Find-the-missing-permutation b/Lang/REXX/Find-the-missing-permutation new file mode 120000 index 0000000000..42135cc06d --- /dev/null +++ b/Lang/REXX/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/REXX \ No newline at end of file diff --git a/Lang/REXX/First-class-environments b/Lang/REXX/First-class-environments new file mode 120000 index 0000000000..fee0fbabdf --- /dev/null +++ b/Lang/REXX/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/REXX \ No newline at end of file diff --git a/Lang/REXX/Five-weekends b/Lang/REXX/Five-weekends new file mode 120000 index 0000000000..c933b9c12a --- /dev/null +++ b/Lang/REXX/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/REXX \ No newline at end of file diff --git a/Lang/REXX/Flatten-a-list b/Lang/REXX/Flatten-a-list new file mode 120000 index 0000000000..851b2195c6 --- /dev/null +++ b/Lang/REXX/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/REXX \ No newline at end of file diff --git a/Lang/REXX/Flow-control-structures b/Lang/REXX/Flow-control-structures new file mode 120000 index 0000000000..74581b1612 --- /dev/null +++ b/Lang/REXX/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/REXX \ No newline at end of file diff --git a/Lang/REXX/Floyds-triangle b/Lang/REXX/Floyds-triangle new file mode 120000 index 0000000000..ae01839de5 --- /dev/null +++ b/Lang/REXX/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/REXX \ No newline at end of file diff --git a/Lang/REXX/Fork b/Lang/REXX/Fork new file mode 120000 index 0000000000..be36c00dbe --- /dev/null +++ b/Lang/REXX/Fork @@ -0,0 +1 @@ +../../Task/Fork/REXX \ No newline at end of file diff --git a/Lang/REXX/Formatted-numeric-output b/Lang/REXX/Formatted-numeric-output new file mode 120000 index 0000000000..b3ba9610fa --- /dev/null +++ b/Lang/REXX/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/REXX \ No newline at end of file diff --git a/Lang/REXX/Forward-difference b/Lang/REXX/Forward-difference new file mode 120000 index 0000000000..00bf4eb7ba --- /dev/null +++ b/Lang/REXX/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/REXX \ No newline at end of file diff --git a/Lang/REXX/Four-bit-adder b/Lang/REXX/Four-bit-adder new file mode 120000 index 0000000000..884ffe5eea --- /dev/null +++ b/Lang/REXX/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/REXX \ No newline at end of file diff --git a/Lang/REXX/Function-composition b/Lang/REXX/Function-composition new file mode 120000 index 0000000000..50eba7ca9d --- /dev/null +++ b/Lang/REXX/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/REXX \ No newline at end of file diff --git a/Lang/REXX/Function-definition b/Lang/REXX/Function-definition new file mode 120000 index 0000000000..bd50441b33 --- /dev/null +++ b/Lang/REXX/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/REXX \ No newline at end of file diff --git a/Lang/REXX/Function-frequency b/Lang/REXX/Function-frequency new file mode 120000 index 0000000000..01ff29e9c8 --- /dev/null +++ b/Lang/REXX/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/REXX \ No newline at end of file diff --git a/Lang/REXX/Gamma-function b/Lang/REXX/Gamma-function new file mode 120000 index 0000000000..3e651c995a --- /dev/null +++ b/Lang/REXX/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/REXX \ No newline at end of file diff --git a/Lang/REXX/Generator-Exponential b/Lang/REXX/Generator-Exponential new file mode 120000 index 0000000000..530205e69f --- /dev/null +++ b/Lang/REXX/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/REXX \ No newline at end of file diff --git a/Lang/REXX/Generic-swap b/Lang/REXX/Generic-swap new file mode 120000 index 0000000000..41c703d770 --- /dev/null +++ b/Lang/REXX/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/REXX \ No newline at end of file diff --git a/Lang/REXX/Globally-replace-text-in-several-files b/Lang/REXX/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..523139589e --- /dev/null +++ b/Lang/REXX/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/REXX \ No newline at end of file diff --git a/Lang/REXX/Gray-code b/Lang/REXX/Gray-code new file mode 120000 index 0000000000..c16f78b7a3 --- /dev/null +++ b/Lang/REXX/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/REXX \ No newline at end of file diff --git a/Lang/REXX/Grayscale-image b/Lang/REXX/Grayscale-image new file mode 120000 index 0000000000..038a36b015 --- /dev/null +++ b/Lang/REXX/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/REXX \ No newline at end of file diff --git a/Lang/REXX/Greatest-common-divisor b/Lang/REXX/Greatest-common-divisor new file mode 120000 index 0000000000..92f0c302c2 --- /dev/null +++ b/Lang/REXX/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/REXX \ No newline at end of file diff --git a/Lang/REXX/Greatest-element-of-a-list b/Lang/REXX/Greatest-element-of-a-list new file mode 120000 index 0000000000..5ea4227f18 --- /dev/null +++ b/Lang/REXX/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/REXX \ No newline at end of file diff --git a/Lang/REXX/Greatest-subsequential-sum b/Lang/REXX/Greatest-subsequential-sum new file mode 120000 index 0000000000..049a23cb3f --- /dev/null +++ b/Lang/REXX/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/REXX \ No newline at end of file diff --git a/Lang/REXX/Guess-the-number b/Lang/REXX/Guess-the-number new file mode 120000 index 0000000000..15398e52a0 --- /dev/null +++ b/Lang/REXX/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/REXX \ No newline at end of file diff --git a/Lang/REXX/Guess-the-number-With-feedback b/Lang/REXX/Guess-the-number-With-feedback new file mode 120000 index 0000000000..8d6a902816 --- /dev/null +++ b/Lang/REXX/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/REXX \ No newline at end of file diff --git a/Lang/REXX/Guess-the-number-With-feedback-player b/Lang/REXX/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..3804a73ab0 --- /dev/null +++ b/Lang/REXX/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/REXX \ No newline at end of file diff --git a/Lang/REXX/Hailstone-sequence b/Lang/REXX/Hailstone-sequence new file mode 120000 index 0000000000..52ba13ae6b --- /dev/null +++ b/Lang/REXX/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Hamming-numbers b/Lang/REXX/Hamming-numbers new file mode 120000 index 0000000000..32e1ac2c0f --- /dev/null +++ b/Lang/REXX/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Handle-a-signal b/Lang/REXX/Handle-a-signal new file mode 120000 index 0000000000..bd4297b20c --- /dev/null +++ b/Lang/REXX/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/REXX \ No newline at end of file diff --git a/Lang/REXX/Happy-numbers b/Lang/REXX/Happy-numbers new file mode 120000 index 0000000000..485da34a5e --- /dev/null +++ b/Lang/REXX/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Harshad-or-Niven-series b/Lang/REXX/Harshad-or-Niven-series new file mode 120000 index 0000000000..d74d3be7b6 --- /dev/null +++ b/Lang/REXX/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/REXX \ No newline at end of file diff --git a/Lang/REXX/Hash-from-two-arrays b/Lang/REXX/Hash-from-two-arrays new file mode 120000 index 0000000000..8fa8ee3bd5 --- /dev/null +++ b/Lang/REXX/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/REXX \ No newline at end of file diff --git a/Lang/REXX/Haversine-formula b/Lang/REXX/Haversine-formula new file mode 120000 index 0000000000..66b3d8b0df --- /dev/null +++ b/Lang/REXX/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/REXX \ No newline at end of file diff --git a/Lang/REXX/Hello-world-Graphical b/Lang/REXX/Hello-world-Graphical new file mode 120000 index 0000000000..149c113c52 --- /dev/null +++ b/Lang/REXX/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/REXX \ No newline at end of file diff --git a/Lang/REXX/Hello-world-Line-printer b/Lang/REXX/Hello-world-Line-printer new file mode 120000 index 0000000000..bf9183cc53 --- /dev/null +++ b/Lang/REXX/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/REXX \ No newline at end of file diff --git a/Lang/REXX/Hello-world-Newline-omission b/Lang/REXX/Hello-world-Newline-omission new file mode 120000 index 0000000000..afa8277afa --- /dev/null +++ b/Lang/REXX/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/REXX \ No newline at end of file diff --git a/Lang/REXX/Hello-world-Standard-error b/Lang/REXX/Hello-world-Standard-error new file mode 120000 index 0000000000..b838f1ed06 --- /dev/null +++ b/Lang/REXX/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/REXX \ No newline at end of file diff --git a/Lang/REXX/Hello-world-Text b/Lang/REXX/Hello-world-Text new file mode 120000 index 0000000000..93128d4d60 --- /dev/null +++ b/Lang/REXX/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/REXX \ No newline at end of file diff --git a/Lang/REXX/Here-document b/Lang/REXX/Here-document new file mode 120000 index 0000000000..a40806e250 --- /dev/null +++ b/Lang/REXX/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/REXX \ No newline at end of file diff --git a/Lang/REXX/Higher-order-functions b/Lang/REXX/Higher-order-functions new file mode 120000 index 0000000000..d1d0c08ad8 --- /dev/null +++ b/Lang/REXX/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/REXX \ No newline at end of file diff --git a/Lang/REXX/History-variables b/Lang/REXX/History-variables new file mode 120000 index 0000000000..7f850a68db --- /dev/null +++ b/Lang/REXX/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/REXX \ No newline at end of file diff --git a/Lang/REXX/Hofstadter-Conway-$10,000-sequence b/Lang/REXX/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..cc1cf5d39d --- /dev/null +++ b/Lang/REXX/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Hofstadter-Figure-Figure-sequences b/Lang/REXX/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..2beadf1428 --- /dev/null +++ b/Lang/REXX/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/REXX \ No newline at end of file diff --git a/Lang/REXX/Hofstadter-Q-sequence b/Lang/REXX/Hofstadter-Q-sequence new file mode 120000 index 0000000000..3f4f08147e --- /dev/null +++ b/Lang/REXX/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Horizontal-sundial-calculations b/Lang/REXX/Horizontal-sundial-calculations new file mode 120000 index 0000000000..9a11db2ff8 --- /dev/null +++ b/Lang/REXX/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/REXX \ No newline at end of file diff --git a/Lang/REXX/Horners-rule-for-polynomial-evaluation b/Lang/REXX/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..b1970e57a2 --- /dev/null +++ b/Lang/REXX/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/REXX \ No newline at end of file diff --git a/Lang/REXX/Host-introspection b/Lang/REXX/Host-introspection new file mode 120000 index 0000000000..6b9dd165b8 --- /dev/null +++ b/Lang/REXX/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/REXX \ No newline at end of file diff --git a/Lang/REXX/Hostname b/Lang/REXX/Hostname new file mode 120000 index 0000000000..5d330d4386 --- /dev/null +++ b/Lang/REXX/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/REXX \ No newline at end of file diff --git a/Lang/REXX/I-before-E-except-after-C b/Lang/REXX/I-before-E-except-after-C new file mode 120000 index 0000000000..032c2f695e --- /dev/null +++ b/Lang/REXX/I-before-E-except-after-C @@ -0,0 +1 @@ +../../Task/I-before-E-except-after-C/REXX \ No newline at end of file diff --git a/Lang/REXX/Identity-matrix b/Lang/REXX/Identity-matrix new file mode 120000 index 0000000000..d19884cfe9 --- /dev/null +++ b/Lang/REXX/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/REXX \ No newline at end of file diff --git a/Lang/REXX/Increment-a-numerical-string b/Lang/REXX/Increment-a-numerical-string new file mode 120000 index 0000000000..c652cf16f3 --- /dev/null +++ b/Lang/REXX/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/REXX \ No newline at end of file diff --git a/Lang/REXX/Input-loop b/Lang/REXX/Input-loop new file mode 120000 index 0000000000..c0d14b6e93 --- /dev/null +++ b/Lang/REXX/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/REXX \ No newline at end of file diff --git a/Lang/REXX/Integer-comparison b/Lang/REXX/Integer-comparison new file mode 120000 index 0000000000..9ef88928c9 --- /dev/null +++ b/Lang/REXX/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/REXX \ No newline at end of file diff --git a/Lang/REXX/Integer-sequence b/Lang/REXX/Integer-sequence new file mode 120000 index 0000000000..d971276888 --- /dev/null +++ b/Lang/REXX/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Interactive-programming b/Lang/REXX/Interactive-programming new file mode 120000 index 0000000000..ea9b0c6ff6 --- /dev/null +++ b/Lang/REXX/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/REXX \ No newline at end of file diff --git a/Lang/REXX/Introspection b/Lang/REXX/Introspection new file mode 120000 index 0000000000..2c2f1fa3a4 --- /dev/null +++ b/Lang/REXX/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/REXX \ No newline at end of file diff --git a/Lang/REXX/Inverted-index b/Lang/REXX/Inverted-index new file mode 120000 index 0000000000..eecdb53cfd --- /dev/null +++ b/Lang/REXX/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/REXX \ No newline at end of file diff --git a/Lang/REXX/Inverted-syntax b/Lang/REXX/Inverted-syntax new file mode 120000 index 0000000000..0151026c37 --- /dev/null +++ b/Lang/REXX/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/REXX \ No newline at end of file diff --git a/Lang/REXX/Jensens-Device b/Lang/REXX/Jensens-Device new file mode 120000 index 0000000000..698fdac1cd --- /dev/null +++ b/Lang/REXX/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/REXX \ No newline at end of file diff --git a/Lang/REXX/Josephus-problem b/Lang/REXX/Josephus-problem new file mode 120000 index 0000000000..1bd07181e9 --- /dev/null +++ b/Lang/REXX/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/REXX \ No newline at end of file diff --git a/Lang/REXX/Jump-anywhere b/Lang/REXX/Jump-anywhere new file mode 120000 index 0000000000..093b955d0c --- /dev/null +++ b/Lang/REXX/Jump-anywhere @@ -0,0 +1 @@ +../../Task/Jump-anywhere/REXX \ No newline at end of file diff --git a/Lang/REXX/Kaprekar-numbers b/Lang/REXX/Kaprekar-numbers new file mode 120000 index 0000000000..fa4a9c27bd --- /dev/null +++ b/Lang/REXX/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Keyboard-input-Flush-the-keyboard-buffer b/Lang/REXX/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..e8da47a3d7 --- /dev/null +++ b/Lang/REXX/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/REXX \ No newline at end of file diff --git a/Lang/REXX/Keyboard-input-Keypress-check b/Lang/REXX/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..c7b15e02a3 --- /dev/null +++ b/Lang/REXX/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/REXX \ No newline at end of file diff --git a/Lang/REXX/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/REXX/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..9db3432156 --- /dev/null +++ b/Lang/REXX/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/REXX \ No newline at end of file diff --git a/Lang/REXX/Keyboard-macros b/Lang/REXX/Keyboard-macros new file mode 120000 index 0000000000..c24e433ae8 --- /dev/null +++ b/Lang/REXX/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/REXX \ No newline at end of file diff --git a/Lang/REXX/Knapsack-problem-0-1 b/Lang/REXX/Knapsack-problem-0-1 new file mode 120000 index 0000000000..4d6538c847 --- /dev/null +++ b/Lang/REXX/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/REXX \ No newline at end of file diff --git a/Lang/REXX/Knapsack-problem-Bounded b/Lang/REXX/Knapsack-problem-Bounded new file mode 120000 index 0000000000..8f5cbd88ed --- /dev/null +++ b/Lang/REXX/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/REXX \ No newline at end of file diff --git a/Lang/REXX/Knapsack-problem-Continuous b/Lang/REXX/Knapsack-problem-Continuous new file mode 120000 index 0000000000..3ecd04c934 --- /dev/null +++ b/Lang/REXX/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/REXX \ No newline at end of file diff --git a/Lang/REXX/Knapsack-problem-Unbounded b/Lang/REXX/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..c647aae7fd --- /dev/null +++ b/Lang/REXX/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/REXX \ No newline at end of file diff --git a/Lang/REXX/Knights-tour b/Lang/REXX/Knights-tour new file mode 120000 index 0000000000..dba9e3d6c1 --- /dev/null +++ b/Lang/REXX/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/REXX \ No newline at end of file diff --git a/Lang/REXX/Knuths-algorithm-S b/Lang/REXX/Knuths-algorithm-S new file mode 120000 index 0000000000..42f5b70789 --- /dev/null +++ b/Lang/REXX/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/REXX \ No newline at end of file diff --git a/Lang/REXX/LU-decomposition b/Lang/REXX/LU-decomposition new file mode 120000 index 0000000000..c3caba847a --- /dev/null +++ b/Lang/REXX/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/REXX \ No newline at end of file diff --git a/Lang/REXX/Langtons-ant b/Lang/REXX/Langtons-ant new file mode 120000 index 0000000000..74b62f7209 --- /dev/null +++ b/Lang/REXX/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/REXX \ No newline at end of file diff --git a/Lang/REXX/Largest-int-from-concatenated-ints b/Lang/REXX/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..acc0617b64 --- /dev/null +++ b/Lang/REXX/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/REXX \ No newline at end of file diff --git a/Lang/REXX/Last-Friday-of-each-month b/Lang/REXX/Last-Friday-of-each-month new file mode 120000 index 0000000000..602b8b53b7 --- /dev/null +++ b/Lang/REXX/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/REXX \ No newline at end of file diff --git a/Lang/REXX/Last-letter-first-letter b/Lang/REXX/Last-letter-first-letter new file mode 120000 index 0000000000..cb94e45cbf --- /dev/null +++ b/Lang/REXX/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/REXX \ No newline at end of file diff --git a/Lang/REXX/Leap-year b/Lang/REXX/Leap-year new file mode 120000 index 0000000000..a21e9bc1d2 --- /dev/null +++ b/Lang/REXX/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/REXX \ No newline at end of file diff --git a/Lang/REXX/Least-common-multiple b/Lang/REXX/Least-common-multiple new file mode 120000 index 0000000000..a48f333563 --- /dev/null +++ b/Lang/REXX/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/REXX \ No newline at end of file diff --git a/Lang/REXX/Letter-frequency b/Lang/REXX/Letter-frequency new file mode 120000 index 0000000000..2da76da2fd --- /dev/null +++ b/Lang/REXX/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/REXX \ No newline at end of file diff --git a/Lang/REXX/Levenshtein-distance b/Lang/REXX/Levenshtein-distance new file mode 120000 index 0000000000..de1726df1d --- /dev/null +++ b/Lang/REXX/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/REXX \ No newline at end of file diff --git a/Lang/REXX/Linear-congruential-generator b/Lang/REXX/Linear-congruential-generator new file mode 120000 index 0000000000..1c852b4c56 --- /dev/null +++ b/Lang/REXX/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/REXX \ No newline at end of file diff --git a/Lang/REXX/List-comprehensions b/Lang/REXX/List-comprehensions new file mode 120000 index 0000000000..b9173930e2 --- /dev/null +++ b/Lang/REXX/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/REXX \ No newline at end of file diff --git a/Lang/REXX/Literals-Floating-point b/Lang/REXX/Literals-Floating-point new file mode 120000 index 0000000000..8627fcb68a --- /dev/null +++ b/Lang/REXX/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/REXX \ No newline at end of file diff --git a/Lang/REXX/Literals-Integer b/Lang/REXX/Literals-Integer new file mode 120000 index 0000000000..1746a24050 --- /dev/null +++ b/Lang/REXX/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/REXX \ No newline at end of file diff --git a/Lang/REXX/Literals-String b/Lang/REXX/Literals-String new file mode 120000 index 0000000000..209175e931 --- /dev/null +++ b/Lang/REXX/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/REXX \ No newline at end of file diff --git a/Lang/REXX/Logical-operations b/Lang/REXX/Logical-operations new file mode 120000 index 0000000000..314fdb3ed5 --- /dev/null +++ b/Lang/REXX/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/REXX \ No newline at end of file diff --git a/Lang/REXX/Long-multiplication b/Lang/REXX/Long-multiplication new file mode 120000 index 0000000000..74d8d59f8e --- /dev/null +++ b/Lang/REXX/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/REXX \ No newline at end of file diff --git a/Lang/REXX/Longest-common-subsequence b/Lang/REXX/Longest-common-subsequence new file mode 120000 index 0000000000..d830f390c7 --- /dev/null +++ b/Lang/REXX/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Longest-string-challenge b/Lang/REXX/Longest-string-challenge new file mode 120000 index 0000000000..18db3e75ce --- /dev/null +++ b/Lang/REXX/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/REXX \ No newline at end of file diff --git a/Lang/REXX/Look-and-say-sequence b/Lang/REXX/Look-and-say-sequence new file mode 120000 index 0000000000..59b16f0259 --- /dev/null +++ b/Lang/REXX/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Loop-over-multiple-arrays-simultaneously b/Lang/REXX/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..41bb59ba13 --- /dev/null +++ b/Lang/REXX/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Break b/Lang/REXX/Loops-Break new file mode 120000 index 0000000000..04a31a5a84 --- /dev/null +++ b/Lang/REXX/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Continue b/Lang/REXX/Loops-Continue new file mode 120000 index 0000000000..a06c87896f --- /dev/null +++ b/Lang/REXX/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Do-while b/Lang/REXX/Loops-Do-while new file mode 120000 index 0000000000..420be6ebdc --- /dev/null +++ b/Lang/REXX/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Downward-for b/Lang/REXX/Loops-Downward-for new file mode 120000 index 0000000000..7176e74478 --- /dev/null +++ b/Lang/REXX/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-For b/Lang/REXX/Loops-For new file mode 120000 index 0000000000..4272cd1452 --- /dev/null +++ b/Lang/REXX/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-For-with-a-specified-step b/Lang/REXX/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..79fab80b80 --- /dev/null +++ b/Lang/REXX/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Foreach b/Lang/REXX/Loops-Foreach new file mode 120000 index 0000000000..72e2394779 --- /dev/null +++ b/Lang/REXX/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Infinite b/Lang/REXX/Loops-Infinite new file mode 120000 index 0000000000..436067864f --- /dev/null +++ b/Lang/REXX/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-N-plus-one-half b/Lang/REXX/Loops-N-plus-one-half new file mode 120000 index 0000000000..00cb181844 --- /dev/null +++ b/Lang/REXX/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-Nested b/Lang/REXX/Loops-Nested new file mode 120000 index 0000000000..7d980aae58 --- /dev/null +++ b/Lang/REXX/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/REXX \ No newline at end of file diff --git a/Lang/REXX/Loops-While b/Lang/REXX/Loops-While new file mode 120000 index 0000000000..9cbc048e2f --- /dev/null +++ b/Lang/REXX/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/REXX \ No newline at end of file diff --git a/Lang/REXX/Lucas-Lehmer-test b/Lang/REXX/Lucas-Lehmer-test new file mode 120000 index 0000000000..7766440d8d --- /dev/null +++ b/Lang/REXX/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/REXX \ No newline at end of file diff --git a/Lang/REXX/Luhn-test-of-credit-card-numbers b/Lang/REXX/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..3ac0810fe8 --- /dev/null +++ b/Lang/REXX/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/MD5 b/Lang/REXX/MD5 new file mode 120000 index 0000000000..9e1d0b0a71 --- /dev/null +++ b/Lang/REXX/MD5 @@ -0,0 +1 @@ +../../Task/MD5/REXX \ No newline at end of file diff --git a/Lang/REXX/MD5-Implementation b/Lang/REXX/MD5-Implementation new file mode 120000 index 0000000000..084ab552c0 --- /dev/null +++ b/Lang/REXX/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/REXX \ No newline at end of file diff --git a/Lang/REXX/Mad-Libs b/Lang/REXX/Mad-Libs new file mode 120000 index 0000000000..32746d9d13 --- /dev/null +++ b/Lang/REXX/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/REXX \ No newline at end of file diff --git a/Lang/REXX/Main-step-of-GOST-28147-89 b/Lang/REXX/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..00b40366fd --- /dev/null +++ b/Lang/REXX/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/REXX \ No newline at end of file diff --git a/Lang/REXX/Map-range b/Lang/REXX/Map-range new file mode 120000 index 0000000000..160affbfe6 --- /dev/null +++ b/Lang/REXX/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/REXX \ No newline at end of file diff --git a/Lang/REXX/Matrix-multiplication b/Lang/REXX/Matrix-multiplication new file mode 120000 index 0000000000..f9f3dffc66 --- /dev/null +++ b/Lang/REXX/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/REXX \ No newline at end of file diff --git a/Lang/REXX/Matrix-transposition b/Lang/REXX/Matrix-transposition new file mode 120000 index 0000000000..79c393cb0c --- /dev/null +++ b/Lang/REXX/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/REXX \ No newline at end of file diff --git a/Lang/REXX/Maze-generation b/Lang/REXX/Maze-generation new file mode 120000 index 0000000000..e27d880038 --- /dev/null +++ b/Lang/REXX/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/REXX \ No newline at end of file diff --git a/Lang/REXX/Memory-allocation b/Lang/REXX/Memory-allocation new file mode 120000 index 0000000000..d33f93b609 --- /dev/null +++ b/Lang/REXX/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/REXX \ No newline at end of file diff --git a/Lang/REXX/Memory-layout-of-a-data-structure b/Lang/REXX/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..2d20e15117 --- /dev/null +++ b/Lang/REXX/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/REXX \ No newline at end of file diff --git a/Lang/REXX/Menu b/Lang/REXX/Menu new file mode 120000 index 0000000000..538408f757 --- /dev/null +++ b/Lang/REXX/Menu @@ -0,0 +1 @@ +../../Task/Menu/REXX \ No newline at end of file diff --git a/Lang/REXX/Metaprogramming b/Lang/REXX/Metaprogramming new file mode 120000 index 0000000000..6dda94535d --- /dev/null +++ b/Lang/REXX/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/REXX \ No newline at end of file diff --git a/Lang/REXX/Metronome b/Lang/REXX/Metronome new file mode 120000 index 0000000000..e101cf676b --- /dev/null +++ b/Lang/REXX/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/REXX \ No newline at end of file diff --git a/Lang/REXX/Middle-three-digits b/Lang/REXX/Middle-three-digits new file mode 120000 index 0000000000..e85396519e --- /dev/null +++ b/Lang/REXX/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/REXX \ No newline at end of file diff --git a/Lang/REXX/Miller-Rabin-primality-test b/Lang/REXX/Miller-Rabin-primality-test new file mode 120000 index 0000000000..6b9607754b --- /dev/null +++ b/Lang/REXX/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/REXX \ No newline at end of file diff --git a/Lang/REXX/Modular-exponentiation b/Lang/REXX/Modular-exponentiation new file mode 120000 index 0000000000..68cd17af9d --- /dev/null +++ b/Lang/REXX/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/REXX \ No newline at end of file diff --git a/Lang/REXX/Modular-inverse b/Lang/REXX/Modular-inverse new file mode 120000 index 0000000000..671de31f53 --- /dev/null +++ b/Lang/REXX/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/REXX \ No newline at end of file diff --git a/Lang/REXX/Monte-Carlo-methods b/Lang/REXX/Monte-Carlo-methods new file mode 120000 index 0000000000..bc7e99db81 --- /dev/null +++ b/Lang/REXX/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/REXX \ No newline at end of file diff --git a/Lang/REXX/Multifactorial b/Lang/REXX/Multifactorial new file mode 120000 index 0000000000..d0b802a067 --- /dev/null +++ b/Lang/REXX/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/REXX \ No newline at end of file diff --git a/Lang/REXX/Multiplication-tables b/Lang/REXX/Multiplication-tables new file mode 120000 index 0000000000..e171e3fe0a --- /dev/null +++ b/Lang/REXX/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/REXX \ No newline at end of file diff --git a/Lang/REXX/Multisplit b/Lang/REXX/Multisplit new file mode 120000 index 0000000000..ea2fcb8032 --- /dev/null +++ b/Lang/REXX/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/REXX \ No newline at end of file diff --git a/Lang/REXX/Mutual-recursion b/Lang/REXX/Mutual-recursion new file mode 120000 index 0000000000..251e1805f0 --- /dev/null +++ b/Lang/REXX/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/REXX \ No newline at end of file diff --git a/Lang/Racket/Arbitrary-precision-integers-included b/Lang/Racket/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..6c3f0607cf --- /dev/null +++ b/Lang/Racket/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Racket \ No newline at end of file diff --git a/Lang/Racket/Factorial b/Lang/Racket/Factorial new file mode 120000 index 0000000000..fe5b6c3ec1 --- /dev/null +++ b/Lang/Racket/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Racket \ No newline at end of file diff --git a/Lang/Racket/Fibonacci-sequence b/Lang/Racket/Fibonacci-sequence new file mode 120000 index 0000000000..f4dd0c4479 --- /dev/null +++ b/Lang/Racket/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Racket \ No newline at end of file diff --git a/Lang/Racket/File-modification-time b/Lang/Racket/File-modification-time new file mode 120000 index 0000000000..99233af911 --- /dev/null +++ b/Lang/Racket/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Racket \ No newline at end of file diff --git a/Lang/Racket/First-class-functions b/Lang/Racket/First-class-functions new file mode 120000 index 0000000000..4e487f3171 --- /dev/null +++ b/Lang/Racket/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Racket \ No newline at end of file diff --git a/Lang/Racket/Flatten-a-list b/Lang/Racket/Flatten-a-list new file mode 120000 index 0000000000..9a04c06e4c --- /dev/null +++ b/Lang/Racket/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Racket \ No newline at end of file diff --git a/Lang/Racket/Floyds-triangle b/Lang/Racket/Floyds-triangle new file mode 120000 index 0000000000..112c48238a --- /dev/null +++ b/Lang/Racket/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Racket \ No newline at end of file diff --git a/Lang/Racket/Function-composition b/Lang/Racket/Function-composition new file mode 120000 index 0000000000..e5365f3e5b --- /dev/null +++ b/Lang/Racket/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Racket \ No newline at end of file diff --git a/Lang/Racket/Function-definition b/Lang/Racket/Function-definition new file mode 120000 index 0000000000..42a6878e8e --- /dev/null +++ b/Lang/Racket/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Racket \ No newline at end of file diff --git a/Lang/Racket/Generator-Exponential b/Lang/Racket/Generator-Exponential new file mode 120000 index 0000000000..d6a33edd44 --- /dev/null +++ b/Lang/Racket/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Racket \ No newline at end of file diff --git a/Lang/Racket/Generic-swap b/Lang/Racket/Generic-swap new file mode 120000 index 0000000000..01651fde78 --- /dev/null +++ b/Lang/Racket/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Racket \ No newline at end of file diff --git a/Lang/Racket/Gray-code b/Lang/Racket/Gray-code new file mode 120000 index 0000000000..f189af95c8 --- /dev/null +++ b/Lang/Racket/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Racket \ No newline at end of file diff --git a/Lang/Racket/Greatest-common-divisor b/Lang/Racket/Greatest-common-divisor new file mode 120000 index 0000000000..200edea98f --- /dev/null +++ b/Lang/Racket/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Racket \ No newline at end of file diff --git a/Lang/Racket/Greatest-element-of-a-list b/Lang/Racket/Greatest-element-of-a-list new file mode 120000 index 0000000000..7e036701af --- /dev/null +++ b/Lang/Racket/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Racket \ No newline at end of file diff --git a/Lang/Racket/Greatest-subsequential-sum b/Lang/Racket/Greatest-subsequential-sum new file mode 120000 index 0000000000..e07c05dff2 --- /dev/null +++ b/Lang/Racket/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Racket \ No newline at end of file diff --git a/Lang/Racket/Greyscale-bars-Display b/Lang/Racket/Greyscale-bars-Display new file mode 120000 index 0000000000..4479069318 --- /dev/null +++ b/Lang/Racket/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Racket \ No newline at end of file diff --git a/Lang/Racket/HTTP b/Lang/Racket/HTTP new file mode 120000 index 0000000000..d43502635d --- /dev/null +++ b/Lang/Racket/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Racket \ No newline at end of file diff --git a/Lang/Racket/HTTPS b/Lang/Racket/HTTPS new file mode 120000 index 0000000000..77dc92e719 --- /dev/null +++ b/Lang/Racket/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Racket \ No newline at end of file diff --git a/Lang/Racket/HTTPS-Authenticated b/Lang/Racket/HTTPS-Authenticated new file mode 120000 index 0000000000..b3f5aa2216 --- /dev/null +++ b/Lang/Racket/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Racket \ No newline at end of file diff --git a/Lang/Racket/Hailstone-sequence b/Lang/Racket/Hailstone-sequence new file mode 120000 index 0000000000..22ffc915d0 --- /dev/null +++ b/Lang/Racket/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Racket \ No newline at end of file diff --git a/Lang/Racket/Hamming-numbers b/Lang/Racket/Hamming-numbers new file mode 120000 index 0000000000..af8ca4d82a --- /dev/null +++ b/Lang/Racket/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Racket \ No newline at end of file diff --git a/Lang/Racket/Harshad-or-Niven-series b/Lang/Racket/Harshad-or-Niven-series new file mode 120000 index 0000000000..348f9f26af --- /dev/null +++ b/Lang/Racket/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Racket \ No newline at end of file diff --git a/Lang/Racket/Hash-from-two-arrays b/Lang/Racket/Hash-from-two-arrays new file mode 120000 index 0000000000..952346c7d1 --- /dev/null +++ b/Lang/Racket/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Racket \ No newline at end of file diff --git a/Lang/Racket/Haversine-formula b/Lang/Racket/Haversine-formula new file mode 120000 index 0000000000..1053d24019 --- /dev/null +++ b/Lang/Racket/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Racket \ No newline at end of file diff --git a/Lang/Racket/Hello-world-Graphical b/Lang/Racket/Hello-world-Graphical new file mode 120000 index 0000000000..d82db51279 --- /dev/null +++ b/Lang/Racket/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Racket \ No newline at end of file diff --git a/Lang/Racket/Hello-world-Standard-error b/Lang/Racket/Hello-world-Standard-error new file mode 120000 index 0000000000..ca0c69cd21 --- /dev/null +++ b/Lang/Racket/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Racket \ No newline at end of file diff --git a/Lang/Racket/Hello-world-Text b/Lang/Racket/Hello-world-Text new file mode 120000 index 0000000000..b971e048df --- /dev/null +++ b/Lang/Racket/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Racket \ No newline at end of file diff --git a/Lang/Racket/Hello-world-Web-server b/Lang/Racket/Hello-world-Web-server new file mode 120000 index 0000000000..44d7b20f40 --- /dev/null +++ b/Lang/Racket/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Racket \ No newline at end of file diff --git a/Lang/Racket/Here-document b/Lang/Racket/Here-document new file mode 120000 index 0000000000..933a5b9d8d --- /dev/null +++ b/Lang/Racket/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Racket \ No newline at end of file diff --git a/Lang/Racket/Higher-order-functions b/Lang/Racket/Higher-order-functions new file mode 120000 index 0000000000..ef850ff793 --- /dev/null +++ b/Lang/Racket/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Racket \ No newline at end of file diff --git a/Lang/Racket/History-variables b/Lang/Racket/History-variables new file mode 120000 index 0000000000..52ad372aee --- /dev/null +++ b/Lang/Racket/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Racket \ No newline at end of file diff --git a/Lang/Racket/Hofstadter-Q-sequence b/Lang/Racket/Hofstadter-Q-sequence new file mode 120000 index 0000000000..3011455830 --- /dev/null +++ b/Lang/Racket/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Racket \ No newline at end of file diff --git a/Lang/Racket/Horizontal-sundial-calculations b/Lang/Racket/Horizontal-sundial-calculations new file mode 120000 index 0000000000..fee13ae2ba --- /dev/null +++ b/Lang/Racket/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Racket \ No newline at end of file diff --git a/Lang/Racket/Horners-rule-for-polynomial-evaluation b/Lang/Racket/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..9c5098358b --- /dev/null +++ b/Lang/Racket/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Racket \ No newline at end of file diff --git a/Lang/Racket/Host-introspection b/Lang/Racket/Host-introspection new file mode 120000 index 0000000000..6ed217de25 --- /dev/null +++ b/Lang/Racket/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Racket \ No newline at end of file diff --git a/Lang/Racket/Hostname b/Lang/Racket/Hostname new file mode 120000 index 0000000000..2c50d7c256 --- /dev/null +++ b/Lang/Racket/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Racket \ No newline at end of file diff --git a/Lang/Racket/Huffman-coding b/Lang/Racket/Huffman-coding new file mode 120000 index 0000000000..bfc89cbf76 --- /dev/null +++ b/Lang/Racket/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Racket \ No newline at end of file diff --git a/Lang/Racket/Identity-matrix b/Lang/Racket/Identity-matrix new file mode 120000 index 0000000000..cf17899a9d --- /dev/null +++ b/Lang/Racket/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Racket \ No newline at end of file diff --git a/Lang/Racket/Include-a-file b/Lang/Racket/Include-a-file new file mode 120000 index 0000000000..b6060b07d5 --- /dev/null +++ b/Lang/Racket/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Racket \ No newline at end of file diff --git a/Lang/Racket/Increment-a-numerical-string b/Lang/Racket/Increment-a-numerical-string new file mode 120000 index 0000000000..f1da5ba331 --- /dev/null +++ b/Lang/Racket/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Racket \ No newline at end of file diff --git a/Lang/Racket/Inheritance-Multiple b/Lang/Racket/Inheritance-Multiple new file mode 120000 index 0000000000..4312a61a75 --- /dev/null +++ b/Lang/Racket/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Racket \ No newline at end of file diff --git a/Lang/Racket/Inheritance-Single b/Lang/Racket/Inheritance-Single new file mode 120000 index 0000000000..9537e506de --- /dev/null +++ b/Lang/Racket/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Racket \ No newline at end of file diff --git a/Lang/Racket/Input-loop b/Lang/Racket/Input-loop new file mode 120000 index 0000000000..57243dc62a --- /dev/null +++ b/Lang/Racket/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Racket \ No newline at end of file diff --git a/Lang/Racket/Integer-sequence b/Lang/Racket/Integer-sequence new file mode 120000 index 0000000000..774d669acb --- /dev/null +++ b/Lang/Racket/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Racket \ No newline at end of file diff --git a/Lang/Racket/Interactive-programming b/Lang/Racket/Interactive-programming new file mode 120000 index 0000000000..d59e6de249 --- /dev/null +++ b/Lang/Racket/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Racket \ No newline at end of file diff --git a/Lang/Racket/Introspection b/Lang/Racket/Introspection new file mode 120000 index 0000000000..5d275b1194 --- /dev/null +++ b/Lang/Racket/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Racket \ No newline at end of file diff --git a/Lang/Racket/Inverted-syntax b/Lang/Racket/Inverted-syntax new file mode 120000 index 0000000000..b597988981 --- /dev/null +++ b/Lang/Racket/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Racket \ No newline at end of file diff --git a/Lang/Racket/Jensens-Device b/Lang/Racket/Jensens-Device new file mode 120000 index 0000000000..e99b603854 --- /dev/null +++ b/Lang/Racket/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Racket \ No newline at end of file diff --git a/Lang/Racket/Kaprekar-numbers b/Lang/Racket/Kaprekar-numbers new file mode 120000 index 0000000000..475ebe05da --- /dev/null +++ b/Lang/Racket/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Racket \ No newline at end of file diff --git a/Lang/Racket/Knuths-algorithm-S b/Lang/Racket/Knuths-algorithm-S new file mode 120000 index 0000000000..3378677c51 --- /dev/null +++ b/Lang/Racket/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Racket \ No newline at end of file diff --git a/Lang/Racket/LU-decomposition b/Lang/Racket/LU-decomposition new file mode 120000 index 0000000000..5adc6247a5 --- /dev/null +++ b/Lang/Racket/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Racket \ No newline at end of file diff --git a/Lang/Racket/LZW-compression b/Lang/Racket/LZW-compression new file mode 120000 index 0000000000..7995fc8d47 --- /dev/null +++ b/Lang/Racket/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Racket \ No newline at end of file diff --git a/Lang/Racket/Langtons-ant b/Lang/Racket/Langtons-ant new file mode 120000 index 0000000000..f1a13c0495 --- /dev/null +++ b/Lang/Racket/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Racket \ No newline at end of file diff --git a/Lang/Racket/Leap-year b/Lang/Racket/Leap-year new file mode 120000 index 0000000000..f1dd7d6f84 --- /dev/null +++ b/Lang/Racket/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Racket \ No newline at end of file diff --git a/Lang/Racket/Letter-frequency b/Lang/Racket/Letter-frequency new file mode 120000 index 0000000000..e917e1eebe --- /dev/null +++ b/Lang/Racket/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Racket \ No newline at end of file diff --git a/Lang/Racket/Levenshtein-distance b/Lang/Racket/Levenshtein-distance new file mode 120000 index 0000000000..d0af75042c --- /dev/null +++ b/Lang/Racket/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Racket \ No newline at end of file diff --git a/Lang/Racket/Linear-congruential-generator b/Lang/Racket/Linear-congruential-generator new file mode 120000 index 0000000000..9364df5c8b --- /dev/null +++ b/Lang/Racket/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Racket \ No newline at end of file diff --git a/Lang/Racket/List-comprehensions b/Lang/Racket/List-comprehensions new file mode 120000 index 0000000000..2a91c16f42 --- /dev/null +++ b/Lang/Racket/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Racket \ No newline at end of file diff --git a/Lang/Racket/Literals-Integer b/Lang/Racket/Literals-Integer new file mode 120000 index 0000000000..48da3836ce --- /dev/null +++ b/Lang/Racket/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Racket \ No newline at end of file diff --git a/Lang/Racket/Longest-common-subsequence b/Lang/Racket/Longest-common-subsequence new file mode 120000 index 0000000000..fb8e25f064 --- /dev/null +++ b/Lang/Racket/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Racket \ No newline at end of file diff --git a/Lang/Racket/Loop-over-multiple-arrays-simultaneously b/Lang/Racket/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..bfb0cba732 --- /dev/null +++ b/Lang/Racket/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Break b/Lang/Racket/Loops-Break new file mode 120000 index 0000000000..171d0a841e --- /dev/null +++ b/Lang/Racket/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Continue b/Lang/Racket/Loops-Continue new file mode 120000 index 0000000000..0703eacfdf --- /dev/null +++ b/Lang/Racket/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Do-while b/Lang/Racket/Loops-Do-while new file mode 120000 index 0000000000..04f2ab9061 --- /dev/null +++ b/Lang/Racket/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Downward-for b/Lang/Racket/Loops-Downward-for new file mode 120000 index 0000000000..322f515724 --- /dev/null +++ b/Lang/Racket/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-For b/Lang/Racket/Loops-For new file mode 120000 index 0000000000..7f2bdefd6a --- /dev/null +++ b/Lang/Racket/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-For-with-a-specified-step b/Lang/Racket/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..2a2509bdb4 --- /dev/null +++ b/Lang/Racket/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Foreach b/Lang/Racket/Loops-Foreach new file mode 120000 index 0000000000..d233093533 --- /dev/null +++ b/Lang/Racket/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Infinite b/Lang/Racket/Loops-Infinite new file mode 120000 index 0000000000..ec114b37bb --- /dev/null +++ b/Lang/Racket/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-Nested b/Lang/Racket/Loops-Nested new file mode 120000 index 0000000000..7c0c17aad2 --- /dev/null +++ b/Lang/Racket/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Racket \ No newline at end of file diff --git a/Lang/Racket/Loops-While b/Lang/Racket/Loops-While new file mode 120000 index 0000000000..1f24f6218d --- /dev/null +++ b/Lang/Racket/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Racket \ No newline at end of file diff --git a/Lang/Racket/Lucas-Lehmer-test b/Lang/Racket/Lucas-Lehmer-test new file mode 120000 index 0000000000..2d278e951c --- /dev/null +++ b/Lang/Racket/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Racket \ No newline at end of file diff --git a/Lang/Racket/MD5 b/Lang/Racket/MD5 new file mode 120000 index 0000000000..5df8042fa4 --- /dev/null +++ b/Lang/Racket/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Racket \ No newline at end of file diff --git a/Lang/Racket/Man-or-boy-test b/Lang/Racket/Man-or-boy-test new file mode 120000 index 0000000000..b854dd8489 --- /dev/null +++ b/Lang/Racket/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Racket \ No newline at end of file diff --git a/Lang/Racket/Mandelbrot-set b/Lang/Racket/Mandelbrot-set new file mode 120000 index 0000000000..a6f6e7d15c --- /dev/null +++ b/Lang/Racket/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Racket \ No newline at end of file diff --git a/Lang/Racket/Matrix-multiplication b/Lang/Racket/Matrix-multiplication new file mode 120000 index 0000000000..d339840ee8 --- /dev/null +++ b/Lang/Racket/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Racket \ No newline at end of file diff --git a/Lang/Racket/Matrix-transposition b/Lang/Racket/Matrix-transposition new file mode 120000 index 0000000000..2dc0795329 --- /dev/null +++ b/Lang/Racket/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Racket \ No newline at end of file diff --git a/Lang/Racket/Middle-three-digits b/Lang/Racket/Middle-three-digits new file mode 120000 index 0000000000..cfc0b59524 --- /dev/null +++ b/Lang/Racket/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Racket \ No newline at end of file diff --git a/Lang/Racket/Monte-Carlo-methods b/Lang/Racket/Monte-Carlo-methods new file mode 120000 index 0000000000..035ee40223 --- /dev/null +++ b/Lang/Racket/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Racket \ No newline at end of file diff --git a/Lang/Racket/Mouse-position b/Lang/Racket/Mouse-position new file mode 120000 index 0000000000..c4b2bca702 --- /dev/null +++ b/Lang/Racket/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Racket \ No newline at end of file diff --git a/Lang/Racket/Multifactorial b/Lang/Racket/Multifactorial new file mode 120000 index 0000000000..1c203d5f29 --- /dev/null +++ b/Lang/Racket/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Racket \ No newline at end of file diff --git a/Lang/Racket/Multiple-distinct-objects b/Lang/Racket/Multiple-distinct-objects new file mode 120000 index 0000000000..2254448234 --- /dev/null +++ b/Lang/Racket/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Racket \ No newline at end of file diff --git a/Lang/Ruby/24-game-Solve b/Lang/Ruby/24-game-Solve new file mode 120000 index 0000000000..6b0bcd92fb --- /dev/null +++ b/Lang/Ruby/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arbitrary-precision-integers-included b/Lang/Ruby/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..565a808afb --- /dev/null +++ b/Lang/Ruby/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N b/Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N new file mode 120000 index 0000000000..2e751f5f43 --- /dev/null +++ b/Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Factorial b/Lang/Ruby/Factorial new file mode 120000 index 0000000000..880c32b2a6 --- /dev/null +++ b/Lang/Ruby/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Factors-of-a-Mersenne-number b/Lang/Ruby/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..80b1f913c8 --- /dev/null +++ b/Lang/Ruby/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Factors-of-an-integer b/Lang/Ruby/Factors-of-an-integer new file mode 120000 index 0000000000..7351a09826 --- /dev/null +++ b/Lang/Ruby/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Fibonacci-n-step-number-sequences b/Lang/Ruby/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..2a49410598 --- /dev/null +++ b/Lang/Ruby/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Fibonacci-sequence b/Lang/Ruby/Fibonacci-sequence new file mode 120000 index 0000000000..eaf28d24d8 --- /dev/null +++ b/Lang/Ruby/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/File-IO b/Lang/Ruby/File-IO new file mode 120000 index 0000000000..cbe2085f9f --- /dev/null +++ b/Lang/Ruby/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Ruby \ No newline at end of file diff --git a/Lang/Ruby/File-modification-time b/Lang/Ruby/File-modification-time new file mode 120000 index 0000000000..de305b9a5a --- /dev/null +++ b/Lang/Ruby/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Ruby \ No newline at end of file diff --git a/Lang/Ruby/File-size b/Lang/Ruby/File-size new file mode 120000 index 0000000000..353c5c229d --- /dev/null +++ b/Lang/Ruby/File-size @@ -0,0 +1 @@ +../../Task/File-size/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Filter b/Lang/Ruby/Filter new file mode 120000 index 0000000000..7ae6439ffa --- /dev/null +++ b/Lang/Ruby/Filter @@ -0,0 +1 @@ +../../Task/Filter/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Find-common-directory-path b/Lang/Ruby/Find-common-directory-path new file mode 120000 index 0000000000..00492c5419 --- /dev/null +++ b/Lang/Ruby/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/Ruby/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..48faafdc5e --- /dev/null +++ b/Lang/Ruby/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Find-limit-of-recursion b/Lang/Ruby/Find-limit-of-recursion new file mode 120000 index 0000000000..6891d2f590 --- /dev/null +++ b/Lang/Ruby/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Find-the-missing-permutation b/Lang/Ruby/Find-the-missing-permutation new file mode 120000 index 0000000000..0a53b4f48b --- /dev/null +++ b/Lang/Ruby/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/First-class-environments b/Lang/Ruby/First-class-environments new file mode 120000 index 0000000000..7993ad52ee --- /dev/null +++ b/Lang/Ruby/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/Ruby \ No newline at end of file diff --git a/Lang/Ruby/First-class-functions b/Lang/Ruby/First-class-functions new file mode 120000 index 0000000000..11cbb2aa52 --- /dev/null +++ b/Lang/Ruby/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/First-class-functions-Use-numbers-analogously b/Lang/Ruby/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..c1f0ba8825 --- /dev/null +++ b/Lang/Ruby/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Five-weekends b/Lang/Ruby/Five-weekends new file mode 120000 index 0000000000..f3271bd26d --- /dev/null +++ b/Lang/Ruby/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Flatten-a-list b/Lang/Ruby/Flatten-a-list new file mode 120000 index 0000000000..c19e04bb0b --- /dev/null +++ b/Lang/Ruby/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Flow-control-structures b/Lang/Ruby/Flow-control-structures new file mode 120000 index 0000000000..3481cfc599 --- /dev/null +++ b/Lang/Ruby/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Floyds-triangle b/Lang/Ruby/Floyds-triangle new file mode 120000 index 0000000000..839346d340 --- /dev/null +++ b/Lang/Ruby/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Fork b/Lang/Ruby/Fork new file mode 120000 index 0000000000..138b0f4ed5 --- /dev/null +++ b/Lang/Ruby/Fork @@ -0,0 +1 @@ +../../Task/Fork/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Formatted-numeric-output b/Lang/Ruby/Formatted-numeric-output new file mode 120000 index 0000000000..4a6edb0ce4 --- /dev/null +++ b/Lang/Ruby/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Forward-difference b/Lang/Ruby/Forward-difference new file mode 120000 index 0000000000..4b54400393 --- /dev/null +++ b/Lang/Ruby/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Four-bit-adder b/Lang/Ruby/Four-bit-adder new file mode 120000 index 0000000000..dcb2e64405 --- /dev/null +++ b/Lang/Ruby/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Fractal-tree b/Lang/Ruby/Fractal-tree new file mode 120000 index 0000000000..50b6390d16 --- /dev/null +++ b/Lang/Ruby/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Function-composition b/Lang/Ruby/Function-composition new file mode 120000 index 0000000000..304b6201a4 --- /dev/null +++ b/Lang/Ruby/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Function-definition b/Lang/Ruby/Function-definition new file mode 120000 index 0000000000..8e7ca7f22b --- /dev/null +++ b/Lang/Ruby/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/GUI-component-interaction b/Lang/Ruby/GUI-component-interaction new file mode 120000 index 0000000000..0831d78a68 --- /dev/null +++ b/Lang/Ruby/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Ruby \ No newline at end of file diff --git a/Lang/Ruby/GUI-enabling-disabling-of-controls b/Lang/Ruby/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..d07104904b --- /dev/null +++ b/Lang/Ruby/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Galton-box-animation b/Lang/Ruby/Galton-box-animation new file mode 120000 index 0000000000..52867976dc --- /dev/null +++ b/Lang/Ruby/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Gamma-function b/Lang/Ruby/Gamma-function new file mode 120000 index 0000000000..6fdf47153b --- /dev/null +++ b/Lang/Ruby/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Generator-Exponential b/Lang/Ruby/Generator-Exponential new file mode 120000 index 0000000000..be6ebb412f --- /dev/null +++ b/Lang/Ruby/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Generic-swap b/Lang/Ruby/Generic-swap new file mode 120000 index 0000000000..2b545d4589 --- /dev/null +++ b/Lang/Ruby/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Gray-code b/Lang/Ruby/Gray-code new file mode 120000 index 0000000000..15698af1ac --- /dev/null +++ b/Lang/Ruby/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Grayscale-image b/Lang/Ruby/Grayscale-image new file mode 120000 index 0000000000..c2005f18d3 --- /dev/null +++ b/Lang/Ruby/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Greatest-common-divisor b/Lang/Ruby/Greatest-common-divisor new file mode 120000 index 0000000000..688bd03845 --- /dev/null +++ b/Lang/Ruby/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Greatest-element-of-a-list b/Lang/Ruby/Greatest-element-of-a-list new file mode 120000 index 0000000000..dceded32d4 --- /dev/null +++ b/Lang/Ruby/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Greatest-subsequential-sum b/Lang/Ruby/Greatest-subsequential-sum new file mode 120000 index 0000000000..3feec2b8e6 --- /dev/null +++ b/Lang/Ruby/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Guess-the-number b/Lang/Ruby/Guess-the-number new file mode 120000 index 0000000000..c4a0106ea7 --- /dev/null +++ b/Lang/Ruby/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Guess-the-number-With-feedback b/Lang/Ruby/Guess-the-number-With-feedback new file mode 120000 index 0000000000..95ac1f8846 --- /dev/null +++ b/Lang/Ruby/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Guess-the-number-With-feedback-player b/Lang/Ruby/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..821cc0809f --- /dev/null +++ b/Lang/Ruby/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Ruby \ No newline at end of file diff --git a/Lang/Ruby/HTTP b/Lang/Ruby/HTTP new file mode 120000 index 0000000000..7e7023511a --- /dev/null +++ b/Lang/Ruby/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Ruby \ No newline at end of file diff --git a/Lang/Ruby/HTTPS b/Lang/Ruby/HTTPS new file mode 120000 index 0000000000..eee6af110c --- /dev/null +++ b/Lang/Ruby/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hailstone-sequence b/Lang/Ruby/Hailstone-sequence new file mode 120000 index 0000000000..42755e9b1d --- /dev/null +++ b/Lang/Ruby/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hamming-numbers b/Lang/Ruby/Hamming-numbers new file mode 120000 index 0000000000..43cf6714d1 --- /dev/null +++ b/Lang/Ruby/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Handle-a-signal b/Lang/Ruby/Handle-a-signal new file mode 120000 index 0000000000..a4fba8820e --- /dev/null +++ b/Lang/Ruby/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Happy-numbers b/Lang/Ruby/Happy-numbers new file mode 120000 index 0000000000..b8a3f1bc76 --- /dev/null +++ b/Lang/Ruby/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Harshad-or-Niven-series b/Lang/Ruby/Harshad-or-Niven-series new file mode 120000 index 0000000000..2eac826e07 --- /dev/null +++ b/Lang/Ruby/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hash-from-two-arrays b/Lang/Ruby/Hash-from-two-arrays new file mode 120000 index 0000000000..2026cf431b --- /dev/null +++ b/Lang/Ruby/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Haversine-formula b/Lang/Ruby/Haversine-formula new file mode 120000 index 0000000000..ac694a38b2 --- /dev/null +++ b/Lang/Ruby/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Graphical b/Lang/Ruby/Hello-world-Graphical new file mode 120000 index 0000000000..9d0e92908d --- /dev/null +++ b/Lang/Ruby/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Line-printer b/Lang/Ruby/Hello-world-Line-printer new file mode 120000 index 0000000000..ae8dccf9bf --- /dev/null +++ b/Lang/Ruby/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Newline-omission b/Lang/Ruby/Hello-world-Newline-omission new file mode 120000 index 0000000000..880142fc5c --- /dev/null +++ b/Lang/Ruby/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Standard-error b/Lang/Ruby/Hello-world-Standard-error new file mode 120000 index 0000000000..55fc8a7103 --- /dev/null +++ b/Lang/Ruby/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Text b/Lang/Ruby/Hello-world-Text new file mode 120000 index 0000000000..6a046a005a --- /dev/null +++ b/Lang/Ruby/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hello-world-Web-server b/Lang/Ruby/Hello-world-Web-server new file mode 120000 index 0000000000..716a9b757e --- /dev/null +++ b/Lang/Ruby/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Here-document b/Lang/Ruby/Here-document new file mode 120000 index 0000000000..ed0bb12f9f --- /dev/null +++ b/Lang/Ruby/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Higher-order-functions b/Lang/Ruby/Higher-order-functions new file mode 120000 index 0000000000..da1036b964 --- /dev/null +++ b/Lang/Ruby/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hofstadter-Conway-$10,000-sequence b/Lang/Ruby/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..de6ae7095f --- /dev/null +++ b/Lang/Ruby/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hofstadter-Figure-Figure-sequences b/Lang/Ruby/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..763887c70f --- /dev/null +++ b/Lang/Ruby/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hofstadter-Q-sequence b/Lang/Ruby/Hofstadter-Q-sequence new file mode 120000 index 0000000000..fe6285d2bf --- /dev/null +++ b/Lang/Ruby/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Holidays-related-to-Easter b/Lang/Ruby/Holidays-related-to-Easter new file mode 120000 index 0000000000..24c57bcfe0 --- /dev/null +++ b/Lang/Ruby/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Honeycombs b/Lang/Ruby/Honeycombs new file mode 120000 index 0000000000..249971d081 --- /dev/null +++ b/Lang/Ruby/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Horizontal-sundial-calculations b/Lang/Ruby/Horizontal-sundial-calculations new file mode 120000 index 0000000000..1410223e79 --- /dev/null +++ b/Lang/Ruby/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Horners-rule-for-polynomial-evaluation b/Lang/Ruby/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..1a64d6d9d9 --- /dev/null +++ b/Lang/Ruby/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Host-introspection b/Lang/Ruby/Host-introspection new file mode 120000 index 0000000000..a584ac8cec --- /dev/null +++ b/Lang/Ruby/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hostname b/Lang/Ruby/Hostname new file mode 120000 index 0000000000..8373c96042 --- /dev/null +++ b/Lang/Ruby/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Hough-transform b/Lang/Ruby/Hough-transform new file mode 120000 index 0000000000..b84cfb03b3 --- /dev/null +++ b/Lang/Ruby/Hough-transform @@ -0,0 +1 @@ +../../Task/Hough-transform/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Huffman-coding b/Lang/Ruby/Huffman-coding new file mode 120000 index 0000000000..0484f0c3e5 --- /dev/null +++ b/Lang/Ruby/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Identity-matrix b/Lang/Ruby/Identity-matrix new file mode 120000 index 0000000000..187a1a8903 --- /dev/null +++ b/Lang/Ruby/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Image-convolution b/Lang/Ruby/Image-convolution new file mode 120000 index 0000000000..6f9fe646ef --- /dev/null +++ b/Lang/Ruby/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Image-noise b/Lang/Ruby/Image-noise new file mode 120000 index 0000000000..8ddfa7d93d --- /dev/null +++ b/Lang/Ruby/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Include-a-file b/Lang/Ruby/Include-a-file new file mode 120000 index 0000000000..a79780d02d --- /dev/null +++ b/Lang/Ruby/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Increment-a-numerical-string b/Lang/Ruby/Increment-a-numerical-string new file mode 120000 index 0000000000..59f81e10c2 --- /dev/null +++ b/Lang/Ruby/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Inheritance-Multiple b/Lang/Ruby/Inheritance-Multiple new file mode 120000 index 0000000000..b7e45d1451 --- /dev/null +++ b/Lang/Ruby/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Inheritance-Single b/Lang/Ruby/Inheritance-Single new file mode 120000 index 0000000000..ede17d1b43 --- /dev/null +++ b/Lang/Ruby/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Input-loop b/Lang/Ruby/Input-loop new file mode 120000 index 0000000000..6f7edb4db0 --- /dev/null +++ b/Lang/Ruby/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Integer-comparison b/Lang/Ruby/Integer-comparison new file mode 120000 index 0000000000..fd769d5b2b --- /dev/null +++ b/Lang/Ruby/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Integer-sequence b/Lang/Ruby/Integer-sequence new file mode 120000 index 0000000000..06e9ade9d6 --- /dev/null +++ b/Lang/Ruby/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Interactive-programming b/Lang/Ruby/Interactive-programming new file mode 120000 index 0000000000..47de3b504e --- /dev/null +++ b/Lang/Ruby/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Introspection b/Lang/Ruby/Introspection new file mode 120000 index 0000000000..6cff93b00f --- /dev/null +++ b/Lang/Ruby/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Inverted-index b/Lang/Ruby/Inverted-index new file mode 120000 index 0000000000..2555a6fb63 --- /dev/null +++ b/Lang/Ruby/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Inverted-syntax b/Lang/Ruby/Inverted-syntax new file mode 120000 index 0000000000..e680c9e81d --- /dev/null +++ b/Lang/Ruby/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Jensens-Device b/Lang/Ruby/Jensens-Device new file mode 120000 index 0000000000..5921b4578f --- /dev/null +++ b/Lang/Ruby/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Josephus-problem b/Lang/Ruby/Josephus-problem new file mode 120000 index 0000000000..3280e4588a --- /dev/null +++ b/Lang/Ruby/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Kaprekar-numbers b/Lang/Ruby/Kaprekar-numbers new file mode 120000 index 0000000000..9b468e3cc8 --- /dev/null +++ b/Lang/Ruby/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Ruby/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..96c46b05de --- /dev/null +++ b/Lang/Ruby/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Ruby/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..43ebc1223c --- /dev/null +++ b/Lang/Ruby/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Keyboard-macros b/Lang/Ruby/Keyboard-macros new file mode 120000 index 0000000000..050f42ae86 --- /dev/null +++ b/Lang/Ruby/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Knapsack-problem-0-1 b/Lang/Ruby/Knapsack-problem-0-1 new file mode 120000 index 0000000000..09bcfa6705 --- /dev/null +++ b/Lang/Ruby/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Knapsack-problem-Unbounded b/Lang/Ruby/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..1dcbc92191 --- /dev/null +++ b/Lang/Ruby/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Knights-tour b/Lang/Ruby/Knights-tour new file mode 120000 index 0000000000..088a85d55b --- /dev/null +++ b/Lang/Ruby/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Knuths-algorithm-S b/Lang/Ruby/Knuths-algorithm-S new file mode 120000 index 0000000000..c9eef224cd --- /dev/null +++ b/Lang/Ruby/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Ruby \ No newline at end of file diff --git a/Lang/Ruby/LU-decomposition b/Lang/Ruby/LU-decomposition new file mode 120000 index 0000000000..89233e2668 --- /dev/null +++ b/Lang/Ruby/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/LZW-compression b/Lang/Ruby/LZW-compression new file mode 120000 index 0000000000..03453d9cda --- /dev/null +++ b/Lang/Ruby/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Langtons-ant b/Lang/Ruby/Langtons-ant new file mode 120000 index 0000000000..7a4d48f3e4 --- /dev/null +++ b/Lang/Ruby/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Largest-int-from-concatenated-ints b/Lang/Ruby/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..02c26dd1ef --- /dev/null +++ b/Lang/Ruby/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Last-Friday-of-each-month b/Lang/Ruby/Last-Friday-of-each-month new file mode 120000 index 0000000000..1081a82383 --- /dev/null +++ b/Lang/Ruby/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Last-letter-first-letter b/Lang/Ruby/Last-letter-first-letter new file mode 120000 index 0000000000..50b0492316 --- /dev/null +++ b/Lang/Ruby/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Leap-year b/Lang/Ruby/Leap-year new file mode 120000 index 0000000000..2fabce0fb5 --- /dev/null +++ b/Lang/Ruby/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Least-common-multiple b/Lang/Ruby/Least-common-multiple new file mode 120000 index 0000000000..d0405fbf58 --- /dev/null +++ b/Lang/Ruby/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Letter-frequency b/Lang/Ruby/Letter-frequency new file mode 120000 index 0000000000..b71d8683f1 --- /dev/null +++ b/Lang/Ruby/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Levenshtein-distance b/Lang/Ruby/Levenshtein-distance new file mode 120000 index 0000000000..69098d1626 --- /dev/null +++ b/Lang/Ruby/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Linear-congruential-generator b/Lang/Ruby/Linear-congruential-generator new file mode 120000 index 0000000000..69bd6afa97 --- /dev/null +++ b/Lang/Ruby/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Ruby \ No newline at end of file diff --git a/Lang/Ruby/List-comprehensions b/Lang/Ruby/List-comprehensions new file mode 120000 index 0000000000..f185dbff8f --- /dev/null +++ b/Lang/Ruby/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Literals-Integer b/Lang/Ruby/Literals-Integer new file mode 120000 index 0000000000..1e43e33f66 --- /dev/null +++ b/Lang/Ruby/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Literals-String b/Lang/Ruby/Literals-String new file mode 120000 index 0000000000..fa4e579f73 --- /dev/null +++ b/Lang/Ruby/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Logical-operations b/Lang/Ruby/Logical-operations new file mode 120000 index 0000000000..a3fd0080d2 --- /dev/null +++ b/Lang/Ruby/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Long-multiplication b/Lang/Ruby/Long-multiplication new file mode 120000 index 0000000000..4ea91b929b --- /dev/null +++ b/Lang/Ruby/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Longest-common-subsequence b/Lang/Ruby/Longest-common-subsequence new file mode 120000 index 0000000000..dbf5a28613 --- /dev/null +++ b/Lang/Ruby/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Longest-string-challenge b/Lang/Ruby/Longest-string-challenge new file mode 120000 index 0000000000..0180bc8cd8 --- /dev/null +++ b/Lang/Ruby/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Look-and-say-sequence b/Lang/Ruby/Look-and-say-sequence new file mode 120000 index 0000000000..0899c4ad4f --- /dev/null +++ b/Lang/Ruby/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loop-over-multiple-arrays-simultaneously b/Lang/Ruby/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..6ef55d36df --- /dev/null +++ b/Lang/Ruby/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Break b/Lang/Ruby/Loops-Break new file mode 120000 index 0000000000..d2acf31f46 --- /dev/null +++ b/Lang/Ruby/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Continue b/Lang/Ruby/Loops-Continue new file mode 120000 index 0000000000..7e07118ce8 --- /dev/null +++ b/Lang/Ruby/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Do-while b/Lang/Ruby/Loops-Do-while new file mode 120000 index 0000000000..0085c223c4 --- /dev/null +++ b/Lang/Ruby/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Downward-for b/Lang/Ruby/Loops-Downward-for new file mode 120000 index 0000000000..d4a7608da4 --- /dev/null +++ b/Lang/Ruby/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-For b/Lang/Ruby/Loops-For new file mode 120000 index 0000000000..cb5e042243 --- /dev/null +++ b/Lang/Ruby/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-For-with-a-specified-step b/Lang/Ruby/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..3a4511a8b5 --- /dev/null +++ b/Lang/Ruby/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Foreach b/Lang/Ruby/Loops-Foreach new file mode 120000 index 0000000000..7d1053b77a --- /dev/null +++ b/Lang/Ruby/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Infinite b/Lang/Ruby/Loops-Infinite new file mode 120000 index 0000000000..1642f91714 --- /dev/null +++ b/Lang/Ruby/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-N-plus-one-half b/Lang/Ruby/Loops-N-plus-one-half new file mode 120000 index 0000000000..597eabcd10 --- /dev/null +++ b/Lang/Ruby/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-Nested b/Lang/Ruby/Loops-Nested new file mode 120000 index 0000000000..a80ecfa960 --- /dev/null +++ b/Lang/Ruby/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Loops-While b/Lang/Ruby/Loops-While new file mode 120000 index 0000000000..3165e2a2c2 --- /dev/null +++ b/Lang/Ruby/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Lucas-Lehmer-test b/Lang/Ruby/Lucas-Lehmer-test new file mode 120000 index 0000000000..5d48f9a5fd --- /dev/null +++ b/Lang/Ruby/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Luhn-test-of-credit-card-numbers b/Lang/Ruby/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..6c59bc98ba --- /dev/null +++ b/Lang/Ruby/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/MD4 b/Lang/Ruby/MD4 new file mode 120000 index 0000000000..bc35f43104 --- /dev/null +++ b/Lang/Ruby/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Ruby \ No newline at end of file diff --git a/Lang/Ruby/MD5 b/Lang/Ruby/MD5 new file mode 120000 index 0000000000..f3f05c358f --- /dev/null +++ b/Lang/Ruby/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Mad-Libs b/Lang/Ruby/Mad-Libs new file mode 120000 index 0000000000..97543f5270 --- /dev/null +++ b/Lang/Ruby/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Man-or-boy-test b/Lang/Ruby/Man-or-boy-test new file mode 120000 index 0000000000..bddca4739b --- /dev/null +++ b/Lang/Ruby/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Mandelbrot-set b/Lang/Ruby/Mandelbrot-set new file mode 120000 index 0000000000..451214b867 --- /dev/null +++ b/Lang/Ruby/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Map-range b/Lang/Ruby/Map-range new file mode 120000 index 0000000000..761fa08db0 --- /dev/null +++ b/Lang/Ruby/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Matrix-multiplication b/Lang/Ruby/Matrix-multiplication new file mode 120000 index 0000000000..b6281235ad --- /dev/null +++ b/Lang/Ruby/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Matrix-transposition b/Lang/Ruby/Matrix-transposition new file mode 120000 index 0000000000..590c8ed5ff --- /dev/null +++ b/Lang/Ruby/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Maze-generation b/Lang/Ruby/Maze-generation new file mode 120000 index 0000000000..3b314e234b --- /dev/null +++ b/Lang/Ruby/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Maze-solving b/Lang/Ruby/Maze-solving new file mode 120000 index 0000000000..b6adb89e2d --- /dev/null +++ b/Lang/Ruby/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Median-filter b/Lang/Ruby/Median-filter new file mode 120000 index 0000000000..d6271e1d0d --- /dev/null +++ b/Lang/Ruby/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Memory-allocation b/Lang/Ruby/Memory-allocation new file mode 120000 index 0000000000..99b0276179 --- /dev/null +++ b/Lang/Ruby/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Memory-layout-of-a-data-structure b/Lang/Ruby/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..16122f8903 --- /dev/null +++ b/Lang/Ruby/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Menu b/Lang/Ruby/Menu new file mode 120000 index 0000000000..558d45ff18 --- /dev/null +++ b/Lang/Ruby/Menu @@ -0,0 +1 @@ +../../Task/Menu/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Metaprogramming b/Lang/Ruby/Metaprogramming new file mode 120000 index 0000000000..d12c2a1d44 --- /dev/null +++ b/Lang/Ruby/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Middle-three-digits b/Lang/Ruby/Middle-three-digits new file mode 120000 index 0000000000..73401b5af6 --- /dev/null +++ b/Lang/Ruby/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Miller-Rabin-primality-test b/Lang/Ruby/Miller-Rabin-primality-test new file mode 120000 index 0000000000..d7cbf43733 --- /dev/null +++ b/Lang/Ruby/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Minesweeper-game b/Lang/Ruby/Minesweeper-game new file mode 120000 index 0000000000..9a32be6212 --- /dev/null +++ b/Lang/Ruby/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Modular-exponentiation b/Lang/Ruby/Modular-exponentiation new file mode 120000 index 0000000000..718494f414 --- /dev/null +++ b/Lang/Ruby/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Monte-Carlo-methods b/Lang/Ruby/Monte-Carlo-methods new file mode 120000 index 0000000000..652bf2502c --- /dev/null +++ b/Lang/Ruby/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Monty-Hall-problem b/Lang/Ruby/Monty-Hall-problem new file mode 120000 index 0000000000..dcbfdac18c --- /dev/null +++ b/Lang/Ruby/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Morse-code b/Lang/Ruby/Morse-code new file mode 120000 index 0000000000..237ed63c1e --- /dev/null +++ b/Lang/Ruby/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Mouse-position b/Lang/Ruby/Mouse-position new file mode 120000 index 0000000000..7ce659f233 --- /dev/null +++ b/Lang/Ruby/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multifactorial b/Lang/Ruby/Multifactorial new file mode 120000 index 0000000000..fdf2000718 --- /dev/null +++ b/Lang/Ruby/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multiple-distinct-objects b/Lang/Ruby/Multiple-distinct-objects new file mode 120000 index 0000000000..2b2218109d --- /dev/null +++ b/Lang/Ruby/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multiple-regression b/Lang/Ruby/Multiple-regression new file mode 120000 index 0000000000..8cf667ed1c --- /dev/null +++ b/Lang/Ruby/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multiplication-tables b/Lang/Ruby/Multiplication-tables new file mode 120000 index 0000000000..833e8865b4 --- /dev/null +++ b/Lang/Ruby/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multiplicative-order b/Lang/Ruby/Multiplicative-order new file mode 120000 index 0000000000..616273823c --- /dev/null +++ b/Lang/Ruby/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Multisplit b/Lang/Ruby/Multisplit new file mode 120000 index 0000000000..8b5fe230d4 --- /dev/null +++ b/Lang/Ruby/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Mutex b/Lang/Ruby/Mutex new file mode 120000 index 0000000000..1de5f8656e --- /dev/null +++ b/Lang/Ruby/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Mutual-recursion b/Lang/Ruby/Mutual-recursion new file mode 120000 index 0000000000..8b6581c4ca --- /dev/null +++ b/Lang/Ruby/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Ruby \ No newline at end of file diff --git a/Lang/SNUSP/Fibonacci-sequence b/Lang/SNUSP/Fibonacci-sequence new file mode 120000 index 0000000000..f9d5dbb6c8 --- /dev/null +++ b/Lang/SNUSP/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Function-definition b/Lang/SNUSP/Function-definition new file mode 120000 index 0000000000..b1692cd33d --- /dev/null +++ b/Lang/SNUSP/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Hello-world-Text b/Lang/SNUSP/Hello-world-Text new file mode 120000 index 0000000000..6d23bda8a2 --- /dev/null +++ b/Lang/SNUSP/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Integer-comparison b/Lang/SNUSP/Integer-comparison new file mode 120000 index 0000000000..05583a0c94 --- /dev/null +++ b/Lang/SNUSP/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Loops-Downward-for b/Lang/SNUSP/Loops-Downward-for new file mode 120000 index 0000000000..8936027d62 --- /dev/null +++ b/Lang/SNUSP/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Loops-Infinite b/Lang/SNUSP/Loops-Infinite new file mode 120000 index 0000000000..f195f4db19 --- /dev/null +++ b/Lang/SNUSP/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Loops-N-plus-one-half b/Lang/SNUSP/Loops-N-plus-one-half new file mode 120000 index 0000000000..f63bfb29e7 --- /dev/null +++ b/Lang/SNUSP/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/SNUSP \ No newline at end of file diff --git a/Lang/SNUSP/Mutual-recursion b/Lang/SNUSP/Mutual-recursion new file mode 120000 index 0000000000..8d466373c8 --- /dev/null +++ b/Lang/SNUSP/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/SNUSP \ No newline at end of file diff --git a/Lang/Sather/Arbitrary-precision-integers-included b/Lang/Sather/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..7283ce66c0 --- /dev/null +++ b/Lang/Sather/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Sather \ No newline at end of file diff --git a/Lang/Sather/Factorial b/Lang/Sather/Factorial new file mode 120000 index 0000000000..6c676d2b04 --- /dev/null +++ b/Lang/Sather/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Sather \ No newline at end of file diff --git a/Lang/Sather/Factors-of-an-integer b/Lang/Sather/Factors-of-an-integer new file mode 120000 index 0000000000..b33b6b3d14 --- /dev/null +++ b/Lang/Sather/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Sather \ No newline at end of file diff --git a/Lang/Sather/Fibonacci-sequence b/Lang/Sather/Fibonacci-sequence new file mode 120000 index 0000000000..66aff69588 --- /dev/null +++ b/Lang/Sather/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Sather \ No newline at end of file diff --git a/Lang/Sather/Filter b/Lang/Sather/Filter new file mode 120000 index 0000000000..50b37563fa --- /dev/null +++ b/Lang/Sather/Filter @@ -0,0 +1 @@ +../../Task/Filter/Sather \ No newline at end of file diff --git a/Lang/Sather/Find-limit-of-recursion b/Lang/Sather/Find-limit-of-recursion new file mode 120000 index 0000000000..1a4f2947e6 --- /dev/null +++ b/Lang/Sather/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Sather \ No newline at end of file diff --git a/Lang/Sather/Formatted-numeric-output b/Lang/Sather/Formatted-numeric-output new file mode 120000 index 0000000000..1ba07fe862 --- /dev/null +++ b/Lang/Sather/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Sather \ No newline at end of file diff --git a/Lang/Sather/Four-bit-adder b/Lang/Sather/Four-bit-adder new file mode 120000 index 0000000000..90ed9ae8ad --- /dev/null +++ b/Lang/Sather/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Sather \ No newline at end of file diff --git a/Lang/Sather/Function-definition b/Lang/Sather/Function-definition new file mode 120000 index 0000000000..e0bfa633ca --- /dev/null +++ b/Lang/Sather/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Sather \ No newline at end of file diff --git a/Lang/Sather/Generic-swap b/Lang/Sather/Generic-swap new file mode 120000 index 0000000000..39111a4896 --- /dev/null +++ b/Lang/Sather/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Sather \ No newline at end of file diff --git a/Lang/Sather/Greatest-common-divisor b/Lang/Sather/Greatest-common-divisor new file mode 120000 index 0000000000..71093cc834 --- /dev/null +++ b/Lang/Sather/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Sather \ No newline at end of file diff --git a/Lang/Sather/Hash-from-two-arrays b/Lang/Sather/Hash-from-two-arrays new file mode 120000 index 0000000000..478ef38c63 --- /dev/null +++ b/Lang/Sather/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Sather \ No newline at end of file diff --git a/Lang/Sather/Hello-world-Standard-error b/Lang/Sather/Hello-world-Standard-error new file mode 120000 index 0000000000..ae939bbe92 --- /dev/null +++ b/Lang/Sather/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Sather \ No newline at end of file diff --git a/Lang/Sather/Hello-world-Text b/Lang/Sather/Hello-world-Text new file mode 120000 index 0000000000..6a75b6d0ca --- /dev/null +++ b/Lang/Sather/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Sather \ No newline at end of file diff --git a/Lang/Sather/Horizontal-sundial-calculations b/Lang/Sather/Horizontal-sundial-calculations new file mode 120000 index 0000000000..f1146d39d7 --- /dev/null +++ b/Lang/Sather/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Sather \ No newline at end of file diff --git a/Lang/Sather/Horners-rule-for-polynomial-evaluation b/Lang/Sather/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..5d05258e40 --- /dev/null +++ b/Lang/Sather/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Sather \ No newline at end of file diff --git a/Lang/Sather/Loop-over-multiple-arrays-simultaneously b/Lang/Sather/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..e5b7289715 --- /dev/null +++ b/Lang/Sather/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Break b/Lang/Sather/Loops-Break new file mode 120000 index 0000000000..094c9eca35 --- /dev/null +++ b/Lang/Sather/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Continue b/Lang/Sather/Loops-Continue new file mode 120000 index 0000000000..9200c76a93 --- /dev/null +++ b/Lang/Sather/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Do-while b/Lang/Sather/Loops-Do-while new file mode 120000 index 0000000000..257f9e7561 --- /dev/null +++ b/Lang/Sather/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Downward-for b/Lang/Sather/Loops-Downward-for new file mode 120000 index 0000000000..33f8e1ce50 --- /dev/null +++ b/Lang/Sather/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-For b/Lang/Sather/Loops-For new file mode 120000 index 0000000000..49853c0772 --- /dev/null +++ b/Lang/Sather/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-For-with-a-specified-step b/Lang/Sather/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..efe6084253 --- /dev/null +++ b/Lang/Sather/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Foreach b/Lang/Sather/Loops-Foreach new file mode 120000 index 0000000000..ab4e6d511b --- /dev/null +++ b/Lang/Sather/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Infinite b/Lang/Sather/Loops-Infinite new file mode 120000 index 0000000000..1210c9e226 --- /dev/null +++ b/Lang/Sather/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-Nested b/Lang/Sather/Loops-Nested new file mode 120000 index 0000000000..b67052cabc --- /dev/null +++ b/Lang/Sather/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Sather \ No newline at end of file diff --git a/Lang/Sather/Loops-While b/Lang/Sather/Loops-While new file mode 120000 index 0000000000..f9276fba22 --- /dev/null +++ b/Lang/Sather/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Sather \ No newline at end of file diff --git a/Lang/Sather/Mutual-recursion b/Lang/Sather/Mutual-recursion new file mode 120000 index 0000000000..ab52357353 --- /dev/null +++ b/Lang/Sather/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Sather \ No newline at end of file diff --git a/Lang/Scala/24-game-Solve b/Lang/Scala/24-game-Solve new file mode 120000 index 0000000000..a0c4d4bdf2 --- /dev/null +++ b/Lang/Scala/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Scala \ No newline at end of file diff --git a/Lang/Scala/Arbitrary-precision-integers-included b/Lang/Scala/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..98c3992076 --- /dev/null +++ b/Lang/Scala/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Scala \ No newline at end of file diff --git a/Lang/Scala/Factorial b/Lang/Scala/Factorial new file mode 120000 index 0000000000..269bd1f6f7 --- /dev/null +++ b/Lang/Scala/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Scala \ No newline at end of file diff --git a/Lang/Scala/Factors-of-a-Mersenne-number b/Lang/Scala/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..52f614e876 --- /dev/null +++ b/Lang/Scala/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Scala \ No newline at end of file diff --git a/Lang/Scala/Factors-of-an-integer b/Lang/Scala/Factors-of-an-integer new file mode 120000 index 0000000000..bc3f9bc5e8 --- /dev/null +++ b/Lang/Scala/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Scala \ No newline at end of file diff --git a/Lang/Scala/Fast-Fourier-transform b/Lang/Scala/Fast-Fourier-transform new file mode 120000 index 0000000000..6b0d014ead --- /dev/null +++ b/Lang/Scala/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Scala \ No newline at end of file diff --git a/Lang/Scala/Fibonacci-sequence b/Lang/Scala/Fibonacci-sequence new file mode 120000 index 0000000000..363c8760d8 --- /dev/null +++ b/Lang/Scala/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/File-IO b/Lang/Scala/File-IO new file mode 120000 index 0000000000..644d1c03e8 --- /dev/null +++ b/Lang/Scala/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Scala \ No newline at end of file diff --git a/Lang/Scala/Filter b/Lang/Scala/Filter new file mode 120000 index 0000000000..cdd437e6d1 --- /dev/null +++ b/Lang/Scala/Filter @@ -0,0 +1 @@ +../../Task/Filter/Scala \ No newline at end of file diff --git a/Lang/Scala/Find-limit-of-recursion b/Lang/Scala/Find-limit-of-recursion new file mode 120000 index 0000000000..0f471fce64 --- /dev/null +++ b/Lang/Scala/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Scala \ No newline at end of file diff --git a/Lang/Scala/Find-the-missing-permutation b/Lang/Scala/Find-the-missing-permutation new file mode 120000 index 0000000000..2c33547bd3 --- /dev/null +++ b/Lang/Scala/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Scala \ No newline at end of file diff --git a/Lang/Scala/First-class-functions b/Lang/Scala/First-class-functions new file mode 120000 index 0000000000..d174a70d92 --- /dev/null +++ b/Lang/Scala/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Scala \ No newline at end of file diff --git a/Lang/Scala/First-class-functions-Use-numbers-analogously b/Lang/Scala/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..c32da6b960 --- /dev/null +++ b/Lang/Scala/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Scala \ No newline at end of file diff --git a/Lang/Scala/Flatten-a-list b/Lang/Scala/Flatten-a-list new file mode 120000 index 0000000000..7feb3e786e --- /dev/null +++ b/Lang/Scala/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Scala \ No newline at end of file diff --git a/Lang/Scala/Floyds-triangle b/Lang/Scala/Floyds-triangle new file mode 120000 index 0000000000..7f3ec9268d --- /dev/null +++ b/Lang/Scala/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Scala \ No newline at end of file diff --git a/Lang/Scala/Formatted-numeric-output b/Lang/Scala/Formatted-numeric-output new file mode 120000 index 0000000000..2f292bc414 --- /dev/null +++ b/Lang/Scala/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Scala \ No newline at end of file diff --git a/Lang/Scala/Forward-difference b/Lang/Scala/Forward-difference new file mode 120000 index 0000000000..3b616221c8 --- /dev/null +++ b/Lang/Scala/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Scala \ No newline at end of file diff --git a/Lang/Scala/Four-bit-adder b/Lang/Scala/Four-bit-adder new file mode 120000 index 0000000000..9cdbcadf3e --- /dev/null +++ b/Lang/Scala/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Scala \ No newline at end of file diff --git a/Lang/Scala/Fractal-tree b/Lang/Scala/Fractal-tree new file mode 120000 index 0000000000..c62409bb03 --- /dev/null +++ b/Lang/Scala/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Scala \ No newline at end of file diff --git a/Lang/Scala/Function-composition b/Lang/Scala/Function-composition new file mode 120000 index 0000000000..b237aa4d41 --- /dev/null +++ b/Lang/Scala/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Scala \ No newline at end of file diff --git a/Lang/Scala/Function-definition b/Lang/Scala/Function-definition new file mode 120000 index 0000000000..4c061c5f5f --- /dev/null +++ b/Lang/Scala/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Scala \ No newline at end of file diff --git a/Lang/Scala/GUI-component-interaction b/Lang/Scala/GUI-component-interaction new file mode 120000 index 0000000000..0d14257c12 --- /dev/null +++ b/Lang/Scala/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Scala \ No newline at end of file diff --git a/Lang/Scala/GUI-enabling-disabling-of-controls b/Lang/Scala/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..6f6d1f7c3e --- /dev/null +++ b/Lang/Scala/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Scala \ No newline at end of file diff --git a/Lang/Scala/Gamma-function b/Lang/Scala/Gamma-function new file mode 120000 index 0000000000..4b4ad1f8db --- /dev/null +++ b/Lang/Scala/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Scala \ No newline at end of file diff --git a/Lang/Scala/Generator-Exponential b/Lang/Scala/Generator-Exponential new file mode 120000 index 0000000000..c99ed8ea76 --- /dev/null +++ b/Lang/Scala/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Scala \ No newline at end of file diff --git a/Lang/Scala/Generic-swap b/Lang/Scala/Generic-swap new file mode 120000 index 0000000000..d38a0d8162 --- /dev/null +++ b/Lang/Scala/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Scala \ No newline at end of file diff --git a/Lang/Scala/Gray-code b/Lang/Scala/Gray-code new file mode 120000 index 0000000000..b5662342ec --- /dev/null +++ b/Lang/Scala/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Scala \ No newline at end of file diff --git a/Lang/Scala/Grayscale-image b/Lang/Scala/Grayscale-image new file mode 120000 index 0000000000..7c8c0ac94f --- /dev/null +++ b/Lang/Scala/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Scala \ No newline at end of file diff --git a/Lang/Scala/Greatest-common-divisor b/Lang/Scala/Greatest-common-divisor new file mode 120000 index 0000000000..274ab3aaf0 --- /dev/null +++ b/Lang/Scala/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Scala \ No newline at end of file diff --git a/Lang/Scala/Greatest-element-of-a-list b/Lang/Scala/Greatest-element-of-a-list new file mode 120000 index 0000000000..b6a3ab70f3 --- /dev/null +++ b/Lang/Scala/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Scala \ No newline at end of file diff --git a/Lang/Scala/Greatest-subsequential-sum b/Lang/Scala/Greatest-subsequential-sum new file mode 120000 index 0000000000..e36ccf35d2 --- /dev/null +++ b/Lang/Scala/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Scala \ No newline at end of file diff --git a/Lang/Scala/Greyscale-bars-Display b/Lang/Scala/Greyscale-bars-Display new file mode 120000 index 0000000000..ecc73da549 --- /dev/null +++ b/Lang/Scala/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Scala \ No newline at end of file diff --git a/Lang/Scala/Guess-the-number b/Lang/Scala/Guess-the-number new file mode 120000 index 0000000000..2ebca5689a --- /dev/null +++ b/Lang/Scala/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Scala \ No newline at end of file diff --git a/Lang/Scala/HTTP b/Lang/Scala/HTTP new file mode 120000 index 0000000000..ae04307f4e --- /dev/null +++ b/Lang/Scala/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Scala \ No newline at end of file diff --git a/Lang/Scala/Hailstone-sequence b/Lang/Scala/Hailstone-sequence new file mode 120000 index 0000000000..42d6168fea --- /dev/null +++ b/Lang/Scala/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Hamming-numbers b/Lang/Scala/Hamming-numbers new file mode 120000 index 0000000000..014aa80339 --- /dev/null +++ b/Lang/Scala/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Happy-numbers b/Lang/Scala/Happy-numbers new file mode 120000 index 0000000000..79dfe9c79b --- /dev/null +++ b/Lang/Scala/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Hash-from-two-arrays b/Lang/Scala/Hash-from-two-arrays new file mode 120000 index 0000000000..33076b628f --- /dev/null +++ b/Lang/Scala/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Scala \ No newline at end of file diff --git a/Lang/Scala/Haversine-formula b/Lang/Scala/Haversine-formula new file mode 120000 index 0000000000..ebcc15d061 --- /dev/null +++ b/Lang/Scala/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Scala \ No newline at end of file diff --git a/Lang/Scala/Hello-world-Graphical b/Lang/Scala/Hello-world-Graphical new file mode 120000 index 0000000000..b24cfc9911 --- /dev/null +++ b/Lang/Scala/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Scala \ No newline at end of file diff --git a/Lang/Scala/Hello-world-Standard-error b/Lang/Scala/Hello-world-Standard-error new file mode 120000 index 0000000000..67cd145d0d --- /dev/null +++ b/Lang/Scala/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Scala \ No newline at end of file diff --git a/Lang/Scala/Hello-world-Text b/Lang/Scala/Hello-world-Text new file mode 120000 index 0000000000..a0e54350e0 --- /dev/null +++ b/Lang/Scala/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Scala \ No newline at end of file diff --git a/Lang/Scala/Higher-order-functions b/Lang/Scala/Higher-order-functions new file mode 120000 index 0000000000..302bd1fd40 --- /dev/null +++ b/Lang/Scala/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Scala \ No newline at end of file diff --git a/Lang/Scala/History-variables b/Lang/Scala/History-variables new file mode 120000 index 0000000000..f129c71310 --- /dev/null +++ b/Lang/Scala/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Scala \ No newline at end of file diff --git a/Lang/Scala/Hofstadter-Conway-$10,000-sequence b/Lang/Scala/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..b378efc023 --- /dev/null +++ b/Lang/Scala/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Hofstadter-Figure-Figure-sequences b/Lang/Scala/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..e297b64904 --- /dev/null +++ b/Lang/Scala/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Scala \ No newline at end of file diff --git a/Lang/Scala/Hofstadter-Q-sequence b/Lang/Scala/Hofstadter-Q-sequence new file mode 120000 index 0000000000..38f5035665 --- /dev/null +++ b/Lang/Scala/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Holidays-related-to-Easter b/Lang/Scala/Holidays-related-to-Easter new file mode 120000 index 0000000000..a948004bbc --- /dev/null +++ b/Lang/Scala/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Scala \ No newline at end of file diff --git a/Lang/Scala/Horners-rule-for-polynomial-evaluation b/Lang/Scala/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..28ff37c565 --- /dev/null +++ b/Lang/Scala/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Scala \ No newline at end of file diff --git a/Lang/Scala/Hostname b/Lang/Scala/Hostname new file mode 120000 index 0000000000..6065d35e53 --- /dev/null +++ b/Lang/Scala/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Scala \ No newline at end of file diff --git a/Lang/Scala/Huffman-coding b/Lang/Scala/Huffman-coding new file mode 120000 index 0000000000..a26933cef6 --- /dev/null +++ b/Lang/Scala/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Scala \ No newline at end of file diff --git a/Lang/Scala/Identity-matrix b/Lang/Scala/Identity-matrix new file mode 120000 index 0000000000..f0a61194d7 --- /dev/null +++ b/Lang/Scala/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Scala \ No newline at end of file diff --git a/Lang/Scala/Image-noise b/Lang/Scala/Image-noise new file mode 120000 index 0000000000..6d61528064 --- /dev/null +++ b/Lang/Scala/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Scala \ No newline at end of file diff --git a/Lang/Scala/Increment-a-numerical-string b/Lang/Scala/Increment-a-numerical-string new file mode 120000 index 0000000000..d207064421 --- /dev/null +++ b/Lang/Scala/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Scala \ No newline at end of file diff --git a/Lang/Scala/Inheritance-Single b/Lang/Scala/Inheritance-Single new file mode 120000 index 0000000000..e302907247 --- /dev/null +++ b/Lang/Scala/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Scala \ No newline at end of file diff --git a/Lang/Scala/Input-loop b/Lang/Scala/Input-loop new file mode 120000 index 0000000000..43e4c1bea4 --- /dev/null +++ b/Lang/Scala/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Scala \ No newline at end of file diff --git a/Lang/Scala/Integer-comparison b/Lang/Scala/Integer-comparison new file mode 120000 index 0000000000..2ad648989d --- /dev/null +++ b/Lang/Scala/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Scala \ No newline at end of file diff --git a/Lang/Scala/Integer-sequence b/Lang/Scala/Integer-sequence new file mode 120000 index 0000000000..49d91d61f7 --- /dev/null +++ b/Lang/Scala/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Interactive-programming b/Lang/Scala/Interactive-programming new file mode 120000 index 0000000000..eb5103fb2b --- /dev/null +++ b/Lang/Scala/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Scala \ No newline at end of file diff --git a/Lang/Scala/Jensens-Device b/Lang/Scala/Jensens-Device new file mode 120000 index 0000000000..5ccac616b7 --- /dev/null +++ b/Lang/Scala/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Scala \ No newline at end of file diff --git a/Lang/Scala/Josephus-problem b/Lang/Scala/Josephus-problem new file mode 120000 index 0000000000..9df8a8c14b --- /dev/null +++ b/Lang/Scala/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Scala \ No newline at end of file diff --git a/Lang/Scala/Kaprekar-numbers b/Lang/Scala/Kaprekar-numbers new file mode 120000 index 0000000000..bd6d03364f --- /dev/null +++ b/Lang/Scala/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Knapsack-problem-0-1 b/Lang/Scala/Knapsack-problem-0-1 new file mode 120000 index 0000000000..1f41cc76fe --- /dev/null +++ b/Lang/Scala/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Scala \ No newline at end of file diff --git a/Lang/Scala/Langtons-ant b/Lang/Scala/Langtons-ant new file mode 120000 index 0000000000..1808933a79 --- /dev/null +++ b/Lang/Scala/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Scala \ No newline at end of file diff --git a/Lang/Scala/Last-Friday-of-each-month b/Lang/Scala/Last-Friday-of-each-month new file mode 120000 index 0000000000..78674c8ac4 --- /dev/null +++ b/Lang/Scala/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Scala \ No newline at end of file diff --git a/Lang/Scala/Leap-year b/Lang/Scala/Leap-year new file mode 120000 index 0000000000..48f8ce8654 --- /dev/null +++ b/Lang/Scala/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Scala \ No newline at end of file diff --git a/Lang/Scala/Least-common-multiple b/Lang/Scala/Least-common-multiple new file mode 120000 index 0000000000..ffede0460f --- /dev/null +++ b/Lang/Scala/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Scala \ No newline at end of file diff --git a/Lang/Scala/Letter-frequency b/Lang/Scala/Letter-frequency new file mode 120000 index 0000000000..1ab7b46af3 --- /dev/null +++ b/Lang/Scala/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Scala \ No newline at end of file diff --git a/Lang/Scala/Levenshtein-distance b/Lang/Scala/Levenshtein-distance new file mode 120000 index 0000000000..c80ccf4533 --- /dev/null +++ b/Lang/Scala/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Scala \ No newline at end of file diff --git a/Lang/Scala/Linear-congruential-generator b/Lang/Scala/Linear-congruential-generator new file mode 120000 index 0000000000..e368b26167 --- /dev/null +++ b/Lang/Scala/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Scala \ No newline at end of file diff --git a/Lang/Scala/List-comprehensions b/Lang/Scala/List-comprehensions new file mode 120000 index 0000000000..46f445aad0 --- /dev/null +++ b/Lang/Scala/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Scala \ No newline at end of file diff --git a/Lang/Scala/Literals-String b/Lang/Scala/Literals-String new file mode 120000 index 0000000000..280ec8fee1 --- /dev/null +++ b/Lang/Scala/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Scala \ No newline at end of file diff --git a/Lang/Scala/Logical-operations b/Lang/Scala/Logical-operations new file mode 120000 index 0000000000..42c24dc55a --- /dev/null +++ b/Lang/Scala/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Scala \ No newline at end of file diff --git a/Lang/Scala/Long-multiplication b/Lang/Scala/Long-multiplication new file mode 120000 index 0000000000..22549866a7 --- /dev/null +++ b/Lang/Scala/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Scala \ No newline at end of file diff --git a/Lang/Scala/Longest-common-subsequence b/Lang/Scala/Longest-common-subsequence new file mode 120000 index 0000000000..98535a6762 --- /dev/null +++ b/Lang/Scala/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Look-and-say-sequence b/Lang/Scala/Look-and-say-sequence new file mode 120000 index 0000000000..db009a340a --- /dev/null +++ b/Lang/Scala/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Scala \ No newline at end of file diff --git a/Lang/Scala/Loop-over-multiple-arrays-simultaneously b/Lang/Scala/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..a56c35b0a4 --- /dev/null +++ b/Lang/Scala/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Break b/Lang/Scala/Loops-Break new file mode 120000 index 0000000000..cfcb2eb4cd --- /dev/null +++ b/Lang/Scala/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Continue b/Lang/Scala/Loops-Continue new file mode 120000 index 0000000000..09fba9f487 --- /dev/null +++ b/Lang/Scala/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Do-while b/Lang/Scala/Loops-Do-while new file mode 120000 index 0000000000..07e32a9d41 --- /dev/null +++ b/Lang/Scala/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Downward-for b/Lang/Scala/Loops-Downward-for new file mode 120000 index 0000000000..1ca0ef16f2 --- /dev/null +++ b/Lang/Scala/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-For b/Lang/Scala/Loops-For new file mode 120000 index 0000000000..d14a82684d --- /dev/null +++ b/Lang/Scala/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-For-with-a-specified-step b/Lang/Scala/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..e7b296fcb5 --- /dev/null +++ b/Lang/Scala/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Foreach b/Lang/Scala/Loops-Foreach new file mode 120000 index 0000000000..36c093002f --- /dev/null +++ b/Lang/Scala/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Infinite b/Lang/Scala/Loops-Infinite new file mode 120000 index 0000000000..6447726946 --- /dev/null +++ b/Lang/Scala/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-Nested b/Lang/Scala/Loops-Nested new file mode 120000 index 0000000000..3160db4819 --- /dev/null +++ b/Lang/Scala/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Scala \ No newline at end of file diff --git a/Lang/Scala/Loops-While b/Lang/Scala/Loops-While new file mode 120000 index 0000000000..4270ab6461 --- /dev/null +++ b/Lang/Scala/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Scala \ No newline at end of file diff --git a/Lang/Scala/Lucas-Lehmer-test b/Lang/Scala/Lucas-Lehmer-test new file mode 120000 index 0000000000..1841aa46dd --- /dev/null +++ b/Lang/Scala/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Scala \ No newline at end of file diff --git a/Lang/Scala/Luhn-test-of-credit-card-numbers b/Lang/Scala/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..ef3340aef9 --- /dev/null +++ b/Lang/Scala/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/MD5 b/Lang/Scala/MD5 new file mode 120000 index 0000000000..65abb5edbb --- /dev/null +++ b/Lang/Scala/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Scala \ No newline at end of file diff --git a/Lang/Scala/Man-or-boy-test b/Lang/Scala/Man-or-boy-test new file mode 120000 index 0000000000..d35280b9c7 --- /dev/null +++ b/Lang/Scala/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Scala \ No newline at end of file diff --git a/Lang/Scala/Mandelbrot-set b/Lang/Scala/Mandelbrot-set new file mode 120000 index 0000000000..d4cb2ff032 --- /dev/null +++ b/Lang/Scala/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Scala \ No newline at end of file diff --git a/Lang/Scala/Map-range b/Lang/Scala/Map-range new file mode 120000 index 0000000000..eff5d9970b --- /dev/null +++ b/Lang/Scala/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Scala \ No newline at end of file diff --git a/Lang/Scala/Matrix-exponentiation-operator b/Lang/Scala/Matrix-exponentiation-operator new file mode 120000 index 0000000000..34ffc17cb6 --- /dev/null +++ b/Lang/Scala/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Scala \ No newline at end of file diff --git a/Lang/Scala/Matrix-multiplication b/Lang/Scala/Matrix-multiplication new file mode 120000 index 0000000000..01a01915ca --- /dev/null +++ b/Lang/Scala/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Scala \ No newline at end of file diff --git a/Lang/Scala/Matrix-transposition b/Lang/Scala/Matrix-transposition new file mode 120000 index 0000000000..66314f2601 --- /dev/null +++ b/Lang/Scala/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Scala \ No newline at end of file diff --git a/Lang/Scala/Middle-three-digits b/Lang/Scala/Middle-three-digits new file mode 120000 index 0000000000..43b7d88592 --- /dev/null +++ b/Lang/Scala/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Scala \ No newline at end of file diff --git a/Lang/Scala/Modular-exponentiation b/Lang/Scala/Modular-exponentiation new file mode 120000 index 0000000000..32988967f8 --- /dev/null +++ b/Lang/Scala/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Scala \ No newline at end of file diff --git a/Lang/Scala/Monte-Carlo-methods b/Lang/Scala/Monte-Carlo-methods new file mode 120000 index 0000000000..c2221c7584 --- /dev/null +++ b/Lang/Scala/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Scala \ No newline at end of file diff --git a/Lang/Scala/Monty-Hall-problem b/Lang/Scala/Monty-Hall-problem new file mode 120000 index 0000000000..8a87fb5908 --- /dev/null +++ b/Lang/Scala/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Scala \ No newline at end of file diff --git a/Lang/Scala/Multiple-distinct-objects b/Lang/Scala/Multiple-distinct-objects new file mode 120000 index 0000000000..2e1fa2858e --- /dev/null +++ b/Lang/Scala/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Scala \ No newline at end of file diff --git a/Lang/Scala/Multisplit b/Lang/Scala/Multisplit new file mode 120000 index 0000000000..537c27f8a0 --- /dev/null +++ b/Lang/Scala/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Scala \ No newline at end of file diff --git a/Lang/Scala/Mutual-recursion b/Lang/Scala/Mutual-recursion new file mode 120000 index 0000000000..771e708522 --- /dev/null +++ b/Lang/Scala/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Scala \ No newline at end of file diff --git a/Lang/Scheme/Arbitrary-precision-integers-included b/Lang/Scheme/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..2421538c94 --- /dev/null +++ b/Lang/Scheme/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Factorial b/Lang/Scheme/Factorial new file mode 120000 index 0000000000..fb690bd8c2 --- /dev/null +++ b/Lang/Scheme/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Factors-of-a-Mersenne-number b/Lang/Scheme/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..ed5c20c8b3 --- /dev/null +++ b/Lang/Scheme/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Factors-of-an-integer b/Lang/Scheme/Factors-of-an-integer new file mode 120000 index 0000000000..8fc9c8abe1 --- /dev/null +++ b/Lang/Scheme/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Fibonacci-sequence b/Lang/Scheme/Fibonacci-sequence new file mode 120000 index 0000000000..c9d6f8375c --- /dev/null +++ b/Lang/Scheme/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Scheme \ No newline at end of file diff --git a/Lang/Scheme/File-IO b/Lang/Scheme/File-IO new file mode 120000 index 0000000000..7c63da792c --- /dev/null +++ b/Lang/Scheme/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Scheme \ No newline at end of file diff --git a/Lang/Scheme/File-size b/Lang/Scheme/File-size new file mode 120000 index 0000000000..9b888d6a95 --- /dev/null +++ b/Lang/Scheme/File-size @@ -0,0 +1 @@ +../../Task/File-size/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Filter b/Lang/Scheme/Filter new file mode 120000 index 0000000000..b18952414c --- /dev/null +++ b/Lang/Scheme/Filter @@ -0,0 +1 @@ +../../Task/Filter/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Find-limit-of-recursion b/Lang/Scheme/Find-limit-of-recursion new file mode 120000 index 0000000000..14e8667848 --- /dev/null +++ b/Lang/Scheme/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Scheme \ No newline at end of file diff --git a/Lang/Scheme/First-class-functions b/Lang/Scheme/First-class-functions new file mode 120000 index 0000000000..639ad710ac --- /dev/null +++ b/Lang/Scheme/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/First-class-functions-Use-numbers-analogously b/Lang/Scheme/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..e4ebf14a0d --- /dev/null +++ b/Lang/Scheme/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Flatten-a-list b/Lang/Scheme/Flatten-a-list new file mode 120000 index 0000000000..55372dfa3e --- /dev/null +++ b/Lang/Scheme/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Formal-power-series b/Lang/Scheme/Formal-power-series new file mode 120000 index 0000000000..780543bf0e --- /dev/null +++ b/Lang/Scheme/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Forward-difference b/Lang/Scheme/Forward-difference new file mode 120000 index 0000000000..3a7bd5fcaa --- /dev/null +++ b/Lang/Scheme/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Function-composition b/Lang/Scheme/Function-composition new file mode 120000 index 0000000000..a56bd612b3 --- /dev/null +++ b/Lang/Scheme/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Function-definition b/Lang/Scheme/Function-definition new file mode 120000 index 0000000000..606034ede7 --- /dev/null +++ b/Lang/Scheme/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Generator-Exponential b/Lang/Scheme/Generator-Exponential new file mode 120000 index 0000000000..031ec04119 --- /dev/null +++ b/Lang/Scheme/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Generic-swap b/Lang/Scheme/Generic-swap new file mode 120000 index 0000000000..aaca8672f1 --- /dev/null +++ b/Lang/Scheme/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Greatest-common-divisor b/Lang/Scheme/Greatest-common-divisor new file mode 120000 index 0000000000..458a6c3fbe --- /dev/null +++ b/Lang/Scheme/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Greatest-element-of-a-list b/Lang/Scheme/Greatest-element-of-a-list new file mode 120000 index 0000000000..dc83b37c96 --- /dev/null +++ b/Lang/Scheme/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Greatest-subsequential-sum b/Lang/Scheme/Greatest-subsequential-sum new file mode 120000 index 0000000000..dc10ad6bee --- /dev/null +++ b/Lang/Scheme/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Guess-the-number b/Lang/Scheme/Guess-the-number new file mode 120000 index 0000000000..164650a1b0 --- /dev/null +++ b/Lang/Scheme/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Guess-the-number-With-feedback b/Lang/Scheme/Guess-the-number-With-feedback new file mode 120000 index 0000000000..939559515c --- /dev/null +++ b/Lang/Scheme/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Guess-the-number-With-feedback-player b/Lang/Scheme/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..5a88b0302d --- /dev/null +++ b/Lang/Scheme/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Scheme \ No newline at end of file diff --git a/Lang/Scheme/HTTP b/Lang/Scheme/HTTP new file mode 120000 index 0000000000..573893c1a7 --- /dev/null +++ b/Lang/Scheme/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hailstone-sequence b/Lang/Scheme/Hailstone-sequence new file mode 120000 index 0000000000..9412ec9304 --- /dev/null +++ b/Lang/Scheme/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hamming-numbers b/Lang/Scheme/Hamming-numbers new file mode 120000 index 0000000000..2966e7349e --- /dev/null +++ b/Lang/Scheme/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Happy-numbers b/Lang/Scheme/Happy-numbers new file mode 120000 index 0000000000..ed08b29eac --- /dev/null +++ b/Lang/Scheme/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Harshad-or-Niven-series b/Lang/Scheme/Harshad-or-Niven-series new file mode 120000 index 0000000000..faeb283e75 --- /dev/null +++ b/Lang/Scheme/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hash-from-two-arrays b/Lang/Scheme/Hash-from-two-arrays new file mode 120000 index 0000000000..1ad2c07de4 --- /dev/null +++ b/Lang/Scheme/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Haversine-formula b/Lang/Scheme/Haversine-formula new file mode 120000 index 0000000000..51997998fe --- /dev/null +++ b/Lang/Scheme/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hello-world-Graphical b/Lang/Scheme/Hello-world-Graphical new file mode 120000 index 0000000000..407d751c83 --- /dev/null +++ b/Lang/Scheme/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hello-world-Line-printer b/Lang/Scheme/Hello-world-Line-printer new file mode 120000 index 0000000000..281fb3a2a3 --- /dev/null +++ b/Lang/Scheme/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hello-world-Newline-omission b/Lang/Scheme/Hello-world-Newline-omission new file mode 120000 index 0000000000..3b03a5f31d --- /dev/null +++ b/Lang/Scheme/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hello-world-Standard-error b/Lang/Scheme/Hello-world-Standard-error new file mode 120000 index 0000000000..d63ca917f5 --- /dev/null +++ b/Lang/Scheme/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hello-world-Text b/Lang/Scheme/Hello-world-Text new file mode 120000 index 0000000000..c7657551ab --- /dev/null +++ b/Lang/Scheme/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Higher-order-functions b/Lang/Scheme/Higher-order-functions new file mode 120000 index 0000000000..9d7145b509 --- /dev/null +++ b/Lang/Scheme/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hofstadter-Q-sequence b/Lang/Scheme/Hofstadter-Q-sequence new file mode 120000 index 0000000000..c0b7821a24 --- /dev/null +++ b/Lang/Scheme/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Holidays-related-to-Easter b/Lang/Scheme/Holidays-related-to-Easter new file mode 120000 index 0000000000..98363ad6de --- /dev/null +++ b/Lang/Scheme/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Horners-rule-for-polynomial-evaluation b/Lang/Scheme/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..da15c309cf --- /dev/null +++ b/Lang/Scheme/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Host-introspection b/Lang/Scheme/Host-introspection new file mode 120000 index 0000000000..ac18cbb354 --- /dev/null +++ b/Lang/Scheme/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Hostname b/Lang/Scheme/Hostname new file mode 120000 index 0000000000..cc067f139b --- /dev/null +++ b/Lang/Scheme/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Identity-matrix b/Lang/Scheme/Identity-matrix new file mode 120000 index 0000000000..e3bdbd5b82 --- /dev/null +++ b/Lang/Scheme/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Increment-a-numerical-string b/Lang/Scheme/Increment-a-numerical-string new file mode 120000 index 0000000000..67c57657c9 --- /dev/null +++ b/Lang/Scheme/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Integer-comparison b/Lang/Scheme/Integer-comparison new file mode 120000 index 0000000000..b42a1eee28 --- /dev/null +++ b/Lang/Scheme/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Integer-sequence b/Lang/Scheme/Integer-sequence new file mode 120000 index 0000000000..51268ac9f5 --- /dev/null +++ b/Lang/Scheme/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Interactive-programming b/Lang/Scheme/Interactive-programming new file mode 120000 index 0000000000..16a03d8dee --- /dev/null +++ b/Lang/Scheme/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Jensens-Device b/Lang/Scheme/Jensens-Device new file mode 120000 index 0000000000..f79696d616 --- /dev/null +++ b/Lang/Scheme/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Kaprekar-numbers b/Lang/Scheme/Kaprekar-numbers new file mode 120000 index 0000000000..2cb35672de --- /dev/null +++ b/Lang/Scheme/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/LZW-compression b/Lang/Scheme/LZW-compression new file mode 120000 index 0000000000..9f5c9b2fe7 --- /dev/null +++ b/Lang/Scheme/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Leap-year b/Lang/Scheme/Leap-year new file mode 120000 index 0000000000..441bfd3b2b --- /dev/null +++ b/Lang/Scheme/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Least-common-multiple b/Lang/Scheme/Least-common-multiple new file mode 120000 index 0000000000..76db797786 --- /dev/null +++ b/Lang/Scheme/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Letter-frequency b/Lang/Scheme/Letter-frequency new file mode 120000 index 0000000000..87c7849275 --- /dev/null +++ b/Lang/Scheme/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Levenshtein-distance b/Lang/Scheme/Levenshtein-distance new file mode 120000 index 0000000000..1b400d6410 --- /dev/null +++ b/Lang/Scheme/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Linear-congruential-generator b/Lang/Scheme/Linear-congruential-generator new file mode 120000 index 0000000000..394cbb2a8b --- /dev/null +++ b/Lang/Scheme/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Scheme \ No newline at end of file diff --git a/Lang/Scheme/List-comprehensions b/Lang/Scheme/List-comprehensions new file mode 120000 index 0000000000..aac1b22cfd --- /dev/null +++ b/Lang/Scheme/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Literals-Floating-point b/Lang/Scheme/Literals-Floating-point new file mode 120000 index 0000000000..cd64536586 --- /dev/null +++ b/Lang/Scheme/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Literals-Integer b/Lang/Scheme/Literals-Integer new file mode 120000 index 0000000000..80b5d1431c --- /dev/null +++ b/Lang/Scheme/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Literals-String b/Lang/Scheme/Literals-String new file mode 120000 index 0000000000..c65624c09d --- /dev/null +++ b/Lang/Scheme/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Logical-operations b/Lang/Scheme/Logical-operations new file mode 120000 index 0000000000..be69f9e111 --- /dev/null +++ b/Lang/Scheme/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Long-multiplication b/Lang/Scheme/Long-multiplication new file mode 120000 index 0000000000..1d4a4ea61e --- /dev/null +++ b/Lang/Scheme/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Longest-common-subsequence b/Lang/Scheme/Longest-common-subsequence new file mode 120000 index 0000000000..56cd8f345c --- /dev/null +++ b/Lang/Scheme/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loop-over-multiple-arrays-simultaneously b/Lang/Scheme/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..2c43d25a80 --- /dev/null +++ b/Lang/Scheme/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Break b/Lang/Scheme/Loops-Break new file mode 120000 index 0000000000..e82c48e3ac --- /dev/null +++ b/Lang/Scheme/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Continue b/Lang/Scheme/Loops-Continue new file mode 120000 index 0000000000..d9bf3f3621 --- /dev/null +++ b/Lang/Scheme/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Do-while b/Lang/Scheme/Loops-Do-while new file mode 120000 index 0000000000..ef24637370 --- /dev/null +++ b/Lang/Scheme/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Downward-for b/Lang/Scheme/Loops-Downward-for new file mode 120000 index 0000000000..12c49d4160 --- /dev/null +++ b/Lang/Scheme/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-For b/Lang/Scheme/Loops-For new file mode 120000 index 0000000000..bd15470c23 --- /dev/null +++ b/Lang/Scheme/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-For-with-a-specified-step b/Lang/Scheme/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..2ff1aef3d5 --- /dev/null +++ b/Lang/Scheme/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Foreach b/Lang/Scheme/Loops-Foreach new file mode 120000 index 0000000000..672450e026 --- /dev/null +++ b/Lang/Scheme/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Infinite b/Lang/Scheme/Loops-Infinite new file mode 120000 index 0000000000..004483e746 --- /dev/null +++ b/Lang/Scheme/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-N-plus-one-half b/Lang/Scheme/Loops-N-plus-one-half new file mode 120000 index 0000000000..73441b97fd --- /dev/null +++ b/Lang/Scheme/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-Nested b/Lang/Scheme/Loops-Nested new file mode 120000 index 0000000000..388d55858a --- /dev/null +++ b/Lang/Scheme/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Loops-While b/Lang/Scheme/Loops-While new file mode 120000 index 0000000000..583b693038 --- /dev/null +++ b/Lang/Scheme/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Lucas-Lehmer-test b/Lang/Scheme/Lucas-Lehmer-test new file mode 120000 index 0000000000..35fd5a7a0c --- /dev/null +++ b/Lang/Scheme/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Luhn-test-of-credit-card-numbers b/Lang/Scheme/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..6f4379e9b5 --- /dev/null +++ b/Lang/Scheme/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Man-or-boy-test b/Lang/Scheme/Man-or-boy-test new file mode 120000 index 0000000000..878cd448ee --- /dev/null +++ b/Lang/Scheme/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Mandelbrot-set b/Lang/Scheme/Mandelbrot-set new file mode 120000 index 0000000000..058f2ada38 --- /dev/null +++ b/Lang/Scheme/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Matrix-multiplication b/Lang/Scheme/Matrix-multiplication new file mode 120000 index 0000000000..1c0aec0f7d --- /dev/null +++ b/Lang/Scheme/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Matrix-transposition b/Lang/Scheme/Matrix-transposition new file mode 120000 index 0000000000..e90aa638db --- /dev/null +++ b/Lang/Scheme/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Monty-Hall-problem b/Lang/Scheme/Monty-Hall-problem new file mode 120000 index 0000000000..24a2e59d5c --- /dev/null +++ b/Lang/Scheme/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Multiplication-tables b/Lang/Scheme/Multiplication-tables new file mode 120000 index 0000000000..038be2cef2 --- /dev/null +++ b/Lang/Scheme/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Mutual-recursion b/Lang/Scheme/Mutual-recursion new file mode 120000 index 0000000000..5011a27b7a --- /dev/null +++ b/Lang/Scheme/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Scheme \ No newline at end of file diff --git a/Lang/Smalltalk/Arbitrary-precision-integers-included b/Lang/Smalltalk/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..c4c742c9d3 --- /dev/null +++ b/Lang/Smalltalk/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Factorial b/Lang/Smalltalk/Factorial new file mode 120000 index 0000000000..782970f55c --- /dev/null +++ b/Lang/Smalltalk/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Fibonacci-sequence b/Lang/Smalltalk/Fibonacci-sequence new file mode 120000 index 0000000000..339e269d87 --- /dev/null +++ b/Lang/Smalltalk/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/File-IO b/Lang/Smalltalk/File-IO new file mode 120000 index 0000000000..ca4b4b1c77 --- /dev/null +++ b/Lang/Smalltalk/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/File-modification-time b/Lang/Smalltalk/File-modification-time new file mode 120000 index 0000000000..f9e5c2ea17 --- /dev/null +++ b/Lang/Smalltalk/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/File-size b/Lang/Smalltalk/File-size new file mode 120000 index 0000000000..91d9638799 --- /dev/null +++ b/Lang/Smalltalk/File-size @@ -0,0 +1 @@ +../../Task/File-size/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Filter b/Lang/Smalltalk/Filter new file mode 120000 index 0000000000..1ab392a809 --- /dev/null +++ b/Lang/Smalltalk/Filter @@ -0,0 +1 @@ +../../Task/Filter/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/First-class-functions b/Lang/Smalltalk/First-class-functions new file mode 120000 index 0000000000..7ae8a9703a --- /dev/null +++ b/Lang/Smalltalk/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Flatten-a-list b/Lang/Smalltalk/Flatten-a-list new file mode 120000 index 0000000000..4529a3027e --- /dev/null +++ b/Lang/Smalltalk/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Fork b/Lang/Smalltalk/Fork new file mode 120000 index 0000000000..336307ac7c --- /dev/null +++ b/Lang/Smalltalk/Fork @@ -0,0 +1 @@ +../../Task/Fork/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Formatted-numeric-output b/Lang/Smalltalk/Formatted-numeric-output new file mode 120000 index 0000000000..b3b83686d4 --- /dev/null +++ b/Lang/Smalltalk/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Forward-difference b/Lang/Smalltalk/Forward-difference new file mode 120000 index 0000000000..8f02c2cf77 --- /dev/null +++ b/Lang/Smalltalk/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Function-composition b/Lang/Smalltalk/Function-composition new file mode 120000 index 0000000000..1ed8960369 --- /dev/null +++ b/Lang/Smalltalk/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Function-definition b/Lang/Smalltalk/Function-definition new file mode 120000 index 0000000000..629aa04e61 --- /dev/null +++ b/Lang/Smalltalk/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/GUI-component-interaction b/Lang/Smalltalk/GUI-component-interaction new file mode 120000 index 0000000000..aad4af0b98 --- /dev/null +++ b/Lang/Smalltalk/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/GUI-enabling-disabling-of-controls b/Lang/Smalltalk/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..aaed9dfaa2 --- /dev/null +++ b/Lang/Smalltalk/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Generic-swap b/Lang/Smalltalk/Generic-swap new file mode 120000 index 0000000000..8357de4d6e --- /dev/null +++ b/Lang/Smalltalk/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Greatest-common-divisor b/Lang/Smalltalk/Greatest-common-divisor new file mode 120000 index 0000000000..c47a07d60d --- /dev/null +++ b/Lang/Smalltalk/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Greatest-element-of-a-list b/Lang/Smalltalk/Greatest-element-of-a-list new file mode 120000 index 0000000000..78d852c336 --- /dev/null +++ b/Lang/Smalltalk/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Guess-the-number-With-feedback-player b/Lang/Smalltalk/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..4f3cf09f40 --- /dev/null +++ b/Lang/Smalltalk/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/HTTP b/Lang/Smalltalk/HTTP new file mode 120000 index 0000000000..ef3c7dc04b --- /dev/null +++ b/Lang/Smalltalk/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hailstone-sequence b/Lang/Smalltalk/Hailstone-sequence new file mode 120000 index 0000000000..66c14d3a5f --- /dev/null +++ b/Lang/Smalltalk/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hamming-numbers b/Lang/Smalltalk/Hamming-numbers new file mode 120000 index 0000000000..1270d26d91 --- /dev/null +++ b/Lang/Smalltalk/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Handle-a-signal b/Lang/Smalltalk/Handle-a-signal new file mode 120000 index 0000000000..a7a970649e --- /dev/null +++ b/Lang/Smalltalk/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Happy-numbers b/Lang/Smalltalk/Happy-numbers new file mode 120000 index 0000000000..6aca0a0c9c --- /dev/null +++ b/Lang/Smalltalk/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hash-from-two-arrays b/Lang/Smalltalk/Hash-from-two-arrays new file mode 120000 index 0000000000..f8ae1c1536 --- /dev/null +++ b/Lang/Smalltalk/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hello-world-Graphical b/Lang/Smalltalk/Hello-world-Graphical new file mode 120000 index 0000000000..df2371f450 --- /dev/null +++ b/Lang/Smalltalk/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hello-world-Text b/Lang/Smalltalk/Hello-world-Text new file mode 120000 index 0000000000..7aa9d79494 --- /dev/null +++ b/Lang/Smalltalk/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hello-world-Web-server b/Lang/Smalltalk/Hello-world-Web-server new file mode 120000 index 0000000000..6c4a2e5faa --- /dev/null +++ b/Lang/Smalltalk/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Higher-order-functions b/Lang/Smalltalk/Higher-order-functions new file mode 120000 index 0000000000..d38a5a269f --- /dev/null +++ b/Lang/Smalltalk/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/History-variables b/Lang/Smalltalk/History-variables new file mode 120000 index 0000000000..a426246694 --- /dev/null +++ b/Lang/Smalltalk/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Horizontal-sundial-calculations b/Lang/Smalltalk/Horizontal-sundial-calculations new file mode 120000 index 0000000000..10374151c0 --- /dev/null +++ b/Lang/Smalltalk/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Horners-rule-for-polynomial-evaluation b/Lang/Smalltalk/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..dbd757d1d0 --- /dev/null +++ b/Lang/Smalltalk/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Hostname b/Lang/Smalltalk/Hostname new file mode 120000 index 0000000000..dc2d6825a7 --- /dev/null +++ b/Lang/Smalltalk/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Include-a-file b/Lang/Smalltalk/Include-a-file new file mode 120000 index 0000000000..e06a0cfca6 --- /dev/null +++ b/Lang/Smalltalk/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Increment-a-numerical-string b/Lang/Smalltalk/Increment-a-numerical-string new file mode 120000 index 0000000000..b29a4377e1 --- /dev/null +++ b/Lang/Smalltalk/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Inheritance-Single b/Lang/Smalltalk/Inheritance-Single new file mode 120000 index 0000000000..91280a3436 --- /dev/null +++ b/Lang/Smalltalk/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Input-loop b/Lang/Smalltalk/Input-loop new file mode 120000 index 0000000000..8a43165759 --- /dev/null +++ b/Lang/Smalltalk/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Integer-comparison b/Lang/Smalltalk/Integer-comparison new file mode 120000 index 0000000000..39a183c0cf --- /dev/null +++ b/Lang/Smalltalk/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Integer-sequence b/Lang/Smalltalk/Integer-sequence new file mode 120000 index 0000000000..36afad650c --- /dev/null +++ b/Lang/Smalltalk/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Interactive-programming b/Lang/Smalltalk/Interactive-programming new file mode 120000 index 0000000000..57e91e12d8 --- /dev/null +++ b/Lang/Smalltalk/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Introspection b/Lang/Smalltalk/Introspection new file mode 120000 index 0000000000..17b3b0d1bb --- /dev/null +++ b/Lang/Smalltalk/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Levenshtein-distance b/Lang/Smalltalk/Levenshtein-distance new file mode 120000 index 0000000000..7fba4d1b9f --- /dev/null +++ b/Lang/Smalltalk/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/List-comprehensions b/Lang/Smalltalk/List-comprehensions new file mode 120000 index 0000000000..2d8a1bd388 --- /dev/null +++ b/Lang/Smalltalk/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Literals-Floating-point b/Lang/Smalltalk/Literals-Floating-point new file mode 120000 index 0000000000..5f8651aac1 --- /dev/null +++ b/Lang/Smalltalk/Literals-Floating-point @@ -0,0 +1 @@ +../../Task/Literals-Floating-point/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Literals-Integer b/Lang/Smalltalk/Literals-Integer new file mode 120000 index 0000000000..cdcc44e2ff --- /dev/null +++ b/Lang/Smalltalk/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Logical-operations b/Lang/Smalltalk/Logical-operations new file mode 120000 index 0000000000..fab44c9eb1 --- /dev/null +++ b/Lang/Smalltalk/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Long-multiplication b/Lang/Smalltalk/Long-multiplication new file mode 120000 index 0000000000..388656dc93 --- /dev/null +++ b/Lang/Smalltalk/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Look-and-say-sequence b/Lang/Smalltalk/Look-and-say-sequence new file mode 120000 index 0000000000..13819b5cd7 --- /dev/null +++ b/Lang/Smalltalk/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loop-over-multiple-arrays-simultaneously b/Lang/Smalltalk/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..41cda1fd93 --- /dev/null +++ b/Lang/Smalltalk/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Break b/Lang/Smalltalk/Loops-Break new file mode 120000 index 0000000000..6df83c1f01 --- /dev/null +++ b/Lang/Smalltalk/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Do-while b/Lang/Smalltalk/Loops-Do-while new file mode 120000 index 0000000000..63dfcf7419 --- /dev/null +++ b/Lang/Smalltalk/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Downward-for b/Lang/Smalltalk/Loops-Downward-for new file mode 120000 index 0000000000..a228fd21b0 --- /dev/null +++ b/Lang/Smalltalk/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-For b/Lang/Smalltalk/Loops-For new file mode 120000 index 0000000000..9bbd4fe8a1 --- /dev/null +++ b/Lang/Smalltalk/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-For-with-a-specified-step b/Lang/Smalltalk/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..fff012c46c --- /dev/null +++ b/Lang/Smalltalk/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Foreach b/Lang/Smalltalk/Loops-Foreach new file mode 120000 index 0000000000..dedf22d1b1 --- /dev/null +++ b/Lang/Smalltalk/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Infinite b/Lang/Smalltalk/Loops-Infinite new file mode 120000 index 0000000000..36762b5147 --- /dev/null +++ b/Lang/Smalltalk/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-Nested b/Lang/Smalltalk/Loops-Nested new file mode 120000 index 0000000000..8bc56d76a8 --- /dev/null +++ b/Lang/Smalltalk/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Loops-While b/Lang/Smalltalk/Loops-While new file mode 120000 index 0000000000..8b462235b8 --- /dev/null +++ b/Lang/Smalltalk/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/MD5 b/Lang/Smalltalk/MD5 new file mode 120000 index 0000000000..a1e32e90f6 --- /dev/null +++ b/Lang/Smalltalk/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Miller-Rabin-primality-test b/Lang/Smalltalk/Miller-Rabin-primality-test new file mode 120000 index 0000000000..e3a303744d --- /dev/null +++ b/Lang/Smalltalk/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Multiple-distinct-objects b/Lang/Smalltalk/Multiple-distinct-objects new file mode 120000 index 0000000000..a9e2658efb --- /dev/null +++ b/Lang/Smalltalk/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Mutual-recursion b/Lang/Smalltalk/Mutual-recursion new file mode 120000 index 0000000000..9cfe5aed88 --- /dev/null +++ b/Lang/Smalltalk/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Smalltalk \ No newline at end of file diff --git a/Lang/Tcl/24-game-Solve b/Lang/Tcl/24-game-Solve new file mode 120000 index 0000000000..6310982699 --- /dev/null +++ b/Lang/Tcl/24-game-Solve @@ -0,0 +1 @@ +../../Task/24-game-Solve/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arbitrary-precision-integers-included b/Lang/Tcl/Arbitrary-precision-integers-included new file mode 120000 index 0000000000..c1a2cb119a --- /dev/null +++ b/Lang/Tcl/Arbitrary-precision-integers-included @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers-included/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N b/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N new file mode 120000 index 0000000000..2ff9107c8e --- /dev/null +++ b/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 b/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 new file mode 120000 index 0000000000..a8987eb00c --- /dev/null +++ b/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 @@ -0,0 +1 @@ +../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Factorial b/Lang/Tcl/Factorial new file mode 120000 index 0000000000..f64dc2f1f8 --- /dev/null +++ b/Lang/Tcl/Factorial @@ -0,0 +1 @@ +../../Task/Factorial/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Factors-of-a-Mersenne-number b/Lang/Tcl/Factors-of-a-Mersenne-number new file mode 120000 index 0000000000..36cdca115b --- /dev/null +++ b/Lang/Tcl/Factors-of-a-Mersenne-number @@ -0,0 +1 @@ +../../Task/Factors-of-a-Mersenne-number/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Factors-of-an-integer b/Lang/Tcl/Factors-of-an-integer new file mode 120000 index 0000000000..0fb929d8d3 --- /dev/null +++ b/Lang/Tcl/Factors-of-an-integer @@ -0,0 +1 @@ +../../Task/Factors-of-an-integer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Fast-Fourier-transform b/Lang/Tcl/Fast-Fourier-transform new file mode 120000 index 0000000000..2be85da183 --- /dev/null +++ b/Lang/Tcl/Fast-Fourier-transform @@ -0,0 +1 @@ +../../Task/Fast-Fourier-transform/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Fibonacci-n-step-number-sequences b/Lang/Tcl/Fibonacci-n-step-number-sequences new file mode 120000 index 0000000000..573ee8814e --- /dev/null +++ b/Lang/Tcl/Fibonacci-n-step-number-sequences @@ -0,0 +1 @@ +../../Task/Fibonacci-n-step-number-sequences/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Fibonacci-sequence b/Lang/Tcl/Fibonacci-sequence new file mode 120000 index 0000000000..0737d04328 --- /dev/null +++ b/Lang/Tcl/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/File-IO b/Lang/Tcl/File-IO new file mode 120000 index 0000000000..0f1da9084e --- /dev/null +++ b/Lang/Tcl/File-IO @@ -0,0 +1 @@ +../../Task/File-IO/Tcl \ No newline at end of file diff --git a/Lang/Tcl/File-modification-time b/Lang/Tcl/File-modification-time new file mode 120000 index 0000000000..a8dadac553 --- /dev/null +++ b/Lang/Tcl/File-modification-time @@ -0,0 +1 @@ +../../Task/File-modification-time/Tcl \ No newline at end of file diff --git a/Lang/Tcl/File-size b/Lang/Tcl/File-size new file mode 120000 index 0000000000..ee94532f83 --- /dev/null +++ b/Lang/Tcl/File-size @@ -0,0 +1 @@ +../../Task/File-size/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Filter b/Lang/Tcl/Filter new file mode 120000 index 0000000000..eb6d162d55 --- /dev/null +++ b/Lang/Tcl/Filter @@ -0,0 +1 @@ +../../Task/Filter/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Find-common-directory-path b/Lang/Tcl/Find-common-directory-path new file mode 120000 index 0000000000..aeca8be46a --- /dev/null +++ b/Lang/Tcl/Find-common-directory-path @@ -0,0 +1 @@ +../../Task/Find-common-directory-path/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Find-largest-left-truncatable-prime-in-a-given-base b/Lang/Tcl/Find-largest-left-truncatable-prime-in-a-given-base new file mode 120000 index 0000000000..bee7f282a4 --- /dev/null +++ b/Lang/Tcl/Find-largest-left-truncatable-prime-in-a-given-base @@ -0,0 +1 @@ +../../Task/Find-largest-left-truncatable-prime-in-a-given-base/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Find-limit-of-recursion b/Lang/Tcl/Find-limit-of-recursion new file mode 120000 index 0000000000..a7e06bcaf4 --- /dev/null +++ b/Lang/Tcl/Find-limit-of-recursion @@ -0,0 +1 @@ +../../Task/Find-limit-of-recursion/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Find-the-missing-permutation b/Lang/Tcl/Find-the-missing-permutation new file mode 120000 index 0000000000..8c943db658 --- /dev/null +++ b/Lang/Tcl/Find-the-missing-permutation @@ -0,0 +1 @@ +../../Task/Find-the-missing-permutation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/First-class-environments b/Lang/Tcl/First-class-environments new file mode 120000 index 0000000000..0713d893e6 --- /dev/null +++ b/Lang/Tcl/First-class-environments @@ -0,0 +1 @@ +../../Task/First-class-environments/Tcl \ No newline at end of file diff --git a/Lang/Tcl/First-class-functions b/Lang/Tcl/First-class-functions new file mode 120000 index 0000000000..d8acb531bd --- /dev/null +++ b/Lang/Tcl/First-class-functions @@ -0,0 +1 @@ +../../Task/First-class-functions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/First-class-functions-Use-numbers-analogously b/Lang/Tcl/First-class-functions-Use-numbers-analogously new file mode 120000 index 0000000000..1188427549 --- /dev/null +++ b/Lang/Tcl/First-class-functions-Use-numbers-analogously @@ -0,0 +1 @@ +../../Task/First-class-functions-Use-numbers-analogously/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Five-weekends b/Lang/Tcl/Five-weekends new file mode 120000 index 0000000000..ab6bb35879 --- /dev/null +++ b/Lang/Tcl/Five-weekends @@ -0,0 +1 @@ +../../Task/Five-weekends/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Flatten-a-list b/Lang/Tcl/Flatten-a-list new file mode 120000 index 0000000000..dc3cf1fc94 --- /dev/null +++ b/Lang/Tcl/Flatten-a-list @@ -0,0 +1 @@ +../../Task/Flatten-a-list/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Flow-control-structures b/Lang/Tcl/Flow-control-structures new file mode 120000 index 0000000000..4daab89f08 --- /dev/null +++ b/Lang/Tcl/Flow-control-structures @@ -0,0 +1 @@ +../../Task/Flow-control-structures/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Floyds-triangle b/Lang/Tcl/Floyds-triangle new file mode 120000 index 0000000000..ce9928e75a --- /dev/null +++ b/Lang/Tcl/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Fork b/Lang/Tcl/Fork new file mode 120000 index 0000000000..461a7bf385 --- /dev/null +++ b/Lang/Tcl/Fork @@ -0,0 +1 @@ +../../Task/Fork/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Formal-power-series b/Lang/Tcl/Formal-power-series new file mode 120000 index 0000000000..c0e864dabc --- /dev/null +++ b/Lang/Tcl/Formal-power-series @@ -0,0 +1 @@ +../../Task/Formal-power-series/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Formatted-numeric-output b/Lang/Tcl/Formatted-numeric-output new file mode 120000 index 0000000000..83c705bfc4 --- /dev/null +++ b/Lang/Tcl/Formatted-numeric-output @@ -0,0 +1 @@ +../../Task/Formatted-numeric-output/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Forward-difference b/Lang/Tcl/Forward-difference new file mode 120000 index 0000000000..2811bdcdf0 --- /dev/null +++ b/Lang/Tcl/Forward-difference @@ -0,0 +1 @@ +../../Task/Forward-difference/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Four-bit-adder b/Lang/Tcl/Four-bit-adder new file mode 120000 index 0000000000..f80ad05b06 --- /dev/null +++ b/Lang/Tcl/Four-bit-adder @@ -0,0 +1 @@ +../../Task/Four-bit-adder/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Fractal-tree b/Lang/Tcl/Fractal-tree new file mode 120000 index 0000000000..108c4f801d --- /dev/null +++ b/Lang/Tcl/Fractal-tree @@ -0,0 +1 @@ +../../Task/Fractal-tree/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Function-composition b/Lang/Tcl/Function-composition new file mode 120000 index 0000000000..690886349e --- /dev/null +++ b/Lang/Tcl/Function-composition @@ -0,0 +1 @@ +../../Task/Function-composition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Function-definition b/Lang/Tcl/Function-definition new file mode 120000 index 0000000000..37bcc04302 --- /dev/null +++ b/Lang/Tcl/Function-definition @@ -0,0 +1 @@ +../../Task/Function-definition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Function-frequency b/Lang/Tcl/Function-frequency new file mode 120000 index 0000000000..781d3c7250 --- /dev/null +++ b/Lang/Tcl/Function-frequency @@ -0,0 +1 @@ +../../Task/Function-frequency/Tcl \ No newline at end of file diff --git a/Lang/Tcl/GUI-Maximum-window-dimensions b/Lang/Tcl/GUI-Maximum-window-dimensions new file mode 120000 index 0000000000..14c545eb4b --- /dev/null +++ b/Lang/Tcl/GUI-Maximum-window-dimensions @@ -0,0 +1 @@ +../../Task/GUI-Maximum-window-dimensions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/GUI-component-interaction b/Lang/Tcl/GUI-component-interaction new file mode 120000 index 0000000000..4d16d306ea --- /dev/null +++ b/Lang/Tcl/GUI-component-interaction @@ -0,0 +1 @@ +../../Task/GUI-component-interaction/Tcl \ No newline at end of file diff --git a/Lang/Tcl/GUI-enabling-disabling-of-controls b/Lang/Tcl/GUI-enabling-disabling-of-controls new file mode 120000 index 0000000000..7498c781f1 --- /dev/null +++ b/Lang/Tcl/GUI-enabling-disabling-of-controls @@ -0,0 +1 @@ +../../Task/GUI-enabling-disabling-of-controls/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Galton-box-animation b/Lang/Tcl/Galton-box-animation new file mode 120000 index 0000000000..2172236ae4 --- /dev/null +++ b/Lang/Tcl/Galton-box-animation @@ -0,0 +1 @@ +../../Task/Galton-box-animation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Gamma-function b/Lang/Tcl/Gamma-function new file mode 120000 index 0000000000..8e1debecaa --- /dev/null +++ b/Lang/Tcl/Gamma-function @@ -0,0 +1 @@ +../../Task/Gamma-function/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Generator-Exponential b/Lang/Tcl/Generator-Exponential new file mode 120000 index 0000000000..30aafd6466 --- /dev/null +++ b/Lang/Tcl/Generator-Exponential @@ -0,0 +1 @@ +../../Task/Generator-Exponential/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Generic-swap b/Lang/Tcl/Generic-swap new file mode 120000 index 0000000000..0ef4511c0e --- /dev/null +++ b/Lang/Tcl/Generic-swap @@ -0,0 +1 @@ +../../Task/Generic-swap/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Globally-replace-text-in-several-files b/Lang/Tcl/Globally-replace-text-in-several-files new file mode 120000 index 0000000000..35745e5e54 --- /dev/null +++ b/Lang/Tcl/Globally-replace-text-in-several-files @@ -0,0 +1 @@ +../../Task/Globally-replace-text-in-several-files/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Gray-code b/Lang/Tcl/Gray-code new file mode 120000 index 0000000000..ab25bd15c1 --- /dev/null +++ b/Lang/Tcl/Gray-code @@ -0,0 +1 @@ +../../Task/Gray-code/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Grayscale-image b/Lang/Tcl/Grayscale-image new file mode 120000 index 0000000000..9fc8ac4d7c --- /dev/null +++ b/Lang/Tcl/Grayscale-image @@ -0,0 +1 @@ +../../Task/Grayscale-image/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Greatest-common-divisor b/Lang/Tcl/Greatest-common-divisor new file mode 120000 index 0000000000..c1d543559b --- /dev/null +++ b/Lang/Tcl/Greatest-common-divisor @@ -0,0 +1 @@ +../../Task/Greatest-common-divisor/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Greatest-element-of-a-list b/Lang/Tcl/Greatest-element-of-a-list new file mode 120000 index 0000000000..216ce12669 --- /dev/null +++ b/Lang/Tcl/Greatest-element-of-a-list @@ -0,0 +1 @@ +../../Task/Greatest-element-of-a-list/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Greatest-subsequential-sum b/Lang/Tcl/Greatest-subsequential-sum new file mode 120000 index 0000000000..c6f2eca40a --- /dev/null +++ b/Lang/Tcl/Greatest-subsequential-sum @@ -0,0 +1 @@ +../../Task/Greatest-subsequential-sum/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Greyscale-bars-Display b/Lang/Tcl/Greyscale-bars-Display new file mode 120000 index 0000000000..1fd07eb585 --- /dev/null +++ b/Lang/Tcl/Greyscale-bars-Display @@ -0,0 +1 @@ +../../Task/Greyscale-bars-Display/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Guess-the-number b/Lang/Tcl/Guess-the-number new file mode 120000 index 0000000000..169cd5bde7 --- /dev/null +++ b/Lang/Tcl/Guess-the-number @@ -0,0 +1 @@ +../../Task/Guess-the-number/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Guess-the-number-With-feedback b/Lang/Tcl/Guess-the-number-With-feedback new file mode 120000 index 0000000000..449102a181 --- /dev/null +++ b/Lang/Tcl/Guess-the-number-With-feedback @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Guess-the-number-With-feedback-player b/Lang/Tcl/Guess-the-number-With-feedback-player new file mode 120000 index 0000000000..45eec94bee --- /dev/null +++ b/Lang/Tcl/Guess-the-number-With-feedback-player @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback-player/Tcl \ No newline at end of file diff --git a/Lang/Tcl/HTTP b/Lang/Tcl/HTTP new file mode 120000 index 0000000000..12104093d1 --- /dev/null +++ b/Lang/Tcl/HTTP @@ -0,0 +1 @@ +../../Task/HTTP/Tcl \ No newline at end of file diff --git a/Lang/Tcl/HTTPS b/Lang/Tcl/HTTPS new file mode 120000 index 0000000000..a86ec6feda --- /dev/null +++ b/Lang/Tcl/HTTPS @@ -0,0 +1 @@ +../../Task/HTTPS/Tcl \ No newline at end of file diff --git a/Lang/Tcl/HTTPS-Authenticated b/Lang/Tcl/HTTPS-Authenticated new file mode 120000 index 0000000000..950e404370 --- /dev/null +++ b/Lang/Tcl/HTTPS-Authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Authenticated/Tcl \ No newline at end of file diff --git a/Lang/Tcl/HTTPS-Client-authenticated b/Lang/Tcl/HTTPS-Client-authenticated new file mode 120000 index 0000000000..7f2f235a71 --- /dev/null +++ b/Lang/Tcl/HTTPS-Client-authenticated @@ -0,0 +1 @@ +../../Task/HTTPS-Client-authenticated/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hailstone-sequence b/Lang/Tcl/Hailstone-sequence new file mode 120000 index 0000000000..17e8362242 --- /dev/null +++ b/Lang/Tcl/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hamming-numbers b/Lang/Tcl/Hamming-numbers new file mode 120000 index 0000000000..c01c6c5613 --- /dev/null +++ b/Lang/Tcl/Hamming-numbers @@ -0,0 +1 @@ +../../Task/Hamming-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Handle-a-signal b/Lang/Tcl/Handle-a-signal new file mode 120000 index 0000000000..0364a138e6 --- /dev/null +++ b/Lang/Tcl/Handle-a-signal @@ -0,0 +1 @@ +../../Task/Handle-a-signal/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Happy-numbers b/Lang/Tcl/Happy-numbers new file mode 120000 index 0000000000..631124d66a --- /dev/null +++ b/Lang/Tcl/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Harshad-or-Niven-series b/Lang/Tcl/Harshad-or-Niven-series new file mode 120000 index 0000000000..4001a57e50 --- /dev/null +++ b/Lang/Tcl/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hash-from-two-arrays b/Lang/Tcl/Hash-from-two-arrays new file mode 120000 index 0000000000..33ed4fdf4f --- /dev/null +++ b/Lang/Tcl/Hash-from-two-arrays @@ -0,0 +1 @@ +../../Task/Hash-from-two-arrays/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Haversine-formula b/Lang/Tcl/Haversine-formula new file mode 120000 index 0000000000..236677d78c --- /dev/null +++ b/Lang/Tcl/Haversine-formula @@ -0,0 +1 @@ +../../Task/Haversine-formula/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Graphical b/Lang/Tcl/Hello-world-Graphical new file mode 120000 index 0000000000..643140197f --- /dev/null +++ b/Lang/Tcl/Hello-world-Graphical @@ -0,0 +1 @@ +../../Task/Hello-world-Graphical/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Line-printer b/Lang/Tcl/Hello-world-Line-printer new file mode 120000 index 0000000000..5a7cacdb1f --- /dev/null +++ b/Lang/Tcl/Hello-world-Line-printer @@ -0,0 +1 @@ +../../Task/Hello-world-Line-printer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Newline-omission b/Lang/Tcl/Hello-world-Newline-omission new file mode 120000 index 0000000000..90caf7d7e9 --- /dev/null +++ b/Lang/Tcl/Hello-world-Newline-omission @@ -0,0 +1 @@ +../../Task/Hello-world-Newline-omission/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Standard-error b/Lang/Tcl/Hello-world-Standard-error new file mode 120000 index 0000000000..55538cb9d2 --- /dev/null +++ b/Lang/Tcl/Hello-world-Standard-error @@ -0,0 +1 @@ +../../Task/Hello-world-Standard-error/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Text b/Lang/Tcl/Hello-world-Text new file mode 120000 index 0000000000..1daebe4ada --- /dev/null +++ b/Lang/Tcl/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hello-world-Web-server b/Lang/Tcl/Hello-world-Web-server new file mode 120000 index 0000000000..c3541a0089 --- /dev/null +++ b/Lang/Tcl/Hello-world-Web-server @@ -0,0 +1 @@ +../../Task/Hello-world-Web-server/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Here-document b/Lang/Tcl/Here-document new file mode 120000 index 0000000000..bc3463ec58 --- /dev/null +++ b/Lang/Tcl/Here-document @@ -0,0 +1 @@ +../../Task/Here-document/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Higher-order-functions b/Lang/Tcl/Higher-order-functions new file mode 120000 index 0000000000..1a20592a2a --- /dev/null +++ b/Lang/Tcl/Higher-order-functions @@ -0,0 +1 @@ +../../Task/Higher-order-functions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/History-variables b/Lang/Tcl/History-variables new file mode 120000 index 0000000000..80ed61299d --- /dev/null +++ b/Lang/Tcl/History-variables @@ -0,0 +1 @@ +../../Task/History-variables/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hofstadter-Conway-$10,000-sequence b/Lang/Tcl/Hofstadter-Conway-$10,000-sequence new file mode 120000 index 0000000000..5f3e319202 --- /dev/null +++ b/Lang/Tcl/Hofstadter-Conway-$10,000-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Conway-$10,000-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hofstadter-Figure-Figure-sequences b/Lang/Tcl/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..dec6b9ea5a --- /dev/null +++ b/Lang/Tcl/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hofstadter-Q-sequence b/Lang/Tcl/Hofstadter-Q-sequence new file mode 120000 index 0000000000..a3bb709959 --- /dev/null +++ b/Lang/Tcl/Hofstadter-Q-sequence @@ -0,0 +1 @@ +../../Task/Hofstadter-Q-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Holidays-related-to-Easter b/Lang/Tcl/Holidays-related-to-Easter new file mode 120000 index 0000000000..307fabf369 --- /dev/null +++ b/Lang/Tcl/Holidays-related-to-Easter @@ -0,0 +1 @@ +../../Task/Holidays-related-to-Easter/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Honeycombs b/Lang/Tcl/Honeycombs new file mode 120000 index 0000000000..c9fcb39550 --- /dev/null +++ b/Lang/Tcl/Honeycombs @@ -0,0 +1 @@ +../../Task/Honeycombs/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Horizontal-sundial-calculations b/Lang/Tcl/Horizontal-sundial-calculations new file mode 120000 index 0000000000..4a3a06f0a8 --- /dev/null +++ b/Lang/Tcl/Horizontal-sundial-calculations @@ -0,0 +1 @@ +../../Task/Horizontal-sundial-calculations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Horners-rule-for-polynomial-evaluation b/Lang/Tcl/Horners-rule-for-polynomial-evaluation new file mode 120000 index 0000000000..04b718e527 --- /dev/null +++ b/Lang/Tcl/Horners-rule-for-polynomial-evaluation @@ -0,0 +1 @@ +../../Task/Horners-rule-for-polynomial-evaluation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Host-introspection b/Lang/Tcl/Host-introspection new file mode 120000 index 0000000000..e204a7ba2d --- /dev/null +++ b/Lang/Tcl/Host-introspection @@ -0,0 +1 @@ +../../Task/Host-introspection/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Hostname b/Lang/Tcl/Hostname new file mode 120000 index 0000000000..8418d4d02b --- /dev/null +++ b/Lang/Tcl/Hostname @@ -0,0 +1 @@ +../../Task/Hostname/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Huffman-coding b/Lang/Tcl/Huffman-coding new file mode 120000 index 0000000000..2872281129 --- /dev/null +++ b/Lang/Tcl/Huffman-coding @@ -0,0 +1 @@ +../../Task/Huffman-coding/Tcl \ No newline at end of file diff --git a/Lang/Tcl/I-before-E-except-after-C b/Lang/Tcl/I-before-E-except-after-C new file mode 120000 index 0000000000..7d9d243d8d --- /dev/null +++ b/Lang/Tcl/I-before-E-except-after-C @@ -0,0 +1 @@ +../../Task/I-before-E-except-after-C/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Identity-matrix b/Lang/Tcl/Identity-matrix new file mode 120000 index 0000000000..f0c1c1bcf4 --- /dev/null +++ b/Lang/Tcl/Identity-matrix @@ -0,0 +1 @@ +../../Task/Identity-matrix/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Image-convolution b/Lang/Tcl/Image-convolution new file mode 120000 index 0000000000..b3d5db8838 --- /dev/null +++ b/Lang/Tcl/Image-convolution @@ -0,0 +1 @@ +../../Task/Image-convolution/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Image-noise b/Lang/Tcl/Image-noise new file mode 120000 index 0000000000..e3ff2c13fc --- /dev/null +++ b/Lang/Tcl/Image-noise @@ -0,0 +1 @@ +../../Task/Image-noise/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Include-a-file b/Lang/Tcl/Include-a-file new file mode 120000 index 0000000000..7e75fc97f4 --- /dev/null +++ b/Lang/Tcl/Include-a-file @@ -0,0 +1 @@ +../../Task/Include-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Increment-a-numerical-string b/Lang/Tcl/Increment-a-numerical-string new file mode 120000 index 0000000000..6914d6ada3 --- /dev/null +++ b/Lang/Tcl/Increment-a-numerical-string @@ -0,0 +1 @@ +../../Task/Increment-a-numerical-string/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Inheritance-Multiple b/Lang/Tcl/Inheritance-Multiple new file mode 120000 index 0000000000..5f7fc33a74 --- /dev/null +++ b/Lang/Tcl/Inheritance-Multiple @@ -0,0 +1 @@ +../../Task/Inheritance-Multiple/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Inheritance-Single b/Lang/Tcl/Inheritance-Single new file mode 120000 index 0000000000..8714425755 --- /dev/null +++ b/Lang/Tcl/Inheritance-Single @@ -0,0 +1 @@ +../../Task/Inheritance-Single/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Input-loop b/Lang/Tcl/Input-loop new file mode 120000 index 0000000000..540b737c8c --- /dev/null +++ b/Lang/Tcl/Input-loop @@ -0,0 +1 @@ +../../Task/Input-loop/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Integer-comparison b/Lang/Tcl/Integer-comparison new file mode 120000 index 0000000000..99a7f862be --- /dev/null +++ b/Lang/Tcl/Integer-comparison @@ -0,0 +1 @@ +../../Task/Integer-comparison/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Integer-sequence b/Lang/Tcl/Integer-sequence new file mode 120000 index 0000000000..026f6204cc --- /dev/null +++ b/Lang/Tcl/Integer-sequence @@ -0,0 +1 @@ +../../Task/Integer-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Interactive-programming b/Lang/Tcl/Interactive-programming new file mode 120000 index 0000000000..0ca678d3f3 --- /dev/null +++ b/Lang/Tcl/Interactive-programming @@ -0,0 +1 @@ +../../Task/Interactive-programming/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Introspection b/Lang/Tcl/Introspection new file mode 120000 index 0000000000..676b8e7a84 --- /dev/null +++ b/Lang/Tcl/Introspection @@ -0,0 +1 @@ +../../Task/Introspection/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Inverted-index b/Lang/Tcl/Inverted-index new file mode 120000 index 0000000000..68379e40d9 --- /dev/null +++ b/Lang/Tcl/Inverted-index @@ -0,0 +1 @@ +../../Task/Inverted-index/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Inverted-syntax b/Lang/Tcl/Inverted-syntax new file mode 120000 index 0000000000..e9292a1f31 --- /dev/null +++ b/Lang/Tcl/Inverted-syntax @@ -0,0 +1 @@ +../../Task/Inverted-syntax/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Jensens-Device b/Lang/Tcl/Jensens-Device new file mode 120000 index 0000000000..fcf72d25e6 --- /dev/null +++ b/Lang/Tcl/Jensens-Device @@ -0,0 +1 @@ +../../Task/Jensens-Device/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Josephus-problem b/Lang/Tcl/Josephus-problem new file mode 120000 index 0000000000..6597cb0f71 --- /dev/null +++ b/Lang/Tcl/Josephus-problem @@ -0,0 +1 @@ +../../Task/Josephus-problem/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Joystick-position b/Lang/Tcl/Joystick-position new file mode 120000 index 0000000000..071e43b8f0 --- /dev/null +++ b/Lang/Tcl/Joystick-position @@ -0,0 +1 @@ +../../Task/Joystick-position/Tcl \ No newline at end of file diff --git a/Lang/Tcl/K-means++-clustering b/Lang/Tcl/K-means++-clustering new file mode 120000 index 0000000000..fd3249425f --- /dev/null +++ b/Lang/Tcl/K-means++-clustering @@ -0,0 +1 @@ +../../Task/K-means++-clustering/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Kaprekar-numbers b/Lang/Tcl/Kaprekar-numbers new file mode 120000 index 0000000000..6a75cb666c --- /dev/null +++ b/Lang/Tcl/Kaprekar-numbers @@ -0,0 +1 @@ +../../Task/Kaprekar-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Keyboard-input-Flush-the-keyboard-buffer b/Lang/Tcl/Keyboard-input-Flush-the-keyboard-buffer new file mode 120000 index 0000000000..0fbf76e145 --- /dev/null +++ b/Lang/Tcl/Keyboard-input-Flush-the-keyboard-buffer @@ -0,0 +1 @@ +../../Task/Keyboard-input-Flush-the-keyboard-buffer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Keyboard-input-Keypress-check b/Lang/Tcl/Keyboard-input-Keypress-check new file mode 120000 index 0000000000..6450992aa8 --- /dev/null +++ b/Lang/Tcl/Keyboard-input-Keypress-check @@ -0,0 +1 @@ +../../Task/Keyboard-input-Keypress-check/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Keyboard-input-Obtain-a-Y-or-N-response b/Lang/Tcl/Keyboard-input-Obtain-a-Y-or-N-response new file mode 120000 index 0000000000..a693dfaf0d --- /dev/null +++ b/Lang/Tcl/Keyboard-input-Obtain-a-Y-or-N-response @@ -0,0 +1 @@ +../../Task/Keyboard-input-Obtain-a-Y-or-N-response/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Keyboard-macros b/Lang/Tcl/Keyboard-macros new file mode 120000 index 0000000000..e93aa044d7 --- /dev/null +++ b/Lang/Tcl/Keyboard-macros @@ -0,0 +1 @@ +../../Task/Keyboard-macros/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knapsack-problem-0-1 b/Lang/Tcl/Knapsack-problem-0-1 new file mode 120000 index 0000000000..dd505edac8 --- /dev/null +++ b/Lang/Tcl/Knapsack-problem-0-1 @@ -0,0 +1 @@ +../../Task/Knapsack-problem-0-1/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knapsack-problem-Bounded b/Lang/Tcl/Knapsack-problem-Bounded new file mode 120000 index 0000000000..6bbf42f956 --- /dev/null +++ b/Lang/Tcl/Knapsack-problem-Bounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Bounded/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knapsack-problem-Continuous b/Lang/Tcl/Knapsack-problem-Continuous new file mode 120000 index 0000000000..aaff170cce --- /dev/null +++ b/Lang/Tcl/Knapsack-problem-Continuous @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Continuous/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knapsack-problem-Unbounded b/Lang/Tcl/Knapsack-problem-Unbounded new file mode 120000 index 0000000000..7a74f296e9 --- /dev/null +++ b/Lang/Tcl/Knapsack-problem-Unbounded @@ -0,0 +1 @@ +../../Task/Knapsack-problem-Unbounded/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knights-tour b/Lang/Tcl/Knights-tour new file mode 120000 index 0000000000..fd66674dda --- /dev/null +++ b/Lang/Tcl/Knights-tour @@ -0,0 +1 @@ +../../Task/Knights-tour/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Knuths-algorithm-S b/Lang/Tcl/Knuths-algorithm-S new file mode 120000 index 0000000000..871baee1cd --- /dev/null +++ b/Lang/Tcl/Knuths-algorithm-S @@ -0,0 +1 @@ +../../Task/Knuths-algorithm-S/Tcl \ No newline at end of file diff --git a/Lang/Tcl/LU-decomposition b/Lang/Tcl/LU-decomposition new file mode 120000 index 0000000000..9e1bcfc819 --- /dev/null +++ b/Lang/Tcl/LU-decomposition @@ -0,0 +1 @@ +../../Task/LU-decomposition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/LZW-compression b/Lang/Tcl/LZW-compression new file mode 120000 index 0000000000..3813a536b0 --- /dev/null +++ b/Lang/Tcl/LZW-compression @@ -0,0 +1 @@ +../../Task/LZW-compression/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Langtons-ant b/Lang/Tcl/Langtons-ant new file mode 120000 index 0000000000..c0a6193496 --- /dev/null +++ b/Lang/Tcl/Langtons-ant @@ -0,0 +1 @@ +../../Task/Langtons-ant/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Largest-int-from-concatenated-ints b/Lang/Tcl/Largest-int-from-concatenated-ints new file mode 120000 index 0000000000..9d9a3efe46 --- /dev/null +++ b/Lang/Tcl/Largest-int-from-concatenated-ints @@ -0,0 +1 @@ +../../Task/Largest-int-from-concatenated-ints/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Last-Friday-of-each-month b/Lang/Tcl/Last-Friday-of-each-month new file mode 120000 index 0000000000..1e1a75947c --- /dev/null +++ b/Lang/Tcl/Last-Friday-of-each-month @@ -0,0 +1 @@ +../../Task/Last-Friday-of-each-month/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Last-letter-first-letter b/Lang/Tcl/Last-letter-first-letter new file mode 120000 index 0000000000..bce4cbf4cd --- /dev/null +++ b/Lang/Tcl/Last-letter-first-letter @@ -0,0 +1 @@ +../../Task/Last-letter-first-letter/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Leap-year b/Lang/Tcl/Leap-year new file mode 120000 index 0000000000..b133dd3434 --- /dev/null +++ b/Lang/Tcl/Leap-year @@ -0,0 +1 @@ +../../Task/Leap-year/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Least-common-multiple b/Lang/Tcl/Least-common-multiple new file mode 120000 index 0000000000..b239e15560 --- /dev/null +++ b/Lang/Tcl/Least-common-multiple @@ -0,0 +1 @@ +../../Task/Least-common-multiple/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Letter-frequency b/Lang/Tcl/Letter-frequency new file mode 120000 index 0000000000..a68a68fcfd --- /dev/null +++ b/Lang/Tcl/Letter-frequency @@ -0,0 +1 @@ +../../Task/Letter-frequency/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Levenshtein-distance b/Lang/Tcl/Levenshtein-distance new file mode 120000 index 0000000000..2037f540d6 --- /dev/null +++ b/Lang/Tcl/Levenshtein-distance @@ -0,0 +1 @@ +../../Task/Levenshtein-distance/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Linear-congruential-generator b/Lang/Tcl/Linear-congruential-generator new file mode 120000 index 0000000000..8390dbf95e --- /dev/null +++ b/Lang/Tcl/Linear-congruential-generator @@ -0,0 +1 @@ +../../Task/Linear-congruential-generator/Tcl \ No newline at end of file diff --git a/Lang/Tcl/List-comprehensions b/Lang/Tcl/List-comprehensions new file mode 120000 index 0000000000..6a43a716cf --- /dev/null +++ b/Lang/Tcl/List-comprehensions @@ -0,0 +1 @@ +../../Task/List-comprehensions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Literals-Integer b/Lang/Tcl/Literals-Integer new file mode 120000 index 0000000000..59ec577376 --- /dev/null +++ b/Lang/Tcl/Literals-Integer @@ -0,0 +1 @@ +../../Task/Literals-Integer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Literals-String b/Lang/Tcl/Literals-String new file mode 120000 index 0000000000..1c109dd388 --- /dev/null +++ b/Lang/Tcl/Literals-String @@ -0,0 +1 @@ +../../Task/Literals-String/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Logical-operations b/Lang/Tcl/Logical-operations new file mode 120000 index 0000000000..3cd032b251 --- /dev/null +++ b/Lang/Tcl/Logical-operations @@ -0,0 +1 @@ +../../Task/Logical-operations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Long-multiplication b/Lang/Tcl/Long-multiplication new file mode 120000 index 0000000000..7354bab6d6 --- /dev/null +++ b/Lang/Tcl/Long-multiplication @@ -0,0 +1 @@ +../../Task/Long-multiplication/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Longest-common-subsequence b/Lang/Tcl/Longest-common-subsequence new file mode 120000 index 0000000000..75e189e2fd --- /dev/null +++ b/Lang/Tcl/Longest-common-subsequence @@ -0,0 +1 @@ +../../Task/Longest-common-subsequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Longest-string-challenge b/Lang/Tcl/Longest-string-challenge new file mode 120000 index 0000000000..a763dd7e32 --- /dev/null +++ b/Lang/Tcl/Longest-string-challenge @@ -0,0 +1 @@ +../../Task/Longest-string-challenge/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Look-and-say-sequence b/Lang/Tcl/Look-and-say-sequence new file mode 120000 index 0000000000..95c9e9073f --- /dev/null +++ b/Lang/Tcl/Look-and-say-sequence @@ -0,0 +1 @@ +../../Task/Look-and-say-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loop-over-multiple-arrays-simultaneously b/Lang/Tcl/Loop-over-multiple-arrays-simultaneously new file mode 120000 index 0000000000..011c5f2654 --- /dev/null +++ b/Lang/Tcl/Loop-over-multiple-arrays-simultaneously @@ -0,0 +1 @@ +../../Task/Loop-over-multiple-arrays-simultaneously/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Break b/Lang/Tcl/Loops-Break new file mode 120000 index 0000000000..6adb4b1655 --- /dev/null +++ b/Lang/Tcl/Loops-Break @@ -0,0 +1 @@ +../../Task/Loops-Break/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Continue b/Lang/Tcl/Loops-Continue new file mode 120000 index 0000000000..f352ccc53f --- /dev/null +++ b/Lang/Tcl/Loops-Continue @@ -0,0 +1 @@ +../../Task/Loops-Continue/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Do-while b/Lang/Tcl/Loops-Do-while new file mode 120000 index 0000000000..06959ef733 --- /dev/null +++ b/Lang/Tcl/Loops-Do-while @@ -0,0 +1 @@ +../../Task/Loops-Do-while/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Downward-for b/Lang/Tcl/Loops-Downward-for new file mode 120000 index 0000000000..ab3882fdc5 --- /dev/null +++ b/Lang/Tcl/Loops-Downward-for @@ -0,0 +1 @@ +../../Task/Loops-Downward-for/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-For b/Lang/Tcl/Loops-For new file mode 120000 index 0000000000..65f3b2c945 --- /dev/null +++ b/Lang/Tcl/Loops-For @@ -0,0 +1 @@ +../../Task/Loops-For/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-For-with-a-specified-step b/Lang/Tcl/Loops-For-with-a-specified-step new file mode 120000 index 0000000000..0b1f4d4e26 --- /dev/null +++ b/Lang/Tcl/Loops-For-with-a-specified-step @@ -0,0 +1 @@ +../../Task/Loops-For-with-a-specified-step/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Foreach b/Lang/Tcl/Loops-Foreach new file mode 120000 index 0000000000..1961afb83a --- /dev/null +++ b/Lang/Tcl/Loops-Foreach @@ -0,0 +1 @@ +../../Task/Loops-Foreach/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Infinite b/Lang/Tcl/Loops-Infinite new file mode 120000 index 0000000000..f69f661120 --- /dev/null +++ b/Lang/Tcl/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-N-plus-one-half b/Lang/Tcl/Loops-N-plus-one-half new file mode 120000 index 0000000000..47a85cecd0 --- /dev/null +++ b/Lang/Tcl/Loops-N-plus-one-half @@ -0,0 +1 @@ +../../Task/Loops-N-plus-one-half/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-Nested b/Lang/Tcl/Loops-Nested new file mode 120000 index 0000000000..60f1e81e0a --- /dev/null +++ b/Lang/Tcl/Loops-Nested @@ -0,0 +1 @@ +../../Task/Loops-Nested/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Loops-While b/Lang/Tcl/Loops-While new file mode 120000 index 0000000000..02b289da64 --- /dev/null +++ b/Lang/Tcl/Loops-While @@ -0,0 +1 @@ +../../Task/Loops-While/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Lucas-Lehmer-test b/Lang/Tcl/Lucas-Lehmer-test new file mode 120000 index 0000000000..79f56a22f5 --- /dev/null +++ b/Lang/Tcl/Lucas-Lehmer-test @@ -0,0 +1 @@ +../../Task/Lucas-Lehmer-test/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Luhn-test-of-credit-card-numbers b/Lang/Tcl/Luhn-test-of-credit-card-numbers new file mode 120000 index 0000000000..81984537ca --- /dev/null +++ b/Lang/Tcl/Luhn-test-of-credit-card-numbers @@ -0,0 +1 @@ +../../Task/Luhn-test-of-credit-card-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/MD4 b/Lang/Tcl/MD4 new file mode 120000 index 0000000000..25b211636c --- /dev/null +++ b/Lang/Tcl/MD4 @@ -0,0 +1 @@ +../../Task/MD4/Tcl \ No newline at end of file diff --git a/Lang/Tcl/MD5 b/Lang/Tcl/MD5 new file mode 120000 index 0000000000..122c034e17 --- /dev/null +++ b/Lang/Tcl/MD5 @@ -0,0 +1 @@ +../../Task/MD5/Tcl \ No newline at end of file diff --git a/Lang/Tcl/MD5-Implementation b/Lang/Tcl/MD5-Implementation new file mode 120000 index 0000000000..6ff94c2275 --- /dev/null +++ b/Lang/Tcl/MD5-Implementation @@ -0,0 +1 @@ +../../Task/MD5-Implementation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Mad-Libs b/Lang/Tcl/Mad-Libs new file mode 120000 index 0000000000..e97911ea7d --- /dev/null +++ b/Lang/Tcl/Mad-Libs @@ -0,0 +1 @@ +../../Task/Mad-Libs/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Main-step-of-GOST-28147-89 b/Lang/Tcl/Main-step-of-GOST-28147-89 new file mode 120000 index 0000000000..a96dbed529 --- /dev/null +++ b/Lang/Tcl/Main-step-of-GOST-28147-89 @@ -0,0 +1 @@ +../../Task/Main-step-of-GOST-28147-89/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Man-or-boy-test b/Lang/Tcl/Man-or-boy-test new file mode 120000 index 0000000000..99c895bb3a --- /dev/null +++ b/Lang/Tcl/Man-or-boy-test @@ -0,0 +1 @@ +../../Task/Man-or-boy-test/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Mandelbrot-set b/Lang/Tcl/Mandelbrot-set new file mode 120000 index 0000000000..774ee37ce0 --- /dev/null +++ b/Lang/Tcl/Mandelbrot-set @@ -0,0 +1 @@ +../../Task/Mandelbrot-set/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Map-range b/Lang/Tcl/Map-range new file mode 120000 index 0000000000..f3409bcabc --- /dev/null +++ b/Lang/Tcl/Map-range @@ -0,0 +1 @@ +../../Task/Map-range/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Matrix-arithmetic b/Lang/Tcl/Matrix-arithmetic new file mode 120000 index 0000000000..f015a12a91 --- /dev/null +++ b/Lang/Tcl/Matrix-arithmetic @@ -0,0 +1 @@ +../../Task/Matrix-arithmetic/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Matrix-exponentiation-operator b/Lang/Tcl/Matrix-exponentiation-operator new file mode 120000 index 0000000000..bf735d16cb --- /dev/null +++ b/Lang/Tcl/Matrix-exponentiation-operator @@ -0,0 +1 @@ +../../Task/Matrix-exponentiation-operator/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Matrix-multiplication b/Lang/Tcl/Matrix-multiplication new file mode 120000 index 0000000000..86c5ed9c2e --- /dev/null +++ b/Lang/Tcl/Matrix-multiplication @@ -0,0 +1 @@ +../../Task/Matrix-multiplication/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Matrix-transposition b/Lang/Tcl/Matrix-transposition new file mode 120000 index 0000000000..b6446c1b35 --- /dev/null +++ b/Lang/Tcl/Matrix-transposition @@ -0,0 +1 @@ +../../Task/Matrix-transposition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Maze-generation b/Lang/Tcl/Maze-generation new file mode 120000 index 0000000000..ca7475669e --- /dev/null +++ b/Lang/Tcl/Maze-generation @@ -0,0 +1 @@ +../../Task/Maze-generation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Maze-solving b/Lang/Tcl/Maze-solving new file mode 120000 index 0000000000..e0c00f2576 --- /dev/null +++ b/Lang/Tcl/Maze-solving @@ -0,0 +1 @@ +../../Task/Maze-solving/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Median-filter b/Lang/Tcl/Median-filter new file mode 120000 index 0000000000..297b58f0e8 --- /dev/null +++ b/Lang/Tcl/Median-filter @@ -0,0 +1 @@ +../../Task/Median-filter/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Memory-allocation b/Lang/Tcl/Memory-allocation new file mode 120000 index 0000000000..11c5f33f30 --- /dev/null +++ b/Lang/Tcl/Memory-allocation @@ -0,0 +1 @@ +../../Task/Memory-allocation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Memory-layout-of-a-data-structure b/Lang/Tcl/Memory-layout-of-a-data-structure new file mode 120000 index 0000000000..0d845697ef --- /dev/null +++ b/Lang/Tcl/Memory-layout-of-a-data-structure @@ -0,0 +1 @@ +../../Task/Memory-layout-of-a-data-structure/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Menu b/Lang/Tcl/Menu new file mode 120000 index 0000000000..ecedbc3b9c --- /dev/null +++ b/Lang/Tcl/Menu @@ -0,0 +1 @@ +../../Task/Menu/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Metaprogramming b/Lang/Tcl/Metaprogramming new file mode 120000 index 0000000000..bfd9e7976e --- /dev/null +++ b/Lang/Tcl/Metaprogramming @@ -0,0 +1 @@ +../../Task/Metaprogramming/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Metered-concurrency b/Lang/Tcl/Metered-concurrency new file mode 120000 index 0000000000..7f0c871428 --- /dev/null +++ b/Lang/Tcl/Metered-concurrency @@ -0,0 +1 @@ +../../Task/Metered-concurrency/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Metronome b/Lang/Tcl/Metronome new file mode 120000 index 0000000000..e3dbaf5bd2 --- /dev/null +++ b/Lang/Tcl/Metronome @@ -0,0 +1 @@ +../../Task/Metronome/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Middle-three-digits b/Lang/Tcl/Middle-three-digits new file mode 120000 index 0000000000..ec76b27218 --- /dev/null +++ b/Lang/Tcl/Middle-three-digits @@ -0,0 +1 @@ +../../Task/Middle-three-digits/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Miller-Rabin-primality-test b/Lang/Tcl/Miller-Rabin-primality-test new file mode 120000 index 0000000000..5e3095425f --- /dev/null +++ b/Lang/Tcl/Miller-Rabin-primality-test @@ -0,0 +1 @@ +../../Task/Miller-Rabin-primality-test/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Minesweeper-game b/Lang/Tcl/Minesweeper-game new file mode 120000 index 0000000000..10ef611291 --- /dev/null +++ b/Lang/Tcl/Minesweeper-game @@ -0,0 +1 @@ +../../Task/Minesweeper-game/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Modular-exponentiation b/Lang/Tcl/Modular-exponentiation new file mode 120000 index 0000000000..3c28084d92 --- /dev/null +++ b/Lang/Tcl/Modular-exponentiation @@ -0,0 +1 @@ +../../Task/Modular-exponentiation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Modular-inverse b/Lang/Tcl/Modular-inverse new file mode 120000 index 0000000000..10d64545a6 --- /dev/null +++ b/Lang/Tcl/Modular-inverse @@ -0,0 +1 @@ +../../Task/Modular-inverse/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Monte-Carlo-methods b/Lang/Tcl/Monte-Carlo-methods new file mode 120000 index 0000000000..e0c96937ee --- /dev/null +++ b/Lang/Tcl/Monte-Carlo-methods @@ -0,0 +1 @@ +../../Task/Monte-Carlo-methods/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Monty-Hall-problem b/Lang/Tcl/Monty-Hall-problem new file mode 120000 index 0000000000..f15966a8d5 --- /dev/null +++ b/Lang/Tcl/Monty-Hall-problem @@ -0,0 +1 @@ +../../Task/Monty-Hall-problem/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Morse-code b/Lang/Tcl/Morse-code new file mode 120000 index 0000000000..cb5ddf13ac --- /dev/null +++ b/Lang/Tcl/Morse-code @@ -0,0 +1 @@ +../../Task/Morse-code/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Mouse-position b/Lang/Tcl/Mouse-position new file mode 120000 index 0000000000..fc31f3a744 --- /dev/null +++ b/Lang/Tcl/Mouse-position @@ -0,0 +1 @@ +../../Task/Mouse-position/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multifactorial b/Lang/Tcl/Multifactorial new file mode 120000 index 0000000000..9a61ddac9f --- /dev/null +++ b/Lang/Tcl/Multifactorial @@ -0,0 +1 @@ +../../Task/Multifactorial/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multiple-distinct-objects b/Lang/Tcl/Multiple-distinct-objects new file mode 120000 index 0000000000..8267a55368 --- /dev/null +++ b/Lang/Tcl/Multiple-distinct-objects @@ -0,0 +1 @@ +../../Task/Multiple-distinct-objects/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multiple-regression b/Lang/Tcl/Multiple-regression new file mode 120000 index 0000000000..b3423d6b6c --- /dev/null +++ b/Lang/Tcl/Multiple-regression @@ -0,0 +1 @@ +../../Task/Multiple-regression/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multiplication-tables b/Lang/Tcl/Multiplication-tables new file mode 120000 index 0000000000..41c9b9f772 --- /dev/null +++ b/Lang/Tcl/Multiplication-tables @@ -0,0 +1 @@ +../../Task/Multiplication-tables/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multiplicative-order b/Lang/Tcl/Multiplicative-order new file mode 120000 index 0000000000..327d277260 --- /dev/null +++ b/Lang/Tcl/Multiplicative-order @@ -0,0 +1 @@ +../../Task/Multiplicative-order/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Multisplit b/Lang/Tcl/Multisplit new file mode 120000 index 0000000000..4ab3fef29d --- /dev/null +++ b/Lang/Tcl/Multisplit @@ -0,0 +1 @@ +../../Task/Multisplit/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Mutex b/Lang/Tcl/Mutex new file mode 120000 index 0000000000..cacc864612 --- /dev/null +++ b/Lang/Tcl/Mutex @@ -0,0 +1 @@ +../../Task/Mutex/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Mutual-recursion b/Lang/Tcl/Mutual-recursion new file mode 120000 index 0000000000..07685f07ac --- /dev/null +++ b/Lang/Tcl/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/Tcl \ No newline at end of file diff --git a/Meta/Lang.yaml b/Meta/Lang.yaml index 52eda8b49f..bd99307542 100644 --- a/Meta/Lang.yaml +++ b/Meta/Lang.yaml @@ -704,6 +704,101 @@ Excel: name: Excel path: Excel url: Excel +F: + ext: f + name: F + path: F + url: F +F Sharp: + ext: fs + name: F Sharp + path: F-Sharp + url: F_Sharp +FALSE: + ext: 'false' + name: FALSE + path: FALSE + url: FALSE +FAUST: + ext: faust + name: FAUST + path: FAUST + url: FAUST +FBSL: + ext: fbsl + name: FBSL + path: FBSL + url: FBSL +FLORA-2: + ext: flora-2 + name: FLORA-2 + path: FLORA-2 + url: FLORA-2 +FP: + ext: fp + name: FP + path: FP + url: FP +FPI: + ext: fpi + name: FPI + path: FPI + url: FPI +Factor: + ext: factor + name: Factor + path: Factor + url: Factor +Falcon: + ext: falcon + name: Falcon + path: Falcon + url: Falcon +Fan: + ext: fan + name: Fan + path: Fan + url: Fan +Fancy: + ext: fancy + name: Fancy + path: Fancy + url: Fancy +Fantom: + ext: fantom + name: Fantom + path: Fantom + url: Fantom +FeatureC++: + ext: cpp + name: FeatureC++ + path: FeatureC++ + url: FeatureC++ +Felix: + ext: felix + name: Felix + path: Felix + url: Felix +Ferite: + ext: ferite + name: Ferite + path: Ferite + url: Ferite +Fexl: + ext: fexl + name: Fexl + path: Fexl + url: Fexl +Fish: + ext: fish + name: Fish + path: Fish + url: Fish +Florid: + ext: florid + name: Florid + path: Florid + url: Florid Forth: ext: fth name: Forth @@ -714,41 +809,626 @@ Fortran: name: Fortran path: Fortran url: Fortran +Fortress: + ext: fortress + name: Fortress + path: Fortress + url: Fortress +Free Pascal/Lazarus: + ext: pas + name: Free Pascal/Lazarus + path: Free-Pascal-Lazarus + url: Free_Pascal/Lazarus +FreeMat: + ext: freemat + name: FreeMat + path: FreeMat + url: FreeMat +Frege: + ext: frege + name: Frege + path: Frege + url: Frege +Friendly interactive shell: + ext: fish + name: Friendly interactive shell + path: Friendly-interactive-shell + url: Friendly_interactive_shell +Frink: + ext: frink + name: Frink + path: Frink + url: Frink +GAP: + ext: gap + name: GAP + path: GAP + url: GAP +GLBasic: + ext: glbasic + name: GLBasic + path: GLBasic + url: GLBasic +GML: + ext: gml + name: GML + path: GML + url: GML +GUISS: + ext: guiss + name: GUISS + path: GUISS + url: GUISS +GW-BASIC: + ext: bas + name: GW-BASIC + path: GW-BASIC + url: GW-BASIC +Gambas: + ext: gambas + name: Gambas + path: Gambas + url: Gambas +Gdl: + ext: gdl + name: Gdl + path: Gdl + url: Gdl +Gecho: + ext: gecho + name: Gecho + path: Gecho + url: Gecho +Gema: + ext: gema + name: Gema + path: Gema + url: Gema +Gentee: + ext: gentee + name: Gentee + path: Gentee + url: Gentee +Genyris: + ext: genyris + name: Genyris + path: Genyris + url: Genyris +Glee: + ext: glee + name: Glee + path: Glee + url: Glee +Gnuplot: + ext: gnuplot + name: Gnuplot + path: Gnuplot + url: Gnuplot Go: ext: go name: Go path: Go url: Go +Golfscript: + ext: golf + name: Golfscript + path: Golfscript + url: Golfscript +Goo: + ext: goo + name: Goo + path: Goo + url: Goo +Gosu: + ext: gosu + name: Gosu + path: Gosu + url: Gosu +Groovy: + ext: groovy + name: Groovy + path: Groovy + url: Groovy +HLA: + ext: hla + name: HLA + path: HLA + url: HLA +HQ9+: + ext: hq9p + name: HQ9+ + path: HQ9+ + url: HQ9+ Haskell: ext: hs name: Haskell path: Haskell url: Haskell +Haxe: + ext: haxe + name: Haxe + path: Haxe + url: Haxe +Heron: + ext: heron + name: Heron + path: Heron + url: Heron +HicEst: + ext: hicest + name: HicEst + path: HicEst + url: HicEst +Hope: + ext: hope + name: Hope + path: Hope + url: Hope +HyperTalk: + ext: ht + name: HyperTalk + path: HyperTalk + url: HyperTalk +IDL: + ext: idl + name: IDL + path: IDL + url: IDL +Icon: + ext: icon + name: Icon + path: Icon + url: Icon +Inform 6: + ext: inf + name: Inform 6 + path: Inform-6 + url: Inform_6 +Inform 7: + ext: inf + name: Inform 7 + path: Inform-7 + url: Inform_7 +Informix 4GL: + ext: 4gl + name: Informix 4GL + path: Informix-4GL + url: Informix_4GL +Integer BASIC: + ext: bas + name: Integer BASIC + path: Integer-BASIC + url: Integer_BASIC +Intercal: + ext: ical + name: Intercal + path: Intercal + url: Intercal +Io: + ext: io + name: Io + path: Io + url: Io +Ioke: + ext: ioke + name: Ioke + path: Ioke + url: Ioke +Iptscrae: + ext: iptscrae + name: Iptscrae + path: Iptscrae + url: Iptscrae +J: + ext: j + name: J + path: J + url: J +JAMES II/Rule-based Cellular Automata: + ext: james + name: JAMES II/Rule-based Cellular Automata + path: JAMES-II-Rule-based-Cellular-Automata + url: JAMES_II/Rule-based_Cellular_Automata +JCL: + ext: jcl + name: JCL + path: JCL + url: JCL +JScript.NET: + ext: net + name: JScript.NET + path: JScript.NET + url: JScript.NET +Jabaco: + ext: jabaco + name: Jabaco + path: Jabaco + url: Jabaco +Jacquard Loom: + ext: jacquard + name: Jacquard Loom + path: Jacquard-Loom + url: Jacquard_Loom Java: ext: java name: Java path: Java url: Java +JavaFX Script: + ext: javafx + name: JavaFX Script + path: JavaFX-Script + url: JavaFX_Script JavaScript: ext: js name: JavaScript path: JavaScript url: JavaScript +Jcon: + ext: jcon + name: Jcon + path: Jcon + url: Jcon +JoCaml: + ext: jocaml + name: JoCaml + path: JoCaml + url: JoCaml +Joy: + ext: joy + name: Joy + path: Joy + url: Joy +JudoScript: + ext: judo + name: JudoScript + path: JudoScript + url: JudoScript +Julia: + ext: julia + name: Julia + path: Julia + url: Julia +K: + ext: k + name: K + path: K + url: K +K3d: + ext: k3d + name: K3d + path: K3d + url: K3d +Kaya: + ext: kaya + name: Kaya + path: Kaya + url: Kaya +KeyList Databasing: + ext: keylist + name: KeyList Databasing + path: KeyList-Databasing + url: KeyList_Databasing +Kite: + ext: kite + name: Kite + path: Kite + url: Kite +KonsolScript: + ext: konso + name: KonsolScript + path: KonsolScript + url: KonsolScript +Kotlin: + ext: kotlin + name: Kotlin + path: Kotlin + url: Kotlin +L.in.oleum: + ext: lin + name: L.in.oleum + path: L.in.oleum + url: L.in.oleum +LLP: + ext: llp + name: LLP + path: LLP + url: LLP +LLVM: + ext: llvm + name: LLVM + path: LLVM + url: LLVM +LOLCODE: + ext: lol + name: LOLCODE + path: LOLCODE + url: LOLCODE +LSE64: + ext: lse64 + name: LSE64 + path: LSE64 + url: LSE64 +LSL: + ext: lsl + name: LSL + path: LSL + url: LSL LaTeX: ext: tex name: LaTeX path: LaTeX url: LaTeX +LabVIEW: + ext: labview + name: LabVIEW + path: LabVIEW + url: LabVIEW +Lang5: + ext: lang5 + name: Lang5 + path: Lang5 + url: Lang5 +Lhogho: + ext: lhogho + name: Lhogho + path: Lhogho + url: Lhogho +Liberty BASIC: + ext: liberty + name: Liberty BASIC + path: Liberty-BASIC + url: Liberty_BASIC +Lilypond: + ext: lilypond + name: Lilypond + path: Lilypond + url: Lilypond +Limbo: + ext: limbo + name: Limbo + path: Limbo + url: Limbo +Lisaac: + ext: lisaac + name: Lisaac + path: Lisaac + url: Lisaac +Lisp: + ext: lisp + name: Lisp + path: Lisp + url: Lisp +Locomotive Basic: + ext: bas + name: Locomotive Basic + path: Locomotive-Basic + url: Locomotive_Basic +Logo: + ext: logo + name: Logo + path: Logo + url: Logo +Logtalk: + ext: logtalk + name: Logtalk + path: Logtalk + url: Logtalk +Lolli: + ext: lolli + name: Lolli + path: Lolli + url: Lolli +Lotus 123 Macro Scripting: + ext: lotus + name: Lotus 123 Macro Scripting + path: Lotus-123-Macro-Scripting + url: Lotus_123_Macro_Scripting +LotusScript: + ext: lotus + name: LotusScript + path: LotusScript + url: LotusScript +Lout: + ext: lout + name: Lout + path: Lout + url: Lout Lua: ext: lua name: Lua path: Lua url: Lua +Lucid: + ext: lucid + name: Lucid + path: Lucid + url: Lucid +Lush: + ext: lush + name: Lush + path: Lush + url: Lush +Lygon: + ext: lygon + name: Lygon + path: Lygon + url: Lygon +M4: + ext: m4 + name: M4 + path: M4 + url: M4 +M680x0: + ext: m680x0 + name: M680x0 + path: M680x0 + url: M680x0 +MAPPER: + ext: mapper + name: MAPPER + path: MAPPER + url: MAPPER MATLAB: ext: m name: MATLAB path: MATLAB url: MATLAB +MAXScript: + ext: max + name: MAXScript + path: MAXScript + url: MAXScript +MBS: + ext: mbs + name: MBS + path: MBS + url: MBS +ME10 macro: + ext: me10 + name: ME10 macro + path: ME10-macro + url: ME10_macro +MEL: + ext: mel + name: MEL + path: MEL + url: MEL +MGS: + ext: mgs + name: MGS + path: MGS + url: MGS +MIPS Assembly: + ext: mips + name: MIPS Assembly + path: MIPS-Assembly + url: MIPS_Assembly +MIRC Scripting Language: + ext: mirc + name: MIRC Scripting Language + path: MIRC-Scripting-Language + url: MIRC_Scripting_Language +ML/I: + ext: ml + name: ML/I + path: ML-I + url: ML/I +MMIX: + ext: mmix + name: MMIX + path: MMIX + url: MMIX +MOO: + ext: moo + name: MOO + path: MOO + url: MOO +MPIF90: + ext: mpif90 + name: MPIF90 + path: MPIF90 + url: MPIF90 +MS SQL: + ext: ms + name: MS SQL + path: MS-SQL + url: MS_SQL +MSSQL: + ext: mssql + name: MSSQL + path: MSSQL + url: MSSQL +MUF: + ext: muf + name: MUF + path: MUF + url: MUF +MUMPS: + ext: mumps + name: MUMPS + path: MUMPS + url: MUMPS +Make: + ext: make + name: Make + path: Make + url: Make +Maple: + ext: maple + name: Maple + path: Maple + url: Maple +Mathematica: + ext: mathematica + name: Mathematica + path: Mathematica + url: Mathematica +Mathprog: + ext: mathprog + name: Mathprog + path: Mathprog + url: Mathprog +Maxima: + ext: maxima + name: Maxima + path: Maxima + url: Maxima +Mercury: + ext: mercury + name: Mercury + path: Mercury + url: Mercury +Metafont: + ext: metafont + name: Metafont + path: Metafont + url: Metafont +Metapost: + ext: metapost + name: Metapost + path: Metapost + url: Metapost +Mirah: + ext: mirah + name: Mirah + path: Mirah + url: Mirah +Mirelle: + ext: mirelle + name: Mirelle + path: Mirelle + url: Mirelle +Modula-2: + ext: mod2 + name: Modula-2 + path: Modula-2 + url: Modula-2 +Modula-3: + ext: mod3 + name: Modula-3 + path: Modula-3 + url: Modula-3 +Moonscript: + ext: moon + name: Moonscript + path: Moonscript + url: Moonscript +MySQL: + ext: mysql + name: MySQL + path: MySQL + url: MySQL +Mython: + ext: mython + name: Mython + path: Mython + url: Mython +Mythryl: + ext: mythryl + name: Mythryl + path: Mythryl + url: Mythryl PHP: ext: php name: PHP diff --git a/Meta/Task.yaml b/Meta/Task.yaml index ffdd0eb5fb..b2ea35bc04 100644 --- a/Meta/Task.yaml +++ b/Meta/Task.yaml @@ -7,6 +7,10 @@ name: 24 game path: 24-game url: 24_game +24 game/Solve: + name: 24 game/Solve + path: 24-game-Solve + url: 24_game/Solve 99 Bottles of Beer: name: 99 Bottles of Beer path: 99-Bottles-of-Beer @@ -77,7 +81,7 @@ Apply a callback to an array: url: Apply_a_callback_to_an_array Arbitrary-precision integers (included): name: Arbitrary-precision integers (included) - path: Arbitrary-precision-integers-(included) + path: Arbitrary-precision-integers-included url: Arbitrary-precision_integers_(included) Arena storage pool: name: Arena storage pool @@ -425,12 +429,12 @@ Continued fraction/Arithmetic/Construct from rational number: url: Continued_fraction/Arithmetic/Construct_from_rational_number Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N): name: Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N) - path: Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N) + path: Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N url: Continued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N) Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N1, Contined Fraction N2): name: Continued fraction/Arithmetic/G(matrix NG, Contined Fraction N1, Contined Fraction N2) - path: Continued-fraction-Arithmetic-G(matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2) + path: Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 url: Continued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N1,_Contined_Fraction_N2) Conway's Game of Life: name: Conway's Game of Life @@ -688,30 +692,758 @@ Extreme floating point values: name: Extreme floating point values path: Extreme-floating-point-values url: Extreme_floating_point_values +Factorial: + name: Factorial + path: Factorial + url: Factorial +Factors of a Mersenne number: + name: Factors of a Mersenne number + path: Factors-of-a-Mersenne-number + url: Factors_of_a_Mersenne_number +Factors of an integer: + name: Factors of an integer + path: Factors-of-an-integer + url: Factors_of_an_integer +Fast Fourier transform: + name: Fast Fourier transform + path: Fast-Fourier-transform + url: Fast_Fourier_transform +Fibonacci n-step number sequences: + name: Fibonacci n-step number sequences + path: Fibonacci-n-step-number-sequences + url: Fibonacci_n-step_number_sequences +Fibonacci sequence: + name: Fibonacci sequence + path: Fibonacci-sequence + url: Fibonacci_sequence +File IO: + name: File IO + path: File-IO + url: File_IO +File modification time: + name: File modification time + path: File-modification-time + url: File_modification_time +File size: + name: File size + path: File-size + url: File_size +Filter: + name: Filter + path: Filter + url: Filter +Find common directory path: + name: Find common directory path + path: Find-common-directory-path + url: Find_common_directory_path +Find largest left truncatable prime in a given base: + name: Find largest left truncatable prime in a given base + path: Find-largest-left-truncatable-prime-in-a-given-base + url: Find_largest_left_truncatable_prime_in_a_given_base +Find limit of recursion: + name: Find limit of recursion + path: Find-limit-of-recursion + url: Find_limit_of_recursion +Find the missing permutation: + name: Find the missing permutation + path: Find-the-missing-permutation + url: Find_the_missing_permutation +First class environments: + name: First class environments + path: First-class-environments + url: First_class_environments +First-class functions: + name: First-class functions + path: First-class-functions + url: First-class_functions +First-class functions/Use numbers analogously: + name: First-class functions/Use numbers analogously + path: First-class-functions-Use-numbers-analogously + url: First-class_functions/Use_numbers_analogously +Five weekends: + name: Five weekends + path: Five-weekends + url: Five_weekends FizzBuzz: name: FizzBuzz path: FizzBuzz url: FizzBuzz +Flatten a list: + name: Flatten a list + path: Flatten-a-list + url: Flatten_a_list +Flow-control structures: + name: Flow-control structures + path: Flow-control-structures + url: Flow-control_structures +Floyd's triangle: + name: Floyd's triangle + path: Floyds-triangle + url: Floyd's_triangle Forest fire: name: Forest fire path: Forest-fire url: Forest_fire +Fork: + name: Fork + path: Fork + url: Fork +Formal power series: + name: Formal power series + path: Formal-power-series + url: Formal_power_series +Formatted numeric output: + name: Formatted numeric output + path: Formatted-numeric-output + url: Formatted_numeric_output +Forward difference: + name: Forward difference + path: Forward-difference + url: Forward_difference +Four bit adder: + name: Four bit adder + path: Four-bit-adder + url: Four_bit_adder +Fractal tree: + name: Fractal tree + path: Fractal-tree + url: Fractal_tree +Function composition: + name: Function composition + path: Function-composition + url: Function_composition +Function definition: + name: Function definition + path: Function-definition + url: Function_definition +Function frequency: + name: Function frequency + path: Function-frequency + url: Function_frequency +Function prototype: + name: Function prototype + path: Function-prototype + url: Function_prototype +GUI component interaction: + name: GUI component interaction + path: GUI-component-interaction + url: GUI_component_interaction +GUI enabling/disabling of controls: + name: GUI enabling/disabling of controls + path: GUI-enabling-disabling-of-controls + url: GUI_enabling/disabling_of_controls +GUI/Maximum window dimensions: + name: GUI/Maximum window dimensions + path: GUI-Maximum-window-dimensions + url: GUI/Maximum_window_dimensions +Galton box animation: + name: Galton box animation + path: Galton-box-animation + url: Galton_box_animation +Gamma function: + name: Gamma function + path: Gamma-function + url: Gamma_function +Generator/Exponential: + name: Generator/Exponential + path: Generator-Exponential + url: Generator/Exponential +Generic swap: + name: Generic swap + path: Generic-swap + url: Generic_swap +Globally replace text in several files: + name: Globally replace text in several files + path: Globally-replace-text-in-several-files + url: Globally_replace_text_in_several_files Go Fish: name: Go Fish path: Go-Fish url: Go_Fish +Gray code: + name: Gray code + path: Gray-code + url: Gray_code +Grayscale image: + name: Grayscale image + path: Grayscale-image + url: Grayscale_image +Greatest common divisor: + name: Greatest common divisor + path: Greatest-common-divisor + url: Greatest_common_divisor +Greatest element of a list: + name: Greatest element of a list + path: Greatest-element-of-a-list + url: Greatest_element_of_a_list +Greatest subsequential sum: + name: Greatest subsequential sum + path: Greatest-subsequential-sum + url: Greatest_subsequential_sum +Greyscale bars/Display: + name: Greyscale bars/Display + path: Greyscale-bars-Display + url: Greyscale_bars/Display +Guess the number: + name: Guess the number + path: Guess-the-number + url: Guess_the_number +Guess the number/With feedback: + name: Guess the number/With feedback + path: Guess-the-number-With-feedback + url: Guess_the_number/With_feedback +Guess the number/With feedback (player): + name: Guess the number/With feedback (player) + path: Guess-the-number-With-feedback-player + url: Guess_the_number/With_feedback_(player) +HTTP: + name: HTTP + path: HTTP + url: HTTP +HTTPS: + name: HTTPS + path: HTTPS + url: HTTPS +HTTPS/Authenticated: + name: HTTPS/Authenticated + path: HTTPS-Authenticated + url: HTTPS/Authenticated +HTTPS/Client-authenticated: + name: HTTPS/Client-authenticated + path: HTTPS-Client-authenticated + url: HTTPS/Client-authenticated +Hailstone sequence: + name: Hailstone sequence + path: Hailstone-sequence + url: Hailstone_sequence +Hamming numbers: + name: Hamming numbers + path: Hamming-numbers + url: Hamming_numbers +Handle a signal: + name: Handle a signal + path: Handle-a-signal + url: Handle_a_signal +Happy numbers: + name: Happy numbers + path: Happy-numbers + url: Happy_numbers +Harshad or Niven series: + name: Harshad or Niven series + path: Harshad-or-Niven-series + url: Harshad_or_Niven_series +Hash from two arrays: + name: Hash from two arrays + path: Hash-from-two-arrays + url: Hash_from_two_arrays +Haversine formula: + name: Haversine formula + path: Haversine-formula + url: Haversine_formula +Hello world/Graphical: + name: Hello world/Graphical + path: Hello-world-Graphical + url: Hello_world/Graphical +Hello world/Line printer: + name: Hello world/Line printer + path: Hello-world-Line-printer + url: Hello_world/Line_printer +Hello world/Newline omission: + name: Hello world/Newline omission + path: Hello-world-Newline-omission + url: Hello_world/Newline_omission +Hello world/Standard error: + name: Hello world/Standard error + path: Hello-world-Standard-error + url: Hello_world/Standard_error +Hello world/Text: + name: Hello world/Text + path: Hello-world-Text + url: Hello_world/Text +Hello world/Web server: + name: Hello world/Web server + path: Hello-world-Web-server + url: Hello_world/Web_server +Here document: + name: Here document + path: Here-document + url: Here_document +Higher-order functions: + name: Higher-order functions + path: Higher-order-functions + url: Higher-order_functions +History variables: + name: History variables + path: History-variables + url: History_variables +Hofstadter Figure-Figure sequences: + name: Hofstadter Figure-Figure sequences + path: Hofstadter-Figure-Figure-sequences + url: Hofstadter_Figure-Figure_sequences +Hofstadter Q sequence: + name: Hofstadter Q sequence + path: Hofstadter-Q-sequence + url: Hofstadter_Q_sequence +Hofstadter-Conway $10,000 sequence: + name: Hofstadter-Conway $10,000 sequence + path: Hofstadter-Conway-$10,000-sequence + url: Hofstadter-Conway_$10,000_sequence +Holidays related to Easter: + name: Holidays related to Easter + path: Holidays-related-to-Easter + url: Holidays_related_to_Easter +Honeycombs: + name: Honeycombs + path: Honeycombs + url: Honeycombs +Horizontal sundial calculations: + name: Horizontal sundial calculations + path: Horizontal-sundial-calculations + url: Horizontal_sundial_calculations +Horner's rule for polynomial evaluation: + name: Horner's rule for polynomial evaluation + path: Horners-rule-for-polynomial-evaluation + url: Horner's_rule_for_polynomial_evaluation +Host introspection: + name: Host introspection + path: Host-introspection + url: Host_introspection +Hostname: + name: Hostname + path: Hostname + url: Hostname +Hough transform: + name: Hough transform + path: Hough-transform + url: Hough_transform +Huffman coding: + name: Huffman coding + path: Huffman-coding + url: Huffman_coding +I before E except after C: + name: I before E except after C + path: I-before-E-except-after-C + url: I_before_E_except_after_C +Identity matrix: + name: Identity matrix + path: Identity-matrix + url: Identity_matrix +Image convolution: + name: Image convolution + path: Image-convolution + url: Image_convolution +Image noise: + name: Image noise + path: Image-noise + url: Image_noise +Include a file: + name: Include a file + path: Include-a-file + url: Include_a_file +Increment a numerical string: + name: Increment a numerical string + path: Increment-a-numerical-string + url: Increment_a_numerical_string 'Infinity': name: 'Infinity' path: 'Infinity' url: 'Infinity' +Inheritance/Multiple: + name: Inheritance/Multiple + path: Inheritance-Multiple + url: Inheritance/Multiple +Inheritance/Single: + name: Inheritance/Single + path: Inheritance-Single + url: Inheritance/Single +Input loop: + name: Input loop + path: Input-loop + url: Input_loop +Integer comparison: + name: Integer comparison + path: Integer-comparison + url: Integer_comparison +Integer sequence: + name: Integer sequence + path: Integer-sequence + url: Integer_sequence +Interactive programming: + name: Interactive programming + path: Interactive-programming + url: Interactive_programming +Introspection: + name: Introspection + path: Introspection + url: Introspection +Inverted index: + name: Inverted index + path: Inverted-index + url: Inverted_index +Inverted syntax: + name: Inverted syntax + path: Inverted-syntax + url: Inverted_syntax JSON: name: JSON path: JSON url: JSON +Jensen's Device: + name: Jensen's Device + path: Jensens-Device + url: Jensen's_Device +Josephus problem: + name: Josephus problem + path: Josephus-problem + url: Josephus_problem +Joystick position: + name: Joystick position + path: Joystick-position + url: Joystick_position +Jump anywhere: + name: Jump anywhere + path: Jump-anywhere + url: Jump_anywhere +K-means++ clustering: + name: K-means++ clustering + path: K-means++-clustering + url: K-means++_clustering +Kaprekar numbers: + name: Kaprekar numbers + path: Kaprekar-numbers + url: Kaprekar_numbers +Keyboard input/Flush the keyboard buffer: + name: Keyboard input/Flush the keyboard buffer + path: Keyboard-input-Flush-the-keyboard-buffer + url: Keyboard_input/Flush_the_keyboard_buffer +Keyboard input/Keypress check: + name: Keyboard input/Keypress check + path: Keyboard-input-Keypress-check + url: Keyboard_input/Keypress_check +Keyboard input/Obtain a Y or N response: + name: Keyboard input/Obtain a Y or N response + path: Keyboard-input-Obtain-a-Y-or-N-response + url: Keyboard_input/Obtain_a_Y_or_N_response +Keyboard macros: + name: Keyboard macros + path: Keyboard-macros + url: Keyboard_macros +Knapsack problem/0-1: + name: Knapsack problem/0-1 + path: Knapsack-problem-0-1 + url: Knapsack_problem/0-1 +Knapsack problem/Bounded: + name: Knapsack problem/Bounded + path: Knapsack-problem-Bounded + url: Knapsack_problem/Bounded +Knapsack problem/Continuous: + name: Knapsack problem/Continuous + path: Knapsack-problem-Continuous + url: Knapsack_problem/Continuous +Knapsack problem/Unbounded: + name: Knapsack problem/Unbounded + path: Knapsack-problem-Unbounded + url: Knapsack_problem/Unbounded +Knight's tour: + name: Knight's tour + path: Knights-tour + url: Knight's_tour Knuth shuffle: name: Knuth shuffle path: Knuth-shuffle url: Knuth_shuffle +Knuth's algorithm S: + name: Knuth's algorithm S + path: Knuths-algorithm-S + url: Knuth's_algorithm_S +LU decomposition: + name: LU decomposition + path: LU-decomposition + url: LU_decomposition +LZW compression: + name: LZW compression + path: LZW-compression + url: LZW_compression +Langton's ant: + name: Langton's ant + path: Langtons-ant + url: Langton's_ant +Largest int from concatenated ints: + name: Largest int from concatenated ints + path: Largest-int-from-concatenated-ints + url: Largest_int_from_concatenated_ints +Last Friday of each month: + name: Last Friday of each month + path: Last-Friday-of-each-month + url: Last_Friday_of_each_month +Last letter-first letter: + name: Last letter-first letter + path: Last-letter-first-letter + url: Last_letter-first_letter +Leap year: + name: Leap year + path: Leap-year + url: Leap_year +Least common multiple: + name: Least common multiple + path: Least-common-multiple + url: Least_common_multiple +Letter frequency: + name: Letter frequency + path: Letter-frequency + url: Letter_frequency +Levenshtein distance: + name: Levenshtein distance + path: Levenshtein-distance + url: Levenshtein_distance +Linear congruential generator: + name: Linear congruential generator + path: Linear-congruential-generator + url: Linear_congruential_generator +List comprehensions: + name: List comprehensions + path: List-comprehensions + url: List_comprehensions +Literals/Floating point: + name: Literals/Floating point + path: Literals-Floating-point + url: Literals/Floating_point +Literals/Integer: + name: Literals/Integer + path: Literals-Integer + url: Literals/Integer +Literals/String: + name: Literals/String + path: Literals-String + url: Literals/String +Logical operations: + name: Logical operations + path: Logical-operations + url: Logical_operations +Long multiplication: + name: Long multiplication + path: Long-multiplication + url: Long_multiplication +Longest common subsequence: + name: Longest common subsequence + path: Longest-common-subsequence + url: Longest_common_subsequence +Longest string challenge: + name: Longest string challenge + path: Longest-string-challenge + url: Longest_string_challenge +Look-and-say sequence: + name: Look-and-say sequence + path: Look-and-say-sequence + url: Look-and-say_sequence +Loop over multiple arrays simultaneously: + name: Loop over multiple arrays simultaneously + path: Loop-over-multiple-arrays-simultaneously + url: Loop_over_multiple_arrays_simultaneously +Loops/Break: + name: Loops/Break + path: Loops-Break + url: Loops/Break +Loops/Continue: + name: Loops/Continue + path: Loops-Continue + url: Loops/Continue +Loops/Do-while: + name: Loops/Do-while + path: Loops-Do-while + url: Loops/Do-while +Loops/Downward for: + name: Loops/Downward for + path: Loops-Downward-for + url: Loops/Downward_for +Loops/For: + name: Loops/For + path: Loops-For + url: Loops/For +Loops/For with a specified step: + name: Loops/For with a specified step + path: Loops-For-with-a-specified-step + url: Loops/For_with_a_specified_step +Loops/Foreach: + name: Loops/Foreach + path: Loops-Foreach + url: Loops/Foreach +Loops/Infinite: + name: Loops/Infinite + path: Loops-Infinite + url: Loops/Infinite +Loops/N plus one half: + name: Loops/N plus one half + path: Loops-N-plus-one-half + url: Loops/N_plus_one_half +Loops/Nested: + name: Loops/Nested + path: Loops-Nested + url: Loops/Nested +Loops/While: + name: Loops/While + path: Loops-While + url: Loops/While +Lucas-Lehmer test: + name: Lucas-Lehmer test + path: Lucas-Lehmer-test + url: Lucas-Lehmer_test +Luhn test of credit card numbers: + name: Luhn test of credit card numbers + path: Luhn-test-of-credit-card-numbers + url: Luhn_test_of_credit_card_numbers +MD4: + name: MD4 + path: MD4 + url: MD4 +MD5: + name: MD5 + path: MD5 + url: MD5 +MD5/Implementation: + name: MD5/Implementation + path: MD5-Implementation + url: MD5/Implementation +Mad Libs: + name: Mad Libs + path: Mad-Libs + url: Mad_Libs +Main step of GOST 28147-89: + name: Main step of GOST 28147-89 + path: Main-step-of-GOST-28147-89 + url: Main_step_of_GOST_28147-89 +Man or boy test: + name: Man or boy test + path: Man-or-boy-test + url: Man_or_boy_test +Mandelbrot set: + name: Mandelbrot set + path: Mandelbrot-set + url: Mandelbrot_set +Map range: + name: Map range + path: Map-range + url: Map_range +Matrix arithmetic: + name: Matrix arithmetic + path: Matrix-arithmetic + url: Matrix_arithmetic +Matrix multiplication: + name: Matrix multiplication + path: Matrix-multiplication + url: Matrix_multiplication +Matrix transposition: + name: Matrix transposition + path: Matrix-transposition + url: Matrix_transposition +Matrix-exponentiation operator: + name: Matrix-exponentiation operator + path: Matrix-exponentiation-operator + url: Matrix-exponentiation_operator +Maze generation: + name: Maze generation + path: Maze-generation + url: Maze_generation +Maze solving: + name: Maze solving + path: Maze-solving + url: Maze_solving +Median filter: + name: Median filter + path: Median-filter + url: Median_filter +Memory allocation: + name: Memory allocation + path: Memory-allocation + url: Memory_allocation +Memory layout of a data structure: + name: Memory layout of a data structure + path: Memory-layout-of-a-data-structure + url: Memory_layout_of_a_data_structure +Menu: + name: Menu + path: Menu + url: Menu +Metaprogramming: + name: Metaprogramming + path: Metaprogramming + url: Metaprogramming +Metered concurrency: + name: Metered concurrency + path: Metered-concurrency + url: Metered_concurrency +Metronome: + name: Metronome + path: Metronome + url: Metronome +Middle three digits: + name: Middle three digits + path: Middle-three-digits + url: Middle_three_digits +Miller-Rabin primality test: + name: Miller-Rabin primality test + path: Miller-Rabin-primality-test + url: Miller-Rabin_primality_test +Minesweeper game: + name: Minesweeper game + path: Minesweeper-game + url: Minesweeper_game +Modular exponentiation: + name: Modular exponentiation + path: Modular-exponentiation + url: Modular_exponentiation +Modular inverse: + name: Modular inverse + path: Modular-inverse + url: Modular_inverse +Monte Carlo methods: + name: Monte Carlo methods + path: Monte-Carlo-methods + url: Monte_Carlo_methods +Monty Hall problem: + name: Monty Hall problem + path: Monty-Hall-problem + url: Monty_Hall_problem +Morse code: + name: Morse code + path: Morse-code + url: Morse_code +Mouse position: + name: Mouse position + path: Mouse-position + url: Mouse_position +Multifactorial: + name: Multifactorial + path: Multifactorial + url: Multifactorial +Multiple distinct objects: + name: Multiple distinct objects + path: Multiple-distinct-objects + url: Multiple_distinct_objects +Multiple regression: + name: Multiple regression + path: Multiple-regression + url: Multiple_regression +Multiplication tables: + name: Multiplication tables + path: Multiplication-tables + url: Multiplication_tables +Multiplicative order: + name: Multiplicative order + path: Multiplicative-order + url: Multiplicative_order +Multisplit: + name: Multisplit + path: Multisplit + url: Multisplit +Mutex: + name: Mutex + path: Mutex + url: Mutex +Mutual recursion: + name: Mutual recursion + path: Mutual-recursion + url: Mutual_recursion Narcissist: name: Narcissist path: Narcissist diff --git a/Task/100-doors/Factor/100-doors.factor b/Task/100-doors/Factor/100-doors.factor new file mode 100644 index 0000000000..6dccd9b759 --- /dev/null +++ b/Task/100-doors/Factor/100-doors.factor @@ -0,0 +1,23 @@ +USING: bit-arrays formatting fry kernel math math.ranges +sequences ; +IN: rosetta.doors + +CONSTANT: number-of-doors 100 + +: multiples ( n -- range ) + 0 number-of-doors rot ; + +: toggle-multiples ( n doors -- ) + [ multiples ] dip '[ _ [ not ] change-nth ] each ; + +: toggle-all-multiples ( doors -- ) + [ number-of-doors [1,b] ] dip '[ _ toggle-multiples ] each ; + +: print-doors ( doors -- ) + [ + swap "open" "closed" ? "Door %d is %s\n" printf + ] each-index ; + +: main ( -- ) + number-of-doors 1 + + [ toggle-all-multiples ] [ print-doors ] bi ; diff --git a/Task/100-doors/Falcon/100-doors-1.falcon b/Task/100-doors/Falcon/100-doors-1.falcon new file mode 100644 index 0000000000..e10119e06a --- /dev/null +++ b/Task/100-doors/Falcon/100-doors-1.falcon @@ -0,0 +1,11 @@ +doors = arrayBuffer( 101, false ) + +for pass in [ 0 : doors.len() ] + for door in [ 0 : doors.len() : pass+1 ] + doors[ door ] = not doors[ door ] + end +end + +for door in [ 1 : doors.len() ] // Show Output + > "Door ", $door, " is: ", ( doors[ door ] ) ? "open" : "closed" +end diff --git a/Task/100-doors/Falcon/100-doors-2.falcon b/Task/100-doors/Falcon/100-doors-2.falcon new file mode 100644 index 0000000000..5cd38fbeb8 --- /dev/null +++ b/Task/100-doors/Falcon/100-doors-2.falcon @@ -0,0 +1 @@ +for door in [ 1 : 101 ]: > "Door ", $door, " is: ", fract( door ** 0.5 ) ? "closed" : "open" diff --git a/Task/100-doors/Fantom/100-doors-1.fantom b/Task/100-doors/Fantom/100-doors-1.fantom new file mode 100644 index 0000000000..c7d4785a81 --- /dev/null +++ b/Task/100-doors/Fantom/100-doors-1.fantom @@ -0,0 +1,5 @@ + states := (1..100).toList + 100.times |i| { + states = states.map |state| { state % (i+1) == 0 ? -state : +state } + } + echo("Open doors are " + states.findAll { it < 0 }.map { -it }) diff --git a/Task/100-doors/Fantom/100-doors-2.fantom b/Task/100-doors/Fantom/100-doors-2.fantom new file mode 100644 index 0000000000..3b93d5920e --- /dev/null +++ b/Task/100-doors/Fantom/100-doors-2.fantom @@ -0,0 +1 @@ + echo("Open doors are " + (1..100).toList.findAll { it.toFloat.pow(0.5f).toInt.pow(2) == it}) diff --git a/Task/100-doors/GAP/100-doors.gap b/Task/100-doors/GAP/100-doors.gap new file mode 100644 index 0000000000..3f41419f00 --- /dev/null +++ b/Task/100-doors/GAP/100-doors.gap @@ -0,0 +1,18 @@ +doors := function(n) + local a,j,s; + a := [ ]; + for j in [1 .. n] do + a[j] := 0; + od; + for s in [1 .. n] do + j := s; + while j <= n do + a[j] := 1 - a[j]; + j := j + s; + od; + od; + return Filtered([1 .. n], j -> a[j] = 1); +end; + +doors(100); +# [ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 ] diff --git a/Task/100-doors/GML/100-doors.gml b/Task/100-doors/GML/100-doors.gml new file mode 100644 index 0000000000..4aec96e638 --- /dev/null +++ b/Task/100-doors/GML/100-doors.gml @@ -0,0 +1,28 @@ +var doors,a,i; +//Sets up the array for all of the doors. +for (i=1;i<=100;i+=1) + { + doors[i]=0; + } +//This first for loop goes through and passes the interval down to the next for loop. +for (i=1;i<=100;i+=1) + { + //This for loop opens or closes the doors and uses the interval(if interval is 2 it only uses every other etc..) + for (a=0;a<=100;a+=i;) + { + //Opens or closes a door. + doors[a]=!doors[a]; + } + } +open_doors=''; +//This for loop goes through the array and checks for open doors. +//If the door is open it adds it to the string then displays the string. +for (i=1;i<=100;i+=1) + { + if doors[i]=1 + { + open_doors+="Door Number "+string(i)+" is open#"; + } + } +show_message(open_doors); +game_end(); diff --git a/Task/100-doors/Golfscript/100-doors-1.golf b/Task/100-doors/Golfscript/100-doors-1.golf new file mode 100644 index 0000000000..56ba8b2d8f --- /dev/null +++ b/Task/100-doors/Golfscript/100-doors-1.golf @@ -0,0 +1,4 @@ +100:c;[{0}c*]:d; +c,{.c,>\)%{.d<\.d=1^\)d>++:d;}/}/ +[c,{)"door "\+" is"+}%d{{"open"}{"closed"}if}%]zip +{" "*puts}/ diff --git a/Task/100-doors/Golfscript/100-doors-2.golf b/Task/100-doors/Golfscript/100-doors-2.golf new file mode 100644 index 0000000000..71826cec49 --- /dev/null +++ b/Task/100-doors/Golfscript/100-doors-2.golf @@ -0,0 +1,3 @@ +100,{)}% +{:d.sqrt 2?= +{"open"}{"close"}if"door "d+" is "+\+puts}/ diff --git a/Task/100-doors/Golfscript/100-doors-3.golf b/Task/100-doors/Golfscript/100-doors-3.golf new file mode 100644 index 0000000000..79bc7cc8bf --- /dev/null +++ b/Task/100-doors/Golfscript/100-doors-3.golf @@ -0,0 +1,4 @@ +[{"close"}100*]:d; +10,{)2?(.d<\["open"]\)d>++:d;}/ +[100,{)"door "\+" is"+}%d]zip +{" "*puts}/ diff --git a/Task/100-doors/Gosu/100-doors-1.gosu b/Task/100-doors/Gosu/100-doors-1.gosu new file mode 100644 index 0000000000..c856c330dc --- /dev/null +++ b/Task/100-doors/Gosu/100-doors-1.gosu @@ -0,0 +1,16 @@ +uses java.util.Arrays + +var doors = new boolean[100] +Arrays.fill( doors, false ) + +for( pass in 1..100 ) { + var counter = pass-1 + while( counter < 100 ) { + doors[counter] = !doors[counter] + counter += pass + } +} + +for( door in doors index i ) { + print( "door ${i+1} is ${door ? 'open' : 'closed'}" ) +} diff --git a/Task/100-doors/Gosu/100-doors-2.gosu b/Task/100-doors/Gosu/100-doors-2.gosu new file mode 100644 index 0000000000..ba151a051b --- /dev/null +++ b/Task/100-doors/Gosu/100-doors-2.gosu @@ -0,0 +1,12 @@ +var door = 1 +var delta = 0 + +for( i in 1..100 ) { + if( i == door ) { + print( "door ${i} is open" ) + delta++ + door += 2*delta + 1 + } else { + print( "door ${i} is closed" ) + } +} diff --git a/Task/100-doors/Groovy/100-doors-1.groovy b/Task/100-doors/Groovy/100-doors-1.groovy new file mode 100644 index 0000000000..77ca9fb4f4 --- /dev/null +++ b/Task/100-doors/Groovy/100-doors-1.groovy @@ -0,0 +1,9 @@ +doors = [false] * 100 +(0..99).each { + it.step(100, it + 1) { + doors[it] ^= true + } +} +(0..99).each { + println("Door #${it + 1} is ${doors[it] ? 'open' : 'closed'}.") +} diff --git a/Task/100-doors/Groovy/100-doors-2.groovy b/Task/100-doors/Groovy/100-doors-2.groovy new file mode 100644 index 0000000000..918ee41716 --- /dev/null +++ b/Task/100-doors/Groovy/100-doors-2.groovy @@ -0,0 +1,3 @@ +(1..100).each { + println("Door #${it} is ${Math.sqrt(it).with{it==(int)it} ? 'open' : 'closed'}.") +} diff --git a/Task/100-doors/Groovy/100-doors-3.groovy b/Task/100-doors/Groovy/100-doors-3.groovy new file mode 100644 index 0000000000..63c0f5c0e4 --- /dev/null +++ b/Task/100-doors/Groovy/100-doors-3.groovy @@ -0,0 +1,5 @@ +doors = ['closed'] * 100 +(1..10).each { doors[it**2 - 1] = 'open' } +(0..99).each { + println("Door #${it + 1} is ${doors[it]}.") +} diff --git a/Task/100-doors/Haxe/100-doors.haxe b/Task/100-doors/Haxe/100-doors.haxe new file mode 100644 index 0000000000..4d86d44909 --- /dev/null +++ b/Task/100-doors/Haxe/100-doors.haxe @@ -0,0 +1,18 @@ +class RosettaDemo +{ + static public function main() + { + findOpenLockers(100); + } + + static function findOpenLockers(n : Int) + { + var i = 1; + + while((i*i) <= n) + { + Sys.print(i*i + "\n"); + i++; + } + } +} diff --git a/Task/100-doors/HicEst/100-doors-1.hicest b/Task/100-doors/HicEst/100-doors-1.hicest new file mode 100644 index 0000000000..f6882e7548 --- /dev/null +++ b/Task/100-doors/HicEst/100-doors-1.hicest @@ -0,0 +1,9 @@ +REAL :: n=100, open=1, door(n) + +door = 1 - open ! = closed +DO i = 1, n + DO j = i, n, i + door(j) = open - door(j) + ENDDO +ENDDO +DLG(Text=door, TItle=SUM(door)//" doors open") diff --git a/Task/100-doors/HicEst/100-doors-2.hicest b/Task/100-doors/HicEst/100-doors-2.hicest new file mode 100644 index 0000000000..f72d1d4ba9 --- /dev/null +++ b/Task/100-doors/HicEst/100-doors-2.hicest @@ -0,0 +1,5 @@ +door = 1 - open ! = closed +DO i = 1, n^0.5 + door(i*i) = open +ENDDO +DLG(Text=door, TItle=SUM(door)//" doors open") diff --git a/Task/100-doors/Icon/100-doors-1.icon b/Task/100-doors/Icon/100-doors-1.icon new file mode 100644 index 0000000000..1be53b29aa --- /dev/null +++ b/Task/100-doors/Icon/100-doors-1.icon @@ -0,0 +1,7 @@ +procedure main() + door := table(0) # default value of entries is 0 + every pass := 1 to 100 do + every door[i := pass to 100 by pass] := 1 - door[i] + + every write("Door ", i := 1 to 100, " is ", if door[i] = 1 then "open" else "closed") +end diff --git a/Task/100-doors/Icon/100-doors-2.icon b/Task/100-doors/Icon/100-doors-2.icon new file mode 100644 index 0000000000..9e19450cd1 --- /dev/null +++ b/Task/100-doors/Icon/100-doors-2.icon @@ -0,0 +1,3 @@ +procedure main() + every write("Door ", i := 1 to 100, " is ", if integer(sqrt(i)) = sqrt(i) then "open" else "closed") +end diff --git a/Task/100-doors/Icon/100-doors-3.icon b/Task/100-doors/Icon/100-doors-3.icon new file mode 100644 index 0000000000..40f594870d --- /dev/null +++ b/Task/100-doors/Icon/100-doors-3.icon @@ -0,0 +1,5 @@ +procedure main(args) + dMap := table("closed") + every dMap[(1 to sqrt(100))^2] := "open" + every write("Door ",i := 1 to 100," is ",dMap[i]) +end diff --git a/Task/100-doors/Inform-7/100-doors.inf b/Task/100-doors/Inform-7/100-doors.inf new file mode 100644 index 0000000000..16dcd73921 --- /dev/null +++ b/Task/100-doors/Inform-7/100-doors.inf @@ -0,0 +1,29 @@ +Hallway is a room. + +A toggle door is a kind of thing. +A toggle door can be open or closed. It is usually closed. +A toggle door has a number called the door number. +Understand the door number property as referring to a toggle door. +Rule for printing the name of a toggle door: say "door #[door number]". + +There are 100 toggle doors. + +When play begins (this is the initialize doors rule): + let the next door number be 1; + repeat with D running through toggle doors: + now the door number of D is the next door number; + increment the next door number. + +To toggle (D - open toggle door): now D is closed. +To toggle (D - closed toggle door): now D is open. + +When play begins (this is the solve puzzle rule): + let the door list be the list of toggle doors; + let the door count be the number of entries in the door list; + repeat with iteration running from 1 to 100: + let N be the iteration; + while N is less than the door count: + toggle entry N in the door list; + increase N by the iteration; + say "Doors left open: [list of open toggle doors]."; + end the story. diff --git a/Task/100-doors/Informix-4GL/100-doors.4gl b/Task/100-doors/Informix-4GL/100-doors.4gl new file mode 100644 index 0000000000..dac085cb34 --- /dev/null +++ b/Task/100-doors/Informix-4GL/100-doors.4gl @@ -0,0 +1,22 @@ +MAIN + DEFINE + i, pass SMALLINT, + doors ARRAY[100] OF SMALLINT + + FOR i = 1 TO 100 + LET doors[i] = FALSE + END FOR + + FOR pass = 1 TO 100 + FOR i = pass TO 100 STEP pass + LET doors[i] = NOT doors[i] + END FOR + END FOR + + FOR i = 1 TO 100 + IF doors[i] + THEN DISPLAY i USING "Door <<& is open" + ELSE DISPLAY i USING "Door <<& is closed" + END IF + END FOR +END MAIN diff --git a/Task/100-doors/Io/100-doors.io b/Task/100-doors/Io/100-doors.io new file mode 100644 index 0000000000..6ee0ac567f --- /dev/null +++ b/Task/100-doors/Io/100-doors.io @@ -0,0 +1,6 @@ +doors := List clone +for(i,1,100, doors append(false)) +for(i,1,100, + for(x,i,100, i, doors atPut(x - 1, doors at(x - 1) not)) +) +doors foreach(i, x, if(x, "Door #{i + 1} is open" interpolate println)) diff --git a/Task/100-doors/Ioke/100-doors.ioke b/Task/100-doors/Ioke/100-doors.ioke new file mode 100644 index 0000000000..caf4f16ac2 --- /dev/null +++ b/Task/100-doors/Ioke/100-doors.ioke @@ -0,0 +1,21 @@ +NDoors = Origin mimic + +NDoors Toggle = Origin mimic do( + initialize = method(toggled?, @toggled? = toggled?) + toggle! = method(@toggled? = !toggled?. self) +) + +NDoors Doors = Origin mimic do( + initialize = method(n, + @n = n + @doors = {} addKeysAndValues(1..n, (1..n) map(_, NDoors Toggle mimic(false))) + ) + numsToToggle = method(n, for(x <- (1..@n), (x % n) zero?, x)) + toggleThese = method(nums, nums each(x, @doors[x] = @doors at(x) toggle)) + show = method(@doors filter:dict(value toggled?) keys sort println) +) + +; Test code +x = NDoors Doors mimic(100) +(1..100) each(n, x toggleThese(x numsToToggle(n))) +x show diff --git a/Task/100-doors/J/100-doors-1.j b/Task/100-doors/J/100-doors-1.j new file mode 100644 index 0000000000..de4fd5eef9 --- /dev/null +++ b/Task/100-doors/J/100-doors-1.j @@ -0,0 +1,4 @@ + ~:/ (100 $ - {. 1:)"0 >:i.100 +1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ... + ~:/ 0=|/~ >:i.100 NB. alternative +1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ... diff --git a/Task/100-doors/J/100-doors-2.j b/Task/100-doors/J/100-doors-2.j new file mode 100644 index 0000000000..c7f2cf7d86 --- /dev/null +++ b/Task/100-doors/J/100-doors-2.j @@ -0,0 +1,4 @@ + (e. *:) 1+i.100 +1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ... + 1 (<:*:i.10)} 100$0 NB. alternative +1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ... diff --git a/Task/100-doors/J/100-doors-3.j b/Task/100-doors/J/100-doors-3.j new file mode 100644 index 0000000000..3a185875e1 --- /dev/null +++ b/Task/100-doors/J/100-doors-3.j @@ -0,0 +1,4 @@ + 'these doors are open' ; >: I. (>:i.100) e. *: i.11 +┌────────────────────┬───────────────────────────┐ +│these doors are open│1 4 9 16 25 36 49 64 81 100│ +└────────────────────┴───────────────────────────┘ diff --git a/Task/100-doors/Julia/100-doors-1.julia b/Task/100-doors/Julia/100-doors-1.julia new file mode 100644 index 0000000000..b239ca730e --- /dev/null +++ b/Task/100-doors/Julia/100-doors-1.julia @@ -0,0 +1,5 @@ +doors = falses(100) +for a = 1:100, b in a:a:100 + doors[b] = !doors[b] +end +for a = 1:100 println("Door $a is " * (doors[a] ? "open" : "close") ) end diff --git a/Task/100-doors/Julia/100-doors-2.julia b/Task/100-doors/Julia/100-doors-2.julia new file mode 100644 index 0000000000..4da27443f8 --- /dev/null +++ b/Task/100-doors/Julia/100-doors-2.julia @@ -0,0 +1 @@ +for i = 1:10 println("Door $(i^2) is open") end diff --git a/Task/100-doors/K/100-doors-1.k b/Task/100-doors/K/100-doors-1.k new file mode 100644 index 0000000000..598941d7ee --- /dev/null +++ b/Task/100-doors/K/100-doors-1.k @@ -0,0 +1 @@ + `closed `open ![ ; 2 ] @ #:' 1 _ = ,/ &:' 0 = t !\:/: t : ! 101 diff --git a/Task/100-doors/K/100-doors-2.k b/Task/100-doors/K/100-doors-2.k new file mode 100644 index 0000000000..16a13a441e --- /dev/null +++ b/Task/100-doors/K/100-doors-2.k @@ -0,0 +1 @@ + ( 1 + ! 10 ) ^ 2 diff --git a/Task/100-doors/K/100-doors-3.k b/Task/100-doors/K/100-doors-3.k new file mode 100644 index 0000000000..85eb38d925 --- /dev/null +++ b/Task/100-doors/K/100-doors-3.k @@ -0,0 +1 @@ + { ( 1 + ! _ x ^ % 2 ) ^ 2 } 100 diff --git a/Task/100-doors/LOLCODE/100-doors.lol b/Task/100-doors/LOLCODE/100-doors.lol new file mode 100644 index 0000000000..30e7625ea8 --- /dev/null +++ b/Task/100-doors/LOLCODE/100-doors.lol @@ -0,0 +1,27 @@ +HAI 1.3 + +I HAS A doors ITZ A BUKKIT +IM IN YR hallway UPPIN YR door TIL BOTH SAEM door AN 100 + doors HAS A SRS door ITZ FAIL BTW, INISHULIZE ALL TEH DOORZ AS CLOZD +IM OUTTA YR hallway + +IM IN YR hallway UPPIN YR pass TIL BOTH SAEM pass AN 100 + I HAS A door ITZ pass + IM IN YR passer + doors'Z SRS door R NOT doors'Z SRS door + door R SUM OF door AN SUM OF pass AN 1 + DIFFRINT door AN SMALLR OF door AN 99, O RLY? + YA RLY, GTFO + OIC + IM OUTTA YR passer +IM OUTTA YR hallway + +IM IN YR printer UPPIN YR door TIL BOTH SAEM door AN 100 + VISIBLE "Door #" SUM OF door AN 1 " is "! + doors'Z SRS door, O RLY? + YA RLY, VISIBLE "open." + NO WAI, VISIBLE "closed." + OIC +IM OUTTA YR printer + +KTHXBYE diff --git a/Task/100-doors/Lhogho/100-doors.lhogho b/Task/100-doors/Lhogho/100-doors.lhogho new file mode 100644 index 0000000000..05284bae1b --- /dev/null +++ b/Task/100-doors/Lhogho/100-doors.lhogho @@ -0,0 +1,30 @@ +to doors + ;Problem 100 Doors + ;Lhogho + + for "p [1 100] + [ + make :p "false + ] + + for "a [1 100 1] + [ + for "b [:a 100 :a] + [ + if :b < 101 + [ + make :b not thing :b + ] + ] + ] + + for "c [1 100] + [ + if thing :c + [ + (print "door :c "is "open) + ] + ] +end + +doors diff --git a/Task/100-doors/Liberty-BASIC/100-doors.liberty b/Task/100-doors/Liberty-BASIC/100-doors.liberty new file mode 100644 index 0000000000..c77064a855 --- /dev/null +++ b/Task/100-doors/Liberty-BASIC/100-doors.liberty @@ -0,0 +1,10 @@ +dim doors(100) +for pass = 1 to 100 + for door = pass to 100 step pass + doors(door) = not(doors(door)) + next door +next pass +print "open doors "; +for door = 1 to 100 + if doors(door) then print door;" "; +next door diff --git a/Task/100-doors/Logo/100-doors.logo b/Task/100-doors/Logo/100-doors.logo new file mode 100644 index 0000000000..2c955f7661 --- /dev/null +++ b/Task/100-doors/Logo/100-doors.logo @@ -0,0 +1,14 @@ +to doors +;Problem 100 Doors +;FMSLogo +;lrcvs 2010 + +make "door (vector 100 1) +for [p 1 100][setitem :p :door 0] + +for [a 1 100 1][for [b :a 100 :a][make "x item :b :door + ifelse :x = 0 [setitem :b :door 1][setitem :b :door 0] ] ] + +for [c 1 100][make "y item :c :door + ifelse :y = 0 [pr (list :c "Close)] [pr (list :c "Open)] ] +end diff --git a/Task/100-doors/M4/100-doors.m4 b/Task/100-doors/M4/100-doors.m4 new file mode 100644 index 0000000000..73110f5af4 --- /dev/null +++ b/Task/100-doors/M4/100-doors.m4 @@ -0,0 +1,10 @@ +define(`_set', `define(`$1[$2]', `$3')')dnl +define(`_get', `defn(`$1[$2]')')dnl +define(`for',`ifelse($#,0,``$0'',`ifelse(eval($2<=$3),1, +`pushdef(`$1',$2)$5`'popdef(`$1')$0(`$1',eval($2+$4),$3,$4,`$5')')')')dnl +define(`opposite',`_set(`door',$1,ifelse(_get(`door',$1),`closed',`open',`closed'))')dnl +define(`upper',`100')dnl +for(`x',`1',upper,`1',`_set(`door',x,`closed')')dnl +for(`x',`1',upper,`1',`for(`y',x,upper,x,`opposite(y)')')dnl +for(`x',`1',upper,`1',`door x is _get(`door',x) +')dnl diff --git a/Task/100-doors/MAXScript/100-doors-1.max b/Task/100-doors/MAXScript/100-doors-1.max new file mode 100644 index 0000000000..5f239e926e --- /dev/null +++ b/Task/100-doors/MAXScript/100-doors-1.max @@ -0,0 +1,14 @@ +doorsOpen = for i in 1 to 100 collect false + +for pass in 1 to 100 do +( + for door in pass to 100 by pass do + ( + doorsOpen[door] = not doorsOpen[door] + ) +) + +for i in 1 to doorsOpen.count do +( + format ("Door % is open?: %\n") i doorsOpen[i] +) diff --git a/Task/100-doors/MAXScript/100-doors-2.max b/Task/100-doors/MAXScript/100-doors-2.max new file mode 100644 index 0000000000..c090ff0533 --- /dev/null +++ b/Task/100-doors/MAXScript/100-doors-2.max @@ -0,0 +1,5 @@ +for i in 1 to 100 do +( + root = pow i 0.5 + format ("Door % is open?: %\n") i (root == (root as integer)) +) diff --git a/Task/100-doors/MIPS-Assembly/100-doors.mips b/Task/100-doors/MIPS-Assembly/100-doors.mips new file mode 100644 index 0000000000..8f2c4267e3 --- /dev/null +++ b/Task/100-doors/MIPS-Assembly/100-doors.mips @@ -0,0 +1,63 @@ +.data + doors: .space 100 + num_str: .asciiz "Number " + comma_gap: .asciiz " is " + newline: .asciiz "\n" + +.text +main: +# Clear all the cells to zero + li $t1, 100 + la $t2, doors +clear_loop: + sb $0, ($t2) + add $t2, $t2, 1 + sub $t1, $t1, 1 + bnez $t1, clear_loop + +# Now start the loops + li $t0, 1 # This will the the step size + li $t4, 1 # just an arbitrary 1 +loop1: + move $t1, $t0 # Counter + la $t2, doors # Current pointer + add $t2, $t2, $t0 + addi $t2, $t2, -1 +loop2: + lb $t3, ($t2) + sub $t3, $t4, $t3 + sb $t3, ($t2) + add $t1, $t1, $t0 + add $t2, $t2, $t0 + ble $t1, 100, loop2 + + addi $t0, $t0, 1 + ble $t0, 100, loop1 + + # Now display everything + la $t0, doors + li $t1, 1 +loop3: + li $v0, 4 + la $a0, num_str + syscall + + li $v0, 1 + move $a0, $t1 + syscall + + li $v0, 4 + la $a0, comma_gap + syscall + + li $v0, 1 + lb $a0, ($t0) + syscall + + li $v0, 4, + la $a0, newline + syscall + + addi $t0, $t0, 1 + addi $t1, $t1, 1 + bne $t1, 101 loop3 diff --git a/Task/100-doors/ML-I/100-doors.ml b/Task/100-doors/ML-I/100-doors.ml new file mode 100644 index 0000000000..2f7f47fa3c --- /dev/null +++ b/Task/100-doors/ML-I/100-doors.ml @@ -0,0 +1,41 @@ +MCSKIP "WITH" NL +"" 100 doors +MCINS %. +MCSKIP MT,<> +"" Doors represented by P1-P100, 0 is closed +MCPVAR 100 +"" Set P variables to 0 +MCDEF ZEROPS WITHS NL AS +ZEROPS +"" Generate door state +MCDEF STATE WITHS () AS MCGO L0 +%L1.open> +"" Main macro - no arguments +"" T1 is pass number +"" T2 is door number +MCDEF DOORS WITHS NL +AS +"" Do it +DOORS diff --git a/Task/100-doors/MOO/100-doors.moo b/Task/100-doors/MOO/100-doors.moo new file mode 100644 index 0000000000..dd16dc6756 --- /dev/null +++ b/Task/100-doors/MOO/100-doors.moo @@ -0,0 +1,14 @@ +is_open = make(100); +for pass in [1..100] + for door in [pass..100] + if (door % pass) + continue; + endif + is_open[door] = !is_open[door]; + endfor +endfor + +"output the result"; +for door in [1..100] + player:tell("door #", door, " is ", (is_open[door] ? "open" : "closed"), "."); +endfor diff --git a/Task/100-doors/MUMPS/100-doors.mumps b/Task/100-doors/MUMPS/100-doors.mumps new file mode 100644 index 0000000000..dd34d289d4 --- /dev/null +++ b/Task/100-doors/MUMPS/100-doors.mumps @@ -0,0 +1,18 @@ +doors new door,pass + For door=1:1:100 Set door(door)=0 + For pass=1:1:100 For door=pass:pass:100 Set door(door)='door(door) + For door=1:1:100 If door(door) Write !,"Door",$j(door,4)," is open" + Write !,"All other doors are closed." + Quit +Do doors +Door 1 is open +Door 4 is open +Door 9 is open +Door 16 is open +Door 25 is open +Door 36 is open +Door 49 is open +Door 64 is open +Door 81 is open +Door 100 is open +All other doors are closed. diff --git a/Task/100-doors/Maple/100-doors-1.maple b/Task/100-doors/Maple/100-doors-1.maple new file mode 100644 index 0000000000..af1eb31b4f --- /dev/null +++ b/Task/100-doors/Maple/100-doors-1.maple @@ -0,0 +1,16 @@ +NDoors := proc( N :: posint ) + # Initialise, using 0 to represent "closed" + local doors := Array( 1 .. N, 'datatype' = 'integer'[ 1 ] ); + # Now do N passes + for local pass from 1 to N do + for local door from pass by pass while door <= N do + doors[ door ] := 1 - doors[ door ] + end do + end do; + # Output + for door from 1 to N do + printf( "Door %d is %s.\n", door, `if`( doors[ door ] = 0, "closed", "open" ) ) + end do; + # Since this is a printing routine, return nothing. + NULL +end proc: diff --git a/Task/100-doors/Maple/100-doors-2.maple b/Task/100-doors/Maple/100-doors-2.maple new file mode 100644 index 0000000000..f57bbf9f4a --- /dev/null +++ b/Task/100-doors/Maple/100-doors-2.maple @@ -0,0 +1 @@ +> NDoors( 100 ); diff --git a/Task/100-doors/Maple/100-doors-3.maple b/Task/100-doors/Maple/100-doors-3.maple new file mode 100644 index 0000000000..304ef23687 --- /dev/null +++ b/Task/100-doors/Maple/100-doors-3.maple @@ -0,0 +1,2 @@ +> seq( i^2, i = 1 .. isqrt( 100 ) ); + 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 diff --git a/Task/100-doors/Maple/100-doors-4.maple b/Task/100-doors/Maple/100-doors-4.maple new file mode 100644 index 0000000000..523d8b93a8 --- /dev/null +++ b/Task/100-doors/Maple/100-doors-4.maple @@ -0,0 +1,2 @@ +> [seq]( 1 .. 10 )^~2; + [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] diff --git a/Task/100-doors/Mathematica/100-doors-1.mathematica b/Task/100-doors/Mathematica/100-doors-1.mathematica new file mode 100644 index 0000000000..d703d385c1 --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-1.mathematica @@ -0,0 +1,3 @@ +f[n_] = "Closed"; +Do[Do[If[f[n] == "Closed", f[n] = "Open", f[n] = "Closed"], {n, k, 100, k}], {k, 1, 100}]; +Table[f[n], {n, 1, 100}] diff --git a/Task/100-doors/Mathematica/100-doors-2.mathematica b/Task/100-doors/Mathematica/100-doors-2.mathematica new file mode 100644 index 0000000000..b867d8da88 --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-2.mathematica @@ -0,0 +1 @@ +Do[Print["door ",i," is ",If[IntegerQ[Sqrt[i]],"open","closed"]],{i,100}] diff --git a/Task/100-doors/Mathematica/100-doors-3.mathematica b/Task/100-doors/Mathematica/100-doors-3.mathematica new file mode 100644 index 0000000000..272215487f --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-3.mathematica @@ -0,0 +1,3 @@ +n=100; +a=Range[1,Sqrt[n]]^2 +Do[Print["door ",i," is ",If[MemberQ[a,i],"open","closed"]],{i,100}] diff --git a/Task/100-doors/Mathematica/100-doors-4.mathematica b/Task/100-doors/Mathematica/100-doors-4.mathematica new file mode 100644 index 0000000000..5c83a1f2b3 --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-4.mathematica @@ -0,0 +1,12 @@ +n=100 +nn=1 +a=0 +For[i=1,i<=n,i++, + If[i==nn, + Print["door ",i," is open"]; + a++; + nn+=2a+1; + , + Print["door ",i," is closed"]; + ]; +] diff --git a/Task/100-doors/Mathematica/100-doors-5.mathematica b/Task/100-doors/Mathematica/100-doors-5.mathematica new file mode 100644 index 0000000000..8dab41125d --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-5.mathematica @@ -0,0 +1 @@ +Pick[Range[100], Xor@@@Array[Divisible[#1,#2]&, {100,100}]] diff --git a/Task/100-doors/Mathematica/100-doors-6.mathematica b/Task/100-doors/Mathematica/100-doors-6.mathematica new file mode 100644 index 0000000000..11e842986e --- /dev/null +++ b/Task/100-doors/Mathematica/100-doors-6.mathematica @@ -0,0 +1 @@ +Range[Sqrt[100]]^2 diff --git a/Task/100-doors/Maxima/100-doors.maxima b/Task/100-doors/Maxima/100-doors.maxima new file mode 100644 index 0000000000..98bad752a6 --- /dev/null +++ b/Task/100-doors/Maxima/100-doors.maxima @@ -0,0 +1,10 @@ +doors(n) := block([v: makelist(i, i, 1, n)], + for i from 2 thru n do + for j from i step i while j <= n do v[j]: -v[j], + sublist(v, ?plusp))$ + +doors(100); +[1, 4, 9, 16, 25, 36, 49, 64, 81, 100] + +/* Note: ?plusp is a Lisp function. Maxima has nonnegintegerp, which is equivalent, +but it needs load(linearalgebra)$ first. */ diff --git a/Task/100-doors/Mercury/100-doors.mercury b/Task/100-doors/Mercury/100-doors.mercury new file mode 100644 index 0000000000..9d1bdb769e --- /dev/null +++ b/Task/100-doors/Mercury/100-doors.mercury @@ -0,0 +1,33 @@ +:- module doors. +:- interface. +:- import_module array, io, int. + +:- type door ---> open ; closed. +:- type doors == array(door). + +:- func toggle(door) = door. +:- pred walk(int::in, doors::in, doors::out) is semidet. +:- pred walks(int::in, int::in, doors::in, doors::out) is det. + +:- pred main(io::di, io::uo) is det. + +:- implementation. + +toggle(open) = closed. +toggle(closed) = open. + +walk(N, !D) :- walk(N, N, !D). + +:- pred walk(int::in, int::in, doors::in, doors::out) is semidet. +walk(At, By, !D) :- + semidet_lookup(!.D, At - 1, Door), + slow_set(!.D, At - 1, toggle(Door), !:D), + ( walk(At + By, By, !D) -> true ; true ). + +walks(N, End, !D) :- + ( N =< End, walk(N, !D) -> walks(N + 1, End, !D) ; true ). + +main(!IO) :- + io.write(Doors1, !IO), io.nl(!IO), + array.init(100, closed, Doors0), + walks(1, 100, Doors0, Doors1). diff --git a/Task/100-doors/Metafont/100-doors.metafont b/Task/100-doors/Metafont/100-doors.metafont new file mode 100644 index 0000000000..87f7581289 --- /dev/null +++ b/Task/100-doors/Metafont/100-doors.metafont @@ -0,0 +1,11 @@ +boolean doors[]; +for i = 1 upto 100: doors[i] := false; endfor +for i = 1 upto 100: + for j = 1 step i until 100: + doors[j] := not doors[j]; + endfor +endfor +for i = 1 upto 100: + message decimal(i) & " " & if doors[i]: "open" else: "close" fi; +endfor +end diff --git a/Task/100-doors/Mirah/100-doors.mirah b/Task/100-doors/Mirah/100-doors.mirah new file mode 100644 index 0000000000..75779d5370 --- /dev/null +++ b/Task/100-doors/Mirah/100-doors.mirah @@ -0,0 +1,44 @@ +import java.util.ArrayList + +class Door + :state + + def initialize + @state=false + end + + def closed?; !@state; end + def open?; @state; end + + def close; @state=false; end + def open; @state=true; end + + def toggle + if closed? + open + else + close + end + end + + def toString; Boolean.toString(@state); end +end + +doors=ArrayList.new +1.upto(100) do + doors.add(Door.new) +end + +1.upto(100) do |multiplier| + index = 0 + doors.each do |door| + Door(door).toggle if (index+1)%multiplier == 0 + index += 1 + end +end + +i = 0 +doors.each do |door| + puts "Door #{i+1} is #{door}." + i+=1 +end diff --git a/Task/100-doors/Modula-2/100-doors-1.mod2 b/Task/100-doors/Modula-2/100-doors-1.mod2 new file mode 100644 index 0000000000..c483684695 --- /dev/null +++ b/Task/100-doors/Modula-2/100-doors-1.mod2 @@ -0,0 +1,36 @@ +MODULE Doors; +IMPORT InOut; + +TYPE State = (Closed, Open); +TYPE List = ARRAY [1 .. 100] OF State; + +VAR + Doors: List; + I, J: CARDINAL; + +BEGIN + FOR I := 1 TO 100 DO + FOR J := 1 TO 100 DO + IF J MOD I = 0 THEN + IF Doors[J] = Closed THEN + Doors[J] := Open + ELSE + Doors[J] := Closed + END + END + END + END; + + FOR I := 1 TO 100 DO + InOut.WriteCard(I, 3); + InOut.WriteString(' is '); + + IF Doors[I] = Closed THEN + InOut.WriteString('Closed.') + ELSE + InOut.WriteString('Open.') + END; + + InOut.WriteLn + END +END Doors. diff --git a/Task/100-doors/Modula-2/100-doors-2.mod2 b/Task/100-doors/Modula-2/100-doors-2.mod2 new file mode 100644 index 0000000000..751f4c4caa --- /dev/null +++ b/Task/100-doors/Modula-2/100-doors-2.mod2 @@ -0,0 +1,26 @@ +MODULE DoorsOpt; +IMPORT InOut; + +TYPE State = (Closed, Open); +TYPE List = ARRAY [1 .. 100] OF State; + +VAR + Doors: List; + I: CARDINAL; + +BEGIN + FOR I := 1 TO 10 DO + Doors[I*I] := Open + END; + + FOR I := 1 TO 100 DO + InOut.WriteCard(I, 3); + InOut.WriteString(' is '); + IF Doors[I] = Closed THEN + InOut.WriteString('Closed.') + ELSE + InOut.WriteString('Open.') + END; + InOut.WriteLn + END +END DoorsOpt. diff --git a/Task/100-doors/Modula-3/100-doors-1.mod3 b/Task/100-doors/Modula-3/100-doors-1.mod3 new file mode 100644 index 0000000000..24107d279a --- /dev/null +++ b/Task/100-doors/Modula-3/100-doors-1.mod3 @@ -0,0 +1,31 @@ +MODULE Doors EXPORTS Main; + +IMPORT IO, Fmt; + +TYPE State = {Closed, Open}; +TYPE List = ARRAY [1..100] OF State; + +VAR doors := List{State.Closed, ..}; + +BEGIN + FOR i := 1 TO 100 DO + FOR j := FIRST(doors) TO LAST(doors) DO + IF j MOD i = 0 THEN + IF doors[j] = State.Closed THEN + doors[j] := State.Open; + ELSE + doors[j] := State.Closed; + END; + END; + END; + END; + + FOR i := FIRST(doors) TO LAST(doors) DO + IO.Put(Fmt.Int(i) & " is "); + IF doors[i] = State.Closed THEN + IO.Put("Closed.\n"); + ELSE + IO.Put("Open.\n"); + END; + END; +END Doors. diff --git a/Task/100-doors/Modula-3/100-doors-2.mod3 b/Task/100-doors/Modula-3/100-doors-2.mod3 new file mode 100644 index 0000000000..d8159f5e12 --- /dev/null +++ b/Task/100-doors/Modula-3/100-doors-2.mod3 @@ -0,0 +1,23 @@ +MODULE DoorsOpt EXPORTS Main; + +IMPORT IO, Fmt; + +TYPE State = {Closed, Open}; +TYPE List = ARRAY [1..100] OF State; + +VAR doors := List{State.Closed, ..}; + +BEGIN + FOR i := 1 TO 10 DO + doors[i * i] := State.Open; + END; + + FOR i := FIRST(doors) TO LAST(doors) DO + IO.Put(Fmt.Int(i) & " is "); + IF doors[i] = State.Closed THEN + IO.Put("Closed.\n"); + ELSE + IO.Put("Open.\n"); + END; + END; +END DoorsOpt. diff --git a/Task/24-game-Solve/0DESCRIPTION b/Task/24-game-Solve/0DESCRIPTION new file mode 100644 index 0000000000..b198118587 --- /dev/null +++ b/Task/24-game-Solve/0DESCRIPTION @@ -0,0 +1,6 @@ +Write a function that given four digits subject to the rules of the [[24 game]], computes an expression to solve the game if possible. + +Show examples of solutions generated by the function + + +C.F: [[Arithmetic Evaluator]] diff --git a/Task/24-game-Solve/ABAP/24-game-solve.abap b/Task/24-game-Solve/ABAP/24-game-solve.abap new file mode 100644 index 0000000000..9822151d93 --- /dev/null +++ b/Task/24-game-Solve/ABAP/24-game-solve.abap @@ -0,0 +1,198 @@ +data: lv_flag type c, + lv_number type i, + lt_numbers type table of i. + +constants: c_no_val type i value 9999. + +append 1 to lt_numbers. +append 1 to lt_numbers. +append 2 to lt_numbers. +append 7 to lt_numbers. + +write 'Evaluating 24 with the following input: '. +loop at lt_numbers into lv_number. + write lv_number. +endloop. +perform solve_24 using lt_numbers. + +form eval_formula using iv_eval type string changing ev_out type i. + call function 'EVAL_FORMULA' "analysis of a syntactically correct formula + exporting + formula = iv_eval + importing + value = ev_out + exceptions + others = 1. + + if sy-subrc <> 0. + ev_out = -1. + endif. +endform. + +" Solve a 24 puzzle. +form solve_24 using it_numbers like lt_numbers. + data: lv_flag type c, + lv_op1 type c, + lv_op2 type c, + lv_op3 type c, + lv_var1 type c, + lv_var2 type c, + lv_var3 type c, + lv_var4 type c, + lv_eval type string, + lv_result type i, + lv_var type i. + + define retrieve_var. + read table it_numbers index &1 into lv_var. + &2 = lv_var. + end-of-definition. + + define retrieve_val. + perform eval_formula using lv_eval changing lv_result. + if lv_result = 24. + write / lv_eval. + endif. + end-of-definition. + " Loop through all the possible number permutations. + do. + " Init. the operations table. + + retrieve_var: 1 lv_var1, 2 lv_var2, 3 lv_var3, 4 lv_var4. + do 4 times. + case sy-index. + when 1. + lv_op1 = '+'. + when 2. + lv_op1 = '*'. + when 3. + lv_op1 = '-'. + when 4. + lv_op1 = '/'. + endcase. + do 4 times. + case sy-index. + when 1. + lv_op2 = '+'. + when 2. + lv_op2 = '*'. + when 3. + lv_op2 = '-'. + when 4. + lv_op2 = '/'. + endcase. + do 4 times. + case sy-index. + when 1. + lv_op3 = '+'. + when 2. + lv_op3 = '*'. + when 3. + lv_op3 = '-'. + when 4. + lv_op3 = '/'. + endcase. + concatenate '(' '(' lv_var1 lv_op1 lv_var2 ')' lv_op2 lv_var3 ')' lv_op3 lv_var4 into lv_eval separated by space. + retrieve_val. + concatenate '(' lv_var1 lv_op1 lv_var2 ')' lv_op2 '(' lv_var3 lv_op3 lv_var4 ')' into lv_eval separated by space. + retrieve_val. + concatenate '(' lv_var1 lv_op1 '(' lv_var2 lv_op2 lv_var3 ')' ')' lv_op3 lv_var4 into lv_eval separated by space. + retrieve_val. + concatenate lv_var1 lv_op1 '(' '(' lv_var2 lv_op2 lv_var3 ')' lv_op3 lv_var4 ')' into lv_eval separated by space. + retrieve_val. + concatenate lv_var1 lv_op1 '(' lv_var2 lv_op2 '(' lv_var3 lv_op3 lv_var4 ')' ')' into lv_eval separated by space. + retrieve_val. + enddo. + enddo. + enddo. + + " Once we've reached the last permutation -> Exit. + perform permute using it_numbers changing lv_flag. + if lv_flag = 'X'. + exit. + endif. + enddo. +endform. + + +" Permutation function - this is used to permute: +" A = {A1...AN} -> Set of supplied variables. +" B = {B1...BN - 1} -> Set of operators. +" Can be used for an unbounded size set. Relies +" on lexicographic ordering of the set. +form permute using iv_set like lt_numbers + changing ev_last type c. + data: lv_len type i, + lv_first type i, + lv_third type i, + lv_count type i, + lv_temp type i, + lv_temp_2 type i, + lv_second type i, + lv_changed type c, + lv_perm type i. + describe table iv_set lines lv_len. + + lv_perm = lv_len - 1. + lv_changed = ' '. + " Loop backwards through the table, attempting to find elements which + " can be permuted. If we find one, break out of the table and set the + " flag indicating a switch. + do. + if lv_perm <= 0. + exit. + endif. + " Read the elements. + read table iv_set index lv_perm into lv_first. + add 1 to lv_perm. + read table iv_set index lv_perm into lv_second. + subtract 1 from lv_perm. + if lv_first < lv_second. + lv_changed = 'X'. + exit. + endif. + subtract 1 from lv_perm. + enddo. + + " Last permutation. + if lv_changed <> 'X'. + ev_last = 'X'. + exit. + endif. + + " Swap tail decresing to get a tail increasing. + lv_count = lv_perm + 1. + do. + lv_first = lv_len + lv_perm - lv_count + 1. + if lv_count >= lv_first. + exit. + endif. + + read table iv_set index lv_count into lv_temp. + read table iv_set index lv_first into lv_temp_2. + modify iv_set index lv_count from lv_temp_2. + modify iv_set index lv_first from lv_temp. + add 1 to lv_count. + enddo. + + lv_count = lv_len - 1. + do. + if lv_count <= lv_perm. + exit. + endif. + + read table iv_set index lv_count into lv_first. + read table iv_set index lv_perm into lv_second. + read table iv_set index lv_len into lv_third. + if ( lv_first < lv_third ) and ( lv_first > lv_second ). + lv_len = lv_count. + endif. + + subtract 1 from lv_count. + enddo. + + read table iv_set index lv_perm into lv_temp. + read table iv_set index lv_len into lv_temp_2. + modify iv_set index lv_perm from lv_temp_2. + modify iv_set index lv_len from lv_temp. +endform. diff --git a/Task/24-game-Solve/Argile/24-game-solve.argile b/Task/24-game-Solve/Argile/24-game-solve.argile new file mode 100644 index 0000000000..2896ac57a7 --- /dev/null +++ b/Task/24-game-Solve/Argile/24-game-solve.argile @@ -0,0 +1,98 @@ +die "Please give 4 digits as argument 1\n" if argc < 2 + +print a function that given four digits argv[1] subject to the rules of \ +the _24_ game, computes an expression to solve the game if possible. + +use std, array + +let digits be an array of 4 byte +let operators be an array of 4 byte +(: reordered arrays :) +let (type of digits) rdigits +let (type of operators) roperators + +.: a function that given four digits subject to + the rules of the _24_ game, computes an expression to solve + the game if possible. :. -> text + if #digits != 4 {return "[error: need exactly 4 digits]"} + operators[0] = '+' ; operators[1] = '-' + operators[2] = '*' ; operators[3] = '/' + for each (val int d) from 0 to 3 + if (digits[d] < '1') || (digits[d] > '9') + return "[error: non-digit character given]" + (super digits)[d] = digits[d] + let expr = for each operand order stuff + return "" if expr is nil + expr + +.:for each operand order stuff:. -> text + for each (val int a) from 0 to 3 + for each (val int b) from 0 to 3 + next if (b == a) + for each (val int c) from 0 to 3 + next if (c == b) or (c == a) + for each (val int d) from 0 to 3 + next if (d == c) or (d == b) or (d == a) + rdigits[0] = digits[a] ; rdigits[1] = digits[b] + rdigits[2] = digits[c] ; rdigits[3] = digits[d] + let found = for each operator order stuff + return found unless found is nil + nil + +.:for each operator order stuff:. -> text + for each (val int i) from 0 to 3 + for each (val int j) from 0 to 3 + for each (val int k) from 0 to 3 + roperators[0] = operators[i] + roperators[1] = operators[j] + roperators[2] = operators[k] + let found = for each RPN pattern stuff + return found if found isn't nil + nil + +our (raw array of text) RPN_patterns = Cdata + "xx.x.x." + "xx.xx.." + "xxx..x." + "xxx.x.." + "xxxx..." +our (raw array of text) formats = Cdata + "((%c%c%c)%c%c)%c%c" + "(%c%c%c)%c(%c%c%c)" + "(%c%c(%c%c%c))%c%c" + "%c%c((%c%c%c)%c%c)" + "%c%c(%c%c(%c%c%c))" +our (raw array of array of 3 int) rrop = Cdata + {0;1;2}; {0;2;1}; {1;0;2}; {2;0;1}; {2;1;0} + +.:for each RPN pattern stuff:. -> text + let RPN_stack be an array of 4 real + for each (val int rpn) from 0 to 4 + let (nat) sp=0, op=0, dg=0. + let text p + for (p = RPN_patterns[rpn]) (*p != 0) (p++) + if *p == 'x' + if sp >= 4 {die "RPN stack overflow\n"} + if dg > 3 {die "RPN digits overflow\n"} + RPN_stack[sp++] = (rdigits[dg++] - '0') as real + if *p == '.' + if sp < 2 {die "RPN stack underflow\n"} + if op > 2 {die "RPN operators overflow\n"} + sp -= 2 + let x = RPN_stack[sp] + let y = RPN_stack[sp + 1] + switch roperators[op++] + case '+' {x += y} + case '-' {x -= y} + case '*' {x *= y} + case '/' {x /= y} + default {die "RPN operator unknown\n"} + RPN_stack[sp++] = x + if RPN_stack[0] == 24.0 + our array of 12 byte buffer (: 4 paren + 3 ops + 4 digits + null :) + snprintf (buffer as text) (size of buffer) (formats[rpn]) \ + (rdigits[0]) (roperators[(rrop[rpn][0])]) (rdigits[1]) \ + (roperators[(rrop[rpn][1])]) (rdigits[2]) \ + (roperators[(rrop[rpn][2])]) (rdigits[3]); + return buffer as text + nil diff --git a/Task/24-game-Solve/AutoHotkey/24-game-solve.ahk b/Task/24-game-Solve/AutoHotkey/24-game-solve.ahk new file mode 100644 index 0000000000..df08ec784f --- /dev/null +++ b/Task/24-game-Solve/AutoHotkey/24-game-solve.ahk @@ -0,0 +1,108 @@ +#NoEnv +InputBox, NNNN ; user input 4 digits +NNNN := RegExReplace(NNNN, "(\d)(?=\d)", "$1,") ; separate with commas for the sort command +sort NNNN, d`, ; sort in ascending order for the permutations to work +StringReplace NNNN, NNNN, `,, , All ; remove comma separators after sorting + +ops := "+-*/" +patterns := [ "x x.x.x." + ,"x x.x x.." + ,"x x x..x." + ,"x x x.x.." + ,"x x x x..." ] + +; build bruteforce operator list ("+++, ++-, ++* ... ///") +a := b := c := 0 +While (++a<5){ + While (++b<5){ + While (++c<5){ + l := SubStr(ops, a, 1) . SubStr(ops, b, 1) . SubStr(ops, c, 1) + + ; build bruteforce template ("x x+x+x+, x x+x x++ ... x x x x///") + For each, pattern in patterns + { + Loop 3 + StringReplace, pattern, pattern, ., % SubStr(l, A_Index, 1) + pat .= pattern "`n" + } + }c := 0 + }b := 0 +} +StringTrimRight, pat, pat, 1 ; remove trailing newline + + +; permutate input. As the lexicographic algorithm is used, each permutation generated is unique +While NNNN +{ + StringSplit, N, NNNN + ; substitute numbers in for x's and evaluate + Loop Parse, pat, `n + { + eval := A_LoopField ; current line + Loop 4 + StringReplace, eval, eval, x, % N%A_Index% ; substitute number for "x" + If Round(evalRPN(eval), 4) = 24 + final .= eval "`n" + } + NNNN := perm_next(NNNN) ; next lexicographic permutation of user's digits +} +MsgBox % final ? clipboard := final : "No solution" + +; simple stack-based evaluation. Integers only. Whitespace is used to push a value. +evalRPN(s){ + stack := [] + Loop Parse, s + If A_LoopField is number + t .= A_LoopField + else + { + If t + stack.Insert(t), t := "" + If InStr("+-/*", l := A_LoopField) + { + a := stack.Remove(), b := stack.Remove() + stack.Insert( l = "+" ? b + a + :l = "-" ? b - a + :l = "*" ? b * a + :l = "/" ? b / a + :0 ) + } + } + return stack.Remove() +} + + + +perm_Next(str){ + p := 0, sLen := StrLen(str) + Loop % sLen + { + If A_Index=1 + continue + t := SubStr(str, sLen+1-A_Index, 1) + n := SubStr(str, sLen+2-A_Index, 1) + If ( t < n ) + { + p := sLen+1-A_Index, pC := SubStr(str, p, 1) + break + } + } + If !p + return false + Loop + { + t := SubStr(str, sLen+1-A_Index, 1) + If ( t > pC ) + { + n := sLen+1-A_Index, nC := SubStr(str, n, 1) + break + } + } + return SubStr(str, 1, p-1) . nC . Reverse(SubStr(str, p+1, n-p-1) . pC . SubStr(str, n+1)) +} + +Reverse(s){ + Loop Parse, s + o := A_LoopField o + return o +} diff --git a/Task/24-game-Solve/BBC-BASIC/24-game-solve.bbc b/Task/24-game-Solve/BBC-BASIC/24-game-solve.bbc new file mode 100644 index 0000000000..d77ff7bd9e --- /dev/null +++ b/Task/24-game-Solve/BBC-BASIC/24-game-solve.bbc @@ -0,0 +1,56 @@ + PROCsolve24("1234") + PROCsolve24("6789") + PROCsolve24("1127") + PROCsolve24("5566") + END + + DEF PROCsolve24(s$) + LOCAL F%, I%, J%, K%, L%, P%, T%, X$, o$(), p$(), t$() + DIM o$(4), p$(24,4), t$(11) + o$() = "", "+", "-", "*", "/" + RESTORE + FOR T% = 1 TO 11 + READ t$(T%) + NEXT + DATA "abcdefg", "(abc)defg", "ab(cde)fg", "abcd(efg)", "(abc)d(efg)", "(abcde)fg" + DATA "ab(cdefg)", "((abc)de)fg", "(ab(cde))fg", "ab((cde)fg)", "ab(cd(efg))" + + FOR I% = 1 TO 4 + FOR J% = 1 TO 4 + FOR K% = 1 TO 4 + FOR L% = 1 TO 4 + IF I%<>J% IF J%<>K% IF K%<>L% IF I%<>K% IF J%<>L% IF I%<>L% THEN + P% += 1 + p$(P%,1) = MID$(s$,I%,1) + p$(P%,2) = MID$(s$,J%,1) + p$(P%,3) = MID$(s$,K%,1) + p$(P%,4) = MID$(s$,L%,1) + ENDIF + NEXT + NEXT + NEXT + NEXT + + FOR I% = 1 TO 4 + FOR J% = 1 TO 4 + FOR K% = 1 TO 4 + FOR T% = 1 TO 11 + FOR P% = 1 TO 24 + X$ = t$(T%) + MID$(X$, INSTR(X$,"a"), 1) = p$(P%,1) + MID$(X$, INSTR(X$,"b"), 1) = o$(I%) + MID$(X$, INSTR(X$,"c"), 1) = p$(P%,2) + MID$(X$, INSTR(X$,"d"), 1) = o$(J%) + MID$(X$, INSTR(X$,"e"), 1) = p$(P%,3) + MID$(X$, INSTR(X$,"f"), 1) = o$(K%) + MID$(X$, INSTR(X$,"g"), 1) = p$(P%,4) + F% = TRUE : ON ERROR LOCAL F% = FALSE + IF F% IF EVAL(X$) = 24 THEN PRINT X$ : EXIT FOR I% + RESTORE ERROR + NEXT + NEXT + NEXT + NEXT + NEXT + IF I% > 4 PRINT "No solution found" + ENDPROC diff --git a/Task/24-game-Solve/C/24-game-solve.c b/Task/24-game-Solve/C/24-game-solve.c new file mode 100644 index 0000000000..7b7c80864b --- /dev/null +++ b/Task/24-game-Solve/C/24-game-solve.c @@ -0,0 +1,141 @@ +#include +#include +#include + +#define n_cards 4 +#define solve_goal 24 +#define max_digit 9 + +typedef struct { int num, denom; } frac_t, *frac; +typedef enum { C_NUM = 0, C_ADD, C_SUB, C_MUL, C_DIV, } op_type; + +typedef struct expr_t *expr; +typedef struct expr_t { + op_type op; + expr left, right; + int value; +} expr_t; + +void show_expr(expr e, op_type prec, int is_right) +{ + const char * op; + switch(e->op) { + case C_NUM: printf("%d", e->value); + return; + case C_ADD: op = " + "; break; + case C_SUB: op = " - "; break; + case C_MUL: op = " x "; break; + case C_DIV: op = " / "; break; + } + + if ((e->op == prec && is_right) || e->op < prec) printf("("); + show_expr(e->left, e->op, 0); + printf("%s", op); + show_expr(e->right, e->op, 1); + if ((e->op == prec && is_right) || e->op < prec) printf(")"); +} + +void eval_expr(expr e, frac f) +{ + frac_t left, right; + if (e->op == C_NUM) { + f->num = e->value; + f->denom = 1; + return; + } + eval_expr(e->left, &left); + eval_expr(e->right, &right); + switch (e->op) { + case C_ADD: + f->num = left.num * right.denom + left.denom * right.num; + f->denom = left.denom * right.denom; + return; + case C_SUB: + f->num = left.num * right.denom - left.denom * right.num; + f->denom = left.denom * right.denom; + return; + case C_MUL: + f->num = left.num * right.num; + f->denom = left.denom * right.denom; + return; + case C_DIV: + f->num = left.num * right.denom; + f->denom = left.denom * right.num; + return; + default: + fprintf(stderr, "Unknown op: %d\n", e->op); + return; + } +} +int solve(expr ex_in[], int len) +{ + int i, j; + expr_t node; + expr ex[n_cards]; + frac_t final; + + if (len == 1) { + eval_expr(ex_in[0], &final); + if (final.num == final.denom * solve_goal && final.denom) { + show_expr(ex_in[0], 0, 0); + return 1; + } + return 0; + } + + for (i = 0; i < len - 1; i++) { + for (j = i + 1; j < len; j++) + ex[j - 1] = ex_in[j]; + ex[i] = &node; + for (j = i + 1; j < len; j++) { + node.left = ex_in[i]; + node.right = ex_in[j]; + for (node.op = C_ADD; node.op <= C_DIV; node.op++) + if (solve(ex, len - 1)) + return 1; + + node.left = ex_in[j]; + node.right = ex_in[i]; + node.op = C_SUB; + if (solve(ex, len - 1)) return 1; + node.op = C_DIV; + if (solve(ex, len - 1)) return 1; + + ex[j] = ex_in[j]; + } + ex[i] = ex_in[i]; + } + + return 0; +} + +int solve24(int n[]) +{ + int i; + expr_t ex[n_cards]; + expr e[n_cards]; + for (i = 0; i < n_cards; i++) { + e[i] = ex + i; + ex[i].op = C_NUM; + ex[i].left = ex[i].right = 0; + ex[i].value = n[i]; + } + return solve(e, n_cards); +} + +int main() +{ + int i, j, n[] = { 3, 3, 8, 8, 9 }; + srand(time(0)); + + for (j = 0; j < 10; j++) { + for (i = 0; i < n_cards; i++) { + n[i] = 1 + (double) rand() * max_digit / RAND_MAX; + printf(" %d", n[i]); + } + printf(": "); + printf(solve24(n) ? "\n" : "No solution\n"); + } + + return 0; +} diff --git a/Task/24-game-Solve/Clojure/24-game-solve.clj b/Task/24-game-Solve/Clojure/24-game-solve.clj new file mode 100644 index 0000000000..f30b5c5987 --- /dev/null +++ b/Task/24-game-Solve/Clojure/24-game-solve.clj @@ -0,0 +1,30 @@ +(use 'clojure.contrib.combinatorics) + +(defn nested-replace [l m] +(cond +(= l '()) '() +(m (first l)) (concat (list (m (first l))) (nested-replace (rest l) m)) +(seq? (first l)) (concat (list (nested-replace (first l) m)) (nested-replace (rest l) m)) +true (concat (list (first l)) (nested-replace (rest l) m)))) + +(defn format-solution [sol] +(cond +(number? sol) sol +(seq? sol) + (list (format-solution (second sol)) (first sol) (format-solution (nth sol 2))))) + +(defn play24 [& digits] (count (map #(-> % format-solution println) +(let [operator-map-list (map (fn [a] {:op1 (nth a 0) :op2 (nth a 1) :op3 (nth a 2)}) + (selections '(* + - /) 3)) + digits-map-list + (map (fn [a] {:num1 (nth a 0) :num2 (nth a 1) :num3 (nth a 2) :num4 (nth a 3)}) + (permutations digits)) + patterns-list (list + '(:op1 (:op2 :num1 :num2) (:op3 :num3 :num4)) + '(:op1 :num1 (:op2 :num2 (:op3 :num3 :num4)))) + ;other patterns can be added here, e.g. '(:op1 (:op2 (:op3 :num1 :num2) :num3) :num4) + op-subbed (reduce concat '() + (map (fn [a] (map #(nested-replace a % ) operator-map-list)) patterns-list)) + full-subbed (reduce concat '() + (map (fn [a] (map #(nested-replace % a) op-subbed)) digits-map-list))] + (filter #(= (try (eval %) (catch Exception e nil)) 24) full-subbed))))) diff --git a/Task/24-game-Solve/CoffeeScript/24-game-solve-1.coffee b/Task/24-game-Solve/CoffeeScript/24-game-solve-1.coffee new file mode 100644 index 0000000000..ca775d9813 --- /dev/null +++ b/Task/24-game-Solve/CoffeeScript/24-game-solve-1.coffee @@ -0,0 +1,87 @@ +# This program tries to find some way to turn four digits into an arithmetic +# expression that adds up to 24. +# +# Example solution for 5, 7, 8, 8: +# (((8 + 7) * 8) / 5) + + +solve_24_game = (digits...) -> + # Create an array of objects for our helper functions + arr = for digit in digits + { + val: digit + expr: digit + } + combo4 arr... + +combo4 = (a, b, c, d) -> + arr = [a, b, c, d] + # Reduce this to a three-node problem by combining two + # nodes from the array. + permutations = [ + [0, 1, 2, 3] + [0, 2, 1, 3] + [0, 3, 1, 2] + [1, 2, 0, 3] + [1, 3, 0, 2] + [2, 3, 0, 1] + ] + for permutation in permutations + [i, j, k, m] = permutation + for combo in combos arr[i], arr[j] + answer = combo3 combo, arr[k], arr[m] + return answer if answer + null + +combo3 = (a, b, c) -> + arr = [a, b, c] + permutations = [ + [0, 1, 2] + [0, 2, 1] + [1, 2, 0] + ] + for permutation in permutations + [i, j, k] = permutation + for combo in combos arr[i], arr[j] + answer = combo2 combo, arr[k] + return answer if answer + null + +combo2 = (a, b) -> + for combo in combos a, b + return combo.expr if combo.val == 24 + null + +combos = (a, b) -> + [ + val: a.val + b.val + expr: "(#{a.expr} + #{b.expr})" + , + val: a.val * b.val + expr: "(#{a.expr} * #{b.expr})" + , + val: a.val - b.val + expr: "(#{a.expr} - #{b.expr})" + , + val: b.val - a.val + expr: "(#{b.expr} - #{a.expr})" + , + val: a.val / b.val + expr: "(#{a.expr} / #{b.expr})" + , + val: b.val / a.val + expr: "(#{b.expr} / #{a.expr})" + , + ] + +# test +do -> + rand_digit = -> 1 + Math.floor (9 * Math.random()) + + for i in [1..15] + a = rand_digit() + b = rand_digit() + c = rand_digit() + d = rand_digit() + solution = solve_24_game a, b, c, d + console.log "Solution for #{[a,b,c,d]}: #{solution ? 'no solution'}" diff --git a/Task/24-game-Solve/CoffeeScript/24-game-solve-2.coffee b/Task/24-game-Solve/CoffeeScript/24-game-solve-2.coffee new file mode 100644 index 0000000000..c0b84511eb --- /dev/null +++ b/Task/24-game-Solve/CoffeeScript/24-game-solve-2.coffee @@ -0,0 +1,16 @@ +> coffee 24_game.coffee +Solution for 8,3,1,8: ((1 + 8) * (8 / 3)) +Solution for 6,9,5,7: (6 - ((5 - 7) * 9)) +Solution for 4,2,1,1: no solution +Solution for 3,5,1,3: (((3 + 5) * 1) * 3) +Solution for 6,4,1,7: ((7 - (4 - 1)) * 6) +Solution for 8,1,3,1: (((8 + 1) - 1) * 3) +Solution for 6,1,3,3: (((6 + 1) * 3) + 3) +Solution for 7,1,5,6: (((7 - 1) * 5) - 6) +Solution for 4,2,3,1: ((3 + 1) * (4 + 2)) +Solution for 8,8,5,8: ((5 * 8) - (8 + 8)) +Solution for 3,8,4,1: ((1 - (3 - 8)) * 4) +Solution for 6,4,3,8: ((8 - (6 / 3)) * 4) +Solution for 2,1,8,7: (((2 * 8) + 1) + 7) +Solution for 5,2,7,5: ((2 * 7) + (5 + 5)) +Solution for 2,4,8,9: ((9 - (2 + 4)) * 8) diff --git a/Task/24-game-Solve/Common-Lisp/24-game-solve.lisp b/Task/24-game-Solve/Common-Lisp/24-game-solve.lisp new file mode 100644 index 0000000000..389ce648fe --- /dev/null +++ b/Task/24-game-Solve/Common-Lisp/24-game-solve.lisp @@ -0,0 +1,56 @@ +(defconstant +ops+ '(* / + -)) + +(defun digits () + (sort (loop repeat 4 collect (1+ (random 9))) #'<)) + +(defun expr-value (expr) + (eval expr)) + +(defun divides-by-zero-p (expr) + (when (consp expr) + (destructuring-bind (op &rest args) expr + (or (divides-by-zero-p (car args)) + (and (eq op '/) + (or (and (= 1 (length args)) + (zerop (expr-value (car args)))) + (some (lambda (arg) + (or (divides-by-zero-p arg) + (zerop (expr-value arg)))) + (cdr args)))))))) + +(defun solvable-p (digits &optional expr) + (unless (divides-by-zero-p expr) + (if digits + (destructuring-bind (next &rest rest) digits + (if expr + (some (lambda (op) + (solvable-p rest (cons op (list next expr)))) + +ops+) + (solvable-p rest (list (car +ops+) next)))) + (when (and expr + (eql 24 (expr-value expr))) + (merge-exprs expr))))) + +(defun merge-exprs (expr) + (if (atom expr) + expr + (destructuring-bind (op &rest args) expr + (if (and (member op '(* +)) + (= 1 (length args))) + (car args) + (cons op + (case op + ((* +) + (loop for arg in args + for merged = (merge-exprs arg) + when (and (consp merged) + (eq op (car merged))) + append (cdr merged) + else collect merged)) + (t (mapcar #'merge-exprs args)))))))) + +(defun solve-24-game (digits) + "Generate a lisp form using the operators in +ops+ and the given +digits which evaluates to 24. The first form found is returned, or +NIL if there is no solution." + (solvable-p digits)) diff --git a/Task/24-game-Solve/D/24-game-solve.d b/Task/24-game-Solve/D/24-game-solve.d new file mode 100644 index 0000000000..690bf17863 --- /dev/null +++ b/Task/24-game-Solve/D/24-game-solve.d @@ -0,0 +1,47 @@ +import std.stdio, std.algorithm, std.range, std.typecons, std.conv, + std.string, permutations2, arithmetic_rational; + +string solve(in int target, in int[] problem) { + static struct ComputeAllOperations { + //static struct T { Rational r; string e; } + alias T = Tuple!(Rational,"r", string,"e"); + Rational[] L; + + int opApply(in int delegate(ref T) dg) { + int result; + + if (!L.empty) { + auto x = L[0]; + auto xs = L[1 .. $]; + if (L.length == 1) { + T aux = T(x, text(x)); + result = dg(aux); + } else { + OUTER: foreach (o; ComputeAllOperations(xs)) { + auto y = o.r; + auto sub = [T(x * y, "*"), T(x + y, "+"), T(x - y, "-")]; + if (y) sub ~= [T(x/y, "/")]; + foreach (e; sub) { + auto aux = T(e.r, format("(%s%s%s)", x, e.e, o.e)); + result = dg(aux); if (result) break OUTER; + } + } + } + } + + return result; + } + } + + + foreach (p; problem.map!Rational.array.permutations) + foreach (sol; ComputeAllOperations(p)) + if (sol.r == target) + return sol.e; + return "No solution"; +} + +void main() { + foreach (prob; [[6, 7, 9, 5], [3, 3, 8, 8], [1, 1, 1, 1]]) + writeln(prob, ": ", solve(24, prob)); +} diff --git a/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-1.euler b/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-1.euler new file mode 100644 index 0000000000..4be2aa25cf --- /dev/null +++ b/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-1.euler @@ -0,0 +1,22 @@ +>function try24 (v) ... +$n=cols(v); +$if n==1 and v[1]~=24 then +$ "Solved the problem", +$ return 1; +$endif +$loop 1 to n +$ w=tail(v,2); +$ loop 1 to n-1 +$ h=w; a=v[1]; b=w[1]; +$ w[1]=a+b; if try24(w); ""+a+"+"+b+"="+(a+b), return 1; endif; +$ w[1]=a-b; if try24(w); ""+a+"-"+b+"="+(a-b), return 1; endif; +$ w[1]=a*b; if try24(w); ""+a+"*"+b+"="+(a*b), return 1; endif; +$ if not b~=0 then +$ w[1]=a/b; if try24(w); ""+a+"/"+b+"="+(a/b), return 1; endif; +$ endif; +$ w=rotright(w); +$ end; +$ v=rotright(v); +$end; +$return 0; +$endfunction diff --git a/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-2.euler b/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-2.euler new file mode 100644 index 0000000000..f7da5e1fca --- /dev/null +++ b/Task/24-game-Solve/Euler-Math-Toolbox/24-game-solve-2.euler @@ -0,0 +1,20 @@ +>try24([1,2,3,4]); + Solved the problem + 6*4=24 + 3+3=6 + 1+2=3 +>try24([8,7,7,1]); + Solved the problem + 22+2=24 + 14+8=22 + 7+7=14 +>try24([8,4,7,1]); + Solved the problem + 6*4=24 + 7-1=6 + 8-4=4 +>try24([3,4,5,6]); + Solved the problem + 4*6=24 + -1+5=4 + 3-4=-1 diff --git a/Task/24-game-Solve/Fortran/24-game-solve-1.f b/Task/24-game-Solve/Fortran/24-game-solve-1.f new file mode 100644 index 0000000000..af81b9c0a3 --- /dev/null +++ b/Task/24-game-Solve/Fortran/24-game-solve-1.f @@ -0,0 +1,69 @@ +program solve_24 + use helpers + implicit none + real :: vector(4), reals(4), p, q, r, s + integer :: numbers(4), n, i, j, k, a, b, c, d + character, parameter :: ops(4) = (/ '+', '-', '*', '/' /) + logical :: last + real,parameter :: eps = epsilon(1.0) + + do n=1,12 + call random_number(vector) + reals = 9 * vector + 1 + numbers = int(reals) + call Insertion_Sort(numbers) + + permutations: do + a = numbers(1); b = numbers(2); c = numbers(3); d = numbers(4) + reals = real(numbers) + p = reals(1); q = reals(2); r = reals(3); s = reals(4) + ! combinations of operators: + do i=1,4 + do j=1,4 + do k=1,4 + if ( abs(op(op(op(p,i,q),j,r),k,s)-24.0) < eps ) then + write (*,*) numbers, ' : ', '((',a,ops(i),b,')',ops(j),c,')',ops(k),d + exit permutations + else if ( abs(op(op(p,i,op(q,j,r)),k,s)-24.0) < eps ) then + write (*,*) numbers, ' : ', '(',a,ops(i),'(',b,ops(j),c,'))',ops(k),d + exit permutations + else if ( abs(op(p,i,op(op(q,j,r),k,s))-24.0) < eps ) then + write (*,*) numbers, ' : ', a,ops(i),'((',b,ops(j),c,')',ops(k),d,')' + exit permutations + else if ( abs(op(p,i,op(q,j,op(r,k,s)))-24.0) < eps ) then + write (*,*) numbers, ' : ', a,ops(i),'(',b,ops(j),'(',c,ops(k),d,'))' + exit permutations + else if ( abs(op(op(p,i,q),j,op(r,k,s))-24.0) < eps ) then + write (*,*) numbers, ' : ', '(',a,ops(i),b,')',ops(j),'(',c,ops(k),d,')' + exit permutations + end if + end do + end do + end do + call nextpermutation(numbers,last) + if ( last ) then + write (*,*) numbers, ' : no solution.' + exit permutations + end if + end do permutations + + end do + +contains + + pure real function op(x,c,y) + integer, intent(in) :: c + real, intent(in) :: x,y + select case ( ops(c) ) + case ('+') + op = x+y + case ('-') + op = x-y + case ('*') + op = x*y + case ('/') + op = x/y + end select + end function op + +end program solve_24 diff --git a/Task/24-game-Solve/Fortran/24-game-solve-2.f b/Task/24-game-Solve/Fortran/24-game-solve-2.f new file mode 100644 index 0000000000..14d4f04a09 --- /dev/null +++ b/Task/24-game-Solve/Fortran/24-game-solve-2.f @@ -0,0 +1,72 @@ +module helpers + +contains + + pure subroutine Insertion_Sort(a) + integer, intent(inout) :: a(:) + integer :: temp, i, j + do i=2,size(a) + j = i-1 + temp = a(i) + do while ( j>=1 .and. a(j)>temp ) + a(j+1) = a(j) + j = j - 1 + end do + a(j+1) = temp + end do + end subroutine Insertion_Sort + + subroutine nextpermutation(perm,last) + integer, intent(inout) :: perm(:) + logical, intent(out) :: last + integer :: k,l + k = largest1() + last = k == 0 + if ( .not. last ) then + l = largest2(k) + call swap(l,k) + call reverse(k) + end if + contains + pure integer function largest1() + integer :: k, max + max = 0 + do k=1,size(perm)-1 + if ( perm(k) < perm(k+1) ) then + max = k + end if + end do + largest1 = max + end function largest1 + + pure integer function largest2(k) + integer, intent(in) :: k + integer :: l, max + max = k+1 + do l=k+2,size(perm) + if ( perm(k) < perm(l) ) then + max = l + end if + end do + largest2 = max + end function largest2 + + subroutine swap(l,k) + integer, intent(in) :: k,l + integer :: temp + temp = perm(k) + perm(k) = perm(l) + perm(l) = temp + end subroutine swap + + subroutine reverse(k) + integer, intent(in) :: k + integer :: i + do i=1,(size(perm)-k)/2 + call swap(k+i,size(perm)+1-i) + end do + end subroutine reverse + + end subroutine nextpermutation + +end module helpers diff --git a/Task/24-game-Solve/GAP/24-game-solve.gap b/Task/24-game-Solve/GAP/24-game-solve.gap new file mode 100644 index 0000000000..ce34544bf6 --- /dev/null +++ b/Task/24-game-Solve/GAP/24-game-solve.gap @@ -0,0 +1,84 @@ +# Solution in '''RPN''' +check := function(x, y, z) + local r, c, s, i, j, k, a, b, p; + i := 0; + j := 0; + k := 0; + s := [ ]; + r := ""; + for c in z do + if c = 'x' then + i := i + 1; + k := k + 1; + s[k] := x[i]; + Append(r, String(x[i])); + else + j := j + 1; + b := s[k]; + k := k - 1; + a := s[k]; + p := y[j]; + r[Size(r) + 1] := p; + if p = '+' then + a := a + b; + elif p = '-' then + a := a - b; + elif p = '*' then + a := a * b; + elif p = '/' then + if b = 0 then + continue; + else + a := a / b; + fi; + else + return fail; + fi; + s[k] := a; + fi; + od; + if s[1] = 24 then + return r; + else + return fail; + fi; +end; + +Player24 := function(digits) + local u, v, w, x, y, z, r; + u := PermutationsList(digits); + v := Tuples("+-*/", 3); + w := ["xx*x*x*", "xx*xx**", "xxx**x*", "xxx*x**", "xxxx***"]; + for x in u do + for y in v do + for z in w do + r := check(x, y, z); + if r <> fail then + return r; + fi; + od; + od; + od; + return fail; +end; + +Player24([1,2,7,7]); +# "77*1-2/" +Player24([9,8,7,6]); +# "68*97-/" +Player24([1,1,7,7]); +# fail + +# Solutions with only one distinct digit are found only for 3, 4, 5, 6: +Player24([3,3,3,3]); +# "33*3*3-" +Player24([4,4,4,4]); +# "44*4+4+" +Player24([5,5,5,5]); +# "55*55/-" +Player24([6,6,6,6]); +# "66*66+-" + +# A tricky one: +Player24([3,3,8,8]); +"8383/-/" diff --git a/Task/24-game-Solve/Go/24-game-solve.go b/Task/24-game-Solve/Go/24-game-solve.go new file mode 100644 index 0000000000..c19b9116f3 --- /dev/null +++ b/Task/24-game-Solve/Go/24-game-solve.go @@ -0,0 +1,171 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +const ( + op_num = iota + op_add + op_sub + op_mul + op_div +) + +type frac struct { + num, denom int +} + +// Expression: can either be a single number, or a result of binary +// operation from left and right node +type Expr struct { + op int + left, right *Expr + value frac +} + +var n_cards = 4 +var goal = 24 +var digit_range = 9 + +func (x *Expr) String() string { + if x.op == op_num { + return fmt.Sprintf("%d", x.value.num) + } + + var bl1, br1, bl2, br2, opstr string + switch { + case x.left.op == op_num: + case x.left.op >= x.op: + case x.left.op == op_add && x.op == op_sub: + bl1, br1 = "", "" + default: + bl1, br1 = "(", ")" + } + + if x.right.op == op_num || x.op < x.right.op { + bl2, br2 = "", "" + } else { + bl2, br2 = "(", ")" + } + + switch { + case x.op == op_add: + opstr = " + " + case x.op == op_sub: + opstr = " - " + case x.op == op_mul: + opstr = " * " + case x.op == op_div: + opstr = " / " + } + + return bl1 + x.left.String() + br1 + opstr + + bl2 + x.right.String() + br2 +} + +func expr_eval(x *Expr) (f frac) { + if x.op == op_num { + return x.value + } + + l, r := expr_eval(x.left), expr_eval(x.right) + + switch { + case x.op == op_add: + f.num = l.num*r.denom + l.denom*r.num + f.denom = l.denom * r.denom + return + + case x.op == op_sub: + f.num = l.num*r.denom - l.denom*r.num + f.denom = l.denom * r.denom + return + + case x.op == op_mul: + f.num = l.num * r.num + f.denom = l.denom * r.denom + return + + case x.op == op_div: + f.num = l.num * r.denom + f.denom = l.denom * r.num + return + } + return +} + +func solve(ex_in []*Expr) bool { + // only one expression left, meaning all numbers are arranged into + // a binary tree, so evaluate and see if we get 24 + if len(ex_in) == 1 { + f := expr_eval(ex_in[0]) + if f.denom != 0 && f.num == f.denom*goal { + fmt.Println(ex_in[0].String()) + return true + } + return false + } + + var node Expr + ex := make([]*Expr, len(ex_in)-1) + + // try to combine a pair of expressions into one, thus reduce + // the list length by 1, and recurse down + for i := range ex { + copy(ex[i:len(ex)], ex_in[i+1:len(ex_in)]) + + ex[i] = &node + for j := i + 1; j < len(ex_in); j++ { + node.left = ex_in[i] + node.right = ex_in[j] + + // try all 4 operators + for o := op_add; o <= op_div; o++ { + node.op = o + if solve(ex) { + return true + } + } + + // also - and / are not commutative, so swap arguments + node.left = ex_in[j] + node.right = ex_in[i] + + node.op = op_sub + if solve(ex) { + return true + } + + node.op = op_div + if solve(ex) { + return true + } + + if j < len(ex) { + ex[j] = ex_in[j] + } + } + ex[i] = ex_in[i] + } + return false +} + +func main() { + cards := make([]*Expr, n_cards) + rand.Seed(time.Now().Unix()) + + for k := 0; k < 10; k++ { + for i := 0; i < n_cards; i++ { + cards[i] = &Expr{op_num, nil, nil, + frac{rand.Intn(digit_range-1) + 1, 1}} + fmt.Printf(" %d", cards[i].value.num) + } + fmt.Print(": ") + if !solve(cards) { + fmt.Println("No solution") + } + } +} diff --git a/Task/24-game-Solve/Gosu/24-game-solve.gosu b/Task/24-game-Solve/Gosu/24-game-solve.gosu new file mode 100644 index 0000000000..a58172c0d8 --- /dev/null +++ b/Task/24-game-Solve/Gosu/24-game-solve.gosu @@ -0,0 +1,110 @@ +uses java.lang.Integer +uses java.lang.Double +uses java.lang.System +uses java.util.ArrayList +uses java.util.LinkedList +uses java.util.List +uses java.util.Scanner +uses java.util.Stack + +function permutations( lst : List ) : List> { + if( lst.size() == 0 ) return {} + if( lst.size() == 1 ) return { lst } + + var pivot = lst.get(lst.size()-1) + + var sublist = new ArrayList( lst ) + sublist.remove( sublist.size() - 1 ) + + var subPerms = permutations( sublist ) + + var ret = new ArrayList>() + for( x in subPerms ) { + for( e in x index i ) { + var next = new LinkedList( x ) + next.add( i, pivot ) + ret.add( next ) + } + x.add( pivot ) + ret.add( x ) + } + return ret +} + +function readVals() : List { + var line = new java.io.BufferedReader( new java.io.InputStreamReader( System.in ) ).readLine() + var scan = new Scanner( line ) + + var ret = new ArrayList() + for( i in 0..3 ) { + var next = scan.nextInt() + if( 0 >= next || next >= 10 ) { + print( "Invalid entry: ${next}" ) + return null + } + ret.add( next ) + } + return ret +} + +function getOp( i : int ) : char[] { + var ret = new char[3] + var ops = { '+', '-', '*', '/' } + ret[0] = ops[i / 16] + ret[1] = ops[(i / 4) % 4 ] + ret[2] = ops[i % 4 ] + return ret +} + +function isSoln( nums : List, ops : char[] ) : boolean { + var stk = new Stack() + for( n in nums ) { + stk.push( n ) + } + + for( c in ops ) { + var r = stk.pop().doubleValue() + var l = stk.pop().doubleValue() + if( c == '+' ) { + stk.push( l + r ) + } else if( c == '-' ) { + stk.push( l - r ) + } else if( c == '*' ) { + stk.push( l * r ) + } else if( c == '/' ) { + // Avoid division by 0 + if( r == 0.0 ) { + return false + } + stk.push( l / r ) + } + } + + return java.lang.Math.abs( stk.pop().doubleValue() - 24.0 ) < 0.001 +} + +function printSoln( nums : List, ops : char[] ) { + // RPN: a b c d + - * + // Infix (a * (b - (c + d))) + print( "Found soln: (${nums.get(0)} ${ops[0]} (${nums.get(1)} ${ops[1]} (${nums.get(2)} ${ops[2]} ${nums.get(3)})))" ) +} + +System.out.print( "#> " ) +var vals = readVals() + +var opPerms = 0..63 +var solnFound = false + +for( i in permutations( vals ) ) { + for( j in opPerms ) { + var opList = getOp( j ) + if( isSoln( i, opList ) ) { + printSoln( i, opList ) + solnFound = true + } + } +} + +if( ! solnFound ) { + print( "No solution!" ) +} diff --git a/Task/24-game-Solve/Haskell/24-game-solve-1.hs b/Task/24-game-Solve/Haskell/24-game-solve-1.hs new file mode 100644 index 0000000000..b5917fd864 --- /dev/null +++ b/Task/24-game-Solve/Haskell/24-game-solve-1.hs @@ -0,0 +1,50 @@ +import Data.List +import Data.Ratio +import Control.Monad +import System.Environment (getArgs) + +data Expr = Constant Rational | + Expr :+ Expr | Expr :- Expr | + Expr :* Expr | Expr :/ Expr + deriving (Eq) + +ops = [(:+), (:-), (:*), (:/)] + +instance Show Expr where + show (Constant x) = show $ numerator x + -- In this program, we need only print integers. + show (a :+ b) = strexp "+" a b + show (a :- b) = strexp "-" a b + show (a :* b) = strexp "*" a b + show (a :/ b) = strexp "/" a b + +strexp :: String -> Expr -> Expr -> String +strexp op a b = "(" ++ show a ++ " " ++ op ++ " " ++ show b ++ ")" + +templates :: [[Expr] -> Expr] +templates = do + op1 <- ops + op2 <- ops + op3 <- ops + [\[a, b, c, d] -> op1 a $ op2 b $ op3 c d, + \[a, b, c, d] -> op1 (op2 a b) $ op3 c d, + \[a, b, c, d] -> op1 a $ op2 (op3 b c) d, + \[a, b, c, d] -> op1 (op2 a $ op3 b c) d, + \[a, b, c, d] -> op1 (op2 (op3 a b) c) d] + +eval :: Expr -> Maybe Rational +eval (Constant c) = Just c +eval (a :+ b) = liftM2 (+) (eval a) (eval b) +eval (a :- b) = liftM2 (-) (eval a) (eval b) +eval (a :* b) = liftM2 (*) (eval a) (eval b) +eval (a :/ b) = do + denom <- eval b + guard $ denom /= 0 + liftM (/ denom) $ eval a + +solve :: Rational -> [Rational] -> [Expr] +solve target r4 = filter (maybe False (== target) . eval) $ + liftM2 ($) templates $ + nub $ permutations $ map Constant r4 + +main = getArgs >>= mapM_ print . solve 24 . map (toEnum . read) diff --git a/Task/24-game-Solve/Haskell/24-game-solve-2.hs b/Task/24-game-Solve/Haskell/24-game-solve-2.hs new file mode 100644 index 0000000000..2d42d88fdc --- /dev/null +++ b/Task/24-game-Solve/Haskell/24-game-solve-2.hs @@ -0,0 +1,76 @@ +invocable all +link strings # for csort, deletec, permutes + +procedure main() +static eL +initial { + eoP := [] # set-up expression and operator permutation patterns + every ( e := !["a@b#c$d", "a@(b#c)$d", "a@b#(c$d)", "a@(b#c$d)", "a@(b#(c$d))"] ) & + ( o := !(opers := "+-*/") || !opers || !opers ) do + put( eoP, map(e,"@#$",o) ) # expr+oper perms + + eL := [] # all cases + every ( e := !eoP ) & ( p := permutes("wxyz") ) do + put(eL, map(e,"abcd",p)) + + } + +write("This will attempt to find solutions to 24 for sets of numbers by\n", + "combining 4 single digits between 1 and 9 to make 24 using only + - * / and ( ).\n", + "All operations have equal precedence and are evaluated left to right.\n", + "Enter 'use n1 n2 n3 n4' or just hit enter (to use a random set),", + "'first'/'all' shows the first or all solutions, 'quit' to end.\n\n") + +repeat { + e := trim(read()) | fail + e ? case tab(find(" ")|0) of { + "q"|"quit" : break + "u"|"use" : e := tab(0) + "f"|"first": first := 1 & next + "a"|"all" : first := &null & next + "" : e := " " ||(1+?8) || " " || (1+?8) ||" " || (1+?8) || " " || (1+?8) + } + + writes("Attempting to solve 24 for",e) + + e := deletec(e,' \t') # no whitespace + if e ? ( tab(many('123456789')), pos(5), pos(0) ) then + write(":") + else write(" - invalid, only the digits '1..9' are allowed.") & next + + eS := set() + every ex := map(!eL,"wxyz",e) do { + if member(eS,ex) then next # skip duplicates of final expression + insert(eS,ex) + if ex ? (ans := eval(E()), pos(0)) then # parse and evaluate + if ans = 24 then { + write("Success ",image(ex)," evaluates to 24.") + if \first then break + } + } + } +write("Quiting.") +end + +procedure eval(X) #: return the evaluated AST + if type(X) == "list" then { + x := eval(get(X)) + while o := get(X) do + if y := get(X) then + x := o( real(x), (o ~== "/" | fail, eval(y) )) + else write("Malformed expression.") & fail + } + return \x | X +end + +procedure E() #: expression + put(lex := [],T()) + while put(lex,tab(any('+-*/'))) do + put(lex,T()) + suspend if *lex = 1 then lex[1] else lex # strip useless [] +end + +procedure T() #: Term + suspend 2(="(", E(), =")") | # parenthesized subexpression, or ... + tab(any(&digits)) # just a value +end diff --git a/Task/24-game-Solve/J/24-game-solve.j b/Task/24-game-Solve/J/24-game-solve.j new file mode 100644 index 0000000000..8d2413a05e --- /dev/null +++ b/Task/24-game-Solve/J/24-game-solve.j @@ -0,0 +1,9 @@ +perm=: (A.&i.~ !) 4 +ops=: ' ',.'+-*%' {~ >,{i.each 4 4 4 +cmask=: 1 + 0j1 * i.@{:@$@[ e. ] +left=: [ #!.'('~"1 cmask +right=: [ #!.')'~"1 cmask +paren=: 2 :'[: left&m right&n' +parens=: ], 0 paren 3, 0 paren 5, 2 paren 5, [: 0 paren 7 (0 paren 3) +all=: [: parens [:,/ ops ,@,."1/ perm { [:;":each +answer=: ({.@#~ 24 = ".)@all diff --git a/Task/24-game-Solve/JavaScript/24-game-solve.js b/Task/24-game-Solve/JavaScript/24-game-solve.js new file mode 100644 index 0000000000..6c9c5e7d6c --- /dev/null +++ b/Task/24-game-Solve/JavaScript/24-game-solve.js @@ -0,0 +1,104 @@ +var ar=[],order=[0,1,2],op=[],val=[]; +var NOVAL=9999,oper="+-*/",out; + +function rnd(n){return Math.floor(Math.random()*n)} + +function say(s){ + try{document.write(s+"
")} + catch(e){WScript.Echo(s)} +} + +function getvalue(x,dir){ + var r=NOVAL; + if(dir>0)++x; + while(1){ + if(val[x]!=NOVAL){ + r=val[x]; + val[x]=NOVAL; + break; + } + x+=dir; + } + return r*1; +} + +function calc(){ + var c=0,l,r,x; + val=ar.join('/').split('/'); + while(c<3){ + x=order[c]; + l=getvalue(x,-1); + r=getvalue(x,1); + switch(op[x]){ + case 0:val[x]=l+r;break; + case 1:val[x]=l-r;break; + case 2:val[x]=l*r;break; + case 3: + if(!r||l%r)return 0; + val[x]=l/r; + } + ++c; + } + return getvalue(-1,1); +} + +function shuffle(s,n){ + var x=n,p=eval(s),r,t; + while(x--){ + r=rnd(n); + t=p[x]; + p[x]=p[r]; + p[r]=t; + } +} + +function parenth(n){ + while(n>0)--n,out+='('; + while(n<0)++n,out+=')'; +} + +function getpriority(x){ + for(var z=3;z--;)if(order[z]==x)return 3-z; + return 0; +} + +function showsolution(){ + var x=0,p=0,lp=0,v=0; + while(x<4){ + if(x<3){ + lp=p; + p=getpriority(x); + v=p-lp; + if(v>0)parenth(v); + } + out+=ar[x]; + if(x<3){ + if(v<0)parenth(v); + out+=oper.charAt(op[x]); + } + ++x; + } + parenth(-p); + say(out); +} + +function solve24(s){ + var z=4,r; + while(z--)ar[z]=s.charCodeAt(z)-48; + out=""; + for(z=100000;z--;){ + r=rnd(256); + op[0]=r&3; + op[1]=(r>>2)&3; + op[2]=(r>>4)&3; + shuffle("ar",4); + shuffle("order",3); + if(calc()!=24)continue; + showsolution(); + break; + } +} + +solve24("1234"); +solve24("6789"); +solve24("1127"); diff --git a/Task/24-game-Solve/Liberty-BASIC/24-game-solve.liberty b/Task/24-game-Solve/Liberty-BASIC/24-game-solve.liberty new file mode 100644 index 0000000000..92cdb5fbfc --- /dev/null +++ b/Task/24-game-Solve/Liberty-BASIC/24-game-solve.liberty @@ -0,0 +1,123 @@ +dim d(4) +input "Enter 4 digits: "; a$ +nD=0 +for i =1 to len(a$) + c$=mid$(a$,i,1) + if instr("123456789",c$) then + nD=nD+1 + d(nD)=val(c$) + end if +next +'for i = 1 to 4 +' print d(i); +'next + +'precompute permutations. Dumb way. +nPerm = 1*2*3*4 +dim perm(nPerm, 4) +n = 0 +for i = 1 to 4 + for j = 1 to 4 + for k = 1 to 4 + for l = 1 to 4 + 'valid permutation (no dupes?) + if i<>j and i<>k and i<>l _ + and j<>k and j<>l _ + and k<>l then + n=n+1 + ' +' perm(n,1)=i +' perm(n,2)=j +' perm(n,3)=k +' perm(n,4)=l + 'actually, we can as well permute given digits + perm(n,1)=d(i) + perm(n,2)=d(j) + perm(n,3)=d(k) + perm(n,4)=d(l) + end if + next + next + next +next +'check if permutations look OK. They are +'for i =1 to n +' print i, +' for j =1 to 4: print perm(i,j);:next +' print +'next + +'possible brackets +NBrackets = 11 +dim Brakets$(NBrackets) +DATA "4#4#4#4" +DATA "(4#4)#4#4" +DATA "4#(4#4)#4" +DATA "4#4#(4#4)" +DATA "(4#4)#(4#4)" +DATA "(4#4#4)#4" +DATA "4#(4#4#4)" +DATA "((4#4)#4)#4" +DATA "(4#(4#4))#4" +DATA "4#((4#4)#4)" +DATA "4#(4#(4#4))" +for i = 1 to NBrackets + read Tmpl$: Brakets$(i) = Tmpl$ +next + +'operations: full search +count = 0 +Ops$="+ - * /" +dim Op$(3) +For op1=1 to 4 + Op$(1)=word$(Ops$,op1) + For op2=1 to 4 + Op$(2)=word$(Ops$,op2) + For op3=1 to 4 + Op$(3)=word$(Ops$,op3) + 'print "*" + 'substitute all brackets + for t = 1 to NBrackets + Tmpl$=Brakets$(t) + 'print , Tmpl$ + 'now, substitute all digits: permutations. + for p = 1 to nPerm + res$= "" + nOp=0 + nD=0 + for i = 1 to len(Tmpl$) + c$ = mid$(Tmpl$, i, 1) + select case c$ + case "#" 'operations + nOp = nOp+1 + res$ = res$+Op$(nOp) + case "4" 'digits + nD = nOp+1 + res$ = res$; perm(p,nD) + case else 'brackets goes here + res$ = res$+ c$ + end select + next + 'print,, res$ + 'eval here + if evalWithErrCheck(res$) = 24 then + print "24 = ";res$ + end 'comment it out if you want to see all versions + end if + count = count + 1 + next + next + Next + Next +next + +print "If you see this, probably task cannot be solved with these digits" +'print count +end + +function evalWithErrCheck(expr$) + on error goto [handler] + evalWithErrCheck=eval(expr$) + exit function +[handler] +end function diff --git a/Task/24-game-Solve/Lua/24-game-solve.lua b/Task/24-game-Solve/Lua/24-game-solve.lua new file mode 100644 index 0000000000..589f9a2bd2 --- /dev/null +++ b/Task/24-game-Solve/Lua/24-game-solve.lua @@ -0,0 +1,74 @@ +local SIZE = #arg[1] +local GOAL = tonumber(arg[2]) or 24 + +local input = {} +for v in arg[1]:gmatch("%d") do + table.insert(input, v) +end +assert(#input == SIZE, 'Invalid input') + +local operations = {'+', '-', '*', '/'} + +local function BinaryTrees(vert) + if vert == 0 then + return {false} + else + local buf = {} + for leften = 0, vert - 1 do + local righten = vert - leften - 1 + for _, left in pairs(BinaryTrees(leften)) do + for _, right in pairs(BinaryTrees(righten)) do + table.insert(buf, {left, right}) + end + end + end + return buf + end +end +local trees = BinaryTrees(SIZE-1) +local c, opc, oper, str +local max = math.pow(#operations, SIZE-1) +local function op(a,b) + opc = opc + 1 + local i = math.floor(oper/math.pow(#operations, opc-1))%#operations+1 + return '('.. a .. operations[i] .. b ..')' +end + +local function EvalTree(tree) + if tree == false then + c = c + 1 + return input[c-1] + else + return op(EvalTree(tree[1]), EvalTree(tree[2])) + end +end + +local function printResult() + for _, v in ipairs(trees) do + for i = 0, max do + c, opc, oper = 1, 0, i + str = EvalTree(v) + loadstring('res='..str)() + if(res == GOAL) then print(str, '=', res) end + end + end +end + +local uniq = {} +local function permgen (a, n) + if n == 0 then + local str = table.concat(a) + if not uniq[str] then + printResult() + uniq[str] = true + end + else + for i = 1, n do + a[n], a[i] = a[i], a[n] + permgen(a, n - 1) + a[n], a[i] = a[i], a[n] + end + end +end + +permgen(input, SIZE) diff --git a/Task/24-game-Solve/Mathematica/24-game-solve-1.mathematica b/Task/24-game-Solve/Mathematica/24-game-solve-1.mathematica new file mode 100644 index 0000000000..fdab5165cd --- /dev/null +++ b/Task/24-game-Solve/Mathematica/24-game-solve-1.mathematica @@ -0,0 +1,16 @@ +treeR[n_] := Table[o[trees[a], trees[n - a]], {a, 1, n - 1}] +treeR[1] := n +tree[n_] := + Flatten[treeR[n] //. {o[a_List, b_] :> (o[#, b] & /@ a), + o[a_, b_List] :> (o[a, #] & /@ b)}] +game24play[val_List] := + Union[StringReplace[StringTake[ToString[#, InputForm], {10, -2}], + "-1*" ~~ n_ :> "-" <> n] & /@ (HoldForm /@ + Select[Union@ + Flatten[Outer[# /. {o[q_Integer] :> #2[[q]], + n[q_] :> #3[[q]]} &, + Block[{O = 1, N = 1}, # /. {o :> o[O++], n :> n[N++]}] & /@ + tree[4], Tuples[{Plus, Subtract, Times, Divide}, 3], + Permutations[Array[v, 4]], 1]], + Quiet[(# /. v[q_] :> val[[q]]) == 24] &] /. + Table[v[q] -> val[[q]], {q, 4}])] diff --git a/Task/24-game-Solve/Mathematica/24-game-solve-2.mathematica b/Task/24-game-Solve/Mathematica/24-game-solve-2.mathematica new file mode 100644 index 0000000000..2a1593abac --- /dev/null +++ b/Task/24-game-Solve/Mathematica/24-game-solve-2.mathematica @@ -0,0 +1 @@ +game24play[RandomInteger[{1, 9}, 4]] diff --git a/Task/24-game-Solve/Perl/24-game-solve.pl b/Task/24-game-Solve/Perl/24-game-solve.pl new file mode 100644 index 0000000000..1ec0df4aa4 --- /dev/null +++ b/Task/24-game-Solve/Perl/24-game-solve.pl @@ -0,0 +1,54 @@ +# Fischer-Krause ordered permutation generator +# http://faq.perl.org/perlfaq4.html#How_do_I_permute_N_e +sub permute (&@) { + my $code = shift; + my @idx = 0..$#_; + while ( $code->(@_[@idx]) ) { + my $p = $#idx; + --$p while $idx[$p-1] > $idx[$p]; + my $q = $p or return; + push @idx, reverse splice @idx, $p; + ++$q while $idx[$p-1] > $idx[$q]; + @idx[$p-1,$q]=@idx[$q,$p-1]; + } + } + +@formats = ( + '((%d %s %d) %s %d) %s %d', + '(%d %s (%d %s %d)) %s %d', + '(%d %s %d) %s (%d %s %d)', + '%d %s ((%d %s %d) %s %d)', + '%d %s (%d %s (%d %s %d))', + ); + +# generate all possible combinations of operators +@op = qw( + - * / ); +@operators = map{ $a=$_; map{ $b=$_; map{ "$a $b $_" }@op }@op }@op; + +while(1) +{ + print "Enter four integers or 'q' to exit: "; + chomp($ent = <>); + last if $ent eq 'q'; + + + if($ent !~ /^[1-9] [1-9] [1-9] [1-9]$/){ print "invalid input\n"; next } + + @n = split / /,$ent; + permute { push @numbers,join ' ',@_ }@n; + + for $format (@formats) + { + for(@numbers) + { + @n = split; + for(@operators) + { + @o = split; + $str = sprintf $format,$n[0],$o[0],$n[1],$o[1],$n[2],$o[2],$n[3]; + $r = eval($str); + print "$str\n" if $r == 24; + } + } + } +} diff --git a/Task/24-game-Solve/PicoLisp/24-game-solve.l b/Task/24-game-Solve/PicoLisp/24-game-solve.l new file mode 100644 index 0000000000..dee3526918 --- /dev/null +++ b/Task/24-game-Solve/PicoLisp/24-game-solve.l @@ -0,0 +1,18 @@ +(be play24 (@Lst @Expr) # Define Pilog rule + (permute @Lst (@A @B @C @D)) + (member @Op1 (+ - * /)) + (member @Op2 (+ - * /)) + (member @Op3 (+ - * /)) + (or + ((equal @Expr (@Op1 (@Op2 @A @B) (@Op3 @C @D)))) + ((equal @Expr (@Op1 @A (@Op2 @B (@Op3 @C @D))))) ) + (@ = 24 (catch '("Div/0") (eval (-> @Expr)))) ) + +(de play24 (A B C D) # Define PicoLisp function + (pilog + (quote + @L (list A B C D) + (play24 @L @X) ) + (println @X) ) ) + +(play24 5 6 7 8) # Call 'play24' function diff --git a/Task/24-game-Solve/Prolog/24-game-solve.pro b/Task/24-game-Solve/Prolog/24-game-solve.pro new file mode 100644 index 0000000000..075af285ed --- /dev/null +++ b/Task/24-game-Solve/Prolog/24-game-solve.pro @@ -0,0 +1,91 @@ +play24(Len, Range, Goal) :- + game(Len, Range, Goal, L, S), + maplist(my_write, L), + format(': ~w~n', [S]). + +game(Len, Range, Value, L, S) :- + length(L, Len), + maplist(choose(Range), L), + compute(L, Value, [], S). + + +choose(Range, V) :- + V is random(Range) + 1. + + +write_tree([M], [M]). + +write_tree([+, M, N], S) :- + write_tree(M, MS), + write_tree(N, NS), + append(MS, [+ | NS], S). + +write_tree([-, M, N], S) :- + write_tree(M, MS), + write_tree(N, NS), + ( is_add(N) -> append(MS, [-, '(' | NS], Temp), append(Temp, ')', S) + ; append(MS, [- | NS], S)). + + +write_tree([Op, M, N], S) :- + member(Op, [*, /]), + write_tree(M, MS), + write_tree(N, NS), + ( is_add(M) -> append(['(' | MS], [')'], TempM) + ; TempM = MS), + ( is_add(N) -> append(['(' | NS], [')'], TempN) + ; TempN = NS), + append(TempM, [Op | TempN], S). + +is_add([Op, _, _]) :- + member(Op, [+, -]). + +compute([Value], Value, [[_R-S1]], S) :- + write_tree(S1, S2), + with_output_to(atom(S), maplist(write, S2)). + +compute(L, Value, CS, S) :- + select(M, L, L1), + select(N, L1, L2), + next_value(M, N, R, CS, Expr), + compute([R|L2], Value, Expr, S). + +next_value(M, N, R, CS,[[R - [+, M1, N1]] | CS2]) :- + R is M+N, + ( member([M-ExprM], CS) -> select([M-ExprM], CS, CS1), M1 = ExprM + ; M1 = [M], CS1 = CS + ), + ( member([N-ExprN], CS1) -> select([N-ExprN], CS1, CS2), N1 = ExprN + ; N1 = [N], CS2 = CS1 + ). + +next_value(M, N, R, CS,[[R - [-, M1, N1]] | CS2]) :- + R is M-N, + ( member([M-ExprM], CS) -> select([M-ExprM], CS, CS1), M1 = ExprM + ; M1 = [M], CS1 = CS + ), + ( member([N-ExprN], CS1) -> select([N-ExprN], CS1, CS2), N1 = ExprN + ; N1 = [N], CS2 = CS1 + ). + +next_value(M, N, R, CS,[[R - [*, M1, N1]] | CS2]) :- + R is M*N, + ( member([M-ExprM], CS) -> select([M-ExprM], CS, CS1), M1 = ExprM + ; M1 = [M], CS1 = CS + ), + ( member([N-ExprN], CS1) -> select([N-ExprN], CS1, CS2), N1 = ExprN + ; N1 = [N], CS2 = CS1 + ). + +next_value(M, N, R, CS,[[R - [/, M1, N1]] | CS2]) :- + N \= 0, + R is rdiv(M,N), + ( member([M-ExprM], CS) -> select([M-ExprM], CS, CS1), M1 = ExprM + ; M1 = [M], CS1 = CS + ), + ( member([N-ExprN], CS1) -> select([N-ExprN], CS1, CS2), N1 = ExprN + ; N1 = [N], CS2 = CS1 + ). + +my_write(V) :- + format('~w ', [V]). diff --git a/Task/24-game-Solve/Python/24-game-solve.py b/Task/24-game-Solve/Python/24-game-solve.py new file mode 100644 index 0000000000..6731c6cc39 --- /dev/null +++ b/Task/24-game-Solve/Python/24-game-solve.py @@ -0,0 +1,159 @@ +''' + The 24 Game Player + + Given any four digits in the range 1 to 9, which may have repetitions, + Using just the +, -, *, and / operators; and the possible use of + brackets, (), show how to make an answer of 24. + + An answer of "q" will quit the game. + An answer of "!" will generate a new set of four digits. + An answer of "!!" will ask you for a new set of four digits. + An answer of "?" will compute an expression for the current digits. + + Otherwise you are repeatedly asked for an expression until it evaluates to 24 + + Note: you cannot form multiple digit numbers from the supplied digits, + so an answer of 12+12 when given 1, 2, 2, and 1 would not be allowed. + +''' + +from __future__ import division, print_function +from itertools import permutations, combinations, product, \ + chain +from pprint import pprint as pp +from fractions import Fraction as F +import random, ast, re +import sys + +if sys.version_info[0] < 3: + input = raw_input + from itertools import izip_longest as zip_longest +else: + from itertools import zip_longest + + +def choose4(): + 'four random digits >0 as characters' + return [str(random.randint(1,9)) for i in range(4)] + +def ask4(): + 'get four random digits >0 from the player' + digits = '' + while len(digits) != 4 or not all(d in '123456789' for d in digits): + digits = input('Enter the digits to solve for: ') + digits = ''.join(digits.strip().split()) + return list(digits) + +def welcome(digits): + print (__doc__) + print ("Your four digits: " + ' '.join(digits)) + +def check(answer, digits): + allowed = set('() +-*/\t'+''.join(digits)) + ok = all(ch in allowed for ch in answer) and \ + all(digits.count(dig) == answer.count(dig) for dig in set(digits)) \ + and not re.search('\d\d', answer) + if ok: + try: + ast.parse(answer) + except: + ok = False + return ok + +def solve(digits): + """\ + >>> for digits in '3246 4788 1111 123456 1127 3838'.split(): + solve(list(digits)) + + + Solution found: 2 + 3 * 6 + 4 + '2 + 3 * 6 + 4' + Solution found: ( 4 + 7 - 8 ) * 8 + '( 4 + 7 - 8 ) * 8' + No solution found for: 1 1 1 1 + '!' + Solution found: 1 + 2 + 3 * ( 4 + 5 ) - 6 + '1 + 2 + 3 * ( 4 + 5 ) - 6' + Solution found: ( 1 + 2 ) * ( 1 + 7 ) + '( 1 + 2 ) * ( 1 + 7 )' + Solution found: 8 / ( 3 - 8 / 3 ) + '8 / ( 3 - 8 / 3 )' + >>> """ + digilen = len(digits) + # length of an exp without brackets + exprlen = 2 * digilen - 1 + # permute all the digits + digiperm = sorted(set(permutations(digits))) + # All the possible operator combinations + opcomb = list(product('+-*/', repeat=digilen-1)) + # All the bracket insertion points: + brackets = ( [()] + [(x,y) + for x in range(0, exprlen, 2) + for y in range(x+4, exprlen+2, 2) + if (x,y) != (0,exprlen+1)] + + [(0, 3+1, 4+2, 7+3)] ) # double brackets case + for d in digiperm: + for ops in opcomb: + if '/' in ops: + d2 = [('F(%s)' % i) for i in d] # Use Fractions for accuracy + else: + d2 = d + ex = list(chain.from_iterable(zip_longest(d2, ops, fillvalue=''))) + for b in brackets: + exp = ex[::] + for insertpoint, bracket in zip(b, '()'*(len(b)//2)): + exp.insert(insertpoint, bracket) + txt = ''.join(exp) + try: + num = eval(txt) + except ZeroDivisionError: + continue + if num == 24: + if '/' in ops: + exp = [ (term if not term.startswith('F(') else term[2]) + for term in exp ] + ans = ' '.join(exp).rstrip() + print ("Solution found:",ans) + return ans + print ("No solution found for:", ' '.join(digits)) + return '!' + +def main(): + digits = choose4() + welcome(digits) + trial = 0 + answer = '' + chk = ans = False + while not (chk and ans == 24): + trial +=1 + answer = input("Expression %i: " % trial) + chk = check(answer, digits) + if answer == '?': + solve(digits) + answer = '!' + if answer.lower() == 'q': + break + if answer == '!': + digits = choose4() + trial = 0 + print ("\nNew digits:", ' '.join(digits)) + continue + if answer == '!!': + digits = ask4() + trial = 0 + print ("\nNew digits:", ' '.join(digits)) + continue + if not chk: + print ("The input '%s' was wonky!" % answer) + else: + if '/' in answer: + # Use Fractions for accuracy in divisions + answer = ''.join( (('F(%s)' % char) if char in '123456789' else char) + for char in answer ) + ans = eval(answer) + print (" = ", ans) + if ans == 24: + print ("Thats right!") + print ("Thank you and goodbye") + +main() diff --git a/Task/24-game-Solve/R/24-game-solve-1.r b/Task/24-game-Solve/R/24-game-solve-1.r new file mode 100644 index 0000000000..951518e77e --- /dev/null +++ b/Task/24-game-Solve/R/24-game-solve-1.r @@ -0,0 +1,34 @@ +library(gtools) + +solve24 <- function(vals=c(8, 4, 2, 1), + goal=24, + ops=c("+", "-", "*", "/")) { + + val.perms <- as.data.frame(t( + permutations(length(vals), length(vals)))) + + nop <- length(vals)-1 + op.perms <- as.data.frame(t( + do.call(expand.grid, + replicate(nop, list(ops))))) + + ord.perms <- as.data.frame(t( + do.call(expand.grid, + replicate(n <- nop, 1:((n <<- n-1)+1))))) + + for (val.perm in val.perms) + for (op.perm in op.perms) + for (ord.perm in ord.perms) + { + expr <- as.list(vals[val.perm]) + for (i in 1:nop) { + expr[[ ord.perm[i] ]] <- call(as.character(op.perm[i]), + expr[[ ord.perm[i] ]], + expr[[ ord.perm[i]+1 ]]) + expr <- expr[ -(ord.perm[i]+1) ] + } + if (identical(eval(expr[[1]]), goal)) return(expr[[1]]) + } + + return(NA) +} diff --git a/Task/24-game-Solve/R/24-game-solve-2.r b/Task/24-game-Solve/R/24-game-solve-2.r new file mode 100644 index 0000000000..5e3d4e96c8 --- /dev/null +++ b/Task/24-game-Solve/R/24-game-solve-2.r @@ -0,0 +1,12 @@ +> solve24() +8 * (4 - 2 + 1) +> solve24(c(6,7,9,5)) +6 + (7 - 5) * 9 +> solve24(c(8,8,8,8)) +[1] NA +> solve24(goal=49) #different goal value +8 * (4 + 2) + 1 +> solve24(goal=52) #no solution +[1] NA +> solve24(ops=c('-', '/')) #restricted set of operators +(8 - 2)/(1/4) diff --git a/Task/24-game-Solve/REXX/24-game-solve.rexx b/Task/24-game-Solve/REXX/24-game-solve.rexx new file mode 100644 index 0000000000..4c57515328 --- /dev/null +++ b/Task/24-game-Solve/REXX/24-game-solve.rexx @@ -0,0 +1,99 @@ +/*REXX program to help the user find solutions to the game of 24. */ +/* ┌──────────────────────────────────────────────────────────────────┐ + │ Argument is either of two forms: ssss ==or== ssss-ffff │ + │ │ + │ where one or both strings must be exactly four numerals (digits) │ + │ comprised soley of the numerals (digits) 1 ──> 9 (no zeroes). │ + │ │ + │ In SSSS-FFFF SSSS is the start, │ + │ FFFF is the start. │ + └──────────────────────────────────────────────────────────────────┘ */ +parse arg orig /*get the guess from the argument. */ +parse var orig start '-' finish /*get the start and finish (maybe). */ +start=space(start,0) /*remove any blanks from the START. */ +finish=space(finish,0) /*remove any blanks from the FINISH. */ +finish=word(finish start,1) /*if no FINISH specified, use START.*/ +digs=123456789 /*numerals (digits) that can be used. */ +call validate start +call validate finish +opers='+-*/' /*define the legal arithmetic operators*/ +ops=length(opers) /* ... and the count of them (length). */ + do j=1 for ops /*define a version for fast execution. */ + o.j=substr(opers,j,1) + end /*j*/ +finds=0 /*number of found solutions (so far). */ +x.=0 /*a method to hold unique expressions. */ +indent=left('',30) /*used to indent display of solutions. */ + /*alternative: indent=copies(' ',30) */ +Lpar='(' /*a string to make REXX code prettier. */ +Rpar=')' /*ditto. */ + + do g=start to finish /*process a (possible) range of values.*/ + if pos(0,g)\==0 then iterate /*ignore values with zero in them. */ + + do _=1 for 4 /*define versions for faster execution.*/ + g._=substr(g,_,1) + end /*_*/ + + do i=1 for ops /*insert an operator after 1st number. */ + do j=1 for ops /*insert an operator after 2nd number. */ + do k=1 for ops /*insert an operator after 2nd number. */ + do m=0 to 3; L.= /*assume no left parenthesis so far. */ + do n=m+1 to 4 /*match left paren with a right paren. */ + L.m=Lpar /*define a left paren, m=0 means ignore*/ + R.="" /*un-define all right parenthesis. */ + if m==1 & n==2 then L.="" /*special case: (n)+ ... */ + else if m\==0 then R.n=Rpar /*no (, no )*/ + e= L.1 g.1 o.i L.2 g.2 o.j L.3 g.3 R.3 o.k g.4 R.4 + e=space(e,0) /*remove all blanks from the expression*/ + + /*(below) change expression: */ + /* /(yyy) ===> /div(yyy) */ + /*Enables to check for division by zero*/ + origE=e /*keep old version for the display. */ + if pos('/(',e)\==0 then e=changestr('/(',e,"/div(") + /*The above could be replaced by: */ + /* e=changestr('/(',e,"/div(") */ + + /*INTERPRET stresses REXX's groin, so */ + /* try to avoid repeated heavy lifting.*/ + if x.e then iterate /*was the expression already used? */ + x.e=1 /*mark this expression as unique. */ + /*have REXX do the heavy lifting (ugh).*/ + interpret 'x=' e /*... strain... */ + x=x/1 /*remove trailing decimal points(maybe)*/ + if x\==24 then iterate /*Not correct? Try again. */ + finds=finds+1 /*bump number of found solutions. */ + _=translate(origE, '][', ")(") /*show [], not (). */ + say indent 'a solution:' _ /*display a solution. */ + end /*n*/ + end /*m*/ + end /*k*/ + end /*j*/ + end /*i*/ + end /*g*/ + +sols=finds +if sols==0 then sols='No' /*make the sentence not so geek-like. */ +say; say sols 'unique solution's(finds) "found for" orig /*pluralize.*/ +exit +/*───────────────────────────DIV subroutine─────────────────────────────*/ +div: procedure; parse arg q /*tests if dividing by 0 (zero). */ +if q=0 then q=1e9 /*if dividing by zero, change divisor. */ +return q /*changing Q invalidates the expression*/ +/*───────────────────────────GER subroutine─────────────────────────────*/ +ger: say; say '*** error! ***'; if _\=='' then say 'guess=' _ +say arg(1); say; exit 13 +/*───────────────────────────S subroutine───────────────────────────────*/ +s: if arg(1)==1 then return ''; return 's' /*simple pluralizer.*/ +/*───────────────────────────validate subroutine────────────────────────*/ +validate: parse arg y; errCode=0; _v=verify(y,digs) + select + when y=='' then call ger 'no digits entered.' + when length(y)<4 then call ger 'not enough digits entered, must be 4' + when length(y)>4 then call ger 'too many digits entered, must be 4' + when pos(0,y)\==0 then call ger "can't use the digit 0 (zero)" + when _v\==0 then call ger 'illegal character:' substr(y,_v,1) + otherwise nop + end /*select*/ +return \errCode diff --git a/Task/24-game-Solve/Ruby/24-game-solve.rb b/Task/24-game-Solve/Ruby/24-game-solve.rb new file mode 100644 index 0000000000..cc39bfa3c2 --- /dev/null +++ b/Task/24-game-Solve/Ruby/24-game-solve.rb @@ -0,0 +1,57 @@ +require 'rational' + +class TwentyFourGamePlayer + EXPRESSIONS = [ + '((%d %s %d) %s %d) %s %d', + '(%d %s (%d %s %d)) %s %d', + '(%d %s %d) %s (%d %s %d)', + '%d %s ((%d %s %d) %s %d)', + '%d %s (%d %s (%d %s %d))', + ] + OPERATORS = [:+, :-, :*, :/] + + @@objective = Rational(24,1) + + def initialize(digits) + @digits = digits + @solutions = [] + solve + end + + attr_reader :digits, :solutions + + def solve + digits.permutation.to_a.uniq.each do |a,b,c,d| + OPERATORS.each do |op1| + OPERATORS.each do |op2| + OPERATORS.each do |op3| + EXPRESSIONS.each do |expr| + # evaluate using rational arithmetic + test = expr.gsub('%d', 'Rational(%d,1)') % [a, op1, b, op2, c, op3, d] + value = eval(test) rescue -1 # catch division by zero + if value == @@objective + @solutions << expr % [a, op1, b, op2, c, op3, d] + end + end;end;end;end + end + end + +end + +# validate user input +digits = ARGV.map do |arg| + begin + Integer(arg) + rescue ArgumentError + raise "error: not an integer: '#{arg}'" + end +end +digits.size == 4 or raise "error: need 4 digits, only have #{digits.size}" + +player = TwentyFourGamePlayer.new(digits) +if player.solutions.empty? + puts "no solutions" +else + puts "found #{player.solutions.size} solutions, including #{player.solutions.first}" + puts player.solutions.sort.join("\n") +end diff --git a/Task/24-game-Solve/Scala/24-game-solve.scala b/Task/24-game-Solve/Scala/24-game-solve.scala new file mode 100644 index 0000000000..de81705d0b --- /dev/null +++ b/Task/24-game-Solve/Scala/24-game-solve.scala @@ -0,0 +1,25 @@ +def permute(l: List[Double]): List[List[Double]] = l match { + case Nil => List(Nil) + case x :: xs => + for { + ys <- permute(xs) + position <- 0 to ys.length + (left, right) = ys splitAt position + } yield left ::: (x :: right) +} + +def computeAllOperations(l: List[Double]): List[(Double,String)] = l match { + case Nil => Nil + case x :: Nil => List((x, "%1.0f" format x)) + case x :: xs => + for { + (y, ops) <- computeAllOperations(xs) + (z, op) <- + if (y == 0) + List((x*y, "*"), (x+y, "+"), (x-y, "-")) + else + List((x*y, "*"), (x/y, "/"), (x+y, "+"), (x-y, "-")) + } yield (z, "(%1.0f%s%s)" format (x,op,ops)) +} + +def hasSolution(l: List[Double]) = permute(l) flatMap computeAllOperations filter (_._1 == 24) map (_._2) diff --git a/Task/24-game-Solve/Tcl/24-game-solve.tcl b/Task/24-game-Solve/Tcl/24-game-solve.tcl new file mode 100644 index 0000000000..0099b6a4c3 --- /dev/null +++ b/Task/24-game-Solve/Tcl/24-game-solve.tcl @@ -0,0 +1,62 @@ +package require struct::list +# Encoding the various expression trees that are possible +set patterns { + {((A x B) y C) z D} + {(A x (B y C)) z D} + {(A x B) y (C z D)} + {A x ((B y C) z D)} + {A x (B y (C z D))} +} +# Encoding the various permutations of digits +set permutations [struct::list map [struct::list permutations {a b c d}] \ + {apply {v {lassign $v a b c d; list A $a B $b C $c D $d}}}] +# The permitted operations +set operations {+ - * /} + +# Given a list of four integers (precondition not checked!) return a list of +# solutions to the 24 game using those four integers. +proc find24GameSolutions {values} { + global operations patterns permutations + set found {} + # For each possible structure with numbers at the leaves... + foreach pattern $patterns { + foreach permutation $permutations { + set p [string map [subst { + a [lindex $values 0].0 + b [lindex $values 1].0 + c [lindex $values 2].0 + d [lindex $values 3].0 + }] [string map $permutation $pattern]] + + # For each possible structure with operators at the branches... + foreach x $operations { + foreach y $operations { + foreach z $operations { + set e [string map [subst {x $x y $y z $z}] $p] + + # Try to evaluate (div-zero is an issue!) and add it to + # the result if it is 24 + catch { + if {[expr $e] == 24.0} { + lappend found [string map {.0 {}} $e] + } + } + } + } + } + } + } + return $found +} + +# Wrap the solution finder into a player +proc print24GameSolutionFor {values} { + set found [lsort -unique [find24GameSolutions $values]] + if {![llength $found]} { + puts "No solution possible" + } else { + puts "Total [llength $found] solutions (may include logical duplicates)" + puts "First solution: [lindex $found 0]" + } +} +print24GameSolutionFor $argv diff --git a/Task/24-game/Falcon/24-game.falcon b/Task/24-game/Falcon/24-game.falcon new file mode 100644 index 0000000000..3470b55279 --- /dev/null +++ b/Task/24-game/Falcon/24-game.falcon @@ -0,0 +1,71 @@ +load compiler + +function genRandomNumbers( amount ) + rtn = [] + for i in [ 0 : amount ]: rtn += random( 1, 9 ) + return( rtn ) +end + +function getAnswer( exp ) + ic = ICompiler() + ic.compileAll(exp) + + return( ic.result ) +end + +function validInput( str ) + for i in [ 0 : str.len() ] + if str[i] notin ' ()[]0123456789-+/*' + > 'INVALID Character = ', str[i] + return( false ) + end + end + + return( true ) +end + +printl(' +The 24 Game + +Given any four digits in the range 1 to 9, which may have repetitions, +Using just the +, -, *, and / operators; and the possible use of +brackets, (), show how to make an answer of 24. + +An answer of "q" will quit the game. +An answer of "!" will generate a new set of four digits. +Otherwise you are repeatedly asked for an expression until it evaluates to 24 + +Note: you cannot form multiple digit numbers from the supplied digits, +so an answer of 12+12 when given 1, 2, 2, and 1 would not be allowed. +') + +num = genRandomNumbers( 4 ) + +while( true ) + + >> "Here are the numbers to choose from: " + map({ a => print(a, " ") }, num) + > + + exp = input() + + switch exp + case "q", "Q" + exit() + + case "!" + > 'Generating new numbers list' + num = genRandomNumbers( 4 ) + + default + if not validInput( exp ): continue + + answer = getAnswer( exp ) + + if answer == 24 + > "By George you GOT IT! Your expression equals 24" + else + > "Ahh Sorry, So Sorry your answer of ", answer, " does not equal 24." + end + end +end diff --git a/Task/24-game/GAP/24-game.gap b/Task/24-game/GAP/24-game.gap new file mode 100644 index 0000000000..d2941990cf --- /dev/null +++ b/Task/24-game/GAP/24-game.gap @@ -0,0 +1,92 @@ +# Solution in '''RPN''' +Play24 := function() + local input, digits, line, c, chars, stack, stackptr, cur, p, q, ok, a, b, run; + input := InputTextUser(); + run := true; + while run do + digits := List([1 .. 4], n -> Random(1, 9)); + while true do + Display(digits); + line := ReadLine(input); + line := Chomp(line); + if line = "end" then + run := false; + break; + elif line = "next" then + break; + else + ok := true; + stack := [ ]; + stackptr := 0; + chars := "123456789+-*/ "; + cur := ShallowCopy(digits); + for c in line do + if c = ' ' then + continue; + fi; + p := Position(chars, c); + if p = fail then + ok := false; + break; + fi; + if p < 10 then + q := Position(cur, p); + if q = fail then + ok := false; + break; + fi; + Unbind(cur[q]); + stackptr := stackptr + 1; + stack[stackptr] := p; + else + if stackptr < 2 then + ok := false; + break; + fi; + b := stack[stackptr]; + a := stack[stackptr - 1]; + stackptr := stackptr - 1; + if c = '+' then + a := a + b; + elif c = '-' then + a := a - b; + elif c = '*' then + a := a * b; + elif c = '/' then + if b = 0 then + ok := false; + break; + fi; + a := a / b; + else + ok := false; + break; + fi; + stack[stackptr] := a; + fi; + od; + if ok and stackptr = 1 and Size(cur) = 0 then + if stack[1] = 24 then + Print("Good !\n"); + break; + else + Print("Bad value: ", stack[1], "\n"); + continue; + fi; + fi; + Print("Invalid expression\n"); + fi; + od; + od; + CloseStream(input); +end; + +# example session +# type "end" to quit the game, "next" to try another list of digits +gap> Play24(); +[ 7, 6, 8, 5 ] +86*75-/ +Good ! +[ 5, 9, 2, 7 ] +end +gap> diff --git a/Task/24-game/Gosu/24-game.gosu b/Task/24-game/Gosu/24-game.gosu new file mode 100644 index 0000000000..dd63e3de6b --- /dev/null +++ b/Task/24-game/Gosu/24-game.gosu @@ -0,0 +1,105 @@ +uses java.lang.Double +uses java.lang.Integer +uses java.util.ArrayList +uses java.util.List +uses java.util.Scanner +uses java.util.Stack + +function doEval( scanner : Scanner, allowed : List ) : double { + var stk = new Stack() + + while( scanner.hasNext() ) { + if( scanner.hasNextInt() ) { + var n = scanner.nextInt() + + // Make sure they're allowed to use n + if( n <= 0 || n >= 10 ) { + print( n + " isn't allowed" ) + return 0 + } + var idx = allowed.indexOf( n ) + if( idx == -1 ) { + print( "You aren't allowed to use so many " + n + "s!" ) + return 0 + } + + // Add the input number to the stack + stk.push( new Double( n ) ) + + // Mark n as used + allowed.remove( idx ) + } else { + // It has to be an operator... + if( stk.size() < 2 ) { + print( "Invalid Expression: Stack underflow!" ) + return 0 + } + + // Gets the next operator as a single character token + var s = scanner.next("[\\+-/\\*]") + + // Get the operands + var r = stk.pop().doubleValue() + var l = stk.pop().doubleValue() + + // Determine which operator and invoke it + if( s.equals( "+" ) ) { + stk.push( new Double( l + r ) ) + } else if( s.equals( "-" ) ) { + stk.push( new Double( l - r ) ) + } else if( s.equals( "*" ) ) { + stk.push( new Double( l * r ) ) + } else if( s.equals( "/" ) ) { + if( r == 0.0 ) { + print( "Invalid Expression: Division by zero!" ) + return 0 + } + stk.push( new Double( l / r ) ) + } else { + print( "Internal Error: looking for operator yielded '" + s + "'" ) + return 0 + } + } + } + + // Did they skip any numbers? + if( allowed.size() != 0 ) { + print( "You didn't use ${allowed}" ) + return 0 + } + + // Did they use enough operators? + if( stk.size() != 1 ) { + print( "Invalid Expression: Not enough operators!" ) + return 0 + } + + return stk.pop().doubleValue() +} + +// Pick 4 random numbers from [1..9] +var nums = new ArrayList() +var gen = new java.util.Random( new java.util.Date().getTime() ) +for( i in 0..3 ) { + nums.add( gen.nextInt(9) + 1 ) +} + +// Prompt the user +print( "Using addition, subtraction, multiplication and division, write an" ) +print( "expression that evaluates to 24 using" ) +print( "${nums.get(0)}, ${nums.get(1)}, ${nums.get(2)} and ${nums.get(3)}" ) +print( "" ) +print( "Please enter your expression in RPN" ) + +// Build a tokenizer over a line of input +var sc = new Scanner( new java.io.BufferedReader( new java.io.InputStreamReader( java.lang.System.in ) ).readLine() ) + +// eval the expression +var val = doEval( sc, nums ) + +// winner? +if( java.lang.Math.abs( val - 24.0 ) < 0.001 ) { + print( "You win!" ) +} else { + print( "You lose!" ) +} diff --git a/Task/24-game/Groovy/24-game.groovy b/Task/24-game/Groovy/24-game.groovy new file mode 100644 index 0000000000..5a6460abcf --- /dev/null +++ b/Task/24-game/Groovy/24-game.groovy @@ -0,0 +1,67 @@ +final random = new Random() +final input = new Scanner(System.in) + + +def evaluate = { expr -> + if (expr == 'QUIT') { + return 'QUIT' + } else { + try { Eval.me(expr.replaceAll(/(\d)/, '$1.0')) } + catch (e) { 'syntax error' } + } +} + + +def readGuess = { digits -> + while (true) { + print "Enter your guess using ${digits} (q to quit): " + def expr = input.nextLine() + + switch (expr) { + case ~/^[qQ].*/: + return 'QUIT' + + case ~/.*[^\d\s\+\*\/\(\)-].*/: + def badChars = expr.replaceAll(~/[\d\s\+\*\/\(\)-]/, '') + println "invalid characters in input: ${(badChars as List) as Set}" + break + + case { (it.replaceAll(~/\D/, '') as List).sort() != ([]+digits).sort() }: + println '''you didn't use the right digits''' + break + + case ~/.*\d\d.*/: + println 'no multi-digit numbers allowed' + break + + default: + return expr + } + } +} + + +def digits = (1..4).collect { (random.nextInt(9) + 1) as String } + +while (true) { + def guess = readGuess(digits) + def result = evaluate(guess) + + switch (result) { + case 'QUIT': + println 'Awwww. Maybe next time?' + return + + case 24: + println 'Yes! You got it.' + return + + case 'syntax error': + println "A ${result} was found in ${guess}" + break + + default: + println "Nope: ${guess} == ${result}, not 24" + println 'One more try, then?' + } +} diff --git a/Task/24-game/HicEst/24-game-1.hicest b/Task/24-game/HicEst/24-game-1.hicest new file mode 100644 index 0000000000..a73f5781a4 --- /dev/null +++ b/Task/24-game/HicEst/24-game-1.hicest @@ -0,0 +1,35 @@ +DIMENSION digits(4), input_digits(100), difference(4) +CHARACTER expression*100, prompt*100, answers='Wrong,Correct,', protocol='24 game.txt' + +1 digits = CEILING( RAN(9) ) +2 DLG(Edit=expression, Text=digits, TItle=prompt) + + READ(Text=expression, ItemS=n) input_digits + IF(n == 4) THEN + ALIAS(input_digits,1, input,4) + SORT(Vector=digits, Sorted=digits) + SORT(Vector=input, Sorted=input) + difference = ABS(digits - input) + IF( SUM(difference) == 0 ) THEN + EDIT(Text=expression, ScaNnot='123456789+-*/ ()', GetPos=i, CoPyto=prompt) + IF( i > 0 ) THEN + prompt = TRIM(expression) // ': ' //TRIM(prompt) // ' is an illegal character' + ELSE + prompt = TRIM(expression) // ': Syntax error' + result = XEQ(expression, *2) ! on error branch to label 2 + EDIT(Text=answers, ITeM=(result==24)+1, Parse=answer) + WRITE(Text=prompt, Name) TRIM(expression)//': ', answer, result + ENDIF + ELSE + WRITE(Text=prompt) TRIM(expression), ': You used ', input, ' instead ', digits + ENDIF + ELSE + prompt = TRIM(expression) // ': Instead 4 digits you used ' // n + ENDIF + + OPEN(FIle=protocol, APPend) + WRITE(FIle=protocol, CLoSe=1) prompt + + DLG(TItle=prompt, Button='>2:Try again', B='>1:New game', B='Quit') + +END diff --git a/Task/24-game/HicEst/24-game-2.hicest b/Task/24-game/HicEst/24-game-2.hicest new file mode 100644 index 0000000000..7792fce5a6 --- /dev/null +++ b/Task/24-game/HicEst/24-game-2.hicest @@ -0,0 +1,6 @@ +4 + 8 + 7 + 5: You used 4 5 7 8 instead 4 4 7 8 +4 + 8 + 7 + a: Instead 4 digits you used 3 +4 + 8 + 7 + a + 4: a is an illegal character +4 + 8 + 7a + 4: a is an illegal character +4 + 8 + 7 + 4:; answer=Wrong; result=23; +4 * 7 - 8 + 4:; answer=Correct; result=24; diff --git a/Task/24-game/Icon/24-game.icon b/Task/24-game/Icon/24-game.icon new file mode 100644 index 0000000000..1aa0e0192d --- /dev/null +++ b/Task/24-game/Icon/24-game.icon @@ -0,0 +1,58 @@ +invocable all +link strings # for csort, deletec + +procedure main() +help() +repeat { + every (n := "") ||:= (1 to 4, string(1+?8)) + writes("Your four digits are : ") + every writes(!n," ") + write() + + e := trim(read()) | fail + case e of { + "q"|"quit": return + "?"|"help": help() + default: { + e := deletec(e,' \t') # no whitespace + d := deletec(e,~&digits) # just digits + if csort(n) ~== csort(d) then # and only the 4 given digits + write("Invalid repsonse.") & next + + if e ? (ans := eval(E()), pos(0)) then # parse and evaluate + if ans = 24 then write("Congratulations you win!") + else write("Your answer was ",ans,". Try again.") + else write("Invalid expression.") + } + } + } +end + +procedure eval(X) #: return the evaluated AST + if type(X) == "list" then { + x := eval(get(X)) + while x := get(X)(real(x), real(eval(get(X) | stop("Malformed expression.")))) + } + return \x | X +end + +procedure E() #: expression + put(lex := [],T()) + while put(lex,tab(any('+-*/'))) do + put(lex,T()) + suspend if *lex = 1 then lex[1] else lex # strip useless [] +end + +procedure T() #: Term + suspend 2(="(", E(), =")") | # parenthesized subexpression, or ... + tab(any(&digits)) # just a value +end + +procedure help() +return write( + "Welcome to 24\n\n", + "Combine the 4 given digits to make 24 using only + - * / and ( ).\n ", + "All operations have equal precedence and are evaluated left to right.\n", + "Combining (concatenating) digits is not allowed.\n", + "Enter 'help', 'quit', or an expression.\n") +end diff --git a/Task/24-game/J/24-game.j b/Task/24-game/J/24-game.j new file mode 100644 index 0000000000..73034a24eb --- /dev/null +++ b/Task/24-game/J/24-game.j @@ -0,0 +1,11 @@ +require'misc' +deal=: 1 + ? bind 9 9 9 9 +rules=: smoutput bind 'see http://en.wikipedia.org/wiki/24_Game' +input=: prompt @ ('enter 24 expression using ', ":, ': '"_) + +wellformed=: (' '<;._1@, ":@[) -:&(/:~) '(+-*%)' -.&;:~ ] +is24=: 24 -: ". ::0:@] + +respond=: (;:'no yes') {::~ wellformed * is24 + +game24=: (respond input)@deal@rules diff --git a/Task/24-game/Liberty-BASIC/24-game.liberty b/Task/24-game/Liberty-BASIC/24-game.liberty new file mode 100644 index 0000000000..4001cbf70f --- /dev/null +++ b/Task/24-game/Liberty-BASIC/24-game.liberty @@ -0,0 +1,87 @@ +dim d(4) +dim chk(4) +print "The 24 Game" +print +print "Given four digits and using just the +, -, *, and / operators; and the" +print "possible use of brackets, (), enter an expression that equates to 24." + +do + d$="" + for i = 1 to 4 + d(i)=int(rnd(1)*9)+1 '1..9 + chk(i)=d(i) + d$=d$;d(i) 'valid digits, to check with Instr + next + + print + print "These are your four digits: "; + for i = 1 to 4 + print d(i);left$(",",i<>4); + next + print + + Print "Enter expression:" + Input "24 = ";expr$ + 'check expr$ for validity + + 'check right digits used + failed = 0 + for i = 1 to len(expr$) + c$=mid$(expr$,i,1) + if instr("123456789", c$)<>0 then 'digit + if instr(d$, c$)=0 then failed = 1: exit for + if i>1 and instr("123456789", mid$(expr$,i-1,1))<>0 then failed = 2: exit for + for j =1 to 4 + if chk(j)=val(c$) then chk(j)=0: exit for + next + end if + next + if failed=1 then + print "Wrong digit (";c$;")" + goto [fail] + end if + + if failed=2 then + print "Multiple digit numbers is disallowed." + goto [fail] + end if + + 'check all digits used + if chk(1)+ chk(2)+ chk(3)+ chk(4)<>0 then + print "Not all digits used" + goto [fail] + end if + + 'check valid operations + failed = 0 + for i = 1 to len(expr$) + c$=mid$(expr$,i,1) + if instr("+-*/()"+d$, c$)=0 then failed = 1: exit for + next + if failed then + print "Wrong operation (";c$;")" + goto [fail] + end if + 'some errors (like brackets) trapped by error handler + Err$="" + res=evalWithErrCheck(expr$) + if Err$<>"" then + print "Error in expression" + goto [fail] + end if + if res = 24 then + print "Correct!" + else + print "Wrong! (you got ";res ;")" + end if +[fail] + Input "Play again (y/n)? "; ans$ +loop while ans$="y" +end + +function evalWithErrCheck(expr$) + on error goto [handler] + evalWithErrCheck=eval(expr$) + exit function +[handler] +end function diff --git a/Task/24-game/Locomotive-Basic/24-game.bas b/Task/24-game/Locomotive-Basic/24-game.bas new file mode 100644 index 0000000000..a8aef97023 --- /dev/null +++ b/Task/24-game/Locomotive-Basic/24-game.bas @@ -0,0 +1,54 @@ +10 CLS:RANDOMIZE TIME +20 PRINT "The 24 Game" +30 PRINT "===========":PRINT +40 PRINT "Enter an arithmetic expression" +50 PRINT "that evaluates to 24," +60 PRINT "using only the provided digits" +70 PRINT "and +, -, *, /, (, )." +80 PRINT "(Just hit Return for new digits.)" +90 ' create new digits +100 FOR i=1 TO 4:a(i)=INT(RND*9)+1:NEXT +110 PRINT +120 PRINT "The digits are";a(1);a(2);a(3);a(4) +130 PRINT +140 ' user enters solution +150 INPUT "Your solution";s$ +160 IF s$="" THEN PRINT "Creating new digits...":GOTO 100 +170 GOTO 300 +180 ' a little hack to create something like an EVAL function +190 OPENOUT "exp.bas" +200 PRINT #9,"1000 x="s$":return" +210 CLOSEOUT +220 CHAIN MERGE "exp",240 +230 ' now evaluate the expression +240 ON ERROR GOTO 530 +250 GOSUB 1000 +260 IF x=24 THEN PRINT "Well done!":END +270 PRINT "No, this evaluates to"x:PRINT "Please try again." +280 GOTO 150 +290 ' check input for correctness +300 FOR i=1 TO LEN(s$) +310 q=ASC(MID$(s$,i,1)) +320 IF q=32 OR (q>39 AND q<44) OR q=45 OR (q>46 AND q<58) THEN NEXT +330 IF i-1=LEN(s$) THEN 370 +340 PRINT "Bad character in expression:"CHR$(q) +350 PRINT "Try again":GOTO 150 +360 ' new numbers in solution? +370 FOR i=1 TO LEN(s$)-1 +380 q=ASC(MID$(s$,i,1)):p=ASC(MID$(s$,i+1,1)) +390 IF q>47 AND q<58 AND p>47 AND p<58 THEN PRINT "No forming of new numbers, please!":GOTO 150 +400 NEXT +410 FOR i=1 TO 9:orig(i)=0:guess(i)=0:NEXT +420 FOR i=1 TO 4:orig(a(i))=orig(a(i))+1:NEXT +430 FOR i=1 TO LEN(s$) +440 v$=MID$(s$,i,1) +450 va=ASC(v$)-48 +460 IF va>0 AND va<10 THEN guess(va)=guess(va)+1 +470 NEXT +480 FOR i=1 TO 9 +490 IF guess(i)<>orig(i) THEN PRINT "Only use all the provided digits!":GOTO 150 +500 NEXT +510 GOTO 190 +520 ' syntax error, e.g. non-matching parentheses +530 PRINT "Error in expression, please try again." +540 RESUME 150 diff --git a/Task/24-game/Logo/24-game.logo b/Task/24-game/Logo/24-game.logo new file mode 100644 index 0000000000..e152547397 --- /dev/null +++ b/Task/24-game/Logo/24-game.logo @@ -0,0 +1,74 @@ +; useful constants +make "false 1=0 +make "true 1=1 +make "lf char 10 +make "sp char 32 + +; non-digits legal in expression +make "operators (lput sp [+ - * / \( \)]) + +; display help message +to show_help :digits + type lf + print sentence quoted [Using only these digits:] :digits + print sentence quoted [and these operators:] [* / + -] + print quoted [\(and parentheses as needed\),] + print quoted [enter an arithmetic expression + which evaluates to exactly 24.] + type lf + print quoted [Enter \"!\" to get fresh numbers.] + print quoted [Enter \"q\" to quit.] + type lf +end + +make "digits [] +make "done false +until [done] [ + + if empty? digits [ + make "digits (map [(random 9) + 1] [1 2 3 4]) + ] + + (type "Solution sp "for sp digits "? sp ) + make "expression readrawline + + ifelse [expression = "?] [ + + show_help digits + + ] [ifelse [expression = "q] [ + + print "Bye! + make "done true + + ] [ifelse [expression = "!] [ + + make "digits [] + + ] [ + make "exprchars ` expression + make "allowed (sentence digits operators) + + ifelse (member? false (map [[c] member? c allowed] exprchars)) [ + (print quoted [Illegal character in input.]) + ] [ + catch "error [ + make "syntax_error true + make "testval (run expression) + make "syntax_error false + ] + ifelse syntax_error [ + (print quoted [Invalid expression.]) + ] [ + ifelse (testval = 24) [ + print quoted [You win!] + make "done true + ] [ + (print (sentence + quoted [Incorrect \(got ] testval quoted [instead of 24\).])) + ] + ] + ] + ]]] +] +bye diff --git a/Task/24-game/Mathematica/24-game.mathematica b/Task/24-game/Mathematica/24-game.mathematica new file mode 100644 index 0000000000..a7aa154774 --- /dev/null +++ b/Task/24-game/Mathematica/24-game.mathematica @@ -0,0 +1,15 @@ +isLegal[n_List, x_String] := + Quiet[Check[ + With[{h = ToExpression[x, StandardForm, HoldForm]}, + If[Cases[Level[h, {2, \[Infinity]}, Hold, Heads -> True], + Except[_Integer | Plus | _Plus | Times | _Times | Power | + Power[_, -1]]] === {} && + Sort[Level[h /. Power[q_, -1] -> q, {-1}] /. + q_Integer -> Abs[q]] === Sort[n], ReleaseHold[h]]], Null]] +Grid[{{Button[ + "new numbers", {a, b, c, d} = Table[RandomInteger[{1, 9}], {4}]], + InputField[Dynamic[x], String]}, {Dynamic[{a, b, c, d}], + Dynamic[Switch[isLegal[{a, b, c, d}, x], Null, + "Sorry, that is invalid.", 24, "Congrats! That's 24!", _, + "Sorry, that makes " <> ToString[ToExpression@x, InputForm] <> + ", not 24."]]}}] diff --git a/Task/24-game/Modula-2/24-game.mod2 b/Task/24-game/Modula-2/24-game.mod2 new file mode 100644 index 0000000000..f5421c8db6 --- /dev/null +++ b/Task/24-game/Modula-2/24-game.mod2 @@ -0,0 +1,179 @@ +MODULE TwentyFour; + +FROM InOut IMPORT WriteString, WriteLn, Write, ReadString, WriteInt; +FROM RandomGenerator IMPORT Random; + +TYPE operator_t = (add, sub, mul, div); + expr_t = RECORD + operand : ARRAY[0..3] OF CARDINAL; + operator : ARRAY[1..3] OF operator_t; + END;(*of RECORD*) + numbers_t = SET OF CHAR; + +VAR expr : expr_t; + numbers : numbers_t; +(*******************************************************************createExpr*) +(*analyse the input string *) +PROCEDURE createExpr(s: ARRAY OF CHAR); + +VAR index, counter : INTEGER; + token : CHAR; + temp_expr : expr_t; + operand : CARDINAL; + operator : operator_t; + + (************************************nextToken*) + (* returns the next CHAR that isn`t a space *) + PROCEDURE nextToken(): CHAR; + BEGIN + INC(index); + WHILE (s[index] = ' ') DO + INC(index); + END;(*of WHILE*) + RETURN(s[index]); + END nextToken; + (***********************************set_operand*) + (* checks if the CHAR o inerhits a valid number*) + (* and sets 'operand' to its value *) + PROCEDURE set_operand(o: CHAR); + BEGIN + CASE o OF + '0'..'9': IF o IN numbers THEN + operand := ORD(o)-48; + numbers := numbers - numbers_t{o}; + ELSE + WriteString("ERROR: '"); + Write( o); + WriteString( "' isn`t a available number "); + WriteLn; + HALT; + END;(*of IF*)| + 0 : WriteString("ERROR: error in input "); + WriteLn; + HALT; + ELSE + WriteString("ERROR: '"); + Write( o); + WriteString( "' isn`t a number "); + WriteLn; + HALT; + END;(*of CASE*) + END set_operand; + (**********************************set_operator*) + (* checks if the CHAR o inerhits a valid *) + (* operator and sets 'operator' to its value *) + PROCEDURE set_operator(o: CHAR); + BEGIN + CASE o OF + '+' : operator := add;| + '-' : operator := sub;| + '*' : operator := mul;| + '/' : operator := div;| + 0 : WriteString("ERROR: error in input "); + WriteLn; + HALT; + ELSE + WriteString("ERROR: '"); + Write( o); + WriteString( "' isn`t a operator "); + WriteLn; + HALT; + END;(*of CASE*) + END set_operator; + (************************************************) +BEGIN + index := -1; + + token := nextToken(); + set_operand(token); + expr.operand[0] := operand; + + token := nextToken(); + set_operator(token); + expr.operator[1] := operator; + + + token := nextToken(); + set_operand(token); + expr.operand[1] := operand; + + token := nextToken(); + set_operator(token); + expr.operator[2] := operator; + + token := nextToken(); + set_operand(token); + expr.operand[2] := operand; + + token := nextToken(); + set_operator(token); + expr.operator[3] := operator; + + token := nextToken(); + set_operand(token); + expr.operand[3] := operand; +END createExpr; + +(*****************************************************************evaluateExpr*) +(* evaluate the expresion that was createt by 'createExpr' *) + +PROCEDURE evaluateExpr(VAR num: REAL); + +VAR index : INTEGER; +BEGIN + WITH expr DO + num := VAL(REAL,operand[0]); + FOR index := 1 TO 3 DO + CASE operator[index] OF + add : num := num + VAL(REAL,operand[index]);| + sub : num := num - VAL(REAL,operand[index]);| + mul : num := num * VAL(REAL,operand[index]);| + div : num := num / VAL(REAL,operand[index]); + END;(*of CASE*) + END;(*of FOR*) + END;(*of WIHT*) +END evaluateExpr; + +(**************************************************************generateNumbers*) +(* generates the 4 random numbers ond write them *) +PROCEDURE generateNumbers; +VAR index,ran : INTEGER; +BEGIN + numbers := numbers_t{}; + ran := Random(0,9); + FOR index := 1 TO 4 DO + WHILE (CHR(ran+48) IN numbers )DO + ran := Random(0,9); + END;(*of While*) + Write(CHR(ran+48)); + WriteLn; + numbers := numbers + numbers_t{CHR(ran+48)} + END;(*of FOR*) +END generateNumbers; +(****************************************************************Main Programm*) +VAR str : ARRAY[0..255] OF CHAR; + sum : REAL; +BEGIN + WriteString("Welcome to the 24 game in MODULA-2"); + WriteLn; + WriteString("Here are your numbers:"); + WriteLn; + generateNumbers; + WriteString("Enter your equation(This implementation dosn`t support brackets yet): "); + WriteLn; + ReadString(str); + createExpr(str); + evaluateExpr(sum); + WriteLn; + WriteString("Result:"); + WriteLn; + WriteInt(TRUNC(sum),0); + WriteLn; + CASE (TRUNC(sum) - 24) OF + 0 : WriteString("Perfect!");| + 1 : WriteString("Almost perfect."); + ELSE + WriteString("You loose!"); + END;(*of CASE*) + WriteLn; +END TwentyFour. diff --git a/Task/99-Bottles-of-Beer/FALSE/99-bottles-of-beer.false b/Task/99-Bottles-of-Beer/FALSE/99-bottles-of-beer.false new file mode 100644 index 0000000000..083dac697c --- /dev/null +++ b/Task/99-Bottles-of-Beer/FALSE/99-bottles-of-beer.false @@ -0,0 +1,7 @@ +[$." bottle"$1-["s"]?" of beer"]b: +99 +[$][b;!" on the wall +"b;!" +Take one down and pass it around +"1-b;!" on the wall +"]#% diff --git a/Task/99-Bottles-of-Beer/FBSL/99-bottles-of-beer.fbsl b/Task/99-Bottles-of-Beer/FBSL/99-bottles-of-beer.fbsl new file mode 100644 index 0000000000..6374d43017 --- /dev/null +++ b/Task/99-Bottles-of-Beer/FBSL/99-bottles-of-beer.fbsl @@ -0,0 +1,62 @@ +#Option Explicit +#AppType Console +#Include + +Class Wall + bottles + + Sub Initialize(%n = 99) + bottles = n + End Sub + + Method Denom() + if bottles+1 > 1 then + return "one" + elseif bottles+1 = 1 then + return "it" + end if + End Method + + Method StockUp( %n = 99 ) + bottles = n + End Method + + Method TakeOneDown() + bottles = bottles - 1 + end Method + + Method Pluraliser() + if bottles > 1 then + return "s" + else + return "" + end if + end method + + Method Sing() + print bottles, " bottle", Pluraliser(), " of beer on the wall" + print bottles, " bottle", Pluraliser(), " of beer" + TakeOneDown() + print "take ", Denom(), " down and pass it round" + if bottles > 0 then + print bottles, " bottle", Pluraliser(), " of beer on the wall" + print + else + print "no more bottles of beer on the wall" + print + print "no more bottles of beer on the wall" + print "no more bottles of beer on the wall" + print "go to the store and buy some more" + StockUp(99) + print bottles, " bottle", Pluraliser(), " of beer on the wall" + print + end if + return bottles + End Method + +End Class + +Dim BeerSong as new Wall(99) + +while BeerSong.Sing() <> 99 +end while diff --git a/Task/99-Bottles-of-Beer/Factor/99-bottles-of-beer.factor b/Task/99-Bottles-of-Beer/Factor/99-bottles-of-beer.factor new file mode 100644 index 0000000000..688115c662 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Factor/99-bottles-of-beer.factor @@ -0,0 +1,22 @@ +USING: io kernel make math math.parser math.ranges sequences ; + +: bottle ( -- quot ) + [ + [ + [ + [ # " bottles of beer on the wall,\n" % ] + [ # " bottles of beer.\n" % ] bi + ] keep + "Take one down, pass it around,\n" % + 1 - # " bottles of beer on the wall\n" % + ] " " make print + ] ; inline + +: last-verse ( -- ) + "Go to the store and buy some more," + "no more bottles of beer on the wall!" [ print ] bi@ ; + +: bottles ( n -- ) + 1 [a,b] bottle each last-verse ; + +! Usage: 99 bottles diff --git a/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-1.falcon b/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-1.falcon new file mode 100644 index 0000000000..d47cc40373 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-1.falcon @@ -0,0 +1,6 @@ +for i in [99:1] + > i, " bottles of beer on the wall" + > i, " bottles of beer" + > "Take one down, pass it around" + > i-1, " bottles of beer on the wall\n" +end diff --git a/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-2.falcon b/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-2.falcon new file mode 100644 index 0000000000..d3f94095ca --- /dev/null +++ b/Task/99-Bottles-of-Beer/Falcon/99-bottles-of-beer-2.falcon @@ -0,0 +1,7 @@ +for i in [99:1] + plural = (i != 1) ? 's' : "" + > @ "$i bottle$plural of beer on the wall" + > @ "$i bottle$plural of beer" + > "Take one down, pass it around" + > i-1, @ " bottle$plural of beer on the wall\n" +end diff --git a/Task/99-Bottles-of-Beer/Fexl/99-bottles-of-beer.fexl b/Task/99-Bottles-of-Beer/Fexl/99-bottles-of-beer.fexl new file mode 100644 index 0000000000..f0d54e3fd2 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Fexl/99-bottles-of-beer.fexl @@ -0,0 +1,36 @@ +\bottles_of_beer = + (\n + print (< n 1 "No more" n); + print " bottle"; print (== n 1 "" "s"); + print " of beer"; + ) + +\bottles_of_beer_on_the_wall = + (\n + bottles_of_beer n; print " on the wall"; + ) + +\sing_bottles_of_beer = + (\max + do (range max 0) \qty + bottles_of_beer_on_the_wall qty; nl; + bottles_of_beer qty; nl; + + \qty = + ( + > qty 0 + ( + print "Take one down, pass it around";nl; + - qty 1 + ) + ( + print "Go to the store and buy some more";nl; + max + ) + ) + + bottles_of_beer_on_the_wall qty; nl; + nl; + ) + +sing_bottles_of_beer 99; diff --git a/Task/99-Bottles-of-Beer/Frege/99-bottles-of-beer.frege b/Task/99-Bottles-of-Beer/Frege/99-bottles-of-beer.frege new file mode 100644 index 0000000000..b9995a8fe7 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Frege/99-bottles-of-beer.frege @@ -0,0 +1,10 @@ +module Beer where + +beer 1 = "1 bottle of beer on the wall\n1 bottle of beer\nTake one down, pass it around" +beer 0 = "better go to the store and buy some more." +beer v = show v ++ " bottles of beer on the wall\n" + ++ show v + ++" bottles of beer\nTake one down, pass it around\n" + ++ head (lines $ beer $ v-1) ++ "\n" + +main _ = mapM_ (printStrLn . beer) (reverse (0..99)) diff --git a/Task/99-Bottles-of-Beer/Frink/99-bottles-of-beer.frink b/Task/99-Bottles-of-Beer/Frink/99-bottles-of-beer.frink new file mode 100644 index 0000000000..a093a5facb --- /dev/null +++ b/Task/99-Bottles-of-Beer/Frink/99-bottles-of-beer.frink @@ -0,0 +1,17 @@ +units = array[units[volume]] +showApproximations[false] + +for n = 99 to 0 step -1 +{ + unit = units.removeRandom[] + str = getBottleString[n, unit] + + println["$str of beer on the wall, $str."] + + if (n == 0) + println["Go to the store and buy some more, 99 bottles of beer on the wall."] + else + println["Take one down and pass it around, " + getBottleString[n-1, unit] + " on the wall.\n"] +} + +getBottleString[n, unit] := format[n*12 floz, unit, 6] + "s" diff --git a/Task/99-Bottles-of-Beer/GAP/99-bottles-of-beer.gap b/Task/99-Bottles-of-Beer/GAP/99-bottles-of-beer.gap new file mode 100644 index 0000000000..b972885469 --- /dev/null +++ b/Task/99-Bottles-of-Beer/GAP/99-bottles-of-beer.gap @@ -0,0 +1,22 @@ +Bottles := function(n) + local line, i, j, u; + line := function(n) + s := String(n); + if n < 2 then + return Concatenation(String(n), " bottle of beer"); + else + return Concatenation(String(n), " bottles of beer"); + fi; + end; + for i in [1 .. n] do + j := n - i + 1; + u := line(j); + Display(Concatenation(u, " on the wall")); + Display(u); + Display("Take one down, pass it around"); + Display(Concatenation(line(j - 1), " on the wall")); + if i <> n then + Display(""); + fi; + od; +end; diff --git a/Task/99-Bottles-of-Beer/GUISS/99-bottles-of-beer.guiss b/Task/99-Bottles-of-Beer/GUISS/99-bottles-of-beer.guiss new file mode 100644 index 0000000000..8ec69b9992 --- /dev/null +++ b/Task/99-Bottles-of-Beer/GUISS/99-bottles-of-beer.guiss @@ -0,0 +1,5 @@ +Start,Programs,Accessories,Calculator,Button:9,Button:9, +Button:[hyphen],Button:1,Button:[equals],Button:[hyphen],Button:1,Button:[equals], +Button:[hyphen],Button:1,Button:[equals],Button:[hyphen],Button:1,Button:[equals], +Button:[hyphen],Button:1,Button:[equals],Button:[hyphen],Button:1,Button:[equals], +Button:[hyphen],Button:1,Button:[equals],Button:[hyphen],Button:1,Button:[equals] diff --git a/Task/99-Bottles-of-Beer/Golfscript/99-bottles-of-beer.golf b/Task/99-Bottles-of-Beer/Golfscript/99-bottles-of-beer.golf new file mode 100644 index 0000000000..ddb3073a42 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Golfscript/99-bottles-of-beer.golf @@ -0,0 +1 @@ +[296,{3/)}%-1%["No more"]+[" bottles":b]294*[b-1<]2*+[b]+[" of beer on the wall\n".8<"\nTake one down, pass it around\n"+1$n+]99*]zip diff --git a/Task/99-Bottles-of-Beer/Gosu/99-bottles-of-beer.gosu b/Task/99-Bottles-of-Beer/Gosu/99-bottles-of-beer.gosu new file mode 100644 index 0000000000..6ebef9e3cf --- /dev/null +++ b/Task/99-Bottles-of-Beer/Gosu/99-bottles-of-beer.gosu @@ -0,0 +1,11 @@ +for (i in 99..0) { + + print("${i} bottles of beer on the wall") + + if (i > 0) { + print("${i} bottles of beer") + print("Take one down, pass it around") + } + print(""); + +} diff --git a/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-1.groovy b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-1.groovy new file mode 100644 index 0000000000..9b0a268879 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-1.groovy @@ -0,0 +1,10 @@ +def bottles = { "${it==0 ? 'No more' : it} bottle${it==1 ? '' : 's' }" } + +99.downto(1) { i -> + print """ +${bottles(i)} of beer on the wall +${bottles(i)} of beer +Take one down, pass it around +${bottles(i-1)} of beer on the wall +""" +} diff --git a/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-2.groovy b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-2.groovy new file mode 100644 index 0000000000..5b575ed158 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-2.groovy @@ -0,0 +1,5 @@ +298.downto(2) { + def (m,d) = [it%3,(int)it/3] + print "${m==1?'\n':''}${d?:'No more'} bottle${d!=1?'s':''} of beer" + + "${m?' on the wall':'\nTake one down, pass it around'}\n" +} diff --git a/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-3.groovy b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-3.groovy new file mode 100644 index 0000000000..b21f5f775e --- /dev/null +++ b/Task/99-Bottles-of-Beer/Groovy/99-bottles-of-beer-3.groovy @@ -0,0 +1,30 @@ +def bottles = { "${it==0 ? 'No more' : it} bottle${it==1 ? '' : 's' }" } + +def initialState = { + """${result(it)} +${resultShort(it)}""" +} + +def act = { + it > 0 ? + "Take ${it==1 ? 'it' : 'one'} down, pass it around" : + "Go to the store, buy some more" +} + +def delta = { it > 0 ? -1 : 99 } + +def resultShort = { "${bottles(it)} of beer" } + +def result = { "${resultShort(it)} on the wall" } + +// //// uncomment commented lines to create endless drunken binge //// // +// while (true) { +99.downto(0) { i -> + print """ +${initialState(i)} +${act(i)} +${result(i+delta(i))} +""" +} +// Thread.sleep(1000) +// } diff --git a/Task/99-Bottles-of-Beer/HQ9+/99-bottles-of-beer.hq9p b/Task/99-Bottles-of-Beer/HQ9+/99-bottles-of-beer.hq9p new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/HQ9+/99-bottles-of-beer.hq9p @@ -0,0 +1 @@ +9 diff --git a/Task/99-Bottles-of-Beer/Haxe/99-bottles-of-beer.haxe b/Task/99-Bottles-of-Beer/Haxe/99-bottles-of-beer.haxe new file mode 100644 index 0000000000..67fc36e3a6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Haxe/99-bottles-of-beer.haxe @@ -0,0 +1,33 @@ +class RosettaDemo +{ + static public function main() + { + singBottlesOfBeer(100); + } + + static function singBottlesOfBeer(bottles : Int) + { + var plural : String = 's'; + + while (bottles >= 1) + { + Sys.println(bottles + " bottle" + plural + " of beer on the wall,"); + Sys.println(bottles + " bottle" + plural + " of beer!"); + Sys.println("Take one down, pass it around,"); + if (bottles - 1 == 1) + { + plural = ''; + } + + if (bottles > 1) + { + Sys.println(bottles-1 + " bottle" + plural + " of beer on the wall!\n"); + } + else + { + Sys.println("No more bottles of beer on the wall!"); + } + bottles--; + } + } +} diff --git a/Task/99-Bottles-of-Beer/HicEst/99-bottles-of-beer.hicest b/Task/99-Bottles-of-Beer/HicEst/99-bottles-of-beer.hicest new file mode 100644 index 0000000000..3bc96ed928 --- /dev/null +++ b/Task/99-Bottles-of-Beer/HicEst/99-bottles-of-beer.hicest @@ -0,0 +1,13 @@ +DO x = 99, 1, -1 + WRITE() x , "bottles of beer on the wall" + BEEP("T16 be be be bH bH bH be be be 2be ") + + WRITE() x , "bottles of beer" + BEEP("2p f f f c c c 2f ") + + WRITE() "take one down, pass it around" + BEEP("2p 2d d d 2p d d d 2d ") + + WRITE() x , "bottles of beer on the wall" + BEEP("2p #A #A #A c c d #d #d #d 2#d 2p") +ENDDO diff --git a/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-1.idl b/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-1.idl new file mode 100644 index 0000000000..ce51766995 --- /dev/null +++ b/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-1.idl @@ -0,0 +1,10 @@ +Pro bottles + +for i=1,99 do begin + print, 100-i, " bottles of beer on the wall.", 100-i, $ + " bottles of beer.", " Take one down, pass it around," , $ + 99-i, " bottles of beer on the wall." +endfor +End + +} diff --git a/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-2.idl b/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-2.idl new file mode 100644 index 0000000000..71fd23605a --- /dev/null +++ b/Task/99-Bottles-of-Beer/IDL/99-bottles-of-beer-2.idl @@ -0,0 +1,8 @@ +Pro bottles_noloop + b=(reverse(shift(sindgen(100),-1)))[1:99] + b2=reverse(sindgen(99)) + wallT=replicate(' bottles of beer on the wall.', 100) + wallT2=replicate(' bottles of beer.', 100) + takeT=replicate('Take one down, pass it around,', 100) + print, b+wallT+string(10B)+b+wallT2+string(10B)+takeT+string(10B)+b2+wallT+string(10B) +End diff --git a/Task/99-Bottles-of-Beer/Icon/99-bottles-of-beer.icon b/Task/99-Bottles-of-Beer/Icon/99-bottles-of-beer.icon new file mode 100644 index 0000000000..b0f1dc15a7 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Icon/99-bottles-of-beer.icon @@ -0,0 +1,27 @@ +procedure main(args) + numBeers := integer(args[1]) | 99 + drinkUp(numBeers) +end + +procedure drinkUp(beerMax) + static beerMap + initial { + beerMap := table(" bottles") + beerMap[1] := " bottle" + } + + every beerCount := beerMax to 1 by -1 do { + writes( beerCount,beerMap[beerCount]," of beer on the wall, ") + write( beerCount,beerMap[beerCount]," of beer.") + + writes("Take one down and pass it around, ") + write(case x := beerCount-1 of { + 0 : "no more bottles" + default : x||beerMap[x] + }," of beer on the wall.\n") + } + + write("No more bottles of beer on the wall, no more bottles of beer.") + write("Go to the store and buy some more, ", + beerMax," bottles of beer on the wall.") +end diff --git a/Task/99-Bottles-of-Beer/Inform-6/99-bottles-of-beer.inf b/Task/99-Bottles-of-Beer/Inform-6/99-bottles-of-beer.inf new file mode 100644 index 0000000000..481a4eb31d --- /dev/null +++ b/Task/99-Bottles-of-Beer/Inform-6/99-bottles-of-beer.inf @@ -0,0 +1,19 @@ +[ Bottles i; + if(i == 1) return "bottle"; + + return "bottles"; +]; + +[ Beer i; + print i, " ", (string) Bottles(i), " of beer on the wall^"; + print i, " ", (string) Bottles(i), " of beer^"; + print "Take one down, pass it around^"; + i--; + print i, " ", (string) Bottles(i), " of beer on the wall^^"; + + if(i ~= 0) Beer(i); +]; + +[ Main; + Beer(99); +]; diff --git a/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-1.inf b/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-1.inf new file mode 100644 index 0000000000..bfa6548ed6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-1.inf @@ -0,0 +1,10 @@ +Beer Hall is a room. + +When play begins: + repeat with iteration running from 1 to 99: + let N be 100 - iteration; + say "[N] bottle[s] of beer on the wall[line break]"; + say "[N] bottle[s] of beer[line break]"; + say "Take one down, pass it around[line break]"; + say "[N - 1] bottle[s] of beer on the wall[paragraph break]"; + end the story. diff --git a/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-2.inf b/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-2.inf new file mode 100644 index 0000000000..0e466949c3 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Inform-7/99-bottles-of-beer-2.inf @@ -0,0 +1,18 @@ +Beer Hall is a room. + +The plural of bottle of beer is bottles of beer. A bottle of beer is a kind of thing. + +The wall is a scenery supporter in Beer Hall. 99 bottles of beer are on the wall. + +When play begins: + while something is on the wall: + say "[what's on the wall] on the wall[line break]"; + say "[what's on the wall][line break]"; + say "Take one down, pass it around[line break]"; + remove a random thing on the wall from play; + say "[what's on the wall] on the wall[paragraph break]"; + end the story. + +To say what's on the wall: + if more than one thing is on the wall, say list of things on the wall; + otherwise say "[number of things on the wall in words] bottle[s] of beer". diff --git a/Task/99-Bottles-of-Beer/Integer-BASIC/99-bottles-of-beer.bas b/Task/99-Bottles-of-Beer/Integer-BASIC/99-bottles-of-beer.bas new file mode 100644 index 0000000000..2e743c2ed3 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Integer-BASIC/99-bottles-of-beer.bas @@ -0,0 +1,28 @@ +E000G (APPLE II) +E000R (APPLE I) +10 REM ------------------------- +11 REM BEERSONG IN APPLE INTEGER +12 REM BASIC BY BARRYM 2011-8-21 +13 REM THANKS : APPLEWIN1.17.2.0 +14 REM THANKS ALSO : POM1 0.7B +15 REM ------------------------- +16 REM PRINTS THE COMPLETE UPPER +17 REM CASE LYRICS ON AN APPLE I +18 REM OR AN 'ORIGINAL' APPLE II +19 REM WITH WOZ'S INTEGER BASIC. +20 REM ------------------------- +21 REM THIS BASIC HAS AN UNUSUAL +22 REM 'THEN', WHICH EXECUTES OR +23 REM SKIPS ONE (AND ONLY ONE!) +24 REM STATEMENT. THIS CONFUSED +25 REM US KIDS REGULARLY WHEN WE +26 REM TRIED TRANSLATING INTEGER +27 REM BASIC GAMES TO APPLE$OFT! +30 REM ------------------------- +40 FOR B=99 TO 98 STEP 0: PRINT : FOR W=0 TO 2: IF W<2 THEN 70 +50 IF B THEN PRINT "TAKE ONE DOWN AND PASS IT AROUND";:B=B-1 +60 IF B+1 THEN 70:B=99: PRINT "GO TO THE STORE AND BUY SOME MORE"; +70 IF W THEN PRINT ",": IF B THEN PRINT B;: IF B=0 THEN PRINT "NO MORE"; +80 PRINT " BOTTLE";: IF B#1 THEN PRINT "S";: PRINT " OF BEER"; +90 IF W#1 THEN PRINT " ON THE WALL";: IF W THEN PRINT ".": NEXT W,B: END +RUN diff --git a/Task/99-Bottles-of-Beer/Io/99-bottles-of-beer.io b/Task/99-Bottles-of-Beer/Io/99-bottles-of-beer.io new file mode 100644 index 0000000000..f1cb32b1f7 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Io/99-bottles-of-beer.io @@ -0,0 +1,13 @@ +bottles := method(i, + if(i==0, return "no more bottles of beer") + if(i==1, return "1 bottle of beer") + "" .. i .. " bottles of beer" +) +for(i, 99, 1, -1, + write( + bottles(i), " on the wall, ", + bottles(i), ",\n", + "take one down, pass it around,\n", + bottles(i - 1), " on the wall.\n\n" + ) +) diff --git a/Task/99-Bottles-of-Beer/Ioke/99-bottles-of-beer.ioke b/Task/99-Bottles-of-Beer/Ioke/99-bottles-of-beer.ioke new file mode 100644 index 0000000000..3ec7be2715 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Ioke/99-bottles-of-beer.ioke @@ -0,0 +1,11 @@ +bottle = method(i, + case(i, + 0, "no more bottles of beer", + 1, "1 bottle of beer", + "#{i} bottles of beer")) + +(99..1) each(i, + "#{bottle(i)} on the wall, " println + "take one down, pass it around," println + "#{bottle(i - 1)} on the wall.\n" println +) diff --git a/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-1.j b/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-1.j new file mode 100644 index 0000000000..09f09cd83e --- /dev/null +++ b/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-1.j @@ -0,0 +1,4 @@ +bob =: ": , ' bottle' , (1 = ]) }. 's of beer'"_ +bobw=: bob , ' on the wall'"_ +beer=: bobw , ', ' , bob , '; take one down and pass it around, ' , bobw@<: +beer"0 >:i.-99 diff --git a/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-2.j b/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-2.j new file mode 100644 index 0000000000..328f6c0640 --- /dev/null +++ b/Task/99-Bottles-of-Beer/J/99-bottles-of-beer-2.j @@ -0,0 +1,6 @@ +99 bottles of beer on the wall, 99 bottles of beer; take one down and pass it around, 98 bottles of beer on the wall +98 bottles of beer on the wall, 98 bottles of beer; take one down and pass it around, 97 bottles of beer on the wall +... +3 bottles of beer on the wall, 3 bottles of beer; take one down and pass it around, 2 bottles of beer on the wall +2 bottles of beer on the wall, 2 bottles of beer; take one down and pass it around, 1 bottle of beer on the wall +1 bottle of beer on the wall, 1 bottle of beer; take one down and pass it around, 0 bottles of beer on the wall diff --git a/Task/99-Bottles-of-Beer/Joy/99-bottles-of-beer.joy b/Task/99-Bottles-of-Beer/Joy/99-bottles-of-beer.joy new file mode 100644 index 0000000000..8911aff953 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Joy/99-bottles-of-beer.joy @@ -0,0 +1,26 @@ +LIBRA + + _beerlib == true ; + +HIDE + beer == "of beer " putchars ; + wall == "on the wall" putchars ; + take1 == "Take one down and pass it around, " putchars ; + dup3 == dup dup dup ; + comma == ", " putchars ; + period == '. putch ; + bottles == [dup small] + [ [null] [pop "no more bottles " putchars] [put "bottle " putchars] ifte] + [put "bottles " putchars] ifte ; + sing-verse == dup3 bottles beer wall comma + bottles beer ".\n" putchars + take1 1 - bottles beer wall period newline newline ; + sing-verse-0 == "No more bottles of beer on the wall, no more bottles of beer\n" putchars + "Go to the store and buy some more, " putchars + 99 bottles pop beer wall period newline ; + +IN + (* n -- *) + sing-verses == [null] + [sing-verse-0] + [sing-verse 1 -] tailrec . diff --git a/Task/99-Bottles-of-Beer/Julia/99-bottles-of-beer.julia b/Task/99-Bottles-of-Beer/Julia/99-bottles-of-beer.julia new file mode 100644 index 0000000000..2b2c99ad40 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Julia/99-bottles-of-beer.julia @@ -0,0 +1 @@ +for i = 99:-1:1 print("\n$i bottles of beer on the wall\n$i bottles of beer\nTake one down, pass it around\n$(i-1) bottles of beer on the wall\n") end diff --git a/Task/99-Bottles-of-Beer/K/99-bottles-of-beer.k b/Task/99-Bottles-of-Beer/K/99-bottles-of-beer.k new file mode 100644 index 0000000000..6f67396593 --- /dev/null +++ b/Task/99-Bottles-of-Beer/K/99-bottles-of-beer.k @@ -0,0 +1 @@ +`0:\:{x[z],y,a,x[z],a,"Take one down, pass it around",a,x[z-1],y,a,a:"\n"}[{($x)," bottle",:[x=1;"";"s"]," of beer"};" on the wall"]'|1_!100 diff --git a/Task/99-Bottles-of-Beer/Kotlin/99-bottles-of-beer.kotlin b/Task/99-Bottles-of-Beer/Kotlin/99-bottles-of-beer.kotlin new file mode 100644 index 0000000000..4b1da88360 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Kotlin/99-bottles-of-beer.kotlin @@ -0,0 +1,11 @@ +fun main(args : Array) { + var i = 99 + while (i > 0) { + + System.out?.println("${i} bottles of beer on the wall") + System.out?.println("${i} bottles of beer") + System.out?.println("Take one down, pass it around") + i--; + } + System.out?.println("0 bottles of beer on the wall") +} diff --git a/Task/99-Bottles-of-Beer/LLVM/99-bottles-of-beer.llvm b/Task/99-Bottles-of-Beer/LLVM/99-bottles-of-beer.llvm new file mode 100644 index 0000000000..e60b4f47d3 --- /dev/null +++ b/Task/99-Bottles-of-Beer/LLVM/99-bottles-of-beer.llvm @@ -0,0 +1,70 @@ +; "99 Bottles of Beer on the Wall" in LLVM Assembly + +; This is not strictly LLVM, as it uses the C library function "printf". +; LLVM does not provide a way to print values, so the alternative would be +; to just load the string into memory, and that would be boring. + +; The song lyrics are global constants. +; Lyrics for plural verses: +@pluralVerse = private constant [120 x i8] +c"%d bottles of beer on the wall, %d bottles of beer.\0ATake one down and pass it around, %d bottles of beer on the wall.\0A\0A\00" +; Lyrics for the singular verse: +@singularVerse = private constant [121 x i8] + c"1 bottle of beer on the wall, 1 bottle of beer.\0ATake one down and pass it around, no more bottles of beer on the wall.\0A\0A\00" +; Lyrics for the final verse: +@finalVerse = private constant [130 x i8] + c"No more bottles of beer on the wall, no more bottles of beer.\0AGo to the store and buy some more, %d bottles of beer on the wall.\0A\00" + +; Initial number of bottles of beer. +; This must be a natural number. +@initialVerseNumber = private constant i32 99 + +; The declaration for the external C printf function. +declare i32 @printf(i8*, ...) + +; Prints a verse, with %numberOfBottles being the initial number of bottles +; in that verse. +define fastcc void @printVerse(i32 %numberOfBottles) { + switch i32 %numberOfBottles, + label %pluralVerse + [ i32 1, label %singularVerse + i32 0, label %finalVerse ] + +pluralVerse: + %pluralVersePointer = getelementptr [120 x i8]* @pluralVerse, i64 0, i64 0 + %newNumberOfBottles = sub i32 %numberOfBottles, 1 + call i32(i8*, ...)* @printf( + i8* %pluralVersePointer, + i32 %numberOfBottles, + i32 %numberOfBottles, + i32 %newNumberOfBottles) + ret void + +singularVerse: + %singularVersePointer = getelementptr [121 x i8]* @singularVerse,i64 0,i64 0 + call i32(i8*, ...)* @printf(i8* %singularVersePointer) + ret void + +finalVerse: + %finalVersePointer = getelementptr [130 x i8]* @finalVerse, i64 0, i64 0 + %initialVerseNumberL = load i32* @initialVerseNumber + call i32(i8*, ...)* @printf(i8* %finalVersePointer,i32 %initialVerseNumberL) + ret void +} + +define i32 @main() { +loopHeader: + %initialVerseNumberL = load i32* @initialVerseNumber + br label %loop ; This br terminates the first basic block. +loop: + %verseNumber = + phi i32 [%initialVerseNumberL, %loopHeader], [%nextVerseNumber, %do] + %cond = icmp eq i32 -1, %verseNumber + br i1 %cond, label %break, label %do +do: + call fastcc void @printVerse(i32 %verseNumber) + %nextVerseNumber = sub i32 %verseNumber, 1 + br label %loop +break: + ret i32 0 +} diff --git a/Task/99-Bottles-of-Beer/LOLCODE/99-bottles-of-beer.lol b/Task/99-Bottles-of-Beer/LOLCODE/99-bottles-of-beer.lol new file mode 100644 index 0000000000..1fec3e9577 --- /dev/null +++ b/Task/99-Bottles-of-Beer/LOLCODE/99-bottles-of-beer.lol @@ -0,0 +1,24 @@ +HAI 1.3 + +I HAS A bottles ITZ 99 +I HAS A plural ITZ "Z" +I HAS A lyric ITZ "99 BOTTLZ OV BEER" + +IM IN YR song + VISIBLE lyric " ON TEH WALL" + VISIBLE lyric + VISIBLE "TAEK 1 DOWN, PAZ IT AROUN" + + bottles R DIFF OF bottles AN 1 + NOT bottles, O RLY? + YA RLY, VISIBLE "NO MOAR BOTTLZ OV BEER ON TEH WALL", GTFO + OIC + BOTH SAEM bottles AN 1, O RLY? + YA RLY, plural R "" + OIC + + lyric R SMOOSH bottles " BOTTL" plural " OV BEER" MKAY + VISIBLE lyric " ON TEH WALL:)" +IM OUTTA YR song + +KTHXBYE diff --git a/Task/99-Bottles-of-Beer/Liberty-BASIC/99-bottles-of-beer.liberty b/Task/99-Bottles-of-Beer/Liberty-BASIC/99-bottles-of-beer.liberty new file mode 100644 index 0000000000..5dffeed1a5 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Liberty-BASIC/99-bottles-of-beer.liberty @@ -0,0 +1,13 @@ +For bottles = 99 To 1 Step -1 + song$ = song$ + str$(bottles) + " bottle" + If (bottles > 1) Then song$ = song$ + "s" + song$ = song$ + " of beer on the wall, " + str$(bottles) + " bottle" + If (bottles > 1) Then song$ = song$ + "s" + song$ = song$ + " of beer," + chr$(13) + chr$(10) + "Take one down, pass it around, " + str$(bottles - 1) + " bottle" + If (bottles > 2) Or (bottles = 1) Then song$ = song$ + "s" + song$ = song$ + " of beer on the wall." + chr$(13) + chr$(10) +Next bottles +song$ = song$ + "No more bottles of beer on the wall, no more bottles of beer." _ + + chr$(13) + chr$(10) + "Go to the store and buy some more, 99 bottles of beer on the wall." + +Print song$ diff --git a/Task/99-Bottles-of-Beer/Logo/99-bottles-of-beer.logo b/Task/99-Bottles-of-Beer/Logo/99-bottles-of-beer.logo new file mode 100644 index 0000000000..867a4d1da5 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Logo/99-bottles-of-beer.logo @@ -0,0 +1,12 @@ +to bottles :n + if :n = 0 [output [No more bottles]] + if :n = 1 [output [1 bottle]] + output sentence :n "bottles +end +to verse :n + print sentence bottles :n [of beer on the wall] + print sentence bottles :n [of beer] + print [Take one down, pass it around] + print sentence bottles :n-1 [of beer on the wall] +end +for [n 99 1] [verse :n (print)] diff --git a/Task/99-Bottles-of-Beer/Logtalk/99-bottles-of-beer.logtalk b/Task/99-Bottles-of-Beer/Logtalk/99-bottles-of-beer.logtalk new file mode 100644 index 0000000000..5afb2df0d6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Logtalk/99-bottles-of-beer.logtalk @@ -0,0 +1,23 @@ +:- object(bottles). + + :- initialization(sing(99)). + + sing(0) :- + write('No more bottles of beer on the wall, no more bottles of beer.'), nl, + write('Go to the store and buy some more, 99 bottles of beer on the wall.'), nl, nl. + sing(N) :- + N > 0, + N2 is N -1, + beers(N), write(' of beer on the wall, '), beers(N), write(' of beer.'), nl, + write('Take one down and pass it around, '), beers(N2), write(' of beer on the wall.'), nl, nl, + sing(N2). + + beers(0) :- + write('no more bottles'). + beers(1) :- + write('1 bottle'). + beers(N) :- + N > 1, + write(N), write(' bottles'). + +:- end_object. diff --git a/Task/99-Bottles-of-Beer/Lucid/99-bottles-of-beer.lucid b/Task/99-Bottles-of-Beer/Lucid/99-bottles-of-beer.lucid new file mode 100644 index 0000000000..81fb1bb010 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Lucid/99-bottles-of-beer.lucid @@ -0,0 +1,13 @@ +// Run luval with -s inside the lucid shell script +// The print out is a list of lines. So the output is not separated by new lines, rather +// by '[' and ']' -- I cant figure out how to do string concatenation with numbers in lucid. +// beer(N) ^ bottle(N) ^ wall ^ beer(N) ^ bottle(N) ^ pass ^ beer(N-1) ^ bottle(N-1) ^ wall +// should have worked but doesn't +[%beer(N),bottle(N),wall,beer(N),bottle(N),pass,beer(N-1),bottle(N-1),wall%] + where + N = 100 fby N - 1; + wall = if N > 0 then ` On the wall ' else eod fi; + pass = `Take one down and pass it around.'; + beer(A) = if A > 0 then A else `No more' fi; + bottle(A) = if A eq 1 then `bottle of beer' else `bottles of beer' fi; + end diff --git a/Task/99-Bottles-of-Beer/M4/99-bottles-of-beer.m4 b/Task/99-Bottles-of-Beer/M4/99-bottles-of-beer.m4 new file mode 100644 index 0000000000..03204e2141 --- /dev/null +++ b/Task/99-Bottles-of-Beer/M4/99-bottles-of-beer.m4 @@ -0,0 +1,9 @@ +define(`BOTTLES', `bottles of beer')dnl +define(`BOTTLE', `bottle of beer')dnl +define(`WALL', `on the wall')dnl +define(`TAKE', `take one down, pass it around')dnl +define(`NINETEEN', `$1 ifelse(`$1',`1',BOTTLE,BOTTLES) WALL +$1 ifelse(`$1',`1',BOTTLE,BOTTLES) +ifelse(`$1',`0',,`TAKE') +ifelse(`$1',`0',,`NINETEEN(eval($1-1))')')dnl +NINETEEN(99) diff --git a/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-1.max b/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-1.max new file mode 100644 index 0000000000..8454e01444 --- /dev/null +++ b/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-1.max @@ -0,0 +1,26 @@ +escapeEnable = true +resetMaxFile #noPrompt +viewport.setType #view_top +max tool maximize +viewport.SetRenderLevel #smoothhighlights +delay = 1.6 +a = text size:30 +a.wirecolor = white +theMod = extrude() +addModifier a theMod + +for i in 99 to 1 by -1 do -- this will iterate through 99 times use the escape key to terminate. +( + a.text = (i as string + " bottles of beer on the wall") + redrawViews() + sleep delay + a.text = (i as string + " bottles of beer") + redrawViews() + sleep delay + a.text = "Take one down, pass it around" + redrawViews() + sleep delay + a.text = ((i-1) as string + " bottles of beer on the wall") + redrawViews() + sleep delay +) diff --git a/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-2.max b/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-2.max new file mode 100644 index 0000000000..f325c0b633 --- /dev/null +++ b/Task/99-Bottles-of-Beer/MAXScript/99-bottles-of-beer-2.max @@ -0,0 +1,3 @@ +for i = 99 to 1 by -1 do (print (i as string + (if i == 1 then " bottle" else " bottles") + " of beer on the wall\n" + i as string +\ +(if i == 1 then " bottle" else " bottles") + " of beer\nTake one down, pass it around\n" + (i - 1) as string + (if i - 1 == 1 then "\ +bottle" else " bottles") + " of beer on the wall\n" + (if i - 1 == 0 then "\nno more beer" else ""))) diff --git a/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-1.ml b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-1.ml new file mode 100644 index 0000000000..4880e9edde --- /dev/null +++ b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-1.ml @@ -0,0 +1,20 @@ +MCSKIP "WITH" NL +"" 99 bottles - simple iterative version +MCSKIP MT,<> +MCINS %. +"" Macro to generate singular or plural bottle(s) +MCDEF BOT WITHS () AS MCGO L0 IF %A1. EN 1 +s> +"" Main macro - argument is initial number of bottles +MCDEF BOTTLES NL AS +"" Do it +BOTTLES 99 diff --git a/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-2.ml b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-2.ml new file mode 100644 index 0000000000..ab57ff5b14 --- /dev/null +++ b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-2.ml @@ -0,0 +1,20 @@ +MCSKIP "WITH" NL +"" 99 bottles - recursive version +MCSKIP MT,<> +MCINS %. +"" Macro to generate singular or plural bottle(s) +MCDEF BOT WITHS () AS MCGO L0 IF %A1. EN 1 +s> +"" Main macro - recurses for each verse - argument is initial number of bottles +MCDEF BOTTLES NL AS +"" Do it +BOTTLES 99 diff --git a/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-3.ml b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-3.ml new file mode 100644 index 0000000000..34c07b421a --- /dev/null +++ b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-3.ml @@ -0,0 +1,98 @@ +MCSKIP - WITH - NL +-- The line above defines the comment syntax: -- through to newline is completely deleted. +-- 99 Bottles of beer in 99 lines of ML/I by Parzival Herzog. +-- ML/I is P.J. Brown's famous general purpose macro processor designed in 1967. +-- +-- Define nestable quotes {...}, replaced by the unevaluated text within: +MCSKIP MT, {} +-- Define non-nestable quotes "...", replaced by the unevaluated text within: +MCSKIP T, "" +-- Define the argument insertion and expression evaluation syntax: +-- ?e. is replaced by the value of macro expression e: +MCINS ?. +-- +-- Top level macro: Sing N CONTAINERS of CONTENTS SOMEWHERE : DO THE DEED! REPLENISH. +MCDEF "Sing WITH SPACE SPACE of WITH SPACE SPACE : ! ." AS -- +{MCDEF "CONTAINERS" AS "{"?A2."}" +MCDEF "CONTAINER" AS "{"MCSUB(CONTAINERS,1,-1)"}" +MCDEF "CONTENTS" AS "{"?A3."}" +MCDEF "SOMEWHERE" AS "{"?A4."}" +MCDEF "DO WITHS THE WITHS DEED" AS "{"?A5."}" +MCDEF "REPLENISH" AS "{"?A6."}" +MCSET T1 = ?A1. +MCDEF "n" AS "("?T1.")" +MCDEF "N" AS "{"n"}" +?L1.n of CONTENTS SOMEWHERE, + n of CONTENTS. +MCGO L2 UNLESS ?T1. GR 0 +MCSET T1 = T1 - 1 +MCDEF "n" AS "("?T1.")" +DO THE DEED: + n of CONTENTS SOMEWHERE. + +MCGO L1 +?L2.REPLENISH: + N of CONTENTS SOMEWHERE!} +-- +-- (n): Wordify 0 to 99 CONTAINERS +MCDEF "()" AS {MCSET T1=?A1. +MCGO L1 UNLESS T1 GR 99 +?T1. CONTAINERS-- Return the decimal number instead of words. +MCGO L0 +?L1.MCGO L2 IF T1 GR 9 +MCDEF "0units" AS ?T1."Unit" +MCGO L3 +?L2.MCSET T3 = T1 - T1/10*10 +MCDEF "0units" AS ?T3."unit" +MCSET T1 = T1 / 10 +MCDEF "0tens" AS ?T1."Ten" +0tens?L3.0units CONTAINERS} +-- Exceptions: +MCDEF "(WITH 0 WITH)" AS {"No more" CONTAINERS} +MCDEF "(WITH 1 WITH)" AS {"One more" CONTAINER} +MCDEF "(WITH 11 WITH)" AS {"Eleven" CONTAINERS} +MCDEF "(WITH 12 WITH)" AS {"Twelve" CONTAINERS} +MCDEF "(WITH 13 WITH)" AS {"Thirteen" CONTAINERS} +MCDEF "(WITH 14 WITH)" AS {"Fourteen" CONTAINERS} +MCDEF "(WITH 15 WITH)" AS {"Fifteen" CONTAINERS} +MCDEF "(WITH 16 WITH)" AS {"Sixteen" CONTAINERS} +MCDEF "(WITH 17 WITH)" AS {"Seventeen" CONTAINERS} +MCDEF "(WITH 18 WITH)" AS {"Eighteen" CONTAINERS} +MCDEF "(WITH 19 WITH)" AS {"Nineteen" CONTAINERS} +-- Regular cases: +MCDEF "2Unit" AS {"Two"} +MCDEF "3Unit" AS {"Three"} +MCDEF "4Unit" AS {"Four"} +MCDEF "5Unit" AS {"Five"} +MCDEF "6Unit" AS {"Six"} +MCDEF "7Unit" AS {"Seven"} +MCDEF "8Unit" AS {"Eight"} +MCDEF "9Unit" AS {"Nine"} +MCDEF "0unit" AS +MCDEF "1unit" AS {" one"} +MCDEF "2unit" AS {" two"} +MCDEF "3unit" AS {" three"} +MCDEF "4unit" AS {" four"} +MCDEF "5unit" AS {" five"} +MCDEF "6unit" AS {" six"} +MCDEF "7unit" AS {" seven"} +MCDEF "8unit" AS {" eight"} +MCDEF "9unit" AS {" nine"} +MCDEF "1Ten" AS {"Ten"} +MCDEF "2Ten" AS {"Twenty"} +MCDEF "3Ten" AS {"Thirty"} +MCDEF "4Ten" AS {"Forty"} +MCDEF "5Ten" AS {"Fifty"} +MCDEF "6Ten" AS {"Sixty"} +MCDEF "7Ten" AS {"Seventy"} +MCDEF "8Ten" AS {"Eighty"} +MCDEF "9Ten" AS {"Ninety"} +-- +-- The specified song: +Sing 99 bottles of beer on the wall: Take one down, pass it around! -- +Go to the store and buy some more. +-- +-- +-- Try uncommenting the next two lines: +-- Sing 7 flasks of Armagnac on the table: Take a swig, throw it down! +-- Emilie vists, she brings some more. diff --git a/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-4.ml b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-4.ml new file mode 100644 index 0000000000..ba942659f6 --- /dev/null +++ b/Task/99-Bottles-of-Beer/ML-I/99-bottles-of-beer-4.ml @@ -0,0 +1,22 @@ +Ninety nine bottles of beer on the wall, + Ninety nine bottles of beer. +Take one down, pass it around: + Ninety eight bottles of beer on the wall. + +Ninety eight bottles of beer on the wall, + Ninety eight bottles of beer. +Take one down, pass it around: + Ninety seven bottles of beer on the wall. + + ... + + +One more bottle of beer on the wall, + One more bottle of beer. +Take one down, pass it around: + No more 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: + Ninety nine bottles of beer on the wall! diff --git a/Task/99-Bottles-of-Beer/MOO/99-bottles-of-beer.moo b/Task/99-Bottles-of-Beer/MOO/99-bottles-of-beer.moo new file mode 100644 index 0000000000..a0ee8656a1 --- /dev/null +++ b/Task/99-Bottles-of-Beer/MOO/99-bottles-of-beer.moo @@ -0,0 +1,9 @@ +bottles = 99; +while (bottles > 0) + unit = (bottles == 1 ? "bottle" | "bottles"); + player:tell(bottles, " ", unit, " of beer on the wall."); + player:tell(bottles, " ", unit, " of beer."); + player:tell("Take one down, pass it around."); + bottles = bottles - 1; +endwhile +player:tell("0 bottles of beer on the wall."); diff --git a/Task/99-Bottles-of-Beer/MPIF90/99-bottles-of-beer.mpif90 b/Task/99-Bottles-of-Beer/MPIF90/99-bottles-of-beer.mpif90 new file mode 100644 index 0000000000..7037ec367a --- /dev/null +++ b/Task/99-Bottles-of-Beer/MPIF90/99-bottles-of-beer.mpif90 @@ -0,0 +1,28 @@ +program bottlesMPI + + implicit none + + integer :: ierr,rank,nproc + + character(len=*), parameter :: bwall = " on the wall", & + bottles = "bottles of beer", & + bottle = "bottle of beer", & + take = "Take one down, pass it around", & + form = "(I0, ' ', A)" + + call mpi_init(ierr) + call mpi_comm_size(MPI_COMM_WORLD,nproc, ierr) + call mpi_comm_rank(MPI_COMM_WORLD,rank,ierr) + + if ( rank /= 1 ) then + write (*,form) rank, bottles // bwall + if ( rank > 0 ) write (*,form) rank, bottles + else + write (*,form) rank, bottle // bwall + write (*,form) rank, bottle + end if + if ( rank > 0 ) write (*,*) take + + call mpi_finalize(ierr) + +end program bottlesMPI diff --git a/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-1.mumps b/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-1.mumps new file mode 100644 index 0000000000..3ee62e18de --- /dev/null +++ b/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-1.mumps @@ -0,0 +1,8 @@ +beer(n) If n<1 Write "No bottles of beer on the wall... " Quit + Write !!,n," bottle",$Select(n=1:"",1:"s")," of beer on the wall." + Write !,n," bottle",$Select(n=1:"",1:"s")," of beer." + Write !,"Take one down, pass it around." + Do beer(n-1) + Quit + +Do beer(99) diff --git a/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-2.mumps b/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-2.mumps new file mode 100644 index 0000000000..875011fcee --- /dev/null +++ b/Task/99-Bottles-of-Beer/MUMPS/99-bottles-of-beer-2.mumps @@ -0,0 +1,7 @@ +beer(n) If n<1 Write "No bottles of beer on the wall... " Quit + Write !!,n," bottle",$Select(n=1:"",1:"s")," of beer on the wall." + Write !,n," bottle",$Select(n=1:"",1:"s")," of beer." + Write !,"Take one down, pass it around." + Quit + +For ii=99:-1:0 Do beer(ii) diff --git a/Task/99-Bottles-of-Beer/Mathematica/99-bottles-of-beer.mathematica b/Task/99-Bottles-of-Beer/Mathematica/99-bottles-of-beer.mathematica new file mode 100644 index 0000000000..b26b8489d3 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Mathematica/99-bottles-of-beer.mathematica @@ -0,0 +1,10 @@ +Bottle[n_] := ToString[n] <> If[n==1," bottle"," bottles"] <> " of beer" + +BottleSong[n_] := Speak[ + Bottle[n] <> " on the wall," <> + Bottle[n] <> + ", take one down, pass it around," <> + Bottle[n-1] <> " on the wall." +] + +BottleSong /@ Range[99,1,-1] diff --git a/Task/99-Bottles-of-Beer/Maxima/99-bottles-of-beer.maxima b/Task/99-Bottles-of-Beer/Maxima/99-bottles-of-beer.maxima new file mode 100644 index 0000000000..55fd2e7628 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Maxima/99-bottles-of-beer.maxima @@ -0,0 +1,13 @@ +bottle(n) := if n = 1 then "bottle" else "bottles"$ + +bottles(n) := block( + for i from n thru 1 step -1 do ( + printf(true, "~d ~a of beer on the wall~%", i, bottle(i)), + printf(true, "~d ~a of beer~%", i, bottle(i)), + printf(true, "Take one down, pass it around~%"), + printf(true, "~d ~a of beer on the wall~%", i - 1, bottle(i - 1)), + disp("") + ) +)$ + +bottles(99); diff --git a/Task/99-Bottles-of-Beer/Mirah/99-bottles-of-beer.mirah b/Task/99-Bottles-of-Beer/Mirah/99-bottles-of-beer.mirah new file mode 100644 index 0000000000..d6dc5973d5 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Mirah/99-bottles-of-beer.mirah @@ -0,0 +1,13 @@ +plural = 's' +99.downto(1) do |i| + puts "#{i} bottle#{plural} of beer on the wall," + puts "#{i} bottle#{plural} of beer" + puts "Take one down, pass it around!" + plural = '' if i - 1 == 1 + if i > 1 + puts "#{i-1} bottle#{plural} of beer on the wall!" + puts + else + puts "No more bottles of beer on the wall!" + end +end diff --git a/Task/99-Bottles-of-Beer/Modula-2/99-bottles-of-beer.mod2 b/Task/99-Bottles-of-Beer/Modula-2/99-bottles-of-beer.mod2 new file mode 100644 index 0000000000..8ecf1f9978 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Modula-2/99-bottles-of-beer.mod2 @@ -0,0 +1,23 @@ +MODULE b99; +IMPORT InOut; + +VAR nr : CARDINAL; + +BEGIN + nr := 99; + REPEAT + InOut.WriteCard (nr, 4); + InOut.WriteString (" bottles of beer on the wall"); + InOut.WriteLn; + InOut.WriteCard (nr, 4); + InOut.WriteString (" bottles of beer"); + InOut.WriteLn; + InOut.WriteString ("Take one down, pass it around"); + InOut.WriteLn; + DEC (nr); + InOut.WriteCard (nr, 4); + InOut.WriteString (" bottles of beer on the wall"); + InOut.WriteLn; + InOut.WriteLn + UNTIL nr = 0 +END b99. diff --git a/Task/99-Bottles-of-Beer/Modula-3/99-bottles-of-beer.mod3 b/Task/99-Bottles-of-Beer/Modula-3/99-bottles-of-beer.mod3 new file mode 100644 index 0000000000..dd00dd9e15 --- /dev/null +++ b/Task/99-Bottles-of-Beer/Modula-3/99-bottles-of-beer.mod3 @@ -0,0 +1,13 @@ +MODULE Bottles EXPORTS Main; + +IMPORT IO, Fmt; + +BEGIN + FOR i := 99 TO 1 BY -1 DO + IO.Put(Fmt.Int(i) & " bottles of beer on the wall\n"); + IO.Put(Fmt.Int(i) & " bottles of beer\n"); + IO.Put("Take one down, pass it around\n"); + IO.Put(Fmt.Int(i - 1) & " bottles of beer on the wall\n"); + IO.Put("\n"); + END; +END Bottles. diff --git a/Task/A+B/FALSE/a+b.false b/Task/A+B/FALSE/a+b.false new file mode 100644 index 0000000000..f47f790a31 --- /dev/null +++ b/Task/A+B/FALSE/a+b.false @@ -0,0 +1,2 @@ +[0[^$$'9>'0@>|~]['0-\10*+]#%]n: {read an integer} +n;!n;!+. diff --git a/Task/A+B/Factor/a+b.factor b/Task/A+B/Factor/a+b.factor new file mode 100644 index 0000000000..35bc4bf7e0 --- /dev/null +++ b/Task/A+B/Factor/a+b.factor @@ -0,0 +1,5 @@ +USING: math.parser splitting ; +: a+b ( -- ) + readln " " split1 + [ string>number ] bi@ + + number>string print ; diff --git a/Task/A+B/Fantom/a+b.fantom b/Task/A+B/Fantom/a+b.fantom new file mode 100644 index 0000000000..1f65e4e3d9 --- /dev/null +++ b/Task/A+B/Fantom/a+b.fantom @@ -0,0 +1,11 @@ +class APlusB +{ + public static Void main () + { + echo ("Enter two numbers: ") + Str input := Env.cur.in.readLine + Int sum := 0 + input.split.each |n| { sum += n.toInt } + echo (sum) + } +} diff --git a/Task/A+B/Fish/a+b.fish b/Task/A+B/Fish/a+b.fish new file mode 100644 index 0000000000..ece040f57b --- /dev/null +++ b/Task/A+B/Fish/a+b.fish @@ -0,0 +1,7 @@ +i:o:"-"=?v1$68*-v +v >~01-0 > +>i:o:" "=?v68*-$a*+ + >~*i:o:"-"=?v1$68*-v +v >~01-0 > +>i:o:d=?v68*-$a*+ + >~*+aonao; diff --git a/Task/A+B/GML/a+b.gml b/Task/A+B/GML/a+b.gml new file mode 100644 index 0000000000..82116589e3 --- /dev/null +++ b/Task/A+B/GML/a+b.gml @@ -0,0 +1,4 @@ +add = argument0 // get the string with the numbers to add +a = real(string_copy(add, 1, string_pos(" ", add))) +b = real(string_copy(add, string_pos(" ", add) + 1, string_length(add) - string_pos(" ", add))) +return(a + b) diff --git a/Task/A+B/GUISS/a+b.guiss b/Task/A+B/GUISS/a+b.guiss new file mode 100644 index 0000000000..cff5d903a8 --- /dev/null +++ b/Task/A+B/GUISS/a+b.guiss @@ -0,0 +1,2 @@ +Start,Programs,Accessories,Calculator,Button:3,Button:[plus], +Button:2,Button:[equals] diff --git a/Task/A+B/Golfscript/a+b.golf b/Task/A+B/Golfscript/a+b.golf new file mode 100644 index 0000000000..f078567a22 --- /dev/null +++ b/Task/A+B/Golfscript/a+b.golf @@ -0,0 +1 @@ +~+ diff --git a/Task/A+B/Gosu/a+b.gosu b/Task/A+B/Gosu/a+b.gosu new file mode 100644 index 0000000000..f2a19e7b68 --- /dev/null +++ b/Task/A+B/Gosu/a+b.gosu @@ -0,0 +1,9 @@ +uses java.io.InputStreamReader +uses java.util.Scanner +uses java.lang.System + +var scanner = new Scanner( new InputStreamReader( System.in ) ) +var a = scanner.nextInt() +var b = scanner.nextInt() + +print( a + b ) diff --git a/Task/A+B/Groovy/a+b.groovy b/Task/A+B/Groovy/a+b.groovy new file mode 100644 index 0000000000..ec80640dcd --- /dev/null +++ b/Task/A+B/Groovy/a+b.groovy @@ -0,0 +1,8 @@ +def abAdder = { + def reader = new Scanner(System.in) + def a = reader.nextInt(); + def b = reader.nextInt(); + assert (-1000..1000).containsAll([a,b]) : "both numbers must be between -1000 and 1000 (inclusive)" + a + b +} +abAdder() diff --git a/Task/A+B/HicEst/a+b.hicest b/Task/A+B/HicEst/a+b.hicest new file mode 100644 index 0000000000..5ffa9a732e --- /dev/null +++ b/Task/A+B/HicEst/a+b.hicest @@ -0,0 +1,2 @@ +DLG(Edit=A, DNum, MIn=-1000, MAx=1000, E=B, DN, MI=-1000, MA=1000) +WRITE(Messagebox, Name) A, B, "Sum = ", A+B diff --git a/Task/A+B/Icon/a+b.icon b/Task/A+B/Icon/a+b.icon new file mode 100644 index 0000000000..de7e1602e3 --- /dev/null +++ b/Task/A+B/Icon/a+b.icon @@ -0,0 +1,8 @@ +procedure main() + numChars := '-'++&digits + read() ? { + A := (tab(upto(numChars)), integer(tab(many(numChars)))) + B := (tab(upto(numChars)), integer(tab(many(numChars)))) + } + write((\A + \B) | "Bad input") +end diff --git a/Task/A+B/J/a+b-1.j b/Task/A+B/J/a+b-1.j new file mode 100644 index 0000000000..982e40107a --- /dev/null +++ b/Task/A+B/J/a+b-1.j @@ -0,0 +1,2 @@ + 2+3 +5 diff --git a/Task/A+B/J/a+b-2.j b/Task/A+B/J/a+b-2.j new file mode 100644 index 0000000000..9410c12167 --- /dev/null +++ b/Task/A+B/J/a+b-2.j @@ -0,0 +1 @@ ++/". (1!:1(3))-.LF diff --git a/Task/A+B/J/a+b-3.j b/Task/A+B/J/a+b-3.j new file mode 100644 index 0000000000..f9bb9096df --- /dev/null +++ b/Task/A+B/J/a+b-3.j @@ -0,0 +1,3 @@ +#!/Applications/j602/bin/jconsole +echo +/". (1!:1(3))-.LF +exit '' diff --git a/Task/A+B/J/a+b-4.j b/Task/A+B/J/a+b-4.j new file mode 100644 index 0000000000..7ed718eca0 --- /dev/null +++ b/Task/A+B/J/a+b-4.j @@ -0,0 +1,2 @@ +echo 2 3 | ./a+b.ijs +5 diff --git a/Task/A+B/Joy/a+b-1.joy b/Task/A+B/Joy/a+b-1.joy new file mode 100644 index 0000000000..2ae07b6dc7 --- /dev/null +++ b/Task/A+B/Joy/a+b-1.joy @@ -0,0 +1 @@ +get get +. diff --git a/Task/A+B/Joy/a+b-2.joy b/Task/A+B/Joy/a+b-2.joy new file mode 100644 index 0000000000..8f156ef457 --- /dev/null +++ b/Task/A+B/Joy/a+b-2.joy @@ -0,0 +1,3 @@ +"input.txt" include +"output.txt" "w" fopen +get get + fput pop quit. diff --git a/Task/A+B/Julia/a+b-1.julia b/Task/A+B/Julia/a+b-1.julia new file mode 100644 index 0000000000..b0066208b5 --- /dev/null +++ b/Task/A+B/Julia/a+b-1.julia @@ -0,0 +1,6 @@ +macro add(a,b) + return a + b +end + +julia> @add 1 2 +3 diff --git a/Task/A+B/Julia/a+b-2.julia b/Task/A+B/Julia/a+b-2.julia new file mode 100644 index 0000000000..9ccc30098d --- /dev/null +++ b/Task/A+B/Julia/a+b-2.julia @@ -0,0 +1,6 @@ +#aplusb.jl contents +x = sum(ARGS) +print(x) +#run at command prompt +$ julia aplusb.jl 1 2 +$ 3 diff --git a/Task/A+B/Kite/a+b-1.kite b/Task/A+B/Kite/a+b-1.kite new file mode 100644 index 0000000000..a3a3e3d14d --- /dev/null +++ b/Task/A+B/Kite/a+b-1.kite @@ -0,0 +1,13 @@ +#!/usr/bin/kite + +import "System.file"; + +in = System.file.stdin; +line = in|readline; +while(not (line is null)) [ + arry = line|split(" "); + result = (arry[0])|int + (arry[1])|int; + result|print; + + line = in|readline; +]; diff --git a/Task/A+B/Kite/a+b-2.kite b/Task/A+B/Kite/a+b-2.kite new file mode 100644 index 0000000000..ce039f95fb --- /dev/null +++ b/Task/A+B/Kite/a+b-2.kite @@ -0,0 +1,5 @@ +$ kite a_plus_b.kt < +MCINS %. +MCDEF SL SPACES NL AS +MCSKIP SL WITH * +MCSET S1=1 +*MCSET S10=2 diff --git a/Task/A+B/MUMPS/a+b.mumps b/Task/A+B/MUMPS/a+b.mumps new file mode 100644 index 0000000000..d5dc79807c --- /dev/null +++ b/Task/A+B/MUMPS/a+b.mumps @@ -0,0 +1,8 @@ +ANB + NEW A,B,T,S + READ !,"Input two integers between -1000 and 1000, separated by a space: ",S + SET A=$PIECE(S," ",1),B=$PIECE(S," ",2) + SET T=(A>=-1000)&(A<=1000)&(B>=-1000)&(B<=1000)&(A\1=A)&(B\1=B) + IF T WRITE !,(A+B) + IF 'T WRITE !,"Bad input" + QUIT diff --git a/Task/A+B/Maple/a+b.maple b/Task/A+B/Maple/a+b.maple new file mode 100644 index 0000000000..f4471f7a31 --- /dev/null +++ b/Task/A+B/Maple/a+b.maple @@ -0,0 +1,3 @@ +> convert( scanf( "%d %d" ), '`+`' ); +23 34 + 57 diff --git a/Task/A+B/Mathematica/a+b.mathematica b/Task/A+B/Mathematica/a+b.mathematica new file mode 100644 index 0000000000..bd0a8854c0 --- /dev/null +++ b/Task/A+B/Mathematica/a+b.mathematica @@ -0,0 +1 @@ +Input[] + Input[] diff --git a/Task/A+B/Mercury/a+b.mercury b/Task/A+B/Mercury/a+b.mercury new file mode 100644 index 0000000000..bb30b0e4fd --- /dev/null +++ b/Task/A+B/Mercury/a+b.mercury @@ -0,0 +1,20 @@ +:- module a_plus_b. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + io.read_line_as_string(Result, !IO), + ( if + Result = ok(Line), + [AStr, BStr] = string.words(Line), + string.to_int(AStr, A), string.to_int(BStr, B) + then + io.format("%d\n", [i(A + B)], !IO) + else + true + ). diff --git a/Task/A+B/Modula-2/a+b.mod2 b/Task/A+B/Modula-2/a+b.mod2 new file mode 100644 index 0000000000..b08e3de791 --- /dev/null +++ b/Task/A+B/Modula-2/a+b.mod2 @@ -0,0 +1,12 @@ +MODULE ab; + +IMPORT InOut; + +VAR A, B : INTEGER; + +BEGIN + InOut.ReadInt (A); + InOut.ReadInt (B); + InOut.WriteInt (A + B, 8); + InOut.WriteLn +END ab. diff --git a/Task/Abstract-type/Fantom/abstract-type.fantom b/Task/Abstract-type/Fantom/abstract-type.fantom new file mode 100644 index 0000000000..11518b5048 --- /dev/null +++ b/Task/Abstract-type/Fantom/abstract-type.fantom @@ -0,0 +1,28 @@ +abstract class X +{ + Void method1 () + { + echo ("Method 1 in X") + } + + abstract Void method2 () +} + +class Y : X +{ + // Y must override the abstract method in X + override Void method2 () + { + echo ("Method 2 in Y") + } +} + +class Main +{ + public static Void main () + { + y := Y() + y.method1 + y.method2 + } +} diff --git a/Task/Abstract-type/Genyris/abstract-type-1.genyris b/Task/Abstract-type/Genyris/abstract-type-1.genyris new file mode 100644 index 0000000000..047661716b --- /dev/null +++ b/Task/Abstract-type/Genyris/abstract-type-1.genyris @@ -0,0 +1,4 @@ +class AbstractStack() + def .valid?(object) nil + +tag AbstractStack some-object # always fails diff --git a/Task/Abstract-type/Genyris/abstract-type-2.genyris b/Task/Abstract-type/Genyris/abstract-type-2.genyris new file mode 100644 index 0000000000..06566840ec --- /dev/null +++ b/Task/Abstract-type/Genyris/abstract-type-2.genyris @@ -0,0 +1,8 @@ +class StackInterface() + def .valid?(object) + object + and + bound? .enstack + is-instance? .enstack Closure + bound? .destack + is-instance? .destack Closure diff --git a/Task/Abstract-type/Genyris/abstract-type-3.genyris b/Task/Abstract-type/Genyris/abstract-type-3.genyris new file mode 100644 index 0000000000..9de119bb1d --- /dev/null +++ b/Task/Abstract-type/Genyris/abstract-type-3.genyris @@ -0,0 +1,9 @@ +class XYZstack(Object) + def .init() + var .items () + def .enstack(object) + setq .items (cons object .items) + def .destack() + var tmp (car .items) + setq .items (cdr .items) + tmp diff --git a/Task/Abstract-type/Genyris/abstract-type-4.genyris b/Task/Abstract-type/Genyris/abstract-type-4.genyris new file mode 100644 index 0000000000..959d8fdd52 --- /dev/null +++ b/Task/Abstract-type/Genyris/abstract-type-4.genyris @@ -0,0 +1 @@ +tag StackInterface (XYZstack(.new)) diff --git a/Task/Abstract-type/Groovy/abstract-type-1.groovy b/Task/Abstract-type/Groovy/abstract-type-1.groovy new file mode 100644 index 0000000000..cc6e77c512 --- /dev/null +++ b/Task/Abstract-type/Groovy/abstract-type-1.groovy @@ -0,0 +1,5 @@ +public interface Interface { + int method1(double value) + int method2(String name) + int add(int a, int b) +} diff --git a/Task/Abstract-type/Groovy/abstract-type-2.groovy b/Task/Abstract-type/Groovy/abstract-type-2.groovy new file mode 100644 index 0000000000..4e0a4fc8cd --- /dev/null +++ b/Task/Abstract-type/Groovy/abstract-type-2.groovy @@ -0,0 +1,5 @@ +public abstract class Abstract1 { + abstract public int methodA(Date value) + abstract protected int methodB(String name) + int add(int a, int b) { a + b } +} diff --git a/Task/Abstract-type/Groovy/abstract-type-3.groovy b/Task/Abstract-type/Groovy/abstract-type-3.groovy new file mode 100644 index 0000000000..ad0f66c283 --- /dev/null +++ b/Task/Abstract-type/Groovy/abstract-type-3.groovy @@ -0,0 +1,3 @@ +public abstract class Abstract2 implements Interface { + int add(int a, int b) { a + b } +} diff --git a/Task/Abstract-type/Groovy/abstract-type-4.groovy b/Task/Abstract-type/Groovy/abstract-type-4.groovy new file mode 100644 index 0000000000..604ed7e12c --- /dev/null +++ b/Task/Abstract-type/Groovy/abstract-type-4.groovy @@ -0,0 +1,15 @@ +public class Concrete1 implements Interface { + public int method1(double value) { value as int } + public int method2(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() } + public int add(int a, int b) { a + b } +} + +public class Concrete2 extends Abstract1 { + public int methodA(Date value) { value.toCalendar()[Calendar.DAY_OF_YEAR] } + protected int methodB(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() } +} + +public class Concrete3 extends Abstract2 { + public int method1(double value) { value as int } + public int method2(String name) { (! name) ? 0 : name.toList().collect { it as char }.sum() } +} diff --git a/Task/Abstract-type/Groovy/abstract-type-5.groovy b/Task/Abstract-type/Groovy/abstract-type-5.groovy new file mode 100644 index 0000000000..4d76fa907b --- /dev/null +++ b/Task/Abstract-type/Groovy/abstract-type-5.groovy @@ -0,0 +1,12 @@ +def c1 = new Concrete1() +assert c1 instanceof Interface +println (new Concrete1().method2("Superman")) + +def c2 = new Concrete2() +assert c2 instanceof Abstract1 +println (new Concrete2().methodB("Spiderman")) + +def c3 = new Concrete3() +assert c3 instanceof Interface +assert c3 instanceof Abstract2 +println (new Concrete3().method2("Hellboy")) diff --git a/Task/Abstract-type/Julia/abstract-type.julia b/Task/Abstract-type/Julia/abstract-type.julia new file mode 100644 index 0000000000..a27849a327 --- /dev/null +++ b/Task/Abstract-type/Julia/abstract-type.julia @@ -0,0 +1,2 @@ +abstract «name» +abstract «name» <: «supertype» diff --git a/Task/Abstract-type/Logtalk/abstract-type.logtalk b/Task/Abstract-type/Logtalk/abstract-type.logtalk new file mode 100644 index 0000000000..37cffb3f3c --- /dev/null +++ b/Task/Abstract-type/Logtalk/abstract-type.logtalk @@ -0,0 +1,9 @@ +:- protocol(datep). + + :- public(today/3). + :- public(leap_year/1). + :- public(name_of_day/3). + :- public(name_of_month/3). + :- public(days_in_month/3). + +:- end_protocol. diff --git a/Task/Accumulator-factory/Factor/accumulator-factory.factor b/Task/Accumulator-factory/Factor/accumulator-factory.factor new file mode 100644 index 0000000000..dbe12b3cda --- /dev/null +++ b/Task/Accumulator-factory/Factor/accumulator-factory.factor @@ -0,0 +1,6 @@ +:: accumulator ( n! -- quot ) [ n + dup n! ] ; + +1 accumulator +[ 5 swap call drop ] +[ drop 3 accumulator drop ] +[ 2.3 swap call ] tri . diff --git a/Task/Accumulator-factory/Fantom/accumulator-factory.fantom b/Task/Accumulator-factory/Fantom/accumulator-factory.fantom new file mode 100644 index 0000000000..a64483585e --- /dev/null +++ b/Task/Accumulator-factory/Fantom/accumulator-factory.fantom @@ -0,0 +1,50 @@ +class AccumulatorFactory +{ + static |Num -> Num| accumulator (Num sum) + { + return |Num a -> Num| + { // switch on type of sum + if (sum is Int) + { // and then type of a + if (a is Int) + return sum = sum->plus(a) + else if (a is Float) + return sum = sum->plusFloat(a) + else + return sum = sum->plusDecimal(a) + } + else if (sum is Float) + { + if (a is Int) + return sum = sum->plusInt(a) + else if (a is Float) + return sum = sum->plus(a) + else + return sum = sum->plusDecimal(a) + } + else // if (sum is Decimal) + { + if (a is Int) + return sum = sum->plusInt(a) + else if (a is Float) + return sum = sum->plusFloat(a) + else + return sum = sum->plus(a) + } + } + } + + public static Void main () + { + x := accumulator (3.1) + y := accumulator (3f) + echo (x(5)) // the Decimal sum combines with an Int + echo (x(2)) + echo (y(5.1)) // the Float sum combines with a Decimal + + x = accumulator (1) + x (5) + accumulator (3) + echo (x(2.3)) // the Int sum is now a Decimal + } +} diff --git a/Task/Accumulator-factory/GAP/accumulator-factory.gap b/Task/Accumulator-factory/GAP/accumulator-factory.gap new file mode 100644 index 0000000000..777986bdd7 --- /dev/null +++ b/Task/Accumulator-factory/GAP/accumulator-factory.gap @@ -0,0 +1,29 @@ +accu := function(n) + local f, v; + v := n; + f := function(a) + v := v + a; + return v; + end; + return f; +end; + +a := accu(0); +# function( a ) ... end +b := accu(100); +# function( a ) ... end +a(6); +# 6 +b(6); +# 106 +a(1); +# 7 +b(1); +# 107 +# These functions also accept other types, as long as addition is meaningful +b(1/FLOAT_INT(3)) +# 107.333 +a(2/3); +# 23/3 +a([1, 2, 3]); +# [ 26/3, 29/3, 32/3 ] diff --git a/Task/Accumulator-factory/Groovy/accumulator-factory-1.groovy b/Task/Accumulator-factory/Groovy/accumulator-factory-1.groovy new file mode 100644 index 0000000000..29b478b753 --- /dev/null +++ b/Task/Accumulator-factory/Groovy/accumulator-factory-1.groovy @@ -0,0 +1,4 @@ +def accumulator = { Number n -> + def value = n; + { it = 0 -> value += it} +} diff --git a/Task/Accumulator-factory/Groovy/accumulator-factory-2.groovy b/Task/Accumulator-factory/Groovy/accumulator-factory-2.groovy new file mode 100644 index 0000000000..43d87d1c1a --- /dev/null +++ b/Task/Accumulator-factory/Groovy/accumulator-factory-2.groovy @@ -0,0 +1,23 @@ +def x = accumulator(1) + +println x() +assert x() instanceof Integer + +println x(5) +assert x() instanceof Integer + +def y = accumulator(3) +println y() +assert y() instanceof Integer + +println x(2.3) +assert x() instanceof BigDecimal + +println y(10) +assert y() instanceof Integer + +println y(200L) +assert y() instanceof Long + +println y(2.25D) +assert y() instanceof Double diff --git a/Task/Accumulator-factory/Icon/accumulator-factory.icon b/Task/Accumulator-factory/Icon/accumulator-factory.icon new file mode 100644 index 0000000000..3d84b24a62 --- /dev/null +++ b/Task/Accumulator-factory/Icon/accumulator-factory.icon @@ -0,0 +1,17 @@ +procedure main() + a := genAcc(3) + b := genAcc(5) + + write(" " ,center("a",5), " ", center("b", 5)) + write("genAcc: ", right(a(4),5), " ", right(b(4), 5)) + write("genAcc: ", right(a(2),5), " ", right(b(3),5)) + write("genAcc: ", right(a(4.5),5)," ", right(b(1.3),5)) +end + +procedure genAcc(n) # The generator factory + return makeProc { while i := (n@&source)[1] do n +:= i } +end + +procedure makeProc(A) # A Programmer-Defined Control Operation + return (@A[1],A[1]) +end diff --git a/Task/Accumulator-factory/J/accumulator-factory-1.j b/Task/Accumulator-factory/J/accumulator-factory-1.j new file mode 100644 index 0000000000..1195ed02c6 --- /dev/null +++ b/Task/Accumulator-factory/J/accumulator-factory-1.j @@ -0,0 +1,5 @@ +oleg=:1 :0 + a=. cocreate'' + n__a=: m + a&(4 : 'n__x=: n__x + y') +) diff --git a/Task/Accumulator-factory/J/accumulator-factory-2.j b/Task/Accumulator-factory/J/accumulator-factory-2.j new file mode 100644 index 0000000000..ec64a1e05d --- /dev/null +++ b/Task/Accumulator-factory/J/accumulator-factory-2.j @@ -0,0 +1,7 @@ + F=: 10 oleg + F 11 +21 + F 12 +33 + F 11 +44 diff --git a/Task/Accumulator-factory/Julia/accumulator-factory.julia b/Task/Accumulator-factory/Julia/accumulator-factory.julia new file mode 100644 index 0000000000..798534f6e5 --- /dev/null +++ b/Task/Accumulator-factory/Julia/accumulator-factory.julia @@ -0,0 +1,20 @@ +julia> function accumulator(i) + function f(n) + i += n + return i + end + return f +end +# method added to generic function accumulator + +julia> x = accumulator(1) +# methods for generic function f +f(Any,) at none:3 + +julia> x(5) +6 + +julia> print(accumulator(3)) +f +julia> print(x(2.3)) +8.3 diff --git a/Task/Accumulator-factory/Maple/accumulator-factory-1.maple b/Task/Accumulator-factory/Maple/accumulator-factory-1.maple new file mode 100644 index 0000000000..d76dd8f0b4 --- /dev/null +++ b/Task/Accumulator-factory/Maple/accumulator-factory-1.maple @@ -0,0 +1,4 @@ +AccumulatorFactory := proc( initial := 0 ) + local total := initial; + proc( val := 1 ) total := total + val end +end proc: diff --git a/Task/Accumulator-factory/Maple/accumulator-factory-2.maple b/Task/Accumulator-factory/Maple/accumulator-factory-2.maple new file mode 100644 index 0000000000..e742810f4b --- /dev/null +++ b/Task/Accumulator-factory/Maple/accumulator-factory-2.maple @@ -0,0 +1,16 @@ +> acc := AccumulatorFactory( 1 ): +> acc( 5 ); + 6 + +> AccumulatorFactory( 3 ): +> acc( 2.3 ); + 8.3 + +> acc(); # use the default increment of 1 + 9.3 + +> acc( 3 - 4 * I ); # also handles complex numbers + 12.3 - 4. I + +> acc( I ); # add the imaginary unit + 12.3 - 3. I diff --git a/Task/Accumulator-factory/Mathematica/accumulator-factory.mathematica b/Task/Accumulator-factory/Mathematica/accumulator-factory.mathematica new file mode 100644 index 0000000000..b9a6099435 --- /dev/null +++ b/Task/Accumulator-factory/Mathematica/accumulator-factory.mathematica @@ -0,0 +1,8 @@ +accFactory[initial_] := + Module[{total = initial}, + Function[x, total += x] + ] +x=accFactory[1]; +x[5.0]; +accFactory[3]; +x[2.3] diff --git a/Task/Ackermann-function/FALSE/ackermann-function.false b/Task/Ackermann-function/FALSE/ackermann-function.false new file mode 100644 index 0000000000..96ab6675fe --- /dev/null +++ b/Task/Ackermann-function/FALSE/ackermann-function.false @@ -0,0 +1,12 @@ +[$$[% + \$$[% + 1-\$@@a;! { i j -> A(i-1, A(i, j-1)) } + 1]?0=[ + %1 { i 0 -> A(i-1, 1) } + ]? + \1-a;! +1]?0=[ + %1+ { 0 j -> j+1 } + ]?]a: { j i } + +3 3 a;! . { 61 } diff --git a/Task/Ackermann-function/Factor/ackermann-function.factor b/Task/Ackermann-function/Factor/ackermann-function.factor new file mode 100644 index 0000000000..3564f04b58 --- /dev/null +++ b/Task/Ackermann-function/Factor/ackermann-function.factor @@ -0,0 +1,9 @@ +USING: kernel math locals combinators ; +IN: ackermann + +:: ackermann ( m n -- u ) + { + { [ m 0 = ] [ n 1 + ] } + { [ n 0 = ] [ m 1 - 1 ackermann ] } + [ m 1 - m n 1 - ackermann ackermann ] + } cond ; diff --git a/Task/Ackermann-function/Falcon/ackermann-function.falcon b/Task/Ackermann-function/Falcon/ackermann-function.falcon new file mode 100644 index 0000000000..d1e3e9dc1e --- /dev/null +++ b/Task/Ackermann-function/Falcon/ackermann-function.falcon @@ -0,0 +1,12 @@ +function ackermann( m, n ) + if m == 0: return( n + 1 ) + if n == 0: return( ackermann( m - 1, 1 ) ) + return( ackermann( m - 1, ackermann( m, n - 1 ) ) ) +end + +for M in [ 0:4 ] + for N in [ 0:7 ] + >> ackermann( M, N ), " " + end + > +end diff --git a/Task/Ackermann-function/Fantom/ackermann-function.fantom b/Task/Ackermann-function/Fantom/ackermann-function.fantom new file mode 100644 index 0000000000..2e9eaad9dd --- /dev/null +++ b/Task/Ackermann-function/Fantom/ackermann-function.fantom @@ -0,0 +1,24 @@ +class Main +{ + // assuming m,n are positive + static Int ackermann (Int m, Int n) + { + if (m == 0) + return n + 1 + else if (n == 0) + return ackermann (m - 1, 1) + else + return ackermann (m - 1, ackermann (m, n - 1)) + } + + public static Void main () + { + (0..3).each |m| + { + (0..6).each |n| + { + echo ("Ackerman($m, $n) = ${ackermann(m, n)}") + } + } + } +} diff --git a/Task/Ackermann-function/GAP/ackermann-function.gap b/Task/Ackermann-function/GAP/ackermann-function.gap new file mode 100644 index 0000000000..536c02e077 --- /dev/null +++ b/Task/Ackermann-function/GAP/ackermann-function.gap @@ -0,0 +1,11 @@ +ack := function(m, n) + if m = 0 then + return n + 1; + elif (m > 0) and (n = 0) then + return ack(m - 1, 1); + elif (m > 0) and (n > 0) then + return ack(m - 1, ack(m, n - 1)); + else + return fail; + fi; +end; diff --git a/Task/Ackermann-function/GML/ackermann-function.gml b/Task/Ackermann-function/GML/ackermann-function.gml new file mode 100644 index 0000000000..770d4deed2 --- /dev/null +++ b/Task/Ackermann-function/GML/ackermann-function.gml @@ -0,0 +1,8 @@ +m=argument0 +n=argument1 +if(m=0) + return (n+1) +else if(n=0) + return (ackermann(m-1,1,1)) +else + return (ackermann(m-1,ackermann(m,n-1,2),1)) diff --git a/Task/Ackermann-function/Genyris/ackermann-function.genyris b/Task/Ackermann-function/Genyris/ackermann-function.genyris new file mode 100644 index 0000000000..7b9335771e --- /dev/null +++ b/Task/Ackermann-function/Genyris/ackermann-function.genyris @@ -0,0 +1,9 @@ +def A (m n) + cond + (equal? m 0) + + n 1 + (equal? n 0) + A (- m 1) 1 + else + A (- m 1) + A m (- n 1) diff --git a/Task/Ackermann-function/Golfscript/ackermann-function.golf b/Task/Ackermann-function/Golfscript/ackermann-function.golf new file mode 100644 index 0000000000..a135e95105 --- /dev/null +++ b/Task/Ackermann-function/Golfscript/ackermann-function.golf @@ -0,0 +1,8 @@ +{ + :_n; :_m; + _m 0= {_n 1+} + {_n 0= {_m 1- 1 ack} + {_m 1- _m _n 1- ack ack} + if} + if +}:ack; diff --git a/Task/Ackermann-function/Groovy/ackermann-function-1.groovy b/Task/Ackermann-function/Groovy/ackermann-function-1.groovy new file mode 100644 index 0000000000..e9682b58fc --- /dev/null +++ b/Task/Ackermann-function/Groovy/ackermann-function-1.groovy @@ -0,0 +1,4 @@ +def ack ( m, n ) { + assert m >= 0 && n >= 0 : 'both arguments must be non-negative' + m == 0 ? n + 1 : n == 0 ? ack(m-1, 1) : ack(m-1, ack(m, n-1)) +} diff --git a/Task/Ackermann-function/Groovy/ackermann-function-2.groovy b/Task/Ackermann-function/Groovy/ackermann-function-2.groovy new file mode 100644 index 0000000000..6fa705f7b9 --- /dev/null +++ b/Task/Ackermann-function/Groovy/ackermann-function-2.groovy @@ -0,0 +1,2 @@ +def ackMatrix = (0..3).collect { m -> (0..8).collect { n -> ack(m, n) } } +ackMatrix.each { it.each { elt -> printf "%7d", elt }; println() } diff --git a/Task/Ackermann-function/Haxe/ackermann-function.haxe b/Task/Ackermann-function/Haxe/ackermann-function.haxe new file mode 100644 index 0000000000..e95d735efc --- /dev/null +++ b/Task/Ackermann-function/Haxe/ackermann-function.haxe @@ -0,0 +1,20 @@ +class RosettaDemo +{ + static public function main() + { + Sys.print(ackermann(3, 4)); + } + + static function ackermann(m : Int, n : Int) + { + if (m == 0) + { + return n + 1; + } + else if (n == 0) + { + return ackermann(m-1, 1); + } + return ackermann(m-1, ackermann(m, n-1)); + } +} diff --git a/Task/Ackermann-function/Icon/ackermann-function.icon b/Task/Ackermann-function/Icon/ackermann-function.icon new file mode 100644 index 0000000000..a2eba7a8a9 --- /dev/null +++ b/Task/Ackermann-function/Icon/ackermann-function.icon @@ -0,0 +1,25 @@ +procedure acker(i, j) + static memory + + initial { + memory := table() + every memory[0 to 100] := table() + } + + if i = 0 then return j + 1 + + if j = 0 then /memory[i][j] := acker(i - 1, 1) + else /memory[i][j] := acker(i - 1, acker(i, j - 1)) + + return memory[i][j] + +end + +procedure main() + every m := 0 to 3 do { + every n := 0 to 8 do { + writes(acker(m, n) || " ") + } + write() + } +end diff --git a/Task/Ackermann-function/Ioke/ackermann-function.ioke b/Task/Ackermann-function/Ioke/ackermann-function.ioke new file mode 100644 index 0000000000..72f19e28cd --- /dev/null +++ b/Task/Ackermann-function/Ioke/ackermann-function.ioke @@ -0,0 +1,6 @@ +ackermann = method(m,n, + cond( + m zero?, n succ, + n zero?, ackermann(m pred, 1), + ackermann(m pred, ackermann(m, n pred))) +) diff --git a/Task/Ackermann-function/J/ackermann-function-1.j b/Task/Ackermann-function/J/ackermann-function-1.j new file mode 100644 index 0000000000..cad82f8d5e --- /dev/null +++ b/Task/Ackermann-function/J/ackermann-function-1.j @@ -0,0 +1,4 @@ +ack=: c1`c1`c2`c3 @. (#.@,&*) M. +c1=: >:@] NB. if 0=x, 1+y +c2=: <:@[ ack 1: NB. if 0=y, (x-1) ack 1 +c3=: <:@[ ack [ ack <:@] NB. else, (x-1) ack x ack y-1 diff --git a/Task/Ackermann-function/J/ackermann-function-2.j b/Task/Ackermann-function/J/ackermann-function-2.j new file mode 100644 index 0000000000..397865d9a4 --- /dev/null +++ b/Task/Ackermann-function/J/ackermann-function-2.j @@ -0,0 +1,8 @@ + 0 ack 3 +4 + 1 ack 3 +5 + 2 ack 3 +9 + 3 ack 3 +61 diff --git a/Task/Ackermann-function/J/ackermann-function-3.j b/Task/Ackermann-function/J/ackermann-function-3.j new file mode 100644 index 0000000000..7b48188e8a --- /dev/null +++ b/Task/Ackermann-function/J/ackermann-function-3.j @@ -0,0 +1 @@ + Ack=. 3 -~ [ ({&(2 4$'>: 2x&+') ::(,&'&1'&'2x&*'@:(-&2))"0@:[ 128!:2 ]) 3 + ] diff --git a/Task/Ackermann-function/J/ackermann-function-4.j b/Task/Ackermann-function/J/ackermann-function-4.j new file mode 100644 index 0000000000..d399b2f999 --- /dev/null +++ b/Task/Ackermann-function/J/ackermann-function-4.j @@ -0,0 +1,15 @@ + 0 1 2 3 Ack 0 1 2 3 4 5 6 7 +1 2 3 4 5 6 7 8 +2 3 4 5 6 7 8 9 +3 5 7 9 11 13 15 17 +5 13 29 61 125 253 509 1021 + + 3 4 Ack 0 1 2 + 5 13 ... +13 65533 2003529930406846464979072351560255750447825475569751419265016973710894059556311453089506130880933348101038234342907263181822949382118812668869506364761547029165041871916351587966347219442930927982084309104855990570159318959639524863372367203002916... + + 4 # @: ": @: Ack 2 NB. Number of digits of 4 Ack 2 +19729 + + 5 Ack 0 +65533 diff --git a/Task/Ackermann-function/J/ackermann-function-5.j b/Task/Ackermann-function/J/ackermann-function-5.j new file mode 100644 index 0000000000..694278f3db --- /dev/null +++ b/Task/Ackermann-function/J/ackermann-function-5.j @@ -0,0 +1,27 @@ + o=. @: NB. Composition of verbs (functions) + x=. o[ NB. Composing the left noun (argument) + + (rows2up=. ,&'&1'&'2x&*') o i. 4 +2x&* +2x&*&1 +2x&*&1&1 +2x&*&1&1&1 + NB. 2's multiplication, exponentiation, tetration, pentation, etc. + + 0 1 2 (BuckTruncated=. (rows2up x apply ]) f.) 0 1 2 3 4 5 +0 2 4 6 8 ... +1 2 4 8 16 ... +1 2 4 16 65536 2003529930406846464979072351560255750447825475569751419265016973710894059556311453089506130880933348101038234342907263181822949382118812668869506364761547029165041871916351587966347219442930927982084309104855990570159318959639524863372367203... + NB. Buck truncated function (missing the first two rows) + + BuckTruncated NB. Buck truncated function-level code +,&'&1'&'2x&*'@:[ 128!:2 ] + + (rows01=. {&('>:',:'2x&+')) 0 1 NB. The missing first two rows +>: +2x&+ + + Buck=. (rows01 :: (rows2up o (-&2)))"0 x apply ] + + (Ack=. (3 -~ [ Buck 3 + ])f.) NB. Ackermann function-level code +3 -~ [ ({&(2 4$'>: 2x&+') ::(,&'&1'&'2x&*'@:(-&2))"0@:[ 128!:2 ]) 3 + ] diff --git a/Task/Ackermann-function/Joy/ackermann-function-1.joy b/Task/Ackermann-function/Joy/ackermann-function-1.joy new file mode 100644 index 0000000000..8b5724681d --- /dev/null +++ b/Task/Ackermann-function/Joy/ackermann-function-1.joy @@ -0,0 +1,4 @@ +DEFINE ack == [ [ [pop null] popd succ ] + [ [null] pop pred 1 ack ] + [ [dup pred swap] dip pred ack ack ] ] + cond. diff --git a/Task/Ackermann-function/Joy/ackermann-function-2.joy b/Task/Ackermann-function/Joy/ackermann-function-2.joy new file mode 100644 index 0000000000..fc82935436 --- /dev/null +++ b/Task/Ackermann-function/Joy/ackermann-function-2.joy @@ -0,0 +1,4 @@ +DEFINE ack == [ [ [pop null] [popd succ] ] + [ [null] [pop pred 1] [] ] + [ [[dup pred swap] dip pred] [] [] ] ] + condnestrec. diff --git a/Task/Ackermann-function/Julia/ackermann-function.julia b/Task/Ackermann-function/Julia/ackermann-function.julia new file mode 100644 index 0000000000..976ced7de6 --- /dev/null +++ b/Task/Ackermann-function/Julia/ackermann-function.julia @@ -0,0 +1,12 @@ +function ack(m,n) + if m == 0 + return n + 1 + elseif n == 0 + return ack(m-1,1) + else + return ack(m-1,ack(m,n-1)) + end +end + +#One-liner +ack2(m,n) = m == 0 ? n + 1 : n == 0 ? ack2(m-1,1) : ack2(m-1,ack2(m,n-1)) diff --git a/Task/Ackermann-function/K/ackermann-function.k b/Task/Ackermann-function/K/ackermann-function.k new file mode 100644 index 0000000000..bad0f3aa53 --- /dev/null +++ b/Task/Ackermann-function/K/ackermann-function.k @@ -0,0 +1,2 @@ +ack:{:[0=x;y+1;0=y;_f[x-1;1];_f[x-1;_f[x;y-1]]]} +ack[2;2] diff --git a/Task/Ackermann-function/LOLCODE/ackermann-function.lol b/Task/Ackermann-function/LOLCODE/ackermann-function.lol new file mode 100644 index 0000000000..36dd2a4700 --- /dev/null +++ b/Task/Ackermann-function/LOLCODE/ackermann-function.lol @@ -0,0 +1,22 @@ +HAI 1.3 + +HOW IZ I ackermann YR m AN YR n + NOT m, O RLY? + YA RLY, FOUND YR SUM OF n AN 1 + OIC + + NOT n, O RLY? + YA RLY, FOUND YR I IZ ackermann YR DIFF OF m AN 1 AN YR 1 MKAY + OIC + + FOUND YR I IZ ackermann YR DIFF OF m AN 1 AN YR... + I IZ ackermann YR m AN YR DIFF OF n AN 1 MKAY MKAY +IF U SAY SO + +IM IN YR outer UPPIN YR m TIL BOTH SAEM m AN 5 + IM IN YR inner UPPIN YR n TIL BOTH SAEM n AN DIFF OF 6 AN m + VISIBLE "A(" m ", " n ") = " I IZ ackermann YR m AN YR n MKAY + IM OUTTA YR inner +IM OUTTA YR outer + +KTHXBYE diff --git a/Task/Ackermann-function/Liberty-BASIC/ackermann-function.liberty b/Task/Ackermann-function/Liberty-BASIC/ackermann-function.liberty new file mode 100644 index 0000000000..c1cb796e35 --- /dev/null +++ b/Task/Ackermann-function/Liberty-BASIC/ackermann-function.liberty @@ -0,0 +1,14 @@ +Print Ackermann(1, 2) + + Function Ackermann(m, n) + Select Case + Case (m < 0) Or (n < 0) + Exit Function + Case (m = 0) + Ackermann = (n + 1) + Case (m > 0) And (n = 0) + Ackermann = Ackermann((m - 1), 1) + Case (m > 0) And (n > 0) + Ackermann = Ackermann((m - 1), Ackermann(m, (n - 1))) + End Select + End Function diff --git a/Task/Ackermann-function/Logo/ackermann-function.logo b/Task/Ackermann-function/Logo/ackermann-function.logo new file mode 100644 index 0000000000..bbd5a8c4f1 --- /dev/null +++ b/Task/Ackermann-function/Logo/ackermann-function.logo @@ -0,0 +1,5 @@ +to ack :i :j + if :i = 0 [output :j+1] + if :j = 0 [output ack :i-1 1] + output ack :i-1 ack :i :j-1 +end diff --git a/Task/Ackermann-function/Logtalk/ackermann-function.logtalk b/Task/Ackermann-function/Logtalk/ackermann-function.logtalk new file mode 100644 index 0000000000..9688b21d50 --- /dev/null +++ b/Task/Ackermann-function/Logtalk/ackermann-function.logtalk @@ -0,0 +1,12 @@ +ack(0, N, V) :- + !, + V is N + 1. +ack(M, 0, V) :- + !, + M2 is M - 1, + ack(M2, 1, V). +ack(M, N, V) :- + M2 is M - 1, + N2 is N - 1, + ack(M, N2, V2), + ack(M2, V2, V). diff --git a/Task/Ackermann-function/Lucid/ackermann-function.lucid b/Task/Ackermann-function/Lucid/ackermann-function.lucid new file mode 100644 index 0000000000..4ad75a63da --- /dev/null +++ b/Task/Ackermann-function/Lucid/ackermann-function.lucid @@ -0,0 +1,7 @@ +ack(m,n) + where + ack(m,n) = if m eq 0 then n+1 + else if n eq 0 then ack(m-1,1) + else ack(m-1, ack(m, n-1)) fi + fi; + end diff --git a/Task/Ackermann-function/M4/ackermann-function.m4 b/Task/Ackermann-function/M4/ackermann-function.m4 new file mode 100644 index 0000000000..ff3ff9f0fc --- /dev/null +++ b/Task/Ackermann-function/M4/ackermann-function.m4 @@ -0,0 +1,2 @@ +define(`ack',`ifelse($1,0,`incr($2)',`ifelse($2,0,`ack(decr($1),1)',`ack(decr($1),ack($1,decr($2)))')')')dnl +ack(3,3) diff --git a/Task/Ackermann-function/MAXScript/ackermann-function.max b/Task/Ackermann-function/MAXScript/ackermann-function.max new file mode 100644 index 0000000000..d5e36d43a4 --- /dev/null +++ b/Task/Ackermann-function/MAXScript/ackermann-function.max @@ -0,0 +1,15 @@ +fn ackermann m n = +( + if m == 0 then + ( + return n + 1 + ) + else if n == 0 then + ( + ackermann (m-1) 1 + ) + else + ( + ackermann (m-1) (ackermann m (n-1)) + ) +) diff --git a/Task/Ackermann-function/ML-I/ackermann-function-1.ml b/Task/Ackermann-function/ML-I/ackermann-function-1.ml new file mode 100644 index 0000000000..247932f53c --- /dev/null +++ b/Task/Ackermann-function/ML-I/ackermann-function-1.ml @@ -0,0 +1,33 @@ +MCSKIP "WITH" NL +"" Ackermann function +"" Will overflow when it reaches implementation-defined signed integer limit +MCSKIP MT,<> +MCINS %. +MCDEF ACK WITHS ( , ) +AS +"" Macro ACK now defined, so try it out +a(0,0) => ACK(0,0) +a(0,1) => ACK(0,1) +a(0,2) => ACK(0,2) +a(0,3) => ACK(0,3) +a(0,4) => ACK(0,4) +a(0,5) => ACK(0,5) +a(1,0) => ACK(1,0) +a(1,1) => ACK(1,1) +a(1,2) => ACK(1,2) +a(1,3) => ACK(1,3) +a(1,4) => ACK(1,4) +a(2,0) => ACK(2,0) +a(2,1) => ACK(2,1) +a(2,2) => ACK(2,2) +a(2,3) => ACK(2,3) +a(3,0) => ACK(3,0) +a(3,1) => ACK(3,1) +a(3,2) => ACK(3,2) +a(4,0) => ACK(4,0) diff --git a/Task/Ackermann-function/ML-I/ackermann-function-2.ml b/Task/Ackermann-function/ML-I/ackermann-function-2.ml new file mode 100644 index 0000000000..b585d78616 --- /dev/null +++ b/Task/Ackermann-function/ML-I/ackermann-function-2.ml @@ -0,0 +1,19 @@ +a(0,0) => 1 +a(0,1) => 2 +a(0,2) => 3 +a(0,3) => 4 +a(0,4) => 5 +a(0,5) => 6 +a(1,0) => 2 +a(1,1) => 3 +a(1,2) => 4 +a(1,3) => 5 +a(1,4) => 6 +a(2,0) => 3 +a(2,1) => 5 +a(2,2) => 7 +a(2,3) => 9 +a(3,0) => 5 +a(3,1) => 13 +a(3,2) => 29 +a(4,0) => 13 diff --git a/Task/Ackermann-function/MUMPS/ackermann-function.mumps b/Task/Ackermann-function/MUMPS/ackermann-function.mumps new file mode 100644 index 0000000000..2109cd85e3 --- /dev/null +++ b/Task/Ackermann-function/MUMPS/ackermann-function.mumps @@ -0,0 +1,9 @@ +Ackermann(m,n) ; + If m=0 Quit n+1 + If m>0,n=0 Quit $$Ackermann(m-1,1) + If m>0,n>0 Quit $$Ackermann(m-1,$$Ackermann(m,n-1)) + Set $Ecode=",U13-Invalid parameter for Ackermann: m="_m_", n="_n_"," + +Write $$Ackermann(1,8) ; 10 +Write $$Ackermann(2,8) ; 19 +Write $$Ackermann(3,5) ; 253 diff --git a/Task/Ackermann-function/Maple/ackermann-function-1.maple b/Task/Ackermann-function/Maple/ackermann-function-1.maple new file mode 100644 index 0000000000..fa188cd475 --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-1.maple @@ -0,0 +1,10 @@ +Ackermann := proc( m :: nonnegint, n :: nonnegint ) + option remember; # optional automatic memoization + if m = 0 then + n + 1 + elif n = 0 then + thisproc( m - 1, 1 ) + else + thisproc( m - 1, thisproc( m, n - 1 ) ) + end if +end proc: diff --git a/Task/Ackermann-function/Maple/ackermann-function-2.maple b/Task/Ackermann-function/Maple/ackermann-function-2.maple new file mode 100644 index 0000000000..ca1c3e6b69 --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-2.maple @@ -0,0 +1 @@ +thisproc diff --git a/Task/Ackermann-function/Maple/ackermann-function-3.maple b/Task/Ackermann-function/Maple/ackermann-function-3.maple new file mode 100644 index 0000000000..2af3bcc371 --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-3.maple @@ -0,0 +1,16 @@ +Ackermann := proc( m :: nonnegint, n :: nonnegint ) + option remember; # optional automatic memoization + if m = 0 then + n + 1 + elif m = 1 then + n + 2 + elif m = 2 then + 2 * n + 3 + elif m = 3 then + 8 * 2^n - 3 + elif n = 0 then + thisproc( m - 1, 1 ) + else + thisproc( m - 1, thisproc( m, n - 1 ) ) + end if +end proc: diff --git a/Task/Ackermann-function/Maple/ackermann-function-4.maple b/Task/Ackermann-function/Maple/ackermann-function-4.maple new file mode 100644 index 0000000000..d3e975b22d --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-4.maple @@ -0,0 +1,2 @@ +> map2( Ackermann, 1, [seq]( 1 .. 10 ) ); + [3, 4, 5, 6, 7, 8, 9, 10, 11, 12] diff --git a/Task/Ackermann-function/Maple/ackermann-function-5.maple b/Task/Ackermann-function/Maple/ackermann-function-5.maple new file mode 100644 index 0000000000..7d52b37015 --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-5.maple @@ -0,0 +1,2 @@ +> map2( Ackermann, 2, [seq]( 1 .. 10 ) ); + [5, 7, 9, 11, 13, 15, 17, 19, 21, 23] diff --git a/Task/Ackermann-function/Maple/ackermann-function-6.maple b/Task/Ackermann-function/Maple/ackermann-function-6.maple new file mode 100644 index 0000000000..47c2d3df7c --- /dev/null +++ b/Task/Ackermann-function/Maple/ackermann-function-6.maple @@ -0,0 +1,2 @@ +> length( Ackermann( 4, 2 ) ); + 19729 diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-1.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-1.mathematica new file mode 100644 index 0000000000..897eb136f1 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-1.mathematica @@ -0,0 +1,11 @@ +$RecursionLimit=Infinity +Ackermann1[m_,n_]:= + If[m==0,n+1, + If[ n==0,Ackermann1[m-1,1], + Ackermann1[m-1,Ackermann1[m,n-1]] + ] + ] + + Ackermann2[0,n_]:=n+1; + Ackermann2[m_,0]:=Ackermann1[m-1,1]; + Ackermann2[m_,n_]:=Ackermann1[m-1,Ackermann1[m,n-1]] diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-2.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-2.mathematica new file mode 100644 index 0000000000..9a602342b0 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-2.mathematica @@ -0,0 +1 @@ +Flatten[#,1]&@Table[{"Ackermann2["<>ToString[i]<>","<>ToString[j]<>"] =",Ackermann2[i,j]},{i,3},{j,8}]//Grid diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-3.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-3.mathematica new file mode 100644 index 0000000000..1fb78d9d07 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-3.mathematica @@ -0,0 +1,24 @@ +Ackermann2[1,1] = 3 +Ackermann2[1,2] = 4 +Ackermann2[1,3] = 5 +Ackermann2[1,4] = 6 +Ackermann2[1,5] = 7 +Ackermann2[1,6] = 8 +Ackermann2[1,7] = 9 +Ackermann2[1,8] = 10 +Ackermann2[2,1] = 5 +Ackermann2[2,2] = 7 +Ackermann2[2,3] = 9 +Ackermann2[2,4] = 11 +Ackermann2[2,5] = 13 +Ackermann2[2,6] = 15 +Ackermann2[2,7] = 17 +Ackermann2[2,8] = 19 +Ackermann2[3,1] = 13 +Ackermann2[3,2] = 29 +Ackermann2[3,3] = 61 +Ackermann2[3,4] = 125 +Ackermann2[3,5] = 253 +Ackermann2[3,6] = 509 +Ackermann2[3,7] = 1021 +Ackermann2[3,8] = 2045 diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-4.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-4.mathematica new file mode 100644 index 0000000000..d08c983a90 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-4.mathematica @@ -0,0 +1,8 @@ +Clear[Ackermann3] +$RecursionLimit=Infinity; +Ackermann3[0,n_]:=n+1; +Ackermann3[1,n_]:=n+2; +Ackermann3[2,n_]:=3+2n; +Ackermann3[3,n_]:=5+8 (2^n-1); +Ackermann3[m_,0]:=Ackermann3[m-1,1]; +Ackermann3[m_,n_]:=Ackermann3[m-1,Ackermann3[m,n-1]] diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-5.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-5.mathematica new file mode 100644 index 0000000000..63a1e13bf8 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-5.mathematica @@ -0,0 +1,2 @@ +Ackermann3[4, 1] +Ackermann3[4, 2] diff --git a/Task/Ackermann-function/Mathematica/ackermann-function-6.mathematica b/Task/Ackermann-function/Mathematica/ackermann-function-6.mathematica new file mode 100644 index 0000000000..e27315d169 --- /dev/null +++ b/Task/Ackermann-function/Mathematica/ackermann-function-6.mathematica @@ -0,0 +1,2 @@ +65533 +2003529930406846464979072351560255750447825475569751419265016973710894059556311453089506130880........699146577530041384717124577965048175856395072895337539755822087777506072339445587895905719156733 diff --git a/Task/Ackermann-function/Maxima/ackermann-function.maxima b/Task/Ackermann-function/Maxima/ackermann-function.maxima new file mode 100644 index 0000000000..2e29d18ac2 --- /dev/null +++ b/Task/Ackermann-function/Maxima/ackermann-function.maxima @@ -0,0 +1,15 @@ +ackermann(m, n) := if integerp(m) and integerp(n) then ackermann[m, n] else 'ackermann(m, n)$ + +ackermann[m, n] := if m = 0 then n + 1 + elseif m = 1 then 2 + (n + 3) - 3 + elseif m = 2 then 2 * (n + 3) - 3 + elseif m = 3 then 2^(n + 3) - 3 + elseif n = 0 then ackermann[m - 1, 1] + else ackermann[m - 1, ackermann[m, n - 1]]$ + +tetration(a, n) := if integerp(n) then block([b: a], for i from 2 thru n do b: a^b, b) else 'tetration(a, n)$ + +/* this should evaluate to zero */ +ackermann(4, n) - (tetration(2, n + 3) - 3); +subst(n = 2, %); +ev(%, nouns); diff --git a/Task/Ackermann-function/Mercury/ackermann-function.mercury b/Task/Ackermann-function/Mercury/ackermann-function.mercury new file mode 100644 index 0000000000..1a5d1fbcc3 --- /dev/null +++ b/Task/Ackermann-function/Mercury/ackermann-function.mercury @@ -0,0 +1,10 @@ +:- func ack(integer, integer) = integer. +ack(M, N) = R :- ack(M, N, R). + +:- pred ack(integer::in, integer::in, integer::out) is det. +ack(M, N, R) :- + ( ( M < integer(0) + ; N < integer(0) ) -> throw(bounds_error) + ; M = integer(0) -> R = N + integer(1) + ; N = integer(0) -> ack(M - integer(1), integer(1), R) + ; ack(M - integer(1), ack(M, N - integer(1)), R) ). diff --git a/Task/Ackermann-function/Modula-2/ackermann-function.mod2 b/Task/Ackermann-function/Modula-2/ackermann-function.mod2 new file mode 100644 index 0000000000..f7570302ae --- /dev/null +++ b/Task/Ackermann-function/Modula-2/ackermann-function.mod2 @@ -0,0 +1,33 @@ +MODULE ackerman; + +IMPORT ASCII, NumConv, InOut; + +VAR m, n : LONGCARD; + string : ARRAY [0..19] OF CHAR; + OK : BOOLEAN; + +PROCEDURE Ackerman (x, y : LONGCARD) : LONGCARD; + +BEGIN + IF x = 0 THEN RETURN y + 1 + ELSIF y = 0 THEN RETURN Ackerman (x - 1 , 1) + ELSE + RETURN Ackerman (x - 1 , Ackerman (x , y - 1)) + END +END Ackerman; + +BEGIN + FOR m := 0 TO 3 DO + FOR n := 0 TO 6 DO + NumConv.Num2Str (Ackerman (m, n), 10, string, OK); + IF OK THEN + InOut.WriteString (string) + ELSE + InOut.WriteString ("* Error in number * ") + END; + InOut.Write (ASCII.HT) + END; + InOut.WriteLn + END; + InOut.WriteLn +END ackerman. diff --git a/Task/Ackermann-function/Modula-3/ackermann-function.mod3 b/Task/Ackermann-function/Modula-3/ackermann-function.mod3 new file mode 100644 index 0000000000..48640bfb12 --- /dev/null +++ b/Task/Ackermann-function/Modula-3/ackermann-function.mod3 @@ -0,0 +1,24 @@ +MODULE Ack EXPORTS Main; + +FROM IO IMPORT Put; +FROM Fmt IMPORT Int; + +PROCEDURE Ackermann(m, n: CARDINAL): CARDINAL = + BEGIN + IF m = 0 THEN + RETURN n + 1; + ELSIF n = 0 THEN + RETURN Ackermann(m - 1, 1); + ELSE + RETURN Ackermann(m - 1, Ackermann(m, n - 1)); + END; + END Ackermann; + +BEGIN + FOR m := 0 TO 3 DO + FOR n := 0 TO 6 DO + Put(Int(Ackermann(m, n)) & " "); + END; + Put("\n"); + END; +END Ack. diff --git a/Task/Active-object/Factor/active-object.factor b/Task/Active-object/Factor/active-object.factor new file mode 100644 index 0000000000..4b9ec895a0 --- /dev/null +++ b/Task/Active-object/Factor/active-object.factor @@ -0,0 +1,41 @@ +USING: accessors alarms calendar combinators kernel locals math +math.constants math.functions prettyprint system threads ; +IN: rosettacode.active + +TUPLE: active-object alarm function state previous-time ; + +: apply-stack-effect ( quot -- quot' ) + [ call( x -- x ) ] curry ; inline + +: nano-to-seconds ( -- seconds ) nano-count 9 10^ / ; + +: object-times ( active-object -- t1 t2 ) + [ previous-time>> ] + [ nano-to-seconds [ >>previous-time drop ] keep ] bi ; +:: adding-function ( t1 t2 active-object -- function ) + t2 t1 active-object function>> apply-stack-effect bi@ + + t2 t1 - * 2 / [ + ] curry ; +: integrate ( active-object -- ) + [ object-times ] + [ adding-function ] + [ swap apply-stack-effect change-state drop ] tri ; + +: ( -- object ) + active-object new + 0 >>state + nano-to-seconds >>previous-time + [ drop 0 ] >>function + dup [ integrate ] curry 1 nanoseconds every >>alarm ; +: destroy ( active-object -- ) alarm>> cancel-alarm ; + +: input ( object quot -- object ) >>function ; +: output ( object -- val ) state>> ; + +: active-test ( -- ) + + [ 2 pi 0.5 * * * sin ] input + 2 seconds sleep + [ drop 0 ] input + 0.5 seconds sleep + [ output . ] [ destroy ] bi ; +MAIN: active-test diff --git a/Task/Active-object/Mathematica/active-object.mathematica b/Task/Active-object/Mathematica/active-object.mathematica new file mode 100644 index 0000000000..aa9f7e9a45 --- /dev/null +++ b/Task/Active-object/Mathematica/active-object.mathematica @@ -0,0 +1,5 @@ +Block[{start = SessionTime[], K, t0 = 0, t1, kt0, S = 0}, + K[t_] = Sin[2 Pi f t] /. f -> 0.5; kt0 = K[t0]; + While[True, t1 = SessionTime[] - start; + S += (kt0 + (kt0 = K[t1])) (t1 - t0)/2; t0 = t1; + If[t1 > 2, K[t_] = 0; If[t1 > 2.5, Break[]]]]; S] diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-1.falcon b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-1.falcon new file mode 100644 index 0000000000..d4406d9e29 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-1.falcon @@ -0,0 +1,8 @@ +vect = [ 'alpha', 'beta', 'gamma' ] +vect.dump = function () + for n in [0: self.len()] + > @"$(n): ", self[n] + end +end +vect += 'delta' +vect.dump() diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-2.falcon b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-2.falcon new file mode 100644 index 0000000000..c3110de9f0 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-2.falcon @@ -0,0 +1,4 @@ +0: alpha +1: beta +2: gamma +3: delta diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-3.falcon b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-3.falcon new file mode 100644 index 0000000000..8fbf1dfd11 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Falcon/add-a-variable-to-a-class-instance-at-runtime-3.falcon @@ -0,0 +1,15 @@ +function sub_func( value ) + self['prop'] -= value + return self.prop +end + +dict = bless( [ + 'prop' => 0, + 'add' => function ( value ) + self.prop += value + return self.prop + end , + 'sub' => sub_func +]) + +dict[ 'newVar' ] = "I'm Rich In Data" diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-1.groovy b/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-1.groovy new file mode 100644 index 0000000000..08ff4c43bc --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-1.groovy @@ -0,0 +1,6 @@ +class A { + final x = { it + 25 } + private map = new HashMap() + Object get(String key) { map[key] } + void set(String key, Object value) { map[key] = value } +} diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-2.groovy b/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-2.groovy new file mode 100644 index 0000000000..81675819bd --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Groovy/add-a-variable-to-a-class-instance-at-runtime-2.groovy @@ -0,0 +1,9 @@ +def a = new A() +a.y = 55 +a.z = { println (new Date()); Thread.sleep 5000 } + +println a.x(25) +println a.y +(0..2).each(a.z) + +println a.q diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Icon/add-a-variable-to-a-class-instance-at-runtime.icon b/Task/Add-a-variable-to-a-class-instance-at-runtime/Icon/add-a-variable-to-a-class-instance-at-runtime.icon new file mode 100644 index 0000000000..d9b81a6d5e --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Icon/add-a-variable-to-a-class-instance-at-runtime.icon @@ -0,0 +1,27 @@ +link ximage + +procedure main() + c1 := foo(1,2) # instance of foo + write("c1:\n",ximage(c1)) + c1 := extend(c1,["c","d"],[8,9]) # 2 new fields + write("new c1:\n",ximage(c1)) + c1 := extend(c1,["e"],[7]) # 1 more + write("newest c1:\n",ximage(c1)) +end + +class foo(a,b) # dummy class +end + +procedure extend(instance,newvars,newvals) #: extend a class instance + every put(f := [],fieldnames(instance)) # copy existing fieldnames + c := ["tempconstructor"] ||| f # new constructor + every put(c,!newvars) # append new vars + t := constructor!c # new constructor + x := t() # new instance + every x[v := !f] := instance[v] # same as old instance + x.__s := x # new self + if \newvals then + every i := 1 to min(*newvars,*newvals) do + x[newvars[i]] := newvals[i] # add new vars = values + return x +end diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Io/add-a-variable-to-a-class-instance-at-runtime.io b/Task/Add-a-variable-to-a-class-instance-at-runtime/Io/add-a-variable-to-a-class-instance-at-runtime.io new file mode 100644 index 0000000000..73b7554073 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Io/add-a-variable-to-a-class-instance-at-runtime.io @@ -0,0 +1,4 @@ +Empty := Object clone + +e := Empty clone +e foo := 1 diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/J/add-a-variable-to-a-class-instance-at-runtime.j b/Task/Add-a-variable-to-a-class-instance-at-runtime/J/add-a-variable-to-a-class-instance-at-runtime.j new file mode 100644 index 0000000000..f3e8b779ff --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/J/add-a-variable-to-a-class-instance-at-runtime.j @@ -0,0 +1,13 @@ + C=:<'exampleclass' NB. this will be our class name + V__C=: 0 NB. ensure the class exists + OBJ1=:conew 'exampleclass' NB. create an instance of our class + OBJ2=:conew 'exampleclass' NB. create another instance + V__OBJ1,V__OBJ2 NB. both of our instances exist +0 + W__OBJ1 NB. instance does not have a W +|value error + W__OBJ1=: 0 NB. here, we add a W to this instance + W__OBJ1 NB. this instance now has a W +0 + W__OBJ2 NB. our other instance does not +|value error diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/LOLCODE/add-a-variable-to-a-class-instance-at-runtime.lol b/Task/Add-a-variable-to-a-class-instance-at-runtime/LOLCODE/add-a-variable-to-a-class-instance-at-runtime.lol new file mode 100644 index 0000000000..b9d4d8bfa1 --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/LOLCODE/add-a-variable-to-a-class-instance-at-runtime.lol @@ -0,0 +1,21 @@ +HAI 1.3 + +I HAS A object ITZ A BUKKIT +I HAS A name, I HAS A value + +IM IN YR interface + VISIBLE "R U WANTIN 2 (A)DD A VAR OR (P)RINT 1? "! + I HAS A option, GIMMEH option + + option, WTF? + OMG "A" + VISIBLE "NAME: "!, GIMMEH name + VISIBLE "VALUE: "!, GIMMEH value + object HAS A SRS name ITZ value, GTFO + OMG "P" + VISIBLE "NAME: "!, GIMMEH name + VISIBLE object'Z SRS name + OIC +IM OUTTA YR interface + +KTHXBYE diff --git a/Task/Add-a-variable-to-a-class-instance-at-runtime/Mathematica/add-a-variable-to-a-class-instance-at-runtime.mathematica b/Task/Add-a-variable-to-a-class-instance-at-runtime/Mathematica/add-a-variable-to-a-class-instance-at-runtime.mathematica new file mode 100644 index 0000000000..bb079088dc --- /dev/null +++ b/Task/Add-a-variable-to-a-class-instance-at-runtime/Mathematica/add-a-variable-to-a-class-instance-at-runtime.mathematica @@ -0,0 +1,4 @@ +f[a]=1; +f[b]=2; +f[a]=3; +? f diff --git a/Task/Address-of-a-variable/Modula-2/address-of-a-variable-1.mod2 b/Task/Address-of-a-variable/Modula-2/address-of-a-variable-1.mod2 new file mode 100644 index 0000000000..1872309081 --- /dev/null +++ b/Task/Address-of-a-variable/Modula-2/address-of-a-variable-1.mod2 @@ -0,0 +1,12 @@ +MODULE GetAddress; + +FROM SYSTEM IMPORT ADR; +FROM InOut IMPORT WriteInt, WriteLn; + +VAR var : INTEGER; + adr : LONGINT; +BEGIN + adr := ADR(var); (*get the address*) + WriteInt(adr, 0); + WriteLn; +END GetAddress. diff --git a/Task/Address-of-a-variable/Modula-2/address-of-a-variable-2.mod2 b/Task/Address-of-a-variable/Modula-2/address-of-a-variable-2.mod2 new file mode 100644 index 0000000000..be92511f0c --- /dev/null +++ b/Task/Address-of-a-variable/Modula-2/address-of-a-variable-2.mod2 @@ -0,0 +1,9 @@ +MODULE SetAddress; + +CONST adress = 134664460; + +VAR var [adress] : INTEGER; + +BEGIN + (*do nothing*) +END SetAddress. diff --git a/Task/Align-columns/Factor/align-columns.factor b/Task/Align-columns/Factor/align-columns.factor new file mode 100644 index 0000000000..268c09ad61 --- /dev/null +++ b/Task/Align-columns/Factor/align-columns.factor @@ -0,0 +1,40 @@ +USING: fry io kernel math math.functions math.order sequences +splitting strings ; +IN: rosetta.column-aligner + +CONSTANT: example-text "Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column." + +: split-and-pad ( text -- lines ) + "\n" split [ "$" split harvest ] map + dup [ length ] [ max ] map-reduce + '[ _ "" pad-tail ] map ; + +: column-widths ( columns -- widths ) + [ [ length ] [ max ] map-reduce ] map ; + +SINGLETONS: +left+ +middle+ +right+ ; + +GENERIC: align-string ( str n alignment -- str' ) + +M: +left+ align-string drop CHAR: space pad-tail ; +M: +right+ align-string drop CHAR: space pad-head ; + +M: +middle+ align-string + drop + over length - 2 / + [ floor CHAR: space ] + [ ceiling CHAR: space ] bi surround ; + +: align-columns ( columns alignment -- columns' ) + [ dup column-widths ] dip '[ + [ _ align-string ] curry map + ] 2map ; + +: print-aligned ( text alignment -- ) + [ split-and-pad flip ] dip align-columns flip + [ [ write " " write ] each nl ] each ; diff --git a/Task/Align-columns/Groovy/align-columns-1.groovy b/Task/Align-columns/Groovy/align-columns-1.groovy new file mode 100644 index 0000000000..f4f61b5495 --- /dev/null +++ b/Task/Align-columns/Groovy/align-columns-1.groovy @@ -0,0 +1,14 @@ +def alignColumns = { align, rawText -> + def lines = rawText.tokenize('\n') + def words = lines.collect { it.tokenize(/\$/) } + def maxLineWords = words.collect {it.size()}.max() + words = words.collect { line -> line + [''] * (maxLineWords - line.size()) } + def columnWidths = words.transpose().collect{ column -> column.collect { it.size() }.max() } + + def justify = [ Right : { width, string -> string.padLeft(width) }, + Left : { width, string -> string.padRight(width) }, + Center : { width, string -> string.center(width) } ] + def padAll = { pad, colWidths, lineWords -> [colWidths, lineWords].transpose().collect { pad(it) + ' ' } } + + words.each { padAll(justify[align], columnWidths, it).each { print it }; println() } +} diff --git a/Task/Align-columns/Groovy/align-columns-2.groovy b/Task/Align-columns/Groovy/align-columns-2.groovy new file mode 100644 index 0000000000..a5185dfb81 --- /dev/null +++ b/Task/Align-columns/Groovy/align-columns-2.groovy @@ -0,0 +1,12 @@ +def rawTextInput = '''Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column.''' + +['Left', 'Center', 'Right'].each { align -> + println "${align} Justified:" + alignColumns(align, rawTextInput) + println() +} diff --git a/Task/Align-columns/HicEst/align-columns.hicest b/Task/Align-columns/HicEst/align-columns.hicest new file mode 100644 index 0000000000..0aa0070d7e --- /dev/null +++ b/Task/Align-columns/HicEst/align-columns.hicest @@ -0,0 +1,27 @@ +CHARACTER Fnam = "\HicEst\Rosetta\Align columns.txt" + + OPEN(FIle=Fnam, Format="12$", LENgth=rows) +! call the DLG function in MatrixExplorer mode: + DLG(Edit=Fnam, Format='12A10') ! left adjusted, 12 columns, 10 spaces each + +! or the standard way: + CALL Align( "LLLLLLLLLLL ", Fnam, rows) ! left align + CALL Align( "CCCCCCCCCCC ", Fnam, rows) ! center align + CALL Align( "RRRRRRRRRRR ", Fnam, rows) ! right align +END + +SUBROUTINE Align(picture, filename, rows) + CHARACTER picture, filename + CHARACTER out*400, txt*20 + + W = LEN(picture) + DO i = 1, rows + out = " " + DO j = 0, 100 + txt = filename(i, j+1, *9) ! on error branch to label 9 + WRITE(Text=out(j*W+1 : ), Format=picture) txt + ENDDO + 9 CONTINUE + WRITE() out + ENDDO +END diff --git a/Task/Align-columns/Icon/align-columns.icon b/Task/Align-columns/Icon/align-columns.icon new file mode 100644 index 0000000000..8ecfeb25ac --- /dev/null +++ b/Task/Align-columns/Icon/align-columns.icon @@ -0,0 +1,30 @@ +global width + +procedure main(args) + lines := [] + width := 0 + format := left + match("left"|"right"|"center", format <- !args) + every put(lines,prepare(!&input)) + display(lines, proc(format,3)) +end + +procedure prepare(lines) + line := [] + lines ? { + while (not pos(0)) & (field := tab(upto('$')|0)) do { + put(line, field) + width <:= *field + move(1) + } + } + return line +end + +procedure display(lines, format) + width +:= 1 + every line := !lines do { + every writes(format(!line, width)) + write() + } +end diff --git a/Task/Align-columns/J/align-columns-1.j b/Task/Align-columns/J/align-columns-1.j new file mode 100644 index 0000000000..41623a361a --- /dev/null +++ b/Task/Align-columns/J/align-columns-1.j @@ -0,0 +1,18 @@ +'LEFT CENTER RIGHT'=: i.3 NB. justification constants + +NB.* alignCols v Format delimited text in justified columns +NB. y: text to format +NB. rows marked by last character in text +NB. columns marked by $ +NB. optional x: justification. Default is LEFT +NB. result: text table +alignCols=: verb define + LEFT alignCols y NB. default +: + global=. dyad def'9!:x y'each + oldbox=. 6 16 global '';'' NB. save settings + 7 17 global (11#' ');,~x NB. apply new settings + result=. _2{:\ ": <;._2 @:,&'$';._2 y NB. parse & format text + 7 17 global oldbox NB. restore settings + result +) diff --git a/Task/Align-columns/J/align-columns-2.j b/Task/Align-columns/J/align-columns-2.j new file mode 100644 index 0000000000..dda9d61cb5 --- /dev/null +++ b/Task/Align-columns/J/align-columns-2.j @@ -0,0 +1,24 @@ + text=: noun define +Given$a$text$file$of$many$lines,$where$fields$within$a$line$ +are$delineated$by$a$single$'dollar'$character,$write$a$program +that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ +column$are$separated$by$at$least$one$space. +Further,$allow$for$each$word$in$a$column$to$be$either$left$ +justified,$right$justified,$or$center$justified$within$its$column. +) + + alignCols text NB. default justification + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. + + CENTER alignCols text NB. specify desired justification as left argument + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. diff --git a/Task/Align-columns/Liberty-BASIC/align-columns.liberty b/Task/Align-columns/Liberty-BASIC/align-columns.liberty new file mode 100644 index 0000000000..253e749bf1 --- /dev/null +++ b/Task/Align-columns/Liberty-BASIC/align-columns.liberty @@ -0,0 +1,78 @@ +mainwin 140 32 + + CRLF$ =chr$( 13) + maxlen =0 + + read y + + Dim txt$( y) + + For i =1 To y + Read i$ + print i$ + if right$( i$, 1) <>"$" then i$ =i$ +"$" + txt$( i) =i$ + x =max( CountDollars( txt$( i)), x) + Next i + + print x + + Dim matrix$( x, y) + + Print CRLF$; " ---- Left ----" + For yy =1 To y + For xx =1 To x + matrix$( xx, yy) =word$( txt$( yy), xx, "$") + print matrix$( xx, yy), "|"; + maxlen =max( maxlen, Len( matrix$( xx, yy))) + Next xx + print "" + Next yy + + Print CRLF$; " ---- Right ----" + For yy =1 To y + For xx =1 To x + Print right$( " " +matrix$( xx, yy), maxlen +1); "|"; + ' will truncate column words longer than 20. Change to use maxlen.... + Next xx + Print "" + Next yy + + Print CRLF$ +" ---- Center ----" + For yy =1 to y + For xx =1 to x + wordLen =Len( matrix$( xx, yy)) + padNeeded =maxlen -wordLen +4 + LeftSpaces =padNeeded /2 + + if LeftSpaces =int( LeftSpaces) then + RightSpaces =LeftSpaces + else + RightSpaces =LeftSpaces -1 + end if + + Print space$( LeftSpaces); matrix$( xx, yy); space$( RightSpaces); "|"; + Next xx + Print "" + Next yy + + wait + + Data 6 + + Data "Given$a$text$file$of$many$lines,$where$fields$within$a$line$" + Data "are$delineated$by$a$single$'dollar'$character,$write$a$program" + Data "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" + Data "column$are$separated$by$at$least$one$space." + Data "Further,$allow$for$each$word$in$a$column$to$be$either$left$" + Data "justified,$right$justified,$or$center$justified$within$its$column." + + function CountDollars( src$) + c =0 + for j =1 to len( src$) + if mid$( src$, j, 1) ="$" then c =c +1 + next j + CountDollars =c + end function + + end diff --git a/Task/Align-columns/ML-I/align-columns.ml b/Task/Align-columns/ML-I/align-columns.ml new file mode 100644 index 0000000000..f9e6712b10 --- /dev/null +++ b/Task/Align-columns/ML-I/align-columns.ml @@ -0,0 +1,57 @@ +MCSKIP "WITH" NL +"" Align columns - assumes macros on input stream 1, data on stream 2 +MCPVAR 102 +"" Set P102 to alignment required: +"" 1 = centre +"" 2 = left +"" 3 = right +MCSET P102 = 1 +MCSKIP MT,<> +MCINS %. +MCSKIP SL WITH * +"" Assume no more than 100 columns - P101 used for max number of fields +"" Set P variables 1-101 to 0 +MCDEF ZEROPS WITHS NL AS +ZEROPS +"" First pass - macro to accumulate max columns, and max widths +MCDEF SL N1 OPT $ N1 OR $ WITHS NL OR SPACE WITHS NL OR NL ALL +AS +MCSET S1=1 +*MCSET S10=2 +*MCSET S1=0 +MCSET S4=1 +""MCNOTE Max field is %P101. +""MCDEF REP NL AS +""REP +MCDEF SL N1 OPT $ N1 OR $ WITHS NL OR SPACE WITHS NL OR NL ALL +AS ,1,T3)%L7.%WBT2."" +MCSUB(< >,1,PT2-T3-MCLENG(%WBT2.)+1)MCGO L4 +%L2.MCSUB(%WBT2.< >,1,PT2)MCGO L4 +%L3.MCSUB(< >%WBT2.,1-PT2,0)"" +%L4. MCSET T2=T2+1 +MCGO L5 +%L6. +> +MCSET S1=1 +*MCSET S10=102 diff --git a/Task/Align-columns/MUMPS/align-columns.mumps b/Task/Align-columns/MUMPS/align-columns.mumps new file mode 100644 index 0000000000..5f28225fb5 --- /dev/null +++ b/Task/Align-columns/MUMPS/align-columns.mumps @@ -0,0 +1,53 @@ +columns(how) ; how = "Left", "Center" or "Right" + New col,half,ii,max,spaces,word + Set ii=0 + Set ii=ii+1,line(ii)="Given$a$text$file$of$many$lines,$where$fields$within$a$line$" + Set ii=ii+1,line(ii)="are$delineated$by$a$single$'dollar'$character,$write$a$program" + Set ii=ii+1,line(ii)="that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$" + Set ii=ii+1,line(ii)="column$are$separated$by$at$least$one$space." + Set ii=ii+1,line(ii)="Further,$allow$for$each$word$in$a$column$to$be$either$left$" + Set ii=ii+1,line(ii)="justified,$right$justified,$or$center$justified$within$its$column." + Set ii="" For Set ii=$Order(line(ii)) Quit:ii="" Do + . For col=1:1:$Length(line(ii),"$") Do + . . Set max=$Length($Piece(line(ii),"$",col)) + . . Set:max>$Get(max(col)) max(col)=max + . . Quit + . Quit + Set ii="" For Set ii=$Order(line(ii)) Quit:ii="" Do + . Write ! For col=1:1:$Length(line(ii),"$") Do:$Get(max(col)) + . . Set word=$Piece(line(ii),"$",col) + . . Set spaces=$Justify("",max(col)-$Length(word)) + . . If how="Left" Write word,spaces," " Quit + . . If how="Right" Write spaces,word," " Quit + . . Set half=$Length(spaces)\2 + . . Write $Extract(spaces,1,half),word,$Extract(spaces,half+1,$Length(spaces))," " + . . Quit + . Quit + Write ! + Quit +Do columns("Left") + +Given a text file of many lines, where fields within a line +are delineated by a single 'dollar' character, write a program +that aligns each column of fields by ensuring that words in each +column are separated by at least one space. +Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. + +Do columns("Center") + + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. + +Do columns("Right") + + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. diff --git a/Task/Align-columns/Maple/align-columns-1.maple b/Task/Align-columns/Maple/align-columns-1.maple new file mode 100644 index 0000000000..ab56031487 --- /dev/null +++ b/Task/Align-columns/Maple/align-columns-1.maple @@ -0,0 +1,7 @@ +txt := +"Given$a$text$file$of$many$lines,$where$fields$within$a$line$\n" +"are$delineated$by$a$single$'dollar'$character,$write$a$program\n" +"that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$\n" +"column$are$separated$by$at$least$one$space.\n" +"Further,$allow$for$each$word$in$a$column$to$be$either$left$\n" +"justified,$right$justified,$or$center$justified$within$its$column.\n": diff --git a/Task/Align-columns/Maple/align-columns-2.maple b/Task/Align-columns/Maple/align-columns-2.maple new file mode 100644 index 0000000000..19095617aa --- /dev/null +++ b/Task/Align-columns/Maple/align-columns-2.maple @@ -0,0 +1,24 @@ +AlignColumns := proc( txt, align :: { "left", "right", "centre" } := "centre" ) + uses StringTools; + + # Get a list of lists of fields + local A := map( Split, Split( txt ), "$" ); + + # Calculate the column width + local width := 1 + max( map( L -> max( map( length, L ) ), A ) ); + + # Add spacing according to the requested type of alignment + if align = "left" then + local J := map( line -> map( PadRight, line, width ), A ) + elif align = "right" then + J := map( line -> map( PadLeft, line, width ), A ) + else + J := map( line -> map( Center, line, width ), A ) + end if; + + # Join up the fields in each line. + J := map( cat@op, J ); + + # Re-assemble the lines into a single string. + Join( J, "\n" ) +end proc: diff --git a/Task/Align-columns/Maple/align-columns-3.maple b/Task/Align-columns/Maple/align-columns-3.maple new file mode 100644 index 0000000000..8af33e79ec --- /dev/null +++ b/Task/Align-columns/Maple/align-columns-3.maple @@ -0,0 +1,28 @@ +> printf( "%s\n", AlignColumns( txt ) ): + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. +> printf( "%s\n", AlignColumns( txt, "center" ) ): # same as above + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. +> printf( "%s\n", AlignColumns( txt, "left" ) ): +Given a text file of many lines, where fields within a line +are delineated by a single 'dollar' character, write a program +that aligns each column of fields by ensuring that words in each +column are separated by at least one space. +Further, allow for each word in a column to be either left +justified, right justified, or center justified within its column. +> printf( "%s\n", AlignColumns( txt, "right" ) ): + Given a text file of many lines, where fields within a line + are delineated by a single 'dollar' character, write a program + that aligns each column of fields by ensuring that words in each + column are separated by at least one space. + Further, allow for each word in a column to be either left + justified, right justified, or center justified within its column. diff --git a/Task/Align-columns/Mathematica/align-columns.mathematica b/Task/Align-columns/Mathematica/align-columns.mathematica new file mode 100644 index 0000000000..cd142d71b2 --- /dev/null +++ b/Task/Align-columns/Mathematica/align-columns.mathematica @@ -0,0 +1 @@ +TableForm[StringSplit[StringSplit[a,"\n"],"$"],TableAlignments -> Center] diff --git a/Task/Anagrams-Deranged-anagrams/Factor/anagrams-deranged-anagrams.factor b/Task/Anagrams-Deranged-anagrams/Factor/anagrams-deranged-anagrams.factor new file mode 100644 index 0000000000..91cfb9549b --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Factor/anagrams-deranged-anagrams.factor @@ -0,0 +1,24 @@ +USING: assocs fry io.encodings.utf8 io.files kernel math +math.combinatorics sequences sorting strings ; +IN: rosettacode.deranged-anagrams + +: derangement? ( str1 str2 -- ? ) [ = not ] 2all? ; +: derangements ( seq -- seq ) + 2 [ first2 derangement? ] filter-combinations ; + +: parse-dict-file ( path -- hash ) + utf8 file-lines + H{ } clone [ + '[ + [ natural-sort >string ] keep + _ [ swap suffix ] with change-at + ] each + ] keep ; + +: anagrams ( hash -- seq ) [ nip length 1 > ] assoc-filter values ; + +: deranged-anagrams ( path -- seq ) + parse-dict-file anagrams [ derangements ] map concat ; + +: longest-deranged-anagrams ( path -- anagrams ) + deranged-anagrams [ first length ] sort-with last ; diff --git a/Task/Anagrams-Deranged-anagrams/GAP/anagrams-deranged-anagrams.gap b/Task/Anagrams-Deranged-anagrams/GAP/anagrams-deranged-anagrams.gap new file mode 100644 index 0000000000..0abb414771 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/GAP/anagrams-deranged-anagrams.gap @@ -0,0 +1,30 @@ +IsDeranged := function(a, b) + local i, n; + for i in [1 .. Size(a)] do + if a[i] = b[i] then + return false; + fi; + od; + return true; +end; + +# This solution will find all deranged pairs of any length. +Deranged := function(name) + local sol, ana, u, v; + sol := [ ]; + ana := Anagrams(name); + for u in ana do + for v in Combinations(u, 2) do + if IsDeranged(v[1], v[2]) then + Add(sol, v); + fi; + od; + od; + return sol; +end; + +# Now we find all deranged pairs of maximum length +a := Deranged("unixdict.txt");; +n := Maximum(List(a, x -> Size(x[1]))); +Filtered(a, x -> Size(x[1]) = n); +# [ [ "excitation", "intoxicate" ] ] diff --git a/Task/Anagrams-Deranged-anagrams/Icon/anagrams-deranged-anagrams.icon b/Task/Anagrams-Deranged-anagrams/Icon/anagrams-deranged-anagrams.icon new file mode 100644 index 0000000000..6556e93bca --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Icon/anagrams-deranged-anagrams.icon @@ -0,0 +1,26 @@ +link strings # for csort() procedure + +procedure main() + anagrams := table() # build lists of anagrams + every *(word := !&input) > 1 do { + canon := csort(word) + /anagrams[canon] := [] + put(anagrams[canon], word) + } + + longest := 1 # find a longest derangement + every *(aList := !anagrams) > 1 do + if derangement := derange(aList) then + if longest <:= *derangement[1] then long := derangement + + every writes((!\long||" ")|"\n") # show longest +end + +procedure derange(aList) # Return a single derangement from this list + while aWord := get(aList) do return noMatch(aWord, !aList) +end + +procedure noMatch(s1,s2) # Produce pair only if s1,s2 are deranged. + every i := 1 to *s1 do if s1[i] == s2[i] then fail + return [s1,s2] +end diff --git a/Task/Anagrams-Deranged-anagrams/J/anagrams-deranged-anagrams.j b/Task/Anagrams-Deranged-anagrams/J/anagrams-deranged-anagrams.j new file mode 100644 index 0000000000..a10727688c --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/J/anagrams-deranged-anagrams.j @@ -0,0 +1,14 @@ + #words=: <;._2 ] 1!:1 <'unixdict.txt' +25104 + #anagrams=: (#~ 1 < #@>) () words +1303 + #maybederanged=: (#~ (1 -.@e. #@~."1)@|:@:>&>) anagrams +432 + #longest=: (#~ [: (= >./) #@>@{.@>) maybederanged +1 + longest +┌───────────────────────┐ +│┌──────────┬──────────┐│ +││excitation│intoxicate││ +│└──────────┴──────────┘│ +└───────────────────────┘ diff --git a/Task/Anagrams-Deranged-anagrams/K/anagrams-deranged-anagrams.k b/Task/Anagrams-Deranged-anagrams/K/anagrams-deranged-anagrams.k new file mode 100644 index 0000000000..03749beaaf --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/K/anagrams-deranged-anagrams.k @@ -0,0 +1,7 @@ + / anagram clusters + a:{x g@&1<#:'g:={x@ 0 + j = instr(a$,c10$,i) + ln = j - i + again = 1 + sWord$ = mid$(a$,i,j-i) + n = n + 1 + theWord$(n) = sWord$ + + while again = 1 + again = 0 + for kk = 1 to len(sWord$) - 1 + if mid$(sWord$,kk,1) > mid$(sWord$,kk +1,1) then + sWord$ = left$(sWord$,kk-1);mid$(sWord$,kk+1,1);mid$(sWord$,kk,1);mid$(sWord$,kk+2) + again = 1 + end if + next kk + wend + ssWord$(n) = sWord$ + i = j + 1 +wend +print "Checking for deranged anagrams." +for i = 1 to n + if len(theWord$(i)) > maxLen then + for j = 1 to n + if ssWord$(i) = ssWord$(j) and i <> j then + cnt = 0 + for k = 1 to len(theWord$(i)) + if mid$(theWord$(i),k,1) = mid$(theWord$(j),k,1) then cnt = cnt + 1 + next k + if cnt = 0 then + maxLen = len(theWord$(i)) + maxPtrI = i + maxPtrJ = j + end if + end if + next j + end if +next i + +print theWord$(maxPtrI);" => ";theWord$(maxPtrJ) +end diff --git a/Task/Anagrams-Deranged-anagrams/Mathematica/anagrams-deranged-anagrams.mathematica b/Task/Anagrams-Deranged-anagrams/Mathematica/anagrams-deranged-anagrams.mathematica new file mode 100644 index 0000000000..5e43a775c5 --- /dev/null +++ b/Task/Anagrams-Deranged-anagrams/Mathematica/anagrams-deranged-anagrams.mathematica @@ -0,0 +1,6 @@ +words=First/@Import["http://www.puzzlers.org/pub/wordlists/unixdict.txt","Table"]; +anagramDegrangement=Function[{w1,w2}, + Module[{c1=ToCharacterCode@w1,c2=ToCharacterCode@w2}, + Sort@c1==Sort@c2&&Select[c1-c2,#==0&,1]==={}]]; +gs=Select[GatherBy[words,{StringLength@#,Union@ToCharacterCode@#}&],Length@#>=2&]; +First@Flatten[Function[ws,Select[Join@@Outer[List,ws,ws,1],anagramDegrangement@@#&]]/@SortBy[gs,-StringLength@First@#&],1] diff --git a/Task/Anagrams/Fantom/anagrams-1.fantom b/Task/Anagrams/Fantom/anagrams-1.fantom new file mode 100644 index 0000000000..513ba49326 --- /dev/null +++ b/Task/Anagrams/Fantom/anagrams-1.fantom @@ -0,0 +1,43 @@ +class Main +{ + // take given word and return a string rearranging characters in order + static Str toOrderedChars (Str word) + { + Str[] chars := [,] + word.each |Int c| { chars.add (c.toChar) } + return chars.sort.join("") + } + + // add given word to anagrams map + static Void addWord (Str:Str[] anagrams, Str word) + { + Str orderedWord := toOrderedChars (word) + if (anagrams.containsKey (orderedWord)) + anagrams[orderedWord].add (word) + else + anagrams[orderedWord] = [word] + } + + public static Void main () + { + Str:Str[] anagrams := [:] // map Str -> Str[] + // loop through input file, adding each word to map of anagrams + File (`unixdict.txt`).eachLine |Str word| + { + addWord (anagrams, word) + } + // loop through anagrams, keeping the keys with values of largest size + Str[] largestKeys := [,] + anagrams.keys.each |Str k| + { + if ((largestKeys.size < 1) || (anagrams[k].size == anagrams[largestKeys[0]].size)) + largestKeys.add (k) + else if (anagrams[k].size > anagrams[largestKeys[0]].size) + largestKeys = [k] + } + largestKeys.each |Str k| + { + echo ("Key: $k -> " + anagrams[k].join(", ")) + } + } +} diff --git a/Task/Anagrams/Fantom/anagrams-2.fantom b/Task/Anagrams/Fantom/anagrams-2.fantom new file mode 100644 index 0000000000..45a08d570b --- /dev/null +++ b/Task/Anagrams/Fantom/anagrams-2.fantom @@ -0,0 +1,175 @@ +!*************************************************************************************** + module anagram_routines +!*************************************************************************************** + implicit none + + !the dictionary file: + integer,parameter :: file_unit = 1000 + character(len=*),parameter :: filename = 'unixdict.txt' + + !maximum number of characters in a word: + integer,parameter :: max_chars = 50 + + !maximum number of characters in the string displaying the anagram lists: + integer,parameter :: str_len = 256 + + type word + character(len=max_chars) :: str = repeat(' ',max_chars) !the word from the dictionary + integer :: n = 0 !length of this word + integer :: n_anagrams = 0 !number of anagrams found + logical :: checked = .false. !if this one has already been checked + character(len=str_len) :: anagrams = repeat(' ',str_len) !the anagram list for this word + end type word + + !the dictionary structure: + type(word),dimension(:),allocatable,target :: dict + + contains +!*************************************************************************************** + + !****************************************************************************** + function count_lines_in_file(fid) result(n_lines) + !****************************************************************************** + implicit none + + integer :: n_lines + integer,intent(in) :: fid + character(len=1) :: tmp + integer :: i + integer :: ios + + !the file is assumed to be open already. + + rewind(fid) !rewind to beginning of the file + + n_lines = 0 + do !read each line until the end of the file. + read(fid,'(A1)',iostat=ios) tmp + if (ios < 0) exit !End of file + n_lines = n_lines + 1 !row counter + end do + + rewind(fid) !rewind to beginning of the file + + !****************************************************************************** + end function count_lines_in_file + !****************************************************************************** + + !****************************************************************************** + pure elemental function is_anagram(x,y) + !****************************************************************************** + implicit none + character(len=*),intent(in) :: x + character(len=*),intent(in) :: y + logical :: is_anagram + + character(len=len(x)) :: x_tmp !a copy of x + integer :: i,j + + !a character not found in any word: + character(len=1),parameter :: null = achar(0) + + !x and y are assumed to be the same size. + + x_tmp = x + do i=1,len_trim(x) + j = index(x_tmp, y(i:i)) !look for this character in x_tmp + if (j/=0) then + x_tmp(j:j) = null !clear it so it won't be checked again + else + is_anagram = .false. !character not found: x,y are not anagrams + return + end if + end do + + !if we got to this point, all the characters + ! were the same, so x,y are anagrams: + is_anagram = .true. + + !****************************************************************************** + end function is_anagram + !****************************************************************************** + +!*************************************************************************************** + end module anagram_routines +!*************************************************************************************** + +!*************************************************************************************** + program main +!*************************************************************************************** + use anagram_routines + implicit none + + integer :: n,i,j,n_max + type(word),pointer :: x,y + logical :: first_word + real :: start, finish + + call cpu_time(start) !..start timer + + !open the dictionary and read in all the words: + open(unit=file_unit,file=filename) !open the file + n = count_lines_in_file(file_unit) !count lines in the file + allocate(dict(n)) !allocate dictionary structure + do i=1,n ! + read(file_unit,'(A)') dict(i)%str !each line is a word in the dictionary + dict(i)%n = len_trim(dict(i)%str) !saving length here to avoid trim's below + end do + close(file_unit) !close the file + + !search dictionary for anagrams: + do i=1,n + + x => dict(i) !pointer to simplify code + first_word = .true. !initialize + + do j=i,n + + y => dict(j) !pointer to simplify code + + !checks to avoid checking words unnecessarily: + if (x%checked .or. y%checked) cycle !both must not have been checked already + if (x%n/=y%n) cycle !must be the same size + if (x%str(1:x%n)==y%str(1:y%n)) cycle !can't be the same word + + ! check to see if x,y are anagrams: + if (is_anagram(x%str(1:x%n), y%str(1:y%n))) then + !they are anagrams. + y%checked = .true. !don't check this one again. + x%n_anagrams = x%n_anagrams + 1 + if (first_word) then + !this is the first anagram found for this word. + first_word = .false. + x%n_anagrams = x%n_anagrams + 1 + x%anagrams = trim(x%anagrams)//x%str(1:x%n) !add first word to list + end if + x%anagrams = trim(x%anagrams)//','//y%str(1:y%n) !add next word to list + end if + + end do + x%checked = .true. !don't check this one again + + end do + + !anagram groups with the most words: + write(*,*) '' + n_max = maxval(dict%n_anagrams) + do i=1,n + if (dict(i)%n_anagrams==n_max) write(*,'(A)') trim(dict(i)%anagrams) + end do + + !anagram group containing longest words: + write(*,*) '' + n_max = maxval(dict%n, mask=dict%n_anagrams>0) + do i=1,n + if (dict(i)%n_anagrams>0 .and. dict(i)%n==n_max) write(*,'(A)') trim(dict(i)%anagrams) + end do + write(*,*) '' + + call cpu_time(finish) !...stop timer + write(*,'(A,F6.3,A)') '[Runtime = ',finish-start,' sec]' + write(*,*) '' + +!*************************************************************************************** + end program main +!*************************************************************************************** diff --git a/Task/Anagrams/GAP/anagrams.gap b/Task/Anagrams/GAP/anagrams.gap new file mode 100644 index 0000000000..4d9f7776d5 --- /dev/null +++ b/Task/Anagrams/GAP/anagrams.gap @@ -0,0 +1,53 @@ +Anagrams := function(name) + local f, p, L, line, word, words, swords, res, cur, r; + words := [ ]; + swords := [ ]; + f := InputTextFile(name); + while true do + line := ReadLine(f); + if line = fail then + break; + else + word := Chomp(line); + Add(words, word); + Add(swords, SortedList(word)); + fi; + od; + CloseStream(f); + p := SortingPerm(swords); + L := Permuted(words, p); + r := ""; + cur := [ ]; + res := [ ]; + for word in L do + if SortedList(word) = r then + Add(cur, word); + else + if Length(cur) > 0 then + Add(res, cur); + fi; + r := SortedList(word); + cur := [ word ]; + fi; + od; + if Length(cur) > 0 then + Add(res, cur); + fi; + return Filtered(res, v -> Length(v) > 1); +end; + + +ana := Anagrams("my/gap/unixdict.txt");; + +# What is the longest anagram sequence ? +Maximum(List(ana, Length)); +# 5 + +# Which are they ? +Filtered(ana, v -> Length(v) = 5); +# [ [ "abel", "able", "bale", "bela", "elba" ], +# [ "caret", "carte", "cater", "crate", "trace" ], +# [ "angel", "angle", "galen", "glean", "lange" ], +# [ "alger", "glare", "lager", "large", "regal" ], +# [ "elan", "lane", "lean", "lena", "neal" ], +# [ "evil", "levi", "live", "veil", "vile" ] ] diff --git a/Task/Anagrams/Icon/anagrams-1.icon b/Task/Anagrams/Icon/anagrams-1.icon new file mode 100644 index 0000000000..b641e81895 --- /dev/null +++ b/Task/Anagrams/Icon/anagrams-1.icon @@ -0,0 +1,34 @@ +procedure main(args) + every writeSet(!getLongestAnagramSets()) +end + +procedure getLongestAnagramSets() + wordSets := table() + longestWSet := 0 + longSets := set() + + every word := !&input do { + wChars := csort(word) + /wordSets[wChars] := set() + insert(wordSets[wChars], word) + + if 1 < *wordSets[wChars} == longestWSet then + insert(longSets, wordSets[wChars]) + if 1 < *wordSets[wChars} > longestWSet then { + longestWSet := *wordSets[wChars} + longSets := set([wordSets[wChars]]) + } + } + + return longSets +end + +procedure writeSet(words) + every writes("\t"|!words," ") + write() +end + +procedure csort(w) + every (s := "") ||:= (find(c := !cset(w),w),c) + return s +end diff --git a/Task/Anagrams/Icon/anagrams-2.icon b/Task/Anagrams/Icon/anagrams-2.icon new file mode 100644 index 0000000000..8b5d6a5b67 --- /dev/null +++ b/Task/Anagrams/Icon/anagrams-2.icon @@ -0,0 +1,14 @@ + (#~ a: ~: {:"1) (]/.~ /:~&>) <;._2 ] 1!:1 <'unixdict.txt' ++-----+-----+-----+-----+-----+ +|abel |able |bale |bela |elba | ++-----+-----+-----+-----+-----+ +|alger|glare|lager|large|regal| ++-----+-----+-----+-----+-----+ +|angel|angle|galen|glean|lange| ++-----+-----+-----+-----+-----+ +|caret|carte|cater|crate|trace| ++-----+-----+-----+-----+-----+ +|elan |lane |lean |lena |neal | ++-----+-----+-----+-----+-----+ +|evil |levi |live |veil |vile | ++-----+-----+-----+-----+-----+ diff --git a/Task/Anagrams/Icon/anagrams-3.icon b/Task/Anagrams/Icon/anagrams-3.icon new file mode 100644 index 0000000000..c2984e170e --- /dev/null +++ b/Task/Anagrams/Icon/anagrams-3.icon @@ -0,0 +1 @@ + <;._2 ] 1!:1 <'unixdict.txt' diff --git a/Task/Anagrams/Icon/anagrams-4.icon b/Task/Anagrams/Icon/anagrams-4.icon new file mode 100644 index 0000000000..4a8673f037 --- /dev/null +++ b/Task/Anagrams/Icon/anagrams-4.icon @@ -0,0 +1 @@ + (]/.~ /:~&>) diff --git a/Task/Anagrams/Icon/anagrams-5.icon b/Task/Anagrams/Icon/anagrams-5.icon new file mode 100644 index 0000000000..6fb29c20e3 --- /dev/null +++ b/Task/Anagrams/Icon/anagrams-5.icon @@ -0,0 +1 @@ + (#~ a: ~: {:"1) diff --git a/Task/Anagrams/K/anagrams.k b/Task/Anagrams/K/anagrams.k new file mode 100644 index 0000000000..49ff9837b0 --- /dev/null +++ b/Task/Anagrams/K/anagrams.k @@ -0,0 +1 @@ +{x@&a=|/a:#:'x}{x g@&1<#:'g:={x@0),1, + [$3(substr([$1],0,$2))[]eachline(substr([$1],incr($2)),[$3])])]) +define([eachline],[eachlineA([$1],index($1,[ +]),[$2])]) +define([removefirst], + [substr([$1],0,$2)[]substr([$1],incr($2))]) +define([checkfirst], + [ifelse(eval(index([$2],substr([$1],0,1))<0),1, + 0, + [ispermutation(substr([$1],1), + removefirst([$2],index([$2],substr([$1],0,1))))])]) +define([ispermutation], + [ifelse([$1],[$2],1, + eval(len([$1])!=len([$2])),1,0, + len([$1]),0,0, + [checkfirst([$1],[$2])])]) +define([_set],[define($1<$2>,$3)]) +define([_get],[defn([$1<$2>])]) +define([_max],1) +define([_n],0) +define([matchj], + [_set([count],$2,incr(_get([count],$2)))[]ifelse(eval(_get([count],$2)>_max), + 1,[define([_max],incr(_max))])[]_set([list],$2,[_get([list],$2) $1])]) +define([checkwordj], + [ifelse(ispermutation([$1],_get([word],$2)),1,[matchj([$1],$2)], + [addwordj([$1],incr($2))])]) +define([_append], + [_set([word],_n,[$1])[]_set([count],_n,1)[]_set([list],_n, + [$1 ])[]define([_n],incr(_n))]) +define([addwordj], + [ifelse($2,_n,[_append([$1])],[checkwordj([$1],$2)])]) +define([addword], + [addwordj([$1],0)]) +divert +eachline(_bar,[addword]) +_max +for([x],1,_n,[ifelse(_get([count],x),_max,[_get([list],x) +])]) diff --git a/Task/Anagrams/MUMPS/anagrams.mumps b/Task/Anagrams/MUMPS/anagrams.mumps new file mode 100644 index 0000000000..9fb21b0a45 --- /dev/null +++ b/Task/Anagrams/MUMPS/anagrams.mumps @@ -0,0 +1,35 @@ +Anagrams New ii,file,longest,most,sorted,word + Set file="unixdict.txt" + Open file:"r" Use file + For Quit:$ZEOF DO + . New char,sort + . Read word Quit:word="" + . For ii=1:1:$Length(word) Do + . . Set char=$ASCII(word,ii) + . . If char>64,char<91 Set char=char+32 + . . Set sort(char)=$Get(sort(char))+1 + . . Quit + . Set (sorted,char)="" For Set char=$Order(sort(char)) Quit:char="" Do + . . For ii=1:1:sort(char) Set sorted=sorted_$Char(char) + . . Quit + . Set table(sorted,word)=1 + . Quit + Close file + Set sorted="" For Set sorted=$Order(table(sorted)) Quit:sorted="" Do + . Set ii=0,word="" For Set word=$Order(table(sorted,word)) Quit:word="" Set ii=ii+1 + . Quit:ii<2 + . Set most(ii,sorted)=1 + . Quit + Write !,"The anagrams with the most variations:" + Set ii=$Order(most(""),-1) + Set sorted="" For Set sorted=$Order(most(ii,sorted)) Quit:sorted="" Do + . Write ! Set word="" For Set word=$Order(table(sorted,word)) Quit:word="" Write " ",word + . Quit + Write !,"The longest anagrams:" + Set ii=$Order(longest(""),-1) + Set sorted="" For Set sorted=$Order(longest(ii,sorted)) Quit:sorted="" Do + . Write ! Set word="" For Set word=$Order(table(sorted,word)) Quit:word="" Write " ",word + . Quit + Quit + +Do Anagrams diff --git a/Task/Anagrams/Maple/anagrams-1.maple b/Task/Anagrams/Maple/anagrams-1.maple new file mode 100644 index 0000000000..3b4d54e6d8 --- /dev/null +++ b/Task/Anagrams/Maple/anagrams-1.maple @@ -0,0 +1,7 @@ +words := HTTP:-Get( "http://www.puzzlers.org/pub/wordlists/unixdict.txt" )[2]: # ignore errors +use StringTools, ListTools in + T := Classify( Sort, map( Trim, Split( words ) ) ) +end use: +L := convert( T, 'list' ): +m := max( map( nops, L ) ); # what is the largest set? +A := select( s -> evalb( nops( s ) = m ), L ); # get the maximal sets of anagrams diff --git a/Task/Anagrams/Maple/anagrams-2.maple b/Task/Anagrams/Maple/anagrams-2.maple new file mode 100644 index 0000000000..3571188c70 --- /dev/null +++ b/Task/Anagrams/Maple/anagrams-2.maple @@ -0,0 +1,4 @@ +A := [{"abel", "able", "bale", "bela", "elba"}, {"angel", "angle", "galen", +"glean", "lange"}, {"alger", "glare", "lager", "large", "regal"}, {"evil", +"levi", "live", "veil", "vile"}, {"caret", "carte", "cater", "crate", "trace"} +, {"elan", "lane", "lean", "lena", "neal"}]; diff --git a/Task/Anagrams/Mathematica/anagrams-1.mathematica b/Task/Anagrams/Mathematica/anagrams-1.mathematica new file mode 100644 index 0000000000..254a3f2cd2 --- /dev/null +++ b/Task/Anagrams/Mathematica/anagrams-1.mathematica @@ -0,0 +1,6 @@ +list=Import["http://www.puzzlers.org/pub/wordlists/unixdict.txt","Lines"]; +text={#,StringJoin@@Sort[Characters[#]]}&/@list; +text=SortBy[text,#[[2]]&]; +splits=Split[text,#1[[2]]==#2[[2]]&][[All,All,1]]; +maxlen=Max[Length/@splits]; +Select[splits,Length[#]==maxlen&] diff --git a/Task/Anagrams/Mathematica/anagrams-2.mathematica b/Task/Anagrams/Mathematica/anagrams-2.mathematica new file mode 100644 index 0000000000..ab7103a5ac --- /dev/null +++ b/Task/Anagrams/Mathematica/anagrams-2.mathematica @@ -0,0 +1 @@ +{{abel,able,bale,bela,elba},{caret,carte,cater,crate,trace},{angel,angle,galen,glean,lange},{alger,glare,lager,large,regal},{elan,lane,lean,lena,neal},{evil,levi,live,veil,vile}} diff --git a/Task/Anagrams/Mathematica/anagrams-3.mathematica b/Task/Anagrams/Mathematica/anagrams-3.mathematica new file mode 100644 index 0000000000..0cf25f709b --- /dev/null +++ b/Task/Anagrams/Mathematica/anagrams-3.mathematica @@ -0,0 +1,3 @@ +splits = Gather[list, Sort[Characters[#]] == Sort[Characters[#2]] &]; +maxlen = Max[Length /@ splits]; +Select[splits, Length[#] == maxlen &] diff --git a/Task/Anagrams/Mathematica/anagrams-4.mathematica b/Task/Anagrams/Mathematica/anagrams-4.mathematica new file mode 100644 index 0000000000..4a10c9a512 --- /dev/null +++ b/Task/Anagrams/Mathematica/anagrams-4.mathematica @@ -0,0 +1,2 @@ +anagramGroups = GatherBy[SortBy[GatherBy[list,Sort[Characters[#]] &],Length],Length]; +anagramGroups[[-1]] diff --git a/Task/Anagrams/Maxima/anagrams.maxima b/Task/Anagrams/Maxima/anagrams.maxima new file mode 100644 index 0000000000..bdcbaa4105 --- /dev/null +++ b/Task/Anagrams/Maxima/anagrams.maxima @@ -0,0 +1,39 @@ +read_file(name) := block([file, s, L], file: openr(name), L: [], +while stringp(s: readline(file)) do L: cons(s, L), close(file), L)$ + +u: read_file("C:/my/mxm/unixdict.txt")$ + +v: map(lambda([s], [ssort(s), s]), u)$ + +w: sort(v, lambda([x, y], orderlessp(x[1], y[1])))$ + +ana(L) := block([m, n, p, r, u, v, w], +L: endcons(["", ""], L), +n: length(L), +r: "", +m: 0, +v: [ ], +w: [ ], +for i from 1 thru n do ( + u: L[i], + if r = u[1] then ( + w: cons(u[2], w) + ) else ( + p: length(w), + if p >= m then ( + if p > m then (m: p, v: []), + v: cons(w, v) + ), + w: [u[2]], + r: u[1] + ) +), +v)$ + +ana(w); +/* [["evil", "levi", "live", "veil", "vile"], + ["elan", "lane", "lean", "lena", "neal"], + ["alger", "glare", "lager", "large", "regal"], + ["angel", "angle", "galen", "glean", "lange"], + ["caret", "carte", "cater", "crate", "trace"], + ["abel", "able", "bale", "bela", "elba"]] */ diff --git a/Task/Animate-a-pendulum/Factor/animate-a-pendulum.factor b/Task/Animate-a-pendulum/Factor/animate-a-pendulum.factor new file mode 100644 index 0000000000..b78633bc1a --- /dev/null +++ b/Task/Animate-a-pendulum/Factor/animate-a-pendulum.factor @@ -0,0 +1,41 @@ +USING: accessors alarms arrays calendar colors.constants kernel +locals math math.constants math.functions math.rectangles +math.vectors opengl sequences system ui ui.gadgets ui.render ; +IN: pendulum + +CONSTANT: g 9.81 +CONSTANT: l 20 +CONSTANT: theta0 0.5 + +: current-time ( -- time ) nano-count -9 10^ * ; + +: T0 ( -- T0 ) 2 pi l g / sqrt * * ; +: omega0 ( -- omega0 ) 2 pi * T0 / ; +: theta ( -- theta ) current-time omega0 * cos theta0 * ; + +: relative-xy ( theta l -- xy ) + [ [ sin ] [ cos ] bi ] + [ [ * ] curry ] bi* bi@ 2array ; +: theta-to-xy ( origin theta l -- xy ) relative-xy v+ ; + +TUPLE: pendulum-gadget < gadget alarm ; + +: O ( gadget -- origin ) rect-bounds [ drop ] [ first 2 / ] bi* 0 2array ; +: window-l ( gadget -- l ) rect-bounds [ drop ] [ second ] bi* ; +: gadget-xy ( gadget -- xy ) [ O ] [ drop theta ] [ window-l ] tri theta-to-xy ; + +M: pendulum-gadget draw-gadget* + COLOR: black gl-color + [ O ] [ gadget-xy ] bi gl-line ; + +M:: pendulum-gadget graft* ( gadget -- ) + [ gadget relayout-1 ] + 20 milliseconds every gadget (>>alarm) ; +M: pendulum-gadget ungraft* alarm>> cancel-alarm ; + +: ( -- gadget ) + pendulum-gadget new + { 500 500 } >>pref-dim ; +: pendulum-main ( -- ) + [ "pendulum" open-window ] with-ui ; +MAIN: pendulum-main diff --git a/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-1.hicest b/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-1.hicest new file mode 100644 index 0000000000..94d258376e --- /dev/null +++ b/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-1.hicest @@ -0,0 +1,33 @@ +REAL :: msec=10, Lrod=1, dBob=0.03, g=9.81, Theta(2), dTheta(2) +BobMargins = ALIAS(ls, rs, ts, bs) ! box margins to draw the bob + + +Theta = (1, 0) ! initial angle and velocity +start_t = TIME() + +DO i = 1, 1E100 ! "forever" + end_t = TIME() ! to integrate in real-time sections: + DIFFEQ(Callback="pendulum", T=end_t, Y=Theta, DY=dTheta, T0=start_t) + xBob = (SIN(Theta(1)) + 1) / 2 + yBob = COS(Theta(1)) - dBob + + ! create or clear window and draw pendulum bob at (xBob, yBob): + WINDOW(WIN=wh, LeftSpace=0, RightSpace=0, TopSpace=0, BottomSpace=0, Up=999) + BobMargins = (xBob-dBob, 1-xBob-dBob, yBob-dBob, 1-yBob-dBob) + WINDOW(WIN=wh, LeftSpace=ls, RightSpace=rs, TopSpace=ts, BottomSpace=bs) + WRITE(WIN=wh, DeCoRation='EL=4, BC=4') ! flooded red ellipse as bob + + ! draw the rod hanging from the center of the window: + WINDOW(WIN=wh, LeftSpace=0.5, TopSpace=0, RightSpace=rs+dBob) + WRITE(WIN=wh, DeCoRation='LI=0 0; 1 1, FC=4.02') ! red pendulum rod + + SYSTEM(WAIT=msec) + start_t = end_t +ENDDO + +END + +SUBROUTINE pendulum ! Theta" = - (g/Lrod) * SIN(Theta) + dTheta(1) = Theta(2) ! Theta' = Theta(2) substitution + dTheta(2) = -g/Lrod*SIN(Theta(1)) ! Theta" = Theta(2)' = -g/Lrod*SIN(Theta(1)) +END diff --git a/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-2.hicest b/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-2.hicest new file mode 100644 index 0000000000..1bc0e48f59 --- /dev/null +++ b/Task/Animate-a-pendulum/HicEst/animate-a-pendulum-2.hicest @@ -0,0 +1,93 @@ +import gui +$include "guih.icn" + +# some constants to define the display and pendulum +$define HEIGHT 400 +$define WIDTH 500 +$define STRING_LENGTH 200 +$define HOME_X 250 +$define HOME_Y 21 +$define SIZE 30 +$define START_ANGLE 80 + +class WindowApp : Dialog () + + # draw the pendulum on given context_window, at position (x,y) + method draw_pendulum (x, y) + # reference to current screen area to draw on + cw := Clone(self.cwin) + + # clear screen + WAttrib (cw, "bg=grey") + EraseRectangle (cw, 0, 0, WIDTH, HEIGHT) + + # draw the display + WAttrib (cw, "fg=dark gray") + DrawLine (cw, 10, 20, WIDTH-20, 20) + WAttrib (cw, "fg=black") + DrawLine (cw, HOME_X, HOME_Y, x, y) + FillCircle (cw, x, y, SIZE+2) + WAttrib (cw, "fg=yellow") + FillCircle (cw, x, y, SIZE) + + # free reference to screen area + Uncouple (cw) + end + + # find the average of given two arguments + method avg (a, b) + return (a + b) / 2 + end + + # this method gets called by the ticker + # it computes the next position of the pendulum and + # requests a redraw + method tick () + static x, y + static theta := START_ANGLE + static d_theta := 0 + # update x,y of pendulum + scaling := 3000.0 / (STRING_LENGTH * STRING_LENGTH) + # -- first estimate + first_dd_theta := -(sin (dtor (theta)) * scaling) + mid_d_theta := d_theta + first_dd_theta + mid_theta := theta + avg (d_theta, mid_d_theta) + # -- second estimate + mid_dd_theta := - (sin (dtor (mid_theta)) * scaling) + mid_d_theta_2 := d_theta + avg (first_dd_theta, mid_dd_theta) + mid_theta_2 := theta + avg (d_theta, mid_d_theta_2) + # -- again first + mid_dd_theta_2 := -(sin (dtor (mid_theta_2)) * scaling) + last_d_theta := mid_d_theta_2 + mid_dd_theta_2 + last_theta := mid_theta_2 + avg (mid_d_theta_2, last_d_theta) + # -- again second + last_dd_theta := - (sin (dtor (last_theta)) * scaling) + last_d_theta_2 := mid_d_theta_2 + avg (mid_dd_theta_2, last_dd_theta) + last_theta_2 := mid_theta_2 + avg (mid_d_theta_2, last_d_theta_2) + # -- update stored angles + d_theta := last_d_theta_2 + theta := last_theta_2 + # -- update x, y + pendulum_angle := dtor (theta) + x := HOME_X + STRING_LENGTH * sin (pendulum_angle) + y := HOME_Y + STRING_LENGTH * cos (pendulum_angle) + + # draw pendulum + draw_pendulum (x, y) + end + + # set up the window + method component_setup () + # some cosmetic settings for the window + attrib("size="||WIDTH||","||HEIGHT, "bg=light gray", "label=Pendulum") + # make sure we respond to window close event + connect (self, "dispose", CLOSE_BUTTON_EVENT) + # start the ticker, to update the display periodically + self.set_ticker (20) + end +end + +procedure main () + w := WindowApp () + w.show_modal () +end diff --git a/Task/Animate-a-pendulum/J/animate-a-pendulum.j b/Task/Animate-a-pendulum/J/animate-a-pendulum.j new file mode 100644 index 0000000000..6d87485676 --- /dev/null +++ b/Task/Animate-a-pendulum/J/animate-a-pendulum.j @@ -0,0 +1,44 @@ +require 'gl2 trig' +coinsert 'jgl2' + +DT =: %30 NB. seconds +ANGLE=: 0.25p1 NB. radians +L =: 1 NB. metres +G =: 9.80665 NB. ms_2 +VEL =: 0 NB. ms_1 + +PEND=: noun define +pc pend;pn "Pendulum"; +xywh 0 0 320 200;cc isi isigraph rightmove bottommove; +pas 0 0;pcenter; +rem form end; +) + +pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1000 ' +pend_close =: verb def ' wd ''timer 0; pclose'' ' +pend_isi_paint=: verb def ' drawPendulum ANGLE ' + +sys_timer_z_=: verb define + recalcAngle '' + wd 'psel pend; setinvalid isi' +) + +recalcAngle=: verb define + accel=. - (G % L) * sin ANGLE + VEL =: VEL + accel * DT + ANGLE=: ANGLE + VEL * DT +) + +drawPendulum=: verb define + width=. {. glqwh'' + ps=. (-: width) , 40 + pe=. ps + 280 <.@* (cos , sin) 0.5p1 + y NB. adjust orientation + glrgb 91 91 91 + glbrush'' + gllines ps , pe + glellipse (,~ ps - -:) 40 15 + glellipse (,~ pe - -:) 20 20 + glrect 0 0 ,width, 40 +) + +pend_run'' NB. run animation diff --git a/Task/Animate-a-pendulum/Liberty-BASIC/animate-a-pendulum.liberty b/Task/Animate-a-pendulum/Liberty-BASIC/animate-a-pendulum.liberty new file mode 100644 index 0000000000..e0b94a4a3a --- /dev/null +++ b/Task/Animate-a-pendulum/Liberty-BASIC/animate-a-pendulum.liberty @@ -0,0 +1,42 @@ +nomainwin + WindowWidth = 400 + WindowHeight = 300 + + open "Pendulum" for graphics_nsb_nf as #main + #main "down;fill white; flush" + #main "color black" + #main "trapclose [quit.main]" + + Angle = asn(1) + DeltaT = 0.1 + PendLength = 150 + FixX = int(WindowWidth / 2) + FixY = 40 + + timer 30, [swing] + + wait + +[swing] + + #main "cls" + #main "discard" + + PlumbobX = FixX + int(sin(Angle) * PendLength) + PlumbobY = FixY + int(cos(Angle) * PendLength) + AngAccel = -9.81 / PendLength * sin(Angle) + AngVelocity = AngVelocity + AngAccel * DeltaT + Angle = Angle + AngVelocity * DeltaT + + #main "backcolor black" + #main "place ";FixX;" ";FixY + #main "circlefilled 3" + #main "line ";FixX;" ";FixY;" ";PlumbobX;" ";PlumbobY + #main "backcolor red" + #main "circlefilled 10" + + wait + +[quit.main] + close #main + end diff --git a/Task/Animate-a-pendulum/Logo/animate-a-pendulum.logo b/Task/Animate-a-pendulum/Logo/animate-a-pendulum.logo new file mode 100644 index 0000000000..d11ac9b32e --- /dev/null +++ b/Task/Animate-a-pendulum/Logo/animate-a-pendulum.logo @@ -0,0 +1,29 @@ +make "angle 45 +make "L 1 +make "bob 10 + +to draw.pendulum + clearscreen + seth :angle+180 ; down on screen is 180 + forward :L*100-:bob + penup + forward :bob + pendown + arc 360 :bob +end + +make "G 9.80665 +make "dt 1/30 +make "acc 0 +make "vel 0 + +to step.pendulum + make "acc -:G / :L * sin :angle + make "vel :vel + :acc * :dt + make "angle :angle + :vel * :dt + wait :dt*60 + draw.pendulum +end + +hideturtle +until [key?] [step.pendulum] diff --git a/Task/Animate-a-pendulum/Mathematica/animate-a-pendulum.mathematica b/Task/Animate-a-pendulum/Mathematica/animate-a-pendulum.mathematica new file mode 100644 index 0000000000..dd0e9591a1 --- /dev/null +++ b/Task/Animate-a-pendulum/Mathematica/animate-a-pendulum.mathematica @@ -0,0 +1,5 @@ +freq = 8; length = freq^(-1/2); +Animate[Graphics[ + List[{Line[{{0, 0}, length {Sin[T], -Cos[T]}} /. {T -> (Pi/6) Cos[2 Pi freq t]}], PointSize[Large], + Point[{length {Sin[T], -Cos[T]}} /. {T -> (Pi/6) Cos[2 Pi freq t]}]}], + PlotRange -> {{-0.3, 0.3}, {-0.5, 0}}], {t, 0, 1}, AnimationRate -> 0.07] diff --git a/Task/Animation/Factor/animation.factor b/Task/Animation/Factor/animation.factor new file mode 100644 index 0000000000..5d2572fcad --- /dev/null +++ b/Task/Animation/Factor/animation.factor @@ -0,0 +1,30 @@ +USING: accessors timers calendar kernel models sequences ui +ui.gadgets ui.gadgets.labels ui.gestures ; +FROM: models => change-model ; +IN: rosetta.animation + +CONSTANT: sentence "Hello World! " + +TUPLE: animated-label < label-control reversed alarm ; +: ( model -- ) + sentence animated-label new-label swap >>model + monospace-font >>font ; +: update-string ( str reverse -- str ) + [ unclip-last prefix ] [ unclip suffix ] if ; +: update-model ( model reversed? -- ) + [ update-string ] curry change-model ; + +animated-label + H{ + { T{ button-down } [ [ not ] change-reversed drop ] } + } set-gestures + +M: animated-label graft* + [ [ [ model>> ] [ reversed>> ] bi update-model ] curry 400 milliseconds every ] keep + alarm<< ; +M: animated-label ungraft* + alarm>> stop-timer ; +: main ( -- ) + [ sentence "Rosetta" open-window ] with-ui ; + +MAIN: main diff --git a/Task/Animation/Fantom/animation.fantom b/Task/Animation/Fantom/animation.fantom new file mode 100644 index 0000000000..b30e834bec --- /dev/null +++ b/Task/Animation/Fantom/animation.fantom @@ -0,0 +1,75 @@ +using concurrent +using fwt +using gfx + +const class RotateString : Actor +{ + new make (Label label) : super (ActorPool ()) + { + Actor.locals["rotate-label"] = label + Actor.locals["rotate-string"] = label.text + Actor.locals["direction"] = "forward" + sendLater (1sec, "update") + } + + // responsible for calling appropriate methods to process each message + override Obj? receive (Obj? msg) + { + switch (msg) + { + case "update": + Desktop.callAsync |->| { update } // make sure we update GUI in event thread + sendLater (1sec, "update") + case "reverse": + Desktop.callAsync |->| { reverse } + } + + return null + } + + // change the stored string indicating the direction to rotate + Void reverse () + { + Actor.locals["direction"] = + (Actor.locals["direction"] == "forward" ? "backward" : "forward") + } + + // update the text on the label according to the stored direction + Void update () + { + label := Actor.locals["rotate-label"] as Label + str := Actor.locals["rotate-string"] as Str + if (label != null) + { + newStr := "" + if (Actor.locals["direction"] == "forward") + newStr = str[1..-1] + str[0].toChar + else + newStr = str[-1].toChar + str[0..<-1] + label.text = newStr + Actor.locals["rotate-string"] = newStr + } + } +} + +class Animate +{ + public static Void main () + { + label := Label + { + text = "Hello world! " + halign = Halign.center + } + ticker := RotateString (label) + label.onMouseDown.add |Event e| + { + ticker.send ("reverse") + } + Window + { + title = "Animate" + label, + }.open + } +} diff --git a/Task/Animation/HicEst/animation-1.hicest b/Task/Animation/HicEst/animation-1.hicest new file mode 100644 index 0000000000..a510f720fc --- /dev/null +++ b/Task/Animation/HicEst/animation-1.hicest @@ -0,0 +1,18 @@ +CHARACTER string="Hello World! " + + WINDOW(WINdowhandle=wh, Height=1, X=1, TItle="left/right click to rotate left/right, Y-click-position sets milliseconds period") + AXIS(WINdowhandle=wh, PoinT=20, X=2048, Y, Title='ms', MiN=0, MaX=400, MouSeY=msec, MouSeCall=Mouse_callback, MouSeButton=button_type) + direction = 4 + msec = 100 ! initial milliseconds + DO tic = 1, 1E20 + WRITE(WIN=wh, Align='Center Vertical') string + IF(direction == 4) string = string(LEN(string)) // string ! rotate left + IF(direction == 8) string = string(2:) // string(1) ! rotate right + WRITE(StatusBar, Name) tic, direction, msec + SYSTEM(WAIT=msec) + ENDDO + END + +SUBROUTINE Mouse_callback() + direction = button_type ! 4 == left button up, 8 == right button up + END diff --git a/Task/Animation/HicEst/animation-2.hicest b/Task/Animation/HicEst/animation-2.hicest new file mode 100644 index 0000000000..e0fad2322e --- /dev/null +++ b/Task/Animation/HicEst/animation-2.hicest @@ -0,0 +1,44 @@ +import gui +$include "guih.icn" + +class WindowApp : Dialog (label, direction) + + method rotate_left (msg) + return msg[2:0] || msg[1] + end + + method rotate_right (msg) + return msg[-1:0] || msg[1:-1] + end + + method reverse_direction () + direction := 1-direction + end + + # this method gets called by the ticker, and updates the label + method tick () + static msg := "Hello World! " + if direction = 0 + then msg := rotate_left (msg) + else msg := rotate_right (msg) + label.set_label(msg) + end + + method component_setup () + direction := 1 # start off rotating to the right + label := Label("label=Hello World! ", "pos=0,0") + # respond to a mouse click on the label + label.connect (self, "reverse_direction", MOUSE_RELEASE_EVENT) + add (label) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + # tick every 100ms + self.set_ticker (100) + end +end + +# create and show the window +procedure main () + w := WindowApp () + w.show_modal () +end diff --git a/Task/Animation/J/animation.j b/Task/Animation/J/animation.j new file mode 100644 index 0000000000..9e655a362c --- /dev/null +++ b/Task/Animation/J/animation.j @@ -0,0 +1,26 @@ +coinsert'jgl2' [ require'gl2' + +MESSAGE =: 'Hello World! ' +TIMER_INTERVAL =: 0.5 * 1000 NB. Milliseconds +DIRECTION =: -1 NB. Initial direction is right --> + +ANIM =: noun define + pc anim nomax nosize;pn "Basic Animation in J"; + xywh 1 1 174 24;cc isi isigraph rightmove bottommove; + pas 0 0;pcenter;pshow; +) + +anim_run =: verb def ' wd ANIM,''; timer '',":TIMER_INTERVAL ' +sys_timer_z_ =: verb def ' isiMsg MESSAGE=: DIRECTION |. MESSAGE ' NB. Rotate MESSAGE according to DIRECTION +anim_isi_mbldown =: verb def ' DIRECTION=: - DIRECTION ' NB. Reverse direction when user clicks +anim_close =: verb def ' wd ''timer 0; pclose; reset;'' ' NB. Shut down timer + +isiMsg =: verb define + wd'psel anim' + glclear '' NB. Clear out old drawing + glfont '"courier new" 36' + gltext y + glpaint '' NB. Copy to screen +) + +anim_run '' diff --git a/Task/Animation/Liberty-BASIC/animation.liberty b/Task/Animation/Liberty-BASIC/animation.liberty new file mode 100644 index 0000000000..db90c0e165 --- /dev/null +++ b/Task/Animation/Liberty-BASIC/animation.liberty @@ -0,0 +1,34 @@ + txt$ = "Hello World! " + txtLength = len(txt$) + direction=1 + + NoMainWin + + open "Rosetta Task: Animation" for graphics_nsb as #demo + #demo "Trapclose [quit]" + #demo "down" + #demo "Font Verdana 20 Bold" + #demo "When leftButtonUp [changedirection]" + + timer 150 , [draw] + wait + +[draw] + if direction then + txt$ = right$(txt$, 1);left$(txt$, txtLength - 1) + else + txt$ = right$(txt$, txtLength - 1);left$(txt$, 1) + end if + #demo "discard" + #demo "place 50 100" + #demo "\";txt$ + wait + +[changedirection] + direction = not(direction) + wait + +[quit] + timer 0 + close #demo + end diff --git a/Task/Animation/Logo/animation.logo b/Task/Animation/Logo/animation.logo new file mode 100644 index 0000000000..406378d137 --- /dev/null +++ b/Task/Animation/Logo/animation.logo @@ -0,0 +1,20 @@ +to rotate.left :thing + output lput first :thing butfirst :thing +end +to rotate.right :thing + output fput last :thing butlast :thing +end + +make "text "|Hello World! | +make "right? "true + +to step.animation + label :text ; graphical + ; type char 13 type :text ; textual + wait 6 ; 1/10 second + if button <> 0 [make "right? not :right?] + make "text ifelse :right? [rotate.right :text] [rotate.left :text] +end + +hideturtle +until [key?] [step.animation] diff --git a/Task/Animation/Mathematica/animation.mathematica b/Task/Animation/Mathematica/animation.mathematica new file mode 100644 index 0000000000..0cbe946196 --- /dev/null +++ b/Task/Animation/Mathematica/animation.mathematica @@ -0,0 +1,10 @@ +mystring = "Hello World! "; +Scroll[str_, dir_] := StringJoin @@ RotateLeft[str // Characters, dir]; +GiveString[dir_] := (mystring = Scroll[mystring, dir]); +CreateDialog[{ + DynamicModule[{direction = -1}, + EventHandler[ + Dynamic[TextCell[ + Refresh[GiveString[direction], UpdateInterval -> 1/8]], + TrackedSymbols -> {}], {"MouseClicked" :> (direction *= -1)}]] + }]; diff --git a/Task/Anonymous-recursion/Factor/anonymous-recursion.factor b/Task/Anonymous-recursion/Factor/anonymous-recursion.factor new file mode 100644 index 0000000000..3f03111770 --- /dev/null +++ b/Task/Anonymous-recursion/Factor/anonymous-recursion.factor @@ -0,0 +1,12 @@ +USING: kernel math ; +IN: rosettacode.fibonacci.ar + +: fib ( n -- m ) + dup 0 < [ "fib of negative" throw ] when + [ + ! If n < 2, then drop q, else find q(n - 1) + q(n - 2). + [ dup 2 < ] dip swap [ drop ] [ + [ [ 1 - ] dip dup call ] + [ [ 2 - ] dip dup call ] 2bi + + ] if + ] dup call( n q -- m ) ; diff --git a/Task/Anonymous-recursion/Falcon/anonymous-recursion.falcon b/Task/Anonymous-recursion/Falcon/anonymous-recursion.falcon new file mode 100644 index 0000000000..01f82d21f0 --- /dev/null +++ b/Task/Anonymous-recursion/Falcon/anonymous-recursion.falcon @@ -0,0 +1,25 @@ +function fib(x) + if x < 0 + raise ParamError(description|"Negative argument invalid", extra|"Fibbonacci sequence is undefined for negative numbers") + else + return (function(y) + if y == 0 + return 0 + elif y == 1 + return 1 + else + return fself(y-1) + fself(y-2) + end + end)(x) + end +end + + +try +>fib(2) +>fib(3) +>fib(4) +>fib(-1) +catch in e +> e +end diff --git a/Task/Anonymous-recursion/Groovy/anonymous-recursion-1.groovy b/Task/Anonymous-recursion/Groovy/anonymous-recursion-1.groovy new file mode 100644 index 0000000000..bcdd7f5964 --- /dev/null +++ b/Task/Anonymous-recursion/Groovy/anonymous-recursion-1.groovy @@ -0,0 +1,4 @@ +def fib = { + assert it > -1 + {i -> i < 2 ? i : {j -> owner.call(j)}(i-1) + {k -> owner.call(k)}(i-2)}(it) +} diff --git a/Task/Anonymous-recursion/Groovy/anonymous-recursion-2.groovy b/Task/Anonymous-recursion/Groovy/anonymous-recursion-2.groovy new file mode 100644 index 0000000000..7bf867554c --- /dev/null +++ b/Task/Anonymous-recursion/Groovy/anonymous-recursion-2.groovy @@ -0,0 +1,9 @@ +def fib0to20 = (0..20).collect(fib) +println fib0to20 + +try { + println fib(-25) +} catch (Throwable e) { + println "KABOOM!!" + println e.message +} diff --git a/Task/Anonymous-recursion/Icon/anonymous-recursion-1.icon b/Task/Anonymous-recursion/Icon/anonymous-recursion-1.icon new file mode 100644 index 0000000000..14cc56a25e --- /dev/null +++ b/Task/Anonymous-recursion/Icon/anonymous-recursion-1.icon @@ -0,0 +1,24 @@ +procedure main(A) + every write("fib(",a := numeric(!A),")=",fib(a)) +end + +procedure fib(n) + local source, i + static cache + initial { + cache := table() + cache[0] := 0 + cache[1] := 1 + } + if type(n) == "integer" & n >= 0 then + return n @ makeProc {{ + i := @(source := &source) # 1 + /cache[i] := ((i-1)@makeProc(^¤t)+(i-2)@makeProc(^¤t)) # 2 + cache[i] @ source # 3 + }} +end + +procedure makeProc(A) + A := if type(A) == "list" then A[1] + return (@A, A) # prime and return +end diff --git a/Task/Anonymous-recursion/Icon/anonymous-recursion-2.icon b/Task/Anonymous-recursion/Icon/anonymous-recursion-2.icon new file mode 100644 index 0000000000..5ffa1ff440 --- /dev/null +++ b/Task/Anonymous-recursion/Icon/anonymous-recursion-2.icon @@ -0,0 +1,9 @@ +procedure fib(n) + local source, i + if type(n) == "integer" & n >= 0 then + return n @ makeProc {{ + i := @(source := &source) + if i = (0|1) then i@source + ((i-1)@makeProc(^¤t) + (i-2)@makeProc(^¤t)) @ source + }} +end diff --git a/Task/Anonymous-recursion/J/anonymous-recursion-1.j b/Task/Anonymous-recursion/J/anonymous-recursion-1.j new file mode 100644 index 0000000000..52f1c2cd0d --- /dev/null +++ b/Task/Anonymous-recursion/J/anonymous-recursion-1.j @@ -0,0 +1 @@ + fibN=: (-&2 +&$: -&1)^:(1&<) M."0 diff --git a/Task/Anonymous-recursion/J/anonymous-recursion-2.j b/Task/Anonymous-recursion/J/anonymous-recursion-2.j new file mode 100644 index 0000000000..e37a577cec --- /dev/null +++ b/Task/Anonymous-recursion/J/anonymous-recursion-2.j @@ -0,0 +1,4 @@ + fibN 12 +144 + fibN i.31 +0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 diff --git a/Task/Anonymous-recursion/K/anonymous-recursion-1.k b/Task/Anonymous-recursion/K/anonymous-recursion-1.k new file mode 100644 index 0000000000..5e386b90a3 --- /dev/null +++ b/Task/Anonymous-recursion/K/anonymous-recursion-1.k @@ -0,0 +1 @@ +fib: {:[x<0; "Error Negative Number"; {:[x<2;x;_f[x-2]+_f[x-1]]}x]} diff --git a/Task/Anonymous-recursion/K/anonymous-recursion-2.k b/Task/Anonymous-recursion/K/anonymous-recursion-2.k new file mode 100644 index 0000000000..ec1dddc5aa --- /dev/null +++ b/Task/Anonymous-recursion/K/anonymous-recursion-2.k @@ -0,0 +1,4 @@ + fib'!10 +0 1 1 2 3 5 8 13 21 34 + fib -1 +"Error Negative Number" diff --git a/Task/Anonymous-recursion/LOLCODE/anonymous-recursion.lol b/Task/Anonymous-recursion/LOLCODE/anonymous-recursion.lol new file mode 100644 index 0000000000..97f5c6a631 --- /dev/null +++ b/Task/Anonymous-recursion/LOLCODE/anonymous-recursion.lol @@ -0,0 +1,32 @@ +HAI 1.3 + +HOW IZ I fib YR x + DIFFRINT x AN BIGGR OF x AN 0, O RLY? + YA RLY, FOUND YR "ERROR" + OIC + + HOW IZ I fib_i YR n + DIFFRINT n AN BIGGR OF n AN 2, O RLY? + YA RLY, FOUND YR n + OIC + + FOUND YR SUM OF... + I IZ fib_i YR DIFF OF n AN 2 MKAY AN... + I IZ fib_i YR DIFF OF n AN 1 MKAY + IF U SAY SO + + FOUND YR I IZ fib_i YR x MKAY +IF U SAY SO + +HOW IZ I fib_i YR n + VISIBLE "SRY U CANT HAS FIBS DIS TIEM" +IF U SAY SO + +IM IN YR fibber UPPIN YR i TIL BOTH SAEM i AN 5 + I HAS A i ITZ DIFF OF i AN 1 + VISIBLE "fib(:{i}) = " I IZ fib YR i MKAY +IM OUTTA YR fibber + +I IZ fib_i YR 3 MKAY + +KTHXBYE diff --git a/Task/Anonymous-recursion/Maple/anonymous-recursion-1.maple b/Task/Anonymous-recursion/Maple/anonymous-recursion-1.maple new file mode 100644 index 0000000000..61c0050ce9 --- /dev/null +++ b/Task/Anonymous-recursion/Maple/anonymous-recursion-1.maple @@ -0,0 +1,13 @@ +Fib := proc( n :: nonnegint ) + proc( k ) + option remember; # automatically memoise + if k = 0 then + 0 + elif k = 1 then + 1 + else + # Recurse, anonymously + thisproc( k - 1 ) + thisproc( k - 2 ) + end + end( n ) +end proc: diff --git a/Task/Anonymous-recursion/Maple/anonymous-recursion-2.maple b/Task/Anonymous-recursion/Maple/anonymous-recursion-2.maple new file mode 100644 index 0000000000..e484c83368 --- /dev/null +++ b/Task/Anonymous-recursion/Maple/anonymous-recursion-2.maple @@ -0,0 +1,6 @@ +> seq( Fib( i ), i = 0 .. 10 ); + 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 + +> Fib( -1 ); +Error, invalid input: Fib expects its 1st argument, n, to be of type +nonnegint, but received -1 diff --git a/Task/Anonymous-recursion/Mathematica/anonymous-recursion-1.mathematica b/Task/Anonymous-recursion/Mathematica/anonymous-recursion-1.mathematica new file mode 100644 index 0000000000..e4f33cafc1 --- /dev/null +++ b/Task/Anonymous-recursion/Mathematica/anonymous-recursion-1.mathematica @@ -0,0 +1,5 @@ +check := #<0& +fib := If[check[#],Throw["Negative Argument"],If[#<=1,1,#0[#-2]+#0[#-1]]&[#]]& +fib /@ Range[0,10] + +{1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89} diff --git a/Task/Anonymous-recursion/Mathematica/anonymous-recursion-2.mathematica b/Task/Anonymous-recursion/Mathematica/anonymous-recursion-2.mathematica new file mode 100644 index 0000000000..cca6c296be --- /dev/null +++ b/Task/Anonymous-recursion/Mathematica/anonymous-recursion-2.mathematica @@ -0,0 +1,9 @@ +check := (Print[#];#<0)& +fib /@ Range[0,4] +0 +1 +2 +3 +4 + +{1, 1, 2, 3, 5} diff --git a/Task/Apply-a-callback-to-an-array/FP/apply-a-callback-to-an-array.fp b/Task/Apply-a-callback-to-an-array/FP/apply-a-callback-to-an-array.fp new file mode 100644 index 0000000000..1d532fb60e --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/FP/apply-a-callback-to-an-array.fp @@ -0,0 +1,2 @@ +{square * . [id, id]} +& square: <1,2,3,4,5> diff --git a/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-1.factor b/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-1.factor new file mode 100644 index 0000000000..ae531e7582 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-1.factor @@ -0,0 +1 @@ +{ 1 2 3 4 } [ sq . ] each diff --git a/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-2.factor b/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-2.factor new file mode 100644 index 0000000000..e771252412 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Factor/apply-a-callback-to-an-array-2.factor @@ -0,0 +1 @@ +{ 1 2 3 4 } [ sq ] map diff --git a/Task/Apply-a-callback-to-an-array/Fantom/apply-a-callback-to-an-array.fantom b/Task/Apply-a-callback-to-an-array/Fantom/apply-a-callback-to-an-array.fantom new file mode 100644 index 0000000000..5cddd37de8 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Fantom/apply-a-callback-to-an-array.fantom @@ -0,0 +1,9 @@ +class Main +{ + public static Void main () + { + [1,2,3,4,5].each |Int i| { echo (i) } + Int[] result := [1,2,3,4,5].map |Int i->Int| { return i * i } + echo (result) + } +} diff --git a/Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap b/Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap new file mode 100644 index 0000000000..4515dd4421 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/GAP/apply-a-callback-to-an-array.gap @@ -0,0 +1,17 @@ +a := [1 .. 4]; +b := ShallowCopy(a); + +# Apply and replace values +Apply(a, n -> n*n); +a; +# [ 1, 4, 9, 16 ] + +# Apply and don't change values +Perform(b, Display); +1 +2 +3 +4 + +b; +# [ 1 .. 4 ] diff --git a/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-1.groovy b/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-1.groovy new file mode 100644 index 0000000000..fdae7779ab --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-1.groovy @@ -0,0 +1 @@ +[1,2,3,4].each { println it } diff --git a/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-2.groovy b/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-2.groovy new file mode 100644 index 0000000000..d2dcad34af --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Groovy/apply-a-callback-to-an-array-2.groovy @@ -0,0 +1 @@ +[1,2,3,4].collect { it * it } diff --git a/Task/Apply-a-callback-to-an-array/IDL/apply-a-callback-to-an-array.idl b/Task/Apply-a-callback-to-an-array/IDL/apply-a-callback-to-an-array.idl new file mode 100644 index 0000000000..139823c5c1 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/IDL/apply-a-callback-to-an-array.idl @@ -0,0 +1 @@ +b = a^3 diff --git a/Task/Apply-a-callback-to-an-array/Icon/apply-a-callback-to-an-array.icon b/Task/Apply-a-callback-to-an-array/Icon/apply-a-callback-to-an-array.icon new file mode 100644 index 0000000000..8d7d5e94ee --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Icon/apply-a-callback-to-an-array.icon @@ -0,0 +1,9 @@ +procedure main() + local lst + lst := [10, 20, 30, 40] + every callback(write,!lst) +end + +procedure callback(p,arg) + return p(" -> ", arg) +end diff --git a/Task/Apply-a-callback-to-an-array/Io/apply-a-callback-to-an-array.io b/Task/Apply-a-callback-to-an-array/Io/apply-a-callback-to-an-array.io new file mode 100644 index 0000000000..dfe4644228 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Io/apply-a-callback-to-an-array.io @@ -0,0 +1 @@ +list(1,2,3,4,5) map(squared) diff --git a/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-1.j b/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-1.j new file mode 100644 index 0000000000..1b96ae1a6f --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-1.j @@ -0,0 +1 @@ + "_1 diff --git a/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-2.j b/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-2.j new file mode 100644 index 0000000000..5d46ec2b57 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/J/apply-a-callback-to-an-array-2.j @@ -0,0 +1,5 @@ + callback =: *: + array =: 1 2 3 4 5 + + callback"_1 array +1 4 9 16 25 diff --git a/Task/Apply-a-callback-to-an-array/Joy/apply-a-callback-to-an-array.joy b/Task/Apply-a-callback-to-an-array/Joy/apply-a-callback-to-an-array.joy new file mode 100644 index 0000000000..640032c15b --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Joy/apply-a-callback-to-an-array.joy @@ -0,0 +1 @@ +[1 2 3 4 5] [dup *] map. diff --git a/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-1.julia b/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-1.julia new file mode 100644 index 0000000000..a80a7e58d2 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-1.julia @@ -0,0 +1,8 @@ +a = [1,2,3,4,5] +julia> map(x -> x*2,a) +5-element Int32 Array: + 2 + 4 + 6 + 8 + 10 diff --git a/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-2.julia b/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-2.julia new file mode 100644 index 0000000000..bf447939a3 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Julia/apply-a-callback-to-an-array-2.julia @@ -0,0 +1,7 @@ +julia> a .* 2 +5-element Int32 Array: + 2 + 4 + 6 + 8 + 10 diff --git a/Task/Apply-a-callback-to-an-array/Lang5/apply-a-callback-to-an-array.lang5 b/Task/Apply-a-callback-to-an-array/Lang5/apply-a-callback-to-an-array.lang5 new file mode 100644 index 0000000000..a694c6f9a2 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Lang5/apply-a-callback-to-an-array.lang5 @@ -0,0 +1,3 @@ +: square(*) dup * ; +[1 2 3 4 5] square . "\n" . +[1 2 3 4 5] 'square apply . "\n" . diff --git a/Task/Apply-a-callback-to-an-array/Lisaac/apply-a-callback-to-an-array.lisaac b/Task/Apply-a-callback-to-an-array/Lisaac/apply-a-callback-to-an-array.lisaac new file mode 100644 index 0000000000..78dbf9456c --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Lisaac/apply-a-callback-to-an-array.lisaac @@ -0,0 +1,14 @@ ++ a : ARRAY(INTEGER); ++ b : {INTEGER;}; + +a := ARRAY(INTEGER).create 1 to 3; +1.to 3 do { i : INTEGER; + a.put i to i; +}; + +b := { arg : INTEGER; + (arg * arg).print; + '\n'.print; +}; + +a.foreach b; diff --git a/Task/Apply-a-callback-to-an-array/Logo/apply-a-callback-to-an-array.logo b/Task/Apply-a-callback-to-an-array/Logo/apply-a-callback-to-an-array.logo new file mode 100644 index 0000000000..6988b111b0 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Logo/apply-a-callback-to-an-array.logo @@ -0,0 +1,6 @@ +to square :x + output :x * :x +end +show map "square [1 2 3 4 5] ; [1 4 9 16 25] +show map [? * ?] [1 2 3 4 5] ; [1 4 9 16 25] +foreach [1 2 3 4 5] [print square ?] ; 1 4 9 16 25, one per line diff --git a/Task/Apply-a-callback-to-an-array/M4/apply-a-callback-to-an-array.m4 b/Task/Apply-a-callback-to-an-array/M4/apply-a-callback-to-an-array.m4 new file mode 100644 index 0000000000..bdc139feff --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/M4/apply-a-callback-to-an-array.m4 @@ -0,0 +1,9 @@ +define(`foreach', `pushdef(`$1')_foreach($@)popdef(`$1')')dnl +define(`_arg1', `$1')dnl +define(`_foreach', `ifelse(`$2', `()', `', + `define(`$1', _arg1$2)$3`'$0(`$1', (shift$2), `$3')')')dnl +dnl +define(`apply',`foreach(`x',$1,`$2(x)')')dnl +dnl +define(`z',`eval(`$1*2') ')dnl +apply(`(1,2,3)',`z') diff --git a/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-1.maple b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-1.maple new file mode 100644 index 0000000000..8f6e1754ea --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-1.maple @@ -0,0 +1,11 @@ +> map( sqrt, [ 1.1, 3.2, 5.7 ] ); + [1.048808848, 1.788854382, 2.387467277] + +> map( x -> x + 1, { 1, 3, 5 } ); + {2, 4, 6} + +> sqrt~( [ 1.1, 3.2, 5.7 ] ); + [1.048808848, 1.788854382, 2.387467277] + +> (x -> x + 1)~( { 1, 3, 5 } ); + {2, 4, 6} diff --git a/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-2.maple b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-2.maple new file mode 100644 index 0000000000..861c0bfbb3 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-2.maple @@ -0,0 +1,14 @@ +> a := Array( [ 1.1, 3.2, 5.7 ] ); + a := [1.1, 3.2, 5.7] + +> sqrt~( a ); + [1.048808848, 1.788854382, 2.387467277] + +> a; + [1.1, 3.2, 5.7] + +> map( sqrt, a ); + [1.048808848, 1.788854382, 2.387467277] + +> a; + [1.1, 3.2, 5.7] diff --git a/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-3.maple b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-3.maple new file mode 100644 index 0000000000..b3ffb599c7 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-3.maple @@ -0,0 +1,5 @@ +> map[inplace]( sqrt, a ); + [1.048808848, 1.788854382, 2.387467277] + +> a; + [1.048808848, 1.788854382, 2.387467277] diff --git a/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-4.maple b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-4.maple new file mode 100644 index 0000000000..eff6b0580e --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-4.maple @@ -0,0 +1,2 @@ +> map( `+`, [ 1, 2, 3 ], 3 ); + [4, 5, 6] diff --git a/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-5.maple b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-5.maple new file mode 100644 index 0000000000..beac28bcc0 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maple/apply-a-callback-to-an-array-5.maple @@ -0,0 +1,5 @@ +> map2( `-`, 5, [ 1, 2, 3 ] ); + [4, 3, 2] + +> map[2]( `/`, 5, [ 1, 2, 3 ] ); + [5, 5/2, 5/3] diff --git a/Task/Apply-a-callback-to-an-array/Mathematica/apply-a-callback-to-an-array.mathematica b/Task/Apply-a-callback-to-an-array/Mathematica/apply-a-callback-to-an-array.mathematica new file mode 100644 index 0000000000..415d387271 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Mathematica/apply-a-callback-to-an-array.mathematica @@ -0,0 +1,7 @@ +(#*#)& /@ {1, 2, 3, 4} + +Map[Function[#*#], {1, 2, 3, 4}] + +Map[((#*#)&,{1,2,3,4}] + +Map[Function[w,w*w],{1,2,3,4}] diff --git a/Task/Apply-a-callback-to-an-array/Maxima/apply-a-callback-to-an-array.maxima b/Task/Apply-a-callback-to-an-array/Maxima/apply-a-callback-to-an-array.maxima new file mode 100644 index 0000000000..75df0466f2 --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Maxima/apply-a-callback-to-an-array.maxima @@ -0,0 +1,8 @@ +/* for lists or sets */ + +map(sin, [1, 2, 3, 4]); +map(sin, {1, 2, 3, 4}); + +/* for matrices */ + +matrixmap(sin, matrix([1, 2], [2, 4])); diff --git a/Task/Apply-a-callback-to-an-array/Modula-3/apply-a-callback-to-an-array.mod3 b/Task/Apply-a-callback-to-an-array/Modula-3/apply-a-callback-to-an-array.mod3 new file mode 100644 index 0000000000..7a26b9a8fb --- /dev/null +++ b/Task/Apply-a-callback-to-an-array/Modula-3/apply-a-callback-to-an-array.mod3 @@ -0,0 +1,26 @@ +MODULE Callback EXPORTS Main; + +IMPORT IO, Fmt; + +TYPE CallBack = PROCEDURE (a: CARDINAL; b: INTEGER); + Values = REF ARRAY OF INTEGER; + +VAR sample := ARRAY [1..5] OF INTEGER {5, 4, 3, 2, 1}; + callback := Display; + +PROCEDURE Display(loc: CARDINAL; val: INTEGER) = + BEGIN + IO.Put("array[" & Fmt.Int(loc) & "] = " & Fmt.Int(val * val) & "\n"); + END Display; + +PROCEDURE Map(VAR values: ARRAY OF INTEGER; size: CARDINAL; worker: CallBack) = + VAR lvalues := NEW(Values, size); + BEGIN + FOR i := FIRST(lvalues^) TO LAST(lvalues^) DO + worker(i, values[i]); + END; + END Map; + +BEGIN + Map(sample, NUMBER(sample), callback); +END Callback. diff --git a/Task/Arbitrary-precision-integers-included/0DESCRIPTION b/Task/Arbitrary-precision-integers-included/0DESCRIPTION new file mode 100644 index 0000000000..917612b3f6 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/0DESCRIPTION @@ -0,0 +1,11 @@ +Using the in-built capabilities of your language, calculate the integer value of: + +::5^{4^{3^2}} + +* Confirm that the first and last twenty digits of the answer are: 62060698786608744707...92256259918212890625 +* Find and show the number of decimal digits in the answer. + +C.F. [[Long multiplication]] + +Note:
  • Do not submit an ''implementation'' of [[wp:arbitrary precision arithmetic|arbitrary precision arithmetic]]. The intention is to show the capabilities of the language as supplied. If a language has a [[Talk:Arbitrary-precision integers (included)#Use of external libraries|single, overwhelming, library]] of varied modules that is endorsed by its home site – such as [[CPAN]] for Perl or [[Boost]] for C++ – then that ''may'' be used instead. +
  • Strictly speaking, this should not be solved by fixed-precision numeric libraries where the precision has to be manually set to a large value; although if this is the '''only''' recourse then it may be used with a note explaining that the precision must be set manually to a large enough value.
diff --git a/Task/Arbitrary-precision-integers-included/1META.yaml b/Task/Arbitrary-precision-integers-included/1META.yaml new file mode 100644 index 0000000000..a34a05e951 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arbitrary precision diff --git a/Task/Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 b/Task/Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 new file mode 100644 index 0000000000..b337fa9520 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 @@ -0,0 +1,19 @@ +(in-package "ACL2") + +(include-book "arithmetic-3/floor-mod/floor-mod" :dir :system) + +(set-print-length 0 state) + +(defun arbitrary-precision () + (declare (xargs :mode :program)) + (let* ((x (expt 5 (expt 4 (expt 3 2)))) + (s (mv-let (col str) + (fmt1-to-string "~xx" + (list (cons #\x x)) + 0) + (declare (ignore col)) + str))) + (cw "~s0 ... ~x1 (~x2 digits)~%" + (subseq s 1 21) + (mod x (expt 10 20)) + (1- (length s))))) diff --git a/Task/Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada b/Task/Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada new file mode 100644 index 0000000000..838bfb5fec --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada @@ -0,0 +1,16 @@ +with Ada.Text_IO; use Ada.Text_IO; +with GNATCOLL.GMP; use GNATCOLL.GMP; +with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers; +procedure ArbitraryInt is + type stracc is access String; + BigInt : Big_Integer; + len : Natural; + str : stracc; +begin + Set (BigInt, 5); + Raise_To_N (BigInt, Unsigned_Long (4**(3**2))); + str := new String'(Image (BigInt)); + len := str'Length; + Put_Line ("Size is:"& Natural'Image (len)); + Put_Line (str (1 .. 20) & "....." & str (len - 19 .. len)); +end ArbitraryInt; diff --git a/Task/Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore b/Task/Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore new file mode 100644 index 0000000000..ff113918e1 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore @@ -0,0 +1,9 @@ +def Main() + var len as Int + var result as Str + result = Str(5**4**3**2) + len = result.length() + Print(len) + Print(result[:20]) + Print(result[len-20:]) +end diff --git a/Task/Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat b/Task/Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat new file mode 100644 index 0000000000..0cf1eaa821 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat @@ -0,0 +1,4 @@ +{?} @(5^4^3^2:?first [20 ? [-21 ?last [?length)&str$(!first "..." !last "\nlength " !length) +{!} 62060698786608744707...92256259918212890625 +length 183231 + S 2,46 sec diff --git a/Task/Arbitrary-precision-integers-included/C-sharp/arbitrary-precision-integers-included.cs b/Task/Arbitrary-precision-integers-included/C-sharp/arbitrary-precision-integers-included.cs new file mode 100644 index 0000000000..a16bcb2aed --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/C-sharp/arbitrary-precision-integers-included.cs @@ -0,0 +1,23 @@ +using System; +using System.Diagnostics; +using System.Linq; +using System.Numerics; + +static class Program { + static void Main() { + BigInteger n = BigInteger.Pow(5, (int)BigInteger.Pow(4, (int)BigInteger.Pow(3, 2))); + string result = n.ToString(); + + Debug.Assert(result.Length == 183231); + Debug.Assert(result.StartsWith("62060698786608744707")); + Debug.Assert(result.EndsWith("92256259918212890625")); + + Console.WriteLine("n = 5^4^3^2"); + Console.WriteLine("n = {0}...{1}", + result.Substring(0, 20), + result.Substring(result.Length - 20, 20) + ); + + Console.WriteLine("n digits = {0}", result.Length); + } +} diff --git a/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c b/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c new file mode 100644 index 0000000000..9473b610d5 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + mpz_t a; + mpz_init_set_ui(a, 5); + mpz_pow_ui(a, a, 1 << 18); /* 2**18 == 4**9 */ + + int len = mpz_sizeinbase(a, 10); + printf("GMP says size is: %d\n", len); + + /* because GMP may report size 1 too big; see doc */ + char *s = mpz_get_str(0, 10, a); + printf("size really is %d\n", len = strlen(s)); + printf("Digits: %.20s...%s\n", s, s + len - 20); + + // free(s); /* we could, but we won't. we are exiting anyway */ + return 0; +} diff --git a/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c b/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c new file mode 100644 index 0000000000..64af6a5d8d --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c @@ -0,0 +1,65 @@ +/* 5432.c */ + +#include /* BN_*() */ +#include /* ERR_*() */ +#include /* exit() */ +#include /* fprintf() */ +#include /* strlen() */ + +void +fail(const char *message) +{ + fprintf(stderr, "%s: error 0x%08lx\n", ERR_get_error()); + exit(1); +} + +int +main() +{ + BIGNUM two, three, four, five; + BIGNUM answer; + BN_CTX *context; + size_t length; + char *string; + + context = BN_CTX_new(); + if (context == NULL) + fail("BN_CTX_new"); + + /* answer = 5 ** 4 ** 3 ** 2 */ + BN_init(&two); + BN_init(&three); + BN_init(&four); + BN_init(&five); + if (BN_set_word(&two, 2) == 0 || + BN_set_word(&three, 3) == 0 || + BN_set_word(&four, 4) == 0 || + BN_set_word(&five, 5) == 0) + fail("BN_set_word"); + BN_init(&answer); + if (BN_exp(&answer, &three, &two, context) == 0 || + BN_exp(&answer, &four, &answer, context) == 0 || + BN_exp(&answer, &five, &answer, context) == 0) + fail("BN_exp"); + + /* string = decimal answer */ + string = BN_bn2dec(&answer); + if (string == NULL) + fail("BN_bn2dec"); + + length = strlen(string); + printf(" First 20 digits: %.20s\n", string); + if (length >= 20) + printf(" Last 20 digits: %.20s\n", string + length - 20); + printf("Number of digits: %zd\n", length); + + OPENSSL_free(string); + BN_free(&answer); + BN_free(&five); + BN_free(&four); + BN_free(&three); + BN_free(&two); + BN_CTX_free(context); + + return 0; +} diff --git a/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj b/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj new file mode 100644 index 0000000000..fb911a500b --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj @@ -0,0 +1,12 @@ +(defn exp [n k] (reduce * (repeat k n))) + +(def big (->> 2 (exp 3) (exp 4) (exp 5))) +(def sbig (str big)) + +(assert (= "62060698786608744707" (.substring sbig 0 20))) +(assert (= "92256259918212890625" (.substring sbig (- (count sbig) 20)))) +(println (count sbig) "digits") + +(println (str (.substring sbig 0 20) ".." + (.substring sbig (- (count sbig) 20))) + (str "(" (count sbig) " digits)")) diff --git a/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj b/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj new file mode 100644 index 0000000000..70c00fc896 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj @@ -0,0 +1,5 @@ +(defn exp [n k] + (cond + (zero? (mod k 2)) (recur (* n n) (/ k 2)) + (zero? (mod k 3)) (recur (* n n n) (/ k 3)) + :else (reduce * (repeat k n)))) diff --git a/Task/Arbitrary-precision-integers-included/Common-Lisp/arbitrary-precision-integers-included.lisp b/Task/Arbitrary-precision-integers-included/Common-Lisp/arbitrary-precision-integers-included.lisp new file mode 100644 index 0000000000..9d75c9feba --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Common-Lisp/arbitrary-precision-integers-included.lisp @@ -0,0 +1,3 @@ +(let ((s (format () "~s" (expt 5 (expt 4 (expt 3 2)))))) + (format t "~a...~a, length ~a" (subseq s 0 20) + (subseq s (- (length s) 20)) (length s))) diff --git a/Task/Arbitrary-precision-integers-included/D/arbitrary-precision-integers-included.d b/Task/Arbitrary-precision-integers-included/D/arbitrary-precision-integers-included.d new file mode 100644 index 0000000000..3206a0fc59 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/D/arbitrary-precision-integers-included.d @@ -0,0 +1,6 @@ +import std.stdio, std.bigint, std.conv; + +void main() { + auto s = text(BigInt(5) ^^ 4 ^^ 3 ^^ 2); + writefln("5^4^3^2 = %s..%s (%d digits)", s[0..20], s[$-20..$], s.length); +} diff --git a/Task/Arbitrary-precision-integers-included/E/arbitrary-precision-integers-included.e b/Task/Arbitrary-precision-integers-included/E/arbitrary-precision-integers-included.e new file mode 100644 index 0000000000..45384c7657 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/E/arbitrary-precision-integers-included.e @@ -0,0 +1,10 @@ +? def value := 5**(4**(3**2)); null +? def decimal := value.toString(10); null +? decimal(0, 20) +# value: "62060698786608744707" + +? decimal(decimal.size() - 20) +# value: "92256259918212890625" + +? decimal.size() +# value: 183231 diff --git a/Task/Arbitrary-precision-integers-included/Emacs-Lisp/arbitrary-precision-integers-included.l b/Task/Arbitrary-precision-integers-included/Emacs-Lisp/arbitrary-precision-integers-included.l new file mode 100644 index 0000000000..1d6a049d06 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Emacs-Lisp/arbitrary-precision-integers-included.l @@ -0,0 +1,9 @@ +(let* ((answer (calc-eval "5**4**3**2")) + (length (length answer))) + (message "%s has %d digits" + (if (> length 40) + (format "%s...%s" + (substring answer 0 20) + (substring answer (- length 20) length)) + answer) + length)) diff --git a/Task/Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl b/Task/Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl new file mode 100644 index 0000000000..706332b1bd --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl @@ -0,0 +1,20 @@ +-module(arbitrary). +-compile([export_all]). + +pow(B,E) when E > 0 -> + pow(B,E,1). + +pow(_,0,_) -> 0; +pow(B,1,Acc) -> Acc * B; +pow(B,P,Acc) when P rem 2 == 0 -> + pow(B*B,P div 2, Acc); +pow(B,P,Acc) -> + pow(B,P-1,Acc*B). + +test() -> + I = pow(5,pow(4,pow(3,2))), + [S] = io_lib:format("~b",[I]), + L = length(S), + Prefix = lists:sublist(S,20), + Suffix = lists:sublist(S,L-19,20), + io:format("Length: ~b~nPrefix:~s~nSuffix:~s~n",[L,Prefix,Suffix]). diff --git a/Task/Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor b/Task/Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor new file mode 100644 index 0000000000..4fbd7a7d5d --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor @@ -0,0 +1,7 @@ +USING: formatting kernel math.functions math.parser sequences ; +IN: rosettacode.bignums + +: test-bignums ( -- ) + 5 4 3 2 ^ ^ ^ number>string + [ 20 head ] [ 20 tail* ] [ length ] tri + "5^4^3^2 is %s...%s and has %d digits\n" printf ; diff --git a/Task/Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink b/Task/Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink new file mode 100644 index 0000000000..c586f383e1 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink @@ -0,0 +1,3 @@ +a = 5^4^3^2 +as = "$a" // Coerce to string +println["Length=" + length[as] + ", " + left[as,20] + "..." + right[as,20]] diff --git a/Task/Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap b/Task/Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap new file mode 100644 index 0000000000..7fc6805214 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap @@ -0,0 +1,8 @@ +n:=5^(4^(3^2));; +s := String(n);; +m := Length(s); +# 183231 +s{[1..20]}; +# "62060698786608744707" +s{[m-19..m]}; +# "92256259918212890625" diff --git a/Task/Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go b/Task/Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go new file mode 100644 index 0000000000..91527a94ce --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + answer := big.NewInt(42) + answer.Exp(big.NewInt(5), answer.Exp(big.NewInt(4), + answer.Exp(big.NewInt(3), big.NewInt(2), nil), nil), nil) + answer_string := answer.String() + length := len(answer_string) + fmt.Printf("has %d digits: %s ... %s\n", + length, + answer_string[0:20], + answer_string[length-20:]) +} diff --git a/Task/Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golf b/Task/Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golf new file mode 100644 index 0000000000..22b8260274 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golf @@ -0,0 +1,5 @@ +5 4 3 2??? # Calculate 5^(4^(3^2)) +`.. # Convert to string and make two copies +20

p # Print the last 20 digits +,p # Print the length diff --git a/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy b/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy new file mode 100644 index 0000000000..17a9a1b4fa --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy @@ -0,0 +1 @@ +def bigNumber = 5G ** (4 ** (3 ** 2)) diff --git a/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy b/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy new file mode 100644 index 0000000000..c0d98ff5a1 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy @@ -0,0 +1,6 @@ +def bigString = bigNumber.toString() + +assert bigString[0..<20] == "62060698786608744707" +assert bigString[-20..-1] == "92256259918212890625" + +println bigString.size() diff --git a/Task/Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs b/Task/Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs new file mode 100644 index 0000000000..e5f6738b4d --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs @@ -0,0 +1,4 @@ +main = do + let y = show ( 5^4^3^2 ) + let l = length y + putStrLn ("5**4**3**2 = " ++ take 20 y ++ "..." ++ drop (l-20) y ++ " and has " ++ show l ++ " digits") diff --git a/Task/Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon b/Task/Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon new file mode 100644 index 0000000000..bec1a3f863 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon @@ -0,0 +1,8 @@ +procedure main() + x := 5^4^3^2 + write("done with computation") + x := string(x) + write("5 ^ 4 ^ 3 ^ 2 has ",*x," digits") + write("The first twenty digits are ",x[1+:20]) + write("The last twenty digits are ",x[0-:20]) +end diff --git a/Task/Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j b/Task/Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j new file mode 100644 index 0000000000..8a628a10bd --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j @@ -0,0 +1,6 @@ + Pow5432=: 5^4^3^2x + Pow5432=: ^/ 5 4 3 2x NB. alternate J solution + # ": Pow5432 NB. number of digits +183231 + 20 ({. , '...' , -@[ {. ]) ": Pow5432 NB. 20 first & 20 last digits +62060698786608744707...92256259918212890625 diff --git a/Task/Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java b/Task/Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java new file mode 100644 index 0000000000..6d9f1d5c70 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java @@ -0,0 +1,11 @@ +import java.math.BigInteger; + +class Program { + public static void main(String[] args) { + BigInteger x = BigInteger.valueOf(5).pow(BigInteger.valueOf(4).pow(BigInteger.valueOf(3).pow(2).intValue()).intValue()); + String y = x.toString(); + int l = y.length(); + System.out.printf("5**4**3**2 = %s...%s and has %d digits\n", + y.substring(0,20), y.substring(l-20), l); + } +} diff --git a/Task/Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia b/Task/Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia new file mode 100644 index 0000000000..902ae23e88 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia @@ -0,0 +1,11 @@ +julia> @elapsed big = string(BigInt(5)^4^3^2) +0.06799983978271484 seconds + +julia> length(big) +183231 + +julia> big[1:20] +"62060698786608744707" + +julia> big[end-20:end] +"892256259918212890625" diff --git a/Task/Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty b/Task/Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty new file mode 100644 index 0000000000..b4d97021ac --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty @@ -0,0 +1,3 @@ +a$ = str$( 5^(4^(3^2))) +print len( a$) +print left$( a$, 20); "......"; right$( a$, 20) diff --git a/Task/Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m b/Task/Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m new file mode 100644 index 0000000000..4dec511994 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m @@ -0,0 +1,13 @@ +>> answer = vpi(5)^(vpi(4)^(vpi(3)^vpi(2))); +>> numDigits = order(answer) + 1 + +numDigits = + + 183231 + +>> [sprintf('%d',leadingdigit(answer,20)) '...' sprintf('%d',trailingdigit(answer,20))] +%First and Last 20 Digits + +ans = + +62060698786608744707...92256259918212890625 diff --git a/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple b/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple new file mode 100644 index 0000000000..d79c875847 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple @@ -0,0 +1,7 @@ +> n := 5^(4^(3^2)): +> length( n ); # number of digits + 183231 + +> s := convert( n, 'string' ): +> s[ 1 .. 20 ], s[ -20 .. -1 ]; # extract first and last twenty digits + "62060698786608744707", "92256259918212890625" diff --git a/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple b/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple new file mode 100644 index 0000000000..3329ccf6fd --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple @@ -0,0 +1,3 @@ +> interface( elisiondigitsbefore = 20, elisiondigitsafter = 20 ): +> 5^(4^(3^2)): + 62060698786608744707[...183191 digits...]92256259918212890625 diff --git a/Task/Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.mathematica b/Task/Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.mathematica new file mode 100644 index 0000000000..ce95e04c25 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.mathematica @@ -0,0 +1,2 @@ +s:=ToString[5^4^3^2]; +Print[StringTake[s,20]<>"..."<>StringTake[s,-20]<>" ("<>ToString@StringLength@s<>" digits)"]; diff --git a/Task/Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima b/Task/Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima new file mode 100644 index 0000000000..7420e2f7ec --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima @@ -0,0 +1,3 @@ +block([s, n], s: string(5^4^3^2), n: slength(s), print(substring(s, 1, 21), "...", substring(s, n - 19)), n); +/* 62060698786608744707...92256259918212890625 +183231 */ diff --git a/Task/Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php b/Task/Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php new file mode 100644 index 0000000000..5b9940bd32 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php @@ -0,0 +1,4 @@ + diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl new file mode 100644 index 0000000000..16f8bb144f --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl @@ -0,0 +1,4 @@ +use Math::BigInt; +my $x = Math::BigInt->new('5') ** Math::BigInt->new('4') ** Math::BigInt->new('3') ** Math::BigInt->new('2'); +my $y = "$x"; +printf("5**4**3**2 = %s...%s and has %i digits\n", substr($y,0,20), substr($y,-20), length($y)); diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl new file mode 100644 index 0000000000..0ac8cb28d6 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl @@ -0,0 +1,4 @@ +use bigint; +my $x = 5**4**3**2; +my $y = "$x"; +printf("5**4**3**2 = %s...%s and has %i digits\n", substr($y,0,20), substr($y,-20), length($y)); diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl new file mode 100644 index 0000000000..2a2c2692b8 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl @@ -0,0 +1,3 @@ +$ time perl transparent-bigint.pl +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits + 1m4.28s real 1m4.30s user 0m0.00s system diff --git a/Task/Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l b/Task/Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l new file mode 100644 index 0000000000..f8d0095c14 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l @@ -0,0 +1,3 @@ +(let L (chop (** 5 (** 4 (** 3 2)))) + (prinl (head 20 L) "..." (tail 20 L)) + (length L) ) diff --git a/Task/Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py b/Task/Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py new file mode 100644 index 0000000000..9c73f44c8e --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py @@ -0,0 +1,3 @@ +>>> y = str( 5**4**3**2 ) +>>> print ("5**4**3**2 = %s...%s and has %i digits" % (y[:20], y[-20:], len(y))) +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits diff --git a/Task/Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r b/Task/Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r new file mode 100644 index 0000000000..7c3443d92f --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r @@ -0,0 +1,6 @@ +library(gmp) +large=pow.bigz(5,pow.bigz(4,pow.bigz(3,2))) +largestr=as.character(large) +cat("first 20 digits:",substr(largestr,1,20),"\n", + "last 20 digits:",substr(largestr,nchar(largestr)-19,nchar(largestr)),"\n", + "number of digits: ",nchar(largestr),"\n") diff --git a/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx b/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx new file mode 100644 index 0000000000..c708819f2c --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx @@ -0,0 +1,12 @@ +/*REXX program to calculate and demonstrate arbitrary precision numbers.*/ +numeric digits 200000 +check = 62060698786608744707...92256259918212890625 + n = 5 ** (4 ** (3 ** 2)) /*calc. multiple exponentations. */ +sampl = left(n, 20)'...'right(n, 20) +say ' check:' check +say 'sample:' sampl +say 'digits:' length(n) +say +if check==sampl then say 'passed!' + else say 'failed!' + /*stick a fork in it, we're done.*/ diff --git a/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx b/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx new file mode 100644 index 0000000000..4753dbe0da --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx @@ -0,0 +1,21 @@ +/*REXX program to calculate and demonstrate arbitrary precision numbers.*/ +numeric digits 5 /*set to low precision for speed.*/ +check = 62060698786608744707...92256259918212890625 + + n=5** (4** (3** 2)) /*calc. multiple exponentations. */ + +parse var n 'E' pow . /*POW might be null, so N is OK.*/ + +if pow\=='' then do /*general case: POW might be < 0*/ + numeric digits abs(pow)+9 /*recalc. with more digits.*/ + n=5** (4** (3** 2)) /*calc. multiple exponentations. */ + end + +sampl = left(n, 20)'...'right(n, 20) +say ' check:' check +say 'sample:' sampl +say 'digits:' length(n) +say +if check==sampl then say 'passed!' + else say 'failed!' + /*stick a fork in it, we're done.*/ diff --git a/Task/Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt b/Task/Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt new file mode 100644 index 0000000000..f9150a2615 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt @@ -0,0 +1,9 @@ +#lang racket + +(define answer (number->string (foldr expt 1 '(5 4 3 2)))) +(define len (string-length answer)) + +(printf "Got ~a digits~n" len) +(printf "~a ... ~a~n" + (substring answer 0 20) + (substring answer (- len 20) len)) diff --git a/Task/Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb b/Task/Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb new file mode 100644 index 0000000000..ff50bf1764 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb @@ -0,0 +1,2 @@ +irb(main):001:0> y = ( 5**4**3**2 ).to_s; puts "5**4**3**2 = #{y[0..19]}...#{y[-20..-1]} and has #{y.length} digits" +5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits diff --git a/Task/Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa b/Task/Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa new file mode 100644 index 0000000000..9b96acc2ed --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa @@ -0,0 +1,22 @@ +class MAIN is + main is + r:INTI; + p1 ::= "62060698786608744707"; + p2 ::= "92256259918212890625"; + + -- computing 5^(4^(3^2)), it could be written + -- also e.g. (5.inti)^((4.inti)^((3.inti)^(2.inti))) + r := (3.pow(2)).inti; + r := (4.inti).pow(r); + r := (5.inti).pow(r); + + sr ::= r.str; -- string rappr. of the number + if sr.head(p1.size) = p1 + and sr.tail(p2.size) = p2 then + #OUT + "result is ok..\n"; + else + #OUT + "oops\n"; + end; + #OUT + "# of digits: " + sr.size + "\n"; + end; +end; diff --git a/Task/Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala b/Task/Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala new file mode 100644 index 0000000000..5c23ab93a4 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala @@ -0,0 +1,21 @@ +scala> BigInt(5) modPow (BigInt(4) pow (BigInt(3) pow 2).toInt, BigInt(10) pow 20) +res21: scala.math.BigInt = 92256259918212890625 + +scala> (BigInt(5) pow (BigInt(4) pow (BigInt(3) pow 2).toInt).toInt).toString +res22: String = 6206069878660874470748320557284679309194219265199117173177383244 +78446890420544620839553285931321349485035253770303663683982841794590287939217907 +89641300156281305613064874236198955114921296922487632406742326659692228562195387 +46210423235340883954495598715281862895110697243759768434501295076608139350684049 +01191160699929926568099301259938271975526587719565309995276438998093283175080241 +55833224724855977970015112594128926594587205662421861723789001208275184293399910 +13912158886504596553858675842231519094813553261073608575593794241686443569888058 +92732524316323249492420512640962691673104618378381545202638771401061171968052873 +21414945463925055899307933774904078819911387324217976311238875802878310483037255 +33789567769926391314746986316354035923183981697660495275234703657750678459919... +scala> res22 take 20 +res23: String = 62060698786608744707 + +scala> res22 length +res24: Int = 183231 + +scala> diff --git a/Task/Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss b/Task/Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss new file mode 100644 index 0000000000..eb4a9716cb --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss @@ -0,0 +1,5 @@ +(define x (expt 5 (expt 4 (expt 3 2)))) +(define y (number->string x)) +(define l (string-length y)) +(display (string-append "5**4**3**2 = " (substring y 0 20) "..." (substring y (- l 20) l) " and has " (number->string l) " digits")) +(newline) diff --git a/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st b/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st new file mode 100644 index 0000000000..bc43ca6f12 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st @@ -0,0 +1,5 @@ +|num| +num := (5 raisedTo: (4 raisedTo: (3 raisedTo: 2))) asString. +Transcript + show: (num first: 20), '...', (num last: 20); cr; + show: 'digits: ', num size asString. diff --git a/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st b/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st new file mode 100644 index 0000000000..0174b99ebf --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st @@ -0,0 +1,7 @@ +|num numstr| +num := (2 to: 5) fold: [:exp :base| base raisedTo: exp]. +numstr := num asString. +'<1s>...<2s> digits:<3p>' + expandMacrosWith: (numstr first: 20) + with: (numstr last: 20) + with: numstr size. diff --git a/Task/Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl b/Task/Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl new file mode 100644 index 0000000000..71fdc22752 --- /dev/null +++ b/Task/Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl @@ -0,0 +1,7 @@ +set bigValue [expr {5**4**3**2}] +puts "5**4**3**2 has [string length $bigValue] digits" +if {[string match "62060698786608744707*92256259918212890625" $bigValue]} { + puts "Value starts with 62060698786608744707, ends with 92256259918212890625" +} else { + puts "Value does not match 62060698786608744707...92256259918212890625" +} diff --git a/Task/Arena-storage-pool/J/arena-storage-pool-1.j b/Task/Arena-storage-pool/J/arena-storage-pool-1.j new file mode 100644 index 0000000000..204a72e77e --- /dev/null +++ b/Task/Arena-storage-pool/J/arena-storage-pool-1.j @@ -0,0 +1,27 @@ +coclass 'integerPool' +require 'jmf' +create=: monad define + Lim=: y*SZI_jmf_ + Next=: -SZI_jmf_ + Pool=: mema Lim +) + +destroy=: monad define + memf Pool + codestroy'' +) + +alloc=: monad define + assert.Lim >: Next=: Next+SZI_jmf_ + r=.Pool,Next,1,JINT + r set y + r +) + +get=: adverb define + memr m +) + +set=: adverb define + y memw m +) diff --git a/Task/Arena-storage-pool/J/arena-storage-pool-2.j b/Task/Arena-storage-pool/J/arena-storage-pool-2.j new file mode 100644 index 0000000000..897c1622c2 --- /dev/null +++ b/Task/Arena-storage-pool/J/arena-storage-pool-2.j @@ -0,0 +1,9 @@ + pool0=: 3 conew 'integerPool' + x0=: alloc__pool0 0 + x1=: alloc__pool0 0 + x2=: alloc__pool0 0 + x0 set__pool0 7 + x1 set__pool0 8 + x2 set__pool0 9 + x0 get__pool0 + x1 get__pool0 + x2 get__pool0 +24 diff --git a/Task/Arena-storage-pool/J/arena-storage-pool-3.j b/Task/Arena-storage-pool/J/arena-storage-pool-3.j new file mode 100644 index 0000000000..b08dc2799d --- /dev/null +++ b/Task/Arena-storage-pool/J/arena-storage-pool-3.j @@ -0,0 +1 @@ + destroy__pool0 _ diff --git a/Task/Arena-storage-pool/Mathematica/arena-storage-pool.mathematica b/Task/Arena-storage-pool/Mathematica/arena-storage-pool.mathematica new file mode 100644 index 0000000000..c401b4becc --- /dev/null +++ b/Task/Arena-storage-pool/Mathematica/arena-storage-pool.mathematica @@ -0,0 +1 @@ +f[x_] := x^2 diff --git a/Task/Arithmetic-Complex/Factor/arithmetic-complex.factor b/Task/Arithmetic-Complex/Factor/arithmetic-complex.factor new file mode 100644 index 0000000000..91689d7e6d --- /dev/null +++ b/Task/Arithmetic-Complex/Factor/arithmetic-complex.factor @@ -0,0 +1,18 @@ +USING: combinators kernel math math.functions prettyprint ; + +C{ 1 2 } C{ 0.9 -2.78 } { + [ + . ] ! addition + [ - . ] ! subtraction + [ * . ] ! multiplication + [ / . ] ! division + [ ^ . ] ! power +} 2cleave + +C{ 1 2 } { + [ neg . ] ! negation + [ 1 swap / . ] ! multiplicative inverse + [ conjugate . ] ! complex conjugate + [ sin . ] ! sine + [ log . ] ! natural logarithm + [ sqrt . ] ! square root +} cleave diff --git a/Task/Arithmetic-Complex/GAP/arithmetic-complex.gap b/Task/Arithmetic-Complex/GAP/arithmetic-complex.gap new file mode 100644 index 0000000000..165525440d --- /dev/null +++ b/Task/Arithmetic-Complex/GAP/arithmetic-complex.gap @@ -0,0 +1,19 @@ +# GAP knows gaussian integers, gaussian rationals (i.e. Q[i]), and cyclotomic fields. Here are some examples. +# E(n) is an nth primitive root of 1 +i := Sqrt(-1); +# E(4) +(3 + 2*i)*(5 - 7*i); +# 29-11*E(4) +1/i; +# -E(4) +Sqrt(-3); +# E(3)-E(3)^2 + +i in GaussianIntegers; +# true +i/2 in GaussianIntegers; +# false +i/2 in GaussianRationals; +# true +Sqrt(-3) in Cyclotomics; +# true diff --git a/Task/Arithmetic-Complex/Groovy/arithmetic-complex-1.groovy b/Task/Arithmetic-Complex/Groovy/arithmetic-complex-1.groovy new file mode 100644 index 0000000000..085c50b795 --- /dev/null +++ b/Task/Arithmetic-Complex/Groovy/arithmetic-complex-1.groovy @@ -0,0 +1,94 @@ +class Complex { + final Number real, imag + + static final Complex I = [0,1] as Complex + + Complex(Number real) { this(real, 0) } + + Complex(real, imag) { this.real = real; this.imag = imag } + + Complex plus (Complex c) { [real + c.real, imag + c.imag] as Complex } + + Complex plus (Number n) { [real + n, imag] as Complex } + + Complex minus (Complex c) { [real - c.real, imag - c.imag] as Complex } + + Complex minus (Number n) { [real - n, imag] as Complex } + + Complex multiply (Complex c) { [real*c.real - imag*c.imag , imag*c.real + real*c.imag] as Complex } + + Complex multiply (Number n) { [real*n , imag*n] as Complex } + + Complex div (Complex c) { this * c.recip() } + + Complex div (Number n) { this * (1/n) } + + Complex negative () { [-real, -imag] as Complex } + + /** the complex conjugate of this complex number. + * Overloads the bitwise complement (~) operator. */ + Complex bitwiseNegate () { [real, -imag] as Complex } + + /** the magnitude of this complex number. */ + // could also use Math.sqrt( (this * (~this)).real ) + Number abs () { Math.sqrt( real*real + imag*imag ) } + + /** the complex reciprocal of this complex number. */ + Complex recip() { (~this) / ((this * (~this)).real) } + + /** derived angle θ (theta) for polar form. + * Normalized to 0 ≤ θ < 2π. */ + Number getTheta() { + def theta = Math.atan2(imag,real) + theta = theta < 0 ? theta + 2 * Math.PI : theta + } + + /** derived magnitude ρ (rho) for polar form. */ + Number getRho() { this.abs() } + + /** Runs Euler's polar-to-Cartesian complex conversion, + * converting [ρ, θ] inputs into a [real, imag]-based complex number */ + static Complex fromPolar(Number rho, Number theta) { + [rho * Math.cos(theta), rho * Math.sin(theta)] as Complex + } + + /** Creates new complex with same magnitude ρ, but different angle θ */ + Complex withTheta(Number theta) { fromPolar(this.rho, theta) } + + /** Creates new complex with same angle θ, but different magnitude ρ */ + Complex withRho(Number rho) { fromPolar(rho, this.theta) } + + static Complex exp(Complex c) { fromPolar(Math.exp(c.real), c.imag) } + + static Complex log(Complex c) { [Math.log(c.rho), c.theta] as Complex } + + Complex power(Complex c) { + this == 0 && c != 0 \ + ? [0] as Complex \ + : c == 1 \ + ? this \ + : exp( log(this) * c ) + } + + Complex power(Number n) { this ** ([n, 0] as Complex) } + + boolean equals(other) { + other != null && (other instanceof Complex \ + ? [real, imag] == [other.real, other.imag] \ + : other instanceof Number && [real, imag] == [other, 0]) + } + + int hashCode() { [real, imag].hashCode() } + + String toString() { + def realPart = "${real}" + def imagPart = imag.abs() == 1 ? "i" : "${imag.abs()}i" + real == 0 && imag == 0 \ + ? "0" \ + : real == 0 \ + ? (imag > 0 ? '' : "-") + imagPart \ + : imag == 0 \ + ? realPart \ + : realPart + (imag > 0 ? " + " : " - ") + imagPart + } +} diff --git a/Task/Arithmetic-Complex/Groovy/arithmetic-complex-2.groovy b/Task/Arithmetic-Complex/Groovy/arithmetic-complex-2.groovy new file mode 100644 index 0000000000..c42cc548b5 --- /dev/null +++ b/Task/Arithmetic-Complex/Groovy/arithmetic-complex-2.groovy @@ -0,0 +1,36 @@ +def tol = 0.000000001 // tolerance: acceptable "wrongness" to account for rounding error + +println 'Demo 1: functionality as requested' +def a = [5,3] as Complex +println 'a == ' + a +def b = [0.5,6] as Complex +println 'b == ' + b + +println "a + b == (${a}) + (${b}) == " + (a + b) +println "a * b == (${a}) * (${b}) == " + (a * b) +assert a + (-a) == 0 +println "-a == -(${a}) == " + (-a) +assert (a * a.recip() - 1).abs() < tol +println "1/a == (${a}).recip() == " + (a.recip()) +println() + +println 'Demo 2: other functionality not requested, but important for completeness' +println "a - b == (${a}) - (${b}) == " + (a - b) +println "a / b == (${a}) / (${b}) == " + (a / b) +println "a ** b == (${a}) ** (${b}) == " + (a ** b) +println 'a.real == ' + a.real +println 'a.imag == ' + a.imag +println 'a.rho == ' + a.rho +println 'a.theta == ' + a.theta +println '|a| == ' + a.abs() +println 'a_bar == ' + ~a + +def rho = 10 +def piOverTheta = 3 +def theta = Math.PI / piOverTheta +def fromPolar1 = Complex.fromPolar(rho, theta) // direct polar-to-cartesian conversion +def fromPolar2 = Complex.exp(Complex.I * theta) * rho // Euler's equation +println "rho*cos(theta) + rho*i*sin(theta) == ${rho}*cos(pi/${piOverTheta}) + ${rho}*i*sin(pi/${piOverTheta}) == " + fromPolar1 +println "rho * exp(i * theta) == ${rho} * exp(i * pi/${piOverTheta}) == " + fromPolar2 +assert (fromPolar1 - fromPolar2).abs() < tol +println() diff --git a/Task/Arithmetic-Complex/IDL/arithmetic-complex.idl b/Task/Arithmetic-Complex/IDL/arithmetic-complex.idl new file mode 100644 index 0000000000..446f3c6dc9 --- /dev/null +++ b/Task/Arithmetic-Complex/IDL/arithmetic-complex.idl @@ -0,0 +1,10 @@ +x=complex(1,1) + y=complex(!pi,1.2) + print,x+y +( 4.14159, 2.20000) + print,x*y +( 1.94159, 4.34159) + print,-x +( -1.00000, -1.00000) + print,1/x +( 0.500000, -0.500000) diff --git a/Task/Arithmetic-Complex/Icon/arithmetic-complex-1.icon b/Task/Arithmetic-Complex/Icon/arithmetic-complex-1.icon new file mode 100644 index 0000000000..51a0282957 --- /dev/null +++ b/Task/Arithmetic-Complex/Icon/arithmetic-complex-1.icon @@ -0,0 +1,22 @@ +procedure main() + +SetupComplex() +a := complex(1,2) +b := complex(3,4) + +c := complex(&pi,1.5) +d := complex(1) +e := complex(,1) + +every v := !"abcde" do write(v," := ",cpxstr(variable(v))) + +write("a+b := ", cpxstr(cpxadd(a,b))) +write("a-b := ", cpxstr(cpxsub(a,b))) +write("a*b := ", cpxstr(cpxmul(a,b))) +write("a/b := ", cpxstr(cpxdiv(a,b))) +write("neg(a) := ", cpxstr(cpxneg(a))) +write("inv(a) := ", cpxstr(cpxinv(a))) +write("conj(a) := ", cpxstr(cpxconj(a))) +write("abs(a) := ", cpxabs(a)) +write("neg(1) := ", cpxstr(cpxneg(1))) +end diff --git a/Task/Arithmetic-Complex/Icon/arithmetic-complex-2.icon b/Task/Arithmetic-Complex/Icon/arithmetic-complex-2.icon new file mode 100644 index 0000000000..dce6305779 --- /dev/null +++ b/Task/Arithmetic-Complex/Icon/arithmetic-complex-2.icon @@ -0,0 +1,27 @@ +link complex # for complex number support + +procedure SetupComplex() #: used to setup safe complex +COMPLEX() # replace complex record constructor +SetupComplex := 1 # never call here again +return +end + +procedure COMPLEX(rpart,ipart) #: new safe record constructor and coercion +initial complex :=: COMPLEX # get in front of record constructor +return if /ipart & (type(rpart) == "complex") + then rpart # already complex + else COMPLEX( real(\rpart | 0.0), real(\ipart|0) ) # create a new complex number +end + +procedure cpxneg(z) #: negate z + z := complex(z) # coerce + return complex( -z.rpart, -z.ipart) +end + +procedure cpxinv(z) #: inverse of z + local denom + z := complex(z) # coerce + + denom := z.rpart ^ 2 + z.ipart ^ 2 + return complex(z.rpart / denom, z.ipart / denom) +end diff --git a/Task/Arithmetic-Complex/J/arithmetic-complex.j b/Task/Arithmetic-Complex/J/arithmetic-complex.j new file mode 100644 index 0000000000..1e48b12c99 --- /dev/null +++ b/Task/Arithmetic-Complex/J/arithmetic-complex.j @@ -0,0 +1,10 @@ + x=: 1j1 + y=: 3.14159j1.2 + x+y +4.14159j2.2 + x*y +1.94159j4.34159 + %x +0.5j_0.5 + -x +_1j_1 diff --git a/Task/Arithmetic-Complex/Liberty-BASIC/arithmetic-complex.liberty b/Task/Arithmetic-Complex/Liberty-BASIC/arithmetic-complex.liberty new file mode 100644 index 0000000000..bdec8aa4d1 --- /dev/null +++ b/Task/Arithmetic-Complex/Liberty-BASIC/arithmetic-complex.liberty @@ -0,0 +1,51 @@ +mainwin 50 10 + +print " Adding" +call cprint cadd$( complex$( 1, 1), complex$( 3.14159265, 1.2)) +print " Multiplying" +call cprint cmulti$( complex$( 1, 1), complex$( 3.14159265, 1.2)) +print " Inverting" +call cprint cinv$( complex$( 1, 1)) +print " Negating" +call cprint cneg$( complex$( 1, 1)) + +end + +sub cprint cx$ + print "( "; word$( cx$, 1); " + i *"; word$( cx$, 2); ")" +end sub + +function complex$( a , bj ) +''complex number string-object constructor + complex$ = str$( a ) ; " " ; str$( bj ) +end function + +function cadd$( a$ , b$ ) + ar = val( word$( a$ , 1 ) ) + ai = val( word$( a$ , 2 ) ) + br = val( word$( b$ , 1 ) ) + bi = val( word$( b$ , 2 ) ) + cadd$ = complex$( ar + br , ai + bi ) +end function + +function cmulti$( a$ , b$ ) + ar = val( word$( a$ , 1 ) ) + ai = val( word$( a$ , 2 ) ) + br = val( word$( b$ , 1 ) ) + bi = val( word$( b$ , 2 ) ) + cmulti$ = complex$( ar * br - ai * bi _ + , ar * bi + ai * br ) +end function + +function cneg$( a$) + ar = val( word$( a$ , 1 ) ) + ai = val( word$( a$ , 2 ) ) + cneg$ =complex$( 0 -ar, 0 -ai) +end function + +function cinv$( a$) + ar = val( word$( a$ , 1 ) ) + ai = val( word$( a$ , 2 ) ) + D =ar^2 +ai^2 + cinv$ =complex$( ar /D , 0 -ai /D ) +end function diff --git a/Task/Arithmetic-Complex/Maple/arithmetic-complex-1.maple b/Task/Arithmetic-Complex/Maple/arithmetic-complex-1.maple new file mode 100644 index 0000000000..617211d721 --- /dev/null +++ b/Task/Arithmetic-Complex/Maple/arithmetic-complex-1.maple @@ -0,0 +1,2 @@ +x := 1+I; +y := Pi+I*1.2; diff --git a/Task/Arithmetic-Complex/Maple/arithmetic-complex-2.maple b/Task/Arithmetic-Complex/Maple/arithmetic-complex-2.maple new file mode 100644 index 0000000000..e8bfaa3a9d --- /dev/null +++ b/Task/Arithmetic-Complex/Maple/arithmetic-complex-2.maple @@ -0,0 +1,4 @@ +x*y; + ==> (1 + I) (Pi + 1.2 I) +simplify(x*y); + ==> 1.941592654 + 4.341592654 I diff --git a/Task/Arithmetic-Complex/Maple/arithmetic-complex-3.maple b/Task/Arithmetic-Complex/Maple/arithmetic-complex-3.maple new file mode 100644 index 0000000000..87eea46285 --- /dev/null +++ b/Task/Arithmetic-Complex/Maple/arithmetic-complex-3.maple @@ -0,0 +1,4 @@ +x+y; +x*y; +-x; +1/x; diff --git a/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-1.mathematica b/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-1.mathematica new file mode 100644 index 0000000000..2d1676d719 --- /dev/null +++ b/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-1.mathematica @@ -0,0 +1,11 @@ +x=1+2I +y=3+4I + +x+y => 4 + 6 I +x-y => -2 - 2 I +y x => -5 + 10 I +y/x => 11/5 - (2 I)/5 +x^3 => -11 - 2 I +y^4 => -527 - 336 I +x^y => (1 + 2 I)^(3 + 4 I) +N[x^y] => 0.12901 + 0.0339241 I diff --git a/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-2.mathematica b/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-2.mathematica new file mode 100644 index 0000000000..9a01c0ce4e --- /dev/null +++ b/Task/Arithmetic-Complex/Mathematica/arithmetic-complex-2.mathematica @@ -0,0 +1,9 @@ +Exp Log +Sin Cos Tan Csc Sec Cot +ArcSin ArcCos ArcTan ArcCsc ArcSec ArcCot +Sinh Cosh Tanh Csch Sech Coth +ArcSinh ArcCosh ArcTanh ArcCsch ArcSech ArcCoth +Sinc +Haversine InverseHaversine +Factorial Gamma PolyGamma LogGamma +Erf BarnesG Hyperfactorial Zeta ProductLog RamanujanTauL diff --git a/Task/Arithmetic-Complex/Maxima/arithmetic-complex.maxima b/Task/Arithmetic-Complex/Maxima/arithmetic-complex.maxima new file mode 100644 index 0000000000..7dfb7d243e --- /dev/null +++ b/Task/Arithmetic-Complex/Maxima/arithmetic-complex.maxima @@ -0,0 +1,44 @@ +z1: 5 + 2 * %i; +2*%i+5 + +z2: 3 - 7 * %i; +3-7*%i + +carg(z1); +atan(2/5) + +cabs(z1); +sqrt(29) + +rectform(z1 * z2); +29-29*%i + +polarform(z1); +sqrt(29)*%e^(%i*atan(2/5)) + +conjugate(z1); +5-2*%i + +z1 + z2; +8-5*%i + +z1 - z2; +9*%i+2 + +z1 * z2; +(3-7*%i)*(2*%i+5) + +z1 * z2, rectform; +29-29*%i + +z1 / z2; +(2*%i+5)/(3-7*%i) + +z1 / z2, rectform; +(41*%i)/58+1/58 + +realpart(z1); +5 + +imagpart(z1); +2 diff --git a/Task/Arithmetic-Complex/Modula-2/arithmetic-complex.mod2 b/Task/Arithmetic-Complex/Modula-2/arithmetic-complex.mod2 new file mode 100644 index 0000000000..de5fc2b329 --- /dev/null +++ b/Task/Arithmetic-Complex/Modula-2/arithmetic-complex.mod2 @@ -0,0 +1,66 @@ +MODULE complex; + +IMPORT InOut; + +TYPE Complex = RECORD R, Im : REAL END; + +VAR z : ARRAY [0..3] OF Complex; + +PROCEDURE ShowComplex (str : ARRAY OF CHAR; p : Complex); + +BEGIN + InOut.WriteString (str); InOut.WriteString (" = "); + InOut.WriteReal (p.R, 6, 2); + IF p.Im >= 0.0 THEN InOut.WriteString (" + ") ELSE InOut.WriteString (" - ") END; + InOut.WriteReal (ABS (p.Im), 6, 2); InOut.WriteString (" i "); + InOut.WriteLn; InOut.WriteBf +END ShowComplex; + +PROCEDURE AddComplex (x1, x2 : Complex; VAR x3 : Complex); + +BEGIN + x3.R := x1.R + x2.R; + x3.Im := x1.Im + x2.Im +END AddComplex; + +PROCEDURE SubComplex (x1, x2 : Complex; VAR x3 : Complex); + +BEGIN + x3.R := x1.R - x2.R; + x3.Im := x1.Im - x2.Im +END SubComplex; + +PROCEDURE MulComplex (x1, x2 : Complex; VAR x3 : Complex); + +BEGIN + x3.R := x1.R * x2.R - x1.Im * x2.Im; + x3.Im := x1.R * x2.Im + x1.Im * x2.R +END MulComplex; + +PROCEDURE InvComplex (x1 : Complex; VAR x2 : Complex); + +BEGIN + x2.R := x1.R / (x1.R * x1.R + x1.Im * x1.Im); + x2.Im := -1.0 * x1.Im / (x1.R * x1.R + x1.Im * x1.Im) +END InvComplex; + +PROCEDURE NegComplex (x1 : Complex; VAR x2 : Complex); + +BEGIN + x2.R := - x1.R; x2.Im := - x1.Im +END NegComplex; + +BEGIN + InOut.WriteString ("Enter two complex numbers : "); + InOut.WriteBf; + InOut.ReadReal (z[0].R); InOut.ReadReal (z[0].Im); + InOut.ReadReal (z[1].R); InOut.ReadReal (z[1].Im); + ShowComplex ("z1", z[0]); ShowComplex ("z2", z[1]); + InOut.WriteLn; + AddComplex (z[0], z[1], z[2]); ShowComplex ("z1 + z2", z[2]); + SubComplex (z[0], z[1], z[2]); ShowComplex ("z1 - z2", z[2]); + MulComplex (z[0], z[1], z[2]); ShowComplex ("z1 * z2", z[2]); + InvComplex (z[0], z[2]); ShowComplex ("1 / z1", z[2]); + NegComplex (z[0], z[2]); ShowComplex (" - z1", z[2]); + InOut.WriteLn +END complex. diff --git a/Task/Arithmetic-Integer/FALSE/arithmetic-integer.false b/Task/Arithmetic-Integer/FALSE/arithmetic-integer.false new file mode 100644 index 0000000000..44472f01f4 --- /dev/null +++ b/Task/Arithmetic-Integer/FALSE/arithmetic-integer.false @@ -0,0 +1,8 @@ +12 7 +\$@$@$@$@$@$@$@$@$@$@\ { 6 copies } +"sum = "+." +difference = "-." +product = "*." +quotient = "/." +modulus = "/*-." +" diff --git a/Task/Arithmetic-Integer/Factor/arithmetic-integer-1.factor b/Task/Arithmetic-Integer/Factor/arithmetic-integer-1.factor new file mode 100644 index 0000000000..b8f74e2c70 --- /dev/null +++ b/Task/Arithmetic-Integer/Factor/arithmetic-integer-1.factor @@ -0,0 +1,17 @@ +USING: combinators io kernel math math.functions math.order +math.parser prettyprint ; + +"a=" "b=" [ write readln string>number ] bi@ +{ + [ + "sum: " write . ] + [ - "difference: " write . ] + [ * "product: " write . ] + [ / "quotient: " write . ] + [ /i "integer quotient: " write . ] + [ rem "remainder: " write . ] + [ mod "modulo: " write . ] + [ max "maximum: " write . ] + [ min "minimum: " write . ] + [ gcd "gcd: " write . drop ] + [ lcm "lcm: " write . ] +} 2cleave diff --git a/Task/Arithmetic-Integer/Factor/arithmetic-integer-2.factor b/Task/Arithmetic-Integer/Factor/arithmetic-integer-2.factor new file mode 100644 index 0000000000..8cd761db5c --- /dev/null +++ b/Task/Arithmetic-Integer/Factor/arithmetic-integer-2.factor @@ -0,0 +1,13 @@ +a=8 +b=12 +sum: 20 +difference: -4 +product: 96 +quotient: 2/3 +integer quotient: 0 +remainder: 8 +modulo: 8 +maximum: 12 +minimum: 8 +gcd: 4 +lcm: 24 diff --git a/Task/Arithmetic-Integer/Frink/arithmetic-integer-1.frink b/Task/Arithmetic-Integer/Frink/arithmetic-integer-1.frink new file mode 100644 index 0000000000..8eff493125 --- /dev/null +++ b/Task/Arithmetic-Integer/Frink/arithmetic-integer-1.frink @@ -0,0 +1,7 @@ +[a,b] = input["Enter numbers",["a","b"]] +ops=["+", "-", "*", "/", "div" ,"mod" ,"^"] +for op = ops +{ + str = "$a $op $b" + println["$str = " + eval[str]] +} diff --git a/Task/Arithmetic-Integer/Frink/arithmetic-integer-2.frink b/Task/Arithmetic-Integer/Frink/arithmetic-integer-2.frink new file mode 100644 index 0000000000..d00fa36cf1 --- /dev/null +++ b/Task/Arithmetic-Integer/Frink/arithmetic-integer-2.frink @@ -0,0 +1,7 @@ +10 + 20 = 30 +10 - 20 = -10 +10 * 20 = 200 +10 / 20 = 1/2 (exactly 0.5) +10 div 20 = 0 +10 mod 20 = 10 +10 ^ 20 = 100000000000000000000 diff --git a/Task/Arithmetic-Integer/GAP/arithmetic-integer.gap b/Task/Arithmetic-Integer/GAP/arithmetic-integer.gap new file mode 100644 index 0000000000..03b9f4a2d5 --- /dev/null +++ b/Task/Arithmetic-Integer/GAP/arithmetic-integer.gap @@ -0,0 +1,15 @@ +run := function() + local a, b, f; + f := InputTextUser(); + Print("a =\n"); + a := Int(Chomp(ReadLine(f))); + Print("b =\n"); + b := Int(Chomp(ReadLine(f))); + Display(Concatenation(String(a), " + ", String(b), " = ", String(a + b))); + Display(Concatenation(String(a), " - ", String(b), " = ", String(a - b))); + Display(Concatenation(String(a), " * ", String(b), " = ", String(a * b))); + Display(Concatenation(String(a), " / ", String(b), " = ", String(QuoInt(a, b)))); # toward 0 + Display(Concatenation(String(a), " mod ", String(b), " = ", String(RemInt(a, b)))); # nonnegative + Display(Concatenation(String(a), " ^ ", String(b), " = ", String(a ^ b))); + CloseStream(f); +end; diff --git a/Task/Arithmetic-Integer/Groovy/arithmetic-integer-1.groovy b/Task/Arithmetic-Integer/Groovy/arithmetic-integer-1.groovy new file mode 100644 index 0000000000..60b5d42676 --- /dev/null +++ b/Task/Arithmetic-Integer/Groovy/arithmetic-integer-1.groovy @@ -0,0 +1,14 @@ +def arithmetic = { a, b -> + println """ + a + b = ${a} + ${b} = ${a + b} + a - b = ${a} - ${b} = ${a - b} + a * b = ${a} * ${b} = ${a * b} + a / b = ${a} / ${b} = ${a / b} !!! Converts to floating point! +(int)(a / b) = (int)(${a} / ${b}) = ${(int)(a / b)} !!! Truncates downward after the fact + a.intdiv(b) = ${a}.intdiv(${b}) = ${a.intdiv(b)} !!! Behaves as if truncating downward, actual implementation varies + a % b = ${a} % ${b} = ${a % b} + +Exponentiation is also a base arithmetic operation in Groovy, so: + a ** b = ${a} ** ${b} = ${a ** b} +""" +} diff --git a/Task/Arithmetic-Integer/Groovy/arithmetic-integer-2.groovy b/Task/Arithmetic-Integer/Groovy/arithmetic-integer-2.groovy new file mode 100644 index 0000000000..884dcbc243 --- /dev/null +++ b/Task/Arithmetic-Integer/Groovy/arithmetic-integer-2.groovy @@ -0,0 +1 @@ +arithmetic(5,3) diff --git a/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe b/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe new file mode 100644 index 0000000000..d18971aa92 --- /dev/null +++ b/Task/Arithmetic-Integer/Haxe/arithmetic-integer.haxe @@ -0,0 +1,13 @@ +class BasicIntegerArithmetic { + public static function main() { + var args =Sys.args(); + if (args.length < 2) return; + var a = Std.parseFloat(args[0]); + var b = Std.parseFloat(args[1]); + trace("a+b = " + (a+b)); + trace("a-b = " + (a-b)); + trace("a*b = " + (a*b)); + trace("a/b = " + (a/b)); + trace("a%b = " + (a%b)); + } +} diff --git a/Task/Arithmetic-Integer/HicEst/arithmetic-integer-1.hicest b/Task/Arithmetic-Integer/HicEst/arithmetic-integer-1.hicest new file mode 100644 index 0000000000..9eba7b52df --- /dev/null +++ b/Task/Arithmetic-Integer/HicEst/arithmetic-integer-1.hicest @@ -0,0 +1,13 @@ +DLG(Edit=A, Edit=B, TItle='Enter numeric A and B') +WRITE(Name) A, B +WRITE() ' A + B = ', A + B +WRITE() ' A - B = ', A - B +WRITE() ' A * B = ', A * B +WRITE() ' A / B = ', A / B ! no truncation +WRITE() 'truncate A / B = ', INT(A / B) ! truncates towards 0 +WRITE() 'round next A / B = ', NINT(A / B) ! truncates towards next integer +WRITE() 'round down A / B = ', FLOOR(A / B) ! truncates towards minus infinity +WRITE() 'round up A / B = ', CEILING(A / B) ! truncates towards plus infinity +WRITE() 'remainder of A / B = ', MOD(A, B) ! same sign as A +WRITE() 'A to the power of B = ', A ^ B +WRITE() 'A to the power of B = ', A ** B diff --git a/Task/Arithmetic-Integer/HicEst/arithmetic-integer-2.hicest b/Task/Arithmetic-Integer/HicEst/arithmetic-integer-2.hicest new file mode 100644 index 0000000000..3df70d1ff6 --- /dev/null +++ b/Task/Arithmetic-Integer/HicEst/arithmetic-integer-2.hicest @@ -0,0 +1,12 @@ +A=5; B=-4; + A + B = 1 + A - B = 9 + A * B = -20 + A / B = -1.25 +truncate A / B = -1 +round next A / B = -1 +round down A / B = -2 +round up A / B = -1 +remainder of A / B = 1 +A to the power of B = 16E-4 +A to the power of B = 16E-4 diff --git a/Task/Arithmetic-Integer/Icon/arithmetic-integer.icon b/Task/Arithmetic-Integer/Icon/arithmetic-integer.icon new file mode 100644 index 0000000000..b40bbed194 --- /dev/null +++ b/Task/Arithmetic-Integer/Icon/arithmetic-integer.icon @@ -0,0 +1,13 @@ +procedure main() +writes("Input 1st integer a := ") +a := integer(read()) +writes("Input 2nd integer b := ") +b := integer(read()) + +write(" a + b = ",a+b) +write(" a - b = ",a-b) +write(" a * b = ",a*b) +write(" a / b = ",a/b, " rounds toward 0") +write(" a % b = ",a%b, " remainder sign matches a") +write(" a ^ b = ",a^b) +end diff --git a/Task/Arithmetic-Integer/Inform-7/arithmetic-integer.inf b/Task/Arithmetic-Integer/Inform-7/arithmetic-integer.inf new file mode 100644 index 0000000000..a3ed14b6e0 --- /dev/null +++ b/Task/Arithmetic-Integer/Inform-7/arithmetic-integer.inf @@ -0,0 +1,24 @@ +Enter Two Numbers is a room. + +Numerically entering is an action applying to one number. Understand "[number]" as numerically entering. + +The first number is a number that varies. + +After numerically entering for the first time: + now the first number is the number understood. + +After numerically entering for the second time: + let A be the first number; + let B be the number understood; + say "[A] + [B] = [A + B]."; [operator syntax] + say "[A] - [B] = [A minus B]."; [English syntax] + let P be given by P = A * B where P is a number; [inline equation] + say "[A] * [B] = [P]."; + let Q be given by the Division Formula; [named equation] + say "[A] / [B] = [Q]."; + say "[A] mod [B] = [remainder after dividing A by B]."; + end the story. + +Equation - Division Formula + Q = A / B +where Q is a number, A is a number, and B is a number. diff --git a/Task/Arithmetic-Integer/J/arithmetic-integer-1.j b/Task/Arithmetic-Integer/J/arithmetic-integer-1.j new file mode 100644 index 0000000000..45320c252e --- /dev/null +++ b/Task/Arithmetic-Integer/J/arithmetic-integer-1.j @@ -0,0 +1 @@ +calc =: + , - , * , <.@% , |~ , ^ diff --git a/Task/Arithmetic-Integer/J/arithmetic-integer-2.j b/Task/Arithmetic-Integer/J/arithmetic-integer-2.j new file mode 100644 index 0000000000..f4d5b7779f --- /dev/null +++ b/Task/Arithmetic-Integer/J/arithmetic-integer-2.j @@ -0,0 +1,2 @@ + 17 calc 3 +20 14 51 5 2 4913 diff --git a/Task/Arithmetic-Integer/J/arithmetic-integer-3.j b/Task/Arithmetic-Integer/J/arithmetic-integer-3.j new file mode 100644 index 0000000000..553e36ec43 --- /dev/null +++ b/Task/Arithmetic-Integer/J/arithmetic-integer-3.j @@ -0,0 +1,11 @@ +labels =: ];.2 'Sum: Difference: Product: Quotient: Remainder: Exponentiation: ' +combine =: ,. ":@,. +bia =: labels combine calc + + 17 bia 3 +Sum: 20 +Difference: 14 +Product: 51 +Quotient: 5 +Remainder: 2 +Exponentiation: 4913 diff --git a/Task/Arithmetic-Integer/LSE64/arithmetic-integer.lse64 b/Task/Arithmetic-Integer/LSE64/arithmetic-integer.lse64 new file mode 100644 index 0000000000..05b086764d --- /dev/null +++ b/Task/Arithmetic-Integer/LSE64/arithmetic-integer.lse64 @@ -0,0 +1,10 @@ +over : 2 pick +2dup : over over + +arithmetic : \ + " A=" ,t over , sp " B=" ,t dup , nl \ + " A+B=" ,t 2dup + , nl \ + " A-B=" ,t 2dup - , nl \ + " A*B=" ,t 2dup * , nl \ + " A/B=" ,t 2dup / , nl \ + " A%B=" ,t % , nl diff --git a/Task/Arithmetic-Integer/Liberty-BASIC/arithmetic-integer.liberty b/Task/Arithmetic-Integer/Liberty-BASIC/arithmetic-integer.liberty new file mode 100644 index 0000000000..90b480548c --- /dev/null +++ b/Task/Arithmetic-Integer/Liberty-BASIC/arithmetic-integer.liberty @@ -0,0 +1,9 @@ +input "Enter the first integer: "; first +input "Enter the second integer: "; second + +print "The sum is " ; first + second +print "The difference is " ; first -second +print "The product is " ; first *second +if second <>0 then print "The integer quotient is " ; int( first /second); " (rounds towards 0)" else print "Division by zero not allowed." +print "The remainder is " ; first MOD second; " (sign matches first operand)" +print "The first raised to the power of the second is " ; first ^second diff --git a/Task/Arithmetic-Integer/Logo/arithmetic-integer.logo b/Task/Arithmetic-Integer/Logo/arithmetic-integer.logo new file mode 100644 index 0000000000..6f7521d0d1 --- /dev/null +++ b/Task/Arithmetic-Integer/Logo/arithmetic-integer.logo @@ -0,0 +1,9 @@ +to operate :a :b + (print [a =] :a) + (print [b =] :b) + (print [a + b =] :a + :b) + (print [a - b =] :a - :b) + (print [a * b =] :a * :b) + (print [a / b =] int :a / :b) + (print [a mod b =] modulo :a :b) +end diff --git a/Task/Arithmetic-Integer/M4/arithmetic-integer-1.m4 b/Task/Arithmetic-Integer/M4/arithmetic-integer-1.m4 new file mode 100644 index 0000000000..53ea1fcdf0 --- /dev/null +++ b/Task/Arithmetic-Integer/M4/arithmetic-integer-1.m4 @@ -0,0 +1,5 @@ +eval(A+B) +eval(A-B) +eval(A*B) +eval(A/B) +eval(A%B) diff --git a/Task/Arithmetic-Integer/M4/arithmetic-integer-2.m4 b/Task/Arithmetic-Integer/M4/arithmetic-integer-2.m4 new file mode 100644 index 0000000000..964c65119d --- /dev/null +++ b/Task/Arithmetic-Integer/M4/arithmetic-integer-2.m4 @@ -0,0 +1,3 @@ +define(`A', 4)dnl +define(`B', 6)dnl +include(`operations.m4') diff --git a/Task/Arithmetic-Integer/MAXScript/arithmetic-integer.max b/Task/Arithmetic-Integer/MAXScript/arithmetic-integer.max new file mode 100644 index 0000000000..46fb6f0a9f --- /dev/null +++ b/Task/Arithmetic-Integer/MAXScript/arithmetic-integer.max @@ -0,0 +1,8 @@ +x = getKBValue prompt:"First number" +y = getKBValue prompt:"Second number:" + +format "Sum: %\n" (x + y) +format "Difference: %\n" (x - y) +format "Product: %\n" (x * y) +format "Quotient: %\n" (x / y) +format "Remainder: %\n" (mod x y) diff --git a/Task/Arithmetic-Integer/ML-I/arithmetic-integer.ml b/Task/Arithmetic-Integer/ML-I/arithmetic-integer.ml new file mode 100644 index 0000000000..cbd315f61d --- /dev/null +++ b/Task/Arithmetic-Integer/ML-I/arithmetic-integer.ml @@ -0,0 +1,15 @@ +MCSKIP "WITH" NL +"" Arithmetic/Integer +"" assumes macros on input stream 1, terminal on stream 2 +MCSKIP MT,<> +MCINS %. +MCDEF SL SPACES NL AS DoIt(); +Input an integer: 15; +Input another integer: 12; +Sum = 27 +Difference = 3 +Product = 180 +Quotient = 1 +Remainder = 3 +> diff --git a/Task/Arithmetic-Integer/Mathematica/arithmetic-integer.mathematica b/Task/Arithmetic-Integer/Mathematica/arithmetic-integer.mathematica new file mode 100644 index 0000000000..43cbb29286 --- /dev/null +++ b/Task/Arithmetic-Integer/Mathematica/arithmetic-integer.mathematica @@ -0,0 +1,9 @@ +a = Input["Give me an integer please!"]; +b = Input["Give me another integer please!"]; +Print["You gave me ", a, " and ", b]; +Print["sum: ", a + b]; +Print["difference: ", a - b]; +Print["product: ", a b]; +Print["integer quotient: ", IntegerPart[a/b]]; +Print["remainder: ", Mod[a, b]]; +Print["exponentiation: ", a^b]; diff --git a/Task/Arithmetic-Integer/Maxima/arithmetic-integer.maxima b/Task/Arithmetic-Integer/Maxima/arithmetic-integer.maxima new file mode 100644 index 0000000000..251702785e --- /dev/null +++ b/Task/Arithmetic-Integer/Maxima/arithmetic-integer.maxima @@ -0,0 +1,10 @@ +block( + [a: read("a"), b: read("b")], + print(a + b), + print(a - b), + print(a * b), + print(a / b), + print(quotient(a, b)), + print(remainder(a, b)), + a^b +); diff --git a/Task/Arithmetic-Integer/Mercury/arithmetic-integer.mercury b/Task/Arithmetic-Integer/Mercury/arithmetic-integer.mercury new file mode 100644 index 0000000000..558bec0439 --- /dev/null +++ b/Task/Arithmetic-Integer/Mercury/arithmetic-integer.mercury @@ -0,0 +1,42 @@ +:- module arith_int. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + io.command_line_arguments(Args, !IO), + ( if + Args = [AStr, BStr], + string.to_int(AStr, A), + string.to_int(BStr, B) + then + io.format("A + B = %d\n", [i(A + B)], !IO), + io.format("A - B = %d\n", [i(A - B)], !IO), + io.format("A * B = %d\n", [i(A * B)], !IO), + + % Division: round towards zero. + % + io.format("A / B = %d\n", [i(A / B)], !IO), + + % Division: round towards minus infinity. + % + io.format("A div B = %d\n", [i(A div B)], !IO), + + % Modulus: X mod Y = X - (X div Y) * Y. + % + io.format("A mod B = %d\n", [i(A mod B)], !IO), + + % Remainder: X rem Y = X - (X / Y) * Y. + % + io.format("A rem B = %d\n", [i(A rem B)], !IO), + + % Exponentiation is done using the function int.pow/2. + % + io.format("A `pow` B = %d\n", [i(A `pow` B)], !IO) + else + io.set_exit_status(1, !IO) + ). diff --git a/Task/Arithmetic-Integer/Metafont/arithmetic-integer.metafont b/Task/Arithmetic-Integer/Metafont/arithmetic-integer.metafont new file mode 100644 index 0000000000..b03551472f --- /dev/null +++ b/Task/Arithmetic-Integer/Metafont/arithmetic-integer.metafont @@ -0,0 +1,18 @@ +string s[]; +message "input number a: "; +s1 := readstring; +message "input number b: "; +s2 := readstring; +a := scantokens s1; +b := scantokens s2; + +def outp(expr op) = + message "a " & op & " b = " & decimal(a scantokens(op) b) enddef; + +outp("+"); +outp("-"); +outp("*"); +outp("div"); +outp("mod"); + +end diff --git a/Task/Arithmetic-Integer/Modula-2/arithmetic-integer.mod2 b/Task/Arithmetic-Integer/Modula-2/arithmetic-integer.mod2 new file mode 100644 index 0000000000..e7bf2cfa1d --- /dev/null +++ b/Task/Arithmetic-Integer/Modula-2/arithmetic-integer.mod2 @@ -0,0 +1,17 @@ +MODULE ints; + +IMPORT InOut; + +VAR a, b : INTEGER; + +BEGIN + InOut.WriteString ("Enter two integer numbers : "); InOut.WriteBf; + InOut.ReadInt (a); + InOut.ReadInt (b); + InOut.WriteString ("a + b = "); InOut.WriteInt (a + b, 9); InOut.WriteLn; + InOut.WriteString ("a - b = "); InOut.WriteInt (a - b, 9); InOut.WriteLn; + InOut.WriteString ("a * b = "); InOut.WriteInt (a * b, 9); InOut.WriteLn; + InOut.WriteString ("a / b = "); InOut.WriteInt (a DIV b, 9); InOut.WriteLn; + InOut.WriteString ("a MOD b = "); InOut.WriteInt (a MOD b, 9); InOut.WriteLn; + InOut.WriteLn; +END ints. diff --git a/Task/Arithmetic-Integer/Modula-3/arithmetic-integer.mod3 b/Task/Arithmetic-Integer/Modula-3/arithmetic-integer.mod3 new file mode 100644 index 0000000000..97c0973dc9 --- /dev/null +++ b/Task/Arithmetic-Integer/Modula-3/arithmetic-integer.mod3 @@ -0,0 +1,15 @@ +MODULE Arith EXPORTS Main; + +IMPORT IO, Fmt; + +VAR a, b: INTEGER; + +BEGIN + a := IO.GetInt(); + b := IO.GetInt(); + IO.Put("a+b = " & Fmt.Int(a + b) & "\n"); + IO.Put("a-b = " & Fmt.Int(a - b) & "\n"); + IO.Put("a*b = " & Fmt.Int(a * b) & "\n"); + IO.Put("a DIV b = " & Fmt.Int(a DIV b) & "\n"); + IO.Put("a MOD b = " & Fmt.Int(a MOD b) & "\n"); +END Arith. diff --git a/Task/Arithmetic-Rational/GAP/arithmetic-rational.gap b/Task/Arithmetic-Rational/GAP/arithmetic-rational.gap new file mode 100644 index 0000000000..1ff53cb71f --- /dev/null +++ b/Task/Arithmetic-Rational/GAP/arithmetic-rational.gap @@ -0,0 +1,4 @@ +2/3 in Rationals; +# true +2/3 + 3/4; +# 17/12 diff --git a/Task/Arithmetic-Rational/Groovy/arithmetic-rational-1.groovy b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-1.groovy new file mode 100644 index 0000000000..150460ab5a --- /dev/null +++ b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-1.groovy @@ -0,0 +1,130 @@ +class Rational implements Comparable { + final BigInteger numerator, denominator + + static final Rational ONE = new Rational(1, 1) + + static final Rational ZERO = new Rational(0, 1) + + Rational(BigInteger whole) { this(whole, 1) } + + Rational(BigDecimal decimal) { + this( + decimal.scale() < 0 ? decimal.unscaledValue()*10**(-decimal.scale()) : decimal.unscaledValue(), + decimal.scale() < 0 ? 1 : 10**(decimal.scale()) + ) + } + + Rational(num, denom) { + assert denom != 0 : "Denominator must not be 0" + def values = denom > 0 ? [num, denom] : [-num, -denom] //reduce(num, denom) + + numerator = values[0] + denominator = values[1] + } + + private List reduce(BigInteger num, BigInteger denom) { + BigInteger sign = ((num < 0) != (denom < 0)) ? -1 : 1 + num = num.abs() + denom = denom.abs() + BigInteger commonFactor = gcd(num, denom) + + [num.intdiv(commonFactor) * sign, denom.intdiv(commonFactor)] + } + + public Rational toLeastTerms() { + def reduced = reduce(numerator, denominator) + new Rational(reduced[0], reduced[1]) + } + + private BigInteger gcd(BigInteger n, BigInteger m) { n == 0 ? m : { while(m%n != 0) { def t=n; n=m%n; m=t }; n }() } + + Rational plus (Rational r) { new Rational(numerator*r.denominator + r.numerator*denominator, denominator*r.denominator) } + + Rational plus (BigInteger n) { new Rational(numerator + n*denominator, denominator) } + + Rational next () { new Rational(numerator + denominator, denominator) } + + Rational minus (Rational r) { new Rational(numerator*r.denominator - r.numerator*denominator, denominator*r.denominator) } + + Rational minus (BigInteger n) { new Rational(numerator - n*denominator, denominator) } + + Rational previous () { new Rational(numerator - denominator, denominator) } + + Rational multiply (Rational r) { new Rational(numerator*r.numerator, denominator*r.denominator) } + + Rational multiply (BigInteger n) { new Rational(numerator*n, denominator) } + + Rational div (Rational r) { new Rational(numerator*r.denominator, denominator*r.numerator) } + + Rational div (BigInteger n) { new Rational(numerator, denominator*n) } + + BigInteger intdiv (BigInteger n) { numerator.intdiv(denominator*n) } + + Rational negative () { new Rational(-numerator, denominator) } + + Rational abs () { new Rational(numerator.abs(), denominator) } + + Rational reciprocal() { new Rational(denominator, numerator) } + + Rational power(BigInteger n) { new Rational(numerator ** n, denominator ** n) } + + boolean asBoolean() { numerator != 0 } + + BigDecimal toBigDecimal() { (numerator as BigDecimal)/(denominator as BigDecimal) } + + BigInteger toBigInteger() { numerator.intdiv(denominator) } + + Double toDouble() { toBigDecimal().toDouble() } + + double doubleValue() { toDouble() as double } + + Float toFloat() { toBigDecimal().toFloat() } + + float floatValue() { toFloat() as float } + + Integer toInteger() { toBigInteger().toInteger() } + + int intValue() { toInteger() as int } + + Long toLong() { toBigInteger().toLong() } + + long longValue() { toLong() as long } + + Object asType(Class type) { + switch (type) { + case this.getClass(): return this + case Boolean.class: return asBoolean() + case BigDecimal.class: return toBigDecimal() + case BigInteger.class: return toBigInteger() + case Double.class: return toDouble() + case Float.class: return toFloat() + case Integer.class: return toInteger() + case Long.class: return toLong() + case String.class: return toString() + default: throw new ClassCastException("Cannot convert from type Rational to type " + type) + } + } + + boolean equals(o) { + compareTo(o) == 0 + } + + int compareTo(o) { + o instanceof Rational \ + ? compareTo(o as Rational) \ + : o instanceof Number \ + ? compareTo(o as Number)\ + : (Double.NaN as int) + } + + int compareTo(Rational r) { numerator*r.denominator <=> denominator*r.numerator } + + int compareTo(Number n) { numerator <=> denominator*(n as BigInteger) } + + int hashCode() { [numerator, denominator].hashCode() } + + String toString() { + def reduced = reduce(numerator, denominator) + "${reduced[0]}//${reduced[1]}" + } +} diff --git a/Task/Arithmetic-Rational/Groovy/arithmetic-rational-2.groovy b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-2.groovy new file mode 100644 index 0000000000..4638a46b10 --- /dev/null +++ b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-2.groovy @@ -0,0 +1,74 @@ +def x = new Rational(5, 20) +def y = new Rational(9, 12) +def z = new Rational(0, 10000) + +println x +println y +println z +println (x <=> y) +println ((x as Rational).compareTo(y)) +assert x*3 == y +assert (z + 1) <= y*4 +assert x != y + +println "x + y == ${x} + ${y} == ${x + y}" +println "x + z == ${x} + ${z} == ${x + z}" +println "x - y == ${x} - ${y} == ${x - y}" +println "x - z == ${x} - ${z} == ${x - z}" +println "x * y == ${x} * ${y} == ${x * y}" +println "y ** 3 == ${y} ** 3 == ${y ** 3}" +println "x * z == ${x} * ${z} == ${x * z}" +println "x / y == ${x} / ${y} == ${x / y}" +try { print "x / z == ${x} / ${z} == "; println "${x / z}" } +catch (Throwable t) { println t.message } + +println "-x == -${x} == ${-x}" +println "-y == -${y} == ${-y}" +println "-z == -${z} == ${-z}" + +print "x as int == ${x} as int == "; println x.intValue() +print "x as double == ${x} as double == "; println x.doubleValue() +print "1 / x as int == 1 / ${x} as int == "; println x.reciprocal().intValue() +print "1.0 / x == 1.0 / ${x} == "; println x.reciprocal().doubleValue() +print "y as int == ${y} as int == "; println y.intValue() +print "y as double == ${y} as double == "; println y.doubleValue() +print "1 / y as int == 1 / ${y} as int == "; println y.reciprocal().intValue() +print "1.0 / y == 1.0 / ${y} == "; println y.reciprocal().doubleValue() +print "z as int == ${z} as int == "; println z.intValue() +print "z as double == ${z} as double == "; println z.doubleValue() +try { print "1 / z as int == 1 / ${z} as int == "; println z.reciprocal().intValue() } +catch (Throwable t) { println t.message } +try { print "1.0 / z == 1.0 / ${z} == "; println z.reciprocal().doubleValue() } +catch (Throwable t) { println t.message } + +println "++x == ++ ${x} == ${++x}" +println "++y == ++ ${y} == ${++y}" +println "++z == ++ ${z} == ${++z}" +println "-- --x == -- -- ${x} == ${-- (--x)}" +println "-- --y == -- -- ${y} == ${-- (--y)}" +println "-- --z == -- -- ${z} == ${-- (--z)}" +println x +println y +println z + +println (x <=> y) +assert x*3 == y +assert (z + 1) <= y*4 +assert (x < y) + +println (new Rational(25)) +println (new Rational(25.0)) +println (new Rational(0.25)) + +println Math.PI +println (new Rational(Math.PI)) +println ((new Rational(Math.PI)).toBigDecimal()) +println ((new Rational(Math.PI)) as BigDecimal) +println ((new Rational(Math.PI)) as Double) +println ((new Rational(Math.PI)) as double) +println ((new Rational(Math.PI)) as boolean) +println (z as boolean) +try { println ((new Rational(Math.PI)) as Date) } +catch (Throwable t) { println t.message } +try { println ((new Rational(Math.PI)) as char) } +catch (Throwable t) { println t.message } diff --git a/Task/Arithmetic-Rational/Groovy/arithmetic-rational-3.groovy b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-3.groovy new file mode 100644 index 0000000000..1421eca833 --- /dev/null +++ b/Task/Arithmetic-Rational/Groovy/arithmetic-rational-3.groovy @@ -0,0 +1,26 @@ +def factorize = { target -> + if (target == 1L) { + return [1L] + } else if ([2L, 3L].contains(target)) { + return [1L, target] + } + def targetSqrt = Math.ceil(Math.sqrt(target)) as long + def lowfactors = (2L..(targetSqrt)).findAll { (target % it) == 0 } + + if (lowfactors.isEmpty()) { + return [1L, target] + } + + def nhalf = lowfactors.size() - ((lowfactors[-1] == targetSqrt) ? 1 : 0) + + return ([1L] + lowfactors + ((nhalf-1)..0).collect { target.intdiv(lowfactors[it]) } + [target]).unique() +} + +1.upto(2**19) { + if ((it % 100000) == 0) { println "HT" } + else if ((it % 1000) == 0) { print "." } + + def factors = factorize(it) + def isPerfect = factors.collect{ factor -> new Rational( factor ).reciprocal() }.sum() == new Rational(2) + if (isPerfect) { println() ; println ([perfect: it, factors: factors]) } +} diff --git a/Task/Arithmetic-Rational/Icon/arithmetic-rational-1.icon b/Task/Arithmetic-Rational/Icon/arithmetic-rational-1.icon new file mode 100644 index 0000000000..42d43bf7a0 --- /dev/null +++ b/Task/Arithmetic-Rational/Icon/arithmetic-rational-1.icon @@ -0,0 +1,34 @@ +procedure main() + limit := 2^19 + + write("Perfect numbers up to ",limit," (using rational arithmetic):") + every write(is_perfect(c := 2 to limit)) + write("End of perfect numbers") + + # verify the rest of the implementation + + zero := makerat(0) # from integer + half := makerat(0.5) # from real + qtr := makerat("1/4") # from strings ... + one := makerat("1") + mone := makerat("-1") + + verifyrat("eqrat",zero,zero) + verifyrat("ltrat",zero,half) + verifyrat("ltrat",half,zero) + verifyrat("gtrat",zero,half) + verifyrat("gtrat",half,zero) + verifyrat("nerat",zero,half) + verifyrat("nerat",zero,zero) + verifyrat("absrat",mone,) + +end + +procedure is_perfect(c) #: test for perfect numbers using rational arithmetic + rsum := rational(1, c, 1) + every f := 2 to sqrt(c) do + if 0 = c % f then + rsum := addrat(rsum,addrat(rational(1,f,1),rational(1,integer(c/f),1))) + if rsum.numer = rsum.denom = 1 then + return c +end diff --git a/Task/Arithmetic-Rational/Icon/arithmetic-rational-2.icon b/Task/Arithmetic-Rational/Icon/arithmetic-rational-2.icon new file mode 100644 index 0000000000..7828b55afd --- /dev/null +++ b/Task/Arithmetic-Rational/Icon/arithmetic-rational-2.icon @@ -0,0 +1,61 @@ +procedure verifyrat(p,r1,r2) #: verification tests for rational procedures +return write("Testing ",p,"( ",rat2str(r1),", ",rat2str(\r2) | &null," ) ==> ","returned " || rat2str(p(r1,r2)) | "failed") +end + +procedure makerat(x) #: make rational (from integer, real, or strings) +local n,d +static c +initial c := &digits++'+-' + + return case type(x) of { + "real" : real2rat(x) + "integer" : ratred(rational(x,1,1)) + "string" : if x ? ( n := integer(tab(many(c))), ="/", d := integer(tab(many(c))), pos(0)) then + ratred(rational(n,d,1)) + else + makerat(numeric(x)) + } +end + +procedure absrat(r1) #: abs(rational) + r1 := ratred(r1) + r1.sign := 1 + return r1 +end + +invocable all # for string invocation + +procedure xoprat(op,r1,r2) #: support procedure for binary operations that cross denominators + local numer, denom, div + + r1 := ratred(r1) + r2 := ratred(r2) + + return if op(r1.numer * r2.denom,r2.numer * r1.denom) then r2 # return right argument on success +end + +procedure eqrat(r1,r2) #: rational r1 = r2 +return xoprat("=",r1,r2) +end + +procedure nerat(r1,r2) #: rational r1 ~= r2 +return xoprat("~=",r1,r2) +end + +procedure ltrat(r1,r2) #: rational r1 < r2 +return xoprat("<",r1,r2) +end + +procedure lerat(r1,r2) #: rational r1 <= r2 +return xoprat("<=",r1,r2) +end + +procedure gerat(r1,r2) #: rational r1 >= r2 +return xoprat(">=",r1,r2) +end + +procedure gtrat(r1,r2) #: rational r1 > r2 +return xoprat(">",r1,r2) +end + +link rational diff --git a/Task/Arithmetic-Rational/Icon/arithmetic-rational-3.icon b/Task/Arithmetic-Rational/Icon/arithmetic-rational-3.icon new file mode 100644 index 0000000000..f62052e43c --- /dev/null +++ b/Task/Arithmetic-Rational/Icon/arithmetic-rational-3.icon @@ -0,0 +1,15 @@ + record rational(numer, denom, sign) # rational type + + addrat(r1,r2) # Add rational numbers r1 and r2. + divrat(r1,r2) # Divide rational numbers r1 and r2. + medrat(r1,r2) # Form mediant of r1 and r2. + mpyrat(r1,r2) # Multiply rational numbers r1 and r2. + negrat(r) # Produce negative of rational number r. + rat2real(r) # Produce floating-point approximation of r + rat2str(r) # Convert the rational number r to its string representation. + real2rat(v,p) # Convert real to rational with precision p (default 1e-10). Warning: excessive p gives ugly fractions + reciprat(r) # Produce the reciprocal of rational number r. + str2rat(s) # Convert the string representation (such as "3/2") to a rational number + subrat(r1,r2) # Subtract rational numbers r1 and r2. + + gcd(i, j) # returns greatest common divisor of i and j diff --git a/Task/Arithmetic-Rational/J/arithmetic-rational-1.j b/Task/Arithmetic-Rational/J/arithmetic-rational-1.j new file mode 100644 index 0000000000..43410ffad4 --- /dev/null +++ b/Task/Arithmetic-Rational/J/arithmetic-rational-1.j @@ -0,0 +1,2 @@ + 3r4*2r5 +3r10 diff --git a/Task/Arithmetic-Rational/J/arithmetic-rational-2.j b/Task/Arithmetic-Rational/J/arithmetic-rational-2.j new file mode 100644 index 0000000000..69202bf44d --- /dev/null +++ b/Task/Arithmetic-Rational/J/arithmetic-rational-2.j @@ -0,0 +1 @@ + is_perfect_rational=: 2 = (1 + i.) +/@:%@([ #~ 0 = |) ] diff --git a/Task/Arithmetic-Rational/J/arithmetic-rational-3.j b/Task/Arithmetic-Rational/J/arithmetic-rational-3.j new file mode 100644 index 0000000000..3e4a5cd64e --- /dev/null +++ b/Task/Arithmetic-Rational/J/arithmetic-rational-3.j @@ -0,0 +1,2 @@ +factors=: */&>@{@((^ i.@>:)&.>/)@q:~&__ +is_perfect_rational=: 2= +/@:%@,@factors diff --git a/Task/Arithmetic-Rational/J/arithmetic-rational-4.j b/Task/Arithmetic-Rational/J/arithmetic-rational-4.j new file mode 100644 index 0000000000..22a9cdb013 --- /dev/null +++ b/Task/Arithmetic-Rational/J/arithmetic-rational-4.j @@ -0,0 +1,4 @@ + I.is_perfect_rational@"0 i.2^19 +6 28 496 8128 + I.is_perfect_rational@x:@"0 i.2^19x +6 28 496 8128 diff --git a/Task/Arithmetic-Rational/J/arithmetic-rational-5.j b/Task/Arithmetic-Rational/J/arithmetic-rational-5.j new file mode 100644 index 0000000000..4a3f32d884 --- /dev/null +++ b/Task/Arithmetic-Rational/J/arithmetic-rational-5.j @@ -0,0 +1,2 @@ + (#~ is_perfect_rational"0) (* <:@+:) 2^i.10x +6 28 496 8128 diff --git a/Task/Arithmetic-Rational/Liberty-BASIC/arithmetic-rational.liberty b/Task/Arithmetic-Rational/Liberty-BASIC/arithmetic-rational.liberty new file mode 100644 index 0000000000..c2f7fa1baa --- /dev/null +++ b/Task/Arithmetic-Rational/Liberty-BASIC/arithmetic-rational.liberty @@ -0,0 +1,120 @@ +n=2^19 +for testNumber=1 to n + sum$=castToFraction$(0) + for factorTest=1 to sqr(testNumber) + if GCD(factorTest,testNumber)=factorTest then sum$=add$(sum$,add$(reciprocal$(castToFraction$(factorTest)),reciprocal$(castToFraction$(testNumber/factorTest)))) + next factorTest + if equal(sum$,castToFraction$(2))=1 then print testNumber +next testNumber +end + +function abs$(a$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + bNumerator=abs(aNumerator) + bDenominator=abs(aDenominator) + b$=str$(bNumerator)+"/"+str$(bDenominator) + abs$=simplify$(b$) +end function + +function negate$(a$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + bNumerator=-1*aNumerator + bDenominator=aDenominator + b$=str$(bNumerator)+"/"+str$(bDenominator) + negate$=simplify$(b$) +end function + +function add$(a$,b$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + bNumerator=val(word$(b$,1,"/")) + bDenominator=val(word$(b$,2,"/")) + cNumerator=(aNumerator*bDenominator+bNumerator*aDenominator) + cDenominator=aDenominator*bDenominator + c$=str$(cNumerator)+"/"+str$(cDenominator) + add$=simplify$(c$) +end function + +function subtract$(a$,b$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + bNumerator=val(word$(b$,1,"/")) + bDenominator=val(word$(b$,2,"/")) + cNumerator=(aNumerator*bDenominator-bNumerator*aDenominator) + cDenominator=aDenominator*bDenominator + c$=str$(cNumerator)+"/"+str$(cDenominator) + subtract$=simplify$(c$) +end function + +function multiply$(a$,b$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + bNumerator=val(word$(b$,1,"/")) + bDenominator=val(word$(b$,2,"/")) + cNumerator=aNumerator*bNumerator + cDenominator=aDenominator*bDenominator + c$=str$(cNumerator)+"/"+str$(cDenominator) + multiply$=simplify$(c$) +end function + +function divide$(a$,b$) + divide$=multiply$(a$,reciprocal$(b$)) +end function + +function simplify$(a$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + gcd=GCD(aNumerator,aDenominator) + if aNumerator<0 and aDenominator<0 then gcd=-1*gcd + bNumerator=aNumerator/gcd + bDenominator=aDenominator/gcd + b$=str$(bNumerator)+"/"+str$(bDenominator) + simplify$=b$ +end function + +function reciprocal$(a$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + reciprocal$=str$(aDenominator)+"/"+str$(aNumerator) +end function + +function equal(a$,b$) + if simplify$(a$)=simplify$(b$) then equal=1:else equal=0 +end function + +function castToFraction$(a) + do + exp=exp+1 + a=a*10 + loop until a=int(a) + castToFraction$=simplify$(str$(a)+"/"+str$(10^exp)) +end function + +function castToReal(a$) + aNumerator=val(word$(a$,1,"/")) + aDenominator=val(word$(a$,2,"/")) + castToReal=aNumerator/aDenominator +end function + +function castToInt(a$) + castToInt=int(castToReal(a$)) +end function + +function GCD(a,b) + if a=0 then + GCD=1 + else + if a>=b then + while b + c = a + a = b + b = c mod b + GCD = abs(a) + wend + else + GCD=GCD(b,a) + end if + end if +end function diff --git a/Task/Arithmetic-Rational/Maple/arithmetic-rational-1.maple b/Task/Arithmetic-Rational/Maple/arithmetic-rational-1.maple new file mode 100644 index 0000000000..61c9f3dc12 --- /dev/null +++ b/Task/Arithmetic-Rational/Maple/arithmetic-rational-1.maple @@ -0,0 +1,8 @@ +> a := 3 / 5; + a := 3/5 + +> numer( a ); + 3 + +> denom( a ); + 5 diff --git a/Task/Arithmetic-Rational/Maple/arithmetic-rational-2.maple b/Task/Arithmetic-Rational/Maple/arithmetic-rational-2.maple new file mode 100644 index 0000000000..e8d5d0acb2 --- /dev/null +++ b/Task/Arithmetic-Rational/Maple/arithmetic-rational-2.maple @@ -0,0 +1,2 @@ +> b := 4 / 6; + b := 2/3 diff --git a/Task/Arithmetic-Rational/Maple/arithmetic-rational-3.maple b/Task/Arithmetic-Rational/Maple/arithmetic-rational-3.maple new file mode 100644 index 0000000000..6c5eb15ebf --- /dev/null +++ b/Task/Arithmetic-Rational/Maple/arithmetic-rational-3.maple @@ -0,0 +1,21 @@ +> a + b; + 19 + -- + 15 + +> a * b; + 2/5 + +> a / b; + 9/10 + +> a - b; + -1 + -- + 15 + +> a + 1; + 8/5 + +> a - 1; + -2/5 diff --git a/Task/Arithmetic-Rational/Maple/arithmetic-rational-4.maple b/Task/Arithmetic-Rational/Maple/arithmetic-rational-4.maple new file mode 100644 index 0000000000..1186136af9 --- /dev/null +++ b/Task/Arithmetic-Rational/Maple/arithmetic-rational-4.maple @@ -0,0 +1,6 @@ +> evalf( 22 / 7 ); # default is 10 digits + 3.142857143 + +> evalf[100]( 22 / 7 ); # 100 digits +3.142857142857142857142857142857142857142857142857142857142857142857\ + 142857142857142857142857142857143 diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-1.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-1.mathematica new file mode 100644 index 0000000000..7427db21f9 --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-1.mathematica @@ -0,0 +1,26 @@ +4/16 +3/8 +8/4 +4Pi/2 +16!/10! +Sqrt[9/16] +Sqrt[3/4] +(23/12)^5 +2 + 1/(1 + 1/(3 + 1/4)) + +1/2+1/3+1/5 +8/Pi+Pi/8 //Together +13/17 + 7/31 +Sum[1/n,{n,1,100}] (*summation of 1/1 + 1/2 + 1/3 + 1/4+ .........+ 1/99 + 1/100*) + +1/2-1/3 +a=1/3;a+=1/7 + +1/4==2/8 +1/4>3/8 +Pi/E >23/20 +1/3!=123/370 +Sin[3]/Sin[2]>3/20 + +Numerator[6/9] +Denominator[6/9] diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-2.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-2.mathematica new file mode 100644 index 0000000000..7228dbd8e6 --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-2.mathematica @@ -0,0 +1,3 @@ +c/(2 c) +(b^2 - c^2)/(b - c) // Cancel +1/2 + b/c // Together diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-3.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-3.mathematica new file mode 100644 index 0000000000..b4ff08b7c1 --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-3.mathematica @@ -0,0 +1,3 @@ +1/2 +b+c +(2 b+c) / (2 c) diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-4.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-4.mathematica new file mode 100644 index 0000000000..e4812dc77c --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-4.mathematica @@ -0,0 +1 @@ +1+2*{1,2,3}^3 diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-5.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-5.mathematica new file mode 100644 index 0000000000..5505fa9236 --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-5.mathematica @@ -0,0 +1 @@ +{3, 17, 55} diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-6.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-6.mathematica new file mode 100644 index 0000000000..0101f2d1f3 --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-6.mathematica @@ -0,0 +1,4 @@ +found={}; +CheckPerfect[num_Integer]:=If[Total[1/Divisors[num]]==2,AppendTo[found,num]]; +Do[CheckPerfect[i],{i,1,2^25}]; +found diff --git a/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-7.mathematica b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-7.mathematica new file mode 100644 index 0000000000..f15295c89a --- /dev/null +++ b/Task/Arithmetic-Rational/Mathematica/arithmetic-rational-7.mathematica @@ -0,0 +1 @@ +{6, 28, 496, 8128, 33550336} diff --git a/Task/Arithmetic-Rational/Maxima/arithmetic-rational.maxima b/Task/Arithmetic-Rational/Maxima/arithmetic-rational.maxima new file mode 100644 index 0000000000..522fdd418c --- /dev/null +++ b/Task/Arithmetic-Rational/Maxima/arithmetic-rational.maxima @@ -0,0 +1,30 @@ +/* Rational numbers are builtin */ +a: 3 / 11; +3/11 + +b: 117 / 17; +117/17 + +a + b; +1338/187 + +a - b; +-1236/187 + +a * b; +351/187 + +a / b; +17/429 + +a^5; +243/161051 + +num(a); +3 + +denom(a); +11 + +ratnump(a); +true diff --git a/Task/Arithmetic-evaluation/Factor/arithmetic-evaluation.factor b/Task/Arithmetic-evaluation/Factor/arithmetic-evaluation.factor new file mode 100644 index 0000000000..c8461deafe --- /dev/null +++ b/Task/Arithmetic-evaluation/Factor/arithmetic-evaluation.factor @@ -0,0 +1,42 @@ +USING: accessors kernel locals math math.parser peg.ebnf ; +IN: rosetta.arith + +TUPLE: operator left right ; +TUPLE: add < operator ; C: add +TUPLE: sub < operator ; C: sub +TUPLE: mul < operator ; C: mul +TUPLE: div < operator ; C:

div + +EBNF: expr-ast +spaces = [\n\t ]* +digit = [0-9] +number = (digit)+ => [[ string>number ]] + +value = spaces number:n => [[ n ]] + | spaces "(" exp:e spaces ")" => [[ e ]] + +fac = fac:a spaces "*" value:b => [[ a b ]] + | fac:a spaces "/" value:b => [[ a b
]] + | value + +exp = exp:a spaces "+" fac:b => [[ a b ]] + | exp:a spaces "-" fac:b => [[ a b ]] + | fac + +main = exp:e spaces !(.) => [[ e ]] +;EBNF + +GENERIC: eval-ast ( ast -- result ) + +M: number eval-ast ; + +: recursive-eval ( ast -- left-result right-result ) + [ left>> eval-ast ] [ right>> eval-ast ] bi ; + +M: add eval-ast recursive-eval + ; +M: sub eval-ast recursive-eval - ; +M: mul eval-ast recursive-eval * ; +M: div eval-ast recursive-eval / ; + +: evaluate ( string -- result ) + expr-ast eval-ast ; diff --git a/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-1.groovy b/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-1.groovy new file mode 100644 index 0000000000..d0082a39dd --- /dev/null +++ b/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-1.groovy @@ -0,0 +1,144 @@ +enum Op { + ADD('+', 2), + SUBTRACT('-', 2), + MULTIPLY('*', 1), + DIVIDE('/', 1); + + static { + ADD.operation = { a, b -> a + b } + SUBTRACT.operation = { a, b -> a - b } + MULTIPLY.operation = { a, b -> a * b } + DIVIDE.operation = { a, b -> a / b } + } + + final String symbol + final int precedence + Closure operation + + private Op(String symbol, int precedence) { + this.symbol = symbol + this.precedence = precedence + } + + String toString() { symbol } + + static Op fromSymbol(String symbol) { + Op.values().find { it.symbol == symbol } + } +} + +interface Expression { + Number evaluate(); +} + +class Constant implements Expression { + Number value + + Constant (Number value) { this.value = value } + + Constant (String str) { + try { this.value = str as BigInteger } + catch (e) { this.value = str as BigDecimal } + } + + Number evaluate() { value } + + String toString() { "${value}" } +} + +class Term implements Expression { + Op op + Expression left, right + + Number evaluate() { op.operation(left.evaluate(), right.evaluate()) } + + String toString() { "(${op} ${left} ${right})" } +} + +void fail(String msg, Closure cond = {true}) { + if (cond()) throw new IllegalArgumentException("Cannot parse expression: ${msg}") +} + +Expression parse(String expr) { + def tokens = tokenize(expr) + def elements = groupByParens(tokens, 0) + parse(elements) +} + +List tokenize(String expr) { + def tokens = [] + def constStr = "" + def captureConstant = { i -> + if (constStr) { + try { tokens << new Constant(constStr) } + catch (NumberFormatException e) { fail "Invalid constant '${constStr}' near position ${i}" } + constStr = '' + } + } + for(def i = 0; i tokens.size() } + def subGroup = groupByParens(tokens[i+1..-1], depth+1) + tokenGroups << subGroup[0..-2] + i += subGroup[-1] + 1 + break + case ')': + fail("Unbalanced parens, found extra ')'") { deepness == 0 } + tokenGroups << i + return tokenGroups + default: + tokenGroups << token + } + } + fail("Unbalanced parens, unclosed groupings at end of expression") { deepness != 0 } + def n = tokenGroups.size() + fail("The operand/operator sequence is wrong") { n%2 == 0 } + (0.. 1) { + def n = elements.size() + fail ("The operand/operator sequence is wrong") { n%2 == 0 } + def groupLoc = (0.. elements[i] instanceof List } + if (groupLoc != null) { + elements[groupLoc] = parse(elements[groupLoc]) + continue + } + def opLoc = (0.. elements[i] instanceof Op && elements[i].precedence == 1 } \ + ?: (0.. elements[i] instanceof Op && elements[i].precedence == 2 } + if (opLoc != null) { + fail ("Operator out of sequence") { opLoc%2 == 0 } + def term = new Term(left:elements[opLoc-1], op:elements[opLoc], right:elements[opLoc+1]) + elements[(opLoc-1)..(opLoc+1)] = [term] + continue + } + } + return elements[0] instanceof List ? parse(elements[0]) : elements[0] +} diff --git a/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-2.groovy b/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-2.groovy new file mode 100644 index 0000000000..d2df101dde --- /dev/null +++ b/Task/Arithmetic-evaluation/Groovy/arithmetic-evaluation-2.groovy @@ -0,0 +1,36 @@ +def testParse = { + def ex = parse(it) + print """ +Input: ${it} +AST: ${ex} +value: ${ex.evaluate()} +""" +} + + +testParse('1+1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1/15)/14)/13)/12)/11)/10)/9)/8)/7)/6)/5)/4)/3)/2') +assert (parse('1+1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1/15)/14)/13)/12)/11)/10)/9)/8)/7)/6)/5)/4)/3)/2') + .evaluate() - Math.E).abs() < 0.0000000000001 +testParse('1 + 2*(3 - 2*(3 - 2)*((2 - 4)*5 - 22/(7 + 2*(3 - 1)) - 1)) + 1') +testParse('1 - 5 * 2 / 20 + 1') +testParse('(1 - 5) * 2 / (20 + 1)') +testParse('2 * (3 + ((5) / (7 - 11)))') +testParse('(2 + 3) / (10 - 5)') +testParse('(1 + 2) * 10 / 100') +testParse('(1 + 2 / 2) * (5 + 5)') +testParse('2*-3--4+-.25') +testParse('2*(-3)-(-4)+(-.25)') +testParse('((11+15)*15)*2-(3)*4*1') +testParse('((11+15)*15)* 2 + (3) * -4 *1') +testParse('(((((1)))))') +testParse('-35') +println() + +try { testParse('((11+15)*1') } catch (e) { println e } +try { testParse('((11+15)*1)))') } catch (e) { println e } +try { testParse('((11+15)*x)') } catch (e) { println e } +try { testParse('+++++') } catch (e) { println e } +try { testParse('1 /') } catch (e) { println e } +try { testParse('1++') } catch (e) { println e } +try { testParse('*1') } catch (e) { println e } +try { testParse('/ 1 /') } catch (e) { println e } diff --git a/Task/Arithmetic-evaluation/Icon/arithmetic-evaluation.icon b/Task/Arithmetic-evaluation/Icon/arithmetic-evaluation.icon new file mode 100644 index 0000000000..a7e0c3cae4 --- /dev/null +++ b/Task/Arithmetic-evaluation/Icon/arithmetic-evaluation.icon @@ -0,0 +1,101 @@ +procedure main() #: simple arithmetical parser / evaluator + write("Usage: Input expression = Abstract Syntax Tree = Value, ^Z to end.") + repeat { + writes("Input expression : ") + if not writes(line := read()) then break + if map(line) ? { (x := E()) & pos(0) } then + write(" = ", showAST(x), " = ", evalAST(x)) + else + write(" rejected") + } +end + +procedure evalAST(X) #: return the evaluated AST + local x + + if type(X) == "list" then { + x := evalAST(get(X)) + while x := get(X)(x, evalAST(get(X) | stop("Malformed AST."))) + } + return \x | X +end + +procedure showAST(X) #: return a string representing the AST + local x,s + + s := "" + every x := !X do + s ||:= if type(x) == "list" then "(" || showAST(x) || ")" else x + return s +end + +######## +# When you're writing a big parser, a few utility recognisers are very useful +# +procedure ws() # skip optional whitespace + suspend tab(many(' \t')) | "" +end + +procedure digits() + suspend tab(many(&digits)) +end + +procedure radixNum(r) # r sets the radix + static chars + initial chars := &digits || &lcase + suspend tab(many(chars[1 +: r])) +end +######## + +global token +record HansonsDevice(precedence,associativity) + +procedure opinfo() + static O + initial { + O := HansonsDevice([], table(&null)) # parsing table + put(O.precedence, ["+", "-"], ["*", "/", "%"], ["^"]) # Lowest to Highest precedence + every O.associativity[!!O.precedence] := 1 # default to 1 for LEFT associativity + O.associativity["^"] := 0 # RIGHT associativity + } + return O +end + +procedure E(k) #: Expression + local lex, pL + static opT + initial opT := opinfo() + + /k := 1 + lex := [] + if not (pL := opT.precedence[k]) then # this op at this level? + put(lex, F()) + else { + put(lex, E(k + 1)) + while ws() & put(lex, token := =!pL) do + put(lex, E(k + opT.associativity[token])) + } + suspend if *lex = 1 then lex[1] else lex # strip useless [] +end + +procedure F() #: Factor + suspend ws() & ( # skip optional whitespace, and ... + (="+" & F()) | # unary + and a Factor, or ... + (="-" || V()) | # unary - and a Value, or ... + (="-" & [-1, "*", F()]) | # unary - and a Factor, or ... + 2(="(", E(), ws(), =")") | # parenthesized subexpression, or ... + V() # just a value + ) +end + +procedure V() #: Value + local r + suspend ws() & numeric( # skip optional whitespace, and ... + =(r := 1 to 36) || ="r" || radixNum(r) | # N-based number, or ... + digits() || (="." || digits() | "") || exponent() # plain number with optional fraction + ) +end + +procedure exponent() + suspend tab(any('eE')) || =("+" | "-" | "") || digits() | "" +end diff --git a/Task/Arithmetic-evaluation/J/arithmetic-evaluation-1.j b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-1.j new file mode 100644 index 0000000000..05d141904e --- /dev/null +++ b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-1.j @@ -0,0 +1,66 @@ +parse=:parse_parser_ +eval=:monad define + 'gerund structure'=:y + gerund@.structure +) + +coclass 'parser' +classify=: '$()*/+-'&(((>:@#@[ # 2:) #: 2 ^ i.)&;:) + +rules=: '' +patterns=: ,"0 assert 1 + +addrule=: dyad define + rules=: rules,;:x + patterns=: patterns,+./@classify"1 y +) + +'Term' addrule '$()', '0', '+-',: '0' +'Factor' addrule '$()+-', '0', '*/',: '0' +'Parens' addrule '(', '*/+-0', ')',: ')*/+-0$' +rules=: rules,;:'Move' + +buildTree=: monad define + words=: ;:'$',y + queue=: classify '$',y + stack=: classify '$$$$' + tokens=: ]&.>i.#words + tree=: '' + while.(#queue)+.6<#stack do. + rule=: rules {~ i.&1 patterns (*./"1)@:(+./"1) .(*."1)4{.stack + rule`:6'' + end. + 'syntax' assert 1 0 1 1 1 1 -: {:"1 stack + gerund=: literal&.> (<,'%') (I. words=<,'/')} words + gerund;1{tree +) + +literal=:monad define ::] + ".'t=.',y + 5!:1<'t' +) + +Term=: Factor=: monad define + stack=: ({.stack),(classify '0'),4}.stack + tree=: ({.tree),(<1 2 3{tree),4}.tree +) + +Parens=: monad define + stack=: (1{stack),3}.stack + tree=: (1{tree),3}.tree +) + +Move=: monad define + 'syntax' assert 0<#queue + stack=: ({:queue),stack + queue=: }:queue + tree=: ({:tokens),tree + tokens=: }:tokens +) + +parse=:monad define + tmp=: conew 'parser' + r=: buildTree__tmp y + coerase tmp + r +) diff --git a/Task/Arithmetic-evaluation/J/arithmetic-evaluation-2.j b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-2.j new file mode 100644 index 0000000000..cd7e9275c8 --- /dev/null +++ b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-2.j @@ -0,0 +1,2 @@ + eval parse '1+2*3/(4-5+6)' +2.2 diff --git a/Task/Arithmetic-evaluation/J/arithmetic-evaluation-3.j b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-3.j new file mode 100644 index 0000000000..6db0a6250c --- /dev/null +++ b/Task/Arithmetic-evaluation/J/arithmetic-evaluation-3.j @@ -0,0 +1,10 @@ + parse '2*3/(4-5)' +┌─────────────────────────────────────────────────────┬───────────────────┐ +│┌───┬───────┬───┬───────┬───┬─┬───────┬───┬───────┬─┐│┌───────┬─┬───────┐│ +││┌─┐│┌─────┐│┌─┐│┌─────┐│┌─┐│(│┌─────┐│┌─┐│┌─────┐│)│││┌─┬─┬─┐│4│┌─┬─┬─┐││ +│││$│││┌─┬─┐│││*│││┌─┬─┐│││%││ ││┌─┬─┐│││-│││┌─┬─┐││ ││││1│2│3││ ││6│7│8│││ +││└─┘│││0│2│││└─┘│││0│3│││└─┘│ │││0│4│││└─┘│││0│5│││ │││└─┴─┴─┘│ │└─┴─┴─┘││ +││ ││└─┴─┘││ ││└─┴─┘││ │ ││└─┴─┘││ ││└─┴─┘││ ││└───────┴─┴───────┘│ +││ │└─────┘│ │└─────┘│ │ │└─────┘│ │└─────┘│ ││ │ +│└───┴───────┴───┴───────┴───┴─┴───────┴───┴───────┴─┘│ │ +└─────────────────────────────────────────────────────┴───────────────────┘ diff --git a/Task/Arithmetic-evaluation/Julia/arithmetic-evaluation.julia b/Task/Arithmetic-evaluation/Julia/arithmetic-evaluation.julia new file mode 100644 index 0000000000..7a5eb59458 --- /dev/null +++ b/Task/Arithmetic-evaluation/Julia/arithmetic-evaluation.julia @@ -0,0 +1,41 @@ +julia> expr="2 * (3 -1) + 2 * 5" +"2 * (3 -1) + 2 * 5" + +julia> parsed = parse(expr) #Julia provides low-level access to language parser for AST/Expr creation +:(+(*(2,-(3,1)),*(2,5))) + +julia> t = typeof(parsed) +Expr + +julia> names(t) #shows type fields +(:head,:args,:typ) + +julia> parsed.args #Inspect our 'Expr' type innards +3-element Any Array: + :+ + :(*(2,-(3,1))) + :(*(2,5)) + +julia> typeof(parsed.args[2]) #'Expr' types can nest +Expr + +julia> parsed.args[2].args +3-element Any Array: + :* + 2 + :(-(3,1)) + +julia> parsed.args[2].args[3].args #Will nest until lowest level of AST +3-element Any Array: + :- + 3 + 1 + +julia> eval(parsed) +14 + +julia> eval(parse("1 - 5 * 2 / 20 + 1")) +1.5 + +julia> eval(parse("2 * (3 + ((5) / (7 - 11)))")) +3.5 diff --git a/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-1.mathematica b/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-1.mathematica new file mode 100644 index 0000000000..b68beefc1c --- /dev/null +++ b/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-1.mathematica @@ -0,0 +1,34 @@ +(*parsing:*) +parse[string_] := + Module[{e}, + StringCases[string, + "+" | "-" | "*" | "/" | "(" | ")" | + DigitCharacter ..] //. {a_String?DigitQ :> + e[ToExpression@a], {x___, PatternSequence["(", a_e, ")"], + y___} :> {x, a, + y}, {x : + PatternSequence[] | + PatternSequence[___, "(" | "+" | "-" | "*" | "/"], + PatternSequence[op : "+" | "-", a_e], y___} :> {x, e[op, a], + y}, {x : + PatternSequence[] | PatternSequence[___, "(" | "+" | "-"], + PatternSequence[a_e, op : "*" | "/", b_e], y___} :> {x, + e[op, a, b], + y}, {x : + PatternSequence[] | PatternSequence[___, "(" | "+" | "-"], + PatternSequence[a_e, b_e], y___} :> {x, e["*", a, b], + y}, {x : PatternSequence[] | PatternSequence[___, "("], + PatternSequence[a_e, op : "+" | "-", b_e], + y : PatternSequence[] | + PatternSequence[")" | "+" | "-", ___]} :> {x, e[op, a, b], + y}} //. {e -> List, {a_Integer} :> a, {a_List} :> a}] + +(*evaluation*) +evaluate[a_Integer] := a; +evaluate[{"+", a_}] := evaluate[a]; +evaluate[{"-", a_}] := -evaluate[a]; +evaluate[{"+", a_, b_}] := evaluate[a] + evaluate[b]; +evaluate[{"-", a_, b_}] := evaluate[a] - evaluate[b]; +evaluate[{"*", a_, b_}] := evaluate[a]*evaluate[b]; +evaluate[{"/", a_, b_}] := evaluate[a]/evaluate[b]; +evaluate[string_String] := evaluate[parse[string]] diff --git a/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-2.mathematica b/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-2.mathematica new file mode 100644 index 0000000000..156ef89de8 --- /dev/null +++ b/Task/Arithmetic-evaluation/Mathematica/arithmetic-evaluation-2.mathematica @@ -0,0 +1,2 @@ +parse["-1+2(3+4*-5/6)"] +evaluate["-1+2(3+4*-5/6)"] diff --git a/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-1.j b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-1.j new file mode 100644 index 0000000000..886ffca52e --- /dev/null +++ b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-1.j @@ -0,0 +1,3 @@ +mean=: +/ % # + (mean , */ %:~ #)^:_] 1,%%:2 +0.8472130847939792 0.8472130847939791 diff --git a/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-2.j b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-2.j new file mode 100644 index 0000000000..42b9305572 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-2.j @@ -0,0 +1,2 @@ + ~.(mean , */ %:~ #)^:_] 1,%%:2 +0.8472130847939792 diff --git a/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-3.j b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-3.j new file mode 100644 index 0000000000..7fd85b0ff0 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/J/arithmetic-geometric-mean-3.j @@ -0,0 +1,6 @@ + (mean, */ %:~ #)^:a: 1,%%:2 + 1 0.7071067811865475 +0.8535533905932737 0.8408964152537145 +0.8472249029234942 0.8472012667468915 +0.8472130848351929 0.8472130847527654 +0.8472130847939792 0.8472130847939791 diff --git a/Task/Arithmetic-geometric-mean/Liberty-BASIC/arithmetic-geometric-mean.liberty b/Task/Arithmetic-geometric-mean/Liberty-BASIC/arithmetic-geometric-mean.liberty new file mode 100644 index 0000000000..429ff1e011 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Liberty-BASIC/arithmetic-geometric-mean.liberty @@ -0,0 +1,13 @@ +print agm(1, 1/sqr(2)) +print using("#.#################",agm(1, 1/sqr(2))) + +function agm(a,g) + do + absdiff = abs(a-g) + an=(a+g)/2 + gn=sqr(a*g) + a=an + g=gn + loop while abs(an-gn)< absdiff + agm = a +end function diff --git a/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-1.maple b/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-1.maple new file mode 100644 index 0000000000..3b173b4997 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-1.maple @@ -0,0 +1,6 @@ +> evalf( GaussAGM( 1, 1 / sqrt( 2 ) ) ); # default precision is 10 digits + 0.8472130847 + +> evalf[100]( GaussAGM( 1, 1 / sqrt( 2 ) ) ); # to 100 digits +0.847213084793979086606499123482191636481445910326942185060579372659\ + 7340048341347597232002939946112300 diff --git a/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-2.maple b/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-2.maple new file mode 100644 index 0000000000..5f33866d21 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Maple/arithmetic-geometric-mean-2.maple @@ -0,0 +1,2 @@ +> GaussAGM( 1.0, 1 / sqrt( 2 ) ); + 0.8472130847 diff --git a/Task/Arithmetic-geometric-mean/Mathematica/arithmetic-geometric-mean.mathematica b/Task/Arithmetic-geometric-mean/Mathematica/arithmetic-geometric-mean.mathematica new file mode 100644 index 0000000000..1dcbbcae92 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Mathematica/arithmetic-geometric-mean.mathematica @@ -0,0 +1,2 @@ +PrecisionDigits = 85; +AGMean[a_, b_] := FixedPoint[{ (Plus@@#)/2, Sqrt[Times@@#] }&, N[{a,b}, PrecisionDigits]][[1]] diff --git a/Task/Arithmetic-geometric-mean/Maxima/arithmetic-geometric-mean.maxima b/Task/Arithmetic-geometric-mean/Maxima/arithmetic-geometric-mean.maxima new file mode 100644 index 0000000000..fb68dbb533 --- /dev/null +++ b/Task/Arithmetic-geometric-mean/Maxima/arithmetic-geometric-mean.maxima @@ -0,0 +1,4 @@ +agm(a, b) := %pi/4*(a + b)/elliptic_kc(((a - b)/(a + b))^2)$ + +agm(1, 1/sqrt(2)), bfloat, fpprec: 85; +/* 8.472130847939790866064991234821916364814459103269421850605793726597340048341347597232b-1 */ diff --git a/Task/Array-concatenation/Factor/array-concatenation-1.factor b/Task/Array-concatenation/Factor/array-concatenation-1.factor new file mode 100644 index 0000000000..15bfb21a64 --- /dev/null +++ b/Task/Array-concatenation/Factor/array-concatenation-1.factor @@ -0,0 +1 @@ +append diff --git a/Task/Array-concatenation/Factor/array-concatenation-2.factor b/Task/Array-concatenation/Factor/array-concatenation-2.factor new file mode 100644 index 0000000000..150f26f30b --- /dev/null +++ b/Task/Array-concatenation/Factor/array-concatenation-2.factor @@ -0,0 +1,3 @@ +( scratchpad ) USE: sequences +( scratchpad ) { 1 2 } { 3 4 } append . +{ 1 2 3 4 } diff --git a/Task/Array-concatenation/Fantom/array-concatenation.fantom b/Task/Array-concatenation/Fantom/array-concatenation.fantom new file mode 100644 index 0000000000..aaf8b0bbb5 --- /dev/null +++ b/Task/Array-concatenation/Fantom/array-concatenation.fantom @@ -0,0 +1,5 @@ +> a := [1,2,3] +> b := [4,5,6] +> a.addAll(b) +> a +[1,2,3,4,5,6] diff --git a/Task/Array-concatenation/GAP/array-concatenation.gap b/Task/Array-concatenation/GAP/array-concatenation.gap new file mode 100644 index 0000000000..a9d534615d --- /dev/null +++ b/Task/Array-concatenation/GAP/array-concatenation.gap @@ -0,0 +1,10 @@ +# Concatenate arrays +Concatenation([1, 2, 3], [4, 5, 6], [7, 8, 9]); +# [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] + +# Append to a variable +a := [1, 2, 3]; +Append(a, [4, 5, 6); +Append(a, [7, 8, 9]); +a; +# [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] diff --git a/Task/Array-concatenation/Gosu/array-concatenation.gosu b/Task/Array-concatenation/Gosu/array-concatenation.gosu new file mode 100644 index 0000000000..3cd2a392ed --- /dev/null +++ b/Task/Array-concatenation/Gosu/array-concatenation.gosu @@ -0,0 +1,6 @@ +var listA = { 1, 2, 3 } +var listB = { 4, 5, 6 } + +var listC = listA.concat( listB ) + +print( listC ) // prints [1, 2, 3, 4, 5, 6] diff --git a/Task/Array-concatenation/Groovy/array-concatenation-1.groovy b/Task/Array-concatenation/Groovy/array-concatenation-1.groovy new file mode 100644 index 0000000000..4ed31b0c49 --- /dev/null +++ b/Task/Array-concatenation/Groovy/array-concatenation-1.groovy @@ -0,0 +1 @@ +def list = [1, 2, 3] + ["Crosby", "Stills", "Nash", "Young"] diff --git a/Task/Array-concatenation/Groovy/array-concatenation-2.groovy b/Task/Array-concatenation/Groovy/array-concatenation-2.groovy new file mode 100644 index 0000000000..64ef5c96ea --- /dev/null +++ b/Task/Array-concatenation/Groovy/array-concatenation-2.groovy @@ -0,0 +1 @@ +println list diff --git a/Task/Array-concatenation/HicEst/array-concatenation.hicest b/Task/Array-concatenation/HicEst/array-concatenation.hicest new file mode 100644 index 0000000000..67a02970ec --- /dev/null +++ b/Task/Array-concatenation/HicEst/array-concatenation.hicest @@ -0,0 +1,6 @@ +REAL :: a(7), b(3), c(10) + +c = a +DO i = 1, LEN(b) + c(i + LEN(a)) = b(i) +ENDDO diff --git a/Task/Array-concatenation/IDL/array-concatenation-1.idl b/Task/Array-concatenation/IDL/array-concatenation-1.idl new file mode 100644 index 0000000000..1ee93be148 --- /dev/null +++ b/Task/Array-concatenation/IDL/array-concatenation-1.idl @@ -0,0 +1,10 @@ + > a = [1,2,3] + > b = [4,5,6] + > help,a + A INT = Array[3] + > help,b + B INT = Array[3] + > print,a + 1 2 3 + > print,b + 4 5 6 diff --git a/Task/Array-concatenation/IDL/array-concatenation-2.idl b/Task/Array-concatenation/IDL/array-concatenation-2.idl new file mode 100644 index 0000000000..9e87f15671 --- /dev/null +++ b/Task/Array-concatenation/IDL/array-concatenation-2.idl @@ -0,0 +1,4 @@ + > help,[a,b] + INT = Array[6] + > print,[a,b] + 1 2 3 4 5 6 diff --git a/Task/Array-concatenation/IDL/array-concatenation-3.idl b/Task/Array-concatenation/IDL/array-concatenation-3.idl new file mode 100644 index 0000000000..a5c3c99e5e --- /dev/null +++ b/Task/Array-concatenation/IDL/array-concatenation-3.idl @@ -0,0 +1,5 @@ + > help,[[a],[b]] + INT = Array[3, 2] + > print,[[a],[b]] + 1 2 3 + 4 5 6 diff --git a/Task/Array-concatenation/IDL/array-concatenation-4.idl b/Task/Array-concatenation/IDL/array-concatenation-4.idl new file mode 100644 index 0000000000..695b3325be --- /dev/null +++ b/Task/Array-concatenation/IDL/array-concatenation-4.idl @@ -0,0 +1,13 @@ + > b = transpose(b) + > help,b + B INT = Array[1, 3] + > print,b + 4 + 5 + 6 + > print,[a,b] + Unable to concatenate variables because the dimensions do not agree: B. + Execution halted at: $MAIN$ + > print,[[a],[b]] + Unable to concatenate variables because the dimensions do not agree: B. + Execution halted at: $MAIN$ diff --git a/Task/Array-concatenation/Icon/array-concatenation.icon b/Task/Array-concatenation/Icon/array-concatenation.icon new file mode 100644 index 0000000000..fb55e17143 --- /dev/null +++ b/Task/Array-concatenation/Icon/array-concatenation.icon @@ -0,0 +1,10 @@ +procedure main() + L1 := [1, 2, 3, 4] + L2 := [11, 12, 13, 14] + L3 := L1 ||| L2 + + sep := "" + every writes(sep, !L3) do + sep := ", " + write() +end diff --git a/Task/Array-concatenation/Inform-7/array-concatenation.inf b/Task/Array-concatenation/Inform-7/array-concatenation.inf new file mode 100644 index 0000000000..3c166d234b --- /dev/null +++ b/Task/Array-concatenation/Inform-7/array-concatenation.inf @@ -0,0 +1,3 @@ +let A be {1, 2, 3}; +let B be {4, 5, 6}; +add B to A; diff --git a/Task/Array-concatenation/Ioke/array-concatenation.ioke b/Task/Array-concatenation/Ioke/array-concatenation.ioke new file mode 100644 index 0000000000..3d80c0f70e --- /dev/null +++ b/Task/Array-concatenation/Ioke/array-concatenation.ioke @@ -0,0 +1,3 @@ +iik> [1,2,3] + [3,2,1] +[1,2,3] + [3,2,1] ++> [1, 2, 3, 3, 2, 1] diff --git a/Task/Array-concatenation/J/array-concatenation-1.j b/Task/Array-concatenation/J/array-concatenation-1.j new file mode 100644 index 0000000000..bb635fcb9b --- /dev/null +++ b/Task/Array-concatenation/J/array-concatenation-1.j @@ -0,0 +1,4 @@ + array1 =: 1 2 3 + array2 =: 4 5 6 + array1 , array2 +1 2 3 4 5 6 diff --git a/Task/Array-concatenation/J/array-concatenation-2.j b/Task/Array-concatenation/J/array-concatenation-2.j new file mode 100644 index 0000000000..6da7a7468b --- /dev/null +++ b/Task/Array-concatenation/J/array-concatenation-2.j @@ -0,0 +1,33 @@ + ]ab=: 3 3 $ 'aaabbbccc' +aaa +bbb +ccc + ]wx=: 3 3 $ 'wxyz' +wxy +zwx +yzw + ab , wx +aaa +bbb +ccc +wxy +zwx +yzw + ab ,. wx +aaawxy +bbbzwx +cccyzw + ab ,: wx +aaa +bbb +ccc + +wxy +zwx +yzw + $ ab , wx NB. applies to first (highest) axis +6 3 + $ ab ,. wx NB. applies to last (atomic) axis +3 6 + $ ab ,: wx NB. applies to new (higher) axis +2 3 3 diff --git a/Task/Array-concatenation/Julia/array-concatenation.julia b/Task/Array-concatenation/Julia/array-concatenation.julia new file mode 100644 index 0000000000..edd741fcf0 --- /dev/null +++ b/Task/Array-concatenation/Julia/array-concatenation.julia @@ -0,0 +1,5 @@ +a = [1,2,3] +b = [4,5,6] +ab = [a,b] +#alternative +ab = vcat(a,b) diff --git a/Task/Array-concatenation/K/array-concatenation-1.k b/Task/Array-concatenation/K/array-concatenation-1.k new file mode 100644 index 0000000000..bb9ef52688 --- /dev/null +++ b/Task/Array-concatenation/K/array-concatenation-1.k @@ -0,0 +1,4 @@ + a: 1 2 3 + b: 4 5 6 + a,b +1 2 3 4 5 6 diff --git a/Task/Array-concatenation/K/array-concatenation-2.k b/Task/Array-concatenation/K/array-concatenation-2.k new file mode 100644 index 0000000000..04ee56b1ab --- /dev/null +++ b/Task/Array-concatenation/K/array-concatenation-2.k @@ -0,0 +1,32 @@ + ab:3 3#"abcdefghi" +("abc" + "def" + "ghi") + + dd:3 3#"012345678" +("012" + "345" + "678") + + ab,dd +("abc" + "def" + "ghi" + "012" + "345" + "678") + + +ab,dd / flip (transpose) join +("adg036" + "beh147" + "cfi258") + + ab,'dd / eachpair join +("abc012" + "def345" + "ghi678") + + +(+ab),dd +("abc036" + "def147" + "ghi258") diff --git a/Task/Array-concatenation/Lang5/array-concatenation.lang5 b/Task/Array-concatenation/Lang5/array-concatenation.lang5 new file mode 100644 index 0000000000..d65862fb34 --- /dev/null +++ b/Task/Array-concatenation/Lang5/array-concatenation.lang5 @@ -0,0 +1 @@ +[1 2] [3 4] append diff --git a/Task/Array-concatenation/Liberty-BASIC/array-concatenation.liberty b/Task/Array-concatenation/Liberty-BASIC/array-concatenation.liberty new file mode 100644 index 0000000000..0b7f146bc0 --- /dev/null +++ b/Task/Array-concatenation/Liberty-BASIC/array-concatenation.liberty @@ -0,0 +1,18 @@ + x=10 + y=20 + dim array1(x) + dim array2(y) + +[concatenate] + dim array3(x + y) + for i = 1 to x + array3(i) = array1(i) + next + for i = 1 to y + array3(i + x) = array2(i) + next + +[print] + for i = 1 to x + y + print array3(i) + next diff --git a/Task/Array-concatenation/Logo/array-concatenation.logo b/Task/Array-concatenation/Logo/array-concatenation.logo new file mode 100644 index 0000000000..16d0c03a2c --- /dev/null +++ b/Task/Array-concatenation/Logo/array-concatenation.logo @@ -0,0 +1,4 @@ +to combine-arrays :a1 :a2 + output listtoarray sentence arraytolist :a1 arraytolist :a2 +end +show combine-arrays {1 2 3} {4 5 6} ; {1 2 3 4 5 6} diff --git a/Task/Array-concatenation/Maple/array-concatenation-1.maple b/Task/Array-concatenation/Maple/array-concatenation-1.maple new file mode 100644 index 0000000000..9e470e6e48 --- /dev/null +++ b/Task/Array-concatenation/Maple/array-concatenation-1.maple @@ -0,0 +1,25 @@ +> A := Array( [ 1, 2, 3 ] ); + A := [1, 2, 3] + +> B := Vector['row']( [ sin( x ), cos( x ), tan( x ) ] ); + B := [sin(x), cos(x), tan(x)] + +> ArrayTools:-Concatenate( 1, A, B ); # stack vertically + [ 1 2 3 ] + [ ] + [sin(x) cos(x) tan(x)] + +> ArrayTools:-Concatenate( 2, A, B ); # stack horizontally + [1, 2, 3, sin(x), cos(x), tan(x)] + +> M := << a, b, c ; d, e, f >>; # a matrix + [a b c] + M := [ ] + [d e f] + +> ArrayTools:-Concatenate( 1, M, A ); + [a b c] + [ ] + [d e f] + [ ] + [1 2 3] diff --git a/Task/Array-concatenation/Maple/array-concatenation-2.maple b/Task/Array-concatenation/Maple/array-concatenation-2.maple new file mode 100644 index 0000000000..79b61516f5 --- /dev/null +++ b/Task/Array-concatenation/Maple/array-concatenation-2.maple @@ -0,0 +1,6 @@ +> ArrayTools:-Concatenate( 1, A, M ); + [1 2 3] + [ ] + [a b c] + [ ] + [d e f] diff --git a/Task/Array-concatenation/Maple/array-concatenation-3.maple b/Task/Array-concatenation/Maple/array-concatenation-3.maple new file mode 100644 index 0000000000..e68b99028d --- /dev/null +++ b/Task/Array-concatenation/Maple/array-concatenation-3.maple @@ -0,0 +1,11 @@ +> L1 := [ 1, 2, 3 ]; + L1 := [1, 2, 3] + +> L2 := [ a, b, c ]; + L2 := [a, b, c] + +> [ op( L1 ), op( L2 ) ]; + [1, 2, 3, a, b, c] + +> [ L1[], L2[] ]; # equivalent, just different syntax + [1, 2, 3, a, b, c] diff --git a/Task/Array-concatenation/Mathematica/array-concatenation.mathematica b/Task/Array-concatenation/Mathematica/array-concatenation.mathematica new file mode 100644 index 0000000000..80670e5562 --- /dev/null +++ b/Task/Array-concatenation/Mathematica/array-concatenation.mathematica @@ -0,0 +1,3 @@ +Join[{1,2,3}, {4,5,6}] + +-> {1, 2, 3, 4, 5, 6} diff --git a/Task/Array-concatenation/Maxima/array-concatenation.maxima b/Task/Array-concatenation/Maxima/array-concatenation.maxima new file mode 100644 index 0000000000..48f54aee6d --- /dev/null +++ b/Task/Array-concatenation/Maxima/array-concatenation.maxima @@ -0,0 +1,23 @@ +u: [1, 2, 3, 4]$ +v: [5, 6, 7, 8, 9, 10]$ +append(u, v); +/* [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] */ + +/* There are also functions for matrices */ + +a: matrix([6, 1, 8], + [7, 5, 3], + [2, 9, 4])$ + +addcol(a, ident(3)); +/* matrix([6, 1, 8, 1, 0, 0], + [7, 5, 3, 0, 1, 0], + [2, 9, 4, 0, 0, 1]) */ + +addrow(a, ident(3)); +/* matrix([6, 1, 8], + [7, 5, 3], + [2, 9, 4], + [1, 0, 0], + [0, 1, 0], + [0, 0, 1]) */ diff --git a/Task/Array-concatenation/Mercury/array-concatenation.mercury b/Task/Array-concatenation/Mercury/array-concatenation.mercury new file mode 100644 index 0000000000..aba0703fbb --- /dev/null +++ b/Task/Array-concatenation/Mercury/array-concatenation.mercury @@ -0,0 +1 @@ +A `append` B = C diff --git a/Task/Arrays/Factor/arrays-1.factor b/Task/Arrays/Factor/arrays-1.factor new file mode 100644 index 0000000000..316ffebc5a --- /dev/null +++ b/Task/Arrays/Factor/arrays-1.factor @@ -0,0 +1,7 @@ +{ 1 2 3 } +{ + [ "The initial array: " write . ] + [ [ 42 1 ] dip set-nth ] + [ "Modified array: " write . ] + [ "The element we modified: " write [ 1 ] dip nth . ] +} cleave diff --git a/Task/Arrays/Factor/arrays-2.factor b/Task/Arrays/Factor/arrays-2.factor new file mode 100644 index 0000000000..1c7793c4dd --- /dev/null +++ b/Task/Arrays/Factor/arrays-2.factor @@ -0,0 +1,6 @@ +V{ 1 2 3 } +{ + [ "The initial vector: " write . ] + [ [ 42 ] dip push ] + [ "Modified vector: " write . ] +} cleave diff --git a/Task/Arrays/GAP/arrays.gap b/Task/Arrays/GAP/arrays.gap new file mode 100644 index 0000000000..8dc56657b7 --- /dev/null +++ b/Task/Arrays/GAP/arrays.gap @@ -0,0 +1,45 @@ +# Arrays are better called lists in GAP. Lists may have elements of mixed types, e$ +v := [ 10, 7, "bob", true, [ "inner", 5 ] ]; +# [ 10, 7, "bob", true, [ "inner", 5 ] ] + +# List index runs from 1 to Size(v) +v[1]; +# 10 + +v[0]; +# error + +v[5]; +# [ "inner", 5 ] + +v[6]; +# error + +# One can assign a value to an undefined element +v[6] := 100; + +# Even if it's not after the last: a list may have undefined elements +v[10] := 1000; +v; +# [ 10, 7, "bob", true, [ "inner", 5 ], 100,,,, 1000 ] + +# And one can check for defined values +IsBound(v[10]); +# true + +IsBound(v[9]); +# false + +# Size of the list +Size(v); +# 10 + +# Appending a list to the end of another +Append(v, [ 8, 9]); +v; +# [ 10, 7, "bob", true, [ "inner", 5 ], 100,,,, 1000, 8, 9 ] + +# Adding an element at the end +Add(v, "added"); +v; +# [ 10, 7, "bob", true, [ "inner", 5 ], 100,,,, 1000, 8, 9, "added" ] diff --git a/Task/Arrays/GML/arrays-1.gml b/Task/Arrays/GML/arrays-1.gml new file mode 100644 index 0000000000..c956a6e8ee --- /dev/null +++ b/Task/Arrays/GML/arrays-1.gml @@ -0,0 +1,4 @@ +array[0] = ' ' +array[1] = 'A' +array[2] = 'B' +array[3] = 'C' diff --git a/Task/Arrays/GML/arrays-2.gml b/Task/Arrays/GML/arrays-2.gml new file mode 100644 index 0000000000..7b918c83b6 --- /dev/null +++ b/Task/Arrays/GML/arrays-2.gml @@ -0,0 +1,2 @@ +for(i = 0; i < k; i += 1) + array[i] = i + 1 diff --git a/Task/Arrays/GML/arrays-3.gml b/Task/Arrays/GML/arrays-3.gml new file mode 100644 index 0000000000..aede078472 --- /dev/null +++ b/Task/Arrays/GML/arrays-3.gml @@ -0,0 +1,12 @@ +array[1,1] = 1 +array[1,2] = 2 +array[1,3] = 3 +array[1,4] = 4 +array[2,1] = 2 +array[2,2] = 4 +array[2,3] = 6 +array[2,4] = 8 +array[3,1] = 3 +array[3,2] = 6 +array[3,3] = 9 +array[3,4] = 12 diff --git a/Task/Arrays/GML/arrays-4.gml b/Task/Arrays/GML/arrays-4.gml new file mode 100644 index 0000000000..cc01ddee35 --- /dev/null +++ b/Task/Arrays/GML/arrays-4.gml @@ -0,0 +1,3 @@ +for(i = 1; i <= k; i += 1) + for(j = 1; j <= h; j += 1) + array[i,j] = i * j diff --git a/Task/Arrays/GUISS/arrays.guiss b/Task/Arrays/GUISS/arrays.guiss new file mode 100644 index 0000000000..c17a7d445e --- /dev/null +++ b/Task/Arrays/GUISS/arrays.guiss @@ -0,0 +1 @@ +Start,Programs,Lotus 123,Type:Bob[downarrow],Kat[downarrow],Sarah[downarrow] diff --git a/Task/Arrays/Gambas/arrays.gambas b/Task/Arrays/Gambas/arrays.gambas new file mode 100644 index 0000000000..2848498fb1 --- /dev/null +++ b/Task/Arrays/Gambas/arrays.gambas @@ -0,0 +1,8 @@ +DIM mynumbers AS INTEGER[] +myfruits AS STRING[] + +mynumbers[0] = 1.5 +mynumbers[1] = 2.3 + +myfruits[0] = "apple" +myfruits[1] = "banana" diff --git a/Task/Arrays/Golfscript/arrays.golf b/Task/Arrays/Golfscript/arrays.golf new file mode 100644 index 0000000000..28bd325e50 --- /dev/null +++ b/Task/Arrays/Golfscript/arrays.golf @@ -0,0 +1,5 @@ +[1 2 3]:a; # numeric only array, assigned to a and then dropped +10,:a; # assign to a [0 1 2 3 4 5 6 7 8 9] +a 0= puts # pick element at index 0 (stack: 0) +a 10+puts # append 10 to the end of a +10 a+puts # prepend 10 to a diff --git a/Task/Arrays/Groovy/arrays-1.groovy b/Task/Arrays/Groovy/arrays-1.groovy new file mode 100644 index 0000000000..2a8ce1e5e1 --- /dev/null +++ b/Task/Arrays/Groovy/arrays-1.groovy @@ -0,0 +1,20 @@ +def aa = [ 1, 25, 31, -3 ] // list +def a = [0] * 100 // list of 100 zeroes +def b = 1..9 // range notation +def c = (1..10).collect { 2.0**it } // each output element is 2**(corresponding invoking list element) + +// There are no true "multi-dimensional" arrays in Groovy (as in most C-derived languages). +// Use lists of lists in natural ("row major") order as a stand in. +def d = (0..1).collect { i -> (1..5).collect { j -> 2**(5*i+j) as double } } +def e = [ [ 1.0, 2.0, 3.0, 4.0 ], + [ 5.0, 6.0, 7.0, 8.0 ], + [ 9.0, 10.0, 11.0, 12.0 ], + [ 13.0, 14.0, 15.0, 16.0 ] ] + +println aa +println b +println c +println() +d.each { print "["; it.each { elt -> printf "%7.1f ", elt }; println "]" } +println() +e.each { print "["; it.each { elt -> printf "%7.1f ", elt }; println "]" } diff --git a/Task/Arrays/Groovy/arrays-2.groovy b/Task/Arrays/Groovy/arrays-2.groovy new file mode 100644 index 0000000000..b938fea146 --- /dev/null +++ b/Task/Arrays/Groovy/arrays-2.groovy @@ -0,0 +1,3 @@ +def identity = { n -> + (1..n).collect { i -> (1..n).collect { j -> i==j ? 1.0 : 0.0 } } +} diff --git a/Task/Arrays/Groovy/arrays-3.groovy b/Task/Arrays/Groovy/arrays-3.groovy new file mode 100644 index 0000000000..7eb3f0c35e --- /dev/null +++ b/Task/Arrays/Groovy/arrays-3.groovy @@ -0,0 +1,7 @@ +def i2 = identity(2) +def i15 = identity(15) + + +i2.each { print "["; it.each { elt -> printf "%4.1f ", elt }; println "]" } +println() +i15.each { print "["; it.each { elt -> printf "%4.1f ", elt }; println "]" } diff --git a/Task/Arrays/Groovy/arrays-4.groovy b/Task/Arrays/Groovy/arrays-4.groovy new file mode 100644 index 0000000000..cb92128ca2 --- /dev/null +++ b/Task/Arrays/Groovy/arrays-4.groovy @@ -0,0 +1,11 @@ +def strings = ['Mary', 'had', 'a', 'little', 'lamb', ". It's", 'fleece', 'was', 'white', 'as', 'snow'] + +println strings + +strings[0] = 'Arthur' +strings[4] = 'towel' +strings[6] = 'stain' +strings[8] = 'ripe' +strings[10] = 'strawberries' + +println strings diff --git a/Task/Arrays/Groovy/arrays-5.groovy b/Task/Arrays/Groovy/arrays-5.groovy new file mode 100644 index 0000000000..67067d3105 --- /dev/null +++ b/Task/Arrays/Groovy/arrays-5.groovy @@ -0,0 +1 @@ +println strings[-1] diff --git a/Task/Arrays/Groovy/arrays-6.groovy b/Task/Arrays/Groovy/arrays-6.groovy new file mode 100644 index 0000000000..8d3f9ba85d --- /dev/null +++ b/Task/Arrays/Groovy/arrays-6.groovy @@ -0,0 +1,3 @@ +println strings[0, 7, 2, 3, 8] +println strings[0..4] +println strings[0..3, -5] diff --git a/Task/Arrays/HicEst/arrays-1.hicest b/Task/Arrays/HicEst/arrays-1.hicest new file mode 100644 index 0000000000..410727cc4f --- /dev/null +++ b/Task/Arrays/HicEst/arrays-1.hicest @@ -0,0 +1,11 @@ +REAL :: n = 3, Astat(n), Bdyn(1, 1) + +Astat(2) = 2.22222222 +WRITE(Messagebox, Name) Astat(2) + +ALLOCATE(Bdyn, 2*n, 3*n) +Bdyn(n-1, n) = -123 +WRITE(Row=27) Bdyn(n-1, n) + +ALIAS(Astat, n-1, last2ofAstat, 2) +WRITE(ClipBoard) last2ofAstat ! 2.22222222 0 diff --git a/Task/Arrays/HicEst/arrays-2.hicest b/Task/Arrays/HicEst/arrays-2.hicest new file mode 100644 index 0000000000..ae65dbdff8 --- /dev/null +++ b/Task/Arrays/HicEst/arrays-2.hicest @@ -0,0 +1,98 @@ +record aThing(a, b, c) # arbitrary object (record or class) for illustration + +procedure main() + A0 := [] # empty list + A0 := list() # empty list (default size 0) + A0 := list(0) # empty list (literal size 0) + + A1 := list(10) # 10 elements, default initializer &null + A2 := list(10, 1) # 10 elements, initialized to 1 + + # literal array construction - arbitrary dynamically typed members + A3 := [1, 2, 3, ["foo", "bar", "baz"], aThing(1, 2, 3), "the end"] + + # left-end workers + # NOTE: get() is a synonym for pop() which allows nicely-worded use of put() and get() to implement queues + # + Q := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + x := pop(A0) # x is 1 + x := get(A0) # x is 2 + push(Q,0) + # Q is now [0,3, 4, 5, 6, 7, 8, 9, 10] + + # right-end workers + x := pull(Q) # x is 10 + put(Q, 100) # Q is now [0, 3, 4, 5, 6, 7, 8, 9, 100] + + # push and put return the list they are building + # they also can have multiple arguments which work like repeated calls + + Q2 := put([],1,2,3) # Q2 is [1,2,3] + Q3 := push([],1,2,3) # Q3 is [3,2,1] + Q4 := push(put(Q2),4),0] # Q4 is [0,1,2,3,4] and so is Q2 + + # array access follows with A as the sample array + A := [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] + + # get element indexed from left + x := A[1] # x is 10 + x := A[2] # x is 20 + x := A[10] # x is 100 + + # get element indexed from right + x := A[-1] # x is 100 + x := A[-2] # x is 90 + x := A[-10] # x is 10 + + # copy array to show assignment to elements + B := copy(A) + + # assign element indexed from left + B[1] := 11 + B[2] := 21 + B[10] := 101 + # B is now [11, 21, 30, 50, 60, 60, 70, 80, 90, 101] + + # assign element indexed from right - see below + B[-1] := 102 + B[-2] := 92 + B[-10] := 12 + # B is now [12, 21, 30, 50, 60, 60, 70, 80, 92, 102] + + # list slicing + # the unusual nature of the slice - returning 1 less element than might be expected + # in many languages - is best understood if you imagine indexes as pointing to BEFORE + # the item of interest. When a slice is made, the elements between the two points are + # collected. eg in the A[3 : 6] sample, it will get the elements between the [ ] marks + # + # sample list: 10 20 [30 40 50] 60 70 80 90 100 + # positive indexes: 1 2 3 4 5 6 7 8 9 10 11 + # non-positive indexes: -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 + # + # I have deliberately drawn the indexes between the positions of the values. + # The nature of this indexing brings simplicity to string operations + # + # list slicing can also use non-positive indexes to access values from the right. + # The final index of 0 shown above shows how the end of the list can be nominated + # without having to know it's length + # + # NOTE: list slices are distinct lists, so assigning to the slice + # or a member of the slice does not change the values in A + # + # Another key fact to understand: once the non-positive indexes and length-offsets are + # resolved to a simple positive index, the index pair (if two are given) are swapped + # if necessary to yield the elements between the two. + # + S := A[3 : 6] # S is [30, 40, 50] + S := A[6 : 3] # S is [30, 40, 50] not illegal or erroneous + S := A[-5 : -8] # S is [30, 40, 50] + S := A[-8 : -5] # S is [30, 40, 50] also legal and meaningful + + # list slicing with length request + S := A[3 +: 3] # S is [30, 40, 50] + S := A[6 -: 3] # S is [30, 40, 50] + S := A[-8 +: 3] # S is [30, 40, 50] + S := A[-5 -: 3] # S is [30, 40, 50] + S := A[-8 -: -3] # S is [30, 40, 50] + S := A[-5 +: -3] # S is [30, 40, 50] +end diff --git a/Task/Arrays/HicEst/arrays-3.hicest b/Task/Arrays/HicEst/arrays-3.hicest new file mode 100644 index 0000000000..a3a972a13f --- /dev/null +++ b/Task/Arrays/HicEst/arrays-3.hicest @@ -0,0 +1,3 @@ +# Unicon provides a number of extensions +# insert and delete work on lists allowing changes in the middle +# possibly others diff --git a/Task/Arrays/Io/arrays.io b/Task/Arrays/Io/arrays.io new file mode 100644 index 0000000000..66b00c3f43 --- /dev/null +++ b/Task/Arrays/Io/arrays.io @@ -0,0 +1,5 @@ +foo := list("foo", "bar", "baz") +foo at(1) println // bar +foo append("Foobarbaz") +foo println +foo atPut(2, "barbaz") // baz becomes barbaz diff --git a/Task/Arrays/J/arrays.j b/Task/Arrays/J/arrays.j new file mode 100644 index 0000000000..35ff36045b --- /dev/null +++ b/Task/Arrays/J/arrays.j @@ -0,0 +1,28 @@ + 1 NB. a stand-alone scalar value is an array without any axis +1 + NB. invoking any array produces that array as the result + {. array=: 1 3, 6#0 NB. create, name, then get head item of the array: 1 3 0 0 0 0 0 0 +1 + 0 { array NB. another way to get the head item +1 + aword=: 'there' NB. a literal array + 0 1 3 2 2 { aword NB. multiple items can be drawn in a single action +three + ]twoD=: 3 5 $ 'abcdefghijklmnopqrstuvwxyz' +abcde +fghij +klmno + 1 { twoD NB. item 1 from twoD - a list of three items +fghij + 1 {"1 twoD NB. item 1 from each rank-1 item of twoD (i.e. column 1) +bgl + (<2 2){ twoD NB. bracket indexing is not used in J +m + 'X' 1} aword NB. amend item 1 +tXere + aword=: 'X' 1 4} aword NB. in-place amend of items 1 and 4 +tXerX + 'X' (0 0;1 1;2 2)} twoD NB. amend specified items +Xbcde +fXhij +klXno diff --git a/Task/Arrays/KonsolScript/arrays.konso b/Task/Arrays/KonsolScript/arrays.konso new file mode 100644 index 0000000000..fe4fea1e5d --- /dev/null +++ b/Task/Arrays/KonsolScript/arrays.konso @@ -0,0 +1,11 @@ +//creates an array of length 3 +Array:New array[3]:Number; + +function main() { + Var:Number length; + Array:GetLength(array, length) //retrieve length of array + Konsol:Log(length) + + array[0] = 5; //assign value + Konsol:Log(array[0]) //retrieve value and display +} diff --git a/Task/Arrays/LSE64/arrays.lse64 b/Task/Arrays/LSE64/arrays.lse64 new file mode 100644 index 0000000000..2112e8b9ee --- /dev/null +++ b/Task/Arrays/LSE64/arrays.lse64 @@ -0,0 +1,3 @@ +10 myArray :array +0 array 5 [] ! # store 0 at the sixth cell in the array +array 5 [] @ # contents of sixth cell in array diff --git a/Task/Arrays/LSL/arrays.lsl b/Task/Arrays/LSL/arrays.lsl new file mode 100644 index 0000000000..1f9bddca0f --- /dev/null +++ b/Task/Arrays/LSL/arrays.lsl @@ -0,0 +1,28 @@ +default { + state_entry() { + list lst = ["1", "2", "3"]; + llSay(0, "Create and Initialize a List\nList=["+llList2CSV(lst)+"]\n"); + + lst += ["A", "B", "C"]; + llSay(0, "Append to List\nList=["+llList2CSV(lst)+"]\n"); + + lst = llListInsertList(lst, ["4", "5", "6"], 3); + llSay(0, "List Insertion\nList=["+llList2CSV(lst)+"]\n"); + + lst = llListReplaceList(lst, ["a", "b", "c"], 3, 5); + llSay(0, "Replace a portion of a list\nList=["+llList2CSV(lst)+"]\n"); + + lst = llListRandomize(lst, 1); + llSay(0, "Randomize a List\nList=["+llList2CSV(lst)+"]\n"); + + lst = llListSort(lst, 1, TRUE); + llSay(0, "Sort a List\nList=["+llList2CSV(lst)+"]\n"); + + lst = [1, 2.0, "string", (key)NULL_KEY, ZERO_VECTOR, ZERO_ROTATION]; + string sCSV = llList2CSV(lst); + llSay(0, "Serialize a List of different datatypes to a string\n(integer, float, string, key, vector, rotation)\nCSV=\""+sCSV+"\"\n"); + + lst = llCSV2List(sCSV); + llSay(0, "Deserialize a string CSV List\n(note that all elements are now string datatype)\nList=["+llList2CSV(lst)+"]\n"); + } +} diff --git a/Task/Arrays/Liberty-BASIC/arrays.liberty b/Task/Arrays/Liberty-BASIC/arrays.liberty new file mode 100644 index 0000000000..82bdcd5e5f --- /dev/null +++ b/Task/Arrays/Liberty-BASIC/arrays.liberty @@ -0,0 +1,13 @@ +dim Array(10) + +Array(0) = -1 +Array(10) = 1 + +print Array( 0), Array( 10) + +REDIM Array( 100) + +print Array( 0), Array( 10) + +Array( 0) = -1 +print Array( 0), Array( 10) diff --git a/Task/Arrays/Lisaac/arrays.lisaac b/Task/Arrays/Lisaac/arrays.lisaac new file mode 100644 index 0000000000..1c969b1700 --- /dev/null +++ b/Task/Arrays/Lisaac/arrays.lisaac @@ -0,0 +1,5 @@ ++ a : ARRAY(INTEGER); +a := ARRAY(INTEGER).create 0 to 9; +a.put 1 to 0; +a.put 3 to 1; +a.item(1).print; diff --git a/Task/Arrays/Logo/arrays.logo b/Task/Arrays/Logo/arrays.logo new file mode 100644 index 0000000000..acb5dbfe95 --- /dev/null +++ b/Task/Arrays/Logo/arrays.logo @@ -0,0 +1,5 @@ +array 5 ; default origin is 1, every item is empty +(array 5 0) ; custom origin +make "a {1 2 3 4 5} ; array literal +setitem 1 :a "ten ; Logo is dynamic; arrays can contain different types +print item 1 :a ; ten diff --git a/Task/Arrays/Mathematica/arrays.mathematica b/Task/Arrays/Mathematica/arrays.mathematica new file mode 100644 index 0000000000..737b0baada --- /dev/null +++ b/Task/Arrays/Mathematica/arrays.mathematica @@ -0,0 +1,3 @@ +a = Array[Sin, 10] +a[[1]] +Delete[a, 2] diff --git a/Task/Arrays/Maxima/arrays.maxima b/Task/Arrays/Maxima/arrays.maxima new file mode 100644 index 0000000000..44750b326a --- /dev/null +++ b/Task/Arrays/Maxima/arrays.maxima @@ -0,0 +1,25 @@ +/* Declare an array, subscripts run from 0 to max value */ +array(a, flonum, 20, 20, 3)$ + +arrayinfo(a); +/* [complete, 3, [20, 20, 3]] */ + +a[0, 0]: 1.0; + +listarray(a); +/* [1.0, 0.0, 0.0, ..., 0.0] */ + +/* Show all declared arrays */ +arrays; +/* [a] */ + + +/* One may also use an array without declaring it, it's a hashed array */ +b[1]: 1000; +b['x]: 3/4; /* hashed array may have any subscript */ + +arrayinfo(b); +/* [hashed, 1, [1], [x]] */ + +listarray(b); +/* [1000, 3/4] */ diff --git a/Task/Arrays/Modula-3/arrays-1.mod3 b/Task/Arrays/Modula-3/arrays-1.mod3 new file mode 100644 index 0000000000..3aecf873fe --- /dev/null +++ b/Task/Arrays/Modula-3/arrays-1.mod3 @@ -0,0 +1 @@ +VAR a: ARRAY [1..10] OF INTEGER; diff --git a/Task/Arrays/Modula-3/arrays-2.mod3 b/Task/Arrays/Modula-3/arrays-2.mod3 new file mode 100644 index 0000000000..fd03aa8e5e --- /dev/null +++ b/Task/Arrays/Modula-3/arrays-2.mod3 @@ -0,0 +1,2 @@ +VAR a := ARRAY [1..10] OF INTEGER {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +VAR arr1 := ARRAY [1..10] OF INTEGER {1, ..} (* Initialize all elements to 1. *) diff --git a/Task/Arrays/Modula-3/arrays-3.mod3 b/Task/Arrays/Modula-3/arrays-3.mod3 new file mode 100644 index 0000000000..aeffb7495b --- /dev/null +++ b/Task/Arrays/Modula-3/arrays-3.mod3 @@ -0,0 +1,2 @@ +VAR arr := ARRAY [1..3] OF INTEGER {1, 2, 3}; +VAR myVar := a[2]; diff --git a/Task/Arrays/Modula-3/arrays-4.mod3 b/Task/Arrays/Modula-3/arrays-4.mod3 new file mode 100644 index 0000000000..ba800feba1 --- /dev/null +++ b/Task/Arrays/Modula-3/arrays-4.mod3 @@ -0,0 +1,2 @@ +VAR arr := ARRAY [1..3] OF INTEGER; +arr[1] := 10; diff --git a/Task/Assertions/Factor/assertions.factor b/Task/Assertions/Factor/assertions.factor new file mode 100644 index 0000000000..98dc50509e --- /dev/null +++ b/Task/Assertions/Factor/assertions.factor @@ -0,0 +1,2 @@ +USING: kernel ; +42 assert= diff --git a/Task/Assertions/GAP/assertions.gap b/Task/Assertions/GAP/assertions.gap new file mode 100644 index 0000000000..c2f2a6a54c --- /dev/null +++ b/Task/Assertions/GAP/assertions.gap @@ -0,0 +1,19 @@ +# See section 7.5 of reference manual + +# GAP has assertions levels. An assertion is tested if its level +# is less then the global level. + +# Set global level +SetAssertionLevel(10); + +a := 1; +Assert(20, a > 1, "a should be greater than one"); +# nothing happens + +a := 1; +Assert(4, a > 1, "a should be greater than one"); +# error + +# Show current global level +AssertionLevel(); +# 10 diff --git a/Task/Assertions/Groovy/assertions-1.groovy b/Task/Assertions/Groovy/assertions-1.groovy new file mode 100644 index 0000000000..e6c5230576 --- /dev/null +++ b/Task/Assertions/Groovy/assertions-1.groovy @@ -0,0 +1,3 @@ +def checkTheAnswer = { + assert it == 42 : "This: " + it + " is not the answer!" +} diff --git a/Task/Assertions/Groovy/assertions-2.groovy b/Task/Assertions/Groovy/assertions-2.groovy new file mode 100644 index 0000000000..6e8661a609 --- /dev/null +++ b/Task/Assertions/Groovy/assertions-2.groovy @@ -0,0 +1,4 @@ +println "before 42..." +checkTheAnswer(42) +println "before 'Hello Universe'..." +checkTheAnswer("Hello Universe") diff --git a/Task/Assertions/Icon/assertions-1.icon b/Task/Assertions/Icon/assertions-1.icon new file mode 100644 index 0000000000..993292f5d0 --- /dev/null +++ b/Task/Assertions/Icon/assertions-1.icon @@ -0,0 +1,5 @@ +... +runerr(n,( expression ,"Assertion/error - message.")) # Throw (and possibly trap) an error number n if expression succeeds. +... +stop(( expression ,"Assertion/stop - message.")) # Terminate program if expression succeeds. +... diff --git a/Task/Assertions/Icon/assertions-2.icon b/Task/Assertions/Icon/assertions-2.icon new file mode 100644 index 0000000000..4111a3796b --- /dev/null +++ b/Task/Assertions/Icon/assertions-2.icon @@ -0,0 +1,12 @@ +$define DEBUG 1 # this allows the assertions to go through + +procedure check (a) + if DEBUG then stop (42 = a, " is invalid value for 'a'") + write (a) +end + +procedure main () + check (10) + check (42) + check (12) +end diff --git a/Task/Assertions/J/assertions.j b/Task/Assertions/J/assertions.j new file mode 100644 index 0000000000..78b94ed685 --- /dev/null +++ b/Task/Assertions/J/assertions.j @@ -0,0 +1 @@ + assert n = 42 diff --git a/Task/Assertions/Julia/assertions.julia b/Task/Assertions/Julia/assertions.julia new file mode 100644 index 0000000000..f51e34b12c --- /dev/null +++ b/Task/Assertions/Julia/assertions.julia @@ -0,0 +1,9 @@ +#assert() function takes expression as 1st argument, failed-assertion message as optional 2nd argument +julia> assert(x==42,"x is not 42") +ERROR: assertion failed: x is not 42 +#@assert macro checks the supplied conditional expression, with the expression returned in the failed-assertion message +julia> @assert x==42 +ERROR: assertion failed: :((x==42)) +#Julia also has type assertions of the form, x::Type which can be appended to a variable for type-checking at any point +julia> x::String +ERROR: type: typeassert: expected String, got Int32 diff --git a/Task/Assertions/Lisaac/assertions.lisaac b/Task/Assertions/Lisaac/assertions.lisaac new file mode 100644 index 0000000000..54439b444d --- /dev/null +++ b/Task/Assertions/Lisaac/assertions.lisaac @@ -0,0 +1 @@ +? { n = 42 }; diff --git a/Task/Assertions/Maple/assertions.maple b/Task/Assertions/Maple/assertions.maple new file mode 100644 index 0000000000..9a95639594 --- /dev/null +++ b/Task/Assertions/Maple/assertions.maple @@ -0,0 +1,3 @@ +a := 5: +ASSERT( a = 42 ); +ASSERT( a = 42, "a is not the answer to life, the universe, and everything" ); diff --git a/Task/Assertions/Mathematica/assertions.mathematica b/Task/Assertions/Mathematica/assertions.mathematica new file mode 100644 index 0000000000..9bc7ab1537 --- /dev/null +++ b/Task/Assertions/Mathematica/assertions.mathematica @@ -0,0 +1 @@ +Assert[var===42] diff --git a/Task/Assertions/Metafont/assertions-1.metafont b/Task/Assertions/Metafont/assertions-1.metafont new file mode 100644 index 0000000000..ad8fccc717 --- /dev/null +++ b/Task/Assertions/Metafont/assertions-1.metafont @@ -0,0 +1 @@ +def assert(expr t) = if not (t): errmessage("assertion failed") fi enddef; diff --git a/Task/Assertions/Metafont/assertions-2.metafont b/Task/Assertions/Metafont/assertions-2.metafont new file mode 100644 index 0000000000..abc812a1e2 --- /dev/null +++ b/Task/Assertions/Metafont/assertions-2.metafont @@ -0,0 +1,3 @@ +n := 41; +assert(n=42); +message "ok"; diff --git a/Task/Assertions/Modula-3/assertions.mod3 b/Task/Assertions/Modula-3/assertions.mod3 new file mode 100644 index 0000000000..36c3815842 --- /dev/null +++ b/Task/Assertions/Modula-3/assertions.mod3 @@ -0,0 +1 @@ +<*ASSERT a = 42*> diff --git a/Task/Associative-array-Creation/Factor/associative-array-creation.factor b/Task/Associative-array-Creation/Factor/associative-array-creation.factor new file mode 100644 index 0000000000..9578618bef --- /dev/null +++ b/Task/Associative-array-Creation/Factor/associative-array-creation.factor @@ -0,0 +1,6 @@ +H{ { "one" 1 } { "two" 2 } } +{ [ "one" swap at . ] + [ 2 swap value-at . ] + [ "three" swap at . ] + [ [ 3 "three" ] dip set-at ] + [ "three" swap at . ] } cleave diff --git a/Task/Associative-array-Creation/Fantom/associative-array-creation.fantom b/Task/Associative-array-Creation/Fantom/associative-array-creation.fantom new file mode 100644 index 0000000000..d12c31b105 --- /dev/null +++ b/Task/Associative-array-Creation/Fantom/associative-array-creation.fantom @@ -0,0 +1,17 @@ +class Main +{ + public static Void main () + { + // create a map which maps Ints to Strs, with given key-value pairs + Int:Str map := [1:"alpha", 2:"beta", 3:"gamma"] + + // create an empty map + Map map2 := [:] + // now add some numbers mapped to their doubles + 10.times |Int i| + { + map2[i] = 2*i + } + + } +} diff --git a/Task/Associative-array-Creation/Groovy/associative-array-creation-1.groovy b/Task/Associative-array-Creation/Groovy/associative-array-creation-1.groovy new file mode 100644 index 0000000000..3fc5ed102e --- /dev/null +++ b/Task/Associative-array-Creation/Groovy/associative-array-creation-1.groovy @@ -0,0 +1,10 @@ +map = [:] +map[7] = 7 +map['foo'] = 'foovalue' +map.put('bar', 'barvalue') +map.moo = 'moovalue' + +assert 7 == map[7] +assert 'foovalue' == map.foo +assert 'barvalue' == map['bar'] +assert 'moovalue' == map.get('moo') diff --git a/Task/Associative-array-Creation/Groovy/associative-array-creation-2.groovy b/Task/Associative-array-Creation/Groovy/associative-array-creation-2.groovy new file mode 100644 index 0000000000..4f3e5d78eb --- /dev/null +++ b/Task/Associative-array-Creation/Groovy/associative-array-creation-2.groovy @@ -0,0 +1,6 @@ +map = [7:7, foo:'foovalue', bar:'barvalue', moo:'moovalue'] + +assert 7 == map[7] +assert 'foovalue' == map.foo +assert 'barvalue' == map['bar'] +assert 'moovalue' == map.get('moo') diff --git a/Task/Associative-array-Creation/Icon/associative-array-creation.icon b/Task/Associative-array-Creation/Icon/associative-array-creation.icon new file mode 100644 index 0000000000..b94f5e929c --- /dev/null +++ b/Task/Associative-array-Creation/Icon/associative-array-creation.icon @@ -0,0 +1,6 @@ +procedure main() + local t + t := table() + t["foo"] := "bar" + write(t["foo"]) +end diff --git a/Task/Associative-array-Creation/Inform-7/associative-array-creation-1.inf b/Task/Associative-array-Creation/Inform-7/associative-array-creation-1.inf new file mode 100644 index 0000000000..3bff2ad87f --- /dev/null +++ b/Task/Associative-array-Creation/Inform-7/associative-array-creation-1.inf @@ -0,0 +1,18 @@ +Hash Bar is a room. + +Connection relates various texts to one number. The verb to be connected to implies the connection relation. + +"foo" is connected to 12. +"bar" is connected to 34. +"baz" is connected to 56. + +When play begins: + [change values] + now "bleck" is connected to 78; + [check values] + if "foo" is connected to 12, say "good."; + if "bar" is not connected to 56, say "good."; + [retrieve values] + let V be the number that "baz" relates to by the connection relation; + say "'baz' => [V]."; + end the story. diff --git a/Task/Associative-array-Creation/Inform-7/associative-array-creation-2.inf b/Task/Associative-array-Creation/Inform-7/associative-array-creation-2.inf new file mode 100644 index 0000000000..db9f750318 --- /dev/null +++ b/Task/Associative-array-Creation/Inform-7/associative-array-creation-2.inf @@ -0,0 +1,15 @@ +Hash Bar is a room. + +When play begins: + let R be a various-to-one relation of texts to numbers; + [initialize the relation] + now R relates "foo" to 12; + now R relates "bar" to 34; + now R relates "baz" to 56; + [check values] + if R relates "foo" to 12, say "good."; + if R does not relate "bar" to 56, say "good."; + [retrieve values] + let V be the number that "baz" relates to by R; + say "'baz' => [V]."; + end the story. diff --git a/Task/Associative-array-Creation/Ioke/associative-array-creation.ioke b/Task/Associative-array-Creation/Ioke/associative-array-creation.ioke new file mode 100644 index 0000000000..7aba2c6a62 --- /dev/null +++ b/Task/Associative-array-Creation/Ioke/associative-array-creation.ioke @@ -0,0 +1 @@ +{a: "a", b: "b"} diff --git a/Task/Associative-array-Creation/J/associative-array-creation-1.j b/Task/Associative-array-Creation/J/associative-array-creation-1.j new file mode 100644 index 0000000000..f63108d899 --- /dev/null +++ b/Task/Associative-array-Creation/J/associative-array-creation-1.j @@ -0,0 +1,5 @@ +coclass 'assocArray' + encode=: 'z', (a.{~;48 65 97(+ i.)&.>10 26 26) {~ 62x #.inv 256x #. a.&i. + get=: ".@encode + has=: 0 <: nc@<@encode + set=:4 :'(encode x)=:y' diff --git a/Task/Associative-array-Creation/J/associative-array-creation-2.j b/Task/Associative-array-Creation/J/associative-array-creation-2.j new file mode 100644 index 0000000000..2bda49123b --- /dev/null +++ b/Task/Associative-array-Creation/J/associative-array-creation-2.j @@ -0,0 +1,13 @@ + example=: conew 'assocArray' + 'foo' set__example 1 2 3 +1 2 3 + 'bar' set__example 4 5 6 +4 5 6 + get__example 'foo' +1 2 3 + has__example 'foo' +1 + bletch__example=: 7 8 9 + get__example 'bletch' +7 8 9 + codestroy__example'' diff --git a/Task/Associative-array-Creation/K/associative-array-creation-1.k b/Task/Associative-array-Creation/K/associative-array-creation-1.k new file mode 100644 index 0000000000..0aeedbdd77 --- /dev/null +++ b/Task/Associative-array-Creation/K/associative-array-creation-1.k @@ -0,0 +1,6 @@ + / creating an dictionary + d1:.((`foo;1); (`bar;2); (`baz;3)) + + / extracting a value + d1[`bar] +2 diff --git a/Task/Associative-array-Creation/K/associative-array-creation-2.k b/Task/Associative-array-Creation/K/associative-array-creation-2.k new file mode 100644 index 0000000000..18027d82a8 --- /dev/null +++ b/Task/Associative-array-Creation/K/associative-array-creation-2.k @@ -0,0 +1,9 @@ + d2: .() / create empty dictionary + d2[`"zero"]:0 + d2[`"one"]:1 + d2[`"two"]:2 + + d2 +.((`zero;0;) + (`one;1;) + (`two;2;)) diff --git a/Task/Associative-array-Creation/K/associative-array-creation-3.k b/Task/Associative-array-Creation/K/associative-array-creation-3.k new file mode 100644 index 0000000000..ed9ffc7d88 --- /dev/null +++ b/Task/Associative-array-Creation/K/associative-array-creation-3.k @@ -0,0 +1,5 @@ + !d2 / the keys +`zero `one `two + + d2[] / the values +0 1 2 diff --git a/Task/Associative-array-Creation/Lang5/associative-array-creation.lang5 b/Task/Associative-array-Creation/Lang5/associative-array-creation.lang5 new file mode 100644 index 0000000000..408de045bf --- /dev/null +++ b/Task/Associative-array-Creation/Lang5/associative-array-creation.lang5 @@ -0,0 +1,17 @@ +: dip swap '_ set execute _ ; : nip swap drop ; +: first 0 extract nip ; : second 1 extract nip ; + +: assoc-in swap keys eq ; +: assoc-index' over keys swap eq [1] index collapse ; +: at swap assoc-index' subscript collapse second ; +: delete-at swap assoc-index' first remove ; +: keys 1 transpose first ; +: set-at + over 'dup dip assoc-in '+ reduce if 'dup dip delete-at then + "swap 2 compress 1 compress" dip swap append ; + +[['foo 5]] +10 'bar rot set-at +'bar over at . +'hello 'bar rot set-at +20 'baz rot set-at . diff --git a/Task/Associative-array-Creation/Liberty-BASIC/associative-array-creation.liberty b/Task/Associative-array-Creation/Liberty-BASIC/associative-array-creation.liberty new file mode 100644 index 0000000000..c8d5132d9e --- /dev/null +++ b/Task/Associative-array-Creation/Liberty-BASIC/associative-array-creation.liberty @@ -0,0 +1,12 @@ +data "red", "255 50 50", "green", "50 255 50", "blue", "50 50 255" +data "my fave", "220 120 120", "black", "0 0 0" + +myAssocList$ ="" + +for i =1 to 5 + read k$ + read dat$ + call sl.Set myAssocList$, k$, dat$ +next i + +print " Key 'green' is associated with data item "; sl.Get$( myAssocList$, "green") diff --git a/Task/Associative-array-Creation/Logo/associative-array-creation.logo b/Task/Associative-array-Creation/Logo/associative-array-creation.logo new file mode 100644 index 0000000000..a30d35e696 --- /dev/null +++ b/Task/Associative-array-Creation/Logo/associative-array-creation.logo @@ -0,0 +1,6 @@ +pprop "animals "cat 5 +pprop "animals "dog 4 +pprop "animals "mouse 11 +print gprop "animals "cat ; 5 +remprop "animals "dog +show plist "animals ; [mouse 11 cat 5] diff --git a/Task/Associative-array-Creation/Maple/associative-array-creation-1.maple b/Task/Associative-array-Creation/Maple/associative-array-creation-1.maple new file mode 100644 index 0000000000..673fa248cc --- /dev/null +++ b/Task/Associative-array-Creation/Maple/associative-array-creation-1.maple @@ -0,0 +1,11 @@ +> T := table( [ (2,3) = 4, "foo" = 1, sin(x) = cos(x) ] ); + T := table(["foo" = 1, sin(x) = cos(x), (2, 3) = 4]) + +> T[2,3]; + 4 + +> T[sin(x)]; + cos(x) + +> T["foo"]; + 1 diff --git a/Task/Associative-array-Creation/Maple/associative-array-creation-2.maple b/Task/Associative-array-Creation/Maple/associative-array-creation-2.maple new file mode 100644 index 0000000000..816d973f6e --- /dev/null +++ b/Task/Associative-array-Creation/Maple/associative-array-creation-2.maple @@ -0,0 +1,5 @@ +> T[ "bar" ] := 2; + T["bar"] := 2 + +> T[ "bar" ]; + 2 diff --git a/Task/Associative-array-Creation/Maple/associative-array-creation-3.maple b/Task/Associative-array-Creation/Maple/associative-array-creation-3.maple new file mode 100644 index 0000000000..bada120c23 --- /dev/null +++ b/Task/Associative-array-Creation/Maple/associative-array-creation-3.maple @@ -0,0 +1,5 @@ +> T[ "foo" ] := evaln( T[ "foo" ] ); + T["foo"] := T["foo"] + +> T[ "foo" ]; + T["foo"] diff --git a/Task/Associative-array-Creation/Mathematica/associative-array-creation.mathematica b/Task/Associative-array-Creation/Mathematica/associative-array-creation.mathematica new file mode 100644 index 0000000000..747508b30e --- /dev/null +++ b/Task/Associative-array-Creation/Mathematica/associative-array-creation.mathematica @@ -0,0 +1 @@ +a[2] = "string"; a["sometext"] = 23; diff --git a/Task/Associative-array-Creation/Maxima/associative-array-creation.maxima b/Task/Associative-array-Creation/Maxima/associative-array-creation.maxima new file mode 100644 index 0000000000..1600675ed3 --- /dev/null +++ b/Task/Associative-array-Creation/Maxima/associative-array-creation.maxima @@ -0,0 +1,7 @@ +/* No need to declare anything, undeclared arrays are hashed */ + +h[1]: 6; +h[9]: 2; + +arrayinfo(h); +[hashed, 1, [1], [9]] diff --git a/Task/Associative-array-Iteration/Factor/associative-array-iteration.factor b/Task/Associative-array-Iteration/Factor/associative-array-iteration.factor new file mode 100644 index 0000000000..822084c470 --- /dev/null +++ b/Task/Associative-array-Iteration/Factor/associative-array-iteration.factor @@ -0,0 +1 @@ +H{ { "hi" "there" } { "a" "b" } } [ ": " glue print ] assoc-each diff --git a/Task/Associative-array-Iteration/Fantom/associative-array-iteration.fantom b/Task/Associative-array-Iteration/Fantom/associative-array-iteration.fantom new file mode 100644 index 0000000000..8b880636be --- /dev/null +++ b/Task/Associative-array-Iteration/Fantom/associative-array-iteration.fantom @@ -0,0 +1,22 @@ +class Main +{ + public static Void main () + { + Int:Str map := [1:"alpha", 2:"beta", 3:"gamma"] + + map.keys.each |Int key| + { + echo ("Key is: $key") + } + + map.vals.each |Str value| + { + echo ("Value is: $value") + } + + map.each |Str value, Int key| + { + echo ("Key $key maps to $value") + } + } +} diff --git a/Task/Associative-array-Iteration/Groovy/associative-array-iteration.groovy b/Task/Associative-array-Iteration/Groovy/associative-array-iteration.groovy new file mode 100644 index 0000000000..f03ef217d4 --- /dev/null +++ b/Task/Associative-array-Iteration/Groovy/associative-array-iteration.groovy @@ -0,0 +1,12 @@ +def map = [lastName: "Anderson", firstName: "Thomas", nickname: "Neo", age: 24, address: "everywhere"] + +println "Entries:" +map.each { println it } + +println() +println "Keys:" +map.keySet().each { println it } + +println() +println "Values:" +map.values().each { println it } diff --git a/Task/Associative-array-Iteration/Icon/associative-array-iteration.icon b/Task/Associative-array-Iteration/Icon/associative-array-iteration.icon new file mode 100644 index 0000000000..aee359326b --- /dev/null +++ b/Task/Associative-array-Iteration/Icon/associative-array-iteration.icon @@ -0,0 +1,15 @@ +procedure main() + t := table() + every t[a := !"ABCDE"] := map(a) + + every pair := !sort(t) do + write("\t",pair[1]," -> ",pair[2]) + + writes("Keys:") + every writes(" ",key(t)) + write() + + writes("Values:") + every writes(" ",!t) + write() +end diff --git a/Task/Associative-array-Iteration/J/associative-array-iteration-1.j b/Task/Associative-array-Iteration/J/associative-array-iteration-1.j new file mode 100644 index 0000000000..b26a093be4 --- /dev/null +++ b/Task/Associative-array-Iteration/J/associative-array-iteration-1.j @@ -0,0 +1 @@ +nl__example 0 diff --git a/Task/Associative-array-Iteration/J/associative-array-iteration-2.j b/Task/Associative-array-Iteration/J/associative-array-iteration-2.j new file mode 100644 index 0000000000..bd621ffa82 --- /dev/null +++ b/Task/Associative-array-Iteration/J/associative-array-iteration-2.j @@ -0,0 +1 @@ +get__example each nl__example 0 diff --git a/Task/Associative-array-Iteration/J/associative-array-iteration-3.j b/Task/Associative-array-Iteration/J/associative-array-iteration-3.j new file mode 100644 index 0000000000..cf26dc6d72 --- /dev/null +++ b/Task/Associative-array-Iteration/J/associative-array-iteration-3.j @@ -0,0 +1 @@ +(,&< get__example) each nl__example 0 diff --git a/Task/Associative-array-Iteration/K/associative-array-iteration-1.k b/Task/Associative-array-Iteration/K/associative-array-iteration-1.k new file mode 100644 index 0000000000..a3c7501846 --- /dev/null +++ b/Task/Associative-array-Iteration/K/associative-array-iteration-1.k @@ -0,0 +1 @@ + d: .((`"hello";1); (`"world";2);(`"!";3)) diff --git a/Task/Associative-array-Iteration/K/associative-array-iteration-2.k b/Task/Associative-array-Iteration/K/associative-array-iteration-2.k new file mode 100644 index 0000000000..5ad9f2a40b --- /dev/null +++ b/Task/Associative-array-Iteration/K/associative-array-iteration-2.k @@ -0,0 +1,7 @@ + !d +`hello `world `"!" + + $!d / convert keys (symbols) as strings +("hello" + "world" + ,"!") diff --git a/Task/Associative-array-Iteration/K/associative-array-iteration-3.k b/Task/Associative-array-Iteration/K/associative-array-iteration-3.k new file mode 100644 index 0000000000..5453975112 --- /dev/null +++ b/Task/Associative-array-Iteration/K/associative-array-iteration-3.k @@ -0,0 +1,4 @@ + `0:{,/$x,": ",d[x]}'!d +hello: 1 +world: 2 +!: 3 diff --git a/Task/Associative-array-Iteration/K/associative-array-iteration-4.k b/Task/Associative-array-Iteration/K/associative-array-iteration-4.k new file mode 100644 index 0000000000..b70fa5fdf1 --- /dev/null +++ b/Task/Associative-array-Iteration/K/associative-array-iteration-4.k @@ -0,0 +1,5 @@ + d[] +1 2 3 + + {x+1}'d[] +2 3 4 diff --git a/Task/Associative-array-Iteration/Lang5/associative-array-iteration.lang5 b/Task/Associative-array-Iteration/Lang5/associative-array-iteration.lang5 new file mode 100644 index 0000000000..6dffe5c7e6 --- /dev/null +++ b/Task/Associative-array-Iteration/Lang5/associative-array-iteration.lang5 @@ -0,0 +1,4 @@ +: first 0 extract nip ; : second 1 extract nip ; : nip swap drop ; +: say(*) dup first " => " 2 compress "" join . second . ; + +[['foo 5] ['bar 10] ['baz 20]] 'say apply drop diff --git a/Task/Associative-array-Iteration/Liberty-BASIC/associative-array-iteration.liberty b/Task/Associative-array-Iteration/Liberty-BASIC/associative-array-iteration.liberty new file mode 100644 index 0000000000..186e4f0ca9 --- /dev/null +++ b/Task/Associative-array-Iteration/Liberty-BASIC/associative-array-iteration.liberty @@ -0,0 +1,23 @@ +data "red", "255 50 50", "green", "50 255 50", "blue", "50 50 255" +data "my fave", "220 120 120", "black", "0 0 0" + +myAssocList$ ="" + +for i =1 to 5 + read k$ + read dat$ + call sl.Set myAssocList$, k$, dat$ +next i + +keys$ = "" ' List to hold the keys in myList$. +keys = 0 + +keys = sl.Keys( myAssocList$, keys$) +print " Number of key-data pairs ="; keys + +For i = 1 To keys + keyName$ = sl.Get$( keys$, Str$( i)) + Print " Key "; i; ":", keyName$, "Data: ", sl.Get$( myAssocList$, keyName$) +Next i + +end diff --git a/Task/Associative-array-Iteration/M4/associative-array-iteration.m4 b/Task/Associative-array-Iteration/M4/associative-array-iteration.m4 new file mode 100644 index 0000000000..de54853879 --- /dev/null +++ b/Task/Associative-array-Iteration/M4/associative-array-iteration.m4 @@ -0,0 +1,35 @@ +divert(-1) +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')') +define(`new',`define(`$1[size]key',0)') +define(`asize',`defn(`$1[size]key')') +define(`aget',`defn(`$1[$2]')') +define(`akget',`defn(`$1[$2]key')') +define(`avget',`aget($1,akget($1,$2))') +define(`aset', + `ifdef($1[$2], + `', + `define(`$1[size]key',incr(asize(`$1')))`'define($1[asize(`$1')]key,$2)')`'define($1[$2],$3)') +define(`dquote', ``$@'') +define(`akeyvalue',`dquote(akget($1,$2),aget($1,akget($1,$2)))') +define(`akey',`dquote(akget($1,$2))') +define(`avalue',`dquote(aget($1,akget($1,$2)))') +divert +new(`a') +aset(`a',`wow',5) +aset(`a',`wow',flame) +aset(`a',`bow',7) +key-value pairs +for(`x',1,asize(`a'), + `akeyvalue(`a',x) +') +keys +for(`x',1,asize(`a'), + `akey(`a',x) +') +values +for(`x',1,asize(`a'), + `avalue(`a',x) +') diff --git a/Task/Associative-array-Iteration/Maple/associative-array-iteration.maple b/Task/Associative-array-Iteration/Maple/associative-array-iteration.maple new file mode 100644 index 0000000000..9e035253a6 --- /dev/null +++ b/Task/Associative-array-Iteration/Maple/associative-array-iteration.maple @@ -0,0 +1,21 @@ +> T := table( [ "a" = 1, "b" = 2, ("c","d") = 3 ] ): +> for i in indices( T ) do print( i, T[ op( i ) ] ) end: + ["a"], 1 + + ["c", "d"], 3 + + ["b"], 2 + +> for i in indices( T ) do print( op( i ) ) end: + "a" + + "c", "d" + + "b" + +> for i in entries( T ) do print( i) end: + [1] + + [3] + + [2] diff --git a/Task/Associative-array-Iteration/Mathematica/associative-array-iteration.mathematica b/Task/Associative-array-Iteration/Mathematica/associative-array-iteration.mathematica new file mode 100644 index 0000000000..b7b02488df --- /dev/null +++ b/Task/Associative-array-Iteration/Mathematica/associative-array-iteration.mathematica @@ -0,0 +1,8 @@ +keys=DownValues[#,Sort->False][[All,1,1,1]]&; +hashes=#/@keys[#]&; + +a[2]="string";a["sometext"]=23; +keys[a] +->{2,sometext} +hashes[a] +->{string,23} diff --git a/Task/Atomic-updates/Groovy/atomic-updates.groovy b/Task/Atomic-updates/Groovy/atomic-updates.groovy new file mode 100644 index 0000000000..54c4701691 --- /dev/null +++ b/Task/Atomic-updates/Groovy/atomic-updates.groovy @@ -0,0 +1,79 @@ +class Buckets { + + def cells = [] + final n + + Buckets(n, limit=1000, random=new Random()) { + this.n = n + (0.. + synchronized(buckets) { + def targetDiff = (buckets[i]-buckets[j]).intdiv(2) + if (targetDiff < 0) { + buckets.transfer(j, i, -targetDiff) + } else { + buckets.transfer(i, j, targetDiff) + } + } +} + +def randomize = { i, j -> + synchronized(buckets) { + def targetLimit = buckets[i] + buckets[j] + def targetI = random.nextInt(targetLimit + 1) + if (targetI < buckets[i]) { + buckets.transfer(i, j, buckets[i] - targetI) + } else { + buckets.transfer(j, i, targetI - buckets[i]) + } + } +} + +Thread.start { + def start = System.currentTimeMillis() + while (start + 10000 > System.currentTimeMillis()) { + def i = random.nextInt(buckets.n) + def j = random.nextInt(buckets.n) + makeCloser(i, j) + } +} + +Thread.start { + def start = System.currentTimeMillis() + while (start + 10000 > System.currentTimeMillis()) { + def i = random.nextInt(buckets.n) + def j = random.nextInt(buckets.n) + randomize(i, j) + } +} + +def start = System.currentTimeMillis() +while (start + 10000 > System.currentTimeMillis()) { + synchronized(buckets) { + def sum = buckets.cells.sum() + println "${new Date()}: checksum: ${sum} buckets: ${buckets}" + } + Thread.sleep(500) +} diff --git a/Task/Average-loop-length/J/average-loop-length-1.j b/Task/Average-loop-length/J/average-loop-length-1.j new file mode 100644 index 0000000000..b9c6260f74 --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-1.j @@ -0,0 +1,4 @@ + (~.@, {&0 0@{:)^:_] 0 +0 + (~.@, {&0 0@{:)^:_] 1 +1 0 diff --git a/Task/Average-loop-length/J/average-loop-length-2.j b/Task/Average-loop-length/J/average-loop-length-2.j new file mode 100644 index 0000000000..49b3251ee1 --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-2.j @@ -0,0 +1,2 @@ + 0 0 ([: # (] ~.@, {:@] { [)^:_) 1 +2 diff --git a/Task/Average-loop-length/J/average-loop-length-3.j b/Task/Average-loop-length/J/average-loop-length-3.j new file mode 100644 index 0000000000..b06059a95b --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-3.j @@ -0,0 +1,5 @@ + (#.inv i.@^~)2 +0 0 +0 1 +1 0 +1 1 diff --git a/Task/Average-loop-length/J/average-loop-length-4.j b/Task/Average-loop-length/J/average-loop-length-4.j new file mode 100644 index 0000000000..20fa310518 --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-4.j @@ -0,0 +1,12 @@ + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)1 +1 + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)2 +1.5 + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)3 +1.88889 + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)4 +2.21875 + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)5 +2.5104 + (+/ % #)@,@((#.inv i.@^~) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.)6 +2.77469 diff --git a/Task/Average-loop-length/J/average-loop-length-5.j b/Task/Average-loop-length/J/average-loop-length-5.j new file mode 100644 index 0000000000..72354f9914 --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-5.j @@ -0,0 +1,3 @@ + ana=: +/@(!@[ % !@- * ^) 1+i. + ana"0]1 2 3 4 5 6 +1 1.5 1.88889 2.21875 2.5104 2.77469 diff --git a/Task/Average-loop-length/J/average-loop-length-6.j b/Task/Average-loop-length/J/average-loop-length-6.j new file mode 100644 index 0000000000..d6d0b7b384 --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-6.j @@ -0,0 +1,3 @@ + sim=: (+/ % #)@,@((]?@$~1e4,]) ([: # (] ~.@, {:@] { [)^:_)"1 0/ i.) + sim"0]1 2 3 4 5 6 +1 1.5034 1.8825 2.22447 2.51298 2.76898 diff --git a/Task/Average-loop-length/J/average-loop-length-7.j b/Task/Average-loop-length/J/average-loop-length-7.j new file mode 100644 index 0000000000..2c81a8d2df --- /dev/null +++ b/Task/Average-loop-length/J/average-loop-length-7.j @@ -0,0 +1,25 @@ + (;:'N average analytic error'),:,.each(;ana"0 ([;];-|@%[) sim"0)1+i.20 ++--+-------+--------+-----------+ +|N |average|analytic|error | ++--+-------+--------+-----------+ +| 1| 1| 1 | 0| +| 2| 1.5|1.49955 | 0.0003| +| 3|1.88889| 1.8928 | 0.00207059| +| 4|2.21875|2.23082 | 0.00544225| +| 5| 2.5104|2.52146 | 0.00440567| +| 6|2.77469|2.78147 | 0.00244182| +| 7|3.01814| 3.0101 | 0.00266346| +| 8|3.24502|3.25931 | 0.00440506| +| 9|3.45832|3.45314 | 0.00149532| +|10|3.66022| 3.6708 | 0.00289172| +|11|3.85237|3.84139 | 0.00285049| +|12|4.03607|4.03252 |0.000881304| +|13|4.21235|4.18358 | 0.00682833| +|14|4.38203|4.38791 | 0.00134132| +|15|4.54581|4.54443 |0.000302246| +|16|4.70426|4.71351 | 0.00196721| +|17|4.85787|4.85838 |0.000104089| +|18|5.00706|5.00889 |0.000365752| +|19| 5.1522|5.14785 |0.000843052| +|20|5.29358|5.28587 | 0.00145829| ++--+-------+--------+-----------+ diff --git a/Task/Average-loop-length/Mathematica/average-loop-length.mathematica b/Task/Average-loop-length/Mathematica/average-loop-length.mathematica new file mode 100644 index 0000000000..5aada18963 --- /dev/null +++ b/Task/Average-loop-length/Mathematica/average-loop-length.mathematica @@ -0,0 +1,9 @@ +Grid@Prepend[ + Table[{n, #[[1]], #[[2]], + Row[{Round[10000 Abs[#[[1]] - #[[2]]]/#[[2]]]/100., "%"}]} &@ + N[{Mean[Array[ + Length@NestWhileList[#, 1, UnsameQ[##] &, All] - 1 &[# /. + MapIndexed[#2[[1]] -> #1 &, + RandomInteger[{1, n}, n]] &] &, 10000]], + Sum[n! n^(n - k - 1)/(n - k)!, {k, n}]/n^(n - 1)}, 5], {n, 1, + 20}], {"N", "average", "analytical", "error"}] diff --git a/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-1.factor b/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-1.factor new file mode 100644 index 0000000000..0287b01854 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-1.factor @@ -0,0 +1,4 @@ +USING: math math.statistics ; + +: arithmetic-mean ( seq -- n ) + [ 0 ] [ mean ] if-empty ; diff --git a/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-2.factor b/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-2.factor new file mode 100644 index 0000000000..2fa6a27324 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Factor/averages-arithmetic-mean-2.factor @@ -0,0 +1,2 @@ +( scratchpad ) { 2 3 5 } arithmetic-mean >float +3.333333333333333 diff --git a/Task/Averages-Arithmetic-mean/Fantom/averages-arithmetic-mean.fantom b/Task/Averages-Arithmetic-mean/Fantom/averages-arithmetic-mean.fantom new file mode 100644 index 0000000000..01aa636498 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Fantom/averages-arithmetic-mean.fantom @@ -0,0 +1,18 @@ +class Main +{ + static Float average (Float[] nums) + { + if (nums.size == 0) return 0.0f + Float sum := 0f + nums.each |num| { sum += num } + return sum / nums.size.toFloat + } + + public static Void main () + { + [[,], [1f], [1f,2f,3f,4f]].each |Float[] i| + { + echo ("Average of $i is: " + average(i)) + } + } +} diff --git a/Task/Averages-Arithmetic-mean/Fish/averages-arithmetic-mean.fish b/Task/Averages-Arithmetic-mean/Fish/averages-arithmetic-mean.fish new file mode 100644 index 0000000000..1b90fd7d66 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Fish/averages-arithmetic-mean.fish @@ -0,0 +1,3 @@ +!vl0=?vl1=?vl&! +v< +<>0n; >n; +>l1)?^&,n; diff --git a/Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap b/Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap new file mode 100644 index 0000000000..3e419b56cd --- /dev/null +++ b/Task/Averages-Arithmetic-mean/GAP/averages-arithmetic-mean.gap @@ -0,0 +1,12 @@ +Mean := function(v) + local n; + n := Length(v); + if n = 0 then + return 0; + else + return Sum(v)/n; + fi; +end; + +Mean([3, 1, 4, 1, 5, 9]); +# 23/6 diff --git a/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-1.groovy b/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-1.groovy new file mode 100644 index 0000000000..260715106d --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-1.groovy @@ -0,0 +1 @@ +def avg = { list -> list == [] ? 0 : list.sum() / list.size() } diff --git a/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-2.groovy b/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-2.groovy new file mode 100644 index 0000000000..c75883f8ed --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Groovy/averages-arithmetic-mean-2.groovy @@ -0,0 +1,3 @@ +println avg(0..9) +println avg([2,2,2,4,2]) +println avg ([]) diff --git a/Task/Averages-Arithmetic-mean/HicEst/averages-arithmetic-mean.hicest b/Task/Averages-Arithmetic-mean/HicEst/averages-arithmetic-mean.hicest new file mode 100644 index 0000000000..c54768692a --- /dev/null +++ b/Task/Averages-Arithmetic-mean/HicEst/averages-arithmetic-mean.hicest @@ -0,0 +1,5 @@ +REAL :: vec(100) ! no zero-length arrays in HicEst + + vec = $ - 1/2 ! 0.5 ... 99.5 + mean = SUM(vec) / LEN(vec) ! 50 +END diff --git a/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-1.idl b/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-1.idl new file mode 100644 index 0000000000..5ec124c9f6 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-1.idl @@ -0,0 +1,2 @@ +x = [3,1,4,1,5,9] +print,mean(x) diff --git a/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-2.idl b/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-2.idl new file mode 100644 index 0000000000..165a52130e --- /dev/null +++ b/Task/Averages-Arithmetic-mean/IDL/averages-arithmetic-mean-2.idl @@ -0,0 +1,3 @@ +print,moment(x) +; ==> + 3.83333 8.96667 0.580037 -1.25081 diff --git a/Task/Averages-Arithmetic-mean/Icon/averages-arithmetic-mean.icon b/Task/Averages-Arithmetic-mean/Icon/averages-arithmetic-mean.icon new file mode 100644 index 0000000000..cb9b8421ba --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Icon/averages-arithmetic-mean.icon @@ -0,0 +1,4 @@ +procedure main(args) + every (s := 0) +:= !args + write((real(s)/(0 ~= *args)) | 0) +end diff --git a/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-1.j b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-1.j new file mode 100644 index 0000000000..306c387f9c --- /dev/null +++ b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-1.j @@ -0,0 +1 @@ +mean=: +/ % # diff --git a/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-2.j b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-2.j new file mode 100644 index 0000000000..9511cb7e1b --- /dev/null +++ b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-2.j @@ -0,0 +1,7 @@ + mean 3 1 4 1 5 9 +3.83333 + mean $0 NB. $0 is a zero-length vector +0 + x=: 20 4 ?@$ 0 NB. a 20-by-4 table of random (0,1) numbers + mean x +0.58243 0.402948 0.477066 0.511155 diff --git a/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-3.j b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-3.j new file mode 100644 index 0000000000..597a63f235 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/J/averages-arithmetic-mean-3.j @@ -0,0 +1,11 @@ +mean1=: 3 : 0 + z=. 0 + for_i. i.#y do. z=. z+i{y end. + z % #y +) + mean1 3 1 4 1 5 9 +3.83333 + mean1 $0 +0 + mean1 x +0.58243 0.402948 0.477066 0.511155 diff --git a/Task/Averages-Arithmetic-mean/Julia/averages-arithmetic-mean.julia b/Task/Averages-Arithmetic-mean/Julia/averages-arithmetic-mean.julia new file mode 100644 index 0000000000..8ff131b323 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Julia/averages-arithmetic-mean.julia @@ -0,0 +1,5 @@ +julia> mean([1,2,3]) +2.0 + +julia> mean([]) +ERROR: mean of empty collection undefined: [] diff --git a/Task/Averages-Arithmetic-mean/K/averages-arithmetic-mean.k b/Task/Averages-Arithmetic-mean/K/averages-arithmetic-mean.k new file mode 100644 index 0000000000..de1aaf1ec9 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/K/averages-arithmetic-mean.k @@ -0,0 +1,5 @@ + mean: {(+/x)%#x} + mean 1 2 3 5 7 +3.6 + mean@!0 / empty array +0.0 diff --git a/Task/Averages-Arithmetic-mean/LSL/averages-arithmetic-mean.lsl b/Task/Averages-Arithmetic-mean/LSL/averages-arithmetic-mean.lsl new file mode 100644 index 0000000000..1c048b656f --- /dev/null +++ b/Task/Averages-Arithmetic-mean/LSL/averages-arithmetic-mean.lsl @@ -0,0 +1,22 @@ +integer MAX_ELEMENTS = 10; +integer MAX_VALUE = 100; +default { + state_entry() { + list lst = []; + integer x = 0; + for(x=0 ; x$L(X,"^") SET S=S+$P(X,"^",I),I=I+1 + QUIT (S/$L(X,"^")) diff --git a/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-1.maple b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-1.maple new file mode 100644 index 0000000000..67b0acc214 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-1.maple @@ -0,0 +1,4 @@ +mean := proc( a :: indexable ) + local i; + Normalizer( add( i, i in a ) / numelems( a ) ) +end proc: diff --git a/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-2.maple b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-2.maple new file mode 100644 index 0000000000..babb9bc8d0 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-2.maple @@ -0,0 +1,21 @@ +> mean( { 1/2, 2/3, 3/4, 4/5, 5/6 } ); # set + 71 + --- + 100 + +> mean( [ a, 2, c, 2.3, e ] ); # list + 0.8600000000 + a/5 + c/5 + e/5 + +> mean( Array( [ 1, sin( s ), 3, exp( I*t ), 5 ] ) ); # array + 9/5 + 1/5 sin(s) + 1/5 exp(t I) + +> mean( [ sin(s)^2, cos(s)^2 ] ); + 2 2 + 1/2 sin(s) + 1/2 cos(s) + +> Normalizer := simplify: # use a stronger normalizer than the default +> mean( [ sin(s)^2, cos(s)^2 ] ); + 1/2 + +> mean([]); # empty argument causes an exception to be raised. +Error, (in mean) numeric exception: division by zero diff --git a/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-3.maple b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-3.maple new file mode 100644 index 0000000000..5a85ec92f4 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-3.maple @@ -0,0 +1 @@ +mean := () -> Normalizer( `+`( args ) / nargs ): diff --git a/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-4.maple b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-4.maple new file mode 100644 index 0000000000..ec9d29bf5b --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-4.maple @@ -0,0 +1,10 @@ +> mean( 1, 2, 3, 4, 5 ); + 3 + +> mean( a + b, b + c, c + d, d + e, e + a ); + 2 a 2 b 2 c 2 d 2 e + --- + --- + --- + --- + --- + 5 5 5 5 5 + +> mean(); # again, an exception is raised +Error, (in mean) numeric exception: division by zero diff --git a/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-5.maple b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-5.maple new file mode 100644 index 0000000000..bd195d12c2 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maple/averages-arithmetic-mean-5.maple @@ -0,0 +1 @@ +mean := ( s :: seq(algebraic) ) -> Normalizer( `+`( args ) / nargs ): diff --git a/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-1.mathematica b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-1.mathematica new file mode 100644 index 0000000000..f6c81a5a84 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-1.mathematica @@ -0,0 +1,2 @@ +Unprotect[Mean]; +Mean[{}] := 0 diff --git a/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-2.mathematica b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-2.mathematica new file mode 100644 index 0000000000..4865f5ed52 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-2.mathematica @@ -0,0 +1,6 @@ +Mean[{3,4,5}] +Mean[{3.2,4.5,5.9}] +Mean[{-4, 1.233}] +Mean[{}] +Mean[{1/2,1/3,1/4,1/5}] +Mean[{a,c,Pi,-3,a}] diff --git a/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-3.mathematica b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-3.mathematica new file mode 100644 index 0000000000..db0a6114db --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Mathematica/averages-arithmetic-mean-3.mathematica @@ -0,0 +1,6 @@ +4 +4.53333 +-1.3835 +0 +77/240 +1/5 (-3+2 a+c+Pi) diff --git a/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-1.mathprog b/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-1.mathprog new file mode 100644 index 0000000000..fd0787365f --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-1.mathprog @@ -0,0 +1,24 @@ +/*Arithmetic Mean of a large number of Integers + - or - solve a very large constraint matrix + over 1 million rows and columns + Nigel_Galloway + March 18th., 2008. +*/ + +param e := 20; +set Sample := {1..2**e-1}; + +var Mean; +var E{z in Sample}; + +/* sum of variances is zero */ +zumVariance: sum{z in Sample} E[z] = 0; + +/* Mean + variance[n] = Sample[n] */ +variances{z in Sample}: Mean + E[z] = z; + +solve; + +printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean; + +end; diff --git a/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-2.mathprog b/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-2.mathprog new file mode 100644 index 0000000000..290f280013 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Mathprog/averages-arithmetic-mean-2.mathprog @@ -0,0 +1,22 @@ +GLPSOL: GLPK LP/MIP Solver, v4.47 +Parameter(s) specified in the command line: + --nopresol --math AM.mprog +Reading model section from AM.mprog... +24 lines were read +Generating zumVariance... +Generating variances... +Model has been successfully generated +Scaling... + A: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000 +Problem data seem to be well scaled +Constructing initial basis... +Size of triangular part = 1048575 +GLPK Simplex Optimizer, v4.47 +1048576 rows, 1048576 columns, 3145725 non-zeros + 0: obj = 0.000000000e+000 infeas = 5.498e+011 (1) +* 1: obj = 0.000000000e+000 infeas = 0.000e+000 (0) +OPTIMAL SOLUTION FOUND +Time used: 2.0 secs +Memory used: 1393.8 Mb (1461484590 bytes) +The arithmetic mean of the integers from 1 to 1048575 is 524288.000000 +Model has been successfully processed diff --git a/Task/Averages-Arithmetic-mean/Maxima/averages-arithmetic-mean.maxima b/Task/Averages-Arithmetic-mean/Maxima/averages-arithmetic-mean.maxima new file mode 100644 index 0000000000..3e54624546 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Maxima/averages-arithmetic-mean.maxima @@ -0,0 +1 @@ +mean([2, 7, 11, 17]); diff --git a/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-1.mod2 b/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-1.mod2 new file mode 100644 index 0000000000..71458f9848 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-1.mod2 @@ -0,0 +1,10 @@ +PROCEDURE Avg; + +VAR avg : REAL; + +BEGIN + avg := sx / n; + InOut.WriteString ("Average = "); + InOut.WriteReal (avg, 8, 2); + InOut.WriteLn +END Avg; diff --git a/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-2.mod2 b/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-2.mod2 new file mode 100644 index 0000000000..de34683407 --- /dev/null +++ b/Task/Averages-Arithmetic-mean/Modula-2/averages-arithmetic-mean-2.mod2 @@ -0,0 +1,14 @@ +PROCEDURE Average (Data : ARRAY OF REAL; Samples : CARDINAL) : REAL; + +(* Calculate the average over 'Samples' values, stored in array 'Data'. *) + +VAR sum : REAL; + n : CARDINAL; + +BEGIN + sum := 0.0; + FOR n := 0 TO Samples - 1 DO + sum := sum + Data [n] + END; + RETURN sum / FLOAT(Samples) +END Average; diff --git a/Task/Averages-Mean-angle/J/averages-mean-angle-1.j b/Task/Averages-Mean-angle/J/averages-mean-angle-1.j new file mode 100644 index 0000000000..00f37b5218 --- /dev/null +++ b/Task/Averages-Mean-angle/J/averages-mean-angle-1.j @@ -0,0 +1 @@ +avgAngleD=: (_1 { [: (**|)&.+.@(+/ % #)&.(*.inv) 1,.])&.(1r180p1&*) diff --git a/Task/Averages-Mean-angle/J/averages-mean-angle-2.j b/Task/Averages-Mean-angle/J/averages-mean-angle-2.j new file mode 100644 index 0000000000..7d2fd083f5 --- /dev/null +++ b/Task/Averages-Mean-angle/J/averages-mean-angle-2.j @@ -0,0 +1,6 @@ +rfd=: 1r180p1&* NB. convert angle to radians from degrees +toComplex=: *.inv NB. maps integer pairs as length, complex angle (in radians) +mean=: +/ % # NB. calculate arithmetic mean +roundComplex=: (* * |)&.+. NB. discard an extraneous least significant bit of precision from a complex value whose magnitude is in the vicinity of 1 +avgAngleR=: _1 { [: roundComplex@mean&.toComplex 1 ,. ] NB. calculate average angle in radians +avgAngleD=: avgAngleR&.rfd diff --git a/Task/Averages-Mean-angle/J/averages-mean-angle-3.j b/Task/Averages-Mean-angle/J/averages-mean-angle-3.j new file mode 100644 index 0000000000..885df3edfe --- /dev/null +++ b/Task/Averages-Mean-angle/J/averages-mean-angle-3.j @@ -0,0 +1,6 @@ + avgAngleD 10 350 +0 + avgAngleD 90 180 270 360 NB. result not meaningful +0 + avgAngleD 10 20 30 +20 diff --git a/Task/Averages-Mean-angle/Liberty-BASIC/averages-mean-angle.liberty b/Task/Averages-Mean-angle/Liberty-BASIC/averages-mean-angle.liberty new file mode 100644 index 0000000000..e2ff4d591a --- /dev/null +++ b/Task/Averages-Mean-angle/Liberty-BASIC/averages-mean-angle.liberty @@ -0,0 +1,42 @@ +global Pi +Pi =3.1415926535 + +print "Mean Angle( "; chr$( 34); "350,10"; chr$( 34); ") = "; using( "###.#", meanAngle( "350,10")); " degrees." ' 0 +print "Mean Angle( "; chr$( 34); "90,180,270,360"; chr$( 34); ") = "; using( "###.#", meanAngle( "90,180,270,360")); " degrees." ' -90 +print "Mean Angle( "; chr$( 34); "10,20,30"; chr$( 34); ") = "; using( "###.#", meanAngle( "10,20,30")); " degrees." ' 20 + +end + +function meanAngle( angles$) + term =1 + while word$( angles$, term, ",") <>"" + angle =val( word$( angles$, term, ",")) + sumSin = sumSin +sin( degRad( angle)) + sumCos = sumCos +cos( degRad( angle)) + term =term +1 + wend + meanAngle= radDeg( atan2( sumSin, sumCos)) + if abs( sumSin) +abs( sumCos) <0.001 then notice "Not Available." +_ + chr$( 13) +"(" +angles$ +")" +_ + chr$( 13) +"Result nearly equals zero vector." +_ + chr$( 13) +"Displaying '666'.": meanAngle =666 + +end function + +function degRad( theta) + degRad =theta *Pi /180 +end function + +function radDeg( theta) + radDeg =theta *180 /Pi +end function + +function atan2( y, x) + if x >0 then at =atn( y /x) + if y >=0 and x <0 then at =atn( y /x) +pi + if y <0 and x <0 then at =atn( y /x) -pi + if y >0 and x =0 then at = pi /2 + if y <0 and x =0 then at = 0 -pi /2 + if y =0 and x =0 then notice "undefined": end + atan2 =at +end function diff --git a/Task/Averages-Mean-angle/Maple/averages-mean-angle-1.maple b/Task/Averages-Mean-angle/Maple/averages-mean-angle-1.maple new file mode 100644 index 0000000000..9a05c5cab1 --- /dev/null +++ b/Task/Averages-Mean-angle/Maple/averages-mean-angle-1.maple @@ -0,0 +1,2 @@ +> [ 350, 10 ] *~ Unit(arcdeg); + [350 [arcdeg], 10 [arcdeg]] diff --git a/Task/Averages-Mean-angle/Maple/averages-mean-angle-2.maple b/Task/Averages-Mean-angle/Maple/averages-mean-angle-2.maple new file mode 100644 index 0000000000..9716729cf3 --- /dev/null +++ b/Task/Averages-Mean-angle/Maple/averages-mean-angle-2.maple @@ -0,0 +1,5 @@ +MeanAngle := proc( L ) + uses Units:-Standard; # for unit-awareness + local u; + evalf( convert( argument( add( u, u = exp~( I *~ L ) ) ), 'units', 'radian', 'degree' ) ) +end proc: diff --git a/Task/Averages-Mean-angle/Maple/averages-mean-angle-3.maple b/Task/Averages-Mean-angle/Maple/averages-mean-angle-3.maple new file mode 100644 index 0000000000..a794c4f804 --- /dev/null +++ b/Task/Averages-Mean-angle/Maple/averages-mean-angle-3.maple @@ -0,0 +1,8 @@ +> MeanAngle( [ 350, 10 ] *~ Unit(arcdeg) ); + 0. + +> MeanAngle( [ 90, 180, 270, 360 ] *~ Unit(arcdeg) ); + 0. + +> MeanAngle( [ 10, 20, 30 ] *~ Unit(arcdeg) ); + 20.00000000 diff --git a/Task/Averages-Mean-angle/Mathematica/averages-mean-angle.mathematica b/Task/Averages-Mean-angle/Mathematica/averages-mean-angle.mathematica new file mode 100644 index 0000000000..9092bcf811 --- /dev/null +++ b/Task/Averages-Mean-angle/Mathematica/averages-mean-angle.mathematica @@ -0,0 +1 @@ +meanAngle[data_List] := N@Arg[Mean[Exp[I data Degree]]]/Degree diff --git a/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-1.j b/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-1.j new file mode 100644 index 0000000000..b1a2252a09 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-1.j @@ -0,0 +1,5 @@ +require 'types/datetime' +parseTimes=: ([: _&".;._2 ,&':');._2 +secsFromTime=: 24 60 60 #. ] NB. convert from time to seconds +rft=: 2r86400p1 * secsFromTime NB. convert from time to radians +meanTime=: 'hh:mm:ss' fmtTime [: secsFromTime [: avgAngleR&.rft parseTimes diff --git a/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-2.j b/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-2.j new file mode 100644 index 0000000000..128331b151 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/J/averages-mean-time-of-day-2.j @@ -0,0 +1,2 @@ + meanTime '23:00:17 23:40:20 00:12:45 00:17:19 ' +23:47:43 diff --git a/Task/Averages-Mean-time-of-day/Mathematica/averages-mean-time-of-day.mathematica b/Task/Averages-Mean-time-of-day/Mathematica/averages-mean-time-of-day.mathematica new file mode 100644 index 0000000000..e2c129ca31 --- /dev/null +++ b/Task/Averages-Mean-time-of-day/Mathematica/averages-mean-time-of-day.mathematica @@ -0,0 +1,8 @@ +meanTime[list_] := + StringJoin@ + Riffle[ToString /@ + Floor@{Mod[24 #, 24], Mod[24*60 #, 60], Mod[24*60*60 #, 60]} &[ + Arg[Mean[ + Exp[FromDigits[ToExpression@StringSplit[#, ":"], 60] & /@ + list/(24*60*60) 2 Pi I]]]/(2 Pi)], ":"]; +meanTime[{"23:00:17", "23:40:20", "00:12:45", "00:17:19"}] diff --git a/Task/Averages-Median/Factor/averages-median-1.factor b/Task/Averages-Median/Factor/averages-median-1.factor new file mode 100644 index 0000000000..5113bd9971 --- /dev/null +++ b/Task/Averages-Median/Factor/averages-median-1.factor @@ -0,0 +1,27 @@ +USING: arrays kernel locals math math.functions random sequences ; +IN: median + +: pivot ( seq -- pivot ) random ; + +: split ( seq pivot -- {lt,eq,gt} ) + [ [ < ] curry partition ] keep + [ = ] curry partition + 3array ; + +DEFER: nth-in-order +:: nth-in-order-recur ( seq ind -- elt ) + seq dup pivot split + dup [ length ] map 0 [ + ] accumulate nip + dup [ ind <= [ 1 ] [ 0 ] if ] map sum 1 - + [ swap nth ] curry bi@ + ind swap - + nth-in-order ; + +: nth-in-order ( seq ind -- elt ) + dup 0 = + [ drop first ] + [ nth-in-order-recur ] + if ; + +: median ( seq -- median ) + dup length 1 - 2 / floor nth-in-order ; diff --git a/Task/Averages-Median/Factor/averages-median-2.factor b/Task/Averages-Median/Factor/averages-median-2.factor new file mode 100644 index 0000000000..1ec9951602 --- /dev/null +++ b/Task/Averages-Median/Factor/averages-median-2.factor @@ -0,0 +1,4 @@ +( scratchpad ) 11 iota median . +5 +( scratchpad ) 10 iota median . +4 diff --git a/Task/Averages-Median/GAP/averages-median.gap b/Task/Averages-Median/GAP/averages-median.gap new file mode 100644 index 0000000000..b4afcb0bad --- /dev/null +++ b/Task/Averages-Median/GAP/averages-median.gap @@ -0,0 +1,14 @@ +Median := function(v) + local n, w; + w := SortedList(v); + n := Length(v); + return (w[QuoInt(n + 1, 2)] + w[QuoInt(n, 2) + 1]) / 2; +end; + +a := [41, 56, 72, 17, 93, 44, 32]; +b := [41, 72, 17, 93, 44, 32]; + +Median(a); +# 44 +Median(b); +# 85/2 diff --git a/Task/Averages-Median/Groovy/averages-median-1.groovy b/Task/Averages-Median/Groovy/averages-median-1.groovy new file mode 100644 index 0000000000..2bc8acd0ab --- /dev/null +++ b/Task/Averages-Median/Groovy/averages-median-1.groovy @@ -0,0 +1,9 @@ +def median(Iterable col) { + def s = col as SortedSet + if (s == null) return null + if (s.empty) return 0 + def n = s.size() + def m = n.intdiv(2) + def l = s.collect { it } + n%2 == 1 ? l[m] : (l[m] + l[m-1])/2 +} diff --git a/Task/Averages-Median/Groovy/averages-median-2.groovy b/Task/Averages-Median/Groovy/averages-median-2.groovy new file mode 100644 index 0000000000..79cb8b7197 --- /dev/null +++ b/Task/Averages-Median/Groovy/averages-median-2.groovy @@ -0,0 +1,7 @@ +def a = [4.4, 2.3, -1.7, 7.5, 6.6, 0.0, 1.9, 8.2, 9.3, 4.5] +def sz = a.size() + +(0..sz).each { + println """${median(a[0..<(sz-it)])} == median(${a[0..<(sz-it)]}) +${median(a[it...)@midpt { /:~) diff --git a/Task/Averages-Median/J/averages-median-3.j b/Task/Averages-Median/J/averages-median-3.j new file mode 100644 index 0000000000..15dc1d4bd0 --- /dev/null +++ b/Task/Averages-Median/J/averages-median-3.j @@ -0,0 +1,3 @@ + median=: ~.@(<. , >.)@midpt { /:~ + median 1 9 2 4 +2 4 diff --git a/Task/Averages-Median/Julia/averages-median.julia b/Task/Averages-Median/Julia/averages-median.julia new file mode 100644 index 0000000000..407dbf74ec --- /dev/null +++ b/Task/Averages-Median/Julia/averages-median.julia @@ -0,0 +1,4 @@ + julia> values = [1:10] + [1,2,3,4,5,6,7,8,9,10] + julia> median(values) + 5.5 diff --git a/Task/Averages-Median/LSL/averages-median.lsl b/Task/Averages-Median/LSL/averages-median.lsl new file mode 100644 index 0000000000..1c048b656f --- /dev/null +++ b/Task/Averages-Median/LSL/averages-median.lsl @@ -0,0 +1,22 @@ +integer MAX_ELEMENTS = 10; +integer MAX_VALUE = 100; +default { + state_entry() { + list lst = []; + integer x = 0; + for(x=0 ; xintmiddle then median= a( 1 +intmiddle) else median =( a( intmiddle) +a( intmiddle +1)) /2 + end function diff --git a/Task/Averages-Median/MUMPS/averages-median.mumps b/Task/Averages-Median/MUMPS/averages-median.mumps new file mode 100644 index 0000000000..2a5177b05c --- /dev/null +++ b/Task/Averages-Median/MUMPS/averages-median.mumps @@ -0,0 +1,14 @@ +MEDIAN(X) + ;X is assumed to be a list of numbers separated by "^" + ;I is a loop index + ;L is the length of X + ;Y is a new array + QUIT:'$DATA(X) "No data" + QUIT:X="" "Empty Set" + NEW I,ODD,L,Y + SET L=$LENGTH(X,"^"),ODD=L#2,I=1 + ;The values in the vector are used as indices for a new array Y, which sorts them + FOR QUIT:I>L SET Y($PIECE(X,"^",I))=1,I=I+1 + ;Go to the median index, or the lesser of the middle if there is an even number of elements + SET J="" FOR I=1:1:$SELECT(ODD:L\2+1,'ODD:L/2) SET J=$ORDER(Y(J)) + QUIT $SELECT(ODD:J,'ODD:(J+$ORDER(Y(J)))/2) diff --git a/Task/Averages-Median/Maple/averages-median-1.maple b/Task/Averages-Median/Maple/averages-median-1.maple new file mode 100644 index 0000000000..d16efdbddf --- /dev/null +++ b/Task/Averages-Median/Maple/averages-median-1.maple @@ -0,0 +1,5 @@ +> Statistics:-Median( [ 1, 5, 3, 2, 4 ] ); + 3. + +> Statistics:-Median( [ 1, 5, 3, 6, 2, 4 ] ); + 3.50000000000000 diff --git a/Task/Averages-Median/Maple/averages-median-2.maple b/Task/Averages-Median/Maple/averages-median-2.maple new file mode 100644 index 0000000000..f6a03260ca --- /dev/null +++ b/Task/Averages-Median/Maple/averages-median-2.maple @@ -0,0 +1,4 @@ +median1 := proc() + local L := sort( [ args ] ); + ( L[ iquo( 1 + nargs, 2 ) ] + L[ 1 + iquo( nargs, 2 ) ] ) / 2 +end proc: diff --git a/Task/Averages-Median/Maple/averages-median-3.maple b/Task/Averages-Median/Maple/averages-median-3.maple new file mode 100644 index 0000000000..7897ac995e --- /dev/null +++ b/Task/Averages-Median/Maple/averages-median-3.maple @@ -0,0 +1,5 @@ +> median1( 1, 5, 3, 2, 4 ); # 3 + 3 + +> median1( 1, 5, 3, 6, 4, 2 ); # 7/2 + 7/2 diff --git a/Task/Averages-Median/Mathematica/averages-median-1.mathematica b/Task/Averages-Median/Mathematica/averages-median-1.mathematica new file mode 100644 index 0000000000..b715fb8878 --- /dev/null +++ b/Task/Averages-Median/Mathematica/averages-median-1.mathematica @@ -0,0 +1,2 @@ +Median[{1, 5, 3, 2, 4}] +Median[{1, 5, 3, 6, 4, 2}] diff --git a/Task/Averages-Median/Mathematica/averages-median-2.mathematica b/Task/Averages-Median/Mathematica/averages-median-2.mathematica new file mode 100644 index 0000000000..5cb0fa1dd6 --- /dev/null +++ b/Task/Averages-Median/Mathematica/averages-median-2.mathematica @@ -0,0 +1,7 @@ +mymedian[x_List]:=Module[{t=Sort[x],L=Length[x]}, + If[Mod[L,2]==0, + (t[[L/2]]+t[[L/2+1]])/2 + , + t[[(L+1)/2]] + ] +] diff --git a/Task/Averages-Median/Mathematica/averages-median-3.mathematica b/Task/Averages-Median/Mathematica/averages-median-3.mathematica new file mode 100644 index 0000000000..a47b57290b --- /dev/null +++ b/Task/Averages-Median/Mathematica/averages-median-3.mathematica @@ -0,0 +1,2 @@ +mymedian[{1, 5, 3, 2, 4}] +mymedian[{1, 5, 3, 6, 4, 2}] diff --git a/Task/Averages-Median/Maxima/averages-median.maxima b/Task/Averages-Median/Maxima/averages-median.maxima new file mode 100644 index 0000000000..f01c9cb51f --- /dev/null +++ b/Task/Averages-Median/Maxima/averages-median.maxima @@ -0,0 +1,3 @@ +/* built-in */ +median([41, 56, 72, 17, 93, 44, 32]); /* 44 */ +median([41, 72, 17, 93, 44, 32]); /* 85/2 */ diff --git a/Task/Averages-Mode/Factor/averages-mode.factor b/Task/Averages-Mode/Factor/averages-mode.factor new file mode 100644 index 0000000000..6f3109dcd3 --- /dev/null +++ b/Task/Averages-Mode/Factor/averages-mode.factor @@ -0,0 +1 @@ +{ 11 9 4 9 4 9 } mode ! 9 diff --git a/Task/Averages-Mode/GAP/averages-mode.gap b/Task/Averages-Mode/GAP/averages-mode.gap new file mode 100644 index 0000000000..14397cc90e --- /dev/null +++ b/Task/Averages-Mode/GAP/averages-mode.gap @@ -0,0 +1,9 @@ +mode := function(v) + local c, m; + c := Collected(SortedList(v)); + m := Maximum(List(c, x -> x[2])); + return List(Filtered(c, x -> x[2] = m), y -> y[1]); +end; + +mode([ 7, 5, 6, 1, 5, 5, 7, 12, 17, 6, 6, 5, 12, 3, 6 ]); +# [ 5, 6 ] diff --git a/Task/Averages-Mode/Groovy/averages-mode-1.groovy b/Task/Averages-Mode/Groovy/averages-mode-1.groovy new file mode 100644 index 0000000000..e7a8618daa --- /dev/null +++ b/Task/Averages-Mode/Groovy/averages-mode-1.groovy @@ -0,0 +1,9 @@ +def mode(Iterable col) { + assert col + def m = [:] + col.each { + m[it] = m[it] == null ? 1 : m[it] + 1 + } + def keys = m.keySet().sort { -m[it] } + keys.findAll { m[it] == m[keys[0]] } +} diff --git a/Task/Averages-Mode/Groovy/averages-mode-2.groovy b/Task/Averages-Mode/Groovy/averages-mode-2.groovy new file mode 100644 index 0000000000..a2628ca797 --- /dev/null +++ b/Task/Averages-Mode/Groovy/averages-mode-2.groovy @@ -0,0 +1,6 @@ +def random = new Random() +def sourceList = [ 'Lamp', 42.0, java.awt.Color.RED, new Date(), ~/pattern/] +(0..10).each { + def a = (0..10).collect { sourceList[random.nextInt(5)] } + println "${mode(a)} == mode(${a})" +} diff --git a/Task/Averages-Mode/Icon/averages-mode.icon b/Task/Averages-Mode/Icon/averages-mode.icon new file mode 100644 index 0000000000..3d0f91a583 --- /dev/null +++ b/Task/Averages-Mode/Icon/averages-mode.icon @@ -0,0 +1,14 @@ +procedure main(args) + every write(!mode(args)) +end + +procedure mode(A) + hist := table(0) + every hist[!A] +:= 1 + hist := sort(hist, 2) + modeCnt := hist[*hist][2] + every modeP := hist[*hist to 1 by -1] do { + if modeCnt = modeP[2] then suspend modeP[1] + else fail + } +end diff --git a/Task/Averages-Mode/J/averages-mode.j b/Task/Averages-Mode/J/averages-mode.j new file mode 100644 index 0000000000..059ecec48f --- /dev/null +++ b/Task/Averages-Mode/J/averages-mode.j @@ -0,0 +1 @@ +mode=: ~. #~ ( = >./ )@( #/.~ ) diff --git a/Task/Averages-Mode/K/averages-mode.k b/Task/Averages-Mode/K/averages-mode.k new file mode 100644 index 0000000000..44ce50c413 --- /dev/null +++ b/Task/Averages-Mode/K/averages-mode.k @@ -0,0 +1,3 @@ + mode: {(?x)@&n=|/n:#:'=x} + mode 1 1 1 1 2 2 2 3 3 3 3 4 4 3 2 4 4 4 +3 4 diff --git a/Task/Averages-Mode/MUMPS/averages-mode.mumps b/Task/Averages-Mode/MUMPS/averages-mode.mumps new file mode 100644 index 0000000000..93394a8d5f --- /dev/null +++ b/Task/Averages-Mode/MUMPS/averages-mode.mumps @@ -0,0 +1,15 @@ +MODE(X) + ;X is assumed to be a list of numbers separated by "^" + ;I is a loop index + ;L is the length of X + ;Y is a new array + ;ML is the list of modes + ;LOC is a placeholder to shorten the statement + Q:'$DATA(X) "No data" + Q:X="" "Empty Set" + NEW Y,I,L,LOC + SET L=$LENGTH(X,"^"),ML="" + FOR I=1:1:L SET LOC=+$P(X,"^",I),Y(LOC)=$S($DATA(Y(LOC)):Y(LOC)+1,1:1) + SET I="",I=$O(Y(I)),ML=I ;Prime the pump, rather than test for no data + FOR S I=$O(Y(I)) Q:I="" S ML=$SELECT(Y($P(ML,"^"))>Y(I):ML,Y($P(ML,"^"))= geometricMean (items)) && + (geometricMean (items) >= harmonicMean (items))) + echo ("relation holds") + else + echo ("relation failed") + } +} diff --git a/Task/Averages-Pythagorean-means/GAP/averages-pythagorean-means.gap b/Task/Averages-Pythagorean-means/GAP/averages-pythagorean-means.gap new file mode 100644 index 0000000000..baaa5d87a8 --- /dev/null +++ b/Task/Averages-Pythagorean-means/GAP/averages-pythagorean-means.gap @@ -0,0 +1,18 @@ +# The first two work with rationals or with floats +# (but bear in mind that support of floating point is very poor in GAP) +mean := v -> Sum(v) / Length(v); +harmean := v -> Length(v) / Sum(v, Inverse); +geomean := v -> EXP_FLOAT(Sum(v, LOG_FLOAT) / Length(v)); + +mean([1 .. 10]); +# 11/2 +harmean([1 .. 10]); +# 25200/7381 + +v := List([1..10], FLOAT_INT);; +mean(v); +# 5.5 +harmean(v); +# 3.41417 +geomean(v); +# 4.52873 diff --git a/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-1.groovy b/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-1.groovy new file mode 100644 index 0000000000..305b61c7ab --- /dev/null +++ b/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-1.groovy @@ -0,0 +1,23 @@ +def arithMean = { list -> + list == null \ + ? null \ + : list.empty \ + ? 0 \ + : list.sum() / list.size() +} + +def geomMean = { list -> + list == null \ + ? null \ + : list.empty \ + ? 1 \ + : list.inject(1) { prod, item -> prod*item } ** (1 / list.size()) +} + +def harmMean = { list -> + list == null \ + ? null \ + : list.empty \ + ? 0 \ + : list.size() / list.collect { 1.0/it }.sum() +} diff --git a/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-2.groovy b/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-2.groovy new file mode 100644 index 0000000000..42997701a8 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Groovy/averages-pythagorean-means-2.groovy @@ -0,0 +1,12 @@ +def list = 1..10 +def A = arithMean(list) +def G = geomMean(list) +assert A >= G +def H = harmMean(list) +assert G >= H +println """ +list: ${list} + A: ${A} + G: ${G} + H: ${H} +""" diff --git a/Task/Averages-Pythagorean-means/HicEst/averages-pythagorean-means.hicest b/Task/Averages-Pythagorean-means/HicEst/averages-pythagorean-means.hicest new file mode 100644 index 0000000000..81cb6f20a1 --- /dev/null +++ b/Task/Averages-Pythagorean-means/HicEst/averages-pythagorean-means.hicest @@ -0,0 +1,10 @@ +AGH = ALIAS( A, G, H ) ! named vector elements +AGH = (0, 1, 0) +DO i = 1, 10 + A = A + i + G = G * i + H = H + 1/i +ENDDO +AGH = (A/10, G^0.1, 10/H) + +WRITE(ClipBoard, Name) AGH, "Result = " // (A>=G) * (G>=H) diff --git a/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-1.icon b/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-1.icon new file mode 100644 index 0000000000..9ac231b655 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-1.icon @@ -0,0 +1,11 @@ +link numbers # for a/g/h means + +procedure main() +every put(x := [], 1 to 10) +writes("x := [ "); every writes(!x," "); write("]") + +write("Arithmetic mean:", a := amean!x) +write("Geometric mean:",g := gmean!x) +write("Harmonic mean:", h := hmean!x) +write(" a >= g >= h is ", if a >= g >= h then "true" else "false") +end diff --git a/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-2.icon b/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-2.icon new file mode 100644 index 0000000000..e9f48cf569 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Icon/averages-pythagorean-means-2.icon @@ -0,0 +1,30 @@ +procedure amean(L[]) #: arithmetic mean + local m + if *L = 0 then fail + m := 0.0 + every m +:= !L + return m / *L +end + +procedure gmean(L[]) #: geometric mean + local m + if *L = 0 then fail + m := 1.0 + every m *:= !L + m := abs(m) + if m > 0.0 then + return exp (log(m) / *L) + else + fail +end + +procedure hmean(L[]) #: harmonic mean + local m, r + if *L = 0 then fail + m := 0.0 + every r := !L do { + if r = 0.0 then fail + else m +:= 1.0 / r + } + return *L / m +end diff --git a/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-1.j b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-1.j new file mode 100644 index 0000000000..992439a006 --- /dev/null +++ b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-1.j @@ -0,0 +1,3 @@ +amean=: +/ % # +gmean=: # %: */ +hmean=: amean&.:% diff --git a/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-2.j b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-2.j new file mode 100644 index 0000000000..08b14ddf25 --- /dev/null +++ b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-2.j @@ -0,0 +1,3 @@ + (amean , gmean , hmean) >: i. 10 +5.5 4.528729 3.414172 + assert 2 >:/\ (amean , gmean , hmean) >: i. 10 NB. check amean >= gmean and gmean >= hmean diff --git a/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-3.j b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-3.j new file mode 100644 index 0000000000..47e710c21d --- /dev/null +++ b/Task/Averages-Pythagorean-means/J/averages-pythagorean-means-3.j @@ -0,0 +1 @@ +gmean=:amean&.:^. diff --git a/Task/Averages-Pythagorean-means/Liberty-BASIC/averages-pythagorean-means.liberty b/Task/Averages-Pythagorean-means/Liberty-BASIC/averages-pythagorean-means.liberty new file mode 100644 index 0000000000..4dc7a78913 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Liberty-BASIC/averages-pythagorean-means.liberty @@ -0,0 +1,25 @@ +for i = 1 to 10 + a = a + i +next +ArithmeticMean = a/10 + +b = 1 +for i = 1 to 10 + b = b * i +next +GeometricMean = b ^ (1/10) + +for i = 1 to 10 + c = c + (1/i) +next +HarmonicMean = 10/c + +print "ArithmeticMean: ";ArithmeticMean +print "Geometric Mean: ";GeometricMean +print "Harmonic Mean: ";HarmonicMean + +if (ArithmeticMean>=GeometricMean) and (GeometricMean>=HarmonicMean) then +print "True" +else +print "False" +end if diff --git a/Task/Averages-Pythagorean-means/Logo/averages-pythagorean-means.logo b/Task/Averages-Pythagorean-means/Logo/averages-pythagorean-means.logo new file mode 100644 index 0000000000..a4620b4fd6 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Logo/averages-pythagorean-means.logo @@ -0,0 +1,23 @@ +to compute_means :count + local "sum + make "sum 0 + local "product + make "product 1 + local "reciprocal_sum + make "reciprocal_sum 0 + + repeat :count [ + make "sum sum :sum repcount + make "product product :product repcount + make "reciprocal_sum sum :reciprocal_sum (quotient repcount) + ] + + output (sentence (quotient :sum :count) (power :product (quotient :count)) + (quotient :count :reciprocal_sum)) +end + +make "means compute_means 10 +print sentence [Arithmetic mean is] item 1 :means +print sentence [Geometric mean is] item 2 :means +print sentence [Harmonic mean is] item 3 :means +bye diff --git a/Task/Averages-Pythagorean-means/MUMPS/averages-pythagorean-means.mumps b/Task/Averages-Pythagorean-means/MUMPS/averages-pythagorean-means.mumps new file mode 100644 index 0000000000..bb4b7fbb9c --- /dev/null +++ b/Task/Averages-Pythagorean-means/MUMPS/averages-pythagorean-means.mumps @@ -0,0 +1,22 @@ +Pyth(n) New a,ii,g,h,x + For ii=1:1:n set x(ii)=ii + ; + ; Average + Set a=0 For ii=1:1:n Set a=a+x(ii) + Set a=a/n + ; + ; Geometric + Set g=1 For ii=1:1:n Set g=g*x(ii) + Set g=g**(1/n) + ; + ; Harmonic + Set h=0 For ii=1:1:n Set h=1/x(ii)+h + Set h=n/h + ; + Write !,"Pythagorean means for 1..",n,":",! + Write "Average = ",a," >= Geometric ",g," >= harmonic ",h,! + Quit +Do Pyth(10) + +Pythagorean means for 1..10: +Average = 5.5 >= Geometric 4.528728688116178495 >= harmonic 3.414171521474055006 diff --git a/Task/Averages-Pythagorean-means/Mathematica/averages-pythagorean-means.mathematica b/Task/Averages-Pythagorean-means/Mathematica/averages-pythagorean-means.mathematica new file mode 100644 index 0000000000..a504967f59 --- /dev/null +++ b/Task/Averages-Pythagorean-means/Mathematica/averages-pythagorean-means.mathematica @@ -0,0 +1,2 @@ +Print["{Arithmetic Mean, Geometric Mean, Harmonic Mean} = ", + N@Through[{Mean, GeometricMean, HarmonicMean}[Range@10]]] diff --git a/Task/Averages-Pythagorean-means/Maxima/averages-pythagorean-means.maxima b/Task/Averages-Pythagorean-means/Maxima/averages-pythagorean-means.maxima new file mode 100644 index 0000000000..475a3797fc --- /dev/null +++ b/Task/Averages-Pythagorean-means/Maxima/averages-pythagorean-means.maxima @@ -0,0 +1,6 @@ +/* built-in */ +L: makelist(i, i, 1, 10)$ + +mean(L), numer; /* 5.5 */ +geometric_mean(L), numer; /* 4.528728688116765 */ +harmonic_mean(L), numer; /* 3.414171521474055 */ diff --git a/Task/Averages-Root-mean-square/Factor/averages-root-mean-square.factor b/Task/Averages-Root-mean-square/Factor/averages-root-mean-square.factor new file mode 100644 index 0000000000..028a2c349d --- /dev/null +++ b/Task/Averages-Root-mean-square/Factor/averages-root-mean-square.factor @@ -0,0 +1,2 @@ +: root-mean-square ( seq -- mean ) + [ [ sq ] map-sum ] [ length ] bi / sqrt ; diff --git a/Task/Averages-Root-mean-square/Fantom/averages-root-mean-square.fantom b/Task/Averages-Root-mean-square/Fantom/averages-root-mean-square.fantom new file mode 100644 index 0000000000..ec261baa07 --- /dev/null +++ b/Task/Averages-Root-mean-square/Fantom/averages-root-mean-square.fantom @@ -0,0 +1,16 @@ +class Main +{ + static Float averageRms (Float[] nums) + { + if (nums.size == 0) return 0.0f + Float sum := 0f + nums.each { sum += it * it } + return (sum / nums.size.toFloat).sqrt + } + + public static Void main () + { + a := [1f,2f,3f,4f,5f,6f,7f,8f,9f,10f] + echo ("RMS Average of $a is: " + averageRms(a)) + } +} diff --git a/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-1.groovy b/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-1.groovy new file mode 100644 index 0000000000..8866c292bd --- /dev/null +++ b/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-1.groovy @@ -0,0 +1,7 @@ +def quadMean = { list -> + list == null \ + ? null \ + : list.empty \ + ? 0 \ + : ((list.collect { it*it }.sum()) / list.size()) ** 0.5 +} diff --git a/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-2.groovy b/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-2.groovy new file mode 100644 index 0000000000..8ec806ff67 --- /dev/null +++ b/Task/Averages-Root-mean-square/Groovy/averages-root-mean-square-2.groovy @@ -0,0 +1,6 @@ +def list = 1..10 +def Q = quadMean(list) +println """ +list: ${list} + Q: ${Q} +""" diff --git a/Task/Averages-Root-mean-square/HicEst/averages-root-mean-square.hicest b/Task/Averages-Root-mean-square/HicEst/averages-root-mean-square.hicest new file mode 100644 index 0000000000..14e7478988 --- /dev/null +++ b/Task/Averages-Root-mean-square/HicEst/averages-root-mean-square.hicest @@ -0,0 +1,5 @@ +sum = 0 +DO i = 1, 10 + sum = sum + i^2 +ENDDO +WRITE(ClipBoard) "RMS(1..10) = ", (sum/10)^0.5 diff --git a/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-1.icon b/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-1.icon new file mode 100644 index 0000000000..fe15d53b85 --- /dev/null +++ b/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-1.icon @@ -0,0 +1,5 @@ +procedure main() +every put(x := [], 1 to 10) +writes("x := [ "); every writes(!x," "); write("]") +write("Quadratic mean:",q := qmean!x) +end diff --git a/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-2.icon b/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-2.icon new file mode 100644 index 0000000000..2d993863a0 --- /dev/null +++ b/Task/Averages-Root-mean-square/Icon/averages-root-mean-square-2.icon @@ -0,0 +1,6 @@ +procedure qmean(L[]) #: quadratic mean + local m + if *L = 0 then fail + every (m := 0.0) +:= !L^2 + return sqrt(m / *L) +end diff --git a/Task/Averages-Root-mean-square/Io/averages-root-mean-square.io b/Task/Averages-Root-mean-square/Io/averages-root-mean-square.io new file mode 100644 index 0000000000..b43545a014 --- /dev/null +++ b/Task/Averages-Root-mean-square/Io/averages-root-mean-square.io @@ -0,0 +1,3 @@ +rms := method (figs, (figs map(** 2) reduce(+) / figs size) sqrt) + +rms( Range 1 to(10) asList ) println diff --git a/Task/Averages-Root-mean-square/J/averages-root-mean-square-1.j b/Task/Averages-Root-mean-square/J/averages-root-mean-square-1.j new file mode 100644 index 0000000000..e02db1451b --- /dev/null +++ b/Task/Averages-Root-mean-square/J/averages-root-mean-square-1.j @@ -0,0 +1 @@ +rms=: (+/ % #)&.:*: diff --git a/Task/Averages-Root-mean-square/J/averages-root-mean-square-2.j b/Task/Averages-Root-mean-square/J/averages-root-mean-square-2.j new file mode 100644 index 0000000000..6ec5f367ea --- /dev/null +++ b/Task/Averages-Root-mean-square/J/averages-root-mean-square-2.j @@ -0,0 +1,2 @@ + rms 1 + i. 10 +6.20484 diff --git a/Task/Averages-Root-mean-square/Liberty-BASIC/averages-root-mean-square.liberty b/Task/Averages-Root-mean-square/Liberty-BASIC/averages-root-mean-square.liberty new file mode 100644 index 0000000000..1200d70531 --- /dev/null +++ b/Task/Averages-Root-mean-square/Liberty-BASIC/averages-root-mean-square.liberty @@ -0,0 +1,26 @@ +' [RC] Averages/Root mean square + + SourceList$ ="1 2 3 4 5 6 7 8 9 10" + + ' If saved as an array we'd have to have a flag for last data. + ' LB has the very useful word$() to read from delimited strings. + ' The default delimiter is a space character, " ". + + SumOfSquares =0 + n =0 ' This holds index to number, and counts number of data. + data$ ="666" ' temporary dummy to enter the loop. + + while data$ <>"" ' we loop until no data left. + data$ =word$( SourceList$, n +1) ' first data, as a string + NewVal =val( data$) ' convert string to number + SumOfSquares =SumOfSquares +NewVal^2 ' add to existing sum of squares + n =n +1 ' increment number of data items found + wend + + n =n -1 + + print "Supplied data was "; SourceList$ + print "This contained "; n; " numbers." + print "R.M.S. value is "; ( SumOfSquares /n)^0.5 + + end diff --git a/Task/Averages-Root-mean-square/Logo/averages-root-mean-square.logo b/Task/Averages-Root-mean-square/Logo/averages-root-mean-square.logo new file mode 100644 index 0000000000..cd6f3be3bb --- /dev/null +++ b/Task/Averages-Root-mean-square/Logo/averages-root-mean-square.logo @@ -0,0 +1,5 @@ +to rms :v + output sqrt quotient (apply "sum map [? * ?] :v) count :v +end + +show rms iseq 1 10 diff --git a/Task/Averages-Root-mean-square/Mathematica/averages-root-mean-square.mathematica b/Task/Averages-Root-mean-square/Mathematica/averages-root-mean-square.mathematica new file mode 100644 index 0000000000..18c372a3fa --- /dev/null +++ b/Task/Averages-Root-mean-square/Mathematica/averages-root-mean-square.mathematica @@ -0,0 +1 @@ +RootMeanSquare@Range[10] diff --git a/Task/Averages-Root-mean-square/Maxima/averages-root-mean-square.maxima b/Task/Averages-Root-mean-square/Maxima/averages-root-mean-square.maxima new file mode 100644 index 0000000000..a635ce583f --- /dev/null +++ b/Task/Averages-Root-mean-square/Maxima/averages-root-mean-square.maxima @@ -0,0 +1,5 @@ +L: makelist(i, i, 1, 10)$ + +rms(L) := sqrt(lsum(x^2, x, L)/length(L))$ + +rms(L), numer; /* 6.204836822995429 */ diff --git a/Task/Averages-Simple-moving-average/Fantom/averages-simple-moving-average.fantom b/Task/Averages-Simple-moving-average/Fantom/averages-simple-moving-average.fantom new file mode 100644 index 0000000000..c0d4717891 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Fantom/averages-simple-moving-average.fantom @@ -0,0 +1,45 @@ +class MovingAverage +{ + Int period + Int[] stream + + new make (Int period) + { + this.period = period + stream = [,] + } + + // add number to end of stream and remove numbers from start if + // stream is larger than period + public Void addNumber (Int number) + { + stream.add (number) + while (stream.size > period) + { + stream.removeAt (0) + } + } + + // compute average of numbers in stream + public Float average () + { + if (stream.isEmpty) + return 0.0f + else + 1.0f * (Int)(stream.reduce(0, |a,b| { (Int) a + b })) / stream.size + } +} + +class Main +{ + public static Void main () + { // test by adding random numbers and printing average after each number + av := MovingAverage (5) + + 10.times |i| + { + echo ("After $i numbers list is ${av.stream} average is ${av.average}") + av.addNumber (Int.random(0..100)) + } + } +} diff --git a/Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap b/Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap new file mode 100644 index 0000000000..fca65c5ae8 --- /dev/null +++ b/Task/Averages-Simple-moving-average/GAP/averages-simple-moving-average.gap @@ -0,0 +1,27 @@ +MovingAverage := function(n) + local sma, buffer, pos, sum, len; + buffer := List([1 .. n], i -> 0); + pos := 0; + len := 0; + sum := 0; + sma := function(x) + pos := RemInt(pos, n) + 1; + sum := sum + x - buffer[pos]; + buffer[pos] := x; + len := Minimum(len + 1, n); + return sum/len; + end; + return sma; +end; + +f := MovingAverage(3); +f(1); # 1 +f(2); # 3/2 +f(3); # 2 +f(4); # 3 +f(5); # 4 +f(5); # 14/3 +f(4); # 14/3 +f(3); # 4 +f(2); # 3 +f(1); # 2 diff --git a/Task/Averages-Simple-moving-average/Groovy/averages-simple-moving-average.groovy b/Task/Averages-Simple-moving-average/Groovy/averages-simple-moving-average.groovy new file mode 100644 index 0000000000..6dff757820 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Groovy/averages-simple-moving-average.groovy @@ -0,0 +1,15 @@ +def simple_moving_average = { size -> + def nums = [] + double total = 0.0 + return { newElement -> + nums += newElement + oldestElement = nums.size() > size ? nums.remove(0) : 0 + total += newElement - oldestElement + total / nums.size() + } +} + +ma5 = simple_moving_average(5) + +(1..5).each{ printf( "%1.1f ", ma5(it)) } +(5..1).each{ printf( "%1.1f ", ma5(it)) } diff --git a/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-1.hicest b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-1.hicest new file mode 100644 index 0000000000..ae51600497 --- /dev/null +++ b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-1.hicest @@ -0,0 +1,26 @@ +REAL :: n=10, nums(n) + +nums = (1,2,3,4,5, 5,4,3,2,1) +DO i = 1, n + WRITE() "num=", i, "SMA3=", SMA(3,nums(i)), "SMA5=",SMA(5,nums(i)) +ENDDO + +END ! of "main" + +FUNCTION SMA(period, num) ! maxID independent streams + REAL :: maxID=10, now(maxID), Periods(maxID), Offsets(maxID), Pool(1000) + + ID = INDEX(Periods, period) + IF( ID == 0) THEN ! initialization + IDs = IDs + 1 + ID = IDs + Offsets(ID) = SUM(Periods) + 1 + Periods(ID) = period + ENDIF + + now(ID) = now(ID) + 1 + ALIAS(Pool,Offsets(ID), Past,Periods(ID)) ! renames relevant part of data pool + Past = Past($+1) ! shift left + Past(Periods(ID)) = num + SMA = SUM(Past) / MIN( now(ID), Periods(ID) ) + END diff --git a/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-2.hicest b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-2.hicest new file mode 100644 index 0000000000..cf45eddb0b --- /dev/null +++ b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-2.hicest @@ -0,0 +1,18 @@ +procedure main(A) + sma := buildSMA(3) # Use better name than "I". + every write(sma(!A)) +end + +procedure buildSMA(P) + local stream + c := create { + stream := [] + while n := (avg@&source)[1] do { + put(stream, n) + if *stream > P then pop(stream) + every (avg := 0.0) +:= !stream + avg := avg/*stream + } + } + return (@c, c) +end diff --git a/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-3.hicest b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-3.hicest new file mode 100644 index 0000000000..297f9475cd --- /dev/null +++ b/Task/Averages-Simple-moving-average/HicEst/averages-simple-moving-average-3.hicest @@ -0,0 +1,14 @@ +import Utils + +procedure main(A) + sma1 := closure(SMA,[],3) + sma2 := closure(SMA,[],4) + every every n := !A do write(left(sma1(n),20), sma2(n)) +end + +procedure SMA(stream,P,n) + put(stream, n) + if *stream > P then pop(stream) + every (avg := 0.0) +:= !stream + return avg / *stream +end diff --git a/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-1.j b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-1.j new file mode 100644 index 0000000000..85e9d8445f --- /dev/null +++ b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-1.j @@ -0,0 +1,2 @@ + 5 (+/%#)\ 1 2 3 4 5 5 4 3 2 1 NB. not a solution for this task +3 3.8 4.2 4.2 3.8 3 diff --git a/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-2.j b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-2.j new file mode 100644 index 0000000000..3012ebd22e --- /dev/null +++ b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-2.j @@ -0,0 +1 @@ + lex =: 1 :'(a[n__a=.m#_.[a=.18!:3$~0)&(4 :''(+/%#)(#~1-128!:5)n__x=.1|.!.y n__x'')' diff --git a/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-3.j b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-3.j new file mode 100644 index 0000000000..b999b13ced --- /dev/null +++ b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-3.j @@ -0,0 +1,3 @@ + sma =: 5 lex + sma&> 1 2 3 4 5 5 4 3 2 1 +1 1.5 2 2.5 3 3.8 4.2 4.2 3.8 3 diff --git a/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-4.j b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-4.j new file mode 100644 index 0000000000..bb23309b6d --- /dev/null +++ b/Task/Averages-Simple-moving-average/J/averages-simple-moving-average-4.j @@ -0,0 +1,9 @@ +avg=: +/ % # +SEQ=:'' +moveAvg=:4 :0"0 + SEQ=:SEQ,y + avg ({.~ x -@<. #) SEQ +) + + 5 moveAvg 1 2 3 4 5 5 4 3 2 1 +1 1.5 2 2.5 3 3.8 4.2 4.2 3.8 3 diff --git a/Task/Averages-Simple-moving-average/Liberty-BASIC/averages-simple-moving-average.liberty b/Task/Averages-Simple-moving-average/Liberty-BASIC/averages-simple-moving-average.liberty new file mode 100644 index 0000000000..27fd659310 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Liberty-BASIC/averages-simple-moving-average.liberty @@ -0,0 +1,68 @@ + dim v$( 100) ' Each array term stores a particular SMA of period p in p*10 bytes + + nomainwin + + WindowWidth =1080 + WindowHeight = 780 + + graphicbox #w.gb1, 20, 20, 1000, 700 + + open "Running averages to smooth data" for window as #w + + #w "trapclose quit" + + #w.gb1 "down" + + old.x = 0 + old.y.orig =500 ' black + old.y.3.SMA =350 ' red + old.y.20.SMA =300 ' green + + for i =0 to 999 step 1 + scan + v =1.1 +sin( i /1000 *2 *3.14159265) + 0.2 *rnd( 1) ' sin wave with added random noise + x =i /6.28318 *1000 + y.orig =500 -v /2.5 *500 + + #w.gb1 "color black ; down ; line "; i-1; " "; old.y.orig; " "; i; " "; y.orig; " ; up" + + y.3.SMA =500 -SMA( 1, v, 3) /2.5 *500 ' SMA given ID of 1 is to do 3-term running average + #w.gb1 "color red ; down ; line "; i-1; " "; old.y.3.SMA +50; " "; i; " "; y.3.SMA +50; " ; up" + + y.20.SMA =500 -SMA( 2, v, 20) /2.5 *500 ' SMA given ID of 2 is to do 20-term running average + #w.gb1 "color green ; down ; line "; i-1; " "; old.y.20.SMA +100; " "; i; " "; y.20.SMA +100; " ; up" + + 'print "Supplied with "; v; ", so SMAs are now "; using( "###.###", SMA( 1, v, 3)); " over 3 terms or "; using( "###.###", SMA( 2, v, 5)) ; " over 5 terms." ' ID, latest data, period + + old.y.orig =y.orig + old.y.3.SMA =y.3.SMA + old.y.20.SMA =y.20.SMA + next i + + wait + +sub quit j$ + close #w + end +end sub + + + +function SMA( ID, Number, Period) + v$( ID) =right$( " " +str$( Number), 10) +v$( ID) ' add new number at left, lose last number on right + v$( ID) =left$( v$( ID), Period *10) + 'print "{"; v$( ID); "}", + + k =0 ' number of terms read + total =0 ' sum of terms read + + do + p$ =mid$( v$( ID), 1 +k *10, 10) + if p$ ="" then exit do + vv =val( p$) + total =total +vv + k =k +1 + loop until p$ ="" + + if k (MAData[[2]] = r), #[[-r ;; -1]], #] &@ + Append[MAData[[1]], x]]] diff --git a/Task/Averages-Simple-moving-average/Mercury/averages-simple-moving-average.mercury b/Task/Averages-Simple-moving-average/Mercury/averages-simple-moving-average.mercury new file mode 100644 index 0000000000..a5309c3315 --- /dev/null +++ b/Task/Averages-Simple-moving-average/Mercury/averages-simple-moving-average.mercury @@ -0,0 +1,10 @@ + % state(period, list of floats from [newest, ..., oldest]) +:- type state ---> state(int, list(float)). + +:- func init(int) = state. +init(Period) = state(Period, []). + +:- pred sma(float::in, float::out, state::in, state::out) is det. +sma(N, Average, state(P, L0), state(P, L)) :- + take_upto(P, [N|L0], L), + Average = foldl((+), L, 0.0) / float(length(L)). diff --git a/Task/Balanced-brackets/Factor/balanced-brackets.factor b/Task/Balanced-brackets/Factor/balanced-brackets.factor new file mode 100644 index 0000000000..aba286a551 --- /dev/null +++ b/Task/Balanced-brackets/Factor/balanced-brackets.factor @@ -0,0 +1,22 @@ +USING: io formatting locals kernel math sequences unicode.case ; +IN: balanced-brackets + +:: balanced ( str -- ) + 0 :> counter! + 1 :> ok! + str + [ dup length 0 > ] + [ 1 cut swap + "[" = [ counter 1 + counter! ] [ counter 1 - counter! ] if + counter 0 < [ 0 ok! ] when + ] + while + drop + ok 0 = + [ "NO" ] + [ counter 0 > [ "NO" ] [ "YES" ] if ] + if + print ; + +readln +balanced diff --git a/Task/Balanced-brackets/Fantom/balanced-brackets.fantom b/Task/Balanced-brackets/Fantom/balanced-brackets.fantom new file mode 100644 index 0000000000..aaf68c715a --- /dev/null +++ b/Task/Balanced-brackets/Fantom/balanced-brackets.fantom @@ -0,0 +1,39 @@ +class Main +{ + static Bool matchingBrackets (Str[] brackets) + { + Int opened := 0 + Int i := 0 + while (i < brackets.size) + { + if (brackets[i] == "[") + opened += 1 + else + opened -= 1 + if (opened < 0) return false + i += 1 + } + return true + } + + public static Void main (Str[] args) + { + if (args.size == 1 && Int.fromStr(args[0], 10, false) != null) + { + n := Int.fromStr(args[0]) + Str[] brackets := [,] + 20.times + { + brackets = [,] + // create a random set of brackets + n.times { brackets.addAll (["[", "]"]) } + n.times { brackets.swap(Int.random(0..<2*n), Int.random(0..<2*n)) } + // report if matching or not + if (matchingBrackets(brackets)) + echo (brackets.join(" ") + " Matching") + else + echo (brackets.join(" ") + " not matching") + } + } + } +} diff --git a/Task/Balanced-brackets/GAP/balanced-brackets.gap b/Task/Balanced-brackets/GAP/balanced-brackets.gap new file mode 100644 index 0000000000..4a4d7f5b17 --- /dev/null +++ b/Task/Balanced-brackets/GAP/balanced-brackets.gap @@ -0,0 +1,36 @@ +Balanced := function(L) + local c, r; + r := 0; + for c in L do + if c = ']' then + r := r - 1; + if r < 0 then + return false; + fi; + elif c = '[' then + r := r + 1; + fi; + od; + return r = 0; +end; + +Balanced(""); +# true + +Balanced("["); +# false + +Balanced("]"); +# false + +Balanced("[]"); +# true + +Balanced("]["); +# false + +Balanced("[[][]]"); +# true + +Balanced("[[[]][]]]"); +# false diff --git a/Task/Balanced-brackets/Groovy/balanced-brackets-1.groovy b/Task/Balanced-brackets/Groovy/balanced-brackets-1.groovy new file mode 100644 index 0000000000..9a469ec0f0 --- /dev/null +++ b/Task/Balanced-brackets/Groovy/balanced-brackets-1.groovy @@ -0,0 +1,21 @@ +def random = new Random() + +def factorial = { (it > 1) ? (2..it).inject(1) { i, j -> i*j } : 1 } + +def makePermutation; +makePermutation = { string, i -> + def n = string.size() + if (n < 2) return string + def fact = factorial(n-1) + assert i < fact*n + + def index = i.intdiv(fact) + string[index] + makePermutation(string[0.. + if (n == 0) return '' + def base = '['*n + ']'*n + def p = random.nextInt(factorial(n*2)) + makePermutation(base, p) +} diff --git a/Task/Balanced-brackets/Groovy/balanced-brackets-2.groovy b/Task/Balanced-brackets/Groovy/balanced-brackets-2.groovy new file mode 100644 index 0000000000..9c18f4280f --- /dev/null +++ b/Task/Balanced-brackets/Groovy/balanced-brackets-2.groovy @@ -0,0 +1,11 @@ +boolean balancedBrackets(String brackets, int depth=0) { + if (brackets == null || brackets.empty) return depth == 0 + switch (brackets[0]) { + case '[': + return brackets.size() > 1 && balancedBrackets(brackets[1..-1], depth + 1) + case ']': + return depth > 0 && (brackets.size() == 1 || balancedBrackets(brackets[1..-1], depth - 1)) + default: + return brackets.size() == 1 ? depth == 0 : balancedBrackets(brackets[1..-1], depth) + } +} diff --git a/Task/Balanced-brackets/Groovy/balanced-brackets-3.groovy b/Task/Balanced-brackets/Groovy/balanced-brackets-3.groovy new file mode 100644 index 0000000000..9489cd460c --- /dev/null +++ b/Task/Balanced-brackets/Groovy/balanced-brackets-3.groovy @@ -0,0 +1,13 @@ +Set brackets = [] +(0..100).each { + (0..8).each { r -> + brackets << randomBrackets(r) + } +} + +brackets.sort { a, b -> + a.size() <=> b.size() ?: a <=> b +} .each { + def bal = balancedBrackets(it) ? "balanced: " : "unbalanced: " + println "${bal} ${it}" +} diff --git a/Task/Balanced-brackets/Icon/balanced-brackets.icon b/Task/Balanced-brackets/Icon/balanced-brackets.icon new file mode 100644 index 0000000000..133cb9b25a --- /dev/null +++ b/Task/Balanced-brackets/Icon/balanced-brackets.icon @@ -0,0 +1,15 @@ +procedure main(arglist) +every s := genbs(!arglist) do + write(image(s), if isbalanced(s) then " is balanced." else " is unbalanced") +end + +procedure isbalanced(s) # test if a string is balanced re: [] +return (s || " ") ? (bal(,'[',']') = *s+1) +end + +procedure genbs(i) # generate strings of i pairs of [] +s := "" +every 1 to i do s ||:= "[]" # generate i pairs +every !s := ?s # shuffle +return s +end diff --git a/Task/Balanced-brackets/J/balanced-brackets-1.j b/Task/Balanced-brackets/J/balanced-brackets-1.j new file mode 100644 index 0000000000..7da00fec3d --- /dev/null +++ b/Task/Balanced-brackets/J/balanced-brackets-1.j @@ -0,0 +1,3 @@ +bracketDepth =: '[]' -&(+/\)/@:(=/) ] +checkBalanced =: _1 -.@e. bracketDepth +genBracketPairs =: (?~@# { ])@#"0 1&'[]' NB. bracket pairs in arbitrary order diff --git a/Task/Balanced-brackets/J/balanced-brackets-2.j b/Task/Balanced-brackets/J/balanced-brackets-2.j new file mode 100644 index 0000000000..8cb613b3d3 --- /dev/null +++ b/Task/Balanced-brackets/J/balanced-brackets-2.j @@ -0,0 +1,11 @@ + (,&' ' , ('bad';'OK') {::~ checkBalanced)"1 genBracketPairs i. 10 + OK +][ bad +][[] bad +[[[]]] OK +[][[]][] OK +[][[[][]]] OK +[]][]][]][[[ bad +[[]][[][][]][] OK +]]]][[][][[[[]][ bad +[]]][][][[[[]][[]] bad diff --git a/Task/Balanced-brackets/Liberty-BASIC/balanced-brackets.liberty b/Task/Balanced-brackets/Liberty-BASIC/balanced-brackets.liberty new file mode 100644 index 0000000000..8795ff98a0 --- /dev/null +++ b/Task/Balanced-brackets/Liberty-BASIC/balanced-brackets.liberty @@ -0,0 +1,62 @@ +print "Supplied examples" +for i =1 to 7 + read test$ + print "The string '"; test$; "' is "; validString$( test$) +next i +print +data "", "[]", "][","[][]","][][","[[][]]","[]][[]" + +print "Random generated examples" +for example =1 to 10 + test$ =generate$( int( 1 +10 *rnd(1))) + print "The string '"; test$; "' is "; validString$( test$) +next example +end + +function validString$( in$) + if left$( in$, 1) <>"[" and len( test$) <>0 then + validString$ ="not OK. Opens wrongly." + exit function + end if + paired =0 + for i =1 to len( in$) + c$ =mid$( in$, i, 1) + if c$ ="[" then paired =paired +1 + if c$ ="]" then paired =paired -1 + if paired <0 then + exit for + end if + next i + if ( lBr =rBr) and ( paired >=0) then validString$ ="OK." else validString$ ="not OK. Unbalanced." +end function + +function generate$( N) + lBr =0 + rBr =0 + ' choose at random until N of one type generated + while ( lBr use StringTools in +> IsBalanced( "", "[", "]" ); +> IsBalanced( "[", "[", "]" ); +> IsBalanced( "]", "[", "]" ); +> IsBalanced( "[]", "[", "]" ); +> IsBalanced( "][", "[", "]" ); +> IsBalanced( "[][]", "[", "]" ); +> IsBalanced( "[[][]]", "[", "]" ); +> IsBalanced( "[[[]][]]]", "[", "]" ); +> s := Random( 20, "[]" ); +> IsBalanced( s, "[", "]" ) +> end use; + true + + false + + false + + true + + false + + true + + true + + false + + s := "[[]][[[[[[[[[]][][]]" + + false diff --git a/Task/Balanced-brackets/Maple/balanced-brackets-2.maple b/Task/Balanced-brackets/Maple/balanced-brackets-2.maple new file mode 100644 index 0000000000..ff523ac8a7 --- /dev/null +++ b/Task/Balanced-brackets/Maple/balanced-brackets-2.maple @@ -0,0 +1,2 @@ +> StringTools:-IsBalanced( "[()()]", "[(", "])" ); + true diff --git a/Task/Balanced-brackets/Mathematica/balanced-brackets.mathematica b/Task/Balanced-brackets/Mathematica/balanced-brackets.mathematica new file mode 100644 index 0000000000..2765a2d874 --- /dev/null +++ b/Task/Balanced-brackets/Mathematica/balanced-brackets.mathematica @@ -0,0 +1,13 @@ +(* Generate open/close events. *) +gen[n_] := RandomSample[Table[{1, -1}, {n}] // Flatten] + +(* Check balance. *) +check[lst_] := And @@ (# >= 0 & /@ Accumulate[lst]) + +(* Do task for string with n opening and n closing brackets. *) +doString[n_] := ( + lst = gen[n]; + str = StringJoin[lst /. {1 -> "[", -1 -> "]"}]; + Print[str <> If[match[lst, 0], + " is balanced.", + " is not balanced."]]) diff --git a/Task/Balanced-brackets/Maxima/balanced-brackets.maxima b/Task/Balanced-brackets/Maxima/balanced-brackets.maxima new file mode 100644 index 0000000000..8b41b6cc3c --- /dev/null +++ b/Task/Balanced-brackets/Maxima/balanced-brackets.maxima @@ -0,0 +1,31 @@ +brack(s) := block( + [n: slength(s), r: 0, c], + catch( + for i thru n do ( + if cequal(c: charat(s, i), "]") then (if (r: r - 1) < 0 then throw(false)) + elseif cequal(c, "[") then r: r + 1 + ), + is(r = 0) + ) +)$ + +brack(""); +true + +brack("["); +false + +brack("]"); +false + +brack("[]"); +true + +brack("]["); +false + +brack("[[][]]"); +true + +brack("[[[]][]]]"); +false diff --git a/Task/Balanced-ternary/J/balanced-ternary-1.j b/Task/Balanced-ternary/J/balanced-ternary-1.j new file mode 100644 index 0000000000..0b273d7166 --- /dev/null +++ b/Task/Balanced-ternary/J/balanced-ternary-1.j @@ -0,0 +1,12 @@ +trigits=: 1+3 <.@^. 2 * 1&>.@| +trinOfN=: |.@((_1 + ] #: #.&1@] + [) #&3@trigits) :. nOfTrin +nOfTrin=: p.&3 :. trinOfN +trinOfStr=: 0 1 _1 {~ '0+-'&i.@|. :. strOfTrin +strOfTrin=: {&'0+-'@|. :. trinOfStr + +carry=: +//.@:(trinOfN"0)^:_ +trimLead0=: (}.~ i.&1@:~:&0)&.|. + +add=: carry@(+/@,:) +neg=: - +mul=: trimLead0@carry@(+//.@(*/)) diff --git a/Task/Balanced-ternary/J/balanced-ternary-2.j b/Task/Balanced-ternary/J/balanced-ternary-2.j new file mode 100644 index 0000000000..cd16cd1bbd --- /dev/null +++ b/Task/Balanced-ternary/J/balanced-ternary-2.j @@ -0,0 +1,3 @@ +a=: trinOfStr '+-0++0+' +b=: trinOfN -436 +c=: trinOfStr '+-++-' diff --git a/Task/Balanced-ternary/J/balanced-ternary-3.j b/Task/Balanced-ternary/J/balanced-ternary-3.j new file mode 100644 index 0000000000..203fa83ad9 --- /dev/null +++ b/Task/Balanced-ternary/J/balanced-ternary-3.j @@ -0,0 +1,7 @@ + nOfTrin&> a;b;c +523 _436 65 + + strOfTrin a mul b (add -) c +----0+--0++0 + nOfTrin a mul b (add -) c +_262023 diff --git a/Task/Balanced-ternary/Mathematica/balanced-ternary-1.mathematica b/Task/Balanced-ternary/Mathematica/balanced-ternary-1.mathematica new file mode 100644 index 0000000000..9d053ddc9f --- /dev/null +++ b/Task/Balanced-ternary/Mathematica/balanced-ternary-1.mathematica @@ -0,0 +1,22 @@ +frombt = FromDigits[StringCases[#, {"+" -> 1, "-" -> -1, "0" -> 0}], + 3] &; +tobt = If[Quotient[#, 3, -1] == 0, + "", #0@Quotient[#, 3, -1]] <> (Mod[#, + 3, -1] /. {1 -> "+", -1 -> "-", 0 -> "0"}) &; +btnegate = StringReplace[#, {"+" -> "-", "-" -> "+"}] &; +btadd = StringReplace[ + StringJoin[ + Fold[Sort@{#1[[1]], + Sequence @@ #2} /. {{x_, x_, x_} :> {x, + "0" <> #1[[2]]}, {"-", "+", x_} | {x_, "-", "+"} | {x_, + "0", "0"} :> {"0", x <> #1[[2]]}, {"+", "+", "0"} -> {"+", + "-" <> #1[[2]]}, {"-", "-", "0"} -> {"-", + "+" <> #1[[2]]}} &, {"0", ""}, + Reverse@Transpose@PadLeft[Characters /@ {#1, #2}] /. {0 -> + "0"}]], StartOfString ~~ "0" .. ~~ x__ :> x] &; +btsubtract = btadd[#1, btnegate@#2] &; +btmultiply = + btadd[Switch[StringTake[#2, -1], "0", "0", "+", #1, "-", + btnegate@#1], + If[StringLength@#2 == 1, + "0", #0[#1, StringDrop[#2, -1]] <> "0"]] &; diff --git a/Task/Balanced-ternary/Mathematica/balanced-ternary-2.mathematica b/Task/Balanced-ternary/Mathematica/balanced-ternary-2.mathematica new file mode 100644 index 0000000000..0319fc510f --- /dev/null +++ b/Task/Balanced-ternary/Mathematica/balanced-ternary-2.mathematica @@ -0,0 +1,4 @@ +frombt[a = "+-0++0+"] +b = tobt@-436 +frombt[c = "+-++-"] +btmultiply[a, btsubtract[b, c]] diff --git a/Task/Best-shuffle/Groovy/best-shuffle.groovy b/Task/Best-shuffle/Groovy/best-shuffle.groovy new file mode 100644 index 0000000000..29af197e7b --- /dev/null +++ b/Task/Best-shuffle/Groovy/best-shuffle.groovy @@ -0,0 +1,29 @@ +def shuffle(text) { + def shuffled = (text as List) + for (sourceIndex in 0.. + if (character == shuffled[index]) { + score++ + } + } + score +} + +["abracadabra", "seesaw", "elk", "grrrrrr", "up", "a"].each { text -> + def result = shuffle(text) + println "${result.original}, ${result.shuffled}, (${result.score})" +} diff --git a/Task/Best-shuffle/Icon/best-shuffle-1.icon b/Task/Best-shuffle/Icon/best-shuffle-1.icon new file mode 100644 index 0000000000..a1774a8dc2 --- /dev/null +++ b/Task/Best-shuffle/Icon/best-shuffle-1.icon @@ -0,0 +1 @@ +# every !t :=: ?t # Uncomment to get a random best shuffling diff --git a/Task/Best-shuffle/Icon/best-shuffle-2.icon b/Task/Best-shuffle/Icon/best-shuffle-2.icon new file mode 100644 index 0000000000..887300f924 --- /dev/null +++ b/Task/Best-shuffle/Icon/best-shuffle-2.icon @@ -0,0 +1,18 @@ +procedure main(args) + while scram := bestShuffle(line := read()) do + write(line," -> ",scram," (",unchanged(line,scram),")") +end + +procedure bestShuffle(s) + t := s + # every !t :=: ?t # Uncomment to get a random best shuffling + every i := 1 to *t do + every j := (1 to i-1) | (i+1 to *t) do + if (t[i] ~== s[j]) & (s[i] ~== t[j]) then break t[i] :=: t[j] + return t +end + +procedure unchanged(s1,s2) # Number of unchanged elements + every (count := 0) +:= (s1[i := 1 to *s1] == s2[i], 1) + return count +end diff --git a/Task/Best-shuffle/J/best-shuffle-1.j b/Task/Best-shuffle/J/best-shuffle-1.j new file mode 100644 index 0000000000..a43f1ac15c --- /dev/null +++ b/Task/Best-shuffle/J/best-shuffle-1.j @@ -0,0 +1,9 @@ +bestShuf =: verb define + yy=. <@({~ ?~@#)@I.@= y + y C.~ (;yy) ./#@> yy +) + +fmtBest=:3 :0 + b=. bestShuf y + y,', ',b,' (',')',~":+/b=y +) diff --git a/Task/Best-shuffle/J/best-shuffle-2.j b/Task/Best-shuffle/J/best-shuffle-2.j new file mode 100644 index 0000000000..55e73c7172 --- /dev/null +++ b/Task/Best-shuffle/J/best-shuffle-2.j @@ -0,0 +1,7 @@ + fmtBest&>;:'abracadabra seesaw elk grrrrrr up a' +abracadabra, bdacararaab (0) +seesaw, eawess (0) +elk, lke (0) +grrrrrr, rrrrrrg (5) +up, pu (0) +a, a (1) diff --git a/Task/Best-shuffle/Liberty-BASIC/best-shuffle.liberty b/Task/Best-shuffle/Liberty-BASIC/best-shuffle.liberty new file mode 100644 index 0000000000..384d6308ce --- /dev/null +++ b/Task/Best-shuffle/Liberty-BASIC/best-shuffle.liberty @@ -0,0 +1,26 @@ +'see Run BASIC solution +list$ = "abracadabra seesaw pop grrrrrr up a" + +while word$(list$,ii + 1," ") <> "" + ii = ii + 1 + w$ = word$(list$,ii," ") + bs$ = bestShuffle$(w$) + count = 0 + for i = 1 to len(w$) + if mid$(w$,i,1) = mid$(bs$,i,1) then count = count + 1 + next i + print w$;" ";bs$;" ";count +wend + +function bestShuffle$(s1$) + s2$ = s1$ + for i = 1 to len(s2$) + for j = 1 to len(s2$) + if (i <> j) and (mid$(s2$,i,1) <> mid$(s1$,j,1)) and (mid$(s2$,j,1) <> mid$(s1$,i,1)) then + if j < i then i1 = j:j1 = i else i1 = i:j1 = j + s2$ = left$(s2$,i1-1) + mid$(s2$,j1,1) + mid$(s2$,i1+1,(j1-i1)-1) + mid$(s2$,i1,1) + mid$(s2$,j1+1) + end if + next j + next i +bestShuffle$ = s2$ +end function diff --git a/Task/Best-shuffle/Mathematica/best-shuffle.mathematica b/Task/Best-shuffle/Mathematica/best-shuffle.mathematica new file mode 100644 index 0000000000..042aa5b0f8 --- /dev/null +++ b/Task/Best-shuffle/Mathematica/best-shuffle.mathematica @@ -0,0 +1,5 @@ +BestShuffle[data_] := + Flatten[{data,First[SortBy[ + List[#, StringLength[data]-HammingDistance[#,data]] & /@ StringJoin /@ Permutations[StringSplit[data, ""]], Last]]}] + +Print[#[[1]], "," #[[2]], ",(", #[[3]], ")"] & /@ BestShuffle /@ {"abracadabra","seesaw","elk","grrrrrr","up","a"} diff --git a/Task/Binary-search/Factor/binary-search.factor b/Task/Binary-search/Factor/binary-search.factor new file mode 100644 index 0000000000..9854fd98f4 --- /dev/null +++ b/Task/Binary-search/Factor/binary-search.factor @@ -0,0 +1,4 @@ +USING: binary-search kernel math.order ; + +: binary-search ( seq elt -- index/f ) + [ [ <=> ] curry search ] keep = [ drop f ] unless ; diff --git a/Task/Binary-search/GAP/binary-search.gap b/Task/Binary-search/GAP/binary-search.gap new file mode 100644 index 0000000000..1af13f88ce --- /dev/null +++ b/Task/Binary-search/GAP/binary-search.gap @@ -0,0 +1,23 @@ +Find := function(v, x) + local low, high, mid; + low := 1; + high := Length(v); + while low <= high do + mid := QuoInt(low + high, 2); + if v[mid] > x then + high := mid - 1; + elif v[mid] < x then + low := mid + 1; + else + return mid; + fi; + od; + return fail; +end; + +u := [1..10]*7; +# [ 7, 14, 21, 28, 35, 42, 49, 56, 63, 70 ] +Find(u, 34); +# fail +Find(u, 35); +# 5 diff --git a/Task/Binary-search/Groovy/binary-search-1.groovy b/Task/Binary-search/Groovy/binary-search-1.groovy new file mode 100644 index 0000000000..18ef3aceb8 --- /dev/null +++ b/Task/Binary-search/Groovy/binary-search-1.groovy @@ -0,0 +1,12 @@ +def binSearchR +binSearchR = { a, target, offset=0 -> + def n = a.size() + def m = n.intdiv(2) + a.empty \ + ? ["insertion point": offset] \ + : a[m] > target \ + ? binSearchR(a[0.. + def a = aList + def offset = 0 + while (!a.empty) { + def n = a.size() + def m = n.intdiv(2) + if(a[m] > target) { + a = a[0.. assert si < source[i+1] } + +println "${source}" +1.upto(5) { + target = random.nextInt(10) + (it - 2) * 10 + print "Trial #${it}. Looking for: ${target}" + def answers = [binSearchR, binSearchI].collect { search -> + search(source, target) + } + assert answers[0] == answers[1] + println """ + Answer: ${answers[0]}, : ${source[answers[0].values().iterator().next()]}""" +} diff --git a/Task/Binary-search/HicEst/binary-search-1.hicest b/Task/Binary-search/HicEst/binary-search-1.hicest new file mode 100644 index 0000000000..bafdb08664 --- /dev/null +++ b/Task/Binary-search/HicEst/binary-search-1.hicest @@ -0,0 +1,32 @@ +REAL :: n=10, array(n) + + array = NINT( RAN(n) ) + SORT(Vector=array, Sorted=array) + x = NINT( RAN(n) ) + + idx = binarySearch( array, x ) + WRITE(ClipBoard) x, "has position ", idx, "in ", array + END + +FUNCTION binarySearch(A, value) + REAL :: A(1), value + + low = 1 + high = LEN(A) + DO i = 1, high + IF( low > high) THEN + binarySearch = 0 + RETURN + ELSE + mid = INT( (low + high) / 2 ) + IF( A(mid) > value) THEN + high = mid - 1 + ELSEIF( A(mid) < value ) THEN + low = mid + 1 + ELSE + binarySearch = mid + RETURN + ENDIF + ENDIF + ENDDO + END diff --git a/Task/Binary-search/HicEst/binary-search-2.hicest b/Task/Binary-search/HicEst/binary-search-2.hicest new file mode 100644 index 0000000000..002ecf6522 --- /dev/null +++ b/Task/Binary-search/HicEst/binary-search-2.hicest @@ -0,0 +1,2 @@ +7 has position 9 in 0 0 1 2 3 3 4 6 7 8 +5 has position 0 in 0 0 1 2 3 3 4 6 7 8 diff --git a/Task/Binary-search/Icon/binary-search-1.icon b/Task/Binary-search/Icon/binary-search-1.icon new file mode 100644 index 0000000000..1ee1e97b0a --- /dev/null +++ b/Task/Binary-search/Icon/binary-search-1.icon @@ -0,0 +1,11 @@ +procedure binsearch(A, target) + if *A = 0 then fail + mid := *A/2 + 1 + if target > A[mid] then { + return mid + binsearch(A[(mid+1):0], target) + } + else if target < A[mid] then { + return binsearch(A[1+:(mid-1)], target) + } + return mid +end diff --git a/Task/Binary-search/Icon/binary-search-2.icon b/Task/Binary-search/Icon/binary-search-2.icon new file mode 100644 index 0000000000..396b43a091 --- /dev/null +++ b/Task/Binary-search/Icon/binary-search-2.icon @@ -0,0 +1,13 @@ +procedure main(args) + target := integer(!args) | 3 + every put(A := [], 1 to 18 by 2) + + outList("Searching", A) + write(target," is ",("at "||binsearch(A, target)) | "not found") +end + +procedure outList(prefix, A) + writes(prefix,": ") + every writes(!A," ") + write() +end diff --git a/Task/Binary-search/J/binary-search-1.j b/Task/Binary-search/J/binary-search-1.j new file mode 100644 index 0000000000..7536594a82 --- /dev/null +++ b/Task/Binary-search/J/binary-search-1.j @@ -0,0 +1 @@ +bs=. i. 'Not Found'"_^:(-.@-:) I. diff --git a/Task/Binary-search/J/binary-search-2.j b/Task/Binary-search/J/binary-search-2.j new file mode 100644 index 0000000000..3c7eb3aa71 --- /dev/null +++ b/Task/Binary-search/J/binary-search-2.j @@ -0,0 +1,4 @@ + 2 3 5 6 8 10 11 15 19 20 bs 11 +6 + 2 3 5 6 8 10 11 15 19 20 bs 12 +Not Found diff --git a/Task/Binary-search/J/binary-search-3.j b/Task/Binary-search/J/binary-search-3.j new file mode 100644 index 0000000000..2c3d764d3e --- /dev/null +++ b/Task/Binary-search/J/binary-search-3.j @@ -0,0 +1,13 @@ +'X Y L H M'=. i.5 NB. Setting mnemonics for boxes +f=. &({::) NB. Fetching the contents of a box +o=. @: NB. Composing verbs (functions) + +boxes=. ; , a: $~ 3: NB. Appending 3 (empty) boxes to the inputs +LowHigh=. (0 ; # o (X f)) (L,H)} ] NB. Setting the low and high bounds +midpoint=. < o (<. o (2 %~ L f + H f)) M} ] NB. Updating the midpoint +case=. >: o * o (Y f - M f { X f) NB. Less=0, equal=1, or greater=2 + +squeeze=. (< o (_1 + M f) H} ])`(< o _: L} ])`(< o (1 + M f) L} ])@.case +return=. (M f) o ((<@:('Not Found'"_) M} ]) ^: (_ ~: L f)) + +bs=. return o (squeeze o midpoint ^: (L f <: H f) ^:_) o LowHigh o boxes diff --git a/Task/Binary-search/J/binary-search-4.j b/Task/Binary-search/J/binary-search-4.j new file mode 100644 index 0000000000..c2bbee104e --- /dev/null +++ b/Task/Binary-search/J/binary-search-4.j @@ -0,0 +1,11 @@ +'X Y L H M'=. i.5 NB. Setting mnemonics for boxes +f=. &({::) NB. Fetching the contents of a box +o=. @: NB. Composing verbs (functions) + +boxes=. a: ,~ ; NB. Appending 1 (empty) box to the inputs +midpoint=. < o (<. o (2 %~ L f + H f)) M} ] NB. Updating the midpoint +case=. >: o * o (Y f - M f { X f) NB. Less=0, equal=1, or greater=2 + +recur=. (X f bs Y f ; L f ; (_1 + M f))`(M f)`(X f bs Y f ; (1 + M f) ; H f)@.case + +bs=. (recur o midpoint`('Not Found'"_) @. (H f < L f) o boxes) :: ([ bs ] ; 0 ; (<: o # o [)) diff --git a/Task/Binary-search/Liberty-BASIC/binary-search.liberty b/Task/Binary-search/Liberty-BASIC/binary-search.liberty new file mode 100644 index 0000000000..a1cd3a10ce --- /dev/null +++ b/Task/Binary-search/Liberty-BASIC/binary-search.liberty @@ -0,0 +1,19 @@ +dim theArray(100) +for i = 1 to 100 + theArray(i) = i +next i + +print binarySearch(80,30,90) + +wait + +FUNCTION binarySearch(val, lo, hi) + IF hi < lo THEN + binarySearch = 0 + ELSE + middle = int((hi + lo) / 2):print middle + if val < theArray(middle) then binarySearch = binarySearch(val, lo, middle-1) + if val > theArray(middle) then binarySearch = binarySearch(val, middle+1, hi) + if val = theArray(middle) then binarySearch = middle + END IF +END FUNCTION diff --git a/Task/Binary-search/Logo/binary-search.logo b/Task/Binary-search/Logo/binary-search.logo new file mode 100644 index 0000000000..111197b615 --- /dev/null +++ b/Task/Binary-search/Logo/binary-search.logo @@ -0,0 +1,7 @@ +to bsearch :value :a :lower :upper + if :upper < :lower [output []] + localmake "mid int (:lower + :upper) / 2 + if item :mid :a > :value [output bsearch :value :a :lower :mid-1] + if item :mid :a < :value [output bsearch :value :a :mid+1 :upper] + output :mid +end diff --git a/Task/Binary-search/M4/binary-search.m4 b/Task/Binary-search/M4/binary-search.m4 new file mode 100644 index 0000000000..0307132de6 --- /dev/null +++ b/Task/Binary-search/M4/binary-search.m4 @@ -0,0 +1,10 @@ +define(`notfound',`-1')dnl +define(`midsearch',`ifelse(defn($1[$4]),$2,$4, +`ifelse(eval(defn($1[$4])>$2),1,`binarysearch($1,$2,$3,decr($4))',`binarysearch($1,$2,incr($4),$5)')')')dnl +define(`binarysearch',`ifelse(eval($4<$3),1,notfound,`midsearch($1,$2,$3,eval(($3+$4)/2),$4)')')dnl +dnl +define(`setrange',`ifelse(`$3',`',$2,`define($1[$2],$3)`'setrange($1,incr($2),shift(shift(shift($@))))')')dnl +define(`asize',decr(setrange(`a',1,1,3,5,7,11,13,17,19,23,29)))dnl +dnl +binarysearch(`a',5,1,asize) +binarysearch(`a',8,1,asize) diff --git a/Task/Binary-search/MAXScript/binary-search-1.max b/Task/Binary-search/MAXScript/binary-search-1.max new file mode 100644 index 0000000000..d6f0642326 --- /dev/null +++ b/Task/Binary-search/MAXScript/binary-search-1.max @@ -0,0 +1,25 @@ +fn binarySearchIterative arr value = +( + lower = 1 + upper = arr.count + while lower <= upper do + ( + mid = (lower + upper) / 2 + if arr[mid] > value then + ( + upper = mid - 1 + ) + else if arr[mid] < value then + ( + lower = mid + 1 + ) + else + ( + return mid + ) + ) + -1 +) + +arr = #(1, 3, 4, 5, 6, 7, 8, 9, 10) +result = binarySearchIterative arr 6 diff --git a/Task/Binary-search/MAXScript/binary-search-2.max b/Task/Binary-search/MAXScript/binary-search-2.max new file mode 100644 index 0000000000..26bcdb630a --- /dev/null +++ b/Task/Binary-search/MAXScript/binary-search-2.max @@ -0,0 +1,30 @@ +fn binarySearchRecursive arr value lower upper = +( + if lower == upper then + ( + if arr[lower] == value then + ( + return lower + ) + else + ( + return -1 + ) + ) + mid = (lower + upper) / 2 + if arr[mid] > value then + ( + return binarySearchRecursive arr value lower (mid-1) + ) + else if arr[mid] < value then + ( + return binarySearchRecursive arr value (mid+1) upper + ) + else + ( + return mid + ) +) + +arr = #(1, 3, 4, 5, 6, 7, 8, 9, 10) +result = binarySearchRecursive arr 6 1 arr.count diff --git a/Task/Binary-search/Maple/binary-search-1.maple b/Task/Binary-search/Maple/binary-search-1.maple new file mode 100644 index 0000000000..047901a3ad --- /dev/null +++ b/Task/Binary-search/Maple/binary-search-1.maple @@ -0,0 +1,15 @@ +BinarySearch := proc( A, value, low, high ) + description "recursive binary search"; + if high < low then + FAIL + else + local mid := iquo( high + low, 2 ); + if A[ mid ] > value then + thisproc( A, value, low, mid - 1 ) + elif A[ mid ] < value then + thisproc( A, value, mid + 1, high ) + else + mid + end if + end if +end proc: diff --git a/Task/Binary-search/Maple/binary-search-2.maple b/Task/Binary-search/Maple/binary-search-2.maple new file mode 100644 index 0000000000..a58eb8ecf1 --- /dev/null +++ b/Task/Binary-search/Maple/binary-search-2.maple @@ -0,0 +1,17 @@ +BinarySearch := proc( A, value ) + description "iterative binary search"; + local low, high; + + low, high := ( lowerbound, upperbound )( A ); + while low <= high do + local mid := iquo( low + high, 2 ); + if A[ mid ] > value then + high := mid - 1 + elif A[ mid ] < value then + low := mid + 1 + else + return mid + end if + end do; + FAIL +end proc: diff --git a/Task/Binary-search/Maple/binary-search-3.maple b/Task/Binary-search/Maple/binary-search-3.maple new file mode 100644 index 0000000000..58927c806f --- /dev/null +++ b/Task/Binary-search/Maple/binary-search-3.maple @@ -0,0 +1,17 @@ +> N := 10: +> P := [seq]( ithprime( i ), i = 1 .. N ): +> BinarySearch( P, 12, 1, N ); # recursive version + FAIL + +> BinarySearch( P, 13, 1, N ); # recursive version + 6 + +> BinarySearch( Array( P ), 13, 1, N ); # make P into an array + 6 + +> PP := Array( -2 .. 7, P ): # check it works if the array is not 1-based. +> BinarySearch( PP, 13 ); # iterative version + 3 + +> PP[ 3 ]; + 13 diff --git a/Task/Binary-search/Mathematica/binary-search-1.mathematica b/Task/Binary-search/Mathematica/binary-search-1.mathematica new file mode 100644 index 0000000000..cbe24b4be1 --- /dev/null +++ b/Task/Binary-search/Mathematica/binary-search-1.mathematica @@ -0,0 +1,9 @@ +BinarySearchRecursive[x_List, val_, lo_, hi_] := + Module[{mid = lo + Round@((hi - lo)/2)}, + If[hi < lo, Return[-1]]; + Return[ + Which[x[[mid]] > val, BinarySearchRecursive[x, val, lo, mid - 1], + x[[mid]] < val, BinarySearchRecursive[x, val, mid + 1, hi], + True, mid] + ]; + ] diff --git a/Task/Binary-search/Mathematica/binary-search-2.mathematica b/Task/Binary-search/Mathematica/binary-search-2.mathematica new file mode 100644 index 0000000000..a702abb515 --- /dev/null +++ b/Task/Binary-search/Mathematica/binary-search-2.mathematica @@ -0,0 +1,10 @@ +BinarySearch[x_List, val_] := Module[{lo = 1, hi = Length@x, mid}, + While[lo <= hi, + mid = lo + Round@((hi - lo)/2); + Which[x[[mid]] > val, hi = mid - 1, + x[[mid]] < val, lo = mid + 1, + True, Return[mid] + ]; + ]; + Return[-1]; + ] diff --git a/Task/Binary-search/Maxima/binary-search.maxima b/Task/Binary-search/Maxima/binary-search.maxima new file mode 100644 index 0000000000..5077c0b4ff --- /dev/null +++ b/Task/Binary-search/Maxima/binary-search.maxima @@ -0,0 +1,20 @@ +find(L, n) := block([i: 1, j: length(L), k, p], + if n < L[i] or n > L[j] then 0 else ( + while j - i > 0 do ( + k: quotient(i + j, 2), + p: L[k], + if n < p then j: k - 1 elseif n > p then i: k + 1 else i: j: k + ), + if n = L[i] then i else 0 + ) +)$ + +".."(a, b) := if a < b then makelist(i, i, a, b) else makelist(i, i, a, b, -1)$ +infix("..")$ + +a: sublist(1 .. 1000, primep)$ + +find(a, 27); +0 +find(a, 421); +82 diff --git a/Task/Binary-strings/Factor/binary-strings-1.factor b/Task/Binary-strings/Factor/binary-strings-1.factor new file mode 100644 index 0000000000..feb1923c98 --- /dev/null +++ b/Task/Binary-strings/Factor/binary-strings-1.factor @@ -0,0 +1 @@ +"Hello, byte-array!" utf8 encode . diff --git a/Task/Binary-strings/Factor/binary-strings-2.factor b/Task/Binary-strings/Factor/binary-strings-2.factor new file mode 100644 index 0000000000..4710103e11 --- /dev/null +++ b/Task/Binary-strings/Factor/binary-strings-2.factor @@ -0,0 +1 @@ +B{ 147 250 150 123 } shift-jis decode . diff --git a/Task/Binary-strings/Icon/binary-strings-1.icon b/Task/Binary-strings/Icon/binary-strings-1.icon new file mode 100644 index 0000000000..a7df2a4e61 --- /dev/null +++ b/Task/Binary-strings/Icon/binary-strings-1.icon @@ -0,0 +1,14 @@ +s := "\x00" # strings can contain any value, even nulls +s := "abc" # create a string +s := &null # destroy a string (well sbsnfon it for garbage collection) +v := s # assignment +s == t # expression s equals t +s << t # expression s less than t +s <<= t # expression s less than or equal to t +v := s # strings are immutable, no copying or cloning are needed +s == "" # equal empty string +*s = 0 # string length is zero +s ||:= "a" # append a byte "a" to s via concatenation +t := s[2+:3] # t is set to position 2 for 3 characters +s := replace(s,s2,s3) # IPL replace function +s := s1 || s2 # concatenation (joining) of strings diff --git a/Task/Binary-strings/Icon/binary-strings-2.icon b/Task/Binary-strings/Icon/binary-strings-2.icon new file mode 100644 index 0000000000..e3febbd622 --- /dev/null +++ b/Task/Binary-strings/Icon/binary-strings-2.icon @@ -0,0 +1,16 @@ +procedure replace(s1, s2, s3) #: string replacement + local result, i + + result := "" + i := *s2 + if i = 0 then fail # would loop on empty string + + s1 ? { + while result ||:= tab(find(s2)) do { + result ||:= s3 + move(i) + } + return result || tab(0) + } + +end diff --git a/Task/Binary-strings/J/binary-strings-1.j b/Task/Binary-strings/J/binary-strings-1.j new file mode 100644 index 0000000000..2cf9eff1ad --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-1.j @@ -0,0 +1 @@ + name=: '' diff --git a/Task/Binary-strings/J/binary-strings-10.j b/Task/Binary-strings/J/binary-strings-10.j new file mode 100644 index 0000000000..920fe6ff0c --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-10.j @@ -0,0 +1 @@ + 'string1','string2' diff --git a/Task/Binary-strings/J/binary-strings-11.j b/Task/Binary-strings/J/binary-strings-11.j new file mode 100644 index 0000000000..ebb4d15b6b --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-11.j @@ -0,0 +1 @@ + n{a. diff --git a/Task/Binary-strings/J/binary-strings-12.j b/Task/Binary-strings/J/binary-strings-12.j new file mode 100644 index 0000000000..17de57e58c --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-12.j @@ -0,0 +1 @@ +1 0 255{a. diff --git a/Task/Binary-strings/J/binary-strings-2.j b/Task/Binary-strings/J/binary-strings-2.j new file mode 100644 index 0000000000..0b409b1194 --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-2.j @@ -0,0 +1 @@ + name=: 0 diff --git a/Task/Binary-strings/J/binary-strings-3.j b/Task/Binary-strings/J/binary-strings-3.j new file mode 100644 index 0000000000..64a963be69 --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-3.j @@ -0,0 +1 @@ + name=: 'value' diff --git a/Task/Binary-strings/J/binary-strings-4.j b/Task/Binary-strings/J/binary-strings-4.j new file mode 100644 index 0000000000..09c0411dd0 --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-4.j @@ -0,0 +1 @@ + name1 -: name2 diff --git a/Task/Binary-strings/J/binary-strings-5.j b/Task/Binary-strings/J/binary-strings-5.j new file mode 100644 index 0000000000..1f067bf642 --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-5.j @@ -0,0 +1,2 @@ + name1= 'example' + name2= name1 diff --git a/Task/Binary-strings/J/binary-strings-6.j b/Task/Binary-strings/J/binary-strings-6.j new file mode 100644 index 0000000000..d505f8f30c --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-6.j @@ -0,0 +1 @@ + 0=#string diff --git a/Task/Binary-strings/J/binary-strings-7.j b/Task/Binary-strings/J/binary-strings-7.j new file mode 100644 index 0000000000..bdf506b37c --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-7.j @@ -0,0 +1,3 @@ + string=: 'example' + byte=: DEL + string=: string,byte diff --git a/Task/Binary-strings/J/binary-strings-8.j b/Task/Binary-strings/J/binary-strings-8.j new file mode 100644 index 0000000000..2d96c64e7d --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-8.j @@ -0,0 +1 @@ + 3{.5}.'The quick brown fox runs...' diff --git a/Task/Binary-strings/J/binary-strings-9.j b/Task/Binary-strings/J/binary-strings-9.j new file mode 100644 index 0000000000..fcb5c7ec59 --- /dev/null +++ b/Task/Binary-strings/J/binary-strings-9.j @@ -0,0 +1,2 @@ +require 'strings' +'The quick brown fox runs...' rplc ' ';' !!! ' diff --git a/Task/Binary-strings/Liberty-BASIC/binary-strings.liberty b/Task/Binary-strings/Liberty-BASIC/binary-strings.liberty new file mode 100644 index 0000000000..9973ad7efb --- /dev/null +++ b/Task/Binary-strings/Liberty-BASIC/binary-strings.liberty @@ -0,0 +1,33 @@ +'string creation +s$ = "Hello, world!" + +'string destruction - not needed because of garbage collection +s$ = "" + +'string comparison +s$ = "Hello, world!" +If s$ = "Hello, world!" then print "Equal Strings" + +'string copying +a$ = s$ + +'check If empty +If s$ = "" then print "Empty String" + +'append a byte +s$ = s$ + Chr$(33) + +'extract a substring +a$ = Mid$(s$, 1, 5) + +'replace bytes +a$ = "Hello, world!" +for i = 1 to len(a$) + if mid$(a$,i,1)="l" then + a$=left$(a$,i-1)+"L"+mid$(a$,i+1) + end if +next +print a$ + +'join strings +s$ = "Good" + "bye" + " for now." diff --git a/Task/Binary-strings/Mathematica/binary-strings.mathematica b/Task/Binary-strings/Mathematica/binary-strings.mathematica new file mode 100644 index 0000000000..9f39cf71f6 --- /dev/null +++ b/Task/Binary-strings/Mathematica/binary-strings.mathematica @@ -0,0 +1,19 @@ +(* String creation and destruction *) BinaryString = {}; BinaryString = . ; +(* String assignment *) BinaryString1 = {12,56,82,65} , BinaryString2 = {83,12,56,65} +-> {12,56,82,65} +-> {83,12,56,65} +(* String comparison *) BinaryString1 === BinaryString2 +-> False +(* String cloning and copying *) BinaryString3 = BinaryString1 +-> {12,56,82,65} +(* Check if a string is empty *) BinaryString3 === {} +-> False +(* Append a byte to a string *) AppendTo[BinaryString3, 22] +-> {12,56,82,65,22} +(* Extract a substring from a string *) Take[BinaryString3, {2, 5}] +-> {56,82,65,22} +(* Replace every occurrence of a byte (or a string) in a string with another string *) +BinaryString3 /. {22 -> Sequence[33, 44]} +-> {12,56,82,65,33,44} +(* Join strings *) BinaryString4 = Join[BinaryString1 , BinaryString2] +-> {12,56,82,65,83,12,56,65} diff --git a/Task/Bitmap-B-zier-curves-Cubic/Factor/bitmap-b-zier-curves-cubic.factor b/Task/Bitmap-B-zier-curves-Cubic/Factor/bitmap-b-zier-curves-cubic.factor new file mode 100644 index 0000000000..f44ccbcfe4 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Factor/bitmap-b-zier-curves-cubic.factor @@ -0,0 +1,25 @@ +USING: arrays kernel locals math math.functions + rosettacode.raster.storage sequences ; +IN: rosettacode.raster.line + +! this gives a function +:: (cubic-bezier) ( P0 P1 P2 P3 -- bezier ) + [ :> x + 1 x - 3 ^ P0 n*v + 1 x - sq 3 * x * P1 n*v + 1 x - 3 * x sq * P2 n*v + x 3 ^ P3 n*v + v+ v+ v+ ] ; inline +! gives an interval of x from 0 to 1 to map the bezier function +: t-interval ( x -- interval ) + [ iota ] keep 1 - [ / ] curry map ; +! turns a list of points into the list of lines between them +: points-to-lines ( seq -- seq ) + dup rest [ 2array ] 2map ; +: draw-lines ( {R,G,B} points image -- ) + [ [ first2 ] dip draw-line ] curry with each ; +:: bezier-lines ( {R,G,B} P0 P1 P2 P3 image -- ) + ! 100 is an arbitrary value.. could be given as a parameter.. + 100 t-interval P0 P1 P2 P3 (cubic-bezier) map + points-to-lines + {R,G,B} swap image draw-lines ; diff --git a/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-1.j b/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-1.j new file mode 100644 index 0000000000..05e51d8ae5 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-1.j @@ -0,0 +1,21 @@ +require 'numeric' + +bik=: 2 : '((*&(u!v))@(^&u * ^&(v-u)@-.))' +basiscoeffs=: <: 4 : 'x bik y t. i.>:y'"0~ i. +linearcomb=: basiscoeffs@#@[ +evalBernstein=: ([ +/ .* linearcomb) p. ] NB. evaluate Bernstein Polynomial (general) + +NB.*getBezierPoints v Returns points for bezier curve given control points (y) +NB. eg: getBezierPoints controlpoints +NB. y is: y0 x0, y1 x1, y2 x2 ... +getBezierPoints=: monad define + ctrlpts=. (/: {:"1) _2]\ y NB. sort ctrlpts for increasing x + xvals=. ({: ,~ {. + +:@:i.@<.@-:@-~/) ({:"1) 0 _1{ctrlpts + tvals=. ((] - {.) % ({: - {.)) xvals + xvals ,.~ ({."1 ctrlpts) evalBernstein tvals +) + +NB.*drawBezier v Draws bezier curve defined by (x) on image (y) +NB. eg: (42 40 10 30 186 269 26 187;255 0 0) drawBezier myimg +NB. x is: 2-item list of boxed (controlpoints) ; (color) +drawBezier=: (1&{:: ;~ 2 ]\ [: roundint@getBezierPoints"1 (0&{::))@[ drawLines ] diff --git a/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-2.j b/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-2.j new file mode 100644 index 0000000000..96673198c7 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/J/bitmap-b-zier-curves-cubic-2.j @@ -0,0 +1,5 @@ +myimg=: 0 0 255 makeRGB 300 300 +]randomctrlpts=: ,3 2 ?@$ }:$ myimg NB. 3 control points - quadratic +]randomctrlpts=: ,4 2 ?@$ }:$ myimg NB. 4 control points - cubic +myimg=: ((2 ,.~ _2]\randomctrlpts);255 0 255) drawCircles myimg NB. draw control points +viewRGB (randomctrlpts; 255 255 0) drawBezier myimg NB. display image with bezier line diff --git a/Task/Bitmap-B-zier-curves-Cubic/Mathematica/bitmap-b-zier-curves-cubic.mathematica b/Task/Bitmap-B-zier-curves-Cubic/Mathematica/bitmap-b-zier-curves-cubic.mathematica new file mode 100644 index 0000000000..f3e76dbb45 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Cubic/Mathematica/bitmap-b-zier-curves-cubic.mathematica @@ -0,0 +1,2 @@ +points= {{0, 0}, {1, 1}, {2, -1}, {3, 0}}; +Graphics[{BSplineCurve[points], Green, Line[points], Red, Point[points]}] diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Factor/bitmap-b-zier-curves-quadratic.factor b/Task/Bitmap-B-zier-curves-Quadratic/Factor/bitmap-b-zier-curves-quadratic.factor new file mode 100644 index 0000000000..ed75352884 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Factor/bitmap-b-zier-curves-quadratic.factor @@ -0,0 +1,23 @@ +USING: arrays kernel locals math math.functions + rosettacode.raster.storage sequences ; +IN: rosettacode.raster.line + +! This gives a function +:: (quadratic-bezier) ( P0 P1 P2 -- bezier ) + [ :> x + 1 x - sq P0 n*v + 2 1 x - x * * P1 n*v + x sq P2 n*v + v+ v+ ] ; inline + +! Same code from the cubic bezier task +: t-interval ( x -- interval ) + [ iota ] keep 1 - [ / ] curry map ; +: points-to-lines ( seq -- seq ) + dup rest [ 2array ] 2map ; +: draw-lines ( {R,G,B} points image -- ) + [ [ first2 ] dip draw-line ] curry with each ; +:: bezier-lines ( {R,G,B} P0 P1 P2 image -- ) + 100 t-interval P0 P1 P2 (quadratic-bezier) map + points-to-lines + {R,G,B} swap image draw-lines ; diff --git a/Task/Bitmap-B-zier-curves-Quadratic/Mathematica/bitmap-b-zier-curves-quadratic.mathematica b/Task/Bitmap-B-zier-curves-Quadratic/Mathematica/bitmap-b-zier-curves-quadratic.mathematica new file mode 100644 index 0000000000..7561cfebf6 --- /dev/null +++ b/Task/Bitmap-B-zier-curves-Quadratic/Mathematica/bitmap-b-zier-curves-quadratic.mathematica @@ -0,0 +1,2 @@ +pts = {{0, 0}, {1, -1}, {2, 1}}; +Graphics[{BSplineCurve[pts], Green, Line[pts], Red, Point[pts]}] diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Factor/bitmap-bresenhams-line-algorithm.factor b/Task/Bitmap-Bresenhams-line-algorithm/Factor/bitmap-bresenhams-line-algorithm.factor new file mode 100644 index 0000000000..86c977fefc --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Factor/bitmap-bresenhams-line-algorithm.factor @@ -0,0 +1,37 @@ +USING: accessors arrays kernel locals math math.functions +math.ranges math.vectors rosettacode.raster.display +rosettacode.raster.storage sequences ui.gadgets ; +IN: rosettacode.raster.line + +:: line-points ( pt1 pt2 -- points ) + pt1 first2 :> y0! :> x0! + pt2 first2 :> y1! :> x1! + y1 y0 - abs x1 x0 - abs > :> steep + steep [ + y0 x0 y0! x0! + y1 x1 y1! x1! + ] when + x0 x1 > [ + x0 x1 x0! x1! + y0 y1 y0! y1! + ] when + x1 x0 - :> deltax + y1 y0 - abs :> deltay + 0 :> current-error! + deltay deltax / abs :> deltaerr + 0 :> ystep! + y0 :> y! + y0 y1 < [ 1 ystep! ] [ -1 ystep! ] if + x0 x1 1 [ + y steep [ swap ] when 2array + current-error deltaerr + current-error! + current-error 0.5 >= [ + ystep y + y! + current-error 1 - current-error! + ] when + ] { } map-as ; + +! Needs rosettacode.raster.storage for the set-pixel function and to create the image +: draw-line ( {R,G,B} pt1 pt2 image -- ) + [ line-points ] dip + [ set-pixel ] curry with each ; diff --git a/Task/Bitmap-Bresenhams-line-algorithm/J/bitmap-bresenhams-line-algorithm-1.j b/Task/Bitmap-Bresenhams-line-algorithm/J/bitmap-bresenhams-line-algorithm-1.j new file mode 100644 index 0000000000..cac6b93173 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/J/bitmap-bresenhams-line-algorithm-1.j @@ -0,0 +1,16 @@ +thru=: <./ + -~ i.@+ _1 ^ > NB. integers from x through y + +NB.*getBresenhamLine v Returns points for a line given start and end points +NB. y is: y0 x0 ,: y1 x1 +getBresenhamLine=: monad define + steep=. ([: (abs (end.x - start.x)) + + if steep then + ( + swap start.x start.y + swap end.x end.y + ) + + if start.x > end.x then + ( + swap start.x end.x + swap start.y end.y + ) + + local deltaX = end.x - start.x + local deltaY = abs (end.y - start.y) + local error = deltaX / 2.0 + local yStep = -1 + local y = start.y + + if start.y < end.y then + ( + yStep = 1 + ) + + for x in start.x to end.x do + ( + plot img [x, y] steep col + error -= deltaY + if error < 0 then + ( + y += yStep + error += deltaX + ) + ) + img +) + +myBitmap = bitmap 512 512 color:(color 0 0 0) +myBitmap = drawLine myBitmap [0, 511] [511, 0] #((color 255 255 255)) +display myBitmap diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Maple/bitmap-bresenhams-line-algorithm.maple b/Task/Bitmap-Bresenhams-line-algorithm/Maple/bitmap-bresenhams-line-algorithm.maple new file mode 100644 index 0000000000..0dd7c22112 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Maple/bitmap-bresenhams-line-algorithm.maple @@ -0,0 +1,36 @@ +SegmentBresenham := proc (img, x0, y0, x1, y1) + local deltax, deltay, x, y, ystep, steep, err, img2, x02, y02, x12, y12; + x02, x12, y02, y12 := y0, y1, x0, x1; + steep := abs(x12 - x02) < abs(y12 - y02); + img2 := copy(img); + if steep then + x02, y02 := y02, x02; + x12, y12 := y12, x12; + end if; + if x12 < x02 then + x02, x12 := x12, x02; + y02, y12 := y12, y02; + end if; + deltax := x12 - x02; + deltay := abs(y12 - y02); + err := deltax / 2; + y := y02; + if y02 < y12 then + ystep := 1 + else + ystep := -1 + end if; + for x from x02 to x12 do + if steep then + img2[y, x] := 0 + else + img2[x, y] := 0 + end if; + err := err - deltay; + if err < 0 then + y := y + ystep; + err := err + deltax + end if; + end do; + return img2; +end proc: diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Mathematica/bitmap-bresenhams-line-algorithm.mathematica b/Task/Bitmap-Bresenhams-line-algorithm/Mathematica/bitmap-bresenhams-line-algorithm.mathematica new file mode 100644 index 0000000000..45acb3c039 --- /dev/null +++ b/Task/Bitmap-Bresenhams-line-algorithm/Mathematica/bitmap-bresenhams-line-algorithm.mathematica @@ -0,0 +1 @@ +Rasterize[ Style[Graphics[Line[{{0, 0}, {20, 10}}]], Antialiasing -> False]] diff --git a/Task/Bitmap-Flood-fill/HicEst/bitmap-flood-fill.hicest b/Task/Bitmap-Flood-fill/HicEst/bitmap-flood-fill.hicest new file mode 100644 index 0000000000..ebe5b537be --- /dev/null +++ b/Task/Bitmap-Flood-fill/HicEst/bitmap-flood-fill.hicest @@ -0,0 +1,8 @@ +WINDOW(WINdowhandle=wh, BaCkcolor=0, TItle="Rosetta test image") + +WRITE(WIN=wh, DeCoRation="EL=14, BC=14") ! color 14 == bright yellow + +RGB(128, 100, 0, 25) ! define color nr 25 as 128/255 red, 100/255 green, 0 blue +WRITE(WIN=wh, DeCoRation="L=1/4, R=1/2, T=1/4, B=1/2, EL=25, BC=25") + +WINDOW(Kill=wh) diff --git a/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-1.j b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-1.j new file mode 100644 index 0000000000..59463165bd --- /dev/null +++ b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-1.j @@ -0,0 +1,10 @@ +NB. finds and labels contiguous areas with the same numbers +NB. ref: http://www.jsoftware.com/pipermail/general/2005-August/023886.html +findcontig=: (|."1@|:@:>. (* * 1&(|.!.0)))^:4^:_@(* >:@i.@$) + +NB.*getFloodpoints v Returns points to fill given starting point (x) and image (y) +getFloodpoints=: [: 4&$.@$. [ (] = getPixels) [: findcontig ] -:"1 getPixels + +NB.*floodFill v Floods area, defined by point and color (x), of image (y) +NB. x is: 2-item list of (y x) ; (color) +floodFill=: (1&({::)@[ ;~ 0&({::)@[ getFloodpoints ]) setPixels ] diff --git a/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-2.j b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-2.j new file mode 100644 index 0000000000..cfb69c60d0 --- /dev/null +++ b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-2.j @@ -0,0 +1,9 @@ +'white blue yellow black orange red'=: 255 255 255,0 0 255,255 255 0,0 0 0,255 165 0,:255 0 0 +myimg=: white makeRGB 50 70 +lines=: (_2]\^:2) 0 0 25 0 , 25 0 25 35 , 25 35 0 35 , 0 35 0 0 +myimg=: (lines;blue) drawLines myimg +myimg=: (3 3; yellow) floodFill myimg +myimg=: ((35 25 24 ,: 35 25 10);black) drawCircles myimg +myimg=: (5 34;orange) floodFill myimg +myimg=: (5 36;red) floodFill myimg +viewRGB myimg diff --git a/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-3.j b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-3.j new file mode 100644 index 0000000000..8cbbfbfc4b --- /dev/null +++ b/Task/Bitmap-Flood-fill/J/bitmap-flood-fill-3.j @@ -0,0 +1,7 @@ +NB. ref: http://www.jsoftware.com/pipermail/general/2005-August/024174.html +eq=:[:}:"1 [:($$[:([:+/\1:,}:~:}.),) ,&_"1 NB. equal numbers for atoms of y connected in first direction +eq_nd=: i.@#@$(<"0@[([:, |:^:_1"0 _)&> [:EQ&.> <@|:"0 _)] NB. n-dimensional eq, gives an #@$,*/@$ shaped matrix +repl=: (i.~{.){ {:@] NB. replaces x by applying replace table y +cnnct=: [: |:@({."1<.//.]) [: ; <@(,.<./)/.~ + +findcontig_nd=: 3 : '($y)${. ([:({.,~}:) ([ repl cnnct)/\.)^:([:+./@(~:/)2&{.)^:_ (,{.) eq_nd (i.~ ~.@,) y' diff --git a/Task/Bitmap-Flood-fill/Liberty-BASIC/bitmap-flood-fill.liberty b/Task/Bitmap-Flood-fill/Liberty-BASIC/bitmap-flood-fill.liberty new file mode 100644 index 0000000000..f6d7a41dcb --- /dev/null +++ b/Task/Bitmap-Flood-fill/Liberty-BASIC/bitmap-flood-fill.liberty @@ -0,0 +1,89 @@ +'This example requires the Windows API +NoMainWin +WindowWidth = 267.5 +WindowHeight = 292.5 +UpperLeftX=int((DisplayWidth-WindowWidth)/2) +UpperLeftY=int((DisplayHeight-WindowHeight)/2) + +Global hDC : hDC = GetDC(0) +Struct point, x As long, y As long +Struct RGB, Red As long, Green As long, Blue As long +Struct rect, left As long, top As long, right As long, bottom As long + +StyleBits #main.gbox, 0, _WS_BORDER, 0, 0 +GraphicBox #main.gbox, 2.5, 2.5, 253, 252 + +Open "Flood Fill - Click a Color" For Window As #main +Print #main, "TrapClose quit" +Print #main.gbox, "Down; Fill Black; Place 125 125; BackColor White; " _ + + "CircleFilled 115; Place 105 105; BackColor Black; CircleFilled 50; Flush" +Print #main.gbox, "When leftButtonUp gBoxClick" +Print #main.gbox, "Size 1" +Wait + + Sub quit handle$ + Call ReleaseDC 0, hDC + Close #main + End + End Sub + + + Sub gBoxClick handle$, MouseX, MouseY + result = GetCursorPos() + targetRGB = GetPixel(hDC, point.x.struct, point.y.struct) + ColorDialog "", replacementColor$ + If replacementColor$ = "" Then Exit Sub + Print #main.gbox, "Color " + Word$(replacementColor$, 1) + " " + Word$(replacementColor$, 2) + " " + Word$(replacementColor$, 3) + result = FloodFill(MouseX, MouseY, targetRGB) + Print #main.gbox, "DelSegment FloodFill" + Print #main.gbox, "GetBMP FloodFill 0 0 500 500; CLS; DrawBMP FloodFill 0 0; Flush FloodFill" + Notice "Complete!" + UnLoadBMP "FloodFill" + End Sub + + Sub ReleaseDC hWnd, hDC + CallDLL #user32,"ReleaseDC", hWnd As uLong, hDC As uLong, ret As Long + End Sub + + Function GetDC(hWnd) + CallDLL #user32, "GetDC", hWnd As uLong, GetDC As uLong + End Function + + Function GetCursorPos() + CallDLL #user32, "GetCursorPos", point As struct, GetCursorPos As uLong + End Function + + Function GetPixel(hDC, x, y) + CallDLL #gdi32, "GetPixel", hDC As uLong, x As long, y As long, GetPixel As long + End Function + + Function getLongRGB(RGB.Blue) + getLongRGB = (RGB.Blue * (256 * 256)) + End Function + + Function GetWindowRect(hWnd) + 'Get ClientRectangle + CallDLL #user32, "GetWindowRect", hWnd As ulong, rect As struct, GetWindowRect As ulong + End Function + + Function FloodFill(mouseXX, mouseYY, targetColor) + Scan + result = GetWindowRect(Hwnd(#main.gbox)) + X = Int(mouseXX + rect.left.struct) + Y = Int(mouseYY + rect.top.struct) + If (GetPixel(hDC, X, Y) <> targetColor) Then + Exit Function + Else + CLS + Print str$(mouseXX) + " " + str$(mouseYY) + Print #main.gbox, "Set " + str$(mouseXX) + " " + str$(mouseYY) + End If + If (mouseXX > 0) And (mouseXX < 253) Then + result = FloodFill((mouseXX - 1), mouseYY, targetColor) + result = FloodFill((mouseXX + 1), mouseYY, targetColor) + End If + If (mouseYY > 0) And (mouseYY < 252) Then + result = FloodFill(mouseXX, (mouseYY + 1), targetColor) + result = FloodFill(mouseXX, (mouseYY - 1), targetColor) + End If + End Function diff --git a/Task/Bitmap-Flood-fill/Mathematica/bitmap-flood-fill.mathematica b/Task/Bitmap-Flood-fill/Mathematica/bitmap-flood-fill.mathematica new file mode 100644 index 0000000000..3d57098663 --- /dev/null +++ b/Task/Bitmap-Flood-fill/Mathematica/bitmap-flood-fill.mathematica @@ -0,0 +1,9 @@ +createMask[img_, pos_, tol_] := + RegionBinarize[img, Image[SparseArray[pos -> 1, ImageDimensions[img]]], tol]; +floodFill[img_Image, pos_List, tol_Real, color_List] := + ImageCompose[ + SetAlphaChannel[ImageSubtract[img, createMask[img, pos, tol]], 1], + SetAlphaChannel[Image[ConstantArray[color, ImageDimensions[img]]], + Dilation[createMask[img, pos, tol],1] + ] + ] diff --git a/Task/Bitmap-Histogram/J/bitmap-histogram-1.j b/Task/Bitmap-Histogram/J/bitmap-histogram-1.j new file mode 100644 index 0000000000..da86fc76a0 --- /dev/null +++ b/Task/Bitmap-Histogram/J/bitmap-histogram-1.j @@ -0,0 +1,3 @@ +getImgHist=: ([: /:~ ~. ,. #/.~)@, +medianHist=: {."1 {~ [: (+/\ I. -:@(+/)) {:"1 +toBW=: 255 * medianHist@getImgHist < toGray diff --git a/Task/Bitmap-Histogram/J/bitmap-histogram-2.j b/Task/Bitmap-Histogram/J/bitmap-histogram-2.j new file mode 100644 index 0000000000..43df88cc6e --- /dev/null +++ b/Task/Bitmap-Histogram/J/bitmap-histogram-2.j @@ -0,0 +1,3 @@ + require 'media/platimg' + 'Lenna100.ppm' writeppm~ 256#.inv readimg 'Lenna100.jpg' +786447 diff --git a/Task/Bitmap-Histogram/J/bitmap-histogram-3.j b/Task/Bitmap-Histogram/J/bitmap-histogram-3.j new file mode 100644 index 0000000000..09ddcff031 --- /dev/null +++ b/Task/Bitmap-Histogram/J/bitmap-histogram-3.j @@ -0,0 +1,2 @@ + 'Lenna100BW.ppm' writeppm~ toColor toBW readppm 'Lenna100.ppm' +786447 diff --git a/Task/Bitmap-Histogram/Mathematica/bitmap-histogram.mathematica b/Task/Bitmap-Histogram/Mathematica/bitmap-histogram.mathematica new file mode 100644 index 0000000000..174d9757ec --- /dev/null +++ b/Task/Bitmap-Histogram/Mathematica/bitmap-histogram.mathematica @@ -0,0 +1 @@ +ImageLevels[img]; diff --git a/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-1.j b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-1.j new file mode 100644 index 0000000000..561b38974b --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-1.j @@ -0,0 +1,24 @@ +NB.*getBresenhamCircle v Returns points for a circle given center and radius +NB. y is: y0 x0 radius +getBresenhamCircle=: monad define + 'y0 x0 radius'=. y + x=. 0 + y=. radius + f=. -. radius + pts=. 0 2$0 + while. x <: y do. + pts=. pts , y , x + if. f >: 0 do. + y=. <:y + f=. f + _2 * y + end. + x=. >:x + f =. f + >: 2 * x + end. + offsets=. (,|."1) (1 _1 {~ #: i.4) *"1"1 _ pts + ~.,/ (y0,x0) +"1 offsets +) + +NB.*drawCircles v Draws circle(s) (x) on image (y) +NB. x is: 2-item list of boxed (y0 x0 radius) ; (color) +drawCircles=: (1&{:: ;~ [: ; [: <@getBresenhamCircle"1 (0&{::))@[ setPixels ] diff --git a/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-2.j b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-2.j new file mode 100644 index 0000000000..808c667e6a --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-2.j @@ -0,0 +1,3 @@ +myimg=: 0 255 0 makeRGB 25 25 NB. 25 by 25 green image +myimg=: (12 12 12 ; 255 0 0) drawCircles myimg NB. draw red circle with radius 12 +viewRGB ((12 12 9 ,: 12 12 6) ; 0 0 255) drawCircles myimg NB. draw two more concentric circles diff --git a/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-3.j b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-3.j new file mode 100644 index 0000000000..8bdb1805d4 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/J/bitmap-midpoint-circle-algorithm-3.j @@ -0,0 +1,35 @@ +import java.awt.Color; + +public class MidPointCircle { + private BasicBitmapStorage image; + + public MidPointCircle(final int imageWidth, final int imageHeight) { + this.image = new BasicBitmapStorage(imageWidth, imageHeight); + } + + private void drawCircle(final int centerX, final int centerY, final int radius) { + int d = (5 - r * 4)/4; + int x = 0; + int y = radius; + Color circleColor = Color.white; + + do { + image.setPixel(centerX + x, centerY + y, circleColor); + image.setPixel(centerX + x, centerY - y, circleColor); + image.setPixel(centerX - x, centerY + y, circleColor); + image.setPixel(centerX - x, centerY - y, circleColor); + image.setPixel(centerX + y, centerY + x, circleColor); + image.setPixel(centerX + y, centerY - x, circleColor); + image.setPixel(centerX - y, centerY + x, circleColor); + image.setPixel(centerX - y, centerY - x, circleColor); + if (d < 0) { + d += 2 * x + 1; + } else { + d += 2 * (x - y) + 1; + y--; + } + x++; + } while (x <= y); + + } +} diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-1.mathematica b/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-1.mathematica new file mode 100644 index 0000000000..ae98bc9522 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-1.mathematica @@ -0,0 +1,10 @@ +SetAttributes[drawcircle, HoldFirst]; +drawcircle[img_, {x0_, y0_}, r_, color_: White] := + Module[{f = 1 - r, ddfx = 1, ddfy = -2 r, x = 0, y = r, + pixels = {{0, r}, {0, -r}, {r, 0}, {-r, 0}}}, + While[x < y, + If[f >= 0, y--; ddfy += 2; f += ddfy]; + x++; ddfx += 2; f += ddfx; + pixels = Join[pixels, {{x, y}, {x, -y}, {-x, y}, {-x, -y}, + {y, x}, {y, -x}, {-y, x}, {-y, -x}}]]; + img = ReplacePixelValue[img, {x0, y0} + # -> color & /@ pixels]] diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-2.mathematica b/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-2.mathematica new file mode 100644 index 0000000000..65ee9d5244 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Mathematica/bitmap-midpoint-circle-algorithm-2.mathematica @@ -0,0 +1,2 @@ +img = ExampleData[{"TestImage", "Lena"}]; +drawcircle[img, {250, 250}, 100] diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-1.mod3 b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-1.mod3 new file mode 100644 index 0000000000..fb2eba24f9 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-1.mod3 @@ -0,0 +1,11 @@ +INTERFACE Circle; + +IMPORT Bitmap; + +PROCEDURE Draw( + img: Bitmap.T; + center: Bitmap.Point; + radius: CARDINAL; + color: Bitmap.Pixel); + +END Circle. diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-2.mod3 b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-2.mod3 new file mode 100644 index 0000000000..f28a134e43 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-2.mod3 @@ -0,0 +1,41 @@ +MODULE Circle; + +IMPORT Bitmap; + +PROCEDURE Draw( + img: Bitmap.T; + center: Bitmap.Point; + radius: CARDINAL; + color: Bitmap.Pixel) = + VAR f := 1 - radius; + ddfx := 0; + ddfy := - 2 * radius; + x := 0; + y := radius; + BEGIN + Bitmap.SetPixel(img, Bitmap.Point{center.x, center.y + radius}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x, center.y - radius}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x + radius, center.y}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x - radius, center.y}, color); + WHILE x < y DO + IF f >= 0 THEN + y := y - 1; + ddfy := ddfy + 2; + f := f + ddfy; + END; + x := x + 1; + ddfx := ddfx + 2; + f := f + ddfx + 1; + Bitmap.SetPixel(img, Bitmap.Point{center.x + x, center.y + y}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x - x, center.y + y}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x + x, center.y - y}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x - x, center.y - y}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x + y, center.y + x}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x - y, center.y + x}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x + y, center.y - x}, color); + Bitmap.SetPixel(img, Bitmap.Point{center.x - y, center.y - x}, color); + END; + END Draw; + +BEGIN +END Circle. diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-3.mod3 b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-3.mod3 new file mode 100644 index 0000000000..05d3184085 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-3.mod3 @@ -0,0 +1,12 @@ +MODULE Main; + +IMPORT Circle, Bitmap, PPM; + +VAR testpic: Bitmap.T; + +BEGIN + testpic := Bitmap.NewImage(32, 32); + Bitmap.Fill(testpic, Bitmap.White); + Circle.Draw(testpic, Bitmap.Point{16, 16}, 10, Bitmap.Black); + PPM.Create("testpic.ppm", testpic); +END Main. diff --git a/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-4.mod3 b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-4.mod3 new file mode 100644 index 0000000000..ab00f34686 --- /dev/null +++ b/Task/Bitmap-Midpoint-circle-algorithm/Modula-3/bitmap-midpoint-circle-algorithm-4.mod3 @@ -0,0 +1,27 @@ +let raster_circle ~img ~color ~c:(x0, y0) ~r = + let plot = put_pixel img color in + let x = 0 + and y = r + and m = 5 - 4 * r + in + let rec loop x y m = + plot (x0 + x) (y0 + y); + plot (x0 + y) (y0 + x); + plot (x0 - x) (y0 + y); + plot (x0 - y) (y0 + x); + plot (x0 + x) (y0 - y); + plot (x0 + y) (y0 - x); + plot (x0 - x) (y0 - y); + plot (x0 - y) (y0 - x); + let y, m = + if m > 0 + then (y - 1), (m - 8 * y) + else y, m + in + if x <= y then + let x = x + 1 in + let m = m + 8 * x + 4 in + loop x y m + in + loop x y m +;; diff --git a/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-1.j b/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-1.j new file mode 100644 index 0000000000..e04637b490 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-1.j @@ -0,0 +1,10 @@ +require 'files' + +readppm=: monad define + dat=. fread y NB. read from file + msk=. 1 ,~ (*. 3 >: +/\) (LF&=@}: *. '#'&~:@}.) dat NB. mark field ends + 't wbyh maxval dat'=. msk <;._2 dat NB. parse + 'wbyh maxval'=. 2 1([ {. [: _99&". (LF,' ')&charsub)&.> wbyh;maxval NB. convert to numeric + if. (_99 0 +./@e. wbyh,maxval) +. 'P6' -.@-: 2{.t do. _1 return. end. + (a. i. dat) makeRGB |.wbyh NB. convert to basic bitmap format +) diff --git a/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-2.j b/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-2.j new file mode 100644 index 0000000000..6409582834 --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/J/bitmap-read-a-ppm-file-2.j @@ -0,0 +1,3 @@ +myimg=: readppm jpath '~temp/myimg.ppm' +myimgGray=: toColor toGray myimg +myimgGray writeppm jpath '~temp/myimgGray.ppm' diff --git a/Task/Bitmap-Read-a-PPM-file/Mathematica/bitmap-read-a-ppm-file.mathematica b/Task/Bitmap-Read-a-PPM-file/Mathematica/bitmap-read-a-ppm-file.mathematica new file mode 100644 index 0000000000..40a8e6149c --- /dev/null +++ b/Task/Bitmap-Read-a-PPM-file/Mathematica/bitmap-read-a-ppm-file.mathematica @@ -0,0 +1 @@ +Import["file.ppm","PPM"] diff --git a/Task/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.gap b/Task/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.gap new file mode 100644 index 0000000000..0506cea8c6 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/GAP/bitmap-write-a-ppm-file.gap @@ -0,0 +1,51 @@ +# Dirty implementation +# Only P3 format, an image is a list of 3 matrices (r, g, b) +# Max color is always 255 +WriteImage := function(name, img) + local f, r, g, b, i, j, maxcolor, nrow, ncol, dim; + f := OutputTextFile(name, false); + r := img[1]; + g := img[2]; + b := img[3]; + dim := DimensionsMat(r); + nrow := dim[1]; + ncol := dim[2]; + maxcolor := 255; + WriteLine(f, "P3"); + WriteLine(f, Concatenation(String(ncol), " ", String(nrow), " ", String(maxcolor))); + for i in [1 .. nrow] do + for j in [1 .. ncol] do + WriteLine(f, Concatenation(String(r[i][j]), " ", String(g[i][j]), " ", String(b[i][j]))); + od; + od; + CloseStream(f); +end; + +PutPixel := function(img, i, j, color) + img[1][i][j] := color[1]; + img[2][i][j] := color[2]; + img[3][i][j] := color[3]; +end; + +GetPixel := function(img, i, j) + return [img[1][i][j], img[2][i][j], img[3][i][j]]; +end; + +NewImage := function(nrow, ncol, color) + local r, g, b; + r := color[1] + NullMat(nrow, ncol); + g := color[2] + NullMat(nrow, ncol); + b := color[3] + NullMat(nrow, ncol); + return [r, g, b]; +end; + +# Reproducing the example from Wikipedia +black := [ 0, 0, 0 ]; +g := NewImage(2, 3, black); +PutPixel(g, 1, 1, [255, 0, 0]); +PutPixel(g, 1, 2, [0, 255, 0]); +PutPixel(g, 1, 3, [0, 0, 255]); +PutPixel(g, 2, 1, [255, 255, 0]); +PutPixel(g, 2, 2, [255, 255, 255]); +PutPixel(g, 2, 3, [0, 0, 0]); +WriteImage("example.ppm", g); diff --git a/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-1.j b/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-1.j new file mode 100644 index 0000000000..d41ac6e5e9 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-1.j @@ -0,0 +1,7 @@ +require 'files' + +NB. ($x) is height, width, colors per pixel +writeppm=:dyad define + header=. 'P6',LF,(":1 0{$x),LF,'255',LF + (header,,x{a.) fwrite y +) diff --git a/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-2.j b/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-2.j new file mode 100644 index 0000000000..d7b33df89e --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/J/bitmap-write-a-ppm-file-2.j @@ -0,0 +1,4 @@ + NB. create 10 by 10 block of magenta pixels in top right quadrant of a 300 wide by 600 high green image + myimg=: ((145 + pixellist) ; 255 0 255) setPixels 0 255 0 makeRGB 600 200 + myimg writeppm jpath '~temp/myimg.ppm' +360015 diff --git a/Task/Bitmap-Write-a-PPM-file/Mathematica/bitmap-write-a-ppm-file.mathematica b/Task/Bitmap-Write-a-PPM-file/Mathematica/bitmap-write-a-ppm-file.mathematica new file mode 100644 index 0000000000..bc6c31dfae --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Mathematica/bitmap-write-a-ppm-file.mathematica @@ -0,0 +1 @@ +Export["file.ppm",image,"PPM"] diff --git a/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-1.mod3 b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-1.mod3 new file mode 100644 index 0000000000..048127b861 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-1.mod3 @@ -0,0 +1,7 @@ +INTERFACE PPM; + +IMPORT Bitmap, Pathname; + +PROCEDURE Create(imgfile: Pathname.T; img: Bitmap.T); + +END PPM. diff --git a/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-2.mod3 b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-2.mod3 new file mode 100644 index 0000000000..65389b44d4 --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-2.mod3 @@ -0,0 +1,30 @@ +MODULE PPM; + +IMPORT Bitmap, Wr, FileWr, Pathname; +FROM Fmt IMPORT F, Int; + +<*FATAL ANY*> + +VAR imgfilewr: FileWr.T; + +PROCEDURE Create(imgfile: Pathname.T; img: Bitmap.T) = + VAR height := LAST(img^); + width := LAST(img[0]); + color: Bitmap.Pixel; + BEGIN + imgfilewr := FileWr.Open(imgfile); + Wr.PutText(imgfilewr, F("P6\n%s %s\n255\n", Int(height + 1), Int(width + 1))); + FOR i := 0 TO height DO + FOR j := 0 TO width DO + color := img[i,j]; + Wr.PutChar(imgfilewr, VAL(color.R, CHAR)); + Wr.PutChar(imgfilewr, VAL(color.G, CHAR)); + Wr.PutChar(imgfilewr, VAL(color.B, CHAR)); + END; + END; + Wr.PutChar(imgfilewr, '\n'); + Wr.Flush(imgfilewr); + END Create; + +BEGIN +END PPM. diff --git a/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-3.mod3 b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-3.mod3 new file mode 100644 index 0000000000..2bfe07248e --- /dev/null +++ b/Task/Bitmap-Write-a-PPM-file/Modula-3/bitmap-write-a-ppm-file-3.mod3 @@ -0,0 +1,14 @@ +let output_ppm ~oc ~img:(_, r_channel, g_channel, b_channel) = + let width = Bigarray.Array2.dim1 r_channel + and height = Bigarray.Array2.dim2 r_channel in + Printf.fprintf oc "P6\n%d %d\n255\n" width height; + for y = 0 to pred height do + for x = 0 to pred width do + output_char oc (char_of_int r_channel.{x,y}); + output_char oc (char_of_int g_channel.{x,y}); + output_char oc (char_of_int b_channel.{x,y}); + done; + done; + output_char oc '\n'; + flush oc; +;; diff --git a/Task/Bitmap/Factor/bitmap.factor b/Task/Bitmap/Factor/bitmap.factor new file mode 100644 index 0000000000..a6be11f3ce --- /dev/null +++ b/Task/Bitmap/Factor/bitmap.factor @@ -0,0 +1,25 @@ +USING: arrays fry kernel math.matrices sequences ; +IN: rosettacode.raster.storage + +! Various utilities +: meach ( matrix quot -- ) [ each ] curry each ; inline +: meach-index ( matrix quot -- ) + [ swap 2array ] prepose + [ curry each-index ] curry each-index ; inline +: mmap ( matrix quot -- matrix' ) [ map ] curry map ; inline +: mmap! ( matrix quot -- matrix' ) [ map! ] curry map! ; inline +: mmap-index ( matrix quot -- matrix' ) + [ swap 2array ] prepose + [ curry map-index ] curry map-index ; inline + +: matrix-dim ( matrix -- i j ) [ length ] [ first length ] bi ; +: set-Mi,j ( elt {i,j} matrix -- ) [ first2 swap ] dip nth set-nth ; +: Mi,j ( {i,j} matrix -- elt ) [ first2 swap ] dip nth nth ; + +! The storage functions +: ( width height -- image ) + zero-matrix [ drop { 0 0 0 } ] mmap ; +: fill-image ( {R,G,B} image -- image ) + swap '[ drop _ ] mmap! ; +: set-pixel ( {R,G,B} {i,j} image -- ) set-Mi,j ; inline +: get-pixel ( {i,j} image -- pixel ) Mi,j ; inline diff --git a/Task/Bitmap/Icon/bitmap.icon b/Task/Bitmap/Icon/bitmap.icon new file mode 100644 index 0000000000..263a59bffb --- /dev/null +++ b/Task/Bitmap/Icon/bitmap.icon @@ -0,0 +1,15 @@ +procedure makebitmap(width,height) + return open("bitmap", "g", "canvas=hidden", + "size="||width||","||height) +end +procedure fillimage(w,color) + Fg(w,color) + FillRectangle(w) +end +procedure setpixel(w,x,y,color) + Fg(w,color) + DrawPixel(x,y) +end +procedure getpixel(w,x,y) + return Pixel(w,x,y) +end diff --git a/Task/Bitmap/J/bitmap-1.j b/Task/Bitmap/J/bitmap-1.j new file mode 100644 index 0000000000..244349c6a9 --- /dev/null +++ b/Task/Bitmap/J/bitmap-1.j @@ -0,0 +1,4 @@ +makeRGB=: 0&$: : (($,)~ ,&3) +fillRGB=: makeRGB }:@$ +setPixels=: (1&{::@[)`(<"1@(0&{::@[))`]} +getPixels=: <"1@[ { ] diff --git a/Task/Bitmap/J/bitmap-2.j b/Task/Bitmap/J/bitmap-2.j new file mode 100644 index 0000000000..de25a9f397 --- /dev/null +++ b/Task/Bitmap/J/bitmap-2.j @@ -0,0 +1,15 @@ + myimg=: makeRGB 5 8 NB. create a bitmap with height 5 and width 8 (black) + myimg=: 255 makeRGB 5 8 NB. create a white bitmap with height 5 and width 8 + myimg=: 0 255 0 makeRGB 5 8 NB. create a green bitmap with height 5 and width 8 + myimg=: 0 0 255 fillRGB myimg NB. fill myimg with blue + colors=: 0 255 {~ #: i.8 NB. black,blue,green,cyan,red,magenta,yellow,white + myimg=: colors fillRGB myimg NB. fill myimg with vertical stripes of colors + 2 4 getPixels myimg NB. get the pixel color from point (2, 4) +255 0 0 + + myimg=: (2 4 ; 255 255 255) setPixels myimg NB. set pixel at point (2, 4) to white + 2 4 getPixels myimg NB. get the pixel color from point (2, 4) +255 255 255 + + }:$ myimg NB. get height and width of the image +5 8 diff --git a/Task/Bitmap/J/bitmap-3.j b/Task/Bitmap/J/bitmap-3.j new file mode 100644 index 0000000000..96fb0c1333 --- /dev/null +++ b/Task/Bitmap/J/bitmap-3.j @@ -0,0 +1,7 @@ +pixellist=: ,"0/~ i. 10 NB. row and column indices for 10 by 10 block of pixels + +NB. create 10 by 10 block of magenta pixels in the middle of a 300 by 300 green image +myimg=: ((145 + pixellist) ; 255 0 255) setPixels 0 255 0 makeRGB 300 300 + +NB. get pixel color for 10x10 block offset from magenta block +subimg=: (140 + pixellist) getPixels myimg diff --git a/Task/Bitmap/J/bitmap-4.j b/Task/Bitmap/J/bitmap-4.j new file mode 100644 index 0000000000..855893b16b --- /dev/null +++ b/Task/Bitmap/J/bitmap-4.j @@ -0,0 +1,4 @@ +require 'viewmat' +viewRGB=: [: viewrgb 256&#. + +viewRGB myimg diff --git a/Task/Bitmap/KonsolScript/bitmap.konso b/Task/Bitmap/KonsolScript/bitmap.konso new file mode 100644 index 0000000000..ded4313572 --- /dev/null +++ b/Task/Bitmap/KonsolScript/bitmap.konso @@ -0,0 +1,13 @@ +function main() { + Var:Number shape; + + Image:New(50, 50, shape) + Draw:RectFill(0, 0, 50, 50, 0xFF0000, shape) //one to fill an image with a plain RED color + + Draw:Pixel(30, 30, 0x0000FF, shape) //set a given pixel at (30,30) with a BLUE color + + while (B1 == false) { + Image:Blit(10, 10, shape, screen) + Screen:Render() + } +} diff --git a/Task/Bitmap/MAXScript/bitmap-1.max b/Task/Bitmap/MAXScript/bitmap-1.max new file mode 100644 index 0000000000..cfb2559667 --- /dev/null +++ b/Task/Bitmap/MAXScript/bitmap-1.max @@ -0,0 +1 @@ +local myBitmap = bitmap 512 512 diff --git a/Task/Bitmap/MAXScript/bitmap-2.max b/Task/Bitmap/MAXScript/bitmap-2.max new file mode 100644 index 0000000000..93aa37ee59 --- /dev/null +++ b/Task/Bitmap/MAXScript/bitmap-2.max @@ -0,0 +1 @@ +local myBitmap = bitmap 512 512 color:(color 128 128 128) diff --git a/Task/Bitmap/MAXScript/bitmap-3.max b/Task/Bitmap/MAXScript/bitmap-3.max new file mode 100644 index 0000000000..f2c1f75c5b --- /dev/null +++ b/Task/Bitmap/MAXScript/bitmap-3.max @@ -0,0 +1 @@ +setPixels myBitmap [256, 256] #((color 255 255 255)) diff --git a/Task/Bitmap/MAXScript/bitmap-4.max b/Task/Bitmap/MAXScript/bitmap-4.max new file mode 100644 index 0000000000..6ead9d046f --- /dev/null +++ b/Task/Bitmap/MAXScript/bitmap-4.max @@ -0,0 +1 @@ +local myPixel = getPixels myBitmap [256, 256] 1 diff --git a/Task/Bitmap/Mathematica/bitmap-1.mathematica b/Task/Bitmap/Mathematica/bitmap-1.mathematica new file mode 100644 index 0000000000..4094414a26 --- /dev/null +++ b/Task/Bitmap/Mathematica/bitmap-1.mathematica @@ -0,0 +1,3 @@ +img = Image[ConstantArray[{1, 0, 0}, {1000, 1000}]]; +img = ReplacePart[img, {1, 1, 1} -> {0, 0, 1}]; +ImageValue[img, {1, 1}] diff --git a/Task/Bitmap/Mathematica/bitmap-2.mathematica b/Task/Bitmap/Mathematica/bitmap-2.mathematica new file mode 100644 index 0000000000..fff2af1753 --- /dev/null +++ b/Task/Bitmap/Mathematica/bitmap-2.mathematica @@ -0,0 +1,3 @@ +img = Image[ConstantArray[{1, 0, 0}, {1000, 1000}]]; +img = ReplacePixelValue[img, {1, 1} -> {0, 0, 1}]; +ImageValue[img, {1, 1}] diff --git a/Task/Bitmap/Modula-3/bitmap-1.mod3 b/Task/Bitmap/Modula-3/bitmap-1.mod3 new file mode 100644 index 0000000000..c94c60f747 --- /dev/null +++ b/Task/Bitmap/Modula-3/bitmap-1.mod3 @@ -0,0 +1,24 @@ +INTERFACE Bitmap; + +TYPE UByte = BITS 8 FOR [0 .. 16_FF]; + Pixel = RECORD R, G, B: UByte; END; + Point = RECORD x, y: UByte; END; + T = REF ARRAY OF ARRAY OF Pixel; + +CONST + Black = Pixel{0, 0, 0}; + White = Pixel{255, 255, 255}; + Red = Pixel{255, 0, 0}; + Green = Pixel{0, 255, 0}; + Blue = Pixel{0, 0, 255}; + Yellow = Pixel{255, 255, 0}; + +EXCEPTION BadImage; + BadColor; + +PROCEDURE NewImage(height, width: UByte): T RAISES {BadImage}; +PROCEDURE Fill(VAR pic: T; color: Pixel); +PROCEDURE GetPixel(VAR pic: T; point: Point): Pixel RAISES {BadColor}; +PROCEDURE SetPixel(VAR pic: T; point: Point; color: Pixel); + +END Bitmap. diff --git a/Task/Bitmap/Modula-3/bitmap-2.mod3 b/Task/Bitmap/Modula-3/bitmap-2.mod3 new file mode 100644 index 0000000000..d248a371b5 --- /dev/null +++ b/Task/Bitmap/Modula-3/bitmap-2.mod3 @@ -0,0 +1,48 @@ +MODULE Bitmap; + +PROCEDURE NewImage(height, width: UByte): T RAISES {BadImage} = + (* To make things easier, limit image size to also + be UByte (0 to 255), and to have equal dimensions. *) + BEGIN + IF height # width THEN + RAISE BadImage; + END; + RETURN NEW(T, height, width); + END NewImage; + +PROCEDURE Fill(VAR pic: T; color: Pixel) = + BEGIN + FOR i := FIRST(pic^) TO LAST(pic^) DO + FOR j := FIRST(pic[0]) TO LAST(pic[0]) DO + pic[i,j] := color; + END; + END; + END Fill; + +PROCEDURE GetPixel(VAR pic: T; point: Point): Pixel RAISES {BadColor} = + VAR pixel := pic[point.x, point.y]; + BEGIN + IF pixel = White THEN + RETURN White; + ELSIF pixel = Black THEN + RETURN Black; + ELSIF pixel = Red THEN + RETURN Red; + ELSIF pixel = Green THEN + RETURN Green; + ELSIF pixel = Blue THEN + RETURN Blue; + ELSIF pixel = Yellow THEN + RETURN Yellow; + ELSE + RAISE BadColor; + END; + END GetPixel; + +PROCEDURE SetPixel(VAR pic: T; point: Point; color: Pixel) = + BEGIN + pic[point.x, point.y] := color; + END SetPixel; + +BEGIN +END Bitmap. diff --git a/Task/Bitwise-IO/J/bitwise-io-1.j b/Task/Bitwise-IO/J/bitwise-io-1.j new file mode 100644 index 0000000000..503539b89c --- /dev/null +++ b/Task/Bitwise-IO/J/bitwise-io-1.j @@ -0,0 +1,2 @@ +bitReader =: a. {~ _7 #.\ ({.~ <.&.(%&7)@#) +bitWriter =: , @ ((7$2) & #: @ (a.&i.)), 0 $~ 8 | # diff --git a/Task/Bitwise-IO/J/bitwise-io-2.j b/Task/Bitwise-IO/J/bitwise-io-2.j new file mode 100644 index 0000000000..725533f6a7 --- /dev/null +++ b/Task/Bitwise-IO/J/bitwise-io-2.j @@ -0,0 +1,4 @@ +text=: 'This text is used to illustrate the Rosetta Code task about ''bit oriented IO''.' + + bitReader bitWriter text +This text is used to illustrate the Rosetta Code task about 'bit oriented IO'. diff --git a/Task/Bitwise-IO/J/bitwise-io-3.j b/Task/Bitwise-IO/J/bitwise-io-3.j new file mode 100644 index 0000000000..67593675f7 --- /dev/null +++ b/Task/Bitwise-IO/J/bitwise-io-3.j @@ -0,0 +1,2 @@ + # text +78 diff --git a/Task/Bitwise-IO/J/bitwise-io-4.j b/Task/Bitwise-IO/J/bitwise-io-4.j new file mode 100644 index 0000000000..75069957fd --- /dev/null +++ b/Task/Bitwise-IO/J/bitwise-io-4.j @@ -0,0 +1,2 @@ + %&8 # bitWriter text +69 diff --git a/Task/Bitwise-operations/FALSE/bitwise-operations.false b/Task/Bitwise-operations/FALSE/bitwise-operations.false new file mode 100644 index 0000000000..60eb178825 --- /dev/null +++ b/Task/Bitwise-operations/FALSE/bitwise-operations.false @@ -0,0 +1,6 @@ +10 3 +\$@$@$@$@\ { 3 copies } +"a & b = "&." +a | b = "|." +~a = "%~." +" diff --git a/Task/Bitwise-operations/Factor/bitwise-operations-1.factor b/Task/Bitwise-operations/Factor/bitwise-operations-1.factor new file mode 100644 index 0000000000..0552a501e1 --- /dev/null +++ b/Task/Bitwise-operations/Factor/bitwise-operations-1.factor @@ -0,0 +1,9 @@ +"a=" "b=" [ write readln string>number ] bi@ +{ + [ bitand "a AND b: " write . ] + [ bitor "a OR b: " write . ] + [ bitxor "a XOR b: " write . ] + [ drop bitnot "NOT a: " write . ] + [ abs shift "a asl b: " write . ] + [ neg shift "a asr b: " write . ] +} 2cleave diff --git a/Task/Bitwise-operations/Factor/bitwise-operations-2.factor b/Task/Bitwise-operations/Factor/bitwise-operations-2.factor new file mode 100644 index 0000000000..7b85c05e2a --- /dev/null +++ b/Task/Bitwise-operations/Factor/bitwise-operations-2.factor @@ -0,0 +1,8 @@ +a=255 +b=5 +a AND b: 5 +a OR b: 255 +a XOR b: 250 +NOT a: -256 +a asl b: 8160 +a asr b: 7 diff --git a/Task/Bitwise-operations/Groovy/bitwise-operations-1.groovy b/Task/Bitwise-operations/Groovy/bitwise-operations-1.groovy new file mode 100644 index 0000000000..c401b7b534 --- /dev/null +++ b/Task/Bitwise-operations/Groovy/bitwise-operations-1.groovy @@ -0,0 +1,11 @@ +def bitwise = { a, b -> + println """ +a & b = ${a} & ${b} = ${a & b} +a | b = ${a} | ${b} = ${a | b} +a ^ b = ${a} ^ ${b} = ${a ^ b} +~ a = ~ ${a} = ${~ a} +a << b = ${a} << ${b} = ${a << b} +a >> b = ${a} >> ${b} = ${a >> b} arithmetic (sign-preserving) shift +a >>> b = ${a} >>> ${b} = ${a >>> b} logical (zero-filling) shift +""" +} diff --git a/Task/Bitwise-operations/Groovy/bitwise-operations-2.groovy b/Task/Bitwise-operations/Groovy/bitwise-operations-2.groovy new file mode 100644 index 0000000000..284cb236c1 --- /dev/null +++ b/Task/Bitwise-operations/Groovy/bitwise-operations-2.groovy @@ -0,0 +1 @@ +bitwise(-15,3) diff --git a/Task/Bitwise-operations/HicEst/bitwise-operations.hicest b/Task/Bitwise-operations/HicEst/bitwise-operations.hicest new file mode 100644 index 0000000000..8df74498dc --- /dev/null +++ b/Task/Bitwise-operations/HicEst/bitwise-operations.hicest @@ -0,0 +1,4 @@ +i = IAND(k, j) +i = IOR( k, j) +i = IEOR(k, j) +i = NOT( k ) diff --git a/Task/Bitwise-operations/Icon/bitwise-operations.icon b/Task/Bitwise-operations/Icon/bitwise-operations.icon new file mode 100644 index 0000000000..4bcace1afa --- /dev/null +++ b/Task/Bitwise-operations/Icon/bitwise-operations.icon @@ -0,0 +1,21 @@ +procedure main() +bitdemo(255,2) +bitdemo(-15,3) +end + +procedure bitdemo(i,i2) + write() + demowrite("i",i) + demowrite("i2",i2) + demowrite("complement i",icom(i)) + demowrite("i or i2",ior(i,i2)) + demowrite("i and i2",iand(i,i2)) + demowrite("i xor i2",ixor(i,i2)) + demowrite("i shift " || i2,ishift(i,i2)) + demowrite("i shift -" || i2,ishift(i,-i2)) + return +end + +procedure demowrite(vs,v) +return write(vs, ": ", v, " = ", int2bit(v),"b") +end diff --git a/Task/Bitwise-operations/Inform-6/bitwise-operations.inf b/Task/Bitwise-operations/Inform-6/bitwise-operations.inf new file mode 100644 index 0000000000..b263032bed --- /dev/null +++ b/Task/Bitwise-operations/Inform-6/bitwise-operations.inf @@ -0,0 +1,15 @@ +[ bitwise a b temp; + print "a and b: ", a & b, "^"; + print "a or b: ", a | b, "^"; + print "not a: ", ~a, "^"; + @art_shift a b -> temp; + print "a << b (arithmetic): ", temp, "^"; + temp = -b; + @art_shift a temp -> temp; + print "a >> b (arithmetic): ", temp, "^"; + @log_shift a b -> temp; + print "a << b (logical): ", temp, "^"; + temp = -b; + @log_shift a temp -> temp; + print "a >> b (logical): ", temp, "^"; +]; diff --git a/Task/Bitwise-operations/J/bitwise-operations-1.j b/Task/Bitwise-operations/J/bitwise-operations-1.j new file mode 100644 index 0000000000..1bea4160e4 --- /dev/null +++ b/Task/Bitwise-operations/J/bitwise-operations-1.j @@ -0,0 +1,9 @@ +bAND=: 17 b. NB. 16+#.0 0 0 1 +bOR=: 23 b. NB. 16+#.0 1 1 1 +bXOR=: 22 b. NB. 16+#.0 1 1 0 +b1NOT=: 28 b. NB. 16+#.1 1 0 0 +bLshift=: 33 b.~ NB. see http://www.jsoftware.com/help/release/bdot.htm +bRshift=: 33 b.~ - +bRAshift=: 34 b.~ - +bLrot=: 32 b.~ +bRrot=: 32 b.~ - diff --git a/Task/Bitwise-operations/J/bitwise-operations-2.j b/Task/Bitwise-operations/J/bitwise-operations-2.j new file mode 100644 index 0000000000..f3a2a2bf1f --- /dev/null +++ b/Task/Bitwise-operations/J/bitwise-operations-2.j @@ -0,0 +1,4 @@ +bitwise=: 1 :0 +: + smoutput (((":x),"1' ',.(>u),.' '),"1":y),"1' => ',"1'.X'{~#:x u`:0 y +) diff --git a/Task/Bitwise-operations/J/bitwise-operations-3.j b/Task/Bitwise-operations/J/bitwise-operations-3.j new file mode 100644 index 0000000000..b4c247be5a --- /dev/null +++ b/Task/Bitwise-operations/J/bitwise-operations-3.j @@ -0,0 +1,10 @@ + 254 bAND`bOR`bXOR`b1NOT`bLshift`bRshift`bRAshift`bLrot`bRrot bitwise 3 +254 bAND 3 => ............................X. +254 bOR 3 => ......................XXXXXXXX +254 bXOR 3 => ......................XXXXXX.X +254 b1NOT 3 => XXXXXXXXXXXXXXXXXXXXXX.......X +254 bLshift 3 => ...................XXXXXXX.... +254 bRshift 3 => .........................XXXXX +254 bRAshift 3 => .........................XXXXX +254 bLrot 3 => ...................XXXXXXX.... +254 bRrot 3 => .........................XXXXX diff --git a/Task/Bitwise-operations/J/bitwise-operations-4.j b/Task/Bitwise-operations/J/bitwise-operations-4.j new file mode 100644 index 0000000000..75eaf55d7a --- /dev/null +++ b/Task/Bitwise-operations/J/bitwise-operations-4.j @@ -0,0 +1,2 @@ +bXOR/ 3333 5555 7777 9999 +8664 diff --git a/Task/Bitwise-operations/LLVM/bitwise-operations.llvm b/Task/Bitwise-operations/LLVM/bitwise-operations.llvm new file mode 100644 index 0000000000..a0ebcf1310 --- /dev/null +++ b/Task/Bitwise-operations/LLVM/bitwise-operations.llvm @@ -0,0 +1,60 @@ +; ModuleID = 'test.o' +;e means little endian +;p: { pointer size : pointer abi : preferred alignment for pointers } +;i same for integers +;v is for vectors +;f for floats +;a for aggregate types +;s for stack objects +;n: {size:size:size...}, best integer sizes +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +;this was compiled with mingw32; thus it must be linked to an ABI compatible c library +target triple = "i386-mingw32" + +@.str = private constant [13 x i8] c"a and b: %d\0A\00", align 1 ; <[13 x i8]*> [#uses=1] +@.str1 = private constant [12 x i8] c"a or b: %d\0A\00", align 1 ; <[12 x i8]*> [#uses=1] +@.str2 = private constant [13 x i8] c"a xor b: %d\0A\00", align 1 ; <[13 x i8]*> [#uses=1] +@.str3 = private constant [11 x i8] c"not a: %d\0A\00", align 1 ; <[11 x i8]*> [#uses=1] +@.str4 = private constant [12 x i8] c"a << n: %d\0A\00", align 1 ; <[12 x i8]*> [#uses=1] +@.str5 = private constant [12 x i8] c"a >> n: %d\0A\00", align 1 ; <[12 x i8]*> [#uses=1] +@.str6 = private constant [12 x i8] c"c >> b: %d\0A\00", align 1 ; <[12 x i8]*> [#uses=1] + +;A function that will do many bitwise opreations to two integer arguments, %a and %b +define void @bitwise(i32 %a, i32 %b) nounwind { +;entry block +entry: + ;Register to store (a & b) + %0 = and i32 %b, %a ; [#uses=1] + ;print the results + %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0), i32 %0) nounwind ; [#uses=0] + ;Register to store (a | b) + %2 = or i32 %b, %a ; [#uses=1] + ;print the results + %3 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32 %2) nounwind ; [#uses=0] + ;Register to store (a ^ b) + %4 = xor i32 %b, %a ; [#uses=1] + ;print the results + %5 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str2, i32 0, i32 0), i32 %4) nounwind ; [#uses=0] + ;Register to store (~a) + %not = xor i32 %a, -1 ; [#uses=1] + ;print the results + %6 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str3, i32 0, i32 0), i32 %not) nounwind ; [#uses=0] + ;Register to store (a << b) + %7 = shl i32 %a, %b ; [#uses=1] + ;print the results + %8 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str4, i32 0, i32 0), i32 %7) nounwind ; [#uses=0] + ;Register to store (a >> b) (a is signed) + %9 = ashr i32 %a, %b ; [#uses=1] + ;print the results + %10 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str5, i32 0, i32 0), i32 %9) nounwind ; [#uses=0] + ;Register to store (c >> b), where c is unsiged (eg. logical right shift) + %11 = lshr i32 %a, %b ; [#uses=1] + ;print the results + %12 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str6, i32 0, i32 0), i32 %11) nounwind ; [#uses=0] + + ;terminator instruction + ret void +} + +;Declare external fuctions +declare i32 @printf(i8* nocapture, ...) nounwind diff --git a/Task/Bitwise-operations/LSE64/bitwise-operations.lse64 b/Task/Bitwise-operations/LSE64/bitwise-operations.lse64 new file mode 100644 index 0000000000..12f0b98d52 --- /dev/null +++ b/Task/Bitwise-operations/LSE64/bitwise-operations.lse64 @@ -0,0 +1,11 @@ +over : 2 pick +2dup : over over + +bitwise : \ + " A=" ,t over ,h sp " B=" ,t dup ,h nl \ + " A and B=" ,t 2dup & ,h nl \ + " A or B=" ,t 2dup | ,h nl \ + " A xor B=" ,t over ^ ,h nl \ + " not A=" ,t ~ ,h nl + +\ a \ 7 bitwise # hex literals diff --git a/Task/Bitwise-operations/Liberty-BASIC/bitwise-operations.liberty b/Task/Bitwise-operations/Liberty-BASIC/bitwise-operations.liberty new file mode 100644 index 0000000000..254b28300b --- /dev/null +++ b/Task/Bitwise-operations/Liberty-BASIC/bitwise-operations.liberty @@ -0,0 +1,46 @@ +' bitwise operations on byte-sized variables + +v =int( 256 *rnd( 1)) + +s = 1 + +print "Shift ="; s; " place." +print +print "Number as dec. = "; v; " & as 8-bits byte = ", dec2Bin$( v) +print "NOT as dec. = "; bitInvert( v), dec2Bin$( bitInvert( v)) +print "Shifted left as dec. = "; shiftLeft( v, s), dec2Bin$( shiftLeft( v, s)) +print "Shifted right as dec. = "; shiftRight( v, s), dec2Bin$( shiftRight( v, s)) +print "Rotated left as dec. = "; rotateLeft( v, s), dec2Bin$( rotateLeft( v, s)) +print "Rotated right as dec. = "; rotateRight( v, s), dec2Bin$( rotateRight( v, s)) + +end + +function shiftLeft( b, n) + shiftLeft =( b *2^n) and 255 +end function + +function shiftRight( b, n) + shiftRight =int(b /2^n) +end function + +function rotateLeft( b, n) + rotateLeft = (( 2^n *b) mod 256) or ( b >127) +end function + +function rotateRight( b, n) + rotateRight = (128*( b and 1)) or int( b /2) +end function + +function bitInvert( b) + bitInvert =b xor 255 +end function + +function dec2Bin$( num) ' Given an integer decimal 0 <--> 255, returns binary equivalent as a string + n =num + dec2Bin$ ="" + while ( num >0) + dec2Bin$ =str$( num mod 2) +dec2Bin$ + num =int( num /2) + wend + dec2Bin$ =right$( "00000000" +dec2Bin$, 8) +end function diff --git a/Task/Bitwise-operations/Logo/bitwise-operations-1.logo b/Task/Bitwise-operations/Logo/bitwise-operations-1.logo new file mode 100644 index 0000000000..4c12099854 --- /dev/null +++ b/Task/Bitwise-operations/Logo/bitwise-operations-1.logo @@ -0,0 +1,11 @@ +to bitwise :a :b + (print [a and b:] BitAnd :a :b) + (print [a or b:] BitOr :a :b) + (print [a xor b:] BitXor :a :b) + (print [not a:] BitNot :a) + ; shifts are to the left if positive, to the right if negative + (print [a lshift b:] LShift :a :b) + (print [a lshift -b:] LShift :a minus :b) + (print [-a ashift -b:] AShift minus :a minus :b) +end +bitwise 255 5 diff --git a/Task/Bitwise-operations/Logo/bitwise-operations-2.logo b/Task/Bitwise-operations/Logo/bitwise-operations-2.logo new file mode 100644 index 0000000000..bc103389ba --- /dev/null +++ b/Task/Bitwise-operations/Logo/bitwise-operations-2.logo @@ -0,0 +1,7 @@ +a and b: 5 +a or b: 255 +a xor b: 250 +not a: -256 +a lshift b: 8160 +a lshift -b: 7 +-a ashift -b: -8 diff --git a/Task/Bitwise-operations/MAXScript/bitwise-operations.max b/Task/Bitwise-operations/MAXScript/bitwise-operations.max new file mode 100644 index 0000000000..1ad2cbb99c --- /dev/null +++ b/Task/Bitwise-operations/MAXScript/bitwise-operations.max @@ -0,0 +1,11 @@ +fn bitwise a b = +( + format "a and b: %\n" (bit.and a b) + format "a or b: %\n" (bit.or a b) + format "a xor b: %\n" (bit.xor a b) + format "not a: %\n" (bit.not a) + format "Left shift a: %\n" (bit.shift a b) + format "Right shift a: %\n" (bit.shift a -b) +) + +bitwise 255 170 diff --git a/Task/Bitwise-operations/ML-I/bitwise-operations.ml b/Task/Bitwise-operations/ML-I/bitwise-operations.ml new file mode 100644 index 0000000000..79fb822cc2 --- /dev/null +++ b/Task/Bitwise-operations/ML-I/bitwise-operations.ml @@ -0,0 +1,15 @@ +MCSKIP "WITH" NL +"" Bitwise operations +"" assumes macros on input stream 1, terminal on stream 2 +MCSKIP MT,<> +MCINS %. +MCDEF SL SPACES NL AS +MCSKIP SL WITH * +MCSET S1=1 +*MCSET S10=2 diff --git a/Task/Bitwise-operations/Mathematica/bitwise-operations-1.mathematica b/Task/Bitwise-operations/Mathematica/bitwise-operations-1.mathematica new file mode 100644 index 0000000000..82d71a93b9 --- /dev/null +++ b/Task/Bitwise-operations/Mathematica/bitwise-operations-1.mathematica @@ -0,0 +1,18 @@ +(*and xor and or*) +BitAnd[integer1, integer2] +BitXor[integer1, integer2] +BitOr[integer1, integer2] + +(*logical not*) +BitNot[integer1] + +(*left and right shift*) +BitShiftLeft[integer1] +BitShiftRight[integer1] + +(*rotate digits left and right*) +FromDigits[RotateLeft[IntegerDigits[integer1, 2]], 2] +FromDigits[RotateRight[IntegerDigits[integer1, 2]], 2] + +(*right arithmetic shift*) +FromDigits[Prepend[Most[#], #[[1]]], 2] &[IntegerDigits[integer1, 2]] diff --git a/Task/Bitwise-operations/Mathematica/bitwise-operations-2.mathematica b/Task/Bitwise-operations/Mathematica/bitwise-operations-2.mathematica new file mode 100644 index 0000000000..7e9f7e7abe --- /dev/null +++ b/Task/Bitwise-operations/Mathematica/bitwise-operations-2.mathematica @@ -0,0 +1 @@ +BitXor[3333, 5555, 7777, 9999] diff --git a/Task/Bitwise-operations/Mathematica/bitwise-operations-3.mathematica b/Task/Bitwise-operations/Mathematica/bitwise-operations-3.mathematica new file mode 100644 index 0000000000..4a972457c2 --- /dev/null +++ b/Task/Bitwise-operations/Mathematica/bitwise-operations-3.mathematica @@ -0,0 +1 @@ +8664 diff --git a/Task/Bitwise-operations/Maxima/bitwise-operations.maxima b/Task/Bitwise-operations/Maxima/bitwise-operations.maxima new file mode 100644 index 0000000000..1dc4a8d5c8 --- /dev/null +++ b/Task/Bitwise-operations/Maxima/bitwise-operations.maxima @@ -0,0 +1,23 @@ +load(functs)$ + +a: 3661$ +b: 2541$ + +logor(a, b); +/* 4077 */ + +logand(a, b); +/* 2125 */ + +logxor(a, b); +/* 1952 */ + +/* NOT(x) is simply -x - 1 +-a - 1; +/* -3662 */ + +logor(a, -a - 1); +/* -1 */ + +logand(a, -a - 1); +/* 0 */ diff --git a/Task/Bitwise-operations/Modula-3/bitwise-operations.mod3 b/Task/Bitwise-operations/Modula-3/bitwise-operations.mod3 new file mode 100644 index 0000000000..9062038047 --- /dev/null +++ b/Task/Bitwise-operations/Modula-3/bitwise-operations.mod3 @@ -0,0 +1,22 @@ +MODULE Bitwise EXPORTS Main; + +IMPORT IO, Fmt, Word; + +VAR c: Word.T; + +PROCEDURE Bitwise(a, b: INTEGER) = + BEGIN + IO.Put("a AND b: " & Fmt.Int(Word.And(a, b)) & "\n"); + IO.Put("a OR b: " & Fmt.Int(Word.Or(a, b)) & "\n"); + IO.Put("a XOR b: " & Fmt.Int(Word.Xor(a, b)) & "\n"); + IO.Put("NOT a: " & Fmt.Int(Word.Not(a)) & "\n"); + c := a; + IO.Put("c LeftShift b: " & Fmt.Unsigned(Word.LeftShift(c, b)) & "\n"); + IO.Put("c RightShift b: " & Fmt.Unsigned(Word.RightShift(c, b)) & "\n"); + IO.Put("c LeftRotate b: " & Fmt.Unsigned(Word.LeftRotate(c, b)) & "\n"); + IO.Put("c RightRotate b: " & Fmt.Unsigned(Word.RightRotate(c, b)) & "\n"); + END Bitwise; + +BEGIN + Bitwise(255, 5); +END Bitwise. diff --git a/Task/Boolean-values/GAP/boolean-values.gap b/Task/Boolean-values/GAP/boolean-values.gap new file mode 100644 index 0000000000..5d63c7b9b3 --- /dev/null +++ b/Task/Boolean-values/GAP/boolean-values.gap @@ -0,0 +1,13 @@ +1 < 2; +# true + +2 < 1; +# false + +# GAP has also the value fail, which cannot be used as a boolean but may be used i$ + +1 = fail; +# false + +fail = fail; +# true diff --git a/Task/Boolean-values/Inform-7/boolean-values-1.inf b/Task/Boolean-values/Inform-7/boolean-values-1.inf new file mode 100644 index 0000000000..b8fb3a2853 --- /dev/null +++ b/Task/Boolean-values/Inform-7/boolean-values-1.inf @@ -0,0 +1 @@ +let B be whether or not 123 is greater than 100; diff --git a/Task/Boolean-values/Inform-7/boolean-values-2.inf b/Task/Boolean-values/Inform-7/boolean-values-2.inf new file mode 100644 index 0000000000..d1a3553f78 --- /dev/null +++ b/Task/Boolean-values/Inform-7/boolean-values-2.inf @@ -0,0 +1 @@ +if B is true, say "123 is greater than 100." diff --git a/Task/Boolean-values/Inform-7/boolean-values-3.inf b/Task/Boolean-values/Inform-7/boolean-values-3.inf new file mode 100644 index 0000000000..2e0f1f2997 --- /dev/null +++ b/Task/Boolean-values/Inform-7/boolean-values-3.inf @@ -0,0 +1,9 @@ +To decide whether the CPU is working correctly: + if 123 is greater than 100, decide yes; + otherwise decide no. + +When play begins: + [convert to truth state...] + let B be whether or not the CPU is working correctly; + [...or use as a condition] + if the CPU is working correctly, say "Whew." diff --git a/Task/Boolean-values/Julia/boolean-values.julia b/Task/Boolean-values/Julia/boolean-values.julia new file mode 100644 index 0000000000..7649afa690 --- /dev/null +++ b/Task/Boolean-values/Julia/boolean-values.julia @@ -0,0 +1,4 @@ +#Boolean and conditional expressions only accept 'true' or 'false' + +#Convert a number or numeric array to boolean +bool(x) diff --git a/Task/Boolean-values/Logo/boolean-values-1.logo b/Task/Boolean-values/Logo/boolean-values-1.logo new file mode 100644 index 0000000000..de1416082f --- /dev/null +++ b/Task/Boolean-values/Logo/boolean-values-1.logo @@ -0,0 +1,4 @@ +print 1 < 0 ; false +print 1 > 0 ; true +if "true [print "yes] ; yes +if not "false [print "no] ; no diff --git a/Task/Boolean-values/Logo/boolean-values-2.logo b/Task/Boolean-values/Logo/boolean-values-2.logo new file mode 100644 index 0000000000..9eec1918e6 --- /dev/null +++ b/Task/Boolean-values/Logo/boolean-values-2.logo @@ -0,0 +1,3 @@ +if equal? 0 ln 1 [print "zero] +if empty? [] [print "empty] ; empty list +if empty? "|| [print "empty] ; empty word diff --git a/Task/Boolean-values/Maxima/boolean-values.maxima b/Task/Boolean-values/Maxima/boolean-values.maxima new file mode 100644 index 0000000000..f05417912e --- /dev/null +++ b/Task/Boolean-values/Maxima/boolean-values.maxima @@ -0,0 +1,11 @@ +is(1 < 2); +/* true */ + +is(2 < 1); +/* false */ + +not true; +/* false */ + +not false; +/* true */ diff --git a/Task/Boolean-values/Mirah/boolean-values.mirah b/Task/Boolean-values/Mirah/boolean-values.mirah new file mode 100644 index 0000000000..2dcb5fd511 --- /dev/null +++ b/Task/Boolean-values/Mirah/boolean-values.mirah @@ -0,0 +1,28 @@ +import java.util.ArrayList +import java.util.HashMap + +# booleans +puts 'true is true' if true +puts 'false is false' if (!false) + +# lists treated as booleans +x = ArrayList.new +puts "empty array is true" if x +x.add("an element") +puts "full array is true" if x +puts "isEmpty() is false" if !x.isEmpty() + +# maps treated as booleans +map = HashMap.new +puts "empty map is true" if map +map.put('a', '1') +puts "full map is true" if map +puts "size() is 0 is false" if !(map.size() == 0) + +# these things do not compile +# value = nil # ==> cannot assign nil to Boolean value +# puts 'nil is false' if false == nil # ==> cannot compare boolean to nil +# puts '0 is false' if (0 == false) # ==> cannot compare int to false + +#puts 'TRUE is true' if TRUE # ==> TRUE does not exist +#puts 'FALSE is false' if !FALSE # ==> FALSE does not exist diff --git a/Task/Boolean-values/Modula-2/boolean-values.mod2 b/Task/Boolean-values/Modula-2/boolean-values.mod2 new file mode 100644 index 0000000000..6f16f773f8 --- /dev/null +++ b/Task/Boolean-values/Modula-2/boolean-values.mod2 @@ -0,0 +1,17 @@ +MODULE boo; + +IMPORT InOut; + +VAR result, done : BOOLEAN; + A, B : INTEGER; + +BEGIN + result := (1 = 2); + result := NOT result; + done := FALSE; + REPEAT + InOut.ReadInt (A); + InOut.ReadInt (B); + done := A > B + UNTIL done +END boo. diff --git a/Task/Boolean-values/Modula-3/boolean-values.mod3 b/Task/Boolean-values/Modula-3/boolean-values.mod3 new file mode 100644 index 0000000000..6b261e3c9d --- /dev/null +++ b/Task/Boolean-values/Modula-3/boolean-values.mod3 @@ -0,0 +1 @@ +TYPE BOOLEAN = {FALSE, TRUE} diff --git a/Task/Box-the-compass/Groovy/box-the-compass.groovy b/Task/Box-the-compass/Groovy/box-the-compass.groovy new file mode 100644 index 0000000000..ec1ea1e998 --- /dev/null +++ b/Task/Box-the-compass/Groovy/box-the-compass.groovy @@ -0,0 +1,22 @@ +def asCompassPoint(angle) { + def cardinalDirections = ["north", "east", "south", "west"] + + int index = Math.floor(angle / 11.25 + 0.5) + int cardinalIndex = (index / 8) + + def c1 = cardinalDirections[cardinalIndex % 4] + def c2 = cardinalDirections[(cardinalIndex + 1) % 4] + def c3 = (cardinalIndex == 0 || cardinalIndex == 2) ? "$c1$c2" : "$c2$c1" + + def point = [ + "$c1", "$c1 by $c2", "$c1-$c3", "$c3 by $c1", "$c3", "$c3 by $c2", "$c2-$c3", "$c2 by $c1" + ][index % 8] + point.substring(0, 1).toUpperCase() + point.substring(1) +} +Number.metaClass.asCompassPoint = { asCompassPoint(delegate) } + +[0.0, 16.87, 16.88, 33.75, 50.62, 50.63, 67.5, 84.37, 84.38, 101.25, 118.12, 118.13, 135.0, 151.87, 151.88, 168.75, + 185.62, 185.63, 202.5, 219.37, 219.38, 236.25, 253.12, 253.13, 270.0, 286.87, 286.88, 303.75, 320.62, 320.63, 337.5, + 354.37, 354.38].eachWithIndex { angle, index -> + println "${(index % 32) + 1}".padRight(3) + "${angle.asCompassPoint().padLeft(20)} $angle\u00b0" +} diff --git a/Task/Box-the-compass/Icon/box-the-compass.icon b/Task/Box-the-compass/Icon/box-the-compass.icon new file mode 100644 index 0000000000..c1f1f16e6a --- /dev/null +++ b/Task/Box-the-compass/Icon/box-the-compass.icon @@ -0,0 +1,26 @@ +link strings,numbers + +procedure main() + +every heading := 11.25 * (i := 0 to 32) do { + case i%3 of { + 1: heading +:= 5.62 + 2: heading -:= 5.62 + } + write(right(i+1,3)," ",left(direction(heading),20)," ",fix(heading,,7,2)) + } +end + +procedure direction(d) # compass heading given +/- degrees +static dirs +initial { + every put(dirs := [], + replacem(!["N","NbE","N-NE","NEbN","NE","NEbE","E-NE","EbN", + "E","EbS","E-SE","SEbE","SE","SEbS","S-SE","SbE", + "S","SbW","S-SW","SWbS","SW","SWbW","W-SW","WbS", + "W","WbN","W-NW","NWbW","NW","NWbN","N-NW","NbW"], + "N","north","E","east","W","west","S","south","b"," by ")) + } + + return dirs[round(((((d%360)+360)%360)/11.25)%32 + 1)] +end diff --git a/Task/Box-the-compass/J/box-the-compass-1.j b/Task/Box-the-compass/J/box-the-compass-1.j new file mode 100644 index 0000000000..5b8dfa04f2 --- /dev/null +++ b/Task/Box-the-compass/J/box-the-compass-1.j @@ -0,0 +1,8 @@ +require'strings' +subs=: 'N,north,S,south,E,east,W,west,b, by ,' +dirs=: subs (toupper@{., }.)@rplc~L:1 0&(<;._2) 0 :0 -. ' ',LF + N,NbE,N-NE,NEbN,NE,NEbE,E-NE,EbN,E,EbS,E-SE,SEbE,SE,SEbS,S-SE,SbE, + S,SbW,S-SW,SWbS,SW,SWbW,W-SW,WbS,W,WbN,W-NW,NWbW,NW,NWbN,N-NW,NbW, +) +indice=: 32 | 0.5 <.@+ %&11.25 +deg2pnt=: dirs {~ indice diff --git a/Task/Box-the-compass/J/box-the-compass-2.j b/Task/Box-the-compass/J/box-the-compass-2.j new file mode 100644 index 0000000000..4f085db567 --- /dev/null +++ b/Task/Box-the-compass/J/box-the-compass-2.j @@ -0,0 +1,6 @@ + i.10 +0 1 2 3 4 5 6 7 8 9 + deg2pnt i.10 +┌─────┬─────┬─────┬─────┬─────┬─────┬─────────────┬─────────────┬─────────────┬─────────────┐ +│North│North│North│North│North│North│North by east│North by east│North by east│North by east│ +└─────┴─────┴─────┴─────┴─────┴─────┴─────────────┴─────────────┴─────────────┴─────────────┘ diff --git a/Task/Box-the-compass/J/box-the-compass-3.j b/Task/Box-the-compass/J/box-the-compass-3.j new file mode 100644 index 0000000000..ffa5077b81 --- /dev/null +++ b/Task/Box-the-compass/J/box-the-compass-3.j @@ -0,0 +1,34 @@ + (":@>:@indice,.' ',.>@deg2pnt,.' ',.":@,.)(*&11.25 + 5.62 * 0 1 _1 {~ 3&|) i.33 +1 North 0 +2 North by east 16.87 +3 North-northeast 16.88 +4 Northeast by north 33.75 +5 Northeast 50.62 +6 Northeast by east 50.63 +7 East-northeast 67.5 +8 East by north 84.37 +9 East 84.38 +10 East by south 101.25 +11 East-southeast 118.12 +12 Southeast by east 118.13 +13 Southeast 135 +14 Southeast by south 151.87 +15 South-southeast 151.88 +16 South by east 168.75 +17 South 185.62 +18 South by west 185.63 +19 South-southwest 202.5 +20 Southwest by south 219.37 +21 Southwest 219.38 +22 Southwest by west 236.25 +23 West-southwest 253.12 +24 West by south 253.13 +25 West 270 +26 West by north 286.87 +27 West-northwest 286.88 +28 Northwest by west 303.75 +29 Northwest 320.62 +30 Northwest by north 320.63 +31 North-northwest 337.5 +32 North by west 354.37 +1 North 354.38 diff --git a/Task/Box-the-compass/K/box-the-compass-1.k b/Task/Box-the-compass/K/box-the-compass-1.k new file mode 100644 index 0000000000..c637148ee0 --- /dev/null +++ b/Task/Box-the-compass/K/box-the-compass-1.k @@ -0,0 +1,16 @@ + d:("N;Nbe;N-ne;Nebn;Ne;Nebe;E-ne;Ebn;") + d,:("E;Ebs;E-se;Sebe;Se;Sebs;S-se;Sbe;") + d,:("S;Sbw;S-sw;Swbs;Sw;Swbw;W-sw;Wbs;") + d,:("W;Wbn;W-nw;Nwbw;Nw;Nwbn;N-nw;Nbw;N") + + split:{1_'(&x=y)_ x:y,x} + dd:split[d;";"] + + / lookup table + s1:"NEWSnewsb-" + s2:("North";"East";"West";"South";"north";"east";"west";"south";" by ";"-") + c:.({`$x}'s1),'{`$x}'s2 / create the dictionary + cc:{,/{$c[`$$x]}'x} / lookup function + + / calculate the degrees + f:{m:x!3;(11.25*x)+:[1=m;+5.62;2=m;-5.62;0]} diff --git a/Task/Box-the-compass/K/box-the-compass-2.k b/Task/Box-the-compass/K/box-the-compass-2.k new file mode 100644 index 0000000000..42eb8efc38 --- /dev/null +++ b/Task/Box-the-compass/K/box-the-compass-2.k @@ -0,0 +1,34 @@ + `0:{((2$(1+x!32))," ",(-19$cc@dd[x]),(6.2$f@x))}'!#dd + 1 North 0.00 + 2 North by east 16.87 + 3 North-northeast 16.88 + 4 Northeast by north 33.75 + 5 Northeast 50.62 + 6 Northeast by east 50.63 + 7 East-northeast 67.50 + 8 East by north 84.37 + 9 East 84.38 +10 East by south 101.25 +11 East-southeast 118.12 +12 Southeast by east 118.13 +13 Southeast 135.00 +14 Southeast by south 151.87 +15 South-southeast 151.88 +16 South by east 168.75 +17 South 185.62 +18 South by west 185.63 +19 South-southwest 202.50 +20 Southwest by south 219.37 +21 Southwest 219.38 +22 Southwest by west 236.25 +23 West-southwest 253.12 +24 West by south 253.13 +25 West 270.00 +26 West by north 286.87 +27 West-northwest 286.88 +28 Northwest by west 303.75 +29 Northwest 320.62 +30 Northwest by north 320.63 +31 North-northwest 337.50 +32 North by west 354.37 + 1 North 354.38 diff --git a/Task/Box-the-compass/Liberty-BASIC/box-the-compass.liberty b/Task/Box-the-compass/Liberty-BASIC/box-the-compass.liberty new file mode 100644 index 0000000000..97ff2cbf48 --- /dev/null +++ b/Task/Box-the-compass/Liberty-BASIC/box-the-compass.liberty @@ -0,0 +1,34 @@ +dim point$( 32) + +for i =1 to 32 + read d$: point$( i) =d$ +next i + +for i = 0 to 32 + heading = i *11.25 + if ( i mod 3) =1 then + heading = heading +5.62 + else + if ( i mod 3) =2 then heading = heading -5.62 + end if + ind = i mod 32 +1 + print ind, compasspoint$( heading), heading +next i + +end + +function compasspoint$( h) + x = h /11.25 +1.5 + if (x >=33.0) then x =x -32.0 + compasspoint$ = point$( int( x)) +end function + +data "North ", "North by east ", "North-northeast " +data "Northeast by north", "Northeast ", "Northeast by east ", "East-northeast " +data "East by north ", "East ", "East by south ", "East-southeast " +data "Southeast by east ", "Southeast ", "Southeast by south", "South-southeast " +data "South by east ", "South ", "South by west ", "South-southwest " +data "Southwest by south", "Southwest ", "Southwest by west ", "West-southwest " +data "West by south ", "West ", "West by north ", "West-northwest " +data "Northwest by west ", "Northwest ", "Northwest by north", "North-northwest " +data "North by west diff --git a/Task/Box-the-compass/Logo/box-the-compass.logo b/Task/Box-the-compass/Logo/box-the-compass.logo new file mode 100644 index 0000000000..2222e56bb1 --- /dev/null +++ b/Task/Box-the-compass/Logo/box-the-compass.logo @@ -0,0 +1,64 @@ +; List of abbreviated compass point labels +make "compass_points [ N NbE N-NE NEbN NE NEbE E-NE EbN + E EbS E-SE SEbE SE SEbS S-SE SbE + S SbW S-SW SWbS SW SWbW W-SW WbS + W WbN W-NW NWbW NW NWbN N-NW NbW ] + +; List of angles to test +make "test_angles [ 0.00 16.87 16.88 33.75 50.62 50.63 67.50 + 84.37 84.38 101.25 118.12 118.13 135.00 151.87 + 151.88 168.75 185.62 185.63 202.50 219.37 219.38 + 236.25 253.12 253.13 270.00 286.87 286.88 303.75 + 320.62 320.63 337.50 354.37 354.38 ] + +; make comparisons case-sensitive +make "caseignoredp "false + +; String utilities: search and replace +to replace_in :src :from :to + output map [ ifelse equalp ? :from [:to] [?] ] :src +end + +; pad with spaces +to pad :string :length + output cascade [lessp :length count ?] [word ? "\ ] :string +end + +; capitalize first letter +to capitalize :string + output word (uppercase first :string) butfirst :string +end + +; convert compass point abbreviation to full text of label +to expand_point :abbr + foreach [[N north] [E east] [S south] [W west] [b \ by\ ]] [ + make "abbr replace_in :abbr (first ?) (last ?) + ] + output capitalize :abbr +end + +; modulus function that returns 1..N instead of 0..N-1 +to adjusted_modulo :n :d + output sum 1 modulo (difference :n 1) :d +end + +; convert a compass angle from degrees into a box index (1..32) +to compass_point :degrees + make "degrees modulo :degrees 360 + output adjusted_modulo (sum 1 int quotient (sum :degrees 5.625) 11.25) 32 +end + +; Now output the table of test data +print (sentence (pad "Degrees 7) "\| (pad "Closest\ Point 18) "\| "Index ) +foreach :test_angles [ + local "index + make "index compass_point ? + local "abbr + make "abbr item :index :compass_points + local "label + make "label expand_point :abbr + print (sentence (form ? 7 2) "\| (pad :label 18) "\| (form :index 2 0) ) +] + +; and exit +bye diff --git a/Task/Box-the-compass/MUMPS/box-the-compass.mumps b/Task/Box-the-compass/MUMPS/box-the-compass.mumps new file mode 100644 index 0000000000..ed71bc4008 --- /dev/null +++ b/Task/Box-the-compass/MUMPS/box-the-compass.mumps @@ -0,0 +1,34 @@ +BOXING(DEGREE) + ;This takes in a degree heading, nominally from 0 to 360, and returns the compass point name. + QUIT:((DEGREE<0)||(DEGREE>360)) "land lubber can't read a compass" + NEW DIRS,UNP,UNPACK,SEP,DIR,DOS,D,DS,I,F + SET DIRS="N^NbE^N-NE^NEbN^NE^NEbE^E-NE^EbN^E^EbS^E-SE^SEbE^SE^SEbS^S-SE^SbE^" + SET DIRS=DIRS_"S^SbW^S-SW^SWbS^SW^SWbW^W-SW^WbS^W^WbN^W-NW^NWbW^NW^NWbN^N-NW^NbW" + SET UNP="NESWb" + SET UNPACK="north^east^south^west^ by " + SET SEP=360/$LENGTH(DIRS,"^") + SET DIR=(DEGREE/SEP)+1.5 + SET DIR=$SELECT((DIR>33):DIR-32,1:DIR) + SET DOS=$NUMBER(DIR-.5,0) + SET D=$PIECE(DIRS,"^",DIR) + SET DS="" + FOR I=1:1:$LENGTH(D) DO + . SET F=$FIND(UNP,$EXTRACT(D,I)) SET DS=DS_$SELECT((F>0):$PIECE(UNPACK,"^",F-1),1:$E(D,I)) + KILL DIRS,UNP,UNPACK,SEP,DIR,D,I,F + QUIT DOS_"^"_DS + +BOXWRITE + NEW POINTS,UP,LO,DIR,P,X + SET POINTS="0.0,16.87,16.88,33.75,50.62,50.63,67.5,84.37,84.38,101.25,118.12,118.13,135.0,151.87," + SET POINTS=POINTS_"151.88,168.75,185.62,185.63,202.5,219.37,219.38,236.25,253.12,253.13,270.0,286.87," + SET POINTS=POINTS_"286.88,303.75,320.62,320.63,337.5,354.37,354.38" + SET UP="ABCDEFGHIJKLMNOPQRSTUVWXYZ" + SET LO="abcdefghijklmnopqrstuvwxyz" + FOR P=1:1:$LENGTH(POINTS,",") DO + . SET X=$$BOXING($PIECE(POINTS,",",P)) + . ;Capitalize the initial letter of the direction + . SET DIR=$PIECE(X,"^",2) + . SET DIR=$TRANSLATE($EXTRACT(DIR,1),LO,UP)_$EXTRACT(DIR,2,$LENGTH(DIR)) + . WRITE $PIECE(X,"^"),?5,DIR,?40,$JUSTIFY($PIECE(POINTS,",",P),10,2),! + KILL POINTS,UP,LO,DIR,P,X + QUIT diff --git a/Task/Box-the-compass/Mathematica/box-the-compass.mathematica b/Task/Box-the-compass/Mathematica/box-the-compass.mathematica new file mode 100644 index 0000000000..9a210ed4dc --- /dev/null +++ b/Task/Box-the-compass/Mathematica/box-the-compass.mathematica @@ -0,0 +1,2 @@ +Map[List[Part[#,1], dirs[[Part[#,1]]], ToString@Part[#,2]<>"°"]&, + Map[{Floor[Mod[ #+5.625 , 360]/11.25]+1,#}&,input] ]//TableForm diff --git a/Task/Break-OO-privacy/Factor/break-oo-privacy-1.factor b/Task/Break-OO-privacy/Factor/break-oo-privacy-1.factor new file mode 100644 index 0000000000..a0a2c89760 --- /dev/null +++ b/Task/Break-OO-privacy/Factor/break-oo-privacy-1.factor @@ -0,0 +1,3 @@ +( scratchpad ) USING: sets sets.private ; +( scratchpad ) { 1 2 3 } { 1 2 4 } sequence/tester count . +2 diff --git a/Task/Break-OO-privacy/Factor/break-oo-privacy-2.factor b/Task/Break-OO-privacy/Factor/break-oo-privacy-2.factor new file mode 100644 index 0000000000..90c941cc96 --- /dev/null +++ b/Task/Break-OO-privacy/Factor/break-oo-privacy-2.factor @@ -0,0 +1,3 @@ +( scratchpad ) USE: sets +( scratchpad ) { 1 2 3 } { 1 2 4 } intersect length . +2 diff --git a/Task/Break-OO-privacy/Factor/break-oo-privacy-3.factor b/Task/Break-OO-privacy/Factor/break-oo-privacy-3.factor new file mode 100644 index 0000000000..1f5f38b3c2 --- /dev/null +++ b/Task/Break-OO-privacy/Factor/break-oo-privacy-3.factor @@ -0,0 +1,17 @@ +link printf + +procedure main() + (x := foo(1,2,3)).print() # create and show a foo + printf("Fieldnames of foo x : ") # show fieldnames + every printf(" %i",fieldnames(x)) # __s (self), __m (methods), vars + printf("\n") + printf("var 1 of foo x = %i\n", x.var1) # read var1 from outside x + x.var1 := -1 # change var1 from outside x + x.print() # show we changed it +end + +class foo(var1,var2,var3) # class with no set/read methods + method print() + printf("foo var1=%i, var2=%i, var3=%i\n",var1,var2,var3) + end +end diff --git a/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-1.j b/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-1.j new file mode 100644 index 0000000000..6545509746 --- /dev/null +++ b/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-1.j @@ -0,0 +1,18 @@ +require'misc' + +poss=:1+~.4{."1 (i.!9)A.i.9 +fmt=: ' ' -.~ ": + +play=:3 :0 + while.1<#poss=.poss do. + smoutput'guessing ',fmt guess=.({~ ?@#)poss + bc=.+/\_".prompt 'how many bull and cows? ' + poss=.poss #~({.bc)=guess+/@:="1 poss + poss=.poss #~({:bc)=guess+/@e."1 poss + end. + if.#poss do. + 'the answer is ',fmt,poss + else. + 'no valid possibilities' + end. +) diff --git a/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-2.j b/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-2.j new file mode 100644 index 0000000000..5c47d29349 --- /dev/null +++ b/Task/Bulls-and-cows-Player/J/bulls-and-cows-player-2.j @@ -0,0 +1,10 @@ + play'' +guessing 7461 +how many bull and cows? 0 1 +guessing 3215 +how many bull and cows? 0 3 +guessing 2357 +how many bull and cows? 2 0 +guessing 1359 +how many bull and cows? 3 0 +the answer is 1358 diff --git a/Task/Bulls-and-cows-Player/Liberty-BASIC/bulls-and-cows-player.liberty b/Task/Bulls-and-cows-Player/Liberty-BASIC/bulls-and-cows-player.liberty new file mode 100644 index 0000000000..49a92f7b2e --- /dev/null +++ b/Task/Bulls-and-cows-Player/Liberty-BASIC/bulls-and-cows-player.liberty @@ -0,0 +1,99 @@ +guesses =0 + +do while len( secret$) <4 ' zero not allowed <<<<<<<<< + n$ =chr$( int( rnd( 1) *9) +49) + if not( instr( secret$, n$)) then secret$ =secret$ +n$ +loop + +print " Secretly, my opponent just chose a number. But she didn't tell anyone! "; secret$; "." +print " I can however be given a score for my guesses." + +for i =1234 to 9876 ' <<<<<<<<< + if check( str$( i)) =0 then available$ =available$ +" " +str$( i): k =k +1 +next i + +available$ =trim$( available$) ' remove the surplus, leading space + +print +print "Currently holding "; k; " possible numbers. " + +while 1 + guess$ =word$( available$, 1 +int( k *rnd( 1)), " ") + print + print "Computer guessed "; guess$; " & got "; + + bulls =0 + cows =0 + guesses =guesses +1 + + r$ =score$( guess$, secret$) + + bulls =val( word$( r$, 1, ",")) + cows =val( word$( r$, 2, ",")) + + print bulls; " bull(s), and "; cows; " cow(s), .... "; + + if guess$ =secret$ then + print "Computer won after "; guesses; " guesses!"; + secs =( time$( "seconds") -now +86400) mod 86400 + print " That took "; secs; " seconds. ENDED!" + print + print " Now scroll right to see original choice and check!" + exit while + end if + + print " so possible numbers are now only..." + kk =0 + new$ ="" + + for j =1 to k + bullsT =0 + cowsT =0 + + possible$ =word$( available$, j, " ") + + r$ =score$( guess$, possible$) + + bullsT =val( word$( r$, 1, ",")) + cowsT =val( word$( r$, 2, ",")) + + if ( bullsT =bulls) and ( cowsT =cows) then + new$ =new$ +" " +possible$ ' keep those with same score + kk =kk +1 + print possible$; " "; + if ( kk mod 20) =0 then print + end if + + scan + next j + + available$ =trim$( new$) + k =kk + + scan +wend + +end + +function score$( a$, b$) ' return as a csv string the number of bulls & cows. + bulls = 0: cows = 0 + for i = 1 to 4 + c$ = mid$( a$, i, 1) + if mid$( b$, i, 1) = c$ then + bulls = bulls + 1 + else + if instr( b$, c$) <>0 and instr( b$, c$) <>i then cows = cows + 1 + end if + next i + score$ =str$( bulls); ","; str$( cows) +end function + +function check( i$) + check =0 ' zero flags available: 1 means not available + for i =1 to 3 + for j =i +1 to 4 + if mid$( i$, i, 1) =mid$( i$, j, 1) then check =1 + next j + next i + if instr( i$, "0") then check =1 +end function diff --git a/Task/Bulls-and-cows-Player/Mathematica/bulls-and-cows-player.mathematica b/Task/Bulls-and-cows-Player/Mathematica/bulls-and-cows-player.mathematica new file mode 100644 index 0000000000..cfda7f31ad --- /dev/null +++ b/Task/Bulls-and-cows-Player/Mathematica/bulls-and-cows-player.mathematica @@ -0,0 +1,14 @@ +bullCow={Count[#1-#2,0],Length[#1\[Intersection]#2]-Count[#1-#2,0]}&; +Module[{r,input,candidates=Permutations[Range[9],{4}]}, +While[True, + r=InputString[]; + If[r===$Canceled,Break[], + input=ToExpression/@StringSplit@r; + If[Length@input!=3,Print["Input the guess, number of bulls, number of cows, delimited by space."], + candidates=Select[candidates,bullCow[ToCharacterCode@StringJoin[ToString/@#],ToCharacterCode@ToString@input[[1]]]==input[[2;;3]]&]; + candidates=SortBy[candidates,{-3,-1}.bullCow[ToCharacterCode@StringJoin[ToString/@#],ToCharacterCode@ToString@input[[1]]]&]; + If[candidates==={},Print["No more candidates."];Break[]]; + If[Length@candidates==1,Print["Must be: "<>StringJoin[ToString/@candidates[[1]]]];Break[]]; + Print[ToString@Length@candidates<>" candidates remaining."]; + Print["Can try "<>StringJoin[ToString/@First@candidates]<>"."]; + ]]]] diff --git a/Task/Bulls-and-cows/Factor/bulls-and-cows.factor b/Task/Bulls-and-cows/Factor/bulls-and-cows.factor new file mode 100644 index 0000000000..8c23f8d6dc --- /dev/null +++ b/Task/Bulls-and-cows/Factor/bulls-and-cows.factor @@ -0,0 +1,64 @@ +USING: accessors assocs combinators fry grouping hashtables kernel + locals math math.parser math.ranges random sequences strings + io ascii ; + +IN: bullsncows + +TUPLE: score bulls cows ; +: ( -- score ) 0 0 score boa ; + +TUPLE: cow ; +: ( -- cow ) cow new ; + +TUPLE: bull ; +: ( -- bull ) bull new ; + +: inc-bulls ( score -- score ) dup bulls>> 1 + >>bulls ; +: inc-cows ( score -- score ) dup cows>> 1 + >>cows ; + +: random-nums ( -- seq ) 9 [1,b] 4 sample ; + +: add-digits ( seq -- n ) 0 [ swap 10 * + ] reduce number>string ; + +: new-number ( -- n narr ) random-nums dup add-digits ; + +: narr>nhash ( narr -- nhash ) { 1 2 3 4 } swap zip ; + +: num>hash ( n -- hash ) + [ 1string string>number ] { } map-as narr>nhash ; + +:: cow-or-bull ( n g -- arr ) + { + { [ n first g at n second = ] [ ] } + { [ n second g value? ] [ ] } + [ f ] + } cond ; + +: add-to-score ( arr -- score ) + [ bull? [ inc-bulls ] [ inc-cows ] if ] reduce ; + +: check-win ( score -- ? ) bulls>> 4 = ; + +: sum-score ( n g -- score ? ) + '[ _ cow-or-bull ] map sift add-to-score dup check-win ; + +: print-sum ( score -- str ) + dup bulls>> number>string "Bulls: " swap append swap cows>> number>string + " Cows: " swap 3append "\n" append ; + +: (validate-readln) ( str -- ? ) dup length 4 = not swap [ letter? ] all? or ; + +: validate-readln ( -- str ) + readln dup (validate-readln) + [ "Invalid input.\nPlease enter a valid 4 digit number: " + write flush drop validate-readln ] + when ; + +: win ( -- ) "\nYou've won! Good job. You're so smart." print flush ; + +: main-loop ( x -- ) + "Enter a 4 digit number: " write flush validate-readln num>hash swap + [ sum-score swap print-sum print flush ] keep swap not + [ main-loop ] [ drop win ] if ; + +: main ( -- ) new-number drop narr>nhash main-loop ; diff --git a/Task/Bulls-and-cows/Fan/bulls-and-cows.fan b/Task/Bulls-and-cows/Fan/bulls-and-cows.fan new file mode 100644 index 0000000000..51a650ab8d --- /dev/null +++ b/Task/Bulls-and-cows/Fan/bulls-and-cows.fan @@ -0,0 +1,50 @@ +** +** Bulls and cows. A game pre-dating, and similar to, Mastermind. +** +class BullsAndCows +{ + + Void main() + { + digits := [1,2,3,4,5,6,7,8,9] + size := 4 + chosen := [,] + size.times { chosen.add(digits.removeAt(Int.random(0..= '1' && ch <= '9' && !guess.contains(ch)) guess.add(ch-'0') } + if (guess.size == 4) + break // input loop + echo("Oops, try again. You need to enter $size unique digits from 1 to 9") + } + if (guess.all |v, i->Bool| { return v == chosen[i] }) + { + echo("\nCongratulations! You guessed correctly in $guesses guesses") + break // game loop + } + bulls := 0 + cows := 0 + (0 ..< size).each |i| + { + if (guess[i] == chosen[i]) + bulls += 1 + else if (chosen.contains(guess[i])) + cows += 1 + } + echo("\n $bulls Bulls\n $cows Cows") + } + } +} diff --git a/Task/Bulls-and-cows/Icon/bulls-and-cows.icon b/Task/Bulls-and-cows/Icon/bulls-and-cows.icon new file mode 100644 index 0000000000..51533e7eb6 --- /dev/null +++ b/Task/Bulls-and-cows/Icon/bulls-and-cows.icon @@ -0,0 +1,24 @@ +procedure main() + digits := "123456789" + every !digits :=: ?digits + num := digits[1+:4] + repeat if score(num, getGuess(num)) then break + write("Good job.") +end + +procedure getGuess(num) + repeat { + writes("Enter a guess: ") + guess := read() | stop("Quitter!") + if *(guess ** '123456789') == *num then return guess + write("Malformed guess: ",guess,". Try again.") + } +end + +procedure score(num, guess) + bulls := 0 + cows := *(num ** guess) + every (num[i := 1 to *num] == guess[i], bulls +:= 1, cows -:= 1) + write("\t",bulls," bulls and ",cows," cows") + return (bulls = *num) +end diff --git a/Task/Bulls-and-cows/J/bulls-and-cows-1.j b/Task/Bulls-and-cows/J/bulls-and-cows-1.j new file mode 100644 index 0000000000..de0d1d72bb --- /dev/null +++ b/Task/Bulls-and-cows/J/bulls-and-cows-1.j @@ -0,0 +1,24 @@ +require 'misc' + +plural=: conjunction define + (":m),' ',n,'s'#~1~:m +) + +bullcow=:monad define + number=. 1+4?9 + whilst. -.guess-:number do. + guess=. 0 "."0 prompt 'Guess my number: ' + if. (4~:#guess)+.(4~:#~.guess)+.0 e.guess e.1+i.9 do. + if. 0=#guess do. + smoutput 'Giving up.' + return. + end. + smoutput 'Guesses must be four different non-zero digits' + continue. + end. + bulls=. +/guess=number + cows=. (+/guess e.number)-bulls + smoutput bulls plural 'bull',' and ',cows plural 'cow','.' + end. + smoutput 'you win' +) diff --git a/Task/Bulls-and-cows/J/bulls-and-cows-2.j b/Task/Bulls-and-cows/J/bulls-and-cows-2.j new file mode 100644 index 0000000000..2d74b0eb9a --- /dev/null +++ b/Task/Bulls-and-cows/J/bulls-and-cows-2.j @@ -0,0 +1,16 @@ + bullcow'' +Guess my number: 1234 +0 bulls and 1 cow. +Guess my number: 5678 +3 bulls and 0 cows. +Guess my number: 2349 +0 bulls and 0 cows. +Guess my number: 1567 +0 bulls and 3 cows. +Guess my number: 6178 +3 bulls and 0 cows. +Guess my number: 6157 +1 bull and 2 cows. +Guess my number: 5178 +4 bulls and 0 cows. +you win diff --git a/Task/Bulls-and-cows/Julia/bulls-and-cows.julia b/Task/Bulls-and-cows/Julia/bulls-and-cows.julia new file mode 100644 index 0000000000..adbc927e0a --- /dev/null +++ b/Task/Bulls-and-cows/Julia/bulls-and-cows.julia @@ -0,0 +1,22 @@ +function cowsbulls() + print("Welcome to Cows & Bulls! I've picked a 4 digit number, go ahead and type your guess.\n + You get one bull for every right number in the right position.\n + You get one cow for every right number in the wrong position.\n + Enter 'n' to pick a new number and 'q' to quit.\n>") + new_number() = string(rand(1:9))*string(rand(1:9))*string(rand(1:9))*string(rand(1:9)) + answer = new_number() + while true + input = chomp(readline(STDIN)) + input == "q" && break + input == "n" && begin answer = new_number(); print("\nLet's try again, go ahead and guess\n>"); continue end + !ismatch(r"^[1-9]{4}$",string(input)) && begin print("Invalid guess: Please enter a 4-digit number\n"); continue end + if input == answer + print("\nYou're right! Good guessing!\nEnter 'n' for a new number or 'q' to quit\n>") + continue + else + bulls = sum(answer.data .== input.data) + cows = sum([answer[x] != input[x] && contains(input.data,answer[x]) for x = 1:4]) + print("\nNot quite! Your guess is worth:\n$bulls Bulls\n$cows Cows\nPlease guess again\n\n>") + end + end +end diff --git a/Task/Bulls-and-cows/Liberty-BASIC/bulls-and-cows.liberty b/Task/Bulls-and-cows/Liberty-BASIC/bulls-and-cows.liberty new file mode 100644 index 0000000000..b9f5b34516 --- /dev/null +++ b/Task/Bulls-and-cows/Liberty-BASIC/bulls-and-cows.liberty @@ -0,0 +1,61 @@ + do while len( secret$) <4 + c$ =chr$( int( rnd( 1) *9) +49) + if not( instr( secret$, c$)) then secret$ =secret$ +c$ + loop + + print " Secret number has been guessed.... "; secret$ + + guesses = 0 + +[loop] + print " Your guess "; + input " "; guess$ + + guesses = guesses +1 + + r$ =score$( guess$, secret$) + + bulls =val( word$( r$, 1, ",")) + cows =val( word$( r$, 2, ",")) + + print " Result: "; bulls; " bulls, and "; cows; " cows" + print + + if guess$ =secret$ then + print " You won after "; guesses; " guesses!" + print " You guessed it in "; guesses + print " Thanks for playing!" + wait + end if + + goto [loop] + +end ' _____________________________________________________________ + +function check( i$) ' check =0 if no digit repeats, else =1 + check =0 + for i =1 to 3 + for j =i +1 to 4 + if mid$( i$, i, 1) =mid$( i$, j, 1) then check =1 + next j + next i +end function + +function score$( a$, b$) ' return as a csv string the number of bulls & cows. + bulls = 0: cows = 0 + for i = 1 to 4 + c$ = mid$( a$, i, 1) + if mid$( b$, i, 1) = c$ then + bulls = bulls + 1 + else + if instr( b$, c$) <>0 and instr( b$, c$) <>i then + cows = cows + 1 + end if + end if + next i + score$ =str$( bulls); ","; str$( cows) +end function + +[quit] +close #w +end diff --git a/Task/Bulls-and-cows/Logo/bulls-and-cows.logo b/Task/Bulls-and-cows/Logo/bulls-and-cows.logo new file mode 100644 index 0000000000..25edf2483e --- /dev/null +++ b/Task/Bulls-and-cows/Logo/bulls-and-cows.logo @@ -0,0 +1,19 @@ +to ok? :n + output (and [number? :n] [4 = count :n] [4 = count remdup :n] [not member? 0 :n]) +end + +to init + do.until [make "hidden random 10000] [ok? :hidden] +end + +to guess :n + if not ok? :n [print [Bad guess! (4 unique digits, 1-9)] stop] + localmake "bulls 0 + localmake "cows 0 + foreach :n [cond [ + [[? = item # :hidden] make "bulls 1 + :bulls] + [[member? ? :hidden] make "cows 1 + :cows ] + ]] + (print :bulls "bulls, :cows "cows) + if :bulls = 4 [print [You guessed it!]] +end diff --git a/Task/Bulls-and-cows/MUMPS/bulls-and-cows.mumps b/Task/Bulls-and-cows/MUMPS/bulls-and-cows.mumps new file mode 100644 index 0000000000..0de561f541 --- /dev/null +++ b/Task/Bulls-and-cows/MUMPS/bulls-and-cows.mumps @@ -0,0 +1,65 @@ +BullCow New bull,cow,guess,guessed,ii,number,pos,x + Set number="",x=1234567890 + For ii=1:1:4 Do + . Set pos=$Random($Length(x))+1 + . Set number=number_$Extract(x,pos) + . Set $Extract(x,pos)="" + . Quit + Write !,"The computer has selected a number that consists" + Write !,"of four different digits." + Write !!,"As you are guessing the number, ""bulls"" and ""cows""" + Write !,"will be awarded: a ""bull"" for each digit that is" + Write !,"placed in the correct position, and a ""cow"" for each" + Write !,"digit that occurs in the number, but in a different place.",! + Write !,"For a guess, enter 4 digits." + Write !,"Any other input is interpreted as ""I give up"".",! + Set guessed=0 For Do Quit:guessed + . Write !,"Your guess: " Read guess If guess'?4n Set guessed=-1 Quit + . Set (bull,cow)=0,x=guess + . For ii=4:-1:1 If $Extract(x,ii)=$Extract(number,ii) Do + . . Set bull=bull+1,$Extract(x,ii)="" + . . Quit + . For ii=1:1:$Length(x) Set:number[$Extract(x,ii) cow=cow+1 + . Write !,"You guessed ",guess,". That earns you " + . If 'bull,'cow Write "neither bulls nor cows..." Quit + . If bull Write bull," bull" Write:bull>1 "s" + . If cow Write:bull " and " Write cow," cow" Write:cow>1 "s" + . Write "." + . If bull=4 Set guessed=1 Write !,"That's a perfect score." + . Quit + If guessed<0 Write !!,"The number was ",number,".",! + Quit +Do BullCow + +The computer has selected a number that consists +of four different digits. + +As you are guessing the number, "bulls" and "cows" +will be awarded: a "bull" for each digit that is +placed in the correct position, and a "cow" for each +digit that occurs in the number, but in a different place. + +For a guess, enter 4 digits. +Any other input is interpreted as "I give up". + +Your guess: 1234 +You guessed 1234. That earns you 1 cow. +Your guess: 5678 +You guessed 5678. That earns you 1 cow. +Your guess: 9815 +You guessed 9815. That earns you 1 cow. +Your guess: 9824 +You guessed 9824. That earns you 2 cows. +Your guess: 9037 +You guessed 9037. That earns you 1 bull and 2 cows. +Your guess: 9048 +You guessed 2789. That earns you 1 bull and 2 cows. +Your guess: 2079 +You guessed 2079. That earns you 1 bull and 3 cows. +Your guess: 2709 +You guessed 2709. That earns you 2 bulls and 2 cows. +Your guess: 0729 +You guessed 0729. That earns you 4 cows. +Your guess: 2907 +You guessed 2907. That earns you 4 bulls. +That's a perfect score. diff --git a/Task/Bulls-and-cows/Mathematica/bulls-and-cows.mathematica b/Task/Bulls-and-cows/Mathematica/bulls-and-cows.mathematica new file mode 100644 index 0000000000..4eb601dc33 --- /dev/null +++ b/Task/Bulls-and-cows/Mathematica/bulls-and-cows.mathematica @@ -0,0 +1,12 @@ +digits=Last@FixedPointList[If[Length@Union@#==4,#,Table[Random[Integer,{1,9}],{4}]]&,{}] +codes=ToCharacterCode[StringJoin[ToString/@digits]]; +Module[{r,bulls,cows}, + While[True, + r=InputString[]; + If[r===$Canceled,Break[], + With[{userCodes=ToCharacterCode@r}, + If[userCodes===codes,Print[r<>": You got it!"];Break[], + If[Length@userCodes==Length@codes, + bulls=Count[userCodes-codes,0];cows=Length@Intersection[codes,userCodes]-bulls; + Print[r<>": "<>ToString[bulls]<>"bull(s), "<>ToString@cows<>"cow(s)."], + Print["Guess four digits."]]]]]]] diff --git a/Task/CRC-32/Icon/crc-32.icon b/Task/CRC-32/Icon/crc-32.icon new file mode 100644 index 0000000000..9d4cee5f2b --- /dev/null +++ b/Task/CRC-32/Icon/crc-32.icon @@ -0,0 +1,33 @@ +link hexcvt,printf + +procedure main() + s := "The quick brown fox jumps over the lazy dog" + a := "414FA339" + printf("crc(%i)=%s - implementation is %s\n", + s,r := crc32(s),if r == a then "correct" else "in error") +end + +procedure crc32(s) #: return crc-32 (ISO 3309, ITU-T V.42, Gzip, PNG) of s +static crcL,mask +initial { + crcL := list(256) # crc table + p := [0,1,2,4,5,7,8,10,11,12,16,22,23,26] # polynomial terms + mask := 2^32-1 # word size mask + every (poly := 0) := ior(poly,ishift(1,31-p[1 to *p])) + every c := n := 0 to *crcL-1 do { # table + every 1 to 8 do + c := iand(mask, + if iand(c,1) = 1 then + ixor(poly,ishift(c,-1)) + else + ishift(c,-1) + ) + crcL[n+1] := c + } + } + + crc := ixor(0,mask) # invert bits + every crc := iand(mask, + ixor(crcL[iand(255,ixor(crc,ord(!s)))+1],ishift(crc,-8))) + return hexstring(ixor(crc,mask)) # return hexstring +end diff --git a/Task/CRC-32/J/crc-32-1.j b/Task/CRC-32/J/crc-32-1.j new file mode 100644 index 0000000000..3b091dd93f --- /dev/null +++ b/Task/CRC-32/J/crc-32-1.j @@ -0,0 +1,2 @@ + ((i.32) e. 32 26 23 22 16 12 11 10 8 7 5 4 2 1 0) 128!:3 'The quick brown fox jumps over the lazy dog' +_3199229127 diff --git a/Task/CRC-32/J/crc-32-2.j b/Task/CRC-32/J/crc-32-2.j new file mode 100644 index 0000000000..a6e7be888e --- /dev/null +++ b/Task/CRC-32/J/crc-32-2.j @@ -0,0 +1,5 @@ + (2^32x)|((i.32) e. 32 26 23 22 16 12 11 10 8 7 5 4 2 1 0) 128!:3 'The quick brown fox jumps over the lazy dog' +1095738169 + require'convert' + hfd (2^32x)|((i.32) e. 32 26 23 22 16 12 11 10 8 7 5 4 2 1 0) 128!:3 'The quick brown fox jumps over the lazy dog' +414FA339 diff --git a/Task/CRC-32/Mathematica/crc-32.mathematica b/Task/CRC-32/Mathematica/crc-32.mathematica new file mode 100644 index 0000000000..a3a1c7c150 --- /dev/null +++ b/Task/CRC-32/Mathematica/crc-32.mathematica @@ -0,0 +1,2 @@ +IntegerString[Hash["The quick brown fox jumps over the lazy dog", "CRC32"], 16, 8] +-> "414fa339" diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-1.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-1.groovy new file mode 100644 index 0000000000..40cb9c49d2 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-1.groovy @@ -0,0 +1,38 @@ +def formatCell = { cell -> + "${cell.replaceAll('&','&').replaceAll('<','<')}" +} + +def formatRow = { row -> + """${row.split(',').collect { cell -> formatCell(cell) }.join('')} +""" +} + +def formatTable = { csv, header=false -> + def rows = csv.split('\n').collect { row -> formatRow(row) } + header \ + ? """ + + +${rows[0]} + +${rows[1..-1].join('')} +
+""" \ + : """ + +${rows.join('')}
+""" +} + +def formatPage = { title, csv, header=false -> +""" + +${title} + + +${formatTable(csv, header)} +""" +} diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-2.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-2.groovy new file mode 100644 index 0000000000..c562694945 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-2.groovy @@ -0,0 +1,17 @@ +def csv = '''Character,Speech +The multitude,The messiah! Show us the messiah! +Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! +The multitude,Who are you? +Brians mother,I'm his mother; that's who! +The multitude,Behold his mother! Behold his mother!''' + +println 'Basic:' +println '-----------------------------------------' +println (formatPage('Basic', csv)) +println '-----------------------------------------' +println() +println() +println 'Extra Credit:' +println '-----------------------------------------' +println (formatPage('Extra Credit', csv, true)) +println '-----------------------------------------' diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-3.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-3.groovy new file mode 100644 index 0000000000..e9fdd43036 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-3.groovy @@ -0,0 +1,19 @@ + + +Basic + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-4.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-4.groovy new file mode 100644 index 0000000000..c89ed30454 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-4.groovy @@ -0,0 +1,23 @@ + + +Extra Credit + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-5.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-5.groovy new file mode 100644 index 0000000000..37214a2aff --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-5.groovy @@ -0,0 +1,30 @@ +import groovy.xml.MarkupBuilder + +def formatRow = { doc, row -> + doc.tr { row.each { cell -> td { mkp.yield(cell) } } } +} + +def formatPage = { titleString, csv, header=false -> + def writer = new StringWriter() + def doc = new MarkupBuilder(writer) + def rows = csv.split('\n').collect { row -> row.split(',') } + doc.html { + head { + title (titleString) + style (type:"text/css") { + mkp.yield(''' + td {background-color:#ddddff; } + thead td {background-color:#ddffdd; text-align:center; } + ''') + } + } + body { + table { + header && thead { formatRow(doc, rows[0]) } + header && tbody { rows[1..-1].each { formatRow(doc, it) } } + header || rows.each { formatRow(doc, it) } + } + } + } + writer.toString() +} diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-6.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-6.groovy new file mode 100644 index 0000000000..a3708ec0b6 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-6.groovy @@ -0,0 +1,37 @@ + + + Basic + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-7.groovy b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-7.groovy new file mode 100644 index 0000000000..55f4ec3dad --- /dev/null +++ b/Task/CSV-to-HTML-translation/Groovy/csv-to-html-translation-7.groovy @@ -0,0 +1,41 @@ + + + Extra Credit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-1.icon b/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-1.icon new file mode 100644 index 0000000000..de2097aa01 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-1.icon @@ -0,0 +1,20 @@ +procedure main(arglist) + pchar := &letters ++ &digits ++ '!?;. ' # printable chars + + write("") + firstHead := (!arglist == "-heading") + tHead := write + while row := trim(read()) do { + if \firstHead then write(" ") else tHead(" ") + writes(" ") + if (\firstHead) := &null then write(" \n ") + tHead := 1 + } + write(" ") + write("
") + while *row > 0 do + row ?:= ( (=",",writes("")) | + writes( tab(many(pchar)) | + ("&#" || ord(move(1))) ), tab(0)) + write("
") +end diff --git a/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-2.icon b/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-2.icon new file mode 100644 index 0000000000..b5121b90fa --- /dev/null +++ b/Task/CSV-to-HTML-translation/Icon/csv-to-html-translation-2.icon @@ -0,0 +1,12 @@ + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/J/csv-to-html-translation-1.j b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-1.j new file mode 100644 index 0000000000..cd549a0cc0 --- /dev/null +++ b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-1.j @@ -0,0 +1,22 @@ +require 'strings tables/csv' +encodeHTML=: ('&';'&';'<';'<';'>';'>')&stringreplace + +tag=: adverb define + 'starttag endtag'=.m + (,&.>/)"1 (starttag , ,&endtag) L:0 y +) + +markupCells=: ('';'') tag +markupHdrCells=: ('';'') tag +markupRows=: ('';'',LF) tag +markupTable=: (('',LF);'
') tag + +makeHTMLtablefromCSV=: verb define + 0 makeHTMLtablefromCSV y NB. default left arg is 0 (no header row) +: + t=. fixcsv encodeHTML y + if. x do. t=. (markupHdrCells@{. , markupCells@}.) t + else. t=. markupCells t + end. + ;markupTable markupRows t +) diff --git a/Task/CSV-to-HTML-translation/J/csv-to-html-translation-2.j b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-2.j new file mode 100644 index 0000000000..b747720b05 --- /dev/null +++ b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-2.j @@ -0,0 +1,2 @@ +tag=: adverb def '[: (,&.>/)"1 m&(0&{::@[ , 1&{::@[ ,~ ]) L:0@]' +makeHTMLtablefromCSV6=: 0&$: : ([: ; markupTable@markupRows@([ markupCells`(markupHdrCells@{. , markupCells@}.)@.[ fixcsv@encodeHTML)) diff --git a/Task/CSV-to-HTML-translation/J/csv-to-html-translation-3.j b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-3.j new file mode 100644 index 0000000000..ff296d8923 --- /dev/null +++ b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-3.j @@ -0,0 +1,9 @@ + CSVstrng=: noun define +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! +) + 1 makeHTMLtablefromCSV CSVstrng diff --git a/Task/CSV-to-HTML-translation/J/csv-to-html-translation-4.j b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-4.j new file mode 100644 index 0000000000..d3a53464a6 --- /dev/null +++ b/Task/CSV-to-HTML-translation/J/csv-to-html-translation-4.j @@ -0,0 +1,8 @@ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/CSV-to-HTML-translation/Liberty-BASIC/csv-to-html-translation.liberty b/Task/CSV-to-HTML-translation/Liberty-BASIC/csv-to-html-translation.liberty new file mode 100644 index 0000000000..e66696be80 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Liberty-BASIC/csv-to-html-translation.liberty @@ -0,0 +1,36 @@ + newline$ ="|" + ' No escape behaviour, so can't refer to '/n'. + ' Generally imported csv would have separator CR LF; easily converted first if needed + + csv$ ="Character,Speech" +newline$+_ + "The multitude,The messiah! Show us the messiah!" +newline$+_ + "Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" +newline$+_ + "The multitude,Who are you?" +newline$+_ + "Brians mother,I'm his mother; that's who!" +newline$+_ + "The multitude,Behold his mother! Behold his mother!" + + print "" + print "" + print "" + print "" + print "

CSV to HTML translation

" + print "" + print "": print "" + print "
" + + for i =1 to len( csv$) + c$ =mid$( csv$, i, 1) + select case c$ + case "|": print "
" + case ",": print ""; + case "<": print "&"+"lt;"; + case ">": print "&"+"gt;"; + case "&": print "&"+"amp;"; + case else: print c$; + end select + next i + + print "
" + print "" + print "" + end diff --git a/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-1.ml b/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-1.ml new file mode 100644 index 0000000000..d45c856aaf --- /dev/null +++ b/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-1.ml @@ -0,0 +1,54 @@ +MCSKIP "WITH" NL +"" CSV to HTML +"" assumes macros on input stream 1, terminal on stream 2 +MCSKIP MT,[] +MCSKIP SL WITH ~ +MCINS %. +"" C1=th before header output, td afterwards +MCCVAR 1,2 +MCSET C1=[th] +"" HTML escapes +MCDEF < AS [[<]] +MCDEF > AS [[>]] +MCDEF & AS [[&]] +"" Main line processing +MCDEF SL N1 OPT , N1 OR NL ALL +AS [[ ] +MCSET T2=1 +%L1.MCGO L2 IF T2 GR T1 + [<]%C1.[>]%AT2.[] +MCSET T2=T2+1 +MCGO L1 +%L2.[ ] +MCSET C1=[td] +] +[ + + +HTML converted from CSV + + + + + +] +MCSET S1=1 +~MCSET S10=2 +~MCSET S1=0 +[
+ + +] diff --git a/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-2.ml b/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-2.ml new file mode 100644 index 0000000000..d9be3e3ca5 --- /dev/null +++ b/Task/CSV-to-HTML-translation/ML-I/csv-to-html-translation-2.ml @@ -0,0 +1,51 @@ + + + +HTML converted from CSV + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah; he's a + very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother; that's who!
The multitudeBehold his mother! Behold his mother!
+ + diff --git a/Task/CSV-to-HTML-translation/Mathematica/csv-to-html-translation.mathematica b/Task/CSV-to-HTML-translation/Mathematica/csv-to-html-translation.mathematica new file mode 100644 index 0000000000..c8c23ec897 --- /dev/null +++ b/Task/CSV-to-HTML-translation/Mathematica/csv-to-html-translation.mathematica @@ -0,0 +1,36 @@ +a="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!"; +(*Naive*) +StringJoin["\n",Map[StringJoin["\n"]&, +StringSplit[StringReplace[a,{","->"
",#,"
","<"->"<",">"->">"}],"\n"]] +,"
"] +(*Extra*) +StringJoin["\n",StringJoin["\n"]&[ +StringSplit[StringReplace[a,{","->"\n"]&, +StringSplit[StringReplace[a,{","->"
",#,"
","<"->"<",">"->">"}],"\n"]//First] +,Map[StringJoin["
",#,"
","<"->"<",">"->">"}],"\n"]//Rest] +,"
"] + +Output: + + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah;he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother;that's who!
The multitudeBehold his mother! Behold his mother!
+ + + + + + + + +
CharacterSpeech
The multitudeThe messiah! Show us the messiah!
Brians mother<angry>Now you listen here! He's not the messiah;he's a very naughty boy! Now go away!</angry>
The multitudeWho are you?
Brians motherI'm his mother;that's who!
The multitudeBehold his mother! Behold his mother!
diff --git a/Task/Caesar-cipher/Fantom/caesar-cipher.fantom b/Task/Caesar-cipher/Fantom/caesar-cipher.fantom new file mode 100644 index 0000000000..560f941e15 --- /dev/null +++ b/Task/Caesar-cipher/Fantom/caesar-cipher.fantom @@ -0,0 +1,52 @@ +class Main +{ + static Int shift (Int char, Int key) + { + newChar := char + key + if (char >= 'a' && char <= 'z') + { + if (newChar - 'a' < 0) { newChar += 26 } + if (newChar - 'a' >= 26) { newChar -= 26 } + } + else if (char >= 'A' && char <= 'Z') + { + if (newChar - 'A' < 0) { newChar += 26 } + if (newChar - 'A' >= 26) { newChar -= 26 } + } + else // not alphabetic, so keep as is + { + newChar = char + } + return newChar + } + + static Str shiftStr (Str msg, Int key) + { + res := StrBuf() + msg.each { res.addChar (shift(it, key)) } + return res.toStr + } + + static Str encode (Str msg, Int key) + { + return shiftStr (msg, key) + } + + static Str decode (Str msg, Int key) + { + return shiftStr (msg, -key) + } + + static Void main (Str[] args) + { + if (args.size == 2) + { + msg := args[0] + key := Int(args[1]) + + echo ("$msg with key $key") + echo ("Encode: ${encode(msg, key)}") + echo ("Decode: ${decode(encode(msg, key), key)}") + } + } +} diff --git a/Task/Caesar-cipher/GAP/caesar-cipher.gap b/Task/Caesar-cipher/GAP/caesar-cipher.gap new file mode 100644 index 0000000000..0a3b660ca3 --- /dev/null +++ b/Task/Caesar-cipher/GAP/caesar-cipher.gap @@ -0,0 +1,26 @@ +CaesarCipher := function(s, n) + local r, c, i, lower, upper; + lower := "abcdefghijklmnopqrstuvwxyz"; + upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + r := ""; + for c in s do + i := Position(lower, c); + if i <> fail then + Add(r, lower[RemInt(i + n - 1, 26) + 1]); + else + i := Position(upper, c); + if i <> fail then + Add(r, upper[RemInt(i + n - 1, 26) + 1]); + else + Add(r, c); + fi; + fi; + od; + return r; +end; + +CaesarCipher("IBM", 25); +# "HAL" + +CaesarCipher("Vgg cphvi wzdibn vmz wjmi amzz viy zlpvg di ydbidot viy mdbcon.", 5); +# "All human beings are born free and equal in dignity and rights." diff --git a/Task/Caesar-cipher/Groovy/caesar-cipher.groovy b/Task/Caesar-cipher/Groovy/caesar-cipher.groovy new file mode 100644 index 0000000000..d444b882b4 --- /dev/null +++ b/Task/Caesar-cipher/Groovy/caesar-cipher.groovy @@ -0,0 +1,24 @@ +def caeserEncode(int ​cipherKey, String text) { + def builder = new StringBuilder() + text.each { character -> + int ch = character[0] as char + switch(ch) { + case 'a'..'z': ch = ((ch - 97 + cipherKey) % 26 + 97); break + case 'A'..'Z': ch = ((ch - 65 + cipherKey) % 26 + 65); break + } + builder.append(ch as char) + } + builder.toString() +} +def caeserDecode(int cipherKey, String text) { caeserEncode(26 - cipherKey, text) } + +def plainText = "The Quick Brown Fox jumped over the lazy dog" +def cipherKey = 12 +def cipherText = caeserEncode(cipherKey, plainText) +def decodedText = caeserDecode(cipherKey, cipherText) + +println "plainText: $plainText" +println "cypherText($cipherKey): $cipherText" +println "decodedText($cipherKey): $decodedText" + +assert plainText == decodedText​​ diff --git a/Task/Caesar-cipher/Icon/caesar-cipher.icon b/Task/Caesar-cipher/Icon/caesar-cipher.icon new file mode 100644 index 0000000000..83ac0ef86d --- /dev/null +++ b/Task/Caesar-cipher/Icon/caesar-cipher.icon @@ -0,0 +1,16 @@ +procedure main() +ctext := caesar(ptext := map("The quick brown fox jumped over the lazy dog")) +dtext := caesar(ctext,,"decrypt") +write("Plain text = ",image(ptext)) +write("Encphered text = ",image(ctext)) +write("Decphered text = ",image(dtext)) +end + +procedure caesar(text,k,mode) #: mono-alphabetic shift cipher +/k := 3 +k := (((k % *&lcase) + *&lcase) % *&lcase) + 1 +case mode of { + &null|"e"|"encrypt": return map(text,&lcase,(&lcase||&lcase)[k+:*&lcase]) + "d"|"decrypt" : return map(text,(&lcase||&lcase)[k+:*&lcase],&lcase) + } +end diff --git a/Task/Caesar-cipher/J/caesar-cipher-1.j b/Task/Caesar-cipher/J/caesar-cipher-1.j new file mode 100644 index 0000000000..0d21093fa9 --- /dev/null +++ b/Task/Caesar-cipher/J/caesar-cipher-1.j @@ -0,0 +1,2 @@ +cndx=: [: , 65 97 +/ 26 | (i.26)&+ +caesar=: (cndx 0)}&a.@u:@cndx@[ {~ a.i.] diff --git a/Task/Caesar-cipher/J/caesar-cipher-2.j b/Task/Caesar-cipher/J/caesar-cipher-2.j new file mode 100644 index 0000000000..a9078850b4 --- /dev/null +++ b/Task/Caesar-cipher/J/caesar-cipher-2.j @@ -0,0 +1,2 @@ + 2 caesar 'This simple "monoalphabetic substitution cipher" provides almost no security, ...' +Vjku ukorng "oqpqcnrjcdgvke uwduvkvwvkqp ekrjgt" rtqxkfgu cnoquv pq ugewtkva, ... diff --git a/Task/Caesar-cipher/J/caesar-cipher-3.j b/Task/Caesar-cipher/J/caesar-cipher-3.j new file mode 100644 index 0000000000..f981e1192f --- /dev/null +++ b/Task/Caesar-cipher/J/caesar-cipher-3.j @@ -0,0 +1 @@ +CAESAR=:1 :'(26|m&+)&.((26{.64}.a.)&i.)' diff --git a/Task/Caesar-cipher/J/caesar-cipher-4.j b/Task/Caesar-cipher/J/caesar-cipher-4.j new file mode 100644 index 0000000000..eb37e971c7 --- /dev/null +++ b/Task/Caesar-cipher/J/caesar-cipher-4.j @@ -0,0 +1,2 @@ + 20 CAESAR 'HI' +BC diff --git a/Task/Caesar-cipher/Liberty-BASIC/caesar-cipher.liberty b/Task/Caesar-cipher/Liberty-BASIC/caesar-cipher.liberty new file mode 100644 index 0000000000..2f8a11c1d3 --- /dev/null +++ b/Task/Caesar-cipher/Liberty-BASIC/caesar-cipher.liberty @@ -0,0 +1,24 @@ +key = 7 + +Print "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + +'Encrypt the text +Print CaesarCypher$("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", key) + +'Decrypt the text by changing the key to (26 - key) +Print CaesarCypher$(CaesarCypher$("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", key), (26 - key)) + +Function CaesarCypher$(string$, key) + If (key < 0) Or (key > 25) Then _ + CaesarCypher$ = "Key is Ouside of Bounds" : Exit Function + For i = 1 To Len(string$) + rotate = Asc(Mid$(string$, i, 1)) + rotate = (rotate + key) + If Asc(Mid$(string$, i, 1)) > Asc("Z") Then + If rotate > Asc("z") Then rotate = (Asc("a") + (rotate - Asc("z")) - 1) + Else + If rotate > Asc("Z") Then rotate = (Asc("A") + (rotate - Asc("Z")) - 1) + End If + CaesarCypher$ = (CaesarCypher$ + Chr$(rotate)) + Next i +End Function diff --git a/Task/Caesar-cipher/Logo/caesar-cipher.logo b/Task/Caesar-cipher/Logo/caesar-cipher.logo new file mode 100644 index 0000000000..815cde4bfb --- /dev/null +++ b/Task/Caesar-cipher/Logo/caesar-cipher.logo @@ -0,0 +1,34 @@ +; some useful constants +make "lower_a ascii "a +make "lower_z ascii "z +make "upper_a ascii "A +make "upper_z ascii "Z + +; encipher a single character +to encipher_char :char :key + local "code make "code ascii :char + local "base make "base 0 + ifelse [and (:code >= :lower_a) (:code <= :lower_z)] [make "base :lower_a] [ + if [and (:code >= :upper_a) (:code <= :upper_z)] [make "base :upper_a] ] + ifelse [:base > 0] [ + output char (:base + (modulo ( :code - :base + :key ) 26 )) + ] [ + output :char + ] +end + +; encipher a whole string +to caesar_cipher :string :key + output map [encipher_char ? :key] :string +end + +; Demo +make "plaintext "|The five boxing wizards jump quickly| +make "key 3 +make "ciphertext caesar_cipher :plaintext :key +make "recovered caesar_cipher :ciphertext -:key + +print sentence "| Original:| :plaintext +print sentence "|Encrypted:| :ciphertext +print sentence "|Recovered:| :recovered +bye diff --git a/Task/Caesar-cipher/Maple/caesar-cipher.maple b/Task/Caesar-cipher/Maple/caesar-cipher.maple new file mode 100644 index 0000000000..66a7fc27fa --- /dev/null +++ b/Task/Caesar-cipher/Maple/caesar-cipher.maple @@ -0,0 +1,5 @@ +> StringTools:-Encode( "The five boxing wizards jump quickly", encoding = alpharot[3] ); + "Wkh ilyh eralqj zlcdugv mxps txlfnob" + +> StringTools:-Encode( %, encoding = alpharot[ 23 ] ); + "The five boxing wizards jump quickly" diff --git a/Task/Caesar-cipher/Mathematica/caesar-cipher.mathematica b/Task/Caesar-cipher/Mathematica/caesar-cipher.mathematica new file mode 100644 index 0000000000..14d801fb45 --- /dev/null +++ b/Task/Caesar-cipher/Mathematica/caesar-cipher.mathematica @@ -0,0 +1 @@ +cypher[mesg_String,n_Integer]:=StringReplace[mesg,Flatten[Thread[Rule[#,RotateLeft[#,3]]]&/@CharacterRange@@@{{"a","z"},{"A","Z"}}]] diff --git a/Task/Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss b/Task/Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss new file mode 100644 index 0000000000..04f2638ee1 --- /dev/null +++ b/Task/Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss @@ -0,0 +1 @@ +RIGHTCLICK:CLOCK,ADJUST DATE AND TIME,BUTTON:CANCEL diff --git a/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon b/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon new file mode 100644 index 0000000000..8d97ab5b6b --- /dev/null +++ b/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon @@ -0,0 +1,48 @@ +$include "REALIZE.ICN" + +LINK DATETIME +$define ISLEAPYEAR IsLeapYear +$define JULIAN julian + +PROCEDURE MAIN(A) +PRINTCALENDAR(\A$<1$>|1969) +END + +PROCEDURE PRINTCALENDAR(YEAR) + COLS := 3 + MONS := $<$> + "JANUARY FEBRUARY MARCH APRIL MAY JUNE " || + "JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER " ? + WHILE PUT(MONS, TAB(FIND(" "))) DO MOVE(1) + + WRITE(CENTER("$",COLS * 24 + 4)) + WRITE(CENTER(YEAR,COLS * 24 + 4), CHAR(10)) + + M := LIST(COLS) + EVERY MON := 0 TO 9 BY COLS DO $( + WRITES(" ") + EVERY I := 1 TO COLS DO { + WRITES(CENTER(MONS$,24)) + M$ := CREATE CALENDARFORMATWEEK(1969,MON + I) + $) + WRITE() + EVERY 1 TO 7 DO $( + EVERY C := 1 TO COLS DO $( + WRITES(" ") + EVERY 1 TO 7 DO WRITES(RIGHT(@M$,3)) + $) + WRITE() + $) + $) +END + +PROCEDURE CALENDARFORMATWEEK(YEAR,M) +STATIC D +INITIAL D := $<31,28,31,30,31,30,31,31,30,31,30,31$> + +EVERY SUSPEND "SU"|"MO"|"TU"|"WE"|"TH"|"FR"|"SA" +EVERY 1 TO (DAY := (JULIAN(M,1,YEAR)+1)%7) DO SUSPEND "" +EVERY SUSPEND 1 TO D$ DO DAY +:= 1 +IF M = 2 & ISLEAPYEAR(YEAR) THEN SUSPEND (DAY +:= 1, 29) +EVERY DAY TO (6*7) DO SUSPEND "" +END diff --git a/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon b/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon new file mode 100644 index 0000000000..7d0c1f509e --- /dev/null +++ b/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon @@ -0,0 +1,25 @@ +$define PROCEDURE procedure +$define END end +$define WRITE write +$define WRITES writes +$define SUSPEND suspend +$define DO do +$define TO to +$define EVERY every +$define LIST list +$define WHILE while +$define MAIN main +$define PUT put +$define TAB tab +$define MOVE move +$define CHAR move +$define CENTER center +$define RIGHT right +$define FIND find +$define STATIC static +$define INITIAL initial +$define CREATE create +$define LINK link +$define IF if +$define THEN then +$define BY by diff --git a/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j b/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j new file mode 100644 index 0000000000..aaf2698c08 --- /dev/null +++ b/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j @@ -0,0 +1,10 @@ +B=: + 4 100 400 -/@:<.@:%~ <: +M=: 28+ 3, (10$5$3 2),~ 0 ~:/@:= 4 100 400 | ] +R=: (7 -@| B+ 0, +/\@}:@M) |."0 1 (0,#\#~41) (]&:>: *"1 >/)~ M +H=. _3(_11&{.)\'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC' +H=. 'SU MO TU WE TH FR SA',:"1~H +C=: H <@,"(2) 12 6 21 }."1@($,) (' ',3 ":,.#\#~31) {~ R +D=: 0 ": -@<.@%&21@+&1@[ ]\ C@] +L=: |."0 1~ +/ .(*./\@:=)"1&' ' +E=: (|."0 1~ _2 <.@%~ +/ .(*./\.@:=)"1&' ')@:({."1) L +F=: 0 _1 }. 0 1 }. (2+[) E '[INSERT SNOOPY HERE]', ":@], D diff --git a/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j b/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j new file mode 100644 index 0000000000..d0ed499ec5 --- /dev/null +++ b/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j @@ -0,0 +1,22 @@ + 132 F 1969 + [INSERT SNOOPY HERE] + 1969 + ┌────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┐ + │ JAN │ FEB │ MAR │ APR │ MAY │ JUN │ + │SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│ + │ 1 2 3 4│ 1│ 1│ 1 2 3 4 5│ 1 2 3│ 1 2 3 4 5 6 7│ + │ 5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 2 3 4 5 6 7 8│ 6 7 8 9 10 11 12│ 4 5 6 7 8 9 10│ 8 9 10 11 12 13 14│ + │12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│ 9 10 11 12 13 14 15│13 14 15 16 17 18 19│11 12 13 14 15 16 17│15 16 17 18 19 20 21│ + │19 20 21 22 23 24 25│16 17 18 19 20 21 22│16 17 18 19 20 21 22│20 21 22 23 24 25 26│18 19 20 21 22 23 24│22 23 24 25 26 27 28│ + │26 27 28 29 30 31 │23 24 25 26 27 28 │23 24 25 26 27 28 29│27 28 29 30 │25 26 27 28 29 30 31│29 30 │ + │ │ │30 31 │ │ │ │ + ├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤ + │ JUL │ AUG │ SEP │ OCT │ NOV │ DEC │ + │SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│SU MO TU WE TH FR SA│ + │ 1 2 3 4 5│ 1 2│ 1 2 3 4 5 6│ 1 2 3 4│ 1│ 1 2 3 4 5 6│ + │ 6 7 8 9 10 11 12│ 3 4 5 6 7 8 9│ 7 8 9 10 11 12 13│ 5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 7 8 9 10 11 12 13│ + │13 14 15 16 17 18 19│10 11 12 13 14 15 16│14 15 16 17 18 19 20│12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│14 15 16 17 18 19 20│ + │20 21 22 23 24 25 26│17 18 19 20 21 22 23│21 22 23 24 25 26 27│19 20 21 22 23 24 25│16 17 18 19 20 21 22│21 22 23 24 25 26 27│ + │27 28 29 30 31 │24 25 26 27 28 29 30│28 29 30 │26 27 28 29 30 31 │23 24 25 26 27 28 29│28 29 30 31 │ + │ │31 │ │ │30 │ │ + └────────────────────┴────────────────────┴────────────────────┴────────────────────┴────────────────────┴────────────────────┘ diff --git a/Task/Calendar/Icon/calendar.icon b/Task/Calendar/Icon/calendar.icon new file mode 100644 index 0000000000..b4849be329 --- /dev/null +++ b/Task/Calendar/Icon/calendar.icon @@ -0,0 +1,44 @@ +procedure main(A) +printCalendar(\A[1]|1969) +end + +procedure printCalendar(year) #: Print a 3 column x 80 char calendar + cols := 3 # fixed width + mons := [] # table of months + "January February March April May June " || + "July August September October November December " ? + while put(mons, tab(find(" "))) do move(1) + + write(center("[Snoopy Picture]",cols * 24 + 4)) # mandatory .. + write(center(year,cols * 24 + 4), "\n") # ... headers + + M := list(cols) # coexpr container + every mon := 0 to 9 by cols do { # go through months by cols + writes(" ") + every i := 1 to cols do { + writes(center(mons[mon+i],24)) # header months + M[i] := create CalendarFormatWeek(1969,mon + i) # formatting coexpr + } + write() + every 1 to 7 do { # 1 to max rows + every c := 1 to cols do { # for each column + writes(" ") + every 1 to 7 do writes(right(@M[c],3)) # each row day element + } + write() + } + } +end + +link datetime + +procedure CalendarFormatWeek(year,m) #: Format Week for Calendar +static D +initial D := [31,28,31,30,31,30,31,31,30,31,30,31] + +every suspend "Su"|"Mo"|"Tu"|"We"|"Th"|"Fr"|"Sa" # header +every 1 to (d := (julian(m,1,year)+1)%7) do suspend "" # lead day alignment +every suspend 1 to D[m] do d +:= 1 # days +if m = 2 & IsLeapYear(year) then suspend (d +:= 1, 29) # LY adjustment +every d to (6*7) do suspend "" # trailer alignment +end diff --git a/Task/Calendar/J/calendar-1.j b/Task/Calendar/J/calendar-1.j new file mode 100644 index 0000000000..7f1092f381 --- /dev/null +++ b/Task/Calendar/J/calendar-1.j @@ -0,0 +1,5 @@ +require 'dates format' NB. J6.x +require 'dates general/misc/format' NB. J7.x +calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) +calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] +formatCalendar=: calTitle , calBody diff --git a/Task/Calendar/J/calendar-2.j b/Task/Calendar/J/calendar-2.j new file mode 100644 index 0000000000..db9154cac3 --- /dev/null +++ b/Task/Calendar/J/calendar-2.j @@ -0,0 +1,39 @@ + 80 formatCalendar 1969 + [Insert Snoopy here] + 1969 + + Jan │ Feb │ Mar + Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa + 1 2 3 4│ 1│ 1 + 5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 2 3 4 5 6 7 8 + 12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│ 9 10 11 12 13 14 15 + 19 20 21 22 23 24 25│ 16 17 18 19 20 21 22│ 16 17 18 19 20 21 22 + 26 27 28 29 30 31 │ 23 24 25 26 27 28 │ 23 24 25 26 27 28 29 + │ │ 30 31 +─────────────────────┼─────────────────────┼───────────────────── + Apr │ May │ Jun + Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa + 1 2 3 4 5│ 1 2 3│ 1 2 3 4 5 6 7 + 6 7 8 9 10 11 12│ 4 5 6 7 8 9 10│ 8 9 10 11 12 13 14 + 13 14 15 16 17 18 19│ 11 12 13 14 15 16 17│ 15 16 17 18 19 20 21 + 20 21 22 23 24 25 26│ 18 19 20 21 22 23 24│ 22 23 24 25 26 27 28 + 27 28 29 30 │ 25 26 27 28 29 30 31│ 29 30 + │ │ +─────────────────────┼─────────────────────┼───────────────────── + Jul │ Aug │ Sep + Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa + 1 2 3 4 5│ 1 2│ 1 2 3 4 5 6 + 6 7 8 9 10 11 12│ 3 4 5 6 7 8 9│ 7 8 9 10 11 12 13 + 13 14 15 16 17 18 19│ 10 11 12 13 14 15 16│ 14 15 16 17 18 19 20 + 20 21 22 23 24 25 26│ 17 18 19 20 21 22 23│ 21 22 23 24 25 26 27 + 27 28 29 30 31 │ 24 25 26 27 28 29 30│ 28 29 30 + │ 31 │ +─────────────────────┼─────────────────────┼───────────────────── + Oct │ Nov │ Dec + Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa│ Su Mo Tu We Th Fr Sa + 1 2 3 4│ 1│ 1 2 3 4 5 6 + 5 6 7 8 9 10 11│ 2 3 4 5 6 7 8│ 7 8 9 10 11 12 13 + 12 13 14 15 16 17 18│ 9 10 11 12 13 14 15│ 14 15 16 17 18 19 20 + 19 20 21 22 23 24 25│ 16 17 18 19 20 21 22│ 21 22 23 24 25 26 27 + 26 27 28 29 30 31 │ 23 24 25 26 27 28 29│ 28 29 30 31 + │ 30 │ diff --git a/Task/Calendar/Mathematica/calendar-1.mathematica b/Task/Calendar/Mathematica/calendar-1.mathematica new file mode 100644 index 0000000000..7d272ca4ef --- /dev/null +++ b/Task/Calendar/Mathematica/calendar-1.mathematica @@ -0,0 +1 @@ +Needs["Calendar`"]; diff --git a/Task/Calendar/Mathematica/calendar-2.mathematica b/Task/Calendar/Mathematica/calendar-2.mathematica new file mode 100644 index 0000000000..f278478a34 --- /dev/null +++ b/Task/Calendar/Mathematica/calendar-2.mathematica @@ -0,0 +1,23 @@ +monthlyCalendar[y_, m_] := + Module[{ + days = {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}, + months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + d1, shortDays, offset, daysInMonth}, + + d1 = DayOfWeek[{y, m, 1}]; + + daysInMonth[year_, month_] := DaysBetween[{year, month, 1}, {If[month == 12, year + 1, year], If[month == 12, 1, month + 1], 1}]; + + shortDays = (StringTake[ToString[#], 3] & /@ days); + + offset = d1 /. Thread[days -> Range[0, 6]]; + + Grid[ + Prepend[ + Prepend[ + Partition[ + PadRight[PadLeft[Range[daysInMonth[y, m]], daysInMonth[y, m] + offset, ""], + 36, "" ], + 7], + shortDays], + {months[[m]], SpanFromLeft}]]] diff --git a/Task/Calendar/Mathematica/calendar-3.mathematica b/Task/Calendar/Mathematica/calendar-3.mathematica new file mode 100644 index 0000000000..7e2d18a6b4 --- /dev/null +++ b/Task/Calendar/Mathematica/calendar-3.mathematica @@ -0,0 +1 @@ + yearlyCalendar[y_] := Grid[Partition[Table[monthlyCalendar[y, k], {k, 12}], 3], Spacings -> {4, 2}]; diff --git a/Task/Call-a-foreign-language-function/Factor/call-a-foreign-language-function.factor b/Task/Call-a-foreign-language-function/Factor/call-a-foreign-language-function.factor new file mode 100644 index 0000000000..5f8315feba --- /dev/null +++ b/Task/Call-a-foreign-language-function/Factor/call-a-foreign-language-function.factor @@ -0,0 +1,4 @@ +FUNCTION: char* strdup ( c-string s ) ; + +: my-strdup ( str -- str' ) + strdup [ utf8 alien>string ] [ (free) ] bi ; diff --git a/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-1.j b/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-1.j new file mode 100644 index 0000000000..5103d0709b --- /dev/null +++ b/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-1.j @@ -0,0 +1,4 @@ +require 'dll' +strdup=: 'msvcrt.dll _strdup >x *' cd < +free=: 'msvcrt.dll free n x' cd < +getstr=: free ] memr@,&0 _1 diff --git a/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-2.j b/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-2.j new file mode 100644 index 0000000000..fbcf3b1575 --- /dev/null +++ b/Task/Call-a-foreign-language-function/J/call-a-foreign-language-function-2.j @@ -0,0 +1,2 @@ + getstr@strdup 'Hello World!' +Hello World! diff --git a/Task/Call-a-foreign-language-function/Lisaac/call-a-foreign-language-function.lisaac b/Task/Call-a-foreign-language-function/Lisaac/call-a-foreign-language-function.lisaac new file mode 100644 index 0000000000..4cdbb77375 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Lisaac/call-a-foreign-language-function.lisaac @@ -0,0 +1,24 @@ +Section Header + ++ name := TEST_C_INTERFACE; + +// this will be inserted in front of the program +- external := `#include `; + +Section Public + +- main <- ( + + s : STRING_CONSTANT; + + p : NATIVE_ARRAY[CHARACTER]; + + s := "Hello World!"; + p := s.to_external; + // this will be inserted in-place + // use `expr`:type to tell Lisaac what's the type of the external expression + p := `strdup(@p)` : NATIVE_ARRAY[CHARACTER]; + s.print; + '='.print; + p.println; + // this will also be inserted in-place, expression type disregarded + `free(@p)`; +); diff --git a/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-1.maple b/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-1.maple new file mode 100644 index 0000000000..b75e5ececf --- /dev/null +++ b/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-1.maple @@ -0,0 +1,3 @@ +> strdup := define_external( strdup, s::string, RETURN::string, LIB = "/lib/libc.so.6" ): +> strdup( "foo" ); + "foo" diff --git a/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-2.maple b/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-2.maple new file mode 100644 index 0000000000..a664cb6b88 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Maple/call-a-foreign-language-function-2.maple @@ -0,0 +1,11 @@ +> csin := define_external( sin, s::float[8], RETURN::float[8], LIB = "libm.so" ); +csin := proc(s::numeric) +option call_external, define_external(sin, s::float[8], +RETURN::float[8], LIB = "libm.so"); + call_external( + Array(1..8, [...], datatype = integer[4], readonly), false, + args) +end proc + +> csin( evalf( Pi / 2 ) ); + 1. diff --git a/Task/Call-a-foreign-language-function/Mathematica/call-a-foreign-language-function.mathematica b/Task/Call-a-foreign-language-function/Mathematica/call-a-foreign-language-function.mathematica new file mode 100644 index 0000000000..0389652b94 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Mathematica/call-a-foreign-language-function.mathematica @@ -0,0 +1,3 @@ +Needs["NETLink`"]; +externalstrdup = DefineDLLFunction["_strdup", "msvcrt.dll", "string", {"string"}]; +Print["Duplicate: ", externalstrdup["Hello world!"]] diff --git a/Task/Call-a-foreign-language-function/Maxima/call-a-foreign-language-function.maxima b/Task/Call-a-foreign-language-function/Maxima/call-a-foreign-language-function.maxima new file mode 100644 index 0000000000..bb447464f0 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Maxima/call-a-foreign-language-function.maxima @@ -0,0 +1,9 @@ +/* Maxima is written in Lisp and can call Lisp functions. +Use load("funcs.lisp"), or inside Maxima: */ + +to_lisp(); +> (defun $f (a b) (+ a b)) +> (to-maxima) + +f(5, 6); +11 diff --git a/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-1.mod2 b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-1.mod2 new file mode 100644 index 0000000000..3214018c8c --- /dev/null +++ b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-1.mod2 @@ -0,0 +1,68 @@ +#include + +int Initialize (void) +{ + if ( vga_init () == 0 ) + return 1; + else + return 0; +} + +void SetMode (int newmode) +{ + vga_setmode (newmode); +} + +int GetMode (void) +{ + return vga_getcurrentmode (); +} + +int MaxWidth (void) +{ + return vga_getxdim (); +} + +int MaxHeight (void) +{ + return vga_getydim (); +} + +void Clear (void) +{ + vga_clear (); +} +void SetColour (int colour) +{ + vga_setcolor (colour); +} + +void SetEGAcolour (int colour) +{ + vga_setegacolor (colour); +} + +void SetRGB (int red, int green, int blue) +{ + vga_setrgbcolor (red, green, blue); +} + +void DrawLine (int x0, int y0, int dx, int dy) +{ + vga_drawline (x0, y0, x0 + dx, y0 + dy); +} + +void Plot (int x, int y) +{ + vga_drawpixel (x, y); +} + +int ThisColour (int x, int y) +{ + return vga_getpixel (x, y); +} + +void GetKey (char *ch) +{ + *ch = vga_getkey (); +} diff --git a/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-2.mod2 b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-2.mod2 new file mode 100644 index 0000000000..5fa5e84169 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-2.mod2 @@ -0,0 +1,32 @@ +FOREIGN MODULE Vga; + +TYPE EGAcolour = (black, blue, green, cyan, red, pink, brown, white, + GREY, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE); + +PROCEDURE Initialize () : BOOLEAN; + +PROCEDURE MaxWidth () : CARDINAL; + +PROCEDURE MaxHeight () : CARDINAL; + +PROCEDURE Clear; + +PROCEDURE SetColour (colour : CARDINAL); + +PROCEDURE SetEGAcolour (colour : CARDINAL); + +PROCEDURE SetRGB (red, green, blue : CARDINAL); + +PROCEDURE DrawLine (x0, y0, dx, dy : CARDINAL); + +PROCEDURE Plot (x, y : CARDINAL); + +PROCEDURE ThisColour (x, y : CARDINAL) : CARDINAL; + +PROCEDURE SetMode (newmode : CARDINAL); + +PROCEDURE GetMode () : CARDINAL; + +PROCEDURE GetKey (VAR ch : CHAR); + +END Vga. diff --git a/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-3.mod2 b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-3.mod2 new file mode 100644 index 0000000000..5859c74aea --- /dev/null +++ b/Task/Call-a-foreign-language-function/Modula-2/call-a-foreign-language-function-3.mod2 @@ -0,0 +1,33 @@ +MODULE svg01; + +FROM InOut IMPORT Read, Write, WriteBf, WriteString; + +IMPORT Vga; + +VAR OldMode, x, y : CARDINAL; + ch : CHAR; + +BEGIN + IF Vga.Initialize () = FALSE THEN + WriteString ('Could not start SVGAlib libraries. Aborting...'); + WriteBf; + HALT + END; + OldMode := Vga.GetMode (); + Vga.SetMode (4); + Vga.SetColour (14); + Vga.Clear (); + Vga.SetColour (10); + FOR y := 125 TO 175 DO + FOR x := 100 TO 500 DO + Vga.Plot (x, y) + END + END; + LOOP + Read (ch); + IF ch = 'X' THEN EXIT END + END; + Vga.SetMode (OldMode); + Write (ch); + WriteBf; +END svg01. diff --git a/Task/Call-a-foreign-language-function/Modula-3/call-a-foreign-language-function.mod3 b/Task/Call-a-foreign-language-function/Modula-3/call-a-foreign-language-function.mod3 new file mode 100644 index 0000000000..7ae82eaa38 --- /dev/null +++ b/Task/Call-a-foreign-language-function/Modula-3/call-a-foreign-language-function.mod3 @@ -0,0 +1,17 @@ +UNSAFE MODULE Foreign EXPORTS Main; + +IMPORT IO, Ctypes, Cstring, M3toC; + +VAR string1, string2: Ctypes.const_char_star; + +BEGIN + string1 := M3toC.CopyTtoS("Foobar"); + string2 := M3toC.CopyTtoS("Foobar2"); + IF Cstring.strcmp(string1, string2) = 0 THEN + IO.Put("string1 = string2\n"); + ELSE + IO.Put("string1 # string2\n"); + END; + M3toC.FreeCopiedS(string1); + M3toC.FreeCopiedS(string2); +END Foreign. diff --git a/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-1.j b/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-1.j new file mode 100644 index 0000000000..b947111963 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-1.j @@ -0,0 +1,12 @@ +require 'dll' +strdup=: 'msvcrt.dll _strdup >x *' cd < +free=: 'msvcrt.dll free n x' cd < +getstr=: free ] memr@,&0 _1 + +DupStr=:verb define + try. + getstr@strdup y + catch. + y + end. +) diff --git a/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-2.j b/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-2.j new file mode 100644 index 0000000000..e5010535ca --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/J/call-a-function-in-a-shared-library-2.j @@ -0,0 +1,4 @@ + DupStr 'hello' +hello + getstr@strdup ::] 'hello' +hello diff --git a/Task/Call-a-function-in-a-shared-library/Julia/call-a-function-in-a-shared-library.julia b/Task/Call-a-function-in-a-shared-library/Julia/call-a-function-in-a-shared-library.julia new file mode 100644 index 0000000000..26dc8e2edf --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Julia/call-a-function-in-a-shared-library.julia @@ -0,0 +1,3 @@ +#ccall((symbol, library), RetType, (ArgType1, ...), ArgVar1, ...) + ccall( (:GetDoubleClickTime, "User32"), stdcall, + Uint, (), ) diff --git a/Task/Call-a-function-in-a-shared-library/Maple/call-a-function-in-a-shared-library.maple b/Task/Call-a-function-in-a-shared-library/Maple/call-a-function-in-a-shared-library.maple new file mode 100644 index 0000000000..5df034b229 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Maple/call-a-function-in-a-shared-library.maple @@ -0,0 +1,3 @@ +> cfloor := define_external( floor, s::float[8], RETURN::float[8], LIB = "libm.so" ): +> cfloor( 2.3 ); + 2. diff --git a/Task/Call-a-function-in-a-shared-library/Mathematica/call-a-function-in-a-shared-library.mathematica b/Task/Call-a-function-in-a-shared-library/Mathematica/call-a-function-in-a-shared-library.mathematica new file mode 100644 index 0000000000..0d0c8137b6 --- /dev/null +++ b/Task/Call-a-function-in-a-shared-library/Mathematica/call-a-function-in-a-shared-library.mathematica @@ -0,0 +1,4 @@ +Needs["NETLink`"]; +externalFloor = DefineDLLFunction["floor", "msvcrt.dll", "double", { "double" }]; +externalFloor[4.2] +-> 4. diff --git a/Task/Call-a-function/Icon/call-a-function.icon b/Task/Call-a-function/Icon/call-a-function.icon new file mode 100644 index 0000000000..fc6a950b19 --- /dev/null +++ b/Task/Call-a-function/Icon/call-a-function.icon @@ -0,0 +1,30 @@ +procedure main() # demonstrate and describe function calling syntax and semantics + + # normal procedure/function calling + + f() # no arguments, also command context + f(x) # fixed number of arguments + f(x,h,w) # variable number of arguments (varargs) + y := f(x) # Obtaining the returned value of a function + + # procedures as first class values and string invocation + + f!L # Alternate calling syntax using a list as args + (if \x then f else g)() # call (f or g)() + f := write # assign a procedure + f("Write is now called") # ... and call it + "f"() # string invocation, procedure + "-"(1) # string invocation, operator + + # Co-expressions + + f{e1,e2} # parallel evaluation co-expression call + # equivalent to f([create e1, create e2]) + expr @ coexp # transmission of a single value to a coexpression + [e1,e2]@coexp # ... of multiple values (list) to a coexpression + coexp(e1,e2) # ... same as above but only in Unicon + + # Other + + f("x:=",1,"y:=",2) # named parameters (user defined) +end diff --git a/Task/Call-a-function/J/call-a-function-1.j b/Task/Call-a-function/J/call-a-function-1.j new file mode 100644 index 0000000000..fd26c1754e --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-1.j @@ -0,0 +1,2 @@ + verb noun + noun verb noun diff --git a/Task/Call-a-function/J/call-a-function-10.j b/Task/Call-a-function/J/call-a-function-10.j new file mode 100644 index 0000000000..09aa7a6682 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-10.j @@ -0,0 +1 @@ +f 1; 2; 3; 4; <5 diff --git a/Task/Call-a-function/J/call-a-function-11.j b/Task/Call-a-function/J/call-a-function-11.j new file mode 100644 index 0000000000..2551b65839 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-11.j @@ -0,0 +1 @@ +f 1; 2; 3; 4; 5 diff --git a/Task/Call-a-function/J/call-a-function-12.j b/Task/Call-a-function/J/call-a-function-12.j new file mode 100644 index 0000000000..7e307cf5d8 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-12.j @@ -0,0 +1 @@ +f 'george';'tom';'howard' diff --git a/Task/Call-a-function/J/call-a-function-13.j b/Task/Call-a-function/J/call-a-function-13.j new file mode 100644 index 0000000000..93d23d9679 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-13.j @@ -0,0 +1 @@ +1 2 3 f 'george';'tom';'howard' diff --git a/Task/Call-a-function/J/call-a-function-14.j b/Task/Call-a-function/J/call-a-function-14.j new file mode 100644 index 0000000000..bc53d50b41 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-14.j @@ -0,0 +1,6 @@ + obj=: conew'blank' + george__obj=: 1 + tom__obj=: 2 + howard__obj=: 3 + f obj + coerase obj diff --git a/Task/Call-a-function/J/call-a-function-15.j b/Task/Call-a-function/J/call-a-function-15.j new file mode 100644 index 0000000000..8a9430dad5 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-15.j @@ -0,0 +1 @@ +f 'george';1;'tom';2;'howard';3 diff --git a/Task/Call-a-function/J/call-a-function-16.j b/Task/Call-a-function/J/call-a-function-16.j new file mode 100644 index 0000000000..4b9617c803 --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-16.j @@ -0,0 +1 @@ +f ('george';1),('tom';2),:(howard';3) diff --git a/Task/Call-a-function/J/call-a-function-17.j b/Task/Call-a-function/J/call-a-function-17.j new file mode 100644 index 0000000000..9696a507fa --- /dev/null +++ b/Task/Call-a-function/J/call-a-function-17.j @@ -0,0 +1 @@ +f ('george';1);('tom';2);True] diff --git a/Task/Call-a-function/Mathematica/call-a-function-4.mathematica b/Task/Call-a-function/Mathematica/call-a-function-4.mathematica new file mode 100644 index 0000000000..23bf5e3405 --- /dev/null +++ b/Task/Call-a-function/Mathematica/call-a-function-4.mathematica @@ -0,0 +1,2 @@ +f[1,Option1->True] +f[1,Option1->True,Option2->False] diff --git a/Task/Call-a-function/Mathematica/call-a-function-5.mathematica b/Task/Call-a-function/Mathematica/call-a-function-5.mathematica new file mode 100644 index 0000000000..ea30a8d2d6 --- /dev/null +++ b/Task/Call-a-function/Mathematica/call-a-function-5.mathematica @@ -0,0 +1 @@ +f[Option1->True,Option2->False] diff --git a/Task/Call-a-function/Mathematica/call-a-function-6.mathematica b/Task/Call-a-function/Mathematica/call-a-function-6.mathematica new file mode 100644 index 0000000000..a13c8d7589 --- /dev/null +++ b/Task/Call-a-function/Mathematica/call-a-function-6.mathematica @@ -0,0 +1 @@ +f[1,2];f[2,3] diff --git a/Task/Call-a-function/Mathematica/call-a-function-7.mathematica b/Task/Call-a-function/Mathematica/call-a-function-7.mathematica new file mode 100644 index 0000000000..cef5752d25 --- /dev/null +++ b/Task/Call-a-function/Mathematica/call-a-function-7.mathematica @@ -0,0 +1 @@ +(#^2)&[3]; diff --git a/Task/Call-an-object-method/J/call-an-object-method-1.j b/Task/Call-an-object-method/J/call-an-object-method-1.j new file mode 100644 index 0000000000..25264b58d0 --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-1.j @@ -0,0 +1 @@ +methodName_className_ parameters diff --git a/Task/Call-an-object-method/J/call-an-object-method-2.j b/Task/Call-an-object-method/J/call-an-object-method-2.j new file mode 100644 index 0000000000..6068f2f45c --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-2.j @@ -0,0 +1 @@ +objectReference=:'' conew 'className' diff --git a/Task/Call-an-object-method/J/call-an-object-method-3.j b/Task/Call-an-object-method/J/call-an-object-method-3.j new file mode 100644 index 0000000000..43cbebdd8d --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-3.j @@ -0,0 +1 @@ +methodName__objectReference parameters diff --git a/Task/Call-an-object-method/J/call-an-object-method-4.j b/Task/Call-an-object-method/J/call-an-object-method-4.j new file mode 100644 index 0000000000..d349a7c4ed --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-4.j @@ -0,0 +1 @@ +parameters methodName_className_ parameters diff --git a/Task/Call-an-object-method/J/call-an-object-method-5.j b/Task/Call-an-object-method/J/call-an-object-method-5.j new file mode 100644 index 0000000000..69e51d8163 --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-5.j @@ -0,0 +1 @@ +parameters methodName__objectReference parameters diff --git a/Task/Call-an-object-method/J/call-an-object-method-6.j b/Task/Call-an-object-method/J/call-an-object-method-6.j new file mode 100644 index 0000000000..7b010f8be3 --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-6.j @@ -0,0 +1,2 @@ +classReference=: <'className' +methodName__classReference parameters diff --git a/Task/Call-an-object-method/J/call-an-object-method-7.j b/Task/Call-an-object-method/J/call-an-object-method-7.j new file mode 100644 index 0000000000..5f2ba0916d --- /dev/null +++ b/Task/Call-an-object-method/J/call-an-object-method-7.j @@ -0,0 +1 @@ +methodName_123_ parameters diff --git a/Task/Carmichael-3-strong-pseudoprimes/Mathematica/carmichael-3-strong-pseudoprimes.mathematica b/Task/Carmichael-3-strong-pseudoprimes/Mathematica/carmichael-3-strong-pseudoprimes.mathematica new file mode 100644 index 0000000000..eb92dfbed5 --- /dev/null +++ b/Task/Carmichael-3-strong-pseudoprimes/Mathematica/carmichael-3-strong-pseudoprimes.mathematica @@ -0,0 +1,8 @@ +Cases[Cases[ + Cases[Table[{p1, h3, d}, {p1, Array[Prime, PrimePi@61]}, {h3, 2, + p1 - 1}, {d, 1, h3 + p1 - 1}], {p1_Integer, h3_, d_} /; + PrimeQ[1 + (p1 - 1) (h3 + p1)/d] && + Divisible[p1^2 + d, h3] :> {p1, 1 + (p1 - 1) (h3 + p1)/d, h3}, + Infinity], {p1_, p2_, h3_} /; PrimeQ[1 + Floor[p1 p2/h3]] :> {p1, + p2, 1 + Floor[p1 p2/h3]}], {p1_, p2_, p3_} /; + Mod[p2 p3, p1 - 1] == 1 :> Print[p1, "*", p2, "*", p3]] diff --git a/Task/Case-sensitivity-of-identifiers/Frink/case-sensitivity-of-identifiers.frink b/Task/Case-sensitivity-of-identifiers/Frink/case-sensitivity-of-identifiers.frink new file mode 100644 index 0000000000..50e4e0d000 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Frink/case-sensitivity-of-identifiers.frink @@ -0,0 +1,4 @@ +dog = "Benjamin" +Dog = "Samba" +DOG = "Bernie" +println["There are three dogs named $dog, $Dog and $DOG"] diff --git a/Task/Case-sensitivity-of-identifiers/GAP/case-sensitivity-of-identifiers.gap b/Task/Case-sensitivity-of-identifiers/GAP/case-sensitivity-of-identifiers.gap new file mode 100644 index 0000000000..7e954c4513 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/GAP/case-sensitivity-of-identifiers.gap @@ -0,0 +1,15 @@ +# GAP is case sensitive +ThreeDogs := function() + local dog, Dog, DOG; + dog := "Benjamin"; + Dog := "Samba"; + DOG := "Bernie"; + if dog = DOG then + Print("There is just one dog named ", dog, "\n"); + else + Print("The three dogs are named ", dog, ", ", Dog, " and ", DOG, "\n"); + fi; +end; + +ThreeDogs(); +# The three dogs are named Benjamin, Samba and Bernie diff --git a/Task/Case-sensitivity-of-identifiers/Groovy/case-sensitivity-of-identifiers.groovy b/Task/Case-sensitivity-of-identifiers/Groovy/case-sensitivity-of-identifiers.groovy new file mode 100644 index 0000000000..04d6374ef7 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Groovy/case-sensitivity-of-identifiers.groovy @@ -0,0 +1,2 @@ +def dog = "Benjamin", Dog = "Samba", DOG = "Bernie" +println (dog == DOG ? "There is one dog named ${dog}" : "There are three dogs named ${dog}, ${Dog} and ${DOG}.") diff --git a/Task/Case-sensitivity-of-identifiers/Icon/case-sensitivity-of-identifiers.icon b/Task/Case-sensitivity-of-identifiers/Icon/case-sensitivity-of-identifiers.icon new file mode 100644 index 0000000000..a1e9047292 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Icon/case-sensitivity-of-identifiers.icon @@ -0,0 +1,12 @@ +procedure main() + + dog := "Benjamin" + Dog := "Samba" + DOG := "Bernie" + + if dog == DOG then + write("There is just one dog named ", dog,".") + else + write("The three dogs are named ", dog, ", ", Dog, " and ", DOG, ".") + +end diff --git a/Task/Case-sensitivity-of-identifiers/J/case-sensitivity-of-identifiers.j b/Task/Case-sensitivity-of-identifiers/J/case-sensitivity-of-identifiers.j new file mode 100644 index 0000000000..c2fd75e09a --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/J/case-sensitivity-of-identifiers.j @@ -0,0 +1,6 @@ + NB. These variables are all different + dog=: 'Benjamin' + Dog=: 'Samba' + DOG=: 'Bernie' + 'The three dogs are named ',dog,', ',Dog,', and ',DOG +The three dogs are named Benjamin, Samba, and Bernie diff --git a/Task/Case-sensitivity-of-identifiers/K/case-sensitivity-of-identifiers.k b/Task/Case-sensitivity-of-identifiers/K/case-sensitivity-of-identifiers.k new file mode 100644 index 0000000000..ba3bc48d8b --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/K/case-sensitivity-of-identifiers.k @@ -0,0 +1,5 @@ + dog: "Benjamin" + Dog: "Samba" + DOG: "Bernie" + "There are three dogs named ",dog,", ",Dog," and ",DOG +"There are three dogs named Benjamin, Samba and Bernie" diff --git a/Task/Case-sensitivity-of-identifiers/Liberty-BASIC/case-sensitivity-of-identifiers.liberty b/Task/Case-sensitivity-of-identifiers/Liberty-BASIC/case-sensitivity-of-identifiers.liberty new file mode 100644 index 0000000000..06b5e159f2 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Liberty-BASIC/case-sensitivity-of-identifiers.liberty @@ -0,0 +1,6 @@ +dog$ = "Benjamin" +Dog$ = "Samba" +DOG$ = "Bernie" +print "The three dogs are "; dog$; ", "; Dog$; " and "; DOG$; "." + +end diff --git a/Task/Case-sensitivity-of-identifiers/Maple/case-sensitivity-of-identifiers.maple b/Task/Case-sensitivity-of-identifiers/Maple/case-sensitivity-of-identifiers.maple new file mode 100644 index 0000000000..d26efb6283 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Maple/case-sensitivity-of-identifiers.maple @@ -0,0 +1,9 @@ +> dog, Dog, DOG := "Benjamin", "Samba", "Bernie": +> if nops( { dog, Dog, DOG } ) = 3 then +> printf( "There are three dogs named %s, %s and %s.\n", dog, Dog, DOG ) +> elif nops( { dog, Dog, DOG } ) = 2 then +> printf( "WTF? There are two dogs named %s and %s.\n", op( { dog, Dog, DOG } ) ) +> else +> printf( "There is one dog named %s.\n", dog ) +> end if: +There are three dogs named Benjamin, Samba and Bernie. diff --git a/Task/Case-sensitivity-of-identifiers/Mathematica/case-sensitivity-of-identifiers.mathematica b/Task/Case-sensitivity-of-identifiers/Mathematica/case-sensitivity-of-identifiers.mathematica new file mode 100644 index 0000000000..954120cce4 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Mathematica/case-sensitivity-of-identifiers.mathematica @@ -0,0 +1,4 @@ +dog = "Benjamin"; Dog = "Samba"; DOG = "Bernie"; +"The three dogs are named "<> dog <>", "<> Dog <>" and "<> DOG + +-> "The three dogs are named Benjamin, Samba and Bernie" diff --git a/Task/Case-sensitivity-of-identifiers/Maxima/case-sensitivity-of-identifiers.maxima b/Task/Case-sensitivity-of-identifiers/Maxima/case-sensitivity-of-identifiers.maxima new file mode 100644 index 0000000000..0a778ede45 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Maxima/case-sensitivity-of-identifiers.maxima @@ -0,0 +1,6 @@ +/* Maxima is case sensitive */ +a: 1$ +A: 2$ + +is(a = A); +false diff --git a/Task/Case-sensitivity-of-identifiers/Modula-2/case-sensitivity-of-identifiers.mod2 b/Task/Case-sensitivity-of-identifiers/Modula-2/case-sensitivity-of-identifiers.mod2 new file mode 100644 index 0000000000..6e45e3c6a2 --- /dev/null +++ b/Task/Case-sensitivity-of-identifiers/Modula-2/case-sensitivity-of-identifiers.mod2 @@ -0,0 +1,14 @@ +MODULE dog; + +IMPORT InOut; + +TYPE String = ARRAY [0..31] OF CHAR; + +VAR dog, Dog, DOG : String; + +(* No compiler error, so the rest is simple *) + +BEGIN + InOut.WriteString ("Three happy dogs."); + InOut.WriteLn +END dog. diff --git a/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-1.j b/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-1.j new file mode 100644 index 0000000000..be30044099 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-1.j @@ -0,0 +1,23 @@ +avg=: +/ % # + +havePoints=: e."1/~ i.@# + +catmullclark=:3 :0 + 'mesh points'=. y + face_point=. avg"2 mesh{points + point_face=. |: mesh havePoints points + avg_face_points=. point_face avg@#"1 2 face_point + edges=. ~.,/ meshEdges=. mesh /:~@,"+1|."1 mesh + edge_face=. *./"2 edges e."0 1/ mesh + edge_center=. avg"2 edges{points + edge_point=. (0.5*edge_center) + 0.25 * edge_face +/ .* face_point + point_edge=. |: edges havePoints points + avg_mid_edges=. point_edge avg@#"1 2 edge_center + n=. +/"1 point_edge + 'm3 m2 m1'=. (2,1,:n-3)%"1 n + new_coords=. (m1 * points) + (m2 * avg_face_points) + (m3 * avg_mid_edges) + pts=. face_point,edge_point,new_coords + c0=. (#edge_point)+ e0=. #face_point + msh=. (,c0+mesh),.(,e0+edges i. meshEdges),.((#i.)~/$mesh),.,e0+_1|."1 edges i. meshEdges + msh;pts +) diff --git a/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-2.j b/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-2.j new file mode 100644 index 0000000000..143f44bf4f --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/J/catmull-clark-subdivision-surface-2.j @@ -0,0 +1,33 @@ +NB.cube +points=: _1+2*#:i.8 +mesh=: 1 A."1 I.(,1-|.)8&$@#&0 1">4 2 1 + + catmullclark mesh;points +┌──────────┬─────────────────────────────┐ +│22 6 0 9│ 1 0 0│ +│23 7 0 6│ 0 1 0│ +│25 8 0 7│ 0 0 1│ +│24 9 0 8│ 0 0 _1│ +│20 10 1 12│ 0 _1 0│ +│21 11 1 10│ _1 0 0│ +│25 8 1 11│ 0.75 _0.75 0│ +│24 12 1 8│ 0.75 0 0.75│ +│19 13 2 14│ 0.75 0.75 0│ +│21 11 2 13│ 0.75 0 _0.75│ +│25 7 2 11│ _0.75 0.75 0│ +│23 14 2 7│ 0 0.75 0.75│ +│18 15 3 16│ 0 0.75 _0.75│ +│20 12 3 15│ _0.75 0 0.75│ +│24 9 3 12│ 0 _0.75 0.75│ +│22 16 3 9│ _0.75 0 _0.75│ +│18 17 4 16│ 0 _0.75 _0.75│ +│19 14 4 17│ _0.75 _0.75 0│ +│23 6 4 14│_0.555556 _0.555556 _0.555556│ +│22 16 4 6│_0.555556 _0.555556 0.555556│ +│18 17 5 15│_0.555556 0.555556 _0.555556│ +│19 13 5 17│_0.555556 0.555556 0.555556│ +│21 10 5 13│ 0.555556 _0.555556 _0.555556│ +│20 15 5 10│ 0.555556 _0.555556 0.555556│ +│ │ 0.555556 0.555556 _0.555556│ +│ │ 0.555556 0.555556 0.555556│ +└──────────┴─────────────────────────────┘ diff --git a/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-1.mathematica b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-1.mathematica new file mode 100644 index 0000000000..dc8f24786c --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-1.mathematica @@ -0,0 +1,6 @@ +subSetQ[large_,small_] := MemberQ[large,small] +subSetQ[large_,small_List] := And@@(MemberQ[large,#]&/@small) + +containing[groupList_,item_]:= Flatten[Position[groupList,group_/;subSetQ[group,item]]] + +ReplaceFace[face_]:=Transpose[Prepend[Transpose[{#[[1]],face,#[[2]]}&/@Transpose[Partition[face,2,1,1]//{#,RotateRight[#]}&]],face]] diff --git a/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-2.mathematica b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-2.mathematica new file mode 100644 index 0000000000..72c0bc9bb0 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-2.mathematica @@ -0,0 +1,28 @@ +CatMullClark[{Points_,faces_}]:=Block[{avgFacePoints,avgEdgePoints,updatedPoints,newEdgePoints,newPoints,edges,newFaces,weights,pointUpdate,edgeUpdate,newIndex}, +edges = DeleteDuplicates[Flatten[Partition[#,2,1,-1]&/@faces,1],Sort[#1]==Sort[#2]&]; +avgFacePoints=Mean[Points[[#]]] &/@ faces; +avgEdgePoints=Mean[Points[[#]]] &/@ edges; + +weights[vertex_]:= Count[faces,vertex,2]//{(#-3),1,2}/#&; +pointUpdate[vertex_]:= + If[Length[faces~containing~vertex]!=Length[edges~containing~vertex], + Mean[avgEdgePoints[[Select[edges~containing~vertex,holeQ[edges[[#]],faces]&]]]], + Total[weights[vertex]{ Points[[vertex]], Mean[avgFacePoints[[faces~containing~vertex]]], Mean[avgEdgePoints[[edges~containing~vertex]]]}] + ]; + +edgeUpdate[edge_]:= + If[Length[faces~containing~edge]==1, + Mean[Points[[edge]]], + Mean[Points[[Flatten[{edge, faces[[faces~containing~edge]]}]]]] + ]; + +updatedPoints = pointUpdate/@Range[1,Length[Points]]; +newEdgePoints = edgeUpdate/@edges; +newPoints = Join[updatedPoints,avgFacePoints,newEdgePoints]; + +newIndex[edge_/;Length[edge]==2] := Length[Points]+Length[faces]+Position[Sort/@edges,Sort@edge][[1,1]] +newIndex[face_] := Length[Points]+Position[faces,face][[1,1]] + +newFaces = Flatten[Map[newIndex[#,{Points,edges,faces}]&,ReplaceFace/@faces,{-2}],1]; +{newPoints,newFaces} +] diff --git a/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-3.mathematica b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-3.mathematica new file mode 100644 index 0000000000..210fb79ace --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-3.mathematica @@ -0,0 +1,5 @@ +{points,faces}=PolyhedronData["Cube",{"VertexCoordinates","FaceIndices"}]; + +Function[iteration, +Graphics3D[(Polygon[iteration[[1]][[#]]]&/@iteration[[2]])] +]/@NestList[CatMullClark,{points,faces},3]//GraphicsRow diff --git a/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-4.mathematica b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-4.mathematica new file mode 100644 index 0000000000..0241ab04a7 --- /dev/null +++ b/Task/Catmull-Clark-subdivision-surface/Mathematica/catmull-clark-subdivision-surface-4.mathematica @@ -0,0 +1,4 @@ +faces = Delete[faces, 6]; +Function[iteration, Graphics3D[ + (Polygon[iteration[[1]][[#]]] & /@ iteration[[2]]) + ]] /@ NestList[CatMullClark, {points, faces}, 3] // GraphicsRow diff --git a/Task/Character-codes/FALSE/character-codes.false b/Task/Character-codes/FALSE/character-codes.false new file mode 100644 index 0000000000..ca97865226 --- /dev/null +++ b/Task/Character-codes/FALSE/character-codes.false @@ -0,0 +1,2 @@ +'A." +"65, diff --git a/Task/Character-codes/Factor/character-codes.factor b/Task/Character-codes/Factor/character-codes.factor new file mode 100644 index 0000000000..73c6c08fe2 --- /dev/null +++ b/Task/Character-codes/Factor/character-codes.factor @@ -0,0 +1,4 @@ +CHAR: katakana-letter-a . +"ア" first . + +12450 1string print diff --git a/Task/Character-codes/Fantom/character-codes.fantom b/Task/Character-codes/Fantom/character-codes.fantom new file mode 100644 index 0000000000..d8d06ba5ae --- /dev/null +++ b/Task/Character-codes/Fantom/character-codes.fantom @@ -0,0 +1,4 @@ +fansh> 97.toChar +a +fansh> 'a'.toInt +97 diff --git a/Task/Character-codes/Frink/character-codes.frink b/Task/Character-codes/Frink/character-codes.frink new file mode 100644 index 0000000000..449dd3f3ea --- /dev/null +++ b/Task/Character-codes/Frink/character-codes.frink @@ -0,0 +1,4 @@ +println[char["a"]] // prints 97 +println[char[97]] // prints a +println[char["Frink rules!"]] // prints [70, 114, 105, 110, 107, 32, 114, 117, 108, 101, 115, 33] +println[[70, 114, 105, 110, 107, 32, 114, 117, 108, 101, 115, 33]] // prints "Frink rules!" diff --git a/Task/Character-codes/GAP/character-codes.gap b/Task/Character-codes/GAP/character-codes.gap new file mode 100644 index 0000000000..92d6697132 --- /dev/null +++ b/Task/Character-codes/GAP/character-codes.gap @@ -0,0 +1,5 @@ +# Code must be in 0 .. 255. +CHAR_INT(65); +# 'A' +INT_CHAR('Z'); +# 90 diff --git a/Task/Character-codes/Golfscript/character-codes-1.golf b/Task/Character-codes/Golfscript/character-codes-1.golf new file mode 100644 index 0000000000..6b0e1344f0 --- /dev/null +++ b/Task/Character-codes/Golfscript/character-codes-1.golf @@ -0,0 +1 @@ +97[]+''+p diff --git a/Task/Character-codes/Golfscript/character-codes-2.golf b/Task/Character-codes/Golfscript/character-codes-2.golf new file mode 100644 index 0000000000..41e090c06d --- /dev/null +++ b/Task/Character-codes/Golfscript/character-codes-2.golf @@ -0,0 +1,4 @@ +'a')\;p +'a'(\;p +'a'0=p +'a'{}/p diff --git a/Task/Character-codes/Groovy/character-codes.groovy b/Task/Character-codes/Groovy/character-codes.groovy new file mode 100644 index 0000000000..c22918d54f --- /dev/null +++ b/Task/Character-codes/Groovy/character-codes.groovy @@ -0,0 +1,2 @@ +printf ("%d\n", ('a' as char) as int) +printf ("%c\n", 97) diff --git a/Task/Character-codes/HicEst/character-codes.hicest b/Task/Character-codes/HicEst/character-codes.hicest new file mode 100644 index 0000000000..19db4fde36 --- /dev/null +++ b/Task/Character-codes/HicEst/character-codes.hicest @@ -0,0 +1 @@ +WRITE(Messagebox) ICHAR('a'), CHAR(97) diff --git a/Task/Character-codes/Icon/character-codes.icon b/Task/Character-codes/Icon/character-codes.icon new file mode 100644 index 0000000000..9f881a0aa6 --- /dev/null +++ b/Task/Character-codes/Icon/character-codes.icon @@ -0,0 +1,6 @@ +procedure main(arglist) +if *arglist > 0 then L := arglist else L := [97, "a"] + +every x := !L do + write(x, " ==> ", char(integer(x)) | ord(x) ) # char produces a character, ord produces a number +end diff --git a/Task/Character-codes/J/character-codes.j b/Task/Character-codes/J/character-codes.j new file mode 100644 index 0000000000..064f5ef3da --- /dev/null +++ b/Task/Character-codes/J/character-codes.j @@ -0,0 +1,5 @@ + 4 u: 97 98 99 9786 +abc☺ + + 3 u: 7 u: 'abc☺' +97 98 99 9786 diff --git a/Task/Character-codes/Joy/character-codes.joy b/Task/Character-codes/Joy/character-codes.joy new file mode 100644 index 0000000000..1eb1a274d7 --- /dev/null +++ b/Task/Character-codes/Joy/character-codes.joy @@ -0,0 +1,2 @@ +'a ord. +97 chr. diff --git a/Task/Character-codes/K/character-codes.k b/Task/Character-codes/K/character-codes.k new file mode 100644 index 0000000000..038c6a31d1 --- /dev/null +++ b/Task/Character-codes/K/character-codes.k @@ -0,0 +1,5 @@ + _ic "abcABC" +97 98 99 65 66 67 + + _ci 97 98 99 65 66 67 +"abcABC" diff --git a/Task/Character-codes/Lang5/character-codes.lang5 b/Task/Character-codes/Lang5/character-codes.lang5 new file mode 100644 index 0000000000..a9a0bb8f3e --- /dev/null +++ b/Task/Character-codes/Lang5/character-codes.lang5 @@ -0,0 +1,9 @@ +: CHAR "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[" comb + '\\ comb -1 remove append "]^_`abcdefghijklmnopqrstuvwxyz{|}~" comb append ; +: CODE 95 iota 33 + ; : comb "" split ; +: extract' rot 1 compress index subscript expand drop ; +: chr CHAR CODE extract' ; +: ord CODE CHAR extract' ; + +'a ord . # 97 +97 chr . # a diff --git a/Task/Character-codes/Liberty-BASIC/character-codes.liberty b/Task/Character-codes/Liberty-BASIC/character-codes.liberty new file mode 100644 index 0000000000..3ebf3475c1 --- /dev/null +++ b/Task/Character-codes/Liberty-BASIC/character-codes.liberty @@ -0,0 +1,4 @@ +charCode = 97 +char$ = "a" +print chr$(charCode) 'prints a +print asc(char$) 'prints 97 diff --git a/Task/Character-codes/Logo/character-codes.logo b/Task/Character-codes/Logo/character-codes.logo new file mode 100644 index 0000000000..bc6c1e7510 --- /dev/null +++ b/Task/Character-codes/Logo/character-codes.logo @@ -0,0 +1,2 @@ +print ascii "a ; 97 +print char 97 ; a diff --git a/Task/Character-codes/Logtalk/character-codes-1.logtalk b/Task/Character-codes/Logtalk/character-codes-1.logtalk new file mode 100644 index 0000000000..fd84256b1b --- /dev/null +++ b/Task/Character-codes/Logtalk/character-codes-1.logtalk @@ -0,0 +1,4 @@ +|?- char_code(Char, 97), write(Char). +a +Char = a +yes diff --git a/Task/Character-codes/Logtalk/character-codes-2.logtalk b/Task/Character-codes/Logtalk/character-codes-2.logtalk new file mode 100644 index 0000000000..fbdc238cf8 --- /dev/null +++ b/Task/Character-codes/Logtalk/character-codes-2.logtalk @@ -0,0 +1,4 @@ +|?- char_code(a, Code), write(Code). +97 +Code = 97 +yes diff --git a/Task/Character-codes/MUMPS/character-codes.mumps b/Task/Character-codes/MUMPS/character-codes.mumps new file mode 100644 index 0000000000..f1f441a7ff --- /dev/null +++ b/Task/Character-codes/MUMPS/character-codes.mumps @@ -0,0 +1,2 @@ +WRITE $ASCII("M") +WRITE $CHAR(77) diff --git a/Task/Character-codes/Maple/character-codes-1.maple b/Task/Character-codes/Maple/character-codes-1.maple new file mode 100644 index 0000000000..a844d92e90 --- /dev/null +++ b/Task/Character-codes/Maple/character-codes-1.maple @@ -0,0 +1,4 @@ +> use StringTools in Ord( "A" ); Char( 65 ) end; + 65 + + "A" diff --git a/Task/Character-codes/Maple/character-codes-2.maple b/Task/Character-codes/Maple/character-codes-2.maple new file mode 100644 index 0000000000..eedea18401 --- /dev/null +++ b/Task/Character-codes/Maple/character-codes-2.maple @@ -0,0 +1,5 @@ +> convert( "A", bytes ); + [65] + +> convert( [65], bytes ); + "A" diff --git a/Task/Character-codes/Mathematica/character-codes.mathematica b/Task/Character-codes/Mathematica/character-codes.mathematica new file mode 100644 index 0000000000..e3a1286418 --- /dev/null +++ b/Task/Character-codes/Mathematica/character-codes.mathematica @@ -0,0 +1,2 @@ +ToCharacterCode["abcd"] +FromCharacterCode[{97}] diff --git a/Task/Character-codes/Maxima/character-codes.maxima b/Task/Character-codes/Maxima/character-codes.maxima new file mode 100644 index 0000000000..8f274aadd4 --- /dev/null +++ b/Task/Character-codes/Maxima/character-codes.maxima @@ -0,0 +1,5 @@ +ascii(65); +"A" + +cint("A"); +65 diff --git a/Task/Character-codes/Metafont/character-codes.metafont b/Task/Character-codes/Metafont/character-codes.metafont new file mode 100644 index 0000000000..28db2339a2 --- /dev/null +++ b/Task/Character-codes/Metafont/character-codes.metafont @@ -0,0 +1,14 @@ +message "enter a letter: "; +string a; +a := readstring; +message decimal (ASCII a); % writes the decimal number of the first character + % of the string a +message "enter a number: "; +num := scantokens readstring; +message char num; % num can be anything between 0 and 255; what will be seen + % on output depends on the encoding used by the "terminal"; e.g. + % any code beyond 127 when UTF-8 encoding is in use will give + % a bad encoding; e.g. to see correctly an "è", we should write +message char10; % (this add a newline...) +message char hex"c3" & char hex"a8"; % since C3 A8 is the UTF-8 encoding for "è" +end diff --git a/Task/Character-codes/Modula-2/character-codes-1.mod2 b/Task/Character-codes/Modula-2/character-codes-1.mod2 new file mode 100644 index 0000000000..b07f06e1e5 --- /dev/null +++ b/Task/Character-codes/Modula-2/character-codes-1.mod2 @@ -0,0 +1,18 @@ +MODULE asc; + +IMPORT InOut; + +VAR letter : CHAR; + ascii : CARDINAL; + +BEGIN + letter := 'a'; + InOut.Write (letter); + ascii := ORD (letter); + InOut.Write (11C); (* ASCII TAB *) + InOut.WriteCard (ascii, 8); + ascii := ascii - ORD ('0'); + InOut.Write (11C); (* ASCII TAB *) + InOut.Write (CHR (ascii)); + InOut.WriteLn +END asc. diff --git a/Task/Character-codes/Modula-2/character-codes-2.mod2 b/Task/Character-codes/Modula-2/character-codes-2.mod2 new file mode 100644 index 0000000000..d05d98e118 --- /dev/null +++ b/Task/Character-codes/Modula-2/character-codes-2.mod2 @@ -0,0 +1,2 @@ +jan@Beryllium:~/modula/rosetta$ ./asc +a 97 1 diff --git a/Task/Character-codes/Modula-3/character-codes.mod3 b/Task/Character-codes/Modula-3/character-codes.mod3 new file mode 100644 index 0000000000..de0a765e3d --- /dev/null +++ b/Task/Character-codes/Modula-3/character-codes.mod3 @@ -0,0 +1,2 @@ +ORD('a') (* Returns 97 *) +VAL(97, CHAR); (* Returns 'a' *) diff --git a/Task/Character-matching/Fantom/character-matching.fantom b/Task/Character-matching/Fantom/character-matching.fantom new file mode 100644 index 0000000000..73e5577501 --- /dev/null +++ b/Task/Character-matching/Fantom/character-matching.fantom @@ -0,0 +1,22 @@ +class Main +{ + public static Void main () + { + string := "Fantom Language" + echo ("String is: " + string) + echo ("does string start with 'Fantom'? " + string.startsWith("Fantom")) + echo ("does string start with 'Language'? " + string.startsWith("Language")) + echo ("does string contain 'age'? " + string.contains("age")) + echo ("does string contain 'page'? " + string.contains("page")) + echo ("does string end with 'Fantom'? " + string.endsWith("Fantom")) + echo ("does string end with 'Language'? " + string.endsWith("Language")) + + echo ("Location of 'age' is: " + string.index("age")) + posn := string.index ("an") + echo ("First location of 'an' is: " + posn) + posn = string.index ("an", posn+1) + echo ("Second location of 'an' is: " + posn) + posn = string.index ("an", posn+1) + if (posn == null) echo ("No third location of 'an'") + } +} diff --git a/Task/Character-matching/GML/character-matching.gml b/Task/Character-matching/GML/character-matching.gml new file mode 100644 index 0000000000..28fe7f7a2c --- /dev/null +++ b/Task/Character-matching/GML/character-matching.gml @@ -0,0 +1,35 @@ +#define charMatch +{ + first = "qwertyuiop"; + + // Determining if the first string starts with second string + second = "qwerty"; + if (string_pos(second, first) > 0) { + show_message("'" + first + "' starts with '" + second + "'"); + } else { + show_message("'" + first + "' does not start with '" + second + "'"); + } + + second = "wert" + // Determining if the first string contains the second string at any location + // Print the location of the match for part 2 + if (string_pos(second, first) > 0) { + show_message("'" + first + "' contains '" + second + "' at position " + string(x)); + } else { + show_message("'" + first + "' does not contain '" + second + "'"); + } + // Handle multiple occurrences of a string for part 2. + x = string_count(second, first); + show_message("'" + first + "' contains " + string(x) + " instances of '" + second + "'"); + +// Determining if the first string ends with the second string + second = "random garbage" + temp = string_copy(first, + (string_length(first) - string_length(second)) + 1, + string_length(second)); + if (temp == second) { + show_message("'" + first + "' ends with '" + second + "'"); + } else { + show_message("'" + first + "' does not end with '" + second + "'"); + } +} diff --git a/Task/Character-matching/J/character-matching-1.j b/Task/Character-matching/J/character-matching-1.j new file mode 100644 index 0000000000..8a82f86763 --- /dev/null +++ b/Task/Character-matching/J/character-matching-1.j @@ -0,0 +1,3 @@ +startswith=: ] -: ({.~ #) +contains=: +./@:E.~ +endswith=: ] -: ({.~ -@#) diff --git a/Task/Character-matching/J/character-matching-2.j b/Task/Character-matching/J/character-matching-2.j new file mode 100644 index 0000000000..4430d9ff95 --- /dev/null +++ b/Task/Character-matching/J/character-matching-2.j @@ -0,0 +1,18 @@ + 'abcd' startswith 'ab' +1 + 'abcd' startswith 'cd' +0 + 'abcd' endswith 'ab' +0 + 'abcd' endswith 'cd' +1 + 'abcd' contains 'bb' +0 + 'abcd' contains 'ab' +1 + 'abcd' contains 'bc' +1 + 'abab' contains 'ab' +1 + 'abab' I.@E.~ 'ab' NB. find starting indicies +0 2 diff --git a/Task/Character-matching/J/character-matching-3.j b/Task/Character-matching/J/character-matching-3.j new file mode 100644 index 0000000000..22a6835cf1 --- /dev/null +++ b/Task/Character-matching/J/character-matching-3.j @@ -0,0 +1,6 @@ + 0 1 2 3 startswith 0 1 NB. integer +1 + 4.2 5.1 1.3 9 3 contains 1.3 4.2 NB. floating point +0 + 4.2 5.1 1.3 4.2 9 3 contains 1.3 4.2 +1 diff --git a/Task/Character-matching/Julia/character-matching.julia b/Task/Character-matching/Julia/character-matching.julia new file mode 100644 index 0000000000..24e8098397 --- /dev/null +++ b/Task/Character-matching/Julia/character-matching.julia @@ -0,0 +1,9 @@ +begins_with("abcd","ab") #returns true +search("abcd","ab") #returns 1:2, indices range where string was found +ends_with("abcd","zn") #returns false +ismatch(r"ab","abcd") #returns true where 1st arg is regex string +julia>for r in each_match(r"ab","abab") + println(r.offset) +end +1 +3 diff --git a/Task/Character-matching/K/character-matching-1.k b/Task/Character-matching/K/character-matching-1.k new file mode 100644 index 0000000000..285ca7a5d4 --- /dev/null +++ b/Task/Character-matching/K/character-matching-1.k @@ -0,0 +1,3 @@ +startswith: {:[0<#p:_ss[x;y];~*p;0]} +endswith: {0=(-#y)+(#x)-*_ss[x;y]} +contains: {0<#_ss[x;y]} diff --git a/Task/Character-matching/K/character-matching-2.k b/Task/Character-matching/K/character-matching-2.k new file mode 100644 index 0000000000..4144f53050 --- /dev/null +++ b/Task/Character-matching/K/character-matching-2.k @@ -0,0 +1,14 @@ + startswith["abcd";"ab"] +1 + startswith["abcd";"bc"] +0 + endswith["abcd";"cd"] +1 + endswith["abcd";"bc"] +0 + contains["abcdef";"cde"] +1 + contains["abcdef";"bdef"] +0 + _ss["abcdabceabc";"abc"] / location of matches +0 4 8 diff --git a/Task/Character-matching/Lang5/character-matching.lang5 b/Task/Character-matching/Lang5/character-matching.lang5 new file mode 100644 index 0000000000..4190c4f84a --- /dev/null +++ b/Task/Character-matching/Lang5/character-matching.lang5 @@ -0,0 +1,20 @@ +: 2array 2 compress ; : bi* '_ set dip _ execute ; : bi@ dup bi* ; +: comb "" split ; : concat "" join ; : dip swap '_ set execute _ ; +: first 0 extract swap drop ; : flip comb reverse concat ; + +: contains + swap 'comb bi@ length do # create a matrix. + 1 - "dup 1 1 compress rotate" dip dup 0 == if break then + loop drop length compress swap drop + "length 1 -" bi@ rot 0 0 "'2array dip" '2array bi* swap 2array slice reverse + : concat.(*) concat ; + 'concat "'concat. apply" bi* eq 1 1 compress index collapse + length if expand drop else drop 0 then ; # r: position. +: end-with 'flip bi@ start-with ; +: start-with 'comb bi@ length rot swap iota subscript 'concat bi@ eq ; + +"rosettacode" "rosetta" start-with . # 1 +"rosettacode" "taco" contains . # 5 +"rosettacode" "ocat" contains . # 0 +"rosettacode" "edoc" end-with . # 0 +"rosettacode" "code" contains . # 7 diff --git a/Task/Character-matching/Liberty-BASIC/character-matching.liberty b/Task/Character-matching/Liberty-BASIC/character-matching.liberty new file mode 100644 index 0000000000..b5afe2af9b --- /dev/null +++ b/Task/Character-matching/Liberty-BASIC/character-matching.liberty @@ -0,0 +1,30 @@ +'1---Determining if the first string starts with second string +st1$="first string" +st2$="first" +if left$(st1$,len(st2$))=st2$ then + print "First string starts with second string." +end if + +'2---Determining if the first string contains the second string at any location +'2.1---Print the location of the match for part 2 +st1$="Mississippi" +st2$="i" +if instr(st1$,st2$) then + print "First string contains second string." + print "Second string is at location ";instr(st1$,st2$) +end if + +'2.2---Handle multiple occurrences of a string for part 2. +pos=instr(st1$,st2$) +while pos + count=count+1 + pos=instr(st1$,st2$,pos+len(st2$)) +wend +print "Number of times second string appears in first string is ";count + +'3---Determining if the first string ends with the second string +st1$="first string" +st2$="string" +if right$(st1$,len(st2$))=st2$ then + print "First string ends with second string." +end if diff --git a/Task/Character-matching/Logo/character-matching.logo b/Task/Character-matching/Logo/character-matching.logo new file mode 100644 index 0000000000..1dab1574ef --- /dev/null +++ b/Task/Character-matching/Logo/character-matching.logo @@ -0,0 +1,17 @@ +to starts.with? :sub :thing + if empty? :sub [output "true] + if empty? :thing [output "false] + if not equal? first :sub first :thing [output "false] + output starts.with? butfirst :sub butfirst :thing +end + +to ends.with? :sub :thing + if empty? :sub [output "true] + if empty? :thing [output "false] + if not equal? last :sub last :thing [output "false] + output ends.with? butlast :sub butlast :thing +end + +show starts.with? "dog "doghouse ; true +show ends.with? "house "doghouse ; true +show substring? "gho "doghouse ; true (built-in) diff --git a/Task/Character-matching/Maple/character-matching.maple b/Task/Character-matching/Maple/character-matching.maple new file mode 100644 index 0000000000..2e99af2261 --- /dev/null +++ b/Task/Character-matching/Maple/character-matching.maple @@ -0,0 +1,31 @@ +> with( StringTools ): # bind package exports at the top-level +> s := "dzrIemaWWIMidXYZwGiqkOOn": +> s[1..4]; # pick a prefix + "dzrI" + +> IsPrefix( s[ 1 .. 4 ], s ); # check it + true + +> s[ -4 .. -1 ]; # pick a suffix + "kOOn" + +> IsSuffix( s[ -4 .. -1 ], s ); # check it + true + +> p := Search( "XYZ", s ); # find a substring + p := 14 + +> s[ p .. p + 2 ]; # check + "XYZ" + +> SearchAll( [ "WWI", "XYZ" ], s ); # search for multiple patterns + [8, 1], [14, 2] + +> to 3 do s := cat( s, s ) end: length( s ); # build a longer string by repeated doubling + 192 + +> p := SearchAll( "XYZ", s ); # find all occurrences + p := 14, 38, 62, 86, 110, 134, 158, 182 + +> {seq}( s[ i .. i + 2 ], i = p ); # check them + {"XYZ"} diff --git a/Task/Character-matching/Mathematica/character-matching.mathematica b/Task/Character-matching/Mathematica/character-matching.mathematica new file mode 100644 index 0000000000..16048b8c66 --- /dev/null +++ b/Task/Character-matching/Mathematica/character-matching.mathematica @@ -0,0 +1,5 @@ +StartWith[x_, y_] := MemberQ[Flatten[StringPosition[x, y]], 1] +EndWith[x_, y_] := MemberQ[Flatten[StringPosition[x, y]], StringLength[x]] +StartWith["XYZaaabXYZaaaaXYZXYZ", "XYZ"] +EndWith["XYZaaabXYZaaaaXYZXYZ", "XYZ"] +StringPosition["XYZaaabXYZaaaaXYZXYZ", "XYZ"] diff --git a/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-1.j b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-1.j new file mode 100644 index 0000000000..73030c6eaf --- /dev/null +++ b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-1.j @@ -0,0 +1 @@ + machin =: 1r4p1 = [: +/ ({. * _3 o. %/@:}.)"1@:x: diff --git a/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-2.j b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-2.j new file mode 100644 index 0000000000..7d0ebf4aee --- /dev/null +++ b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-2.j @@ -0,0 +1,68 @@ + R =: <@:(0&".);._2 ];._2 noun define +  1  1     2 +  1  1     3 +------------ +  2  1     3 +  1  1     7 +------------ +  4  1     5 + _1  1   239 +------------ +  5  1     7 +  2  3    79 +------------ +  5 29   278 +  7  3    79 +------------ +  1  1     2 +  1  1     5 +  1  1     8 +------------ +  4  1     5 + _1  1    70 +  1  1    99 +------------ +  5  1     7 +  4  1    53 +  2  1  4443 +------------ +  6  1     8 +  2  1    57 +  1  1   239 +------------ +  8  1    10 + _1  1   239 + _4  1   515 +------------ + 12  1    18 +  8  1    57 + _5  1   239 +------------ + 16  1    21 +  3  1   239 +  4  3  1042 +------------ + 22  1    28 +  2  1   443 + _5  1  1393 +_10  1 11018 +------------ + 22  1    38 + 17  7   601 + 10  7  8149 +------------ + 44  1    57 +  7  1   239 +_12  1   682 + 24  1 12943 +------------ + 88  1   172 + 51  1   239 + 32  1   682 + 44  1  5357 + 68  1 12943 +------------ +) + +   machin&> R +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-3.j b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-3.j new file mode 100644 index 0000000000..348281c239 --- /dev/null +++ b/Task/Check-Machin-like-formulas/J/check-machin-like-formulas-3.j @@ -0,0 +1,9 @@ +   counterExample=. 12944 (<_1;_1)} >{:R +   counterExample  NB. Same as final test case with 12943 incremented to 12944 +88 1   172 +51 1   239 +32 1   682 +44 1  5357 +68 1 12944 +   machin counterExample +0 diff --git a/Task/Check-Machin-like-formulas/Mathematica/check-machin-like-formulas.mathematica b/Task/Check-Machin-like-formulas/Mathematica/check-machin-like-formulas.mathematica new file mode 100644 index 0000000000..82d93de08b --- /dev/null +++ b/Task/Check-Machin-like-formulas/Mathematica/check-machin-like-formulas.mathematica @@ -0,0 +1,21 @@ +Tan[ArcTan[1/2] + ArcTan[1/3]] == 1 +Tan[2 ArcTan[1/3] + ArcTan[1/7]] == 1 +Tan[4 ArcTan[1/5] - ArcTan[1/239]] == 1 +Tan[5 ArcTan[1/7] + 2 ArcTan[3/79]] == 1 +Tan[5 ArcTan[29/278] + 7 ArcTan[3/79]] == 1 +Tan[ArcTan[1/2] + ArcTan[1/5] + ArcTan[1/8]] == 1 +Tan[4 ArcTan[1/5] - ArcTan[1/70] + ArcTan[1/99]] == 1 +Tan[5 ArcTan[1/7] + 4 ArcTan[1/53] + 2 ArcTan[1/4443]] == 1 +Tan[6 ArcTan[1/8] + 2 ArcTan[1/57] + ArcTan[1/239]] == 1 +Tan[8 ArcTan[1/10] - ArcTan[1/239] - 4 ArcTan[1/515]] == 1 +Tan[12 ArcTan[1/18] + 8 ArcTan[1/57] - 5 ArcTan[1/239]] == 1 +Tan[16 ArcTan[1/21] + 3 ArcTan[1/239] + 4 ArcTan[3/1042]] == 1 +Tan[22 ArcTan[1/28] + 2 ArcTan[1/443] - 5 ArcTan[1/1393] - + 10 ArcTan[1/11018]] == 1 +Tan[22 ArcTan[1/38] + 17 ArcTan[7/601] + 10 ArcTan[7/8149]] == 1 +Tan[44 ArcTan[1/57] + 7 ArcTan[1/239] - 12 ArcTan[1/682] + + 24 ArcTan[1/12943]] == 1 +Tan[88 ArcTan[1/172] + 51 ArcTan[1/239] + 32 ArcTan[1/682] + + 44 ArcTan[1/5357] + 68 ArcTan[1/12943]] == 1 +Tan[88 ArcTan[1/172] + 51 ArcTan[1/239] + 32 ArcTan[1/682] + + 44 ArcTan[1/5357] + 68 ArcTan[1/12944]] == 1 diff --git a/Task/Check-Machin-like-formulas/Maxima/check-machin-like-formulas.maxima b/Task/Check-Machin-like-formulas/Maxima/check-machin-like-formulas.maxima new file mode 100644 index 0000000000..df06789ca8 --- /dev/null +++ b/Task/Check-Machin-like-formulas/Maxima/check-machin-like-formulas.maxima @@ -0,0 +1,18 @@ +trigexpand:true$ +is(tan(atan(1/2)+atan(1/3))=1); +is(tan(2*atan(1/3)+atan(1/7))=1); +is(tan(4*atan(1/5)-atan(1/239))=1); +is(tan(5*atan(1/7)+2*atan(3/79))=1); +is(tan(5*atan(29/278)+7*atan(3/79))=1); +is(tan(atan(1/2)+atan(1/5)+atan(1/8))=1); +is(tan(4*atan(1/5)-atan(1/70)+atan(1/99))=1); +is(tan(5*atan(1/7)+4*atan(1/53)+2*atan(1/4443))=1); +is(tan(6*atan(1/8)+2*atan(1/57)+atan(1/239))=1); +is(tan(8*atan(1/10)-atan(1/239)-4*atan(1/515))=1); +is(tan(12*atan(1/18)+8*atan(1/57)-5*atan(1/239))=1); +is(tan(16*atan(1/21)+3*atan(1/239)+4*atan(3/1042))=1); +is(tan(22*atan(1/28)+2*atan(1/443)-5*atan(1/1393)-10*atan(1/11018))=1); +is(tan(22*atan(1/38)+17*atan(7/601)+10*atan(7/8149))=1); +is(tan(44*atan(1/57)+7*atan(1/239)-12*atan(1/682)+24*atan(1/12943))=1); +is(tan(88*atan(1/172)+51*atan(1/239)+32*atan(1/682)+44*atan(1/5357)+68*atan(1/12943))=1); +is(tan(88*atan(1/172)+51*atan(1/239)+32*atan(1/682)+44*atan(1/5357)+68*atan(1/12944))=1); diff --git a/Task/Check-that-file-exists/Factor/check-that-file-exists.factor b/Task/Check-that-file-exists/Factor/check-that-file-exists.factor new file mode 100644 index 0000000000..79763e1d65 --- /dev/null +++ b/Task/Check-that-file-exists/Factor/check-that-file-exists.factor @@ -0,0 +1,4 @@ +: print-exists? ( path -- ) + [ write ": " write ] [ exists? "exists." "doesn't exist." ? print ] bi ; + +{ "input.txt" "/input.txt" "docs" "/docs" } [ print-exists? ] each diff --git a/Task/Check-that-file-exists/GAP/check-that-file-exists.gap b/Task/Check-that-file-exists/GAP/check-that-file-exists.gap new file mode 100644 index 0000000000..f1df7217b8 --- /dev/null +++ b/Task/Check-that-file-exists/GAP/check-that-file-exists.gap @@ -0,0 +1,4 @@ +IsExistingFile("input.txt"); +IsDirectoryPath("docs"); +IsExistingFile("/input.txt"); +IsDirectoryPath("/docs"); diff --git a/Task/Check-that-file-exists/Groovy/check-that-file-exists.groovy b/Task/Check-that-file-exists/Groovy/check-that-file-exists.groovy new file mode 100644 index 0000000000..39ba67e3b2 --- /dev/null +++ b/Task/Check-that-file-exists/Groovy/check-that-file-exists.groovy @@ -0,0 +1,4 @@ +println new File('input.txt').exists() +println new File('/input.txt').exists() +println new File('docs').exists() +println new File('/docs').exists() diff --git a/Task/Check-that-file-exists/HicEst/check-that-file-exists.hicest b/Task/Check-that-file-exists/HicEst/check-that-file-exists.hicest new file mode 100644 index 0000000000..23a78f5ea0 --- /dev/null +++ b/Task/Check-that-file-exists/HicEst/check-that-file-exists.hicest @@ -0,0 +1,4 @@ + OPEN(FIle= 'input.txt', OLD, IOStat=ios, ERror=99) + OPEN(FIle='C:\input.txt', OLD, IOStat=ios, ERror=99) +! ... +99 WRITE(Messagebox='!') 'File does not exist. Error message ', ios diff --git a/Task/Check-that-file-exists/Icon/check-that-file-exists.icon b/Task/Check-that-file-exists/Icon/check-that-file-exists.icon new file mode 100644 index 0000000000..7476af5a75 --- /dev/null +++ b/Task/Check-that-file-exists/Icon/check-that-file-exists.icon @@ -0,0 +1,4 @@ +every dir := !["./","/"] do { + write("file ", f := dir || "input.txt", if stat(f) then " exists." else " doesn't exist.") + write("directory ", f := dir || "docs", if stat(f) then " exists." else " doesn't exist.") + } diff --git a/Task/Check-that-file-exists/J/check-that-file-exists.j b/Task/Check-that-file-exists/J/check-that-file-exists.j new file mode 100644 index 0000000000..7ffd6954b7 --- /dev/null +++ b/Task/Check-that-file-exists/J/check-that-file-exists.j @@ -0,0 +1,6 @@ +require 'files' +fexist 'input.txt' +fexist '/input.txt' +direxist=: 2 = ftype +direxist 'docs' +direxist '/docs' diff --git a/Task/Check-that-file-exists/Liberty-BASIC/check-that-file-exists.liberty b/Task/Check-that-file-exists/Liberty-BASIC/check-that-file-exists.liberty new file mode 100644 index 0000000000..d270a2b8b9 --- /dev/null +++ b/Task/Check-that-file-exists/Liberty-BASIC/check-that-file-exists.liberty @@ -0,0 +1,29 @@ +'fileExists.bas - Show how to determine if a file exists +dim info$(10,10) +input "Type a file path (ie. c:\windows\somefile.txt)?"; fpath$ +if fileExists(fpath$) then + print fpath$; " exists!" +else + print fpath$; " doesn't exist!" +end if +end + +'return a true if the file in fullPath$ exists, else return false +function fileExists(fullPath$) + files pathOnly$(fullPath$), filenameOnly$(fullPath$), info$() + fileExists = val(info$(0, 0)) > 0 +end function + +'return just the directory path from a full file path +function pathOnly$(fullPath$) + pathOnly$ = fullPath$ + while right$(pathOnly$, 1) <> "\" and pathOnly$ <> "" + pathOnly$ = left$(pathOnly$, len(pathOnly$)-1) + wend +end function + +'return just the filename from a full file path +function filenameOnly$(fullPath$) + pathLength = len(pathOnly$(fullPath$)) + filenameOnly$ = right$(fullPath$, len(fullPath$)-pathLength) +end function diff --git a/Task/Check-that-file-exists/Logo/check-that-file-exists-1.logo b/Task/Check-that-file-exists/Logo/check-that-file-exists-1.logo new file mode 100644 index 0000000000..4c74054f6f --- /dev/null +++ b/Task/Check-that-file-exists/Logo/check-that-file-exists-1.logo @@ -0,0 +1,4 @@ +show file? "input.txt +show file? "/input.txt +show file? "docs +show file? "/docs diff --git a/Task/Check-that-file-exists/Logo/check-that-file-exists-2.logo b/Task/Check-that-file-exists/Logo/check-that-file-exists-2.logo new file mode 100644 index 0000000000..926f40edf2 --- /dev/null +++ b/Task/Check-that-file-exists/Logo/check-that-file-exists-2.logo @@ -0,0 +1,2 @@ +setprefix "/ +show file? "input.txt diff --git a/Task/Check-that-file-exists/MAXScript/check-that-file-exists.max b/Task/Check-that-file-exists/MAXScript/check-that-file-exists.max new file mode 100644 index 0000000000..320af0bd63 --- /dev/null +++ b/Task/Check-that-file-exists/MAXScript/check-that-file-exists.max @@ -0,0 +1,6 @@ +-- Here +doesFileExist "input.txt" +(getDirectories "docs").count == 1 +-- Root +doesFileExist "\input.txt" +(getDirectories "C:\docs").count == 1 diff --git a/Task/Check-that-file-exists/Mathematica/check-that-file-exists.mathematica b/Task/Check-that-file-exists/Mathematica/check-that-file-exists.mathematica new file mode 100644 index 0000000000..15d804a5c7 --- /dev/null +++ b/Task/Check-that-file-exists/Mathematica/check-that-file-exists.mathematica @@ -0,0 +1,6 @@ +wd = NotebookDirectory[]; +FileExistsQ[wd <> "input.txt"] +DirectoryQ[wd <> "docs"] + +FileExistsQ["/" <> "input.txt"] +DirectoryQ["/" <> "docs"] diff --git a/Task/Check-that-file-exists/Modula-3/check-that-file-exists.mod3 b/Task/Check-that-file-exists/Modula-3/check-that-file-exists.mod3 new file mode 100644 index 0000000000..e2162cd4ce --- /dev/null +++ b/Task/Check-that-file-exists/Modula-3/check-that-file-exists.mod3 @@ -0,0 +1,21 @@ +MODULE FileTest EXPORTS Main; + +IMPORT IO, Fmt, FS, File, OSError, Pathname; + +PROCEDURE FileExists(file: Pathname.T): BOOLEAN = + VAR status: File.Status; + BEGIN + TRY + status := FS.Status(file); + RETURN TRUE; + EXCEPT + | OSError.E => RETURN FALSE; + END; + END FileExists; + +BEGIN + IO.Put(Fmt.Bool(FileExists("input.txt")) & "\n"); + IO.Put(Fmt.Bool(FileExists("/input.txt")) & "\n"); + IO.Put(Fmt.Bool(FileExists("docs/")) & "\n"); + IO.Put(Fmt.Bool(FileExists("/docs")) & "\n"); +END FileTest. diff --git a/Task/Cholesky-decomposition/Fantom/cholesky-decomposition.fantom b/Task/Cholesky-decomposition/Fantom/cholesky-decomposition.fantom new file mode 100644 index 0000000000..902c7f9a6d --- /dev/null +++ b/Task/Cholesky-decomposition/Fantom/cholesky-decomposition.fantom @@ -0,0 +1,55 @@ +** +** Cholesky decomposition +** + +class Main +{ + // create an array of Floats, initialised to 0.0 + Float[][] makeArray (Int i, Int j) + { + Float[][] result := [,] + i.times { result.add ([,]) } + i.times |Int x| + { + j.times + { + result[x].add(0f) + } + } + return result + } + + // perform the Cholesky decomposition + Float[][] cholesky (Float[][] array) + { + m := array.size + Float[][] l := makeArray (m, m) + m.times |Int i| + { + (i+1).times |Int k| + { + Float sum := (0.. Float| + { + a + l[i][j] * l[k][j] + } + if (i == k) + l[i][k] = (array[i][i]-sum).sqrt + else + l[i][k] = (1.0f / l[k][k]) * (array[i][k] - sum) + } + } + return l + } + + Void runTest (Float[][] array) + { + echo (array) + echo (cholesky (array)) + } + + Void main () + { + runTest ([[25f,15f,-5f],[15f,18f,0f],[-5f,0f,11f]]) + runTest ([[18f,22f,54f,42f],[22f,70f,86f,62f],[54f,86f,174f,134f],[42f,62f,134f,106f]]) + } +} diff --git a/Task/Cholesky-decomposition/Icon/cholesky-decomposition.icon b/Task/Cholesky-decomposition/Icon/cholesky-decomposition.icon new file mode 100644 index 0000000000..5553cf421c --- /dev/null +++ b/Task/Cholesky-decomposition/Icon/cholesky-decomposition.icon @@ -0,0 +1,41 @@ +procedure cholesky (array) + result := make_square_array (*array) + every (i := 1 to *array) do { + every (k := 1 to i) do { + sum := 0 + every (j := 1 to (k-1)) do { + sum +:= result[i][j] * result[k][j] + } + if (i = k) + then result[i][k] := sqrt(array[i][i] - sum) + else result[i][k] := 1.0 / result[k][k] * (array[i][k] - sum) + } + } + return result +end + +procedure make_square_array (n) + result := [] + every (1 to n) do push (result, list(n, 0)) + return result +end + +procedure print_array (array) + every (row := !array) do { + every writes (!row || " ") + write () + } +end + +procedure do_cholesky (array) + write ("Input:") + print_array (array) + result := cholesky (array) + write ("Result:") + print_array (result) +end + +procedure main () + do_cholesky ([[25,15,-5],[15,18,0],[-5,0,11]]) + do_cholesky ([[18,22,54,42],[22,70,86,62],[54,86,174,134],[42,62,134,106]]) +end diff --git a/Task/Cholesky-decomposition/J/cholesky-decomposition-1.j b/Task/Cholesky-decomposition/J/cholesky-decomposition-1.j new file mode 100644 index 0000000000..9d58d5f3cf --- /dev/null +++ b/Task/Cholesky-decomposition/J/cholesky-decomposition-1.j @@ -0,0 +1,16 @@ +mp=: +/ . * NB. matrix product +h =: +@|: NB. conjugate transpose + +cholesky=: 3 : 0 + n=. #A=. y + if. 1>:n do. + assert. (A=|A)>0=A NB. check for positive definite + %:A + else. + p=. >.n%2 [ q=. <.n%2 + X=. (p,p) {.A [ Y=. (p,-q){.A [ Z=. (-q,q){.A + L0=. cholesky X + L1=. cholesky Z-(T=.(h Y) mp %.X) mp Y + L0,(T mp L0),.L1 + end. +) diff --git a/Task/Cholesky-decomposition/J/cholesky-decomposition-2.j b/Task/Cholesky-decomposition/J/cholesky-decomposition-2.j new file mode 100644 index 0000000000..55e266518b --- /dev/null +++ b/Task/Cholesky-decomposition/J/cholesky-decomposition-2.j @@ -0,0 +1,11 @@ + eg1=: 25 15 _5 , 15 18 0 ,: _5 0 11 + eg2=: 18 22 54 42 , 22 70 86 62 , 54 86 174 134 ,: 42 62 134 106 + cholesky eg1 + 5 0 0 + 3 3 0 +_1 1 3 + cholesky eg2 +4.24264 0 0 0 +5.18545 6.56591 0 0 +12.7279 3.04604 1.64974 0 +9.89949 1.62455 1.84971 1.39262 diff --git a/Task/Cholesky-decomposition/Maple/cholesky-decomposition.maple b/Task/Cholesky-decomposition/Maple/cholesky-decomposition.maple new file mode 100644 index 0000000000..6ecb49c6bf --- /dev/null +++ b/Task/Cholesky-decomposition/Maple/cholesky-decomposition.maple @@ -0,0 +1,52 @@ +> A := << 25, 15, -5; 15, 18, 0; -5, 0, 11 >>; + [25 15 -5] + [ ] + A := [15 18 0] + [ ] + [-5 0 11] + +> B := << 18, 22, 54, 42; 22, 70, 86, 62; 54, 86, 174, 134; 42, 62, 134, 106>>; + [18 22 54 42] + [ ] + [22 70 86 62] + B := [ ] + [54 86 174 134] + [ ] + [42 62 134 106] + +> use LinearAlgebra in +> LUDecomposition( A, method = Cholesky ); +> LUDecomposition( B, method = Cholesky ); +> evalf( % ); +> end use; + [ 5 0 0] + [ ] + [ 3 3 0] + [ ] + [-1 1 3] + + [ 1/2 ] + [3 2 0 0 0 ] + [ ] + [ 1/2 1/2 ] + [11 2 2 97 ] + [------- ------- 0 0 ] + [ 3 3 ] + [ ] + [ 1/2 1/2 ] + [ 1/2 30 97 2 6402 ] + [9 2 -------- --------- 0 ] + [ 97 97 ] + [ ] + [ 1/2 1/2 1/2] + [ 1/2 16 97 74 6402 8 33 ] + [7 2 -------- ---------- -------] + [ 97 3201 33 ] + + [4.242640686 0. 0. 0. ] + [ ] + [5.185449728 6.565905202 0. 0. ] + [ ] + [12.72792206 3.046038495 1.649742248 0. ] + [ ] + [9.899494934 1.624553864 1.849711006 1.392621248] diff --git a/Task/Cholesky-decomposition/Mathematica/cholesky-decomposition.mathematica b/Task/Cholesky-decomposition/Mathematica/cholesky-decomposition.mathematica new file mode 100644 index 0000000000..fb97144b7b --- /dev/null +++ b/Task/Cholesky-decomposition/Mathematica/cholesky-decomposition.mathematica @@ -0,0 +1 @@ +CholeskyDecomposition[{{25, 15, -5}, {15, 18, 0}, {-5, 0, 11}}] diff --git a/Task/Cholesky-decomposition/Maxima/cholesky-decomposition.maxima b/Task/Cholesky-decomposition/Maxima/cholesky-decomposition.maxima new file mode 100644 index 0000000000..3253017048 --- /dev/null +++ b/Task/Cholesky-decomposition/Maxima/cholesky-decomposition.maxima @@ -0,0 +1,12 @@ +/* Cholesky decomposition is built-in */ + +a: hilbert_matrix(4)$ + +b: cholesky(a); +/* matrix([1, 0, 0, 0 ], + [1/2, 1/(2*sqrt(3)), 0, 0 ], + [1/3, 1/(2*sqrt(3)), 1/(6*sqrt(5)), 0 ], + [1/4, 3^(3/2)/20, 1/(4*sqrt(5)), 1/(20*sqrt(7))]) */ + +b . transpose(b) - a; +matrix([0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]) diff --git a/Task/Classes/Factor/classes.factor b/Task/Classes/Factor/classes.factor new file mode 100644 index 0000000000..a373351d6d --- /dev/null +++ b/Task/Classes/Factor/classes.factor @@ -0,0 +1,8 @@ +TUPLE: my-class foo bar baz ; +M: my-class quux foo>> 20 + ; +C: my-class +10 20 30 quux ! result: 30 +TUPLE: my-child-class < my-class quxx ; +C: my-child-class +M: my-child-class foobar 20 >>quux ; +20 20 30 foobar quux ! result: 30 diff --git a/Task/Classes/Falcon/classes-1.falcon b/Task/Classes/Falcon/classes-1.falcon new file mode 100644 index 0000000000..1b16918650 --- /dev/null +++ b/Task/Classes/Falcon/classes-1.falcon @@ -0,0 +1,6 @@ +class class_name[ ( param_list ) ] [ from inh1[, inh2, ..., inhN] ] + [ static block ] + [ properties declaration ] + [init block] + [method list] +end diff --git a/Task/Classes/Falcon/classes-2.falcon b/Task/Classes/Falcon/classes-2.falcon new file mode 100644 index 0000000000..ec546e63d9 --- /dev/null +++ b/Task/Classes/Falcon/classes-2.falcon @@ -0,0 +1,15 @@ +class mailbox( max_msg ) + + capacity = max_msg * 10 + name = nil + messages = [] + + init + printl( "Box now ready for ", self.capacity, " messages." ) + end + + function slot_left() + return self.capacity - len( self.messages ) + end + +end diff --git a/Task/Classes/Falcon/classes-3.falcon b/Task/Classes/Falcon/classes-3.falcon new file mode 100644 index 0000000000..0d04d2ddce --- /dev/null +++ b/Task/Classes/Falcon/classes-3.falcon @@ -0,0 +1,2 @@ +m = mailbox( 10 ) +// Ouputs: Box now ready for 100 messages. diff --git a/Task/Classes/Fancy/classes.fancy b/Task/Classes/Fancy/classes.fancy new file mode 100644 index 0000000000..283f045fcf --- /dev/null +++ b/Task/Classes/Fancy/classes.fancy @@ -0,0 +1,26 @@ +class MyClass { + read_slot: 'instance_var # creates getter method for @instance_var + @@class_var = [] + + def initialize { + # 'initialize' is the constructor method invoked during 'MyClass.new' by convention + @instance_var = 0 + } + + def some_method { + @instance_var = 1 + @another_instance_var = "foo" + } + + # define class methods: define a singleton method on the class object + def self class_method { + # ... + } + + # you can also name the class object itself + def MyClass class_method { + # ... + } +} + +myclass = MyClass new diff --git a/Task/Classes/Fantom/classes.fantom b/Task/Classes/Fantom/classes.fantom new file mode 100644 index 0000000000..6d981525e1 --- /dev/null +++ b/Task/Classes/Fantom/classes.fantom @@ -0,0 +1,27 @@ +class MyClass +{ + // an instance variable + Int x + + // a constructor, providing default value for instance variable + new make (Int x := 1) + { + this.x = x + } + + // a method, return double the number x + public Int double () + { + return 2 * x + } +} + +class Main +{ + public static Void main () + { + a := MyClass (2) // instantiates the class, with x = 2 + b := MyClass() // instantiates the class, x defaults to 1 + c := MyClass { x = 3 } // instantiates the class, sets x to 3 + } +} diff --git a/Task/Classes/Groovy/classes-1.groovy b/Task/Classes/Groovy/classes-1.groovy new file mode 100644 index 0000000000..058c687831 --- /dev/null +++ b/Task/Classes/Groovy/classes-1.groovy @@ -0,0 +1,15 @@ +/** Ye olde classe declaration */ +class Stuff { + /** Heare bee anne instance variable declared */ + def guts + + /** This constuctor converts bits into Stuff */ + Stuff(injectedGuts) { + guts = injectedGuts + } + + /** Brethren and sistren, let us flangulate with this fine flangulating method */ + def flangulate() { + println "This stuff is flangulating its guts: ${guts}" + } +} diff --git a/Task/Classes/Groovy/classes-2.groovy b/Task/Classes/Groovy/classes-2.groovy new file mode 100644 index 0000000000..1eafd50c7d --- /dev/null +++ b/Task/Classes/Groovy/classes-2.groovy @@ -0,0 +1,16 @@ +def stuff = new Stuff(''' +I have made mistakes in the past. +I have made mistakes in the future. + -- Vice President Dan Quayle +''') + +stuff.flangulate() + +stuff.guts = ''' +Our enemies are innovative and resourceful, and so are we. +They never stop thinking about new ways to harm our country and our people, +and neither do we. + -- President George W. Bush +''' + +stuff.flangulate() diff --git a/Task/Classes/J/classes-1.j b/Task/Classes/J/classes-1.j new file mode 100644 index 0000000000..e0bb86c4b1 --- /dev/null +++ b/Task/Classes/J/classes-1.j @@ -0,0 +1,11 @@ +coclass 'exampleClass' + +exampleMethod=: monad define + 1+exampleInstanceVariable +) + +create=: monad define + 'this is the constructor' +) + +exampleInstanceVariable=: 0 diff --git a/Task/Classes/J/classes-2.j b/Task/Classes/J/classes-2.j new file mode 100644 index 0000000000..0b49b9b16f --- /dev/null +++ b/Task/Classes/J/classes-2.j @@ -0,0 +1 @@ + exampleObject=: conew 'exampleClass' diff --git a/Task/Classes/Lisaac/classes.lisaac b/Task/Classes/Lisaac/classes.lisaac new file mode 100644 index 0000000000..1768b8ef03 --- /dev/null +++ b/Task/Classes/Lisaac/classes.lisaac @@ -0,0 +1,24 @@ +Section Header + ++ name := SAMPLE; + +Section Inherit + +- parent : OBJECT := OBJECT; + +Section Private + ++ variable : INTEGER <- 0; + +Section Public + +- some_method <- ( + variable := 1; +); + +- main <- ( + + sample : SAMPLE; + + sample := SAMPLE.clone; + sample.some_method; +); diff --git a/Task/Classes/Logtalk/classes-1.logtalk b/Task/Classes/Logtalk/classes-1.logtalk new file mode 100644 index 0000000000..f78977faa1 --- /dev/null +++ b/Task/Classes/Logtalk/classes-1.logtalk @@ -0,0 +1,20 @@ +:- object(metaclass, + instantiates(metaclass)). + + :- public(new/2). + new(Instance, Value) :- + self(Class), + create_object(Instance, [instantiates(Class)], [], [state(Value)]). + +:- end_object. + +:- object(class, + instantiates(metaclass)). + + :- public(method/1). + method(Value) :- + ::state(Value). + + :- private(state/1). + +:- end_object. diff --git a/Task/Classes/Logtalk/classes-2.logtalk b/Task/Classes/Logtalk/classes-2.logtalk new file mode 100644 index 0000000000..a2191f6743 --- /dev/null +++ b/Task/Classes/Logtalk/classes-2.logtalk @@ -0,0 +1,7 @@ +| ?- class::new(Instance, 1). +Instance = o1 +yes + +| ?- o1::method(Value). +Value = 1 +yes diff --git a/Task/Closest-pair-problem/Fantom/closest-pair-problem.fantom b/Task/Closest-pair-problem/Fantom/closest-pair-problem.fantom new file mode 100644 index 0000000000..871285a259 --- /dev/null +++ b/Task/Closest-pair-problem/Fantom/closest-pair-problem.fantom @@ -0,0 +1,118 @@ +class Point +{ + Float x + Float y + + // create a random point + new make (Float x := Float.random * 10, Float y := Float.random * 10) + { + this.x = x + this.y = y + } + + Float distance (Point p) + { + ((x-p.x)*(x-p.x) + (y-p.y)*(y-p.y)).sqrt + } + + override Str toStr () { "($x, $y)" } +} + +class Main +{ + // use brute force approach + static Point[] findClosestPair1 (Point[] points) + { + if (points.size < 2) return points // list too small + Point[] closestPair := [points[0], points[1]] + Float closestDistance := points[0].distance(points[1]) + + (1.. Int| { a.x <=> b.x } + bestLeft := findClosestPair2 (points[0..(points.size/2)]) + bestRight := findClosestPair2 (points[(points.size/2)..-1]) + + Float minDistance + Point[] closePoints := [,] + if (bestLeft[0].distance(bestLeft[1]) < bestRight[0].distance(bestRight[1])) + { + minDistance = bestLeft[0].distance(bestLeft[1]) + closePoints = bestLeft + } + else + { + minDistance = bestRight[0].distance(bestRight[1]) + closePoints = bestRight + } + yPoints := points.findAll |Point p -> Bool| + { + (points.last.x - p.x).abs < minDistance + }.sort |Point a, Point b -> Int| { a.y <=> b.y } + + closestPair := [,] + closestDist := Float.posInf + + for (Int i := 0; i < yPoints.size - 1; ++i) + { + for (Int j := (i+1); j < yPoints.size; ++j) + { + if ((yPoints[j].y - yPoints[i].y) >= minDistance) + { + break + } + else + { + dist := yPoints[i].distance (yPoints[j]) + if (dist < closestDist) + { + closestDist = dist + closestPair = [yPoints[i], yPoints[j]] + } + } + } + } + if (closestDist < minDistance) + return closestPair + else + return closePoints + } + + public static Void main (Str[] args) + { + Int numPoints := 10 // default value, in case a number not given on command line + if ((args.size > 0) && (args[0].toInt(10, false) != null)) + { + numPoints = args[0].toInt(10, false) + } + + Point[] points := [,] + numPoints.times { points.add (Point()) } + + Int t1 := Duration.now.toMillis + echo (findClosestPair1(points.dup)) + Int t2 := Duration.now.toMillis + echo ("Time taken: ${(t2-t1)}ms") + echo (findClosestPair2(points.dup)) + Int t3 := Duration.now.toMillis + echo ("Time taken: ${(t3-t2)}ms") + } +} diff --git a/Task/Closest-pair-problem/Groovy/closest-pair-problem-1.groovy b/Task/Closest-pair-problem/Groovy/closest-pair-problem-1.groovy new file mode 100644 index 0000000000..5dd4258372 --- /dev/null +++ b/Task/Closest-pair-problem/Groovy/closest-pair-problem-1.groovy @@ -0,0 +1,6 @@ +class Point { + final Number x, y + Point(Number x = 0, Number y = 0) { this.x = x; this.y = y } + Number distance(Point that) { ((this.x - that.x)**2 + (this.y - that.y)**2)**0.5 } + String toString() { "{x:${x}, y:${y}}" } +} diff --git a/Task/Closest-pair-problem/Groovy/closest-pair-problem-2.groovy b/Task/Closest-pair-problem/Groovy/closest-pair-problem-2.groovy new file mode 100644 index 0000000000..69b2cca908 --- /dev/null +++ b/Task/Closest-pair-problem/Groovy/closest-pair-problem-2.groovy @@ -0,0 +1,23 @@ +def bruteClosest(Collection pointCol) { + assert pointCol + List l = pointCol + int n = l.size() + assert n > 1 + if (n == 2) return [distance:l[0].distance(l[1]), points:[l[0],l[1]]] + def answer = [distance: Double.POSITIVE_INFINITY] + (0..<(n-1)).each { i -> + ((i+1).. + (l[i].x - l[j].x).abs() < answer.distance && + (l[i].y - l[j].y).abs() < answer.distance + }.each { j -> + if ((l[i].x - l[j].x).abs() < answer.distance && + (l[i].y - l[j].y).abs() < answer.distance) { + def dist = l[i].distance(l[j]) + if (dist < answer.distance) { + answer = [distance:dist, points:[l[i],l[j]]] + } + } + } + } + answer +} diff --git a/Task/Closest-pair-problem/Groovy/closest-pair-problem-3.groovy b/Task/Closest-pair-problem/Groovy/closest-pair-problem-3.groovy new file mode 100644 index 0000000000..b75b7c250c --- /dev/null +++ b/Task/Closest-pair-problem/Groovy/closest-pair-problem-3.groovy @@ -0,0 +1,48 @@ +def elegantClosest(Collection pointCol) { + assert pointCol + List xList = (pointCol as List).sort { it.x } + List yList = xList.clone().sort { it.y } + reductionClosest(xList, xList) +} + +def reductionClosest(List xPoints, List yPoints) { +// assert xPoints && yPoints +// assert (xPoints as Set) == (yPoints as Set) + int n = xPoints.size() + if (n < 10) return bruteClosest(xPoints) + + int nMid = Math.ceil(n/2) + List xLeft = xPoints[0.. xMid } + if (xRight[0].x == xMid) { + yLeft = xLeft.collect{ it }.sort { it.y } + yRight = xRight.collect{ it }.sort { it.y } + } + + Map aLeft = reductionClosest(xLeft, yLeft) + Map aRight = reductionClosest(xRight, yRight) + Map aMin = aRight.distance < aLeft.distance ? aRight : aLeft + List yMid = yPoints.findAll { (xMid - it.x).abs() < aMin.distance } + int nyMid = yMid.size() + if (nyMid < 2) return aMin + + Map answer = aMin + (0..<(nyMid-1)).each { i -> + ((i+1).. + (yMid[j].x - yMid[i].x).abs() < aMin.distance && + (yMid[j].y - yMid[i].y).abs() < aMin.distance && + yMid[j].distance(yMid[i]) < aMin.distance + }.each { k -> + if ((yMid[k].x - yMid[i].x).abs() < answer.distance && (yMid[k].y - yMid[i].y).abs() < answer.distance) { + def ikDist = yMid[i].distance(yMid[k]) + if ( ikDist < answer.distance) { + answer = [distance:ikDist, points:[yMid[i],yMid[k]]] + } + } + } + } + answer +} diff --git a/Task/Closest-pair-problem/Groovy/closest-pair-problem-4.groovy b/Task/Closest-pair-problem/Groovy/closest-pair-problem-4.groovy new file mode 100644 index 0000000000..303aa82c2f --- /dev/null +++ b/Task/Closest-pair-problem/Groovy/closest-pair-problem-4.groovy @@ -0,0 +1,28 @@ +def random = new Random() + +(1..4).each { +def point10 = (0..<(10**it)).collect { new Point(random.nextInt(1000001) - 500000,random.nextInt(1000001) - 500000) } + +def startE = System.currentTimeMillis() +def closestE = elegantClosest(point10) +def elapsedE = System.currentTimeMillis() - startE +println """ +${10**it} POINTS +----------------------------------------- +Elegant reduction: +elapsed: ${elapsedE/1000} s +closest: ${closestE} +""" + + +def startB = System.currentTimeMillis() +def closestB = bruteClosest(point10) +def elapsedB = System.currentTimeMillis() - startB +println """Brute force: +elapsed: ${elapsedB/1000} s +closest: ${closestB} + +Speedup ratio (B/E): ${elapsedB/elapsedE} +========================================= +""" +} diff --git a/Task/Closest-pair-problem/Icon/closest-pair-problem.icon b/Task/Closest-pair-problem/Icon/closest-pair-problem.icon new file mode 100644 index 0000000000..8ac7543736 --- /dev/null +++ b/Task/Closest-pair-problem/Icon/closest-pair-problem.icon @@ -0,0 +1,25 @@ +record point(x,y) + +procedure main() + minDist := 0 + minPair := &null + every (points := [],p1 := readPoint()) do { + if *points == 1 then minDist := dSquared(p1,points[1]) + every minDist >=:= dSquared(p1,p2 := !points) do minPair := [p1,p2] + push(points, p1) + } + + if \minPair then { + write("(",minPair[1].x,",",minPair[1].y,") -> ", + "(",minPair[2].x,",",minPair[2].y,")") + } + else write("One or fewer points!") +end + +procedure readPoint() # Skips lines that don't have two numbers on them + suspend !&input ? point(numeric(tab(upto(', '))), numeric((move(1),tab(0)))) +end + +procedure dSquared(p1,p2) # Compute the square of the distance + return (p2.x-p1.x)^2 + (p2.y-p1.y)^2 # (sufficient for closeness) +end diff --git a/Task/Closest-pair-problem/J/closest-pair-problem-1.j b/Task/Closest-pair-problem/J/closest-pair-problem-1.j new file mode 100644 index 0000000000..cf1d000445 --- /dev/null +++ b/Task/Closest-pair-problem/J/closest-pair-problem-1.j @@ -0,0 +1,4 @@ +vecl =: +/"1&.:*: NB. length of each of vectors +dist =: <@:vecl@:({: -"1 }:)\ NB. calculate all distances among vectors +minpair=: ({~ > {.@($ #: I.@,)@:= <./@;)dist NB. find one pair of the closest points +closestpairbf =: (; vecl@:-/)@minpair NB. the pair and their distance diff --git a/Task/Closest-pair-problem/J/closest-pair-problem-2.j b/Task/Closest-pair-problem/J/closest-pair-problem-2.j new file mode 100644 index 0000000000..11986327ce --- /dev/null +++ b/Task/Closest-pair-problem/J/closest-pair-problem-2.j @@ -0,0 +1,17 @@ + ]pts=:10 2 ?@$ 0 +0.654682 0.925557 +0.409382 0.619391 +0.891663 0.888594 +0.716629 0.9962 +0.477721 0.946355 +0.925092 0.81822 +0.624291 0.142924 +0.211332 0.221507 +0.293786 0.691701 +0.839186 0.72826 + + closestpairbf pts ++-----------------+---------+ +|0.891663 0.888594|0.0779104| +|0.925092 0.81822| | ++-----------------+---------+ diff --git a/Task/Closest-pair-problem/J/closest-pair-problem-3.j b/Task/Closest-pair-problem/J/closest-pair-problem-3.j new file mode 100644 index 0000000000..4364003115 --- /dev/null +++ b/Task/Closest-pair-problem/J/closest-pair-problem-3.j @@ -0,0 +1,17 @@ + ]pts=:10 4 ?@$ 0 +0.559164 0.482993 0.876 0.429769 +0.217911 0.729463 0.97227 0.132175 +0.479206 0.169165 0.495302 0.362738 +0.316673 0.797519 0.745821 0.0598321 +0.662585 0.726389 0.658895 0.653457 +0.965094 0.664519 0.084712 0.20671 +0.840877 0.591713 0.630206 0.99119 +0.221416 0.114238 0.0991282 0.174741 +0.946262 0.505672 0.776017 0.307362 +0.262482 0.540054 0.707342 0.465234 + + closestpairbf pts ++------------------------------------+--------+ +|0.217911 0.729463 0.97227 0.132175|0.708555| +|0.316673 0.797519 0.745821 0.0598321| | ++------------------------------------+--------+ diff --git a/Task/Closest-pair-problem/Liberty-BASIC/closest-pair-problem.liberty b/Task/Closest-pair-problem/Liberty-BASIC/closest-pair-problem.liberty new file mode 100644 index 0000000000..36e88a47d5 --- /dev/null +++ b/Task/Closest-pair-problem/Liberty-BASIC/closest-pair-problem.liberty @@ -0,0 +1,41 @@ +N =10 + +dim x( N), y( N) + +firstPt =0 +secondPt =0 + +for i =1 to N + read f: x( i) =f + read f: y( i) =f +next i + +minDistance =1E6 + +for i =1 to N -1 + for j =i +1 to N + dxSq =( x( i) -x( j))^2 + dySq =( y( i) -y( j))^2 + D =abs( ( dxSq +dySq)^0.5) + if D [] +a[0]: 1 # => [1] +a[3]: 2 # => [1, nil, nil, 2] + +# creating an array with the constructor +a = Array new # => [] diff --git a/Task/Collections/Fancy/collections-2.fancy b/Task/Collections/Fancy/collections-2.fancy new file mode 100644 index 0000000000..0c9081c43a --- /dev/null +++ b/Task/Collections/Fancy/collections-2.fancy @@ -0,0 +1,9 @@ +# creating an empty hash + +h = <[]> # => <[]> +h["a"]: 1 # => <["a" => 1]> +h["test"]: 2.4 # => <["a" => 1, "test" => 2.4]> +h[3]: "Hello" # => <["a" => 1, "test" => 2.4, 3 => "Hello"]> + +# creating a hash with the constructor +h = Hash new # => <[]> diff --git a/Task/Collections/Groovy/collections-1.groovy b/Task/Collections/Groovy/collections-1.groovy new file mode 100644 index 0000000000..2cdc9b5c2c --- /dev/null +++ b/Task/Collections/Groovy/collections-1.groovy @@ -0,0 +1,21 @@ +def emptyList = [] +assert emptyList.isEmpty() : "These are not the items you're looking for" +assert emptyList.size() == 0 : "Empty list has size 0" +assert ! emptyList : "Empty list evaluates as boolean 'false'" + +def initializedList = [ 1, "b", java.awt.Color.BLUE ] +assert initializedList.size() == 3 +assert initializedList : "Non-empty list evaluates as boolean 'true'" +assert initializedList[2] == java.awt.Color.BLUE : "referencing a single element (zero-based indexing)" +assert initializedList[-1] == java.awt.Color.BLUE : "referencing a single element (reverse indexing of last element)" + +def combinedList = initializedList + [ "more stuff", "even more stuff" ] +assert combinedList.size() == 5 +assert combinedList[1..3] == ["b", java.awt.Color.BLUE, "more stuff"] : "referencing a range of elements" + +combinedList << "even more stuff" +assert combinedList.size() == 6 +assert combinedList[-1..-3] == \ + ["even more stuff", "even more stuff", "more stuff"] \ + : "reverse referencing last 3 elements" +println ([combinedList: combinedList]) diff --git a/Task/Collections/Groovy/collections-2.groovy b/Task/Collections/Groovy/collections-2.groovy new file mode 100644 index 0000000000..4b2a548527 --- /dev/null +++ b/Task/Collections/Groovy/collections-2.groovy @@ -0,0 +1,24 @@ +def emptyMap = [:] +assert emptyMap.isEmpty() : "These are not the items you're looking for" +assert emptyMap.size() == 0 : "Empty map has size 0" +assert ! emptyMap : "Empty map evaluates as boolean 'false'" + +def initializedMap = [ count: 1, initial: "B", eyes: java.awt.Color.BLUE ] +assert initializedMap.size() == 3 +assert initializedMap : "Non-empty map evaluates as boolean 'true'" +assert initializedMap["eyes"] == java.awt.Color.BLUE : "referencing a single element (array syntax)" +assert initializedMap.eyes == java.awt.Color.BLUE : "referencing a single element (member syntax)" +assert initializedMap.height == null : \ + "references to non-existant keys generally evaluate to null (implementation dependent)" + +def combinedMap = initializedMap \ + + [hair: java.awt.Color.BLACK, birthdate: Date.parse("yyyy-MM-dd", "1960-05-17") ] +assert combinedMap.size() == 5 + +combinedMap["weight"] = 185 // array syntax +combinedMap.lastName = "Smith" // member syntax +combinedMap << [firstName: "Joe"] // entry syntax +assert combinedMap.size() == 8 +assert combinedMap.keySet().containsAll( + ["lastName", "count", "eyes", "hair", "weight", "initial", "firstName", "birthdate"]) +println ([combinedMap: combinedMap]) diff --git a/Task/Collections/Groovy/collections-3.groovy b/Task/Collections/Groovy/collections-3.groovy new file mode 100644 index 0000000000..0e3efc4284 --- /dev/null +++ b/Task/Collections/Groovy/collections-3.groovy @@ -0,0 +1,16 @@ +def emptySet = new HashSet() +assert emptySet.isEmpty() : "These are not the items you're looking for" +assert emptySet.size() == 0 : "Empty set has size 0" +assert ! emptySet : "Empty set evaluates as boolean 'false'" + +def initializedSet = new HashSet([ 1, "b", java.awt.Color.BLUE ]) +assert initializedSet.size() == 3 +assert initializedSet : "Non-empty list evaluates as boolean 'true'" +//assert initializedSet[2] == java.awt.Color.BLUE // SYNTAX ERROR!!! No indexing of set elements! + +def combinedSet = initializedSet + new HashSet([ "more stuff", "even more stuff" ]) +assert combinedSet.size() == 5 + +combinedSet << "even more stuff" +assert combinedSet.size() == 5 : "No duplicate elements allowed!" +println ([combinedSet: combinedSet]) diff --git a/Task/Collections/Icon/collections-1.icon b/Task/Collections/Icon/collections-1.icon new file mode 100644 index 0000000000..84baf2e7cf --- /dev/null +++ b/Task/Collections/Icon/collections-1.icon @@ -0,0 +1,8 @@ +# Creation of collections: + s := "abccd" # string, an ordered collection of characters, immutable + c := 'abcd' # cset, an unordered collection of characters, immutable + S := set() # set, an unordered collection of unique values, mutable, contents may be of any type + T := table() # table, an associative array of values accessed via unordered keys, mutable, contents may be of any type + L := [] # list, an ordered collection of values indexed by position 1..n or as stack/queue, mutable, contents may be of any type + record constructorname(field1,field2,fieldetc) # record, a collection of values stored in named fields, mutable, contents may be of any type (declare outside procedures) + R := constructorname() # record (creation) diff --git a/Task/Collections/Icon/collections-2.icon b/Task/Collections/Icon/collections-2.icon new file mode 100644 index 0000000000..a0e1c3d42c --- /dev/null +++ b/Task/Collections/Icon/collections-2.icon @@ -0,0 +1,6 @@ + s ||:= "xyz" # concatenation + c ++:= 'xyz' # union + insert(S,"abc") # insert + T["abc"] := "xyz" # insert create/overwrite + put(L,1) # put (extend), also push + R.field1 := "xyz" # overwrite diff --git a/Task/Collections/Icon/collections-3.icon b/Task/Collections/Icon/collections-3.icon new file mode 100644 index 0000000000..4e9dc69bb2 --- /dev/null +++ b/Task/Collections/Icon/collections-3.icon @@ -0,0 +1,4 @@ + S := S ++ S2 # union of two sets or two csets + S ++:= S2 # augmented assignment + L := L ||| L2 # list concatenation + L |||:= L2 # augmented assignment diff --git a/Task/Collections/J/collections.j b/Task/Collections/J/collections.j new file mode 100644 index 0000000000..55197c3073 --- /dev/null +++ b/Task/Collections/J/collections.j @@ -0,0 +1,87 @@ + c =: 0 10 20 30 40 NB. A collection + + c, 50 NB. Append 50 to the collection +0 10 20 30 40 50 + _20 _10 , c NB. Prepend _20 _10 to the collection +_20 _10 0 10 20 30 40 + + ,~ c NB. Self-append +0 10 20 30 40 0 10 20 30 40 + ,:~ c NB. Duplicate +0 10 20 30 40 +0 10 20 30 40 + + 30 e. c NB. Is 30 in the collection? +1 + 30 i.~c NB. Where? +3 + 30 80 e. c NB. Don't change anything to test multiple values -- collections are native. +1 0 + + 2 1 4 2 { c NB. From the collection, give me items two, one, four, and two again. +20 10 40 20 + + |.c NB. Reverse the collection +40 30 20 10 0 + 1+c NB. Increment the collection +1 11 21 31 41 + c%10 NB. Decimate the collection (divide by 10) +0 1 2 3 4 + + {. c NB. Give me the first item +0 + {: c NB. And the last +40 + 3{.c NB. Give me the first 3 items +0 10 20 + 3}.c NB. Throw away the first 3 items +30 40 + _3{.c NB. Give me the last 3 items +20 30 40 + _3}.c NB. (Guess) +0 10 + + keys_map_ =: 'one';'two';'three' + vals_map_ =: 'alpha';'beta';'gamma' + lookup_map_ =: a:& $: : (dyad def ' (keys i. y) { vals,x')&boxopen + exists_map_ =: verb def 'y e. keys'&boxopen + + exists_map_ 'bad key' +0 + exists_map_ 'two';'bad key' +1 0 + + lookup_map_ 'one' ++-----+ +|alpha| ++-----+ + lookup_map_ 'three';'one';'two';'one' ++-----+-----+----+-----+ +|gamma|alpha|beta|alpha| ++-----+-----+----+-----+ + lookup_map_ 'bad key' +++ +|| +++ + 'some other default' lookup_map_ 'bad key' ++------------------+ +|some other default| ++------------------+ + 'some other default' lookup_map_ 'two';'bad key' ++----+------------------+ +|beta|some other default| ++----+------------------+ + + +/ c NB. Sum of collection +100 + */ c NB. Product of collection +0 + + i.5 NB. Generate the first 5 nonnegative integers +0 1 2 3 4 + 10*i.5 NB. Looks familiar +0 10 20 30 40 + c = 10*i.5 NB. Test each for equality +1 1 1 1 1 + c -: 10 i.5 NB. Test for identicality +1 diff --git a/Task/Collections/Lisaac/collections-1.lisaac b/Task/Collections/Lisaac/collections-1.lisaac new file mode 100644 index 0000000000..be127104e9 --- /dev/null +++ b/Task/Collections/Lisaac/collections-1.lisaac @@ -0,0 +1,4 @@ ++ vector : ARRAY[INTEGER]; +vector := ARRAY[INTEGER].create_with_capacity 32 lower 0; +vector.add_last 1; +vector.add_last 2; diff --git a/Task/Collections/Lisaac/collections-2.lisaac b/Task/Collections/Lisaac/collections-2.lisaac new file mode 100644 index 0000000000..5a7ec89708 --- /dev/null +++ b/Task/Collections/Lisaac/collections-2.lisaac @@ -0,0 +1,4 @@ ++ set : HASHED_SET[INTEGER]; +set := HASHED_SET[INTEGER].create; +set.add 1; +set.add 2; diff --git a/Task/Collections/Lisaac/collections-3.lisaac b/Task/Collections/Lisaac/collections-3.lisaac new file mode 100644 index 0000000000..8fac868ebc --- /dev/null +++ b/Task/Collections/Lisaac/collections-3.lisaac @@ -0,0 +1,4 @@ ++ list : LINKED_LIST[INTEGER]; +list := LINKED_LIST[INTEGER].create; +list.add_last 1; +list.add_last 2; diff --git a/Task/Collections/Lisaac/collections-4.lisaac b/Task/Collections/Lisaac/collections-4.lisaac new file mode 100644 index 0000000000..ae30ba168c --- /dev/null +++ b/Task/Collections/Lisaac/collections-4.lisaac @@ -0,0 +1,4 @@ ++ dict : HASHED_DICTIONARY[INTEGER/*value*/, STRING_CONSTANT/*key*/]; +dict := HASHED_DICTIONARY[INTEGER, STRING_CONSTANT].create; +dict.put 1 to "one"; +dict.put 2 to "two"; diff --git a/Task/Collections/Mathematica/collections.mathematica b/Task/Collections/Mathematica/collections.mathematica new file mode 100644 index 0000000000..906d13f0e9 --- /dev/null +++ b/Task/Collections/Mathematica/collections.mathematica @@ -0,0 +1,13 @@ +Lst = {3, 4, 5, 6} +->{3, 4, 5, 6} + +PrependTo[ Lst, 2] +->{2, 3, 4, 5, 6} +PrependTo[ Lst, 1] +->{1, 2, 3, 4, 5, 6} + +Lst +->{1, 2, 3, 4, 5, 6} + +Insert[ Lst, X, 4] +->{1, 2, 3, X, 4, 5, 6} diff --git a/Task/Color-of-a-screen-pixel/Icon/color-of-a-screen-pixel.icon b/Task/Color-of-a-screen-pixel/Icon/color-of-a-screen-pixel.icon new file mode 100644 index 0000000000..7eaffa5249 --- /dev/null +++ b/Task/Color-of-a-screen-pixel/Icon/color-of-a-screen-pixel.icon @@ -0,0 +1,24 @@ +link graphics,printf + +procedure main() + + WOpen("canvas=hidden") # hide for query + height := WAttrib("displayheight") - 45 # adjust for ... + width := WAttrib("displaywidth") - 20 # ... window 7 borders + WClose(&window) + + W := WOpen("size="||width||","||height,"bg=black") | + stop("Unable to open window") + + every 1 to 10 do { # generate some random rectangles within the frame + x := ?width + y := ?(height-100) + WAttrib("fg="||?["red","green","blue","purple","yellow"]) + FillRectangle(x,x+50,y,y+50) + } + + while Event() do + printf("x=%d,y=%d pixel=%s\n",&x,&y,Pixel(&x,&y,&x,&y)) + + WDone(W) # q to exit +end diff --git a/Task/Color-of-a-screen-pixel/Liberty-BASIC/color-of-a-screen-pixel.liberty b/Task/Color-of-a-screen-pixel/Liberty-BASIC/color-of-a-screen-pixel.liberty new file mode 100644 index 0000000000..3f0dfba47a --- /dev/null +++ b/Task/Color-of-a-screen-pixel/Liberty-BASIC/color-of-a-screen-pixel.liberty @@ -0,0 +1,25 @@ +'This example requires the Windows API +Struct point, x As long, y As long + +hDC = GetDC(0) +result = GetCursorPos() +Print GetPixel(hDC, point.x.struct, point.y.struct) +Call ReleaseDC 0, hDC +End + + + Sub ReleaseDC hWnd, hDC + CallDLL #user32,"ReleaseDC", hWnd As uLong, hDC As uLong, ret As Long + End Sub + + Function GetDC(hWnd) + CallDLL #user32, "GetDC", hWnd As uLong, GetDC As uLong + End Function + + Function GetCursorPos() + CallDLL #user32, "GetCursorPos", point As struct, GetCursorPos As uLong + End Function + + Function GetPixel(hDC, x, y) + CallDLL #gdi32, "GetPixel", hDC As uLong, x As long, y As long, GetPixel As long + End Function diff --git a/Task/Color-of-a-screen-pixel/Locomotive-Basic/color-of-a-screen-pixel.bas b/Task/Color-of-a-screen-pixel/Locomotive-Basic/color-of-a-screen-pixel.bas new file mode 100644 index 0000000000..f5bb546012 --- /dev/null +++ b/Task/Color-of-a-screen-pixel/Locomotive-Basic/color-of-a-screen-pixel.bas @@ -0,0 +1,3 @@ +10 x=320:y=200 +20 color=TEST(x,y) +30 PRINT "Pen color at"; x; y; "is"; color diff --git a/Task/Color-quantization/J/color-quantization-1.j b/Task/Color-quantization/J/color-quantization-1.j new file mode 100644 index 0000000000..95309cfc30 --- /dev/null +++ b/Task/Color-quantization/J/color-quantization-1.j @@ -0,0 +1,10 @@ +kmcL=:4 :0 + C=. /:~ 256 #.inv ,y NB. colors + G=. x (i.@] <.@* %) #C NB. groups (initial) + Q=. _ NB. quantized list of colors (initial + whilst.-. Q-:&<.&(x&*)Q0 do. + Q0=. Q + Q=. /:~C (+/ % #)/.~ G + G=. (i. <./)"1 C +/&.:*: .- |:Q + end.Q +) diff --git a/Task/Color-quantization/J/color-quantization-2.j b/Task/Color-quantization/J/color-quantization-2.j new file mode 100644 index 0000000000..d60dfd966b --- /dev/null +++ b/Task/Color-quantization/J/color-quantization-2.j @@ -0,0 +1,17 @@ + 16 kmcL img +7.52532 22.3347 0.650468 +8.20129 54.4678 0.0326828 +33.1132 69.8148 0.622265 +54.2232 125.682 2.67713 +56.7064 99.5008 3.04013 +61.2135 136.42 4.2015 +68.1246 140.576 6.37512 +74.6006 143.606 7.57854 +78.9101 150.792 10.2563 +89.5873 148.621 14.6202 +98.9523 154.005 25.7583 +114.957 159.697 47.6423 +145.816 178.136 33.8845 +164.969 199.742 67.0467 +179.849 207.594 109.973 +209.229 221.18 204.513 diff --git a/Task/Color-quantization/Mathematica/color-quantization.mathematica b/Task/Color-quantization/Mathematica/color-quantization.mathematica new file mode 100644 index 0000000000..1ea435b5c2 --- /dev/null +++ b/Task/Color-quantization/Mathematica/color-quantization.mathematica @@ -0,0 +1 @@ +ColorQuantize[Import["http://rosettacode.org/mw/images/3/3f/Quantum_frog.png"],16,Dithering->False] diff --git a/Task/Colour-bars-Display/Icon/colour-bars-display-1.icon b/Task/Colour-bars-Display/Icon/colour-bars-display-1.icon new file mode 100644 index 0000000000..f4f008a77e --- /dev/null +++ b/Task/Colour-bars-Display/Icon/colour-bars-display-1.icon @@ -0,0 +1,37 @@ +link graphics,printf + +procedure main() # generalized colour bars + DrawTestCard(Simple_TestCard()) + WDone() +end + +procedure DrawTestCard(TC) + size := sprintf("size=%d,%d",TC.width,TC.height) + &window := TC.window := open(TC.id,"g","bg=black",size) | + stop("Unable to open window") + + every R := TC.bands[r := 1 to *TC.bands -1] do + every C := R.bars[c := 1 to *R.bars - 1] do { + Fg(R.bars[c].colour) + FillRectangle( C.left, R.top, + R.bars[c+1].left-C.left, TC.bands[r+1].top-R.top ) + } + return TC +end + +record testcard(window,id,width,height,bands) +record band(top,bars) +record bar(left,colour) + +procedure Simple_TestCard() #: return structure simple testcard + return testcard(,"Simple Test Card",width := 800,height := 600, + [ band( 1, [ bar( 1, "black"), + bar(114, "red"), + bar(228, "green"), + bar(342, "blue"), + bar(456, "magenta"), + bar(570, "cyan"), + bar(684, "yellow"), + bar(width) ] ), + band(height) ]) +end diff --git a/Task/Colour-bars-Display/Icon/colour-bars-display-2.icon b/Task/Colour-bars-Display/Icon/colour-bars-display-2.icon new file mode 100644 index 0000000000..09462701ab --- /dev/null +++ b/Task/Colour-bars-Display/Icon/colour-bars-display-2.icon @@ -0,0 +1,29 @@ +procedure SMPTE_TestCard() #: return structure with 480i(ish) testcard + return testcard(,"SMPTE TV Test Card",width := 672,height := 504, + [ band( 1, [ bar( 1, "#c0c0c0"), + bar( 95, "#c0c000"), + bar(191, "#00c0c0"), + bar(288, "#00c000"), + bar(383, "#c000c0"), + bar(480, "#c00000"), + bar(575, "#0000c0"), + bar(width) ] ), + band(335, [ bar( 1, "#0000c0"), + bar( 95, "#131313"), + bar(191, "#c000c0"), + bar(288, "#131313"), + bar(383, "#00c0c0"), + bar(480, "#131313"), + bar(575, "#c0c0c0"), + bar(width) ] ), + band(378, [ bar( 1, "#00214c"), + bar(120, "#ffffff"), + bar(240, "#32006a"), + bar(360, "#131313"), + bar(480, "#090909"), + bar(512, "#131313"), + bar(544, "#1d1d1d"), + bar(576, "#131313"), + bar(width) ] ), + band(height) ]) +end diff --git a/Task/Colour-bars-Display/J/colour-bars-display.j b/Task/Colour-bars-Display/J/colour-bars-display.j new file mode 100644 index 0000000000..c37705b5f3 --- /dev/null +++ b/Task/Colour-bars-Display/J/colour-bars-display.j @@ -0,0 +1,4 @@ + load 'viewmat' + size=: 2{.".wd'qm' NB. J6 + size=: getscreenwh_jgtk_ '' NB. J7 + 'rgb'viewmat (|.size){. (>.&.(%&160)|.size)$ 20# 256#.255*#:i.8 diff --git a/Task/Colour-bars-Display/Liberty-BASIC/colour-bars-display.liberty b/Task/Colour-bars-Display/Liberty-BASIC/colour-bars-display.liberty new file mode 100644 index 0000000000..528e576b26 --- /dev/null +++ b/Task/Colour-bars-Display/Liberty-BASIC/colour-bars-display.liberty @@ -0,0 +1,20 @@ +nomainwin +colors$="black red green blue pink cyan yellow white" +WindowWidth=DisplayWidth:WindowHeight=DisplayHeight +UpperLeftX=1:UpperLeftY=1 +barWidth=DisplayWidth/8 +graphicbox #main.g, 0,0,DisplayWidth,DisplayHeight +open "" for window_popup as #main +#main "trapclose [quit]" +#main.g "down; setfocus; when characterInput [quit]" +#main.g "when leftButtonUp [quit]" +#main.g "size ";barWidth + +for x = barWidth/2 to DisplayWidth step barWidth + i=i+1 + if i>8 then i=1 + col$=word$(colors$,i) + #main.g "color ";col$;"; line ";x;" 0 ";x;" ";DisplayHeight +next +wait +[quit] close #main:end diff --git a/Task/Colour-bars-Display/Locomotive-Basic/colour-bars-display.bas b/Task/Colour-bars-Display/Locomotive-Basic/colour-bars-display.bas new file mode 100644 index 0000000000..22c2f0c6e0 --- /dev/null +++ b/Task/Colour-bars-Display/Locomotive-Basic/colour-bars-display.bas @@ -0,0 +1,7 @@ +10 MODE 0:BORDER 23 +20 FOR x=0 TO 15 +30 ORIGIN x*40,0 +40 GRAPHICS PEN x +50 FOR z=0 TO 39 STEP 4:MOVE z,0:DRAW z,400:NEXT +60 NEXT +70 CALL &bb06 ' wait for key press diff --git a/Task/Colour-bars-Display/Mathematica/colour-bars-display.mathematica b/Task/Colour-bars-Display/Mathematica/colour-bars-display.mathematica new file mode 100644 index 0000000000..8c4a27899b --- /dev/null +++ b/Task/Colour-bars-Display/Mathematica/colour-bars-display.mathematica @@ -0,0 +1,3 @@ +ArrayPlot[ + ConstantArray[{Black, Red, Green, Blue, Magenta, Cyan, Yellow, + White}, 5]] diff --git a/Task/Colour-pinstripe-Display/Icon/colour-pinstripe-display.icon b/Task/Colour-pinstripe-Display/Icon/colour-pinstripe-display.icon new file mode 100644 index 0000000000..b996b1838e --- /dev/null +++ b/Task/Colour-pinstripe-Display/Icon/colour-pinstripe-display.icon @@ -0,0 +1,30 @@ +link graphics,numbers,printf + +procedure main() # pinstripe + + &window := open("Colour Pinstripe","g","bg=black") | + stop("Unable to open window") + + WAttrib("canvas=hidden") + WAttrib(sprintf("size=%d,%d",WAttrib("displaywidth"),WAttrib("displayheight"))) + WAttrib("canvas=maximal") + + Colours := ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"] + height := WAttrib("height") + width := WAttrib("width") + + maxbands := 4 # bands to draw + bandheight := height / maxbands # height of each band + every bands := 1 to maxbands do { # for each band + top := 1 + bandheight * (bands-1) # .. top of band + every c := 1 to width do { + colour := Colours[ceil((c+0.)/bands)%*Colours+1] + if colour == "black" then next # skip black + else { + Fg(colour) + DrawLine(c,top,c,top+bandheight-1) + } + } + } + WDone() +end diff --git a/Task/Colour-pinstripe-Display/J/colour-pinstripe-display.j b/Task/Colour-pinstripe-Display/J/colour-pinstripe-display.j new file mode 100644 index 0000000000..630ecf63e7 --- /dev/null +++ b/Task/Colour-pinstripe-Display/J/colour-pinstripe-display.j @@ -0,0 +1,4 @@ + load 'viewmat' + size=. 2{.".wd'qm' NB. J6 + size=. getscreenwh_jgtk_ '' NB. J7 + 'rgb'viewmat (4<.@%~{:size)# ({.size) $&> 1 2 3 4#&.> <256#.255*#:i.8 diff --git a/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-1.icon b/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-1.icon new file mode 100644 index 0000000000..bfcac4de34 --- /dev/null +++ b/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-1.icon @@ -0,0 +1,17 @@ +# generate all combinations of length n from list L, +# including repetitions +procedure combinations_repetitions (L, n) + if n = 0 + then suspend [] # if reach 0, then return an empty list + else if *L > 0 + then { + # keep the first element + item := L[1] + # get all of length n in remaining list + every suspend (combinations_repetitions (L[2:0], n)) + # get all of length n-1 in remaining list + # and add kept element to make list of size n + every i := combinations_repetitions (L, n-1) do + suspend [item] ||| i + } +end diff --git a/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-2.icon b/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-2.icon new file mode 100644 index 0000000000..b107fbb764 --- /dev/null +++ b/Task/Combinations-with-repetitions/Icon/combinations-with-repetitions-2.icon @@ -0,0 +1,16 @@ +# convenience function +procedure write_list (l) + every (writes (!l || " ")) + write () +end + +# testing routine +procedure main () + # display all combinations for 2 of iced/jam/plain + every write_list (combinations_repetitions(["iced", "jam", "plain"], 2)) + # get a count for number of ways to select 3 items from 10 + every push(num_list := [], 1 to 10) + count := 0 + every combinations_repetitions(num_list, 3) do count +:= 1 + write ("There are " || count || " possible combinations of 3 from 10") +end diff --git a/Task/Combinations-with-repetitions/J/combinations-with-repetitions-1.j b/Task/Combinations-with-repetitions/J/combinations-with-repetitions-1.j new file mode 100644 index 0000000000..c802208e9f --- /dev/null +++ b/Task/Combinations-with-repetitions/J/combinations-with-repetitions-1.j @@ -0,0 +1 @@ +rcomb=: >@~.@:(/:~&.>)@,@{@# < diff --git a/Task/Combinations-with-repetitions/J/combinations-with-repetitions-2.j b/Task/Combinations-with-repetitions/J/combinations-with-repetitions-2.j new file mode 100644 index 0000000000..73927e7224 --- /dev/null +++ b/Task/Combinations-with-repetitions/J/combinations-with-repetitions-2.j @@ -0,0 +1,16 @@ + 2 rcomb ;:'iced jam plain' +┌─────┬─────┐ +│iced │iced │ +├─────┼─────┤ +│iced │jam │ +├─────┼─────┤ +│iced │plain│ +├─────┼─────┤ +│jam │jam │ +├─────┼─────┤ +│jam │plain│ +├─────┼─────┤ +│plain│plain│ +└─────┴─────┘ + #3 rcomb i.10 NB. ways to choose 3 items from 10 with replacement +220 diff --git a/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-1.mathematica b/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-1.mathematica new file mode 100644 index 0000000000..917fa12836 --- /dev/null +++ b/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-1.mathematica @@ -0,0 +1,8 @@ +DeleteDuplicates[Tuples[{"iced", "jam", "plain"}, 2],Sort[#1] == Sort[#2] &] +->{{"iced", "iced"}, {"iced", "jam"}, {"iced", "plain"}, {"jam", "jam"}, {"jam", "plain"}, {"plain", "plain"}} + +Combi[x_, y_] := Binomial[(x + y) - 1, y] +Combi[3, 2] +-> 6 +Combi[10, 3] +->220 diff --git a/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-2.mathematica b/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-2.mathematica new file mode 100644 index 0000000000..eb278e4532 --- /dev/null +++ b/Task/Combinations-with-repetitions/Mathematica/combinations-with-repetitions-2.mathematica @@ -0,0 +1,14 @@ +CombinWithRep[S_List, k_] := Module[{occupation, assignment}, + occupation = + Flatten[Permutations /@ + IntegerPartitions[k, {Length[S]}, Range[0, k]], 1]; + assignment = + Flatten[Table[ConstantArray[z, {#[[z]]}], {z, Length[#]}]] & /@ + occupation; + Thread[S[[#]]] & /@ assignment + ] + +In[2]:= CombinWithRep[{"iced", "jam", "plain"}, 2] + +Out[2]= {{"iced", "iced"}, {"jam", "jam"}, {"plain", + "plain"}, {"iced", "jam"}, {"iced", "plain"}, {"jam", "plain"}} diff --git a/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-1.mercury b/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-1.mercury new file mode 100644 index 0000000000..d08594a16b --- /dev/null +++ b/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-1.mercury @@ -0,0 +1,32 @@ +:- module comb. +:- interface. +:- import_module list, int, bag. + +:- pred choose(list(T)::in, int::in, bag(T)::out) is nondet. +:- pred choose_all(list(T)::in, int::in, list(list(T))::out) is det. +:- pred count_choices(list(T)::in, int::in, int::out) is det. + +:- implementation. +:- import_module solutions. + +choose(L, N, R) :- choose(L, N, bag.init, R). + +:- pred choose(list(T)::in, int::in, bag(T)::in, bag(T)::out) is nondet. +choose(L, N, !R) :- + ( N = 0 -> + true + ; + member(X, L), + bag.insert(!.R, X, !:R), + choose(L, N - 1, !R) + ). + +choose_all(L, N, R) :- + solutions(choose(L, N), R0), + list.map(bag.to_list, R0, R). + +count_choices(L, N, Count) :- + aggregate(choose(L, N), count, 0, Count). + +:- pred count(T::in, int::in, int::out) is det. +count(_, N0, N) :- N0 + 1 = N. diff --git a/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-2.mercury b/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-2.mercury new file mode 100644 index 0000000000..c94c6b0e11 --- /dev/null +++ b/Task/Combinations-with-repetitions/Mercury/combinations-with-repetitions-2.mercury @@ -0,0 +1,18 @@ +:- module comb_ex. +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. +:- implementation. +:- import_module comb, list, string. + +:- type doughtnuts + ---> iced ; jam ; plain + ; glazed ; chocolate ; cream_filled ; mystery + ; cubed ; cream_covered ; explosive. + +main(!IO) :- + choose_all([iced, jam, plain], 2, L), + count_choices([iced, jam, plain, glazed, chocolate, cream_filled, + mystery, cubed, cream_covered, explosive], 3, N), + io.write(L, !IO), io.nl(!IO), + io.write_string(from_int(N) ++ " choices.\n", !IO). diff --git a/Task/Combinations/Factor/combinations-1.factor b/Task/Combinations/Factor/combinations-1.factor new file mode 100644 index 0000000000..6ac37abc9a --- /dev/null +++ b/Task/Combinations/Factor/combinations-1.factor @@ -0,0 +1,3 @@ +USING: math.combinatorics prettyprint ; + +5 iota 3 all-combinations . diff --git a/Task/Combinations/Factor/combinations-2.factor b/Task/Combinations/Factor/combinations-2.factor new file mode 100644 index 0000000000..5f76255b34 --- /dev/null +++ b/Task/Combinations/Factor/combinations-2.factor @@ -0,0 +1 @@ +{ "a" "b" "c" } 2 all-combinations . diff --git a/Task/Combinations/GAP/combinations.gap b/Task/Combinations/GAP/combinations.gap new file mode 100644 index 0000000000..c34163ec91 --- /dev/null +++ b/Task/Combinations/GAP/combinations.gap @@ -0,0 +1,6 @@ +# Built-in +Combinations([1 .. n], m); + +Combinations([1 .. 5], 3); +# [ [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 2, 5 ], [ 1, 3, 4 ], [ 1, 3, 5 ], +# [ 1, 4, 5 ], [ 2, 3, 4 ], [ 2, 3, 5 ], [ 2, 4, 5 ], [ 3, 4, 5 ] ] diff --git a/Task/Combinations/Groovy/combinations-1.groovy b/Task/Combinations/Groovy/combinations-1.groovy new file mode 100644 index 0000000000..625851b1b8 --- /dev/null +++ b/Task/Combinations/Groovy/combinations-1.groovy @@ -0,0 +1,10 @@ +def comb +comb = { m, list -> + def n = list.size() + m == 0 ? + [[]] : + (0..(n-m)).inject([]) { newlist, k -> + def sublist = (k+1 == n) ? [] : list[(k+1).. println "Choose ${i}:"; comb(i, csny).each { println it }; println() } diff --git a/Task/Combinations/Groovy/combinations-3.groovy b/Task/Combinations/Groovy/combinations-3.groovy new file mode 100644 index 0000000000..db26605440 --- /dev/null +++ b/Task/Combinations/Groovy/combinations-3.groovy @@ -0,0 +1 @@ +def comb0 = { m, n -> comb(m, (0.. println "Choose ${i}:"; comb0(i, 5).each { println it }; println() } diff --git a/Task/Combinations/Groovy/combinations-5.groovy b/Task/Combinations/Groovy/combinations-5.groovy new file mode 100644 index 0000000000..8e4cc48f84 --- /dev/null +++ b/Task/Combinations/Groovy/combinations-5.groovy @@ -0,0 +1 @@ +def comb1 = { m, n -> comb(m, (1..n)) } diff --git a/Task/Combinations/Groovy/combinations-6.groovy b/Task/Combinations/Groovy/combinations-6.groovy new file mode 100644 index 0000000000..3e7fceb0ef --- /dev/null +++ b/Task/Combinations/Groovy/combinations-6.groovy @@ -0,0 +1,2 @@ +println "Choose out of 5 (one-based):" +(0..3).each { i -> println "Choose ${i}:"; comb1(i, 5).each { println it }; println() } diff --git a/Task/Combinations/Icon/combinations-1.icon b/Task/Combinations/Icon/combinations-1.icon new file mode 100644 index 0000000000..3bdb870f55 --- /dev/null +++ b/Task/Combinations/Icon/combinations-1.icon @@ -0,0 +1,20 @@ +procedure main() +return combinations(3,5,0) +end + +procedure combinations(m,n,z) # demonstrate combinations +/z := 1 + +write(m," combinations of ",n," integers starting from ",z) +every put(L := [], z to n - 1 + z by 1) # generate list of n items from z +write("Intial list\n",list2string(L)) +write("Combinations:") +every write(list2string(lcomb(L,m))) +end + +procedure list2string(L) # helper function +every (s := "[") ||:= " " || (!L|"]") +return s +end + +link lists diff --git a/Task/Combinations/Icon/combinations-2.icon b/Task/Combinations/Icon/combinations-2.icon new file mode 100644 index 0000000000..1e819bd876 --- /dev/null +++ b/Task/Combinations/Icon/combinations-2.icon @@ -0,0 +1,8 @@ +procedure lcomb(L,i) #: list combinations + local j + + if i < 1 then fail + suspend if i = 1 then [!L] + else [L[j := 1 to *L - i + 1]] ||| lcomb(L[j + 1:0],i - 1) + +end diff --git a/Task/Combinations/J/combinations-1.j b/Task/Combinations/J/combinations-1.j new file mode 100644 index 0000000000..5755d528dc --- /dev/null +++ b/Task/Combinations/J/combinations-1.j @@ -0,0 +1,5 @@ +comb1=: dyad define + c=. 1 {.~ - d=. 1+y-x + z=. i.1 0 + for_j. (d-1+y)+/&i.d do. z=. (c#j) ,. z{~;(-c){.&.><i.{.c=. +/\.c end. +) diff --git a/Task/Combinations/J/combinations-2.j b/Task/Combinations/J/combinations-2.j new file mode 100644 index 0000000000..016ce8d83e --- /dev/null +++ b/Task/Combinations/J/combinations-2.j @@ -0,0 +1,3 @@ +comb=: dyad define M. + if. (x>:y)+.0=x do. i.(x<:y),x else. (0,.x comb&.<: y),1+x comb y-1 end. +) diff --git a/Task/Combinations/Julia/combinations.julia b/Task/Combinations/Julia/combinations.julia new file mode 100644 index 0000000000..9b5980a997 --- /dev/null +++ b/Task/Combinations/Julia/combinations.julia @@ -0,0 +1,13 @@ +julia> for i in @task combinations(1:5,3) +println(i) +end +[1, 2, 3] +[1, 2, 4] +[1, 3, 4] +[2, 3, 4] +[1, 2, 5] +[1, 3, 5] +[2, 3, 5] +[1, 4, 5] +[2, 4, 5] +[3, 4, 5] diff --git a/Task/Combinations/Logo/combinations.logo b/Task/Combinations/Logo/combinations.logo new file mode 100644 index 0000000000..b7409800c6 --- /dev/null +++ b/Task/Combinations/Logo/combinations.logo @@ -0,0 +1,7 @@ +to comb :n :list + if :n = 0 [output [[]]] + if empty? :list [output []] + output sentence map [sentence first :list ?] comb :n-1 bf :list ~ + comb :n bf :list +end +print comb 3 [0 1 2 3 4] diff --git a/Task/Combinations/M4/combinations.m4 b/Task/Combinations/M4/combinations.m4 new file mode 100644 index 0000000000..b5bda8ad47 --- /dev/null +++ b/Task/Combinations/M4/combinations.m4 @@ -0,0 +1,26 @@ +divert(-1) +define(`set',`define(`$1[$2]',`$3')') +define(`get',`defn(`$1[$2]')') +define(`setrange',`ifelse(`$3',`',$2,`define($1[$2],$3)`'setrange($1, + incr($2),shift(shift(shift($@))))')') +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')') +define(`show', + `for(`k',0,decr($1),`get(a,k) ')') + +define(`chklim', + `ifelse(get(`a',$3),eval($2-($1-$3)), + `chklim($1,$2,decr($3))', + `set(`a',$3,incr(get(`a',$3)))`'for(`k',incr($3),decr($2), + `set(`a',k,incr(get(`a',decr(k))))')`'nextcomb($1,$2)')') +define(`nextcomb', + `show($1) +ifelse(eval(get(`a',0)<$2-$1),1, + `chklim($1,$2,decr($1))')') +define(`comb', + `for(`j',0,decr($1),`set(`a',j,j)')`'nextcomb($1,$2)') +divert + +comb(3,5) diff --git a/Task/Combinations/Mathematica/combinations.mathematica b/Task/Combinations/Mathematica/combinations.mathematica new file mode 100644 index 0000000000..7fc1036719 --- /dev/null +++ b/Task/Combinations/Mathematica/combinations.mathematica @@ -0,0 +1 @@ +combinations[n_Integer, m_Integer]/;m>= 0:=Union[Sort /@ Permutations[Range[0, n - 1], {m}]] diff --git a/Task/Combinations/Maxima/combinations.maxima b/Task/Combinations/Maxima/combinations.maxima new file mode 100644 index 0000000000..ffed0247d7 --- /dev/null +++ b/Task/Combinations/Maxima/combinations.maxima @@ -0,0 +1,26 @@ +next_comb(n, p, a) := block( + [a: copylist(a), i: p], + if a[1] + p = n + 1 then return(und), + while a[i] - i >= n - p do i: i - 1, + a[i]: a[i] + 1, + for j from i + 1 thru p do a[j]: a[j - 1] + 1, + a +)$ + +combinations(n, p) := block( + [a: makelist(i, i, 1, p), v: [ ]], + while a # 'und do (v: endcons(a, v), a: next_comb(n, p, a)), + v +)$ + +combinations(5, 3); +/* [[1, 2, 3], + [1, 2, 4], + [1, 2, 5], + [1, 3, 4], + [1, 3, 5], + [1, 4, 5], + [2, 3, 4], + [2, 3, 5], + [2, 4, 5], + [3, 4, 5]] */ diff --git a/Task/Command-line-arguments/Fancy/command-line-arguments.fancy b/Task/Command-line-arguments/Fancy/command-line-arguments.fancy new file mode 100644 index 0000000000..eff0d1ea82 --- /dev/null +++ b/Task/Command-line-arguments/Fancy/command-line-arguments.fancy @@ -0,0 +1,3 @@ +ARGV each: |a| { + a println # print each given command line argument +} diff --git a/Task/Command-line-arguments/Fantom/command-line-arguments.fantom b/Task/Command-line-arguments/Fantom/command-line-arguments.fantom new file mode 100644 index 0000000000..e95045e0d0 --- /dev/null +++ b/Task/Command-line-arguments/Fantom/command-line-arguments.fantom @@ -0,0 +1,7 @@ +class Main +{ + public static Void main (Str[] args) + { + echo ("command-line args are: " + args) + } +} diff --git a/Task/Command-line-arguments/Gambas/command-line-arguments.gambas b/Task/Command-line-arguments/Gambas/command-line-arguments.gambas new file mode 100644 index 0000000000..b460d3a57d --- /dev/null +++ b/Task/Command-line-arguments/Gambas/command-line-arguments.gambas @@ -0,0 +1,10 @@ +PUBLIC SUB main() + DIM l AS Integer + DIM numparms AS Integer + DIM parm AS String + numparms = Application.Args.Count + FOR l = 0 TO numparms - 1 + parm = Application.Args[l] + PRINT l; " : "; parm + NEXT +END SUB diff --git a/Task/Command-line-arguments/Groovy/command-line-arguments.groovy b/Task/Command-line-arguments/Groovy/command-line-arguments.groovy new file mode 100644 index 0000000000..f2004b3ac1 --- /dev/null +++ b/Task/Command-line-arguments/Groovy/command-line-arguments.groovy @@ -0,0 +1 @@ +println args diff --git a/Task/Command-line-arguments/HicEst/command-line-arguments.hicest b/Task/Command-line-arguments/HicEst/command-line-arguments.hicest new file mode 100644 index 0000000000..1ee6bc4225 --- /dev/null +++ b/Task/Command-line-arguments/HicEst/command-line-arguments.hicest @@ -0,0 +1,4 @@ +DO i = 2, 100 ! 1 is HicEst.exe + EDIT(Text=$CMD_LINE, SePaRators='-"', ITeM=i, IF ' ', EXit, ENDIF, Parse=cmd, GetPosition=position) + IF(position > 0) WRITE(Messagebox) cmd +ENDDO diff --git a/Task/Command-line-arguments/Icon/command-line-arguments.icon b/Task/Command-line-arguments/Icon/command-line-arguments.icon new file mode 100644 index 0000000000..e18462784c --- /dev/null +++ b/Task/Command-line-arguments/Icon/command-line-arguments.icon @@ -0,0 +1,3 @@ +procedure main(arglist) +every write(!arglist) +end diff --git a/Task/Command-line-arguments/Io/command-line-arguments.io b/Task/Command-line-arguments/Io/command-line-arguments.io new file mode 100644 index 0000000000..3538f36955 --- /dev/null +++ b/Task/Command-line-arguments/Io/command-line-arguments.io @@ -0,0 +1 @@ +System args foreach(a, a println) diff --git a/Task/Command-line-arguments/Ioke/command-line-arguments.ioke b/Task/Command-line-arguments/Ioke/command-line-arguments.ioke new file mode 100644 index 0000000000..584bfac4a3 --- /dev/null +++ b/Task/Command-line-arguments/Ioke/command-line-arguments.ioke @@ -0,0 +1 @@ +System programArguments each(println) diff --git a/Task/Command-line-arguments/J/command-line-arguments.j b/Task/Command-line-arguments/J/command-line-arguments.j new file mode 100644 index 0000000000..1a017718e8 --- /dev/null +++ b/Task/Command-line-arguments/J/command-line-arguments.j @@ -0,0 +1 @@ + ARGV diff --git a/Task/Command-line-arguments/LSE64/command-line-arguments.lse64 b/Task/Command-line-arguments/LSE64/command-line-arguments.lse64 new file mode 100644 index 0000000000..2b9743be0d --- /dev/null +++ b/Task/Command-line-arguments/LSE64/command-line-arguments.lse64 @@ -0,0 +1,4 @@ +argc , nl # number of arguments (including command itself) +0 # argument +dup arg dup 0 = || ,t 1 + repeat +drop diff --git a/Task/Command-line-arguments/Liberty-BASIC/command-line-arguments.liberty b/Task/Command-line-arguments/Liberty-BASIC/command-line-arguments.liberty new file mode 100644 index 0000000000..c68a5bf031 --- /dev/null +++ b/Task/Command-line-arguments/Liberty-BASIC/command-line-arguments.liberty @@ -0,0 +1 @@ +print CommandLine$ diff --git a/Task/Command-line-arguments/Logo/command-line-arguments.logo b/Task/Command-line-arguments/Logo/command-line-arguments.logo new file mode 100644 index 0000000000..10c99d5970 --- /dev/null +++ b/Task/Command-line-arguments/Logo/command-line-arguments.logo @@ -0,0 +1,2 @@ +show :COMMAND.LINE +[arg1 arg2 arg3] diff --git a/Task/Command-line-arguments/MMIX/command-line-arguments.mmix b/Task/Command-line-arguments/MMIX/command-line-arguments.mmix new file mode 100644 index 0000000000..bf64a426ad --- /dev/null +++ b/Task/Command-line-arguments/MMIX/command-line-arguments.mmix @@ -0,0 +1,23 @@ +argv IS $1 +argc IS $0 +i IS $2 + + LOC #100 +Main LOC @ + SETL i,1 % i = 1 +Loop CMP $3,argc,2 % argc < 2 ? + BN $3,1F % then jump to end + XOR $255,$255,$255 % clear $255 + 8ADDU $255,i,argv % i*8 + argv + LDOU $255,$255,0 % argv[i] + TRAP 0,Fputs,StdOut % write the argument + GETA $255,NewLine % add a newline + TRAP 0,Fputs,StdOut + INCL i,1 % increment index + SUB argc,argc,1 % argc-- + BP argc,Loop % argc > 0? then Loop +1H LOC @ + XOR $255,$255,$255 % exit(0) + TRAP 0,Halt,0 + +NewLine BYTE #a,0 diff --git a/Task/Command-line-arguments/Mathematica/command-line-arguments.mathematica b/Task/Command-line-arguments/Mathematica/command-line-arguments.mathematica new file mode 100644 index 0000000000..e6f4c0c899 --- /dev/null +++ b/Task/Command-line-arguments/Mathematica/command-line-arguments.mathematica @@ -0,0 +1,2 @@ +#!/usr/local/bin/MathematicaScript -script +$CommandLine diff --git a/Task/Command-line-arguments/Mercury/command-line-arguments.mercury b/Task/Command-line-arguments/Mercury/command-line-arguments.mercury new file mode 100644 index 0000000000..167de9ac61 --- /dev/null +++ b/Task/Command-line-arguments/Mercury/command-line-arguments.mercury @@ -0,0 +1,19 @@ +:- module cmd_line_args. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + io.progname("", ProgName, !IO), + io.format("This program is named %s.\n", [s(ProgName)], !IO), + io.command_line_arguments(Args, !IO), + list.foldl2(print_arg, Args, 1, _, !IO). + +:- pred print_arg(string::in, int::in, int::out, io::di, io::uo) is det. + +print_arg(Arg, ArgNum, ArgNum + 1, !IO) :- + io.format("the argument #%d is %s\n", [i(ArgNum), s(Arg)], !IO). diff --git a/Task/Command-line-arguments/Modula-2/command-line-arguments-1.mod2 b/Task/Command-line-arguments/Modula-2/command-line-arguments-1.mod2 new file mode 100644 index 0000000000..fe8af63038 --- /dev/null +++ b/Task/Command-line-arguments/Modula-2/command-line-arguments-1.mod2 @@ -0,0 +1,20 @@ +MODULE try; + +FROM Arguments IMPORT GetArgs, ArgTable, GetEnv; +FROM InOut IMPORT WriteCard, WriteLn, WriteString; + +VAR count, item : SHORTCARD; + storage : ArgTable; + +BEGIN + GetArgs (count, storage); + WriteString ('Count ='); WriteCard (count, 4); WriteLn; + item := 0; + REPEAT + WriteCard (item, 4); + WriteString (' : '); + WriteString (storage^ [item]^); + WriteLn; + INC (item) + UNTIL item = count +END try. diff --git a/Task/Command-line-arguments/Modula-2/command-line-arguments-2.mod2 b/Task/Command-line-arguments/Modula-2/command-line-arguments-2.mod2 new file mode 100644 index 0000000000..34e6014e63 --- /dev/null +++ b/Task/Command-line-arguments/Modula-2/command-line-arguments-2.mod2 @@ -0,0 +1,8 @@ +jan@Beryllium:~/modula/test$ try jantje zag eens pruimen hangen +Count = 6 + 0 : try + 1 : jantje + 2 : zag + 3 : eens + 4 : pruimen + 5 : hangen diff --git a/Task/Command-line-arguments/Modula-3/command-line-arguments.mod3 b/Task/Command-line-arguments/Modula-3/command-line-arguments.mod3 new file mode 100644 index 0000000000..07f3df499c --- /dev/null +++ b/Task/Command-line-arguments/Modula-3/command-line-arguments.mod3 @@ -0,0 +1,12 @@ +MODULE Args EXPORTS Main; + +IMPORT IO, Params; + +BEGIN + IO.Put(Params.Get(0) & "\n"); + IF Params.Count > 1 THEN + FOR i := 1 TO Params.Count - 1 DO + IO.Put(Params.Get(i) & "\n"); + END; + END; +END Args. diff --git a/Task/Comments/FALSE/comments.false b/Task/Comments/FALSE/comments.false new file mode 100644 index 0000000000..1c0ae8d18e --- /dev/null +++ b/Task/Comments/FALSE/comments.false @@ -0,0 +1 @@ +{comments are in curly braces} diff --git a/Task/Comments/Factor/comments.factor b/Task/Comments/Factor/comments.factor new file mode 100644 index 0000000000..12f3ced380 --- /dev/null +++ b/Task/Comments/Factor/comments.factor @@ -0,0 +1,3 @@ +! Comments starts with "! " +#! Or with "#! " +! and last until the end of the line diff --git a/Task/Comments/Falcon/comments.falcon b/Task/Comments/Falcon/comments.falcon new file mode 100644 index 0000000000..998d2522ca --- /dev/null +++ b/Task/Comments/Falcon/comments.falcon @@ -0,0 +1,6 @@ +/* Start comment block + My Life Story + */ + +// set up my bank account total +bank_account_total = 1000000 // Wish this was the case diff --git a/Task/Comments/Fancy/comments.fancy b/Task/Comments/Fancy/comments.fancy new file mode 100644 index 0000000000..be74ba2c8e --- /dev/null +++ b/Task/Comments/Fancy/comments.fancy @@ -0,0 +1,2 @@ +# Comments starts with "#" +# and last until the end of the line diff --git a/Task/Comments/Fish/comments.fish b/Task/Comments/Fish/comments.fish new file mode 100644 index 0000000000..bd71f9906e --- /dev/null +++ b/Task/Comments/Fish/comments.fish @@ -0,0 +1,4 @@ +v This is the Fish version of the Integer sequence task +>0>:n1+v all comments here + ^o" "< still here +And of course here :) diff --git a/Task/Comments/GAP/comments.gap b/Task/Comments/GAP/comments.gap new file mode 100644 index 0000000000..4797a0076f --- /dev/null +++ b/Task/Comments/GAP/comments.gap @@ -0,0 +1 @@ +# Comment (till end of line) diff --git a/Task/Comments/GML/comments-1.gml b/Task/Comments/GML/comments-1.gml new file mode 100644 index 0000000000..fc919b4afc --- /dev/null +++ b/Task/Comments/GML/comments-1.gml @@ -0,0 +1 @@ + // comment starts with "//" and continues to the end of the line diff --git a/Task/Comments/GML/comments-2.gml b/Task/Comments/GML/comments-2.gml new file mode 100644 index 0000000000..494f9ac58a --- /dev/null +++ b/Task/Comments/GML/comments-2.gml @@ -0,0 +1,6 @@ + /* a multi-line comment starts with slash-asterisk and, +ends with asterisk-slash. +also note: + * A multi-line comment is ignored inside a string + * A multi-line comment can be ended inside a line +*/ diff --git a/Task/Comments/GW-BASIC/comments.bas b/Task/Comments/GW-BASIC/comments.bas new file mode 100644 index 0000000000..de95f49486 --- /dev/null +++ b/Task/Comments/GW-BASIC/comments.bas @@ -0,0 +1,2 @@ +100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line +110 PRINT "this is code": REM comment after statement diff --git a/Task/Comments/Gambas/comments.gambas b/Task/Comments/Gambas/comments.gambas new file mode 100644 index 0000000000..4559cac6e7 --- /dev/null +++ b/Task/Comments/Gambas/comments.gambas @@ -0,0 +1,2 @@ + ' This whole line is a comment and is ignored by the gambas interpreter + print "Hello" ' Comments after an apostrophe are ignored diff --git a/Task/Comments/Gema/comments.gema b/Task/Comments/Gema/comments.gema new file mode 100644 index 0000000000..434fe0003e --- /dev/null +++ b/Task/Comments/Gema/comments.gema @@ -0,0 +1 @@ +! comment starts with "!" and continues to end of line diff --git a/Task/Comments/Golfscript/comments.golf b/Task/Comments/Golfscript/comments.golf new file mode 100644 index 0000000000..f487027b61 --- /dev/null +++ b/Task/Comments/Golfscript/comments.golf @@ -0,0 +1 @@ +# end of line comment diff --git a/Task/Comments/Haxe/comments.haxe b/Task/Comments/Haxe/comments.haxe new file mode 100644 index 0000000000..3cf6cd4fb6 --- /dev/null +++ b/Task/Comments/Haxe/comments.haxe @@ -0,0 +1,7 @@ +// Single line commment. + +/* + Multiple + line + comment. +*/ diff --git a/Task/Comments/HicEst/comments.hicest b/Task/Comments/HicEst/comments.hicest new file mode 100644 index 0000000000..b9a7677b30 --- /dev/null +++ b/Task/Comments/HicEst/comments.hicest @@ -0,0 +1 @@ +! a comment starts with a "!" and ends at the end of the line diff --git a/Task/Comments/IDL/comments.idl b/Task/Comments/IDL/comments.idl new file mode 100644 index 0000000000..d51f7f7c57 --- /dev/null +++ b/Task/Comments/IDL/comments.idl @@ -0,0 +1,2 @@ +; The following computes the factorial of a number "n" +fact = product(indgen( n )+1) ; where n should be an integer diff --git a/Task/Comments/Icon/comments.icon b/Task/Comments/Icon/comments.icon new file mode 100644 index 0000000000..9d90fccbe0 --- /dev/null +++ b/Task/Comments/Icon/comments.icon @@ -0,0 +1,3 @@ +# This is a comment + +procedure x(y,z) #: This is a comment and an IPL meta-comment for a procedure diff --git a/Task/Comments/Inform-7/comments.inf b/Task/Comments/Inform-7/comments.inf new file mode 100644 index 0000000000..b5704205d3 --- /dev/null +++ b/Task/Comments/Inform-7/comments.inf @@ -0,0 +1,6 @@ +[This is a single-line comment.] + +[This is a +multi-line comment.] + +[Comments can [be nested].] diff --git a/Task/Comments/Io/comments.io b/Task/Comments/Io/comments.io new file mode 100644 index 0000000000..094d180fbd --- /dev/null +++ b/Task/Comments/Io/comments.io @@ -0,0 +1,6 @@ +# Single-line comment + +// Single-line comment + +/* Multi-line + comment */ diff --git a/Task/Comments/J/comments.j b/Task/Comments/J/comments.j new file mode 100644 index 0000000000..a0f2046039 --- /dev/null +++ b/Task/Comments/J/comments.j @@ -0,0 +1,11 @@ +NB. Text that follows 'NB.' has no effect on execution. + +0 : 0 +Multi-line comments may be placed in strings, +like this. +) + +Note 'example' +Another way to record multi-line comments as text is to use 'Note', which is actually +a simple program that makes it clearer when defined text is used only to provide comment. +) diff --git a/Task/Comments/JCL/comments.jcl b/Task/Comments/JCL/comments.jcl new file mode 100644 index 0000000000..fae5a32144 --- /dev/null +++ b/Task/Comments/JCL/comments.jcl @@ -0,0 +1 @@ +//* This is a comment line (//* in columns 1-3) diff --git a/Task/Comments/Joy/comments.joy b/Task/Comments/Joy/comments.joy new file mode 100644 index 0000000000..d332b70d13 --- /dev/null +++ b/Task/Comments/Joy/comments.joy @@ -0,0 +1,4 @@ +# this is a single line comment + +(* this is a +multi-line comment *) diff --git a/Task/Comments/K/comments.k b/Task/Comments/K/comments.k new file mode 100644 index 0000000000..8df7ff27f1 --- /dev/null +++ b/Task/Comments/K/comments.k @@ -0,0 +1,2 @@ + / this is a comment + 2+2 / as is this diff --git a/Task/Comments/KonsolScript/comments.konso b/Task/Comments/KonsolScript/comments.konso new file mode 100644 index 0000000000..8347c20545 --- /dev/null +++ b/Task/Comments/KonsolScript/comments.konso @@ -0,0 +1,8 @@ +//This is a comment. +//This is another comment. + +/* This is a comment too. */ + +/* This is a +multi-line +comment */ diff --git a/Task/Comments/LSE64/comments-1.lse64 b/Task/Comments/LSE64/comments-1.lse64 new file mode 100644 index 0000000000..22685dcacc --- /dev/null +++ b/Task/Comments/LSE64/comments-1.lse64 @@ -0,0 +1 @@ +# single line comment (space after # is required) diff --git a/Task/Comments/LSE64/comments-2.lse64 b/Task/Comments/LSE64/comments-2.lse64 new file mode 100644 index 0000000000..74affcf9e0 --- /dev/null +++ b/Task/Comments/LSE64/comments-2.lse64 @@ -0,0 +1 @@ +# arg1 arg2 '''yields''' result|''nothing'' diff --git a/Task/Comments/Lang5/comments.lang5 b/Task/Comments/Lang5/comments.lang5 new file mode 100644 index 0000000000..a10b5ddae7 --- /dev/null +++ b/Task/Comments/Lang5/comments.lang5 @@ -0,0 +1 @@ +# This is a comment. diff --git a/Task/Comments/Liberty-BASIC/comments.liberty b/Task/Comments/Liberty-BASIC/comments.liberty new file mode 100644 index 0000000000..11bd5365b7 --- /dev/null +++ b/Task/Comments/Liberty-BASIC/comments.liberty @@ -0,0 +1,5 @@ +'This is a comment +REM This is a comment + +print "This has a comment on the end of the line." 'This is a comment +print "This also has a comment on the end of the line." : REM This is a comment diff --git a/Task/Comments/Lilypond/comments.lilypond b/Task/Comments/Lilypond/comments.lilypond new file mode 100644 index 0000000000..f809e72197 --- /dev/null +++ b/Task/Comments/Lilypond/comments.lilypond @@ -0,0 +1,4 @@ +% This is a comment + +%{ This is a comment +spanning several lines %} diff --git a/Task/Comments/Logo/comments.logo b/Task/Comments/Logo/comments.logo new file mode 100644 index 0000000000..65a82907f4 --- /dev/null +++ b/Task/Comments/Logo/comments.logo @@ -0,0 +1 @@ +; comments come after a semicolon, and last until the end of the line diff --git a/Task/Comments/Logtalk/comments-1.logtalk b/Task/Comments/Logtalk/comments-1.logtalk new file mode 100644 index 0000000000..37bfc87be7 --- /dev/null +++ b/Task/Comments/Logtalk/comments-1.logtalk @@ -0,0 +1 @@ +% single-line comment; extends to the end of the line diff --git a/Task/Comments/Logtalk/comments-2.logtalk b/Task/Comments/Logtalk/comments-2.logtalk new file mode 100644 index 0000000000..c59c49f34c --- /dev/null +++ b/Task/Comments/Logtalk/comments-2.logtalk @@ -0,0 +1,2 @@ +/* multi-line +comment */ diff --git a/Task/Comments/LotusScript/comments-1.lotus b/Task/Comments/LotusScript/comments-1.lotus new file mode 100644 index 0000000000..48fac3547a --- /dev/null +++ b/Task/Comments/LotusScript/comments-1.lotus @@ -0,0 +1 @@ +' This is a comment diff --git a/Task/Comments/LotusScript/comments-2.lotus b/Task/Comments/LotusScript/comments-2.lotus new file mode 100644 index 0000000000..3c123d13fe --- /dev/null +++ b/Task/Comments/LotusScript/comments-2.lotus @@ -0,0 +1,4 @@ +%REM +This is a multi- +line comment. +%END REM diff --git a/Task/Comments/M4/comments.m4 b/Task/Comments/M4/comments.m4 new file mode 100644 index 0000000000..70f4a12a49 --- /dev/null +++ b/Task/Comments/M4/comments.m4 @@ -0,0 +1,6 @@ +eval(2*3) # eval(2*3) "#" and text after it aren't processed but passed along +dnl this text completely disappears, including the new line +divert(-1) +Everything diverted to -1 is processed but the output is discarded. +A comment could take this form as long as no macro names are used. +divert diff --git a/Task/Comments/MAXScript/comments.max b/Task/Comments/MAXScript/comments.max new file mode 100644 index 0000000000..c93fc18b05 --- /dev/null +++ b/Task/Comments/MAXScript/comments.max @@ -0,0 +1,4 @@ +-- Two dashes precede a single line comment + +/* This is a + multi-line comment */ diff --git a/Task/Comments/MBS/comments.mbs b/Task/Comments/MBS/comments.mbs new file mode 100644 index 0000000000..878da6fca9 --- /dev/null +++ b/Task/Comments/MBS/comments.mbs @@ -0,0 +1,6 @@ +! A pling in a line starts a comment + +INT n:=5 ! Comments can appear at the end of a line + +/* A comment block can also be defined using climbstar and starclimb symbols. + This allows comments to be stretched across several lines */ diff --git a/Task/Comments/MOO/comments.moo b/Task/Comments/MOO/comments.moo new file mode 100644 index 0000000000..405f496280 --- /dev/null +++ b/Task/Comments/MOO/comments.moo @@ -0,0 +1,3 @@ +"String literals are technically the only long-term comment format"; +// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa) +/* Classical C-style comments are removed entirely during compile */ diff --git a/Task/Comments/Mathematica/comments-1.mathematica b/Task/Comments/Mathematica/comments-1.mathematica new file mode 100644 index 0000000000..79b05713c8 --- /dev/null +++ b/Task/Comments/Mathematica/comments-1.mathematica @@ -0,0 +1 @@ +(*this is a comment*) diff --git a/Task/Comments/Mathematica/comments-2.mathematica b/Task/Comments/Mathematica/comments-2.mathematica new file mode 100644 index 0000000000..0760828c1e --- /dev/null +++ b/Task/Comments/Mathematica/comments-2.mathematica @@ -0,0 +1 @@ +If[a(*number 1*)<(* is smaller than number 2*) b, True (*return value (*bool true*)*), False (*return bool false*)] diff --git a/Task/Comments/Mathematica/comments-3.mathematica b/Task/Comments/Mathematica/comments-3.mathematica new file mode 100644 index 0000000000..cd33ee8ed0 --- /dev/null +++ b/Task/Comments/Mathematica/comments-3.mathematica @@ -0,0 +1 @@ +If[a < b, True, False] diff --git a/Task/Comments/Maxima/comments.maxima b/Task/Comments/Maxima/comments.maxima new file mode 100644 index 0000000000..1d3b796e75 --- /dev/null +++ b/Task/Comments/Maxima/comments.maxima @@ -0,0 +1,3 @@ +/* Comment + /* Nested comment */ +*/ diff --git a/Task/Comments/Metafont/comments.metafont b/Task/Comments/Metafont/comments.metafont new file mode 100644 index 0000000000..22f2f93e2b --- /dev/null +++ b/Task/Comments/Metafont/comments.metafont @@ -0,0 +1 @@ +% this is "to-end-of-line" comment diff --git a/Task/Comments/Mirah/comments.mirah b/Task/Comments/Mirah/comments.mirah new file mode 100644 index 0000000000..bc40df7391 --- /dev/null +++ b/Task/Comments/Mirah/comments.mirah @@ -0,0 +1,4 @@ +puts 'code' # I am a comment +/* This is + * a multiple + * line comment */ diff --git a/Task/Comments/Modula-2/comments.mod2 b/Task/Comments/Modula-2/comments.mod2 new file mode 100644 index 0000000000..0d7a59997a --- /dev/null +++ b/Task/Comments/Modula-2/comments.mod2 @@ -0,0 +1,3 @@ +(* Comments (* can nest *) + and they can span multiple lines. + *) diff --git a/Task/Comments/Modula-3/comments.mod3 b/Task/Comments/Modula-3/comments.mod3 new file mode 100644 index 0000000000..0d7a59997a --- /dev/null +++ b/Task/Comments/Modula-3/comments.mod3 @@ -0,0 +1,3 @@ +(* Comments (* can nest *) + and they can span multiple lines. + *) diff --git a/Task/Compare-sorting-algorithms-performance/J/compare-sorting-algorithms-performance.j b/Task/Compare-sorting-algorithms-performance/J/compare-sorting-algorithms-performance.j new file mode 100644 index 0000000000..c1be09b47d --- /dev/null +++ b/Task/Compare-sorting-algorithms-performance/J/compare-sorting-algorithms-performance.j @@ -0,0 +1,82 @@ +NB. extracts from other rosetta code projects +ts=: 6!:2, 7!:2@] +radix =: 3 : 0 +256 radix y +: +a=. #{. z =. x #.^:_1 y +e=. (-a) {."0 b =. i.x +x#.1{::(<:@[;([: ; (b, {"1) <@}./. e,]))&>/^:a [ z;~a-1 +NB. , ([: ; (b, {:"1) <@(}:"1@:}.)/. e,])^:(#{.z) y,.z +) +bubble=: (([ (<. , >.) {.@]) , }.@])/^:_ +insertion=:((>: # ]) , [ , < #])/ +sel=: 1 : 'x # [' +quick=: 3 : 0 + if. 1 >: #y do. y + else. + e=. y{~?#y + (quick y sel e + end. +) +gaps =: [: }: 1 (1+3*])^:(> {:)^:a:~ # +insert =: (I.~ {. ]) , [ , ] }.~ I.~ +gapinss =: #@] {. ,@|:@(] insert//.~ #@] $ i.@[) +shell =: [: ; gapinss &.>/@(< ,~ ]&.>@gaps) +builtin =: /:~ + + + +NB. characterization of the sorting algorithms. + +sorts =: bubble`insertion`shell`quick`radix`builtin +generators =: #&1`(i.@-)`(?.~) NB. data generators + +round =: [: <. 1r2&+ + +ll =: (<_1 0)&{ NB. verb to extract lower left which holds ln data length +lc =: (<_1 1)&{ NB. verb to fetch lower center which holds most recent time + +NB. maximum_time characterize ln_start_size +NB. characterize returns a rank 4 matrix with successive indexes for +NB. algorithm, input arrangement, max number of tests in group, length time space +characterize =: 4 : 0 + max_time =. x + start =. 1 3{.<:y + for_sort. sorts do. + for_generator. generators do. NB. limit time and paging prevention + t =: }. (, (, [: ts 'sort@.0 (generator@.0)' , ":@round@^)@>:@ll) ^: ((lc < max_time"_) *. ll < 17"_) ^:_ start + if. generator -: {.generators do. + g =. ,:t + else. + g =. g,t + end. + end. + if. sort -: {.sorts do. + s =. ,:g + else. + s =. s,g + end. + end. +) + +NB. character cell graphics + +NB. From j phrases 10E. Approximation +d3=: 1&,.@[ %.~ ] NB. a and b such that y is approx. a + b*x + +NB. domain and range 0 to 14. +D=:14 + +plot =: 1 : '(=/ round@(u&.(*&(D%<:y))))i.y' NB. function plot size +points =: 4 : '1(<"1|:|.round y*D%~<:x)}0$~2#x' NB. size points x,:y + +show =: [: |. [: '0'&~:@{:} ' ' ,: ": + +plt =: 3 : 0 +30 plt y NB. default size 30 +: +n =. >:i.-# experiments =. <@(#~"1 (0&<)@{.)"2 y +pts =. n +./ .*x&points@>experiments +coef =. d3/@>experiments +(_*pts) + n +./ .*1 0 2|:coef&(p."1) plot x +) diff --git a/Task/Compile-time-calculation/Factor/compile-time-calculation.factor b/Task/Compile-time-calculation/Factor/compile-time-calculation.factor new file mode 100644 index 0000000000..85b631f648 --- /dev/null +++ b/Task/Compile-time-calculation/Factor/compile-time-calculation.factor @@ -0,0 +1,3 @@ +: factorial ( n -- n! ) [1,b] product ; + +CONSTANT: 10-factorial $[ 10 factorial ] diff --git a/Task/Compile-time-calculation/J/compile-time-calculation-1.j b/Task/Compile-time-calculation/J/compile-time-calculation-1.j new file mode 100644 index 0000000000..aad18c3e60 --- /dev/null +++ b/Task/Compile-time-calculation/J/compile-time-calculation-1.j @@ -0,0 +1 @@ +pf10=: smoutput bind (!10) diff --git a/Task/Compile-time-calculation/J/compile-time-calculation-2.j b/Task/Compile-time-calculation/J/compile-time-calculation-2.j new file mode 100644 index 0000000000..5abfcc3d20 --- /dev/null +++ b/Task/Compile-time-calculation/J/compile-time-calculation-2.j @@ -0,0 +1,26 @@ + 9!:3]1 2 4 5 6 + + pf10 +┌───────────────────────────────────────┐ +│┌─┬───────────────────────────────────┐│ +││@│┌────────┬────────────────────────┐││ +││ ││smoutput│┌─┬────────────────────┐│││ +││ ││ ││"│┌────────────┬─────┐││││ +││ ││ ││ ││┌─┬────────┐│┌─┬─┐│││││ +││ ││ ││ │││0│3.6288e6│││0│_││││││ +││ ││ ││ ││└─┴────────┘│└─┴─┘│││││ +││ ││ ││ │└────────────┴─────┘││││ +││ ││ │└─┴────────────────────┘│││ +││ │└────────┴────────────────────────┘││ +│└─┴───────────────────────────────────┘│ +└───────────────────────────────────────┘ +┌────────┬─┬──────────────┐ +│smoutput│@│┌────────┬─┬─┐│ +│ │ ││3.6288e6│"│_││ +│ │ │└────────┴─┴─┘│ +└────────┴─┴──────────────┘ + ┌─ smoutput +── @ ─┤ ┌─ 3628800 + └─ " ──────┴─ _ +smoutput@(3628800"_) +smoutput@(3628800"_) diff --git a/Task/Compile-time-calculation/J/compile-time-calculation-3.j b/Task/Compile-time-calculation/J/compile-time-calculation-3.j new file mode 100644 index 0000000000..3fae49a28a --- /dev/null +++ b/Task/Compile-time-calculation/J/compile-time-calculation-3.j @@ -0,0 +1,2 @@ + pf10 '' +3628800 diff --git a/Task/Compile-time-calculation/Mathematica/compile-time-calculation-1.mathematica b/Task/Compile-time-calculation/Mathematica/compile-time-calculation-1.mathematica new file mode 100644 index 0000000000..655a7dddbd --- /dev/null +++ b/Task/Compile-time-calculation/Mathematica/compile-time-calculation-1.mathematica @@ -0,0 +1 @@ +f = Compile[{}, 10!] diff --git a/Task/Compile-time-calculation/Mathematica/compile-time-calculation-2.mathematica b/Task/Compile-time-calculation/Mathematica/compile-time-calculation-2.mathematica new file mode 100644 index 0000000000..42d4223086 --- /dev/null +++ b/Task/Compile-time-calculation/Mathematica/compile-time-calculation-2.mathematica @@ -0,0 +1 @@ +f[] diff --git a/Task/Compound-data-type/Factor/compound-data-type.factor b/Task/Compound-data-type/Factor/compound-data-type.factor new file mode 100644 index 0000000000..1c82487da3 --- /dev/null +++ b/Task/Compound-data-type/Factor/compound-data-type.factor @@ -0,0 +1 @@ +TUPLE: point x y ; diff --git a/Task/Compound-data-type/Fantom/compound-data-type.fantom b/Task/Compound-data-type/Fantom/compound-data-type.fantom new file mode 100644 index 0000000000..9baceff117 --- /dev/null +++ b/Task/Compound-data-type/Fantom/compound-data-type.fantom @@ -0,0 +1,20 @@ +// define a class to contain the two fields +// accessors to get/set the field values are automatically generated +class Point +{ + Int x + Int y +} + +class Main +{ + public static Void main () + { + // empty constructor, so x,y set to 0 + point1 := Point() + // constructor uses with-block, to initialise values + point2 := Point { x = 1; y = 2} + echo ("Point 1 = (" + point1.x + ", " + point1.y + ")") + echo ("Point 2 = (" + point2.x + ", " + point2.y + ")") + } +} diff --git a/Task/Compound-data-type/Groovy/compound-data-type-1.groovy b/Task/Compound-data-type/Groovy/compound-data-type-1.groovy new file mode 100644 index 0000000000..51cf083c92 --- /dev/null +++ b/Task/Compound-data-type/Groovy/compound-data-type-1.groovy @@ -0,0 +1,8 @@ +class Point { + int x + int y + + // Default values make this a 0-, 1-, and 2-argument constructor + Point(int x = 0, int y = 0) { this.x = x; this.y = y } + String toString() { "{x:${x}, y:${y}}" } +} diff --git a/Task/Compound-data-type/Groovy/compound-data-type-2.groovy b/Task/Compound-data-type/Groovy/compound-data-type-2.groovy new file mode 100644 index 0000000000..64fe97860c --- /dev/null +++ b/Task/Compound-data-type/Groovy/compound-data-type-2.groovy @@ -0,0 +1,17 @@ +// Default Construction with explicit property setting: +def p0 = new Point() +assert 0 == p0.x +assert 0 == p0.y +p0.x = 36 +p0.y = -2 +assert 36 == p0.x +assert -2 == p0.y + +// Direct Construction: +def p1 = new Point(36, -2) +assert 36 == p1.x +assert -2 == p1.y + +def p2 = new Point(36) +assert 36 == p2.x +assert 0 == p2.y diff --git a/Task/Compound-data-type/Groovy/compound-data-type-3.groovy b/Task/Compound-data-type/Groovy/compound-data-type-3.groovy new file mode 100644 index 0000000000..8a79aa5a96 --- /dev/null +++ b/Task/Compound-data-type/Groovy/compound-data-type-3.groovy @@ -0,0 +1,19 @@ +// Explicit coersion from list with "as" keyword +def p4 = [36, -2] as Point +assert 36 == p4.x +assert -2 == p4.y + +// Explicit coersion from list with Java/C-style casting +p4 = (Point) [36, -2] +println p4 +assert 36 == p4.x +assert -2 == p4.y + +// Implicit coercion from list (by type of variable) +Point p6 = [36, -2] +assert 36 == p6.x +assert -2 == p6.y + +Point p8 = [36] +assert 36 == p8.x +assert 0 == p8.y diff --git a/Task/Compound-data-type/Groovy/compound-data-type-4.groovy b/Task/Compound-data-type/Groovy/compound-data-type-4.groovy new file mode 100644 index 0000000000..0a0f22ee13 --- /dev/null +++ b/Task/Compound-data-type/Groovy/compound-data-type-4.groovy @@ -0,0 +1,31 @@ +// Direct map-based construction +def p3 = new Point([x: 36, y: -2]) +assert 36 == p3.x +assert -2 == p3.y + +// Direct map-entry-based construction +p3 = new Point(x: 36, y: -2) +assert 36 == p3.x +assert -2 == p3.y + +p3 = new Point(x: 36) +assert 36 == p3.x +assert 0 == p3.y + +p3 = new Point(y: -2) +assert 0 == p3.x +assert -2 == p3.y + +// Explicit coercion from map with "as" keyword +def p5 = [x: 36, y: -2] as Point +assert 36 == p5.x +assert -2 == p5.y + +// Implicit coercion from map (by type of variable) +Point p7 = [x: 36, y: -2] +assert 36 == p7.x +assert -2 == p7.y + +Point p9 = [y:-2] +assert 0 == p9.x +assert -2 == p9.y diff --git a/Task/Compound-data-type/IDL/compound-data-type.idl b/Task/Compound-data-type/IDL/compound-data-type.idl new file mode 100644 index 0000000000..162cbd1b39 --- /dev/null +++ b/Task/Compound-data-type/IDL/compound-data-type.idl @@ -0,0 +1,4 @@ +point = {x: 6 , y: 0 } +point.y = 7 +print, point +;=> { 6 7} diff --git a/Task/Compound-data-type/Icon/compound-data-type.icon b/Task/Compound-data-type/Icon/compound-data-type.icon new file mode 100644 index 0000000000..f5f68325e1 --- /dev/null +++ b/Task/Compound-data-type/Icon/compound-data-type.icon @@ -0,0 +1 @@ +record Point(x,y) diff --git a/Task/Compound-data-type/J/compound-data-type.j b/Task/Compound-data-type/J/compound-data-type.j new file mode 100644 index 0000000000..9bc10cf7f3 --- /dev/null +++ b/Task/Compound-data-type/J/compound-data-type.j @@ -0,0 +1,17 @@ + NB. Create a "Point" class + coclass'Point' + + NB. Define its constuctor + create =: 3 : 0 + 'X Y' =: y + ) + + NB. Instantiate an instance (i.e. an object) + cocurrent 'base' + P =: 10 20 conew 'Point' + + NB. Interrogate its members + X__P +10 + Y__P +20 diff --git a/Task/Compound-data-type/KonsolScript/compound-data-type-1.konso b/Task/Compound-data-type/KonsolScript/compound-data-type-1.konso new file mode 100644 index 0000000000..4db542b67d --- /dev/null +++ b/Task/Compound-data-type/KonsolScript/compound-data-type-1.konso @@ -0,0 +1,5 @@ +Var:Create( + Point, + Number x, + Number y +) diff --git a/Task/Compound-data-type/KonsolScript/compound-data-type-2.konso b/Task/Compound-data-type/KonsolScript/compound-data-type-2.konso new file mode 100644 index 0000000000..c4ea24d186 --- /dev/null +++ b/Task/Compound-data-type/KonsolScript/compound-data-type-2.konso @@ -0,0 +1,3 @@ +function main() { + Var:Point point; +} diff --git a/Task/Compound-data-type/Logo/compound-data-type-1.logo b/Task/Compound-data-type/Logo/compound-data-type-1.logo new file mode 100644 index 0000000000..a1d8c30384 --- /dev/null +++ b/Task/Compound-data-type/Logo/compound-data-type-1.logo @@ -0,0 +1,2 @@ +setpos [100 100] setpos [100 0] setpos [0 0] +show pos ; [0 0] diff --git a/Task/Compound-data-type/Logo/compound-data-type-2.logo b/Task/Compound-data-type/Logo/compound-data-type-2.logo new file mode 100644 index 0000000000..da3fa5cafd --- /dev/null +++ b/Task/Compound-data-type/Logo/compound-data-type-2.logo @@ -0,0 +1 @@ +until [(first mousepos) < 0] [ifelse button? [pendown] [penup] setpos mousepos] diff --git a/Task/Compound-data-type/MAXScript/compound-data-type-1.max b/Task/Compound-data-type/MAXScript/compound-data-type-1.max new file mode 100644 index 0000000000..96cab4abe3 --- /dev/null +++ b/Task/Compound-data-type/MAXScript/compound-data-type-1.max @@ -0,0 +1,2 @@ +struct myPoint (x, y) +newPoint = myPoint x:3 y:4 diff --git a/Task/Compound-data-type/MAXScript/compound-data-type-2.max b/Task/Compound-data-type/MAXScript/compound-data-type-2.max new file mode 100644 index 0000000000..d07fa36e59 --- /dev/null +++ b/Task/Compound-data-type/MAXScript/compound-data-type-2.max @@ -0,0 +1 @@ +newPoint = Point2 3 4 diff --git a/Task/Compound-data-type/Mathematica/compound-data-type-1.mathematica b/Task/Compound-data-type/Mathematica/compound-data-type-1.mathematica new file mode 100644 index 0000000000..5c8b4dade6 --- /dev/null +++ b/Task/Compound-data-type/Mathematica/compound-data-type-1.mathematica @@ -0,0 +1,11 @@ +In[1]:= a = point[2, 3] + +Out[1]= point[2, 3] + +In[2]:= a[[2]] + +Out[2]= 3 + +In[3]:= a[[2]] = 4; a + +Out[3]= point[2, 4] diff --git a/Task/Compound-data-type/Mathematica/compound-data-type-2.mathematica b/Task/Compound-data-type/Mathematica/compound-data-type-2.mathematica new file mode 100644 index 0000000000..67812439a7 --- /dev/null +++ b/Task/Compound-data-type/Mathematica/compound-data-type-2.mathematica @@ -0,0 +1 @@ +p[x] = 2; p[y] = 3; diff --git a/Task/Compound-data-type/Maxima/compound-data-type.maxima b/Task/Compound-data-type/Maxima/compound-data-type.maxima new file mode 100644 index 0000000000..b6f7961f2e --- /dev/null +++ b/Task/Compound-data-type/Maxima/compound-data-type.maxima @@ -0,0 +1,7 @@ +defstruct(point(x, y))$ + +p: new(point)$ + +q: point(1, 2)$ + +p@x: 5$ diff --git a/Task/Compound-data-type/Modula-2/compound-data-type-1.mod2 b/Task/Compound-data-type/Modula-2/compound-data-type-1.mod2 new file mode 100644 index 0000000000..0860a0cb2f --- /dev/null +++ b/Task/Compound-data-type/Modula-2/compound-data-type-1.mod2 @@ -0,0 +1,3 @@ +TYPE Point = RECORD + x, y : INTEGER +END; diff --git a/Task/Compound-data-type/Modula-2/compound-data-type-2.mod2 b/Task/Compound-data-type/Modula-2/compound-data-type-2.mod2 new file mode 100644 index 0000000000..0117a77ba2 --- /dev/null +++ b/Task/Compound-data-type/Modula-2/compound-data-type-2.mod2 @@ -0,0 +1,4 @@ +VAR point : Point; +... +point.x := 12; +point.y := 7; diff --git a/Task/Compound-data-type/Modula-3/compound-data-type.mod3 b/Task/Compound-data-type/Modula-3/compound-data-type.mod3 new file mode 100644 index 0000000000..56bb7ebb4e --- /dev/null +++ b/Task/Compound-data-type/Modula-3/compound-data-type.mod3 @@ -0,0 +1,3 @@ +TYPE Point = RECORD + x, y: INTEGER; +END; diff --git a/Task/Concurrent-computing/Factor/concurrent-computing.factor b/Task/Concurrent-computing/Factor/concurrent-computing.factor new file mode 100644 index 0000000000..cf15d509c8 --- /dev/null +++ b/Task/Concurrent-computing/Factor/concurrent-computing.factor @@ -0,0 +1,3 @@ +USE: concurrency.combinators + +{ "Enjoy" "Rosetta" "Code" } [ print ] parallel-each diff --git a/Task/Concurrent-computing/Groovy/concurrent-computing.groovy b/Task/Concurrent-computing/Groovy/concurrent-computing.groovy new file mode 100644 index 0000000000..76b54180a4 --- /dev/null +++ b/Task/Concurrent-computing/Groovy/concurrent-computing.groovy @@ -0,0 +1,6 @@ +'Enjoy Rosetta Code'.tokenize().collect { w -> + Thread.start { + Thread.sleep(1000 * Math.random() as int) + println w + } +}.each { it.join() } diff --git a/Task/Concurrent-computing/J/concurrent-computing.j b/Task/Concurrent-computing/J/concurrent-computing.j new file mode 100644 index 0000000000..932095a532 --- /dev/null +++ b/Task/Concurrent-computing/J/concurrent-computing.j @@ -0,0 +1,4 @@ + smoutput&>({~?~@#);:'Enjoy Rosetta Code' +Rosetta +Code +Enjoy diff --git a/Task/Concurrent-computing/Logtalk/concurrent-computing.logtalk b/Task/Concurrent-computing/Logtalk/concurrent-computing.logtalk new file mode 100644 index 0000000000..cc04369b9b --- /dev/null +++ b/Task/Concurrent-computing/Logtalk/concurrent-computing.logtalk @@ -0,0 +1,12 @@ +:- object(concurrency). + + :- initialization(output). + + output :- + threaded(( + write('Enjoy'), + write('Rosetta'), + write('Code') + )). + +:- end_object. diff --git a/Task/Concurrent-computing/Mathematica/concurrent-computing.mathematica b/Task/Concurrent-computing/Mathematica/concurrent-computing.mathematica new file mode 100644 index 0000000000..b1a90d4158 --- /dev/null +++ b/Task/Concurrent-computing/Mathematica/concurrent-computing.mathematica @@ -0,0 +1,5 @@ +ParallelDo[ + Pause[RandomReal[]]; + Print[s], + {s, {"Enjoy", "Rosetta", "Code"}} +] diff --git a/Task/Concurrent-computing/Mercury/concurrent-computing.mercury b/Task/Concurrent-computing/Mercury/concurrent-computing.mercury new file mode 100644 index 0000000000..2400b99a03 --- /dev/null +++ b/Task/Concurrent-computing/Mercury/concurrent-computing.mercury @@ -0,0 +1,13 @@ +:- module concurrent_computing. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is cc_multi. + +:- implementation. +:- import_module thread. + +main(!IO) :- + spawn(io.print_cc("Enjoy\n"), !IO), + spawn(io.print_cc("Rosetta\n"), !IO), + spawn(io.print_cc("Code\n"), !IO). diff --git a/Task/Conditional-structures/FALSE/conditional-structures-1.false b/Task/Conditional-structures/FALSE/conditional-structures-1.false new file mode 100644 index 0000000000..d18123f72c --- /dev/null +++ b/Task/Conditional-structures/FALSE/conditional-structures-1.false @@ -0,0 +1 @@ +condition[body]? diff --git a/Task/Conditional-structures/FALSE/conditional-structures-2.false b/Task/Conditional-structures/FALSE/conditional-structures-2.false new file mode 100644 index 0000000000..c437b9f357 --- /dev/null +++ b/Task/Conditional-structures/FALSE/conditional-structures-2.false @@ -0,0 +1 @@ +$[\true\]?~[false]? diff --git a/Task/Conditional-structures/FALSE/conditional-structures-3.false b/Task/Conditional-structures/FALSE/conditional-structures-3.false new file mode 100644 index 0000000000..2304333227 --- /dev/null +++ b/Task/Conditional-structures/FALSE/conditional-structures-3.false @@ -0,0 +1 @@ +$[%true0~]?~[false]? diff --git a/Task/Conditional-structures/Factor/conditional-structures-1.factor b/Task/Conditional-structures/Factor/conditional-structures-1.factor new file mode 100644 index 0000000000..d551e88f91 --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-1.factor @@ -0,0 +1 @@ +t 1 2 ? ! returns 1 diff --git a/Task/Conditional-structures/Factor/conditional-structures-2.factor b/Task/Conditional-structures/Factor/conditional-structures-2.factor new file mode 100644 index 0000000000..564d30be9b --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-2.factor @@ -0,0 +1 @@ +t [ 1 ] [ 2 ] if ! returns 1 diff --git a/Task/Conditional-structures/Factor/conditional-structures-3.factor b/Task/Conditional-structures/Factor/conditional-structures-3.factor new file mode 100644 index 0000000000..21458db5d3 --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-3.factor @@ -0,0 +1 @@ +{ { [ t ] [ 1 ] } { [ f ] [ 2 ] } } cond ! returns 1 diff --git a/Task/Conditional-structures/Factor/conditional-structures-4.factor b/Task/Conditional-structures/Factor/conditional-structures-4.factor new file mode 100644 index 0000000000..0fce3acbeb --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-4.factor @@ -0,0 +1 @@ +t { { t [ 1 ] } { f [ 2 ] } } case ! returns 1 diff --git a/Task/Conditional-structures/Factor/conditional-structures-5.factor b/Task/Conditional-structures/Factor/conditional-structures-5.factor new file mode 100644 index 0000000000..06e0135053 --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-5.factor @@ -0,0 +1 @@ +t [ "1" print ] when ! prints 1 diff --git a/Task/Conditional-structures/Factor/conditional-structures-6.factor b/Task/Conditional-structures/Factor/conditional-structures-6.factor new file mode 100644 index 0000000000..85c52f6ccb --- /dev/null +++ b/Task/Conditional-structures/Factor/conditional-structures-6.factor @@ -0,0 +1 @@ +f [ "1" print ] unless ! prints 1 diff --git a/Task/Conditional-structures/Fancy/conditional-structures-1.fancy b/Task/Conditional-structures/Fancy/conditional-structures-1.fancy new file mode 100644 index 0000000000..c07dfc1d99 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-1.fancy @@ -0,0 +1,3 @@ +if: (x < y) then: { + "x < y!" println # will only execute this block if x < y +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-2.fancy b/Task/Conditional-structures/Fancy/conditional-structures-2.fancy new file mode 100644 index 0000000000..07119e65e7 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-2.fancy @@ -0,0 +1,5 @@ +if: (x < y) then: { + "x < y!" println # will only execute this block if x < y +} else: { + "x not < y!" println +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-3.fancy b/Task/Conditional-structures/Fancy/conditional-structures-3.fancy new file mode 100644 index 0000000000..6318f88735 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-3.fancy @@ -0,0 +1,3 @@ +x < y if_true: { + "x < y!" println # will only execute this block if x < y +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-4.fancy b/Task/Conditional-structures/Fancy/conditional-structures-4.fancy new file mode 100644 index 0000000000..c7f5934db8 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-4.fancy @@ -0,0 +1,3 @@ +x < y if_false: { + "x not < y!" println # will only execute this block if x >= y +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-5.fancy b/Task/Conditional-structures/Fancy/conditional-structures-5.fancy new file mode 100644 index 0000000000..b35da98721 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-5.fancy @@ -0,0 +1,5 @@ +x < y if_true: { + "x < y!" println +} else: { + "x >= y!" println +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-6.fancy b/Task/Conditional-structures/Fancy/conditional-structures-6.fancy new file mode 100644 index 0000000000..0e5adc6243 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-6.fancy @@ -0,0 +1,5 @@ +x < y if_false: { + "x >= y!" +} else: { + "x < y!" println +} diff --git a/Task/Conditional-structures/Fancy/conditional-structures-7.fancy b/Task/Conditional-structures/Fancy/conditional-structures-7.fancy new file mode 100644 index 0000000000..0a73f64e57 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-7.fancy @@ -0,0 +1 @@ +{ "x < y!" println } if: (x < y) # analog, but postfix diff --git a/Task/Conditional-structures/Fancy/conditional-structures-8.fancy b/Task/Conditional-structures/Fancy/conditional-structures-8.fancy new file mode 100644 index 0000000000..47812cef28 --- /dev/null +++ b/Task/Conditional-structures/Fancy/conditional-structures-8.fancy @@ -0,0 +1 @@ +{ "x not < y!" } unless: (x < y) # same here diff --git a/Task/Conditional-structures/HicEst/conditional-structures.hicest b/Task/Conditional-structures/HicEst/conditional-structures.hicest new file mode 100644 index 0000000000..10cee02518 --- /dev/null +++ b/Task/Conditional-structures/HicEst/conditional-structures.hicest @@ -0,0 +1,11 @@ +IF( a > 5 ) WRITE(Messagebox) a ! single line IF + +IF( a >= b ) THEN + WRITE(Text=some_string) a, b + ELSEIF(some_string > "?") THEN + WRITE(ClipBoard) some_string + ELSEIF( nonzero ) THEN + WRITE(WINdowhandle=nnn) some_string + ELSE + WRITE(StatusBar) a, b, some_string +ENDIF diff --git a/Task/Conditional-structures/IDL/conditional-structures-1.idl b/Task/Conditional-structures/IDL/conditional-structures-1.idl new file mode 100644 index 0000000000..0bd89278e3 --- /dev/null +++ b/Task/Conditional-structures/IDL/conditional-structures-1.idl @@ -0,0 +1 @@ +if a eq 5 then print, "a equals five" [else print, "a is something else"] diff --git a/Task/Conditional-structures/IDL/conditional-structures-2.idl b/Task/Conditional-structures/IDL/conditional-structures-2.idl new file mode 100644 index 0000000000..e9ecd5df39 --- /dev/null +++ b/Task/Conditional-structures/IDL/conditional-structures-2.idl @@ -0,0 +1,5 @@ +if a eq 5 then begin + ... some code here ... +endif [else begin + ... some other code here ... +endelse] diff --git a/Task/Conditional-structures/IDL/conditional-structures-3.idl b/Task/Conditional-structures/IDL/conditional-structures-3.idl new file mode 100644 index 0000000000..176ddc885c --- /dev/null +++ b/Task/Conditional-structures/IDL/conditional-structures-3.idl @@ -0,0 +1,5 @@ +case of + (choice-1): + [(choice-2): [...]] + [else: ] +endcase diff --git a/Task/Conditional-structures/IDL/conditional-structures-4.idl b/Task/Conditional-structures/IDL/conditional-structures-4.idl new file mode 100644 index 0000000000..4b8fff707c --- /dev/null +++ b/Task/Conditional-structures/IDL/conditional-structures-4.idl @@ -0,0 +1,5 @@ +switch of + (choice-1): + [(choice-2): [...]] + [else: ] +endswitch diff --git a/Task/Conditional-structures/IDL/conditional-structures-5.idl b/Task/Conditional-structures/IDL/conditional-structures-5.idl new file mode 100644 index 0000000000..ee8d192d30 --- /dev/null +++ b/Task/Conditional-structures/IDL/conditional-structures-5.idl @@ -0,0 +1 @@ +on_error label diff --git a/Task/Conditional-structures/Icon/conditional-structures-1.icon b/Task/Conditional-structures/Icon/conditional-structures-1.icon new file mode 100644 index 0000000000..315bcb979e --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-1.icon @@ -0,0 +1,4 @@ +if expr0 then + expr1 +else + expr2 diff --git a/Task/Conditional-structures/Icon/conditional-structures-10.icon b/Task/Conditional-structures/Icon/conditional-structures-10.icon new file mode 100644 index 0000000000..61444d632d --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-10.icon @@ -0,0 +1 @@ + expr0(expr1, expr2, expr3) diff --git a/Task/Conditional-structures/Icon/conditional-structures-11.icon b/Task/Conditional-structures/Icon/conditional-structures-11.icon new file mode 100644 index 0000000000..810018e83a --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-11.icon @@ -0,0 +1 @@ + 2(expr1, expr2, expr3) diff --git a/Task/Conditional-structures/Icon/conditional-structures-12.icon b/Task/Conditional-structures/Icon/conditional-structures-12.icon new file mode 100644 index 0000000000..2fc23cf8e7 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-12.icon @@ -0,0 +1 @@ + f(expr1)(g(expr2)(expr3,expr4,expr5)) diff --git a/Task/Conditional-structures/Icon/conditional-structures-2.icon b/Task/Conditional-structures/Icon/conditional-structures-2.icon new file mode 100644 index 0000000000..661c8793c1 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-2.icon @@ -0,0 +1,5 @@ +case expr0 of { + expr1 : expr2 + expr3 : expr4 + default: expr5 + } diff --git a/Task/Conditional-structures/Icon/conditional-structures-3.icon b/Task/Conditional-structures/Icon/conditional-structures-3.icon new file mode 100644 index 0000000000..9776f687f8 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-3.icon @@ -0,0 +1,5 @@ +case x of { + f(x) | g(x) : expr2 + s(x) & t(x) : expr4 + default: expr5 + } diff --git a/Task/Conditional-structures/Icon/conditional-structures-4.icon b/Task/Conditional-structures/Icon/conditional-structures-4.icon new file mode 100644 index 0000000000..18e721e477 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-4.icon @@ -0,0 +1,5 @@ +{ + expr1 + expr2 + expr3 +} diff --git a/Task/Conditional-structures/Icon/conditional-structures-5.icon b/Task/Conditional-structures/Icon/conditional-structures-5.icon new file mode 100644 index 0000000000..b4c390a9a6 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-5.icon @@ -0,0 +1 @@ +{expr1; expr2; expr3} diff --git a/Task/Conditional-structures/Icon/conditional-structures-6.icon b/Task/Conditional-structures/Icon/conditional-structures-6.icon new file mode 100644 index 0000000000..48ec3fa570 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-6.icon @@ -0,0 +1 @@ +write({1;2;3;4}) diff --git a/Task/Conditional-structures/Icon/conditional-structures-7.icon b/Task/Conditional-structures/Icon/conditional-structures-7.icon new file mode 100644 index 0000000000..78c9c1c07b --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-7.icon @@ -0,0 +1 @@ + expr1 | expr2 | expr3 diff --git a/Task/Conditional-structures/Icon/conditional-structures-8.icon b/Task/Conditional-structures/Icon/conditional-structures-8.icon new file mode 100644 index 0000000000..011a38eddc --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-8.icon @@ -0,0 +1 @@ + expr1 & expr2 & expr3 diff --git a/Task/Conditional-structures/Icon/conditional-structures-9.icon b/Task/Conditional-structures/Icon/conditional-structures-9.icon new file mode 100644 index 0000000000..8944919ea0 --- /dev/null +++ b/Task/Conditional-structures/Icon/conditional-structures-9.icon @@ -0,0 +1 @@ + (expr1, expr2, expr3) diff --git a/Task/Conditional-structures/Inform-7/conditional-structures-1.inf b/Task/Conditional-structures/Inform-7/conditional-structures-1.inf new file mode 100644 index 0000000000..5534bef94b --- /dev/null +++ b/Task/Conditional-structures/Inform-7/conditional-structures-1.inf @@ -0,0 +1,14 @@ +[short form] +if N is 1, say "one."; +otherwise say "not one."; + +[block form] +if N is 1: + say "one."; +otherwise if N is 2: + say "two."; +otherwise: + say "not one or two."; + +[short and long forms can be negated with "unless"] +unless N is 1, say "not one." diff --git a/Task/Conditional-structures/Inform-7/conditional-structures-2.inf b/Task/Conditional-structures/Inform-7/conditional-structures-2.inf new file mode 100644 index 0000000000..5c4a292551 --- /dev/null +++ b/Task/Conditional-structures/Inform-7/conditional-structures-2.inf @@ -0,0 +1,4 @@ +if N is: + -- 1: say "one."; + -- 2: say "two."; + -- otherwise: say "not one or two."; diff --git a/Task/Conditional-structures/Inform-7/conditional-structures-3.inf b/Task/Conditional-structures/Inform-7/conditional-structures-3.inf new file mode 100644 index 0000000000..230658b62e --- /dev/null +++ b/Task/Conditional-structures/Inform-7/conditional-structures-3.inf @@ -0,0 +1,2 @@ +say "[if N is 1]one[otherwise if N is 2]two[otherwise]three[end if]."; +say "[unless N is odd]even.[end if]"; diff --git a/Task/Conditional-structures/Inform-7/conditional-structures-4.inf b/Task/Conditional-structures/Inform-7/conditional-structures-4.inf new file mode 100644 index 0000000000..e99c08e692 --- /dev/null +++ b/Task/Conditional-structures/Inform-7/conditional-structures-4.inf @@ -0,0 +1,8 @@ +[a different color every time] +say "[one of]red[or]blue[or]green[at random]."; + +["one" the first time it's printed, "two" the second time, then "three or more" subsequently] +say "[one of]one[or]two[or]three or more[stopping]"; + +[only appears once] +say "[first time]Hello world![only]"; diff --git a/Task/Conditional-structures/Inform-7/conditional-structures-5.inf b/Task/Conditional-structures/Inform-7/conditional-structures-5.inf new file mode 100644 index 0000000000..4fdba2cbba --- /dev/null +++ b/Task/Conditional-structures/Inform-7/conditional-structures-5.inf @@ -0,0 +1,13 @@ +Number Factory is a room. + +Number handling is a number based rulebook with default success. + +Number handling for 1: say "one." +Number handling for 2: say "two." +Number handling for an even number (called N): say "[N in words] (which is even)." +Last number handling rule: say "other." + +When play begins: + follow the number handling rules for 2; + follow the number handling rules for 4; + follow the number handling rules for 5. diff --git a/Task/Conditional-structures/LSE64/conditional-structures-1.lse64 b/Task/Conditional-structures/LSE64/conditional-structures-1.lse64 new file mode 100644 index 0000000000..6c068be228 --- /dev/null +++ b/Task/Conditional-structures/LSE64/conditional-structures-1.lse64 @@ -0,0 +1,5 @@ +t : " true" ,t +f : " false" ,t +true if t +false ifnot f +true ifelse t f diff --git a/Task/Conditional-structures/LSE64/conditional-structures-2.lse64 b/Task/Conditional-structures/LSE64/conditional-structures-2.lse64 new file mode 100644 index 0000000000..351597e559 --- /dev/null +++ b/Task/Conditional-structures/LSE64/conditional-structures-2.lse64 @@ -0,0 +1,3 @@ +onetwo : drop " Neither one nor two" ,t # default declared first +onetwo : dup 2 = then " Two" ,t +onetwo : dup 1 = then " One" ,t diff --git a/Task/Conditional-structures/LSE64/conditional-structures-3.lse64 b/Task/Conditional-structures/LSE64/conditional-structures-3.lse64 new file mode 100644 index 0000000000..8dda5c5fb3 --- /dev/null +++ b/Task/Conditional-structures/LSE64/conditional-structures-3.lse64 @@ -0,0 +1 @@ +dup 0 = || ,t # avoid printing a null string diff --git a/Task/Conditional-structures/Lisaac/conditional-structures-1.lisaac b/Task/Conditional-structures/Lisaac/conditional-structures-1.lisaac new file mode 100644 index 0000000000..cc53300c14 --- /dev/null +++ b/Task/Conditional-structures/Lisaac/conditional-structures-1.lisaac @@ -0,0 +1,13 @@ ++ n : INTEGER; + +n := 3; + +(n = 2).if { + IO.put_string "n is 2\n"; +}.elseif {n = 3} then { + IO.put_string "n is 3\n"; +}.elseif {n = 4} then { + IO.put_string "n is 4\n"; +} else { + IO.put_string "n is none of the above\n"; +}; diff --git a/Task/Conditional-structures/Lisaac/conditional-structures-2.lisaac b/Task/Conditional-structures/Lisaac/conditional-structures-2.lisaac new file mode 100644 index 0000000000..339f89d6b2 --- /dev/null +++ b/Task/Conditional-structures/Lisaac/conditional-structures-2.lisaac @@ -0,0 +1,2 @@ +(n = 2).if_true { "n is 2\n".print; }; +(n = 2).if_false { "n is not 2\n".print; }; diff --git a/Task/Conditional-structures/Lisaac/conditional-structures-3.lisaac b/Task/Conditional-structures/Lisaac/conditional-structures-3.lisaac new file mode 100644 index 0000000000..777635fdd5 --- /dev/null +++ b/Task/Conditional-structures/Lisaac/conditional-structures-3.lisaac @@ -0,0 +1,13 @@ ++ n : INTEGER; + +n := 3; +n +.when 2 then { + "n is 2\n".print; +} +.when 3 then { + "n is 3\n".print; +} +.when 4 then { + "n is 4\n".print; +}; diff --git a/Task/Conditional-structures/Logo/conditional-structures-1.logo b/Task/Conditional-structures/Logo/conditional-structures-1.logo new file mode 100644 index 0000000000..cb54ac95c8 --- /dev/null +++ b/Task/Conditional-structures/Logo/conditional-structures-1.logo @@ -0,0 +1,3 @@ +if :x < 0 [make "x 0 - :x] + +ifelse emptyp :list [print [empty]] [print :list] diff --git a/Task/Conditional-structures/Logo/conditional-structures-2.logo b/Task/Conditional-structures/Logo/conditional-structures-2.logo new file mode 100644 index 0000000000..f13f7cc664 --- /dev/null +++ b/Task/Conditional-structures/Logo/conditional-structures-2.logo @@ -0,0 +1,5 @@ +to vowel? :letter +output case :letter [ [[a e i o u] "true] [else "false] ] +end +show vowel? "e +show vowel? "x diff --git a/Task/Conditional-structures/Logo/conditional-structures-3.logo b/Task/Conditional-structures/Logo/conditional-structures-3.logo new file mode 100644 index 0000000000..da29283aaa --- /dev/null +++ b/Task/Conditional-structures/Logo/conditional-structures-3.logo @@ -0,0 +1,2 @@ +true +false diff --git a/Task/Conditional-structures/Logo/conditional-structures-4.logo b/Task/Conditional-structures/Logo/conditional-structures-4.logo new file mode 100644 index 0000000000..4c42abbf09 --- /dev/null +++ b/Task/Conditional-structures/Logo/conditional-structures-4.logo @@ -0,0 +1,5 @@ +to mytest :arg1 :arg2 +test :arg1 = :arg2 +iftrue [print [Arguments are equal]] +iffalse [print [Arguments are not equal]] +end diff --git a/Task/Conditional-structures/MAXScript/conditional-structures-1.max b/Task/Conditional-structures/MAXScript/conditional-structures-1.max new file mode 100644 index 0000000000..addf133ee6 --- /dev/null +++ b/Task/Conditional-structures/MAXScript/conditional-structures-1.max @@ -0,0 +1,12 @@ +if x == 1 then +( + print "one" +) +else if x == 2 then +( + print "two" +) +else +( + print "Neither one or two" +) diff --git a/Task/Conditional-structures/MAXScript/conditional-structures-2.max b/Task/Conditional-structures/MAXScript/conditional-structures-2.max new file mode 100644 index 0000000000..f3174ac975 --- /dev/null +++ b/Task/Conditional-structures/MAXScript/conditional-structures-2.max @@ -0,0 +1,6 @@ +case x of +( + 1: (print "one") + 2: (print "two") + default: (print "Neither one or two") +) diff --git a/Task/Conditional-structures/MAXScript/conditional-structures-3.max b/Task/Conditional-structures/MAXScript/conditional-structures-3.max new file mode 100644 index 0000000000..f3610e1c47 --- /dev/null +++ b/Task/Conditional-structures/MAXScript/conditional-structures-3.max @@ -0,0 +1,6 @@ +case of +( + (x == 1): (print "one") + (x == 2): (print "two") + default: (print "Neither one or two") +) diff --git a/Task/Conditional-structures/MBS/conditional-structures.mbs b/Task/Conditional-structures/MBS/conditional-structures.mbs new file mode 100644 index 0000000000..e25ebe33ca --- /dev/null +++ b/Task/Conditional-structures/MBS/conditional-structures.mbs @@ -0,0 +1,7 @@ +INT x; +x:=0; +IF x = 1 THEN + ! Do something +ELSE + ! Do something else +ENDIF; diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-1.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-1.mumps new file mode 100644 index 0000000000..e773cd1eac --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-1.mumps @@ -0,0 +1 @@ + IF A list-of-MUMPS-commands diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-2.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-2.mumps new file mode 100644 index 0000000000..7b43c98cb7 --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-2.mumps @@ -0,0 +1,2 @@ + IF T DO SUBROUTINE + ELSE DO SOMETHING diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-3.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-3.mumps new file mode 100644 index 0000000000..dfec47cce2 --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-3.mumps @@ -0,0 +1,2 @@ + IF T DO SUBROUTINE IF 1 + ELSE DO SOMETHING diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-4.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-4.mumps new file mode 100644 index 0000000000..3b345928a0 --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-4.mumps @@ -0,0 +1,3 @@ + IF T DO + . DO SUBROUTINE + ELSE DO SOMETHING diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-5.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-5.mumps new file mode 100644 index 0000000000..ce4aa1594a --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-5.mumps @@ -0,0 +1 @@ + WRITE $SELECT(1=2:"Unequal",1=3:"More unequal",1:"Who cares?") diff --git a/Task/Conditional-structures/MUMPS/conditional-structures-6.mumps b/Task/Conditional-structures/MUMPS/conditional-structures-6.mumps new file mode 100644 index 0000000000..c662ea395c --- /dev/null +++ b/Task/Conditional-structures/MUMPS/conditional-structures-6.mumps @@ -0,0 +1,4 @@ + SET:(1=1) SKY="Blue" + GOTO:ReallyGo LABEL + QUIT:LoopDone + WRITE:NotLastInSet "," diff --git a/Task/Conditional-structures/Make/conditional-structures-1.make b/Task/Conditional-structures/Make/conditional-structures-1.make new file mode 100644 index 0000000000..84ab06a32c --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-1.make @@ -0,0 +1,12 @@ +# make -f do.mk C=mycond if +C=0 + +if: + -@expr $(C) >/dev/null && make -f do.mk true; exit 0 + -@expr $(C) >/dev/null || make -f do.mk false; exit 0 + +true: + @echo "was true." + +false: + @echo "was false." diff --git a/Task/Conditional-structures/Make/conditional-structures-2.make b/Task/Conditional-structures/Make/conditional-structures-2.make new file mode 100644 index 0000000000..57e6462eed --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-2.make @@ -0,0 +1,5 @@ +make -f do.mk if C=0 +> was false. + +make -f do.mk if C=1 +> was true. diff --git a/Task/Conditional-structures/Make/conditional-structures-3.make b/Task/Conditional-structures/Make/conditional-structures-3.make new file mode 100644 index 0000000000..e87b3afb66 --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-3.make @@ -0,0 +1,11 @@ +C=0 + +if: true false + +true: + @expr $(C) >/dev/null && exit 0 || exit 1 + @echo "was true." + +false: + @expr $(C) >/dev/null && exit 1 || exit 0 + @echo "was false." diff --git a/Task/Conditional-structures/Make/conditional-structures-4.make b/Task/Conditional-structures/Make/conditional-structures-4.make new file mode 100644 index 0000000000..d87192fa9d --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-4.make @@ -0,0 +1,6 @@ +|make -f do.mk -s -k C=1 +was true. +*** Error code 1 +|make -f do.mk -s -k C=0 +*** Error code 1 +was false. diff --git a/Task/Conditional-structures/Make/conditional-structures-5.make b/Task/Conditional-structures/Make/conditional-structures-5.make new file mode 100644 index 0000000000..ad82c600a1 --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-5.make @@ -0,0 +1,11 @@ +A= +B= + +ifeq "$(A)" "1" + B=true +else + B=false +endif + +do: + @echo $(A) .. $(B) diff --git a/Task/Conditional-structures/Make/conditional-structures-6.make b/Task/Conditional-structures/Make/conditional-structures-6.make new file mode 100644 index 0000000000..95fcb38128 --- /dev/null +++ b/Task/Conditional-structures/Make/conditional-structures-6.make @@ -0,0 +1,4 @@ +|gmake -f if.mk A=1 +1 .. true +|gmake -f if.mk A=0 +0 .. false diff --git a/Task/Conditional-structures/Maxima/conditional-structures.maxima b/Task/Conditional-structures/Maxima/conditional-structures.maxima new file mode 100644 index 0000000000..9339f42b8d --- /dev/null +++ b/Task/Conditional-structures/Maxima/conditional-structures.maxima @@ -0,0 +1 @@ +if test1 then (...) elseif test2 then (...) else (...); diff --git a/Task/Conditional-structures/Metafont/conditional-structures-1.metafont b/Task/Conditional-structures/Metafont/conditional-structures-1.metafont new file mode 100644 index 0000000000..5a4c8079b9 --- /dev/null +++ b/Task/Conditional-structures/Metafont/conditional-structures-1.metafont @@ -0,0 +1,8 @@ +if conditionA: + % do something +elseif conditionB: + % do something +% more elseif, if needed... +else: + % do this +fi; diff --git a/Task/Conditional-structures/Metafont/conditional-structures-2.metafont b/Task/Conditional-structures/Metafont/conditional-structures-2.metafont new file mode 100644 index 0000000000..f9ef001fa7 --- /dev/null +++ b/Task/Conditional-structures/Metafont/conditional-structures-2.metafont @@ -0,0 +1 @@ +b := if a > 5: 3 + else: 2 - fi c; diff --git a/Task/Conditional-structures/Modula-2/conditional-structures-1.mod2 b/Task/Conditional-structures/Modula-2/conditional-structures-1.mod2 new file mode 100644 index 0000000000..5b65096d0c --- /dev/null +++ b/Task/Conditional-structures/Modula-2/conditional-structures-1.mod2 @@ -0,0 +1,9 @@ +IF i = 1 THEN + InOut.WriteString('One') +ELSIF i = 2 THEN + InOut.WriteString('Two') +ELSIF i = 3 THEN + InOut.WriteString('Three') +ELSE + InOut.WriteString('Other') +END; diff --git a/Task/Conditional-structures/Modula-2/conditional-structures-2.mod2 b/Task/Conditional-structures/Modula-2/conditional-structures-2.mod2 new file mode 100644 index 0000000000..349089c2d1 --- /dev/null +++ b/Task/Conditional-structures/Modula-2/conditional-structures-2.mod2 @@ -0,0 +1,7 @@ +CASE i OF + 1 : InOut.WriteString('One') +| 2 : InOut.WriteString('Two') +| 3 : InOut.WriteString('Three') +ELSE + InOut.WriteString('Other') +END diff --git a/Task/Conditional-structures/Modula-3/conditional-structures-1.mod3 b/Task/Conditional-structures/Modula-3/conditional-structures-1.mod3 new file mode 100644 index 0000000000..7bf15e2981 --- /dev/null +++ b/Task/Conditional-structures/Modula-3/conditional-structures-1.mod3 @@ -0,0 +1,5 @@ +IF Foo = TRUE THEN + Bar(); +ELSE + Baz(); +END; diff --git a/Task/Conditional-structures/Modula-3/conditional-structures-2.mod3 b/Task/Conditional-structures/Modula-3/conditional-structures-2.mod3 new file mode 100644 index 0000000000..8e3101b0d5 --- /dev/null +++ b/Task/Conditional-structures/Modula-3/conditional-structures-2.mod3 @@ -0,0 +1,9 @@ +IF Foo = "foo" THEN + Bar(); +ELSIF Foo = "bar" THEN + Baz(); +ELSIF Foo = "foobar" THEN + Quux(); +ELSE + Zeepf(); +END; diff --git a/Task/Conditional-structures/Modula-3/conditional-structures-3.mod3 b/Task/Conditional-structures/Modula-3/conditional-structures-3.mod3 new file mode 100644 index 0000000000..b7aa81e036 --- /dev/null +++ b/Task/Conditional-structures/Modula-3/conditional-structures-3.mod3 @@ -0,0 +1,7 @@ +CASE Foo OF +| 1 => IO.Put("One\n"); +| 2 => IO.Put("Two\n"); +| 3 => IO.Put("Three\n"); +ELSE + IO.Put("Something\n"); +END; diff --git a/Task/Conditional-structures/Modula-3/conditional-structures-4.mod3 b/Task/Conditional-structures/Modula-3/conditional-structures-4.mod3 new file mode 100644 index 0000000000..07ccee8771 --- /dev/null +++ b/Task/Conditional-structures/Modula-3/conditional-structures-4.mod3 @@ -0,0 +1,7 @@ +TYPECASE ref OF +| NULL => IO.Put("Null\n"); +| CHAR => IO.Put("Char\n"); +| INTEGER => IO.Put("Integer\n"); +ELSE + IO.Put("Something\n"); +END; diff --git a/Task/Constrained-genericity/J/constrained-genericity-1.j b/Task/Constrained-genericity/J/constrained-genericity-1.j new file mode 100644 index 0000000000..f9dd1babe2 --- /dev/null +++ b/Task/Constrained-genericity/J/constrained-genericity-1.j @@ -0,0 +1,14 @@ +coclass'Connoisseur' +isEdible=:3 :0 + 0 outside then inside :=: outside + +wsize := integer(2.2*outside) +wsize <:= 150 +center := wsize/2 + +WOpen("size="||wsize||","||wsize,"bg=black","fg=white") | stop("Unable to open window") + +until(points -:= 1) <= 0 do { + x := ?(2*outside)-outside # random x + y := ?(2*outside)-outside # and y + if (inside <= integer(sqrt(x^2+y^2)) ) <= outside then + DrawPoint(x + center,y + center) + } +WDone() + +end diff --git a/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-1.j b/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-1.j new file mode 100644 index 0000000000..f37293aa98 --- /dev/null +++ b/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-1.j @@ -0,0 +1 @@ +gen=: ({~ 100?#)bind((#~ 1=99 225 I.+/"1@:*:),/,"0/~i:15) diff --git a/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-2.j b/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-2.j new file mode 100644 index 0000000000..e3389b53b8 --- /dev/null +++ b/Task/Constrained-random-points-on-a-circle/J/constrained-random-points-on-a-circle-2.j @@ -0,0 +1,31 @@ + '*' (<"1]15+gen '')} 31 31$' ' + + * + * + * * * * * * + * * * * * + * *** + ** * * ** + * ** + * ** + * * * * + * * ** + * ** ** + ** * *** + * ** * * + ** * + * ** * + ** * + * ** * + * * + * * + * * + ** * + * ** + * + * * * * + * ** * * * + * * + ** + * * * + ** * diff --git a/Task/Constrained-random-points-on-a-circle/Liberty-BASIC/constrained-random-points-on-a-circle.liberty b/Task/Constrained-random-points-on-a-circle/Liberty-BASIC/constrained-random-points-on-a-circle.liberty new file mode 100644 index 0000000000..333018c9f3 --- /dev/null +++ b/Task/Constrained-random-points-on-a-circle/Liberty-BASIC/constrained-random-points-on-a-circle.liberty @@ -0,0 +1,30 @@ +' RC Constrained Random Points on a Circle + +nomainwin + +WindowWidth =400 +WindowHeight =430 + +open "Constrained Random Points on a Circle" for graphics_nsb as #w + +#w "trapclose [quit]" +#w "down ; size 7 ; color red ; fill black" + +for i =1 to 1000 + do + x =int( 30 *rnd( 1)) -15 + y =int( 30 *rnd( 1)) -15 + loop until IsInRange( x, y) =1 + #w "set "; 200 +10 *x; " "; 200 - 10 *y +next + +wait + +function IsInRange( x, y) + z =sqr( x*x +y*y) + if 10 <=z and z <=15 then IsInRange =1 else IsInRange =0 +end function + +[quit] +close #w +end diff --git a/Task/Constrained-random-points-on-a-circle/Locomotive-Basic/constrained-random-points-on-a-circle.bas b/Task/Constrained-random-points-on-a-circle/Locomotive-Basic/constrained-random-points-on-a-circle.bas new file mode 100644 index 0000000000..7482071e6d --- /dev/null +++ b/Task/Constrained-random-points-on-a-circle/Locomotive-Basic/constrained-random-points-on-a-circle.bas @@ -0,0 +1,9 @@ +10 MODE 1:RANDOMIZE TIME +20 FOR J=1 TO 100 +30 X=INT(RND*30-15) +40 Y=INT(RND*30-15) +50 D=X*X+Y*Y +60 IF D<100 OR D>225 THEN GOTO 40 +70 PLOT 320+10*X,200+10*Y:LOCATE 1,1:PRINT J +80 NEXT +90 CALL &BB06 ' wait for key press diff --git a/Task/Constrained-random-points-on-a-circle/Mathematica/constrained-random-points-on-a-circle.mathematica b/Task/Constrained-random-points-on-a-circle/Mathematica/constrained-random-points-on-a-circle.mathematica new file mode 100644 index 0000000000..0155b4fe6b --- /dev/null +++ b/Task/Constrained-random-points-on-a-circle/Mathematica/constrained-random-points-on-a-circle.mathematica @@ -0,0 +1,3 @@ +sample = Take[Cases[RandomInteger[{-15, 15}, {500, 2}], {x_, y_} /; 10 <= Sqrt[x^2 + y^2] <= 15], 100]; + +Show[{RegionPlot[10 <= Sqrt[x^2 + y^2] <= 15, {x, -16, 16}, {y, -16, 16}, Axes -> True], ListPlot[sample]}] diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Mathematica/continued-fraction-arithmetic-construct-from-rational-number.mathematica b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Mathematica/continued-fraction-arithmetic-construct-from-rational-number.mathematica new file mode 100644 index 0000000000..1db019587a --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/Mathematica/continued-fraction-arithmetic-construct-from-rational-number.mathematica @@ -0,0 +1,10 @@ +ContinuedFraction[1/2] +ContinuedFraction[3] +ContinuedFraction[23/8] +ContinuedFraction[13/11] +ContinuedFraction[22/7] +ContinuedFraction[-151/77] +ContinuedFraction[14142/10000] +ContinuedFraction[141421/100000] +ContinuedFraction[1414214/1000000] +ContinuedFraction[14142136/10000000] diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/0DESCRIPTION b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/0DESCRIPTION new file mode 100644 index 0000000000..b340488f7a --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/0DESCRIPTION @@ -0,0 +1,41 @@ +This task investigates mathmatical operations that can be performed on a single continued fraction. This requires only a baby version of NG: +: \begin{bmatrix} + a_1 & a \\ + b_1 & b +\end{bmatrix} +I may perform perform the following operations: +:Input the next term of N1 +:Output a term of the continued fraction resulting from the operation. + +I output a term if the integer parts of \frac{a}{b} and \frac{a_1}{b_1} are equal. Otherwise I input a term from N. If I need a term from N but N has no more terms I inject \infty. + +When I input a term t my internal state: \begin{bmatrix} + a_1 & a \\ + b_1 & b +\end{bmatrix} is transposed thus \begin{bmatrix} a + a_1 * t & a_1 \\ + b + b_1 * t & b_1 +\end{bmatrix} + +When I output a term t my internal state: \begin{bmatrix} + a_1 & a \\ + b_1 & b +\end{bmatrix} is transposed thus \begin{bmatrix} b_1 & b \\ + a_1 - b_1 * t & a - b * t +\end{bmatrix} + +When I need a term t but there are no more my internal state: \begin{bmatrix} + a_1 & a \\ + b_1 & b +\end{bmatrix} is transposed thus \begin{bmatrix} a_1 & a_1 \\ + b_1 & b_1 +\end{bmatrix} + +I am done when b1 and b are zero. + +Demonstrate your solution by calculating: +:[1;5,2] + 1/2 +:[3;7] + 1/2 +:[3;7] divided by 4 +Using a generator for \sqrt{2} (e.g., from [[Continued fraction]]) calculate \frac{1}{\sqrt{2}}. You are now at the starting line for using Continued Fractions to implement [[Arithmetic-geometric mean]] without ulps and epsilons. + +The first step in implementing [[Arithmetic-geometric mean]] is to calculate \frac{1 + \frac{1}{\sqrt{2}}}{2} do this now to cross the starting line and begin the race. diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.cpp new file mode 100644 index 0000000000..959b0d4a00 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.cpp @@ -0,0 +1,48 @@ +/* Interface for all matrixNG classes + Nigel Galloway, February 10th., 2013. +*/ +class matrixNG { + private: + virtual void consumeTerm(){} + virtual void consumeTerm(int n){} + virtual const bool needTerm(){} + protected: int cfn = 0, thisTerm; + bool haveTerm = false; + friend class NG; +}; +/* Implement the babyNG matrix + Nigel Galloway, February 10th., 2013. +*/ +class NG_4 : public matrixNG { + private: int a1, a, b1, b, t; + const bool needTerm() { + if (b1==0 and b==0) return false; + if (b1==0 or b==0) return true; else thisTerm = a/b; + if (thisTerm==(int)(a1/b1)){ + t=a; a=b; b=t-b*thisTerm; t=a1; a1=b1; b1=t-b1*thisTerm; + haveTerm=true; return false; + } + return true; + } + void consumeTerm(){a=a1; b=b1;} + void consumeTerm(int n){t=a; a=a1; a1=t+a1*n; t=b; b=b1; b1=t+b1*n;} + public: + NG_4(int a1, int a, int b1, int b): a1(a1), a(a), b1(b1), b(b){} +}; +/* Implement a Continued Fraction which returns the result of an arithmetic operation on + 1 or more Continued Fractions (Currently 1 or 2). + Nigel Galloway, February 10th., 2013. +*/ +class NG : public ContinuedFraction { + private: + matrixNG* ng; + ContinuedFraction* n[2]; + public: + NG(NG_4* ng, ContinuedFraction* n1): ng(ng){n[0] = n1;} + NG(NG_8* ng, ContinuedFraction* n1, ContinuedFraction* n2): ng(ng){n[0] = n1; n[1] = n2;} + const int nextTerm() {ng->haveTerm = false; return ng->thisTerm;} + const bool moreTerms(){ + while(ng->needTerm()) if(n[ng->cfn]->moreTerms()) ng->consumeTerm(n[ng->cfn]->nextTerm()); else ng->consumeTerm(); + return ng->haveTerm; + } +}; diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.cpp new file mode 100644 index 0000000000..92efe9aad1 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.cpp @@ -0,0 +1,7 @@ +int main() { + NG_4 a1(2,1,0,2); + r2cf n1(13,11); + for(NG n(&a1, &n1); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.cpp new file mode 100644 index 0000000000..a61cbb03ee --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.cpp @@ -0,0 +1,7 @@ +int main() { + NG_4 a2(7,0,0,22); + r2cf n2(22,7); + for(NG n(&a2, &n2); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.cpp new file mode 100644 index 0000000000..7fdd5c4895 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.cpp @@ -0,0 +1,7 @@ +int main() { + NG_4 a3(2,1,0,2); + r2cf n3(22,7); + for(NG n(&a3, &n3); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-5.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-5.cpp new file mode 100644 index 0000000000..2bbf9f7773 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-5.cpp @@ -0,0 +1,7 @@ +int main() { + NG_4 a4(1,0,0,4); + r2cf n4(22,7); + for(NG n(&a4, &n4); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-6.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-6.cpp new file mode 100644 index 0000000000..5db15ac3c3 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-6.cpp @@ -0,0 +1,10 @@ +int main() { + NG_4 a5(0,1,1,0); + SQRT2 n5; + int i = 0; + for(NG n(&a5, &n5); n.moreTerms() and i++ < 20; std::cout << n.nextTerm() << " "); + std::cout << "..." << std::endl; + for(r2cf cf(10000000, 14142136); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-7.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-7.cpp new file mode 100644 index 0000000000..142d7f771d --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-7.cpp @@ -0,0 +1,10 @@ +int main() { + int i = 0; + NG_4 a6(1,1,0,2); + SQRT2 n6; + for(NG n(&a6, &n6); n.moreTerms() and i++ < 20; std::cout << n.nextTerm() << " "); + std::cout << "..." << std::endl; + for(r2cf cf(24142136, 20000000); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.rb b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.rb new file mode 100644 index 0000000000..eb2389dc7c --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.rb @@ -0,0 +1,29 @@ +=begin + I define a class to implement baby NG + Nigel Galloway February 6th., 2013 +=end +class NG + def initialize(a1, a, b1, b) + @a1 = a1; @a = a; @b1 = b1; @b = b; + end + def ingress(n) + t=@a; @a=@a1; @a1=t + @a1 * n; t=@b; @b=@b1; @b1=t + @b1 * n; + end + def needterm? + return true if @b1 == 0 or @b == 0 + return true unless @a/@b == @a1/@b1 + return false + end + def egress + n = @a/@b + t=@a; @a=@b; @b=t - @b * n; t=@a1; @a1=@b1; @b1=t - @b1 * n; + return n + end + def egress_done + if needterm? then @a=@a1; @b=@b1 end + return egress + end + def done? + if @b1 == 0 and @b == 0 then return true else return false end + end +end diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.rb b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.rb new file mode 100644 index 0000000000..6c93599a81 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.rb @@ -0,0 +1,3 @@ +op = NG.new(2,1,0,2) +r2cf(13,11) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end} +while not op.done? do print "#{op.egress_done} " end diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.rb b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.rb new file mode 100644 index 0000000000..24ac7eb6c5 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.rb @@ -0,0 +1,3 @@ +op = NG.new(2,1,0,2) +r2cf(22,7) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end} +while not op.done? do print "#{op.egress_done} " end diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.rb b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.rb new file mode 100644 index 0000000000..c6556761ea --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.rb @@ -0,0 +1,3 @@ +op = NG.new(1,0,0,4) +r2cf(22,7) {|n| if op.needterm? then op.ingress(n) else print "#{op.egress} "; op.ingress(n) end} +while not op.done? do print "#{op.egress_done} " end diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.tcl b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.tcl new file mode 100644 index 0000000000..472d3b0ded --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.tcl @@ -0,0 +1,50 @@ +# The single-operand version of the NG operator, using our little generator framework +oo::class create NG1 { + superclass Generator + + variable a1 a b1 b cf + constructor args { + next + lassign $args a1 a b1 b + } + method Ingress n { + lassign [list [expr {$a + $a1*$n}] $a1 [expr {$b + $b1*$n}] $b1] \ + a1 a b1 b + } + method NeedTerm? {} { + expr {$b1 == 0 || $b == 0 || $a/$b != $a1/$b1} + } + method Egress {} { + set n [expr {$a/$b}] + lassign [list $b1 $b [expr {$a1 - $b1*$n}] [expr {$a - $b*$n}]] \ + a1 a b1 b + return $n + } + method EgressDone {} { + if {[my NeedTerm?]} { + set a $a1 + set b $b1 + } + tailcall my Egress + } + method Done? {} { + expr {$b1 == 0 && $b == 0} + } + + method operand {N} { + set cf $N + return [self] + } + method Produce {} { + while 1 { + set n [$cf] + if {![my NeedTerm?]} { + yield [my Egress] + } + my Ingress $n + } + while {![my Done?]} { + yield [my EgressDone] + } + } +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.tcl b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.tcl new file mode 100644 index 0000000000..966e9d0ec7 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.tcl @@ -0,0 +1,29 @@ +# The square root of 2 as a continued fraction in the framework +oo::class create Root2 { + superclass Generator + method apply {} { + yield 1 + while {[self] ne ""} { + yield 2 + } + } +} + +set op [[NG1 new 2 1 0 2] operand [R2CF new 13/11]] +printcf "\[1;5,2\] + 1/2" $op + +set op [[NG1 new 7 0 0 22] operand [R2CF new 22/7]] +printcf "\[3;7\] * 7/22" $op + +set op [[NG1 new 2 1 0 2] operand [R2CF new 22/7]] +printcf "\[3;7\] + 1/2" $op + +set op [[NG1 new 1 0 0 4] operand [R2CF new 22/7]] +printcf "\[3;7\] / 4" $op + +set op [[NG1 new 0 1 1 0] operand [Root2 new]] +printcf "1/\u221a2" $op 20 + +set op [[NG1 new 1 1 0 2] operand [Root2 new]] +printcf "(1+\u221a2)/2" $op 20 +printcf "approx val" [R2CF new 24142136 20000000] diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/0DESCRIPTION b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/0DESCRIPTION new file mode 100644 index 0000000000..6901180101 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/0DESCRIPTION @@ -0,0 +1,59 @@ +This task performs the basic mathematical functions on 2 continued fractions. This requires the full version of matrix NG: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b +\end{bmatrix} +I may perform perform the following operations: +:Input the next term of continued fraction N1 +:Input the next term of continued fraction N2 +:Output a term of the continued fraction resulting from the operation. + +I output a term if the integer parts of \frac{a}{b} and \frac{a_1}{b_1} and \frac{a_2}{b_2} and \frac{a_{12}}{b_{12}} are equal. Otherwise I input a term from continued fraction N1 or continued fraction N2. If I need a term from N but N has no more terms I inject \infty. + +When I input a term t from continued fraction N1 I change my internal state: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix} a_2+a_{12}*t & a+a_1*t & a_{12} & a_1 \\ + b_2+b_{12}*t & b+b_1*t & b_{12} & b_1 +\end{bmatrix} + +When I need a term from exhausted continued fraction N1 I change my internal state: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix} + a_{12} & a_1 & a_{12} & a_1 \\ + b_{12} & b_1 & b_{12} & b_1 +\end{bmatrix} + +When I input a term t from continued fraction N2 I change my internal state: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix} + a_1+a_{12}*t & a_{12} & a+a_2*t & a_2 \\ + b_1+b_{12}*t & b_{12} & b+b_2*t & b_2 +\end{bmatrix} + +When I need a term from exhausted continued fraction N2 I change my internal state: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix} + a_{12} & a_{12} & a_2 & a_2 \\ + b_{12} & b_{12} & b_2 & b_2 +\end{bmatrix} + +When I output a term t I change my internal state: +: \begin{bmatrix} + a_{12} & a_1 & a_2 & a \\ + b_{12} & b_1 & b_2 & b \end{bmatrix} is transposed thus \begin{bmatrix} + b_{12} & b_1 & b_2 & b \\ + a_{12}-b_{12}*t & a_1-b_1*t & a_2-b_2*t & a-b*t +\end{bmatrix} + +When I need to choose to input from N1 or N2 I act: +: if b and b2 are zero I choose N1 +: if b is zero I choose N2 +: if b2 is zero I choose N2 +: if abs(\frac{a_1}{b_1}-\frac{a}{b}) is greater than abs(\frac{a_2}{b_2}-\frac{a}{b}) I choose N1 +: otherwise I choose N2 + +When performing arithmetic operation on two potentially infinite continued fractions it is possible to generate a rational number. eg \sqrt{2} * \sqrt{2} should produce 2. This will require either that I determine that my internal state is approaching infinity, or limiting the number of terms I am willing to input without producing any output. diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/1META.yaml b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/1META.yaml new file mode 100644 index 0000000000..1e81690bbc --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Matrices diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.cpp new file mode 100644 index 0000000000..af0c45b771 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.cpp @@ -0,0 +1,29 @@ +/* Implement matrix NG + Nigel Galloway, February 12., 2013 +*/ +class NG_8 : public matrixNG { + private: int a12, a1, a2, a, b12, b1, b2, b, t; + double ab, a1b1, a2b2, a12b12; + const int chooseCFN(){return fabs(a1b1-ab) > fabs(a2b2-ab)? 0 : 1;} + const bool needTerm() { + if (b1==0 and b==0 and b2==0 and b12==0) return false; + if (b==0){cfn = b2==0? 0:1; return true;} else ab = ((double)a)/b; + if (b2==0){cfn = 1; return true;} else a2b2 = ((double)a2)/b2; + if (b1==0){cfn = 0; return true;} else a1b1 = ((double)a1)/b1; + if (b12==0){cfn = chooseCFN(); return true;} else a12b12 = ((double)a12)/b12; + thisTerm = (int)ab; + if (thisTerm==(int)a1b1 and thisTerm==(int)a2b2 and thisTerm==(int)a12b12){ + t=a; a=b; b=t-b*thisTerm; t=a1; a1=b1; b1=t-b1*thisTerm; t=a2; a2=b2; b2=t-b2*thisTerm; t=a12; a12=b12; b12=t-b12*thisTerm; + haveTerm = true; return false; + } + cfn = chooseCFN(); + return true; + } + void consumeTerm(){if(cfn==0){a=a1; a2=a12; b=b1; b2=b12;} else{a=a2; a1=a12; b=b2; b1=b12;}} + void consumeTerm(int n){ + if(cfn==0){t=a; a=a1; a1=t+a1*n; t=a2; a2=a12; a12=t+a12*n; t=b; b=b1; b1=t+b1*n; t=b2; b2=b12; b12=t+b12*n;} + else{t=a; a=a2; a2=t+a2*n; t=a1; a1=a12; a12=t+a12*n; t=b; b=b2; b2=t+b2*n; t=b1; b1=b12; b12=t+b12*n;} + } + public: + NG_8(int a12, int a1, int a2, int a, int b12, int b1, int b2, int b): a12(a12), a1(a1), a2(a2), a(a), b12(b12), b1(b1), b2(b2), b(b){ +}}; diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.cpp new file mode 100644 index 0000000000..81a4368335 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.cpp @@ -0,0 +1,13 @@ +int main() { + NG_8 a(0,1,1,0,0,0,0,1); + r2cf n2(22,7); + r2cf n1(1,2); + for(NG n(&a, &n1, &n2); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + + NG_4 a3(2,1,0,2); + r2cf n3(22,7); + for(NG n(&a3, &n3); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-3.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-3.cpp new file mode 100644 index 0000000000..d5415ded47 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-3.cpp @@ -0,0 +1,12 @@ +int main() { + NG_8 b(1,0,0,0,0,0,0,1); + r2cf b1(13,11); + r2cf b2(22,7); + for(NG n(&b, &b1, &b2); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + for(NG n(&a, &b2, &b1); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + for(r2cf cf(286,77); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-4.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-4.cpp new file mode 100644 index 0000000000..a17b50ed3f --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-4.cpp @@ -0,0 +1,10 @@ +int main() { + NG_8 c(0,1,-1,0,0,0,0,1); + r2cf c1(13,11); + r2cf c2(22,7); + for(NG n(&c, &c1, &c2); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + for(r2cf cf(-151,77); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-5.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-5.cpp new file mode 100644 index 0000000000..88f73675f3 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-5.cpp @@ -0,0 +1,8 @@ +int main() { + NG_8 d(0,1,0,0,0,0,1,0); + r2cf d1(22*22,7*7); + r2cf d2(22,7); + for(NG n(&d, &d1, &d2); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-6.cpp b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-6.cpp new file mode 100644 index 0000000000..53cc109416 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-6.cpp @@ -0,0 +1,20 @@ +int main() { + r2cf a1(2,7); + r2cf a2(13,11); + NG_8 na(0,1,1,0,0,0,0,1); + NG A(&na, &a1, &a2); //[0;3,2] + [1;5,2] + r2cf b1(2,7); + r2cf b2(13,11); + NG_8 nb(0,1,-1,0,0,0,0,1); + NG B(&nb, &b1, &b2); //[0;3,2] - [1;5,2] + NG_8 nc(1,0,0,0,0,0,0,1); //A*B + for(NG n(&nc, &A, &B); n.moreTerms(); std::cout << n.nextTerm() << " "); + std::cout << std::endl; + for(r2cf cf(2,7); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + for(r2cf cf(13,11); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + for(r2cf cf(-7797,5929); cf.moreTerms(); std::cout << cf.nextTerm() << " "); + std::cout << std::endl; + return 0; +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.tcl b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.tcl new file mode 100644 index 0000000000..cb40e68678 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-1.tcl @@ -0,0 +1,101 @@ +oo::class create NG2 { + variable a b a1 b1 a2 b2 a12 b12 cf1 cf2 + superclass Generator + constructor {args} { + lassign $args a12 a1 a2 a b12 b1 b2 b + next + } + method operands {N1 N2} { + set cf1 $N1 + set cf2 $N2 + return [self] + } + + method Ingress1 t { + lassign [list [expr {$a2+$a12*$t}] [expr {$a+$a1*$t}] $a12 $a1 \ + [expr {$b2+$b12*$t}] [expr {$b+$b1*$t}] $b12 $b1] \ + a12 a1 a2 a b12 b1 b2 b + } + method Exhaust1 {} { + lassign [list $a12 $a1 $a12 $a1 $b12 $b1 $b12 $b1] \ + a12 a1 a2 a b12 b1 b2 b + } + method Ingress2 t { + lassign [list [expr {$a1+$a12*$t}] $a12 [expr {$a+$a2*$t}] $a2 \ + [expr {$b1+$b12*$t}] $b12 [expr {$b+$b2*$t}] $b2] \ + a12 a1 a2 a b12 b1 b2 b + } + method Exhaust2 {} { + lassign [list $a12 $a12 $a2 $a2 $b12 $b12 $b2 $b2] \ + a12 a1 a2 a b12 b1 b2 b + } + method Egress {} { + set t [expr {$a/$b}] + lassign [list $b12 $b1 $b2 $b \ + [expr {$a12 - $b12*$t}] [expr {$a1 - $b1*$t}] \ + [expr {$a2 - $b2*$t}] [expr {$a - $b*$t}]] \ + a12 a1 a2 a b12 b1 b2 b + return $t + } + + method DoIngress1 {} { + try {tailcall my Ingress1 [$cf1]} on break {} {} + oo::objdefine [self] forward DoIngress1 my Exhaust1 + set cf1 "" + tailcall my Exhaust1 + } + method DoIngress2 {} { + try {tailcall my Ingress2 [$cf2]} on break {} {} + oo::objdefine [self] forward DoIngress2 my Exhaust2 + set cf2 "" + tailcall my Exhaust2 + } + method Ingress {} { + if {$b==0} { + if {$b2 == 0} { + tailcall my DoIngress1 + } else { + tailcall my DoIngress2 + } + } + if {!$b2} { + tailcall my DoIngress2 + } + if {!$b1} { + tailcall my DoIngress1 + } + if {[my FirstSource?]} { + tailcall my DoIngress1 + } else { + tailcall my DoIngress2 + } + } + + method FirstSource? {} { + expr {abs($a1*$b*$b2 - $a*$b1*$b2) > abs($a2*$b*$b1 - $a*$b1*$b2)} + } + method NeedTerm? {} { + expr { + ($b*$b1*$b2*$b12==0) || + !($a/$b == $a1/$b1 && $a/$b == $a2/$b2 && $a/$b == $a12/$b12) + } + } + method Done? {} { + expr {$b==0 && $b1==0 && $b2==0 && $b12==0} + } + + method Produce {} { + # Until we've drained both continued fractions... + while {$cf1 ne "" || $cf2 ne ""} { + if {[my NeedTerm?]} { + my Ingress + } else { + yield [my Egress] + } + } + # Drain our internal state + while {![my Done?]} { + yield [my Egress] + } + } +} diff --git a/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.tcl b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.tcl new file mode 100644 index 0000000000..1638d7b354 --- /dev/null +++ b/Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n1,-contined-fraction-n2-2.tcl @@ -0,0 +1,16 @@ +set op [[NG2 new 0 1 1 0 0 0 0 1] operands [R2CF new 1/2] [R2CF new 22/7]] +printcf "\[3;7\] + \[0;2\]" $op + +set op [[NG2 new 1 0 0 0 0 0 0 1] operands [R2CF new 13/11] [R2CF new 22/7]] +printcf "\[1:5,2\] * \[3;7\]" $op + +set op [[NG2 new 0 1 -1 0 0 0 0 1] operands [R2CF new 13/11] [R2CF new 22/7]] +printcf "\[1:5,2\] - \[3;7\]" $op + +set op [[NG2 new 0 1 0 0 0 0 1 0] operands [R2CF new 484/49] [R2CF new 22/7]] +printcf "div test" $op + +set op1 [[NG2 new 0 1 1 0 0 0 0 1] operands [R2CF new 2/7] [R2CF new 13/11]] +set op2 [[NG2 new 0 1 -1 0 0 0 0 1] operands [R2CF new 2/7] [R2CF new 13/11]] +set op3 [[NG2 new 1 0 0 0 0 0 0 1] operands $op1 $op2] +printcf "layered test" $op3 diff --git a/Task/Continued-fraction/Factor/continued-fraction.factor b/Task/Continued-fraction/Factor/continued-fraction.factor new file mode 100644 index 0000000000..f138694017 --- /dev/null +++ b/Task/Continued-fraction/Factor/continued-fraction.factor @@ -0,0 +1,63 @@ +USING: arrays combinators io kernel locals math math.functions + math.ranges prettyprint sequences ; +IN: rosetta.cfrac + +! Every continued fraction must implement these two words. +GENERIC: cfrac-a ( n cfrac -- a ) +GENERIC: cfrac-b ( n cfrac -- b ) + +! square root of 2 +SINGLETON: sqrt2 +M: sqrt2 cfrac-a + ! If n is 1, then a_n is 1, else a_n is 2. + drop { { 1 [ 1 ] } [ drop 2 ] } case ; +M: sqrt2 cfrac-b + ! Always b_n is 1. + 2drop 1 ; + +! Napier's constant +SINGLETON: napier +M: napier cfrac-a + ! If n is 1, then a_n is 2, else a_n is n - 1. + drop { { 1 [ 2 ] } [ 1 - ] } case ; +M: napier cfrac-b + ! If n is 1, then b_n is 1, else b_n is n - 1. + drop { { 1 [ 1 ] } [ 1 - ] } case ; + +SINGLETON: pi +M: pi cfrac-a + ! If n is 1, then a_n is 3, else a_n is 6. + drop { { 1 [ 3 ] } [ drop 6 ] } case ; +M: pi cfrac-b + ! Always b_n is (n * 2 - 1)^2. + drop 2 * 1 - 2 ^ ; + +:: cfrac-estimate ( cfrac terms -- number ) + terms cfrac cfrac-a ! top = last a_n + terms 1 - 1 [a,b] [ :> n + n cfrac cfrac-b swap / ! top = b_n / top + n cfrac cfrac-a + ! top = top + a_n + ] each ; + +:: decimalize ( rational prec -- string ) + rational 1 /mod ! split whole, fractional parts + prec 10^ * ! multiply fraction by 10 ^ prec + [ >integer unparse ] bi@ ! convert digits to strings + :> fraction + "." ! push decimal point + prec fraction length - + dup 0 < [ drop 0 ] when + "0" concat ! push padding zeros + fraction 4array concat ; + + + +MAIN: main diff --git a/Task/Continued-fraction/J/continued-fraction.j b/Task/Continued-fraction/J/continued-fraction.j new file mode 100644 index 0000000000..dc7a471be6 --- /dev/null +++ b/Task/Continued-fraction/J/continued-fraction.j @@ -0,0 +1,14 @@ + cfrac=: +`% / NB. Evaluate a list as a continued fraction + + sqrt2=: cfrac 1 1,200$2 1x + pi=:cfrac 3, , ,&6"0 *:<:+:>:i.100x + e=: cfrac 2 1, , ,~"0 >:i.100x + + NB. translate from fraction to decimal string + NB. translated from factor + dec =: (-@:[ (}.,'.',{.) ":@:<.@:(* 10x&^)~)"0 + + 100 10 100 dec sqrt2, pi, e +1.4142135623730950488016887242096980785696718753769480731766797379907324784621205551109457595775322165 +3.1415924109 +2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274 diff --git a/Task/Continued-fraction/Mathematica/continued-fraction.mathematica b/Task/Continued-fraction/Mathematica/continued-fraction.mathematica new file mode 100644 index 0000000000..445b31e0e5 --- /dev/null +++ b/Task/Continued-fraction/Mathematica/continued-fraction.mathematica @@ -0,0 +1,6 @@ +sqrt2=Function[n,{1,Transpose@{Array[2&,n],Array[1&,n]}}]; +napier=Function[n,{2,Transpose@{Range[n],Prepend[Range[n-1],1]}}]; +pi=Function[n,{3,Transpose@{Array[6&,n],Array[(2#-1)^2&,n]}}]; +approx=Function[l, + N[Divide@@First@Fold[{{#2.#[[;;,1]],#2.#[[;;,2]]},#[[1]]}&,{{l[[2,1,1]]l[[1]]+l[[2,1,2]],l[[2,1,1]]},{l[[1]],1}},l[[2,2;;]]],10]]; +r2=approx/@{sqrt2@#,napier@#,pi@#}&@10000;r2//TableForm diff --git a/Task/Continued-fraction/Maxima/continued-fraction.maxima b/Task/Continued-fraction/Maxima/continued-fraction.maxima new file mode 100644 index 0000000000..219b38da6f --- /dev/null +++ b/Task/Continued-fraction/Maxima/continued-fraction.maxima @@ -0,0 +1,23 @@ +cfeval(x) := block([a, b, n, z], a: x[1], b: x[2], n: length(a), z: 0, + for i from n step -1 thru 2 do z: b[i]/(a[i] + z), a[1] + z)$ + +cf_sqrt2(n) := [cons(1, makelist(2, i, 2, n)), cons(0, makelist(1, i, 2, n))]$ + +cf_e(n) := [cons(2, makelist(i, i, 1, n - 1)), append([0, 1], makelist(i, i, 1, n - 2))]$ + +cf_pi(n) := [cons(3, makelist(6, i, 2, n)), cons(0, makelist((2*i - 1)^2, i, 1, n - 1))]$ + +cfeval(cf_sqrt2(20)), numer; /* 1.414213562373097 */ +% - sqrt(2), numer; /* 1.3322676295501878*10^-15 */ + +cfeval(cf_e(20)), numer; /* 2.718281828459046 */ +% - %e, numer; /* 4.4408920985006262*10^-16 */ + +cfeval(cf_pi(20)), numer; /* 3.141623806667839 */ +% - %pi, numer; /* 3.115307804568701*10^-5 */ + + +/* convergence is much slower for pi */ +fpprec: 20$ +x: cfeval(cf_pi(10000))$ +bfloat(x - %pi); /* 2.4999999900104930006b-13 */ diff --git a/Task/Conways-Game-of-Life/Icon/conways-game-of-life.icon b/Task/Conways-Game-of-Life/Icon/conways-game-of-life.icon new file mode 100644 index 0000000000..23ef3fe8d1 --- /dev/null +++ b/Task/Conways-Game-of-Life/Icon/conways-game-of-life.icon @@ -0,0 +1,79 @@ +global limit + +procedure main(args) + n := args[1] | 50 # default is a 50x50 grid + limit := args[2] | &null # optional limit to number of generations + write("Enter the starting pattern, end with EOF") + grid := getInitialGrid(n) + play(grid) +end + +# This procedure reads in the initial pattern, inserting it +# into an nXn grid of cells. The nXn grid also gets a +# new border of empty cells, which just makes the test simpler +# for determining what do with a cell on each generation. +# It would be better to let the user move the cursor and click +# on cells to create/delete living cells, but this version +# assumes a simple ASCII terminal. +procedure getInitialGrid(n) + static notBlank, allStars + initial { + notBlank := ~' ' + allStars := repl("*",*notBlank) + } + + g := [] # store as an array of strings + + put(g,repl(" ",n)) + while r := read() do { # read in rows of grid + r := left(r,n) # force each to length n + put(g," "||map(r,notBlank,allStars)||" ") # and making any life a '*' + } + while *g ~= (n+2) do + put(g,repl(" ",n)) + + return g +end + +# Simple-minded procedure to 'play' Life from a starting grid. +procedure play(grid) + while not allDone(grid) do { + display(grid) + grid := onePlay(grid) + } +end + +# Display the grid +procedure display(g) + write(repl("-",*g[1])) + every write(!g) + write(repl("-",*g[1])) +end + +# Compute one generation of Life from the current one. +procedure onePlay(g) + ng := [] + every put(ng, !g) # new generation starts as copy of old + every ng[r := 2 to *g-1][c := 2 to *g-1] := case sum(g,r,c) of { + 3: "*" # cell lives (or is born) + 2: g[r][c] # cell unchanged + default: " " # cell dead + } + return ng +end + +# Return the number of living cells surrounding the current cell. +procedure sum(g,r,c) + cnt := 0 + every (i := -1 to 1, j := -1 to 1) do + if ((i ~= 0) | (j ~= 0)) & (g[r+i][c+j] == "*") then cnt +:= 1 + return cnt +end + +# Check to see if all the cells have died or we've exceeded the +# number of allowed generations. +procedure allDone(g) + static count + initial count := 0 + return ((count +:= 1) > \limit) | (trim(!g) == " ") +end diff --git a/Task/Conways-Game-of-Life/J/conways-game-of-life-1.j b/Task/Conways-Game-of-Life/J/conways-game-of-life-1.j new file mode 100644 index 0000000000..0139cad871 --- /dev/null +++ b/Task/Conways-Game-of-Life/J/conways-game-of-life-1.j @@ -0,0 +1,2 @@ +pad=: 0,0,~0,.0,.~] +life=: (_3 _3 (+/ e. 3+0,4&{)@,;._3 ])@pad diff --git a/Task/Conways-Game-of-Life/J/conways-game-of-life-2.j b/Task/Conways-Game-of-Life/J/conways-game-of-life-2.j new file mode 100644 index 0000000000..b54d2de8fb --- /dev/null +++ b/Task/Conways-Game-of-Life/J/conways-game-of-life-2.j @@ -0,0 +1,12 @@ + life^:0 1 2 #:0 7 0 +0 0 0 +1 1 1 +0 0 0 + +0 1 0 +0 1 0 +0 1 0 + +0 0 0 +1 1 1 +0 0 0 diff --git a/Task/Conways-Game-of-Life/JAMES-II-Rule-based-Cellular-Automata/conways-game-of-life.james b/Task/Conways-Game-of-Life/JAMES-II-Rule-based-Cellular-Automata/conways-game-of-life.james new file mode 100644 index 0000000000..babc5b3ac2 --- /dev/null +++ b/Task/Conways-Game-of-Life/JAMES-II-Rule-based-Cellular-Automata/conways-game-of-life.james @@ -0,0 +1,25 @@ +@caversion 1; + +dimensions 2; + +//using Moore neighborhood +neighborhood moore; + +//available states +state DEAD, ALIVE; + +/* + if current state is ALIVE and the + neighborhood does not contain 2 or + 3 ALIVE states the cell changes to + DEAD +*/ +rule{ALIVE}:!ALIVE{2,3}->DEAD; + +/* + if current state is DEAD and there + are exactly 3 ALIVE cells in the + neighborhood the cell changes to + ALIVE +*/ +rule{DEAD}:ALIVE{3}->ALIVE; diff --git a/Task/Conways-Game-of-Life/Liberty-BASIC/conways-game-of-life.liberty b/Task/Conways-Game-of-Life/Liberty-BASIC/conways-game-of-life.liberty new file mode 100644 index 0000000000..e1f236d310 --- /dev/null +++ b/Task/Conways-Game-of-Life/Liberty-BASIC/conways-game-of-life.liberty @@ -0,0 +1,68 @@ + nomainwin + + gridX = 20 + gridY = gridX + + mult =500 /gridX + pointSize =360 /gridX + + dim old( gridX +1, gridY +1), new( gridX +1, gridY +1) + +'Set blinker: + old( 16, 16) =1: old( 16, 17) =1 : old( 16, 18) =1 + +'Set glider: + old( 5, 7) =1: old( 6, 7) =1: old( 7, 7) =1 + old( 7, 6) =1: old( 6, 5) =1 + + WindowWidth =570 + WindowHeight =600 + + open "Conway's 'Game of Life'." for graphics_nsb_nf as #w + + #w "trapclose [quit]" + #w "down ; size "; pointSize + #w "fill black" + +'Draw initial grid + for x = 1 to gridX + for y = 1 to gridY + '#w "color "; int( old( x, y) *256); " 0 255" + if old( x, y) <>0 then #w "color red" else #w "color darkgray" + #w "set "; x *mult +20; " "; y *mult +20 + next y + next x +' ______________________________________________________________________________ +'Run + do + for x =1 to gridX + for y =1 to gridY + 'find number of live Moore neighbours + neighbours =old( x -1, y -1) +old( x, y -1) +old( x +1, y -1)+_ + old( x -1, y) +old( x +1, y )+_ + old( x -1, y +1) +old( x, y +1) +old( x +1, y +1) + was =old( x, y) + if was =0 then + if neighbours =3 then N =1 else N =0 + else + if neighbours =3 or neighbours =2 then N =1 else N =0 + end if + new( x, y) = N + '#w "color "; int( N /8 *256); " 0 255" + if N <>0 then #w "color red" else #w "color darkgray" + #w "set "; x *mult +20; " "; y *mult +20 + next y + next x + scan +'swap + for x =1 to gridX + for y =1 to gridY + old( x, y) =new( x, y) + next y + next x +'Re-run until interrupted... + loop until FALSE +'User shutdown received + [quit] + close #w + end diff --git a/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-1.mathematica b/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-1.mathematica new file mode 100644 index 0000000000..5f31fbd403 --- /dev/null +++ b/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-1.mathematica @@ -0,0 +1 @@ +CellularAutomaton[{224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}}, startconfiguration, steps]; diff --git a/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-2.mathematica b/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-2.mathematica new file mode 100644 index 0000000000..b7e062b0ab --- /dev/null +++ b/Task/Conways-Game-of-Life/Mathematica/conways-game-of-life-2.mathematica @@ -0,0 +1,2 @@ +results=CellularAutomaton[{224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}},{{{0,1,0},{0,0,1},{1,1,1}},0},8]; + Do[Print[i-1];Print[Grid[results[[i]]/.{1->"#",0->"."}]];,{i,1,Length[results]}] diff --git a/Task/Conways-Game-of-Life/Maxima/conways-game-of-life.maxima b/Task/Conways-Game-of-Life/Maxima/conways-game-of-life.maxima new file mode 100644 index 0000000000..7dc2f7f852 --- /dev/null +++ b/Task/Conways-Game-of-Life/Maxima/conways-game-of-life.maxima @@ -0,0 +1,53 @@ +life(A) := block( + [p, q, B: zerofor(A), s], + [p, q]: matrix_size(A), + for i thru p do ( + for j thru q do ( + s: 0, + if j > 1 then s: s + A[i, j - 1], + if j < q then s: s + A[i, j + 1], + if i > 1 then ( + s: s + A[i - 1, j], + if j > 1 then s: s + A[i - 1, j - 1], + if j < q then s: s + A[i - 1, j + 1] + ), + if i < p then ( + s: s + A[i + 1, j], + if j > 1 then s: s + A[i + 1, j - 1], + if j < q then s: s + A[i + 1, j + 1] + ), + B[i, j]: charfun(s = 3 or (s = 2 and A[i, j] = 1)) + ) + ), + B +)$ + + +/* a glider */ + +L: matrix([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], + [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])$ + +gen(A, n) := block(thru n do A: life(A), A)$ + +gen(L, 4); +matrix([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], + [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) diff --git a/Task/Count-in-factors/Groovy/count-in-factors.groovy b/Task/Count-in-factors/Groovy/count-in-factors.groovy new file mode 100644 index 0000000000..ee4d819091 --- /dev/null +++ b/Task/Count-in-factors/Groovy/count-in-factors.groovy @@ -0,0 +1,22 @@ +def factors(number) { + if (number == 1) { + return [1] + } + def factors = [] + BigInteger value = number + BigInteger possibleFactor = 2 + while (possibleFactor <= value) { + if (value % possibleFactor == 0) { + factors << possibleFactor + value /= possibleFactor + } else { + possibleFactor++ + } + } + factors +} +Number.metaClass.factors = { factors(delegate) } + +((1..10) + (6351..6359)).each { number -> + println "$number = ${number.factors().join(' x ')}" +} diff --git a/Task/Count-in-factors/Icon/count-in-factors.icon b/Task/Count-in-factors/Icon/count-in-factors.icon new file mode 100644 index 0000000000..3fb3e2b410 --- /dev/null +++ b/Task/Count-in-factors/Icon/count-in-factors.icon @@ -0,0 +1,9 @@ +procedure main() +write("Press ^C to terminate") +every f := [i:= 1] | factors(i := seq(2)) do { + writes(i," : [") + every writes(" ",!f|"]\n") + } +end + +link factors diff --git a/Task/Count-in-factors/J/count-in-factors-1.j b/Task/Count-in-factors/J/count-in-factors-1.j new file mode 100644 index 0000000000..7f74386238 --- /dev/null +++ b/Task/Count-in-factors/J/count-in-factors-1.j @@ -0,0 +1 @@ +q: diff --git a/Task/Count-in-factors/J/count-in-factors-2.j b/Task/Count-in-factors/J/count-in-factors-2.j new file mode 100644 index 0000000000..199dcaf91a --- /dev/null +++ b/Task/Count-in-factors/J/count-in-factors-2.j @@ -0,0 +1,12 @@ + ('1 : 1',":&> ,"1 ': ',"1 ":@q:) 2+i.10 +1 : 1 +2 : 2 +3 : 3 +4 : 2 2 +5 : 5 +6 : 2 3 +7 : 7 +8 : 2 2 2 +9 : 3 3 +10: 2 5 +11: 11 diff --git a/Task/Count-in-factors/Liberty-BASIC/count-in-factors.liberty b/Task/Count-in-factors/Liberty-BASIC/count-in-factors.liberty new file mode 100644 index 0000000000..7cf493db5d --- /dev/null +++ b/Task/Count-in-factors/Liberty-BASIC/count-in-factors.liberty @@ -0,0 +1,18 @@ +'see Run BASIC solution +for i = 1000 to 1016 + print i;" = "; factorial$(i) +next +wait +function factorial$(num) + if num = 1 then factorial$ = "1" + fct = 2 + while fct <= num + if (num mod fct) = 0 then + factorial$ = factorial$ ; x$ ; fct + x$ = " x " + num = num / fct + else + fct = fct + 1 + end if + wend +end function diff --git a/Task/Count-in-factors/Mathematica/count-in-factors.mathematica b/Task/Count-in-factors/Mathematica/count-in-factors.mathematica new file mode 100644 index 0000000000..b184f7b1c6 --- /dev/null +++ b/Task/Count-in-factors/Mathematica/count-in-factors.mathematica @@ -0,0 +1,4 @@ +n = 2; +While[n < 100, + Print[Row[Riffle[Flatten[Map[Apply[ConstantArray, #] &, FactorInteger[n]]],"*"]]]; + n++] diff --git a/Task/Count-in-octal/Groovy/count-in-octal-1.groovy b/Task/Count-in-octal/Groovy/count-in-octal-1.groovy new file mode 100644 index 0000000000..45210b75d6 --- /dev/null +++ b/Task/Count-in-octal/Groovy/count-in-octal-1.groovy @@ -0,0 +1,4 @@ +println 'decimal octal' +for (def i = 0; i <= Integer.MAX_VALUE; i++) { + printf ('%7d %#5o\n', i, i) +} diff --git a/Task/Count-in-octal/Groovy/count-in-octal-2.groovy b/Task/Count-in-octal/Groovy/count-in-octal-2.groovy new file mode 100644 index 0000000000..573489584c --- /dev/null +++ b/Task/Count-in-octal/Groovy/count-in-octal-2.groovy @@ -0,0 +1,4 @@ +println 'decimal octal' +for (def i = 0g; true; i += 1g) { + printf ('%7d %#5o\n', i, i) +} diff --git a/Task/Count-in-octal/Icon/count-in-octal.icon b/Task/Count-in-octal/Icon/count-in-octal.icon new file mode 100644 index 0000000000..9ab94f5fef --- /dev/null +++ b/Task/Count-in-octal/Icon/count-in-octal.icon @@ -0,0 +1,6 @@ +link convert # To get exbase10 method + +procedure main() + limit := 8r37777777777 + every write(exbase10(seq(0)\limit, 8)) +end diff --git a/Task/Count-in-octal/J/count-in-octal-1.j b/Task/Count-in-octal/J/count-in-octal-1.j new file mode 100644 index 0000000000..eb8ce278bd --- /dev/null +++ b/Task/Count-in-octal/J/count-in-octal-1.j @@ -0,0 +1,2 @@ + disp=.[:smoutput [:,@:(":"0) 8&#.^:_1 + (>:[disp)^:_ ]0 diff --git a/Task/Count-in-octal/J/count-in-octal-2.j b/Task/Count-in-octal/J/count-in-octal-2.j new file mode 100644 index 0000000000..b152c2449f --- /dev/null +++ b/Task/Count-in-octal/J/count-in-octal-2.j @@ -0,0 +1,12 @@ + (>:[disp)^:_ ]0 +0 +1 +2 +3 +4 +5 +6 +7 +10 +11 +... diff --git a/Task/Count-in-octal/LOLCODE/count-in-octal.lol b/Task/Count-in-octal/LOLCODE/count-in-octal.lol new file mode 100644 index 0000000000..54f56c2578 --- /dev/null +++ b/Task/Count-in-octal/LOLCODE/count-in-octal.lol @@ -0,0 +1,19 @@ +HAI 1.3 + +HOW IZ I octal YR num + I HAS A digit, I HAS A oct ITZ "" + IM IN YR octalizer + digit R MOD OF num AN 8 + oct R SMOOSH digit oct MKAY + num R QUOSHUNT OF num AN 8 + NOT num, O RLY? + YA RLY, FOUND YR oct + OIC + IM OUTTA YR octalizer +IF U SAY SO + +IM IN YR printer UPPIN YR num + VISIBLE I IZ octal YR num MKAY +IM OUTTA YR printer + +KTHXBYE diff --git a/Task/Count-in-octal/Lang5/count-in-octal.lang5 b/Task/Count-in-octal/Lang5/count-in-octal.lang5 new file mode 100644 index 0000000000..2a4f95659a --- /dev/null +++ b/Task/Count-in-octal/Lang5/count-in-octal.lang5 @@ -0,0 +1,2 @@ +'%4o '__number_format set +0 do dup 1 compress . "\n" . 1 + loop diff --git a/Task/Count-in-octal/Liberty-BASIC/count-in-octal-1.liberty b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-1.liberty new file mode 100644 index 0000000000..c3544e0fa5 --- /dev/null +++ b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-1.liberty @@ -0,0 +1,26 @@ + 'the method used here uses the base-conversion from RC Non-decimal radices/Convert + 'to terminate hit + + global alphanum$ + alphanum$ ="01234567" + + i =0 + + while 1 + print toBase$( 8, i) + i =i +1 + wend + + end + + function toBase$( base, number) ' Convert decimal variable to number string. + maxIntegerBitSize =len( str$( number)) + toBase$ ="" + for i =10 to 1 step -1 + remainder =number mod base + toBase$ =mid$( alphanum$, remainder +1, 1) +toBase$ + number =int( number /base) + if number <1 then exit for + next i + toBase$ =right$( " " +toBase$, 10) + end function diff --git a/Task/Count-in-octal/Liberty-BASIC/count-in-octal-2.liberty b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-2.liberty new file mode 100644 index 0000000000..6c7dacb227 --- /dev/null +++ b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-2.liberty @@ -0,0 +1,30 @@ + op$ = "00000000000000000000" +L =len( op$) + +while 1 + started =0 + + for i =1 to L + m$ =mid$( op$, i, 1) + if started =0 and m$ ="0" then print " "; else print m$;: started =1 + next i + print + + for i =L to 1 step -1 + p$ =mid$( op$, i, 1) + if p$ =" " then v =0 else v =val( p$) + incDigit = v +carry + if i =L then incDigit =incDigit +1 + if incDigit >=8 then + replDigit =incDigit -8 + carry =1 + else + replDigit =incDigit + carry =0 + end if + op$ =left$( op$, i -1) +chr$( 48 +replDigit) +right$( op$, L -i) + next i + +wend + +end diff --git a/Task/Count-in-octal/Liberty-BASIC/count-in-octal-3.liberty b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-3.liberty new file mode 100644 index 0000000000..a011f10852 --- /dev/null +++ b/Task/Count-in-octal/Liberty-BASIC/count-in-octal-3.liberty @@ -0,0 +1,16 @@ + i = 0 +while 1 + call CountOctal 0, i, i > 0 + i = i + 1 +wend + +sub CountOctal value, depth, startValue + value = value * 10 + for i = startValue to 7 + if depth > 0 then + call CountOctal value + i, depth - 1, 0 + else + print value + i + end if + next i +end sub diff --git a/Task/Count-in-octal/Logo/count-in-octal.logo b/Task/Count-in-octal/Logo/count-in-octal.logo new file mode 100644 index 0000000000..7e790bbc5d --- /dev/null +++ b/Task/Count-in-octal/Logo/count-in-octal.logo @@ -0,0 +1,22 @@ +to increment_octal :n + ifelse [empty? :n] [ + output 1 + ] [ + local "last + make "last last :n + local "butlast + make "butlast butlast :n + make "last sum :last 1 + ifelse [:last < 8] [ + output word :butlast :last + ] [ + output word (increment_octal :butlast) 0 + ] + ] +end + +make "oct 0 +while ["true] [ + print :oct + make "oct increment_octal :oct +] diff --git a/Task/Count-in-octal/Mathematica/count-in-octal.mathematica b/Task/Count-in-octal/Mathematica/count-in-octal.mathematica new file mode 100644 index 0000000000..38328341fe --- /dev/null +++ b/Task/Count-in-octal/Mathematica/count-in-octal.mathematica @@ -0,0 +1,2 @@ +x=0; +While[True,Print[BaseForm[x,8];x++] diff --git a/Task/Count-in-octal/Mercury/count-in-octal.mercury b/Task/Count-in-octal/Mercury/count-in-octal.mercury new file mode 100644 index 0000000000..0810986095 --- /dev/null +++ b/Task/Count-in-octal/Mercury/count-in-octal.mercury @@ -0,0 +1,17 @@ +:- module count_in_octal. +:- interface. +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + count_in_octal(0, !IO). + +:- pred count_in_octal(int::in, io::di, io::uo) is det. + +count_in_octal(N, !IO) :- + io.format("%o\n", [i(N)], !IO), + count_in_octal(N + 1, !IO). diff --git a/Task/Count-in-octal/Modula-2/count-in-octal.mod2 b/Task/Count-in-octal/Modula-2/count-in-octal.mod2 new file mode 100644 index 0000000000..8c2ceb1f63 --- /dev/null +++ b/Task/Count-in-octal/Modula-2/count-in-octal.mod2 @@ -0,0 +1,13 @@ +MODULE octal; + +IMPORT InOut; + +VAR num : CARDINAL; + +BEGIN + num := 0; + REPEAT + InOut.WriteOct (num, 12); InOut.WriteLn; + INC (num) + UNTIL num = 0 +END octal. diff --git a/Task/Count-occurrences-of-a-substring/Groovy/count-occurrences-of-a-substring.groovy b/Task/Count-occurrences-of-a-substring/Groovy/count-occurrences-of-a-substring.groovy new file mode 100644 index 0000000000..5ae41f0329 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Groovy/count-occurrences-of-a-substring.groovy @@ -0,0 +1,4 @@ +println (('the three truths' =~ /th/).count) +println (('ababababab' =~ /abab/).count) +println (('abaabba*bbaba*bbab' =~ /a*b/).count) +println (('abaabba*bbaba*bbab' =~ /a\*b/).count) diff --git a/Task/Count-occurrences-of-a-substring/Icon/count-occurrences-of-a-substring.icon b/Task/Count-occurrences-of-a-substring/Icon/count-occurrences-of-a-substring.icon new file mode 100644 index 0000000000..2c51d91dab --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Icon/count-occurrences-of-a-substring.icon @@ -0,0 +1,14 @@ +procedure main() +every A := ![ ["the three truths","th"], ["ababababab","abab"] ] do + write("The string ",image(A[2])," occurs as a non-overlapping substring ", + countSubstring!A , " times in ",image(A[1])) +end + +procedure countSubstring(s1,s2) #: return count of non-overlapping substrings +c := 0 +s1 ? while tab(find(s2)) do { + move(*s2) + c +:= 1 + } +return c +end diff --git a/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-1.j b/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-1.j new file mode 100644 index 0000000000..82095eb7b6 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-1.j @@ -0,0 +1,2 @@ +require'strings' +countss=: #@] %~ #@[ - [ #@rplc '';~] diff --git a/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-2.j b/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-2.j new file mode 100644 index 0000000000..12fef71a04 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/J/count-occurrences-of-a-substring-2.j @@ -0,0 +1,4 @@ + 'the three truths' countss 'th' +3 + 'ababababab' countss 'abab' +2 diff --git a/Task/Count-occurrences-of-a-substring/K/count-occurrences-of-a-substring.k b/Task/Count-occurrences-of-a-substring/K/count-occurrences-of-a-substring.k new file mode 100644 index 0000000000..1941158fe4 --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/K/count-occurrences-of-a-substring.k @@ -0,0 +1,11 @@ + "the three truths" _ss "th" +0 4 13 + + #"the three truths" _ss "th" +3 + + "ababababab" _ss "abab" +0 4 + + #"ababababab" _ss "abab" +2 diff --git a/Task/Count-occurrences-of-a-substring/Liberty-BASIC/count-occurrences-of-a-substring.liberty b/Task/Count-occurrences-of-a-substring/Liberty-BASIC/count-occurrences-of-a-substring.liberty new file mode 100644 index 0000000000..7f628ed59b --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Liberty-BASIC/count-occurrences-of-a-substring.liberty @@ -0,0 +1,13 @@ +print countSubstring( "the three truths", "th") +print countSubstring( "ababababab", "abab") +end + +function countSubstring( a$, s$) + c =0 + la =len( a$) + ls =len( s$) + for i =1 to la -ls + if mid$( a$, i, ls) =s$ then c =c +1: i =i +ls -1 + next i + countSubstring =c +end function diff --git a/Task/Count-occurrences-of-a-substring/Mathematica/count-occurrences-of-a-substring.mathematica b/Task/Count-occurrences-of-a-substring/Mathematica/count-occurrences-of-a-substring.mathematica new file mode 100644 index 0000000000..56076e675f --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Mathematica/count-occurrences-of-a-substring.mathematica @@ -0,0 +1,4 @@ +StringPosition["the three truths","th",Overlaps->False]//Length +3 +StringPosition["ababababab","abab",Overlaps->False]//Length +2 diff --git a/Task/Count-occurrences-of-a-substring/Maxima/count-occurrences-of-a-substring.maxima b/Task/Count-occurrences-of-a-substring/Maxima/count-occurrences-of-a-substring.maxima new file mode 100644 index 0000000000..f59cf2789c --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Maxima/count-occurrences-of-a-substring.maxima @@ -0,0 +1,8 @@ +scount(e, s) := block( + [n: 0, k: 1], + while integerp(k: ssearch(e, s, k)) do (n: n + 1, k: k + 1), + n +)$ + +scount("na", "banana"); +2 diff --git a/Task/Count-occurrences-of-a-substring/Mirah/count-occurrences-of-a-substring.mirah b/Task/Count-occurrences-of-a-substring/Mirah/count-occurrences-of-a-substring.mirah new file mode 100644 index 0000000000..104e5ee29b --- /dev/null +++ b/Task/Count-occurrences-of-a-substring/Mirah/count-occurrences-of-a-substring.mirah @@ -0,0 +1,38 @@ +import java.util.regex.Pattern +import java.util.regex.Matcher + +#The "remove and count the difference" method +def count_substring(pattern:string, source:string) + (source.length() - source.replace(pattern, "").length()) / pattern.length() +end + +puts count_substring("th", "the three truths") # ==> 3 +puts count_substring("abab", "ababababab") # ==> 2 +puts count_substring("a*b", "abaabba*bbaba*bbab") # ==> 2 + + +# The "split and count" method +def count_substring2(pattern:string, source:string) + # the result of split() will contain one more element than the delimiter + # the "-1" second argument makes it not discard trailing empty strings + source.split(Pattern.quote(pattern), -1).length - 1 +end + +puts count_substring2("th", "the three truths") # ==> 3 +puts count_substring2("abab", "ababababab") # ==> 2 +puts count_substring2("a*b", "abaabba*bbaba*bbab") # ==> 2 + + +# This method does a match and counts how many times it matches +def count_substring3(pattern:string, source:string) + result = 0 + Matcher m = Pattern.compile(Pattern.quote(pattern)).matcher(source); + while (m.find()) + result = result + 1 + end + result +end + +puts count_substring3("th", "the three truths") # ==> 3 +puts count_substring3("abab", "ababababab") # ==> 2 +puts count_substring3("a*b", "abaabba*bbaba*bbab") # ==> 2 diff --git a/Task/Count-the-coins/Factor/count-the-coins.factor b/Task/Count-the-coins/Factor/count-the-coins.factor new file mode 100644 index 0000000000..1c21c57005 --- /dev/null +++ b/Task/Count-the-coins/Factor/count-the-coins.factor @@ -0,0 +1,36 @@ +USING: combinators kernel locals math math.ranges sequences sets sorting ; +IN: rosetta.coins + + types + { + ! End condition: 1 way to make 0 cents. + { [ cents zero? ] [ 1 ] } + ! End condition: 0 ways to make money without any coins. + { [ types zero? ] [ 0 ] } + ! Optimization: At most 1 way to use 1 type of coin. + { [ types 1 number= ] [ + cents coins first mod zero? [ 1 ] [ 0 ] if + ] } + ! Find all ways to use the first type of coin. + [ + ! f = first type, r = other types of coins. + coins unclip-slice :> f :> r + ! Loop for 0, f, 2*f, 3*f, ..., cents. + 0 cents f [ + ! Recursively count how many ways to make remaining cents + ! with other types of coins. + cents swap - r recursive-count + ] [ + ] map-reduce ! Sum the counts. + ] + } cond ; +PRIVATE> + +! How many ways can we make the given amount of cents +! with the given set of coins? +: make-change ( cents coins -- ways ) + members [ ] inv-sort-with ! Sort coins in descending order. + recursive-count ; diff --git a/Task/Count-the-coins/Groovy/count-the-coins-1.groovy b/Task/Count-the-coins/Groovy/count-the-coins-1.groovy new file mode 100644 index 0000000000..2a93130823 --- /dev/null +++ b/Task/Count-the-coins/Groovy/count-the-coins-1.groovy @@ -0,0 +1,13 @@ +def ccR +ccR = { BigInteger tot, List coins -> + BigInteger n = coins.size() + switch ([tot:tot, coins:coins]) { + case { it.tot == 0 } : + return 1g + case { it.tot < 0 || coins == [] } : + return 0g + default: + return ccR(tot, coins[1.. coins -> + List ways = [0g] * (tot+1) + ways[0] = 1g + coins.each { BigInteger coin -> + (coin..tot).each { j -> + ways[j] += ways[j-coin] + } + } + ways[tot] +} diff --git a/Task/Count-the-coins/Groovy/count-the-coins-3.groovy b/Task/Count-the-coins/Groovy/count-the-coins-3.groovy new file mode 100644 index 0000000000..fee8aef35d --- /dev/null +++ b/Task/Count-the-coins/Groovy/count-the-coins-3.groovy @@ -0,0 +1,14 @@ +println '\nBase:' +[iterative: ccI, recursive: ccR].each { label, cc -> + print "${label} " + def start = System.currentTimeMillis() + def ways = cc(100g, [25g, 10g, 5g, 1g]) + def elapsed = System.currentTimeMillis() - start + println ("answer: ${ways} elapsed: ${elapsed}ms") +} + +print '\nExtra Credit:\niterative ' +def start = System.currentTimeMillis() +def ways = ccI(1000g * 100, [100g, 50g, 25g, 10g, 5g, 1g]) +def elapsed = System.currentTimeMillis() - start +println ("answer: ${ways} elapsed: ${elapsed}ms") diff --git a/Task/Count-the-coins/Icon/count-the-coins-1.icon b/Task/Count-the-coins/Icon/count-the-coins-1.icon new file mode 100644 index 0000000000..270f6aa8ca --- /dev/null +++ b/Task/Count-the-coins/Icon/count-the-coins-1.icon @@ -0,0 +1,19 @@ +procedure main() + + US_coins := [1, 5, 10, 25] + US_allcoins := [1,5,10,25,50,100] + EU_coins := [1, 2, 5, 10, 20, 50, 100, 200] + CDN_coins := [1,5,10,25,100,200] + CDN_allcoins := [1,5,10,25,50,100,200] + + every trans := ![ [15,US_coins], + [100,US_coins], + [1000*100,US_allcoins] + ] do + printf("There are %i ways to count change for %i using %s coins.\n",CountCoins!trans,trans[1],ShowList(trans[2])) +end + +procedure ShowList(L) # helper list to string +every (s := "[ ") ||:= !L || " " +return s || "]" +end diff --git a/Task/Count-the-coins/Icon/count-the-coins-2.icon b/Task/Count-the-coins/Icon/count-the-coins-2.icon new file mode 100644 index 0000000000..5333ad76f1 --- /dev/null +++ b/Task/Count-the-coins/Icon/count-the-coins-2.icon @@ -0,0 +1,19 @@ +procedure CountCoins(amt,coins) # very slow, recurse by coin value +local count +static S + +if type(coins) == "list" then { + S := sort(set(coins)) + if *S < 1 then runerr(205,coins) + return CountCoins(amt) + } +else { + /coins := 1 + if value := S[coins] then { + every (count := 0) +:= CountCoins(amt - (0 to amt by value), coins + 1) + return count + } + else + return (amt ~= 0) | 1 + } +end diff --git a/Task/Count-the-coins/J/count-the-coins-1.j b/Task/Count-the-coins/J/count-the-coins-1.j new file mode 100644 index 0000000000..e0484fe62c --- /dev/null +++ b/Task/Count-the-coins/J/count-the-coins-1.j @@ -0,0 +1,4 @@ +merge=: ({:"1 (+/@:({."1),{:@{:)/. ])@; +count=: {.@] <@,. {:@] - [ * [ i.@>:@<.@%~ {:@] +init=: (1 ,. ,.)^:(0=#@$) +nsplits=: 0 { [: +/ [: (merge@:(count"1) init)/ }.@/:~@~.@, diff --git a/Task/Count-the-coins/J/count-the-coins-2.j b/Task/Count-the-coins/J/count-the-coins-2.j new file mode 100644 index 0000000000..1094bcd1c7 --- /dev/null +++ b/Task/Count-the-coins/J/count-the-coins-2.j @@ -0,0 +1,2 @@ + 100 nsplits 1 5 10 25 +242 diff --git a/Task/Count-the-coins/J/count-the-coins-3.j b/Task/Count-the-coins/J/count-the-coins-3.j new file mode 100644 index 0000000000..c354a45443 --- /dev/null +++ b/Task/Count-the-coins/J/count-the-coins-3.j @@ -0,0 +1,2 @@ + 100000 nsplits 1 5 10 25 50 100 +13398445413854501 diff --git a/Task/Count-the-coins/Mathematica/count-the-coins.mathematica b/Task/Count-the-coins/Mathematica/count-the-coins.mathematica new file mode 100644 index 0000000000..e0f43c353c --- /dev/null +++ b/Task/Count-the-coins/Mathematica/count-the-coins.mathematica @@ -0,0 +1,8 @@ +CountCoins[amount_, coinlist_] := ( ways = ConstantArray[1, amount]; +Do[For[j = coin, j <= amount, j++, + If[ j - coin == 0, + ways[[j]] ++, + ways[[j]] += ways[[j - coin]] +]] +, {coin, coinlist}]; +ways[[amount]]) diff --git a/Task/Count-the-coins/Mercury/count-the-coins.mercury b/Task/Count-the-coins/Mercury/count-the-coins.mercury new file mode 100644 index 0000000000..dcdd60187b --- /dev/null +++ b/Task/Count-the-coins/Mercury/count-the-coins.mercury @@ -0,0 +1,48 @@ +:- module coins. +:- interface. +:- import_module int, io. +:- type coin ---> quarter; dime; nickel; penny. +:- type purse ---> purse(int, int, int, int). + +:- pred sum_to(int::in, purse::out) is nondet. + +:- pred main(io::di, io::uo) is det. +:- implementation. +:- import_module solutions, list, string. + +:- func value(coin) = int. +value(quarter) = 25. +value(dime) = 10. +value(nickel) = 5. +value(penny) = 1. + +:- pred supply(coin::in, int::in, int::out) is multi. +supply(C, Target, N) :- upto(Target div value(C), N). + +:- pred upto(int::in, int::out) is multi. +upto(N, R) :- ( nondet_int_in_range(0, N, R0) -> R = R0 ; R = 0 ). + +sum_to(To, Purse) :- + Purse = purse(Q, D, N, P), + sum(Purse) = To, + supply(quarter, To, Q), + supply(dime, To, D), + supply(nickel, To, N), + supply(penny, To, P). + +:- func sum(purse) = int. +sum(purse(Q, D, N, P)) = + value(quarter) * Q + value(dime) * D + + value(nickel) * N + value(penny) * P. + +main(!IO) :- + solutions(sum_to(100), L), + show(L, !IO), + io.format("There are %d ways to make change for a dollar.\n", + [i(length(L))], !IO). + +:- pred show(list(purse)::in, io::di, io::uo) is det. +show([], !IO). +show([P|T], !IO) :- + io.write(P, !IO), io.nl(!IO), + show(T, !IO). diff --git a/Task/Create-a-file-on-magnetic-tape/JCL/create-a-file-on-magnetic-tape.jcl b/Task/Create-a-file-on-magnetic-tape/JCL/create-a-file-on-magnetic-tape.jcl new file mode 100644 index 0000000000..b3e0378768 --- /dev/null +++ b/Task/Create-a-file-on-magnetic-tape/JCL/create-a-file-on-magnetic-tape.jcl @@ -0,0 +1,9 @@ +// EXEC PGM=IEBGENER +//* Create a file named "TAPE.FILE" on magnetic tape; "UNIT=TAPE" +//* may vary depending on site-specific esoteric name assignment +//SYSPRINT DD SYSOUT=* +//SYSIN DD DUMMY +//SYSUT2 DD UNIT=TAPE,DSN=TAPE.FILE,DISP=(,CATLG) +//SYSUT1 DD * +DATA TO BE WRITTEN TO TAPE +/* diff --git a/Task/Create-a-file/Factor/create-a-file.factor b/Task/Create-a-file/Factor/create-a-file.factor new file mode 100644 index 0000000000..9ed1c648e9 --- /dev/null +++ b/Task/Create-a-file/Factor/create-a-file.factor @@ -0,0 +1,4 @@ +USE: io.directories + +"output.txt" "/output.txt" [ touch-file ] bi@ +"docs" "/docs" [ make-directory ] bi@ diff --git a/Task/Create-a-file/Fancy/create-a-file.fancy b/Task/Create-a-file/Fancy/create-a-file.fancy new file mode 100644 index 0000000000..b753f7b7a3 --- /dev/null +++ b/Task/Create-a-file/Fancy/create-a-file.fancy @@ -0,0 +1,8 @@ +["/", "./"] each: |dir| { + # create '/docs', then './docs' + Directory create: (dir ++ "docs") + # create files /output.txt, then ./output.txt + File open: (dir ++ "output.txt") modes: ['write] with: |f| { + f writeln: "hello, world!" + } +} diff --git a/Task/Create-a-file/Groovy/create-a-file.groovy b/Task/Create-a-file/Groovy/create-a-file.groovy new file mode 100644 index 0000000000..b927d2e577 --- /dev/null +++ b/Task/Create-a-file/Groovy/create-a-file.groovy @@ -0,0 +1,4 @@ +new File("output.txt").createNewFile() +new File(File.separator + "output.txt").createNewFile() +new File("docs").mkdir() +new File(File.separator + "docs").mkdir() diff --git a/Task/Create-a-file/HicEst/create-a-file.hicest b/Task/Create-a-file/HicEst/create-a-file.hicest new file mode 100644 index 0000000000..5e62a8856c --- /dev/null +++ b/Task/Create-a-file/HicEst/create-a-file.hicest @@ -0,0 +1,5 @@ +SYSTEM(DIR="\docs") ! create argument if not existent, make it current +OPEN(FILE="output.txt", "NEW") ! in current directory + +SYSTEM(DIR="C:\docs") ! create C:\docs if not existent, make it current +OPEN(FILE="output.txt", "NEW") ! in C:\docs diff --git a/Task/Create-a-file/Icon/create-a-file.icon b/Task/Create-a-file/Icon/create-a-file.icon new file mode 100644 index 0000000000..8d5608d594 --- /dev/null +++ b/Task/Create-a-file/Icon/create-a-file.icon @@ -0,0 +1,4 @@ +every dir := !["./","/"] do { + close(open(f := dir || "input.txt","w")) |stop("failure for open ",f) + mkdir(f := dir || "docs") |stop("failure for mkdir ",f) + } diff --git a/Task/Create-a-file/J/create-a-file-1.j b/Task/Create-a-file/J/create-a-file-1.j new file mode 100644 index 0000000000..c805293ee2 --- /dev/null +++ b/Task/Create-a-file/J/create-a-file-1.j @@ -0,0 +1,2 @@ +'' 1!:2 <'/output.txt' NB. write an empty file + 1!:5 <'/docs' NB. create a directory diff --git a/Task/Create-a-file/J/create-a-file-2.j b/Task/Create-a-file/J/create-a-file-2.j new file mode 100644 index 0000000000..d268ceb2a8 --- /dev/null +++ b/Task/Create-a-file/J/create-a-file-2.j @@ -0,0 +1,7 @@ +require 'files' +NB. create two empty files named /output.txt and output.txt +'' fwrite '/output.txt' ; 'output.txt' + +require 'general/dirutils' NB. addon package +NB. create two directories: /docs and docs: +dircreate '/docs' ; 'docs' diff --git a/Task/Create-a-file/JCL/create-a-file.jcl b/Task/Create-a-file/JCL/create-a-file.jcl new file mode 100644 index 0000000000..3f75e7f5ce --- /dev/null +++ b/Task/Create-a-file/JCL/create-a-file.jcl @@ -0,0 +1,5 @@ +// EXEC PGM=IEFBR14 +//* CREATE EMPTY FILE NAMED "OUTPUT.TXT" (file names upper case only) +//ANYNAME DD UNIT=SYSDA,SPACE=(0,0),DSN=OUTPUT.TXT,DISP=(,CATLG) +//* CREATE DIRECTORY (PARTITIONED DATA SET) NAMED "DOCS" +//ANYNAME DD UNIT=SYSDA,SPACE=(TRK,(1,1)),DSN=DOCS,DISP=(,CATLG) diff --git a/Task/Create-a-file/K/create-a-file.k b/Task/Create-a-file/K/create-a-file.k new file mode 100644 index 0000000000..a8efd2da06 --- /dev/null +++ b/Task/Create-a-file/K/create-a-file.k @@ -0,0 +1,4 @@ + "output.txt" 1: "" + "/output.txt" 1: "" + \ mkdir docs + \ mkdir /docs diff --git a/Task/Create-a-file/Liberty-BASIC/create-a-file.liberty b/Task/Create-a-file/Liberty-BASIC/create-a-file.liberty new file mode 100644 index 0000000000..db42780481 --- /dev/null +++ b/Task/Create-a-file/Liberty-BASIC/create-a-file.liberty @@ -0,0 +1,12 @@ +nomainwin + +open "output.txt" for output as #f +close #f + +result = mkdir( "F:\RC") +if result <>0 then notice "Directory not created!": end + +open "F:\RC\output.txt" for output as #f +close #f + +end diff --git a/Task/Create-a-file/MAXScript/create-a-file.max b/Task/Create-a-file/MAXScript/create-a-file.max new file mode 100644 index 0000000000..f850a38579 --- /dev/null +++ b/Task/Create-a-file/MAXScript/create-a-file.max @@ -0,0 +1,8 @@ +-- Here +f = createFile "output.txt" +close f +makeDir (sysInfo.currentDir + "\docs") +-- System root +f = createFile "\output.txt" +close f +makeDir ("c:\docs") diff --git a/Task/Create-a-file/Mathematica/create-a-file.mathematica b/Task/Create-a-file/Mathematica/create-a-file.mathematica new file mode 100644 index 0000000000..9dbefdf7e2 --- /dev/null +++ b/Task/Create-a-file/Mathematica/create-a-file.mathematica @@ -0,0 +1,11 @@ +SetDirectory@NotebookDirectory[]; +t = OpenWrite["output.txt"] +Close[t] +s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"] +Close[s] + +(*In root directory*) +CreateDirectory["\\docs"] +(*In current operating directory*) +CreateDirectory[Directory[]<>"\\docs"] +(* "<>" is shorthand for "StringJoin[left,right]" *) diff --git a/Task/Create-a-file/Maxima/create-a-file.maxima b/Task/Create-a-file/Maxima/create-a-file.maxima new file mode 100644 index 0000000000..ce0dc73d27 --- /dev/null +++ b/Task/Create-a-file/Maxima/create-a-file.maxima @@ -0,0 +1,9 @@ +f: openw("/output.txt"); +close(f); + +f: openw("output.txt"); +close(f); + +/* Maxima has no function to create directories, but one can use the underlying Lisp system */ + +:lisp (mapcar #'ensure-directories-exist '("docs/" "/docs/")) diff --git a/Task/Create-a-file/Mirah/create-a-file.mirah b/Task/Create-a-file/Mirah/create-a-file.mirah new file mode 100644 index 0000000000..d158ec62e8 --- /dev/null +++ b/Task/Create-a-file/Mirah/create-a-file.mirah @@ -0,0 +1,5 @@ +import java.io.File + +File.new('output.txt').createNewFile() +File.new('docs').mkdir() +File.new("docs#{File.separator}output.txt").createNewFile() diff --git a/Task/Create-a-file/Modula-3/create-a-file.mod3 b/Task/Create-a-file/Modula-3/create-a-file.mod3 new file mode 100644 index 0000000000..83ef3ada0b --- /dev/null +++ b/Task/Create-a-file/Modula-3/create-a-file.mod3 @@ -0,0 +1,18 @@ +MODULE FileCreation EXPORTS Main; + +IMPORT FS, File, OSError, IO, Stdio; + +VAR file: File.T; + +BEGIN + TRY + file := FS.OpenFile("output.txt"); + file.close(); + FS.CreateDirectory("docs"); + file := FS.OpenFile("/output.txt"); + file.close(); + FS.CreateDirectory("/docs"); + EXCEPT + | OSError.E => IO.Put("Error creating file or directory.\n", Stdio.stderr); + END; +END FileCreation. diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Factor/create-a-two-dimensional-array-at-runtime.factor b/Task/Create-a-two-dimensional-array-at-runtime/Factor/create-a-two-dimensional-array-at-runtime.factor new file mode 100644 index 0000000000..b57cf62ea1 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Factor/create-a-two-dimensional-array-at-runtime.factor @@ -0,0 +1,14 @@ +USING: io kernel math.matrices math.parser prettyprint +sequences ; +IN: rosettacode.runtime2darray + +: set-Mi,j ( elt {i,j} matrix -- ) +[ first2 swap ] dip nth set-nth ; +: Mi,j ( {i,j} matrix -- elt ) +[ first2 swap ] dip nth nth ; + +: example ( -- ) +readln readln [ string>number ] bi@ zero-matrix ! create the array +[ [ 42 { 0 0 } ] dip set-Mi,j ] ! set the { 0 0 } element to 42 +[ [ { 0 0 } ] dip Mi,j . ] ! read the { 0 0 } element +bi ; diff --git a/Task/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.gap b/Task/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.gap new file mode 100644 index 0000000000..89bd294f5d --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/GAP/create-a-two-dimensional-array-at-runtime.gap @@ -0,0 +1,15 @@ +# Creating an array of 0 +a := NullMat(2, 2); +# [ [ 0, 0 ], [ 0, 0 ] ] + +# Some assignments +a[1][1] := 4; +a[1][2] := 5; +a[2][1] := 3; +a[2][2] := 4; + +a +# [ [ 4, 5 ], [ 3, 4 ] ] + +Determinant(a); +# 1 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Groovy/create-a-two-dimensional-array-at-runtime-1.groovy b/Task/Create-a-two-dimensional-array-at-runtime/Groovy/create-a-two-dimensional-array-at-runtime-1.groovy new file mode 100644 index 0000000000..c7ee3ab15f --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Groovy/create-a-two-dimensional-array-at-runtime-1.groovy @@ -0,0 +1,3 @@ +def make2d = { nrows, ncols -> + (0.. + def nrows = dim[0] as int + def ncols = dim[1] as int + + def a2d = make2d(nrows, ncols) + + def row = r.nextInt(nrows) + def col = r.nextInt(ncols) + def val = r.nextInt(nrows*ncols) + + a2d[row][col] = val + + println "a2d[${row}][${col}] == ${a2d[row][col]}" + + a2d.each { println it } + println() +} diff --git a/Task/Create-a-two-dimensional-array-at-runtime/HicEst/create-a-two-dimensional-array-at-runtime.hicest b/Task/Create-a-two-dimensional-array-at-runtime/HicEst/create-a-two-dimensional-array-at-runtime.hicest new file mode 100644 index 0000000000..a9e90f1b52 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/HicEst/create-a-two-dimensional-array-at-runtime.hicest @@ -0,0 +1,7 @@ +REAL :: array(1) + +DLG(NameEdit=rows, NameEdit=cols, Button='OK', TItle='Enter array dimensions') + +ALLOCATE(array, cols, rows) +array(1,1) = 1.234 +WRITE(Messagebox, Name) array(1,1) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/IDL/create-a-two-dimensional-array-at-runtime.idl b/Task/Create-a-two-dimensional-array-at-runtime/IDL/create-a-two-dimensional-array-at-runtime.idl new file mode 100644 index 0000000000..a86ddbc7b4 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/IDL/create-a-two-dimensional-array-at-runtime.idl @@ -0,0 +1,9 @@ +read, x, prompt='Enter x size:' +read, y, prompt='Enter y size:' +d = fltarr(x,y) + +d[3,4] = 5.6 +print,d[3,4] +;==> outputs 5.6 + +delvar, d diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Icon/create-a-two-dimensional-array-at-runtime.icon b/Task/Create-a-two-dimensional-array-at-runtime/Icon/create-a-two-dimensional-array-at-runtime.icon new file mode 100644 index 0000000000..9ec9b251c5 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Icon/create-a-two-dimensional-array-at-runtime.icon @@ -0,0 +1,13 @@ +procedure main(args) + nr := integer(args[1]) | 3 # Default to 3x3 + nc := integer(args[2]) | 3 + + A := list(nr) + every !A := list(nc) + + x := ?nr # Select a random element + y := ?nc + + A[x][y] := &pi + write("A[",x,"][",y,"] -> ",A[x][y]) +end diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-1.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-1.j new file mode 100644 index 0000000000..21f8814cfe --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-1.j @@ -0,0 +1,2 @@ + array1=:i. 3 4 NB. a 3 by 4 array with arbitrary values + array2=: 5 6 $ 2 NB. a 5 by 6 array where every value is the number 2 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-2.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-2.j new file mode 100644 index 0000000000..be10ae8265 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-2.j @@ -0,0 +1 @@ + array1=: 99 (<0 0)} array1 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-3.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-3.j new file mode 100644 index 0000000000..83d56c37de --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-3.j @@ -0,0 +1 @@ + (<0 0) { array1 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-4.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-4.j new file mode 100644 index 0000000000..05d5cd4db4 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-4.j @@ -0,0 +1 @@ + array1=: 0 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-5.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-5.j new file mode 100644 index 0000000000..298c97038a --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-5.j @@ -0,0 +1 @@ + erase'array1' diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-6.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-6.j new file mode 100644 index 0000000000..21eeece7ff --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-6.j @@ -0,0 +1,9 @@ +task=: verb define + assert. y -: 0 0 + , y NB. error except when 2 dimensions are specified + INIT=. 0 NB. array will be populated with this value + NEW=. 1 NB. we will later update one location with this value + ARRAY=. y $ INIT NB. here, we create our 2-dimensional array + INDEX=. < ? $ ARRAY NB. pick an arbitrary location within our array + ARRAY=. NEW INDEX} ARRAY NB. use our new value at that location + INDEX { ARRAY NB. and return the value from that location +) diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-7.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-7.j new file mode 100644 index 0000000000..e031098f90 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-7.j @@ -0,0 +1,2 @@ + task 99 99 +1 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-8.j b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-8.j new file mode 100644 index 0000000000..66373a1116 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/J/create-a-two-dimensional-array-at-runtime-8.j @@ -0,0 +1,3 @@ +'init new' =. ' ';'x' NB. literals +'init new' =. 1r2;2r3 NB. fractions +'init new' =. a: ; <<'Rosetta' NB. boxes diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Liberty-BASIC/create-a-two-dimensional-array-at-runtime.liberty b/Task/Create-a-two-dimensional-array-at-runtime/Liberty-BASIC/create-a-two-dimensional-array-at-runtime.liberty new file mode 100644 index 0000000000..c7df5e9a3c --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Liberty-BASIC/create-a-two-dimensional-array-at-runtime.liberty @@ -0,0 +1,9 @@ +input "Enter first array dimension "; a +input "Enter second array dimension "; b + +dim array( a, b) + +array( 1, 1) = 123.456 +print array( 1, 1) + +end diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Logo/create-a-two-dimensional-array-at-runtime.logo b/Task/Create-a-two-dimensional-array-at-runtime/Logo/create-a-two-dimensional-array-at-runtime.logo new file mode 100644 index 0000000000..1d32f5ec12 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Logo/create-a-two-dimensional-array-at-runtime.logo @@ -0,0 +1,3 @@ +make "a2 mdarray [5 5] +mdsetitem [1 1] :a2 0 ; by default, arrays are indexed starting at 1 +print mditem [1 1] :a2 ; 0 diff --git a/Task/Create-a-two-dimensional-array-at-runtime/MAXScript/create-a-two-dimensional-array-at-runtime.max b/Task/Create-a-two-dimensional-array-at-runtime/MAXScript/create-a-two-dimensional-array-at-runtime.max new file mode 100644 index 0000000000..b1d94a2982 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/MAXScript/create-a-two-dimensional-array-at-runtime.max @@ -0,0 +1,11 @@ +a = getKBValue prompt:"Enter first dimension:" +b = getKBValue prompt:"Enter second dimension:" +arr1 = #() +arr2 = #() +arr2[b] = undefined +for i in 1 to a do +( + append arr1 (deepCopy arr2) +) +arr1[a][b] = 1 +print arr1[a][b] diff --git a/Task/Create-a-two-dimensional-array-at-runtime/MUMPS/create-a-two-dimensional-array-at-runtime.mumps b/Task/Create-a-two-dimensional-array-at-runtime/MUMPS/create-a-two-dimensional-array-at-runtime.mumps new file mode 100644 index 0000000000..8e3c9dcb34 --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/MUMPS/create-a-two-dimensional-array-at-runtime.mumps @@ -0,0 +1,11 @@ +ARA2D + NEW X,Y,A,I,J +REARA + WRITE !,"Please enter two positive integers" + READ:10 !,"First: ",X + READ:10 !,"Second: ",Y + GOTO:(X\1'=X)!(X<0)!(Y\1'=Y)!(Y<0) REARA + FOR I=1:1:X FOR J=1:1:Y SET A(I,J)=I+J + WRITE !,"The corner of X and Y is ",A(X,Y) + KILL X,Y,A,I,J + QUIT diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Maple/create-a-two-dimensional-array-at-runtime.maple b/Task/Create-a-two-dimensional-array-at-runtime/Maple/create-a-two-dimensional-array-at-runtime.maple new file mode 100644 index 0000000000..30ea4b7e1a --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Maple/create-a-two-dimensional-array-at-runtime.maple @@ -0,0 +1,12 @@ +> a := Array( 1 .. 3, 1 .. 4 ): # initialised to 0s +> a[1,1] := 1: # assign an element +> a[2,3] := 4: # assign an element +> a; # display the array + [1 0 0 0] + [ ] + [0 0 4 0] + [ ] + [0 0 0 0] + +> a := 'a': # unassign the name +> gc(); # force a garbage collection; may or may not actually collect the array, but it will be eventually diff --git a/Task/Create-a-two-dimensional-array-at-runtime/Mathematica/create-a-two-dimensional-array-at-runtime.mathematica b/Task/Create-a-two-dimensional-array-at-runtime/Mathematica/create-a-two-dimensional-array-at-runtime.mathematica new file mode 100644 index 0000000000..b933a187fe --- /dev/null +++ b/Task/Create-a-two-dimensional-array-at-runtime/Mathematica/create-a-two-dimensional-array-at-runtime.mathematica @@ -0,0 +1,4 @@ +arrayFun[m_Integer,n_Integer]:=Module[{array=ConstantArray[0,{m,n}]}, + array[[1,1]]=RandomReal[]; + array[[1,1]] +] diff --git a/Task/Create-an-HTML-table/Groovy/create-an-html-table.groovy b/Task/Create-an-HTML-table/Groovy/create-an-html-table.groovy new file mode 100644 index 0000000000..b52afc6126 --- /dev/null +++ b/Task/Create-an-HTML-table/Groovy/create-an-html-table.groovy @@ -0,0 +1,20 @@ +import groovy.xml.MarkupBuilder + +def createTable(columns, rowCount) { + def writer = new StringWriter() + new MarkupBuilder(writer).table(style: 'border:1px solid;text-align:center;') { + tr { + th() + columns.each { title -> th(title)} + } + (1..rowCount).each { row -> + tr { + td(row) + columns.each { td((Math.random() * 9999) as int ) } + } + } + } + writer.toString() +} + +println createTable(['X', 'Y', 'Z'], 3) diff --git a/Task/Create-an-HTML-table/Icon/create-an-html-table-1.icon b/Task/Create-an-HTML-table/Icon/create-an-html-table-1.icon new file mode 100644 index 0000000000..f461f0883f --- /dev/null +++ b/Task/Create-an-HTML-table/Icon/create-an-html-table-1.icon @@ -0,0 +1,10 @@ +procedure main() +printf("\n ") +every r := 1 to 4 do { + printf("\n ",r) + every 1 to 3 do printf("",?9999) # random 4 digit numbers per cell + } +printf("\n
XYZ
%d%d
\n") +end + +link printf diff --git a/Task/Create-an-HTML-table/Icon/create-an-html-table-2.icon b/Task/Create-an-HTML-table/Icon/create-an-html-table-2.icon new file mode 100644 index 0000000000..173b2e0f55 --- /dev/null +++ b/Task/Create-an-HTML-table/Icon/create-an-html-table-2.icon @@ -0,0 +1,7 @@ + + + + + + +
XYZ
1312932947013
250451695761
370019634183
4169511581240
diff --git a/Task/Create-an-HTML-table/J/create-an-html-table-1.j b/Task/Create-an-HTML-table/J/create-an-html-table-1.j new file mode 100644 index 0000000000..f12aa9c044 --- /dev/null +++ b/Task/Create-an-HTML-table/J/create-an-html-table-1.j @@ -0,0 +1,10 @@ +ele=:4 :0 + nm=. x-.LF + lf=. x-.nm + ;('<',nm,'>') ,L:0 y ,L:0 '',lf +) + +hTbl=:4 :0 + rows=. 'td' <@ele"1 ":&.>y + 'table' ele ('tr',LF) <@ele ('th' ele x); rows +) diff --git a/Task/Create-an-HTML-table/J/create-an-html-table-2.j b/Task/Create-an-HTML-table/J/create-an-html-table-2.j new file mode 100644 index 0000000000..9632196d7a --- /dev/null +++ b/Task/Create-an-HTML-table/J/create-an-html-table-2.j @@ -0,0 +1,8 @@ + ('';;:'X Y Z') hTbl ":&.>(i.5),.i.5 3 + + + + + + +
XYZ
0012
1345
2678
391011
4121314
diff --git a/Task/Create-an-HTML-table/J/create-an-html-table-3.j b/Task/Create-an-HTML-table/J/create-an-html-table-3.j new file mode 100644 index 0000000000..a1f527d92b --- /dev/null +++ b/Task/Create-an-HTML-table/J/create-an-html-table-3.j @@ -0,0 +1 @@ +jhtml ('';;:'X Y Z') hTbl ":&.>(i.5),.i.5 3 diff --git a/Task/Create-an-HTML-table/Liberty-BASIC/create-an-html-table.liberty b/Task/Create-an-HTML-table/Liberty-BASIC/create-an-html-table.liberty new file mode 100644 index 0000000000..337a16b085 --- /dev/null +++ b/Task/Create-an-HTML-table/Liberty-BASIC/create-an-html-table.liberty @@ -0,0 +1,40 @@ + nomainwin + + quote$ =chr$( 34) + + html$ ="" + + html$ =html$ +"" + + for i =1 to 4 + d1$ =str$( i) + d2$ =str$( int( 10000 *rnd( 1))) + d3$ =str$( int( 10000 *rnd( 1))) + d4$ =str$( int( 10000 *rnd( 1))) + html$ =html$ +"" + next i + + html$ =html$ +"
X Y Z
"; d1$; " " +d2$ +" " +d3$ +" " +d4$ +"
" + + html$ =html$ +"" + + open "table.html" for output as #o + #o html$; + close #o + + address$ ="table.html" + run "explorer.exe "; address$ + + timer 5000, [on] + wait + [on] + timer 0 + + kill "table.html" + + wait + +sub quit w$ + close #w$ + end +end sub diff --git a/Task/Create-an-HTML-table/Mathematica/create-an-html-table.mathematica b/Task/Create-an-HTML-table/Mathematica/create-an-html-table.mathematica new file mode 100644 index 0000000000..d92eebe26a --- /dev/null +++ b/Task/Create-an-HTML-table/Mathematica/create-an-html-table.mathematica @@ -0,0 +1,4 @@ +x := RandomInteger[10]; +Print["", "\n",""] +Scan[Print[""] & , Range[3]] +Print["
XYZ
", #, "", x, "", x, "","
"] diff --git a/Task/Create-an-HTML-table/Modula-2/create-an-html-table.mod2 b/Task/Create-an-HTML-table/Modula-2/create-an-html-table.mod2 new file mode 100644 index 0000000000..9a769af1d4 --- /dev/null +++ b/Task/Create-an-HTML-table/Modula-2/create-an-html-table.mod2 @@ -0,0 +1,47 @@ +MODULE testCGI; + +FROM InOut IMPORT WriteCard, WriteLn, WriteString, WriteBf; +FROM Arguments IMPORT ArgTable, GetEnv; +FROM Strings IMPORT Assign, Length, String; + +VAR EnvVars : ArgTable; + +PROCEDURE ReadEnvVar; + +VAR Value : String; + i : CARDINAL; + +BEGIN + WriteString (''); + WriteString (''); + i := 0; + LOOP + IF EnvVars^ [i] = NIL THEN EXIT END; + Assign (Value, EnvVars^ [i]^); + WriteString ('"); + WriteLn; + INC (i) + END; + WriteString("
IndexLengthContent
'); + WriteCard (i, 2); + WriteString (''); + WriteCard (Length (Value), 3); + WriteString (''); WriteString (Value); + WriteString ("
"); +END ReadEnvVar; + +BEGIN + GetEnv (EnvVars); + WriteString ('Content-type:text/html'); + WriteLn; + WriteLn; + WriteString (''); + WriteString ('CGI with the Mocka Modula-2 compiler'); + WriteString (''); + WriteLn; + WriteString ('

CGI environment passed along by your browser

'); + ReadEnvVar; + WriteString (''); + WriteLn; + WriteBf +END testCGI. diff --git a/Task/Cut-a-rectangle/J/cut-a-rectangle-1.j b/Task/Cut-a-rectangle/J/cut-a-rectangle-1.j new file mode 100644 index 0000000000..a8e8a46ad9 --- /dev/null +++ b/Task/Cut-a-rectangle/J/cut-a-rectangle-1.j @@ -0,0 +1,7 @@ +init=: - {. 1: NB. initial state: 1 square choosen +prop=: < {:,~2 ~:/\ ] NB. propagate: neighboring squares (vertically) +poss=: I.@,@(prop +. prop"1 +. prop&.|. +. prop&.|."1) +keep=: poss -. <:@#@, - I.@, NB. symmetrically valid possibilities +N=: <:@-:@#@, NB. how many neighbors to add +step=: [: ~.@; <@(((= i.@$) +. ])"0 _~ keep)"2 +all=: step^:N@init diff --git a/Task/Cut-a-rectangle/J/cut-a-rectangle-2.j b/Task/Cut-a-rectangle/J/cut-a-rectangle-2.j new file mode 100644 index 0000000000..43b89f64d4 --- /dev/null +++ b/Task/Cut-a-rectangle/J/cut-a-rectangle-2.j @@ -0,0 +1,25 @@ + '.#' <"2@:{~ all 3 4 +┌────┬────┬────┬────┬────┬────┬────┬────┬────┐ +│.###│.###│..##│...#│...#│....│....│....│....│ +│.#.#│..##│..##│..##│.#.#│..##│.#.#│#.#.│##..│ +│...#│...#│..##│.###│.###│####│####│####│####│ +└────┴────┴────┴────┴────┴────┴────┴────┴────┘ + $ all 4 5 +39 4 5 + 3 13$ '.#' <"2@:{~ all 4 5 +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│.####│.####│.####│.####│.####│.####│..###│..###│..###│..###│..###│...##│...##│ +│.####│.##.#│.#..#│..###│...##│....#│.####│.##.#│..###│...##│....#│.####│..###│ +│....#│.#..#│.##.#│...##│..###│.####│....#│.#..#│...##│..###│.####│....#│...##│ +│....#│....#│....#│....#│....#│....#│...##│...##│...##│...##│...##│..###│..###│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│...##│...##│...##│....#│....#│....#│....#│....#│....#│.....│.....│.....│.....│ +│...##│....#│.#..#│.####│..###│...##│....#│.#..#│.##.#│.####│..###│...##│....#│ +│..###│.####│.##.#│....#│...##│..###│.####│.##.#│.#..#│....#│...##│..###│.####│ +│..###│..###│..###│.####│.####│.####│.####│.####│.####│#####│#####│#####│#####│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│.....│.....│.....│.....│.....│.....│.....│.....│.....│.....│.....│.....│.....│ +│.#..#│.##.#│..##.│...#.│.....│.#...│.##..│#.##.│#..#.│#....│##...│###..│####.│ +│.##.#│.#..#│#..##│#.###│#####│###.#│##..#│#..#.│#.##.│####.│###..│##...│#....│ +│#####│#####│#####│#####│#####│#####│#####│#####│#####│#####│#####│#####│#####│ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/Task/Date-format/Factor/date-format.factor b/Task/Date-format/Factor/date-format.factor new file mode 100644 index 0000000000..d78e43924f --- /dev/null +++ b/Task/Date-format/Factor/date-format.factor @@ -0,0 +1,4 @@ +USING: formatting calendar io ; + +now "%Y-%m-%d" strftime print +now "%A, %B %d, %Y" strftime print diff --git a/Task/Date-format/Fantom/date-format.fantom b/Task/Date-format/Fantom/date-format.fantom new file mode 100644 index 0000000000..8c7bd34c37 --- /dev/null +++ b/Task/Date-format/Fantom/date-format.fantom @@ -0,0 +1,4 @@ +fansh> Date.today.toLocale("YYYY-MM-DD") +2011-02-24 +fansh> Date.today.toLocale("WWWW, MMMM DD, YYYY") +Thursday, February 24, 2011 diff --git a/Task/Date-format/Frink/date-format.frink b/Task/Date-format/Frink/date-format.frink new file mode 100644 index 0000000000..5c91979897 --- /dev/null +++ b/Task/Date-format/Frink/date-format.frink @@ -0,0 +1,2 @@ +println[now[] -> ### yyyy-MM-dd ###] +println[now[] -> ### EEEE, MMMM d, yyyy ###] diff --git a/Task/Date-format/Groovy/date-format-1.groovy b/Task/Date-format/Groovy/date-format-1.groovy new file mode 100644 index 0000000000..df94b023ab --- /dev/null +++ b/Task/Date-format/Groovy/date-format-1.groovy @@ -0,0 +1,2 @@ +def isoFormat = { date -> date.format("yyyy-MM-dd") } +def longFormat = { date -> date.format("EEEE, MMMM dd, yyyy") } diff --git a/Task/Date-format/Groovy/date-format-2.groovy b/Task/Date-format/Groovy/date-format-2.groovy new file mode 100644 index 0000000000..4db9b6176e --- /dev/null +++ b/Task/Date-format/Groovy/date-format-2.groovy @@ -0,0 +1,3 @@ +def now = new Date() +println isoFormat(now) +println longFormat(now) diff --git a/Task/Date-format/HicEst/date-format-1.hicest b/Task/Date-format/HicEst/date-format-1.hicest new file mode 100644 index 0000000000..a6a2d0fa4b --- /dev/null +++ b/Task/Date-format/HicEst/date-format-1.hicest @@ -0,0 +1,13 @@ + CHARACTER string*40 + + WRITE(Text=string, Format='UCCYY-MM-DD') 0 ! string: 2010-03-13 + + ! the U-format to write date and time uses ',' to separate additional output formats + ! we therefore use ';' in this example and change it to ',' below: + WRITE(Text=string,Format='UWWWWWWWWW; MM DD; CCYY') 0 ! string = "Saturday ; 03 13; 2010" + READ(Text=string) month ! first numeric value = 3 (no literal month name available) + EDIT(Text='January,February,March,April,May,June,July,August,September,October,November,December', ITeM=month, Parse=cMonth) ! cMonth = "March" + ! change now string = "Saturday ; 03 13; 2010" to "Saturday, March 13, 2010": + EDIT(Text=string, Right=' ', Mark1, Right=';', Right=3, Mark2, Delete, Insert=', '//cMonth, Right=';', RePLaceby=',') + + END diff --git a/Task/Date-format/HicEst/date-format-2.hicest b/Task/Date-format/HicEst/date-format-2.hicest new file mode 100644 index 0000000000..8065d906fd --- /dev/null +++ b/Task/Date-format/HicEst/date-format-2.hicest @@ -0,0 +1,4 @@ +procedure main() +write(map(&date,"/","-")) +write(&dateline ? tab(find(&date[1:5])+4)) +end diff --git a/Task/Date-format/J/date-format-1.j b/Task/Date-format/J/date-format-1.j new file mode 100644 index 0000000000..1f26762e9b --- /dev/null +++ b/Task/Date-format/J/date-format-1.j @@ -0,0 +1,2 @@ + 6!:0 'YYYY-MM-DD' +2010-08-19 diff --git a/Task/Date-format/J/date-format-2.j b/Task/Date-format/J/date-format-2.j new file mode 100644 index 0000000000..490aafef8f --- /dev/null +++ b/Task/Date-format/J/date-format-2.j @@ -0,0 +1,6 @@ +require 'dates system/packages/misc/datefmt.ijs' +days=:;:'Sunday Monday Tuesday Wednesday Thursday Friday Saturday' +fmtDate=: [:((days ;@{~ weekday),', ',ms0) 3 {.] + + fmtDate 6!:0 '' +Thursday, August 19, 2010 diff --git a/Task/Date-format/Joy/date-format.joy b/Task/Date-format/Joy/date-format.joy new file mode 100644 index 0000000000..337328869c --- /dev/null +++ b/Task/Date-format/Joy/date-format.joy @@ -0,0 +1,9 @@ +DEFINE weekdays == [ "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" ]; + months == [ "January" "February" "March" "April" "May" "June" "July" "August" + "September" "October" "November" "December" ]. + +time localtime [ [0 at 'd 4 4 format] ["-"] [1 at 'd 2 2 format] ["-"] [2 at 'd 2 2 format] ] +[i] map [putchars] step '\n putch pop. + +time localtime [ [8 at pred weekdays of] [", "] [1 at pred months of] [" "] [2 at 'd 1 1 format] +[", "] [0 at 'd 4 4 format] ] [i] map [putchars] step '\n putch pop. diff --git a/Task/Date-format/Liberty-BASIC/date-format.liberty b/Task/Date-format/Liberty-BASIC/date-format.liberty new file mode 100644 index 0000000000..bddf99b4f1 --- /dev/null +++ b/Task/Date-format/Liberty-BASIC/date-format.liberty @@ -0,0 +1,23 @@ +'Display the current date in the formats of "2007-11-10" +d$=date$("yyyy/mm/dd") +print word$(d$,1,"/")+"-"+word$(d$,2,"/")+"-"+word$(d$,3,"/") + +'and "Sunday, November 10, 2007". +day$(0)="Tuesday" +day$(1)="Wednesday" +day$(2)="Thursday" +day$(3)="Friday" +day$(4)="Saturday" +day$(5)="Sunday" +day$(6)="Monday" +theDay = date$("days") mod 7 +print day$(theDay);", ";date$() + +' month in full +year=val(word$(d$,1,"/")) +month=val(word$(d$,2,"/")) +day=val(word$(d$,3,"/")) +weekDay$="Tuesday Wednesday Thursday Friday Saturday Sunday Monday" +monthLong$="January February March April May June July August September October November December" + +print word$(weekDay$,theDay+1);", ";word$(monthLong$,month);" ";day;", ";year diff --git a/Task/Date-format/MUMPS/date-format-1.mumps b/Task/Date-format/MUMPS/date-format-1.mumps new file mode 100644 index 0000000000..5010e2a68e --- /dev/null +++ b/Task/Date-format/MUMPS/date-format-1.mumps @@ -0,0 +1,4 @@ +DTZ + WRITE !,"Date format 3: ",$ZDATE($H,3) + WRITE !,"Or ",$ZDATE($H,12),", ",$ZDATE($H,9) + QUIT diff --git a/Task/Date-format/MUMPS/date-format-2.mumps b/Task/Date-format/MUMPS/date-format-2.mumps new file mode 100644 index 0000000000..22f68bb234 --- /dev/null +++ b/Task/Date-format/MUMPS/date-format-2.mumps @@ -0,0 +1,21 @@ +DTM(H) + ;You can pass an integer, but the default is to use today's value + SET:$DATA(H)=0 H=$HOROLOG + NEW Y,YR,RD,MC,MO,DA,MN,DN,DOW + SET MN="January,February,March,April,May,June,July,August,September,October,November,December" + SET DN="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday" + SET MC="31,28,31,30,31,30,31,31,30,31,30,31" + SET Y=+H\365.25 ;This shouldn't be an approximation in production code + SET YR=Y+1841 ;Y is the offset from the epoch in years + SET RD=((+H-(Y*365.25))+1)\1 ;How far are we into the year? + SET $P(MC,",",2)=$S(((YR#4=0)&(YR#100'=0))!((YR#100=0)&(YR#400=0))=0:28,1:29) ;leap year correction + SET MO=1,RE=RD FOR QUIT:RE<=$P(MC,",",MO) SET RE=RE-$P(MC,",",MO),MO=MO+1 + SET DA=RE+1 + SET DOW=(H#7)+5 ;Fencepost issue - the first piece is 1 + ;add padding as needed + SET:$L(MO)<2 MO="0"_MO + SET:$L(DA)<2 DA="0"_DA + WRITE !,YR,"-",MO,"-",DA + WRITE !,$P(DN,",",DOW),", ",$P(MN,",",MO)," ",DA,", ",YR + KILL Y,YR,RD,MC,MO,DA,MN,DN,DOW + QUIT diff --git a/Task/Date-format/Mathematica/date-format.mathematica b/Task/Date-format/Mathematica/date-format.mathematica new file mode 100644 index 0000000000..56c945edf3 --- /dev/null +++ b/Task/Date-format/Mathematica/date-format.mathematica @@ -0,0 +1,2 @@ +DateString[{"Year", "-", "Month", "-", "Day"}] +DateString[{"DayName", ", ", "MonthName", " ", "Day", ", ", "Year"}] diff --git a/Task/Date-manipulation/Fantom/date-manipulation.fantom b/Task/Date-manipulation/Fantom/date-manipulation.fantom new file mode 100644 index 0000000000..b6ba781dc8 --- /dev/null +++ b/Task/Date-manipulation/Fantom/date-manipulation.fantom @@ -0,0 +1,7 @@ +fansh> d := DateTime.fromLocale("March 7 2009 7:30pm EST", "MMMM D YYYY h:mmaa zzz") +fansh> d +2009-03-07T19:30:00-05:00 EST +fansh> d + 12hr +2009-03-08T07:30:00-05:00 EST +fansh> (d+12hr).toTimeZone(TimeZone("London")) // the extra credit! +2009-03-08T12:30:00Z London diff --git a/Task/Date-manipulation/Frink/date-manipulation.frink b/Task/Date-manipulation/Frink/date-manipulation.frink new file mode 100644 index 0000000000..c15753b6bd --- /dev/null +++ b/Task/Date-manipulation/Frink/date-manipulation.frink @@ -0,0 +1,4 @@ +### MMM dd yyyy h:mma ### +d = parseDate["March 7 2009 7:30pm EST"] +println[d + 12 hours -> Eastern] +println[d + 12 hours -> Switzerland] // Extra credit diff --git a/Task/Date-manipulation/Groovy/date-manipulation.groovy b/Task/Date-manipulation/Groovy/date-manipulation.groovy new file mode 100644 index 0000000000..8732a3f6cc --- /dev/null +++ b/Task/Date-manipulation/Groovy/date-manipulation.groovy @@ -0,0 +1,12 @@ +import org.joda.time.* +import java.text.* + +def dateString = 'March 7 2009 7:30pm EST' + +def sdf = new SimpleDateFormat('MMMM d yyyy h:mma zzz') + +DateTime dt = new DateTime(sdf.parse(dateString)) + +println (dt) +println (dt.plusHours(12)) +println (dt.plusHours(12).withZone(DateTimeZone.UTC)) diff --git a/Task/Date-manipulation/HicEst/date-manipulation.hicest b/Task/Date-manipulation/HicEst/date-manipulation.hicest new file mode 100644 index 0000000000..ddac7e219f --- /dev/null +++ b/Task/Date-manipulation/HicEst/date-manipulation.hicest @@ -0,0 +1,10 @@ + CHARACTER date="March 7 2009 7:30pm EST", am_pm, result*20 + + EDIT(Text=date, Parse=cMonth, GetPosition=next) + month = 1 + EDIT(Text='January,February,March,April,May,June,July,August,September,October,November,December', Right=cMonth, Count=',' ) + READ(Text=date(next:)) day, year, hour, minute, am_pm + hour = hour + 12*(am_pm == 'p') + TIME(MOnth=month, Day=day, Year=year, Hour=hour, MInute=minute, TO, Excel=xls_day) + WRITE(Text=result, Format="UWWW CCYY-MM-DD HH:mm") xls_day + 0.5 + ! result = "Sun 2009-03-08 07:30" + END diff --git a/Task/Date-manipulation/Icon/date-manipulation.icon b/Task/Date-manipulation/Icon/date-manipulation.icon new file mode 100644 index 0000000000..9eb2d6774c --- /dev/null +++ b/Task/Date-manipulation/Icon/date-manipulation.icon @@ -0,0 +1,66 @@ +link datetime + +procedure main() +write("input = ",s := "March 7 2009 7:30pm EST" ) +write("+12 hours = ",SecToTZDateLine(s := TZDateLineToSec(s) + 12*3600,"EST")) +write(" = ",SecToTZDateLine(s,"UTC")) +write(" = ",SecToTZDateLine(s,"NST")) +end + +procedure SecToTZDateLine(s,tz) #: returns dateline + time zone given seconds +return NormalizedDate(SecToDateLine(s+\(_TZdata("table")[\tz|"UTC"]))||" "|| tz) +end + +procedure TZDateLineToSec(s) #: returns seconds given dateline (and time zone) + return ( + NormalizedDate(s) ? ( + d := tab(find("am"|"pm")+2),tab(many('\t ,')), + tz := \_TZdata("table")[tab(0)] + ), + DateLineToSec(d) - tz) +end + +procedure NormalizedDate(s) #: returns a consistent dateline +static D,M +initial { + D := ["Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"] + M := ["January","February","March","April","May","June", + "July","August","September","October","November","December"] + } + +map(s) ? { # parse and build consistent dateline + ds := 1(x := !D, =map(x)) | "" # Weekday + ds ||:= 1(", ", tab(many('\t ,')|&pos)) + ds ||:= 1(x := !M, =map(x)) | fail # Month + ds ||:= 1(" ", tab(many('\t ,')|&pos)) + ds ||:= tab(many(&digits)) | fail # day + ds ||:= 1(", ", tab(many('\t ,'))) | fail + ds ||:= tab(many(&digits)) | fail # year + ds ||:= 1(" ", tab(many('\t ,'))) | fail + ds ||:= tab(many(&digits))||(=":"||tab(many(&digits))|&null) | fail # time + ds ||:= 1(" ", tab(many('\t ,')|&pos)) + ds ||:= =("am"|"pm") | fail # halfday + ds ||:= 1(" ", tab(many('\t ,')|&pos)) + tz := map(=!_TZdata("list"),&lcase,&ucase) + } + +if ds[1] == "," then + ds := SecToDateLine(DateLineToSec("Sunday"||ds)) # get IPL to fix weekday + +return ds ||:= " " || \tz|"UTC" +end + +procedure _TZdata(x) #: internal return TZ data (demo version incomplete) +static TZ,AZ +initial { + TZ := table() + AZ := [] + "UTC/0;ACDT/+10.5;CET/1;EST/-5;NPT/+5.75;NST/-3.5;PST/-8;" ? + while ( a := tab(find("/")), move(1), o := tab(find(";")), move(1) ) do { + TZ[map(a)] := TZ[a] := integer(3600*o) + put(AZ,a,map(a)) + } + every TZ[&null|""] := TZ["UTC"] + } +return case x of { "list" : AZ ; "table" : TZ } +end diff --git a/Task/Date-manipulation/Mathematica/date-manipulation.mathematica b/Task/Date-manipulation/Mathematica/date-manipulation.mathematica new file mode 100644 index 0000000000..b9813d3f9b --- /dev/null +++ b/Task/Date-manipulation/Mathematica/date-manipulation.mathematica @@ -0,0 +1,2 @@ +dstr = "March 7 2009 7:30pm EST"; +DateString[DatePlus[dstr, {12, "Hour"}], {"DayName", " ", "MonthName", " ", "Day", " ", "Year", " ", "Hour24", ":", "Minute", "AMPM"}] diff --git a/Task/Day-of-the-week/Factor/day-of-the-week.factor b/Task/Day-of-the-week/Factor/day-of-the-week.factor new file mode 100644 index 0000000000..7924c94913 --- /dev/null +++ b/Task/Day-of-the-week/Factor/day-of-the-week.factor @@ -0,0 +1,2 @@ +USING: calendar math.ranges prettyprint sequences ; +2008 2121 [a,b] [ 12 25 sunday? ] filter . diff --git a/Task/Day-of-the-week/GAP/day-of-the-week.gap b/Task/Day-of-the-week/GAP/day-of-the-week.gap new file mode 100644 index 0000000000..b76532ba80 --- /dev/null +++ b/Task/Day-of-the-week/GAP/day-of-the-week.gap @@ -0,0 +1,13 @@ +xmas := function(a, b) + local y, v; + v := [ ]; + for y in [a .. b] do + if WeekDay([25, 12, y]) = "Sun" then + Add(v, y); + fi; + od; + return v; +end; + +xmas(2008, 2121); +# [ 2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118 ] diff --git a/Task/Day-of-the-week/Groovy/day-of-the-week-1.groovy b/Task/Day-of-the-week/Groovy/day-of-the-week-1.groovy new file mode 100644 index 0000000000..fb76159c14 --- /dev/null +++ b/Task/Day-of-the-week/Groovy/day-of-the-week-1.groovy @@ -0,0 +1 @@ +def yuletide = { start, stop -> (start..stop).findAll { Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" } } diff --git a/Task/Day-of-the-week/Groovy/day-of-the-week-2.groovy b/Task/Day-of-the-week/Groovy/day-of-the-week-2.groovy new file mode 100644 index 0000000000..c183491436 --- /dev/null +++ b/Task/Day-of-the-week/Groovy/day-of-the-week-2.groovy @@ -0,0 +1 @@ +println yuletide(2008, 2121) diff --git a/Task/Day-of-the-week/HicEst/day-of-the-week-1.hicest b/Task/Day-of-the-week/HicEst/day-of-the-week-1.hicest new file mode 100644 index 0000000000..65b9f405d8 --- /dev/null +++ b/Task/Day-of-the-week/HicEst/day-of-the-week-1.hicest @@ -0,0 +1,6 @@ +DO year = 1, 1000000 + TIME(Year=year, MOnth=12, Day=25, TO, WeekDay=weekday) + IF( weekday == 7) WRITE(StatusBar) year +ENDDO + +END diff --git a/Task/Day-of-the-week/HicEst/day-of-the-week-2.hicest b/Task/Day-of-the-week/HicEst/day-of-the-week-2.hicest new file mode 100644 index 0000000000..2325d59a6f --- /dev/null +++ b/Task/Day-of-the-week/HicEst/day-of-the-week-2.hicest @@ -0,0 +1,6 @@ +link datetime + +procedure main() +writes("December 25th is a Sunday in: ") +every writes((dayoweek(25,12,y := 2008 to 2122)=="Sunday",y)," ") +end diff --git a/Task/Day-of-the-week/HicEst/day-of-the-week-3.hicest b/Task/Day-of-the-week/HicEst/day-of-the-week-3.hicest new file mode 100644 index 0000000000..a001c8431e --- /dev/null +++ b/Task/Day-of-the-week/HicEst/day-of-the-week-3.hicest @@ -0,0 +1,43 @@ +procedure dayoweek(day, month, year) #: day of the week + static d_code, c_code, m_code, ml_code, y, C, M, Y + + initial { + d_code := ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] + + c_code := table() + c_code[16] := c_code[20] := 0 + c_code[17] := c_code[21] := 6 + c_code[18] := c_code[22] := 4 + c_code[19] := c_code[23] := 2 + + m_code := table() + m_code[1] := m_code["January"] := 1 + m_code[2] := m_code["February"] := 4 + m_code[3] := m_code["March"] := 4 + m_code[4] := m_code["April"] := 0 + m_code[5] := m_code["May"] := 2 + m_code[6] := m_code["June"] := 5 + m_code[7] := m_code["July"] := 0 + m_code[8] := m_code["August"] := 3 + m_code[9] := m_code["September"] := 6 + m_code[10] := m_code["October"] := 1 + m_code[11] := m_code["November"] := 4 + m_code[12] := m_code["December"] := 6 + + ml_code := copy(m_code) + ml_code[1] := ml_code["January"] := 0 + ml_code[2] := ml_code["February"] := 3 + } + + if year < 1600 then stop("*** can't compute day of week that far back") + if year > 2299 then stop("*** can't compute day of week that far ahead") + + C := c_code[(year / 100) + 1] + y := year % 100 + Y := (y / 12) + (y % 12) + ((y % 12) / 4) + month := integer(month) + M := if (year % 4) = 0 then ml_code[month] else m_code[month] + + return d_code[(C + Y + M + day) % 7 + 1] + +end diff --git a/Task/Day-of-the-week/J/day-of-the-week.j b/Task/Day-of-the-week/J/day-of-the-week.j new file mode 100644 index 0000000000..adfc6e0480 --- /dev/null +++ b/Task/Day-of-the-week/J/day-of-the-week.j @@ -0,0 +1,4 @@ + load 'dates' NB. provides verb 'weekday' + xmasSunday=: #~ 0 = [: weekday 12 25 ,~"1 0 ] NB. returns years where 25 Dec is a Sunday + xmasSunday 2008 + i.114 NB. check years from 2008 to 2121 +2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118 diff --git a/Task/Day-of-the-week/K/day-of-the-week.k b/Task/Day-of-the-week/K/day-of-the-week.k new file mode 100644 index 0000000000..ac0f409d1d --- /dev/null +++ b/Task/Day-of-the-week/K/day-of-the-week.k @@ -0,0 +1,3 @@ + wd:{(__jd x)!7} / Julian day count, Sun=6 + y@&6={wd 1225+x*10000}'y:2008+!114 +2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118 diff --git a/Task/Day-of-the-week/Liberty-BASIC/day-of-the-week.liberty b/Task/Day-of-the-week/Liberty-BASIC/day-of-the-week.liberty new file mode 100644 index 0000000000..c113f000de --- /dev/null +++ b/Task/Day-of-the-week/Liberty-BASIC/day-of-the-week.liberty @@ -0,0 +1,14 @@ + count = 0 + for year = 2008 to 2121 + dateString$="12/25/";year + dayNumber=date$(dateString$) + + if dayNumber mod 7 = 5 then + count = count + 1 + print dateString$ + end if + + next year + + print count; " years when Christmas Day falls on a Sunday" + end diff --git a/Task/Day-of-the-week/M4/day-of-the-week.m4 b/Task/Day-of-the-week/M4/day-of-the-week.m4 new file mode 100644 index 0000000000..2d8e4499d6 --- /dev/null +++ b/Task/Day-of-the-week/M4/day-of-the-week.m4 @@ -0,0 +1,19 @@ +divert(-1) + +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')') + +dnl julian day number corresponding to December 25th of given year +define(`julianxmas', + `define(`yrssince0',eval($1+4712))`'define(`noOfLpYrs', + eval((yrssince0+3)/4))`'define(`jd', + eval(365*yrssince0+noOfLpYrs-10-($1-1501)/100+($1-1201)/400+334+25-1))`' + ifelse(eval($1%4==0 && ($1%100!=0 || $1%400==0)),1, + `define(`jd',incr(jd))')`'jd') + +divert + +for(`yr',2008,2121, + `ifelse(eval(julianxmas(yr)%7==6),1,`yr ')') diff --git a/Task/Day-of-the-week/MUMPS/day-of-the-week.mumps b/Task/Day-of-the-week/MUMPS/day-of-the-week.mumps new file mode 100644 index 0000000000..d0bfdc7eca --- /dev/null +++ b/Task/Day-of-the-week/MUMPS/day-of-the-week.mumps @@ -0,0 +1,19 @@ +DOWHOLIDAY + ;In what years between 2008 and 2121 will December 25 be a Sunday? + ;Uses the VA's public domain routine %DTC (Part of the Kernel) named here DIDTC + NEW BDT,EDT,CHECK,CHKFOR,LIST,I,X,Y + ;BDT - the beginning year to check + ;EDT - the end year to check + ;BDT and EDT are year offsets from the epoch date 1/1/1700 + ;CHECK - the month and day to look at + ;CHKFOR - what day of the week to look for + ;LIST - list of years in which the condition is true + ;I - the year currently being checked + ;X - the date in an "internal" format, for input to DOW^DIDTC + ;Y - the output from DOW^DIDTC + SET BDT=308,EDT=421,CHECK="1225",CHKFOR=0,LIST="" + FOR I=BDT:1:EDT SET X=I_CHECK D DOW^DIDTC SET:(Y=0) LIST=$SELECT($LENGTH(LIST):LIST_", ",1:"")_(I+1700) + IF $LENGTH(LIST)=0 WRITE !,"There are no years that have Christmas on a Sunday in the given range." + IF $LENGTH(LIST) WRITE !,"The following years have Christmas on a Sunday: ",LIST + KILL BDT,EDT,CHECK,CHKFOR,LIST,I,X,Y + QUIT diff --git a/Task/Day-of-the-week/Mathematica/day-of-the-week-1.mathematica b/Task/Day-of-the-week/Mathematica/day-of-the-week-1.mathematica new file mode 100644 index 0000000000..6f7cc398ed --- /dev/null +++ b/Task/Day-of-the-week/Mathematica/day-of-the-week-1.mathematica @@ -0,0 +1 @@ +Reap[If[DateString[{#,12,25},"DayName"]=="Sunday",Sow[#]]&/@Range[2008,2121]][[2,1]] diff --git a/Task/Day-of-the-week/Mathematica/day-of-the-week-2.mathematica b/Task/Day-of-the-week/Mathematica/day-of-the-week-2.mathematica new file mode 100644 index 0000000000..1a16992c7e --- /dev/null +++ b/Task/Day-of-the-week/Mathematica/day-of-the-week-2.mathematica @@ -0,0 +1 @@ +{2011,2016,2022,2033,2039,2044,2050,2061,2067,2072,2078,2089,2095,2101,2107,2112,2118} diff --git a/Task/Day-of-the-week/Maxima/day-of-the-week.maxima b/Task/Day-of-the-week/Maxima/day-of-the-week.maxima new file mode 100644 index 0000000000..1bf7ef38eb --- /dev/null +++ b/Task/Day-of-the-week/Maxima/day-of-the-week.maxima @@ -0,0 +1,10 @@ +weekday(year, month, day) := block([m: month, y: year, k], + if m < 3 then (m: m + 12, y: y - 1), + k: 1 + remainder(day + quotient((m + 1)*26, 10) + y + quotient(y, 4) + + 6*quotient(y, 100) + quotient(y, 400) + 5, 7), + ['monday, 'tuesday, 'wednesday, 'thurdsday, 'friday, 'saturday, 'sunday][k] +)$ + +sublist(makelist(i, i, 2008, 2121), + lambda([y], weekday(y, 12, 25) = 'sunday)); +/* [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118] */ diff --git a/Task/Day-of-the-week/Modula-3/day-of-the-week.mod3 b/Task/Day-of-the-week/Modula-3/day-of-the-week.mod3 new file mode 100644 index 0000000000..b4b07289ff --- /dev/null +++ b/Task/Day-of-the-week/Modula-3/day-of-the-week.mod3 @@ -0,0 +1,28 @@ +MODULE Yule EXPORTS Main; + +IMPORT IO, Fmt, Date, Time; + +VAR date: Date.T; + time: Time.T; + +BEGIN + FOR year := 2008 TO 2121 DO + date.day := 25; + date.month := Date.Month.Dec; + date.year := year; + + TRY + time := Date.ToTime(date); + EXCEPT + | Date.Error => + IO.Put(Fmt.Int(year) & " is the last year we can specify\n"); + EXIT; + END; + + date := Date.FromTime(time); + + IF date.weekDay = Date.WeekDay.Sun THEN + IO.Put("25th of December " & Fmt.Int(year) & " is Sunday\n"); + END; + END; +END Yule. diff --git a/Task/Deal-cards-for-FreeCell/Icon/deal-cards-for-freecell.icon b/Task/Deal-cards-for-FreeCell/Icon/deal-cards-for-freecell.icon new file mode 100644 index 0000000000..d28a98afc5 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/Icon/deal-cards-for-freecell.icon @@ -0,0 +1,43 @@ +procedure main(A) # freecelldealer + freecelldealer(\A[1] | &null) # seed from command line +end + +procedure newDeck() #: return a new unshuffled deck + every D := list(52) & i := 0 & r := !"A23456789TJQK" & s := !"CDHS" do + D[i +:= 1] := r || s # initial deck AC AD ... KS + return D +end + +procedure freecelldealer(gamenum) #: deal a freecell hand + /gamenum := 11982 + return showHand(freecellshuffle(newDeck(),gamenum)) +end + +procedure showHand(D) #: show a freecell hand + write("Hand:\n") + every writes(" ",(1 to 8) | "\n") + every writes(" ",D[i := 1 to *D]) do + if i%8 = 0 then write() + write("\n") + return D +end + +procedure freecellshuffle(D,gamenum) #: freecell shuffle + + srand_freecell(gamenum) # seed random number generator + D2 := [] + until *D = 0 do { # repeat until all dealt + D[r := rand_freecell() % *D + 1] :=: D[*D] # swap random & last cards + put(D2,pull(D)) # remove dealt card from list + } + return D2 +end + +procedure srand_freecell(x) #: seed random +static seed + return seed := \x | \seed | 0 # parm or seed or zero if none +end + +procedure rand_freecell() #: lcrng + return ishift(srand_freecell((214013 * srand_freecell() + 2531011) % 2147483648),-16) +end diff --git a/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-1.j b/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-1.j new file mode 100644 index 0000000000..9082d4fcd7 --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-1.j @@ -0,0 +1,12 @@ +deck=: ,/ 'A23456789TJQK' ,"0/ 7 u: '♣♦♥♠' + +srnd=: 3 :'SEED=:{.y,11982' +srnd '' +seed=: do bind 'SEED' +rnd=: (2^16) <.@%~ (2^31) srnd@| 2531011 + 214013 * seed + +pairs=: <@<@~.@(<: , (| rnd))@>:@i.@-@# NB. indices to swap, for shuffle +swaps=: [: > C.&.>/@|.@; NB. implement the specified shuffle +deal=: |.@(swaps pairs) bind deck + +show=: (,"2)@:(_8 ]\ ' '&,.) diff --git a/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-2.j b/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-2.j new file mode 100644 index 0000000000..4bfba78d0d --- /dev/null +++ b/Task/Deal-cards-for-FreeCell/J/deal-cards-for-freecell-2.j @@ -0,0 +1,16 @@ + show deal srnd 1 + J♦ 2♦ 9♥ J♣ 5♦ 7♥ 7♣ 5♥ + K♦ K♣ 9♠ 5♠ A♦ Q♣ K♥ 3♥ + 2♠ K♠ 9♦ Q♦ J♠ A♠ A♥ 3♣ + 4♣ 5♣ T♠ Q♥ 4♥ A♣ 4♦ 7♠ + 3♠ T♦ 4♠ T♥ 8♥ 2♣ J♥ 7♦ + 6♦ 8♠ 8♦ Q♠ 6♣ 3♦ 8♣ T♣ + 6♠ 9♣ 2♥ 6♥ + show deal srnd 617 + 7♦ A♦ 5♣ 3♠ 5♠ 8♣ 2♦ A♥ + T♦ 7♠ Q♦ A♣ 6♦ 8♥ A♠ K♥ + T♥ Q♣ 3♥ 9♦ 6♠ 8♦ 3♦ T♣ + K♦ 5♥ 9♠ 3♣ 8♠ 7♥ 4♦ J♠ + 4♣ Q♠ 9♣ 9♥ 7♣ 6♥ 2♣ 2♠ + 4♠ T♠ 2♥ 5♦ J♣ 6♣ J♥ Q♥ + J♦ K♠ K♣ 4♥ diff --git a/Task/Death-Star/J/death-star-1.j b/Task/Death-Star/J/death-star-1.j new file mode 100644 index 0000000000..ed24367538 --- /dev/null +++ b/Task/Death-Star/J/death-star-1.j @@ -0,0 +1,39 @@ +mag =: +/&.:*:"1 +norm=: %"1 0 mag +dot =: +/@:*"1 + +NB. (pos;posr;neg;negr) getvec (x,y) +getvec =: 4 :0 "1 + pt =. y + 'pos posr neg negr' =. x + if. (dot~ pt-}:pos) > *:posr do. + 0 0 0 + else. + zb =. ({:pos) (-,+) posr -&.:*: pt mag@:- }:pos + if. (dot~ pt-}:neg) > *:negr do. + (pt,{:zb) - pos + else. + zs =. ({:neg) (-,+) negr -&.:*: pt mag@:- }:neg + if. zs >&{. zb do. (pt,{:zb) - pos + elseif. zs >&{: zb do. 0 0 0 + elseif. ({.zs) < ({:zb) do. neg - (pt,{.zs) + elseif. do. (pt,{.zb) - pos end. + end. + end. +) + + +NB. (k;ambient;light) draw_sphere (pos;posr;neg;negr) +draw_sphere =: 4 :0 + 'pos posr neg negr' =. y + 'k ambient light' =. x + vec=. norm y getvec ,"0// (2{.pos) +/ i: 200 j.~ 0.5+posr + + b=. (mag vec) * ambient + k * 0>. light dot vec +) + +togray =: 256#. 255 255 255 <.@*"1 0 (%>./@,) + +env=.(2; 0.5; (norm _50 30 50)) +sph=. 20 20 0; 20; 1 1 _6; 20 +'rgb' viewmat togray env draw_sphere sph diff --git a/Task/Death-Star/J/death-star-2.j b/Task/Death-Star/J/death-star-2.j new file mode 100644 index 0000000000..f46325be75 --- /dev/null +++ b/Task/Death-Star/J/death-star-2.j @@ -0,0 +1,54 @@ +load'graphics/viewmat' + +resolution=: 8 +spheres=: 3 1 #"1 ] 0 1,_1 1,:0.3 0.6 NB. spheres x y z r + + +coordinates=: (% <:)~ (,"1 0~"0 3 ,"0"1 0~)@:i: +length=: +/ &.: *: +centers=: _ 3&{. +radii=: _ _1&{. + +NB. resolution SlicePittedSphere spheres generates a binary array, 1 in the geometric object +SlicePittedSphere=: (0 { {. > [: +./ }.)@:(radii@[ >:"0 3 ((length@:-"1"_ 1 centers)~ coordinates))~ + +spanTo=: conjunction def '(m<:y)*.y<:n' NB. algebraic similarity, m <= y <= n + +tessellate=: ] ];._3"3~ 3 # [ NB. All cubical edge length x subarrays of array y + +NB. Define "faces" as those points with 9 to 18 inclusive "solid" neighbors. +detectFace=: (9 spanTo 18) @: (+/@:,"3) @: (3&tessellate) + +NB. arrange faces in ANSYS brick face order +ThickFaces=: ((|:"3 , (, |:"2))(,: |."1)3 3 3$2j1#1) /: 'SENWDU' i. 'DUEWSN' +ThinFaces=: ((|:"3 , (, |:"2))(,: |."1)3 3 3$1j2#1) /: 'SENWDU' i. 'DUEWSN' + +FACES=:ThickFaces NB. 6 below comes from #Faces + +NORMALS=: 2 tessellate FACES + +matchNormals=: [: +/@,"6 NORMALS ="6"6 _ (2 tessellate 3 tessellate ]) + +bestFit=: (i.>./)"1&.|: + +topFace=: detectFace i:"1 1: + +choose=: 4 : 'x}y' + +viewmat resolution (topFace choose (,&(#FACES))@:bestFit@matchNormals)@SlicePittedSphere spheres + + + <"_1 ThickFaces NB. display the 6 cubes with reference faces +┌─────┬─────┬─────┬─────┬─────┬─────┐ +│1 1 1│1 1 0│0 0 0│0 1 1│1 1 1│0 0 0│ +│1 1 1│1 1 0│1 1 1│0 1 1│1 1 1│0 0 0│ +│0 0 0│1 1 0│1 1 1│0 1 1│1 1 1│0 0 0│ +│ │ │ │ │ │ │ +│1 1 1│1 1 0│0 0 0│0 1 1│1 1 1│1 1 1│ +│1 1 1│1 1 0│1 1 1│0 1 1│1 1 1│1 1 1│ +│0 0 0│1 1 0│1 1 1│0 1 1│1 1 1│1 1 1│ +│ │ │ │ │ │ │ +│1 1 1│1 1 0│0 0 0│0 1 1│0 0 0│1 1 1│ +│1 1 1│1 1 0│1 1 1│0 1 1│0 0 0│1 1 1│ +│0 0 0│1 1 0│1 1 1│0 1 1│0 0 0│1 1 1│ +└─────┴─────┴─────┴─────┴─────┴─────┘ diff --git a/Task/Death-Star/LSL/death-star.lsl b/Task/Death-Star/LSL/death-star.lsl new file mode 100644 index 0000000000..32c8084e3e --- /dev/null +++ b/Task/Death-Star/LSL/death-star.lsl @@ -0,0 +1,14 @@ +default { + state_entry() { + llSetPrimitiveParams([PRIM_NAME, "RosettaCode DeathStar"]); + llSetPrimitiveParams([PRIM_DESC, llGetObjectName()]); + llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.12, 1.0, 0.0>]); + llSetPrimitiveParams([PRIM_ROTATION, <-0.586217, 0.395411, -0.586217, 0.395411>]); + llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0]); + llSetPrimitiveParams([PRIM_TEXT, llGetObjectName(), <1.0, 1.0, 1.0>, 1.0]); + llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.5, 0.5, 0.5>, 1.0]); + llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_HIGH, PRIM_BUMP_NONE]); + llSetPrimitiveParams([PRIM_SIZE, <10.0, 10.0, 10.0>]); + llSetPrimitiveParams([PRIM_OMEGA, <0.0, 0.0, 1.0>, 1.0, 1.0]); + } +} diff --git a/Task/Death-Star/Mathematica/death-star.mathematica b/Task/Death-Star/Mathematica/death-star.mathematica new file mode 100644 index 0000000000..aef1d1bce1 --- /dev/null +++ b/Task/Death-Star/Mathematica/death-star.mathematica @@ -0,0 +1,3 @@ +RegionPlot3D[x^2 + y^2 + z^2 < 1 && (x + 1.7)^2 + y^2 + z^2 > 1, +{x, -1, 1}, {y, -1, 1}, {z, -1, 1}, +Boxed -> False, Mesh -> False, Axes -> False, Background -> Black, PlotPoints -> 100] diff --git a/Task/Deconvolution-1D/J/deconvolution-1d-1.j b/Task/Deconvolution-1D/J/deconvolution-1d-1.j new file mode 100644 index 0000000000..ba6dc4b4da --- /dev/null +++ b/Task/Deconvolution-1D/J/deconvolution-1d-1.j @@ -0,0 +1,2 @@ +Ai=: (i.@] =/ i.@[ -/ i.@>:@-)&# +divide=: [ +/ .*~ [:%.&.x: ] +/ .* Ai diff --git a/Task/Deconvolution-1D/J/deconvolution-1d-2.j b/Task/Deconvolution-1D/J/deconvolution-1d-2.j new file mode 100644 index 0000000000..4f2e7f5036 --- /dev/null +++ b/Task/Deconvolution-1D/J/deconvolution-1d-2.j @@ -0,0 +1,3 @@ +h=: _8 _9 _3 _1 _6 7 +f=: _3 _6 _1 8 _6 3 _1 _9 _9 3 _2 5 2 _2 _7 _1 +g=: 24 75 71 _34 3 22 _45 23 245 25 52 25 _67 _96 96 31 55 36 29 diff --git a/Task/Deconvolution-1D/J/deconvolution-1d-3.j b/Task/Deconvolution-1D/J/deconvolution-1d-3.j new file mode 100644 index 0000000000..3eddb462fa --- /dev/null +++ b/Task/Deconvolution-1D/J/deconvolution-1d-3.j @@ -0,0 +1,4 @@ + g divide f +_8 _9 _3 _1 _6 7 + g divide h +_3 _6 _1 8 _6 3 _1 _9 _9 3 _2 5 2 _2 _7 _1 diff --git a/Task/Deconvolution-1D/J/deconvolution-1d-4.j b/Task/Deconvolution-1D/J/deconvolution-1d-4.j new file mode 100644 index 0000000000..176e6bce7d --- /dev/null +++ b/Task/Deconvolution-1D/J/deconvolution-1d-4.j @@ -0,0 +1 @@ +divide=: [ +/ .*~ [:%. ] +/ .* Ai diff --git a/Task/Deconvolution-1D/Mathematica/deconvolution-1d.mathematica b/Task/Deconvolution-1D/Mathematica/deconvolution-1d.mathematica new file mode 100644 index 0000000000..972f3b6bab --- /dev/null +++ b/Task/Deconvolution-1D/Mathematica/deconvolution-1d.mathematica @@ -0,0 +1,5 @@ +deconv[f_List, g_List] := + Module[{A = + SparseArray[ + Table[Band[{n, 1}] -> f[[n]], {n, 1, Length[f]}], {Length[g], Length[f] - 1}]}, + Take[LinearSolve[A, g], Length[g] - Length[f] + 1]] diff --git a/Task/Deconvolution-2D+/J/deconvolution-2d+-1.j b/Task/Deconvolution-2D+/J/deconvolution-2d+-1.j new file mode 100644 index 0000000000..0042fa668b --- /dev/null +++ b/Task/Deconvolution-2D+/J/deconvolution-2d+-1.j @@ -0,0 +1,9 @@ +deconv3 =: 4 : 0 + sz =. x >:@-&$ y NB. shape of z + poi =. ,<"1 ($y) ,"0/&(,@i.) sz NB. pair of indexes + t=. /: sc=: , <@(+"1)/&(#: ,@i.)/ ($y),:sz NB. order of ,y + T0=. (<"0,x) ,:~ (]/:"1 {.)&.> (<, y) ({:@] ,: ({"1~ {.))&.> sc <@|:@:>/.&(t&{) poi NB. set of boxed equations + T1=. (,x),.~(<0 #~ */sz) (({:@])`({.@])`[})&> {.T0 NB. set of linear equations + sz $ 1e_8 round ({:"1 %. }:"1) T1 +) +round=: [ * <.@%~ diff --git a/Task/Deconvolution-2D+/J/deconvolution-2d+-2.j b/Task/Deconvolution-2D+/J/deconvolution-2d+-2.j new file mode 100644 index 0000000000..2334c251d7 --- /dev/null +++ b/Task/Deconvolution-2D+/J/deconvolution-2d+-2.j @@ -0,0 +1,57 @@ +h1=: _8 2 _9 _2 9 _8 _2 +f1=: 6 _9 _7 _5 +g1=: _48 84 _16 95 125 _70 7 29 54 10 + +h2=: ".;._2]0 :0 + _8 1 _7 _2 _9 4 + 4 5 _5 2 7 _1 + _6 _3 _3 _6 9 5 +) + +f2=: ".;._2]0 :0 + _5 2 _2 _6 _7 + 9 7 _6 5 _7 + 1 _1 9 2 _7 + 5 9 _9 2 _5 + _8 5 _2 8 5 +) + +g2=: ".;._2]0 :0 + 40 _21 53 42 105 1 87 60 39 _28 + _92 _64 19 _167 _71 _47 128 _109 40 _21 + 58 85 _93 37 101 _14 5 37 _76 _56 + _90 _135 60 _125 68 53 223 4 _36 _48 + 78 16 7 _199 156 _162 29 28 _103 _10 + _62 _89 69 _61 66 193 _61 71 _8 _30 + 48 _6 21 _9 _150 _22 _56 32 85 25 +) + +h3=: ".;._1;._2]0 :0 +/ _6 _8 _5 9/ _7 9 _6 _8/ 2 _7 9 8 +/ 7 4 4 _6/ 9 9 4 _4/ _3 7 _2 _3 +) + +f3=: ".;._1;._2]0 :0 +/ _9 5 _8/ 3 5 1 +/ _1 _7 2/ _5 _6 6 +/ 8 5 8/_2 _6 _4 +) + +g3=: ".;._2;._1]0 :0 +/ 54 42 53 _42 85 _72 + 45 _170 94 _36 48 73 + _39 65 _112 _16 _78 _72 + 6 _11 _6 62 49 8 +/ _57 49 _23 52 _135 66 + _23 127 _58 _5 _118 64 + 87 _16 121 23 _41 _12 + _19 29 35 _148 _11 45 +/ _55 _147 _146 _31 55 60 + _88 _45 _28 46 _26 _144 + _12 _107 _34 150 249 66 + 11 _15 _34 27 _78 _50 +/ 56 67 108 4 2 _48 + 58 67 89 32 32 _8 + _42 _31 _103 _30 _23 _8 + 6 4 _26 _10 26 12 +) diff --git a/Task/Deconvolution-2D+/J/deconvolution-2d+-3.j b/Task/Deconvolution-2D+/J/deconvolution-2d+-3.j new file mode 100644 index 0000000000..8601c56391 --- /dev/null +++ b/Task/Deconvolution-2D+/J/deconvolution-2d+-3.j @@ -0,0 +1,6 @@ + h1 -: g1 deconv3 f1 +1 + h2 -: g2 deconv3 f2 +1 + h3 -: g3 deconv3 f3 NB. -: checks for matching structure and data +1 diff --git a/Task/Deconvolution-2D+/Mathematica/deconvolution-2d+.mathematica b/Task/Deconvolution-2D+/Mathematica/deconvolution-2d+.mathematica new file mode 100644 index 0000000000..d723568d9e --- /dev/null +++ b/Task/Deconvolution-2D+/Mathematica/deconvolution-2d+.mathematica @@ -0,0 +1,14 @@ +Round[ListDeconvolve[{6, -9, -7, -5}, {-48, 84, -16, 95, 125, -70, 7, 29, 54, 10}, Method -> "Wiener"]] + +Round[ListDeconvolve[{{-5, 2, -2, -6, -7}, {9, 7, -6, 5, -7}, {1, -1, 9, 2, -7}, {5, 9, -9, 2, -5}, {-8, 5, -2, 8, 5}}, +{{40, -21, 53, 42, 105, 1, 87, 60, 39, -28}, {-92, -64, 19, -167, -71, -47, 128, -109, 40, -21}, +{58, 85, -93, 37, 101, -14, 5, 37, -76, -56}, {-90, -135, 60, -125, 68, 53, 223, 4, -36, -48}, +{78, 16, 7, -199, 156, -162, 29, 28, -103, -10}, {-62, -89, 69, -61, 66, 193, -61, 71, -8, -30}, +{48, -6, 21, -9, -150, -22, -56, 32, 85, 25}}, Method -> "Wiener"]] + +Round[ListDeconvolve [{{{-9, 5, -8}, {3, 5, 1}}, {{-1, -7, 2}, {-5, -6, 6}}, {{8, 5, 8}, {-2, -6, -4}}}, +{{{54, 42, 53, -42, 85, -72}, {45, -170, 94, -36, 48, 73}, {-39, 65, -112, -16, -78, -72}, +{6, -11, -6, 62, 49, 8}}, {{-57, 49, -23, 52, -135, 66}, {-23, 127, -58, -5, -118, 64}, {87, -16, 121, 23, -41, -12}, +{-19, 29, 35, -148, -11, 45}}, {{-55, -147, -146, -31, 55, 60}, {-88, -45, -28, 46, -26, -144}, +{-12, -107, -34, 150, 249, 66}, {11, -15, -34, 27, -78, -50}}, {{56, 67, 108, 4, 2, -48}, {58, 67, 89, 32, 32, -8}, +{-42, -31, -103, -30, -23, -8}, {6, 4, -26, -10, 26, 12}}}, Method -> "Wiener"]] diff --git a/Task/Deepcopy/Icon/deepcopy-1.icon b/Task/Deepcopy/Icon/deepcopy-1.icon new file mode 100644 index 0000000000..110f5ee4d7 --- /dev/null +++ b/Task/Deepcopy/Icon/deepcopy-1.icon @@ -0,0 +1,24 @@ +procedure deepcopy(A, cache) #: return a deepcopy of A + local k + + /cache := table() # used to handle multireferenced objects + if \cache[A] then return cache[A] + + case type(A) of { + "table"|"list": { + cache[A] := copy(A) + every cache[A][k := key(A)] := deepcopy(A[k], cache) + } + "set": { + cache[A] := set() + every insert(cache[A], deepcopy(!A, cache)) + } + default: { # records and objects (encoded as records) + cache[A] := copy(A) + if match("record ",image(A)) then { + every cache[A][k := key(A)] := deepcopy(A[k], cache) + } + } + } + return .cache[A] +end diff --git a/Task/Deepcopy/Icon/deepcopy-2.icon b/Task/Deepcopy/Icon/deepcopy-2.icon new file mode 100644 index 0000000000..8cc89244ce --- /dev/null +++ b/Task/Deepcopy/Icon/deepcopy-2.icon @@ -0,0 +1,54 @@ +link printf,ximage + +procedure main() + + knot := makeknot() # create a structure with loops + knota := knot # copy by assignment (reference) + knotc := copy(knot) # built-in copy (shallow) + knotdc := deepcopy(knot) # deep copy + + + showdeep("knota (assignment) vs. knot",knota,knot) + showdeep("knotc (copy) vs. knot",knotc,knot) + showdeep("knotdc (deepcopy) vs. knot",knotdc,knot) + + xdump("knot (original)",knot) + xdump("knota (assignment)",knota) + xdump("knotc (copy)",knotc) + xdump("knotdc (deepcopy)",knotdc) +end + +record rec1(a,b,c) # record for example + +class Class1(a1,a2) # class - looks like a record under the covers + method one() + self.a1 := 1 + return + end +initially + self.a1 := 0 +end + + +procedure makeknot() #: return a homogeneous structure with loops + L := [9,8,7] + T := table() + T["a"] := 1 + R := rec1(T) + S := set(R) + C := Class1() + C.one() + T["knot"] := [L,R,S,C] + put(L,R,S,T,C) + return L +end + +procedure showdeep(tag,XC,X) #: demo to show (non-)equivalence of list elements + printf("Analysis of copy depth for %s:\n",tag) + showequiv(XC,X) + every showequiv(XC[i := 1 to *X],X[i]) +end + +procedure showequiv(x,y) #: show (non-)equivalence of two values + return printf(" %i %s %i\n",x,if x === y then "===" else "~===",y) +end diff --git a/Task/Deepcopy/J/deepcopy.j b/Task/Deepcopy/J/deepcopy.j new file mode 100644 index 0000000000..9e1a922c65 --- /dev/null +++ b/Task/Deepcopy/J/deepcopy.j @@ -0,0 +1,6 @@ + a=:b=: 2 2 2 2 2 NB. two copies of the same array + b=: 3 (2)} b NB. modify one of the arrays + b +2 2 3 2 2 + a +2 2 2 2 2 diff --git a/Task/Define-a-primitive-data-type/Modula-3/define-a-primitive-data-type.mod3 b/Task/Define-a-primitive-data-type/Modula-3/define-a-primitive-data-type.mod3 new file mode 100644 index 0000000000..e5a323c0e6 --- /dev/null +++ b/Task/Define-a-primitive-data-type/Modula-3/define-a-primitive-data-type.mod3 @@ -0,0 +1 @@ +TYPE MyInt = [1..10]; diff --git a/Task/Delegates/J/delegates-1.j b/Task/Delegates/J/delegates-1.j new file mode 100644 index 0000000000..5bdf5b7038 --- /dev/null +++ b/Task/Delegates/J/delegates-1.j @@ -0,0 +1,13 @@ +coclass 'delegator' + operation=:3 :'thing__delegate ::thing y' + thing=: 'default implementation'"_ + setDelegate=:3 :'delegate=:y' NB. result is the reference to our new delegate + delegate=:<'delegator' + +coclass 'delegatee1' + +coclass 'delegatee2' + thing=: 'delegate implementation'"_ + +NB. set context in case this script was used interactively, instead of being loaded +cocurrent 'base' diff --git a/Task/Delegates/J/delegates-2.j b/Task/Delegates/J/delegates-2.j new file mode 100644 index 0000000000..dc736634be --- /dev/null +++ b/Task/Delegates/J/delegates-2.j @@ -0,0 +1,15 @@ + obj=:conew'delegator' + operation__obj'' +default implementation + setDelegate__obj conew'delegatee1' +┌─┐ +│4│ +└─┘ + operation__obj'' +default implementation + setDelegate__obj conew'delegatee2' +┌─┐ +│5│ +└─┘ + operation__obj'' +delegate implementation diff --git a/Task/Delegates/Logtalk/delegates.logtalk b/Task/Delegates/Logtalk/delegates.logtalk new file mode 100644 index 0000000000..8077ca26fe --- /dev/null +++ b/Task/Delegates/Logtalk/delegates.logtalk @@ -0,0 +1,76 @@ +% define a category for holding the interface +% and implementation for delegator objects + +:- category(delegator). + + :- public(delegate/1). + :- public(set_delegate/1). + + :- private(delegate_/1). + :- dynamic(delegate_/1). + + delegate(Delegate) :- + ::delegate_(Delegate). + + set_delegate(Delegate) :- + ::retractall(delegate_(Delegate)), + ::assertz(delegate_(Delegate)). + +:- end_category. + +% define a simpler delegator object, with a +% method, operation/1, for testing delegation + +:- object(a_delegator, + imports(delegator)). + + :- public(operation/1). + + operation(String) :- + ( ::delegate(Delegate), Delegate::current_predicate(thing/1) -> + % a delegate is defined that understands the method thing/1 + Delegate::thing(String) + ; % otherwise just use the default implementation + String = 'default implementation' + ). + +:- end_object. + +% define an interface for delegate objects + +:- protocol(delegate). + + :- public(thing/1). + +:- end_protocol. + +% define a simple delegate + +:- object(a_delegate, + implements(delegate)). + + thing('delegate implementation'). + +:- end_object. + +% define a simple object that doesn't implement the "delegate" interface + +:- object(an_object). + +:- end_object. + +% test the delegation solution when this file is compiled and loaded + +:- initialization(( + % without a delegate: + a_delegator::operation(String1), + String1 == 'default implementation', + % with a delegate that does not implement thing/1: + a_delegator::set_delegate(an_object), + a_delegator::operation(String2), + String2 == 'default implementation', + % with a delegate that implements thing/1: + a_delegator::set_delegate(a_delegate), + a_delegator::operation(String3), + String3 == 'delegate implementation' +)). diff --git a/Task/Delete-a-file/Factor/delete-a-file.factor b/Task/Delete-a-file/Factor/delete-a-file.factor new file mode 100644 index 0000000000..bdfc231694 --- /dev/null +++ b/Task/Delete-a-file/Factor/delete-a-file.factor @@ -0,0 +1,2 @@ +"docs" "/docs" [ delete-tree ] bi@ +"input.txt" "/input.txt" [ delete-file ] bi@ diff --git a/Task/Delete-a-file/GAP/delete-a-file.gap b/Task/Delete-a-file/GAP/delete-a-file.gap new file mode 100644 index 0000000000..b536263ffa --- /dev/null +++ b/Task/Delete-a-file/GAP/delete-a-file.gap @@ -0,0 +1,5 @@ +# Apparently GAP can only remove a file, not a directory +RemoveFile("input.txt"); +# true +RemoveFile("docs"); +# fail diff --git a/Task/Delete-a-file/HicEst/delete-a-file.hicest b/Task/Delete-a-file/HicEst/delete-a-file.hicest new file mode 100644 index 0000000000..9bdf93639b --- /dev/null +++ b/Task/Delete-a-file/HicEst/delete-a-file.hicest @@ -0,0 +1,7 @@ +SYSTEM(DIR="docs") ! create docs in current directory (if not existent), make it current +OPEN (FILE="input.txt", "NEW") ! in current directory = docs +WRITE(FIle="input.txt", DELETE=1) ! no command to DELETE a DIRECTORY in HicEst + +SYSTEM(DIR="C:\docs") ! create C:\docs (if not existent), make it current +OPEN (FILE="input.txt", "NEW") ! in current directory = C:\docs +WRITE(FIle="input.txt", DELETE=1) diff --git a/Task/Delete-a-file/Icon/delete-a-file.icon b/Task/Delete-a-file/Icon/delete-a-file.icon new file mode 100644 index 0000000000..c980e6050c --- /dev/null +++ b/Task/Delete-a-file/Icon/delete-a-file.icon @@ -0,0 +1,4 @@ +every dir := !["./","/"] do { + remove(f := dir || "input.txt") |stop("failure for file remove ",f) + rmdir(f := dir || "docs") |stop("failure for directory remove ",f) + } diff --git a/Task/Delete-a-file/Io/delete-a-file-1.io b/Task/Delete-a-file/Io/delete-a-file-1.io new file mode 100644 index 0000000000..079f7fa2b1 --- /dev/null +++ b/Task/Delete-a-file/Io/delete-a-file-1.io @@ -0,0 +1,5 @@ +Directory fileNamed("input.txt") remove +Directory directoryNamed("docs") remove +RootDir := Directory clone setPath("/") +RootDir fileNamed("input.txt") remove +RootDir directoryNamed("docs") remove diff --git a/Task/Delete-a-file/Io/delete-a-file-2.io b/Task/Delete-a-file/Io/delete-a-file-2.io new file mode 100644 index 0000000000..1aad7ca195 --- /dev/null +++ b/Task/Delete-a-file/Io/delete-a-file-2.io @@ -0,0 +1,4 @@ +File with("input.txt") remove +Directory with("docs") remove +File with("/input.txt") remove +Directory with("/docs") remove diff --git a/Task/Delete-a-file/J/delete-a-file-1.j b/Task/Delete-a-file/J/delete-a-file-1.j new file mode 100644 index 0000000000..cf0a40f9dc --- /dev/null +++ b/Task/Delete-a-file/J/delete-a-file-1.j @@ -0,0 +1,8 @@ + load 'files' + ferase 'input.txt' + ferase '\input.txt' + ferase 'docs' + ferase '\docs' + +NB. Or all at once... + ferase 'input.txt';'/input.txt';'docs';'/docs' diff --git a/Task/Delete-a-file/J/delete-a-file-2.j b/Task/Delete-a-file/J/delete-a-file-2.j new file mode 100644 index 0000000000..cf77b4e82e --- /dev/null +++ b/Task/Delete-a-file/J/delete-a-file-2.j @@ -0,0 +1,4 @@ +NB. ========================================================= +NB.*ferase v erases a file +NB. Returns 1 if successful, otherwise _1 +ferase=: (1!:55 :: _1:) @ (fboxname &>) @ boxopen diff --git a/Task/Delete-a-file/J/delete-a-file-3.j b/Task/Delete-a-file/J/delete-a-file-3.j new file mode 100644 index 0000000000..0b793894e6 --- /dev/null +++ b/Task/Delete-a-file/J/delete-a-file-3.j @@ -0,0 +1,4 @@ +1!:55 <'input.txt' +1!:55 <'\input.txt' +1!:55 <'docs' +1!:55 <'\docs' diff --git a/Task/Delete-a-file/Liberty-BASIC/delete-a-file.liberty b/Task/Delete-a-file/Liberty-BASIC/delete-a-file.liberty new file mode 100644 index 0000000000..11c37c510b --- /dev/null +++ b/Task/Delete-a-file/Liberty-BASIC/delete-a-file.liberty @@ -0,0 +1,10 @@ +' show where we are +print DefaultDir$ + +' in here +kill "input.txt" +result=rmdir("Docs") + +' from root +kill "\input.txt" +result=rmdir("\Docs") diff --git a/Task/Delete-a-file/Locomotive-Basic/delete-a-file.bas b/Task/Delete-a-file/Locomotive-Basic/delete-a-file.bas new file mode 100644 index 0000000000..9ba71ac0c6 --- /dev/null +++ b/Task/Delete-a-file/Locomotive-Basic/delete-a-file.bas @@ -0,0 +1 @@ +|era,"input.txt" diff --git a/Task/Delete-a-file/Logo/delete-a-file.logo b/Task/Delete-a-file/Logo/delete-a-file.logo new file mode 100644 index 0000000000..f9d83460fb --- /dev/null +++ b/Task/Delete-a-file/Logo/delete-a-file.logo @@ -0,0 +1,2 @@ +erasefile "input.txt +erasefile "/input.txt diff --git a/Task/Delete-a-file/MAXScript/delete-a-file.max b/Task/Delete-a-file/MAXScript/delete-a-file.max new file mode 100644 index 0000000000..6a789cb514 --- /dev/null +++ b/Task/Delete-a-file/MAXScript/delete-a-file.max @@ -0,0 +1,4 @@ +-- Here +deleteFile "input.txt" +-- Root +deleteFile "\input.txt" diff --git a/Task/Delete-a-file/Mathematica/delete-a-file.mathematica b/Task/Delete-a-file/Mathematica/delete-a-file.mathematica new file mode 100644 index 0000000000..89524c78e6 --- /dev/null +++ b/Task/Delete-a-file/Mathematica/delete-a-file.mathematica @@ -0,0 +1,5 @@ +wd = NotebookDirectory[]; +DeleteFile[wd <> "input.txt"] +DeleteFile["/" <> "input.txt"] +DeleteDirectory[wd <> "docs"] +DeleteDirectory["/" <> "docs"] diff --git a/Task/Detect-division-by-zero/Factor/detect-division-by-zero.factor b/Task/Detect-division-by-zero/Factor/detect-division-by-zero.factor new file mode 100644 index 0000000000..234cb179d0 --- /dev/null +++ b/Task/Detect-division-by-zero/Factor/detect-division-by-zero.factor @@ -0,0 +1,4 @@ +USE: math.floats.env + +: try-div ( a b -- ) + '[ { +fp-zero-divide+ } [ _ _ /f . ] with-fp-traps ] try ; diff --git a/Task/Detect-division-by-zero/Fancy/detect-division-by-zero.fancy b/Task/Detect-division-by-zero/Fancy/detect-division-by-zero.fancy new file mode 100644 index 0000000000..615b5fce20 --- /dev/null +++ b/Task/Detect-division-by-zero/Fancy/detect-division-by-zero.fancy @@ -0,0 +1,7 @@ +def divide: x by: y { + try { + x / y + } catch DivisionByZeroError => e { + e message println # prints error message + } +} diff --git a/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-1.groovy b/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-1.groovy new file mode 100644 index 0000000000..cc9cd9a3bb --- /dev/null +++ b/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-1.groovy @@ -0,0 +1,4 @@ +def dividesByZero = { double n, double d -> + assert ! n.infinite : 'Algorithm fails if the numerator is already infinite.' + (n/d).infinite || (n/d).naN +} diff --git a/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-2.groovy b/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-2.groovy new file mode 100644 index 0000000000..3e7595ba4d --- /dev/null +++ b/Task/Detect-division-by-zero/Groovy/detect-division-by-zero-2.groovy @@ -0,0 +1,5 @@ +((3d)..(0d)).each { i -> + ((2d)..(0d)).each { j -> + println "${i}/${j} divides by zero? " + dividesByZero(i,j) + } +} diff --git a/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-1.hicest b/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-1.hicest new file mode 100644 index 0000000000..0c98afd64b --- /dev/null +++ b/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-1.hicest @@ -0,0 +1,7 @@ +FUNCTION zero_divide(num, denom) + XEQ( num// "/" // denom, *99) ! on error jump to label 99 + zero_divide = 0 ! division OK + RETURN + + 99 zero_divide = 1 +END diff --git a/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-2.hicest b/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-2.hicest new file mode 100644 index 0000000000..fb87ed3c36 --- /dev/null +++ b/Task/Detect-division-by-zero/HicEst/detect-division-by-zero-2.hicest @@ -0,0 +1,2 @@ +zero_divide(0, 1) returns 0 (false) +zero_divide( 1, 3-2-1 ) returns 1 (true) diff --git a/Task/Detect-division-by-zero/IDL/detect-division-by-zero.idl b/Task/Detect-division-by-zero/IDL/detect-division-by-zero.idl new file mode 100644 index 0000000000..5af8d25f34 --- /dev/null +++ b/Task/Detect-division-by-zero/IDL/detect-division-by-zero.idl @@ -0,0 +1 @@ +if not finite( expression ) then ... diff --git a/Task/Detect-division-by-zero/Icon/detect-division-by-zero.icon b/Task/Detect-division-by-zero/Icon/detect-division-by-zero.icon new file mode 100644 index 0000000000..73389a8fdf --- /dev/null +++ b/Task/Detect-division-by-zero/Icon/detect-division-by-zero.icon @@ -0,0 +1,4 @@ +procedure main() +&error := 1 +udef := 1 / 0 | stop("Run-time error ", &errornumber, " : ", &errortext," in line #",&line," - converted to failure") +end diff --git a/Task/Detect-division-by-zero/J/detect-division-by-zero-1.j b/Task/Detect-division-by-zero/J/detect-division-by-zero-1.j new file mode 100644 index 0000000000..a1fbfca317 --- /dev/null +++ b/Task/Detect-division-by-zero/J/detect-division-by-zero-1.j @@ -0,0 +1 @@ +funnydiv=: 0 { [: (,:'division by zero detected')"_^:(_ e. |@,) (,>:)@:(,:^:(0<#@$))@[ %"_1 _ ] diff --git a/Task/Detect-division-by-zero/J/detect-division-by-zero-2.j b/Task/Detect-division-by-zero/J/detect-division-by-zero-2.j new file mode 100644 index 0000000000..7f9975b4d5 --- /dev/null +++ b/Task/Detect-division-by-zero/J/detect-division-by-zero-2.j @@ -0,0 +1,10 @@ + 3 funnydiv 2 +1.5 + 3 funnydiv 0 +division by zero detected + 0 funnydiv 0 +division by zero detected + 0 funnydiv 3 +0 + 2 3 4 funnydiv 5 +0.4 0.6 0.8 diff --git a/Task/Detect-division-by-zero/Liberty-BASIC/detect-division-by-zero.liberty b/Task/Detect-division-by-zero/Liberty-BASIC/detect-division-by-zero.liberty new file mode 100644 index 0000000000..5b02911f51 --- /dev/null +++ b/Task/Detect-division-by-zero/Liberty-BASIC/detect-division-by-zero.liberty @@ -0,0 +1,12 @@ +result = DetectDividebyZero(1, 0) + + +Function DetectDividebyZero(a, b) + On Error GoTo [Error] + DetectDividebyZero= (a/ b) + Exit Function + [Error] + If Err = 11 Then '11 is the error number raised when divide by zero occurs + Notice "Divide by Zero Detected!" + End If +End Function diff --git a/Task/Detect-division-by-zero/Locomotive-Basic/detect-division-by-zero.bas b/Task/Detect-division-by-zero/Locomotive-Basic/detect-division-by-zero.bas new file mode 100644 index 0000000000..27ec7e1b97 --- /dev/null +++ b/Task/Detect-division-by-zero/Locomotive-Basic/detect-division-by-zero.bas @@ -0,0 +1,6 @@ +10 ON ERROR GOTO 60 +20 PRINT 2/3 +30 PRINT 3/5 +40 PRINT 4/0 +50 END +60 IF ERR=11 THEN PRINT "Division by zero in line"ERL:RESUME 50 diff --git a/Task/Detect-division-by-zero/M4/detect-division-by-zero.m4 b/Task/Detect-division-by-zero/M4/detect-division-by-zero.m4 new file mode 100644 index 0000000000..3f488ed632 --- /dev/null +++ b/Task/Detect-division-by-zero/M4/detect-division-by-zero.m4 @@ -0,0 +1 @@ +ifelse(eval(2/0),`',`detected divide by zero or some other error of some kind') diff --git a/Task/Detect-division-by-zero/MAXScript/detect-division-by-zero.max b/Task/Detect-division-by-zero/MAXScript/detect-division-by-zero.max new file mode 100644 index 0000000000..4242a52728 --- /dev/null +++ b/Task/Detect-division-by-zero/MAXScript/detect-division-by-zero.max @@ -0,0 +1 @@ +if not bit.isFinite (expression) then... diff --git a/Task/Detect-division-by-zero/MUMPS/detect-division-by-zero.mumps b/Task/Detect-division-by-zero/MUMPS/detect-division-by-zero.mumps new file mode 100644 index 0000000000..bbfe48c74d --- /dev/null +++ b/Task/Detect-division-by-zero/MUMPS/detect-division-by-zero.mumps @@ -0,0 +1,11 @@ +DIV(A,B) ;Divide A by B, and watch for division by zero + ;The ANSI error code for division by zero is "M9". + ;$ECODE errors are surrounded by commas when set. + NEW $ETRAP + SET $ETRAP="GOTO DIVFIX^ROSETTA" + SET D=(A/B) + SET $ETRAP="" + QUIT D +DIVFIX + IF $FIND($ECODE,",M9,")>1 WRITE !,"Error: Division by zero" SET $ECODE="" QUIT "" + QUIT "" ; Fall through for other errors diff --git a/Task/Detect-division-by-zero/Mathematica/detect-division-by-zero.mathematica b/Task/Detect-division-by-zero/Mathematica/detect-division-by-zero.mathematica new file mode 100644 index 0000000000..a5e9633fb5 --- /dev/null +++ b/Task/Detect-division-by-zero/Mathematica/detect-division-by-zero.mathematica @@ -0,0 +1 @@ +Check[2/0, Print["division by 0"], Power::infy] diff --git a/Task/Detect-division-by-zero/Maxima/detect-division-by-zero.maxima b/Task/Detect-division-by-zero/Maxima/detect-division-by-zero.maxima new file mode 100644 index 0000000000..c7fe5b0cc9 --- /dev/null +++ b/Task/Detect-division-by-zero/Maxima/detect-division-by-zero.maxima @@ -0,0 +1,7 @@ +f(a, b) := block([q: errcatch(a / b)], if emptyp(q) then 'error else q[1]); + +f(5, 6); +5 / 6 + +f(5, 0;) +'error diff --git a/Task/Determine-if-a-string-is-numeric/Factor/determine-if-a-string-is-numeric.factor b/Task/Determine-if-a-string-is-numeric/Factor/determine-if-a-string-is-numeric.factor new file mode 100644 index 0000000000..f900738de3 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Factor/determine-if-a-string-is-numeric.factor @@ -0,0 +1 @@ +: numeric? ( string -- ? ) string>number >boolean ; diff --git a/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric.fantom b/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric.fantom new file mode 100644 index 0000000000..18d805e00d --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Fantom/determine-if-a-string-is-numeric.fantom @@ -0,0 +1,24 @@ +class Main +{ + // function to see if str contains a number of any of built-in types + static Bool readNum (Str str) + { + int := Int.fromStr (str, 10, false) // use base 10 + if (int != null) return true + float := Float.fromStr (str, false) + if (float != null) return true + decimal := Decimal.fromStr (str, false) + if (decimal != null) return true + + return false + } + + public static Void main () + { + echo ("For '2': " + readNum ("2")) + echo ("For '-2': " + readNum ("-2")) + echo ("For '2.5': " + readNum ("2.5")) + echo ("For '2a5': " + readNum ("2a5")) + echo ("For '-2.1e5': " + readNum ("-2.1e5")) + } +} diff --git a/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-1.groovy b/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-1.groovy new file mode 100644 index 0000000000..088f2d73a8 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-1.groovy @@ -0,0 +1,9 @@ +def isNumeric = { + def formatter = java.text.NumberFormat.instance + def pos = [0] as java.text.ParsePosition + formatter.parse(it, pos) + + // if parse position index has moved to end of string + // them the whole string was numeric + pos.index == it.size() +} diff --git a/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-2.groovy b/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-2.groovy new file mode 100644 index 0000000000..1d67a1bb60 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Groovy/determine-if-a-string-is-numeric-2.groovy @@ -0,0 +1,5 @@ +println isNumeric('1') +println isNumeric('-.555') +println isNumeric('1,000,000') +println isNumeric(' 1 1 1 1 ') +println isNumeric('abcdef') diff --git a/Task/Determine-if-a-string-is-numeric/HicEst/determine-if-a-string-is-numeric.hicest b/Task/Determine-if-a-string-is-numeric/HicEst/determine-if-a-string-is-numeric.hicest new file mode 100644 index 0000000000..d37240b487 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/HicEst/determine-if-a-string-is-numeric.hicest @@ -0,0 +1,27 @@ + ! = bin + 2*int + 4*flt + 8*oct +16*hex + 32*sci + isNumeric("1001") ! 27 = 1 1 0 1 1 0 + isNumeric("123") ! 26 = 0 1 0 1 1 0 + isNumeric("1E78") ! 48 = 0 0 0 0 1 1 + isNumeric("-0.123") ! 4 = 0 0 1 0 0 1 + isNumeric("-123.456e-78") ! 32 = 0 0 0 0 0 1 + isNumeric(" 123") ! 0: leading blank + isNumeric("-123.456f-78") ! 0: illegal character f + + +FUNCTION isNumeric(string) ! true ( > 0 ), no leading/trailing blanks + CHARACTER string + b = INDEX(string, "[01]+", 128, Lbin) ! Lbin returns length found + i = INDEX(string, "-?\d+", 128, Lint) ! regular expression: 128 + f = INDEX(string, "-?\d+\.\d*", 128, Lflt) + o = INDEX(string, "[0-7]+", 128, Loct) + h = INDEX(string, "[0-9A-F]+", 128, Lhex) ! case sensitive: 1+128 + s = INDEX(string, "-?\d+\.*\d*E[+-]*\d*", 128, Lsci) + IF(anywhere) THEN ! 0 (false) by default + isNumeric = ( b > 0 ) + 2*( i > 0 ) + 4*( f > 0 ) + 8*( o > 0 ) + 16*( h > 0 ) + 32*( s > 0 ) + ELSEIF(boolean) THEN ! 0 (false) by default + isNumeric = ( b + i + f + o + h + s ) > 0 ! this would return 0 or 1 + ELSE + L = LEN(string) + isNumeric = (Lbin==L) + 2*(Lint==L) + 4*(Lflt==L) + 8*(Loct==L) + 16*(Lhex==L) + 32*(Lsci==L) + ENDIF + END diff --git a/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-1.idl b/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-1.idl new file mode 100644 index 0000000000..a51497c0f9 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-1.idl @@ -0,0 +1,6 @@ +function isnumeric,input + on_ioerror, false + test = double(input) + return, 1 + false: return, 0 +end diff --git a/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-2.idl b/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-2.idl new file mode 100644 index 0000000000..47cd02caf5 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/IDL/determine-if-a-string-is-numeric-2.idl @@ -0,0 +1,4 @@ +if isnumeric('-123.45e-2') then print, 'yes' else print, 'no' +; ==> yes +if isnumeric('picklejuice') then print, 'yes' else print, 'no' +; ==> no diff --git a/Task/Determine-if-a-string-is-numeric/Icon/determine-if-a-string-is-numeric.icon b/Task/Determine-if-a-string-is-numeric/Icon/determine-if-a-string-is-numeric.icon new file mode 100644 index 0000000000..e3caf02c12 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Icon/determine-if-a-string-is-numeric.icon @@ -0,0 +1 @@ +write(image(x), if numeric(x) then " is numeric." else " is not numeric") diff --git a/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-1.j b/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-1.j new file mode 100644 index 0000000000..11cf155310 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-1.j @@ -0,0 +1,4 @@ +isNumeric=: _ ~: _ ". ] +isNumericScalar=: 1 -: isNumeric +TXT=: ,&' a scalar numeric value.' &.> ' is not';' represents' +sayIsNumericScalar=: , TXT {::~ isNumericScalar diff --git a/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-2.j b/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-2.j new file mode 100644 index 0000000000..e9ec8001d0 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/J/determine-if-a-string-is-numeric-2.j @@ -0,0 +1,10 @@ + isNumeric '152' +1 + isNumeric '152 -3.1415926 Foo123' +1 1 0 + isNumeric '42 foo42 4.2e1 4200e-2 126r3 16b2a 42foo' +1 0 1 1 1 1 0 + isNumericScalar '152 -3.1415926 Foo123' +0 + sayIsNumericScalar '-3.1415926' +-3.1415926 represents a scalar numeric value. diff --git a/Task/Determine-if-a-string-is-numeric/Liberty-BASIC/determine-if-a-string-is-numeric.liberty b/Task/Determine-if-a-string-is-numeric/Liberty-BASIC/determine-if-a-string-is-numeric.liberty new file mode 100644 index 0000000000..1042212dbb --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Liberty-BASIC/determine-if-a-string-is-numeric.liberty @@ -0,0 +1,56 @@ +DATA "PI", "0123", "-0123", "12.30", "-12.30", "123!", "0" +DATA "0.0", ".123", "-.123", "12E3", "12E-3", "12+3", "end" + + +while n$ <> "end" + read n$ + print n$, IsNumber(n$) +wend +end + +function IsNumber(string$) + on error goto [NotNumber] + string$ = trim$(string$) + 'check for float overflow + n = val(string$) + + 'assume it is number and try to prove wrong + IsNumber = 1 + for i = 1 to len(string$) + select case mid$(string$, i, 1) + case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" + HasNumeric = 1 'to check if there are any digits + case "e", "E" + '"e" must not occur more than once + 'must not occur before digits + + if HasE > 0 or HasNumeric = 0 then + IsNumber = 0 + exit for + end if + HasE = i 'store position of "e" + HasNumeric = 0 'needs numbers after "e" + case "-", "+" + 'must be either first character or immediately after "e" + '(HasE = 0 if no occurrences yet) + if HasE <> i-1 then + IsNumber = 0 + exit for + end if + case "." + 'must not have previous points and must not come after "e" + if HasE <> 0 or HasPoint <> 0 then + IsNumber = 0 + exit for + end if + HasPoint = 1 + case else + 'no other characters allowed + IsNumber = 0 + exit for + end select + next i + 'must have digits + if HasNumeric = 0 then IsNumber = 0 + [NotNumber] +end function diff --git a/Task/Determine-if-a-string-is-numeric/Lisaac/determine-if-a-string-is-numeric.lisaac b/Task/Determine-if-a-string-is-numeric/Lisaac/determine-if-a-string-is-numeric.lisaac new file mode 100644 index 0000000000..d122bbaa74 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Lisaac/determine-if-a-string-is-numeric.lisaac @@ -0,0 +1,2 @@ +"123457".is_integer.println; +// write TRUE on stdin diff --git a/Task/Determine-if-a-string-is-numeric/Logo/determine-if-a-string-is-numeric.logo b/Task/Determine-if-a-string-is-numeric/Logo/determine-if-a-string-is-numeric.logo new file mode 100644 index 0000000000..c2e6b23d46 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Logo/determine-if-a-string-is-numeric.logo @@ -0,0 +1 @@ +show number? "-1.23 ; true diff --git a/Task/Determine-if-a-string-is-numeric/MAXScript/determine-if-a-string-is-numeric.max b/Task/Determine-if-a-string-is-numeric/MAXScript/determine-if-a-string-is-numeric.max new file mode 100644 index 0000000000..983409085c --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/MAXScript/determine-if-a-string-is-numeric.max @@ -0,0 +1,10 @@ +fn isNumeric str = +( + try + ( + (str as integer) != undefined + ) + catch(false) +) + +isNumeric "123" diff --git a/Task/Determine-if-a-string-is-numeric/Mathematica/determine-if-a-string-is-numeric.mathematica b/Task/Determine-if-a-string-is-numeric/Mathematica/determine-if-a-string-is-numeric.mathematica new file mode 100644 index 0000000000..04c2d1b29c --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Mathematica/determine-if-a-string-is-numeric.mathematica @@ -0,0 +1 @@ +NumberQ[ToExpression["02553352000242"]] diff --git a/Task/Determine-if-a-string-is-numeric/Maxima/determine-if-a-string-is-numeric.maxima b/Task/Determine-if-a-string-is-numeric/Maxima/determine-if-a-string-is-numeric.maxima new file mode 100644 index 0000000000..819dd2621d --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Maxima/determine-if-a-string-is-numeric.maxima @@ -0,0 +1 @@ +numberp(parse_string("170141183460469231731687303715884105727")); diff --git a/Task/Determine-if-a-string-is-numeric/Mirah/determine-if-a-string-is-numeric.mirah b/Task/Determine-if-a-string-is-numeric/Mirah/determine-if-a-string-is-numeric.mirah new file mode 100644 index 0000000000..f8265e9da6 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Mirah/determine-if-a-string-is-numeric.mirah @@ -0,0 +1,125 @@ +import java.text.NumberFormat +import java.text.ParsePosition +import java.util.Scanner + +# this first example relies on catching an exception, +# which is bad style and poorly performing in Java +def is_numeric?(s:string) + begin + Double.parseDouble(s) + return true + rescue + return false + end +end + +puts '123 is numeric' if is_numeric?('123') +puts '-123 is numeric' if is_numeric?('-123') +puts '123.1 is numeric' if is_numeric?('123.1') + +puts 'nil is not numeric' unless is_numeric?(nil) +puts "'' is not numeric" unless is_numeric?('') +puts 'abc is not numeric' unless is_numeric?('abc') +puts '123- is not numeric' unless is_numeric?('123-') +puts '1.2.3 is not numeric' unless is_numeric?('1.2.3') + + +# check every element of the string +def is_numeric2?(s: string) + if (s == nil || s.isEmpty()) + return false + end + if (!s.startsWith('-')) + if s.contains('-') + return false + end + end + + 0.upto(s.length()-1) do |x| + c = s.charAt(x) + if ((x == 0) && (c == '-'.charAt(0))) + # negative number + elsif (c == '.'.charAt(0)) + if (s.indexOf('.', x) > -1) + return false # more than one period + end + elsif (!Character.isDigit(c)) + return false + end + end + true +end + + +puts '123 is numeric' if is_numeric2?('123') +puts '-123 is numeric' if is_numeric2?('-123') +puts '123.1 is numeric' if is_numeric2?('123.1') + +puts 'nil is not numeric' unless is_numeric2?(nil) +puts "'' is not numeric" unless is_numeric2?('') +puts 'abc is not numeric' unless is_numeric2?('abc') +puts '123- is not numeric' unless is_numeric2?('123-') +puts '1.2.3 is not numeric' unless is_numeric2?('1.2.3') + + + +# use a regular expression +def is_numeric3?(s:string) + s == nil || s.matches("[-+]?\\d+(\\.\\d+)?") +end + +puts '123 is numeric' if is_numeric3?('123') +puts '-123 is numeric' if is_numeric3?('-123') +puts '123.1 is numeric' if is_numeric3?('123.1') + +puts 'nil is not numeric' unless is_numeric3?(nil) +puts "'' is not numeric" unless is_numeric3?('') +puts 'abc is not numeric' unless is_numeric3?('abc') +puts '123- is not numeric' unless is_numeric3?('123-') +puts '1.2.3 is not numeric' unless is_numeric3?('1.2.3') + + +# use the positional parser in the java.text.NumberFormat object +# (a more robust solution). If, after parsing, the parse position is at +# the end of the string, we can deduce that the entire string was a +# valid number. +def is_numeric4?(s:string) + return false if s == nil + formatter = NumberFormat.getInstance() + pos = ParsePosition.new(0) + formatter.parse(s, pos) + s.length() == pos.getIndex() +end + + +puts '123 is numeric' if is_numeric4?('123') +puts '-123 is numeric' if is_numeric4?('-123') +puts '123.1 is numeric' if is_numeric4?('123.1') + +puts 'nil is not numeric' unless is_numeric4?(nil) +puts "'' is not numeric" unless is_numeric4?('') +puts 'abc is not numeric' unless is_numeric4?('abc') +puts '123- is not numeric' unless is_numeric4?('123-') +puts '1.2.3 is not numeric' unless is_numeric4?('1.2.3') + + +# use the java.util.Scanner object. Very useful if you have to +# scan multiple entries. Scanner also has similar methods for longs, +# shorts, bytes, doubles, floats, BigIntegers, and BigDecimals as well +# as methods for integral types where you may input a base/radix other than +# 10 (10 is the default, which can be changed using the useRadix method). +def is_numeric5?(s:string) + return false if s == nil + Scanner sc = Scanner.new(s) + sc.hasNextDouble() +end + +puts '123 is numeric' if is_numeric5?('123') +puts '-123 is numeric' if is_numeric5?('-123') +puts '123.1 is numeric' if is_numeric5?('123.1') + +puts 'nil is not numeric' unless is_numeric5?(nil) +puts "'' is not numeric" unless is_numeric5?('') +puts 'abc is not numeric' unless is_numeric5?('abc') +puts '123- is not numeric' unless is_numeric5?('123-') +puts '1.2.3 is not numeric' unless is_numeric5?('1.2.3') diff --git a/Task/Determine-if-a-string-is-numeric/Modula-3/determine-if-a-string-is-numeric.mod3 b/Task/Determine-if-a-string-is-numeric/Modula-3/determine-if-a-string-is-numeric.mod3 new file mode 100644 index 0000000000..1c27b48eb9 --- /dev/null +++ b/Task/Determine-if-a-string-is-numeric/Modula-3/determine-if-a-string-is-numeric.mod3 @@ -0,0 +1,25 @@ +MODULE Numeric EXPORTS Main; + +IMPORT IO, Fmt, Text; + +PROCEDURE isNumeric(s: TEXT): BOOLEAN = + BEGIN + FOR i := 0 TO Text.Length(s) DO + WITH char = Text.GetChar(s, i) DO + IF i = 0 AND char = '-' THEN + EXIT; + END; + IF char >= '0' AND char <= '9' THEN + EXIT; + END; + RETURN FALSE; + END; + END; + RETURN TRUE; + END isNumeric; + +BEGIN + IO.Put("isNumeric(152) = " & Fmt.Bool(isNumeric("152")) & "\n"); + IO.Put("isNumeric(-3.1415926) = " & Fmt.Bool(isNumeric("-3.1415926")) & "\n"); + IO.Put("isNumeric(Foo123) = " & Fmt.Bool(isNumeric("Foo123")) & "\n"); +END Numeric. diff --git a/Task/Determine-if-only-one-instance-is-running/Liberty-BASIC/determine-if-only-one-instance-is-running.liberty b/Task/Determine-if-only-one-instance-is-running/Liberty-BASIC/determine-if-only-one-instance-is-running.liberty new file mode 100644 index 0000000000..3d4cb3fa67 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Liberty-BASIC/determine-if-only-one-instance-is-running.liberty @@ -0,0 +1,16 @@ +'Create a Mutex to prevent more than one instance from being open at a single time. +CallDLL #kernel32, "CreateMutexA", 0 as Long, 1 as Long, "Global\My Program" as ptr, mutex as ulong +CallDLL #kernel32, "GetLastError", LastError as Long + +if LastError = 183 then 'Error returned when a Mutex already exists + 'Close the handle if the mutex already exists + calldll #kernel32, "CloseHandle", mutex as ulong, ret as ulong + notice "An instance of My Program is currently running!" + end +end if + +'Release the Mutex/ Close the handle prior to ending the program +'Comment out these lines to allow the program to remain active to test for the mutex's presence +calldll #kernel32, "ReleaseMutex", mutex as ulong, ret as ulong +calldll #kernel32, "CloseHandle", mutex as ulong, ret as ulong +end diff --git a/Task/Determine-if-only-one-instance-is-running/Mathematica/determine-if-only-one-instance-is-running.mathematica b/Task/Determine-if-only-one-instance-is-running/Mathematica/determine-if-only-one-instance-is-running.mathematica new file mode 100644 index 0000000000..234cb9d1e0 --- /dev/null +++ b/Task/Determine-if-only-one-instance-is-running/Mathematica/determine-if-only-one-instance-is-running.mathematica @@ -0,0 +1,5 @@ +$Epilog := Print["Another instance is running "]; +If[Attributes[Global`Mutex] == {Protected}, + Exit[], + Global`Mutex[x_] := Locked; Protect[Global`Mutex]; + ] diff --git a/Task/Digital-root/J/digital-root-1.j b/Task/Digital-root/J/digital-root-1.j new file mode 100644 index 0000000000..b076c0148e --- /dev/null +++ b/Task/Digital-root/J/digital-root-1.j @@ -0,0 +1,2 @@ +digrot=: +/@(#.inv~&10)^:_ +addper=: _1 + [: # +/@(#.inv~&10)^:a: diff --git a/Task/Digital-root/J/digital-root-2.j b/Task/Digital-root/J/digital-root-2.j new file mode 100644 index 0000000000..acbcc10ae4 --- /dev/null +++ b/Task/Digital-root/J/digital-root-2.j @@ -0,0 +1,5 @@ + (, addper, digrot)&> 627615 39390 588225 393900588225 + 627615 2 9 + 39390 2 6 + 588225 2 3 +393900588225 2 9 diff --git a/Task/Digital-root/J/digital-root-3.j b/Task/Digital-root/J/digital-root-3.j new file mode 100644 index 0000000000..a3db66b958 --- /dev/null +++ b/Task/Digital-root/J/digital-root-3.j @@ -0,0 +1 @@ +equals=: =&(9&|)"0 diff --git a/Task/Digital-root/J/digital-root-4.j b/Task/Digital-root/J/digital-root-4.j new file mode 100644 index 0000000000..2f098f71ff --- /dev/null +++ b/Task/Digital-root/J/digital-root-4.j @@ -0,0 +1,15 @@ + equals table i. 10 +┌──────┬───────────────────┐ +│equals│0 1 2 3 4 5 6 7 8 9│ +├──────┼───────────────────┤ +│0 │1 0 0 0 0 0 0 0 0 1│ +│1 │0 1 0 0 0 0 0 0 0 0│ +│2 │0 0 1 0 0 0 0 0 0 0│ +│3 │0 0 0 1 0 0 0 0 0 0│ +│4 │0 0 0 0 1 0 0 0 0 0│ +│5 │0 0 0 0 0 1 0 0 0 0│ +│6 │0 0 0 0 0 0 1 0 0 0│ +│7 │0 0 0 0 0 0 0 1 0 0│ +│8 │0 0 0 0 0 0 0 0 1 0│ +│9 │1 0 0 0 0 0 0 0 0 1│ +└──────┴───────────────────┘ diff --git a/Task/Digital-root/J/digital-root-5.j b/Task/Digital-root/J/digital-root-5.j new file mode 100644 index 0000000000..bb241eae97 --- /dev/null +++ b/Task/Digital-root/J/digital-root-5.j @@ -0,0 +1,2 @@ +digrt=: +/@(#.inv)^:_ +addpr=: _1 + [: # +/@(#.inv)^:a: diff --git a/Task/Digital-root/Mathematica/digital-root.mathematica b/Task/Digital-root/Mathematica/digital-root.mathematica new file mode 100644 index 0000000000..e6cc5bb7fe --- /dev/null +++ b/Task/Digital-root/Mathematica/digital-root.mathematica @@ -0,0 +1,3 @@ +seq[n_, b_] := FixedPointList[Total[IntegerDigits[#, b]] &, n]; +root[n_Integer, base_: 10] := If[base == 10, #, BaseForm[#, base]] &[Last[seq[n, base]]] +persistance[n_Integer, base_: 10] := Length[seq[n, base]] - 2; diff --git a/Task/Dinesmans-multiple-dwelling-problem/Icon/dinesmans-multiple-dwelling-problem.icon b/Task/Dinesmans-multiple-dwelling-problem/Icon/dinesmans-multiple-dwelling-problem.icon new file mode 100644 index 0000000000..ca48b0f48a --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/Icon/dinesmans-multiple-dwelling-problem.icon @@ -0,0 +1,71 @@ +invocable all +global nameL, nameT, rules + +procedure main() # Dinesman + +nameT := table() +nameL := ["Baker", "Cooper", "Fletcher", "Miller", "Smith"] +rules := [ [ distinct ], + [ "~=", "Baker", top() ], + [ "~=", "Cooper", bottom() ], + [ "~=", "Fletcher", top() ], + [ "~=", "Fletcher", bottom() ], + [ ">", "Miller", "Cooper" ], + [ notadjacent, "Smith", "Fletcher" ], + [ notadjacent, "Fletcher", "Cooper" ], + [ showsolution ], + [ stop ] ] + +if not solve(1) then + write("No solution found.") +end + +procedure dontstop() # use if you want to search for all solutions +end + +procedure showsolution() # show the soluton + write("The solution is:") + every write(" ",n := !nameL, " lives in ", nameT[n]) + return +end + +procedure eval(n) # evaluate a rule + r := copy(rules[n-top()]) + every r[i := 2 to *r] := rv(r[i]) + if get(r)!r then suspend +end + +procedure rv(x) # return referenced value if it exists +return \nameT[x] | x +end + +procedure solve(n) # recursive solver + if n > top() then { # apply rules + if n <= top() + *rules then + ( eval(n) & solve(n+1) ) | fail + } + else # setup locations + (( nameT[nameL[n]] := bottom() to top() ) & solve(n + 1)) | fail + return +end + +procedure distinct(a,b) # ensure each name is distinct + if nameT[n := !nameL] = nameT[n ~== key(nameT)] then fail + suspend +end + +procedure notadjacent(n1,n2) # ensure n1,2 are not adjacent + if not adjacent(n1,n2) then suspend +end + +procedure adjacent(n1,n2) # ensure n1,2 are adjacent + if abs(n1 - n2) = 1 then suspend +end + +procedure bottom() # return bottom + return if *nameL > 0 then 1 else 0 +end + +procedure top() # return top + return *nameL +end diff --git a/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-1.j b/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-1.j new file mode 100644 index 0000000000..de75166084 --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-1.j @@ -0,0 +1 @@ +possible=: ((i.!5) A. i.5) { 'BCFMS' diff --git a/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-2.j b/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-2.j new file mode 100644 index 0000000000..befc0871ee --- /dev/null +++ b/Task/Dinesmans-multiple-dwelling-problem/J/dinesmans-multiple-dwelling-problem-2.j @@ -0,0 +1,9 @@ +possible=: (#~ 'B' ~: {:"1) possible NB. Baker not on top floor +possible=: (#~ 'C' ~: {."1) possible NB. Cooper not on bottom floor +possible=: (#~ 'F' ~: {:"1) possible NB. Fletcher not on top floor +possible=: (#~ 'F' ~: {."1) possible NB. Fletcher not on bottom floor +possible=: (#~ 1 ) +&&( Abs[floor["Fletcher",#] - floor["Smith",#]] > 1 ) +&&( 1 < floor["Cooper",#] < floor["Miller",#] ) +&&( 1 < floor["Fletcher",#] < 5 ) +&] [[1]] //Reverse //Column + +-> +Miller +Fletcher +Baker +Cooper +Smith diff --git a/Task/Dining-philosophers/JoCaml/dining-philosophers-1.jocaml b/Task/Dining-philosophers/JoCaml/dining-philosophers-1.jocaml new file mode 100644 index 0000000000..6463eaa117 --- /dev/null +++ b/Task/Dining-philosophers/JoCaml/dining-philosophers-1.jocaml @@ -0,0 +1,21 @@ +let random_wait n = Unix.sleep (Random.int n);; +let print s m = Printf.printf "philosopher %s is %s\n" s m; flush(stdout);; +let will_eat s = print s "eating"; random_wait 10;; +let will_think s = print s "thinking"; random_wait 20; print s "hungry";; + + (* a,b,c,d,e are thinking philosophers; ah,bh,ch,dh,eh are the same philosophers when hungry; + fab is the fork located between philosophers a and b; similarly for fbc, fcd, ... *) + +def ah() & fab() & fea() = will_eat "Aristotle"; a() & fab() & fea() + or bh() & fab() & fbc() = will_eat "Kant"; b() & fab() & fbc() + or ch() & fbc() & fcd() = will_eat "Spinoza"; c() & fbc() & fcd() + or dh() & fcd() & fde() = will_eat "Marx"; d() & fcd() & fde() + or eh() & fde() & fea() = will_eat "Russell"; e() & fde() & fea() + + and a() = will_think "Aristotle"; ah() + and b() = will_think "Kant"; bh() + and c() = will_think "Spinoza"; ch() + and d() = will_think "Marx"; dh() + and e() = will_think "Russell"; eh() +;; +spawn fab() & fbc() & fcd() & fde() & fea() & a() & b() & c() & d() & e();; diff --git a/Task/Dining-philosophers/JoCaml/dining-philosophers-2.jocaml b/Task/Dining-philosophers/JoCaml/dining-philosophers-2.jocaml new file mode 100644 index 0000000000..17daf02011 --- /dev/null +++ b/Task/Dining-philosophers/JoCaml/dining-philosophers-2.jocaml @@ -0,0 +1,47 @@ +let print s t m = Printf.printf "t=%d: philosopher %s is %s\n" t s m; flush(stdout);; +let random_wait n = Unix.sleep (Random.int n);; + +(* auxiliary function to keep track of time ticks, using integer seconds *) +def ts () & counter(n) = counter(n) & reply n to ts +or update_counter() & counter(n) = counter(n+1) & reply to update_counter +and counter_sentinel() = Unix.sleep 1; update_counter(); counter_sentinel() +;; +spawn counter(0) & counter_sentinel();; + +def stats(n, waited, maxwaited) & report_wait_time(m) = + let (n', waited', maxwaited') = (n+1, waited+m, max maxwaited m) in + Printf.printf "waiting average %f, max waited %d\n" + (float_of_int waited' /. float_of_int n') + maxwaited'; + flush(stdout); + stats(n',waited',maxwaited') & reply () to report_wait_time +;; + +spawn stats(0,0,0);; + +let eat s t = print s t "eating"; random_wait 10;; +let think s = print s (ts()) "thinking"; random_wait 20;; + +(* "p" will be a philosopher channel, to be defined later + the messages ah, bh, ... do not need to be injected now. *) + +let will_eat s t = let t' = ts() in report_wait_time(t'-t); eat s t';; + +def ah(t,p) & fab() & fea() = will_eat "Aristotle" t; p() & fab() & fea() +or bh(t,p) & fab() & fbc() = will_eat "Kant" t; p() & fab() & fbc() +or ch(t,p) & fbc() & fcd() = will_eat "Spinoza" t; p() & fbc() & fcd() +or dh(t,p) & fcd() & fde() = will_eat "Marx" t; p() & fcd() & fde() +or eh(t,p) & fde() & fea() = will_eat "Russell" t; p() & fde() & fea() +;; + +spawn fab() & fbc() & fcd() & fde() & fea();; + +(* define the thinking -> hungry transitions using local philosophers, and inject the philosophers *) +List.map + (fun (h,s) -> def p() = think s; let t = ts() in print s t "hungry"; h(t,p) in spawn p()) + [(ah,"Aristotle"); (bh,"Kant"); (ch,"Spinoza"); (dh,"Marx"); (eh,"Russell")] +;; +(* this replaces repetitive code such as that shown in the previous solution *) + +(* now we need to wait and do nothing; nobody will be able to inject godot() *) +def wait_forever() & godot() = reply () to wait_forever in wait_forever();; diff --git a/Task/Dining-philosophers/JoCaml/dining-philosophers-3.jocaml b/Task/Dining-philosophers/JoCaml/dining-philosophers-3.jocaml new file mode 100644 index 0000000000..91c8304505 --- /dev/null +++ b/Task/Dining-philosophers/JoCaml/dining-philosophers-3.jocaml @@ -0,0 +1,77 @@ +#!/usr/bin/jocamlrun jocaml + +(* eating and thinking between 0 and this-1 *) +let eating_max_interval = 10;; +let thinking_max_interval = 10;; +let number_of_philosophers = 5;; +let random_wait n = Unix.sleep (Random.int n);; + +(* counter for unique timestamp, not related to time in seconds *) +def get_current_time () & unique_ts_counter(n) = unique_ts_counter(n+1) & reply n to get_current_time;; +spawn unique_ts_counter(0);; + +(* functions that wait and print diagnostics *) +let name i = List.nth ["Aristotle"; "Kant"; "Spinoza"; "Marx"; "Russell"] i;; +let message i m = Printf.printf "philosopher %s is %s\n" (name i) m; flush(stdout);; +let eat i = message i "eating"; random_wait eating_max_interval;; +let think i = message i "thinking"; random_wait thinking_max_interval;; + +type philosopher_state_t = Eating | Hungry of int | Thinking;; + +(* initial states *) +let states = Array.make number_of_philosophers Thinking;; +(* one philosopher's processes *) +let make_philosopher i got_hungry done_eating = + def hungry() & forks() = eat i ; done_eating(i) & thinking() + and thinking() = think i; got_hungry(i) & hungry() + in spawn thinking(); forks +;; + +(* deciding who will eat first *) +let next_phil i = (i+1) mod number_of_philosophers;; +let prev_phil i = (number_of_philosophers+i-1) mod number_of_philosophers;; +let is_hungry p = match p with + | Hungry h -> true + | _ -> false;; +let not_eating p = match p with + | Eating -> false + | _ -> true;; +let is_more_hungry p q = match q with + | Hungry hj -> ( + match p with + | Hungry hi -> hi <= hj + | _ -> false + ) + | _ -> true +;; + +let may_eat_first i = + is_hungry states.(i) + && not_eating states.(next_phil i) && not_eating states.(prev_phil i) + && is_more_hungry states.(i) states.(next_phil i) + && is_more_hungry states.(i) states.(prev_phil i);; + +let decide_eating i = + if (may_eat_first i) then (states.(i) <- Eating; true) + else false;; + +def waiter(all_forks) & got_hungry(i) = + states.(i) <- Hungry (get_current_time()); + let will_eat = decide_eating i in ( + waiter(all_forks) & (if will_eat then all_forks.(i)() else 0) +) +or waiter(all_forks) & done_eating(i) = + states.(i) <- Thinking; + let next_will_eat = decide_eating (next_phil i) in + let prev_will_eat = decide_eating (prev_phil i) in ( + waiter(all_forks) + & (if next_will_eat then all_forks.(next_phil i)() else 0) + & (if prev_will_eat then all_forks.(prev_phil i)() else 0) + );; + +let all_forks = Array.init number_of_philosophers (fun i -> make_philosopher i got_hungry done_eating) +in spawn waiter(all_forks);; + +(* now we need to wait and do nothing; nobody will be able to inject godot() *) + +def wait_forever() & godot() = reply () to wait_forever in wait_forever();; diff --git a/Task/Dining-philosophers/Logtalk/dining-philosophers.logtalk b/Task/Dining-philosophers/Logtalk/dining-philosophers.logtalk new file mode 100644 index 0000000000..246e4cd119 --- /dev/null +++ b/Task/Dining-philosophers/Logtalk/dining-philosophers.logtalk @@ -0,0 +1,156 @@ +:- category(chopstick). + + % chopstick actions (picking up and putting down) are synchronized using a notification + % such that a chopstick can only be handled by a single philosopher at a time: + + :- public(pick_up/0). + pick_up :- + threaded_wait(available). + + :- public(put_down/0). + put_down :- + threaded_notify(available). + +:- end_category. + + +:- object(cs1, + imports(chopstick)). + + :- threaded. + :- initialization(threaded_notify(available)). + +:- end_object. + + +:- object(cs2, + imports(chopstick)). + + :- threaded. + :- initialization(threaded_notify(available)). + +:- end_object. + + +:- object(cs3, + imports(chopstick)). + + :- threaded. + :- initialization(threaded_notify(available)). + +:- end_object. + + +:- object(cs4, + imports(chopstick)). + + :- threaded. + :- initialization(threaded_notify(available)). + +:- end_object. + + +:- object(cs5, + imports(chopstick)). + + :- threaded. + :- initialization(threaded_notify(available)). + +:- end_object. + + +:- category(philosopher). + + :- public(left_chopstick/1). + :- public(right_chopstick/1). + :- public(run/2). + + :- private(message/1). + :- synchronized(message/1). + + :- uses(random, [random/3]). + + run(0, _) :- + this(Philosopher), + message([Philosopher, ' terminated.']). + + run(Count, MaxTime) :- + Count > 0, + think(MaxTime), + eat(MaxTime), + Count2 is Count - 1, + run(Count2, MaxTime). + + think(MaxTime):- + this(Philosopher), + random(1, MaxTime, ThinkTime), + message(['Philosopher ', Philosopher, ' thinking for ', ThinkTime, ' seconds.']), + thread_sleep(ThinkTime). + + eat(MaxTime):- + this(Philosopher), + random(1, MaxTime, EatTime), + ::left_chopstick(LeftStick), + ::right_chopstick(RightStick), + LeftStick::pick_up, + RightStick::pick_up, + message(['Philosopher ', Philosopher, ' eating for ', EatTime, ' seconds with chopsticks ', LeftStick, ' and ', RightStick, '.']), + thread_sleep(EatTime), + ::LeftStick::put_down, + ::RightStick::put_down. + + % writing a message needs to be synchronized as it's accomplished + % using a combination of individual write/1 and nl/0 calls: + message([]) :- + nl, + flush_output. + message([Atom| Atoms]) :- + write(Atom), + message(Atoms). + +:- end_category. + + +:- object(aristotle, + imports(philosopher)). + + left_chopstick(cs1). + right_chopstick(cs2). + +:- end_object. + + +:- object(kant, + imports(philosopher)). + + left_chopstick(cs2). + right_chopstick(cs3). + +:- end_object. + + +:- object(spinoza, + imports(philosopher)). + + left_chopstick(cs3). + right_chopstick(cs4). + +:- end_object. + + +:- object(marx, + imports(philosopher)). + + left_chopstick(cs4). + right_chopstick(cs5). + +:- end_object. + + +:- object(russell, + imports(philosopher)). + + left_chopstick(cs1). % change order so that the chopsticks are picked + right_chopstick(cs5). % in different order from the other philosophers + +:- end_object. diff --git a/Task/Discordian-date/Icon/discordian-date.icon b/Task/Discordian-date/Icon/discordian-date.icon new file mode 100644 index 0000000000..d33beaa4b6 --- /dev/null +++ b/Task/Discordian-date/Icon/discordian-date.icon @@ -0,0 +1,55 @@ +link printf + +procedure main() + Demo(2010,1,1) + Demo(2010,7,22) + Demo(2012,2,28) + Demo(2012,2,29) + Demo(2012,3,1) + Demo(2010,1,5) + Demo(2011,5,3) + Demo(2012,2,28) + Demo(2012,2,29) + Demo(2012,3,1) + Demo(2010,7,22) + Demo(2012,12,22) +end + +procedure Demo(y,m,d) #: demo display + printf("%i-%i-%i = %s\n",y,m,d,DiscordianDateString(DiscordianDate(y,m,d))) +end + +record DiscordianDateRecord(year,yday,season,sday,holiday) + +procedure DiscordianDate(year,month,day) #: Convert normal date to Discordian +static cal +initial cal := [31,28,31,30,31,30,31,31,30,31,30,31] + + ddate := DiscordianDateRecord(year+1166) + every (ddate.yday := day - 1) +:= cal[1 to month-1] # zero origin + ddate.sday := ddate.yday + + if ddate.year % 4 = 2 & month = 2 & day = 29 then + ddate.holiday := 1 # Note: st tibs is outside of weekdays + else { + ddate.season := (ddate.yday / 73) + 1 + ddate.sday := (ddate.yday % 73) + 1 + ddate.holiday := 1 + ddate.season * case ddate.sday of { 5 : 1; 50 : 2} + } + return ddate +end + +procedure DiscordianDateString(ddate) #: format a Discordian Date String +static days,seasons,holidays +initial { + days := ["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"] + seasons := ["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"] + holidays := ["St. Tib's Day","Mungday","Chaoflux","Mojoday","Discoflux", + "Syaday","Confuflux","Zaraday","Bureflux","Maladay","Afflux"] + } + + return (( holidays[\ddate.holiday] || "," ) | + ( days[1+ddate.yday%5] || ", day " || + ddate.sday || " of " || seasons[ddate.season])) || + " in the YOLD " || ddate.year +end diff --git a/Task/Discordian-date/J/discordian-date-1.j b/Task/Discordian-date/J/discordian-date-1.j new file mode 100644 index 0000000000..96c63f3a87 --- /dev/null +++ b/Task/Discordian-date/J/discordian-date-1.j @@ -0,0 +1,4 @@ +require'dates' +leap=: _1j1 * 0 -/@:= 4 100 400 |/ {.@] +bs=: ((#:{.) + 0 j. *@[ * {:@]) +. +disc=: ((1+0 73 bs[ +^:(58<]) -/@todayno@(,: 1 1,~{.)@]) ,~1166+{.@])~ leap diff --git a/Task/Discordian-date/J/discordian-date-2.j b/Task/Discordian-date/J/discordian-date-2.j new file mode 100644 index 0000000000..b8daed7f89 --- /dev/null +++ b/Task/Discordian-date/J/discordian-date-2.j @@ -0,0 +1,10 @@ + disc 2012 2 28 +3178 1 59 + disc 2012 2 29 +3178 1 59j1 + disc 2012 3 1 +3178 1 60j1 + disc 2012 12 31 +3178 5 73j1 + disc 2013 1 1 +3179 1 1 diff --git a/Task/Discordian-date/Mathematica/discordian-date.mathematica b/Task/Discordian-date/Mathematica/discordian-date.mathematica new file mode 100644 index 0000000000..2d489342cb --- /dev/null +++ b/Task/Discordian-date/Mathematica/discordian-date.mathematica @@ -0,0 +1,15 @@ +DiscordianDate[y_, m_, d_] := Module[{year = ToString[y + 1166], month = m, day = d}, + + DMONTHS = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"}; + DDAYS = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"}; + DayOfYear = DateDifference[{y} ,{y, m, d}] + 1; + LeapYearQ = (Mod[#, 4]== 0 && (Mod[#, 100] != 0 || Mod[#, 400] == 0))&@ y; + + If [ LeapYearQ && month == 2 && day == 29, + Print["Today is St. Tib's Day, YOLD ", ] + , + If [ LeapYearQ && DayOfYear >= 60, DayOfYear -= 1 ]; + {season, dday} = {Quotient[DayOfYear, 73], Mod[DayOfYear, 73]}; + Print["Today is ", DDAYS[[Mod[dday,4] + 1]],", ",DMONTHS[[season+1]]," ",dday,", YOLD ",year] + ]; +] diff --git a/Task/Distributed-programming/Mathematica/distributed-programming.mathematica b/Task/Distributed-programming/Mathematica/distributed-programming.mathematica new file mode 100644 index 0000000000..40212777f6 --- /dev/null +++ b/Task/Distributed-programming/Mathematica/distributed-programming.mathematica @@ -0,0 +1,2 @@ +LaunchKernels[2]; +ParallelEvaluate[RandomReal[]] diff --git a/Task/Documentation/Fancy/documentation.fancy b/Task/Documentation/Fancy/documentation.fancy new file mode 100644 index 0000000000..875dd94f92 --- /dev/null +++ b/Task/Documentation/Fancy/documentation.fancy @@ -0,0 +1,13 @@ +def class Foo { + """ + This is a docstring. Every object in Fancy can have it's own docstring. + Either defined in the source code, like this one, or by using the Object#docstring: method + """ + def a_method { + """ + Same for methods. They can have docstrings, too. + """ + } +} +Foo docstring println # prints docstring Foo class +Foo instance_method: 'a_method . docstring println # prints method's docstring diff --git a/Task/Documentation/J/documentation.j b/Task/Documentation/J/documentation.j new file mode 100644 index 0000000000..6d3f113263 --- /dev/null +++ b/Task/Documentation/J/documentation.j @@ -0,0 +1,24 @@ +NB. ========================================================= +NB.*apply v apply verb x to y +apply=: 128!:2 + +NB. ========================================================= +NB.*def c : (explicit definition) +def=: : + +NB.*define a : 0 (explicit definition script form) +define=: : 0 + +NB.*do v name for ". +do=: ". + +NB.*drop v name for }. +drop=: }. + + Note 1 +Note accepts multi-line descriptions. +Definitions display the source. +) + + usleep +3 : '''libc.so.6 usleep > i i''&(15!:0) >.y' diff --git a/Task/Documentation/Mathematica/documentation.mathematica b/Task/Documentation/Mathematica/documentation.mathematica new file mode 100644 index 0000000000..399259573c --- /dev/null +++ b/Task/Documentation/Mathematica/documentation.mathematica @@ -0,0 +1,5 @@ +f[x_,y_] := x + y (* Function comment : adds two numbers *) +f::usage = "f[x,y] gives the sum of x and y" + +?f +-> f[x,y] gives the sum of x and y diff --git a/Task/Dot-product/FALSE/dot-product.false b/Task/Dot-product/FALSE/dot-product.false new file mode 100644 index 0000000000..b6d9033938 --- /dev/null +++ b/Task/Dot-product/FALSE/dot-product.false @@ -0,0 +1,3 @@ +[[\1-$0=~][$d;2*1+\-ø\$d;2+\-ø@*@+]#]p: +3d: {Vectors' length} +1 3 5_ 4 2_ 1_ d;$1+ø@*p;!%. {Output: 3} diff --git a/Task/Dot-product/Factor/dot-product.factor b/Task/Dot-product/Factor/dot-product.factor new file mode 100644 index 0000000000..c48f452146 --- /dev/null +++ b/Task/Dot-product/Factor/dot-product.factor @@ -0,0 +1,5 @@ +USING: kernel math.vectors sequences ; + +: dot-product ( u v -- w ) + 2dup [ length ] bi@ = + [ v. ] [ "Vector lengths must be equal" throw ] if ; diff --git a/Task/Dot-product/Fantom/dot-product.fantom b/Task/Dot-product/Fantom/dot-product.fantom new file mode 100644 index 0000000000..58bba0f38b --- /dev/null +++ b/Task/Dot-product/Fantom/dot-product.fantom @@ -0,0 +1,20 @@ +class DotProduct +{ + static Int dotProduct (Int[] a, Int[] b) + { + Int result := 0 + [a.size,b.size].min.times |i| + { + result += a[i] * b[i] + } + return result + } + + public static Void main () + { + Int[] x := [1,2,3,4] + Int[] y := [2,3,4] + + echo ("Dot product of $x and $y is ${dotProduct(x, y)}") + } +} diff --git a/Task/Dot-product/GAP/dot-product.gap b/Task/Dot-product/GAP/dot-product.gap new file mode 100644 index 0000000000..7be9742cb5 --- /dev/null +++ b/Task/Dot-product/GAP/dot-product.gap @@ -0,0 +1,4 @@ +# Built-in + +[1, 3, -5]*[4, -2, -1]; +# 3 diff --git a/Task/Dot-product/Groovy/dot-product-1.groovy b/Task/Dot-product/Groovy/dot-product-1.groovy new file mode 100644 index 0000000000..37716e8e76 --- /dev/null +++ b/Task/Dot-product/Groovy/dot-product-1.groovy @@ -0,0 +1,4 @@ +def dotProduct = { x, y -> + assert x && y && x.size() == y.size() + [x, y].transpose().collect{ it[0] * it[1] }.sum() +} diff --git a/Task/Dot-product/Groovy/dot-product-2.groovy b/Task/Dot-product/Groovy/dot-product-2.groovy new file mode 100644 index 0000000000..f346f7ce8f --- /dev/null +++ b/Task/Dot-product/Groovy/dot-product-2.groovy @@ -0,0 +1 @@ +println dotProduct([1, 3, -5], [4, -2, -1]) diff --git a/Task/Dot-product/Icon/dot-product.icon b/Task/Dot-product/Icon/dot-product.icon new file mode 100644 index 0000000000..b290943a14 --- /dev/null +++ b/Task/Dot-product/Icon/dot-product.icon @@ -0,0 +1,9 @@ +procedure main() +write("a dot b := ",dotproduct([1, 3, -5],[4, -2, -1])) +end + +procedure dotproduct(a,b) #: return dot product of vectors a & b or error +if *a ~= *b & type(a) == type(b) == "list" then runerr(205,a) # invalid value +every (dp := 0) +:= a[i := 1 to *a] * b[i] +return dp +end diff --git a/Task/Dot-product/J/dot-product.j b/Task/Dot-product/J/dot-product.j new file mode 100644 index 0000000000..b8e9d31691 --- /dev/null +++ b/Task/Dot-product/J/dot-product.j @@ -0,0 +1,5 @@ + 1 3 _5 +/ . * 4 _2 _1 +3 + dotp=: +/ . * NB. Or defined as a verb (function) + 1 3 _5 dotp 4 _2 _1 +3 diff --git a/Task/Dot-product/Julia/dot-product.julia b/Task/Dot-product/Julia/dot-product.julia new file mode 100644 index 0000000000..c1b2f8c7ff --- /dev/null +++ b/Task/Dot-product/Julia/dot-product.julia @@ -0,0 +1,3 @@ +x = [1 3 -5] +y = [4 -2 -1] +z = dot(x, y) diff --git a/Task/Dot-product/K/dot-product.k b/Task/Dot-product/K/dot-product.k new file mode 100644 index 0000000000..e09f04441b --- /dev/null +++ b/Task/Dot-product/K/dot-product.k @@ -0,0 +1,5 @@ + +/1 3 -5 * 4 -2 -1 +3 + + 1 3 -5 _dot 4 -2 -1 +3 diff --git a/Task/Dot-product/Liberty-BASIC/dot-product.liberty b/Task/Dot-product/Liberty-BASIC/dot-product.liberty new file mode 100644 index 0000000000..c6bb69b588 --- /dev/null +++ b/Task/Dot-product/Liberty-BASIC/dot-product.liberty @@ -0,0 +1,24 @@ +vectorA$ = "1, 3, -5" +vectorB$ = "4, -2, -1" +print "DotProduct of ";vectorA$;" and "; vectorB$;" is "; +print DotProduct(vectorA$, vectorB$) + +'arbitrary length +vectorA$ = "3, 14, 15, 9, 26" +vectorB$ = "2, 71, 18, 28, 1" +print "DotProduct of ";vectorA$;" and "; vectorB$;" is "; +print DotProduct(vectorA$, vectorB$) + +end + +function DotProduct(a$, b$) + DotProduct = 0 + i = 1 + while 1 + x$=word$( a$, i, ",") + y$=word$( b$, i, ",") + if x$="" or y$="" then exit function + DotProduct = DotProduct + val(x$)*val(y$) + i = i+1 + wend +end function diff --git a/Task/Dot-product/Logo/dot-product.logo b/Task/Dot-product/Logo/dot-product.logo new file mode 100644 index 0000000000..10561054b0 --- /dev/null +++ b/Task/Dot-product/Logo/dot-product.logo @@ -0,0 +1,5 @@ +to dotprod :a :b + output apply "sum (map "product :a :b) +end + +show dotprod [1 3 -5] [4 -2 -1] ; 3 diff --git a/Task/Dot-product/Logtalk/dot-product.logtalk b/Task/Dot-product/Logtalk/dot-product.logtalk new file mode 100644 index 0000000000..c694436302 --- /dev/null +++ b/Task/Dot-product/Logtalk/dot-product.logtalk @@ -0,0 +1,7 @@ +dot_product(A, B, Sum) :- + dot_product(A, B, 0, Sum). + +dot_product([], [], Sum, Sum). +dot_product([A| As], [B| Bs], Acc, Sum) :- + Acc2 is Acc + A*B, + dot_product(As, Bs, Acc2, Sum). diff --git a/Task/Dot-product/MUMPS/dot-product.mumps b/Task/Dot-product/MUMPS/dot-product.mumps new file mode 100644 index 0000000000..6b94761e96 --- /dev/null +++ b/Task/Dot-product/MUMPS/dot-product.mumps @@ -0,0 +1,9 @@ +DOTPROD(A,B) + ;Returns the dot product of two vectors. Vectors are assumed to be stored as caret-delimited strings of numbers. + ;If the vectors are not of equal length, a null string is returned. + QUIT:$LENGTH(A,"^")'=$LENGTH(B,"^") "" + NEW I,SUM + SET SUM=0 + FOR I=1:1:$LENGTH(A,"^") SET SUM=SUM+($PIECE(A,"^",I)*$PIECE(B,"^",I)) + KILL I + QUIT SUM diff --git a/Task/Dot-product/Mathematica/dot-product.mathematica b/Task/Dot-product/Mathematica/dot-product.mathematica new file mode 100644 index 0000000000..8a11f2990f --- /dev/null +++ b/Task/Dot-product/Mathematica/dot-product.mathematica @@ -0,0 +1 @@ +{1,3,-5}.{4,-2,-1} diff --git a/Task/Dot-product/Maxima/dot-product.maxima b/Task/Dot-product/Maxima/dot-product.maxima new file mode 100644 index 0000000000..dd98fb5323 --- /dev/null +++ b/Task/Dot-product/Maxima/dot-product.maxima @@ -0,0 +1,2 @@ +[1, 3, -5] . [4, -2, -1]; +/* 3 */ diff --git a/Task/Dot-product/Mercury/dot-product.mercury b/Task/Dot-product/Mercury/dot-product.mercury new file mode 100644 index 0000000000..7206bf7a4b --- /dev/null +++ b/Task/Dot-product/Mercury/dot-product.mercury @@ -0,0 +1,17 @@ +:- module dot_product. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list. + +main(!IO) :- + io.write_int([1, 3, -5] `dot_product` [4, -2, -1], !IO), + io.nl(!IO). + +:- func dot_product(list(int), list(int)) = int. + +dot_product(As, Bs) = + list.foldl_corresponding((func(A, B, Acc) = Acc + A * B), As, Bs, 0). diff --git a/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-1.j b/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-1.j new file mode 100644 index 0000000000..87f3b7cfea --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-1.j @@ -0,0 +1,6 @@ +coclass'DoublyLinkedListElement' +create=:3 :0 + this=:coname'' + 'predecessor successor data'=:y + successor__predecessor=: predecessor__successor=: this +) diff --git a/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-2.j b/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-2.j new file mode 100644 index 0000000000..ce0b36e77d --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/J/doubly-linked-list-element-definition-2.j @@ -0,0 +1,4 @@ +coclass'DoublyLinkedListHead' +create=:3 :0 + predecessor=:successor=:this=: coname'' +) diff --git a/Task/Doubly-linked-list-Element-definition/Modula-2/doubly-linked-list-element-definition.mod2 b/Task/Doubly-linked-list-Element-definition/Modula-2/doubly-linked-list-element-definition.mod2 new file mode 100644 index 0000000000..aac65cf20d --- /dev/null +++ b/Task/Doubly-linked-list-Element-definition/Modula-2/doubly-linked-list-element-definition.mod2 @@ -0,0 +1,6 @@ +TYPE + Link = POINTER TO LinkRcd; + LinkRcd = RECORD + Prev, Next: Link; + Data: INTEGER + END; diff --git a/Task/Doubly-linked-list-Traversal/J/doubly-linked-list-traversal.j b/Task/Doubly-linked-list-Traversal/J/doubly-linked-list-traversal.j new file mode 100644 index 0000000000..1b106031d6 --- /dev/null +++ b/Task/Doubly-linked-list-Traversal/J/doubly-linked-list-traversal.j @@ -0,0 +1,8 @@ +traverse=:1 :0 + work=. result=. conew 'DoublyLinkedListHead' + current=. y + while. y ~: current=. successor__current do. + work=. (work;result;0 + print tab(2);dechex$(hCurrent);" ";Block.name$(hCurrent);" ";Block.age(hCurrent) + hCurrent=Block.next(hCurrent) + wend + + print + print "-Deleting first, middle, and last person." + + call Delete FirstUser'1 + call Delete MiddleUser'2 + call Delete LastUser'3 + + print + print "-Traversing the list backwards" + hCurrent=hLast + while hCurrent<>0 + print tab(2);dechex$(hCurrent);" ";Block.name$(hCurrent);" ";Block.age(hCurrent) + hCurrent=Block.prev(hCurrent) + wend + +call Uninit + +end + + +function Block.next(hBlock) + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + Block.next=block.nxt.struct +end function + +function Block.prev(hBlock) + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + Block.prev=block.prev.struct +end function + +function Block.age(hBlock) + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + Block.age=block.age.struct +end function + +function Block.name$(hBlock) + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + Block.name$=block.nm.struct +end function + +sub Block.age hBlock,age + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + block.age.struct=age + calldll #kernel32,"RtlMoveMemory",hBlock as ulong,block as struct,blockSize as long,ret as void +end sub + +sub Block.name hBlock,name$ + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + block.nm.struct=name$ + calldll #kernel32,"RtlMoveMemory",hBlock as ulong,block as struct,blockSize as long,ret as void +end sub + +sub Block.next hBlock,nxt + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + block.nxt.struct=nxt + calldll #kernel32,"RtlMoveMemory",hBlock as ulong,block as struct,blockSize as long,ret as void +end sub + +sub Block.prev hBlock,prev + calldll #kernel32,"RtlMoveMemory",block as struct,hBlock as ulong,blockSize as long,ret as void + block.prev.struct=prev + calldll #kernel32,"RtlMoveMemory",hBlock as ulong,block as struct,blockSize as long,ret as void +end sub + +function New(name$,age) + calldll #kernel32,"HeapAlloc",hHeap as ulong,_HEAP_ZERO_MEMORY as ulong,blockSize as long,New as ulong + if New<>0 then + blockCount=blockCount+1 + if hFirst=0 then + hFirst=New + hLast=New + else + call Block.next hLast,New + call Block.prev New,hLast + hLast=New + end if + call Block.name New,name$ + call Block.age New,age + end if +end function + +sub Delete hBlock + if hBlock<>0 then + blockCount=blockCount-1 + if blockCount=0 then + hFirst=0 + hLast=0 + else + if hBlock=hFirst then + hFirst=Block.next(hBlock) + call Block.prev hFirst,0 + else + if hBlock=hLast then + hLast=Block.prev(hBlock) + call Block.next hLast,0 + else + call Block.next Block.prev(hBlock),Block.next(hBlock) + call Block.prev Block.next(hBlock),Block.prev(hBlock) + end if + end if + end if + calldll #kernel32,"HeapFree",hHeap as ulong,0 as long,hBlock as ulong,ret as void + end if +end sub + + +sub Init + calldll #kernel32,"HeapCreate",0 as long,10000 as long,0 as long,hHeap as ulong +end sub + +sub Uninit + calldll #kernel32,"HeapDestroy",hHeap as ulong,ret as void +end sub diff --git a/Task/Draw-a-cuboid/J/draw-a-cuboid.j b/Task/Draw-a-cuboid/J/draw-a-cuboid.j new file mode 100644 index 0000000000..f56586ee76 --- /dev/null +++ b/Task/Draw-a-cuboid/J/draw-a-cuboid.j @@ -0,0 +1,22 @@ + vectors =. ((% +/&.:*:"1) _1 1 0,:_1 _1 3) +/@:*"1/~ 2 3 4*=i.3 + ' .*o' {~ +/ 1 2 3* (|:"2 -."_ 1~ vectors) ([:*./ 1 = 0 1 I. %.~)"_ 1"_1 _ ]4j21 ,~"0/&:i: 4j41 + + + + + + + + oooo + ooooooooooooo + oooooooooooooo.... + *****oooo......... + *******........... + *******........... + *******........... + *******........... + *******........... + *******........... + *******........... + *******......... + *****..... diff --git a/Task/Draw-a-cuboid/LSL/draw-a-cuboid.lsl b/Task/Draw-a-cuboid/LSL/draw-a-cuboid.lsl new file mode 100644 index 0000000000..0d6097b52c --- /dev/null +++ b/Task/Draw-a-cuboid/LSL/draw-a-cuboid.lsl @@ -0,0 +1,6 @@ +vector vSCALE = <2.0, 3.0, 4.0>; +default { + state_entry() { + llSetScale(vSCALE); + } +} diff --git a/Task/Draw-a-cuboid/Logo/draw-a-cuboid-1.logo b/Task/Draw-a-cuboid/Logo/draw-a-cuboid-1.logo new file mode 100644 index 0000000000..c5ffbbbf14 --- /dev/null +++ b/Task/Draw-a-cuboid/Logo/draw-a-cuboid-1.logo @@ -0,0 +1,14 @@ +to cuboid :l1 :l2 :l3 +cs perspective ;making the room ready to use +setxyz :l1 0 0 +setxyz :l1 :l2 0 +setxyz 0 :l2 0 +setxyz 0 0 0 +setxyz :l1 0 0 +setxyz :l1 0 -:l3 +setxyz :l1 :l2 -:l3 +setxyz :l1 :l2 0 +setxyz 0 :l2 0 +setxyz 0 :l2 -:l3 +setxyz :l1 :l2 -:l3 +end diff --git a/Task/Draw-a-cuboid/Logo/draw-a-cuboid-2.logo b/Task/Draw-a-cuboid/Logo/draw-a-cuboid-2.logo new file mode 100644 index 0000000000..084c856e4c --- /dev/null +++ b/Task/Draw-a-cuboid/Logo/draw-a-cuboid-2.logo @@ -0,0 +1 @@ +cuboid 50 100 150 diff --git a/Task/Draw-a-cuboid/Mathematica/draw-a-cuboid.mathematica b/Task/Draw-a-cuboid/Mathematica/draw-a-cuboid.mathematica new file mode 100644 index 0000000000..d937962fa1 --- /dev/null +++ b/Task/Draw-a-cuboid/Mathematica/draw-a-cuboid.mathematica @@ -0,0 +1 @@ +Graphics3D[Cuboid[{0,0,0},{2,3,4}]] diff --git a/Task/Draw-a-cuboid/Maxima/draw-a-cuboid.maxima b/Task/Draw-a-cuboid/Maxima/draw-a-cuboid.maxima new file mode 100644 index 0000000000..ba85cc62e8 --- /dev/null +++ b/Task/Draw-a-cuboid/Maxima/draw-a-cuboid.maxima @@ -0,0 +1,6 @@ +load(draw)$ + +draw3d(xu_grid=100, yv_grid=100, surface_hide=true, + palette=gray, enhanced3d=[x - z / 4 - y / 4, x, y, z], + implicit(max(abs(x / 4), abs(y / 6), abs(z / 8)) = 1, + x,-10,10,y,-10,10,z,-10,10))$ diff --git a/Task/Draw-a-sphere/J/draw-a-sphere-1.j b/Task/Draw-a-sphere/J/draw-a-sphere-1.j new file mode 100644 index 0000000000..b2bd7bb7f2 --- /dev/null +++ b/Task/Draw-a-sphere/J/draw-a-sphere-1.j @@ -0,0 +1 @@ +load 'system/examples/graphics/opengl/simple/sphere.ijs' diff --git a/Task/Draw-a-sphere/J/draw-a-sphere-2.j b/Task/Draw-a-sphere/J/draw-a-sphere-2.j new file mode 100644 index 0000000000..d97a96eb72 --- /dev/null +++ b/Task/Draw-a-sphere/J/draw-a-sphere-2.j @@ -0,0 +1,8 @@ +'R k ambient' =. 10 2 0.4 +light =. (% +/&.:*:) 30 30 _50 +pts =. (0&*^:(0={:))@:(,,(0>.(*:R)-+)&.*:)"0/~ i:15j200 +luminosity =. (>:ambient) %~ (ambient * * +/&.:*:"1 pts) + k^~ 0>. R%~ pts +/@:*"1 -light + +load 'viewmat' +togreyscale =. 256 #. [: <. 255 255 255 *"1 0 ] +'rgb' viewmat togreyscale luminosity diff --git a/Task/Draw-a-sphere/Liberty-BASIC/draw-a-sphere.liberty b/Task/Draw-a-sphere/Liberty-BASIC/draw-a-sphere.liberty new file mode 100644 index 0000000000..735550a7b8 --- /dev/null +++ b/Task/Draw-a-sphere/Liberty-BASIC/draw-a-sphere.liberty @@ -0,0 +1,26 @@ +WindowWidth =420 +WindowHeight =460 + +nomainwin + +open "Sphere" for graphics_nsb_nf as #w + +#w "down ; fill lightgray" + +xS =200 +yS =200 +for radius =150 to 0 step -1 + level$ =str$( int( 256 -256 *radius /150)) + c$ =level$ +" " +level$ +" " +level$ + #w "color "; c$ + #w "backcolor "; c$ + #w "place "; xS; " "; yS + xS =xS -0.5 + yS =yS -0.2 + #w "circlefilled "; radius +next radius + +#w "flush" +wait +close #w +end diff --git a/Task/Draw-a-sphere/Logo/draw-a-sphere.logo b/Task/Draw-a-sphere/Logo/draw-a-sphere.logo new file mode 100644 index 0000000000..04204f24c5 --- /dev/null +++ b/Task/Draw-a-sphere/Logo/draw-a-sphere.logo @@ -0,0 +1,5 @@ +to sphere :r +cs perspective ht ;making the room ready to use +repeat 180 [polystart circle :r polyend down 1] +polyview +end diff --git a/Task/Draw-a-sphere/Mathematica/draw-a-sphere.mathematica b/Task/Draw-a-sphere/Mathematica/draw-a-sphere.mathematica new file mode 100644 index 0000000000..05da40b277 --- /dev/null +++ b/Task/Draw-a-sphere/Mathematica/draw-a-sphere.mathematica @@ -0,0 +1 @@ +Graphics3D[Sphere[{0,0,0},1]] diff --git a/Task/Draw-a-sphere/Maxima/draw-a-sphere.maxima b/Task/Draw-a-sphere/Maxima/draw-a-sphere.maxima new file mode 100644 index 0000000000..53b3456095 --- /dev/null +++ b/Task/Draw-a-sphere/Maxima/draw-a-sphere.maxima @@ -0,0 +1,11 @@ +/* Two solutions */ +plot3d(1, [theta, 0, %pi], [phi, 0, 2 * %pi], +[transform_xy, spherical_to_xyz], [grid, 30, 60], +[box, false], [legend, false])$ + +load(draw)$ +draw3d(xu_grid=30, yv_grid=60, surface_hide=true, + parametric_surface(cos(phi)*sin(theta), + sin(phi)*sin(theta), + cos(theta), + theta, 0, %pi, phi, 0, 2 * %pi))$ diff --git a/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-1.j b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-1.j new file mode 100644 index 0000000000..e979f9ffef --- /dev/null +++ b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-1.j @@ -0,0 +1 @@ +i2b=: {&(;:'red white blue') diff --git a/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-2.j b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-2.j new file mode 100644 index 0000000000..f564c04ad7 --- /dev/null +++ b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-2.j @@ -0,0 +1 @@ +b2i=: i2b inv diff --git a/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-3.j b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-3.j new file mode 100644 index 0000000000..749124a248 --- /dev/null +++ b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-3.j @@ -0,0 +1,5 @@ + BALLS=: i2b ?20#3 + BALLS +┌────┬───┬────┬───┬───┬─────┬─────┬─────┬────┬────┬─────┬────┬────┬───┬────┬───┬─────┬───┬────┬───┐ +│blue│red│blue│red│red│white│white│white│blue│blue│white│blue│blue│red│blue│red│white│red│blue│red│ +└────┴───┴────┴───┴───┴─────┴─────┴─────┴────┴────┴─────┴────┴────┴───┴────┴───┴─────┴───┴────┴───┘ diff --git a/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-4.j b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-4.j new file mode 100644 index 0000000000..79b203affa --- /dev/null +++ b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-4.j @@ -0,0 +1,4 @@ + /:~&.b2i BALLS +┌───┬───┬───┬───┬───┬───┬───┬─────┬─────┬─────┬─────┬─────┬────┬────┬────┬────┬────┬────┬────┬────┐ +│red│red│red│red│red│red│red│white│white│white│white│white│blue│blue│blue│blue│blue│blue│blue│blue│ +└───┴───┴───┴───┴───┴───┴───┴─────┴─────┴─────┴─────┴─────┴────┴────┴────┴────┴────┴────┴────┴────┘ diff --git a/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-5.j b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-5.j new file mode 100644 index 0000000000..f1f09cbf7b --- /dev/null +++ b/Task/Dutch-national-flag-problem/J/dutch-national-flag-problem-5.j @@ -0,0 +1 @@ + assert@(-: /:~)&b2i /:~&.b2i BALLS diff --git a/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-1.logo b/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-1.logo new file mode 100644 index 0000000000..e9a2621418 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-1.logo @@ -0,0 +1,68 @@ +; We'll just use words for the balls +make "colors {red white blue} + +; to get a mapping from colors back to a numeric value, +; we make variables out of the color names (e.g. the variable +; "red" has value "1"). +foreach arraytolist :colors [ + make ? # +] + +; Make a random list of a given size +to random_balls :n + local "balls + make "balls array n + repeat n [ + setitem # :balls pick :colors + ] + output :balls +end + +; Test for Dutchness +to dutch? :array + output dutchlist? arraytolist :array +end + +; List is easier than array to test +to dutchlist? :list + output cond [ + [(less? count :list 2) "true] + [(greater? thing first :list thing item 2 :list) "false ] + [else dutchlist? butfirst :list] + ] +end + +; But array is better for sorting algorithm +to dutch :array + local "lo + make "lo 0 + local "hi + make "hi sum 1 count :array + local "i + make "i 1 + while [:i < :hi] [ + case (item :i :array) [ + [[red] + make "lo sum :lo 1 + swap :array :lo :i + make "i sum :i 1 + ] + [[white] + make "i sum :i 1 + ] + [[blue] + make "hi difference :hi 1 + swap :array :hi :i + ] + ] + ] + output :array +end + +; utility routine to swap array elements +to swap :array :a :b + local "temp + make "temp item :a :array + setitem :a :array item :b :array + setitem :b :array :temp +end diff --git a/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-2.logo b/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-2.logo new file mode 100644 index 0000000000..277ff0f2b0 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Logo/dutch-national-flag-problem-2.logo @@ -0,0 +1,7 @@ +do.while [ + make "list random_balls 10 +] [dutch? :list] + +print (sentence [Start list:] arraytolist :list) +print (sentence [Sorted:] arraytolist dutch :list) +bye diff --git a/Task/Dutch-national-flag-problem/Mathematica/dutch-national-flag-problem.mathematica b/Task/Dutch-national-flag-problem/Mathematica/dutch-national-flag-problem.mathematica new file mode 100644 index 0000000000..44cd140f90 --- /dev/null +++ b/Task/Dutch-national-flag-problem/Mathematica/dutch-national-flag-problem.mathematica @@ -0,0 +1 @@ +flagSort[data_List] := Sort[data, (#1 === RED || #2 === BLUE) &] diff --git a/Task/Dynamic-variable-names/GAP/dynamic-variable-names.gap b/Task/Dynamic-variable-names/GAP/dynamic-variable-names.gap new file mode 100644 index 0000000000..33e9f11fe8 --- /dev/null +++ b/Task/Dynamic-variable-names/GAP/dynamic-variable-names.gap @@ -0,0 +1,4 @@ +# As is, will not work if val is a String +Assign := function(var, val) + Read(InputTextString(Concatenation(var, " := ", String(val), ";"))); +end; diff --git a/Task/Dynamic-variable-names/Genyris/dynamic-variable-names.genyris b/Task/Dynamic-variable-names/Genyris/dynamic-variable-names.genyris new file mode 100644 index 0000000000..9cf8f1d846 --- /dev/null +++ b/Task/Dynamic-variable-names/Genyris/dynamic-variable-names.genyris @@ -0,0 +1,2 @@ +defvar (intern 'This is not a pipe.') 42 +define || 2009 diff --git a/Task/Dynamic-variable-names/Groovy/dynamic-variable-names.groovy b/Task/Dynamic-variable-names/Groovy/dynamic-variable-names.groovy new file mode 100644 index 0000000000..b77e9678d5 --- /dev/null +++ b/Task/Dynamic-variable-names/Groovy/dynamic-variable-names.groovy @@ -0,0 +1,6 @@ +def varname = 'foo' +def value = 42 + +new GroovyShell(this.binding).evaluate("${varname} = ${value}") + +assert foo == 42 diff --git a/Task/Dynamic-variable-names/Icon/dynamic-variable-names.icon b/Task/Dynamic-variable-names/Icon/dynamic-variable-names.icon new file mode 100644 index 0000000000..2670e495ff --- /dev/null +++ b/Task/Dynamic-variable-names/Icon/dynamic-variable-names.icon @@ -0,0 +1,5 @@ +procedure main(arglist) +if *arglist = 0 then stop("Provide the names of variables in the argument list") +&dump := 1 # dump program state information and variables after run +every variable(!arglist) := 1 # set each user specified variable name in arglist to 1 +end diff --git a/Task/Dynamic-variable-names/J/dynamic-variable-names-1.j b/Task/Dynamic-variable-names/J/dynamic-variable-names-1.j new file mode 100644 index 0000000000..f1da048363 --- /dev/null +++ b/Task/Dynamic-variable-names/J/dynamic-variable-names-1.j @@ -0,0 +1,2 @@ +require 'misc' +(prompt 'Enter variable name: ')=: 0 diff --git a/Task/Dynamic-variable-names/J/dynamic-variable-names-2.j b/Task/Dynamic-variable-names/J/dynamic-variable-names-2.j new file mode 100644 index 0000000000..243910165c --- /dev/null +++ b/Task/Dynamic-variable-names/J/dynamic-variable-names-2.j @@ -0,0 +1,5 @@ + require 'misc' + (prompt 'Enter variable name: ')=: 0 +Enter variable name: FOO + FOO +0 diff --git a/Task/Dynamic-variable-names/J/dynamic-variable-names-3.j b/Task/Dynamic-variable-names/J/dynamic-variable-names-3.j new file mode 100644 index 0000000000..a2700077af --- /dev/null +++ b/Task/Dynamic-variable-names/J/dynamic-variable-names-3.j @@ -0,0 +1 @@ +(userDefined)=: 0 diff --git a/Task/Dynamic-variable-names/Logo/dynamic-variable-names.logo b/Task/Dynamic-variable-names/Logo/dynamic-variable-names.logo new file mode 100644 index 0000000000..431d159dfe --- /dev/null +++ b/Task/Dynamic-variable-names/Logo/dynamic-variable-names.logo @@ -0,0 +1,5 @@ +? make readword readword +julie +12 +? show :julie +12 diff --git a/Task/Dynamic-variable-names/M4/dynamic-variable-names.m4 b/Task/Dynamic-variable-names/M4/dynamic-variable-names.m4 new file mode 100644 index 0000000000..48b758a120 --- /dev/null +++ b/Task/Dynamic-variable-names/M4/dynamic-variable-names.m4 @@ -0,0 +1,5 @@ +Enter foo, please. +define(`inp',esyscmd(`echoinp')) +define(`trim',substr(inp,0,decr(len(inp)))) +define(trim,42) +foo diff --git a/Task/Dynamic-variable-names/MUMPS/dynamic-variable-names.mumps b/Task/Dynamic-variable-names/MUMPS/dynamic-variable-names.mumps new file mode 100644 index 0000000000..dad7136e18 --- /dev/null +++ b/Task/Dynamic-variable-names/MUMPS/dynamic-variable-names.mumps @@ -0,0 +1,12 @@ +USER>KILL ;Clean up workspace + +USER>WRITE ;show all variables and definitions + +USER>READ "Enter a variable name: ",A +Enter a variable name: GIBBERISH +USER>SET @A=3.14159 + +USER>WRITE + +A="GIBBERISH" +GIBBERISH=3.14159 diff --git a/Task/Dynamic-variable-names/Mathematica/dynamic-variable-names.mathematica b/Task/Dynamic-variable-names/Mathematica/dynamic-variable-names.mathematica new file mode 100644 index 0000000000..72f5c4a78a --- /dev/null +++ b/Task/Dynamic-variable-names/Mathematica/dynamic-variable-names.mathematica @@ -0,0 +1,4 @@ +varname = InputString["Enter a variable name"]; +varvalue = InputString["Enter a value"]; +ReleaseHold[ Hold[Set["nameholder", "value"]] /. {"nameholder" -> Symbol[varname], "value" -> varvalue}]; +Print[varname, " is now set to ", Symbol[varname]] diff --git a/Task/Dynamic-variable-names/Maxima/dynamic-variable-names.maxima b/Task/Dynamic-variable-names/Maxima/dynamic-variable-names.maxima new file mode 100644 index 0000000000..2259b0e24e --- /dev/null +++ b/Task/Dynamic-variable-names/Maxima/dynamic-variable-names.maxima @@ -0,0 +1,2 @@ +/* Use :: for indirect assignment */ +block([name: read("name?"), x: read("value?")], name :: x); diff --git a/Task/Echo-server/Factor/echo-server.factor b/Task/Echo-server/Factor/echo-server.factor new file mode 100644 index 0000000000..a154c9b263 --- /dev/null +++ b/Task/Echo-server/Factor/echo-server.factor @@ -0,0 +1,17 @@ +USING: accessors io io.encodings.utf8 io.servers.connection +threads ; +IN: rosetta.echo + +CONSTANT: echo-port 12321 + +: handle-client ( -- ) + [ write "\r\n" write flush ] each-line ; + +: ( -- threaded-server ) + utf8 + "echo-server" >>name + echo-port >>insecure + [ handle-client ] >>handler ; + +: start-echo-server ( -- threaded-server ) + [ start-server ] in-thread ; diff --git a/Task/Element-wise-operations/J/element-wise-operations.j b/Task/Element-wise-operations/J/element-wise-operations.j new file mode 100644 index 0000000000..1c81dffa49 --- /dev/null +++ b/Task/Element-wise-operations/J/element-wise-operations.j @@ -0,0 +1,24 @@ + scalar =: 10 + vector =: 2 3 5 + matrix =: 3 3 $ 7 11 13 17 19 23 29 31 37 + + scalar * scalar +100 + scalar * vector +20 30 50 + scalar * matrix + 70 110 130 +170 190 230 +290 310 370 + + vector * vector +4 9 25 + vector * matrix + 14 22 26 + 51 57 69 +145 155 185 + + matrix * matrix + 49 121 169 +289 361 529 +841 961 1369 diff --git a/Task/Element-wise-operations/K/element-wise-operations.k b/Task/Element-wise-operations/K/element-wise-operations.k new file mode 100644 index 0000000000..6c7657157d --- /dev/null +++ b/Task/Element-wise-operations/K/element-wise-operations.k @@ -0,0 +1,24 @@ + scalar: 10 + vector: 2 3 5 + matrix: 3 3 # 7 11 13 17 19 23 29 31 37 + + scalar * scalar +100 + scalar * vector +20 30 50 + scalar * matrix +(70 110 130 + 170 190 230 + 290 310 370) + + vector * vector +4 9 25 + vector * matrix +(14 22 26 + 51 57 69 + 145 155 185) + + matrix * matrix +(49 121 169 + 289 361 529 + 841 961 1369) diff --git a/Task/Element-wise-operations/Mathematica/element-wise-operations.mathematica b/Task/Element-wise-operations/Mathematica/element-wise-operations.mathematica new file mode 100644 index 0000000000..82a97abc2b --- /dev/null +++ b/Task/Element-wise-operations/Mathematica/element-wise-operations.mathematica @@ -0,0 +1,32 @@ +S = 10 ; M = {{7, 11, 13}, {17 , 19, 23} , {29, 31, 37}}; +M + S +M - S +M * S +M / S +M ^ S + +M + M +M - M +M * M +M / M +M ^ M + +Gives: + +->{{17, 21, 23}, {27, 29, 33}, {39, 41, 47}} +->{{-3, 1, 3}, {7, 9, 13}, {19, 21, 27}} +->{{70, 110, 130}, {170, 190, 230}, {290, 310, 370}} +->{{7/10, 11/10, 13/10}, {17/10, 19/10, 23/10}, {29/10, 31/10, 37/10}} +->{{282475249, 25937424601, 137858491849}, {2015993900449, + 6131066257801, 41426511213649}, {420707233300201, 819628286980801, + 4808584372417849}} + +->{{14, 22, 26}, {34, 38, 46}, {58, 62, 74}} +->{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} +->{{49, 121, 169}, {289, 361, 529}, {841, 961, 1369}} +->{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}} +->{{823543, 285311670611, 302875106592253}, {827240261886336764177, + 1978419655660313589123979, + 20880467999847912034355032910567}, {2567686153161211134561828214731016126483469, + 17069174130723235958610643029059314756044734431, + 10555134955777783414078330085995832946127396083370199442517}} diff --git a/Task/Element-wise-operations/Maxima/element-wise-operations.maxima b/Task/Element-wise-operations/Maxima/element-wise-operations.maxima new file mode 100644 index 0000000000..843767481a --- /dev/null +++ b/Task/Element-wise-operations/Maxima/element-wise-operations.maxima @@ -0,0 +1,11 @@ +a: matrix([1, 2], [3, 4]); +b: matrix([2, 4], [3, 1]); + +a * b; +a / b; +a + b; +a - b; +a^3; +a^b; /* won't work */ +fullmapl("^", a, b); +sin(a); diff --git a/Task/Empty-directory/Groovy/empty-directory-1.groovy b/Task/Empty-directory/Groovy/empty-directory-1.groovy new file mode 100644 index 0000000000..952baef099 --- /dev/null +++ b/Task/Empty-directory/Groovy/empty-directory-1.groovy @@ -0,0 +1,4 @@ +def isDirEmpty = { dirName -> + def dir = new File(dirName) + dir.exists() && dir.directory && (dir.list() as List).empty +} diff --git a/Task/Empty-directory/Groovy/empty-directory-2.groovy b/Task/Empty-directory/Groovy/empty-directory-2.groovy new file mode 100644 index 0000000000..4d1fc06cd8 --- /dev/null +++ b/Task/Empty-directory/Groovy/empty-directory-2.groovy @@ -0,0 +1,9 @@ +def currentDir = new File('.') +def random = new Random() +def subDirName = "dir${random.nextInt(100000)}" +def subDir = new File(subDirName) +subDir.mkdir() +subDir.deleteOnExit() + +assert ! isDirEmpty('.') +assert isDirEmpty(subDirName) diff --git a/Task/Empty-directory/J/empty-directory-1.j b/Task/Empty-directory/J/empty-directory-1.j new file mode 100644 index 0000000000..ab8c438801 --- /dev/null +++ b/Task/Empty-directory/J/empty-directory-1.j @@ -0,0 +1,2 @@ +require 'dir' +empty_dir=: 0 = '/*' #@dir@,~ ] diff --git a/Task/Empty-directory/J/empty-directory-2.j b/Task/Empty-directory/J/empty-directory-2.j new file mode 100644 index 0000000000..6905c40f21 --- /dev/null +++ b/Task/Empty-directory/J/empty-directory-2.j @@ -0,0 +1,5 @@ +$ mkdir /tmp/a +$ touch /tmp/a/... +$ mkdir /tmp/b +$ mkdir /tmp/c +$ mkdir /tmp/c/d diff --git a/Task/Empty-directory/J/empty-directory-3.j b/Task/Empty-directory/J/empty-directory-3.j new file mode 100644 index 0000000000..cc83d429b2 --- /dev/null +++ b/Task/Empty-directory/J/empty-directory-3.j @@ -0,0 +1,6 @@ + empty_dir 'c:/cygwin/tmp/a' +0 + empty_dir 'c:/cygwin/tmp/b' +1 + empty_dir 'c:/cygwin/tmp/c' +0 diff --git a/Task/Empty-directory/Liberty-BASIC/empty-directory.liberty b/Task/Empty-directory/Liberty-BASIC/empty-directory.liberty new file mode 100644 index 0000000000..403f76cf58 --- /dev/null +++ b/Task/Empty-directory/Liberty-BASIC/empty-directory.liberty @@ -0,0 +1,15 @@ +dim info$(10, 10) +files "c:\", info$() + +qtyFiles=val(info$(0,0)) +n = qtyFiles+1 'begin directory info + +folder$ = info$(n,0) 'path to first directory in c: + +files folder$, info$() 're-fill array with data from sub folder + +if val(info$(0,0)) + val(info$(0, 1)) <> 0 then + print "Folder ";folder$;" is not empty." +else + print "Folder ";folder$;" is empty." +end if diff --git a/Task/Empty-directory/Mathematica/empty-directory.mathematica b/Task/Empty-directory/Mathematica/empty-directory.mathematica new file mode 100644 index 0000000000..b392f76672 --- /dev/null +++ b/Task/Empty-directory/Mathematica/empty-directory.mathematica @@ -0,0 +1,5 @@ +EmptyDirectoryQ[x_] := (SetDirectory[x]; If[FileNames[] == {}, True, False]) + +Example use: +EmptyDirectoryQ["C:\\Program Files\\Wolfram Research\\Mathematica\\9"] +->True diff --git a/Task/Empty-program/FALSE/empty-program.false b/Task/Empty-program/FALSE/empty-program.false new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Factor/empty-program-1.factor b/Task/Empty-program/Factor/empty-program-1.factor new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Factor/empty-program-2.factor b/Task/Empty-program/Factor/empty-program-2.factor new file mode 100644 index 0000000000..9e5f803ba4 --- /dev/null +++ b/Task/Empty-program/Factor/empty-program-2.factor @@ -0,0 +1,3 @@ +IN: rosetta.empty +: main ( -- ) ; +MAIN: main diff --git a/Task/Empty-program/Fantom/empty-program.fantom b/Task/Empty-program/Fantom/empty-program.fantom new file mode 100644 index 0000000000..ce35911d54 --- /dev/null +++ b/Task/Empty-program/Fantom/empty-program.fantom @@ -0,0 +1,4 @@ +class Main +{ + public static Void main () {} +} diff --git a/Task/Empty-program/Fish/empty-program-1.fish b/Task/Empty-program/Fish/empty-program-1.fish new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Fish/empty-program-2.fish b/Task/Empty-program/Fish/empty-program-2.fish new file mode 100644 index 0000000000..092bc2b041 --- /dev/null +++ b/Task/Empty-program/Fish/empty-program-2.fish @@ -0,0 +1 @@ +; diff --git a/Task/Empty-program/Frink/empty-program.frink b/Task/Empty-program/Frink/empty-program.frink new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Gecho/empty-program.gecho b/Task/Empty-program/Gecho/empty-program.gecho new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Gema/empty-program.gema b/Task/Empty-program/Gema/empty-program.gema new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Groovy/empty-program.groovy b/Task/Empty-program/Groovy/empty-program.groovy new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Haxe/empty-program.haxe b/Task/Empty-program/Haxe/empty-program.haxe new file mode 100644 index 0000000000..478ffeddd7 --- /dev/null +++ b/Task/Empty-program/Haxe/empty-program.haxe @@ -0,0 +1,4 @@ +class Program { + static function main() { + } +} diff --git a/Task/Empty-program/HicEst/empty-program.hicest b/Task/Empty-program/HicEst/empty-program.hicest new file mode 100644 index 0000000000..db763b52bd --- /dev/null +++ b/Task/Empty-program/HicEst/empty-program.hicest @@ -0,0 +1 @@ +END ! looks better, but is not really needed diff --git a/Task/Empty-program/IDL/empty-program.idl b/Task/Empty-program/IDL/empty-program.idl new file mode 100644 index 0000000000..a6a9baf65e --- /dev/null +++ b/Task/Empty-program/IDL/empty-program.idl @@ -0,0 +1 @@ +end diff --git a/Task/Empty-program/Icon/empty-program.icon b/Task/Empty-program/Icon/empty-program.icon new file mode 100644 index 0000000000..71f287c67a --- /dev/null +++ b/Task/Empty-program/Icon/empty-program.icon @@ -0,0 +1,2 @@ +procedure main() # a null file will compile but generate a run-time error for missing main +end diff --git a/Task/Empty-program/Intercal/empty-program.ical b/Task/Empty-program/Intercal/empty-program.ical new file mode 100644 index 0000000000..cc845c46d6 --- /dev/null +++ b/Task/Empty-program/Intercal/empty-program.ical @@ -0,0 +1 @@ +PLEASE GIVE UP diff --git a/Task/Empty-program/J/empty-program-1.j b/Task/Empty-program/J/empty-program-1.j new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/J/empty-program-2.j b/Task/Empty-program/J/empty-program-2.j new file mode 100644 index 0000000000..5c0cafad47 --- /dev/null +++ b/Task/Empty-program/J/empty-program-2.j @@ -0,0 +1,2 @@ + '' -: ". '' +1 diff --git a/Task/Empty-program/Joy/empty-program.joy b/Task/Empty-program/Joy/empty-program.joy new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/K/empty-program.k b/Task/Empty-program/K/empty-program.k new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/KonsolScript/empty-program.konso b/Task/Empty-program/KonsolScript/empty-program.konso new file mode 100644 index 0000000000..7f0cc7bbd3 --- /dev/null +++ b/Task/Empty-program/KonsolScript/empty-program.konso @@ -0,0 +1,3 @@ +function main() { + +} diff --git a/Task/Empty-program/Lang5/empty-program.lang5 b/Task/Empty-program/Lang5/empty-program.lang5 new file mode 100644 index 0000000000..a3abe50906 --- /dev/null +++ b/Task/Empty-program/Lang5/empty-program.lang5 @@ -0,0 +1 @@ +exit diff --git a/Task/Empty-program/Liberty-BASIC/empty-program.liberty b/Task/Empty-program/Liberty-BASIC/empty-program.liberty new file mode 100644 index 0000000000..a6a9baf65e --- /dev/null +++ b/Task/Empty-program/Liberty-BASIC/empty-program.liberty @@ -0,0 +1 @@ +end diff --git a/Task/Empty-program/Lilypond/empty-program-1.lilypond b/Task/Empty-program/Lilypond/empty-program-1.lilypond new file mode 100644 index 0000000000..927373865a --- /dev/null +++ b/Task/Empty-program/Lilypond/empty-program-1.lilypond @@ -0,0 +1 @@ +\version "2.6.12" diff --git a/Task/Empty-program/Lilypond/empty-program-2.lilypond b/Task/Empty-program/Lilypond/empty-program-2.lilypond new file mode 100644 index 0000000000..88f6c11f88 --- /dev/null +++ b/Task/Empty-program/Lilypond/empty-program-2.lilypond @@ -0,0 +1,18 @@ +\version "2.16.2" + +\header { + +} + +\book { + \score { + \new Staff { + \new Voice { + + } + } + \layout { + + } + } +} diff --git a/Task/Empty-program/Lisp/empty-program.lisp b/Task/Empty-program/Lisp/empty-program.lisp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Logo/empty-program-1.logo b/Task/Empty-program/Logo/empty-program-1.logo new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Logo/empty-program-2.logo b/Task/Empty-program/Logo/empty-program-2.logo new file mode 100644 index 0000000000..c985fba794 --- /dev/null +++ b/Task/Empty-program/Logo/empty-program-2.logo @@ -0,0 +1,3 @@ +#! /usr/local/bin/logo + +bye diff --git a/Task/Empty-program/M4/empty-program.m4 b/Task/Empty-program/M4/empty-program.m4 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/ML-I/empty-program.ml b/Task/Empty-program/ML-I/empty-program.ml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/MMIX/empty-program.mmix b/Task/Empty-program/MMIX/empty-program.mmix new file mode 100644 index 0000000000..ced9b57351 --- /dev/null +++ b/Task/Empty-program/MMIX/empty-program.mmix @@ -0,0 +1,2 @@ + LOC #100 +Main TRAP 0,Halt,0 // main (argc, argv) {} diff --git a/Task/Empty-program/Maple/empty-program.maple b/Task/Empty-program/Maple/empty-program.maple new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Mathematica/empty-program.mathematica b/Task/Empty-program/Mathematica/empty-program.mathematica new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Task/Empty-program/Maxima/empty-program.maxima b/Task/Empty-program/Maxima/empty-program.maxima new file mode 100644 index 0000000000..f05032b279 --- /dev/null +++ b/Task/Empty-program/Maxima/empty-program.maxima @@ -0,0 +1 @@ +block()$ diff --git a/Task/Empty-program/Metafont/empty-program.metafont b/Task/Empty-program/Metafont/empty-program.metafont new file mode 100644 index 0000000000..a6a9baf65e --- /dev/null +++ b/Task/Empty-program/Metafont/empty-program.metafont @@ -0,0 +1 @@ +end diff --git a/Task/Empty-program/Modula-2/empty-program.mod2 b/Task/Empty-program/Modula-2/empty-program.mod2 new file mode 100644 index 0000000000..8dc08fda73 --- /dev/null +++ b/Task/Empty-program/Modula-2/empty-program.mod2 @@ -0,0 +1,4 @@ +MODULE Main; + +BEGIN +END Main. diff --git a/Task/Empty-program/Modula-3/empty-program.mod3 b/Task/Empty-program/Modula-3/empty-program.mod3 new file mode 100644 index 0000000000..8dc08fda73 --- /dev/null +++ b/Task/Empty-program/Modula-3/empty-program.mod3 @@ -0,0 +1,4 @@ +MODULE Main; + +BEGIN +END Main. diff --git a/Task/Empty-string/Fantom/empty-string.fantom b/Task/Empty-string/Fantom/empty-string.fantom new file mode 100644 index 0000000000..617a87d415 --- /dev/null +++ b/Task/Empty-string/Fantom/empty-string.fantom @@ -0,0 +1,5 @@ +a := "" // assign an empty string to 'a' +a.isEmpty // method on sys::Str to check if string is empty +a.size == 0 // what isEmpty actually checks +a == "" // alternate check for an empty string +!a.isEmpty // check that a string is not empty diff --git a/Task/Empty-string/Groovy/empty-string.groovy b/Task/Empty-string/Groovy/empty-string.groovy new file mode 100644 index 0000000000..1120817b30 --- /dev/null +++ b/Task/Empty-string/Groovy/empty-string.groovy @@ -0,0 +1,5 @@ +def s = '' // or "" if you wish +assert s.empty + +s = '1 is the loneliest number' +assert !s.empty diff --git a/Task/Empty-string/Icon/empty-string.icon b/Task/Empty-string/Icon/empty-string.icon new file mode 100644 index 0000000000..454d771aab --- /dev/null +++ b/Task/Empty-string/Icon/empty-string.icon @@ -0,0 +1,16 @@ +s := "" # null string +s := string('A'--'A') # ... converted from cset difference +s := char(0)[0:0] # ... by slicing + +s1 == "" # lexical comparison, could convert s1 to string +s1 === "" # comparison won't force conversion +*s1 = 0 # zero length, however, *x is polymorphic +*string(s1) = 0 # zero length string + +s1 ~== "" # non null strings comparisons +s1 ~=== "" +*string(s1) ~= 0 + +s := &null # NOT a null string, null type +/s # test for null type +\s # test for non-null type diff --git a/Task/Empty-string/J/empty-string.j b/Task/Empty-string/J/empty-string.j new file mode 100644 index 0000000000..e9681edb84 --- /dev/null +++ b/Task/Empty-string/J/empty-string.j @@ -0,0 +1,5 @@ + variable=: '' + 0=#variable +1 + 0<#variable +0 diff --git a/Task/Empty-string/K/empty-string.k b/Task/Empty-string/K/empty-string.k new file mode 100644 index 0000000000..66b40f3ddf --- /dev/null +++ b/Task/Empty-string/K/empty-string.k @@ -0,0 +1,5 @@ + variable: "" + 0=#variable +1 + 0<#variable +0 diff --git a/Task/Empty-string/LOLCODE/empty-string.lol b/Task/Empty-string/LOLCODE/empty-string.lol new file mode 100644 index 0000000000..eed246c4ba --- /dev/null +++ b/Task/Empty-string/LOLCODE/empty-string.lol @@ -0,0 +1,9 @@ +HAI 1.3 + +I HAS A string ITZ "" +string, O RLY? + YA RLY, VISIBLE "STRING HAZ CONTENZ" + NO WAI, VISIBLE "Y U NO HAS CHARZ?!" +OIC + +KTHXBYE diff --git a/Task/Empty-string/Lhogho/empty-string.lhogho b/Task/Empty-string/Lhogho/empty-string.lhogho new file mode 100644 index 0000000000..7435f2dc80 --- /dev/null +++ b/Task/Empty-string/Lhogho/empty-string.lhogho @@ -0,0 +1,3 @@ +make "str " ;make null-string word +print empty? :str ;prints 'true' +print not empty? :str ;prints 'false' diff --git a/Task/Empty-string/Liberty-BASIC/empty-string.liberty b/Task/Empty-string/Liberty-BASIC/empty-string.liberty new file mode 100644 index 0000000000..1090885456 --- /dev/null +++ b/Task/Empty-string/Liberty-BASIC/empty-string.liberty @@ -0,0 +1,8 @@ +'assign empty string to variable +a$ = "" +'check for empty string +if a$="" then print "Empty string." +if len(a$)=0 then print "Empty string." +'check for non-empty string +if a$<>"" then print "Not empty." +if len(a$)>0 then print "Not empty." diff --git a/Task/Empty-string/Mathematica/empty-string.mathematica b/Task/Empty-string/Mathematica/empty-string.mathematica new file mode 100644 index 0000000000..16fb3b29ba --- /dev/null +++ b/Task/Empty-string/Mathematica/empty-string.mathematica @@ -0,0 +1,3 @@ +str=""; (*Create*) +str==="" (*test empty*) +str=!="" (*test not empty*) diff --git a/Task/Empty-string/Maxima/empty-string.maxima b/Task/Empty-string/Maxima/empty-string.maxima new file mode 100644 index 0000000000..5f4b768399 --- /dev/null +++ b/Task/Empty-string/Maxima/empty-string.maxima @@ -0,0 +1,9 @@ +s: ""$ + +/* check using string contents */ +sequal(s, ""); +not sequal(s, ""); + +/* check using string length */ +slength(s) = ""; +slength(s) # ""; diff --git a/Task/Empty-string/Mirah/empty-string.mirah b/Task/Empty-string/Mirah/empty-string.mirah new file mode 100644 index 0000000000..9b969d4686 --- /dev/null +++ b/Task/Empty-string/Mirah/empty-string.mirah @@ -0,0 +1,6 @@ +empty_string1 = "" +empty_string2 = String.new + +puts "empty string is empty" if empty_string1.isEmpty() +puts "empty string has no length" if empty_string2.length() == 0 +puts "empty string is not nil" unless empty_string1 == nil diff --git a/Task/Enforced-immutability/Icon/enforced-immutability.icon b/Task/Enforced-immutability/Icon/enforced-immutability.icon new file mode 100644 index 0000000000..5b8199a149 --- /dev/null +++ b/Task/Enforced-immutability/Icon/enforced-immutability.icon @@ -0,0 +1 @@ +$define "1234" diff --git a/Task/Enforced-immutability/J/enforced-immutability-1.j b/Task/Enforced-immutability/J/enforced-immutability-1.j new file mode 100644 index 0000000000..1e6300e139 --- /dev/null +++ b/Task/Enforced-immutability/J/enforced-immutability-1.j @@ -0,0 +1,6 @@ + B=: A=: 'this is a test' + A=: '*' 2 3 5 7} A + A +th** *s*a test + B +this is a test diff --git a/Task/Enforced-immutability/J/enforced-immutability-2.j b/Task/Enforced-immutability/J/enforced-immutability-2.j new file mode 100644 index 0000000000..90abb4138c --- /dev/null +++ b/Task/Enforced-immutability/J/enforced-immutability-2.j @@ -0,0 +1,8 @@ + C=: 'this is a test' + 1 readonly_jmf_ 'C' + + C =: 'some new value' +|read-only data +| C =:'some new value' + C +this is a test diff --git a/Task/Enforced-immutability/MBS/enforced-immutability.mbs b/Task/Enforced-immutability/MBS/enforced-immutability.mbs new file mode 100644 index 0000000000..6281b64c3f --- /dev/null +++ b/Task/Enforced-immutability/MBS/enforced-immutability.mbs @@ -0,0 +1 @@ +CONSTANT INT foo=640; diff --git a/Task/Enforced-immutability/Mathematica/enforced-immutability.mathematica b/Task/Enforced-immutability/Mathematica/enforced-immutability.mathematica new file mode 100644 index 0000000000..393fb7795c --- /dev/null +++ b/Task/Enforced-immutability/Mathematica/enforced-immutability.mathematica @@ -0,0 +1,5 @@ +Tau = 2*Pi;Protect[Tau] +{"Tau"} + +Tau = 2 +->Set::wrsym: Symbol Tau is Protected. diff --git a/Task/Entropy/J/entropy-1.j b/Task/Entropy/J/entropy-1.j new file mode 100644 index 0000000000..51c80c1466 --- /dev/null +++ b/Task/Entropy/J/entropy-1.j @@ -0,0 +1 @@ + entropy=: +/@:-@(* 2&^.)@(#/.~ % #) diff --git a/Task/Entropy/J/entropy-2.j b/Task/Entropy/J/entropy-2.j new file mode 100644 index 0000000000..9ff7ccd7d0 --- /dev/null +++ b/Task/Entropy/J/entropy-2.j @@ -0,0 +1,2 @@ + entropy '1223334444' +1.84644 diff --git a/Task/Entropy/Lang5/entropy.lang5 b/Task/Entropy/Lang5/entropy.lang5 new file mode 100644 index 0000000000..3eb60f1ade --- /dev/null +++ b/Task/Entropy/Lang5/entropy.lang5 @@ -0,0 +1,17 @@ +: -rot rot rot ; [] '__A set : dip swap __A swap 1 compress append '__A +set execute __A -1 extract nip ; : nip swap drop ; : sum '+ reduce ; +: 2array 2 compress ; : comb "" split ; : lensize length nip ; +: #( a -- 'a ) + grade subscript dup 's dress distinct strip + length 1 2array reshape swap + 'A set + : `filter(*) A in A swap select ; + '`filter apply + ; + +: elements(*) lensize ; +: entropy #( s -- n ) + length " 'elements apply" dip / + dup neg swap log * 2 log / sum ; + +"1223334444" comb entropy . # 1.84643934467102 diff --git a/Task/Entropy/Mathematica/entropy-1.mathematica b/Task/Entropy/Mathematica/entropy-1.mathematica new file mode 100644 index 0000000000..929d420221 --- /dev/null +++ b/Task/Entropy/Mathematica/entropy-1.mathematica @@ -0,0 +1,2 @@ +shE[s_String] := -Plus @@ ((# Log[2., #]) & /@ ((Length /@ Gather[#])/ + Length[#]) &[Characters[s]]) diff --git a/Task/Entropy/Mathematica/entropy-2.mathematica b/Task/Entropy/Mathematica/entropy-2.mathematica new file mode 100644 index 0000000000..ae917b45bd --- /dev/null +++ b/Task/Entropy/Mathematica/entropy-2.mathematica @@ -0,0 +1,4 @@ + shE["1223334444"] +1.84644 +shE["Rosetta Code"] +3.08496 diff --git a/Task/Enumerations/Fantom/enumerations-1.fantom b/Task/Enumerations/Fantom/enumerations-1.fantom new file mode 100644 index 0000000000..2ac7b75228 --- /dev/null +++ b/Task/Enumerations/Fantom/enumerations-1.fantom @@ -0,0 +1,2 @@ +// create an enumeration with named constants +enum class Fruits { apple, banana, orange } diff --git a/Task/Enumerations/Fantom/enumerations-2.fantom b/Task/Enumerations/Fantom/enumerations-2.fantom new file mode 100644 index 0000000000..e37d03daba --- /dev/null +++ b/Task/Enumerations/Fantom/enumerations-2.fantom @@ -0,0 +1,7 @@ +// create an enumeration with explicit values +enum class Fruits_ +{ + apple (1), banana (2), orange (3) + const Int value + private new make (Int value) { this.value = value } +} diff --git a/Task/Enumerations/Groovy/enumerations.groovy b/Task/Enumerations/Groovy/enumerations.groovy new file mode 100644 index 0000000000..7c7b2086a4 --- /dev/null +++ b/Task/Enumerations/Groovy/enumerations.groovy @@ -0,0 +1,11 @@ +enum Fruit { apple, banana, cherry } + +enum ValuedFruit { + apple(1), banana(2), cherry(3); + def value + ValuedFruit(val) {value = val} + String toString() { super.toString() + "(${value})" } +} + +println Fruit.values() +println ValuedFruit.values() diff --git a/Task/Enumerations/Icon/enumerations.icon b/Task/Enumerations/Icon/enumerations.icon new file mode 100644 index 0000000000..413e4c7f0c --- /dev/null +++ b/Task/Enumerations/Icon/enumerations.icon @@ -0,0 +1,6 @@ + fruits := [ "apple", "banana", "cherry", "apple" ] # a list keeps ordered data + fruits := set("apple", "banana", "cherry") # a set keeps unique data + fruits := table() # table keeps an unique data with values + fruits["apple"] := 1 + fruits["banana"] := 2 + fruits["cherry"] := 3 diff --git a/Task/Enumerations/Inform-7/enumerations-1.inf b/Task/Enumerations/Inform-7/enumerations-1.inf new file mode 100644 index 0000000000..b55e803100 --- /dev/null +++ b/Task/Enumerations/Inform-7/enumerations-1.inf @@ -0,0 +1 @@ +Fruit is a kind of value. The fruits are apple, banana, and cherry. diff --git a/Task/Enumerations/Inform-7/enumerations-2.inf b/Task/Enumerations/Inform-7/enumerations-2.inf new file mode 100644 index 0000000000..71a4af07b7 --- /dev/null +++ b/Task/Enumerations/Inform-7/enumerations-2.inf @@ -0,0 +1,6 @@ +[sentence form] +Fruit is a kind of value. The fruits are apple, banana, and cherry. +A fruit has a number called numeric value. +The numeric value of apple is 1. +The numeric value of banana is 2. +The numeric value of cherry is 3. diff --git a/Task/Enumerations/Inform-7/enumerations-3.inf b/Task/Enumerations/Inform-7/enumerations-3.inf new file mode 100644 index 0000000000..684eb5d323 --- /dev/null +++ b/Task/Enumerations/Inform-7/enumerations-3.inf @@ -0,0 +1,8 @@ +[table form] +Fruit is a kind of value. The fruits are defined by the Table of Fruits. + +Table of Fruits +fruit numeric value +apple 1 +banana 2 +cherry 3 diff --git a/Task/Enumerations/J/enumerations-1.j b/Task/Enumerations/J/enumerations-1.j new file mode 100644 index 0000000000..712581f7ae --- /dev/null +++ b/Task/Enumerations/J/enumerations-1.j @@ -0,0 +1,4 @@ + enum =: cocreate'' + ( (;:'apple banana cherry') ,L:0 '__enum' ) =: i. 3 + cherry__enum +2 diff --git a/Task/Enumerations/J/enumerations-2.j b/Task/Enumerations/J/enumerations-2.j new file mode 100644 index 0000000000..a0eecd7f7b --- /dev/null +++ b/Task/Enumerations/J/enumerations-2.j @@ -0,0 +1 @@ + fruit=: ;:'apple banana cherry' diff --git a/Task/Enumerations/J/enumerations-3.j b/Task/Enumerations/J/enumerations-3.j new file mode 100644 index 0000000000..ccb58d261c --- /dev/null +++ b/Task/Enumerations/J/enumerations-3.j @@ -0,0 +1,4 @@ + 2 { fruit ++------+ +|cherry| ++------+ diff --git a/Task/Enumerations/J/enumerations-4.j b/Task/Enumerations/J/enumerations-4.j new file mode 100644 index 0000000000..197d706478 --- /dev/null +++ b/Task/Enumerations/J/enumerations-4.j @@ -0,0 +1,2 @@ + fruit i.<'banana' +1 diff --git a/Task/Enumerations/J/enumerations-5.j b/Task/Enumerations/J/enumerations-5.j new file mode 100644 index 0000000000..ee2be77e09 --- /dev/null +++ b/Task/Enumerations/J/enumerations-5.j @@ -0,0 +1,4 @@ + (<'banana') +&.(fruit&i.) <'banana' ++------+ +|cherry| ++------+ diff --git a/Task/Enumerations/JScript.NET/enumerations.net b/Task/Enumerations/JScript.NET/enumerations.net new file mode 100644 index 0000000000..39e00cef93 --- /dev/null +++ b/Task/Enumerations/JScript.NET/enumerations.net @@ -0,0 +1,2 @@ +enum fruits { apple, banana, cherry } +enum fruits { apple = 0, banana = 1, cherry = 2 } diff --git a/Task/Enumerations/M4/enumerations.m4 b/Task/Enumerations/M4/enumerations.m4 new file mode 100644 index 0000000000..0719bc9959 --- /dev/null +++ b/Task/Enumerations/M4/enumerations.m4 @@ -0,0 +1,6 @@ +define(`enums', + `define(`$2',$1)`'ifelse(eval($#>2),1,`enums(incr($1),shift(shift($@)))')') +define(`enum', + `enums(1,$@)') +enum(a,b,c,d) +`c='c diff --git a/Task/Enumerations/Mathematica/enumerations.mathematica b/Task/Enumerations/Mathematica/enumerations.mathematica new file mode 100644 index 0000000000..dc083935be --- /dev/null +++ b/Task/Enumerations/Mathematica/enumerations.mathematica @@ -0,0 +1,11 @@ +MapIndexed[Set, {A, B, F, G}] +->{{1}, {2}, {3}, {4}} + +A +->{1} + +B +->{2} + +G +->{4} diff --git a/Task/Enumerations/Metafont/enumerations-1.metafont b/Task/Enumerations/Metafont/enumerations-1.metafont new file mode 100644 index 0000000000..80c88e9ddc --- /dev/null +++ b/Task/Enumerations/Metafont/enumerations-1.metafont @@ -0,0 +1,4 @@ +vardef enum(expr first)(text t) = +save ?; ? := first; +forsuffixes e := t: e := ?; ?:=?+1; endfor +enddef; diff --git a/Task/Enumerations/Metafont/enumerations-2.metafont b/Task/Enumerations/Metafont/enumerations-2.metafont new file mode 100644 index 0000000000..9b2e2a8560 --- /dev/null +++ b/Task/Enumerations/Metafont/enumerations-2.metafont @@ -0,0 +1,5 @@ +enum(1, Apple, Banana, Cherry); +enum(5, Orange, Pineapple, Qfruit); +show Apple, Banana, Cherry, Orange, Pineapple, Qfruit; + +end diff --git a/Task/Enumerations/Modula-3/enumerations-1.mod3 b/Task/Enumerations/Modula-3/enumerations-1.mod3 new file mode 100644 index 0000000000..57a8a9b9b7 --- /dev/null +++ b/Task/Enumerations/Modula-3/enumerations-1.mod3 @@ -0,0 +1 @@ +TYPE Fruit = {Apple, Banana, Cherry}; diff --git a/Task/Enumerations/Modula-3/enumerations-2.mod3 b/Task/Enumerations/Modula-3/enumerations-2.mod3 new file mode 100644 index 0000000000..3c8b021c49 --- /dev/null +++ b/Task/Enumerations/Modula-3/enumerations-2.mod3 @@ -0,0 +1 @@ +fruit := Fruit.Apple; diff --git a/Task/Enumerations/Modula-3/enumerations-3.mod3 b/Task/Enumerations/Modula-3/enumerations-3.mod3 new file mode 100644 index 0000000000..d93f3f1a48 --- /dev/null +++ b/Task/Enumerations/Modula-3/enumerations-3.mod3 @@ -0,0 +1,2 @@ +ORD(Fruit.Apple); (* Returns 0 *) +VAL(0, Fruit); (* Returns Fruit.Apple *) diff --git a/Task/Equilibrium-index/Factor/equilibrium-index-1.factor b/Task/Equilibrium-index/Factor/equilibrium-index-1.factor new file mode 100644 index 0000000000..2559aee139 --- /dev/null +++ b/Task/Equilibrium-index/Factor/equilibrium-index-1.factor @@ -0,0 +1,6 @@ +USE: math.vectors +: accum-left ( seq id quot -- seq ) accumulate nip ; inline +: accum-right ( seq id quot -- seq ) [ ] 2dip accum-left ; inline +: equilibrium-indices ( seq -- inds ) + 0 [ + ] [ accum-left ] [ accum-right ] 3bi [ = ] 2map + V{ } swap dup length iota [ [ suffix ] curry [ ] if ] 2each ; diff --git a/Task/Equilibrium-index/Factor/equilibrium-index-2.factor b/Task/Equilibrium-index/Factor/equilibrium-index-2.factor new file mode 100644 index 0000000000..3d7f62ddd5 --- /dev/null +++ b/Task/Equilibrium-index/Factor/equilibrium-index-2.factor @@ -0,0 +1,2 @@ +( scratchpad ) { -7 1 5 2 -4 3 0 } equilibrium-indices . +V{ 3 6 } diff --git a/Task/Equilibrium-index/Icon/equilibrium-index.icon b/Task/Equilibrium-index/Icon/equilibrium-index.icon new file mode 100644 index 0000000000..595740c01f --- /dev/null +++ b/Task/Equilibrium-index/Icon/equilibrium-index.icon @@ -0,0 +1,16 @@ +procedure main(arglist) +L := if *arglist > 0 then arglist else [-7, 1, 5, 2, -4, 3, 0] # command line args or default +every writes( "equilibrium indicies of [ " | (!L ||" ") | "] = " | (eqindex(L)||" ") | "\n" ) +end + +procedure eqindex(L) # generate equilibrium points in a list L or fail +local s,l,i + +every (s := 0, i := !L) do + s +:= numeric(i) | fail # sum and validate + +every (l := 0, i := 1 to *L) do { + if l = (s-L[i])/2 then suspend i + l +:= L[i] # sum of left side + } +end diff --git a/Task/Equilibrium-index/J/equilibrium-index-1.j b/Task/Equilibrium-index/J/equilibrium-index-1.j new file mode 100644 index 0000000000..fbf7433d23 --- /dev/null +++ b/Task/Equilibrium-index/J/equilibrium-index-1.j @@ -0,0 +1 @@ +equilidx=: +/\ I.@:= +/\. diff --git a/Task/Equilibrium-index/J/equilibrium-index-2.j b/Task/Equilibrium-index/J/equilibrium-index-2.j new file mode 100644 index 0000000000..9d6f58d7e6 --- /dev/null +++ b/Task/Equilibrium-index/J/equilibrium-index-2.j @@ -0,0 +1,2 @@ + equilidx _7 1 5 2 _4 3 0 +3 6 diff --git a/Task/Equilibrium-index/K/equilibrium-index.k b/Task/Equilibrium-index/K/equilibrium-index.k new file mode 100644 index 0000000000..9d8e5ca7d5 --- /dev/null +++ b/Task/Equilibrium-index/K/equilibrium-index.k @@ -0,0 +1,13 @@ + f:{&{(+/y# x)=+/(y+1)_x}[x]'!#x} + + f -7 1 5 2 -4 3 0 +3 6 + + f 2 4 6 +!0 + + f 2 9 2 +,1 + + f 1 -1 1 -1 1 -1 1 +0 1 2 3 4 5 6 diff --git a/Task/Equilibrium-index/Liberty-BASIC/equilibrium-index.liberty b/Task/Equilibrium-index/Liberty-BASIC/equilibrium-index.liberty new file mode 100644 index 0000000000..fad97fdc1d --- /dev/null +++ b/Task/Equilibrium-index/Liberty-BASIC/equilibrium-index.liberty @@ -0,0 +1,26 @@ +a(0)=-7 +a(1)=1 +a(2)=5 +a(3)=2 +a(4)=-4 +a(5)=3 +a(6)=0 + +print "EQ Indices are ";EQindex$("a",0,6) + +wait + +function EQindex$(b$,mini,maxi) + if mini>=maxi then exit function + sum=0 + for i = mini to maxi + sum=sum+eval(b$;"(";i;")") + next + sumA=0:sumB=sum + for i = mini to maxi + sumB = sumB - eval(b$;"(";i;")") + if sumA=sumB then EQindex$=EQindex$+str$(i)+", " + sumA = sumA + eval(b$;"(";i;")") + next + if len(EQindex$)>0 then EQindex$=mid$(EQindex$, 1, len(EQindex$)-2) 'remove last ", " +end function diff --git a/Task/Equilibrium-index/Mathematica/equilibrium-index.mathematica b/Task/Equilibrium-index/Mathematica/equilibrium-index.mathematica new file mode 100644 index 0000000000..379705e75e --- /dev/null +++ b/Task/Equilibrium-index/Mathematica/equilibrium-index.mathematica @@ -0,0 +1,3 @@ +equilibriumIndex[data_]:=Reap[ + Do[If[Total[data[[;; n - 1]]] == Total[data[[n + 1 ;;]]],Sow[n]], + {n, Length[data]}]][[2, 1]] diff --git a/Task/Ethiopian-multiplication/FALSE/ethiopian-multiplication.false b/Task/Ethiopian-multiplication/FALSE/ethiopian-multiplication.false new file mode 100644 index 0000000000..472d28b335 --- /dev/null +++ b/Task/Ethiopian-multiplication/FALSE/ethiopian-multiplication.false @@ -0,0 +1,5 @@ +[2/]h: +[2*]d: +[1&]o: +[0[@$][$o;![@@\$@+@]?h;!@d;!@]#%\%]m: +17 34m;!. {578} diff --git a/Task/Ethiopian-multiplication/Factor/ethiopian-multiplication.factor b/Task/Ethiopian-multiplication/Factor/ethiopian-multiplication.factor new file mode 100644 index 0000000000..bc042e37ef --- /dev/null +++ b/Task/Ethiopian-multiplication/Factor/ethiopian-multiplication.factor @@ -0,0 +1,17 @@ +USING: arrays kernel math multiline sequences ; +IN: ethiopian-multiplication + +/* +This function is built-in +: odd? ( n -- ? ) 1 bitand 1 number= ; +*/ + +: double ( n -- 2*n ) 2 * ; +: halve ( n -- n/2 ) 2 /i ; + +: ethiopian-mult ( a b -- a*b ) + [ 0 ] 2dip + [ dup 0 > ] [ + [ odd? [ + ] [ drop ] if ] 2keep + [ double ] [ halve ] bi* + ] while 2drop ; diff --git a/Task/Ethiopian-multiplication/GW-BASIC/ethiopian-multiplication.bas b/Task/Ethiopian-multiplication/GW-BASIC/ethiopian-multiplication.bas new file mode 100644 index 0000000000..509d216c77 --- /dev/null +++ b/Task/Ethiopian-multiplication/GW-BASIC/ethiopian-multiplication.bas @@ -0,0 +1,10 @@ +10 DEF FNE(A)=(A+1) MOD 2 +20 DEF FNH(A)=INT(A/2) +30 DEF FND(A)=2*A +40 X=17:Y=34:TOT=0 +50 WHILE X>=1 +60 PRINT X, +70 IF FNE(X)=0 THEN TOT=TOT+Y:PRINT Y ELSE PRINT +80 X=FNH(X):Y=FND(Y) +90 WEND +100 PRINT "=", TOT diff --git a/Task/Ethiopian-multiplication/HicEst/ethiopian-multiplication.hicest b/Task/Ethiopian-multiplication/HicEst/ethiopian-multiplication.hicest new file mode 100644 index 0000000000..f50a85f549 --- /dev/null +++ b/Task/Ethiopian-multiplication/HicEst/ethiopian-multiplication.hicest @@ -0,0 +1,26 @@ + WRITE(Messagebox) ethiopian( 17, 34 ) +END ! of "main" + +FUNCTION ethiopian(x, y) + ethiopian = 0 + left = x + right = y + DO i = x, 1, -1 + IF( isEven(left) == 0 ) ethiopian = ethiopian + right + IF( left == 1 ) RETURN + left = halve(left) + right = double(right) + ENDDO + END + +FUNCTION halve( x ) + halve = INT( x/2 ) + END + +FUNCTION double( x ) + double = 2 * x + END + +FUNCTION isEven( x ) + isEven = MOD(x, 2) == 0 + END diff --git a/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-1.icon b/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-1.icon new file mode 100644 index 0000000000..77b9c5962b --- /dev/null +++ b/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-1.icon @@ -0,0 +1,22 @@ +procedure main(arglist) +while ethiopian(integer(get(arglist)),integer(get(arglist))) # multiply successive pairs of command line arguments +end + +procedure ethiopian(i,j) # recursive Ethiopian multiplication +return ( if not even(i) then j # this exploits that icon control expressions return values + else 0 ) + + ( if i ~= 0 then ethiopian(halve(i),double(j)) + else 0 ) +end + +procedure double(i) +return i * 2 +end + +procedure halve(i) +return i / 2 +end + +procedure even(i) +return ( i % 2 = 0, i ) +end diff --git a/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-2.icon b/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-2.icon new file mode 100644 index 0000000000..84e62bad4f --- /dev/null +++ b/Task/Ethiopian-multiplication/Icon/ethiopian-multiplication-2.icon @@ -0,0 +1,19 @@ +procedure ethiopian(i,j) # iterative tutor +local p,w +w := *j+3 +write("Ethiopian Multiplication of ",i," * ",j) + +p := 0 +until i = 0 do { + writes(right(i,w),right(j,w)) + if not even(i) then { + p +:= j + write(" add") + } + else write(" discard") + i := halve(i) + j := double(j) + } +write(right("=",w),right(p,w)) +return p +end diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-1.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-1.j new file mode 100644 index 0000000000..451de43b71 --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-1.j @@ -0,0 +1,5 @@ +double =: 2&* +halve =: %&2 NB. or the primitive -: +odd =: 2&| + +ethiop =: +/@(odd@] # (double~ <@#)) (1>.<.@halve)^:a: diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-2.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-2.j new file mode 100644 index 0000000000..3d935ae6fb --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-2.j @@ -0,0 +1,2 @@ + 17 ethiop 34 +578 diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-3.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-3.j new file mode 100644 index 0000000000..7c036ad767 --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-3.j @@ -0,0 +1,2 @@ + (<5) double 17 +17 34 68 136 272 diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-4.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-4.j new file mode 100644 index 0000000000..ab3e3cbb6a --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-4.j @@ -0,0 +1 @@ +ethio=: *@] * (ethiop |) diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-5.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-5.j new file mode 100644 index 0000000000..4c0275e7be --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-5.j @@ -0,0 +1 @@ +ethio=: *@] -@]^:(0 > [) (ethiop |) diff --git a/Task/Ethiopian-multiplication/J/ethiopian-multiplication-6.j b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-6.j new file mode 100644 index 0000000000..ac489587c8 --- /dev/null +++ b/Task/Ethiopian-multiplication/J/ethiopian-multiplication-6.j @@ -0,0 +1,8 @@ + 7 ethio 11 +77 + 7 ethio _11 +_77 + _7 ethio 11 +_77 + _7 ethio _11 +77 diff --git a/Task/Ethiopian-multiplication/Liberty-BASIC/ethiopian-multiplication.liberty b/Task/Ethiopian-multiplication/Liberty-BASIC/ethiopian-multiplication.liberty new file mode 100644 index 0000000000..0330729a24 --- /dev/null +++ b/Task/Ethiopian-multiplication/Liberty-BASIC/ethiopian-multiplication.liberty @@ -0,0 +1,29 @@ +x = 17 +y = 34 +msg$ = str$(x) + " * " + str$(y) + " = " +Print str$(x) + " " + str$(y) +'In this routine we will not worry about discarding the right hand value whos left hand partner is even; +'we will just not add it to our product. +Do Until x < 2 + If Not(isEven(x)) Then + product = (product + y) + End If + x = halveInt(x) + y = doubleInt(y) + Print str$(x) + " " + str$(y) +Loop +product = (product + y) +If (x < 0) Then product = (product * -1) +Print msg$ + str$(product) + +Function isEven(num) + isEven = Abs(Not(num Mod 2)) +End Function + +Function halveInt(num) + halveInt = Int(num/ 2) +End Function + +Function doubleInt(num) + doubleInt = (num * 2) +End Function diff --git a/Task/Ethiopian-multiplication/Locomotive-Basic/ethiopian-multiplication.bas b/Task/Ethiopian-multiplication/Locomotive-Basic/ethiopian-multiplication.bas new file mode 100644 index 0000000000..5c944584a2 --- /dev/null +++ b/Task/Ethiopian-multiplication/Locomotive-Basic/ethiopian-multiplication.bas @@ -0,0 +1,10 @@ +10 DEF FNiseven(a)=(a+1) MOD 2 +20 DEF FNhalf(a)=INT(a/2) +30 DEF FNdouble(a)=2*a +40 x=17:y=34:tot=0 +50 WHILE x>=1 +60 PRINT x, +70 IF FNiseven(x)=0 THEN tot=tot+y:PRINT y ELSE PRINT +80 x=FNhalf(x):y=FNdouble(y) +90 WEND +100 PRINT "=", tot diff --git a/Task/Ethiopian-multiplication/Logo/ethiopian-multiplication.logo b/Task/Ethiopian-multiplication/Logo/ethiopian-multiplication.logo new file mode 100644 index 0000000000..5716abbe7a --- /dev/null +++ b/Task/Ethiopian-multiplication/Logo/ethiopian-multiplication.logo @@ -0,0 +1,15 @@ +to double :x + output ashift :x 1 +end +to halve :x + output ashift :x -1 +end +to even? :x + output equal? 0 bitand 1 :x +end +to eproduct :x :y + if :x = 0 [output 0] + ifelse even? :x ~ + [output eproduct halve :x double :y] ~ + [output :y + eproduct halve :x double :y] +end diff --git a/Task/Ethiopian-multiplication/MMIX/ethiopian-multiplication.mmix b/Task/Ethiopian-multiplication/MMIX/ethiopian-multiplication.mmix new file mode 100644 index 0000000000..f2897288be --- /dev/null +++ b/Task/Ethiopian-multiplication/MMIX/ethiopian-multiplication.mmix @@ -0,0 +1,51 @@ +A IS 17 +B IS 34 + +pliar IS $255 % designating main registers +pliand GREG +acc GREG +str IS pliar % reuse reg $255 for printing + + LOC Data_Segment + GREG @ +BUF OCTA #3030303030303030 % reserve a buffer that is big enough to hold + OCTA #3030303030303030 % a max (signed) 64 bit integer: + OCTA #3030300a00000000 % 2^63 - 1 = 9223372036854775807 + % string is terminated with NL, 0 + + LOC #1000 % locate program at address + GREG @ +halve SR pliar,pliar,1 + GO $127,$127,0 + +double SL pliand,pliand,1 + GO $127,$127,0 + +odd DIV $77,pliar,2 + GET $78,rR + GO $127,$127,0 + + % Main is the entry point of the program +Main SET pliar,A % initialize registers for calculation + SET pliand,B + SET acc,0 +1H GO $127,odd + BZ $78,2F % if pliar is even skip incr. acc with pliand + ADD acc,acc,pliand % +2H GO $127,halve % halve pliar + GO $127,double % and double pliand + PBNZ pliar,1B % repeat from 1H while pliar > 0 +// result: acc = 17 x 34 +// next: print result --> stdout +// $0 is a temp register + LDA str,BUF+19 % points after the end of the string +2H SUB str,str,1 % update buffer pointer + DIV acc,acc,10 % do a divide and mod + GET $0,rR % get digit from special purpose reg. rR + % containing the remainder of the division + INCL $0,'0' % convert to ascii + STBU $0,str % place digit in buffer + PBNZ acc,2B % next + % 'str' points to the start of the result + TRAP 0,Fputs,StdOut % output answer to stdout + TRAP 0,Halt,0 % exit diff --git a/Task/Ethiopian-multiplication/MUMPS/ethiopian-multiplication.mumps b/Task/Ethiopian-multiplication/MUMPS/ethiopian-multiplication.mumps new file mode 100644 index 0000000000..34c3b66ab1 --- /dev/null +++ b/Task/Ethiopian-multiplication/MUMPS/ethiopian-multiplication.mumps @@ -0,0 +1,17 @@ +HALVE(I) + ;I should be an integer + QUIT I\2 +DOUBLE(I) + ;I should be an integer + QUIT I*2 +ISEVEN(I) + ;I should be an integer + QUIT '(I#2) +E2(M,N) + New W,A,E,L Set W=$Select($Length(M)>=$Length(N):$Length(M)+2,1:$L(N)+2),A=0,L=0,A(L,1)=M,A(L,2)=N + Write "Multiplying two numbers:" + For Write !,$Justify(A(L,1),W),?W,$Justify(A(L,2),W) Write:$$ISEVEN(A(L,1)) ?(2*W)," Struck" Set:'$$ISEVEN(A(L,1)) A=A+A(L,2) Set L=L+1,A(L,1)=$$HALVE(A(L-1,1)),A(L,2)=$$DOUBLE(A(L-1,2)) Quit:A(L,1)<1 + Write ! For E=W:1:(2*W) Write ?E,"=" + Write !,?W,$Justify(A,W),! + Kill W,A,E,L + Q diff --git a/Task/Ethiopian-multiplication/Mathematica/ethiopian-multiplication.mathematica b/Task/Ethiopian-multiplication/Mathematica/ethiopian-multiplication.mathematica new file mode 100644 index 0000000000..cb67413793 --- /dev/null +++ b/Task/Ethiopian-multiplication/Mathematica/ethiopian-multiplication.mathematica @@ -0,0 +1,7 @@ +IntegerHalving[x_]:=Floor[x/2] +IntegerDoubling[x_]:=x*2; +OddInteger OddQ +Ethiopian[x_, y_] := +Total[Select[NestWhileList[{IntegerHalving[#[[1]]],IntegerDoubling[#[[2]]]}&, {x,y}, (#[[1]]>1&)], OddQ[#[[1]]]&]][[2]] + +Ethiopian[17, 34] diff --git a/Task/Ethiopian-multiplication/Metafont/ethiopian-multiplication.metafont b/Task/Ethiopian-multiplication/Metafont/ethiopian-multiplication.metafont new file mode 100644 index 0000000000..ddb3092992 --- /dev/null +++ b/Task/Ethiopian-multiplication/Metafont/ethiopian-multiplication.metafont @@ -0,0 +1,20 @@ +vardef halve(expr x) = floor(x/2) enddef; +vardef double(expr x) = x*2 enddef; +vardef iseven(expr x) = if (x mod 2) = 0: true else: false fi enddef; + +primarydef a ethiopicmult b = + begingroup + save r_, plier_, plicand_; + plier_ := a; plicand_ := b; + r_ := 0; + forever: exitif plier_ < 1; + if not iseven(plier_): r_ := r_ + plicand_; fi + plier_ := halve(plier_); + plicand_ := double(plicand_); + endfor + r_ + endgroup +enddef; + +show( (17 ethiopicmult 34) ); +end diff --git a/Task/Ethiopian-multiplication/Modula-3/ethiopian-multiplication.mod3 b/Task/Ethiopian-multiplication/Modula-3/ethiopian-multiplication.mod3 new file mode 100644 index 0000000000..e11398eed5 --- /dev/null +++ b/Task/Ethiopian-multiplication/Modula-3/ethiopian-multiplication.mod3 @@ -0,0 +1,38 @@ +MODULE Ethiopian EXPORTS Main; + +IMPORT IO, Fmt; + +PROCEDURE IsEven(n: INTEGER): BOOLEAN = + BEGIN + RETURN n MOD 2 = 0; + END IsEven; + +PROCEDURE Double(n: INTEGER): INTEGER = + BEGIN + RETURN n * 2; + END Double; + +PROCEDURE Half(n: INTEGER): INTEGER = + BEGIN + RETURN n DIV 2; + END Half; + +PROCEDURE Multiply(a, b: INTEGER): INTEGER = + VAR + temp := 0; + plier := a; + plicand := b; + BEGIN + WHILE plier >= 1 DO + IF NOT IsEven(plier) THEN + temp := temp + plicand; + END; + plier := Half(plier); + plicand := Double(plicand); + END; + RETURN temp; + END Multiply; + +BEGIN + IO.Put("17 times 34 = " & Fmt.Int(Multiply(17, 34)) & "\n"); +END Ethiopian. diff --git a/Task/Euler-method/Groovy/euler-method-1.groovy b/Task/Euler-method/Groovy/euler-method-1.groovy new file mode 100644 index 0000000000..b67f2b55ec --- /dev/null +++ b/Task/Euler-method/Groovy/euler-method-1.groovy @@ -0,0 +1,15 @@ +def eulerStep = { xn, yn, h, dydx -> + (yn + h * dydx(xn, yn)) as BigDecimal +} + +Map eulerMapping = { x0, y0, h, dydx, stopCond = { xx, yy, hh, xx0 -> abs(xx - xx0) > (hh * 100) }.rcurry(h, x0) -> + Map yMap = [:] + yMap[x0] = y0 as BigDecimal + def x = x0 + while (!stopCond(x, yMap[x])) { + yMap[x + h] = eulerStep(x, yMap[x], h, dydx) + x += h + } + yMap +} +assert eulerMapping.maximumNumberOfParameters == 5 diff --git a/Task/Euler-method/Groovy/euler-method-2.groovy b/Task/Euler-method/Groovy/euler-method-2.groovy new file mode 100644 index 0000000000..489bc23c47 --- /dev/null +++ b/Task/Euler-method/Groovy/euler-method-2.groovy @@ -0,0 +1,8 @@ +def dtdsNewton = { s, t, tR, k -> k * (tR - t) } +assert dtdsNewton.maximumNumberOfParameters == 4 + +def dtds = dtdsNewton.rcurry(20, 0.07) +assert dtds.maximumNumberOfParameters == 2 + +def tEulerH = eulerMapping.rcurry(dtds) { s, t -> s >= 100 } +assert tEulerH.maximumNumberOfParameters == 3 diff --git a/Task/Euler-method/Groovy/euler-method-3.groovy b/Task/Euler-method/Groovy/euler-method-3.groovy new file mode 100644 index 0000000000..2d9e79b628 --- /dev/null +++ b/Task/Euler-method/Groovy/euler-method-3.groovy @@ -0,0 +1,7 @@ +def tNewton = { s, s0, t0, tR, k -> + tR + (t0 - tR) * Math.exp(k * (s0 - s)) +} +assert tNewton.maximumNumberOfParameters == 5 + +def tAnalytic = tNewton.rcurry(0, 100, 20, 0.07) +assert tAnalytic.maximumNumberOfParameters == 1 diff --git a/Task/Euler-method/Groovy/euler-method-4.groovy b/Task/Euler-method/Groovy/euler-method-4.groovy new file mode 100644 index 0000000000..d841ad159a --- /dev/null +++ b/Task/Euler-method/Groovy/euler-method-4.groovy @@ -0,0 +1,14 @@ +[10, 5, 2].each { h -> + def tEuler = tEulerH.rcurry(h) + assert tEuler.maximumNumberOfParameters == 2 + println """ +STEP SIZE == ${h} + time analytic euler relative +(seconds) (°C) (°C) error +-------- -------- -------- ---------""" + tEuler(0, 100).each { BigDecimal s, tE -> + def tA = tAnalytic(s) + def relError = ((tE - tA)/(tA - 20)).abs() + printf('%5.0f %8.4f %8.4f %9.6f\n', s, tA, tE, relError) + } +} diff --git a/Task/Euler-method/Icon/euler-method.icon b/Task/Euler-method/Icon/euler-method.icon new file mode 100644 index 0000000000..5294572c1c --- /dev/null +++ b/Task/Euler-method/Icon/euler-method.icon @@ -0,0 +1,22 @@ +invocable "newton_cooling" # needed to use the 'proc' procedure + +procedure euler (f, y0, a, b, h) + t := a + y := y0 + until (t >= b) do { + write (right(t, 4) || " " || left(y, 7)) + t +:= h + y +:= h * (proc(f) (t, y)) # 'proc' applies procedure named in f to (t, y) + } + write ("DONE") +end + +procedure newton_cooling (time, T) + return -0.07 * (T - 20) +end + +procedure main () + # generate data for all three step sizes [2, 5, 10] + every (step_size := ![2,5,10]) do + euler ("newton_cooling", 100, 0, 100, step_size) +end diff --git a/Task/Euler-method/J/euler-method-1.j b/Task/Euler-method/J/euler-method-1.j new file mode 100644 index 0000000000..2442d16386 --- /dev/null +++ b/Task/Euler-method/J/euler-method-1.j @@ -0,0 +1,9 @@ +NB.*euler a Approximates Y(t) in Y'(t)=f(t,Y) with Y(a)=Y0 and t=a..b and step size h. +euler=: adverb define + 'Y0 a b h'=. 4{. y + t=. i.@>:&.(%&h) b - a + Y=. (+ h * u)^:(<#t) Y0 + t,.Y +) + +ncl=: _0.07 * -&20 NB. Newton's Cooling Law diff --git a/Task/Euler-method/J/euler-method-2.j b/Task/Euler-method/J/euler-method-2.j new file mode 100644 index 0000000000..b96d806939 --- /dev/null +++ b/Task/Euler-method/J/euler-method-2.j @@ -0,0 +1,16 @@ + ncl euler 100 0 100 2 +... NB. output redacted for brevity + ncl euler 100 0 100 5 +... NB. output redacted for brevity + ncl euler 100 0 100 10 + 0 100 + 10 44 + 20 27.2 + 30 22.16 + 40 20.648 + 50 20.1944 + 60 20.0583 + 70 20.0175 + 80 20.0052 + 90 20.0016 +100 20.0005 diff --git a/Task/Euler-method/Mathematica/euler-method.mathematica b/Task/Euler-method/Mathematica/euler-method.mathematica new file mode 100644 index 0000000000..fd2ca20c09 --- /dev/null +++ b/Task/Euler-method/Mathematica/euler-method.mathematica @@ -0,0 +1 @@ +euler[step_, val_] := NDSolve[{T'[t] == -0.07 (T[t] - 20), T[0] == 100}, T, {t, 0, 100}, Method -> "ExplicitEuler", StartingStepSize -> step][[1, 1, 2]][val] diff --git a/Task/Evaluate-binomial-coefficients/Frink/evaluate-binomial-coefficients.frink b/Task/Evaluate-binomial-coefficients/Frink/evaluate-binomial-coefficients.frink new file mode 100644 index 0000000000..045ccb1095 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Frink/evaluate-binomial-coefficients.frink @@ -0,0 +1 @@ +println[binomial[5,3]] diff --git a/Task/Evaluate-binomial-coefficients/GAP/evaluate-binomial-coefficients.gap b/Task/Evaluate-binomial-coefficients/GAP/evaluate-binomial-coefficients.gap new file mode 100644 index 0000000000..362dca5769 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/GAP/evaluate-binomial-coefficients.gap @@ -0,0 +1,3 @@ +# Built-in +Binomial(5, 3); +# 10 diff --git a/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-1.golf b/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-1.golf new file mode 100644 index 0000000000..236f95ecd5 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-1.golf @@ -0,0 +1,3 @@ +;5 3 # Set up demo input +{),(;{*}*}:f; # Define a factorial function +.f@.f@/\@-f/ diff --git a/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-2.golf b/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-2.golf new file mode 100644 index 0000000000..e7e1a2f278 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Golfscript/evaluate-binomial-coefficients-2.golf @@ -0,0 +1,2 @@ +;5 3 # Set up demo input +1\,@{1$-@\*\)/}+/ diff --git a/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-1.groovy b/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-1.groovy new file mode 100644 index 0000000000..5c24b0ffd6 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-1.groovy @@ -0,0 +1,10 @@ +def factorial = { x -> + assert x > -1 + x == 0 ? 1 : (1..x).inject(1G) { BigInteger product, BigInteger factor -> product *= factor } +} + +def combinations = { n, k -> + assert k >= 0 + assert n >= k + factorial(n).intdiv(factorial(k)*factorial(n-k)) +} diff --git a/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-2.groovy b/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-2.groovy new file mode 100644 index 0000000000..e2d5568b12 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Groovy/evaluate-binomial-coefficients-2.groovy @@ -0,0 +1,4 @@ +assert combinations(20, 0) == combinations(20, 20) +assert combinations(20, 10) == (combinations(19, 9) + combinations(19, 10)) +assert combinations(5, 3) == 10 +println combinations(5, 3) diff --git a/Task/Evaluate-binomial-coefficients/HicEst/evaluate-binomial-coefficients.hicest b/Task/Evaluate-binomial-coefficients/HicEst/evaluate-binomial-coefficients.hicest new file mode 100644 index 0000000000..364f270d26 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/HicEst/evaluate-binomial-coefficients.hicest @@ -0,0 +1,12 @@ +WRITE(Messagebox) BinomCoeff( 5, 3) ! displays 10 + +FUNCTION factorial( n ) + factorial = 1 + DO i = 1, n + factorial = factorial * i + ENDDO +END + +FUNCTION BinomCoeff( n, k ) + BinomCoeff = factorial(n)/factorial(n-k)/factorial(k) +END diff --git a/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-1.icon b/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-1.icon new file mode 100644 index 0000000000..3e066a7df5 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-1.icon @@ -0,0 +1,5 @@ +link math, factors + +procedure main() +write("choose(5,3)=",binocoef(5,3)) +end diff --git a/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-2.icon b/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-2.icon new file mode 100644 index 0000000000..a2cb55fba9 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Icon/evaluate-binomial-coefficients-2.icon @@ -0,0 +1,27 @@ +procedure binocoef(n, k) #: binomial coefficient + + k := integer(k) | fail + n := integer(n) | fail + + if (k = 0) | (n = k) then return 1 + + if 0 <= k <= n then + return factorial(n) / (factorial(k) * factorial(n - k)) + else fail + +end + +procedure factorial(n) #: return n! (n factorial) + local i + + n := integer(n) | runerr(101, n) + + if n < 0 then fail + + i := 1 + + every i *:= 1 to n + + return i + +end diff --git a/Task/Evaluate-binomial-coefficients/J/evaluate-binomial-coefficients.j b/Task/Evaluate-binomial-coefficients/J/evaluate-binomial-coefficients.j new file mode 100644 index 0000000000..44822d748d --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/J/evaluate-binomial-coefficients.j @@ -0,0 +1,2 @@ + 3 ! 5 +10 diff --git a/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-1.k b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-1.k new file mode 100644 index 0000000000..92b9d98c9e --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-1.k @@ -0,0 +1,2 @@ + {[n;k]_(*/(k-1)_1+!n)%(*/1+!k)} . 5 3 +10 diff --git a/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-2.k b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-2.k new file mode 100644 index 0000000000..447fd7b6d3 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-2.k @@ -0,0 +1,2 @@ + {[n;k]i:!(k-1);_*/((n-i)%(i+1))} . 5 3 +10 diff --git a/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-3.k b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-3.k new file mode 100644 index 0000000000..bc08baf008 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/K/evaluate-binomial-coefficients-3.k @@ -0,0 +1,11 @@ + pascal:{x{+':0,x,0}\1} + pascal 5 +(1 + 1 1 + 1 2 1 + 1 3 3 1 + 1 4 6 4 1 + 1 5 10 10 5 1) + + {[n;k](pascal n)[n;k]} . 5 3 +10 diff --git a/Task/Evaluate-binomial-coefficients/Liberty-BASIC/evaluate-binomial-coefficients.liberty b/Task/Evaluate-binomial-coefficients/Liberty-BASIC/evaluate-binomial-coefficients.liberty new file mode 100644 index 0000000000..cf510674d7 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Liberty-BASIC/evaluate-binomial-coefficients.liberty @@ -0,0 +1,21 @@ + ' [RC] Binomial Coefficients + + print "Binomial Coefficient of "; 5; " and "; 3; " is ",BinomialCoefficient( 5, 3) + n =1 +int( 10 *rnd( 1)) + k =1 +int( n *rnd( 1)) + print "Binomial Coefficient of "; n; " and "; k; " is ",BinomialCoefficient( n, k) + + end + + function BinomialCoefficient( n, k) + BinomialCoefficient =factorial( n) /factorial( n -k) /factorial( k) + end function + + function factorial( n) + if n <2 then + f =1 + else + f =n *factorial( n -1) + end if + factorial =f + end function diff --git a/Task/Evaluate-binomial-coefficients/Logo/evaluate-binomial-coefficients.logo b/Task/Evaluate-binomial-coefficients/Logo/evaluate-binomial-coefficients.logo new file mode 100644 index 0000000000..d0e32dc354 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Logo/evaluate-binomial-coefficients.logo @@ -0,0 +1,7 @@ +to choose :n :k + if :k = 0 [output 1] + output (choose :n :k-1) * (:n - :k + 1) / :k +end + +show choose 5 3 ; 10 +show choose 60 30 ; 1.18264581564861e+17 diff --git a/Task/Evaluate-binomial-coefficients/Mathematica/evaluate-binomial-coefficients.mathematica b/Task/Evaluate-binomial-coefficients/Mathematica/evaluate-binomial-coefficients.mathematica new file mode 100644 index 0000000000..c79a50d303 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Mathematica/evaluate-binomial-coefficients.mathematica @@ -0,0 +1,2 @@ +(Local) In[1]:= Binomial[5,3] +(Local) Out[1]= 10 diff --git a/Task/Evaluate-binomial-coefficients/Maxima/evaluate-binomial-coefficients.maxima b/Task/Evaluate-binomial-coefficients/Maxima/evaluate-binomial-coefficients.maxima new file mode 100644 index 0000000000..e4caa80a37 --- /dev/null +++ b/Task/Evaluate-binomial-coefficients/Maxima/evaluate-binomial-coefficients.maxima @@ -0,0 +1,13 @@ +binomial( 5, 3); /* 10 */ +binomial(-5, 3); /* -35 */ +binomial( 5, -3); /* 0 */ +binomial(-5, -3); /* 0 */ +binomial( 3, 5); /* 0 */ + +binomial(x, 3); /* ((x - 2)*(x - 1)*x)/6 */ + +binomial(3, 1/2); /* binomial(3, 1/2) */ +makegamma(%); /* 32/(5*%pi) */ + +binomial(a, b); /* binomial(a, b) */ +makegamma(%); /* gamma(a + 1)/(gamma(-b + a + 1)*gamma(b + 1)) */ diff --git a/Task/Even-or-odd/Fish/even-or-odd.fish b/Task/Even-or-odd/Fish/even-or-odd.fish new file mode 100644 index 0000000000..c27494a242 --- /dev/null +++ b/Task/Even-or-odd/Fish/even-or-odd.fish @@ -0,0 +1,4 @@ +l0)?!vo v < v o< +^ >i:a=?v>i:a=?v$a*+^>"The number is even."ar>l0=?!^> + > >2%0=?^"The number is odd."ar ^ diff --git a/Task/Even-or-odd/Groovy/even-or-odd-1.groovy b/Task/Even-or-odd/Groovy/even-or-odd-1.groovy new file mode 100644 index 0000000000..617558f0a5 --- /dev/null +++ b/Task/Even-or-odd/Groovy/even-or-odd-1.groovy @@ -0,0 +1,2 @@ +def isOdd = { int i -> (i & 1) as boolean } +def isEven = {int i -> ! isOdd(i) } diff --git a/Task/Even-or-odd/Groovy/even-or-odd-2.groovy b/Task/Even-or-odd/Groovy/even-or-odd-2.groovy new file mode 100644 index 0000000000..cf28907386 --- /dev/null +++ b/Task/Even-or-odd/Groovy/even-or-odd-2.groovy @@ -0,0 +1,3 @@ +1.step(20, 2) { assert isOdd(it) } + +50.step(-50, -2) { assert isEven(it) } diff --git a/Task/Even-or-odd/Icon/even-or-odd.icon b/Task/Even-or-odd/Icon/even-or-odd.icon new file mode 100644 index 0000000000..086fa084dc --- /dev/null +++ b/Task/Even-or-odd/Icon/even-or-odd.icon @@ -0,0 +1,3 @@ +procedure isEven(n) + return n%2 = 0 +end diff --git a/Task/Even-or-odd/J/even-or-odd-1.j b/Task/Even-or-odd/J/even-or-odd-1.j new file mode 100644 index 0000000000..5592594947 --- /dev/null +++ b/Task/Even-or-odd/J/even-or-odd-1.j @@ -0,0 +1,4 @@ + 2 | 2 3 5 7 +0 1 1 1 + 2|2 3 5 7 + (2^89x)-1 +1 0 0 0 diff --git a/Task/Even-or-odd/J/even-or-odd-2.j b/Task/Even-or-odd/J/even-or-odd-2.j new file mode 100644 index 0000000000..2c9c9b37ab --- /dev/null +++ b/Task/Even-or-odd/J/even-or-odd-2.j @@ -0,0 +1,4 @@ + (= <.&.-:) 2 3 5 7 +1 0 0 0 + (= <.&.-:) 2 3 5 7+(2^89x)-1 +0 1 1 1 diff --git a/Task/Even-or-odd/J/even-or-odd-3.j b/Task/Even-or-odd/J/even-or-odd-3.j new file mode 100644 index 0000000000..e52c35a4b7 --- /dev/null +++ b/Task/Even-or-odd/J/even-or-odd-3.j @@ -0,0 +1,4 @@ + {:"1@#: 2 3 5 7 +0 1 1 1 + {:"1@#: 2 3 5 7+(2^89x)-1 +1 0 0 0 diff --git a/Task/Even-or-odd/J/even-or-odd-4.j b/Task/Even-or-odd/J/even-or-odd-4.j new file mode 100644 index 0000000000..83d59f5f59 --- /dev/null +++ b/Task/Even-or-odd/J/even-or-odd-4.j @@ -0,0 +1,2 @@ + 1 (17 b.) 2 3 5 7 +0 1 1 1 diff --git a/Task/Even-or-odd/Lang5/even-or-odd.lang5 b/Task/Even-or-odd/Lang5/even-or-odd.lang5 new file mode 100644 index 0000000000..9eddc0ac9a --- /dev/null +++ b/Task/Even-or-odd/Lang5/even-or-odd.lang5 @@ -0,0 +1,4 @@ +: even? 2 % not ; +: odd? 2 % ; +1 even? . # 0 +1 odd? . # 1 diff --git a/Task/Even-or-odd/Liberty-BASIC/even-or-odd.liberty b/Task/Even-or-odd/Liberty-BASIC/even-or-odd.liberty new file mode 100644 index 0000000000..38160d4238 --- /dev/null +++ b/Task/Even-or-odd/Liberty-BASIC/even-or-odd.liberty @@ -0,0 +1,3 @@ +n=12 + +if n mod 2 = 0 then print "even" else print "odd" diff --git a/Task/Even-or-odd/Mathematica/even-or-odd.mathematica b/Task/Even-or-odd/Mathematica/even-or-odd.mathematica new file mode 100644 index 0000000000..31d1dc128b --- /dev/null +++ b/Task/Even-or-odd/Mathematica/even-or-odd.mathematica @@ -0,0 +1 @@ +EvenQ[8] diff --git a/Task/Even-or-odd/Maxima/even-or-odd.maxima b/Task/Even-or-odd/Maxima/even-or-odd.maxima new file mode 100644 index 0000000000..f5d0a5184f --- /dev/null +++ b/Task/Even-or-odd/Maxima/even-or-odd.maxima @@ -0,0 +1,2 @@ +evenp(n); +oddp(n); diff --git a/Task/Even-or-odd/Mercury/even-or-odd.mercury b/Task/Even-or-odd/Mercury/even-or-odd.mercury new file mode 100644 index 0000000000..a551bba8b7 --- /dev/null +++ b/Task/Even-or-odd/Mercury/even-or-odd.mercury @@ -0,0 +1,10 @@ +even(N) % in a body, suceeeds iff N is even. +odd(N). % in a body, succeeds iff N is odd. + +% rolling our own: +:- pred even(int::in) is semidet. + +% It's an error to have all three in one module, mind; even/1 would fail to check as semidet. +even(N) :- N mod 2 = 0. % using division that truncates towards -infinity +even(N) :- N rem 2 = 0. % using division that truncates towards zero +even(N) :- N /\ 1 = 0. % using bit-wise and. diff --git a/Task/Events/Mathematica/events.mathematica b/Task/Events/Mathematica/events.mathematica new file mode 100644 index 0000000000..87fd6d7d11 --- /dev/null +++ b/Task/Events/Mathematica/events.mathematica @@ -0,0 +1,2 @@ +Print["Will exit in 4 seconds"]; Pause[4]; Quit[] +->Will exit in 4 seconds diff --git a/Task/Evolutionary-algorithm/Fantom/evolutionary-algorithm.fantom b/Task/Evolutionary-algorithm/Fantom/evolutionary-algorithm.fantom new file mode 100644 index 0000000000..f9fd354f1e --- /dev/null +++ b/Task/Evolutionary-algorithm/Fantom/evolutionary-algorithm.fantom @@ -0,0 +1,56 @@ +class Main +{ + static const Str target := "METHINKS IT IS LIKE A WEASEL" + static const Int C := 100 // size of population + static const Float p := 0.1f // chance any char is mutated + + // compute distance of str from target + static Int fitness (Str str) + { + Int sum := 0 + str.each |Int c, Int index| + { + if (c != target[index]) sum += 1 + } + return sum + } + + // mutate given parent string + static Str mutate (Str str) + { + Str result := "" + str.size.times |Int index| + { + result += ((Float.random < p) ? randomChar() : str[index]).toChar + } + return result + } + + // return a random char + static Int randomChar () + { + "ABCDEFGHIJKLMNOPQRSTUVWXYZ "[Int.random(0..26)] + } + + // make population by mutating parent and sorting by fitness + static Str[] makePopulation (Str parent) + { + Str[] result := [,] + C.times { result.add (mutate(parent)) } + result.sort |Str a, Str b -> Int| { fitness(a) <=> fitness(b) } + return result + } + + public static Void main () + { + Str parent := "" + target.size.times { parent += randomChar().toChar } + + while (parent != target) + { + echo (parent) + parent = makePopulation(parent).first + } + echo (parent) + } +} diff --git a/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon new file mode 100644 index 0000000000..039ac0694b --- /dev/null +++ b/Task/Evolutionary-algorithm/Icon/evolutionary-algorithm.icon @@ -0,0 +1,51 @@ +global target, chars, parent, C, M, current_fitness + +procedure fitness(s) + fit := 0 + #Increment the fitness for every position in the string s that matches the target + every i := 1 to *target & s[i] == target[i] do fit +:= 1 + return fit +end + +procedure mutate(s) + #If a random number between 0 and 1 is inside the bounds of mutation randomly alter a character in the string + if (?0 <= M) then ?s := ?chars + return s +end + +procedure generation() + population := [ ] + next_parent := "" + next_fitness := -1 + + #Create the next population + every 1 to C do push(population, mutate(parent)) + #Find the member of the population with highest fitness, or use the last one inspected + every x := !population & (xf := fitness(x)) > next_fitness do { + next_parent := x + next_fitness := xf + } + + parent := next_parent + + return next_fitness +end + +procedure main() + target := "METHINKS IT IS LIKE A WEASEL" #Our target string + chars := &ucase ++ " " #Set of usable characters + parent := "" & every 1 to *target do parent ||:= ?chars #The universal common ancestor! + current_fitness := fitness(parent) #The best fitness we have so far + + + C := 50 #Population size in each generation + M := 0.5 #Mutation rate per individual in a generation + + gen := 1 + #Until current fitness reaches a score of perfect match with the target string keep generating new populations + until ((current_fitness := generation()) = *target) do { + write(gen || " " || current_fitness || " " || parent) + gen +:= 1 + } + write("At generation " || gen || " we found a string with perfect fitness at " || current_fitness || " reading: " || parent) +end diff --git a/Task/Evolutionary-algorithm/J/evolutionary-algorithm-1.j b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-1.j new file mode 100644 index 0000000000..040a2f39c6 --- /dev/null +++ b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-1.j @@ -0,0 +1,14 @@ +CHARSET=: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' +NPROG=: 100 NB. number of progeny (C) +MRATE=: 0.05 NB. mutation rate + +create =: (?@$&$ { ])&CHARSET NB. creates random list from charset of same shape as y +fitness =: +/@:~:"1 +copy =: # ,: +mutate =: &(>: $ ?@$ 0:)(`(,: create))} NB. adverb +select =: ] {~ (i. <./)@:fitness NB. select fittest member of population + +nextgen =: select ] , [: MRATE mutate NPROG copy ] +while =: conjunction def '(] , (u {:))^:(v {:)^:_ ,:' + +evolve=: nextgen while (0 < fitness) create diff --git a/Task/Evolutionary-algorithm/J/evolutionary-algorithm-2.j b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-2.j new file mode 100644 index 0000000000..8d3b19b0b0 --- /dev/null +++ b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-2.j @@ -0,0 +1,6 @@ + filter=: {: ,~ ({~ i.@>.&.(%&20)@#) NB. take every 20th and last item + filter evolve 'METHINKS IT IS LIKE A WEASEL' +XXURVQXKQXDLCGFVICCUA NUQPND +MEFHINVQQXT IW LIKEUA WEAPEL +METHINVS IT IW LIKEUA WEAPEL +METHINKS IT IS LIKE A WEASEL diff --git a/Task/Evolutionary-algorithm/J/evolutionary-algorithm-3.j b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-3.j new file mode 100644 index 0000000000..104bc99308 --- /dev/null +++ b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-3.j @@ -0,0 +1,27 @@ +CHARSET=: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' +NPROG=: 100 NB. "C" from specification + +fitness=: +/@:~:"1 +select=: ] {~ (i. <./)@:fitness NB. select fittest member of population +populate=: (?@$&# { ])&CHARSET NB. get random list from charset of same length as y +log=: [: smoutput [: ;:inv (('#';'fitness: ';'; ') ,&.> ":&.>) + +mutate=: dyad define + idxmut=. I. x >: (*/$y) ?@$ 0 + (populate idxmut) idxmut"_} y +) + +evolve=: monad define + target=. y + parent=. populate y + iter=. 0 + mrate=. %#y + while. 0 < val=. target fitness parent do. + if. 0 = 50|iter do. log iter;val;parent end. + iter=. iter + 1 + progeny=. mrate mutate NPROG # ,: parent NB. create progeny by mutating parent copies + parent=. target select parent,progeny NB. select fittest parent for next generation + end. + log iter;val;parent + parent +) diff --git a/Task/Evolutionary-algorithm/J/evolutionary-algorithm-4.j b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-4.j new file mode 100644 index 0000000000..f12be43f82 --- /dev/null +++ b/Task/Evolutionary-algorithm/J/evolutionary-algorithm-4.j @@ -0,0 +1,5 @@ + evolve 'METHINKS IT IS LIKE A WEASEL' +#0 fitness: 27 ; YGFDJFTBEDB FAIJJGMFKDPYELOA +#50 fitness: 2 ; MEVHINKS IT IS LIKE ADWEASEL +#76 fitness: 0 ; METHINKS IT IS LIKE A WEASEL +METHINKS IT IS LIKE A WEASEL diff --git a/Task/Evolutionary-algorithm/Liberty-BASIC/evolutionary-algorithm.liberty b/Task/Evolutionary-algorithm/Liberty-BASIC/evolutionary-algorithm.liberty new file mode 100644 index 0000000000..802c1bad5b --- /dev/null +++ b/Task/Evolutionary-algorithm/Liberty-BASIC/evolutionary-algorithm.liberty @@ -0,0 +1,69 @@ +C = 10 +'mutaterate has to be greater than 1 or it will not mutate +mutaterate = 2 +mutationstaken = 0 +generations = 0 +Dim parentcopies$((C - 1)) +Global targetString$ : targetString$ = "METHINKS IT IS LIKE A WEASEL" +Global allowableCharacters$ : allowableCharacters$ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ" +currentminFitness = Len(targetString$) + +For i = 1 To Len(targetString$) + parent$ = parent$ + Mid$(allowableCharacters$, Int(Rnd(1) * Len(allowableCharacters$)), 1) +Next i + +Print "Parent = " + parent$ + +While parent$ <> targetString$ + generations = (generations + 1) + For i = 0 To (C - 1) + parentcopies$(i) = mutate$(parent$, mutaterate) + mutationstaken = (mutationstaken + 1) + Next i + For i = 0 To (C - 1) + currentFitness = Fitness(targetString$, parentcopies$(i)) + If currentFitness = 0 Then + parent$ = parentcopies$(i) + Exit For + Else + If currentFitness < currentminFitness Then + currentminFitness = currentFitness + parent$ = parentcopies$(i) + End If + End If + Next i + CLS + Print "Generation - " + str$(generations) + Print "Parent - " + parent$ + Scan +Wend + +Print +Print "Congratulations to me; I finished!" +Print "Final Mutation: " + parent$ +'The ((i + 1) - (C)) reduces the total number of mutations that it took by one generation +'minus the perfect child mutation since any after that would not have been required. +Print "Total Mutations Taken - " + str$(mutationstaken - ((i + 1) - (C))) +Print "Total Generations Taken - " + str$(generations) +Print "Child Number " + str$(i) + " has perfect similarities to your target." +End + + + +Function mutate$(mutate$, mutaterate) + If (Rnd(1) * mutaterate) > 1 Then + 'The mutatingcharater randomizer needs 1 more than the length of the string + 'otherwise it will likely take forever to get exactly that as a random number + mutatingcharacter = Int(Rnd(1) * (Len(targetString$) + 1)) + mutate$ = Left$(mutate$, (mutatingcharacter - 1)) + Mid$(allowableCharacters$, Int(Rnd(1) * Len(allowableCharacters$)), 1) _ + + Mid$(mutate$, (mutatingcharacter + 1)) + End If +End Function + +Function Fitness(parent$, offspring$) + For i = 1 To Len(targetString$) + If Mid$(parent$, i, 1) <> Mid$(offspring$, i, 1) Then + Fitness = (Fitness + 1) + End If + Next i +End Function diff --git a/Task/Evolutionary-algorithm/Logo/evolutionary-algorithm.logo b/Task/Evolutionary-algorithm/Logo/evolutionary-algorithm.logo new file mode 100644 index 0000000000..2876b651d9 --- /dev/null +++ b/Task/Evolutionary-algorithm/Logo/evolutionary-algorithm.logo @@ -0,0 +1,44 @@ +make "target "|METHINKS IT IS LIKE A WEASEL| + +to distance :w + output reduce "sum (map.se [ifelse equal? ?1 ?2 [0][1]] :w :target) +end + +to random.letter + output pick "| ABCDEFGHIJKLMNOPQRSTUVWXYZ| +end + +to mutate :parent :rate + output map [ifelse random 100 < :rate [random.letter] [?]] :parent +end + +make "C 100 +make "mutate.rate 10 ; percent + +to breed :parent + make "parent.distance distance :parent + localmake "best.child :parent + repeat :C [ + localmake "child mutate :parent :mutate.rate + localmake "child.distance distance :child + if greater? :parent.distance :child.distance [ + make "parent.distance :child.distance + make "best.child :child + ] + ] + output :best.child +end + +to progress + output (sentence :trials :parent "distance: :parent.distance) +end + +to evolve + make "parent cascade count :target [lput random.letter ?] "|| + make "trials 0 + while [not equal? :parent :target] [ + make "parent breed :parent + print progress + make "trials :trials + 1 + ] +end diff --git a/Task/Evolutionary-algorithm/Mathematica/evolutionary-algorithm.mathematica b/Task/Evolutionary-algorithm/Mathematica/evolutionary-algorithm.mathematica new file mode 100644 index 0000000000..276742a2a0 --- /dev/null +++ b/Task/Evolutionary-algorithm/Mathematica/evolutionary-algorithm.mathematica @@ -0,0 +1,21 @@ +target = "METHINKS IT IS LIKE A WEASEL"; +alphabet = CharacterRange["A", "Z"]~Join~{" "}; +fitness = HammingDistance[target, #] &; +Mutate[parent_String, rate_: 0.01, fertility_Integer: 25] := Module[ + {offspring, kidfits, gen = 0, alphabet = CharacterRange["A", "Z"]~Join~{" "}}, + offspring = ConstantArray[Characters[parent], fertility]; + Table[ + If[RandomReal[] <= rate, offspring[[j, k]] = RandomChoice[alphabet]], + {j, fertility}, {k, StringLength@parent} + ]; + offspring = StringJoin[#] & /@ offspring; + kidfits = fitness[#] & /@ Flatten[{offspring, parent}]; + Return[offspring[[First@Ordering[kidfits]]]]; + ]; + +mutationRate = 0.02; +parent = StringJoin[ alphabet[[RandomInteger[{1, Length@alphabet}, StringLength@target]]] ]; +results = NestWhileList[Mutate[#, mutationRate, 100] &, parent, fitness[#] > 0 &]; +fits = fitness[#] & /@ results; +results = Transpose[{results, fits}]; +TableForm[results[[;; ;; 2]], TableHeadings->{Range[1, Length@results, 2],{"String","Fitness"}}, TableSpacing -> {1, 2}] diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Fantom/exceptions-catch-an-exception-thrown-in-a-nested-call.fantom b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Fantom/exceptions-catch-an-exception-thrown-in-a-nested-call.fantom new file mode 100644 index 0000000000..34e083a479 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Fantom/exceptions-catch-an-exception-thrown-in-a-nested-call.fantom @@ -0,0 +1,48 @@ +const class U0 : Err +{ + new make () : super ("U0") {} +} + +const class U1 : Err +{ + new make () : super ("U1") {} +} + +class Main +{ + Int bazCalls := 0 + + Void baz () + { + bazCalls += 1 + if (bazCalls == 1) + throw U0() + else + throw U1() + } + + Void bar () + { + baz () + } + + Void foo () + { + 2.times + { + try + { + bar () + } + catch (U0 e) + { + echo ("Caught U0") + } + } + } + + public static Void main () + { + Main().foo + } +} diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-1.j b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-1.j new file mode 100644 index 0000000000..0a8a0b8cbf --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-1.j @@ -0,0 +1,22 @@ +main=: monad define + smoutput 'main' + try. foo '' + catcht. smoutput 'main caught ',type_jthrow_ + end. +) + +foo=: monad define + smoutput ' foo' + for_i. 0 1 do. + try. bar i + catcht. if. type_jthrow_-:'U0' do. smoutput ' foo caught ',type_jthrow_ else. throw. end. + end. + end. +) + +bar=: baz [ smoutput bind ' bar' + +baz=: monad define + smoutput ' baz' + type_jthrow_=: 'U',":y throw. +) diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-2.j b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-2.j new file mode 100644 index 0000000000..a582254009 --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/J/exceptions-catch-an-exception-thrown-in-a-nested-call-2.j @@ -0,0 +1,9 @@ + main '' +main + foo + bar + baz + foo caught U0 + bar + baz +main caught U1 diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Mathematica/exceptions-catch-an-exception-thrown-in-a-nested-call.mathematica b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Mathematica/exceptions-catch-an-exception-thrown-in-a-nested-call.mathematica new file mode 100644 index 0000000000..f31cae736c --- /dev/null +++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Mathematica/exceptions-catch-an-exception-thrown-in-a-nested-call.mathematica @@ -0,0 +1,7 @@ +foo[] := Catch[ bar[1]; bar[2]; ] + +bar[i_] := baz[i]; + +baz[i_] := Switch[i, + 1, Throw["Exception U0 in baz"];, + 2, Throw["Exception U1 in baz"];] diff --git a/Task/Exceptions/Factor/exceptions-1.factor b/Task/Exceptions/Factor/exceptions-1.factor new file mode 100644 index 0000000000..68ae678e88 --- /dev/null +++ b/Task/Exceptions/Factor/exceptions-1.factor @@ -0,0 +1,4 @@ +"Install Linux, Problem Solved" throw + +TUPLE: velociraptor ; +\ velociraptor new throw diff --git a/Task/Exceptions/Factor/exceptions-2.factor b/Task/Exceptions/Factor/exceptions-2.factor new file mode 100644 index 0000000000..fee3da7a27 --- /dev/null +++ b/Task/Exceptions/Factor/exceptions-2.factor @@ -0,0 +1,2 @@ +ERROR: velociraptor ; +velociraptor diff --git a/Task/Exceptions/Factor/exceptions-3.factor b/Task/Exceptions/Factor/exceptions-3.factor new file mode 100644 index 0000000000..a984eaab8a --- /dev/null +++ b/Task/Exceptions/Factor/exceptions-3.factor @@ -0,0 +1,12 @@ +! Preferred exception handling +: try-foo + [ foo ] [ foo-failed ] recover ; + +: try-bar + [ bar ] [ bar-errored ] [ bar-always ] cleanup ; + +! Used rarely +[ "Fail" throw ] try ! throws a "Fail" +[ "Fail" throw ] catch ! returns "Fail" +[ "Hi" print ] catch ! returns f (looks the same as throwing f; don't throw f) +[ f throw ] catch ! returns f, bad! use recover or cleanup instead diff --git a/Task/Exceptions/Fancy/exceptions.fancy b/Task/Exceptions/Fancy/exceptions.fancy new file mode 100644 index 0000000000..01fd1b140c --- /dev/null +++ b/Task/Exceptions/Fancy/exceptions.fancy @@ -0,0 +1,20 @@ +# define custom exception class +# StandardError is base class for all exception classes +class MyError : StandardError { + def initialize: message { + # forward to StdError's initialize method + super initialize: message + } +} + +try { + # raises/throws a new MyError exception within try-block + MyError new: "my message" . raise! +} catch MyError => e { + # catch exception + # this will print "my message" + e message println +} finally { + # this will always be executed (as in e.g. Java) + "This is how exception handling in Fancy works :)" println +} diff --git a/Task/Exceptions/Fantom/exceptions.fantom b/Task/Exceptions/Fantom/exceptions.fantom new file mode 100644 index 0000000000..db6bee6744 --- /dev/null +++ b/Task/Exceptions/Fantom/exceptions.fantom @@ -0,0 +1,23 @@ +// Create a new error class by subclassing sys::Err +const class SpecialErr : Err +{ + // you must provide some message about the error + // to the parent class, for reporting + new make () : super ("special error") {} +} + +class Main +{ + static Void fn () + { + throw SpecialErr () + } + + public static Void main () + { + try + fn() + catch (SpecialErr e) + echo ("Caught " + e) + } +} diff --git a/Task/Exceptions/J/exceptions.j b/Task/Exceptions/J/exceptions.j new file mode 100644 index 0000000000..ed73e0ba21 --- /dev/null +++ b/Task/Exceptions/J/exceptions.j @@ -0,0 +1,18 @@ + pickyPicky =: verb define + if. y-:'bad argument' do. + throw. + else. + 'thanks!' + end. + ) + + tryThis =: verb define + try. + pickyPicky y + catcht. + 'Uh oh!' + end. + ) + + tryThis 'bad argument' +Uh oh! diff --git a/Task/Exceptions/Logo/exceptions.logo b/Task/Exceptions/Logo/exceptions.logo new file mode 100644 index 0000000000..8e154f0433 --- /dev/null +++ b/Task/Exceptions/Logo/exceptions.logo @@ -0,0 +1,7 @@ +to div.checked :a :b + if :b = 0 [(throw "divzero 0)] + output :a / :b +end +to div.safely :a :b + output catch "divzero [div.checked :a :b] +end diff --git a/Task/Exceptions/MOO/exceptions-1.moo b/Task/Exceptions/MOO/exceptions-1.moo new file mode 100644 index 0000000000..0cc6cf531a --- /dev/null +++ b/Task/Exceptions/MOO/exceptions-1.moo @@ -0,0 +1 @@ +raise(E_PERM); diff --git a/Task/Exceptions/MOO/exceptions-2.moo b/Task/Exceptions/MOO/exceptions-2.moo new file mode 100644 index 0000000000..97fbf9b9ce --- /dev/null +++ b/Task/Exceptions/MOO/exceptions-2.moo @@ -0,0 +1,5 @@ +try + this:foo(); +except e (ANY) + this:bar(e); +endtry diff --git a/Task/Exceptions/MOO/exceptions-3.moo b/Task/Exceptions/MOO/exceptions-3.moo new file mode 100644 index 0000000000..51ee7dd2c7 --- /dev/null +++ b/Task/Exceptions/MOO/exceptions-3.moo @@ -0,0 +1,5 @@ +try + this:foo(); +finally + this:bar(); +endtry diff --git a/Task/Exceptions/MOO/exceptions-4.moo b/Task/Exceptions/MOO/exceptions-4.moo new file mode 100644 index 0000000000..4afbc228ad --- /dev/null +++ b/Task/Exceptions/MOO/exceptions-4.moo @@ -0,0 +1 @@ +`this:foo()!ANY=>this:bar()'; diff --git a/Task/Exceptions/Make/exceptions-1.make b/Task/Exceptions/Make/exceptions-1.make new file mode 100644 index 0000000000..1dd0cdb323 --- /dev/null +++ b/Task/Exceptions/Make/exceptions-1.make @@ -0,0 +1,2 @@ +all: + false diff --git a/Task/Exceptions/Make/exceptions-2.make b/Task/Exceptions/Make/exceptions-2.make new file mode 100644 index 0000000000..5d6465963d --- /dev/null +++ b/Task/Exceptions/Make/exceptions-2.make @@ -0,0 +1,2 @@ +all: + -@make -f fail.mk diff --git a/Task/Exceptions/Make/exceptions-3.make b/Task/Exceptions/Make/exceptions-3.make new file mode 100644 index 0000000000..953555d8a5 --- /dev/null +++ b/Task/Exceptions/Make/exceptions-3.make @@ -0,0 +1,2 @@ +all: + make -f fail.mk; exit 0 diff --git a/Task/Exceptions/Mathematica/exceptions.mathematica b/Task/Exceptions/Mathematica/exceptions.mathematica new file mode 100644 index 0000000000..3d0175be2c --- /dev/null +++ b/Task/Exceptions/Mathematica/exceptions.mathematica @@ -0,0 +1,8 @@ +f[x_] := If[x > 10, Throw[overflow], x!] + +Example usage : +Catch[f[2] + f[11]] +-> overflow + +Catch[f[2] + f[3]] +-> 8 diff --git a/Task/Exceptions/Modula-3/exceptions-1.mod3 b/Task/Exceptions/Modula-3/exceptions-1.mod3 new file mode 100644 index 0000000000..b7af559840 --- /dev/null +++ b/Task/Exceptions/Modula-3/exceptions-1.mod3 @@ -0,0 +1,2 @@ +EXCEPTION EndOfFile; +EXCEPTION Error(TEXT); diff --git a/Task/Exceptions/Modula-3/exceptions-2.mod3 b/Task/Exceptions/Modula-3/exceptions-2.mod3 new file mode 100644 index 0000000000..624588a7eb --- /dev/null +++ b/Task/Exceptions/Modula-3/exceptions-2.mod3 @@ -0,0 +1,4 @@ +PROCEDURE Foo() RAISES { EndOfFile } = + ... + RAISE EndOfFile; + ... diff --git a/Task/Exceptions/Modula-3/exceptions-3.mod3 b/Task/Exceptions/Modula-3/exceptions-3.mod3 new file mode 100644 index 0000000000..703eeda640 --- /dev/null +++ b/Task/Exceptions/Modula-3/exceptions-3.mod3 @@ -0,0 +1,5 @@ +TRY + Foo(); +EXCEPT +| EndOfFile => HandleFoo(); +END; diff --git a/Task/Exceptions/Modula-3/exceptions-4.mod3 b/Task/Exceptions/Modula-3/exceptions-4.mod3 new file mode 100644 index 0000000000..603a4f9d4b --- /dev/null +++ b/Task/Exceptions/Modula-3/exceptions-4.mod3 @@ -0,0 +1,5 @@ +TRY + Foo(); +FINALLY + CleanupFoo(); (* always executed *) +END; diff --git a/Task/Executable-library/Factor/executable-library-1.factor b/Task/Executable-library/Factor/executable-library-1.factor new file mode 100644 index 0000000000..94ac4bbf28 --- /dev/null +++ b/Task/Executable-library/Factor/executable-library-1.factor @@ -0,0 +1,31 @@ +! rosetta/hailstone/hailstone.factor +USING: arrays io kernel math math.ranges prettyprint sequences vectors ; +IN: rosetta.hailstone + +: hailstone ( n -- seq ) + [ 1vector ] keep + [ dup 1 number= ] + [ + dup even? [ 2 / ] [ 3 * 1 + ] if + 2dup swap push + ] until + drop ; + + { length n }, and reduces to longest Hailstone sequence. + 1 100000 [a,b) + [ [ hailstone length ] keep 2array ] + [ [ [ first ] bi@ > ] most ] map-reduce + first2 + "The hailstone sequence from " write pprint + " has length " write pprint "." print ; +PRIVATE> + +MAIN: main diff --git a/Task/Executable-library/Factor/executable-library-2.factor b/Task/Executable-library/Factor/executable-library-2.factor new file mode 100644 index 0000000000..403d56b387 --- /dev/null +++ b/Task/Executable-library/Factor/executable-library-2.factor @@ -0,0 +1,27 @@ +! rosetta/hailstone/length/length.factor +USING: assocs kernel io math math.ranges prettyprint + rosetta.hailstone sequences ; +IN: rosetta.hailstone.length + +0 ( object/f -- object/0 ) + dup [ drop 0 ] unless ; + +: max-value ( pair1 pair2 -- pair ) + [ [ second ] bi@ > ] most ; + +: main ( -- ) + H{ } clone ! Maps sequence length => count. + 1 100000 [a,b) [ + hailstone length ! Find sequence length. + over [ f>0 1 + ] change-at ! Add 1 to count. + ] each + ! Find the length-count pair with the highest count. + >alist unclip-slice [ max-value ] reduce + first2 swap + "Among Hailstone sequences from 1 <= n < 100000," print + "there are " write pprint + " sequences of length " write pprint "." print ; +PRIVATE> + +MAIN: main diff --git a/Task/Executable-library/J/executable-library-1.j b/Task/Executable-library/J/executable-library-1.j new file mode 100644 index 0000000000..14ec7a2e37 --- /dev/null +++ b/Task/Executable-library/J/executable-library-1.j @@ -0,0 +1,11 @@ +hailseq=: -:`(1 3&p.)@.(2&|) ^:(1 ~: ]) ^:a:"0 +9!:29]1 +9!:27'main 0' +main=:3 :0 + smoutput 'Hailstone sequence for the number 27' + smoutput hailseq 27 + smoutput '' + smoutput 'Finding number with longest hailstone sequence which is' + smoutput 'less than 100000 (and finding that sequence length):' + smoutput (I.@(= >./),>./) #@hailseq i.1e5 +) diff --git a/Task/Executable-library/J/executable-library-2.j b/Task/Executable-library/J/executable-library-2.j new file mode 100644 index 0000000000..d53b254c6e --- /dev/null +++ b/Task/Executable-library/J/executable-library-2.j @@ -0,0 +1,6 @@ + load jpath '~temp/hailseq.ijs' +Hailstone sequence for the number 27 +27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 ... +Finding number with longest hailstone sequence which is +less than 100000 (and finding that sequence length): +77031 351 diff --git a/Task/Executable-library/J/executable-library-3.j b/Task/Executable-library/J/executable-library-3.j new file mode 100644 index 0000000000..2bb186622c --- /dev/null +++ b/Task/Executable-library/J/executable-library-3.j @@ -0,0 +1,8 @@ +require '~temp/hailseq.ijs' +9!:29]1 +9!:27'main 0' +main=:3 :0 + smoutput 'Finding most frequent hailstone sequence length for' + smoutput 'Hailstone sequences for whole numbers less than 100000:' + smoutput {:{.\:~ (#/.~,.~.) #@hailseq }.i.1e5 +) diff --git a/Task/Executable-library/J/executable-library-4.j b/Task/Executable-library/J/executable-library-4.j new file mode 100644 index 0000000000..660d95e774 --- /dev/null +++ b/Task/Executable-library/J/executable-library-4.j @@ -0,0 +1,4 @@ + load jpath '~temp/66.ijs' +Finding most frequent hailstone sequence length for +Hailstone sequences for whole numbers less than 100000 +72 diff --git a/Task/Execute-HQ9+/Icon/execute-hq9+.icon b/Task/Execute-HQ9+/Icon/execute-hq9+.icon new file mode 100644 index 0000000000..16f788ff19 --- /dev/null +++ b/Task/Execute-HQ9+/Icon/execute-hq9+.icon @@ -0,0 +1,27 @@ +procedure main(A) +repeat writes("Enter HQ9+ code: ") & HQ9(get(A)|read()|break) +end + +procedure HQ9(code) +static bnw,bcr +initial { # number matching words and line feeds for the b-th bottle + bnw := table(" bottles"); bnw[1] := " bottle"; bnw[0] := "No more bottles" + bcr := table("\n"); bcr[0]:="" + } +every c := map(!code) do # ignore case + case c of { # interpret + "h" : write("Hello, World!") # . hello + "q" : write(code) # . quine + "9" : { # . 99 bottles + every b := 99 to 1 by -1 do writes( + bcr[b],b,bnw[b]," of beer on the wall\n", + b,bnw[b]," of beer\nTake one down, pass it around\n", + 1~=b|"",bnw[b-1]," of beer on the wall",bcr[b-1]) + write(", ",map(bnw[b-1])," of beer.\nGo to the store ", + "and buy some more, 99 bottles of beer on the wall.") + } + "+" : { /acc := 0 ; acc +:=1 } # . yes it is weird + default: stop("Syntax error in ",code) # . error/exit + } +return +end diff --git a/Task/Execute-HQ9+/Inform-7/execute-hq9+.inf b/Task/Execute-HQ9+/Inform-7/execute-hq9+.inf new file mode 100644 index 0000000000..2ccf888765 --- /dev/null +++ b/Task/Execute-HQ9+/Inform-7/execute-hq9+.inf @@ -0,0 +1,23 @@ +HQ9+ is a room. + +After reading a command: + interpret the player's command; + reject the player's command. + +To interpret (code - indexed text): + let accumulator be 0; + repeat with N running from 1 to the number of characters in code: + let C be character number N in code in upper case; + if C is "H": + say "Hello, world!"; + otherwise if C is "Q": + say "[code][line break]"; + otherwise if C is "9": + repeat with iteration running from 1 to 99: + let N be 100 - iteration; + say "[N] bottle[s] of beer on the wall[line break]"; + say "[N] bottle[s] of beer[line break]"; + say "Take one down, pass it around[line break]"; + say "[N - 1] bottle[s] of beer on the wall[paragraph break]"; + otherwise if C is "+": + increase accumulator by 1. diff --git a/Task/Execute-HQ9+/J/execute-hq9+-1.j b/Task/Execute-HQ9+/J/execute-hq9+-1.j new file mode 100644 index 0000000000..11181783ce --- /dev/null +++ b/Task/Execute-HQ9+/J/execute-hq9+-1.j @@ -0,0 +1,3 @@ +bob =: ": , ' bottle' , (1 = ]) }. 's of beer'"_ +bobw=: bob , ' on the wall'"_ +beer=: bobw , ', ' , bob , '; take one down and pass it around, ' , bobw@<: diff --git a/Task/Execute-HQ9+/J/execute-hq9+-2.j b/Task/Execute-HQ9+/J/execute-hq9+-2.j new file mode 100644 index 0000000000..633a9df02e --- /dev/null +++ b/Task/Execute-HQ9+/J/execute-hq9+-2.j @@ -0,0 +1,6 @@ +H=: smoutput bind 'Hello, world!' +Q=: smoutput @ [ +hq9=: smoutput @: (beer"0) bind (1+i.-99) +hqp=: (A=:1)1 :'0 0$A=:A+m[y'@] + +hq9p=: H`H`Q`Q`hq9`hqp@.('HhQq9+' i. ])"_ 0~ diff --git a/Task/Execute-HQ9+/J/execute-hq9+-3.j b/Task/Execute-HQ9+/J/execute-hq9+-3.j new file mode 100644 index 0000000000..d99cef88b1 --- /dev/null +++ b/Task/Execute-HQ9+/J/execute-hq9+-3.j @@ -0,0 +1,6 @@ + hq9p 'hqQQq' +Hello, world! +hqQQq +hqQQq +hqQQq +hqQQq diff --git a/Task/Execute-HQ9+/Liberty-BASIC/execute-hq9+.liberty b/Task/Execute-HQ9+/Liberty-BASIC/execute-hq9+.liberty new file mode 100644 index 0000000000..186b486319 --- /dev/null +++ b/Task/Execute-HQ9+/Liberty-BASIC/execute-hq9+.liberty @@ -0,0 +1,33 @@ +'Try this hq9+ program - "hq9+HqQ+Qq" +Prompt "Please input your hq9+ program."; code$ +Print hq9plus$(code$) +End + +Function hq9plus$(code$) + For i = 1 to Len(code$) + Select Case + Case Upper$(Mid$(code$, i, 1)) = "H" + hq9plus$ = hq9plus$ + "Hello, world!" + Case Upper$(Mid$(code$, i, 1)) = "Q" + hq9plus$ = hq9plus$ + code$ + Case Mid$(code$, i, 1) = "9" + For bottles = 99 To 1 Step -1 + hq9plus$ = hq9plus$ + str$(bottles) + " bottle" + If (bottles > 1) Then hq9plus$ = hq9plus$ + "s" + hq9plus$ = hq9plus$ + " of beer on the wall, " + str$(bottles) + " bottle" + If (bottles > 1) Then hq9plus$ = hq9plus$ + "s" + hq9plus$ = hq9plus$ + " of beer," + chr$(13) + chr$(10) + "Take one down, pass it around, " + str$(bottles - 1) + " bottle" + If (bottles > 2) Or (bottles = 1) Then hq9plus$ = hq9plus$ + "s" + hq9plus$ = hq9plus$ + " of beer on the wall." + chr$(13) + chr$(10) + Next bottles + hq9plus$ = hq9plus$ + "No more bottles of beer on the wall, no more bottles of beer." _ + + chr$(13) + chr$(10) + "Go to the store and buy some more, 99 bottles of beer on the wall." + Case Mid$(code$, i, 1) = "+" + accumulator = (accumulator + 1) + End Select + If Mid$(code$, i, 1) <> "+" Then + hq9plus$ = hq9plus$ + chr$(13) + chr$(10) + End If + Next i + hq9plus$ = Left$(hq9plus$, (Len(hq9plus$) - 2)) +End Function diff --git a/Task/Execute-HQ9+/Mathematica/execute-hq9+.mathematica b/Task/Execute-HQ9+/Mathematica/execute-hq9+.mathematica new file mode 100644 index 0000000000..759ffa887c --- /dev/null +++ b/Task/Execute-HQ9+/Mathematica/execute-hq9+.mathematica @@ -0,0 +1,10 @@ +hq9plus[program_] := + Module[{accumulator = 0, bottle}, + bottle[n_] := + ToString[n] <> If[n == 1, " bottle", " bottles"] <> " of beer"; + Do[Switch[chr, "H", Print@"hello, world", "Q", Print@program, "9", + Print@StringJoin[ + Table[bottle[n] <> " on the wall\n" <> bottle[n] <> + "\ntake one down, pass it around\n" <> bottle[n - 1] <> + " on the wall" <> If[n == 1, "", "\n\n"], {n, 99, 1, -1}]], + "+", accumulator++], {chr, Characters@program}]; accumulator] diff --git a/Task/Execute-a-system-command/Factor/execute-a-system-command.factor b/Task/Execute-a-system-command/Factor/execute-a-system-command.factor new file mode 100644 index 0000000000..97c1f4b62d --- /dev/null +++ b/Task/Execute-a-system-command/Factor/execute-a-system-command.factor @@ -0,0 +1 @@ +"ls" run-process wait-for-process diff --git a/Task/Execute-a-system-command/Fantom/execute-a-system-command.fantom b/Task/Execute-a-system-command/Fantom/execute-a-system-command.fantom new file mode 100644 index 0000000000..b22380dace --- /dev/null +++ b/Task/Execute-a-system-command/Fantom/execute-a-system-command.fantom @@ -0,0 +1,8 @@ +class Main +{ + public static Void main () + { + p := Process (["ls"]) + p.run + } +} diff --git a/Task/Execute-a-system-command/GUISS/execute-a-system-command.guiss b/Task/Execute-a-system-command/GUISS/execute-a-system-command.guiss new file mode 100644 index 0000000000..5a0a781fcd --- /dev/null +++ b/Task/Execute-a-system-command/GUISS/execute-a-system-command.guiss @@ -0,0 +1 @@ +Start,Programs,Accessories,MSDOS Prompt,Type:dir[enter] diff --git a/Task/Execute-a-system-command/HicEst/execute-a-system-command.hicest b/Task/Execute-a-system-command/HicEst/execute-a-system-command.hicest new file mode 100644 index 0000000000..ea83e7ccdd --- /dev/null +++ b/Task/Execute-a-system-command/HicEst/execute-a-system-command.hicest @@ -0,0 +1,2 @@ +SYSTEM(CoMmand='pause') +SYSTEM(CoMmand='dir & pause') diff --git a/Task/Execute-a-system-command/IDL/execute-a-system-command-1.idl b/Task/Execute-a-system-command/IDL/execute-a-system-command-1.idl new file mode 100644 index 0000000000..1f6b6742e3 --- /dev/null +++ b/Task/Execute-a-system-command/IDL/execute-a-system-command-1.idl @@ -0,0 +1 @@ +$ls diff --git a/Task/Execute-a-system-command/IDL/execute-a-system-command-2.idl b/Task/Execute-a-system-command/IDL/execute-a-system-command-2.idl new file mode 100644 index 0000000000..cb273fd30e --- /dev/null +++ b/Task/Execute-a-system-command/IDL/execute-a-system-command-2.idl @@ -0,0 +1 @@ +spawn,"ls",result diff --git a/Task/Execute-a-system-command/IDL/execute-a-system-command-3.idl b/Task/Execute-a-system-command/IDL/execute-a-system-command-3.idl new file mode 100644 index 0000000000..326b68127e --- /dev/null +++ b/Task/Execute-a-system-command/IDL/execute-a-system-command-3.idl @@ -0,0 +1 @@ +spawn,"ls",unit=unit diff --git a/Task/Execute-a-system-command/Icon/execute-a-system-command-1.icon b/Task/Execute-a-system-command/Icon/execute-a-system-command-1.icon new file mode 100644 index 0000000000..5a7e381f15 --- /dev/null +++ b/Task/Execute-a-system-command/Icon/execute-a-system-command-1.icon @@ -0,0 +1,6 @@ +procedure main() + +write("Trying command ",cmd := if &features == "UNIX" then "ls" else "dir") +system(cmd) + +end diff --git a/Task/Execute-a-system-command/Icon/execute-a-system-command-2.icon b/Task/Execute-a-system-command/Icon/execute-a-system-command-2.icon new file mode 100644 index 0000000000..d74a9aa96e --- /dev/null +++ b/Task/Execute-a-system-command/Icon/execute-a-system-command-2.icon @@ -0,0 +1,2 @@ + pid := system(command_string,&input,&output,&errout,"wait") + pid := system(command_string,&input,&output,&errout,"nowait") diff --git a/Task/Execute-a-system-command/Io/execute-a-system-command.io b/Task/Execute-a-system-command/Io/execute-a-system-command.io new file mode 100644 index 0000000000..c43a579c2c --- /dev/null +++ b/Task/Execute-a-system-command/Io/execute-a-system-command.io @@ -0,0 +1 @@ +System runCommand("ls") stdout println diff --git a/Task/Execute-a-system-command/J/execute-a-system-command.j b/Task/Execute-a-system-command/J/execute-a-system-command.j new file mode 100644 index 0000000000..91bade7b4a --- /dev/null +++ b/Task/Execute-a-system-command/J/execute-a-system-command.j @@ -0,0 +1,15 @@ +load'task' + +NB. Execute a command and wait for it to complete +shell 'dir' + +NB. Execute a command but don't wait for it to complete +fork 'notepad' + +NB. Execute a command and capture its stdout +stdout =: shell 'dir' + +NB. Execute a command, provide it with stdin, +NB. and capture its stdout +stdin =: 'blahblahblah' +stdout =: stdin spawn 'grep blah' diff --git a/Task/Execute-a-system-command/Joy/execute-a-system-command.joy b/Task/Execute-a-system-command/Joy/execute-a-system-command.joy new file mode 100644 index 0000000000..ffb4823f14 --- /dev/null +++ b/Task/Execute-a-system-command/Joy/execute-a-system-command.joy @@ -0,0 +1 @@ +"ls" system. diff --git a/Task/Execute-a-system-command/K/execute-a-system-command-1.k b/Task/Execute-a-system-command/K/execute-a-system-command-1.k new file mode 100644 index 0000000000..4f32642f3c --- /dev/null +++ b/Task/Execute-a-system-command/K/execute-a-system-command-1.k @@ -0,0 +1 @@ + \ls diff --git a/Task/Execute-a-system-command/K/execute-a-system-command-2.k b/Task/Execute-a-system-command/K/execute-a-system-command-2.k new file mode 100644 index 0000000000..8c24bf81fd --- /dev/null +++ b/Task/Execute-a-system-command/K/execute-a-system-command-2.k @@ -0,0 +1 @@ + r: 4:"ls" diff --git a/Task/Execute-a-system-command/Lang5/execute-a-system-command.lang5 b/Task/Execute-a-system-command/Lang5/execute-a-system-command.lang5 new file mode 100644 index 0000000000..3130995d90 --- /dev/null +++ b/Task/Execute-a-system-command/Lang5/execute-a-system-command.lang5 @@ -0,0 +1 @@ +'ls system diff --git a/Task/Execute-a-system-command/Liberty-BASIC/execute-a-system-command.liberty b/Task/Execute-a-system-command/Liberty-BASIC/execute-a-system-command.liberty new file mode 100644 index 0000000000..ee0e3ecea1 --- /dev/null +++ b/Task/Execute-a-system-command/Liberty-BASIC/execute-a-system-command.liberty @@ -0,0 +1,2 @@ + drive1$ = left$(Drives$,1) +run "cmd.exe /";drive1$;" dir & pause" diff --git a/Task/Execute-a-system-command/Locomotive-Basic/execute-a-system-command.bas b/Task/Execute-a-system-command/Locomotive-Basic/execute-a-system-command.bas new file mode 100644 index 0000000000..450cdfbda0 --- /dev/null +++ b/Task/Execute-a-system-command/Locomotive-Basic/execute-a-system-command.bas @@ -0,0 +1 @@ +LIST diff --git a/Task/Execute-a-system-command/Logo/execute-a-system-command.logo b/Task/Execute-a-system-command/Logo/execute-a-system-command.logo new file mode 100644 index 0000000000..288d19c74a --- /dev/null +++ b/Task/Execute-a-system-command/Logo/execute-a-system-command.logo @@ -0,0 +1 @@ +print first butfirst shell [ls -a] ; .. diff --git a/Task/Execute-a-system-command/M4/execute-a-system-command.m4 b/Task/Execute-a-system-command/M4/execute-a-system-command.m4 new file mode 100644 index 0000000000..ada3794e16 --- /dev/null +++ b/Task/Execute-a-system-command/M4/execute-a-system-command.m4 @@ -0,0 +1 @@ +syscmd(ifdef(`__windows__',`dir',`ls')) diff --git a/Task/Execute-a-system-command/MAXScript/execute-a-system-command.max b/Task/Execute-a-system-command/MAXScript/execute-a-system-command.max new file mode 100644 index 0000000000..8904fff74c --- /dev/null +++ b/Task/Execute-a-system-command/MAXScript/execute-a-system-command.max @@ -0,0 +1 @@ +dosCommand "pause" diff --git a/Task/Execute-a-system-command/MUMPS/execute-a-system-command-1.mumps b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-1.mumps new file mode 100644 index 0000000000..a804722df8 --- /dev/null +++ b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-1.mumps @@ -0,0 +1 @@ +Set X=$ZF(-1,"DIR") diff --git a/Task/Execute-a-system-command/MUMPS/execute-a-system-command-2.mumps b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-2.mumps new file mode 100644 index 0000000000..6059c25210 --- /dev/null +++ b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-2.mumps @@ -0,0 +1 @@ +ZSY "DIR" diff --git a/Task/Execute-a-system-command/MUMPS/execute-a-system-command-3.mumps b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-3.mumps new file mode 100644 index 0000000000..7816a7e686 --- /dev/null +++ b/Task/Execute-a-system-command/MUMPS/execute-a-system-command-3.mumps @@ -0,0 +1 @@ +ZSY "ls" diff --git a/Task/Execute-a-system-command/Make/execute-a-system-command-1.make b/Task/Execute-a-system-command/Make/execute-a-system-command-1.make new file mode 100644 index 0000000000..2839af56f0 --- /dev/null +++ b/Task/Execute-a-system-command/Make/execute-a-system-command-1.make @@ -0,0 +1,2 @@ +contents=$(shell cat foo) +curdir=`pwd` diff --git a/Task/Execute-a-system-command/Make/execute-a-system-command-2.make b/Task/Execute-a-system-command/Make/execute-a-system-command-2.make new file mode 100644 index 0000000000..83a5b38bb1 --- /dev/null +++ b/Task/Execute-a-system-command/Make/execute-a-system-command-2.make @@ -0,0 +1,2 @@ +mytarget: + cat foo | grep mytext diff --git a/Task/Execute-a-system-command/Mathematica/execute-a-system-command.mathematica b/Task/Execute-a-system-command/Mathematica/execute-a-system-command.mathematica new file mode 100644 index 0000000000..489958b641 --- /dev/null +++ b/Task/Execute-a-system-command/Mathematica/execute-a-system-command.mathematica @@ -0,0 +1 @@ +Run["ls"] diff --git a/Task/Execute-a-system-command/Maxima/execute-a-system-command.maxima b/Task/Execute-a-system-command/Maxima/execute-a-system-command.maxima new file mode 100644 index 0000000000..a2a19f8c0e --- /dev/null +++ b/Task/Execute-a-system-command/Maxima/execute-a-system-command.maxima @@ -0,0 +1 @@ +system("dir > list.txt")$ diff --git a/Task/Execute-a-system-command/Mercury/execute-a-system-command.mercury b/Task/Execute-a-system-command/Mercury/execute-a-system-command.mercury new file mode 100644 index 0000000000..2dd2c0f58f --- /dev/null +++ b/Task/Execute-a-system-command/Mercury/execute-a-system-command.mercury @@ -0,0 +1,10 @@ +:- module execute_sys_cmd. +:- interface. +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. + +main(!IO) :- + io.call_system("ls", _Result, !IO). diff --git a/Task/Execute-a-system-command/Modula-2/execute-a-system-command.mod2 b/Task/Execute-a-system-command/Modula-2/execute-a-system-command.mod2 new file mode 100644 index 0000000000..121f4b4af2 --- /dev/null +++ b/Task/Execute-a-system-command/Modula-2/execute-a-system-command.mod2 @@ -0,0 +1,34 @@ +MODULE tri; + +FROM SYSTEM IMPORT ADR; +FROM SysLib IMPORT system; + +IMPORT TextIO, InOut, ASCII; + +VAR fd : TextIO.File; + ch : CHAR; + +PROCEDURE SystemCommand (VAR command : ARRAY OF CHAR) : BOOLEAN; + +BEGIN + IF system (ADR (command) ) = 0 THEN + RETURN TRUE + ELSE + RETURN FALSE + END +END SystemCommand; + +BEGIN + IF SystemCommand ("ls -1 tri.mod | ") = TRUE THEN + InOut.WriteString ("No error reported.") + ELSE + InOut.WriteString ("Error reported!") + END; + LOOP + InOut.Read (ch); + InOut.Write (ch); + IF ch < ' ' THEN EXIT END + END; + InOut.WriteLn; + InOut.WriteBf +END tri. diff --git a/Task/Execute-a-system-command/Modula-3/execute-a-system-command.mod3 b/Task/Execute-a-system-command/Modula-3/execute-a-system-command.mod3 new file mode 100644 index 0000000000..c3e4069224 --- /dev/null +++ b/Task/Execute-a-system-command/Modula-3/execute-a-system-command.mod3 @@ -0,0 +1,10 @@ +UNSAFE MODULE Exec EXPORTS Main; + +IMPORT Unix, M3toC; + +VAR command := M3toC.CopyTtoS("ls"); + +BEGIN + EVAL Unix.system(command); + M3toC.FreeCopiedS(command); +END Exec. diff --git a/Task/Exponentiation-operator/Factor/exponentiation-operator-1.factor b/Task/Exponentiation-operator/Factor/exponentiation-operator-1.factor new file mode 100644 index 0000000000..9f981d7388 --- /dev/null +++ b/Task/Exponentiation-operator/Factor/exponentiation-operator-1.factor @@ -0,0 +1,3 @@ +: pow ( f n -- f' ) + dup 0 < [ abs pow recip ] + [ [ 1 ] 2dip swap [ * ] curry times ] if ; diff --git a/Task/Exponentiation-operator/Factor/exponentiation-operator-2.factor b/Task/Exponentiation-operator/Factor/exponentiation-operator-2.factor new file mode 100644 index 0000000000..1b15d68b66 --- /dev/null +++ b/Task/Exponentiation-operator/Factor/exponentiation-operator-2.factor @@ -0,0 +1,6 @@ +: pow ( f n -- f' ) + { + { [ dup 0 < ] [ abs pow recip ] } + { [ dup 0 = ] [ 2drop 1 ] } + [ [ 2 mod 1 = swap 1 ? ] [ [ sq ] [ 2 /i ] bi* pow ] 2bi * ] + } cond ; diff --git a/Task/Exponentiation-operator/Factor/exponentiation-operator-3.factor b/Task/Exponentiation-operator/Factor/exponentiation-operator-3.factor new file mode 100644 index 0000000000..493835e558 --- /dev/null +++ b/Task/Exponentiation-operator/Factor/exponentiation-operator-3.factor @@ -0,0 +1,13 @@ +USING: combinators kernel math ; +IN: test + +: (pow) ( f n -- f' ) + [ dup even? ] [ [ sq ] [ 2 /i ] bi* ] while + dup 1 = [ drop ] [ dupd 1 - (pow) * ] if ; + +: pow ( f n -- f' ) + { + { [ dup 0 < ] [ abs (pow) recip ] } + { [ dup 0 = ] [ 2drop 1 ] } + [ (pow) ] + } cond ; diff --git a/Task/Exponentiation-operator/Factor/exponentiation-operator-4.factor b/Task/Exponentiation-operator/Factor/exponentiation-operator-4.factor new file mode 100644 index 0000000000..0ffec3c5f7 --- /dev/null +++ b/Task/Exponentiation-operator/Factor/exponentiation-operator-4.factor @@ -0,0 +1,6 @@ +: (pow) ( f n -- f' ) + [ 1 ] 2dip + [ dup 1 = ] [ + dup even? [ [ sq ] [ 2 /i ] bi* ] [ [ [ * ] keep ] dip 1 - ] if + ] until + drop * ; diff --git a/Task/Exponentiation-operator/GAP/exponentiation-operator.gap b/Task/Exponentiation-operator/GAP/exponentiation-operator.gap new file mode 100644 index 0000000000..65a17aa725 --- /dev/null +++ b/Task/Exponentiation-operator/GAP/exponentiation-operator.gap @@ -0,0 +1,20 @@ +expon := function(a, n, one, mul) + local p; + p := one; + while n > 0 do + if IsOddInt(n) then + p := mul(a, p); + fi; + a := mul(a, a); + n := QuoInt(n, 2); + od; + return p; +end; + +expon(2, 10, 1, \*); +# 1024 + +# a more creative use of exponentiation +List([0 .. 31], n -> (1 - expon(0, n, 1, \-))/2); +# [ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, +# 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 ] diff --git a/Task/Exponentiation-operator/HicEst/exponentiation-operator.hicest b/Task/Exponentiation-operator/HicEst/exponentiation-operator.hicest new file mode 100644 index 0000000000..5b88f17b32 --- /dev/null +++ b/Task/Exponentiation-operator/HicEst/exponentiation-operator.hicest @@ -0,0 +1,9 @@ +WRITE(Clipboard) pow(5, 3) ! 125 +WRITE(ClipBoard) pow(5.5, 7) ! 152243.5234 + +FUNCTION pow(x, n) + pow = 1 + DO i = 1, n + pow = pow * x + ENDDO +END diff --git a/Task/Exponentiation-operator/Icon/exponentiation-operator.icon b/Task/Exponentiation-operator/Icon/exponentiation-operator.icon new file mode 100644 index 0000000000..cad1978c7d --- /dev/null +++ b/Task/Exponentiation-operator/Icon/exponentiation-operator.icon @@ -0,0 +1,22 @@ +procedure main() +bases := [5,5.] +numbers := [0,2,2.,-1,3] +every write("expon(",b := !bases,", ",x := !numbers,")=",(expon(b,x) | "failed") \ 1) +end + +procedure expon(base,power) +local op,res + +base := numeric(base) | runerror(102,base) +power := power = integer(power) | runerr(101,power) + +if power = 0 then return 1 +else op := if power < 1 then + (base := real(base)) & "/" # force real base + else "*" + +res := 1 +every 1 to abs(power) do + res := op(res,base) +return res +end diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-1.j b/Task/Exponentiation-operator/J/exponentiation-operator-1.j new file mode 100644 index 0000000000..8ad58e6641 --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-1.j @@ -0,0 +1,7 @@ + exp =: */@:#~ + + 10 exp 3 +1000 + + 10 exp 0 +1 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-2.j b/Task/Exponentiation-operator/J/exponentiation-operator-2.j new file mode 100644 index 0000000000..dcdbdb948d --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-2.j @@ -0,0 +1,4 @@ + exp =: *@:] %: */@:(#~|) + + 10 exp _3 +0.001 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-3.j b/Task/Exponentiation-operator/J/exponentiation-operator-3.j new file mode 100644 index 0000000000..0a8313694a --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-3.j @@ -0,0 +1,6 @@ + exp =: dyad def 'x *^:y 1' + + 10 exp 3 +1000 + 10 exp _3 +0.001 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-4.j b/Task/Exponentiation-operator/J/exponentiation-operator-4.j new file mode 100644 index 0000000000..096afd7ae3 --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-4.j @@ -0,0 +1,4 @@ + exp =: ^.^:_1 + + 81 exp 0.5 +9 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-5.j b/Task/Exponentiation-operator/J/exponentiation-operator-5.j new file mode 100644 index 0000000000..c6eb4365a1 --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-5.j @@ -0,0 +1,4 @@ + exp =: %:^:_1~ + + 81 exp 0.5 +9 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-6.j b/Task/Exponentiation-operator/J/exponentiation-operator-6.j new file mode 100644 index 0000000000..3b5eee41c3 --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-6.j @@ -0,0 +1,6 @@ + pi =: 3.14159265358979323846 + e =: 2.71828182845904523536 + i =: 2 %: _1 NB. Square root of -1 + + e^(pi*i) +_1 diff --git a/Task/Exponentiation-operator/J/exponentiation-operator-7.j b/Task/Exponentiation-operator/J/exponentiation-operator-7.j new file mode 100644 index 0000000000..64ddf68722 --- /dev/null +++ b/Task/Exponentiation-operator/J/exponentiation-operator-7.j @@ -0,0 +1,4 @@ + exp =: %:^:_1~ + + e exp (pi*i) +_1 diff --git a/Task/Exponentiation-operator/Liberty-BASIC/exponentiation-operator.liberty b/Task/Exponentiation-operator/Liberty-BASIC/exponentiation-operator.liberty new file mode 100644 index 0000000000..d2bf5f244d --- /dev/null +++ b/Task/Exponentiation-operator/Liberty-BASIC/exponentiation-operator.liberty @@ -0,0 +1,25 @@ + print " 11^5 = ", floatPow( 11, 5 ) + print " (-11)^5 = ", floatPow( -11, 5 ) + print " 11^( -5) = ", floatPow( 11, -5 ) + print " 3.1416^3 = ", floatPow( 3.1416, 3 ) + print " 0^2 = ", floatPow( 0, 2 ) + print " 2^0 = ", floatPow( 2, 0 ) + print " -2^0 = ", floatPow( -2, 0 ) + + end + + function floatPow( a, b) + if a <>0 then + m =1 + if b =abs( b) then + for n =1 to b + m =m *a + next n + else + m =1 /floatPow( a, 0 - b) ' LB has no unitary minus operator. + end if + else + m =0 + end if + floatPow =m + end function diff --git a/Task/Exponentiation-operator/Logo/exponentiation-operator.logo b/Task/Exponentiation-operator/Logo/exponentiation-operator.logo new file mode 100644 index 0000000000..71bdc0c425 --- /dev/null +++ b/Task/Exponentiation-operator/Logo/exponentiation-operator.logo @@ -0,0 +1,5 @@ +to int_power :n :m + if equal? 0 :m [output 1] + if equal? 0 modulo :m 2 [output int_power :n*:n :m/2] + output :n * int_power :n :m-1 +end diff --git a/Task/Exponentiation-operator/Lucid/exponentiation-operator.lucid b/Task/Exponentiation-operator/Lucid/exponentiation-operator.lucid new file mode 100644 index 0000000000..eea04aaa8c --- /dev/null +++ b/Task/Exponentiation-operator/Lucid/exponentiation-operator.lucid @@ -0,0 +1,6 @@ +pow(n,x) + k = n fby k div 2; + p = x fby p*p; + y =1 fby if even(k) then y else y*p; + result y asa k eq 0; +end diff --git a/Task/Exponentiation-operator/M4/exponentiation-operator.m4 b/Task/Exponentiation-operator/M4/exponentiation-operator.m4 new file mode 100644 index 0000000000..e25b337724 --- /dev/null +++ b/Task/Exponentiation-operator/M4/exponentiation-operator.m4 @@ -0,0 +1,2 @@ +define(`power',`ifelse($2,0,1,`eval($1*$0($1,decr($2)))')') +power(2,10) diff --git a/Task/Exponentiation-operator/Mathematica/exponentiation-operator-1.mathematica b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-1.mathematica new file mode 100644 index 0000000000..abd4588bf1 --- /dev/null +++ b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-1.mathematica @@ -0,0 +1,2 @@ +exponentiation[x_,y_Integer]:=Which[y>0,Times@@ConstantArray[x,y],y==0,1,y<0,1/exponentiation[x,-y]] +CirclePlus[x_,y_Integer]:=exponentiation[x,y] diff --git a/Task/Exponentiation-operator/Mathematica/exponentiation-operator-2.mathematica b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-2.mathematica new file mode 100644 index 0000000000..d6ef4d82d9 --- /dev/null +++ b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-2.mathematica @@ -0,0 +1,6 @@ +exponentiation[1.23,3] +exponentiation[4,0] +exponentiation[2.5,-2] +1.23\[CirclePlus]3 +4\[CirclePlus]0 +2.5\[CirclePlus]-2 diff --git a/Task/Exponentiation-operator/Mathematica/exponentiation-operator-3.mathematica b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-3.mathematica new file mode 100644 index 0000000000..51997df377 --- /dev/null +++ b/Task/Exponentiation-operator/Mathematica/exponentiation-operator-3.mathematica @@ -0,0 +1,6 @@ +1.86087 +1 +0.16 +1.86087 +1 +0.16 diff --git a/Task/Exponentiation-operator/Maxima/exponentiation-operator.maxima b/Task/Exponentiation-operator/Maxima/exponentiation-operator.maxima new file mode 100644 index 0000000000..7e7769a70b --- /dev/null +++ b/Task/Exponentiation-operator/Maxima/exponentiation-operator.maxima @@ -0,0 +1,17 @@ +"^^^"(a, n) := block( + [p: 1], + while n > 0 do ( + if oddp(n) then p: p * a, + a: a * a, + n: quotient(n, 2) + ), + p +)$ + +infix("^^^")$ + +2 ^^^ 10; +1024 + +2.5 ^^^ 10; +9536.7431640625 diff --git a/Task/Exponentiation-operator/Modula-2/exponentiation-operator.mod2 b/Task/Exponentiation-operator/Modula-2/exponentiation-operator.mod2 new file mode 100644 index 0000000000..fd57825355 --- /dev/null +++ b/Task/Exponentiation-operator/Modula-2/exponentiation-operator.mod2 @@ -0,0 +1,46 @@ +(* Library Interface *) +DEFINITION MODULE Exponentiation; + +PROCEDURE IntExp(base, exp : INTEGER) : INTEGER; + (* Raises base to the power of exp and returns the result + both base and exp must be of type INTEGER *) + +PROCEDURE RealExp(base : REAL; exp : INTEGER) : REAL; + (* Raises base to the power of exp and returns the result + base must be of type REAL, exp of type INTEGER *) + +END Exponentiation. + +(* Library Implementation *) +IMPLEMENTATION MODULE Exponentiation; + +PROCEDURE IntExp(base, exp : INTEGER) : INTEGER; + VAR + i, res : INTEGER; + BEGIN + res := 1; + FOR i := 1 TO exp DO + res := res * base; + END; + RETURN res; + END IntExp; + +PROCEDURE RealExp(base: REAL; exp: INTEGER) : REAL; + VAR + i : INTEGER; + res : REAL; + BEGIN + res := 1.0; + IF exp < 0 THEN + FOR i := exp TO -1 DO + res := res / base; + END; + ELSE (* exp >= 0 *) + FOR i := 1 TO exp DO + res := res * base; + END; + END; + RETURN res; + END RealExp; + +END Exponentiation. diff --git a/Task/Exponentiation-operator/Modula-3/exponentiation-operator.mod3 b/Task/Exponentiation-operator/Modula-3/exponentiation-operator.mod3 new file mode 100644 index 0000000000..00086dd52e --- /dev/null +++ b/Task/Exponentiation-operator/Modula-3/exponentiation-operator.mod3 @@ -0,0 +1,32 @@ +MODULE Expt EXPORTS Main; + +IMPORT IO, Fmt; + +PROCEDURE IntExpt(arg, exp: INTEGER): INTEGER = + VAR result := 1; + BEGIN + FOR i := 1 TO exp DO + result := result * arg; + END; + RETURN result; + END IntExpt; + +PROCEDURE RealExpt(arg: REAL; exp: INTEGER): REAL = + VAR result := 1.0; + BEGIN + IF exp < 0 THEN + FOR i := exp TO -1 DO + result := result / arg; + END; + ELSE + FOR i := 1 TO exp DO + result := result * arg; + END; + END; + RETURN result; + END RealExpt; + +BEGIN + IO.Put("2 ^ 4 = " & Fmt.Int(IntExpt(2, 4)) & "\n"); + IO.Put("2.5 ^ 4 = " & Fmt.Real(RealExpt(2.5, 4)) & "\n"); +END Expt. diff --git a/Task/Extend-your-language/Factor/extend-your-language.factor b/Task/Extend-your-language/Factor/extend-your-language.factor new file mode 100644 index 0000000000..87da9b2683 --- /dev/null +++ b/Task/Extend-your-language/Factor/extend-your-language.factor @@ -0,0 +1,4 @@ +( scratchpad ) : 2ifte ( ..a ?0 ?1 quot0: ( ..a -- ..b ) quot1: ( ..a -- ..b ) quot2: ( ..a -- ..b ) quot3: ( ..a -- ..b ) -- ..b ) +[ [ if ] curry curry ] 2bi@ if ; inline +( scratchpad ) 3 [ 0 > ] [ even? ] bi [ 0 ] [ 1 ] [ 2 ] [ 3 ] 2ifte . +2 diff --git a/Task/Extend-your-language/Icon/extend-your-language.icon b/Task/Extend-your-language/Icon/extend-your-language.icon new file mode 100644 index 0000000000..47e5805dcc --- /dev/null +++ b/Task/Extend-your-language/Icon/extend-your-language.icon @@ -0,0 +1,20 @@ +procedure main(A) + if2 { (A[1] = A[2]), (A[3] = A[4]), # Use PDCO with all three else clauses + write("1: both true"), + write("1: only first true"), + write("1: only second true"), + write("1: neither true") + } + if2 { (A[1] = A[2]), (A[3] = A[4]), # Use same PDCO with only one else clause + write("2: both true"), + write("2: only first true"), + } +end + +procedure if2(A) # The double-conditional PDCO + suspend if @A[1] then + if @A[2] then |@A[3] # Run-err if missing 'then' clause + else @\A[4] # (all else clauses are optional) + else if @A[2] then |@\A[5] + else |@\A[6] +end diff --git a/Task/Extend-your-language/Inform-7/extend-your-language-1.inf b/Task/Extend-your-language/Inform-7/extend-your-language-1.inf new file mode 100644 index 0000000000..b441cce13c --- /dev/null +++ b/Task/Extend-your-language/Inform-7/extend-your-language-1.inf @@ -0,0 +1,4 @@ +To if2 (c1 - condition) and-or (c2 - condition) begin -- end: (- switch (({c1})*2 + ({c2})) { 3: do -). +To else1 -- in if2: (- } until (1); 2: do { -). +To else2 -- in if2: (- } until (1); 1: do { -). +To else0 -- in if2: (- } until (1); 0: -). diff --git a/Task/Extend-your-language/Inform-7/extend-your-language-2.inf b/Task/Extend-your-language/Inform-7/extend-your-language-2.inf new file mode 100644 index 0000000000..35bdd519e4 --- /dev/null +++ b/Task/Extend-your-language/Inform-7/extend-your-language-2.inf @@ -0,0 +1,12 @@ +Home is a room. + +When play begins: + if2 (the player is in Home) and-or (the player is a person) begin; + say "both"; + else1; + say "only 1"; + else2; + say "only 2"; + else0; + say "neither"; + end if2. diff --git a/Task/Extend-your-language/Inform-7/extend-your-language-3.inf b/Task/Extend-your-language/Inform-7/extend-your-language-3.inf new file mode 100644 index 0000000000..92094194cd --- /dev/null +++ b/Task/Extend-your-language/Inform-7/extend-your-language-3.inf @@ -0,0 +1,6 @@ +To say if2 (c1 - condition) and-or (c2 - condition) -- beginning if2: + (- switch (({c1})*2 + ({c2})) { 3: -). +To say else1 -- continuing if2: (- 2: -). +To say else2 -- continuing if2: (- 1: -). +To say else0 -- continuing if2: (- 0: -). +To say end if2 -- ending if2: (- } -). diff --git a/Task/Extend-your-language/Inform-7/extend-your-language-4.inf b/Task/Extend-your-language/Inform-7/extend-your-language-4.inf new file mode 100644 index 0000000000..3223937727 --- /dev/null +++ b/Task/Extend-your-language/Inform-7/extend-your-language-4.inf @@ -0,0 +1,4 @@ +Home is a room. + +When play begins: + say "[if2 the player is not in Home and-or the player is not a person]both[else1]only 1[else2]only 2[else0]neither[end if2]". diff --git a/Task/Extend-your-language/J/extend-your-language-1.j b/Task/Extend-your-language/J/extend-your-language-1.j new file mode 100644 index 0000000000..aec6c53623 --- /dev/null +++ b/Task/Extend-your-language/J/extend-your-language-1.j @@ -0,0 +1,4 @@ +if2=: 2 :0 + '`b1 b2'=. n + m@.(b1 + 2 * b2) f. +) diff --git a/Task/Extend-your-language/J/extend-your-language-2.j b/Task/Extend-your-language/J/extend-your-language-2.j new file mode 100644 index 0000000000..0d02f139d6 --- /dev/null +++ b/Task/Extend-your-language/J/extend-your-language-2.j @@ -0,0 +1,14 @@ +f0=: [: smoutput 'neither option: ' , ": +f1=: [: smoutput 'first option: ' , ": +f2=: [: smoutput 'second option: ' , ": +f3=: [: smoutput 'both options: ' , ": + +isprime=: 1&p: +iseven=: 0 = 2&| + + f0`f1`f2`f3 if2 (isprime`iseven)"0 i.5 +second option: 0 +neither option: 1 +both options: 2 +first option: 3 +second option: 4 diff --git a/Task/Extend-your-language/Mathematica/extend-your-language.mathematica b/Task/Extend-your-language/Mathematica/extend-your-language.mathematica new file mode 100644 index 0000000000..e0bc0bd27c --- /dev/null +++ b/Task/Extend-your-language/Mathematica/extend-your-language.mathematica @@ -0,0 +1,5 @@ +if2[c1_,c2_]:=Which[ + c1&&c2, bothConditionsAreTrue[], + c1, firstConditionIsTrue[], + c2, secondConditionIsTrue[], + True,noConditionIsTrue] diff --git a/Task/Extreme-floating-point-values/Groovy/extreme-floating-point-values.groovy b/Task/Extreme-floating-point-values/Groovy/extreme-floating-point-values.groovy new file mode 100644 index 0000000000..2f9b1d2498 --- /dev/null +++ b/Task/Extreme-floating-point-values/Groovy/extreme-floating-point-values.groovy @@ -0,0 +1,13 @@ +def negInf = -1.0d / 0.0d; //also Double.NEGATIVE_INFINITY +def inf = 1.0d / 0.0d; //also Double.POSITIVE_INFINITY +def nan = 0.0d / 0.0d; //also Double.NaN +def negZero = -2.0d / inf; + +println(" Negative inf: " + negInf); +println(" Positive inf: " + inf); +println(" NaN: " + nan); +println(" Negative 0: " + negZero); +println(" inf + -inf: " + (inf + negInf)); +println(" 0 * NaN: " + (0 * nan)); +println(" NaN == NaN: " + (nan == nan)); +println("NaN equals NaN: " + (nan.equals(nan))); diff --git a/Task/Extreme-floating-point-values/J/extreme-floating-point-values-1.j b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-1.j new file mode 100644 index 0000000000..73147cab41 --- /dev/null +++ b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-1.j @@ -0,0 +1,4 @@ + Inf=: _ + NegInf=: __ + NB. Negative zero cannot be represented in J. + NaN=. _. diff --git a/Task/Extreme-floating-point-values/J/extreme-floating-point-values-2.j b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-2.j new file mode 100644 index 0000000000..59b4129e2d --- /dev/null +++ b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-2.j @@ -0,0 +1,15 @@ + (1 % 0) , (_1 % 0) +_ __ + (1e234 * 1e234) , (_1e234 * 1e234) +_ __ + _ + __ NB. generates NaN error, rather than NaN +|NaN error +| _ +__ + + _ - _ NB. generates NaN error, rather than NaN +|NaN error +| _ -_ + %_ +0 + %__ NB. Under the covers, the reciprocal of NegInf produces NegZero, but this fact isn't exposed to the user, who just sees zero +0 diff --git a/Task/Extreme-floating-point-values/J/extreme-floating-point-values-3.j b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-3.j new file mode 100644 index 0000000000..1b4c451654 --- /dev/null +++ b/Task/Extreme-floating-point-values/J/extreme-floating-point-values-3.j @@ -0,0 +1,8 @@ + _ + _ +_ + __ + __ +__ + Inf + 0 +_ + NegInf * 0 +0 diff --git a/Task/Extreme-floating-point-values/MUMPS/extreme-floating-point-values.mumps b/Task/Extreme-floating-point-values/MUMPS/extreme-floating-point-values.mumps new file mode 100644 index 0000000000..8419457489 --- /dev/null +++ b/Task/Extreme-floating-point-values/MUMPS/extreme-floating-point-values.mumps @@ -0,0 +1,15 @@ +EXTREMES + NEW INF,NINF,ZERO,NOTNUM,NEGZERO + SET INF=$DOUBLE(3.0E310),NINF=$DOUBLE(-3.0E310),ZERO=$DOUBLE(0),NOTNUM=$DOUBLE(INF-INF),NEGZERO=$DOUBLE(ZERO*-1) + WRITE "Infinity: ",INF,! + WRITE "Infinity ",$SELECT($ISVALIDNUM(INF):"is a number",1:"is not a number"),! + WRITE "Negative Infinity: ",NINF,! + WRITE "Negative Infinity ",$SELECT($ISVALIDNUM(NINF):"is a number",1:"is not a number"),! + WRITE "Zero: ",ZERO,! + WRITE "Zero ",$SELECT($ISVALIDNUM(ZERO):"is a number",1:"is not a number"),! + WRITE "Negative Zero: ",NEGZERO,! + WRITE "Negative Zero ",$SELECT($ISVALIDNUM(NEGZERO):"is a number",1:"is not a number"),! + WRITE "Not a Number: ",NOTNUM,! + WRITE "Not a Number ",$SELECT($ISVALIDNUM(NOTNUM):"is a number",1:"is not a number"),! + KILL INF,NINF,ZERO,NONNUM,NEGZERO + QUIT diff --git a/Task/Extreme-floating-point-values/Mathematica/extreme-floating-point-values.mathematica b/Task/Extreme-floating-point-values/Mathematica/extreme-floating-point-values.mathematica new file mode 100644 index 0000000000..f57324bafd --- /dev/null +++ b/Task/Extreme-floating-point-values/Mathematica/extreme-floating-point-values.mathematica @@ -0,0 +1,9 @@ +Column@{ReleaseHold[ + Function[expression, + Row@{HoldForm@InputForm@expression, " = ", Quiet@expression}, + HoldAll] /@ + Hold[1./0., 0./0., Limit[-Log[x], x -> 0], Limit[Log[x], x -> 0], + Infinity + 1, Infinity + Infinity, 2 Infinity, + Infinity - Infinity, 0 Infinity, ComplexInfinity + 1, + ComplexInfinity + ComplexInfinity, 2 ComplexInfinity, + 0 ComplexInfinity, Indeterminate + 1, 0 Indeterminate]]} diff --git a/Task/Factorial/0815/factorial.0815 b/Task/Factorial/0815/factorial.0815 new file mode 100644 index 0000000000..cf7a0bd226 --- /dev/null +++ b/Task/Factorial/0815/factorial.0815 @@ -0,0 +1,11 @@ +}:r: Start reader loop. + |~ Read n, + #:end: if n is 0 terminates + >= enqueue it as the initial product, reposition. + }:f: Start factorial loop. + x<:1:x- Decrement n. + {=*> Dequeue product, position n, multiply, update product. + ^:f: + {+% Dequeue incidental 0, add to get Y into Z, output fac(n). + <:a:~$ Output a newline. +^:r: diff --git a/Task/Factorial/0DESCRIPTION b/Task/Factorial/0DESCRIPTION new file mode 100644 index 0000000000..9b7a896e69 --- /dev/null +++ b/Task/Factorial/0DESCRIPTION @@ -0,0 +1,3 @@ +The '''Factorial Function''' of a positive integer, ''n'', is defined as the product of the sequence ''n'', ''n''-1, ''n''-2, ...1 and the factorial of zero, 0, is [[wp:Factorial#Definition|defined]] as being 1. + +Write a function to return the factorial of a number. Solutions can be iterative or recursive. Support for trapping negative n errors is optional. diff --git a/Task/Factorial/1META.yaml b/Task/Factorial/1META.yaml new file mode 100644 index 0000000000..f759feccfd --- /dev/null +++ b/Task/Factorial/1META.yaml @@ -0,0 +1,7 @@ +--- +category: +- Recursion +- Memoization +- Classic CS problems and programs +- Arithmetic +note: Arithmetic operations diff --git a/Task/Factorial/ABAP/factorial-1.abap b/Task/Factorial/ABAP/factorial-1.abap new file mode 100644 index 0000000000..585da9d32e --- /dev/null +++ b/Task/Factorial/ABAP/factorial-1.abap @@ -0,0 +1,8 @@ +form factorial using iv_val type i. + data: lv_res type i value 1. + do iv_val times. + multiply lv_res by sy-index. + enddo. + + iv_val = lv_res. +endform. diff --git a/Task/Factorial/ABAP/factorial-2.abap b/Task/Factorial/ABAP/factorial-2.abap new file mode 100644 index 0000000000..f26b6b13cc --- /dev/null +++ b/Task/Factorial/ABAP/factorial-2.abap @@ -0,0 +1,11 @@ +form fac_rec using iv_val type i. + data: lv_temp type i. + + if iv_val = 0. + iv_val = 1. + else. + lv_temp = iv_val - 1. + perform fac_rec using lv_temp. + multiply iv_val by lv_temp. + endif. +endform. diff --git a/Task/Factorial/ALGOL-68/factorial-1.alg b/Task/Factorial/ALGOL-68/factorial-1.alg new file mode 100644 index 0000000000..170a8c2633 --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-1.alg @@ -0,0 +1,5 @@ +PROC factorial = (INT upb n)LONG LONG INT:( + LONG LONG INT z := 1; + FOR n TO upb n DO z *:= n OD; + z +); ~ diff --git a/Task/Factorial/ALGOL-68/factorial-2.alg b/Task/Factorial/ALGOL-68/factorial-2.alg new file mode 100644 index 0000000000..191fe07cfb --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-2.alg @@ -0,0 +1,30 @@ +INT g = 7; +[]REAL p = []REAL(0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7)[@0]; + +PROC complex gamma = (COMPL in z)COMPL: ( + # Reflection formula # + COMPL z := in z; + IF re OF z < 0.5 THEN + pi / (complex sin(pi*z)*complex gamma(1-z)) + ELSE + z -:= 1; + COMPL x := p[0]; + FOR i TO g+1 DO x +:= p[i]/(z+i) OD; + COMPL t := z + g + 0.5; + complex sqrt(2*pi) * t**(z+0.5) * complex exp(-t) * x + FI +); + +OP ** = (COMPL z, p)COMPL: ( z=0|0|complex exp(complex ln(z)*p) ); +PROC factorial = (COMPL n)COMPL: complex gamma(n+1); + +FORMAT compl fmt = $g(-16, 8)"⊥"g(-10, 8)$; + +test:( + printf(($q"factorial(-0.5)**2="f(compl fmt)l$, factorial(-0.5)**2)); + FOR i TO 9 DO + printf(($q"factorial("d")="f(compl fmt)l$, i, factorial(i))) + OD +) diff --git a/Task/Factorial/ALGOL-68/factorial-3.alg b/Task/Factorial/ALGOL-68/factorial-3.alg new file mode 100644 index 0000000000..c9c3e54dd2 --- /dev/null +++ b/Task/Factorial/ALGOL-68/factorial-3.alg @@ -0,0 +1,7 @@ +PROC factorial = (INT n)LONG LONG INT: + CASE n+1 IN + 1,1,2,6,24,120,720 # a brief lookup # + OUT + n*factorial(n-1) + ESAC +; ~ diff --git a/Task/Factorial/AWK/factorial-1.awk b/Task/Factorial/AWK/factorial-1.awk new file mode 100644 index 0000000000..e94f90a94c --- /dev/null +++ b/Task/Factorial/AWK/factorial-1.awk @@ -0,0 +1,5 @@ +function fact_r(n) +{ + if ( n <= 1 ) return 1; + return n*fact_r(n-1); +} diff --git a/Task/Factorial/AWK/factorial-2.awk b/Task/Factorial/AWK/factorial-2.awk new file mode 100644 index 0000000000..f09705e617 --- /dev/null +++ b/Task/Factorial/AWK/factorial-2.awk @@ -0,0 +1,9 @@ +function fact(n) +{ + if ( n < 1 ) return 1; + r = 1 + for(m = 2; m <= n; m++) { + r *= m; + } + return r +} diff --git a/Task/Factorial/ActionScript/factorial-1.as b/Task/Factorial/ActionScript/factorial-1.as new file mode 100644 index 0000000000..e20a5a6452 --- /dev/null +++ b/Task/Factorial/ActionScript/factorial-1.as @@ -0,0 +1,11 @@ +public static function factorial(n:int):int +{ + if (n < 0) + return 0; + + var fact:int = 1; + for (var i:int = 1; i <= n; i++) + fact *= i; + + return fact; +} diff --git a/Task/Factorial/ActionScript/factorial-2.as b/Task/Factorial/ActionScript/factorial-2.as new file mode 100644 index 0000000000..d73ac79c27 --- /dev/null +++ b/Task/Factorial/ActionScript/factorial-2.as @@ -0,0 +1,10 @@ +public static function factorial(n:int):int +{ + if (n < 0) + return 0; + + if (n == 0) + return 1; + + return n * factorial(n - 1); +} diff --git a/Task/Factorial/Ada/factorial-1.ada b/Task/Factorial/Ada/factorial-1.ada new file mode 100644 index 0000000000..96e1766756 --- /dev/null +++ b/Task/Factorial/Ada/factorial-1.ada @@ -0,0 +1,9 @@ +function Factorial (N : Positive) return Positive is + Result : Positive := N; + Counter : Natural := N - 1; +begin + for I in reverse 1..Counter loop + Result := Result * I; + end loop; + return Result; +end Factorial; diff --git a/Task/Factorial/Ada/factorial-2.ada b/Task/Factorial/Ada/factorial-2.ada new file mode 100644 index 0000000000..4891867ed4 --- /dev/null +++ b/Task/Factorial/Ada/factorial-2.ada @@ -0,0 +1,8 @@ +function Factorial(N : Positive) return Positive is + Result : Positive := 1; +begin + if N > 1 then + Result := N * Factorial(N - 1); + end if; + return Result; +end Factorial; diff --git a/Task/Factorial/Ada/factorial-3.ada b/Task/Factorial/Ada/factorial-3.ada new file mode 100644 index 0000000000..a0b5d00151 --- /dev/null +++ b/Task/Factorial/Ada/factorial-3.ada @@ -0,0 +1,62 @@ +with Ada.Numerics.Generic_Complex_Types; +with Ada.Numerics.Generic_Complex_Elementary_Functions; +with Ada.Numerics.Generic_Elementary_Functions; +with Ada.Text_IO.Complex_Io; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Factorial_Numeric_Approximation is + type Real is digits 15; + package Complex_Pck is new Ada.Numerics.Generic_Complex_Types(Real); + use Complex_Pck; + package Complex_Io is new Ada.Text_Io.Complex_Io(Complex_Pck); + use Complex_IO; + package Cmplx_Elem_Funcs is new Ada.Numerics.Generic_Complex_Elementary_Functions(Complex_Pck); + use Cmplx_Elem_Funcs; + + function Gamma(X : Complex) return Complex is + package Elem_Funcs is new Ada.Numerics.Generic_Elementary_Functions(Real); + use Elem_Funcs; + use Ada.Numerics; + -- Coefficients used by the GNU Scientific Library + G : Natural := 7; + P : constant array (Natural range 0..G + 1) of Real := ( + 0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7); + Z : Complex := X; + Cx : Complex; + Ct : Complex; + begin + if Re(Z) < 0.5 then + return Pi / (Sin(Pi * Z) * Gamma(1.0 - Z)); + else + Z := Z - 1.0; + Set_Re(Cx, P(0)); + Set_Im(Cx, 0.0); + for I in 1..P'Last loop + Cx := Cx + (P(I) / (Z + Real(I))); + end loop; + Ct := Z + Real(G) + 0.5; + return Sqrt(2.0 * Pi) * Ct**(Z + 0.5) * Exp(-Ct) * Cx; + end if; + end Gamma; + + function Factorial(N : Complex) return Complex is + begin + return Gamma(N + 1.0); + end Factorial; + Arg : Complex; +begin + Put("factorial(-0.5)**2.0 = "); + Set_Re(Arg, -0.5); + Set_Im(Arg, 0.0); + Put(Item => Factorial(Arg) **2.0, Fore => 1, Aft => 8, Exp => 0); + New_Line; + for I in 0..9 loop + Set_Re(Arg, Real(I)); + Set_Im(Arg, 0.0); + Put("factorial(" & Integer'Image(I) & ") = "); + Put(Item => Factorial(Arg), Fore => 6, Aft => 8, Exp => 0); + New_Line; + end loop; +end Factorial_Numeric_Approximation; diff --git a/Task/Factorial/Aime/factorial.aime b/Task/Factorial/Aime/factorial.aime new file mode 100644 index 0000000000..2ac43df77b --- /dev/null +++ b/Task/Factorial/Aime/factorial.aime @@ -0,0 +1,14 @@ +integer +factorial(integer n) +{ + integer i, result; + + result = 1; + i = 1; + while (i < n) { + i += 1; + result *= i; + } + + return result; +} diff --git a/Task/Factorial/AmigaE/factorial-1.amiga b/Task/Factorial/AmigaE/factorial-1.amiga new file mode 100644 index 0000000000..5bba6b4f93 --- /dev/null +++ b/Task/Factorial/AmigaE/factorial-1.amiga @@ -0,0 +1,5 @@ +PROC fact(x) IS IF x>=2 THEN x*fact(x-1) ELSE 1 + +PROC main() + WriteF('5! = \d\n', fact(5)) +ENDPROC diff --git a/Task/Factorial/AmigaE/factorial-2.amiga b/Task/Factorial/AmigaE/factorial-2.amiga new file mode 100644 index 0000000000..b45960843f --- /dev/null +++ b/Task/Factorial/AmigaE/factorial-2.amiga @@ -0,0 +1,6 @@ +PROC fact(x) + DEF r, y + IF x < 2 THEN RETURN 1 + r := 1; y := x; + FOR x := 2 TO y DO r := r * x +ENDPROC r diff --git a/Task/Factorial/AppleScript/factorial-1.applescript b/Task/Factorial/AppleScript/factorial-1.applescript new file mode 100644 index 0000000000..29a1d8971a --- /dev/null +++ b/Task/Factorial/AppleScript/factorial-1.applescript @@ -0,0 +1,8 @@ +on factorial(x) + if x < 0 then return 0 + set R to 1 + repeat while x > 1 + set {R, x} to {R * x, x - 1} + end repeat + return R +end factorial diff --git a/Task/Factorial/AppleScript/factorial-2.applescript b/Task/Factorial/AppleScript/factorial-2.applescript new file mode 100644 index 0000000000..18f0a0568c --- /dev/null +++ b/Task/Factorial/AppleScript/factorial-2.applescript @@ -0,0 +1,5 @@ +on factorial(x) + if x < 0 then return 0 + if x > 1 then return x * (my factorial(x - 1)) + return 1 +end factorial diff --git a/Task/Factorial/AutoHotkey/factorial-1.ahk b/Task/Factorial/AutoHotkey/factorial-1.ahk new file mode 100644 index 0000000000..2da6100d04 --- /dev/null +++ b/Task/Factorial/AutoHotkey/factorial-1.ahk @@ -0,0 +1,9 @@ +MsgBox % factorial(4) + +factorial(n) +{ + result := 1 + Loop, % n + result *= A_Index + Return result +} diff --git a/Task/Factorial/AutoHotkey/factorial-2.ahk b/Task/Factorial/AutoHotkey/factorial-2.ahk new file mode 100644 index 0000000000..680b95d900 --- /dev/null +++ b/Task/Factorial/AutoHotkey/factorial-2.ahk @@ -0,0 +1,6 @@ +MsgBox % factorial(4) + +factorial(n) +{ + return n > 1 ? n-- * factorial(n) : 1 +} diff --git a/Task/Factorial/AutoIt/factorial-1.autoit b/Task/Factorial/AutoIt/factorial-1.autoit new file mode 100644 index 0000000000..db1aad047b --- /dev/null +++ b/Task/Factorial/AutoIt/factorial-1.autoit @@ -0,0 +1,12 @@ +;AutoIt Version: 3.2.10.0 +MsgBox (0,"Factorial",factorial(6)) +Func factorial($int) + If $int < 0 Then + Return 0 + EndIf + $fact = 1 + For $i = 1 To $int + $fact = $fact * $i + Next + Return $fact +EndFunc diff --git a/Task/Factorial/AutoIt/factorial-2.autoit b/Task/Factorial/AutoIt/factorial-2.autoit new file mode 100644 index 0000000000..21e756fb1c --- /dev/null +++ b/Task/Factorial/AutoIt/factorial-2.autoit @@ -0,0 +1,10 @@ +;AutoIt Version: 3.2.10.0 +MsgBox (0,"Factorial",factorial(6)) +Func factorial($int) + if $int < 0 Then + return 0 + Elseif $int == 0 Then + return 1 + EndIf + return $int * factorial($int - 1) +EndFunc diff --git a/Task/Factorial/BASIC/factorial-1.bas b/Task/Factorial/BASIC/factorial-1.bas new file mode 100644 index 0000000000..d042027a50 --- /dev/null +++ b/Task/Factorial/BASIC/factorial-1.bas @@ -0,0 +1,8 @@ +FUNCTION factorial (n AS Integer) AS Integer + DIM f AS Integer, i AS Integer + f = 1 + FOR i = 2 TO n + f = f*i + NEXT i + factorial = f +END FUNCTION diff --git a/Task/Factorial/BASIC/factorial-2.bas b/Task/Factorial/BASIC/factorial-2.bas new file mode 100644 index 0000000000..0550090d6a --- /dev/null +++ b/Task/Factorial/BASIC/factorial-2.bas @@ -0,0 +1,7 @@ +FUNCTION factorial (n AS Integer) AS Integer + IF n < 2 THEN + factorial = 1 + ELSE + factorial = n * factorial(n-1) + END IF +END FUNCTION diff --git a/Task/Factorial/BASIC256/factorial.basic256 b/Task/Factorial/BASIC256/factorial.basic256 new file mode 100644 index 0000000000..f4a959798a --- /dev/null +++ b/Task/Factorial/BASIC256/factorial.basic256 @@ -0,0 +1,8 @@ +function factorial(n) + factorial = 1 + if n>0 then + for p=1 to n + factorial *= p + next p + end if +end function diff --git a/Task/Factorial/BBC-BASIC/factorial.bbc b/Task/Factorial/BBC-BASIC/factorial.bbc new file mode 100644 index 0000000000..fc1a52a96a --- /dev/null +++ b/Task/Factorial/BBC-BASIC/factorial.bbc @@ -0,0 +1,8 @@ + *FLOAT64 + @% = &1010 + + PRINT FNfactorial(18) + END + + DEF FNfactorial(n) + IF n <= 1 THEN = 1 ELSE = n * FNfactorial(n-1) diff --git a/Task/Factorial/Babel/factorial.pb b/Task/Factorial/Babel/factorial.pb new file mode 100644 index 0000000000..f02ae2a0fc --- /dev/null +++ b/Task/Factorial/Babel/factorial.pb @@ -0,0 +1,16 @@ +main: + { argv 0 th $d + fac + %d cr << } + +fac!: + { dup zero? + { dup one? + { cp 1 - fac * } + { zap 1 } + if } + { zap 1 } + if } + +one?! : { 1 = } +zero?!: { 0 = } diff --git a/Task/Factorial/Batch-File/factorial.bat b/Task/Factorial/Batch-File/factorial.bat new file mode 100644 index 0000000000..f7fe9e8010 --- /dev/null +++ b/Task/Factorial/Batch-File/factorial.bat @@ -0,0 +1,9 @@ +@echo off +set /p x= +set /a fs=%x%-1 +set y=%x% +FOR /L %%a IN (%fs%, -1, 1) DO SET /a y*=%%a +if %x% EQU 0 set y=1 +echo %y% +pause +exit diff --git a/Task/Factorial/Befunge/factorial.bf b/Task/Factorial/Befunge/factorial.bf new file mode 100644 index 0000000000..223963ac13 --- /dev/null +++ b/Task/Factorial/Befunge/factorial.bf @@ -0,0 +1,3 @@ +&1\> :v v *< + ^-1:_$>\:| + @.$< diff --git a/Task/Factorial/Bracmat/factorial-1.bracmat b/Task/Factorial/Bracmat/factorial-1.bracmat new file mode 100644 index 0000000000..273c5443ab --- /dev/null +++ b/Task/Factorial/Bracmat/factorial-1.bracmat @@ -0,0 +1,27 @@ + ( + = + . !arg:0&1 + | !arg + * ( ( + = r + . !arg:?r + & + ' ( + . !arg:0&1 + | !arg*(($r)$($r))$(!arg+-1) + ) + ) + $ ( + = r + . !arg:?r + & + ' ( + . !arg:0&1 + | !arg*(($r)$($r))$(!arg+-1) + ) + ) + ) + $ (!arg+-1) + ) + $ 10 + : 3628800 diff --git a/Task/Factorial/Bracmat/factorial-2.bracmat b/Task/Factorial/Bracmat/factorial-2.bracmat new file mode 100644 index 0000000000..4f27da9d74 --- /dev/null +++ b/Task/Factorial/Bracmat/factorial-2.bracmat @@ -0,0 +1,4 @@ + ( (=(r.!arg:?r&'(.!arg:0&1|!arg*(($r)$($r))$(!arg+-1)))):?g + & (!g$!g):?f + & !f$10 + ) diff --git a/Task/Factorial/Bracmat/factorial-3.bracmat b/Task/Factorial/Bracmat/factorial-3.bracmat new file mode 100644 index 0000000000..56d06abcf2 --- /dev/null +++ b/Task/Factorial/Bracmat/factorial-3.bracmat @@ -0,0 +1,7 @@ +(factorial= + r +. !arg:?r + & whl + ' (!arg:>1&(!arg+-1:?arg)*!r:?r) + & !r +); diff --git a/Task/Factorial/Brainf---/factorial.bf b/Task/Factorial/Brainf---/factorial.bf new file mode 100644 index 0000000000..790e985d3f --- /dev/null +++ b/Task/Factorial/Brainf---/factorial.bf @@ -0,0 +1,4 @@ +>++++++++++>>>+>+[>>>+[-[<<<<<[+<<<<<]>>[[-]>[<<+>+>-]<[>+<-]<[>+<-[>+<-[> ++<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>[-]>>>>+>+<<<<<<-[>+<-]]]]]]]]]]]>[<+>- +]+>>>>>]<<<<<[<<<<<]>>>>>>>[>>>>>]++[-<<<<<]>>>>>>-]+>>>>>]<[>++<-]<<<<[<[ +>+<-]<<<<]>>[->[-]++++++[<++++++++>-]>>>>]<<<<<[<[>+>+<<-]>.<<<<<]>.>>>>] diff --git a/Task/Factorial/Brat/factorial.brat b/Task/Factorial/Brat/factorial.brat new file mode 100644 index 0000000000..cb4f2d70b7 --- /dev/null +++ b/Task/Factorial/Brat/factorial.brat @@ -0,0 +1,3 @@ +factorial = { x | + true? x == 0 1 { x * factorial(x - 1)} +} diff --git a/Task/Factorial/Burlesque/factorial-1.blq b/Task/Factorial/Burlesque/factorial-1.blq new file mode 100644 index 0000000000..f06b1a0aa3 --- /dev/null +++ b/Task/Factorial/Burlesque/factorial-1.blq @@ -0,0 +1,2 @@ +blsq ) 6?! +720 diff --git a/Task/Factorial/Burlesque/factorial-2.blq b/Task/Factorial/Burlesque/factorial-2.blq new file mode 100644 index 0000000000..7f35b64dcd --- /dev/null +++ b/Task/Factorial/Burlesque/factorial-2.blq @@ -0,0 +1,12 @@ +blsq ) 1 6r@pd +720 +blsq ) 1 6r@{?*}r[ +720 +blsq ) 2 6r@(.*)\/[[1+]e!.* +720 +blsq ) 1 6r@p^{.*}5E! +720 +blsq ) 6ropd +720 +blsq ) 7ro)(.*){0 1 11}die! +720 diff --git a/Task/Factorial/C++/factorial-1.cpp b/Task/Factorial/C++/factorial-1.cpp new file mode 100644 index 0000000000..fd75e3ac02 --- /dev/null +++ b/Task/Factorial/C++/factorial-1.cpp @@ -0,0 +1,8 @@ +#include +#include + +int factorial(int n) +{ + // last is one-past-end + return std::accumulate(boost::counting_iterator(1), boost::counting_iterator(n+1), 1, std::multiplies()); +} diff --git a/Task/Factorial/C++/factorial-2.cpp b/Task/Factorial/C++/factorial-2.cpp new file mode 100644 index 0000000000..9f86aec292 --- /dev/null +++ b/Task/Factorial/C++/factorial-2.cpp @@ -0,0 +1,14 @@ +long long int Factorial(long long int m_nValue) + { + long long int result=m_nValue; + long long int result_next; + long long int pc = m_nValue; + do + { + result_next = result*(pc-1); + result = result_next; + pc--; + }while(pc>2); + m_nValue = result; + return m_nValue; + } diff --git a/Task/Factorial/C++/factorial-3.cpp b/Task/Factorial/C++/factorial-3.cpp new file mode 100644 index 0000000000..ee84f7c316 --- /dev/null +++ b/Task/Factorial/C++/factorial-3.cpp @@ -0,0 +1,19 @@ +template +struct Factorial +{ + enum { value = N * Factorial::value }; +}; + +template <> +struct Factorial<0> +{ + enum { value = 1 }; +}; + +// Factorial<4>::value == 24 +// Factorial<0>::value == 1 +void foo() +{ + int x = Factorial<4>::value; // == 24 + int y = Factorial<0>::value; // == 1 +} diff --git a/Task/Factorial/C/factorial-1.c b/Task/Factorial/C/factorial-1.c new file mode 100644 index 0000000000..e3f16f66bf --- /dev/null +++ b/Task/Factorial/C/factorial-1.c @@ -0,0 +1,6 @@ +int factorial(int n) { + int result = 1; + for (int i = 1; i <= n; ++i) + result *= i; + return result; +} diff --git a/Task/Factorial/C/factorial-2.c b/Task/Factorial/C/factorial-2.c new file mode 100644 index 0000000000..8c6f303e63 --- /dev/null +++ b/Task/Factorial/C/factorial-2.c @@ -0,0 +1,3 @@ +int factorial(int n) { + return n == 0 ? 1 : n * factorial(n - 1); +} diff --git a/Task/Factorial/C/factorial-3.c b/Task/Factorial/C/factorial-3.c new file mode 100644 index 0000000000..83a84276be --- /dev/null +++ b/Task/Factorial/C/factorial-3.c @@ -0,0 +1,7 @@ +int fac_aux(int n, int acc) { + return n < 1 ? acc : fac_aux(n - 1, acc * n); +} + +int factorial(int n) { + return fac_aux(n, 1); +} diff --git a/Task/Factorial/CLIPS/factorial.clips b/Task/Factorial/CLIPS/factorial.clips new file mode 100644 index 0000000000..4de6993cca --- /dev/null +++ b/Task/Factorial/CLIPS/factorial.clips @@ -0,0 +1,8 @@ + (deffunction factorial (?a) + (if (or (not (integerp ?a)) (< ?a 0)) then + (printout t "Factorial Error!" crlf) + else + (if (= ?a 0) then + 1 + else + (* ?a (factorial (- ?a 1)))))) diff --git a/Task/Factorial/CMake/factorial.cmake b/Task/Factorial/CMake/factorial.cmake new file mode 100644 index 0000000000..7156c0353f --- /dev/null +++ b/Task/Factorial/CMake/factorial.cmake @@ -0,0 +1,10 @@ +function(factorial var n) + set(product 1) + foreach(i RANGE 2 ${n}) + math(EXPR product "${product} * ${i}") + endforeach(i) + set(${var} ${product} PARENT_SCOPE) +endfunction(factorial) + +factorial(f 12) +message("12! = ${f}") diff --git a/Task/Factorial/Cat/factorial.cat b/Task/Factorial/Cat/factorial.cat new file mode 100644 index 0000000000..5da86b5f29 --- /dev/null +++ b/Task/Factorial/Cat/factorial.cat @@ -0,0 +1,2 @@ +define rec_fac + { dup 1 <= [pop 1] [dec rec_fac *] if } diff --git a/Task/Factorial/Chef/factorial.chef b/Task/Factorial/Chef/factorial.chef new file mode 100644 index 0000000000..f82f135845 --- /dev/null +++ b/Task/Factorial/Chef/factorial.chef @@ -0,0 +1,17 @@ +Caramel Factorials. + +Only reads one value. + +Ingredients. +1 g Caramel +2 g Factorials + +Method. +Take Factorials from refrigerator. +Put Caramel into 1st mixing bowl. +Verb the Factorials. +Combine Factorials into 1st mixing bowl. +Verb Factorials until verbed. +Pour contents of the 1st mixing bowl into the 1st baking dish. + +Serves 1. diff --git a/Task/Factorial/Clay/factorial-1.clay b/Task/Factorial/Clay/factorial-1.clay new file mode 100644 index 0000000000..53a8510d72 --- /dev/null +++ b/Task/Factorial/Clay/factorial-1.clay @@ -0,0 +1,14 @@ +factorialRec(n) { + if (n == 0) return 1; + return n * factorialRec(n - 1); +} + +factorialIter(n) { + for (i in range(1, n)) + n *= i; + return n; +} + +factorialFold(n) { + return reduce(multiply, 1, range(1, n + 1)); +} diff --git a/Task/Factorial/Clay/factorial-2.clay b/Task/Factorial/Clay/factorial-2.clay new file mode 100644 index 0000000000..b939c66a9f --- /dev/null +++ b/Task/Factorial/Clay/factorial-2.clay @@ -0,0 +1,2 @@ +[n|n > 0] factorialStatic(static n) = n * factorialStatic(static n - 1); +overload factorialStatic(static 0) = 1; diff --git a/Task/Factorial/Clay/factorial-3.clay b/Task/Factorial/Clay/factorial-3.clay new file mode 100644 index 0000000000..6e2219eb06 --- /dev/null +++ b/Task/Factorial/Clay/factorial-3.clay @@ -0,0 +1,4 @@ +[N|Integer?(N)] factorial(n: N) { + if (n == 0) return N(1); + return n * factorial(n - 1); +} diff --git a/Task/Factorial/Clay/factorial-4.clay b/Task/Factorial/Clay/factorial-4.clay new file mode 100644 index 0000000000..e02fdbd5a4 --- /dev/null +++ b/Task/Factorial/Clay/factorial-4.clay @@ -0,0 +1,7 @@ +main() { + println(factorialRec(5)); // 120 + println(factorialIter(5)); // 120 + println(factorialFold(5)); // 120 + println(factorialStatic(static 5)); // 120 + println(factorial(Int64(20))); // 2432902008176640000 +} diff --git a/Task/Factorial/Clojure/factorial-1.clj b/Task/Factorial/Clojure/factorial-1.clj new file mode 100644 index 0000000000..f3fb799093 --- /dev/null +++ b/Task/Factorial/Clojure/factorial-1.clj @@ -0,0 +1,2 @@ +(defn factorial [x] + (apply * (range 2 (inc x)))) diff --git a/Task/Factorial/Clojure/factorial-2.clj b/Task/Factorial/Clojure/factorial-2.clj new file mode 100644 index 0000000000..174c8bc8a8 --- /dev/null +++ b/Task/Factorial/Clojure/factorial-2.clj @@ -0,0 +1,4 @@ +(defn factorial [x] + (if (< x 2) + 1 + (* x (factorial (dec x))))) diff --git a/Task/Factorial/Clojure/factorial-3.clj b/Task/Factorial/Clojure/factorial-3.clj new file mode 100644 index 0000000000..d9e87aff42 --- /dev/null +++ b/Task/Factorial/Clojure/factorial-3.clj @@ -0,0 +1,6 @@ +(defn factorial [x] + (loop [x x + acc 1] + (if (< x 2) + acc + (recur (dec x) (* acc x))))) diff --git a/Task/Factorial/CoffeeScript/factorial-1.coffee b/Task/Factorial/CoffeeScript/factorial-1.coffee new file mode 100644 index 0000000000..2d094e4134 --- /dev/null +++ b/Task/Factorial/CoffeeScript/factorial-1.coffee @@ -0,0 +1,5 @@ +fac = (n) -> + if n <= 1 + 1 + else + n * fac n-1 diff --git a/Task/Factorial/CoffeeScript/factorial-2.coffee b/Task/Factorial/CoffeeScript/factorial-2.coffee new file mode 100644 index 0000000000..0494db14a3 --- /dev/null +++ b/Task/Factorial/CoffeeScript/factorial-2.coffee @@ -0,0 +1,2 @@ +fac = (n) -> + [1..n].reduce (x,y) -> x*y diff --git a/Task/Factorial/Common-Lisp/factorial-1.lisp b/Task/Factorial/Common-Lisp/factorial-1.lisp new file mode 100644 index 0000000000..f016a89abf --- /dev/null +++ b/Task/Factorial/Common-Lisp/factorial-1.lisp @@ -0,0 +1,4 @@ +(defun fact (n) + (if (< n 2) + 1 + (* n (fact(- n 1))))) diff --git a/Task/Factorial/Common-Lisp/factorial-2.lisp b/Task/Factorial/Common-Lisp/factorial-2.lisp new file mode 100644 index 0000000000..8e40d68ee5 --- /dev/null +++ b/Task/Factorial/Common-Lisp/factorial-2.lisp @@ -0,0 +1,5 @@ +(defun factorial (n) + "Calculates N!" + (loop for result = 1 then (* result i) + for i from 2 to n + finally (return result))) diff --git a/Task/Factorial/Common-Lisp/factorial-3.lisp b/Task/Factorial/Common-Lisp/factorial-3.lisp new file mode 100644 index 0000000000..3b40c52cdb --- /dev/null +++ b/Task/Factorial/Common-Lisp/factorial-3.lisp @@ -0,0 +1,2 @@ +(defun factorial (n) + (reduce #'* (loop for i from 1 to n collect i))) diff --git a/Task/Factorial/D/factorial.d b/Task/Factorial/D/factorial.d new file mode 100644 index 0000000000..b12d15d18b --- /dev/null +++ b/Task/Factorial/D/factorial.d @@ -0,0 +1,47 @@ +import std.stdio, std.algorithm, std.metastrings, std.range; + +// iterative +int factorial(int n) { + int result = 1; + foreach (i; 1 .. n + 1) + result *= i; + return result; +} + +// recursive +int recFactorial(int n) { + if (n == 0) + return 1; + else + return n * recFactorial(n - 1); +} + +// functional-style +int fact(int n) { + return iota(1, n + 1).reduce!q{a * b}(); +} + +// tail recursive (at run-time, with DMD) +int tfactorial(int n) { + static int facAux(int n, int acc) { + if (n < 1) + return acc; + else + return facAux(n - 1, acc * n); + } + return facAux(n, 1); +} + +// computed and printed at compile-time +pragma(msg, toStringNow!(factorial(15))); +pragma(msg, toStringNow!(recFactorial(15))); +pragma(msg, toStringNow!(fact(15))); +pragma(msg, toStringNow!(tfactorial(15))); + +void main() { + // computed and printed at run-time + writeln(factorial(15)); + writeln(recFactorial(15)); + writeln(fact(15)); + writeln(tfactorial(15)); +} diff --git a/Task/Factorial/DWScript/factorial-1.dwscript b/Task/Factorial/DWScript/factorial-1.dwscript new file mode 100644 index 0000000000..b1040e1024 --- /dev/null +++ b/Task/Factorial/DWScript/factorial-1.dwscript @@ -0,0 +1,8 @@ +function IterativeFactorial(n : Integer) : Integer; +var + i : Integer; +begin + Result := 1; + for i := 2 to n do + Result *= i; +end; diff --git a/Task/Factorial/DWScript/factorial-2.dwscript b/Task/Factorial/DWScript/factorial-2.dwscript new file mode 100644 index 0000000000..be2ed7d4f7 --- /dev/null +++ b/Task/Factorial/DWScript/factorial-2.dwscript @@ -0,0 +1,6 @@ +function RecursiveFactorial(n : Integer) : Integer; +begin + if n>1 then + Result := RecursiveFactorial(n-1)*n + else Result := 1; +end; diff --git a/Task/Factorial/Dart/factorial-1.dart b/Task/Factorial/Dart/factorial-1.dart new file mode 100644 index 0000000000..78e12ba218 --- /dev/null +++ b/Task/Factorial/Dart/factorial-1.dart @@ -0,0 +1,11 @@ +int fact(int n) { + if(n<0) { + throw new IllegalArgumentException('Argument less than 0'); + } + return n==0 ? 1 : n*fact(n-1); +} + +main() { + print(fact(10)); + print(fact(-1)); +} diff --git a/Task/Factorial/Dart/factorial-2.dart b/Task/Factorial/Dart/factorial-2.dart new file mode 100644 index 0000000000..f4aeb001c5 --- /dev/null +++ b/Task/Factorial/Dart/factorial-2.dart @@ -0,0 +1,15 @@ +int fact(int n) { + if(n<0) { + throw new IllegalArgumentException('Argument less than 0'); + } + int res=1; + for(int i=1;i<=n;i++) { + res*=i; + } + return res; +} + +main() { + print(fact(10)); + print(fact(-1)); +} diff --git a/Task/Factorial/Delphi/factorial-1.delphi b/Task/Factorial/Delphi/factorial-1.delphi new file mode 100644 index 0000000000..7afc48fdf9 --- /dev/null +++ b/Task/Factorial/Delphi/factorial-1.delphi @@ -0,0 +1,16 @@ +program Factorial1; + +{$APPTYPE CONSOLE} + +function FactorialIterative(aNumber: Integer): Int64; +var + i: Integer; +begin + Result := 1; + for i := 1 to aNumber do + Result := i * Result; +end; + +begin + Writeln('5! = ', FactorialIterative(5)); +end. diff --git a/Task/Factorial/Delphi/factorial-2.delphi b/Task/Factorial/Delphi/factorial-2.delphi new file mode 100644 index 0000000000..a067ba8935 --- /dev/null +++ b/Task/Factorial/Delphi/factorial-2.delphi @@ -0,0 +1,15 @@ +program Factorial2; + +{$APPTYPE CONSOLE} + +function FactorialRecursive(aNumber: Integer): Int64; +begin + if aNumber < 1 then + Result := 1 + else + Result := aNumber * FactorialRecursive(aNumber - 1); +end; + +begin + Writeln('5! = ', FactorialRecursive(5)); +end. diff --git a/Task/Factorial/Delphi/factorial-3.delphi b/Task/Factorial/Delphi/factorial-3.delphi new file mode 100644 index 0000000000..5648e522b6 --- /dev/null +++ b/Task/Factorial/Delphi/factorial-3.delphi @@ -0,0 +1,24 @@ +program Factorial3; + +{$APPTYPE CONSOLE} + +function FactorialTailRecursive(aNumber: Integer): Int64; + + function FactorialHelper(aNumber: Integer; aAccumulator: Int64): Int64; + begin + if aNumber = 0 then + Result := aAccumulator + else + Result := FactorialHelper(aNumber - 1, aNumber * aAccumulator); + end; + +begin + if aNumber < 1 then + Result := 1 + else + Result := FactorialHelper(aNumber, 1); +end; + +begin + Writeln('5! = ', FactorialTailRecursive(5)); +end. diff --git a/Task/Factorial/Dylan/factorial.dylan b/Task/Factorial/Dylan/factorial.dylan new file mode 100644 index 0000000000..44a5bb1fe8 --- /dev/null +++ b/Task/Factorial/Dylan/factorial.dylan @@ -0,0 +1,3 @@ +define method factorial(n) + reduce1(\*, range(from: 1, to: n)); +end diff --git a/Task/Factorial/E/factorial.e b/Task/Factorial/E/factorial.e new file mode 100644 index 0000000000..cf635f5c88 --- /dev/null +++ b/Task/Factorial/E/factorial.e @@ -0,0 +1,4 @@ +pragma.enable("accumulator") +def factorial(n) { + return accum 1 for i in 2..n { _ * i } +} diff --git a/Task/Factorial/EGL/factorial-1.egl b/Task/Factorial/EGL/factorial-1.egl new file mode 100644 index 0000000000..679f365396 --- /dev/null +++ b/Task/Factorial/EGL/factorial-1.egl @@ -0,0 +1,11 @@ +function fact(n int in) returns (bigint) + if (n < 0) + writestdout("No negative numbers"); + return (0); + end + ans bigint = 1; + for (i int from 1 to n) + ans *= i; + end + return (ans); +end diff --git a/Task/Factorial/EGL/factorial-2.egl b/Task/Factorial/EGL/factorial-2.egl new file mode 100644 index 0000000000..f085dacbcd --- /dev/null +++ b/Task/Factorial/EGL/factorial-2.egl @@ -0,0 +1,11 @@ +function fact(n int in) returns (bigint) + if (n < 0) + SysLib.writeStdout("No negative numbers"); + return (0); + end + if (n < 2) + return (1); + else + return (n * fact(n - 1)); + end +end diff --git a/Task/Factorial/Ela/factorial.ela b/Task/Factorial/Ela/factorial.ela new file mode 100644 index 0000000000..a0ec20ea39 --- /dev/null +++ b/Task/Factorial/Ela/factorial.ela @@ -0,0 +1,3 @@ +fact = fact' 1L + where fact' acc 0 = acc + fact' acc n = fact' (n * acc) (n - 1) diff --git a/Task/Factorial/Emacs-Lisp/factorial-1.l b/Task/Factorial/Emacs-Lisp/factorial-1.l new file mode 100644 index 0000000000..d806098ba8 --- /dev/null +++ b/Task/Factorial/Emacs-Lisp/factorial-1.l @@ -0,0 +1,6 @@ +(defun fact (n) + "n is an integer, this function returns n!, that is n * (n - 1) +* (n - 2)....* 4 * 3 * 2 * 1" + (cond + ((= n 1) 1) + (t (* n (fact (1- n)))))) diff --git a/Task/Factorial/Emacs-Lisp/factorial-2.l b/Task/Factorial/Emacs-Lisp/factorial-2.l new file mode 100644 index 0000000000..b7d69a4dfa --- /dev/null +++ b/Task/Factorial/Emacs-Lisp/factorial-2.l @@ -0,0 +1,4 @@ +(require 'calc) +(calc-eval "fact(30)") +=> +"265252859812191058636308480000000" diff --git a/Task/Factorial/Erlang/factorial-1.erl b/Task/Factorial/Erlang/factorial-1.erl new file mode 100644 index 0000000000..99a638b204 --- /dev/null +++ b/Task/Factorial/Erlang/factorial-1.erl @@ -0,0 +1 @@ +lists:foldl(fun(X,Y) -> X*Y end, 1, lists:seq(1,N)). diff --git a/Task/Factorial/Erlang/factorial-2.erl b/Task/Factorial/Erlang/factorial-2.erl new file mode 100644 index 0000000000..3f6661aed6 --- /dev/null +++ b/Task/Factorial/Erlang/factorial-2.erl @@ -0,0 +1,2 @@ +fac(1) -> 1; +fac(N) -> N * fac(N-1). diff --git a/Task/Factorial/Erlang/factorial-3.erl b/Task/Factorial/Erlang/factorial-3.erl new file mode 100644 index 0000000000..5964d0a25e --- /dev/null +++ b/Task/Factorial/Erlang/factorial-3.erl @@ -0,0 +1,3 @@ +fac(N) -> fac(N-1,N). +fac(1,N) -> N; +fac(I,N) -> fac(I-1,N*I). diff --git a/Task/Factorial/Euphoria/factorial-1.euphoria b/Task/Factorial/Euphoria/factorial-1.euphoria new file mode 100644 index 0000000000..f36ea675c6 --- /dev/null +++ b/Task/Factorial/Euphoria/factorial-1.euphoria @@ -0,0 +1,9 @@ +function factorial(integer n) + atom f = 1 + while n > 1 do + f *= n + n -= 1 + end while + + return f +end function diff --git a/Task/Factorial/Euphoria/factorial-2.euphoria b/Task/Factorial/Euphoria/factorial-2.euphoria new file mode 100644 index 0000000000..df1332ec75 --- /dev/null +++ b/Task/Factorial/Euphoria/factorial-2.euphoria @@ -0,0 +1,7 @@ +function factorial(integer n) + if n > 1 then + return factorial(n-1) * n + else + return 1 + end if +end function diff --git a/Task/Factorial/Euphoria/factorial-3.euphoria b/Task/Factorial/Euphoria/factorial-3.euphoria new file mode 100644 index 0000000000..e32d25e6da --- /dev/null +++ b/Task/Factorial/Euphoria/factorial-3.euphoria @@ -0,0 +1,7 @@ +function factorial(integer n, integer acc = 1) + if n <= 0 then + return acc + else + return factorial(n-1, n*acc) + end if +end function diff --git a/Task/Factorial/Euphoria/factorial-4.euphoria b/Task/Factorial/Euphoria/factorial-4.euphoria new file mode 100644 index 0000000000..0ef293f577 --- /dev/null +++ b/Task/Factorial/Euphoria/factorial-4.euphoria @@ -0,0 +1,106 @@ +include std/mathcons.e + +enum MUL_LLL, + TESTEQ_LIL, + TESTLT_LIL, + TRUEGO_LL, + MOVE_LL, + INCR_L, + TESTGT_LLL, + GOTO_L, + OUT_LI, + OUT_II, + STOP + +global sequence tape = { + 1, + 1, + 0, + 0, + 0, + {TESTLT_LIL, 5, 0, 4}, + {TRUEGO_LL, 4, 22}, + {TESTEQ_LIL, 5, 0, 4}, + {TRUEGO_LL, 4, 20}, + {MUL_LLL, 1, 2, 3}, + {TESTEQ_LIL, 3, PINF, 4}, + {TRUEGO_LL, 4, 18}, + {MOVE_LL, 3, 1}, + {INCR_L, 2}, + {TESTGT_LLL, 2, 5, 4 }, + {TRUEGO_LL, 4, 18}, + {GOTO_L, 10}, + {OUT_LI, 3, "%.0f\n"}, + {STOP}, + {OUT_II, 1, "%.0f\n"}, + {STOP}, + {OUT_II, "Negative argument", "%s\n"}, + {STOP} +} + +global integer ip = 1 + +procedure eval( sequence cmd ) + atom i = 1 + while i <= length( cmd ) do + switch cmd[ i ] do + case MUL_LLL then -- multiply location location giving location + tape[ cmd[ i + 3 ] ] = tape[ cmd[ i + 1 ] ] * tape[ cmd[ i + 2 ] ] + i += 3 + case TESTEQ_LIL then -- test if location eq value giving location + tape[ cmd[ i + 3 ]] = ( tape[ cmd[ i + 1 ] ] = cmd[ i + 2 ] ) + i += 3 + case TESTLT_LIL then -- test if location eq value giving location + tape[ cmd[ i + 3 ]] = ( tape[ cmd[ i + 1 ] ] < cmd[ i + 2 ] ) + i += 3 + case TRUEGO_LL then -- if true in location, goto location + if tape[ cmd[ i + 1 ] ] then + ip = cmd[ i + 2 ] - 1 + end if + i += 2 + case MOVE_LL then -- move value at location to location + tape[ cmd[ i + 2 ] ] = tape[ cmd[ i + 1 ] ] + i += 2 + case INCR_L then -- increment value at location + tape[ cmd[ i + 1 ] ] += 1 + i += 1 + case TESTGT_LLL then -- test if location gt location giving location + tape[ cmd[ i + 3 ]] = ( tape[ cmd[ i + 1 ] ] > tape[ cmd[ i + 2 ] ] ) + i += 3 + case GOTO_L then -- goto location + ip = cmd[ i + 1 ] - 1 + i += 1 + case OUT_LI then -- output location using format + printf( 1, cmd[ i + 2], tape[ cmd[ i + 1 ] ] ) + i += 2 + case OUT_II then -- output immediate using format + if sequence( cmd[ i + 1 ] ) then + printf( 1, cmd[ i + 2], { cmd[ i + 1 ] } ) + else + printf( 1, cmd[ i + 2], cmd[ i + 1 ] ) + end if + i += 2 + case STOP then -- stop + abort(0) + end switch + i += 1 + end while +end procedure + +include std/convert.e + +sequence cmd = command_line() +if length( cmd ) > 2 then + puts( 1, cmd[ 3 ] & "! = " ) + tape[ 5 ] = to_number(cmd[3]) +else + puts( 1, "eui fact.ex \n" ) + abort(1) +end if + +while 1 do + if sequence( tape[ ip ] ) then + eval( tape[ ip ] ) + end if + ip += 1 +end while diff --git a/Task/Factorial/FALSE/factorial-1.false b/Task/Factorial/FALSE/factorial-1.false new file mode 100644 index 0000000000..78ffe76fb8 --- /dev/null +++ b/Task/Factorial/FALSE/factorial-1.false @@ -0,0 +1,2 @@ +[1\[$][$@*\1-]#%]f: +^'0- f;!. diff --git a/Task/Factorial/FALSE/factorial-2.false b/Task/Factorial/FALSE/factorial-2.false new file mode 100644 index 0000000000..806b709ccc --- /dev/null +++ b/Task/Factorial/FALSE/factorial-2.false @@ -0,0 +1 @@ +[$1=~[$1-f;!*]?]f: diff --git a/Task/Factorial/Factor/factorial.factor b/Task/Factorial/Factor/factorial.factor new file mode 100644 index 0000000000..18ecd2d6ef --- /dev/null +++ b/Task/Factorial/Factor/factorial.factor @@ -0,0 +1,3 @@ +USING: math.ranges sequences ; + +: factorial ( n -- n ) [1,b] product ; diff --git a/Task/Factorial/Fancy/factorial.fancy b/Task/Factorial/Fancy/factorial.fancy new file mode 100644 index 0000000000..4af63f802e --- /dev/null +++ b/Task/Factorial/Fancy/factorial.fancy @@ -0,0 +1,10 @@ +def class Number { + def factorial { + 1 upto: self . product + } +} + +# print first ten factorials +1 upto: 10 do_each: |i| { + i to_s ++ "! = " ++ (i factorial) println +} diff --git a/Task/Factorial/Fantom/factorial.fantom b/Task/Factorial/Fantom/factorial.fantom new file mode 100644 index 0000000000..3c605207cd --- /dev/null +++ b/Task/Factorial/Fantom/factorial.fantom @@ -0,0 +1,36 @@ +class Main +{ + static Int factorialRecursive (Int n) + { + if (n <= 1) + return 1 + else + return n * (factorialRecursive (n - 1)) + } + + static Int factorialIterative (Int n) + { + Int product := 1 + for (Int i := 2; i <=n ; ++i) + { + product *= i + } + return product + } + + static Int factorialFunctional (Int n) + { + (1..n).toList.reduce(1) |a,v| + { + v->mult(a) // use a dynamic invoke + // alternatively, cast a: v * (Int)a + } + } + + public static Void main () + { + echo (factorialRecursive(20)) + echo (factorialIterative(20)) + echo (factorialFunctional(20)) + } +} diff --git a/Task/Factorial/Forth/factorial.fth b/Task/Factorial/Forth/factorial.fth new file mode 100644 index 0000000000..dc929b5b63 --- /dev/null +++ b/Task/Factorial/Forth/factorial.fth @@ -0,0 +1 @@ +: fac ( n -- n! ) 1 swap 1+ 1 ?do i * loop ; diff --git a/Task/Factorial/Fortran/factorial-1.f b/Task/Factorial/Fortran/factorial-1.f new file mode 100644 index 0000000000..7e43b5c997 --- /dev/null +++ b/Task/Factorial/Fortran/factorial-1.f @@ -0,0 +1 @@ +nfactorial = PRODUCT((/(i, i=1,n)/)) diff --git a/Task/Factorial/Fortran/factorial-2.f b/Task/Factorial/Fortran/factorial-2.f new file mode 100644 index 0000000000..6313a74fdd --- /dev/null +++ b/Task/Factorial/Fortran/factorial-2.f @@ -0,0 +1,6 @@ + FUNCTION FACT(N) + INTEGER N,I,FACT + FACT=1 + DO 10 I=1,N + 10 FACT=FACT*I + END diff --git a/Task/Factorial/GAP/factorial.gap b/Task/Factorial/GAP/factorial.gap new file mode 100644 index 0000000000..65ddffddad --- /dev/null +++ b/Task/Factorial/GAP/factorial.gap @@ -0,0 +1,5 @@ +# Built-in +Factorial(5); + +# An implementation +fact := n -> Product([1 .. n]); diff --git a/Task/Factorial/GML/factorial.gml b/Task/Factorial/GML/factorial.gml new file mode 100644 index 0000000000..bc315226d3 --- /dev/null +++ b/Task/Factorial/GML/factorial.gml @@ -0,0 +1,5 @@ +n = argument0 +j = 1 +for(i = 1; i <= n; i += 1) + j *= i +return j diff --git a/Task/Factorial/Genyris/factorial.genyris b/Task/Factorial/Genyris/factorial.genyris new file mode 100644 index 0000000000..3909f6e52c --- /dev/null +++ b/Task/Factorial/Genyris/factorial.genyris @@ -0,0 +1,4 @@ +def factorial (n) + if (< n 2) 1 + * n + factorial (- n 1) diff --git a/Task/Factorial/Go/factorial-1.go b/Task/Factorial/Go/factorial-1.go new file mode 100644 index 0000000000..7f1108a14e --- /dev/null +++ b/Task/Factorial/Go/factorial-1.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + fmt.Println(factorial(800)) +} + +func factorial(n int64) *big.Int { + if n < 0 { + return nil + } + r := big.NewInt(1) + var f big.Int + for i := int64(2); i <= n; i++ { + r.Mul(r, f.SetInt64(i)) + } + return r +} diff --git a/Task/Factorial/Go/factorial-2.go b/Task/Factorial/Go/factorial-2.go new file mode 100644 index 0000000000..fbf9b3287c --- /dev/null +++ b/Task/Factorial/Go/factorial-2.go @@ -0,0 +1,15 @@ +package main + +import ( + "math/big" + "fmt" +) + +func factorial(n int64) *big.Int { + var z big.Int + return z.MulRange(1, n) +} + +func main() { + fmt.Println(factorial(800)) +} diff --git a/Task/Factorial/Golfscript/factorial-1.golf b/Task/Factorial/Golfscript/factorial-1.golf new file mode 100644 index 0000000000..99bbd8a8a1 --- /dev/null +++ b/Task/Factorial/Golfscript/factorial-1.golf @@ -0,0 +1,2 @@ +{.!{1}{,{)}%{*}*}if}:fact; +5fact puts # test diff --git a/Task/Factorial/Golfscript/factorial-2.golf b/Task/Factorial/Golfscript/factorial-2.golf new file mode 100644 index 0000000000..1c2fb3848a --- /dev/null +++ b/Task/Factorial/Golfscript/factorial-2.golf @@ -0,0 +1 @@ +{),(;{*}*}:fact; diff --git a/Task/Factorial/Golfscript/factorial-3.golf b/Task/Factorial/Golfscript/factorial-3.golf new file mode 100644 index 0000000000..b09dc275b1 --- /dev/null +++ b/Task/Factorial/Golfscript/factorial-3.golf @@ -0,0 +1 @@ +{.1<{;1}{.(fact*}if}:fact; diff --git a/Task/Factorial/Groovy/factorial-1.groovy b/Task/Factorial/Groovy/factorial-1.groovy new file mode 100644 index 0000000000..eb55b8752e --- /dev/null +++ b/Task/Factorial/Groovy/factorial-1.groovy @@ -0,0 +1,2 @@ +def rFact +rFact = { (it > 1) ? it * rFact(it - 1) : 1 } diff --git a/Task/Factorial/Groovy/factorial-2.groovy b/Task/Factorial/Groovy/factorial-2.groovy new file mode 100644 index 0000000000..237d76fb80 --- /dev/null +++ b/Task/Factorial/Groovy/factorial-2.groovy @@ -0,0 +1 @@ +(0..6).each { println "${it}: ${rFact(it)}" } diff --git a/Task/Factorial/Groovy/factorial-3.groovy b/Task/Factorial/Groovy/factorial-3.groovy new file mode 100644 index 0000000000..16d91aa814 --- /dev/null +++ b/Task/Factorial/Groovy/factorial-3.groovy @@ -0,0 +1 @@ +def iFact = { (it > 1) ? (2..it).inject(1) { i, j -> i*j } : 1 } diff --git a/Task/Factorial/Groovy/factorial-4.groovy b/Task/Factorial/Groovy/factorial-4.groovy new file mode 100644 index 0000000000..6100d01f08 --- /dev/null +++ b/Task/Factorial/Groovy/factorial-4.groovy @@ -0,0 +1 @@ +(0..6).each { println "${it}: ${iFact(it)}" } diff --git a/Task/Factorial/Haskell/factorial-1.hs b/Task/Factorial/Haskell/factorial-1.hs new file mode 100644 index 0000000000..9c54462476 --- /dev/null +++ b/Task/Factorial/Haskell/factorial-1.hs @@ -0,0 +1 @@ +factorial n = product [1..n] diff --git a/Task/Factorial/Haskell/factorial-2.hs b/Task/Factorial/Haskell/factorial-2.hs new file mode 100644 index 0000000000..4a9556a5a8 --- /dev/null +++ b/Task/Factorial/Haskell/factorial-2.hs @@ -0,0 +1 @@ +factorial n = foldl (*) 1 [1..n] diff --git a/Task/Factorial/Haskell/factorial-3.hs b/Task/Factorial/Haskell/factorial-3.hs new file mode 100644 index 0000000000..1536f72670 --- /dev/null +++ b/Task/Factorial/Haskell/factorial-3.hs @@ -0,0 +1 @@ +factorials = scanl (*) 1 [1..] diff --git a/Task/Factorial/Haskell/factorial-4.hs b/Task/Factorial/Haskell/factorial-4.hs new file mode 100644 index 0000000000..6b76b69b6e --- /dev/null +++ b/Task/Factorial/Haskell/factorial-4.hs @@ -0,0 +1,3 @@ +factorial :: Integral -> Integral +factorial 0 = 1 +factorial n = n * factorial (n-1) diff --git a/Task/Factorial/Haskell/factorial-5.hs b/Task/Factorial/Haskell/factorial-5.hs new file mode 100644 index 0000000000..baef906bf8 --- /dev/null +++ b/Task/Factorial/Haskell/factorial-5.hs @@ -0,0 +1,5 @@ +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/HicEst/factorial.hicest b/Task/Factorial/HicEst/factorial.hicest new file mode 100644 index 0000000000..b7bc52434e --- /dev/null +++ b/Task/Factorial/HicEst/factorial.hicest @@ -0,0 +1,8 @@ +WRITE(Clipboard) factorial(6) ! pasted: 720 + +FUNCTION factorial(n) + factorial = 1 + DO i = 2, n + factorial = factorial * i + ENDDO +END diff --git a/Task/Factorial/IDL/factorial.idl b/Task/Factorial/IDL/factorial.idl new file mode 100644 index 0000000000..e7a8f13466 --- /dev/null +++ b/Task/Factorial/IDL/factorial.idl @@ -0,0 +1,3 @@ +function fact,n + return, product(lindgen(n)+1) +end diff --git a/Task/Factorial/Icon/factorial-1.icon b/Task/Factorial/Icon/factorial-1.icon new file mode 100644 index 0000000000..a8ce2e87b1 --- /dev/null +++ b/Task/Factorial/Icon/factorial-1.icon @@ -0,0 +1,5 @@ +procedure factorial(n) + n := integer(n) | runerr(101, n) + if n < 0 then fail + return if n = 0 then 1 else n*factorial(n-1) +end diff --git a/Task/Factorial/Icon/factorial-2.icon b/Task/Factorial/Icon/factorial-2.icon new file mode 100644 index 0000000000..fc539f9281 --- /dev/null +++ b/Task/Factorial/Icon/factorial-2.icon @@ -0,0 +1,8 @@ +procedure factorial(n) #: return n! (n factorial) + local i + n := integer(n) | runerr(101, n) + if n < 0 then fail + i := 1 + every i *:= 1 to n + return i +end diff --git a/Task/Factorial/Inform-6/factorial.inf b/Task/Factorial/Inform-6/factorial.inf new file mode 100644 index 0000000000..851dce6a29 --- /dev/null +++ b/Task/Factorial/Inform-6/factorial.inf @@ -0,0 +1,6 @@ +[ factorial n; + if(n == 0) + return 1; + else + return n * factorial(n - 1); +]; diff --git a/Task/Factorial/Io/factorial.io b/Task/Factorial/Io/factorial.io new file mode 100644 index 0000000000..435b6c7538 --- /dev/null +++ b/Task/Factorial/Io/factorial.io @@ -0,0 +1 @@ +3 factorial diff --git a/Task/Factorial/J/factorial-1.j b/Task/Factorial/J/factorial-1.j new file mode 100644 index 0000000000..153d75e9e7 --- /dev/null +++ b/Task/Factorial/J/factorial-1.j @@ -0,0 +1,2 @@ + ! 8 NB. Built in factorial operator +40320 diff --git a/Task/Factorial/J/factorial-2.j b/Task/Factorial/J/factorial-2.j new file mode 100644 index 0000000000..70b6a815d6 --- /dev/null +++ b/Task/Factorial/J/factorial-2.j @@ -0,0 +1,2 @@ + */1+i.8 +40320 diff --git a/Task/Factorial/J/factorial-3.j b/Task/Factorial/J/factorial-3.j new file mode 100644 index 0000000000..786036644e --- /dev/null +++ b/Task/Factorial/J/factorial-3.j @@ -0,0 +1,2 @@ + (*$:@:<:)^:(1&<) 8 +40320 diff --git a/Task/Factorial/J/factorial-4.j b/Task/Factorial/J/factorial-4.j new file mode 100644 index 0000000000..4deede7a9a --- /dev/null +++ b/Task/Factorial/J/factorial-4.j @@ -0,0 +1,4 @@ + ! 8 0.8 _0.8 NB. Generalizes as the gamma function +40320 0.931384 4.59084 + ! 800x NB. Also arbitrarily large +7710530113353860041446393977750283605955564018160102391634109940339708518270930693670907697955390330926478612242306774446597851526397454014801846531749097625044706382742591201733097017026108750929188168469858421505936237186038616420630788341172340985137252... diff --git a/Task/Factorial/Java/factorial-1.java b/Task/Factorial/Java/factorial-1.java new file mode 100644 index 0000000000..b0b9d120c3 --- /dev/null +++ b/Task/Factorial/Java/factorial-1.java @@ -0,0 +1,11 @@ +public static long fact(final int n) { + if (n < 0) { + System.err.println("No negative numbers"); + return 0; + } + long ans = 1; + for (int i = 1; i <= n; i++) { + ans *= i; + } + return ans; +} diff --git a/Task/Factorial/Java/factorial-2.java b/Task/Factorial/Java/factorial-2.java new file mode 100644 index 0000000000..3f2e2ec883 --- /dev/null +++ b/Task/Factorial/Java/factorial-2.java @@ -0,0 +1,7 @@ +public static long fact(final int n) { + if (n < 0){ + System.err.println("No negative numbers"); + return 0; + } + return (n < 2) ? 1 : n * fact(n - 1); +} diff --git a/Task/Factorial/JavaScript/factorial-1.js b/Task/Factorial/JavaScript/factorial-1.js new file mode 100644 index 0000000000..f94f8ecd87 --- /dev/null +++ b/Task/Factorial/JavaScript/factorial-1.js @@ -0,0 +1,7 @@ +function factorial(n) { + var x = 1; + for (var i = 2; i <= n; i++) { + x *= i; + } + return x; +} diff --git a/Task/Factorial/JavaScript/factorial-2.js b/Task/Factorial/JavaScript/factorial-2.js new file mode 100644 index 0000000000..9035ce0b2e --- /dev/null +++ b/Task/Factorial/JavaScript/factorial-2.js @@ -0,0 +1,3 @@ +function factorial(n) { + return n < 2 ? 1 : n * factorial(n - 1); +} diff --git a/Task/Factorial/JavaScript/factorial-3.js b/Task/Factorial/JavaScript/factorial-3.js new file mode 100644 index 0000000000..9d8ded422e --- /dev/null +++ b/Task/Factorial/JavaScript/factorial-3.js @@ -0,0 +1,8 @@ +function range(n) { + for (let i = 1; i <= n; i++) + yield i; +} + +function factorial(n) { + return [i for (i in range(n))].reduce(function(a, b) a*b, 1); +} diff --git a/Task/Factorial/Joy/factorial.joy b/Task/Factorial/Joy/factorial.joy new file mode 100644 index 0000000000..a65d9122c2 --- /dev/null +++ b/Task/Factorial/Joy/factorial.joy @@ -0,0 +1 @@ +DEFINE factorial == [0 =] [pop 1] [dup 1 - factorial *] ifte. diff --git a/Task/Factorial/Julia/factorial.julia b/Task/Factorial/Julia/factorial.julia new file mode 100644 index 0000000000..41d3c8f9e5 --- /dev/null +++ b/Task/Factorial/Julia/factorial.julia @@ -0,0 +1,16 @@ +# this is just a copy from the combinatorics.jl module of the Julia standard library +function factorial(n::Integer) + if n < 0 + return zero(n) + end + f = one(n) + for i = 2:n + f *= i + end + return f +end + +load("bigint.jl") #use BigInt to avoid overflow for large values of n +n=BigInt(30) +factorial(n) +265252859812191058636308480000000 diff --git a/Task/Factorial/K/factorial-1.k b/Task/Factorial/K/factorial-1.k new file mode 100644 index 0000000000..f00ba1be40 --- /dev/null +++ b/Task/Factorial/K/factorial-1.k @@ -0,0 +1,3 @@ + facti:*/1+!: + facti 5 +120 diff --git a/Task/Factorial/K/factorial-2.k b/Task/Factorial/K/factorial-2.k new file mode 100644 index 0000000000..79e12f3e3a --- /dev/null +++ b/Task/Factorial/K/factorial-2.k @@ -0,0 +1,3 @@ + factr:{:[x>1;x*_f x-1;1]} + factr 6 +720 diff --git a/Task/Factorial/KonsolScript/factorial.konso b/Task/Factorial/KonsolScript/factorial.konso new file mode 100644 index 0000000000..08d0f172f6 --- /dev/null +++ b/Task/Factorial/KonsolScript/factorial.konso @@ -0,0 +1,13 @@ +function factorial(Number n):Number { + Var:Number ret; + if (n >= 0) { + ret = 1; + Var:Number i = 1; + for (i = 1; i <= n; i++) { + ret = ret * i; + } + } else { + ret = 0; + } + return ret; +} diff --git a/Task/Factorial/Lang5/factorial-1.lang5 b/Task/Factorial/Lang5/factorial-1.lang5 new file mode 100644 index 0000000000..ae10faf759 --- /dev/null +++ b/Task/Factorial/Lang5/factorial-1.lang5 @@ -0,0 +1,3 @@ + : fact iota 1 + '* reduce ; + 5 fact +120 diff --git a/Task/Factorial/Lang5/factorial-2.lang5 b/Task/Factorial/Lang5/factorial-2.lang5 new file mode 100644 index 0000000000..0547e94e71 --- /dev/null +++ b/Task/Factorial/Lang5/factorial-2.lang5 @@ -0,0 +1,3 @@ + : fact dup 2 < if else dup 1 - fact * then ; + 5 fact +120 diff --git a/Task/Factorial/Liberty-BASIC/factorial.liberty b/Task/Factorial/Liberty-BASIC/factorial.liberty new file mode 100644 index 0000000000..93c9a79077 --- /dev/null +++ b/Task/Factorial/Liberty-BASIC/factorial.liberty @@ -0,0 +1,29 @@ + for i =0 to 40 + print " FactorialI( "; using( "####", i); ") = "; factorialI( i) + print " FactorialR( "; using( "####", i); ") = "; factorialR( i) + next i + + wait + + function factorialI( n) + if n >1 then + f =1 + For i = 2 To n + f = f * i + Next i + else + f =1 + end if + factorialI =f + end function + + function factorialR( n) + if n <2 then + f =1 + else + f =n *factorialR( n -1) + end if + factorialR =f + end function + + end diff --git a/Task/Factorial/Lisaac/factorial.lisaac b/Task/Factorial/Lisaac/factorial.lisaac new file mode 100644 index 0000000000..3545f5ff7c --- /dev/null +++ b/Task/Factorial/Lisaac/factorial.lisaac @@ -0,0 +1,9 @@ +- factorial x : INTEGER : INTEGER <- ( + + result : INTEGER; + (x <= 1).if { + result := 1; + } else { + result := x * factorial(x - 1); + }; + result +); diff --git a/Task/Factorial/Logo/factorial-1.logo b/Task/Factorial/Logo/factorial-1.logo new file mode 100644 index 0000000000..f81201ac97 --- /dev/null +++ b/Task/Factorial/Logo/factorial-1.logo @@ -0,0 +1,4 @@ +to factorial :n + if :n < 2 [output 1] + output :n * factorial :n-1 +end diff --git a/Task/Factorial/Logo/factorial-2.logo b/Task/Factorial/Logo/factorial-2.logo new file mode 100644 index 0000000000..90fb7728e6 --- /dev/null +++ b/Task/Factorial/Logo/factorial-2.logo @@ -0,0 +1,6 @@ +to factorial :n + make "fact 1 + make "i 1 + repeat :n [make "fact :fact * :i make "i :i + 1] + print :fact +end diff --git a/Task/Factorial/Lua/factorial-1.lua b/Task/Factorial/Lua/factorial-1.lua new file mode 100644 index 0000000000..e9103b655e --- /dev/null +++ b/Task/Factorial/Lua/factorial-1.lua @@ -0,0 +1,3 @@ +function fact(n) + return n > 0 and n * fact(n-1) or 1 +end diff --git a/Task/Factorial/Lua/factorial-2.lua b/Task/Factorial/Lua/factorial-2.lua new file mode 100644 index 0000000000..8b4dee8004 --- /dev/null +++ b/Task/Factorial/Lua/factorial-2.lua @@ -0,0 +1,7 @@ +function fact(n, acc) + acc = acc or 1 + if n == 0 then + return acc + end + return fact(n-1, n*acc) +end diff --git a/Task/Factorial/M4/factorial.m4 b/Task/Factorial/M4/factorial.m4 new file mode 100644 index 0000000000..164be5283f --- /dev/null +++ b/Task/Factorial/M4/factorial.m4 @@ -0,0 +1,3 @@ +define(`factorial',`ifelse(`$1',0,1,`eval($1*factorial(decr($1)))')')dnl +dnl +factorial(5) diff --git a/Task/Factorial/MATLAB/factorial-1.m b/Task/Factorial/MATLAB/factorial-1.m new file mode 100644 index 0000000000..460b7231a1 --- /dev/null +++ b/Task/Factorial/MATLAB/factorial-1.m @@ -0,0 +1 @@ +answer = factorial(N) diff --git a/Task/Factorial/MATLAB/factorial-2.m b/Task/Factorial/MATLAB/factorial-2.m new file mode 100644 index 0000000000..34a2186469 --- /dev/null +++ b/Task/Factorial/MATLAB/factorial-2.m @@ -0,0 +1,7 @@ +function f=fac(n) + if n==0 + f=1; + return + else + f=n*fac(n-1); + end diff --git a/Task/Factorial/MATLAB/factorial-3.m b/Task/Factorial/MATLAB/factorial-3.m new file mode 100644 index 0000000000..6c482bad90 --- /dev/null +++ b/Task/Factorial/MATLAB/factorial-3.m @@ -0,0 +1,5 @@ + function b=factorial(a) + b=1; + for i=1:a + b=b*i; + end diff --git a/Task/Factorial/MAXScript/factorial-1.max b/Task/Factorial/MAXScript/factorial-1.max new file mode 100644 index 0000000000..9fc6bfa2d8 --- /dev/null +++ b/Task/Factorial/MAXScript/factorial-1.max @@ -0,0 +1,10 @@ +fn factorial n = +( + if n == 0 then return 1 + local fac = 1 + for i in 1 to n do + ( + fac *= i + ) + fac +) diff --git a/Task/Factorial/MAXScript/factorial-2.max b/Task/Factorial/MAXScript/factorial-2.max new file mode 100644 index 0000000000..d1e39fba79 --- /dev/null +++ b/Task/Factorial/MAXScript/factorial-2.max @@ -0,0 +1,9 @@ +fn factorial_rec n = +( + local fac = 1 + if n > 1 then + ( + fac = n * factorial_rec (n - 1) + ) + fac +) diff --git a/Task/Factorial/ML-I/factorial-1.ml b/Task/Factorial/ML-I/factorial-1.ml new file mode 100644 index 0000000000..cbaa599e22 --- /dev/null +++ b/Task/Factorial/ML-I/factorial-1.ml @@ -0,0 +1,17 @@ +MCSKIP "WITH" NL +"" Factorial - iterative +MCSKIP MT,<> +MCINS %. +MCDEF FACTORIAL WITHS () +AS +fact(1) is FACTORIAL(1) +fact(2) is FACTORIAL(2) +fact(3) is FACTORIAL(3) +fact(4) is FACTORIAL(4) diff --git a/Task/Factorial/ML-I/factorial-2.ml b/Task/Factorial/ML-I/factorial-2.ml new file mode 100644 index 0000000000..ee127745a3 --- /dev/null +++ b/Task/Factorial/ML-I/factorial-2.ml @@ -0,0 +1,13 @@ +MCSKIP "WITH" NL +"" Factorial - recursive +MCSKIP MT,<> +MCINS %. +MCDEF FACTORIAL WITHS () +AS MCGO L0 +%L1.%%T1.*FACTORIAL(%T1.-1).> +fact(1) is FACTORIAL(1) +fact(2) is FACTORIAL(2) +fact(3) is FACTORIAL(3) +fact(4) is FACTORIAL(4) diff --git a/Task/Factorial/MUMPS/factorial-1.mumps b/Task/Factorial/MUMPS/factorial-1.mumps new file mode 100644 index 0000000000..6a1339671c --- /dev/null +++ b/Task/Factorial/MUMPS/factorial-1.mumps @@ -0,0 +1,13 @@ +factorial(num) New ii,result + If num<0 Quit "Negative number" + If num["." Quit "Not an integer" + Set result=1 For ii=1:1:num Set result=result*ii + Quit result + +Write $$factorial(0) ; 1 +Write $$factorial(1) ; 1 +Write $$factorial(2) ; 2 +Write $$factorial(3) ; 6 +Write $$factorial(10) ; 3628800 +Write $$factorial(-6) ; Negative number +Write $$factorial(3.7) ; Not an integer diff --git a/Task/Factorial/MUMPS/factorial-2.mumps b/Task/Factorial/MUMPS/factorial-2.mumps new file mode 100644 index 0000000000..7a08b65698 --- /dev/null +++ b/Task/Factorial/MUMPS/factorial-2.mumps @@ -0,0 +1,13 @@ +factorial(num) ; + If num<0 Quit "Negative number" + If num["." Quit "Not an integer" + If num<2 Quit 1 + Quit num*$$factorial(num-1) + +Write $$factorial(0) ; 1 +Write $$factorial(1) ; 1 +Write $$factorial(2) ; 2 +Write $$factorial(3) ; 6 +Write $$factorial(10) ; 3628800 +Write $$factorial(-6) ; Negative number +Write $$factorial(3.7) ; Not an integer diff --git a/Task/Factorial/Maple/factorial-1.maple b/Task/Factorial/Maple/factorial-1.maple new file mode 100644 index 0000000000..33c4c0173f --- /dev/null +++ b/Task/Factorial/Maple/factorial-1.maple @@ -0,0 +1,2 @@ +> 5!; + 120 diff --git a/Task/Factorial/Maple/factorial-2.maple b/Task/Factorial/Maple/factorial-2.maple new file mode 100644 index 0000000000..645dc8bebe --- /dev/null +++ b/Task/Factorial/Maple/factorial-2.maple @@ -0,0 +1,7 @@ +RecFact := proc( n :: nonnegint ) + if n = 0 or n = 1 then + 1 + else + n * thisproc( n - 1 ) + end if +end proc: diff --git a/Task/Factorial/Maple/factorial-3.maple b/Task/Factorial/Maple/factorial-3.maple new file mode 100644 index 0000000000..59aa0c9dfe --- /dev/null +++ b/Task/Factorial/Maple/factorial-3.maple @@ -0,0 +1,4 @@ +> seq( RecFact( i ) = i!, i = 0 .. 10 ); +1 = 1, 1 = 1, 2 = 2, 6 = 6, 24 = 24, 120 = 120, 720 = 720, 5040 = 5040, + + 40320 = 40320, 362880 = 362880, 3628800 = 3628800 diff --git a/Task/Factorial/Maple/factorial-4.maple b/Task/Factorial/Maple/factorial-4.maple new file mode 100644 index 0000000000..917a28a0e4 --- /dev/null +++ b/Task/Factorial/Maple/factorial-4.maple @@ -0,0 +1,4 @@ +IterFact := proc( n :: nonnegint ) + local i; + mul( i, i = 2 .. n ) +end proc: diff --git a/Task/Factorial/Maple/factorial-5.maple b/Task/Factorial/Maple/factorial-5.maple new file mode 100644 index 0000000000..b7938f1b93 --- /dev/null +++ b/Task/Factorial/Maple/factorial-5.maple @@ -0,0 +1,4 @@ +> seq( IterFact( i ) = i!, i = 0 .. 10 ); +1 = 1, 1 = 1, 2 = 2, 6 = 6, 24 = 24, 120 = 120, 720 = 720, 5040 = 5040, + + 40320 = 40320, 362880 = 362880, 3628800 = 3628800 diff --git a/Task/Factorial/Mathematica/factorial-1.mathematica b/Task/Factorial/Mathematica/factorial-1.mathematica new file mode 100644 index 0000000000..a55b09e0ed --- /dev/null +++ b/Task/Factorial/Mathematica/factorial-1.mathematica @@ -0,0 +1,2 @@ +factorial[n_Integer] := n*factorial[n-1] +factorial[0] = 1 diff --git a/Task/Factorial/Mathematica/factorial-2.mathematica b/Task/Factorial/Mathematica/factorial-2.mathematica new file mode 100644 index 0000000000..5c2649b671 --- /dev/null +++ b/Task/Factorial/Mathematica/factorial-2.mathematica @@ -0,0 +1,2 @@ +factorial[n_Integer] := + Block[{i, result = 1}, For[i = 1, i <= n, ++i, result *= i]; result] diff --git a/Task/Factorial/Mathematica/factorial-3.mathematica b/Task/Factorial/Mathematica/factorial-3.mathematica new file mode 100644 index 0000000000..05e3a33d29 --- /dev/null +++ b/Task/Factorial/Mathematica/factorial-3.mathematica @@ -0,0 +1 @@ +factorial[n_Integer] := Block[{i}, Times @@ Table[i, {i, n}]] diff --git a/Task/Factorial/Maxima/factorial-1.maxima b/Task/Factorial/Maxima/factorial-1.maxima new file mode 100644 index 0000000000..e749da3428 --- /dev/null +++ b/Task/Factorial/Maxima/factorial-1.maxima @@ -0,0 +1 @@ +n! diff --git a/Task/Factorial/Maxima/factorial-2.maxima b/Task/Factorial/Maxima/factorial-2.maxima new file mode 100644 index 0000000000..5bbf5c92eb --- /dev/null +++ b/Task/Factorial/Maxima/factorial-2.maxima @@ -0,0 +1 @@ +fact(n) := if n < 2 then 1 else n * fact(n - 1)$ diff --git a/Task/Factorial/Maxima/factorial-3.maxima b/Task/Factorial/Maxima/factorial-3.maxima new file mode 100644 index 0000000000..d6ad798946 --- /dev/null +++ b/Task/Factorial/Maxima/factorial-3.maxima @@ -0,0 +1 @@ +fact2(n) := block([r: 1], for i thru n do r: r * i, r)$ diff --git a/Task/Factorial/Mirah/factorial.mirah b/Task/Factorial/Mirah/factorial.mirah new file mode 100644 index 0000000000..8ca2a74959 --- /dev/null +++ b/Task/Factorial/Mirah/factorial.mirah @@ -0,0 +1,8 @@ +def factorial_iterative(n:int) + 2.upto(n-1) do |i| + n *= i + end + n +end + +puts factorial_iterative 10 diff --git a/Task/Factorial/Modula-3/factorial-1.mod3 b/Task/Factorial/Modula-3/factorial-1.mod3 new file mode 100644 index 0000000000..4972a60a60 --- /dev/null +++ b/Task/Factorial/Modula-3/factorial-1.mod3 @@ -0,0 +1,11 @@ +PROCEDURE FactIter(n: CARDINAL): CARDINAL = + VAR + result := n; + counter := n - 1; + + BEGIN + FOR i := counter TO 1 BY -1 DO + result := result * i; + END; + RETURN result; + END FactIter; diff --git a/Task/Factorial/Modula-3/factorial-2.mod3 b/Task/Factorial/Modula-3/factorial-2.mod3 new file mode 100644 index 0000000000..87d1b6b204 --- /dev/null +++ b/Task/Factorial/Modula-3/factorial-2.mod3 @@ -0,0 +1,9 @@ +PROCEDURE FactRec(n: CARDINAL): CARDINAL = + VAR result := 1; + + BEGIN + IF n > 1 THEN + result := n * FactRec(n - 1); + END; + RETURN result; + END FactRec; diff --git a/Task/Factorial/PHP/factorial-1.php b/Task/Factorial/PHP/factorial-1.php new file mode 100644 index 0000000000..ee0b0d0d91 --- /dev/null +++ b/Task/Factorial/PHP/factorial-1.php @@ -0,0 +1,14 @@ += 1; $i--) { + $factorial = $factorial * $i; + } + + return $factorial; +} +?> diff --git a/Task/Factorial/PHP/factorial-2.php b/Task/Factorial/PHP/factorial-2.php new file mode 100644 index 0000000000..de26d6f4ab --- /dev/null +++ b/Task/Factorial/PHP/factorial-2.php @@ -0,0 +1,15 @@ + diff --git a/Task/Factorial/PHP/factorial-3.php b/Task/Factorial/PHP/factorial-3.php new file mode 100644 index 0000000000..878316b7e3 --- /dev/null +++ b/Task/Factorial/PHP/factorial-3.php @@ -0,0 +1,3 @@ + diff --git a/Task/Factorial/PHP/factorial-4.php b/Task/Factorial/PHP/factorial-4.php new file mode 100644 index 0000000000..072c1d95db --- /dev/null +++ b/Task/Factorial/PHP/factorial-4.php @@ -0,0 +1 @@ +gmp_fact($n) diff --git a/Task/Factorial/Perl/factorial-1.pl b/Task/Factorial/Perl/factorial-1.pl new file mode 100644 index 0000000000..ed88223239 --- /dev/null +++ b/Task/Factorial/Perl/factorial-1.pl @@ -0,0 +1,17 @@ +sub factorial +{ + my $n = shift; + my $result = 1; + for (my $i = 1; $i <= $n; ++$i) + { + $result *= $i; + }; + $result; +} + +# using a .. range +sub factorial { + my $r = 1; + $r *= $_ for 1..shift; + $r; +} diff --git a/Task/Factorial/Perl/factorial-2.pl b/Task/Factorial/Perl/factorial-2.pl new file mode 100644 index 0000000000..a985818bb1 --- /dev/null +++ b/Task/Factorial/Perl/factorial-2.pl @@ -0,0 +1,5 @@ +sub factorial +{ + my $n = shift; + ($n == 0)? 1 : $n*factorial($n-1); +} diff --git a/Task/Factorial/Perl/factorial-3.pl b/Task/Factorial/Perl/factorial-3.pl new file mode 100644 index 0000000000..3469a7206a --- /dev/null +++ b/Task/Factorial/Perl/factorial-3.pl @@ -0,0 +1,6 @@ +use List::Util qw(reduce); +sub factorial +{ + my $n = shift; + reduce { $a * $b } 1, 1 .. $n +} diff --git a/Task/Factorial/PicoLisp/factorial-1.l b/Task/Factorial/PicoLisp/factorial-1.l new file mode 100644 index 0000000000..637b2a9c10 --- /dev/null +++ b/Task/Factorial/PicoLisp/factorial-1.l @@ -0,0 +1,4 @@ +(de fact (N) + (if (=0 N) + 1 + (* N (fact (dec N))) ) ) diff --git a/Task/Factorial/PicoLisp/factorial-2.l b/Task/Factorial/PicoLisp/factorial-2.l new file mode 100644 index 0000000000..1e8b545cc6 --- /dev/null +++ b/Task/Factorial/PicoLisp/factorial-2.l @@ -0,0 +1,2 @@ +(de fact (N) + (apply * (range 1 N) ) diff --git a/Task/Factorial/Prolog/factorial-1.pro b/Task/Factorial/Prolog/factorial-1.pro new file mode 100644 index 0000000000..988bbad858 --- /dev/null +++ b/Task/Factorial/Prolog/factorial-1.pro @@ -0,0 +1,2 @@ +fact(X, 1) :- X<2. +fact(X, F) :- Y is X-1, fact(Y,Z), F is Z*X. diff --git a/Task/Factorial/Prolog/factorial-2.pro b/Task/Factorial/Prolog/factorial-2.pro new file mode 100644 index 0000000000..71c8127db5 --- /dev/null +++ b/Task/Factorial/Prolog/factorial-2.pro @@ -0,0 +1,8 @@ +fact(N, NF) :- + fact(1, N, 1, NF). + +fact(X, X, F, F) :- !. +fact(X, N, FX, F) :- + FX1 is FX * X, + X1 is X + 1, + fact(X1, N, FX1, F). diff --git a/Task/Factorial/Prolog/factorial-3.pro b/Task/Factorial/Prolog/factorial-3.pro new file mode 100644 index 0000000000..f15ea94a00 --- /dev/null +++ b/Task/Factorial/Prolog/factorial-3.pro @@ -0,0 +1,13 @@ +% foldl(Pred, Init, List, R). +% +foldl(_Pred, Val, [], Val). +foldl(Pred, Val, [H | T], Res) :- + call(Pred, Val, H, Val1), + foldl(Pred, Val1, T, Res). + +% factorial +p(X, Y, Z) :- Z is X * Y). + +fact(X, F) :- + numlist(2, X, L), + foldl(p, 1, L, F). diff --git a/Task/Factorial/Prolog/factorial-4.pro b/Task/Factorial/Prolog/factorial-4.pro new file mode 100644 index 0000000000..7d62ce017c --- /dev/null +++ b/Task/Factorial/Prolog/factorial-4.pro @@ -0,0 +1,12 @@ +:- use_module(lambda). + +% foldl(Pred, Init, List, R). +% +foldl(_Pred, Val, [], Val). +foldl(Pred, Val, [H | T], Res) :- + call(Pred, Val, H, Val1), + foldl(Pred, Val1, T, Res). + +fact(N, F) :- + numlist(2, N, L), + foldl(\X^Y^Z^(Z is X * Y), 1, L, F). diff --git a/Task/Factorial/Prolog/factorial-5.pro b/Task/Factorial/Prolog/factorial-5.pro new file mode 100644 index 0000000000..7db88cbfed --- /dev/null +++ b/Task/Factorial/Prolog/factorial-5.pro @@ -0,0 +1,14 @@ +:- use_module(lambda). + +fact(N, FN) :- + cont_fact(N, FN, \X^Y^(Y = X)). + +cont_fact(N, F, Pred) :- + ( N = 0 -> + call(Pred, 1, F) + ; N1 is N - 1, + + P = \Z^T^(T is Z * N), + cont_fact(N1, FT, P), + call(Pred, FT, F) + ). diff --git a/Task/Factorial/Python/factorial-1.py b/Task/Factorial/Python/factorial-1.py new file mode 100644 index 0000000000..ff5a65d9e8 --- /dev/null +++ b/Task/Factorial/Python/factorial-1.py @@ -0,0 +1,2 @@ +import math +math.factorial(n) diff --git a/Task/Factorial/Python/factorial-2.py b/Task/Factorial/Python/factorial-2.py new file mode 100644 index 0000000000..45f8c61712 --- /dev/null +++ b/Task/Factorial/Python/factorial-2.py @@ -0,0 +1,5 @@ +def factorial(n): + result = 1 + for i in range(1, n+1): + result *= i + return result diff --git a/Task/Factorial/Python/factorial-3.py b/Task/Factorial/Python/factorial-3.py new file mode 100644 index 0000000000..4c0d73302c --- /dev/null +++ b/Task/Factorial/Python/factorial-3.py @@ -0,0 +1,4 @@ +from operator import mul + +def factorial(n): + return reduce(mul, xrange(1,n+1), 1) diff --git a/Task/Factorial/Python/factorial-4.py b/Task/Factorial/Python/factorial-4.py new file mode 100644 index 0000000000..e440a26db6 --- /dev/null +++ b/Task/Factorial/Python/factorial-4.py @@ -0,0 +1,10 @@ +>>> for i in range(6): + print i, factorial(i) + +0 1 +1 1 +2 2 +3 6 +4 24 +5 120 +>>> diff --git a/Task/Factorial/Python/factorial-5.py b/Task/Factorial/Python/factorial-5.py new file mode 100644 index 0000000000..2e8331bac3 --- /dev/null +++ b/Task/Factorial/Python/factorial-5.py @@ -0,0 +1,27 @@ +from cmath import * + +# Coefficients used by the GNU Scientific Library +g = 7 +p = [0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7] + +def gamma(z): + z = complex(z) + # Reflection formula + if z.real < 0.5: + return pi / (sin(pi*z)*gamma(1-z)) + else: + z -= 1 + x = p[0] + for i in range(1, g+2): + x += p[i]/(z+i) + t = z + g + 0.5 + return sqrt(2*pi) * t**(z+0.5) * exp(-t) * x + +def factorial(n): + return gamma(n+1) + +print "factorial(-0.5)**2=",factorial(-0.5)**2 +for i in range(10): + print "factorial(%d)=%s"%(i,factorial(i)) diff --git a/Task/Factorial/Python/factorial-6.py b/Task/Factorial/Python/factorial-6.py new file mode 100644 index 0000000000..5bf8836512 --- /dev/null +++ b/Task/Factorial/Python/factorial-6.py @@ -0,0 +1,5 @@ +def factorial(n): + z=1 + if n>1: + z=n*factorial(n-1) + return z diff --git a/Task/Factorial/R/factorial-1.r b/Task/Factorial/R/factorial-1.r new file mode 100644 index 0000000000..d8baa8a6d8 --- /dev/null +++ b/Task/Factorial/R/factorial-1.r @@ -0,0 +1,4 @@ +fact <- function(n) { + if ( n <= 1 ) 1 + else n * fact(n-1) +} diff --git a/Task/Factorial/R/factorial-2.r b/Task/Factorial/R/factorial-2.r new file mode 100644 index 0000000000..fc3a2ececd --- /dev/null +++ b/Task/Factorial/R/factorial-2.r @@ -0,0 +1,5 @@ +factIter <- function(n) { + f = 1 + for (i in 2:n) f <- f * i + f +} diff --git a/Task/Factorial/R/factorial-3.r b/Task/Factorial/R/factorial-3.r new file mode 100644 index 0000000000..7de2679c7f --- /dev/null +++ b/Task/Factorial/R/factorial-3.r @@ -0,0 +1 @@ +print(factorial(50)) # 3.041409e+64 diff --git a/Task/Factorial/REXX/factorial-1.rexx b/Task/Factorial/REXX/factorial-1.rexx new file mode 100644 index 0000000000..9d45e4c027 --- /dev/null +++ b/Task/Factorial/REXX/factorial-1.rexx @@ -0,0 +1,21 @@ +/*REXX program computes the factorial of a non-negative integer. */ +numeric digits 100000 /*100k digs: handles N up to 25k.*/ +parse arg n /*get argument from command line. */ +if n='' then call er 'no argument specified' +if arg()>1 | words(n)>1 then call er 'too many arguments specified.' +if \datatype(n,'N') then call er "argument isn't numeric: " n +if \datatype(n,'W') then call er "argument isn't a whole number: " n +if n<0 then call er "argument can't be negative: " n +!=1 /*define factorial product so far.*/ + +/*══════════════════════════════════════where da rubber meets da road──┐*/ + do j=2 to n; !=!*j /*compute the ! the hard way◄───┘*/ + end /*j*/ +/*══════════════════════════════════════════════════════════════════════*/ + +say n'! is ['length(!) "digits]:" /*display # of digits in factorial*/ +say /*add some whitespace to output. */ +say !/1 /*normalize the factorial product.*/ +exit /*stick a fork in it, we're done. */ +/*─────────────────────────────────ER subroutine────────────────────────*/ +er: say; say '***error!***'; say; say arg(1); say; say; exit 13 diff --git a/Task/Factorial/REXX/factorial-2.rexx b/Task/Factorial/REXX/factorial-2.rexx new file mode 100644 index 0000000000..1e2a3c0beb --- /dev/null +++ b/Task/Factorial/REXX/factorial-2.rexx @@ -0,0 +1,53 @@ +/*REXX program computes the factorial of a non-negative integer, and */ +/* automatically adjusts the number of digits to accommodate the answer.*/ +/* ┌────────────────────────────────────────────────────────────────┐ + │ ───── Some factorial lengths ───── │ + │ │ + │ 10 ! = 7 digits │ + │ 20 ! = 19 digits │ + │ 52 ! = 68 digits │ + │ 104 ! = 167 digits │ + │ 208 ! = 394 digits │ + │ 416 ! = 394 digits (8 deck shoe) │ + │ │ + │ 1k ! = 2,568 digits │ + │ 10k ! = 35,660 digits │ + │ 100k ! = 456,574 digits │ + │ │ + │ 1m ! = 5,565,709 digits │ + │ 10m ! = 65,657,060 digits │ + │ 100m ! = 756,570,556 digits │ + │ │ + │ Only one result is shown below for pratical reasons. │ + │ │ + │ This version of the REXX interpreter is essentially limited │ + │ to around 8 million digits, but with some programming │ + │ tricks, it could yield a result up to ≈ 16 million digits. │ + │ │ + │ Also, the Regina REXX interpreter is limited to an exponent │ + │ 9 digits, i.e.: 9.999...999e+999999999 │ + └────────────────────────────────────────────────────────────────┘ */ +numeric digits 99 /*99 digs initially, then expanded*/ +numeric form /*exponentiated #s =scientric form*/ +parse arg n /*get argument from command line. */ +if n='' then call er 'no argument specified' +if arg()>1 | words(n)>1 then call er 'too many arguments specified.' +if \datatype(n,'N') then call er "argument isn't numeric: " n +if \datatype(n,'W') then call er "argument isn't a whole number: " n +if n<0 then call er "argument can't be negative: " n +!=1 /*define factorial product so far.*/ + +/*══════════════════════════════════════where da rubber meets da road──┐*/ + do j=2 to n; !=!*j /*compute the ! the hard way◄───┘*/ + if pos('E',!)==0 then iterate /*is ! in exponential notation? */ + parse var ! 'E' digs /*pick off the factorial exponent.*/ + numeric digits digs+digs%10 /* and incease it by ten percent.*/ + end /*j*/ +/*══════════════════════════════════════════════════════════════════════*/ + +say n'! is ['length(!) "digits]:" /*display # of digits in factorial*/ +say /*add some whitespace to output. */ +say !/1 /*normalize the factorial product.*/ +exit /*stick a fork in it, we're done. */ +/*─────────────────────────────────ER subroutine────────────────────────*/ +er: say; say '***error!***'; say; say arg(1); say; say; exit 13 diff --git a/Task/Factorial/REXX/factorial-3.rexx b/Task/Factorial/REXX/factorial-3.rexx new file mode 100644 index 0000000000..7957839124 --- /dev/null +++ b/Task/Factorial/REXX/factorial-3.rexx @@ -0,0 +1,34 @@ +/*REXX program computes the factorial of a non-negative integer, and */ +/* automatically adjusts the number of digits to accommodate the answer.*/ + +/*This version allows for faster multiplying of #s (no trailing zeros).*/ +numeric digits 100 /*start with 100 digits. */ +numeric form /*indicates we want scientric form*/ +parse arg n .; if n=='' then n=0 /*get argument from command line. */ + +/*════════════════════════════════════where the rubber meets the road. */ +!=1 /*define factorial product so far.*/ + do j=2 to n /*compute factorial the hard way. */ + o!=! /*save old ! in case of overflow. */ + !=!*j /*multiple the factorial with J, */ + /* and strip all trailing zeroes. */ + if pos('E',!)\==0 then do /*is ! in exponential notation? */ + d=digits() /*D is current digs*/ + numeric digits d+d%10 /*add ten percent. */ + !=o!*j /*recalculate for the lost digit. */ + end + !=strip(!,'tail-end',0) /*kill some electrons, strip 0's. */ + end /*(above) only 1st letter is used.*/ + /*let's perform some housekeeping.*/ +if pos('E',!)\==0 then !=strip(!/1,"T",0) /*! in exponential notation?*/ +v=5; tz=0 + do while v<=n /*calculate # of trailing zeroes. */ + tz=tz+n%v + v=v*5 + end /*while v≤n*/ +!=! || copies(0,tz) /*add some water to rehydrate !. */ +/*══════════════════════════════════════════════════════════════════════*/ + +say n'! is ['length(!) "digits]:" /*display # of digits in factorial*/ +say /*add some whitespace to output, */ +say ! /* ... and display the ! product.*/ diff --git a/Task/Factorial/Racket/factorial-1.rkt b/Task/Factorial/Racket/factorial-1.rkt new file mode 100644 index 0000000000..81fc7f4703 --- /dev/null +++ b/Task/Factorial/Racket/factorial-1.rkt @@ -0,0 +1,4 @@ +(define (factorial n) + (if (= 0 n) + 1 + (* n (factorial (- n 1))))) diff --git a/Task/Factorial/Racket/factorial-2.rkt b/Task/Factorial/Racket/factorial-2.rkt new file mode 100644 index 0000000000..006508d94b --- /dev/null +++ b/Task/Factorial/Racket/factorial-2.rkt @@ -0,0 +1,6 @@ +(define (factorial n) + (define (fact n acc) + (if (= 0 n) + acc + (fact (- n 1) (* n acc)))) + (fact n 1)) diff --git a/Task/Factorial/Ruby/factorial.rb b/Task/Factorial/Ruby/factorial.rb new file mode 100644 index 0000000000..17350ea554 --- /dev/null +++ b/Task/Factorial/Ruby/factorial.rb @@ -0,0 +1,39 @@ +# Recursive +def factorial_recursive(n) + n.zero? ? 1 : n * factorial_recursive(n - 1) +end + +# Tail-recursive +def factorial_tail_recursive(n, prod = 1) + n.zero? ? prod : factorial_tail_recursive(n - 1, prod * n) +end + +# Iterative with Range#each +def factorial_iterative(n) + (2 .. n - 1).each {|i| n *= i} + n +end + +# Iterative with Range#inject +def factorial_inject(n) + (1..n).inject {|prod, i| prod * i} +end + +# Iterative with Range#reduce, requires Ruby 1.8.7 +def factorial_reduce(n) + (1..n).reduce(:*) +end + + +require 'benchmark' + +n = 400 +m = 10000 + +Benchmark.bm(16) do |b| + b.report('recursive:') {m.times {factorial_recursive(n)}} + b.report('tail recursive:') {m.times {factorial_tail_recursive(n)}} + b.report('iterative:') {m.times {factorial_iterative(n)}} + b.report('inject:') {m.times {factorial_inject(n)}} + b.report('reduce:') {m.times {factorial_reduce(n)}} +end diff --git a/Task/Factorial/Sather/factorial.sa b/Task/Factorial/Sather/factorial.sa new file mode 100644 index 0000000000..3a69b9f1f2 --- /dev/null +++ b/Task/Factorial/Sather/factorial.sa @@ -0,0 +1,20 @@ +class MAIN is + + -- recursive + fact(a: INTI):INTI is + if a < 1.inti then return 1.inti; end; + return a * fact(a - 1.inti); + end; + + -- iterative + fact_iter(a:INTI):INTI is + s ::= 1.inti; + loop s := s * a.downto!(1.inti); end; + return s; + end; + + main is + a :INTI := 10.inti; + #OUT + fact(a) + " = " + fact_iter(a) + "\n"; + end; +end; diff --git a/Task/Factorial/Scala/factorial-1.scala b/Task/Factorial/Scala/factorial-1.scala new file mode 100644 index 0000000000..d2c66b7055 --- /dev/null +++ b/Task/Factorial/Scala/factorial-1.scala @@ -0,0 +1,6 @@ +def factorial(n: Int)={ + var res = 1 + for(i <- 1 to n) + res *=i + res +} diff --git a/Task/Factorial/Scala/factorial-2.scala b/Task/Factorial/Scala/factorial-2.scala new file mode 100644 index 0000000000..21f31bb7f8 --- /dev/null +++ b/Task/Factorial/Scala/factorial-2.scala @@ -0,0 +1 @@ +def factorial(n: Int) = if(n == 0) 1 else n * factorial(n-1) diff --git a/Task/Factorial/Scala/factorial-3.scala b/Task/Factorial/Scala/factorial-3.scala new file mode 100644 index 0000000000..cf4ecb16c2 --- /dev/null +++ b/Task/Factorial/Scala/factorial-3.scala @@ -0,0 +1 @@ +def factorial(n: Int) = (2 to n).foldLeft(1)(_*_) diff --git a/Task/Factorial/Scala/factorial-4.scala b/Task/Factorial/Scala/factorial-4.scala new file mode 100644 index 0000000000..0229f8c3e2 --- /dev/null +++ b/Task/Factorial/Scala/factorial-4.scala @@ -0,0 +1,5 @@ +// Note use of big integer support in this version + +implicit def IntToFac(i : Int) = new { + def ! = (2 to i).foldLeft(BigInt(1))(_*_) +} diff --git a/Task/Factorial/Scala/factorial-5.scala b/Task/Factorial/Scala/factorial-5.scala new file mode 100644 index 0000000000..7092a52751 --- /dev/null +++ b/Task/Factorial/Scala/factorial-5.scala @@ -0,0 +1,10 @@ +scala> implicit def IntToFac(i : Int) = new { + | def ! = (2 to i).foldLeft(BigInt(1))(_*_) + | } +IntToFac: (i: Int)java.lang.Object{def !: scala.math.BigInt} + +scala> 20! +res0: scala.math.BigInt = 2432902008176640000 + +scala> 100! +res1: scala.math.BigInt = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 diff --git a/Task/Factorial/Scheme/factorial-1.ss b/Task/Factorial/Scheme/factorial-1.ss new file mode 100644 index 0000000000..a8dd066343 --- /dev/null +++ b/Task/Factorial/Scheme/factorial-1.ss @@ -0,0 +1,4 @@ +(define (factorial n) + (if (<= n 0) + 1 + (* n (factorial (- n 1))))) diff --git a/Task/Factorial/Scheme/factorial-2.ss b/Task/Factorial/Scheme/factorial-2.ss new file mode 100644 index 0000000000..065b372525 --- /dev/null +++ b/Task/Factorial/Scheme/factorial-2.ss @@ -0,0 +1,6 @@ +(define (factorial n) + (let loop ((i 1) + (accum 1)) + (if (> i n) + accum + (loop (+ i 1) (* accum i))))) diff --git a/Task/Factorial/Scheme/factorial-3.ss b/Task/Factorial/Scheme/factorial-3.ss new file mode 100644 index 0000000000..ca482efb19 --- /dev/null +++ b/Task/Factorial/Scheme/factorial-3.ss @@ -0,0 +1,4 @@ +(define (factorial n) + (do ((i 1 (+ i 1)) + (accum 1 (* accum i))) + ((> i n) accum))) diff --git a/Task/Factorial/Scheme/factorial-4.ss b/Task/Factorial/Scheme/factorial-4.ss new file mode 100644 index 0000000000..3e179ef9e9 --- /dev/null +++ b/Task/Factorial/Scheme/factorial-4.ss @@ -0,0 +1,23 @@ +;Using a generator and a function that apply generated values to a function taking two arguments + +;A generator knows commands 'next? and 'next +(define (range a b) +(let ((k a)) +(lambda (msg) +(cond + ((eq? msg 'next?) (<= k b)) + ((eq? msg 'next) + (cond + ((<= k b) (set! k (+ k 1)) (- k 1)) + (else 'nothing-left))))))) + +;Similar to List.fold_left in OCaml, but uses a generator +(define (fold fun a gen) +(let aux ((a a)) + (if (gen 'next?) (aux (fun a (gen 'next))) a))) + +;Now the factorial function +(define (factorial n) (fold * 1 (range 1 n))) + +(factorial 8) +;40320 diff --git a/Task/Factorial/Smalltalk/factorial-1.st b/Task/Factorial/Smalltalk/factorial-1.st new file mode 100644 index 0000000000..ad16a599d1 --- /dev/null +++ b/Task/Factorial/Smalltalk/factorial-1.st @@ -0,0 +1,13 @@ +Number extend [ + my_factorial [ + (self < 2) ifTrue: [ ^1 ] + ifFalse: [ |c| + c := OrderedCollection new. + 2 to: self do: [ :i | c add: i ]. + ^ (c fold: [ :a :b | a * b ] ) + ] + ] +]. + +7 factorial printNl. +7 my_factorial printNl. diff --git a/Task/Factorial/Smalltalk/factorial-2.st b/Task/Factorial/Smalltalk/factorial-2.st new file mode 100644 index 0000000000..a91d22ab71 --- /dev/null +++ b/Task/Factorial/Smalltalk/factorial-2.st @@ -0,0 +1,7 @@ +Number extend [ + my_factorial [ + self < 0 ifTrue: [ self error: 'my_factorial is defined for natural numbers' ]. + self isZero ifTrue: [ ^1 ]. + ^self * ((self - 1) my_factorial) + ] +]. diff --git a/Task/Factorial/Smalltalk/factorial-3.st b/Task/Factorial/Smalltalk/factorial-3.st new file mode 100644 index 0000000000..a8fe8fe876 --- /dev/null +++ b/Task/Factorial/Smalltalk/factorial-3.st @@ -0,0 +1,10 @@ + |fac| + + fac := [:n | + n < 0 ifTrue: [ self error: 'fac is defined for natural numbers' ]. + n <= 1 + ifTrue: [ 1 ] + ifFalse: [ n * (fac value:(n - 1)) ] + ]. + fac value:1000. +]. diff --git a/Task/Factorial/Smalltalk/factorial-4.st b/Task/Factorial/Smalltalk/factorial-4.st new file mode 100644 index 0000000000..01038d5720 --- /dev/null +++ b/Task/Factorial/Smalltalk/factorial-4.st @@ -0,0 +1,4 @@ +| fac | +fac := [ :n | (1 to: n) inject: 1 into: [ :prod :next | prod * next ] ]. +fac value: 10. +"3628800" diff --git a/Task/Factorial/Tcl/factorial-1.tcl b/Task/Factorial/Tcl/factorial-1.tcl new file mode 100644 index 0000000000..8220088fdf --- /dev/null +++ b/Task/Factorial/Tcl/factorial-1.tcl @@ -0,0 +1,6 @@ +proc ifact n { + for {set i $n; set sum 1} {$i >= 2} {incr i -1} { + set sum [expr {$sum * $i}] + } + return $sum +} diff --git a/Task/Factorial/Tcl/factorial-2.tcl b/Task/Factorial/Tcl/factorial-2.tcl new file mode 100644 index 0000000000..40cc360692 --- /dev/null +++ b/Task/Factorial/Tcl/factorial-2.tcl @@ -0,0 +1,3 @@ +proc rfact n { + expr {$n < 2 ? 1 : $n * [rfact [incr n -1]]} +} diff --git a/Task/Factorial/Tcl/factorial-3.tcl b/Task/Factorial/Tcl/factorial-3.tcl new file mode 100644 index 0000000000..e25b3f18c7 --- /dev/null +++ b/Task/Factorial/Tcl/factorial-3.tcl @@ -0,0 +1 @@ +proc tcl::mathfunc::fact n {expr {$n < 2? 1: $n*fact($n-1)}} diff --git a/Task/Factorial/Tcl/factorial-4.tcl b/Task/Factorial/Tcl/factorial-4.tcl new file mode 100644 index 0000000000..9a9a02de85 --- /dev/null +++ b/Task/Factorial/Tcl/factorial-4.tcl @@ -0,0 +1,17 @@ +proc ifact_caching n { + global fact_cache + if { ! [info exists fact_cache]} { + set fact_cache {1 1} + } + if {$n < [llength $fact_cache]} { + return [lindex $fact_cache $n] + } + set i [expr {[llength $fact_cache] - 1}] + set sum [lindex $fact_cache $i] + while {$i < $n} { + incr i + set sum [expr {$sum * $i}] + lappend fact_cache $sum + } + return $sum +} diff --git a/Task/Factorial/Tcl/factorial-5.tcl b/Task/Factorial/Tcl/factorial-5.tcl new file mode 100644 index 0000000000..ecdfbe5752 --- /dev/null +++ b/Task/Factorial/Tcl/factorial-5.tcl @@ -0,0 +1,11 @@ +puts [ifact 30] +puts [rfact 30] +puts [ifact_caching 30] + +set n 400 +set iterations 10000 +puts "calculate $n factorial $iterations times" +puts "ifact: [time {ifact $n} $iterations]" +puts "rfact: [time {rfact $n} $iterations]" +# for the caching proc, reset the cache between each iteration so as not to skew the results +puts "ifact_caching: [time {ifact_caching $n; unset -nocomplain fact_cache} $iterations]" diff --git a/Task/Factorial/Tcl/factorial-6.tcl b/Task/Factorial/Tcl/factorial-6.tcl new file mode 100644 index 0000000000..46e5e0fcab --- /dev/null +++ b/Task/Factorial/Tcl/factorial-6.tcl @@ -0,0 +1,5 @@ +package require math::special + +proc gfact n { + expr {round([::math::special::Gamma [expr {$n+1}]])} +} diff --git a/Task/Factors-of-a-Mersenne-number/0DESCRIPTION b/Task/Factors-of-a-Mersenne-number/0DESCRIPTION new file mode 100644 index 0000000000..5f89db5f47 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/0DESCRIPTION @@ -0,0 +1,17 @@ +A Mersenne number is a number in the form of 2P-1. If P is prime, the Mersenne number may be a Mersenne prime (if P is not prime, the Mersenne number is also not prime). In the search for Mersenne prime numbers it is advantageous to eliminate exponents by finding a small factor before starting a, potentially lengthy, [[Lucas-Lehmer test]]. There are very efficient algorithms for determining if a number divides 2P-1 (or equivalently, if 2P mod (the number) = 1). Some languages already have built-in implementations of this exponent-and-mod operation (called ''modPow'' or similar). The following is how to implement this ''modPow'' yourself: + +For example, let's compute 223 mod 47. Convert the exponent 23 to binary, you get 10111. Starting with square = 1, repeatedly square it. Remove the top bit of the exponent, and if it's 1 multiply square by the base of the exponentiation (2), then compute square modulo 47. Use the result of the modulo from the last step as the initial value of square in the next step: + Remove Optional + square top bit multiply by 2 mod 47 + ------------ ------- ------------- ------ + 1*1 = 1 1 0111 1*2 = 2 2 + 2*2 = 4 0 111 no 4 + 4*4 = 16 1 11 16*2 = 32 32 + 32*32 = 1024 1 1 1024*2 = 2048 27 + 27*27 = 729 1 729*2 = 1458 1 + +Since 223 mod 47 = 1, 47 is a factor of 2P-1. (To see this, subtract 1 from both sides: 223-1 = 0 mod 47.) Since we've shown that 47 is a factor, 223-1 is not prime. Further properties of Mersenne numbers allow us to refine the process even more. Any factor q of 2P-1 must be of the form 2kP+1, k being a positive integer or zero. Furthermore, q must be 1 or 7 mod 8. Finally any potential factor q must be [[Primality by Trial Division|prime]]. As in other trial division algorithms, the algorithm stops when 2kP+1 > sqrt(N). + +These primality tests only work on Mersenne numbers where P is prime. For example, M4=15 yields no factors using these techniques, but factors into 3 and 5, neither of which fit 2kP+1. + +'''Task:''' Using the above method find a factor of 2929-1 (aka M929) diff --git a/Task/Factors-of-a-Mersenne-number/1META.yaml b/Task/Factors-of-a-Mersenne-number/1META.yaml new file mode 100644 index 0000000000..fdeafd347e --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Arithmetic operations +note: Prime Numbers diff --git a/Task/Factors-of-a-Mersenne-number/ALGOL-68/factors-of-a-mersenne-number.alg b/Task/Factors-of-a-Mersenne-number/ALGOL-68/factors-of-a-mersenne-number.alg new file mode 100644 index 0000000000..9f30ef2f6f --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/ALGOL-68/factors-of-a-mersenne-number.alg @@ -0,0 +1,51 @@ +MODE ISPRIMEINT = INT; +PR READ "prelude/is_prime.a68" PR; + +MODE POWMODSTRUCT = INT; +PR READ "prelude/pow_mod.a68" PR; + +PROC m factor = (INT p)INT:BEGIN + INT m factor; + INT max k, msb, n, q; + + FOR i FROM bits width - 2 BY -1 TO 0 WHILE ( BIN p SHR i AND 2r1 ) = 2r0 DO + msb := i + OD; + + max k := ENTIER sqrt(max int) OVER p; # limit for k to prevent overflow of max int # + FOR k FROM 1 TO max k DO + q := 2*p*k + 1; + IF NOT is prime(q) THEN + SKIP + ELIF q MOD 8 /= 1 AND q MOD 8 /= 7 THEN + SKIP + ELSE + n := pow mod(2,p,q); + IF n = 1 THEN + m factor := q; + return + FI + FI + OD; + m factor := 0; + return: + m factor +END; + +BEGIN + + INT exponent, factor; + print("Enter exponent of Mersenne number:"); + read(exponent); + IF NOT is prime(exponent) THEN + print(("Exponent is not prime: ", exponent, new line)) + ELSE + factor := m factor(exponent); + IF factor = 0 THEN + print(("No factor found for M", exponent, new line)) + ELSE + print(("M", exponent, " has a factor: ", factor, new line)) + FI + FI + +END diff --git a/Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.ada b/Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.ada new file mode 100644 index 0000000000..3a8772ee0c --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Ada/factors-of-a-mersenne-number.ada @@ -0,0 +1,68 @@ +with Ada.Text_IO; +-- reuse Is_Prime from [[Primality by Trial Division]] +with Is_Prime; + +procedure Mersenne is + function Is_Set (Number : Natural; Bit : Positive) return Boolean is + begin + return Number / 2 ** (Bit - 1) mod 2 = 1; + end Is_Set; + + function Get_Max_Bit (Number : Natural) return Natural is + Test : Natural := 0; + begin + while 2 ** Test <= Number loop + Test := Test + 1; + end loop; + return Test; + end Get_Max_Bit; + + function Modular_Power (Base, Exponent, Modulus : Positive) return Natural is + Maximum_Bit : constant Natural := Get_Max_Bit (Exponent); + Square : Natural := 1; + begin + for Bit in reverse 1 .. Maximum_Bit loop + Square := Square ** 2; + if Is_Set (Exponent, Bit) then + Square := Square * Base; + end if; + Square := Square mod Modulus; + end loop; + return Square; + end Modular_Power; + + Not_A_Prime_Exponent : exception; + + function Get_Factor (Exponent : Positive) return Natural is + Factor : Positive; + begin + if not Is_Prime (Exponent) then + raise Not_A_Prime_Exponent; + end if; + for K in 1 .. 16384 / Exponent loop + Factor := 2 * K * Exponent + 1; + if Factor mod 8 = 1 or else Factor mod 8 = 7 then + if Is_Prime (Factor) and then Modular_Power (2, Exponent, Factor) = 1 then + return Factor; + end if; + end if; + end loop; + return 0; + end Get_Factor; + + To_Test : constant Positive := 929; + Factor : Natural; +begin + Ada.Text_IO.Put ("2 **" & Integer'Image (To_Test) & " - 1 "); + begin + Factor := Get_Factor (To_Test); + if Factor = 0 then + Ada.Text_IO.Put_Line ("is prime."); + else + Ada.Text_IO.Put_Line ("has factor" & Integer'Image (Factor)); + end if; + exception + when Not_A_Prime_Exponent => + Ada.Text_IO.Put_Line ("is not a Mersenne number"); + end; +end Mersenne; diff --git a/Task/Factors-of-a-Mersenne-number/AutoHotkey/factors-of-a-mersenne-number.ahk b/Task/Factors-of-a-Mersenne-number/AutoHotkey/factors-of-a-mersenne-number.ahk new file mode 100644 index 0000000000..f4eba05ecb --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/AutoHotkey/factors-of-a-mersenne-number.ahk @@ -0,0 +1,56 @@ +MsgBox % MFact(27) ;-1: 27 is not prime +MsgBox % MFact(2) ; 0 +MsgBox % MFact(3) ; 0 +MsgBox % MFact(5) ; 0 +MsgBox % MFact(7) ; 0 +MsgBox % MFact(11) ; 23 +MsgBox % MFact(13) ; 0 +MsgBox % MFact(17) ; 0 +MsgBox % MFact(19) ; 0 +MsgBox % MFact(23) ; 47 +MsgBox % MFact(29) ; 233 +MsgBox % MFact(31) ; 0 +MsgBox % MFact(37) ; 223 +MsgBox % MFact(41) ; 13367 +MsgBox % MFact(43) ; 431 +MsgBox % MFact(47) ; 2351 +MsgBox % MFact(53) ; 6361 +MsgBox % MFact(929) ; 13007 + +MFact(p) { ; blank if 2**p-1 can be prime, otherwise a prime divisor < 2**32 + If !IsPrime32(p) + Return -1 ; Error (p must be prime) + Loop % 2.0**(p<64 ? p/2-1 : 31)/p ; test prime divisors < 2**32, up to sqrt(2**p-1) + If (((q:=2*p*A_Index+1)&7 = 1 || q&7 = 7) && IsPrime32(q) && PowMod(2,p,q)=1) + Return q + Return 0 +} + +IsPrime32(n) { ; n < 2**32 + If n in 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 + Return 1 + If (!(n&1)||!mod(n,3)||!mod(n,5)||!mod(n,7)||!mod(n,11)||!mod(n,13)||!mod(n,17)||!mod(n,19)) + Return 0 + n1 := d := n-1, s := 0 + While !(d&1) + d>>=1, s++ + Loop 3 { + x := PowMod( A_Index=1 ? 2 : A_Index=2 ? 7 : 61, d, n) + If (x=1 || x=n1) + Continue + Loop % s-1 + If (1 = x:=PowMod(x,2,n)) + Return 0 + Else If (x = n1) + Break + IfLess x,%n1%, Return 0 + } + Return 1 +} + +PowMod(x,n,m) { ; x**n mod m + y := 1, i := n, z := x + While i>0 + y := i&1 ? mod(y*z,m) : y, z := mod(z*z,m), i >>= 1 + Return y +} diff --git a/Task/Factors-of-a-Mersenne-number/BBC-BASIC/factors-of-a-mersenne-number.bbc b/Task/Factors-of-a-Mersenne-number/BBC-BASIC/factors-of-a-mersenne-number.bbc new file mode 100644 index 0000000000..a2f7270f45 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/BBC-BASIC/factors-of-a-mersenne-number.bbc @@ -0,0 +1,37 @@ + PRINT "A factor of M929 is "; FNmersenne_factor(929) + PRINT "A factor of M937 is "; FNmersenne_factor(937) + END + + DEF FNmersenne_factor(P%) + LOCAL K%, Q% + IF NOT FNisprime(P%) THEN = -1 + FOR K% = 1 TO 1000000 + Q% = 2*K%*P% + 1 + IF (Q% AND 7) = 1 OR (Q% AND 7) = 7 THEN + IF FNisprime(Q%) IF FNmodpow(2, P%, Q%) = 1 THEN = Q% + ENDIF + NEXT K% + = 0 + + DEF FNisprime(N%) + LOCAL D% + IF N% MOD 2=0 THEN = (N% = 2) + IF N% MOD 3=0 THEN = (N% = 3) + D% = 5 + WHILE D% * D% <= N% + IF N% MOD D% = 0 THEN = FALSE + D% += 2 + IF N% MOD D% = 0 THEN = FALSE + D% += 4 + ENDWHILE + = TRUE + + DEF FNmodpow(X%, N%, M%) + LOCAL I%, Y%, Z% + I% = N% : Y% = 1 : Z% = X% + WHILE I% + IF I% AND 1 THEN Y% = (Y% * Z%) MOD M% + Z% = (Z% * Z%) MOD M% + I% = I% >>> 1 + ENDWHILE + = Y% diff --git a/Task/Factors-of-a-Mersenne-number/C-sharp/factors-of-a-mersenne-number.cs b/Task/Factors-of-a-Mersenne-number/C-sharp/factors-of-a-mersenne-number.cs new file mode 100644 index 0000000000..d5d65d1d81 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/C-sharp/factors-of-a-mersenne-number.cs @@ -0,0 +1,46 @@ +using System; + +namespace prog +{ + class MainClass + { + public static void Main (string[] args) + { + int q = 929; + if ( !isPrime(q) ) return; + int r = q; + while( r > 0 ) + r <<= 1; + int d = 2 * q + 1; + do + { + int i = 1; + for( int p=r; p!=0; p<<=1 ) + { + i = (i*i) % d; + if (p < 0) i *= 2; + if (i > d) i -= d; + } + if (i != 1) d += 2 * q; else break; + } + while(true); + + Console.WriteLine("2^"+q+"-1 = 0 (mod "+d+")"); + } + + static bool isPrime(int n) + { + if ( n % 2 == 0 ) return n == 2; + if ( n % 3 == 0 ) return n == 3; + int d = 5; + while( d*d <= n ) + { + if ( n % d == 0 ) return false; + d += 2; + if ( n % d == 0 ) return false; + d += 4; + } + return true; + } + } +} diff --git a/Task/Factors-of-a-Mersenne-number/C/factors-of-a-mersenne-number.c b/Task/Factors-of-a-Mersenne-number/C/factors-of-a-mersenne-number.c new file mode 100644 index 0000000000..3705c02064 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/C/factors-of-a-mersenne-number.c @@ -0,0 +1,24 @@ +int isPrime(int n){ + if (n%2==0) return n==2; + if (n%3==0) return n==3; + int d=5; + while(d*d<=n){ + if(n%d==0) return 0; + d+=2; + if(n%d==0) return 0; + d+=4;} + return 1;} + +main() {int i,d,p,r,q=929; + if (!isPrime(q)) return 1; + r=q; + while(r>0) r<<=1; + d=2*q+1; + do { for(p=r, i= 1; p; p<<= 1){ + i=((long long)i * i) % d; + if (p < 0) i *= 2; + if (i > d) i -= d;} + if (i != 1) d += 2*q; + else break; + } while(1); + printf("2^%d - 1 = 0 (mod %d)\n", q, d);} diff --git a/Task/Factors-of-a-Mersenne-number/CoffeeScript/factors-of-a-mersenne-number.coffee b/Task/Factors-of-a-Mersenne-number/CoffeeScript/factors-of-a-mersenne-number.coffee new file mode 100644 index 0000000000..32796d2cfb --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/CoffeeScript/factors-of-a-mersenne-number.coffee @@ -0,0 +1,27 @@ +mersenneFactor = (p) -> + limit = Math.sqrt(Math.pow(2,p) - 1) + k = 1 + while (2*k*p - 1) < limit + q = 2*k*p + 1 + if isPrime(q) and (q % 8 == 1 or q % 8 == 7) and trialFactor(2,p,q) + return q + k++ + return null + +isPrime = (value) -> + for i in [2...value] + return false if value % i == 0 + return true if value % i != 0 + +trialFactor = (base, exp, mod) -> + square = 1 + bits = exp.toString(2).split('') + for bit in bits + square = Math.pow(square, 2) * (if +bit is 1 then base else 1) % mod + return square == 1 + +checkMersenne = (p) -> + factor = mersenneFactor(+p) + console.log "M#{p} = 2^#{p}-1 is #{if factor is null then "prime" else "composite with #{factor}"}" + +checkMersenne(prime) for prime in ["2","3","4","5","7","11","13","17","19","23","29","31","37","41","43","47","53","929"] diff --git a/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-1.lisp b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-1.lisp new file mode 100644 index 0000000000..1e9a6a8882 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-1.lisp @@ -0,0 +1,7 @@ +(defun mersenne-fac (p &aux (m (1- (expt 2 p)))) + (loop for k from 1 + for n = (1+ (* 2 k p)) + until (zerop (mod m n)) + finally (return n))) + +(print (mersenne-fac 929)) diff --git a/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-2.lisp b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-2.lisp new file mode 100644 index 0000000000..d233bc737b --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-2.lisp @@ -0,0 +1,14 @@ +(defun primep (a) + (cond ((= a 2) T) + ((or (<= a 1) (= (mod a 2) 0)) nil) + ((loop for i from 3 to (sqrt a) by 2 do + (if (= (mod a i) 0) + (return nil))) nil) + (T T))) + +(defun primep (n) + "Is N prime?" + (and (> n 1) + (or (= n 2) (oddp n)) + (loop for i from 3 to (isqrt n) by 2 + never (zerop (rem n i))))) diff --git a/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-3.lisp b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-3.lisp new file mode 100644 index 0000000000..cc1378bc93 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Common-Lisp/factors-of-a-mersenne-number-3.lisp @@ -0,0 +1,19 @@ +(defun modulo-power (base power modulus) + (loop with square = 1 + for bit across (format nil "~b" power) + do (setf square (* square square)) + when (char= bit #\1) do (setf square (* square base)) + do (setf square (mod square modulus)) + finally (return square))) + +(defun mersenne-prime-p (power) + (do* ((N (1- (expt 2 power))) + (sqN (isqrt N)) + (k 1 (1+ k)) + (q (1+ (* 2 power k)) (1+ (* 2 power k))) + (m (mod q 8) (mod q 8))) + ((> q sqN) (values t)) + (when (and (or (= 1 m) (= 7 m)) + (primep q) + (= 1 (modulo-power 2 power q))) + (return (values nil q))))) diff --git a/Task/Factors-of-a-Mersenne-number/D/factors-of-a-mersenne-number.d b/Task/Factors-of-a-Mersenne-number/D/factors-of-a-mersenne-number.d new file mode 100644 index 0000000000..2846eeea76 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/D/factors-of-a-mersenne-number.d @@ -0,0 +1,36 @@ +import std.stdio, std.math, std.traits; + +ulong mersenneFactor(in ulong p) pure nothrow { + static bool isPrime(T)(in T n) pure nothrow { + if (n < 2 || n % 2 == 0) + return n == 2; + for (Unqual!T i = 3; i ^^ 2 <= n; i += 2) + if (n % i == 0) + return false; + return true; + } + + static long modPow(in long cb,in long ce,in long m) pure nothrow { + long b = cb; + long result = 1; + for (long e = ce; e > 0; e >>= 1) { + if ((e & 1) == 1) + result = (result * b) % m; + b = (b ^^ 2) % m; + } + return result; + } + + immutable ulong limit = cast(ulong)sqrt(cast(real)(2 ^^ p - 1)); + for (ulong k = 1; (2 * p * k - 1) < limit; k++) { + immutable ulong q = 2 * p * k + 1; + if (isPrime(q) && (q % 8 == 1 || q % 8 == 7) && + modPow(2, p, q) == 1) + return q; + } + return 0; +} + +void main() { + writefln("Factor of M929: %s", mersenneFactor(929)); +} diff --git a/Task/Factors-of-a-Mersenne-number/Forth/factors-of-a-mersenne-number.fth b/Task/Factors-of-a-Mersenne-number/Forth/factors-of-a-mersenne-number.fth new file mode 100644 index 0000000000..79feec96bf --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Forth/factors-of-a-mersenne-number.fth @@ -0,0 +1,33 @@ +: prime? ( odd -- ? ) + 3 + begin 2dup dup * >= + while 2dup mod 0= + if 2drop false exit + then 2 + + repeat 2drop true ; + +: 2-exp-mod { e m -- 2^e mod m } + 1 + 0 30 do + e 1 i lshift >= if + dup * + e 1 i lshift and if 2* then + m mod + then + -1 +loop ; + +: factor-mersenne ( exponent -- factor ) + 16384 over / dup 2 < abort" Exponent too large!" + 1 do + dup i * 2* 1+ ( q ) + dup prime? if + dup 7 and dup 1 = swap 7 = or if + 2dup 2-exp-mod 1 = if + nip unloop exit + then + then + then drop + loop drop 0 ; + + 929 factor-mersenne . \ 13007 +4423 factor-mersenne . \ 0 diff --git a/Task/Factors-of-a-Mersenne-number/Fortran/factors-of-a-mersenne-number.f b/Task/Factors-of-a-Mersenne-number/Fortran/factors-of-a-mersenne-number.f new file mode 100644 index 0000000000..334db9efdc --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Fortran/factors-of-a-mersenne-number.f @@ -0,0 +1,52 @@ +PROGRAM EXAMPLE + IMPLICIT NONE + INTEGER :: exponent, factor + + WRITE(*,*) "Enter exponent of Mersenne number" + READ(*,*) exponent + factor = Mfactor(exponent) + IF (factor == 0) THEN + WRITE(*,*) "No Factor found" + ELSE + WRITE(*,"(A,I0,A,I0)") "M", exponent, " has a factor: ", factor + END IF + +CONTAINS + +FUNCTION isPrime(number) +! code omitted - see [[Primality by Trial Division]] +END FUNCTION + +FUNCTION Mfactor(p) + INTEGER :: Mfactor + INTEGER, INTENT(IN) :: p + INTEGER :: i, k, maxk, msb, n, q + + DO i = 30, 0 , -1 + IF(BTEST(p, i)) THEN + msb = i + EXIT + END IF + END DO + + maxk = 16384 / p ! limit for k to prevent overflow of 32 bit signed integer + DO k = 1, maxk + q = 2*p*k + 1 + IF (.NOT. isPrime(q)) CYCLE + IF (MOD(q, 8) /= 1 .AND. MOD(q, 8) /= 7) CYCLE + n = 1 + DO i = msb, 0, -1 + IF (BTEST(p, i)) THEN + n = MOD(n*n*2, q) + ELSE + n = MOD(n*n, q) + ENDIF + END DO + IF (n == 1) THEN + Mfactor = q + RETURN + END IF + END DO + Mfactor = 0 +END FUNCTION +END PROGRAM EXAMPLE diff --git a/Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap b/Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap new file mode 100644 index 0000000000..2b479a025e --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap @@ -0,0 +1,29 @@ +MersenneSmallFactor := function(n) + local k, m; + if IsPrime(n) then + for k in [1 .. 1000000] do + m := 2*k*n + 1; + if PowerModInt(2, n, m) = 1 then + return m; + fi; + od; + fi; + return fail; +end; + +# If n is not prime, fail immediately +MersenneSmallFactor(15); +# fail + +MersenneSmallFactor(929); +# 13007 + +MersenneSmallFactor(1009); +# 3454817 + +# We stop at k = 1000000 in 2*k*n + 1, so it may fail if 2^n - 1 has only large factors +MersenneSmallFactor(101); +# fail + +FactorsInt(2^101-1); +# [ 7432339208719, 341117531003194129 ] diff --git a/Task/Factors-of-a-Mersenne-number/Go/factors-of-a-mersenne-number.go b/Task/Factors-of-a-Mersenne-number/Go/factors-of-a-mersenne-number.go new file mode 100644 index 0000000000..36f7231dbd --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Go/factors-of-a-mersenne-number.go @@ -0,0 +1,81 @@ +package main + +import ( + "fmt" + "math" +) + +// limit search to small primes. really this is higher than +// you'd want it, but it's fun to factor M67. +const qlimit = 2e8 + +func main() { + mtest(31) + mtest(67) + mtest(929) +} + +func mtest(m int32) { + // the function finds odd prime factors by + // searching no farther than sqrt(N), where N = 2^m-1. + // the first odd prime is 3, 3^2 = 9, so M3 = 7 is still too small. + // M4 = 15 is first number for which test is meaningful. + if m < 4 { + fmt.Printf("%d < 4. M%d not tested.\n", m, m) + return + } + flimit := math.Sqrt(math.Pow(2, float64(m)) - 1) + var qlast int32 + if flimit < qlimit { + qlast = int32(flimit) + } else { + qlast = qlimit + } + composite := make([]bool, qlast+1) + sq := int32(math.Sqrt(float64(qlast))) +loop: + for q := int32(3); ; { + if q <= sq { + for i := q * q; i <= qlast; i += q { + composite[i] = true + } + } + if q8 := q % 8; (q8 == 1 || q8 == 7) && modPow(2, m, q) == 1 { + fmt.Printf("M%d has factor %d\n", m, q) + return + } + for { + q += 2 + if q > qlast { + break loop + } + if !composite[q] { + break + } + } + } + fmt.Printf("No factors of M%d found.\n", m) +} + +// base b to power p, mod m +func modPow(b, p, m int32) int32 { + pow := int64(1) + b64 := int64(b) + m64 := int64(m) + bit := uint(30) + for 1< if x==0 then Nothing + else Just ((uncurry.flip$(,))$divMod x 2)) + +trialfac m = take 1. dropWhile ((/=1).(\q -> foldl (((`mod` q).).pm) 1 bs)) $ qs + where qs = filter (liftM2 (&&) (liftM2 (||) (==1) (==7) .(`mod`8)) isPrime ). + map (succ.(2*m*)). enumFromTo 1 $ m `div` 2 + bs = int2bin m + pm n b = 2^b*n*n diff --git a/Task/Factors-of-a-Mersenne-number/Haskell/factors-of-a-mersenne-number-2.hs b/Task/Factors-of-a-Mersenne-number/Haskell/factors-of-a-mersenne-number-2.hs new file mode 100644 index 0000000000..f62fb65a75 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Haskell/factors-of-a-mersenne-number-2.hs @@ -0,0 +1,2 @@ +*Main> trialfac 929 +[13007] diff --git a/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-1.j b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-1.j new file mode 100644 index 0000000000..dc2a49c451 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-1.j @@ -0,0 +1,4 @@ +trialfac=: 3 : 0 + qs=. (#~8&(1=|+.7=|))(#~1&p:)1+(*(1x+i.@<:@<.)&.-:)y + qs#~1=qs&|@(2&^@[**:@])/ 1,~ |.#: y +) diff --git a/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-2.j b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-2.j new file mode 100644 index 0000000000..959369b4e1 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-2.j @@ -0,0 +1,2 @@ +trialfac 929 +13007 diff --git a/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-3.j b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-3.j new file mode 100644 index 0000000000..0a8b4590eb --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/J/factors-of-a-mersenne-number-3.j @@ -0,0 +1 @@ +trialfac 44497 diff --git a/Task/Factors-of-a-Mersenne-number/Java/factors-of-a-mersenne-number.java b/Task/Factors-of-a-Mersenne-number/Java/factors-of-a-mersenne-number.java new file mode 100644 index 0000000000..7fd07df54a --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Java/factors-of-a-mersenne-number.java @@ -0,0 +1,68 @@ +import java.math.BigInteger; + +class MersenneFactorCheck +{ + + private final static BigInteger TWO = BigInteger.valueOf(2); + + public static boolean isPrime(long n) + { + if (n == 2) + return true; + if ((n < 2) || ((n & 1) == 0)) + return false; + long maxFactor = (long)Math.sqrt((double)n); + for (long possibleFactor = 3; possibleFactor <= maxFactor; possibleFactor += 2) + if ((n % possibleFactor) == 0) + return false; + return true; + } + + public static BigInteger findFactorMersenneNumber(int primeP) + { + if (primeP <= 0) + throw new IllegalArgumentException(); + BigInteger bigP = BigInteger.valueOf(primeP); + BigInteger m = BigInteger.ONE.shiftLeft(primeP).subtract(BigInteger.ONE); + // There are more complicated ways of getting closer to sqrt(), but not that important here, so go with simple + BigInteger maxFactor = BigInteger.ONE.shiftLeft((primeP + 1) >>> 1); + BigInteger twoP = BigInteger.valueOf(primeP << 1); + BigInteger possibleFactor = BigInteger.ONE; + int possibleFactorBits12 = 0; + int twoPBits12 = primeP & 3; + + while ((possibleFactor = possibleFactor.add(twoP)).compareTo(maxFactor) <= 0) + { + possibleFactorBits12 = (possibleFactorBits12 + twoPBits12) & 3; + // "Furthermore, q must be 1 or 7 mod 8". We know it's odd due to the +1 done above, so bit 0 is set. Therefore, we only care about bits 1 and 2 equaling 00 or 11 + if ((possibleFactorBits12 == 0) || (possibleFactorBits12 == 3)) + if (TWO.modPow(bigP, possibleFactor).equals(BigInteger.ONE)) + return possibleFactor; + } + return null; + } + + public static void checkMersenneNumber(int p) + { + if (!isPrime(p)) + { + System.out.println("M" + p + " is not prime"); + return; + } + BigInteger factor = findFactorMersenneNumber(p); + if (factor == null) + System.out.println("M" + p + " is prime"); + else + System.out.println("M" + p + " is not prime, has factor " + factor); + return; + } + + public static void main(String[] args) + { + for (int p = 1; p <= 50; p++) + checkMersenneNumber(p); + checkMersenneNumber(929); + return; + } + +} diff --git a/Task/Factors-of-a-Mersenne-number/JavaScript/factors-of-a-mersenne-number.js b/Task/Factors-of-a-Mersenne-number/JavaScript/factors-of-a-mersenne-number.js new file mode 100644 index 0000000000..28f4061419 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/JavaScript/factors-of-a-mersenne-number.js @@ -0,0 +1,41 @@ +function mersenne_factor(p){ + var limit, k, q + limit = Math.sqrt(Math.pow(2,p) - 1) + k = 1 + while ((2*k*p - 1) < limit){ + q = 2*k*p + 1 + if (isPrime(q) && (q % 8 == 1 || q % 8 == 7) && trial_factor(2,p,q)){ + return q // q is a factor of 2**p-1 + } + k++ + } + return null +} + +function isPrime(value){ + for (var i=2; i < value; i++){ + if (value % i == 0){ + return false + } + if (value % i != 0){ + return true; + } + } +} + +function trial_factor(base, exp, mod){ + var square, bits + square = 1 + bits = exp.toString(2).split('') + for (var i=0,ln=bits.length; ii]]]; Print["prime test passed; call Lucas and Lehmer"] diff --git a/Task/Factors-of-a-Mersenne-number/Maxima/factors-of-a-mersenne-number.maxima b/Task/Factors-of-a-Mersenne-number/Maxima/factors-of-a-mersenne-number.maxima new file mode 100644 index 0000000000..e56fed28e7 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Maxima/factors-of-a-mersenne-number.maxima @@ -0,0 +1,7 @@ +mersenne_fac(p) := block([m: 2^p - 1, k: 1], + while mod(m, 2 * k * p + 1) # 0 do k: k + 1, + 2 * k * p + 1 +)$ + +mersenne_fac(929); +/* 13007 */ diff --git a/Task/Factors-of-a-Mersenne-number/PHP/factors-of-a-mersenne-number.php b/Task/Factors-of-a-Mersenne-number/PHP/factors-of-a-mersenne-number.php new file mode 100644 index 0000000000..b9d864764a --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/PHP/factors-of-a-mersenne-number.php @@ -0,0 +1,22 @@ +echo 'M929 has a factor: ', mersenneFactor(929), '
'; + +function mersenneFactor($p) { + $limit = sqrt(pow(2, $p) - 1); + for ($k = 1; 2 * $p * $k - 1 < $limit; $k++) { + $q = 2 * $p * $k + 1; + if (isPrime($q) && ($q % 8 == 1 || $q % 8 == 7) && bcpowmod("2", "$p", "$q") == "1") { + return $q; + } + } + return 0; +} + +function isPrime($n) { + if ($n < 2 || $n % 2 == 0) return $n == 2; + for ($i = 3; $i * $i <= $n; $i += 2) { + if ($n % $i == 0) { + return false; + } + } + return true; +} diff --git a/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-1.pl b/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-1.pl new file mode 100644 index 0000000000..7acadd43de --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-1.pl @@ -0,0 +1,61 @@ +use strict; +use utf8; + +sub factors { + my $n = shift; + my $p = 2; + my @out; + + while ($n >= $p * $p) { + while ($n % $p == 0) { + push @out, $p; + $n /= $p; + } + $p = next_prime($p); + } + push @out, $n if $n > 1 || !@out; + @out; +} + +sub next_prime { + my $p = shift; + do { $p = $p == 2 ? 3 : $p + 2 } until is_prime($p); + $p; +} + +my %pcache; +sub is_prime { + my $x = shift; + $pcache{$x} //= (factors($x) == 1) +} + +sub mtest { + my @bits = split "", sprintf("%b", shift); + my $p = shift; + my $sq = 1; + while (@bits) { + $sq = $sq * $sq; + $sq *= 2 if shift @bits; + $sq %= $p; + } + $sq == 1; +} + +for my $m (2 .. 60, 929) { + next unless is_prime($m); + use bigint; + + my ($f, $k, $x) = (0, 0, 2**$m - 1); + + my $q; + while (++$k) { + $q = 2 * $k * $m + 1; + next if (($q & 7) != 1 && ($q & 7) != 7); + next unless is_prime($q); + last if $q * $q > $x; + last if $f = mtest($m, $q); + } + + print $f? "M$m = $x = $q × @{[$x / $q]}\n" + : "M$m = $x is prime\n"; +} diff --git a/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-2.pl b/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-2.pl new file mode 100644 index 0000000000..bc44baf888 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Perl/factors-of-a-mersenne-number-2.pl @@ -0,0 +1,11 @@ +M2 = 3 is prime +M2 = 3 is prime +M3 = 7 is prime +M5 = 31 is prime +M7 = 127 is prime +M11 = 2047 = 23 × 89 +M13 = 8191 is prime +... +M53 = 9007199254740991 = 6361 × 1416003655831 +M59 = 576460752303423487 = 179951 × 3203431780337 +M929 = 4538....8911 = 13007 × 348890....84273 diff --git a/Task/Factors-of-a-Mersenne-number/PicoLisp/factors-of-a-mersenne-number.l b/Task/Factors-of-a-Mersenne-number/PicoLisp/factors-of-a-mersenne-number.l new file mode 100644 index 0000000000..9d784e6821 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/PicoLisp/factors-of-a-mersenne-number.l @@ -0,0 +1,30 @@ +(de **Mod (X Y N) + (let M 1 + (loop + (when (bit? 1 Y) + (setq M (% (* M X) N)) ) + (T (=0 (setq Y (>> 1 Y))) + M ) + (setq X (% (* X X) N)) ) ) ) + +(de prime? (N) + (or + (= N 2) + (and + (> N 1) + (bit? 1 N) + (for (D 3 T (+ D 2)) + (T (> D (sqrt N)) T) + (T (=0 (% N D)) NIL) ) ) ) ) + +(de mFactor (P) + (let (Lim (sqrt (dec (** 2 P))) K 0 Q) + (loop + (setq Q (inc (* 2 (inc 'K) P))) + (T (>= Q Lim) NIL) + (T + (and + (member (% Q 8) (1 7)) + (prime? Q) + (= 1 (**Mod 2 P Q)) ) + Q ) ) ) ) diff --git a/Task/Factors-of-a-Mersenne-number/Python/factors-of-a-mersenne-number.py b/Task/Factors-of-a-Mersenne-number/Python/factors-of-a-mersenne-number.py new file mode 100644 index 0000000000..5efe93532c --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Python/factors-of-a-mersenne-number.py @@ -0,0 +1,25 @@ +def is_prime(number): + return True # code omitted - see Primality by Trial Division + +def m_factor(p): + max_k = 16384 / p # arbitrary limit; since Python automatically uses long's, it doesn't overflow + for k in xrange(max_k): + q = 2*p*k + 1 + if not is_prime(q): + continue + elif q % 8 != 1 and q % 8 != 7: + continue + elif pow(2, p, q) == 1: + return q + return None + +if __name__ == '__main__': + exponent = int(raw_input("Enter exponent of Mersenne number: ")) + if not is_prime(exponent): + print "Exponent is not prime: %d" % exponent + else: + factor = m_factor(exponent) + if not factor: + print "No factor found for M%d" % exponent + else: + print "M%d has a factor: %d" % (exponent, factor) diff --git a/Task/Factors-of-a-Mersenne-number/REXX/factors-of-a-mersenne-number.rexx b/Task/Factors-of-a-Mersenne-number/REXX/factors-of-a-mersenne-number.rexx new file mode 100644 index 0000000000..584ab4f0a4 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/REXX/factors-of-a-mersenne-number.rexx @@ -0,0 +1,39 @@ +/*REXX program uses exponent-&-mod operator to test possible Mersenne #s*/ +numeric digits 500 /*we're dealing with some biggies*/ + + do j=1 to 61; z=j /*when J=61, it turns into 929. */ + if z==61 then z=929 /*switcheroo, 61 turns into 929.*/ + if \isPrime(z) then iterate /*if not prime, keep plugging. */ + r=testM(z) /*not, give it the 3rd degree. */ + if r==0 then say right('M'z,8) "──────── is a Mersenne prime." + else say right('M'z,48) "is composite, a factor:" r + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────MODPOW subroutine───────────────────*/ +modPow: procedure; parse arg base,n,div; sq=1 +bits=x2b(d2x(n))+0 /*dec──► hex──► binary, normalize*/ + do until bits==''; sq=sq ** 2 + if left(bits,1) then sq=sq * base // div + bits=substr(bits,2) + end /*until*/ +return sq +/*─────────────────────────────────────ISPRIME subroutine───────────────*/ +isPrime: procedure; parse arg x; if wordpos(x,'2 3 5 7')\==0 then return 1 +if x<11 then return 0; if x//2==0 then return 0; if x//3==0 then return 0 +do j=5 by 6; if x//j==0|x//(j+2)==0 then return 0; if j*j>x then return 1;end +/*─────────────────────────────────────ISQRT subroutine─────────────────*/ +iSqrt: procedure; parse arg x; r=0; q=1; do while q<=x; q=q*4; end +do while q>1; q=q%4;_=x-r-q;r=r%2;if _>=0 then do;x=_;r=r+q;end;end; return r +/*──────────────────────────────────TESTM subroutine────────────────────*/ +testM: procedure; parse arg x /*test a possible Mersenne prime.*/ +sqroot=iSqrt(2**x) /*iSqrt is: integer square root.*/ + /*───── ─ ── ─ ─ */ + do k=1; q=2*k*x + 1 /* _____ */ + if q>sqroot then leave /*Is q>√(2^x) ? Then we're done*/ + _=q // 8 /*perform modulus arithmetic. */ + if _\==1 & _\==7 then iterate /*must be either one or seven. */ + if \isPrime(q) then iterate /*if not prime, keep on trukin'. */ + if modPow(2,x,q)==1 then return q /*Not a prime? Return a factor.*/ + end /*k*/ + +return 0 /*it's a Mersenne prime, by gum. */ diff --git a/Task/Factors-of-a-Mersenne-number/Ruby/factors-of-a-mersenne-number.rb b/Task/Factors-of-a-Mersenne-number/Ruby/factors-of-a-mersenne-number.rb new file mode 100644 index 0000000000..31af7e6248 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Ruby/factors-of-a-mersenne-number.rb @@ -0,0 +1,49 @@ +require 'mathn' + +def mersenne_factor(p) + limit = Math.sqrt(2**p - 1) + k = 1 + while (2*k*p - 1) < limit + q = 2*k*p + 1 + if prime?(q) and (q % 8 == 1 or q % 8 == 7) and trial_factor(2,p,q) + # q is a factor of 2**p-1 + return q + end + k += 1 + end + nil +end + +def prime?(value) + return false if value < 2 + png = Prime.new + for prime in png + q,r = value.divmod prime + return true if q < prime + return false if r == 0 + end +end + +def trial_factor(base, exp, mod) + square = 1 + ("%b" % exp).each_char {|bit| square = square**2 * (bit == "1" ? base : 1) % mod} + (square == 1) +end + +def check_mersenne(p) + print "M#{p} = 2**#{p}-1 is " + f = mersenne_factor(p) + if f.nil? + puts "prime" + else + puts "composite with factor #{f}" + end +end + +png = Prime.new +for p in png + check_mersenne p + break if p == 53 +end +p = 929 +check_mersenne p diff --git a/Task/Factors-of-a-Mersenne-number/Scala/factors-of-a-mersenne-number.scala b/Task/Factors-of-a-Mersenne-number/Scala/factors-of-a-mersenne-number.scala new file mode 100644 index 0000000000..37d8bffea4 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Scala/factors-of-a-mersenne-number.scala @@ -0,0 +1,65 @@ +import scala.math.BigInt + +def factorMersenne( p:BigInt ) : Option[BigInt] = { + + val two = BigInt("2") + + val factorLimit : BigInt = (two pow p.toInt) - 1 + val limit = factorLimit min (math.sqrt(Long.MaxValue).toInt) + + + def factorTest( p : BigInt, q : BigInt ) : Boolean = { + + // Is q an early factor? + if( + two.modPow(p,q) == 1 && // number divides 2**P-1 + ((q % 8).toInt match {case 1 | 7 => true; case _ => false}) && // mod(8) is of 1 or 7 + q.isProbablePrime(7) // it is a prime number + ) + {true} + else + {false} + } + + // Build a stream of factors from (2*p+1) step-by (2*p) + def s(a:BigInt) : Stream[BigInt] = a #:: s(a + (two * p)) // Build stream of possible factors + + // Limit and Filter Stream and then take the head element + val e = s(two*p+1).takeWhile(_ < limit).filter(factorTest(p,_)) + e.headOption +} + +val l = List(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,929) + +// Test +l.foreach(p => println( "M" + p + ": " + (factorMersenne(p) getOrElse "prime") )) + +/* +Results: +M2: prime +M3: prime +M5: prime +M7: prime +M11: 23 +M13: prime +M17: prime +M19: prime +M23: 47 +M29: 233 +M31: prime +M37: 223 +M41: 13367 +M43: 431 +M47: 2351 +M53: 6361 +M59: 179951 +M61: prime +M67: 193707721 +M71: 228479 +M73: 439 +M79: 2687 +M83: 167 +M89: prime +M97: 11447 +M929: 13007 +*/ diff --git a/Task/Factors-of-a-Mersenne-number/Scheme/factors-of-a-mersenne-number.ss b/Task/Factors-of-a-Mersenne-number/Scheme/factors-of-a-mersenne-number.ss new file mode 100644 index 0000000000..7df3abd070 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Scheme/factors-of-a-mersenne-number.ss @@ -0,0 +1,21 @@ +#lang scheme + +;;; this needs to be changed for other R6RS implementations +(require rnrs/arithmetic/bitwise-6) + +;;; modpow, as per the task description. +(define (modpow exponent base) + (let loop ([square 1] [index (- (bitwise-length exponent) 1)]) + (if (< index 0) + square + (loop (modulo (* (if (bitwise-bit-set? exponent index) 2 1) + square square) base) + (- index 1))))) + +;;; search through all integers from 1 on to find the first divisor +;;; returns #f if 2^p-1 is prime +(define (mersenne-factor p) + (for/first ((i (in-range 1 (floor (expt 2 (quotient p 2))) (* 2 p))) + #:when (and (or (= 1 (modulo i 8)) (= 7 (modulo i 8))) + (= 1 (modpow p i)))) + i)) diff --git a/Task/Factors-of-a-Mersenne-number/Tcl/factors-of-a-mersenne-number.tcl b/Task/Factors-of-a-Mersenne-number/Tcl/factors-of-a-mersenne-number.tcl new file mode 100644 index 0000000000..c472614e28 --- /dev/null +++ b/Task/Factors-of-a-Mersenne-number/Tcl/factors-of-a-mersenne-number.tcl @@ -0,0 +1,45 @@ +proc int2bits {n} { + binary scan [binary format I1 $n] B* binstring + return [split [string trimleft $binstring 0] ""] + + # another method + if {$n == 0} {return 0} + set bits [list] + while {$n > 0} { + lappend bits [expr {$n % 2}] + set n [expr {$n / 2}] + } + return [lreverse $bits] +} + +proc trial_factor {base exp mod} { + set square 1 + foreach bit [int2bits $exp] { + set square [expr {($square ** 2) * ($bit == 1 ? $base : 1) % $mod}] + } + return [expr {$square == 1}] +} + +proc m_factor p { + set limit [expr {sqrt(2**$p - 1)}] + for {set k 1} {2 * $k * $p - 1 < $limit} {incr k} { + set q [expr {2 * $k * $p + 1}] + if { ! [primes::is_prime $q]} { + continue + } elseif { ! ($q % 8 == 1 || $q % 8 == 7)} { + # optimization + continue + } elseif {[trial_factor 2 $p $q]} { + # $q is a factor of 2**$p-1 + return $q + } + } + return -1 +} + +set exp 929 +if {[set fact [m_factor 929]] > 0} { + puts "M$exp has a factor: $fact" +} else { + puts "no factor found for M$exp" +} diff --git a/Task/Factors-of-an-integer/0815/factors-of-an-integer.0815 b/Task/Factors-of-an-integer/0815/factors-of-an-integer.0815 new file mode 100644 index 0000000000..82bfd6f56c --- /dev/null +++ b/Task/Factors-of-an-integer/0815/factors-of-an-integer.0815 @@ -0,0 +1,2 @@ +<:1:~>|~#:end:^>~x}:str:/={^:wei:~%x<:a:x=$~ +=}:wei:x<:1:+{>~>x=-#:fin:^:str:}:fin:{{~% diff --git a/Task/Factors-of-an-integer/0DESCRIPTION b/Task/Factors-of-an-integer/0DESCRIPTION new file mode 100644 index 0000000000..cd69d7c6bc --- /dev/null +++ b/Task/Factors-of-an-integer/0DESCRIPTION @@ -0,0 +1,7 @@ +{{basic data operation}} +[[Category:Arithmetic operations]] +[[Category:Mathematical_operations]] +Compute the [[wp:Divisor|factors]] of a positive integer. These factors are the positive integers by which the number being factored can be divided to yield a positive integer result (though the concepts function correctly for zero and negative integers, the set of factors of zero is has countably infinite members, and the factors of negative integers can be obtained from the factors of related positive numbers without difficulty; this task does not require handling of either of these cases). Note that even prime numbers will have at least two factors; ‘1’ and themselves. + +See also: +* [[Prime decomposition]] diff --git a/Task/Factors-of-an-integer/1META.yaml b/Task/Factors-of-an-integer/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Factors-of-an-integer/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Factors-of-an-integer/ACL2/factors-of-an-integer.acl2 b/Task/Factors-of-an-integer/ACL2/factors-of-an-integer.acl2 new file mode 100644 index 0000000000..7a032a43a6 --- /dev/null +++ b/Task/Factors-of-an-integer/ACL2/factors-of-an-integer.acl2 @@ -0,0 +1,10 @@ +(defun factors-r (n i) + (declare (xargs :measure (nfix (- n i)))) + (cond ((zp (- n i)) + (list n)) + ((= (mod n i) 0) + (cons i (factors-r n (1+ i)))) + (t (factors-r n (1+ i))))) + +(defun factors (n) + (factors-r n 1)) diff --git a/Task/Factors-of-an-integer/ALGOL-68/factors-of-an-integer.alg b/Task/Factors-of-an-integer/ALGOL-68/factors-of-an-integer.alg new file mode 100644 index 0000000000..4a34f3ec98 --- /dev/null +++ b/Task/Factors-of-an-integer/ALGOL-68/factors-of-an-integer.alg @@ -0,0 +1,25 @@ +MODE YIELDINT = PROC(INT)VOID; + +PROC gen factors = (INT n, YIELDINT yield)VOID: ( + FOR i FROM 1 TO ENTIER sqrt(n) DO + IF n MOD i = 0 THEN + yield(i); + INT other = n OVER i; + IF i NE other THEN yield(n OVER i) FI + FI + OD +); + +[]INT nums2factor = (45, 53, 64); + +FOR i TO UPB nums2factor DO + INT num = nums2factor[i]; + STRING sep := ": "; + print(num); +# FOR INT j IN # gen factors(num, # ) DO ( # +## (INT j)VOID:( + print((sep,whole(j,0))); + sep:=", " +# OD # )); + print(new line) +OD diff --git a/Task/Factors-of-an-integer/ActionScript/factors-of-an-integer.as b/Task/Factors-of-an-integer/ActionScript/factors-of-an-integer.as new file mode 100644 index 0000000000..2fcfe1aa3d --- /dev/null +++ b/Task/Factors-of-an-integer/ActionScript/factors-of-an-integer.as @@ -0,0 +1,7 @@ +function factor(n:uint):Vector. +{ + var factors:Vector. = new Vector.(); + for(var i:uint = 1; i <= n; i++) + if(n % i == 0)factors.push(i); + return factors; +} diff --git a/Task/Factors-of-an-integer/Ada/factors-of-an-integer.ada b/Task/Factors-of-an-integer/Ada/factors-of-an-integer.ada new file mode 100644 index 0000000000..4212998a28 --- /dev/null +++ b/Task/Factors-of-an-integer/Ada/factors-of-an-integer.ada @@ -0,0 +1,22 @@ +with Ada.Text_IO; +with Ada.Command_Line; +procedure Factors is + Number : Positive; + Test_Nr : Positive := 1; +begin + if Ada.Command_Line.Argument_Count /= 1 then + Ada.Text_IO.Put (Ada.Text_IO.Standard_Error, "Missing argument!"); + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + return; + end if; + Number := Positive'Value (Ada.Command_Line.Argument (1)); + Ada.Text_IO.Put ("Factors of" & Positive'Image (Number) & ": "); + loop + if Number mod Test_Nr = 0 then + Ada.Text_IO.Put (Positive'Image (Test_Nr) & ","); + end if; + exit when Test_Nr ** 2 >= Number; + Test_Nr := Test_Nr + 1; + end loop; + Ada.Text_IO.Put_Line (Positive'Image (Number) & "."); +end Factors; diff --git a/Task/Factors-of-an-integer/Aikido/factors-of-an-integer.aikido b/Task/Factors-of-an-integer/Aikido/factors-of-an-integer.aikido new file mode 100644 index 0000000000..c77b45513c --- /dev/null +++ b/Task/Factors-of-an-integer/Aikido/factors-of-an-integer.aikido @@ -0,0 +1,34 @@ +import math + +function factor (n:int) { + var result = [] + function append (v) { + if (!(v in result)) { + result.append (v) + } + } + var sqrt = cast(Math.sqrt (n)) + append (1) + for (var i = n-1 ; i >= sqrt ; i--) { + if ((n % i) == 0) { + append (i) + append (n/i) + } + } + append (n) + return result.sort() +} + +function printvec (vec) { + var comma = "" + print ("[") + foreach v vec { + print (comma + v) + comma = ", " + } + println ("]") +} + +printvec (factor (45)) +printvec (factor (25)) +printvec (factor (100)) diff --git a/Task/Factors-of-an-integer/AutoHotkey/factors-of-an-integer.ahk b/Task/Factors-of-an-integer/AutoHotkey/factors-of-an-integer.ahk new file mode 100644 index 0000000000..7ab1f70861 --- /dev/null +++ b/Task/Factors-of-an-integer/AutoHotkey/factors-of-an-integer.ahk @@ -0,0 +1,9 @@ +msgbox, % factors(45) "`n" factors(53) "`n" factors(64) + +Factors(n) +{ Loop, % floor(sqrt(n)) + { v := A_Index = 1 ? 1 "," n : mod(n,A_Index) ? v : v "," A_Index "," n//A_Index + } + Sort, v, N U D, + Return, v +} diff --git a/Task/Factors-of-an-integer/AutoIt/factors-of-an-integer.autoit b/Task/Factors-of-an-integer/AutoIt/factors-of-an-integer.autoit new file mode 100644 index 0000000000..24d556fd64 --- /dev/null +++ b/Task/Factors-of-an-integer/AutoIt/factors-of-an-integer.autoit @@ -0,0 +1,13 @@ +;AutoIt Version: 3.2.10.0 +$num = 45 +MsgBox (0,"Factors", "Factors of " & $num & " are: " & factors($num)) +consolewrite ("Factors of " & $num & " are: " & factors($num)) +Func factors($intg) + $ls_factors="" + For $i = 1 to $intg/2 + if ($intg/$i - int($intg/$i))=0 Then + $ls_factors=$ls_factors&$i &", " + EndIf + Next + Return $ls_factors&$intg +EndFunc diff --git a/Task/Factors-of-an-integer/BASIC/factors-of-an-integer.bas b/Task/Factors-of-an-integer/BASIC/factors-of-an-integer.bas new file mode 100644 index 0000000000..98f6370e71 --- /dev/null +++ b/Task/Factors-of-an-integer/BASIC/factors-of-an-integer.bas @@ -0,0 +1,41 @@ +DECLARE SUB factor (what AS INTEGER) + +REDIM SHARED factors(0) AS INTEGER + +DIM i AS INTEGER, L AS INTEGER + +INPUT "Gimme a number"; i + +factor i + +PRINT factors(0); +FOR L = 1 TO UBOUND(factors) + PRINT ","; factors(L); +NEXT +PRINT + +SUB factor (what AS INTEGER) + DIM tmpint1 AS INTEGER + DIM L0 AS INTEGER, L1 AS INTEGER + + REDIM tmp(0) AS INTEGER + REDIM factors(0) AS INTEGER + factors(0) = 1 + + FOR L0 = 2 TO what + IF (0 = (what MOD L0)) THEN + 'all this REDIMing and copying can be replaced with: + 'REDIM PRESERVE factors(UBOUND(factors)+1) + 'in languages that support the PRESERVE keyword + REDIM tmp(UBOUND(factors)) AS INTEGER + FOR L1 = 0 TO UBOUND(factors) + tmp(L1) = factors(L1) + NEXT + REDIM factors(UBOUND(factors) + 1) + FOR L1 = 0 TO UBOUND(factors) - 1 + factors(L1) = tmp(L1) + NEXT + factors(UBOUND(factors)) = L0 + END IF + NEXT +END SUB diff --git a/Task/Factors-of-an-integer/BBC-BASIC/factors-of-an-integer.bbc b/Task/Factors-of-an-integer/BBC-BASIC/factors-of-an-integer.bbc new file mode 100644 index 0000000000..d75cf566e7 --- /dev/null +++ b/Task/Factors-of-an-integer/BBC-BASIC/factors-of-an-integer.bbc @@ -0,0 +1,25 @@ + INSTALL @lib$+"SORTLIB" + sort% = FN_sortinit(0, 0) + + PRINT "The factors of 45 are " FNfactorlist(45) + PRINT "The factors of 12345 are " FNfactorlist(12345) + END + + DEF FNfactorlist(N%) + LOCAL C%, I%, L%(), L$ + DIM L%(32) + FOR I% = 1 TO SQR(N%) + IF (N% MOD I% = 0) THEN + L%(C%) = I% + C% += 1 + IF (N% <> I%^2) THEN + L%(C%) = (N% DIV I%) + C% += 1 + ENDIF + ENDIF + NEXT I% + CALL sort%, L%(0) + FOR I% = 0 TO C%-1 + L$ += STR$(L%(I%)) + ", " + NEXT + = LEFT$(LEFT$(L$)) diff --git a/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-1.bat b/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-1.bat new file mode 100644 index 0000000000..75c74474f7 --- /dev/null +++ b/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-1.bat @@ -0,0 +1,9 @@ +@echo off +set res=Factors of %1: +for /L %%i in (1,1,%1) do call :fac %1 %%i +echo %res% +goto :eof + +:fac +set /a test = %1 %% %2 +if %test% equ 0 set res=%res% %2 diff --git a/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-2.bat b/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-2.bat new file mode 100644 index 0000000000..993fcd46fa --- /dev/null +++ b/Task/Factors-of-an-integer/Batch-File/factors-of-an-integer-2.bat @@ -0,0 +1,10 @@ +@echo off +set /p limit=Gimme a number: +set res=Factors of %limit%: +for /L %%i in (1,1,%limit%) do call :fac %limit% %%i +echo %res% +goto :eof + +:fac +set /a test = %1 %% %2 +if %test% equ 0 set res=%res% %2 diff --git a/Task/Factors-of-an-integer/C++/factors-of-an-integer.cpp b/Task/Factors-of-an-integer/C++/factors-of-an-integer.cpp new file mode 100644 index 0000000000..3b746244ef --- /dev/null +++ b/Task/Factors-of-an-integer/C++/factors-of-an-integer.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +std::vector GenerateFactors(int n) +{ + std::vector factors; + factors.push_back(1); + factors.push_back(n); + for(int i = 2; i * i <= n; ++i) + { + if(n % i == 0) + { + factors.push_back(i); + if(i * i != n) + factors.push_back(n / i); + } + } + + std::sort(factors.begin(), factors.end()); + return factors; +} + +int main() +{ + const int SampleNumbers[] = {3135, 45, 60, 81}; + + for(size_t i = 0; i < sizeof(SampleNumbers) / sizeof(int); ++i) + { + std::vector factors = GenerateFactors(SampleNumbers[i]); + std::cout << "Factors of " << SampleNumbers[i] << " are:\n"; + std::copy(factors.begin(), factors.end(), std::ostream_iterator(std::cout, "\n")); + std::cout << std::endl; + } +} diff --git a/Task/Factors-of-an-integer/C/factors-of-an-integer-1.c b/Task/Factors-of-an-integer/C/factors-of-an-integer-1.c new file mode 100644 index 0000000000..e9cb31e2b1 --- /dev/null +++ b/Task/Factors-of-an-integer/C/factors-of-an-integer-1.c @@ -0,0 +1,68 @@ +#include +#include + +typedef struct { + int *list; + short count; +} Factors; + +void xferFactors( Factors *fctrs, int *flist, int flix ) +{ + int ix, ij; + int newSize = fctrs->count + flix; + if (newSize > flix) { + fctrs->list = realloc( fctrs->list, newSize * sizeof(int)); + } + else { + fctrs->list = malloc( newSize * sizeof(int)); + } + for (ij=0,ix=fctrs->count; ixlist[ix] = flist[ij]; + } + fctrs->count = newSize; +} + +Factors *factor( int num, Factors *fctrs) +{ + int flist[301], flix; + int dvsr; + flix = 0; + fctrs->count = 0; + free(fctrs->list); + fctrs->list = NULL; + for (dvsr=1; dvsr*dvsr < num; dvsr++) { + if (num % dvsr != 0) continue; + if ( flix == 300) { + xferFactors( fctrs, flist, flix ); + flix = 0; + } + flist[flix++] = dvsr; + flist[flix++] = num/dvsr; + } + if (dvsr*dvsr == num) + flist[flix++] = dvsr; + if (flix > 0) + xferFactors( fctrs, flist, flix ); + + return fctrs; +} + +int main(int argc, char*argv[]) +{ + int nums2factor[] = { 2059, 223092870, 3135, 45 }; + Factors ftors = { NULL, 0}; + char sep; + int i,j; + + for (i=0; i<4; i++) { + factor( nums2factor[i], &ftors ); + printf("\nfactors of %d are:\n ", nums2factor[i]); + sep = ' '; + for (j=0; j +#include +#include + +/* 65536 = 2^16, so we can factor all 32 bit ints */ +char bits[65536]; + +typedef unsigned long ulong; +ulong primes[7000], n_primes; + +typedef struct { ulong p, e; } prime_factor; /* prime, exponent */ + +void sieve() +{ + int i, j; + memset(bits, 1, 65536); + bits[0] = bits[1] = 0; + for (i = 0; i < 256; i++) + if (bits[i]) + for (j = i * i; j < 65536; j += i) + bits[j] = 0; + + /* collect primes into a list. slightly faster this way if dealing with large numbers */ + for (i = j = 0; i < 65536; i++) + if (bits[i]) primes[j++] = i; + + n_primes = j; +} + +int get_prime_factors(ulong n, prime_factor *lst) +{ + ulong i, e, p; + int len = 0; + + for (i = 0; i < n_primes; i++) { + p = primes[i]; + if (p * p > n) break; + for (e = 0; !(n % p); n /= p, e++); + if (e) { + lst[len].p = p; + lst[len++].e = e; + } + } + + return n == 1 ? len : (lst[len].p = n, lst[len].e = 1, ++len); +} + +int ulong_cmp(const void *a, const void *b) +{ + return *(ulong*)a < *(ulong*)b ? -1 : *(ulong*)a > *(ulong*)b; +} + +int get_factors(ulong n, ulong *lst) +{ + int n_f, len, len2, i, j, k, p; + prime_factor f[100]; + + n_f = get_prime_factors(n, f); + + len2 = len = lst[0] = 1; + /* L = (1); L = (L, L * p**(1 .. e)) forall((p, e)) */ + for (i = 0; i < n_f; i++, len2 = len) + for (j = 0, p = f[i].p; j < f[i].e; j++, p *= f[i].p) + for (k = 0; k < len2; k++) + lst[len++] = lst[k] * p; + + qsort(lst, len, sizeof(ulong), ulong_cmp); + return len; +} + +int main() +{ + ulong fac[10000]; + int len, i, j; + ulong nums[] = {3, 120, 1024, 2UL*2*2*2*3*3*3*5*5*7*11*13*17*19 }; + + sieve(); + + for (i = 0; i < 4; i++) { + len = get_factors(nums[i], fac); + printf("%lu:", nums[i]); + for (j = 0; j < len; j++) + printf(" %lu", fac[j]); + printf("\n"); + } + + return 0; +} diff --git a/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-1.clj b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-1.clj new file mode 100644 index 0000000000..3dcb9d74fc --- /dev/null +++ b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-1.clj @@ -0,0 +1,4 @@ +(defn factors [n] + (filter #(zero? (rem n %)) (range 1 (inc n)))) + +(print (factors 45)) diff --git a/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-2.clj b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-2.clj new file mode 100644 index 0000000000..b2cb67e7a1 --- /dev/null +++ b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-2.clj @@ -0,0 +1,4 @@ +(defn factors [n] + (into (sorted-set) + (mapcat (fn [x] [x (/ n x)]) + (filter #(zero? (rem n %)) (range 1 (inc (sqrt n)))) ))) diff --git a/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-3.clj b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-3.clj new file mode 100644 index 0000000000..af4b734e22 --- /dev/null +++ b/Task/Factors-of-an-integer/Clojure/factors-of-an-integer-3.clj @@ -0,0 +1,5 @@ +(defn factors [n] + (into (sorted-set) + (reduce concat + (for [x (range 1 (inc (sqrt n))) :when (zero? (rem n x))] + [x (/ n x)])))) diff --git a/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-1.coffee b/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-1.coffee new file mode 100644 index 0000000000..50fa310a15 --- /dev/null +++ b/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-1.coffee @@ -0,0 +1,59 @@ +# Reference implementation for finding factors is slow, but hopefully +# robust--we'll use it to verify the more complicated (but hopefully faster) +# algorithm. +slow_factors = (n) -> + (i for i in [1..n] when n % i == 0) + +# The rest of this code does two optimizations: +# 1) When you find a prime factor, divide it out of n (smallest_prime_factor). +# 2) Find the prime factorization first, then compute composite factors from those. + +smallest_prime_factor = (n) -> + for i in [2..n] + return n if i*i > n + return i if n % i == 0 + +prime_factors = (n) -> + return {} if n == 1 + spf = smallest_prime_factor n + result = prime_factors(n / spf) + result[spf] or= 0 + result[spf] += 1 + result + +fast_factors = (n) -> + prime_hash = prime_factors n + exponents = [] + for p of prime_hash + exponents.push + p: p + exp: 0 + result = [] + while true + factor = 1 + for obj in exponents + factor *= Math.pow obj.p, obj.exp + result.push factor + break if factor == n + # roll the odometer + for obj, i in exponents + if obj.exp < prime_hash[obj.p] + obj.exp += 1 + break + else + obj.exp = 0 + + return result.sort (a, b) -> a - b + +verify_factors = (factors, n) -> + expected_result = slow_factors n + throw Error("wrong length") if factors.length != expected_result.length + for factor, i in expected_result + console.log Error("wrong value") if factors[i] != factor + + +for n in [1, 3, 4, 8, 24, 37, 1001, 11111111111, 99999999999] + factors = fast_factors n + console.log n, factors + if n < 1000000 + verify_factors factors, n diff --git a/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-2.coffee b/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-2.coffee new file mode 100644 index 0000000000..532bee5b8f --- /dev/null +++ b/Task/Factors-of-an-integer/CoffeeScript/factors-of-an-integer-2.coffee @@ -0,0 +1,21 @@ +> coffee factors.coffee +1 [ 1 ] +3 [ 1, 3 ] +4 [ 1, 2, 4 ] +8 [ 1, 2, 4, 8 ] +24 [ 1, 2, 3, 4, 6, 8, 12, 24 ] +37 [ 1, 37 ] +1001 [ 1, 7, 11, 13, 77, 91, 143, 1001 ] +11111111111 [ 1, 21649, 513239, 11111111111 ] +99999999999 [ 1, + 3, + 9, + 21649, + 64947, + 194841, + 513239, + 1539717, + 4619151, + 11111111111, + 33333333333, + 99999999999 ] diff --git a/Task/Factors-of-an-integer/Common-Lisp/factors-of-an-integer.lisp b/Task/Factors-of-an-integer/Common-Lisp/factors-of-an-integer.lisp new file mode 100644 index 0000000000..3ab77c0701 --- /dev/null +++ b/Task/Factors-of-an-integer/Common-Lisp/factors-of-an-integer.lisp @@ -0,0 +1,10 @@ +(defun factors (n &aux (lows '()) (highs '())) + (do ((limit (isqrt n)) (factor 1 (1+ factor))) + ((= factor limit) + (when (= n (* limit limit)) + (push limit highs)) + (nreconc lows highs)) + (multiple-value-bind (quotient remainder) (floor n factor) + (when (zerop remainder) + (push factor lows) + (push quotient highs))))) diff --git a/Task/Factors-of-an-integer/D/factors-of-an-integer-1.d b/Task/Factors-of-an-integer/D/factors-of-an-integer-1.d new file mode 100644 index 0000000000..2fb629c75a --- /dev/null +++ b/Task/Factors-of-an-integer/D/factors-of-an-integer-1.d @@ -0,0 +1,23 @@ +import std.stdio, std.math, std.algorithm; + +T[] factor(T)(in T n) /*pure nothrow*/ { + if (n == 1) return [n]; + + T[] res = [1, n]; + T limit = cast(T)sqrt(cast(real)n) + 1; + for (T i = 2; i < limit; i++) { + if (n % i == 0) { + res ~= i; + auto q = n / i; + if (q > i) + res ~= q; + } + } + + return res.sort().release(); +} + +void main() { + foreach (i; [45, 53, 64, 1111111]) + writeln(factor(i)); +} diff --git a/Task/Factors-of-an-integer/D/factors-of-an-integer-2.d b/Task/Factors-of-an-integer/D/factors-of-an-integer-2.d new file mode 100644 index 0000000000..f1c6ada6ee --- /dev/null +++ b/Task/Factors-of-an-integer/D/factors-of-an-integer-2.d @@ -0,0 +1,9 @@ +import std.stdio, std.algorithm, std.range; + +auto factors(I)(I n) { + return iota(1, n+1).filter!(i => n % i == 0)(); +} + +void main() { + writeln(factors(36)); +} diff --git a/Task/Factors-of-an-integer/E/factors-of-an-integer.e b/Task/Factors-of-an-integer/E/factors-of-an-integer.e new file mode 100644 index 0000000000..a09859b4d8 --- /dev/null +++ b/Task/Factors-of-an-integer/E/factors-of-an-integer.e @@ -0,0 +1,7 @@ +def factors(x :(int > 0)) { + var xfactors := [] + for f ? (x % f <=> 0) in 1..x { + xfactors with= f + } + return xfactors +} diff --git a/Task/Factors-of-an-integer/Ela/factors-of-an-integer-1.ela b/Task/Factors-of-an-integer/Ela/factors-of-an-integer-1.ela new file mode 100644 index 0000000000..79ae0ffd8d --- /dev/null +++ b/Task/Factors-of-an-integer/Ela/factors-of-an-integer-1.ela @@ -0,0 +1,3 @@ +open list + +factors m = filter (\x -> m % x == 0) [1..m] diff --git a/Task/Factors-of-an-integer/Ela/factors-of-an-integer-2.ela b/Task/Factors-of-an-integer/Ela/factors-of-an-integer-2.ela new file mode 100644 index 0000000000..e0f6e4e394 --- /dev/null +++ b/Task/Factors-of-an-integer/Ela/factors-of-an-integer-2.ela @@ -0,0 +1 @@ +factors m = [x \\ x <- [1..m] | m % x == 0] diff --git a/Task/Factors-of-an-integer/Erlang/factors-of-an-integer.erl b/Task/Factors-of-an-integer/Erlang/factors-of-an-integer.erl new file mode 100644 index 0000000000..048759cdb1 --- /dev/null +++ b/Task/Factors-of-an-integer/Erlang/factors-of-an-integer.erl @@ -0,0 +1,2 @@ +factors(N) -> + [I || I <- lists:seq(1,trunc(math:sqrt(N))), N rem I == 0]++[N]. diff --git a/Task/Factors-of-an-integer/FALSE/factors-of-an-integer.false b/Task/Factors-of-an-integer/FALSE/factors-of-an-integer.false new file mode 100644 index 0000000000..9006d1723c --- /dev/null +++ b/Task/Factors-of-an-integer/FALSE/factors-of-an-integer.false @@ -0,0 +1,2 @@ +[1[\$@$@-][\$@$@$@$@\/*=[$." "]?1+]#.%]f: +45f;! 53f;! 64f;! diff --git a/Task/Factors-of-an-integer/Forth/factors-of-an-integer.fth b/Task/Factors-of-an-integer/Forth/factors-of-an-integer.fth new file mode 100644 index 0000000000..7d909a7326 --- /dev/null +++ b/Task/Factors-of-an-integer/Forth/factors-of-an-integer.fth @@ -0,0 +1,7 @@ +: factors dup 2/ 1+ 1 do dup i mod 0= if i swap then loop ; +: .factors factors begin dup dup . 1 <> while drop repeat drop cr ; + +45 .factors +53 .factors +64 .factors +100 .factors diff --git a/Task/Factors-of-an-integer/Fortran/factors-of-an-integer.f b/Task/Factors-of-an-integer/Fortran/factors-of-an-integer.f new file mode 100644 index 0000000000..333765e87c --- /dev/null +++ b/Task/Factors-of-an-integer/Fortran/factors-of-an-integer.f @@ -0,0 +1,20 @@ +program Factors + implicit none + integer :: i, number + + write(*,*) "Enter a number between 1 and 2147483647" + read*, number + + do i = 1, int(sqrt(real(number))) - 1 + if (mod(number, i) == 0) write (*,*) i, number/i + end do + + ! Check to see if number is a square + i = int(sqrt(real(number))) + if (i*i == number) then + write (*,*) i + else if (mod(number, i) == 0) then + write (*,*) i, number/i + end if + +end program diff --git a/Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap b/Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap new file mode 100644 index 0000000000..cf7fc47627 --- /dev/null +++ b/Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap @@ -0,0 +1,20 @@ +# Built-in function +DivisorsInt(Factorial(5)); +# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ] + +# A possible implementation, not suitable to large n +div := n -> Filtered([1 .. n], k -> n mod k = 0); + +div(Factorial(5)); +# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ] + +# Another implementation, usable for large n (if n can be factored quickly) +div2 := function(n) + local f, p; + f := Collected(FactorsInt(n)); + p := List(f, v -> List([0 .. v[2]], k -> v[1]^k)); + return SortedList(List(Cartesian(p), Product)); +end; + +div2(Factorial(5)); +# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ] diff --git a/Task/Factors-of-an-integer/Go/factors-of-an-integer.go b/Task/Factors-of-an-integer/Go/factors-of-an-integer.go new file mode 100644 index 0000000000..c825dfbedf --- /dev/null +++ b/Task/Factors-of-an-integer/Go/factors-of-an-integer.go @@ -0,0 +1,52 @@ +package main + +import "fmt" + +func main() { + printFactors(-1) + printFactors(0) + printFactors(1) + printFactors(2) + printFactors(3) + printFactors(53) + printFactors(45) + printFactors(64) + printFactors(600851475143) + printFactors(999999999999999989) +} + +func printFactors(nr int64) { + if nr < 1 { + fmt.Println("\nFactors of", nr, "not computed") + return + } + fmt.Printf("\nFactors of %d: ", nr) + fs := make([]int64, 1) + fs[0] = 1 + apf := func(p int64, e int) { + n := len(fs) + for i, pp := 0, p; i < e; i, pp = i+1, pp*p { + for j := 0; j < n; j++ { + fs = append(fs, fs[j]*pp) + } + } + } + e := 0 + for ; nr & 1 == 0; e++ { + nr >>= 1 + } + apf(2, e) + for d := int64(3); nr > 1; d += 2 { + if d*d > nr { + d = nr + } + for e = 0; nr%d == 0; e++ { + nr /= d + } + if e > 0 { + apf(d, e) + } + } + fmt.Println(fs) + fmt.Println("Number of factors =", len(fs)) +} diff --git a/Task/Factors-of-an-integer/Groovy/factors-of-an-integer-1.groovy b/Task/Factors-of-an-integer/Groovy/factors-of-an-integer-1.groovy new file mode 100644 index 0000000000..d422cc90b9 --- /dev/null +++ b/Task/Factors-of-an-integer/Groovy/factors-of-an-integer-1.groovy @@ -0,0 +1,13 @@ +def factorize = { long target -> + + if (target == 1) return [1L] + + if (target < 4) return [1L, target] + + def targetSqrt = Math.sqrt(target) + def lowfactors = (2L..targetSqrt).grep { (target % it) == 0 } + if (lowfactors == []) return [1L, target] + def nhalf = lowfactors.size() - ((lowfactors[-1] == targetSqrt) ? 1 : 0) + + [1] + lowfactors + (0..:)&.>/) __ q: 420 +┌─────┬───┬───┬───┐ +│1 2 4│1 3│1 5│1 7│ +└─────┴───┴───┴───┘ diff --git a/Task/Factors-of-an-integer/J/factors-of-an-integer-4.j b/Task/Factors-of-an-integer/J/factors-of-an-integer-4.j new file mode 100644 index 0000000000..6d29de6a01 --- /dev/null +++ b/Task/Factors-of-an-integer/J/factors-of-an-integer-4.j @@ -0,0 +1,6 @@ +factrs=: */&>@{@((^ i.@>:)&.>/)@q:~&__ + factrs 40 + 1 5 + 2 10 + 4 20 + 8 40 diff --git a/Task/Factors-of-an-integer/J/factors-of-an-integer-5.j b/Task/Factors-of-an-integer/J/factors-of-an-integer-5.j new file mode 100644 index 0000000000..efd8eced61 --- /dev/null +++ b/Task/Factors-of-an-integer/J/factors-of-an-integer-5.j @@ -0,0 +1,3 @@ + factors=: [: /:~@, */&>@{@((^ i.@>:)&.>/)@q:~&__ + factors 420 +1 2 3 4 5 6 7 10 12 14 15 20 21 28 30 35 42 60 70 84 105 140 210 420 diff --git a/Task/Factors-of-an-integer/J/factors-of-an-integer-6.j b/Task/Factors-of-an-integer/J/factors-of-an-integer-6.j new file mode 100644 index 0000000000..318ac2efa1 --- /dev/null +++ b/Task/Factors-of-an-integer/J/factors-of-an-integer-6.j @@ -0,0 +1,2 @@ + ~.,*/&> { 1 ,&.> q: 40 +1 5 2 10 4 20 8 40 diff --git a/Task/Factors-of-an-integer/J/factors-of-an-integer-7.j b/Task/Factors-of-an-integer/J/factors-of-an-integer-7.j new file mode 100644 index 0000000000..cfa234ef6c --- /dev/null +++ b/Task/Factors-of-an-integer/J/factors-of-an-integer-7.j @@ -0,0 +1,7 @@ +factorsOfNumber=: monad define + Y=. y"_ + /:~ ~. ( , Y%]) ( #~ 0=]|Y) 1+i.>.%:y +) + + factorsOfNumber 40 +1 2 4 5 8 10 20 40 diff --git a/Task/Factors-of-an-integer/Java/factors-of-an-integer.java b/Task/Factors-of-an-integer/Java/factors-of-an-integer.java new file mode 100644 index 0000000000..b2d73af86f --- /dev/null +++ b/Task/Factors-of-an-integer/Java/factors-of-an-integer.java @@ -0,0 +1,13 @@ +public static TreeSet factors(long n) +{ + TreeSet factors = new TreeSet(); + factors.add(n); + factors.add(1L); + for(long test = n - 1; test >= Math.sqrt(n); test--) + if(n % test == 0) + { + factors.add(test); + factors.add(n / test); + } + return factors; +} diff --git a/Task/Factors-of-an-integer/JavaScript/factors-of-an-integer.js b/Task/Factors-of-an-integer/JavaScript/factors-of-an-integer.js new file mode 100644 index 0000000000..b3ed1ef663 --- /dev/null +++ b/Task/Factors-of-an-integer/JavaScript/factors-of-an-integer.js @@ -0,0 +1,20 @@ +function factors(num) +{ + var + n_factors = [], + i; + + for (i = 1; i <= Math.floor(Math.sqrt(num)); i += 1) + if (num % i === 0) + { + n_factors.push(i); + if (num / i !== i) + n_factors.push(num / i); + } + n_factors.sort(function(a, b){return a - b;}); // numeric sort + return n_factors; +} + +factors(45); // [1,3,5,9,15,45] +factors(53); // [1,53] +factors(64); // [1,2,4,8,16,32,64] diff --git a/Task/Factors-of-an-integer/K/factors-of-an-integer.k b/Task/Factors-of-an-integer/K/factors-of-an-integer.k new file mode 100644 index 0000000000..62f8cfb163 --- /dev/null +++ b/Task/Factors-of-an-integer/K/factors-of-an-integer.k @@ -0,0 +1,23 @@ + f:{d:&~x!'!1+_sqrt x;?d,_ x%|d} + + f 1 +1 + + f 3 +1 3 + + f 120 +1 2 3 4 5 6 8 10 12 15 20 24 30 40 60 120 + + f 1024 +1 2 4 8 16 32 64 128 256 512 1024 + + f 600851475143 +1 71 839 1471 6857 59569 104441 486847 1234169 5753023 10086647 87625999 408464633 716151937 8462696833 600851475143 + + #f 3491888400 / has 1920 factors +1920 + + / Number of factors for 3491888400 .. 3491888409 + #:'f' 3491888400+!10 +1920 16 4 4 12 16 32 16 8 24 diff --git a/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-1.liberty b/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-1.liberty new file mode 100644 index 0000000000..291e74ed94 --- /dev/null +++ b/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-1.liberty @@ -0,0 +1,73 @@ +num = 10677106534462215678539721403561279 +maxnFactors = 1000 +dim primeFactors(maxnFactors), nPrimeFactors(maxnFactors) +global nDifferentPrimeNumbersFound, nFactors, iFactor + + +print "Start finding all factors of ";num; ":" + +nDifferentPrimeNumbersFound=0 +dummy = factorize(num,2) +nFactors = showPrimeFactors(num) +dim factors(nFactors) +dummy = generateFactors(1,1) +sort factors(), 0, nFactors-1 +for i=1 to nFactors + print i;" ";factors(i-1) +next i + +print "done" + +wait + + +function factorize(iNum,offset) + factorFound=0 + i = offset + do + if (iNum MOD i)=0 _ + then + if primeFactors(nDifferentPrimeNumbersFound) = i _ + then + nPrimeFactors(nDifferentPrimeNumbersFound) = nPrimeFactors(nDifferentPrimeNumbersFound) + 1 + else + nDifferentPrimeNumbersFound = nDifferentPrimeNumbersFound + 1 + primeFactors(nDifferentPrimeNumbersFound) = i + nPrimeFactors(nDifferentPrimeNumbersFound) = 1 + end if + if iNum/i<>1 then dummy = factorize(iNum/i,i) + factorFound=1 + end if + i=i+1 + loop while factorFound=0 and i<=sqr(iNum) + if factorFound=0 _ + then + nDifferentPrimeNumbersFound = nDifferentPrimeNumbersFound + 1 + primeFactors(nDifferentPrimeNumbersFound) = iNum + nPrimeFactors(nDifferentPrimeNumbersFound) = 1 + end if +end function + + +function showPrimeFactors(iNum) + showPrimeFactors=1 + print iNum;" = "; + for i=1 to nDifferentPrimeNumbersFound + print primeFactors(i);"^";nPrimeFactors(i); + if inDifferentPrimeNumbersFound _ + then + factors(iFactor) = product + iFactor=iFactor+1 + else + for i=0 to nPrimeFactors(pIndex) + dummy = generateFactors(product*primeFactors(pIndex)^i,pIndex+1) + next i + end if + end function diff --git a/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-2.liberty b/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-2.liberty new file mode 100644 index 0000000000..a1f577ddcf --- /dev/null +++ b/Task/Factors-of-an-integer/Liberty-BASIC/factors-of-an-integer-2.liberty @@ -0,0 +1,51 @@ +Start finding all factors of 10677106534462215678539721403561279: +10677106534462215678539721403561279 = 29269^1 * 32579^1 * 98731^2 * 104729^3 +1 1 +2 29269 +3 32579 +4 98731 +5 104729 +6 953554751 +7 2889757639 +8 3065313101 +9 3216557249 +10 3411966091 +11 9747810361 +12 10339998899 +13 10968163441 +14 94145414120981 +15 99864835517479 +16 285308661456109 +17 302641427774831 +18 317573913751019 +19 321027175754629 +20 336866824130521 +21 357331796744339 +22 1020878431297169 +23 1082897744693371 +24 1148684789012489 +25 9295070881578575111 +26 9859755075476219149 +27 10458744358910058191 +28 29880090805636839461 +29 31695334089430275799 +30 33259198413230468851 +31 33620855089606540541 +32 35279725624365333809 +33 37423001741237879131 +34 106915577231321212201 +35 113410797903992051459 +36 973463478356842592799919 +37 1032602289299548955255621 +38 1095333837964291484285239 +39 3129312029983540559911069 +40 3319420643851943354153471 +41 3483202590619213772296379 +42 3694810384914157044482761 +43 11197161487859039232598529 +44 101949856624833767901342716951 +45 108143405156052462534965931709 +46 327729719588146219298926345301 +47 364792324112959639158827476291 +48 10677106534462215678539721403561279 +done diff --git a/Task/Factors-of-an-integer/Logo/factors-of-an-integer.logo b/Task/Factors-of-an-integer/Logo/factors-of-an-integer.logo new file mode 100644 index 0000000000..6064639be2 --- /dev/null +++ b/Task/Factors-of-an-integer/Logo/factors-of-an-integer.logo @@ -0,0 +1,5 @@ +to factors :n + output filter [equal? 0 modulo :n ?] iseq 1 :n +end + +show factors 28 ; [1 2 4 7 14 28] diff --git a/Task/Factors-of-an-integer/Lua/factors-of-an-integer.lua b/Task/Factors-of-an-integer/Lua/factors-of-an-integer.lua new file mode 100644 index 0000000000..d4537ce8db --- /dev/null +++ b/Task/Factors-of-an-integer/Lua/factors-of-an-integer.lua @@ -0,0 +1,12 @@ +function Factors( n ) + local f = {} + + for i = 1, n/2 do + if n % i == 0 then + f[#f+1] = i + end + end + f[#f+1] = n + + return f +end diff --git a/Task/Factors-of-an-integer/MATLAB/factors-of-an-integer.m b/Task/Factors-of-an-integer/MATLAB/factors-of-an-integer.m new file mode 100644 index 0000000000..e8832a593b --- /dev/null +++ b/Task/Factors-of-an-integer/MATLAB/factors-of-an-integer.m @@ -0,0 +1,11 @@ + function fact(n); + f = factor(n); % prime decomposition + K = dec2bin(0:2^length(f)-1)-'0'; % generate all possible permutations + F = ones(1,2^length(f)); + for k = 1:size(K) + F(k) = prod(f(~K(k,:))); % and compute products + end; + F = unique(F); % eliminate duplicates + printf('There are %i factors for %i.\n',length(F),n); + disp(F); + end; diff --git a/Task/Factors-of-an-integer/MUMPS/factors-of-an-integer.mumps b/Task/Factors-of-an-integer/MUMPS/factors-of-an-integer.mumps new file mode 100644 index 0000000000..eb094f260b --- /dev/null +++ b/Task/Factors-of-an-integer/MUMPS/factors-of-an-integer.mumps @@ -0,0 +1,11 @@ +factors(num) New fctr,list,sep,sqrt + If num<1 Quit "Too small a number" + If num["." Quit "Not an integer" + Set sqrt=num**0.5\1 + For fctr=1:1:sqrt Set:num/fctr'["." list(fctr)=1,list(num/fctr)=1 + Set (list,fctr)="",sep="[" For Set fctr=$Order(list(fctr)) Quit:fctr="" Set list=list_sep_fctr,sep="," + Quit list_"]" + +w $$factors(45) ; [1,3,5,9,15,45] +w $$factors(53) ; [1,53] +w $$factors(64) ; [1,2,4,8,16,32,64] diff --git a/Task/Factors-of-an-integer/Mathematica/factors-of-an-integer.mathematica b/Task/Factors-of-an-integer/Mathematica/factors-of-an-integer.mathematica new file mode 100644 index 0000000000..96b7302ed4 --- /dev/null +++ b/Task/Factors-of-an-integer/Mathematica/factors-of-an-integer.mathematica @@ -0,0 +1 @@ +Factorize[n_Integer] := Divisors[n] diff --git a/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-1.maxima b/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-1.maxima new file mode 100644 index 0000000000..ca56e9c032 --- /dev/null +++ b/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-1.maxima @@ -0,0 +1,2 @@ +(%i96) divisors(100); +(%o96) {1,2,4,5,10,20,25,50,100} diff --git a/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-2.maxima b/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-2.maxima new file mode 100644 index 0000000000..42725b35d7 --- /dev/null +++ b/Task/Factors-of-an-integer/Maxima/factors-of-an-integer-2.maxima @@ -0,0 +1,5 @@ +divisors2(n) := map( lambda([l], lreduce("*", l)), + apply( cartesian_product, + map( lambda([fac], + setify(makelist(fac[1]^i, i, 0, fac[2]))), + ifactors(n)))); diff --git a/Task/Factors-of-an-integer/Mercury/factors-of-an-integer.mercury b/Task/Factors-of-an-integer/Mercury/factors-of-an-integer.mercury new file mode 100644 index 0000000000..907fc5d8fa --- /dev/null +++ b/Task/Factors-of-an-integer/Mercury/factors-of-an-integer.mercury @@ -0,0 +1,40 @@ +:- module fac. + +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module float, int, list, math, string. + +main(!IO) :- + io.command_line_arguments(Args, !IO), + list.filter_map(string.to_int, Args, CleanArgs), + list.foldl((pred(Arg::in, !.IO::di, !:IO::uo) is det :- + factor(Arg, X), + io.format("factor(%d, [", [i(Arg)], !IO), + io.write_list(X, ",", io.write_int, !IO), + io.write_string("])\n", !IO) + ), CleanArgs, !IO). + +:- pred factor(int::in, list(int)::out) is det. +factor(N, Factors) :- + Limit = float.truncate_to_int(math.sqrt(float(N))), + factor(N, 2, Limit, [], Unsorted), + list.sort_and_remove_dups([1, N | Unsorted], Factors). + +:- pred factor(int, int, int, list(int), list(int)). +:- mode factor(in, in, in, in, out) is det. +factor(N, X, Limit, !Accumulator) :- + ( if X > Limit + then true + else ( if 0 = N mod X + then !:Accumulator = [X, N / X | !.Accumulator] + else true ), + factor(N, X + 1, Limit, !Accumulator) ). + +:- func factor(int) = list(int). +%:- mode factor(in) = out is det. +factor(N) = Factors :- factor(N, Factors). + +:- end_module fac. diff --git a/Task/Factors-of-an-integer/PHP/factors-of-an-integer.php b/Task/Factors-of-an-integer/PHP/factors-of-an-integer.php new file mode 100644 index 0000000000..33d5f4fec2 --- /dev/null +++ b/Task/Factors-of-an-integer/PHP/factors-of-an-integer.php @@ -0,0 +1,12 @@ +function GetFactors($n){ + $factors = array(1, $n); + for($i = 2; $i * $i <= $n; $i++){ + if($n % $i == 0){ + $factors[] = $i; + if($i * $i != $n) + $factors[] = $n/$i; + } + } + sort($factors); + return $factors; +} diff --git a/Task/Factors-of-an-integer/Perl/factors-of-an-integer.pl b/Task/Factors-of-an-integer/Perl/factors-of-an-integer.pl new file mode 100644 index 0000000000..a2f4f485ac --- /dev/null +++ b/Task/Factors-of-an-integer/Perl/factors-of-an-integer.pl @@ -0,0 +1,6 @@ +sub factors +{ + my($n) = @_; + return grep { $n % $_ == 0 }(1 .. $n); +} +print join ' ',factors(64); diff --git a/Task/Factors-of-an-integer/PicoLisp/factors-of-an-integer.l b/Task/Factors-of-an-integer/PicoLisp/factors-of-an-integer.l new file mode 100644 index 0000000000..9efd5fe282 --- /dev/null +++ b/Task/Factors-of-an-integer/PicoLisp/factors-of-an-integer.l @@ -0,0 +1,4 @@ +(de factors (N) + (filter + '((D) (=0 (% N D))) + (range 1 N) ) ) diff --git a/Task/Factors-of-an-integer/Prolog/factors-of-an-integer.pro b/Task/Factors-of-an-integer/Prolog/factors-of-an-integer.pro new file mode 100644 index 0000000000..a9279ebfe1 --- /dev/null +++ b/Task/Factors-of-an-integer/Prolog/factors-of-an-integer.pro @@ -0,0 +1,26 @@ +factor(N, L) :- + factor(N, 1, [], L). + +factor(N, X, LC, L) :- + 0 is N mod X, + !, + Q is N / X, + (Q = X -> + sort([Q | LC], L) + ; + (Q > X -> + X1 is X+1, + factor(N, X1, [X, Q|LC], L) + ; + sort(LC, L) + ) + ). + +factor(N, X, LC, L) :- + Q is N / X, + (Q > X -> + X1 is X+1, + factor(N, X1, LC, L) + ; + sort(LC, L) + ). diff --git a/Task/Factors-of-an-integer/Python/factors-of-an-integer-1.py b/Task/Factors-of-an-integer/Python/factors-of-an-integer-1.py new file mode 100644 index 0000000000..a0928c5d9a --- /dev/null +++ b/Task/Factors-of-an-integer/Python/factors-of-an-integer-1.py @@ -0,0 +1,2 @@ +>>> def factors(n): + return [i for i in range(1, n + 1) if not n%i] diff --git a/Task/Factors-of-an-integer/Python/factors-of-an-integer-2.py b/Task/Factors-of-an-integer/Python/factors-of-an-integer-2.py new file mode 100644 index 0000000000..1238e13b35 --- /dev/null +++ b/Task/Factors-of-an-integer/Python/factors-of-an-integer-2.py @@ -0,0 +1,5 @@ +>>> def factors(n): + return [i for i in range(1, n//2 + 1) if not n%i] + [n] + +>>> factors(45) +[1, 3, 5, 9, 15, 45] diff --git a/Task/Factors-of-an-integer/Python/factors-of-an-integer-3.py b/Task/Factors-of-an-integer/Python/factors-of-an-integer-3.py new file mode 100644 index 0000000000..ff077bff37 --- /dev/null +++ b/Task/Factors-of-an-integer/Python/factors-of-an-integer-3.py @@ -0,0 +1,14 @@ +>>> from math import sqrt +>>> def factor(n): + factors = set() + for x in range(1, int(sqrt(n)) + 1): + if n % x == 0: + factors.add(x) + factors.add(n//x) + return sorted(factors) + +>>> for i in (45, 53, 64): print( "%i: factors: %s" % (i, factor(i)) ) + +45: factors: [1, 3, 5, 9, 15, 45] +53: factors: [1, 53] +64: factors: [1, 2, 4, 8, 16, 32, 64] diff --git a/Task/Factors-of-an-integer/Python/factors-of-an-integer-4.py b/Task/Factors-of-an-integer/Python/factors-of-an-integer-4.py new file mode 100644 index 0000000000..2104905adb --- /dev/null +++ b/Task/Factors-of-an-integer/Python/factors-of-an-integer-4.py @@ -0,0 +1,13 @@ +def factor(n): + a, r = 1, [1] + while a * a < n: + a += 1 + if n % a: continue + b, f = 1, [] + while n % a == 0: + n //= a + b *= a + f += [i * b for i in r] + r += f + if n > 1: r += [i * n for i in r] + return r diff --git a/Task/Factors-of-an-integer/R/factors-of-an-integer-1.r b/Task/Factors-of-an-integer/R/factors-of-an-integer-1.r new file mode 100644 index 0000000000..9e6db29310 --- /dev/null +++ b/Task/Factors-of-an-integer/R/factors-of-an-integer-1.r @@ -0,0 +1,12 @@ +factors <- function(n) +{ + if(length(n) > 1) + { + lapply(as.list(n), factors) + } else + { + one.to.n <- seq_len(n) + one.to.n[(n %% one.to.n) == 0] + } +} +factors(60) diff --git a/Task/Factors-of-an-integer/R/factors-of-an-integer-2.r b/Task/Factors-of-an-integer/R/factors-of-an-integer-2.r new file mode 100644 index 0000000000..ddd3d31eff --- /dev/null +++ b/Task/Factors-of-an-integer/R/factors-of-an-integer-2.r @@ -0,0 +1 @@ +factors(c(45, 53, 64)) diff --git a/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx b/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx new file mode 100644 index 0000000000..27075d8e59 --- /dev/null +++ b/Task/Factors-of-an-integer/REXX/factors-of-an-integer-1.rexx @@ -0,0 +1,18 @@ +/*REXX program to calculate and show divisors of positive integer(s). */ +parse arg low high .; high=word(high low 20,1); low=word(low 1,1) +numeric digits max(9,length(high)) /*ensure modulus has enough digs.*/ + + do n=low to high /*the default range is: 1 ──> 20*/ + say 'divisors of' right(n,length(high)) " ──► " divisors(n) + end /*n*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────DIVISORS subroutine─────────────────*/ +divisors: procedure; parse arg x 1 b; if x==1 then return 1; a=1; odd=x//2 + /*Odd? Then use only odd divisors*/ + do j=2+odd by 1+odd while j*jList(n/x,x)).toList.sort(_>_) diff --git a/Task/Factors-of-an-integer/Scheme/factors-of-an-integer.ss b/Task/Factors-of-an-integer/Scheme/factors-of-an-integer.ss new file mode 100644 index 0000000000..37cc801a17 --- /dev/null +++ b/Task/Factors-of-an-integer/Scheme/factors-of-an-integer.ss @@ -0,0 +1,9 @@ +(define (factors n) + (define (*factors d) + (cond ((> d n) (list)) + ((= (modulo n d) 0) (cons d (*factors (+ d 1)))) + (else (*factors (+ d 1))))) + (*factors 1)) + +(display (factors 1111111)) +(newline) diff --git a/Task/Factors-of-an-integer/Tcl/factors-of-an-integer.tcl b/Task/Factors-of-an-integer/Tcl/factors-of-an-integer.tcl new file mode 100644 index 0000000000..070bcdb8ba --- /dev/null +++ b/Task/Factors-of-an-integer/Tcl/factors-of-an-integer.tcl @@ -0,0 +1,12 @@ +proc factors {n} { + set factors {} + for {set i 1} {$i <= sqrt($n)} {incr i} { + if {$n % $i == 0} { + lappend factors $i [expr {$n / $i}] + } + } + return [lsort -unique -integer $factors] +} +puts [factors 64] +puts [factors 45] +puts [factors 53] diff --git a/Task/Fast-Fourier-transform/0DESCRIPTION b/Task/Fast-Fourier-transform/0DESCRIPTION new file mode 100644 index 0000000000..a4b80f2bf2 --- /dev/null +++ b/Task/Fast-Fourier-transform/0DESCRIPTION @@ -0,0 +1 @@ +The purpose of this task is to calculate the FFT (Fast Fourier Transform) of an input sequence. The most general case allows for complex numbers at the input and results in a sequence of equal length, again of complex numbers. If you need to restrict yourself to real numbers the output should be the magnitude (i.e. sqrt(re²+im²)) of the complex result. The classic version is the recursive Cooley–Tukey FFT. [http://en.wikipedia.org/wiki/Cooley–Tukey_FFT_algorithm Wikipedia] has pseudocode for that. Further optimizations are possible but not required. diff --git a/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-1.alg b/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-1.alg new file mode 100644 index 0000000000..6b7f7c3c9c --- /dev/null +++ b/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-1.alg @@ -0,0 +1,38 @@ +PRIO DICE = 9; # ideally = 11 # + +OP DICE = ([]SCALAR in, INT step)[]SCALAR: ( + ### Dice the array, extract array values a "step" apart ### + IF step = 1 THEN + in + ELSE + INT upb out := 0; + [(UPB in-LWB in)%step+1]SCALAR out; + FOR index FROM LWB in BY step TO UPB in DO + out[upb out+:=1] := in[index] OD; + out[@LWB in] + FI +); + +PROC fft = ([]SCALAR in t)[]SCALAR: ( + ### The Cooley-Tukey FFT algorithm ### + IF LWB in t >= UPB in t THEN + in t[@0] + ELSE + []SCALAR t = in t[@0]; + INT n = UPB t + 1, half n = n % 2; + [LWB t:UPB t]SCALAR coef; + + []SCALAR even = fft(t DICE 2), + odd = fft(t[1:]DICE 2); + + COMPL i = 0 I 1; + + REAL w = 2*pi / n; + FOR k FROM LWB t TO half n-1 DO + COMPL cis t = scalar exp(0 I (-w * k))*odd[k]; + coef[k] := even[k] + cis t; + coef[k + half n] := even[k] - cis t + OD; + coef + FI +); diff --git a/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-2.alg b/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-2.alg new file mode 100644 index 0000000000..f0e07d6183 --- /dev/null +++ b/Task/Fast-Fourier-transform/ALGOL-68/fast-fourier-transform-2.alg @@ -0,0 +1,22 @@ +#!/usr/local/bin/a68g --script # +# -*- coding: utf-8 -*- # + +MODE SCALAR = COMPL; +PROC (COMPL)COMPL scalar exp = complex exp; +PR READ "Template.Fast_Fourier_transform.a68" PR + +FORMAT real fmt := $g(0,3)$; +FORMAT real array fmt := $f(real fmt)", "$; +FORMAT compl fmt := $f(real fmt)"⊥"f(real fmt)$; +FORMAT compl array fmt := $f(compl fmt)", "$; + +test:( + []COMPL + tooth wave ft = fft((1, 1, 1, 1, 0, 0, 0, 0)), + one and a quarter wave ft = fft((0, 0.924, 0.707,-0.383,-1,-0.383, 0.707, 0.924, + 0,-0.924,-0.707, 0.383, 1, 0.383,-0.707,-0.924)); + printf(( + $"Tooth wave: "$,compl array fmt, tooth wave ft, $l$, + $"1¼ cycle wave: "$, compl array fmt, one and a quarter wave ft, $l$ + )) +) diff --git a/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-1.ada b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-1.ada new file mode 100644 index 0000000000..24c6ce5d03 --- /dev/null +++ b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-1.ada @@ -0,0 +1,7 @@ +with Ada.Numerics.Generic_Complex_Arrays; + +generic + with package Complex_Arrays is + new Ada.Numerics.Generic_Complex_Arrays (<>); + use Complex_Arrays; +function Generic_FFT (X : Complex_Vector) return Complex_Vector; diff --git a/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-2.ada b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-2.ada new file mode 100644 index 0000000000..578137caca --- /dev/null +++ b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-2.ada @@ -0,0 +1,39 @@ +with Ada.Numerics; +with Ada.Numerics.Generic_Complex_Elementary_Functions; + +function Generic_FFT (X : Complex_Vector) return Complex_Vector is + + package Complex_Elementary_Functions is + new Ada.Numerics.Generic_Complex_Elementary_Functions + (Complex_Arrays.Complex_Types); + + use Ada.Numerics; + use Complex_Elementary_Functions; + use Complex_Arrays.Complex_Types; + + function FFT (X : Complex_Vector; N, S : Positive) + return Complex_Vector is + begin + if N = 1 then + return (1..1 => X (X'First)); + else + declare + F : constant Complex := exp (Pi * j / Real_Arrays.Real (N/2)); + Even : Complex_Vector := FFT (X, N/2, 2*S); + Odd : Complex_Vector := FFT (X (X'First + S..X'Last), N/2, 2*S); + begin + for K in 0..N/2 - 1 loop + declare + T : constant Complex := Odd (Odd'First + K) / F ** K; + begin + Odd (Odd'First + K) := Even (Even'First + K) - T; + Even (Even'First + K) := Even (Even'First + K) + T; + end; + end loop; + return Even & Odd; + end; + end if; + end FFT; +begin + return FFT (X, X'Length, 1); +end Generic_FFT; diff --git a/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-3.ada b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-3.ada new file mode 100644 index 0000000000..97309d3333 --- /dev/null +++ b/Task/Fast-Fourier-transform/Ada/fast-fourier-transform-3.ada @@ -0,0 +1,20 @@ +with Ada.Numerics.Complex_Arrays; use Ada.Numerics.Complex_Arrays; +with Ada.Complex_Text_IO; use Ada.Complex_Text_IO; +with Ada.Text_IO; use Ada.Text_IO; + +with Ada.Numerics.Complex_Elementary_Functions; +with Generic_FFT; + +procedure Example is + function FFT is new Generic_FFT (Ada.Numerics.Complex_Arrays); + X : Complex_Vector := (1..4 => (1.0, 0.0), 5..8 => (0.0, 0.0)); + Y : Complex_Vector := FFT (X); +begin + Put_Line (" X FFT X "); + for I in Y'Range loop + Put (X (I - Y'First + X'First), Aft => 3, Exp => 0); + Put (" "); + Put (Y (I), Aft => 3, Exp => 0); + New_Line; + end loop; +end; diff --git a/Task/Fast-Fourier-transform/BBC-BASIC/fast-fourier-transform.bbc b/Task/Fast-Fourier-transform/BBC-BASIC/fast-fourier-transform.bbc new file mode 100644 index 0000000000..a2ae4ceeba --- /dev/null +++ b/Task/Fast-Fourier-transform/BBC-BASIC/fast-fourier-transform.bbc @@ -0,0 +1,44 @@ + @% = &60A + + DIM Complex{r#, i#} + DIM in{(7)} = Complex{}, out{(7)} = Complex{} + DATA 1, 1, 1, 1, 0, 0, 0, 0 + + PRINT "Input (real, imag):" + FOR I% = 0 TO 7 + READ in{(I%)}.r# + PRINT in{(I%)}.r# "," in{(I%)}.i# + NEXT + + PROCfft(out{()}, in{()}, 0, 1, DIM(in{()},1)+1) + + PRINT "Output (real, imag):" + FOR I% = 0 TO 7 + PRINT out{(I%)}.r# "," out{(I%)}.i# + NEXT + END + + DEF PROCfft(b{()}, o{()}, B%, S%, N%) + LOCAL I%, t{} : DIM t{} = Complex{} + IF S% < N% THEN + PROCfft(o{()}, b{()}, B%, S%*2, N%) + PROCfft(o{()}, b{()}, B%+S%, S%*2, N%) + FOR I% = 0 TO N%-1 STEP 2*S% + t.r# = COS(-PI*I%/N%) + t.i# = SIN(-PI*I%/N%) + PROCcmul(t{}, o{(B%+I%+S%)}) + b{(B%+I% DIV 2)}.r# = o{(B%+I%)}.r# + t.r# + b{(B%+I% DIV 2)}.i# = o{(B%+I%)}.i# + t.i# + b{(B%+(I%+N%) DIV 2)}.r# = o{(B%+I%)}.r# - t.r# + b{(B%+(I%+N%) DIV 2)}.i# = o{(B%+I%)}.i# - t.i# + NEXT + ENDIF + ENDPROC + + DEF PROCcmul(c{},d{}) + LOCAL r#, i# + r# = c.r#*d.r# - c.i#*d.i# + i# = c.r#*d.i# + c.i#*d.r# + c.r# = r# + c.i# = i# + ENDPROC diff --git a/Task/Fast-Fourier-transform/C++/fast-fourier-transform.cpp b/Task/Fast-Fourier-transform/C++/fast-fourier-transform.cpp new file mode 100644 index 0000000000..ea71b12340 --- /dev/null +++ b/Task/Fast-Fourier-transform/C++/fast-fourier-transform.cpp @@ -0,0 +1,45 @@ +#include +#include +#include + +const double PI = 3.141592653589793238460; + +typedef std::complex Complex; +typedef std::valarray CArray; + +// Cooley–Tukey FFT (in-place) +void fft(CArray& x) +{ + const size_t N = x.size(); + if (N <= 1) return; + + // divide + CArray even = x[std::slice(0, N/2, 2)]; + CArray odd = x[std::slice(1, N/2, 2)]; + + // conquer + fft(even); + fft(odd); + + // combine + for (size_t k = 0; k < N/2; ++k) + { + Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k]; + x[k ] = even[k] + t; + x[k+N/2] = even[k] - t; + } +} + +int main() +{ + const Complex test[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }; + CArray data(test, 8); + + fft(data); + + for (int i = 0; i < 8; ++i) + { + std::cout << data[i] << "\n"; + } + return 0; +} diff --git a/Task/Fast-Fourier-transform/C/fast-fourier-transform-1.c b/Task/Fast-Fourier-transform/C/fast-fourier-transform-1.c new file mode 100644 index 0000000000..21c5b24912 --- /dev/null +++ b/Task/Fast-Fourier-transform/C/fast-fourier-transform-1.c @@ -0,0 +1,49 @@ +#include +#include +#include + +double PI; +typedef double complex cplx; + +void _fft(cplx buf[], cplx out[], int n, int step) +{ + if (step < n) { + _fft(out, buf, n, step * 2); + _fft(out + step, buf + step, n, step * 2); + + for (int i = 0; i < n; i += 2 * step) { + cplx t = cexp(-I * PI * i / n) * out[i + step]; + buf[i / 2] = out[i] + t; + buf[(i + n)/2] = out[i] - t; + } + } +} + +void fft(cplx buf[], int n) +{ + cplx out[n]; + for (int i = 0; i < n; i++) out[i] = buf[i]; + + _fft(buf, out, n, 1); +} + +int main() +{ + PI = atan2(1, 1) * 4; + cplx buf[] = {1, 1, 1, 1, 0, 0, 0, 0}; + + void show(const char * s) { + printf("%s", s); + for (int i = 0; i < 8; i++) + if (!cimag(buf[i])) + printf("%g ", creal(buf[i])); + else + printf("(%g, %g) ", creal(buf[i]), cimag(buf[i])); + } + + show("Data: "); + fft(buf, 8); + show("\nFFT : "); + + return 0; +} diff --git a/Task/Fast-Fourier-transform/C/fast-fourier-transform-2.c b/Task/Fast-Fourier-transform/C/fast-fourier-transform-2.c new file mode 100644 index 0000000000..427fd572bc --- /dev/null +++ b/Task/Fast-Fourier-transform/C/fast-fourier-transform-2.c @@ -0,0 +1,2 @@ +Data: 1 1 1 1 0 0 0 0 +FFT : 4 (1, -2.41421) 0 (1, -0.414214) 0 (1, 0.414214) 0 (1, 2.41421) diff --git a/Task/Fast-Fourier-transform/D/fast-fourier-transform-1.d b/Task/Fast-Fourier-transform/D/fast-fourier-transform-1.d new file mode 100644 index 0000000000..f68b1d9f32 --- /dev/null +++ b/Task/Fast-Fourier-transform/D/fast-fourier-transform-1.d @@ -0,0 +1,15 @@ +import std.stdio, std.math, std.algorithm, std.range; + +/*auto*/ creal[] fft(/*in*/ creal[] x) /*pure nothrow*/ { + int N = x.length; + if (N <= 1) return x; + auto ev = stride(x, 2).array().fft(); + auto od = stride(x[1 .. $], 2).array().fft(); + auto l = map!(k => ev[k] + expi(-2*PI*k/N) * od[k])(iota(N / 2)); + auto r = map!(k => ev[k] - expi(-2*PI*k/N) * od[k])(iota(N / 2)); + return l.chain(r).array(); +} + +void main() { + writeln(fft([1.0L+0i, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0])); +} diff --git a/Task/Fast-Fourier-transform/D/fast-fourier-transform-2.d b/Task/Fast-Fourier-transform/D/fast-fourier-transform-2.d new file mode 100644 index 0000000000..e6158c28c4 --- /dev/null +++ b/Task/Fast-Fourier-transform/D/fast-fourier-transform-2.d @@ -0,0 +1,19 @@ +import std.stdio, std.math, std.algorithm, std.range, std.complex; + +auto fft(Complex!real[] x) +{ + ulong N = x.length; + if (N <= 1) { return x; } + auto ev = stride(x, 2).array.fft; + auto od = stride(x[1 .. $], 2).array.fft; + auto l = map!(k => ev[k] + std.complex.expi(-2*PI*k/N) * od[k])(iota(N / 2)); + auto r = map!(k => ev[k] - std.complex.expi(-2*PI*k/N) * od[k])(iota(N / 2)); + return l.chain(r).array; +} + +void main() +{ + // map produces range, .array converts range to array + auto data = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0].map!(a => Complex!real(a, 0)).array; + data.fft.writeln; +} diff --git a/Task/Fast-Fourier-transform/D/fast-fourier-transform-3.d b/Task/Fast-Fourier-transform/D/fast-fourier-transform-3.d new file mode 100644 index 0000000000..5d02157c26 --- /dev/null +++ b/Task/Fast-Fourier-transform/D/fast-fourier-transform-3.d @@ -0,0 +1,5 @@ +import std.stdio : writeln; +import std.numeric : fft; +void main() { + [1.0, 1.0, 1.0, 1.0, 0, 0, 0, 0].fft.writeln; +} diff --git a/Task/Fast-Fourier-transform/Fortran/fast-fourier-transform.f b/Task/Fast-Fourier-transform/Fortran/fast-fourier-transform.f new file mode 100644 index 0000000000..fd4d3e4b5f --- /dev/null +++ b/Task/Fast-Fourier-transform/Fortran/fast-fourier-transform.f @@ -0,0 +1,60 @@ +module fft_mod + implicit none + integer, parameter :: dp=selected_real_kind(15,300) + real(kind=dp), parameter :: pi=3.141592653589793238460_dp +contains + + ! In place Cooley-Tukey FFT + recursive subroutine fft(x) + complex(kind=dp), dimension(:), intent(inout) :: x + complex(kind=dp) :: t + integer :: N + integer :: i + complex(kind=dp), dimension(:), allocatable :: even, odd + + N=size(x) + + if(n.le.1) return + + allocate(odd((N+1)/2)) + allocate(even(N/2)) + + ! divide + odd =x(1:N:2) + even=x(2:N:2) + + ! conquer + call fft(odd) + call fft(even) + + ! combine + do i=1,N/2 + + +t=exp(cmplx(0.0_dp,-2.0_dp*pi*real(i-1,dp)/real(N,dp),KIND=DP))*even(i) + x(i) = odd(i) + t + x(i+N/2) = odd(i) - t + end do + + deallocate(odd) + deallocate(even) + + end subroutine fft + +end module fft_mod + +program test + use fft_mod + implicit none + complex(kind=dp), dimension(8) :: data = (/1.0, 1.0, 1.0, 1.0, 0.0, + +0.0, 0.0, 0.0/) + integer :: i + + call fft(data) + + do i=1,8 + write(*,'("(", F20.15, ",", F20.15, "i )")') data(i) + end do + +end program test diff --git a/Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap b/Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap new file mode 100644 index 0000000000..6279554cca --- /dev/null +++ b/Task/Fast-Fourier-transform/GAP/fast-fourier-transform.gap @@ -0,0 +1,23 @@ +# Here an implementation with no optimization (O(n^2)). +# In GAP, E(n) = exp(2*i*pi/n), a primitive root of the unity. + +Fourier := function(a) + local n, z; + n := Size(a); + z := E(n); + return List([0 .. n - 1], k -> Sum([0 .. n - 1], j -> a[j + 1]*z^(-k*j))); +end; + +InverseFourier := function(a) + local n, z; + n := Size(a); + z := E(n); + return List([0 .. n - 1], k -> Sum([0 .. n - 1], j -> a[j + 1]*z^(k*j)))/n; +end; + +Fourier([1, 1, 1, 1, 0, 0, 0, 0]); +# [ 4, 1-E(8)-E(8)^2-E(8)^3, 0, 1-E(8)+E(8)^2-E(8)^3, +# 0, 1+E(8)-E(8)^2+E(8)^3, 0, 1+E(8)+E(8)^2+E(8)^3 ] + +InverseFourier(last); +# [ 1, 1, 1, 1, 0, 0, 0, 0 ] diff --git a/Task/Fast-Fourier-transform/Go/fast-fourier-transform.go b/Task/Fast-Fourier-transform/Go/fast-fourier-transform.go new file mode 100644 index 0000000000..05c38e6d61 --- /dev/null +++ b/Task/Fast-Fourier-transform/Go/fast-fourier-transform.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "math" + "math/cmplx" +) + +func ditfft2(x []float64, y []complex128, n, s int) { + if n == 1 { + y[0] = complex(x[0], 0) + return + } + ditfft2(x, y, n/2, 2*s) + ditfft2(x[s:], y[n/2:], n/2, 2*s) + for k := 0; k < n/2; k++ { + tf := cmplx.Rect(1, -2*math.Pi*float64(k)/float64(n)) * y[k+n/2] + y[k], y[k+n/2] = y[k]+tf, y[k]-tf + } +} + +func main() { + x := []float64{1, 1, 1, 1, 0, 0, 0, 0} + y := make([]complex128, len(x)) + ditfft2(x, y, len(x), 1) + for _, c := range y { + fmt.Printf("%8.4f\n", c) + } +} diff --git a/Task/Fast-Fourier-transform/Haskell/fast-fourier-transform.hs b/Task/Fast-Fourier-transform/Haskell/fast-fourier-transform.hs new file mode 100644 index 0000000000..d811dd4e8e --- /dev/null +++ b/Task/Fast-Fourier-transform/Haskell/fast-fourier-transform.hs @@ -0,0 +1,17 @@ +import Data.Complex + +-- Cooley-Tukey +fft [] = [] +fft [x] = [x] +fft xs = zipWith (+) ys ts ++ zipWith (-) ys ts + where n = length xs + ys = fft evens + zs = fft odds + (evens, odds) = split xs + split [] = ([], []) + split [x] = ([x], []) + split (x:y:xs) = (x:xt, y:yt) where (xt, yt) = split xs + ts = zipWith (\z k -> exp' k n * z) zs [0..] + exp' k n = cis $ -2 * pi * (fromIntegral k) / (fromIntegral n) + +main = mapM_ print $ fft [1,1,1,1,0,0,0,0] diff --git a/Task/Fast-Fourier-transform/J/fast-fourier-transform-1.j b/Task/Fast-Fourier-transform/J/fast-fourier-transform-1.j new file mode 100644 index 0000000000..4f0b412325 --- /dev/null +++ b/Task/Fast-Fourier-transform/J/fast-fourier-transform-1.j @@ -0,0 +1,4 @@ +cube =: ($~ q:@#) :. , +rou =: ^@j.@o.@(% #)@i.@-: NB. roots of unity +floop =: 4 : 'for_r. i.#$x do. (y=.{."1 y) ] x=.(+/x) ,&,:"r (-/x)*y end.' +fft =: ] floop&.cube rou@# diff --git a/Task/Fast-Fourier-transform/J/fast-fourier-transform-2.j b/Task/Fast-Fourier-transform/J/fast-fourier-transform-2.j new file mode 100644 index 0000000000..737ec8889d --- /dev/null +++ b/Task/Fast-Fourier-transform/J/fast-fourier-transform-2.j @@ -0,0 +1,3 @@ + (**+)&.+. (,: fft) 1 o. 2p1*3r16 * i.16 +0 0.92388 0.707107 0.382683 1 0.382683 0.707107 0.92388 0 0.92388 0.707107 0.382683 1 0.382683 0.707107 0.92388 +0 0 0 0j8 0 0 0 0 0 0 0 0 0 0j8 0 0 diff --git a/Task/Fast-Fourier-transform/J/fast-fourier-transform-3.j b/Task/Fast-Fourier-transform/J/fast-fourier-transform-3.j new file mode 100644 index 0000000000..6f6139d699 --- /dev/null +++ b/Task/Fast-Fourier-transform/J/fast-fourier-transform-3.j @@ -0,0 +1,9 @@ + Re=: {.@+.@fft + Im=: {:@+.@fft + M=: 4#1 0 + M +1 1 1 1 0 0 0 0 + Re M +4 1 0 1 0 1 0 1 + Im M +0 2.41421 0 0.414214 0 _0.414214 0 _2.41421 diff --git a/Task/Fast-Fourier-transform/Liberty-BASIC/fast-fourier-transform.liberty b/Task/Fast-Fourier-transform/Liberty-BASIC/fast-fourier-transform.liberty new file mode 100644 index 0000000000..d24046979c --- /dev/null +++ b/Task/Fast-Fourier-transform/Liberty-BASIC/fast-fourier-transform.liberty @@ -0,0 +1,105 @@ + P =8 + S =int( log( P) /log( 2) +0.9999) + + Pi =3.14159265 + R1 =2^S + + R =R1 -1 + R2 =div( R1, 2) + R4 =div( R1, 4) + R3 =R4 +R2 + + Dim Re( R1), Im( R1), Co( R3) + + for N =0 to P -1 + read dummy: Re( N) =dummy + read dummy: Im( N) =dummy + next N + + data 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + S2 =div( S, 2) + S1 =S -S2 + P1 =2^S1 + P2 =2^S2 + + dim V( P1 -1) + V( 0) =0 + DV =1 + DP =P1 + + for J =1 to S1 + HA =div( DP, 2) + PT =P1 -HA + for I =HA to PT step DP + V( I) =V( I -HA) +DV + next I + DV =DV +DV + DP =HA + next J + + K =2 *Pi /R1 + + for X =0 to R4 + COX =cos( K *X) + Co( X) =COX + Co( R2 -X) =0 -COX + Co( R2 +X) =0 -COX + next X + + print "FFT: bit reversal" + + for I =0 to P1 -1 + IP =I *P2 + for J =0 to P2 -1 + H =IP +J + G =V( J) *P2 +V( I) + if G >H then temp =Re( G): Re( G) =Re( H): Re( H) =temp + if G >H then temp =Im( G): Im( G) =Im( H): Im( H) =temp + next J + next I + + T =1 + + for stage =0 to S -1 + print " Stage:- "; stage + D =div( R2, T) + for Z =0 to T -1 + L =D *Z + LS =L +R4 + for I =0 to D -1 + A =2 *I *T +Z + B =A +T + F1 =Re( A) + F2 =Im( A) + P1 =Co( L) *Re( B) + P2 =Co( LS) *Im( B) + P3 =Co( LS) *Re( B) + P4 =Co( L) *Im( B) + Re( A) =F1 +P1 -P2 + Im( A) =F2 +P3 +P4 + Re( B) =F1 -P1 +P2 + Im( B) =F2 -P3 -P4 + next I + next Z + T =T +T + next stage + + print " M Re( M) Im( M)" + + for M =0 to R + if abs( Re( M)) <10^-5 then Re( M) =0 + if abs( Im( M)) <10^-5 then Im( M) =0 + print " "; M, Re( M), Im( M) + next M + + end + + + wait + + function div( a, b) + div =int( a /b) + end function + + end diff --git a/Task/Fast-Fourier-transform/MATLAB/fast-fourier-transform.m b/Task/Fast-Fourier-transform/MATLAB/fast-fourier-transform.m new file mode 100644 index 0000000000..4a06ec63d5 --- /dev/null +++ b/Task/Fast-Fourier-transform/MATLAB/fast-fourier-transform.m @@ -0,0 +1 @@ + fft([1,1,1,1,0,0,0,0]') diff --git a/Task/Fast-Fourier-transform/Mathematica/fast-fourier-transform.mathematica b/Task/Fast-Fourier-transform/Mathematica/fast-fourier-transform.mathematica new file mode 100644 index 0000000000..b1a04c9722 --- /dev/null +++ b/Task/Fast-Fourier-transform/Mathematica/fast-fourier-transform.mathematica @@ -0,0 +1 @@ +Fourier[{1,1,1,1,0,0,0,0}, FourierParameters->{1,-1}] diff --git a/Task/Fast-Fourier-transform/Maxima/fast-fourier-transform.maxima b/Task/Fast-Fourier-transform/Maxima/fast-fourier-transform.maxima new file mode 100644 index 0000000000..4c04161fcf --- /dev/null +++ b/Task/Fast-Fourier-transform/Maxima/fast-fourier-transform.maxima @@ -0,0 +1,3 @@ +load(fft)$ +fft([1, 2, 3, 4]); +[2.5, -0.5 * %i - 0.5, -0.5, 0.5 * %i - 0.5] diff --git a/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-1.l b/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-1.l new file mode 100644 index 0000000000..c0d495a19a --- /dev/null +++ b/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-1.l @@ -0,0 +1,20 @@ +# apt-get install libfftw3-dev + +(scl 4) + +(de FFTW_FORWARD . -1) +(de FFTW_ESTIMATE . 64) + +(de fft (Lst) + (let + (Len (length Lst) + In (native "libfftw3.so" "fftw_malloc" 'N (* Len 16)) + Out (native "libfftw3.so" "fftw_malloc" 'N (* Len 16)) + P (native "libfftw3.so" "fftw_plan_dft_1d" 'N + Len In Out FFTW_FORWARD FFTW_ESTIMATE ) ) + (struct In NIL (cons 1.0 (apply append Lst))) + (native "libfftw3.so" "fftw_execute" NIL P) + (prog1 (struct Out (make (do Len (link (1.0 . 2))))) + (native "libfftw3.so" "fftw_destroy_plan" NIL P) + (native "libfftw3.so" "fftw_free" NIL Out) + (native "libfftw3.so" "fftw_free" NIL In) ) ) ) diff --git a/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-2.l b/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-2.l new file mode 100644 index 0000000000..fcf9ee4451 --- /dev/null +++ b/Task/Fast-Fourier-transform/PicoLisp/fast-fourier-transform-2.l @@ -0,0 +1,4 @@ +(for R (fft '((1.0 0) (1.0 0) (1.0 0) (1.0 0) (0 0) (0 0) (0 0) (0 0))) + (tab (6 8) + (round (car R)) + (round (cadr R)) ) ) diff --git a/Task/Fast-Fourier-transform/Python/fast-fourier-transform-1.py b/Task/Fast-Fourier-transform/Python/fast-fourier-transform-1.py new file mode 100644 index 0000000000..fc0151d1d4 --- /dev/null +++ b/Task/Fast-Fourier-transform/Python/fast-fourier-transform-1.py @@ -0,0 +1,11 @@ +from cmath import exp, pi + +def fft(x): + N = len(x) + if N <= 1: return x + even = fft(x[0::2]) + odd = fft(x[1::2]) + return [even[k] + exp(-2j*pi*k/N)*odd[k] for k in xrange(N/2)] + \ + [even[k] - exp(-2j*pi*k/N)*odd[k] for k in xrange(N/2)] + +print fft([1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]) diff --git a/Task/Fast-Fourier-transform/Python/fast-fourier-transform-2.py b/Task/Fast-Fourier-transform/Python/fast-fourier-transform-2.py new file mode 100644 index 0000000000..33534e7988 --- /dev/null +++ b/Task/Fast-Fourier-transform/Python/fast-fourier-transform-2.py @@ -0,0 +1,5 @@ +>>> from numpy.fft import fft +>>> from numpy import array +>>> a = array((0.0, 0.924, 0.707, -0.383, -1.0, -0.383, 0.707, 0.924, 0.0, -0.924, -0.707, 0.383, 1.0, 0.383, -0.707, -0.924)) +>>> print( ' '.join("%5.3f" % abs(f) for f in fft(a)) ) +0.000 0.001 0.000 8.001 0.000 0.001 0.000 0.001 0.000 0.001 0.000 0.001 0.000 8.001 0.000 0.001 diff --git a/Task/Fast-Fourier-transform/R/fast-fourier-transform.r b/Task/Fast-Fourier-transform/R/fast-fourier-transform.r new file mode 100644 index 0000000000..c753e33866 --- /dev/null +++ b/Task/Fast-Fourier-transform/R/fast-fourier-transform.r @@ -0,0 +1 @@ +fft(c(1,1,1,1,0,0,0,0)) diff --git a/Task/Fast-Fourier-transform/REXX/fast-fourier-transform.rexx b/Task/Fast-Fourier-transform/REXX/fast-fourier-transform.rexx new file mode 100644 index 0000000000..95ec69c891 --- /dev/null +++ b/Task/Fast-Fourier-transform/REXX/fast-fourier-transform.rexx @@ -0,0 +1,77 @@ +/*REXX pgm does a fast Fourier transform (FFT) on a set of complex nums.*/ +numeric digits 85 +arg data; if data='' then data='1 1 1 1 0' /*no data? Then use default*/ +data=translate(data, 'J', "I") /*allow use of i as well as j */ +size=words(data); pad=left('',6) /*PAD: for indenting/padding SAYs*/ + do sig=0 until 2**sig>=size ;end /* # args exactly a power of 2?*/ + do j=size+1 to 2**sig;data=data 0;end /*add zeroes until a power of 2.*/ +size=words(data); call hdr /*┌─────────────────────────────┐*/ + /*│ Numbers in data can be in │*/ + do j=0 for size /*│ 7 formats: real │*/ + _=word(data,j+1) /*│ real,imag │*/ + parse var _ #.1.j ',' #.2.j /*│ ,imag │*/ + if right(#.1.j,1)=='J' then /*│ nnnJ │*/ + parse var #.1.j #2.j "J" @.1.j /*│ nnnj │*/ + do p=1 for 2 /*omitted?*/ /*│ nnnI │*/ + #.p.j=word(#.p.j 0, 1) /*│ nnni │*/ + end /*p*/ /*└─────────────────────────────┘*/ + say pad " FFT in " center(j+1,7) pad nice(#.1.j) nice(#.2.j,'i') + end /*j*/ + +say; say; tran=2*pi()/2**sig; !.=0 +hsig=2**sig%2; counterA=2**(sig-sig%2); pointer=counterA; doubler=1 + + do sig-sig%2; halfpointer=pointer%2 + do i=halfpointer by pointer to counterA-halfpointer + _=i-halfpointer; !.i=!._+doubler + end /*i*/ + doubler=doubler*2; pointer=halfpointer + end /*sig-sig%2*/ + + do j=0 to 2**sig%4; cmp.j=cos(j*tran); _m=hsig-j; cmp._m=-cmp.j + _p=hsig+j; cmp._p=-cmp.j + end /*j*/ + +counterB=2**(sig%2) + + do i=0 for counterA; p=i*counterB + do j=0 for counterB; h=p+j; _=!.j*counterB+!.i; if _<=h then iterate + parse value #.1._ #.1.h #.2._ #.2.h with #.1.h #.1._ #.2.h #.2._ + end /*j*/ /* [↓] switch two sets of values*/ + end /*i*/ + +double=1; do sig ; w=2**sig%2%double + do k=0 for double ; lb=w*k ; lh=lb+2**sig%4 + do j=0 for w ; a=j*double*2+k ; b=a+double + r=#.1.a; i=#.2.a ; c1=cmp.lb*#.1.b ; c4=cmp.lb*#.2.b + c2=cmp.lh*#.2.b ; c3=cmp.lh*#.1.b + #.1.a=r+c1-c2 ; #.2.a=i+c3+c4 + #.1.b=r-c1+c2 ; #.2.b=i-c3-c4 + end /*j*/ + end /*k*/ + double=double+double + end /*sig*/ +call hdr + do i=0 for size + say pad " FFT out " center(i+1,7) pad nice(#.1.i) nice(#.2.i,'j') + end /*i*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────HDR subroutine──────────────────────*/ +hdr: _='───data─── num real-part imaginary-part'; say pad _ + say pad translate(_, " "copies('═',256), " "xrange()); return +/*──────────────────────────────────PI subroutine───────────────────────────────────*/ +pi: return , /*add more digs if NUMERIC DIGITS > 85. */ +3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628 +/*──────────────────────────────────R2R subroutine──────────────────────*/ +r2r: return arg(1) // (2*pi()) /*reduce radians to unit circle. */ +/*──────────────────────────────────COS subroutine──────────────────────*/ +cos: procedure; parse arg x; x=r2r(x); return .sincos(1,1,-1) +.sincos: parse arg z,_,i; x=x*x; p=z + do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_; if z=p then leave; p=z; end + return z +/*──────────────────────────────────NICE subroutine─────────────────────*/ +nice: procedure; parse arg x,j /*makes complex nums look nicer. */ +numeric digits digits()%10; nz='1e-'digits() /*show ≈10% of DIGITS.*/ +if abs(x)=0 then x=' '||x; return left(x||j,digits()+4) diff --git a/Task/Fast-Fourier-transform/Scala/fast-fourier-transform.scala b/Task/Fast-Fourier-transform/Scala/fast-fourier-transform.scala new file mode 100644 index 0000000000..08ae1d4449 --- /dev/null +++ b/Task/Fast-Fourier-transform/Scala/fast-fourier-transform.scala @@ -0,0 +1,32 @@ +object FFT extends App { + import scala.math._ + + case class Complex(re: Double, im: Double = 0.0) { + def +(x: Complex): Complex = Complex((this.re+x.re),(this.im+x.im)) + def -(x: Complex): Complex = Complex((this.re-x.re),(this.im-x.im)) + def *(x: Complex): Complex = Complex(this.re*x.re-this.im*x.im,this.re*x.im+this.im*x.re) + } + + def fft(f: List[Complex]): List[Complex] = { + import Stream._ + require((f.size==0)||(from(0) map {x=>pow(2,x).toInt}).takeWhile(_<2*f.size).toList.exists(_==f.size)==true,"list size "+f.size+" not allowed!") + f.size match { + case 0 => Nil + case 1 => f + case n => { + val cis: Double => Complex = phi => Complex(cos(phi),sin(phi)) + val e = fft(f.zipWithIndex.filter(_._2%2==0).map(_._1)) + val o = fft(f.zipWithIndex.filter(_._2%2!=0).map(_._1)) + import scala.collection.mutable.ListBuffer + val lb = new ListBuffer[Pair[Int, Complex]]() + for (k <- 0 to n/2-1) { + lb += Pair(k,e(k)+o(k)*cis(-2*Pi*k/n)) + lb += Pair(k+n/2,e(k)-o(k)*cis(-2*Pi*k/n)) + } + lb.toList.sortWith((x,y)=>x._1n = 2 we have the Fibonacci sequence; with initial values [1, 1] and F_k^2 = F_{k-1}^2 + F_{k-2}^2 +# For n = 3 we have the tribonacci sequence; with initial values [1, 1, 2] and F_k^3 = F_{k-1}^3 + F_{k-2}^3 + F_{k-3}^3 +# For n = 4 we have the tetranacci sequence; with initial values [1, 1, 2, 4] and F_k^4 = F_{k-1}^4 + F_{k-2}^4 + F_{k-3}^4 + F_{k-4}^4
... +# For general n>2 we have the Fibonacci n-step sequence - F_k^n; with initial values of the first n values of the (n-1)'th Fibonacci n-step sequence F_k^{n-1}; and k'th value of this n'th sequence being F_k^n = \sum_{i=1}^{(n)} {F_{k-i}^{(n)}} + +For small values of n, [[wp:Number prefix#Greek_series|Greek numeric prefixes]] are sometimes used to individually name each series. + +:{| style="text-align: left;" border="4" cellpadding="2" cellspacing="2" +|+ Fibonacci n-step sequences +|- style="background-color: rgb(255, 204, 255);" +! n !! Series name !! Values +|- +| 2 || fibonacci || 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ... +|- +| 3 || tribonacci || 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 ... +|- +| 4 || tetranacci || 1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536 ... +|- +| 5 || pentanacci || 1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930 ... +|- +| 6 || hexanacci || 1 1 2 4 8 16 32 63 125 248 492 976 1936 3840 7617 ... +|- +| 7 || heptanacci || 1 1 2 4 8 16 32 64 127 253 504 1004 2000 3984 7936 ... +|- +| 8 || octonacci || 1 1 2 4 8 16 32 64 128 255 509 1016 2028 4048 8080 ... +|- +| 9 || nonanacci || 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144 ... +|- +| 10 || decanacci || 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172 ... +|} + +Allied sequences can be generated where the initial values are changed: +: '''The [[wp:Lucas number|Lucas series]]''' sums the two preceeding values like the fibonacci series for n=2 but uses [2, 1] as its initial values. + +;The task is to: +# Write a function to generate Fibonacci n-step number sequences given its initial values and assuming the number of initial values determines how many previous values are summed to make the next number of the series. +# Use this to print and show here at least the first ten members of the Fibo/tribo/tetra-nacci and Lucas sequences. + +;Cf.: +* [[Fibonacci sequence]] +* [http://mathworld.wolfram.com/Fibonaccin-StepNumber.html Wolfram Mathworld] +* [[Hofstadter Q sequence‎]] diff --git a/Task/Fibonacci-n-step-number-sequences/ACL2/fibonacci-n-step-number-sequences.acl2 b/Task/Fibonacci-n-step-number-sequences/ACL2/fibonacci-n-step-number-sequences.acl2 new file mode 100644 index 0000000000..e39199b9e6 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/ACL2/fibonacci-n-step-number-sequences.acl2 @@ -0,0 +1,13 @@ +(defun sum (xs) + (if (endp xs) + 0 + (+ (first xs) + (sum (rest xs))))) + +(defun n-bonacci (prevs limit) + (if (zp limit) + nil + (let ((next (append (rest prevs) + (list (sum prevs))))) + (cons (first next) + (n-bonacci next (1- limit)))))) diff --git a/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-1.ada b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-1.ada new file mode 100644 index 0000000000..7284d33835 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-1.ada @@ -0,0 +1,11 @@ +package Bonacci is + + type Sequence is array(Positive range <>) of Positive; + + function Generate(Start: Sequence; Length: Positive := 10) return Sequence; + + Start_Fibonacci: constant Sequence := (1, 1); + Start_Tribonacci: constant Sequence := (1, 1, 2); + Start_Tetranacci: constant Sequence := (1, 1, 2, 4); + Start_Lucas: constant Sequence := (2, 1); +end Bonacci; diff --git a/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-2.ada b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-2.ada new file mode 100644 index 0000000000..c1c4709cff --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-2.ada @@ -0,0 +1,20 @@ +package body Bonacci is + + function Generate(Start: Sequence; Length: Positive := 10) return Sequence is + begin + if Length <= Start'Length then + return Start(Start'First .. Start'First+Length-1); + else + declare + Sum: Natural := 0; + begin + for I in Start'Range loop + Sum := Sum + Start(I); + end loop; + return Start(Start'First) + & Generate(Start(Start'First+1 .. Start'Last) & Sum, Length-1); + end; + end if; + end Generate; + +end Bonacci; diff --git a/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-3.ada b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-3.ada new file mode 100644 index 0000000000..9e069f09a5 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ada/fibonacci-n-step-number-sequences-3.ada @@ -0,0 +1,21 @@ +with Ada.Text_IO, Bonacci; + +procedure Test_Bonacci is + + procedure Print(Name: String; S: Bonacci.Sequence) is + begin + Ada.Text_IO.Put(Name & "("); + for I in S'First .. S'Last-1 loop + Ada.Text_IO.Put(Integer'Image(S(I)) & ","); + end loop; + Ada.Text_IO.Put_Line(Integer'Image(S(S'Last)) & " )"); + end Print; + +begin + Print("Fibonacci: ", Bonacci.Generate(Bonacci.Start_Fibonacci)); + Print("Tribonacci: ", Bonacci.Generate(Bonacci.Start_Tribonacci)); + Print("Tetranacci: ", Bonacci.Generate(Bonacci.Start_Tetranacci)); + Print("Lucas: ", Bonacci.Generate(Bonacci.Start_Lucas)); + Print("Decanacci: ", + Bonacci.Generate((1, 1, 2, 4, 8, 16, 32, 64, 128, 256), 15)); +end Test_Bonacci; diff --git a/Task/Fibonacci-n-step-number-sequences/BBC-BASIC/fibonacci-n-step-number-sequences.bbc b/Task/Fibonacci-n-step-number-sequences/BBC-BASIC/fibonacci-n-step-number-sequences.bbc new file mode 100644 index 0000000000..ac4f4409d4 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/BBC-BASIC/fibonacci-n-step-number-sequences.bbc @@ -0,0 +1,27 @@ + @% = 5 : REM Column width + + PRINT "Fibonacci:" + DIM f2%(1) : f2%() = 1,1 + FOR i% = 1 TO 12 : PRINT f2%(0); : PROCfibn(f2%()) : NEXT : PRINT " ..." + + PRINT "Tribonacci:" + DIM f3%(2) : f3%() = 1,1,2 + FOR i% = 1 TO 12 : PRINT f3%(0); : PROCfibn(f3%()) : NEXT : PRINT " ..." + + PRINT "Tetranacci:" + DIM f4%(3) : f4%() = 1,1,2,4 + FOR i% = 1 TO 12 : PRINT f4%(0); : PROCfibn(f4%()) : NEXT : PRINT " ..." + + PRINT "Lucas:" + DIM fl%(1) : fl%() = 2,1 + FOR i% = 1 TO 12 : PRINT fl%(0); : PROCfibn(fl%()) : NEXT : PRINT " ..." + END + + DEF PROCfibn(f%()) + LOCAL i%, s% + s% = SUM(f%()) + FOR i% = 1 TO DIM(f%(),1) + f%(i%-1) = f%(i%) + NEXT + f%(i%-1) = s% + ENDPROC diff --git a/Task/Fibonacci-n-step-number-sequences/C++/fibonacci-n-step-number-sequences.cpp b/Task/Fibonacci-n-step-number-sequences/C++/fibonacci-n-step-number-sequences.cpp new file mode 100644 index 0000000000..7ab202eba6 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/C++/fibonacci-n-step-number-sequences.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +std::vector nacci ( const std::vector & start , int arity ) { + std::vector result ( start ) ; + int sumstart = 1 ;//summing starts at vector's begin + sumstart as + //soon as the vector is longer than arity + while ( result.size( ) < 15 ) { //we print out the first 15 numbers + if ( result.size( ) <= arity ) + result.push_back( std::accumulate( result.begin( ) , + result.begin( ) + result.size( ) , 0 ) ) ; + else { + result.push_back( std::accumulate ( result.begin( ) + + sumstart , result.begin( ) + sumstart + arity , 0 )) ; + sumstart++ ; + } + } + return std::move ( result ) ; +} + +int main( ) { + std::vector naccinames {"fibo" , "tribo" , + "tetra" , "penta" , "hexa" , "hepta" , "octo" , "nona" , "deca" } ; + const std::vector fibo { 1 , 1 } , lucas { 2 , 1 } ; + for ( int i = 2 ; i < 11 ; i++ ) { + std::vector numberrow = nacci ( fibo , i ) ; + std::cout << std::left << std::setw( 10 ) << + naccinames[ i - 2 ].append( "nacci" ) << + std::setw( 2 ) << " : " ; + std::copy ( numberrow.begin( ) , numberrow.end( ) , + std::ostream_iterator( std::cout , " " ) ) ; + std::cout << "...\n" ; + numberrow = nacci ( lucas , i ) ; + std::cout << "Lucas-" << i ; + if ( i < 10 ) //for formatting purposes + std::cout << " : " ; + else + std::cout << " : " ; + std::copy ( numberrow.begin( ) , numberrow.end( ) , + std::ostream_iterator( std::cout , " " ) ) ; + std::cout << "...\n" ; + } + return 0 ; +} diff --git a/Task/Fibonacci-n-step-number-sequences/C/fibonacci-n-step-number-sequences.c b/Task/Fibonacci-n-step-number-sequences/C/fibonacci-n-step-number-sequences.c new file mode 100644 index 0000000000..99b9482504 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/C/fibonacci-n-step-number-sequences.c @@ -0,0 +1,45 @@ +/*29th August, 2012 +Abhishek Ghosh + +The function anynacci determines the n-arity of the sequence from the number of seed elements. 0 ended arrays are used since C does not have a way of determining the length of dynamic and function-passed integer arrays.*/ + +#include +#include + +int * +anynacci (int *seedArray, int howMany) +{ + int *result = malloc (howMany * sizeof (int)); + int i, j, initialCardinality; + + for (i = 0; seedArray[i] != 0; i++); + initialCardinality = i; + + for (i = 0; i < initialCardinality; i++) + result[i] = seedArray[i]; + + for (i = initialCardinality; i < howMany; i++) + { + result[i] = 0; + for (j = i - initialCardinality; j < i; j++) + result[i] += result[j]; + } + return result; +} + +int +main () +{ + int fibo[] = { 1, 1, 0 }, tribo[] = { 1, 1, 2, 0 }, tetra[] = { 1, 1, 2, 4, 0 }, luca[] = { 2, 1, 0 }; + int *fibonacci = anynacci (fibo, 10), *tribonacci = anynacci (tribo, 10), *tetranacci = anynacci (tetra, 10), + *lucas = anynacci(luca, 10); + int i; + + printf ("\nFibonacci\tTribonacci\tTetranacci\tLucas\n"); + + for (i = 0; i < 10; i++) + printf ("\n%d\t\t%d\t\t%d\t\t%d", fibonacci[i], tribonacci[i], + tetranacci[i], lucas[i]); + + return 0; +} diff --git a/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-1.d b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-1.d new file mode 100644 index 0000000000..cc32b84217 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-1.d @@ -0,0 +1,29 @@ +import std.stdio, std.algorithm, std.range, std.conv; + +void main() { + int[] memo; + size_t addNum; + + void setHead(int[] head) nothrow { + memo = head; + addNum = head.length; + } + + int fibber(in size_t n) /*nothrow*/ { + if (n >= memo.length) + memo ~= iota(n - addNum, n).map!fibber().reduce!q{a + b}(); + return memo[n]; + } + + setHead([1, 1]); + iota(10).map!fibber().writeln(); + setHead([2, 1]); + iota(10).map!fibber().writeln(); + + auto prefixes = "fibo tribo tetra penta hexa hepta octo nona deca"; + foreach (n, name; zip(iota(2, 11), prefixes.split())) { + setHead(1 ~ iota(n - 1).map!q{2 ^^ a}().array()); + auto items = iota(15).map!(i => text(fibber(i)))().join(" "); + writefln("n=%2d, %5snacci -> %s ...", n, name, items); + } +} diff --git a/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-2.d b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-2.d new file mode 100644 index 0000000000..e500b0f2a9 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-2.d @@ -0,0 +1,34 @@ +import std.stdio, std.algorithm, std.range, std.conv; + +struct fiblike(T) { + T[] memo; + immutable size_t addNum; + + this(in T[] start) /*nothrow*/ { + this.memo = start.dup; + this.addNum = start.length; + } + + T opCall(in size_t n) /*nothrow*/ { + if (n >= memo.length) + memo ~= iota(n - addNum, n) + .map!(i => opCall(i))() + .reduce!q{a + b}(); + return memo[n]; + } +} + +void main() { + auto fibo = fiblike!int([1, 1]); + iota(10).map!fibo().writeln(); + + auto lucas = fiblike!int([2, 1]); + iota(10).map!lucas().writeln(); + + const prefixes = "fibo tribo tetra penta hexa hepta octo nona deca"; + foreach (n, name; zip(iota(2, 11), prefixes.split())) { + auto fib = fiblike!int(1 ~ iota(n - 1).map!q{2 ^^ a}().array()); + writefln("n=%2d, %5snacci -> %(%d %) ...", + n, name, iota(15).map!fib()); + } +} diff --git a/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-3.d b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-3.d new file mode 100644 index 0000000000..7cee5cf0f8 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/D/fibonacci-n-step-number-sequences-3.d @@ -0,0 +1,41 @@ +import std.stdio, std.algorithm, std.range, std.traits; + +struct Fiblike(T) { + T[] tail; + + int opApply(int delegate(ref T) dg) { + int result, pos; + foreach (x; tail) { + result = dg(x); + if (result) return result; + } + foreach (i; cycle(iota(tail.length))) { + auto x = tail.reduce!q{a + b}(); + result = dg(x); + if (result) break; + tail[i] = x; + } + return result; + } +} + +// std.range.take doesn't work with opApply +ForeachType!It[] takeApply(It)(It iterable, size_t n) { + typeof(return) result; + foreach (x; iterable) { + result ~= x; + if (result.length == n) break; + } + return result; +} + +void main() { + Fiblike!int([1, 1]).takeApply(10).writeln(); + Fiblike!int([2, 1]).takeApply(10).writeln(); + + auto prefixes = "fibo tribo tetra penta hexa hepta octo nona deca"; + foreach (n, name; zip(iota(2, 11), prefixes.split())) { + auto fib = Fiblike!int(1 ~ iota(n-1).map!q{2 ^^ a}().array()); + writefln("n=%2d, %5snacci -> %s", n, name, fib.takeApply(15)); + } +} diff --git a/Task/Fibonacci-n-step-number-sequences/Go/fibonacci-n-step-number-sequences.go b/Task/Fibonacci-n-step-number-sequences/Go/fibonacci-n-step-number-sequences.go new file mode 100644 index 0000000000..55f6d56d46 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Go/fibonacci-n-step-number-sequences.go @@ -0,0 +1,38 @@ +package main + +import "fmt" + +func g(i []int, c chan int) { + var sum int + b := append([]int{}, i...) + for _, t := range b { + c <- t + sum += t + } + for { + for j, t := range b { + c <- sum + b[j], sum = sum, sum+sum-t + } + } +} + +func main() { + for _, s := range []struct { + seq string + i []int + } { + {"Fibonacci", []int{1, 1}}, + {"Tribonacci", []int{1, 1, 2}}, + {"Tetranacci", []int{1, 1, 2, 4}}, + {"Lucas", []int{2, 1}}, + } { + fmt.Printf("%10s:", s.seq) + c := make(chan int) + go g(s.i, c) + for j := 0; j < 10; j++ { + fmt.Print(" ", <-c) + } + fmt.Println() + } +} diff --git a/Task/Fibonacci-n-step-number-sequences/Haskell/fibonacci-n-step-number-sequences.hs b/Task/Fibonacci-n-step-number-sequences/Haskell/fibonacci-n-step-number-sequences.hs new file mode 100644 index 0000000000..428e5cb513 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Haskell/fibonacci-n-step-number-sequences.hs @@ -0,0 +1,18 @@ +import Data.List (tails) +import Control.Monad (zipWithM_) + +fiblike :: [Integer] -> [Integer] +fiblike st = xs where + xs = st ++ map (sum . take n) (tails xs) + n = length st + +nstep :: Int -> [Integer] +nstep n = fiblike $ take n $ 1 : iterate (2*) 1 + +main :: IO () +main = do + print $ take 10 $ fiblike [1,1] + print $ take 10 $ fiblike [2,1] + zipWithM_ (\n name -> do putStr (name ++ "nacci -> ") + print $ take 15 $ nstep n) + [2..] (words "fibo tribo tetra penta hexa hepta octo nona deca") diff --git a/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-1.j b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-1.j new file mode 100644 index 0000000000..afce6484a8 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-1.j @@ -0,0 +1 @@ + nacci =: (] , +/@{.)^:(-@#@]`(-#)`]) diff --git a/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-2.j b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-2.j new file mode 100644 index 0000000000..28ee446e09 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-2.j @@ -0,0 +1,2 @@ + 10 nacci 2 1 NB. Lucas series, first 10 terms +2 1 3 4 7 11 18 29 47 76 diff --git a/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-3.j b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-3.j new file mode 100644 index 0000000000..5478f6df37 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/J/fibonacci-n-step-number-sequences-3.j @@ -0,0 +1,23 @@ + TESTS =: }."1 fixdsv noun define [ require 'tables/dsv' NB. Tests from task description + 2 fibonacci 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ... + 3 tribonacci 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 ... + 4 tetranacci 1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536 ... + 5 pentanacci 1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930 ... + 6 hexanacci 1 1 2 4 8 16 32 63 125 248 492 976 1936 3840 7617 ... + 7 heptanacci 1 1 2 4 8 16 32 64 127 253 504 1004 2000 3984 7936 ... + 8 octonacci 1 1 2 4 8 16 32 64 128 255 509 1016 2028 4048 8080 ... + 9 nonanacci 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144 ... + 10 decanacci 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172 ... +) + testNacci =: ] -: #@] nacci {. NB. Given an order & test sequence, compare nacci to sequence + OT =: __ ".&.> (<<<1) { |: TESTS NB. 'nacci order and test sequence + (> 1 {"1 TESTS) ,. ' ' ,. (u: 16b274c 16b2713) {~ (testNacci }:)&>/ OT NB. ✓ or ❌ for success or failure +fibonacci ✓ +tribonacci ✓ +tetranacci ✓ +pentanacci ✓ +hexanacci ✓ +heptanacci ✓ +octonacci ✓ +nonanacci ✓ +decanacci ✓ diff --git a/Task/Fibonacci-n-step-number-sequences/Java/fibonacci-n-step-number-sequences.java b/Task/Fibonacci-n-step-number-sequences/Java/fibonacci-n-step-number-sequences.java new file mode 100644 index 0000000000..c59f00d625 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Java/fibonacci-n-step-number-sequences.java @@ -0,0 +1,45 @@ +class Fibonacci +{ + public static int[] lucas(int n, int numRequested) + { + if (n < 2) + throw new IllegalArgumentException("Fibonacci value must be at least 2"); + return fibonacci((n == 2) ? new int[] { 2, 1 } : lucas(n - 1, n), numRequested); + } + + public static int[] fibonacci(int n, int numRequested) + { + if (n < 2) + throw new IllegalArgumentException("Fibonacci value must be at least 2"); + return fibonacci((n == 2) ? new int[] { 1, 1 } : fibonacci(n - 1, n), numRequested); + } + + public static int[] fibonacci(int[] startingValues, int numRequested) + { + int[] output = new int[numRequested]; + int n = startingValues.length; + System.arraycopy(startingValues, 0, output, 0, n); + for (int i = n; i < numRequested; i++) + for (int j = 1; j <= n; j++) + output[i] += output[i - j]; + return output; + } + + public static void main(String[] args) + { + for (int n = 2; n <= 10; n++) + { + System.out.print("nacci(" + n + "):"); + for (int value : fibonacci(n, 15)) + System.out.print(" " + value); + System.out.println(); + } + for (int n = 2; n <= 10; n++) + { + System.out.print("lucas(" + n + "):"); + for (int value : lucas(n, 15)) + System.out.print(" " + value); + System.out.println(); + } + } +} diff --git a/Task/Fibonacci-n-step-number-sequences/JavaScript/fibonacci-n-step-number-sequences.js b/Task/Fibonacci-n-step-number-sequences/JavaScript/fibonacci-n-step-number-sequences.js new file mode 100644 index 0000000000..47a15bb1b2 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/JavaScript/fibonacci-n-step-number-sequences.js @@ -0,0 +1,26 @@ +function fib(arity, len) { + return nacci(nacci([1,1], arity, arity), arity, len); +} + +function lucas(arity, len) { + return nacci(nacci([2,1], arity, arity), arity, len); +} + +function nacci(a, arity, len) { + while (a.length < len) { + var sum = 0; + for (var i = Math.max(0, a.length - arity); i < a.length; i++) + sum += a[i]; + a.push(sum); + } + return a; +} + +function main() { + for (var arity = 2; arity <= 10; arity++) + console.log("fib(" + arity + "): " + fib(arity, 15)); + for (var arity = 2; arity <= 10; arity++) + console.log("lucas(" + arity + "): " + lucas(arity, 15)); +} + +main(); diff --git a/Task/Fibonacci-n-step-number-sequences/Mathematica/fibonacci-n-step-number-sequences.mathematica b/Task/Fibonacci-n-step-number-sequences/Mathematica/fibonacci-n-step-number-sequences.mathematica new file mode 100644 index 0000000000..0caf822fb2 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Mathematica/fibonacci-n-step-number-sequences.mathematica @@ -0,0 +1,6 @@ +f2=Function[{l,k}, + Module[{n=Length@l,m}, + m=SparseArray[{{i_,j_}/;i==1||i==j+1->1},{n,n}]; + NestList[m.#&,l,k]]]; +Table[Last/@f2[{1,1}~Join~Table[0,{n-2}],15+n][[-18;;]],{n,2,10}]//TableForm +Table[Last/@f2[{1,2}~Join~Table[0,{n-2}],15+n][[-18;;]],{n,2,10}]//TableForm diff --git a/Task/Fibonacci-n-step-number-sequences/PHP/fibonacci-n-step-number-sequences.php b/Task/Fibonacci-n-step-number-sequences/PHP/fibonacci-n-step-number-sequences.php new file mode 100644 index 0000000000..1edb5fd19b --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/PHP/fibonacci-n-step-number-sequences.php @@ -0,0 +1,80 @@ + + */ + +/** + * @param int $x + * @param array $series + * @param int $n + * @return array + */ +function fib_n_step($x, &$series = array(1, 1), $n = 15) +{ + $count = count($series); + + if($count > $x && $count == $n) // exit point + { + return $series; + } + + if($count < $n) + { + if($count >= $x) // 4 or less + { + fib($series, $x, $count); + return fib_n_step($x, $series, $n); + } + else // 5 or more + { + while(count($series) < $x ) + { + $count = count($series); + fib($series, $count, $count); + } + return fib_n_step($x, $series, $n); + } + } + + return $series; +} + +/** + * @param array $series + * @param int $n + * @param int $i + */ +function fib(&$series, $n, $i) +{ + $end = 0; + for($j = $n; $j > 0; $j--) + { + $end += $series[$i-$j]; + } + $series[$i] = $end; +} + + +/*=================== OUTPUT ============================*/ + +header('Content-Type: text/plain'); +$steps = array( + 'LUCAS' => array(2, array(2, 1)), + 'FIBONACCI' => array(2, array(1, 1)), + 'TRIBONACCI' => array(3, array(1, 1, 2)), + 'TETRANACCI' => array(4, array(1, 1, 2, 4)), + 'PENTANACCI' => array(5, array(1, 1, 2, 4)), + 'HEXANACCI' => array(6, array(1, 1, 2, 4)), + 'HEPTANACCI' => array(7, array(1, 1, 2, 4)), + 'OCTONACCI' => array(8, array(1, 1, 2, 4)), + 'NONANACCI' => array(9, array(1, 1, 2, 4)), + 'DECANACCI' => array(10, array(1, 1, 2, 4)), +); + +foreach($steps as $name=>$pair) +{ + $ser = fib_n_step($pair[0],$pair[1]); + $n = count($ser)-1; + + echo $name." => ".implode(',', $ser) . "\n"; +} diff --git a/Task/Fibonacci-n-step-number-sequences/Perl/fibonacci-n-step-number-sequences.pl b/Task/Fibonacci-n-step-number-sequences/Perl/fibonacci-n-step-number-sequences.pl new file mode 100644 index 0000000000..aa098e4b9f --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Perl/fibonacci-n-step-number-sequences.pl @@ -0,0 +1,24 @@ +use 5.010; + +use List::Util qw/max sum/; + +sub fib { + my $n = shift; + my $xs = shift // [1]; + my @xs = @{$xs}; + + while (my $len = scalar @xs) { + last if $len >= 20; + push( + @xs, + sum(@xs[max($len - $n, 0)..$len-1]) + ); + } + + return @xs; +} + +for (2..10) { + say join(' ', fib($_)); +} +say join(' ', fib(2, [2,1])); diff --git a/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-1.l b/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-1.l new file mode 100644 index 0000000000..214d9e5e18 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-1.l @@ -0,0 +1,6 @@ +(de nacci (Init Cnt) + (let N (length Init) + (make + (made Init) + (do (- Cnt N) + (link (apply + (tail N (made)))) ) ) ) ) diff --git a/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-2.l b/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-2.l new file mode 100644 index 0000000000..d704b1f20a --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/PicoLisp/fibonacci-n-step-number-sequences-2.l @@ -0,0 +1,19 @@ +# Fibonacci +: (nacci (1 1) 10) +-> (1 1 2 3 5 8 13 21 34 55) + +# Tribonacci +: (nacci (1 1 2) 10) +-> (1 1 2 4 7 13 24 44 81 149) + +# Tetranacci +: (nacci (1 1 2 4) 10) +-> (1 1 2 4 8 15 29 56 108 208) + +# Lucas +: (nacci (2 1) 10) +-> (2 1 3 4 7 11 18 29 47 76) + +# Decanacci +: (nacci (1 1 2 4 8 16 32 64 128 256) 15) +-> (1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172) diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-1.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-1.py new file mode 100644 index 0000000000..baef86169c --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-1.py @@ -0,0 +1,33 @@ +>>> def fiblike(start): + addnum = len(start) + memo = start[:] + def fibber(n): + try: + return memo[n] + except IndexError: + ans = sum(fibber(i) for i in range(n-addnum, n)) + memo.append(ans) + return ans + return fibber + +>>> fibo = fiblike([1,1]) +>>> [fibo(i) for i in range(10)] +[1, 1, 2, 3, 5, 8, 13, 21, 34, 55] +>>> lucas = fiblike([2,1]) +>>> [lucas(i) for i in range(10)] +[2, 1, 3, 4, 7, 11, 18, 29, 47, 76] +>>> for n, name in zip(range(2,11), 'fibo tribo tetra penta hexa hepta octo nona deca'.split()) : + fibber = fiblike([1] + [2**i for i in range(n-1)]) + print('n=%2i, %5snacci -> %s ...' % (n, name, ' '.join(str(fibber(i)) for i in range(15)))) + + +n= 2, fibonacci -> 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ... +n= 3, tribonacci -> 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 ... +n= 4, tetranacci -> 1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536 ... +n= 5, pentanacci -> 1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930 ... +n= 6, hexanacci -> 1 1 2 4 8 16 32 63 125 248 492 976 1936 3840 7617 ... +n= 7, heptanacci -> 1 1 2 4 8 16 32 64 127 253 504 1004 2000 3984 7936 ... +n= 8, octonacci -> 1 1 2 4 8 16 32 64 128 255 509 1016 2028 4048 8080 ... +n= 9, nonanacci -> 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144 ... +n=10, decanacci -> 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172 ... +>>> diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-2.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-2.py new file mode 100644 index 0000000000..003de61acd --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-2.py @@ -0,0 +1,34 @@ +>>> class Fiblike(): + def __init__(self, start): + self.addnum = len(start) + self.memo = start[:] + def __call__(self, n): + try: + return self.memo[n] + except IndexError: + ans = sum(self(i) for i in range(n-self.addnum, n)) + self.memo.append(ans) + return ans + + +>>> fibo = Fiblike([1,1]) +>>> [fibo(i) for i in range(10)] +[1, 1, 2, 3, 5, 8, 13, 21, 34, 55] +>>> lucas = Fiblike([2,1]) +>>> [lucas(i) for i in range(10)] +[2, 1, 3, 4, 7, 11, 18, 29, 47, 76] +>>> for n, name in zip(range(2,11), 'fibo tribo tetra penta hexa hepta octo nona deca'.split()) : + fibber = Fiblike([1] + [2**i for i in range(n-1)]) + print('n=%2i, %5snacci -> %s ...' % (n, name, ' '.join(str(fibber(i)) for i in range(15)))) + + +n= 2, fibonacci -> 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ... +n= 3, tribonacci -> 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136 ... +n= 4, tetranacci -> 1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536 ... +n= 5, pentanacci -> 1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930 ... +n= 6, hexanacci -> 1 1 2 4 8 16 32 63 125 248 492 976 1936 3840 7617 ... +n= 7, heptanacci -> 1 1 2 4 8 16 32 64 127 253 504 1004 2000 3984 7936 ... +n= 8, octonacci -> 1 1 2 4 8 16 32 64 128 255 509 1016 2028 4048 8080 ... +n= 9, nonanacci -> 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144 ... +n=10, decanacci -> 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172 ... +>>> 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 new file mode 100644 index 0000000000..fb273a2545 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-3.py @@ -0,0 +1,19 @@ +from itertools import islice, cycle + +def fiblike(tail): + for x in tail: + yield x + for i in cycle(xrange(len(tail))): + tail[i] = x = sum(tail) + yield x + +fibo = fiblike([1, 1]) +print list(islice(fibo, 10)) +lucas = fiblike([2, 1]) +print list(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)]) + items = list(islice(fib, 15)) + print "n=%2i, %5snacci -> %s ..." % (n, name, items) diff --git a/Task/Fibonacci-n-step-number-sequences/REXX/fibonacci-n-step-number-sequences.rexx b/Task/Fibonacci-n-step-number-sequences/REXX/fibonacci-n-step-number-sequences.rexx new file mode 100644 index 0000000000..aca60056be --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/REXX/fibonacci-n-step-number-sequences.rexx @@ -0,0 +1,40 @@ +/*REXX program calculates and displays N-step Fibonacci sequences. */ +parse arg FibName values /*allow user to specify which Fib*/ + +if FibName\='' then do /*if specified, show that Fib. */ + call nStepFib FibName, values + exit /*stick a fork in it, we're done.*/ + end + /*nothing given, so show a bunch.*/ +call nStepFib 'Lucas' , 2 1 +call nStepFib 'fibonacci' , 1 1 +call nStepFib 'tribonacci' , 1 1 2 +call nStepFib 'tetranacci' , 1 1 2 4 +call nStepFib 'pentanacci' , 1 1 2 4 8 +call nStepFib 'hexanacci' , 1 1 2 4 8 16 +call nStepFib 'heptanacci' , 1 1 2 4 8 16 32 +call nStepFib 'octonacci' , 1 1 2 4 8 16 32 64 +call nStepFib 'nonanacci' , 1 1 2 4 8 16 32 64 128 +call nStepFib 'decanacci' , 1 1 2 4 8 16 32 64 128 256 +call nStepFib 'undecanacci' , 1 1 2 4 8 16 32 64 128 256 512 +call nStepFib 'dodecanacci' , 1 1 2 4 8 16 32 64 128 256 512 1024 +call nStepFib '13th-order' , 1 1 2 4 8 16 32 64 128 256 512 1024 2048 +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────NSTEPFIB subroutine─────────────────*/ +nStepFib: procedure; parse arg Fname,vals,m; if m=='' then m=30; L= +N=words(vals) + do pop=1 for N /*use N initial vals*/ + @.pop=word(vals,pop) /*populate initial #s.*/ + end /*pop*/ + do j=1 for m /*calculate M Fibonacci numbers*/ + if j>N then do; @.j=0 /*inialize the sum. */ + do k=j-N for N /*sum the last N #.s*/ + @.j=@.j+@.k /*add the [N-j]th #.*/ + end /*k*/ + end + L=L @.j /*append this Fib num to the list*/ + end /*j*/ + +say right(Fname,11)'[sum'right(N,3) "terms]:" strip(L) '...' /*show #s*/ +return diff --git a/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-1.rb b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-1.rb new file mode 100644 index 0000000000..3682cbf212 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-1.rb @@ -0,0 +1,12 @@ +def anynacci(start_sequence, count) + n = start_sequence.length # Get the n-step for the type of fibonacci sequence + result = start_sequence.dup # Create a new result array with the values copied from the array that was passed by reference + + (n+1..count).each do # Loop for the remaining results up to count + tail = result.last(n) # Get the last n elements from result + next_num = tail.reduce(:+) # In Rails: tail.sum + result << next_num # Array append + end + + result # Return result +end diff --git a/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-2.rb b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-2.rb new file mode 100644 index 0000000000..b9cee748e2 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-2.rb @@ -0,0 +1,13 @@ +def print_nacci + naccis = { :fibo => [1,1], + :lucas => [2,1], + :tribo => [1,1,2], + :tetra => [1,1,2,4] } + + naccis.each do |name, start_sequence| + nacci_result = anynacci(start_sequence, 10) + puts "#{name}nacci: #{nacci_result}" + end + + nil +end diff --git a/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-3.rb b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-3.rb new file mode 100644 index 0000000000..e7d96596a3 --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Ruby/fibonacci-n-step-number-sequences-3.rb @@ -0,0 +1,4 @@ +fibonacci: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] +lucasnacci: [2, 1, 3, 4, 7, 11, 18, 29, 47, 76] +tribonacci: [1, 1, 2, 4, 7, 13, 24, 44, 81, 149] +tetranacci: [1, 1, 2, 4, 8, 15, 29, 56, 108, 208] diff --git a/Task/Fibonacci-n-step-number-sequences/Tcl/fibonacci-n-step-number-sequences.tcl b/Task/Fibonacci-n-step-number-sequences/Tcl/fibonacci-n-step-number-sequences.tcl new file mode 100644 index 0000000000..8feef897eb --- /dev/null +++ b/Task/Fibonacci-n-step-number-sequences/Tcl/fibonacci-n-step-number-sequences.tcl @@ -0,0 +1,30 @@ +package require Tcl 8.6 + +proc fibber {args} { + coroutine fib[incr ::fibs]=[join $args ","] apply {fn { + set n [info coroutine] + foreach f $fn { + if {![yield $n]} return + set n $f + } + while {[yield $n]} { + set fn [linsert [lreplace $fn 0 0] end [set n [+ {*}$fn]]] + } + } ::tcl::mathop} $args +} + +proc print10 cr { + for {set i 1} {$i <= 10} {incr i} { + lappend out [$cr true] + } + puts \[[join [lappend out ...] ", "]\] + $cr false +} +puts "FIBONACCI" +print10 [fibber 1 1] +puts "TRIBONACCI" +print10 [fibber 1 1 2] +puts "TETRANACCI" +print10 [fibber 1 1 2 4] +puts "LUCAS" +print10 [fibber 2 1] diff --git a/Task/Fibonacci-sequence/0815/fibonacci-sequence.0815 b/Task/Fibonacci-sequence/0815/fibonacci-sequence.0815 new file mode 100644 index 0000000000..f8e9df921f --- /dev/null +++ b/Task/Fibonacci-sequence/0815/fibonacci-sequence.0815 @@ -0,0 +1,2 @@ +%<:0D:>~$<:01:~%>=<:a94fad42221f2702:>~> +}:_s:{x{={~$x+%{=>~>x~-x<:0D:~>~>~^:_s:? diff --git a/Task/Fibonacci-sequence/0DESCRIPTION b/Task/Fibonacci-sequence/0DESCRIPTION new file mode 100644 index 0000000000..58010a6249 --- /dev/null +++ b/Task/Fibonacci-sequence/0DESCRIPTION @@ -0,0 +1,23 @@ +The '''Fibonacci sequence''' is a sequence Fn of natural numbers defined recursively: + F0 = 0 + F1 = 1 + Fn = Fn-1 + Fn-2, if n>1 + +Write a function to generate the nth Fibonacci number. Solutions can be iterative or recursive (though recursive solutions are generally considered too slow and are mostly used as an exercise in recursion). + +The sequence is sometimes extended into negative numbers by using a straightforward inverse of the positive definition: + + Fn = Fn+2 - Fn+1, if n<0 + +Support for negative n in the solution is optional. + +;Cf.: +* [[Fibonacci n-step number sequences‎]] + +;References: +* [[wp:Fibonacci number|Wikipedia, Fibonacci number]] +* [[wp:Lucas number|Wikipedia, Lucas number]] +* [http://mathworld.wolfram.com/FibonacciNumber.html MathWorld, Fibonacci Number] +* [http://www.math-cs.ucmo.edu/~curtisc/articles/howardcooper/genfib4.pdf Some identities for r-Fibonacci numbers] +*[[oeis:A000045|OEIS Fibonacci numbers]] +*[[oeis:A000032|OEIS Lucas numbers]] diff --git a/Task/Fibonacci-sequence/1META.yaml b/Task/Fibonacci-sequence/1META.yaml new file mode 100644 index 0000000000..4dd49fa137 --- /dev/null +++ b/Task/Fibonacci-sequence/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Recursion +- Memoization +- Classic CS problems and programs +note: Arithmetic operations diff --git a/Task/Fibonacci-sequence/ACL2/fibonacci-sequence.acl2 b/Task/Fibonacci-sequence/ACL2/fibonacci-sequence.acl2 new file mode 100644 index 0000000000..02f47fc006 --- /dev/null +++ b/Task/Fibonacci-sequence/ACL2/fibonacci-sequence.acl2 @@ -0,0 +1,17 @@ +(defun fast-fib-r (n a b) + (if (or (zp n) (zp (1- n))) + b + (fast-fib-r (1- n) b (+ a b)))) + +(defun fast-fib (n) + (fast-fib-r n 1 1)) + +(defun first-fibs-r (n i) + (declare (xargs :measure (nfix (- n i)))) + (if (zp (- n i)) + nil + (cons (fast-fib i) + (first-fibs-r n (1+ i))))) + +(defun first-fibs (n) + (first-fibs-r n 0)) diff --git a/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-1.alg b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-1.alg new file mode 100644 index 0000000000..e13d686dc7 --- /dev/null +++ b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-1.alg @@ -0,0 +1,13 @@ +PROC analytic fibonacci = (LONG INT n)LONG INT:( + LONG REAL sqrt 5 = long sqrt(5); + LONG REAL p = (1 + sqrt 5) / 2; + LONG REAL q = 1/p; + ROUND( (p**n + q**n) / sqrt 5 ) +); + +FOR i FROM 1 TO 30 WHILE + print(whole(analytic fibonacci(i),0)); +# WHILE # i /= 30 DO + print(", ") +OD; +print(new line) diff --git a/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-2.alg b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-2.alg new file mode 100644 index 0000000000..f4c1dbfcf8 --- /dev/null +++ b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-2.alg @@ -0,0 +1,17 @@ +PROC iterative fibonacci = (INT n)INT: + CASE n+1 IN + 0, 1, 1, 2, 3, 5 + OUT + INT even:=3, odd:=5; + FOR i FROM odd+1 TO n DO + (ODD i|odd|even) := odd + even + OD; + (ODD n|odd|even) + ESAC; + +FOR i FROM 0 TO 30 WHILE + print(whole(iterative fibonacci(i),0)); +# WHILE # i /= 30 DO + print(", ") +OD; +print(new line) diff --git a/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-3.alg b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-3.alg new file mode 100644 index 0000000000..35625a50de --- /dev/null +++ b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-3.alg @@ -0,0 +1,2 @@ +PROC recursive fibonacci = (INT n)INT: + ( n < 2 | n | fib(n-1) + fib(n-2)); diff --git a/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-4.alg b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-4.alg new file mode 100644 index 0000000000..12289120ed --- /dev/null +++ b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-4.alg @@ -0,0 +1,18 @@ +MODE YIELDINT = PROC(INT)VOID; + +PROC gen fibonacci = (INT n, YIELDINT yield)VOID: ( + INT even:=0, odd:=1; + yield(even); + yield(odd); + FOR i FROM odd+1 TO n DO + yield( (ODD i|odd|even) := odd + even ) + OD +); + +main:( + # FOR INT n IN # gen fibonacci(30, # ) DO ( # + ## (INT n)VOID:( + print((" ",whole(n,0))) + # OD # )); + print(new line) +) diff --git a/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-5.alg b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-5.alg new file mode 100644 index 0000000000..1afd4b97e5 --- /dev/null +++ b/Task/Fibonacci-sequence/ALGOL-68/fibonacci-sequence-5.alg @@ -0,0 +1,30 @@ +[]INT const fibonacci = []INT( -1836311903, 1134903170, + -701408733, 433494437, -267914296, 165580141, -102334155, + 63245986, -39088169, 24157817, -14930352, 9227465, -5702887, + 3524578, -2178309, 1346269, -832040, 514229, -317811, 196418, + -121393, 75025, -46368, 28657, -17711, 10946, -6765, 4181, + -2584, 1597, -987, 610, -377, 233, -144, 89, -55, 34, -21, 13, + -8, 5, -3, 2, -1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, + 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, + 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, + 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, + 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, + 701408733, 1134903170, 1836311903 +)[@-46]; + +PROC VOID value error := stop; + +PROC lookup fibonacci = (INT i)INT: ( + IF LWB const fibonacci <= i AND i<= UPB const fibonacci THEN + const fibonacci[i] + ELSE + value error; SKIP + FI +); + +FOR i FROM 0 TO 30 WHILE + print(whole(lookup fibonacci(i),0)); +# WHILE # i /= 30 DO + print(", ") +OD; +print(new line) diff --git a/Task/Fibonacci-sequence/AWK/fibonacci-sequence.awk b/Task/Fibonacci-sequence/AWK/fibonacci-sequence.awk new file mode 100644 index 0000000000..3ce0872bd9 --- /dev/null +++ b/Task/Fibonacci-sequence/AWK/fibonacci-sequence.awk @@ -0,0 +1,3 @@ +$ awk 'func fib(n){return(n<2?n:fib(n-1)+fib(n-2))}{print "fib("$1")="fib($1)}' +10 +fib(10)=55 diff --git a/Task/Fibonacci-sequence/ActionScript/fibonacci-sequence.as b/Task/Fibonacci-sequence/ActionScript/fibonacci-sequence.as new file mode 100644 index 0000000000..90077f8c45 --- /dev/null +++ b/Task/Fibonacci-sequence/ActionScript/fibonacci-sequence.as @@ -0,0 +1,7 @@ +public function fib(n:uint):uint +{ + if (n < 2) + return n; + + return fib(n - 1) + fib(n - 2); +} diff --git a/Task/Fibonacci-sequence/Ada/fibonacci-sequence-1.ada b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-1.ada new file mode 100644 index 0000000000..7e4e9f8563 --- /dev/null +++ b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-1.ada @@ -0,0 +1,19 @@ +with Ada.Text_IO, Ada.Command_Line; + +procedure Fib is + + X: Positive := Positive'Value(Ada.Command_Line.Argument(1)); + + function Fib(P: Positive) return Positive is + begin + if P <= 2 then + return 1; + else + return Fib(P-1) + Fib(P-2); + end if; + end Fib; + +begin + Ada.Text_IO.Put("Fibonacci(" & Integer'Image(X) & " ) = "); + Ada.Text_IO.Put_Line(Integer'Image(Fib(X))); +end Fib; diff --git a/Task/Fibonacci-sequence/Ada/fibonacci-sequence-2.ada b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-2.ada new file mode 100644 index 0000000000..63f969409b --- /dev/null +++ b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-2.ada @@ -0,0 +1,20 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Fibonacci is + function Fibonacci (N : Natural) return Natural is + This : Natural := 0; + That : Natural := 1; + Sum : Natural; + begin + for I in 1..N loop + Sum := This + That; + That := This; + This := Sum; + end loop; + return This; + end Fibonacci; +begin + for N in 0..10 loop + Put_Line (Positive'Image (Fibonacci (N))); + end loop; +end Test_Fibonacci; diff --git a/Task/Fibonacci-sequence/Ada/fibonacci-sequence-3.ada b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-3.ada new file mode 100644 index 0000000000..1bab08c378 --- /dev/null +++ b/Task/Fibonacci-sequence/Ada/fibonacci-sequence-3.ada @@ -0,0 +1,33 @@ +with Ada.Text_IO, Ada.Command_Line, Crypto.Types.Big_Numbers; + +procedure Fibonacci is + + X: Positive := Positive'Value(Ada.Command_Line.Argument(1)); + + Bit_Length: Positive := 1 + (696 * X) / 1000; + -- that number of bits is sufficient to store the full result. + + package LN is new Crypto.Types.Big_Numbers + (Bit_Length + (32 - Bit_Length mod 32)); + -- the actual number of bits has to be a multiple of 32 + use LN; + + function Fib(P: Positive) return Big_Unsigned is + Previous: Big_Unsigned := Big_Unsigned_Zero; + Result: Big_Unsigned := Big_Unsigned_One; + Tmp: Big_Unsigned; + begin + -- Result = 1 = Fibonacci(1) + for I in 1 .. P-1 loop + Tmp := Result; + Result := Previous + Result; + Previous := Tmp; + -- Result = Fibonacci(I+1)) + end loop; + return Result; + end Fib; + +begin + Ada.Text_IO.Put("Fibonacci(" & Integer'Image(X) & " ) = "); + Ada.Text_IO.Put_Line(LN.Utils.To_String(Fib(X))); +end Fibonacci; diff --git a/Task/Fibonacci-sequence/Alore/fibonacci-sequence.alore b/Task/Fibonacci-sequence/Alore/fibonacci-sequence.alore new file mode 100644 index 0000000000..1a6e509968 --- /dev/null +++ b/Task/Fibonacci-sequence/Alore/fibonacci-sequence.alore @@ -0,0 +1,6 @@ +def fib(n as Int) as Int + if n < 2 + return 1 + end + return fib(n-1) + fib(n-2) +end diff --git a/Task/Fibonacci-sequence/AppleScript/fibonacci-sequence.applescript b/Task/Fibonacci-sequence/AppleScript/fibonacci-sequence.applescript new file mode 100644 index 0000000000..4aaa24a506 --- /dev/null +++ b/Task/Fibonacci-sequence/AppleScript/fibonacci-sequence.applescript @@ -0,0 +1,11 @@ +set fibs to {} +set x to (text returned of (display dialog "What fibbonaci number do you want?" default answer "3")) +set x to x as integer +repeat with y from 1 to x + if (y = 1 or y = 2) then + copy 1 to the end of fibs + else + copy ((item (y - 1) of fibs) + (item (y - 2) of fibs)) to the end of fibs + end if +end repeat +return item x of fibs diff --git a/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-1.ahk b/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-1.ahk new file mode 100644 index 0000000000..8df8ac4c57 --- /dev/null +++ b/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-1.ahk @@ -0,0 +1,18 @@ +Loop, 5 + MsgBox % fib(A_Index) +Return + +fib(n) +{ + If (n < 2) + Return n + i := last := this := 1 + While (i <= n) + { + new := last + this + last := this + this := new + i++ + } + Return this +} diff --git a/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-2.ahk b/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-2.ahk new file mode 100644 index 0000000000..4824e2c1e5 --- /dev/null +++ b/Task/Fibonacci-sequence/AutoHotkey/fibonacci-sequence-2.ahk @@ -0,0 +1,17 @@ +/* +Important note: the recursive version would be very slow +without a global or static array. The iterative version +handles also negative arguments properly. +*/ + +FibR(n) { ; n-th Fibonacci number (n>=0, recursive with static array Fibo) + Static + Return n<2 ? n : Fibo%n% ? Fibo%n% : Fibo%n% := FibR(n-1)+FibR(n-2) +} + +Fib(n) { ; n-th Fibonacci number (n < 0 OK, iterative) + a := 0, b := 1 + Loop % abs(n)-1 + c := b, b += a, a := c + Return n=0 ? 0 : n>0 || n&1 ? b : -b +} diff --git a/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-1.autoit b/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-1.autoit new file mode 100644 index 0000000000..33e8dadbe5 --- /dev/null +++ b/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-1.autoit @@ -0,0 +1,27 @@ +#AutoIt Version: 3.2.10.0 +$n0 = 0 +$n1 = 1 +$n = 10 +MsgBox (0,"Iterative Fibonacci ", it_febo($n0,$n1,$n)) + +Func it_febo($n_0,$n_1,$N) + $first = $n_0 + $second = $n_1 + $next = $first + $second + $febo = 0 + For $i = 1 To $N-3 + $first = $second + $second = $next + $next = $first + $second + Next + if $n==0 Then + $febo = 0 + ElseIf $n==1 Then + $febo = $n_0 + ElseIf $n==2 Then + $febo = $n_1 + Else + $febo = $next + EndIf + Return $febo +EndFunc diff --git a/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-2.autoit b/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-2.autoit new file mode 100644 index 0000000000..a8cdffb481 --- /dev/null +++ b/Task/Fibonacci-sequence/AutoIt/fibonacci-sequence-2.autoit @@ -0,0 +1,19 @@ +#AutoIt Version: 3.2.10.0 +$n0 = 0 +$n1 = 1 +$n = 10 +MsgBox (0,"Recursive Fibonacci ", rec_febo($n0,$n1,$n)) +Func rec_febo($r_0,$r_1,$R) + if $R<3 Then + if $R==2 Then + Return $r_1 + ElseIf $R==1 Then + Return $r_0 + ElseIf $R==0 Then + Return 0 + EndIf + Return $R + Else + Return rec_febo($r_0,$r_1,$R-1) + rec_febo($r_0,$r_1,$R-2) + EndIf +EndFunc diff --git a/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-1.bas b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-1.bas new file mode 100644 index 0000000000..8aaa8bfbb8 --- /dev/null +++ b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-1.bas @@ -0,0 +1,14 @@ +FUNCTION itFib (n) + n1 = 0 + n2 = 1 + FOR k = 1 TO ABS(n) + sum = n1 + n2 + n1 = n2 + n2 = sum + NEXT k + IF n < 0 THEN + itFib = n1 * ((-1) ^ ((-n) + 1)) + ELSE + itFib = n1 + END IF +END FUNCTION diff --git a/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-2.bas b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-2.bas new file mode 100644 index 0000000000..21b1b5e89c --- /dev/null +++ b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-2.bas @@ -0,0 +1,38 @@ +DECLARE FUNCTION fibonacci& (n AS INTEGER) + +REDIM SHARED fibNum(1) AS LONG + +fibNum(1) = 1 + +'*****sample inputs***** +PRINT fibonacci(0) 'no calculation needed +PRINT fibonacci(13) 'figure F(2)..F(13) +PRINT fibonacci(-42) 'figure F(14)..F(42) +PRINT fibonacci(47) 'error: too big +'*****sample inputs***** + +FUNCTION fibonacci& (n AS INTEGER) + DIM a AS INTEGER + a = ABS(n) + SELECT CASE a + CASE 0 TO 46 + SHARED fibNum() AS LONG + DIM u AS INTEGER, L0 AS INTEGER + u = UBOUND(fibNum) + IF a > u THEN + REDIM PRESERVE fibNum(a) AS LONG + FOR L0 = u + 1 TO a + fibNum(L0) = fibNum(L0 - 1) + fibNum(L0 - 2) + NEXT + END IF + IF n < 0 THEN + fibonacci = fibNum(a) * ((-1) ^ (a + 1)) + ELSE + fibonacci = fibNum(n) + END IF + CASE ELSE + 'limited to signed 32-bit int (LONG) + 'F(47)=&hB11924E1 + ERROR 6 'overflow + END SELECT +END FUNCTION diff --git a/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-3.bas b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-3.bas new file mode 100644 index 0000000000..3ab578dd8c --- /dev/null +++ b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-3.bas @@ -0,0 +1,7 @@ +FUNCTION recFib (n) + IF (n < 2) THEN + recFib = n + ELSE + recFib = recFib(n - 1) + recFib(n - 2) + END IF +END FUNCTION diff --git a/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-4.bas b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-4.bas new file mode 100644 index 0000000000..f721f68f05 --- /dev/null +++ b/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-4.bas @@ -0,0 +1,21 @@ +DATA -1836311903,1134903170,-701408733,433494437,-267914296,165580141,-102334155 +DATA 63245986,-39088169,24157817,-14930352,9227465,-5702887,3524578,-2178309 +DATA 1346269,-832040,514229,-317811,196418,-121393,75025,-46368,28657,-17711 +DATA 10946,-6765,4181,-2584,1597,-987,610,-377,233,-144,89,-55,34,-21,13,-8,5,-3 +DATA 2,-1,1,0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765 +DATA 10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269 +DATA 2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986 +DATA 102334155,165580141,267914296,433494437,701408733,1134903170,1836311903 + +DIM fibNum(-46 TO 46) AS LONG + +FOR n = -46 TO 46 + READ fibNum(n) +NEXT + +'*****sample inputs***** +FOR n = -46 TO 46 + PRINT fibNum(n), +NEXT +PRINT +'*****sample inputs***** diff --git a/Task/Fibonacci-sequence/BBC-BASIC/fibonacci-sequence.bbc b/Task/Fibonacci-sequence/BBC-BASIC/fibonacci-sequence.bbc new file mode 100644 index 0000000000..c0dabaf9a8 --- /dev/null +++ b/Task/Fibonacci-sequence/BBC-BASIC/fibonacci-sequence.bbc @@ -0,0 +1,19 @@ + PRINT FNfibonacci_r(1), FNfibonacci_i(1) + PRINT FNfibonacci_r(13), FNfibonacci_i(13) + PRINT FNfibonacci_r(26), FNfibonacci_i(26) + END + + DEF FNfibonacci_r(N) + IF N < 2 THEN = N + = FNfibonacci_r(N-1) + FNfibonacci_r(N-2) + + DEF FNfibonacci_i(N) + LOCAL F, I, P, T + IF N < 2 THEN = N + P = 1 + FOR I = 1 TO N + T = F + F += P + P = T + NEXT + = F diff --git a/Task/Fibonacci-sequence/Babel/fibonacci-sequence.pb b/Task/Fibonacci-sequence/Babel/fibonacci-sequence.pb new file mode 100644 index 0000000000..7f87b4a452 --- /dev/null +++ b/Task/Fibonacci-sequence/Babel/fibonacci-sequence.pb @@ -0,0 +1,17 @@ +main: + { argv 0 th $d + fib + %d cr << } + +fib!: + { dup zero? + { dup one? + { cp <- 2 - fib -> 1 - fib + } + { zap 1 } + if } + { zap 1 } + if } + +zero?!: { 0 = } + +one?!: { 1 = } diff --git a/Task/Fibonacci-sequence/Batch-File/fibonacci-sequence.bat b/Task/Fibonacci-sequence/Batch-File/fibonacci-sequence.bat new file mode 100644 index 0000000000..c0e1325fdb --- /dev/null +++ b/Task/Fibonacci-sequence/Batch-File/fibonacci-sequence.bat @@ -0,0 +1,21 @@ +::fibo.cmd +@echo off +if "%1" equ "" goto :eof +call :fib %1 +echo %errorlevel% +goto :eof + +:fib +setlocal enabledelayedexpansion +if %1 geq 2 goto :ge2 +exit /b %1 + +:ge2 +set /a r1 = %1 - 1 +set /a r2 = %1 - 2 +call :fib !r1! +set r1=%errorlevel% +call :fib !r2! +set r2=%errorlevel% +set /a r0 = r1 + r2 +exit /b !r0! diff --git a/Task/Fibonacci-sequence/Befunge/fibonacci-sequence.bf b/Task/Fibonacci-sequence/Befunge/fibonacci-sequence.bf new file mode 100644 index 0000000000..b886df7358 --- /dev/null +++ b/Task/Fibonacci-sequence/Befunge/fibonacci-sequence.bf @@ -0,0 +1,2 @@ +00:.1:.>:"@"8**++\1+:67+`#@_v + ^ .:\/*8"@"\%*8"@":\ < diff --git a/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-1.bracmat b/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-1.bracmat new file mode 100644 index 0000000000..daf2c3caeb --- /dev/null +++ b/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-1.bracmat @@ -0,0 +1 @@ +fib=.!arg:<2|fib$(!arg+-2)+fib$(!arg+-1) diff --git a/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-2.bracmat b/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-2.bracmat new file mode 100644 index 0000000000..a8a87ca1c7 --- /dev/null +++ b/Task/Fibonacci-sequence/Bracmat/fibonacci-sequence-2.bracmat @@ -0,0 +1,13 @@ +(fib= + last i this new +. !arg:<2 + | 0:?last:?i + & 1:?this + & whl + ' ( !i+1:>+<<[->[->+>+<<]>[-<+>]>[-<+>]<<<] diff --git a/Task/Fibonacci-sequence/Brainf---/fibonacci-sequence-2.bf b/Task/Fibonacci-sequence/Brainf---/fibonacci-sequence-2.bf new file mode 100644 index 0000000000..ab977a3e10 --- /dev/null +++ b/Task/Fibonacci-sequence/Brainf---/fibonacci-sequence-2.bf @@ -0,0 +1,37 @@ ++++++ +++++ #0 set to n +>> + Init #2 to 1 +<< +[ + - #Decrement counter in #0 + >>. Notice: This doesn't print it in ascii + To look at results you can pipe into a file and look with a hex editor + + Copying sequence to save #2 in #4 using #5 as restore space + >>[-] Move to #4 and clear + >[-] Clear #5 + <<< #2 + [ Move loop + - >> + > + <<< Subtract #2 and add #4 and #5 + ] + >>> + [ Restore loop + - <<< + >>> Subtract from #5 and add to #2 + ] + + <<<< Back to #1 + Non destructive add sequence using #3 as restore value + [ Loop to add + - > + > + << Subtract #1 and add to value #2 and restore space #3 + ] + >> + [ Loop to restore #1 from #3 + - << + >> Subtract from restore space #3 and add in #1 + ] + + << [-] Clear #1 + >>> + [ Loop to move #4 to #1 + - <<< + >>> Subtract from #4 and add to #1 + ] + <<<< Back to #0 +] diff --git a/Task/Fibonacci-sequence/Brat/fibonacci-sequence-1.brat b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-1.brat new file mode 100644 index 0000000000..1a7ab97c9a --- /dev/null +++ b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-1.brat @@ -0,0 +1,3 @@ +fibonacci = { x | + true? x < 2, x, { fibonacci(x - 1) + fibonacci(x - 2) } +} diff --git a/Task/Fibonacci-sequence/Brat/fibonacci-sequence-2.brat b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-2.brat new file mode 100644 index 0000000000..e78ace44a5 --- /dev/null +++ b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-2.brat @@ -0,0 +1,9 @@ +fib_aux = { x, next, result | + true? x == 0, + result, + { fib_aux x - 1, next + result, next } +} + +fibonacci = { x | + fib_aux x, 1, 0 +} diff --git a/Task/Fibonacci-sequence/Brat/fibonacci-sequence-3.brat b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-3.brat new file mode 100644 index 0000000000..bbc475a63c --- /dev/null +++ b/Task/Fibonacci-sequence/Brat/fibonacci-sequence-3.brat @@ -0,0 +1,7 @@ +cache = hash.new + +fibonacci = { x | + true? cache.key?(x) + { cache[x] } + {true? x < 2, x, { cache[x] = fibonacci(x - 1) + fibonacci(x - 2) }} +} diff --git a/Task/Fibonacci-sequence/Burlesque/fibonacci-sequence.blq b/Task/Fibonacci-sequence/Burlesque/fibonacci-sequence.blq new file mode 100644 index 0000000000..c6bbadce37 --- /dev/null +++ b/Task/Fibonacci-sequence/Burlesque/fibonacci-sequence.blq @@ -0,0 +1 @@ +{0 1}{^^++[+[-^^-]\/}30.*\[e!vv diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-1.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-1.cpp new file mode 100644 index 0000000000..3c47a2244e --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-1.cpp @@ -0,0 +1,16 @@ +#include + +int main() +{ + unsigned int a = 1, b = 1; + unsigned int target = 48; + for(unsigned int n = 3; n <= target; ++n) + { + unsigned int fib = a + b; + std::cout << "F("<< n << ") = " << fib << std::endl; + a = b; + b = fib; + } + + return 0; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-2.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-2.cpp new file mode 100644 index 0000000000..dbcf09e1cc --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-2.cpp @@ -0,0 +1,21 @@ +#include +#include + +int main() +{ + mpz_class a = mpz_class(1), b = mpz_class(1); + mpz_class target = mpz_class(100); + for(mpz_class n = mpz_class(3); n <= target; ++n) + { + mpz_class fib = b + a; + if ( fib < b ) + { + std::cout << "Overflow at " << n << std::endl; + break; + } + std::cout << "F("<< n << ") = " << fib << std::endl; + a = b; + b = fib; + } + return 0; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-3.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-3.cpp new file mode 100644 index 0000000000..2cb0cdba5e --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-3.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +unsigned int fibonacci(unsigned int n) { + if (n == 0) return 0; + std::vector v(n+1); + v[1] = 1; + transform(v.begin(), v.end()-2, v.begin()+1, v.begin()+2, std::plus()); + // "v" now contains the Fibonacci sequence from 0 up + return v[n]; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-4.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-4.cpp new file mode 100644 index 0000000000..011e954219 --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-4.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +unsigned int fibonacci(unsigned int n) { + if (n == 0) return 0; + std::vector v(n, 1); + adjacent_difference(v.begin(), v.end()-1, v.begin()+1, std::plus()); + // "array" now contains the Fibonacci sequence from 1 up + return v[n-1]; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-5.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-5.cpp new file mode 100644 index 0000000000..f1a47fc3ac --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-5.cpp @@ -0,0 +1,24 @@ +#include + +template struct fibo +{ + enum {value=fibo::value+fibo::value}; +}; + +template <> struct fibo<0> +{ + enum {value=0}; +}; + +template <> struct fibo<1> +{ + enum {value=1}; +}; + + +int main(int argc, char const *argv[]) +{ + std::cout<::value<::value< + +inline void fibmul(int* f, int* g) +{ + int tmp = f[0]*g[0] + f[1]*g[1]; + f[1] = f[0]*g[1] + f[1]*(g[0] + g[1]); + f[0] = tmp; +} + +int fibonacci(int n) +{ + int f[] = { 1, 0 }; + int g[] = { 0, 1 }; + while (n > 0) + { + if (n & 1) // n odd + { + fibmul(f, g); + --n; + } + else + { + fibmul(g, g); + n >>= 1; + } + } + return f[1]; +} + +int main() +{ + for (int i = 0; i < 20; ++i) + std::cout << fibonacci(i) << " "; + std::cout << std::endl; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-7.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-7.cpp new file mode 100644 index 0000000000..09b53a7e92 --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-7.cpp @@ -0,0 +1,15 @@ +// Use Zeckendorf numbers to display Fibonacci sequence. +// Nigel Galloway October 23rd., 2012 +int main(void) { + char NG[22] = {'1',0}; + int x = -1; + N G; + for (int fibs = 1; fibs <= 20; fibs++) { + for (;G <= N(NG); ++G) x++; + NG[fibs] = '0'; + NG[fibs+1] = 0; + std::cout << x << " "; + } + std::cout << std::endl; + return 0; +} diff --git a/Task/Fibonacci-sequence/C++/fibonacci-sequence-8.cpp b/Task/Fibonacci-sequence/C++/fibonacci-sequence-8.cpp new file mode 100644 index 0000000000..f8f3d4e336 --- /dev/null +++ b/Task/Fibonacci-sequence/C++/fibonacci-sequence-8.cpp @@ -0,0 +1,11 @@ +// Use Standard Template Library to display Fibonacci sequence. +// Nigel Galloway March 30th., 2013 +#include +#include +#include +int main() +{ + int x = 1, y = 1; + generate_n(std::ostream_iterator(std::cout, " "), 21, [&]{int n=x; x=y; y+=n; return n;}); + return 0; +} diff --git a/Task/Fibonacci-sequence/C/fibonacci-sequence-1.c b/Task/Fibonacci-sequence/C/fibonacci-sequence-1.c new file mode 100644 index 0000000000..30e6a23ce5 --- /dev/null +++ b/Task/Fibonacci-sequence/C/fibonacci-sequence-1.c @@ -0,0 +1,3 @@ +long long unsigned fib(unsigned n) { + return n < 2 ? n : fib(n - 1) + fib(n - 2); +} diff --git a/Task/Fibonacci-sequence/C/fibonacci-sequence-2.c b/Task/Fibonacci-sequence/C/fibonacci-sequence-2.c new file mode 100644 index 0000000000..2016fb230b --- /dev/null +++ b/Task/Fibonacci-sequence/C/fibonacci-sequence-2.c @@ -0,0 +1,10 @@ +long long unsigned fib(unsigned n) { + long long unsigned last = 0, this = 1, new, i; + if (n < 2) return n; + for (i = 1 ; i < n ; ++i) { + new = last + this; + last = this; + this = new; + } + return this; +} diff --git a/Task/Fibonacci-sequence/C/fibonacci-sequence-3.c b/Task/Fibonacci-sequence/C/fibonacci-sequence-3.c new file mode 100644 index 0000000000..f7be627bea --- /dev/null +++ b/Task/Fibonacci-sequence/C/fibonacci-sequence-3.c @@ -0,0 +1,6 @@ +#include +#define PHI ((1 + sqrt(5))/2) + +long long unsigned fib(unsigned n) { + return floor( (pow(PHI, n) - pow(1 - PHI, n))/sqrt(5) ); +} diff --git a/Task/Fibonacci-sequence/C/fibonacci-sequence-4.c b/Task/Fibonacci-sequence/C/fibonacci-sequence-4.c new file mode 100644 index 0000000000..536084dc9e --- /dev/null +++ b/Task/Fibonacci-sequence/C/fibonacci-sequence-4.c @@ -0,0 +1,37 @@ +#include +typedef enum{false=0, true=!0} bool; +typedef void iterator; + +#include +/* declare label otherwise it is not visible in sub-scope */ +#define LABEL(label) jmp_buf label; if(setjmp(label))goto label; +#define GOTO(label) longjmp(label, true) + +/* the following line is the only time I have ever required "auto" */ +#define FOR(i, iterator) { auto bool lambda(i); yield_init = (void *)λ iterator; bool lambda(i) +#define DO { +#define YIELD(x) if(!yield(x))return +#define BREAK return false +#define CONTINUE return true +#define OD CONTINUE; } } + +static volatile void *yield_init; /* not thread safe */ +#define YIELDS(type) bool (*yield)(type) = yield_init + +iterator fibonacci(int stop){ + YIELDS(int); + int f[] = {0, 1}; + int i; + for(i=0; i (take 10 fib) +(0 1 1 2 3 5 8 13 21 34) diff --git a/Task/Fibonacci-sequence/Clojure/fibonacci-sequence-6.clj b/Task/Fibonacci-sequence/Clojure/fibonacci-sequence-6.clj new file mode 100644 index 0000000000..5a40338bc1 --- /dev/null +++ b/Task/Fibonacci-sequence/Clojure/fibonacci-sequence-6.clj @@ -0,0 +1,18 @@ +;; max is which fib number you'd like computed (0th, 1st, 2nd, etc.) +;; n is which fib number you're on for this call (0th, 1st, 2nd, etc.) +;; j is the nth fib number (ex. when n = 5, j = 5) +;; i is the nth - 1 fib number +(defn- fib-iter + [max n i j] + (if (= n max) + j + (recur max + (inc n) + j + (+ i j)))) + +(defn fib + [max] + (if (< max 2) + max + (fib-iter max 1 0N 1N))) diff --git a/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-1.coffee b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-1.coffee new file mode 100644 index 0000000000..23fd97bf7b --- /dev/null +++ b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-1.coffee @@ -0,0 +1,4 @@ +fib_ana = (n) -> + sqrt = Math.sqrt + phi = ((1 + sqrt(5))/2) + return Math.round((Math.pow(phi, n)/sqrt(5))) diff --git a/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-2.coffee b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-2.coffee new file mode 100644 index 0000000000..7061778dd1 --- /dev/null +++ b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-2.coffee @@ -0,0 +1,7 @@ +fib_iter = (n) -> + if n < 2 + return n + [prev, curr] = 0, 1 + for i in [1..n] + [prev, curr] = [curr, curr + prev] + return curr diff --git a/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-3.coffee b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-3.coffee new file mode 100644 index 0000000000..0d4f1f0571 --- /dev/null +++ b/Task/Fibonacci-sequence/CoffeeScript/fibonacci-sequence-3.coffee @@ -0,0 +1,5 @@ +fib_rec = (n) -> + if n < 2 + return n + else + return fib_rec(n-1) + fib_rec(n-2) diff --git a/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-1.lisp b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-1.lisp new file mode 100644 index 0000000000..88b355bdf9 --- /dev/null +++ b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-1.lisp @@ -0,0 +1,4 @@ +(defun fibonacci-recursive (n) + (if (< n 2) + n + (+ (fibonacci-recursive (- n 2)) (fibonacci-recursive (- n 1))))) diff --git a/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-2.lisp b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-2.lisp new file mode 100644 index 0000000000..73bea2e31e --- /dev/null +++ b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-2.lisp @@ -0,0 +1,8 @@ +(defun fibonacci-iterative (n &aux (f0 0) (f1 1)) + (case n + (0 f0) + (1 f1) + (t (loop for n from 2 to n + for a = f0 then b and b = f1 then result + for result = (+ a b) + finally (return result))))) diff --git a/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-3.lisp b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-3.lisp new file mode 100644 index 0000000000..740efb0487 --- /dev/null +++ b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-3.lisp @@ -0,0 +1,4 @@ +(defun fibonacci-tail-recursive ( n &optional (a 0) (b 1)) + (if (= n 0) + a + (fibonacci-tail-recursive (- n 1) b (+ a b)))) diff --git a/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-4.lisp b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-4.lisp new file mode 100644 index 0000000000..bb4e24a4b8 --- /dev/null +++ b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-4.lisp @@ -0,0 +1,9 @@ +(defun fib (n &optional (a 1) (b 0) (p 0) (q 1)) + (if (= n 1) (+ (* b p) (* a q)) + (fib (ash n -1) + (if (evenp n) a (+ (* b q) (* a (+ p q)))) + (if (evenp n) b (+ (* b p) (* a q))) + (+ (* p p) (* q q)) + (+ (* q q) (* 2 p q))))) ;p is Fib(2^n-1), q is Fib(2^n). + +(print (fib 100000)) diff --git a/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-5.lisp b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-5.lisp new file mode 100644 index 0000000000..3b67859ea1 --- /dev/null +++ b/Task/Fibonacci-sequence/Common-Lisp/fibonacci-sequence-5.lisp @@ -0,0 +1 @@ +(loop for x = 0 then y and y = 1 then (+ x y) do (print x)) diff --git a/Task/Fibonacci-sequence/D/fibonacci-sequence-1.d b/Task/Fibonacci-sequence/D/fibonacci-sequence-1.d new file mode 100644 index 0000000000..61a7782e48 --- /dev/null +++ b/Task/Fibonacci-sequence/D/fibonacci-sequence-1.d @@ -0,0 +1,89 @@ +import std.stdio, std.conv, std.algorithm, std.math; + +long sgn(alias unsignedFib)(int n) { // break sign manipulation apart + immutable uint m = (n >= 0) ? n : -n; + if (n < 0 && (n % 2 == 0)) + return -unsignedFib(m); + else + return unsignedFib(m); +} + +long fibD(uint m) { // Direct Calculation, correct for abs(m) <= 84 + enum sqrt5r = 1.0L / sqrt(5.0L); // 1 / sqrt(5) + enum golden = (1.0L + sqrt(5.0L)) / 2.0L; // (1 + sqrt(5)) / 2 + return roundTo!long(pow(golden, m) * sqrt5r); +} + +long fibI(in uint m) pure nothrow { // Iterative + long thisFib = 0; + long nextFib = 1; + foreach (i; 0 .. m) { + long tmp = nextFib; + nextFib += thisFib; + thisFib = tmp; + } + return thisFib; +} + +long fibR(uint m) { // Recursive + return (m < 2) ? m : fibR(m - 1) + fibR(m - 2); +} + +long fibM(uint m) { // memoized Recursive + static long[] fib = [0, 1]; + while (m >= fib.length ) + fib ~= fibM(m - 2) + fibM(m - 1); + return fib[m]; +} + +alias sgn!fibD sfibD; +alias sgn!fibI sfibI; +alias sgn!fibR sfibR; +alias sgn!fibM sfibM; + +auto fibG(in int m) { // generator(?) + immutable int sign = (m < 0) ? -1 : 1; + long yield; + + return new class { + final int opApply(int delegate(ref int, ref long) dg) { + int idx = -sign; // prepare for pre-increment + foreach (f; this) + if (dg(idx += sign, f)) + break; + return 0; + } + + final int opApply(int delegate(ref long) dg) { + long f0, f1 = 1; + foreach (p; 0 .. m * sign + 1) { + if (sign == -1 && (p % 2 == 0)) + yield = -f0; + else + yield = f0; + if (dg(yield)) break; + auto temp = f1; + f1 = f0 + f1; + f0 = temp; + } + return 0; + } + }; +} + +void main(in string[] args) { + int k = args.length > 1 ? to!int(args[1]) : 10; + writefln("Fib(%3d) = ", k); + writefln("D : %20d <- %20d + %20d", + sfibD(k), sfibD(k - 1), sfibD(k - 2)); + writefln("I : %20d <- %20d + %20d", + sfibI(k), sfibI(k - 1), sfibI(k - 2)); + if (abs(k) < 36 || args.length > 2) + // set a limit for recursive version + writefln("R : %20d <- %20d + %20d", + sfibR(k), sfibM(k - 1), sfibM(k - 2)); + writefln("O : %20d <- %20d + %20d", + sfibM(k), sfibM(k - 1), sfibM(k - 2)); + foreach (i, f; fibG(-9)) + writef("%d:%d | ", i, f); +} diff --git a/Task/Fibonacci-sequence/D/fibonacci-sequence-2.d b/Task/Fibonacci-sequence/D/fibonacci-sequence-2.d new file mode 100644 index 0000000000..acd5fb1d0f --- /dev/null +++ b/Task/Fibonacci-sequence/D/fibonacci-sequence-2.d @@ -0,0 +1,30 @@ +import std.stdio, std.bigint; + +T fibonacciMatrix(T=BigInt)(size_t n) { + int[size_t.sizeof * 8] binDigits; + size_t nBinDigits; + while (n > 0) { + binDigits[nBinDigits] = n % 2; + n /= 2; + nBinDigits++; + } + + T x=1, y, z=1; + foreach_reverse (b; binDigits[0 .. nBinDigits]) { + if (b) { + x = (x + z) * y; + y = y ^^ 2 + z ^^ 2; + } else { + auto x_old = x; + x = x ^^ 2 + y ^^ 2; + y = (x_old + z) * y; + } + z = x + y; + } + + return y; +} + +void main() { + writeln(fibonacciMatrix(1_000_000)); +} diff --git a/Task/Fibonacci-sequence/DWScript/fibonacci-sequence.dwscript b/Task/Fibonacci-sequence/DWScript/fibonacci-sequence.dwscript new file mode 100644 index 0000000000..fbe5b9f07e --- /dev/null +++ b/Task/Fibonacci-sequence/DWScript/fibonacci-sequence.dwscript @@ -0,0 +1,5 @@ +function fib(N : Integer) : Integer; +begin + if N < 2 then Result := 1 + else Result := fib(N-2) + fib(N-1); +End; diff --git a/Task/Fibonacci-sequence/Dart/fibonacci-sequence.dart b/Task/Fibonacci-sequence/Dart/fibonacci-sequence.dart new file mode 100644 index 0000000000..e7e5afb66f --- /dev/null +++ b/Task/Fibonacci-sequence/Dart/fibonacci-sequence.dart @@ -0,0 +1,20 @@ +int fib(int n) { + if(n==0 || n==1) { + return n; + } + int prev=1; + int current=1; + for(int i=2;i n==0||n==1 ? n : fibRec(n-1)+fibRec(n-2); + +main() { + print(fib(11)); + print(fibRec(11)); +} diff --git a/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-1.delphi b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-1.delphi new file mode 100644 index 0000000000..7f63c6941f --- /dev/null +++ b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-1.delphi @@ -0,0 +1,18 @@ +function FibonacciI(N: Word): UInt64; +var + Last, New: UInt64; + I: Word; +begin + if N < 2 then + Result := N + else begin + Last := 0; + Result := 1; + for I := 2 to N do + begin + New := Last + Result; + Last := Result; + Result := New; + end; + end; +end; diff --git a/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-2.delphi b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-2.delphi new file mode 100644 index 0000000000..5175b5469b --- /dev/null +++ b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-2.delphi @@ -0,0 +1,7 @@ +function Fibonacci(N: Word): UInt64; +begin + if N < 2 then + Result := N + else + Result := Fibonacci(N - 1) + Fibonacci(N - 2); +end; diff --git a/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-3.delphi b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-3.delphi new file mode 100644 index 0000000000..b1958cc9c9 --- /dev/null +++ b/Task/Fibonacci-sequence/Delphi/fibonacci-sequence-3.delphi @@ -0,0 +1,37 @@ +function fib(n:Int64):int64; + + type TFibMat = array[0..1] of array[0..1] of int64; + + function FibMatMul(a,b:TFibMat):TFibMat; + var i,j,k:integer; + tmp:TFibMat; + begin + for i:=0 to 1 do + for j:=0 to 1 do + begin + tmp[i,j]:=0; + for k:=0 to 1 do tmp[i,j]:=tmp[i,j]+a[i,k]*b[k,j]; + end; + FibMatMul:=tmp; + end; + + function FibMatExp(a:TFibMat;n:int64):TFibmat; + begin + if n<=1 then fibmatexp:=a else + if (n mod 2 = 0) then FibMatExp:=FibMatExp(FibMatMul(a,a), n div 2) else + if (n mod 2 = 1) then FibMatExp:=FibMatMul(a,FibMatExp(FibMatMul(a,a),(n) div 2)); + end; + + +var + matrix:TFibMat; + +begin +matrix[0,0]:=1; +matrix[0,1]:=1; +matrix[1,0]:=1; +matrix[1,1]:=0; +if n>1 then +matrix:=fibmatexp(matrix,n-1); +fib:=matrix[0,0]; +end; diff --git a/Task/Fibonacci-sequence/E/fibonacci-sequence.e b/Task/Fibonacci-sequence/E/fibonacci-sequence.e new file mode 100644 index 0000000000..b5bd714805 --- /dev/null +++ b/Task/Fibonacci-sequence/E/fibonacci-sequence.e @@ -0,0 +1,8 @@ +def fib(n) { + var s := [0, 1] + for _ in 0..!n { + def [a, b] := s + s := [b, a+b] + } + return s[0] +} diff --git a/Task/Fibonacci-sequence/Ela/fibonacci-sequence-1.ela b/Task/Fibonacci-sequence/Ela/fibonacci-sequence-1.ela new file mode 100644 index 0000000000..c0af1897b9 --- /dev/null +++ b/Task/Fibonacci-sequence/Ela/fibonacci-sequence-1.ela @@ -0,0 +1,3 @@ +fib = fib' 0 1 + where fib' a b 0 = a + fib' a b n = fib' b (a + b) (n - 1) diff --git a/Task/Fibonacci-sequence/Ela/fibonacci-sequence-2.ela b/Task/Fibonacci-sequence/Ela/fibonacci-sequence-2.ela new file mode 100644 index 0000000000..90ff815b10 --- /dev/null +++ b/Task/Fibonacci-sequence/Ela/fibonacci-sequence-2.ela @@ -0,0 +1,2 @@ +fib = fib' 1 1 + where fib' x y = & x :: fib' y (x + y) diff --git a/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-1.erl b/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-1.erl new file mode 100644 index 0000000000..69d03b2fbd --- /dev/null +++ b/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-1.erl @@ -0,0 +1,3 @@ +fib(0) -> 0; +fib(1) -> 1; +fib(N) when N > 1 -> fib(N-1) + fib(N-2). diff --git a/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-2.erl b/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-2.erl new file mode 100644 index 0000000000..45e27cafba --- /dev/null +++ b/Task/Fibonacci-sequence/Erlang/fibonacci-sequence-2.erl @@ -0,0 +1,3 @@ +fib(N) -> fib(N,0,1). +fib(0,Res,_) -> Res; +fib(N,Res,Next) when N > 0 -> fib(N-1, Next, Res+Next). diff --git a/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-1.euphoria b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-1.euphoria new file mode 100644 index 0000000000..2001ada169 --- /dev/null +++ b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-1.euphoria @@ -0,0 +1,4 @@ +function fibor(integer n) + if n<2 then return n end if + return fibor(n-1)+fibor(n-2) +end function diff --git a/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-2.euphoria b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-2.euphoria new file mode 100644 index 0000000000..5a4e4b3164 --- /dev/null +++ b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-2.euphoria @@ -0,0 +1,10 @@ +function fiboi(integer n) +integer f0=0, f1=1, f + if n<2 then return n end if + for i=2 to n do + f=f0+f1 + f0=f1 + f1=f + end for + return f +end function diff --git a/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-3.euphoria b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-3.euphoria new file mode 100644 index 0000000000..56d70e8d47 --- /dev/null +++ b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-3.euphoria @@ -0,0 +1,10 @@ +function fibot(integer n, integer u = 1, integer s = 0) + if n < 1 then + return s + else + return fibot(n-1,u+s,u) + end if +end function + +-- example: +? fibot(10) -- says 55 diff --git a/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-4.euphoria b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-4.euphoria new file mode 100644 index 0000000000..c20612ddaa --- /dev/null +++ b/Task/Fibonacci-sequence/Euphoria/fibonacci-sequence-4.euphoria @@ -0,0 +1,78 @@ +include std/mathcons.e -- for PINF constant + +enum ADD, MOVE, GOTO, OUT, TEST, TRUETO + +global sequence tape = { 0, + 1, + { ADD, 2, 1 }, + { TEST, 1, PINF }, + { TRUETO, 0 }, + { OUT, 1, "%.0f\n" }, + { MOVE, 2, 1 }, + { MOVE, 0, 2 }, + { GOTO, 3 } } + +global integer ip +global integer test +global atom accum + +procedure eval( sequence cmd ) + atom i = 1 + while i <= length( cmd ) do + switch cmd[ i ] do + case ADD then + accum = tape[ cmd[ i + 1 ] ] + tape[ cmd[ i + 2 ] ] + i += 2 + + case OUT then + printf( 1, cmd[ i + 2], tape[ cmd[ i + 1 ] ] ) + i += 2 + + case MOVE then + if cmd[ i + 1 ] = 0 then + tape[ cmd[ i + 2 ] ] = accum + else + tape[ cmd[ i + 2 ] ] = tape[ cmd[ i + 1 ] ] + end if + i += 2 + + case GOTO then + ip = cmd[ i + 1 ] - 1 -- due to ip += 1 in main loop + i += 1 + + case TEST then + if tape[ cmd[ i + 1 ] ] = cmd[ i + 2 ] then + test = 1 + else + test = 0 + end if + i += 2 + + case TRUETO then + if test then + if cmd[ i + 1 ] = 0 then + abort(0) + else + ip = cmd[ i + 1 ] - 1 + end if + end if + + end switch + i += 1 + end while +end procedure + +test = 0 +accum = 0 +ip = 1 + +while 1 do + + -- embedded sequences (assumed to be code) are evaluated + -- atoms (assumed to be data) are ignored + + if sequence( tape[ ip ] ) then + eval( tape[ ip ] ) + end if + ip += 1 +end while diff --git a/Task/Fibonacci-sequence/FALSE/fibonacci-sequence.false b/Task/Fibonacci-sequence/FALSE/fibonacci-sequence.false new file mode 100644 index 0000000000..e1d60dd45c --- /dev/null +++ b/Task/Fibonacci-sequence/FALSE/fibonacci-sequence.false @@ -0,0 +1,3 @@ +[[$0=~][1-@@\$@@+\$44,.@]#]f: +20n: {First 20 numbers} +0 1 n;f;!%%44,. {Output: "0,1,1,2,3,5..."} diff --git a/Task/Fibonacci-sequence/Factor/fibonacci-sequence-1.factor b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-1.factor new file mode 100644 index 0000000000..905d8235dd --- /dev/null +++ b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-1.factor @@ -0,0 +1,5 @@ +: fib ( n -- m ) + dup 2 < [ + [ 0 1 ] dip [ swap [ + ] keep ] times + drop + ] unless ; diff --git a/Task/Fibonacci-sequence/Factor/fibonacci-sequence-2.factor b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-2.factor new file mode 100644 index 0000000000..1559de0f9d --- /dev/null +++ b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-2.factor @@ -0,0 +1,4 @@ +: fib ( n -- m ) + dup 2 < [ + [ 1 - fib ] [ 2 - fib ] bi + + ] unless ; diff --git a/Task/Fibonacci-sequence/Factor/fibonacci-sequence-3.factor b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-3.factor new file mode 100644 index 0000000000..f5bb5a3084 --- /dev/null +++ b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-3.factor @@ -0,0 +1,6 @@ +: fib2 ( x y n -- a ) + dup 1 < + [ 2drop ] + [ [ swap [ + ] keep ] dip 1 - fib2 ] + if ; +: fib ( n -- m ) [ 0 1 ] dip fib2 ; diff --git a/Task/Fibonacci-sequence/Factor/fibonacci-sequence-4.factor b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-4.factor new file mode 100644 index 0000000000..003436f39b --- /dev/null +++ b/Task/Fibonacci-sequence/Factor/fibonacci-sequence-4.factor @@ -0,0 +1,7 @@ +USE: math.matrices + +: fib ( n -- m ) + dup 2 < [ + [ { { 0 1 } { 1 1 } } ] dip 1 - m^n + second second + ] unless ; diff --git a/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-1.falcon b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-1.falcon new file mode 100644 index 0000000000..76d11f296e --- /dev/null +++ b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-1.falcon @@ -0,0 +1,13 @@ +function fib_i(n) + + if n < 2: return n + + fibPrev = 1 + fib = 1 + for i in [2:n] + tmp = fib + fib += fibPrev + fibPrev = tmp + end + return fib +end diff --git a/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-2.falcon b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-2.falcon new file mode 100644 index 0000000000..b2b1683222 --- /dev/null +++ b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-2.falcon @@ -0,0 +1,4 @@ +function fib_r(n) + if n < 2 : return n + return fib_r(n-1) + fib_r(n-2) +end diff --git a/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-3.falcon b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-3.falcon new file mode 100644 index 0000000000..05ce2eab65 --- /dev/null +++ b/Task/Fibonacci-sequence/Falcon/fibonacci-sequence-3.falcon @@ -0,0 +1,9 @@ +function fib_tr(n) + return fib_aux(n,0,1) +end +function fib_aux(n,a,b) + switch n + case 0 : return a + default: return fib_aux(n-1,a+b,a) + end +end diff --git a/Task/Fibonacci-sequence/Fancy/fibonacci-sequence.fancy b/Task/Fibonacci-sequence/Fancy/fibonacci-sequence.fancy new file mode 100644 index 0000000000..85eef82a8c --- /dev/null +++ b/Task/Fibonacci-sequence/Fancy/fibonacci-sequence.fancy @@ -0,0 +1,13 @@ +class Fixnum { + def fib { + match self -> { + case 0 -> 0 + case 1 -> 1 + case _ -> self - 1 fib + (self - 2 fib) + } + } +} + +15 times: |x| { + x fib println +} diff --git a/Task/Fibonacci-sequence/Fantom/fibonacci-sequence.fantom b/Task/Fibonacci-sequence/Fantom/fibonacci-sequence.fantom new file mode 100644 index 0000000000..07c2f326ec --- /dev/null +++ b/Task/Fibonacci-sequence/Fantom/fibonacci-sequence.fantom @@ -0,0 +1,21 @@ +class Main +{ + static Int fib (Int n) + { + if (n < 2) return n + fibNums := [1, 0] + while (fibNums.size <= n) + { + fibNums.insert (0, fibNums[0] + fibNums[1]) + } + return fibNums.first + } + + public static Void main () + { + 20.times |n| + { + echo ("Fib($n) is ${fib(n)}") + } + } +} diff --git a/Task/Fibonacci-sequence/Fexl/fibonacci-sequence.fexl b/Task/Fibonacci-sequence/Fexl/fibonacci-sequence.fexl new file mode 100644 index 0000000000..92d6a2ba6d --- /dev/null +++ b/Task/Fibonacci-sequence/Fexl/fibonacci-sequence.fexl @@ -0,0 +1,26 @@ +# fibonacci is the infinite list of all Fibonacci numbers. +# +# Note that this program uses the symbols "1" and "+". You can specify +# the definitions of those symbols however you like, allowing you to use +# any system of arithmetic you need. For example, you can use either the +# built-in long arithmetic, or infinite precision arithmetic, by simply +# defining "1" and "+" appropriately. + +\fibonacci = + ( + \fibonacci == (\x\y + item x; + \z = (+ x y) + fibonacci y z + ) + + fibonacci 1 1 + ) + +# OK, so that's the list of *all* Fibonacci numbers. If you want the nth number, +# you can extract it with the fib function as follows. By the way, this *does* +# have the effect of caching, so once a particular point in the sequence is +# calculated, it doesn't have to be calculated again. + +# (fib n) is the nth fibonacci number, starting with n==0, or 1 if n is negative. +\fib = (\n list_at fibonacci n 1) diff --git a/Task/Fibonacci-sequence/Forth/fibonacci-sequence.fth b/Task/Fibonacci-sequence/Forth/fibonacci-sequence.fth new file mode 100644 index 0000000000..32f076c2dd --- /dev/null +++ b/Task/Fibonacci-sequence/Forth/fibonacci-sequence.fth @@ -0,0 +1,2 @@ +: fib ( n -- fib ) + 0 1 rot 0 ?do over + swap loop drop ; diff --git a/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-1.f b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-1.f new file mode 100644 index 0000000000..66e77dd394 --- /dev/null +++ b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-1.f @@ -0,0 +1,12 @@ +module fibonacci +contains + recursive function fibR(n) result(fib) + integer, intent(in) :: n + integer :: fib + + select case (n) + case (:0); fib = 0 + case (1); fib = 1 + case default; fib = fibR(n-1) + fibR(n-2) + end select + end function fibR diff --git a/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-2.f b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-2.f new file mode 100644 index 0000000000..6dcf24627b --- /dev/null +++ b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-2.f @@ -0,0 +1,20 @@ + function fibI(n) + integer, intent(in) :: n + integer, parameter :: fib0 = 0, fib1 = 1 + integer :: fibI, back1, back2, i + + select case (n) + case (:0); fibI = fib0 + case (1); fibI = fib1 + + case default + fibI = fib1 + back1 = fib0 + do i = 2, n + back2 = back1 + back1 = fibI + fibI = back1 + back2 + end do + end select + end function fibI +end module fibonacci diff --git a/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-3.f b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-3.f new file mode 100644 index 0000000000..6b7cb46101 --- /dev/null +++ b/Task/Fibonacci-sequence/Fortran/fibonacci-sequence-3.f @@ -0,0 +1,7 @@ +program fibTest + use fibonacci + + do i = 0, 10 + print *, fibr(i), fibi(i) + end do +end program fibTest diff --git a/Task/Fibonacci-sequence/GAP/fibonacci-sequence-1.gap b/Task/Fibonacci-sequence/GAP/fibonacci-sequence-1.gap new file mode 100644 index 0000000000..af5017d0e7 --- /dev/null +++ b/Task/Fibonacci-sequence/GAP/fibonacci-sequence-1.gap @@ -0,0 +1,5 @@ +fib := function(n) + local a; + a := [[0, 1], [1, 1]]^n; + return a[1][2]; +end; diff --git a/Task/Fibonacci-sequence/GAP/fibonacci-sequence-2.gap b/Task/Fibonacci-sequence/GAP/fibonacci-sequence-2.gap new file mode 100644 index 0000000000..4968b69136 --- /dev/null +++ b/Task/Fibonacci-sequence/GAP/fibonacci-sequence-2.gap @@ -0,0 +1 @@ +Fibonacci(n); diff --git a/Task/Fibonacci-sequence/Gecho/fibonacci-sequence.gecho b/Task/Fibonacci-sequence/Gecho/fibonacci-sequence.gecho new file mode 100644 index 0000000000..0a5000e4bf --- /dev/null +++ b/Task/Fibonacci-sequence/Gecho/fibonacci-sequence.gecho @@ -0,0 +1 @@ +0 1 dup wover + dup wover + dup wover + dup wover + diff --git a/Task/Fibonacci-sequence/Go/fibonacci-sequence-1.go b/Task/Fibonacci-sequence/Go/fibonacci-sequence-1.go new file mode 100644 index 0000000000..1600cc4580 --- /dev/null +++ b/Task/Fibonacci-sequence/Go/fibonacci-sequence-1.go @@ -0,0 +1,6 @@ +func fib(a int) int { + if a < 2 { + return a + } + return fib(a - 1) + fib(a - 2) +} diff --git a/Task/Fibonacci-sequence/Go/fibonacci-sequence-2.go b/Task/Fibonacci-sequence/Go/fibonacci-sequence-2.go new file mode 100644 index 0000000000..d045c8991e --- /dev/null +++ b/Task/Fibonacci-sequence/Go/fibonacci-sequence-2.go @@ -0,0 +1,16 @@ +import ( + "fmt" + "math/big" +) + +func fib(n uint64) *big.Int { + if n < 2 { + return big.NewInt(int64(n)) + } + a, b := big.NewInt(0), big.NewInt(1) + for n--; n > 0; n-- { + a.Add(a, b) + a, b = b, a + } + return b +} diff --git a/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-1.groovy b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-1.groovy new file mode 100644 index 0000000000..e240e0da8a --- /dev/null +++ b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-1.groovy @@ -0,0 +1,2 @@ +def rFib +rFib = { it < 1 ? 0 : it == 1 ? 1 : rFib(it-1) + rFib(it-2) } diff --git a/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-2.groovy b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-2.groovy new file mode 100644 index 0000000000..55d41b1913 --- /dev/null +++ b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-2.groovy @@ -0,0 +1 @@ +def iFib = { it < 1 ? 0 : it == 1 ? 1 : (2..it).inject([0,1]){i, j -> [i[1], i[0]+i[1]]}[1] } diff --git a/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-3.groovy b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-3.groovy new file mode 100644 index 0000000000..3ad18dc77a --- /dev/null +++ b/Task/Fibonacci-sequence/Groovy/fibonacci-sequence-3.groovy @@ -0,0 +1 @@ +(0..20).each { println "${it}: ${rFib(it)} ${iFib(it)}" } diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-1.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-1.hs new file mode 100644 index 0000000000..eb85845a7f --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-1.hs @@ -0,0 +1 @@ +fib = 0 : 1 : zipWith (+) fib (tail fib) diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-2.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-2.hs new file mode 100644 index 0000000000..bac976bc03 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-2.hs @@ -0,0 +1 @@ +fib = 0 : 1 : next fib where next (a: t@(b:_)) = (a+b) : next t diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-3.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-3.hs new file mode 100644 index 0000000000..093c22af12 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-3.hs @@ -0,0 +1 @@ +fib = 0 : scanl (+) 1 fib diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-4.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-4.hs new file mode 100644 index 0000000000..834fc5fc26 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-4.hs @@ -0,0 +1,15 @@ +import Data.List + +xs <+> ys = zipWith (+) xs ys +xs <*> ys = sum $ zipWith (*) xs ys + +newtype Mat a = Mat {unMat :: [[a]]} deriving Eq + +instance Show a => Show (Mat a) where + show xm = "Mat " ++ show (unMat xm) + +instance Num a => Num (Mat a) where + negate xm = Mat $ map (map negate) $ unMat xm + xm + ym = Mat $ zipWith (<+>) (unMat xm) (unMat ym) + xm * ym = Mat [[xs <*> ys | ys <- transpose $ unMat ym] | xs <- unMat xm] + fromInteger n = Mat [[fromInteger n]] diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-5.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-5.hs new file mode 100644 index 0000000000..1f3ba1d2e4 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-5.hs @@ -0,0 +1,3 @@ +fib 0 = 0 -- this line is necessary because "something ^ 0" returns "fromInteger 1", which unfortunately + -- in our case is not our multiplicative identity (the identity matrix) but just a 1x1 matrix of 1 +fib n = last $ head $ unMat $ (Mat [[1,1],[1,0]]) ^ n diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-6.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-6.hs new file mode 100644 index 0000000000..8a73d176ff --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-6.hs @@ -0,0 +1,20 @@ +fibsteps (a,b) n + | n <= 0 = (a,b) + | True = fibsteps (b, a+b) (n-1) + +fibnums :: [Integer] +fibnums = map fst $ iterate (`fibsteps` 1) (0,1) + +fibN2 :: Integer -> (Integer, Integer) +fibN2 m | m < 10 = fibsteps (0,1) 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 + d = ( 5*g^3 + if even n then (- 3*g) else 3*g ) -- 3(n+1) (*) + b = ( g^3 + 3 * g * f^2 - f^3 ) -- 3n+1 + c = ( g^3 + 3 * g^2 * f + f^3 ) -- 3n+2 diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-7.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-7.hs new file mode 100644 index 0000000000..3a908740e5 --- /dev/null +++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-7.hs @@ -0,0 +1,2 @@ + *Main> take 10 $ show $ fst $ fibN2 (10^6) + "1953282128" diff --git a/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-1.haxe b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-1.haxe new file mode 100644 index 0000000000..319933ed87 --- /dev/null +++ b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-1.haxe @@ -0,0 +1,15 @@ +static function fib(steps:Int, handler:Int->Void) +{ + var current = 0; + var next = 1; + + for (i in 1...steps) + { + handler(current); + + var temp = current + next; + current = next; + next = temp; + } + handler(current); +} diff --git a/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-2.haxe b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-2.haxe new file mode 100644 index 0000000000..b99f722d0c --- /dev/null +++ b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-2.haxe @@ -0,0 +1,23 @@ +class FibIter +{ + public var current:Int; + private var nextItem:Int; + private var limit:Int; + + public function new(limit) { + current = 0; + nextItem = 1; + this.limit = limit; + } + + public function hasNext() return limit > 0 + + public function next() { + limit--; + var ret = current; + var temp = current + nextItem; + current = nextItem; + nextItem = temp; + return ret; + } +} diff --git a/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-3.haxe b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-3.haxe new file mode 100644 index 0000000000..bb6925958f --- /dev/null +++ b/Task/Fibonacci-sequence/Haxe/fibonacci-sequence-3.haxe @@ -0,0 +1,2 @@ +for (i in new FibIter(10)) + Sys.println(i); diff --git a/Task/Fibonacci-sequence/HicEst/fibonacci-sequence.hicest b/Task/Fibonacci-sequence/HicEst/fibonacci-sequence.hicest new file mode 100644 index 0000000000..b34ff25d94 --- /dev/null +++ b/Task/Fibonacci-sequence/HicEst/fibonacci-sequence.hicest @@ -0,0 +1,4 @@ +REAL :: Fibonacci(10) + +Fibonacci = ($==2) + Fibonacci($-1) + Fibonacci($-2) +WRITE(ClipBoard) Fibonacci ! 0 1 1 2 3 5 8 13 21 34 diff --git a/Task/Fibonacci-sequence/Hope/fibonacci-sequence-1.hope b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-1.hope new file mode 100644 index 0000000000..49514111c4 --- /dev/null +++ b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-1.hope @@ -0,0 +1,4 @@ +dec f : num -> num; +--- f 0 <= 0; +--- f 1 <= 1; +--- f(n+2) <= f n + f(n+1); diff --git a/Task/Fibonacci-sequence/Hope/fibonacci-sequence-2.hope b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-2.hope new file mode 100644 index 0000000000..a710ca6cce --- /dev/null +++ b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-2.hope @@ -0,0 +1,4 @@ +dec fib : num -> num; +--- fib n <= l (1, 0, n) + whererec l == \(a,b,succ c) => if c<1 then a else l((a+b),a,c) + |(a,b,0) => 0; diff --git a/Task/Fibonacci-sequence/Hope/fibonacci-sequence-3.hope b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-3.hope new file mode 100644 index 0000000000..5cd5be7907 --- /dev/null +++ b/Task/Fibonacci-sequence/Hope/fibonacci-sequence-3.hope @@ -0,0 +1,2 @@ +dec fibs : list num; +--- fibs <= fs whererec fs == 0::1::map (+) (tail fs||fs); diff --git a/Task/Fibonacci-sequence/IDL/fibonacci-sequence-1.idl b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-1.idl new file mode 100644 index 0000000000..91b4bd6281 --- /dev/null +++ b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-1.idl @@ -0,0 +1,3 @@ +function fib,n + if n lt 3 then return,1L else return, fib(n-1)+fib(n-2) +end diff --git a/Task/Fibonacci-sequence/IDL/fibonacci-sequence-2.idl b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-2.idl new file mode 100644 index 0000000000..534f8f363c --- /dev/null +++ b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-2.idl @@ -0,0 +1,10 @@ +function fib,n + psum = (csum = 1uL) + if n lt 3 then return,csum + for i = 3,n do begin + nsum = psum + csum + psum = csum + csum = nsum + endfor + return,nsum +end diff --git a/Task/Fibonacci-sequence/IDL/fibonacci-sequence-3.idl b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-3.idl new file mode 100644 index 0000000000..c2123fdd31 --- /dev/null +++ b/Task/Fibonacci-sequence/IDL/fibonacci-sequence-3.idl @@ -0,0 +1,4 @@ +function fib,n + q=1/( p=(1+sqrt(5))/2 ) + return,round((p^n+q^n)/sqrt(5)) +end diff --git a/Task/Fibonacci-sequence/Icon/fibonacci-sequence-1.icon b/Task/Fibonacci-sequence/Icon/fibonacci-sequence-1.icon new file mode 100644 index 0000000000..0b7694f67d --- /dev/null +++ b/Task/Fibonacci-sequence/Icon/fibonacci-sequence-1.icon @@ -0,0 +1,14 @@ +procedure main(args) + write(fib(integer(!args) | 1000) +end + +procedure fib(n) + static fCache + initial { + fCache := table() + fCache[0] := 0 + fCache[1] := 1 + } + /fCache[n] := fib(n-1) + fib(n-2) + return fCache[n] +end diff --git a/Task/Fibonacci-sequence/Icon/fibonacci-sequence-2.icon b/Task/Fibonacci-sequence/Icon/fibonacci-sequence-2.icon new file mode 100644 index 0000000000..c750964441 --- /dev/null +++ b/Task/Fibonacci-sequence/Icon/fibonacci-sequence-2.icon @@ -0,0 +1,17 @@ +procedure main(args) + write(fib(integer(!args) | 1000000)) +end + +procedure fib(n) + return fibMat(n)[1] +end + +procedure fibMat(n) + if n <= 0 then return [0,0] + if n = 1 then return [1,0] + fp := fibMat(n/2) + c := fp[1]*fp[1] + fp[2]*fp[2] + d := fp[1]*(fp[1]+2*fp[2]) + if n%2 = 1 then return [c+d, d] + else return [d, c] +end diff --git a/Task/Fibonacci-sequence/J/fibonacci-sequence-1.j b/Task/Fibonacci-sequence/J/fibonacci-sequence-1.j new file mode 100644 index 0000000000..52f1c2cd0d --- /dev/null +++ b/Task/Fibonacci-sequence/J/fibonacci-sequence-1.j @@ -0,0 +1 @@ + fibN=: (-&2 +&$: -&1)^:(1&<) M."0 diff --git a/Task/Fibonacci-sequence/J/fibonacci-sequence-2.j b/Task/Fibonacci-sequence/J/fibonacci-sequence-2.j new file mode 100644 index 0000000000..e37a577cec --- /dev/null +++ b/Task/Fibonacci-sequence/J/fibonacci-sequence-2.j @@ -0,0 +1,4 @@ + fibN 12 +144 + fibN i.31 +0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 diff --git a/Task/Fibonacci-sequence/Java/fibonacci-sequence-1.java b/Task/Fibonacci-sequence/Java/fibonacci-sequence-1.java new file mode 100644 index 0000000000..8c61d1304d --- /dev/null +++ b/Task/Fibonacci-sequence/Java/fibonacci-sequence-1.java @@ -0,0 +1,15 @@ +public static long itFibN(int n) +{ + if (n < 2) + return n; + long ans = 0; + long n1 = 0; + long n2 = 1; + for(n--; n > 0; n--) + { + ans = n1 + n2; + n1 = n2; + n2 = ans; + } + return ans; +} diff --git a/Task/Fibonacci-sequence/Java/fibonacci-sequence-2.java b/Task/Fibonacci-sequence/Java/fibonacci-sequence-2.java new file mode 100644 index 0000000000..2a0d0e756d --- /dev/null +++ b/Task/Fibonacci-sequence/Java/fibonacci-sequence-2.java @@ -0,0 +1,4 @@ +public static long recFibN(final int n) +{ + return (n < 2) ? n : recFibN(n - 1) + recFibN(n - 2); +} diff --git a/Task/Fibonacci-sequence/Java/fibonacci-sequence-3.java b/Task/Fibonacci-sequence/Java/fibonacci-sequence-3.java new file mode 100644 index 0000000000..ca86e5a2aa --- /dev/null +++ b/Task/Fibonacci-sequence/Java/fibonacci-sequence-3.java @@ -0,0 +1,6 @@ +public static long anFibN(final long n) +{ + double p = (1 + Math.sqrt(5)) / 2; + double q = 1 / p; + return (long) ((Math.pow(p, n) + Math.pow(q, n)) / Math.sqrt(5)); +} diff --git a/Task/Fibonacci-sequence/Java/fibonacci-sequence-4.java b/Task/Fibonacci-sequence/Java/fibonacci-sequence-4.java new file mode 100644 index 0000000000..3cb2baabc9 --- /dev/null +++ b/Task/Fibonacci-sequence/Java/fibonacci-sequence-4.java @@ -0,0 +1,9 @@ +public static long fibTailRec(final int n) +{ + return fibInner(0, 1, n); +} + +private static long fibInner(final long a, final long b, final int n) +{ + return n < 1 ? a : n == 1 ? b : fibInner(b, a + b, n - 1); +} diff --git a/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-1.js b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-1.js new file mode 100644 index 0000000000..2546838ad4 --- /dev/null +++ b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-1.js @@ -0,0 +1,5 @@ +function fib(n) { + return function(n,a,b) { + return n>0 ? arguments.callee(n-1,b,a+b) : a; + }(n,0,1); +} diff --git a/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-2.js b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-2.js new file mode 100644 index 0000000000..44e1e03185 --- /dev/null +++ b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-2.js @@ -0,0 +1,18 @@ +function fib(n) +{ + var + a = 0, + b = 1, + t; + while (n-- > 0) + { + t = a; + a = b; + b += t; + } + return a; +} + +var i; +for (i = 0; i < 10; ++i) + alert(fib(i)); diff --git a/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-3.js b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-3.js new file mode 100644 index 0000000000..7b3b4d45fc --- /dev/null +++ b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-3.js @@ -0,0 +1,7 @@ +var fib = (function(cache){ + return cache = cache || {}, function(n){ + if (cache[n]) return cache[n]; + else return cache[n] = n == 0 ? 0 : n < 0 ? -fib(-n) + : n <= 2 ? 1 : fib(n-2) + fib(n-1); + }; +})(); diff --git a/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-4.js b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-4.js new file mode 100644 index 0000000000..9c507fdc23 --- /dev/null +++ b/Task/Fibonacci-sequence/JavaScript/fibonacci-sequence-4.js @@ -0,0 +1,17 @@ +function Y(dn) { + return (function(fn) { + return fn(fn); + }(function(fn) { + return dn(function() { + return fn(fn).apply(null, arguments); + }); + })); +} +var fib = Y(function(fn) { + return function(n) { + if (n === 0 || n === 1) { + return n; + } + return fn(n - 1) + fn(n - 2); + }; +}); diff --git a/Task/Fibonacci-sequence/Joy/fibonacci-sequence-1.joy b/Task/Fibonacci-sequence/Joy/fibonacci-sequence-1.joy new file mode 100644 index 0000000000..ce647abee1 --- /dev/null +++ b/Task/Fibonacci-sequence/Joy/fibonacci-sequence-1.joy @@ -0,0 +1 @@ +DEFINE fib == [small] [] [pred dup pred] [+] binrec. diff --git a/Task/Fibonacci-sequence/Joy/fibonacci-sequence-2.joy b/Task/Fibonacci-sequence/Joy/fibonacci-sequence-2.joy new file mode 100644 index 0000000000..cd3e040e77 --- /dev/null +++ b/Task/Fibonacci-sequence/Joy/fibonacci-sequence-2.joy @@ -0,0 +1 @@ +DEFINE fib == [1 0] dip [swap [+] unary] times popd. diff --git a/Task/Fibonacci-sequence/Julia/fibonacci-sequence.julia b/Task/Fibonacci-sequence/Julia/fibonacci-sequence.julia new file mode 100644 index 0000000000..e78d961c15 --- /dev/null +++ b/Task/Fibonacci-sequence/Julia/fibonacci-sequence.julia @@ -0,0 +1 @@ +fib(n) = n < 2 ? n : fib(n-1) + fib(n-2) diff --git a/Task/Fibonacci-sequence/K/fibonacci-sequence-1.k b/Task/Fibonacci-sequence/K/fibonacci-sequence-1.k new file mode 100644 index 0000000000..8816e02a00 --- /dev/null +++ b/Task/Fibonacci-sequence/K/fibonacci-sequence-1.k @@ -0,0 +1 @@ +{:[x<3;1;_f[x-1]+_f[x-2]]} diff --git a/Task/Fibonacci-sequence/K/fibonacci-sequence-2.k b/Task/Fibonacci-sequence/K/fibonacci-sequence-2.k new file mode 100644 index 0000000000..31a7786133 --- /dev/null +++ b/Task/Fibonacci-sequence/K/fibonacci-sequence-2.k @@ -0,0 +1 @@ +{c::.();{v:c[a:`$$x];:[x<3;1;:[_n~v;c[a]:_f[x-1]+_f[x-2];v]]}x} diff --git a/Task/Fibonacci-sequence/K/fibonacci-sequence-3.k b/Task/Fibonacci-sequence/K/fibonacci-sequence-3.k new file mode 100644 index 0000000000..040f5abb39 --- /dev/null +++ b/Task/Fibonacci-sequence/K/fibonacci-sequence-3.k @@ -0,0 +1,2 @@ +phi:(1+_sqrt(5))%2 +{_((phi^x)-((1-phi)^x))%_sqrt[5]} diff --git a/Task/Fibonacci-sequence/K/fibonacci-sequence-4.k b/Task/Fibonacci-sequence/K/fibonacci-sequence-4.k new file mode 100644 index 0000000000..887f45dd2d --- /dev/null +++ b/Task/Fibonacci-sequence/K/fibonacci-sequence-4.k @@ -0,0 +1 @@ +{(x(|+\)\1 1)[;1]} diff --git a/Task/Fibonacci-sequence/K/fibonacci-sequence-5.k b/Task/Fibonacci-sequence/K/fibonacci-sequence-5.k new file mode 100644 index 0000000000..21427592a4 --- /dev/null +++ b/Task/Fibonacci-sequence/K/fibonacci-sequence-5.k @@ -0,0 +1 @@ +{x{x,+/-2#x}/!2} diff --git a/Task/Fibonacci-sequence/LSL/fibonacci-sequence.lsl b/Task/Fibonacci-sequence/LSL/fibonacci-sequence.lsl new file mode 100644 index 0000000000..3b96c6b595 --- /dev/null +++ b/Task/Fibonacci-sequence/LSL/fibonacci-sequence.lsl @@ -0,0 +1,15 @@ +integer Fibonacci(integer n) { + if(n<2) { + return n; + } else { + return Fibonacci(n-1)+Fibonacci(n-2); + } +} +default { + state_entry() { + integer x = 0; + for(x=0 ; x<35 ; x++) { + llOwnerSay("Fibonacci("+(string)x+")="+(string)Fibonacci(x)); + } + } +} diff --git a/Task/Fibonacci-sequence/Lang5/fibonacci-sequence.lang5 b/Task/Fibonacci-sequence/Lang5/fibonacci-sequence.lang5 new file mode 100644 index 0000000000..75788590d1 --- /dev/null +++ b/Task/Fibonacci-sequence/Lang5/fibonacci-sequence.lang5 @@ -0,0 +1,7 @@ +[] '__A set : dip swap __A swap 2 compress collapse '__A set execute + __A -1 extract nip ; : nip swap drop ; : tuck swap over ; +: -rot rot rot ; : 0= 0 == ; : 1+ 1 + ; : 1- 1 - ; : sum '+ reduce ; +: bi 'keep dip execute ; : keep over 'execute dip ; + +: fib dup 1 > if dup 1- fib swap 2 - fib + then ; +: fib dup 1 > if "1- fib" "2 - fib" bi + then ; diff --git a/Task/Fibonacci-sequence/Liberty-BASIC/fibonacci-sequence.liberty b/Task/Fibonacci-sequence/Liberty-BASIC/fibonacci-sequence.liberty new file mode 100644 index 0000000000..09d4477b46 --- /dev/null +++ b/Task/Fibonacci-sequence/Liberty-BASIC/fibonacci-sequence.liberty @@ -0,0 +1,22 @@ +for i = 0 to 15 + print fiboR(i),fiboI(i) +next i + +function fiboR(n) + if n <= 1 then + fiboR = n + else + fiboR = fiboR(n-1) + fiboR(n-2) + end if +end function + +function fiboI(n) + a = 0 + b = 1 + for i = 1 to n + temp = a + b + a = b + b = temp + next i + fiboI = a +end function diff --git a/Task/Fibonacci-sequence/Lisaac/fibonacci-sequence.lisaac b/Task/Fibonacci-sequence/Lisaac/fibonacci-sequence.lisaac new file mode 100644 index 0000000000..34e2a8994f --- /dev/null +++ b/Task/Fibonacci-sequence/Lisaac/fibonacci-sequence.lisaac @@ -0,0 +1,9 @@ +- fib(n : UINTEGER_32) : UINTEGER_64 <- ( + + result : UINTEGER_64; + (n < 2).if { + result := n; + } else { + result := fib(n - 1) + fib(n - 2); + }; + result +); diff --git a/Task/Fibonacci-sequence/Logo/fibonacci-sequence.logo b/Task/Fibonacci-sequence/Logo/fibonacci-sequence.logo new file mode 100644 index 0000000000..2eee939db8 --- /dev/null +++ b/Task/Fibonacci-sequence/Logo/fibonacci-sequence.logo @@ -0,0 +1,4 @@ +to fib :n [:a 0] [:b 1] + if :n < 1 [output :a] + output (fib :n-1 :b :a+:b) +end diff --git a/Task/Fibonacci-sequence/Lua/fibonacci-sequence.lua b/Task/Fibonacci-sequence/Lua/fibonacci-sequence.lua new file mode 100644 index 0000000000..14e7974c8b --- /dev/null +++ b/Task/Fibonacci-sequence/Lua/fibonacci-sequence.lua @@ -0,0 +1,20 @@ +--calculates the nth fibonacci number. Breaks for negative or non-integer n. +function fibs(n) + return n < 2 and n or fibs(n - 1) + fibs(n - 2) +end + +--more pedantic version, returns 0 for non-integer n +function pfibs(n) + if n ~= math.floor(n) then return 0 + elseif n < 0 then return pfibs(n + 2) - pfibs(n + 1) + elseif n < 2 then return n + else return pfibs(n - 1) + pfibs(n - 2) + end +end + +--tail-recursive +function a(n,u,s) if n<2 then return u+s end return a(n-1,u+s,u) end +function trfib(i) return a(i,1,0) end + +--table-recursive +fib_n = setmetatable({1, 1}, {__index = function(z,n) return z[n-1] + z[n-2] end}) diff --git a/Task/Fibonacci-sequence/M4/fibonacci-sequence.m4 b/Task/Fibonacci-sequence/M4/fibonacci-sequence.m4 new file mode 100644 index 0000000000..4f8533219d --- /dev/null +++ b/Task/Fibonacci-sequence/M4/fibonacci-sequence.m4 @@ -0,0 +1,4 @@ +define(`fibo',`ifelse(0,$1,0,`ifelse(1,$1,1, +`eval(fibo(decr($1)) + fibo(decr(decr($1))))')')')dnl +define(`loop',`ifelse($1,$2,,`$3($1) loop(incr($1),$2,`$3')')')dnl +loop(0,15,`fibo') diff --git a/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-1.m b/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-1.m new file mode 100644 index 0000000000..a40d5e5cb7 --- /dev/null +++ b/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-1.m @@ -0,0 +1,16 @@ +function F = fibonacci(n) + + Fn = [1 0]; %Fn(1) is F_{n-2}, Fn(2) is F_{n-1} + F = 0; %F is F_{n} + + for i = (1:abs(n)) + Fn(2) = F; + F = sum(Fn); + Fn(1) = Fn(2); + end + + if n < 0 + F = F*((-1)^(n+1)); + end + +end diff --git a/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-2.m b/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-2.m new file mode 100644 index 0000000000..d9e46fb81d --- /dev/null +++ b/Task/Fibonacci-sequence/MATLAB/fibonacci-sequence-2.m @@ -0,0 +1,13 @@ +function number = fibonacci2(n) + + if n == 1 + number = 1; + elseif n == 0 + number = 0; + elseif n < 0 + number = ((-1)^(n+1))*fibonacci2(-n);; + else + number = det(gallery('dramadah',n,3)); + end + +end diff --git a/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-1.max b/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-1.max new file mode 100644 index 0000000000..5ded034cb8 --- /dev/null +++ b/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-1.max @@ -0,0 +1,19 @@ +fn fibIter n = +( + if n < 2 then + ( + n + ) + else + ( + fib = 1 + fibPrev = 1 + for num in 3 to n do + ( + temp = fib + fib += fibPrev + fibPrev = temp + ) + fib + ) +) diff --git a/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-2.max b/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-2.max new file mode 100644 index 0000000000..f726fa7546 --- /dev/null +++ b/Task/Fibonacci-sequence/MAXScript/fibonacci-sequence-2.max @@ -0,0 +1,11 @@ +fn fibRec n = +( + if n < 2 then + ( + n + ) + else + ( + fibRec (n - 1) + fibRec (n - 2) + ) +) diff --git a/Task/Fibonacci-sequence/ML-I/fibonacci-sequence.ml b/Task/Fibonacci-sequence/ML-I/fibonacci-sequence.ml new file mode 100644 index 0000000000..81415b30c7 --- /dev/null +++ b/Task/Fibonacci-sequence/ML-I/fibonacci-sequence.ml @@ -0,0 +1,15 @@ +MCSKIP "WITH" NL +"" Fibonacci - recursive +MCSKIP MT,<> +MCINS %. +MCDEF FIB WITHS () +AS MCGO L0 +%L1.%FIB(%T1.-1)+FIB(%T1.-2).> +fib(0) is FIB(0) +fib(1) is FIB(1) +fib(2) is FIB(2) +fib(3) is FIB(3) +fib(4) is FIB(4) +fib(5) is FIB(5) diff --git a/Task/Fibonacci-sequence/MUMPS/fibonacci-sequence.mumps b/Task/Fibonacci-sequence/MUMPS/fibonacci-sequence.mumps new file mode 100644 index 0000000000..3c99a1791b --- /dev/null +++ b/Task/Fibonacci-sequence/MUMPS/fibonacci-sequence.mumps @@ -0,0 +1,11 @@ +FIBOITER(N) + ;Iterative version to get the Nth Fibonacci number + ;N must be a positive integer + ;F is the tree containing the values + ;I is a loop variable. + QUIT:(N\1'=N)!(N<0) "Error: "_N_" is not a positive integer." + NEW F,I + SET F(0)=0,F(1)=1 + QUIT:N<2 F(N) + FOR I=2:1:N SET F(I)=F(I-1)+F(I-2) + QUIT F(N) diff --git a/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-1.mathematica b/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-1.mathematica new file mode 100644 index 0000000000..aabeed704c --- /dev/null +++ b/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-1.mathematica @@ -0,0 +1,3 @@ +fib[0] = 0 +fib[1] = 1 +fib[n_Integer] := fib[n - 1] + fib[n - 2] diff --git a/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-2.mathematica b/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-2.mathematica new file mode 100644 index 0000000000..e37e3af0a6 --- /dev/null +++ b/Task/Fibonacci-sequence/Mathematica/fibonacci-sequence-2.mathematica @@ -0,0 +1,3 @@ +fib[0] = 0 +fib[1] = 1 +fib[n_Integer] := fib[n] = fib[n - 1] + fib[n - 2] diff --git a/Task/Fibonacci-sequence/Maxima/fibonacci-sequence.maxima b/Task/Fibonacci-sequence/Maxima/fibonacci-sequence.maxima new file mode 100644 index 0000000000..35e34cb42c --- /dev/null +++ b/Task/Fibonacci-sequence/Maxima/fibonacci-sequence.maxima @@ -0,0 +1,8 @@ +/* fib(n) is built-in; here is an implementation */ +fib2(n) := (matrix([0, 1], [1, 1])^^n)[1, 2]$ + +fib2(100)-fib(100); +0 + +fib2(-10); +-55 diff --git a/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-1.mercury b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-1.mercury new file mode 100644 index 0000000000..5e307bff1a --- /dev/null +++ b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-1.mercury @@ -0,0 +1,29 @@ +% The following code is derived from the Mercury Tutorial by Ralph Becket. +% http://www.mercury.csse.unimelb.edu.au/information/papers/book.pdf +:- module fib. + +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int. + +:- pred fib(int::in, int::out) is det. +fib(N, X) :- + ( if N =< 2 + then X = 1 + else fib(N - 1, A), fib(N - 2, B), X = A + B ). + +:- func fib(int) = int is det. +fib(N) = X :- fib(N, X). + +main(!IO) :- + fib(40, X), + write_string("fib(40, ", !IO), + write_int(X, !IO), + write_string(")\n", !IO), + + write_string("fib(40) = ", !IO), + write_int(fib(40), !IO), + write_string("\n", !IO). diff --git a/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-2.mercury b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-2.mercury new file mode 100644 index 0000000000..d648f33d78 --- /dev/null +++ b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-2.mercury @@ -0,0 +1,15 @@ +:- pred fib_acc(int::in, int::in, int::in, int::in, int::out) is det. + +fib_acc(N, Limit, Prev2, Prev1, Res) :- + ( N < Limit -> + % limit not reached, continue computation. + ( N =< 2 -> + Res0 = 1 + ; + Res0 = Prev2 + Prev1 + ), + fib_acc(N+1, Limit, Prev1, Res0, Res) + ; + % Limit reached, return the sum of the two previous results. + Res = Prev2 + Prev1 + ). diff --git a/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-3.mercury b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-3.mercury new file mode 100644 index 0000000000..75e0679abe --- /dev/null +++ b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-3.mercury @@ -0,0 +1 @@ +fib_acc(1, 40, 1, 1, Result) diff --git a/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-4.mercury b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-4.mercury new file mode 100644 index 0000000000..79c0ae9d14 --- /dev/null +++ b/Task/Fibonacci-sequence/Mercury/fibonacci-sequence-4.mercury @@ -0,0 +1,6 @@ +:- pragma memo(fib/2). +:- pred fib(int::in, int::out) is det. +fib(N, X) :- + ( if N =< 2 + then X = 1 + else fib(N - 1, A), fib(N - 2, B), X = A + B ). diff --git a/Task/Fibonacci-sequence/Metafont/fibonacci-sequence.metafont b/Task/Fibonacci-sequence/Metafont/fibonacci-sequence.metafont new file mode 100644 index 0000000000..8246d0f337 --- /dev/null +++ b/Task/Fibonacci-sequence/Metafont/fibonacci-sequence.metafont @@ -0,0 +1,10 @@ +vardef fibo(expr n) = +if n=0: 0 +elseif n=1: 1 +else: + fibo(n-1) + fibo(n-2) +fi +enddef; + +for i=0 upto 10: show fibo(i); endfor +end diff --git a/Task/Fibonacci-sequence/Mirah/fibonacci-sequence.mirah b/Task/Fibonacci-sequence/Mirah/fibonacci-sequence.mirah new file mode 100644 index 0000000000..0ddaa99cee --- /dev/null +++ b/Task/Fibonacci-sequence/Mirah/fibonacci-sequence.mirah @@ -0,0 +1,19 @@ +def fibonacci(n:int) + return n if n < 2 + fibPrev = 1 + fib = 1 + 3.upto(Math.abs(n)) do + oldFib = fib + fib = fib + fibPrev + fibPrev = oldFib + end + fib * (n<0 ? int(Math.pow(n+1, -1)) : 1) +end + +puts fibonacci 1 +puts fibonacci 2 +puts fibonacci 3 +puts fibonacci 4 +puts fibonacci 5 +puts fibonacci 6 +puts fibonacci 7 diff --git a/Task/Fibonacci-sequence/Modula-3/fibonacci-sequence.mod3 b/Task/Fibonacci-sequence/Modula-3/fibonacci-sequence.mod3 new file mode 100644 index 0000000000..08c716fe22 --- /dev/null +++ b/Task/Fibonacci-sequence/Modula-3/fibonacci-sequence.mod3 @@ -0,0 +1,8 @@ +PROCEDURE Fib(n: INTEGER): INTEGER = + BEGIN + IF n < 2 THEN + RETURN n; + ELSE + RETURN Fib(n-1) + Fib(n-2); + END; + END Fib; diff --git a/Task/Fibonacci-sequence/PHP/fibonacci-sequence-1.php b/Task/Fibonacci-sequence/PHP/fibonacci-sequence-1.php new file mode 100644 index 0000000000..932b859b7f --- /dev/null +++ b/Task/Fibonacci-sequence/PHP/fibonacci-sequence-1.php @@ -0,0 +1,11 @@ +function fibIter($n) { + if ($n < 2) { + return $n; + } + $fibPrev = 0; + $fib = 1; + foreach (range(1, $n-1) as $i) { + list($fibPrev, $fib) = array($fib, $fib + $fibPrev); + } + return $fib; +} diff --git a/Task/Fibonacci-sequence/PHP/fibonacci-sequence-2.php b/Task/Fibonacci-sequence/PHP/fibonacci-sequence-2.php new file mode 100644 index 0000000000..225f05d2e0 --- /dev/null +++ b/Task/Fibonacci-sequence/PHP/fibonacci-sequence-2.php @@ -0,0 +1,3 @@ +function fibRec($n) { + return $n < 2 ? $n : fibRec($n-1) + fibRec($n-2); +} diff --git a/Task/Fibonacci-sequence/PIR/fibonacci-sequence-1.pir b/Task/Fibonacci-sequence/PIR/fibonacci-sequence-1.pir new file mode 100644 index 0000000000..4bee537547 --- /dev/null +++ b/Task/Fibonacci-sequence/PIR/fibonacci-sequence-1.pir @@ -0,0 +1,30 @@ +.sub fib + .param int n + .local int nt + .local int ft + if n < 2 goto RETURNN + nt = n - 1 + ft = fib( nt ) + dec nt + nt = fib(nt) + ft = ft + nt + .return( ft ) +RETURNN: + .return( n ) + end +.end + +.sub main :main + .local int counter + .local int f + counter=0 +LOOP: + if counter > 20 goto DONE + f = fib(counter) + print f + print "\n" + inc counter + goto LOOP +DONE: + end +.end diff --git a/Task/Fibonacci-sequence/PIR/fibonacci-sequence-2.pir b/Task/Fibonacci-sequence/PIR/fibonacci-sequence-2.pir new file mode 100644 index 0000000000..d3f0d9cfcf --- /dev/null +++ b/Task/Fibonacci-sequence/PIR/fibonacci-sequence-2.pir @@ -0,0 +1,50 @@ +.sub fib + .param int n + .local int counter + .local int f + .local pmc fibs + .local int nmo + .local int nmt + + fibs = new 'ResizableIntegerArray' + if n == 0 goto RETURN0 + if n == 1 goto RETURN1 + push fibs, 0 + push fibs, 1 + counter = 2 +FIBLOOP: + if counter > n goto DONE + nmo = pop fibs + nmt = pop fibs + f = nmo + nmt + push fibs, nmt + push fibs, nmo + push fibs, f + inc counter + goto FIBLOOP +RETURN0: + .return( 0 ) + end +RETURN1: + .return( 1 ) + end +DONE: + f = pop fibs + .return( f ) + end +.end + +.sub main :main + .local int counter + .local int f + counter=0 +LOOP: + if counter > 20 goto DONE + f = fib(counter) + print f + print "\n" + inc counter + goto LOOP +DONE: + end +.end diff --git a/Task/Fibonacci-sequence/Perl/fibonacci-sequence-1.pl b/Task/Fibonacci-sequence/Perl/fibonacci-sequence-1.pl new file mode 100644 index 0000000000..fcfe4901f9 --- /dev/null +++ b/Task/Fibonacci-sequence/Perl/fibonacci-sequence-1.pl @@ -0,0 +1,9 @@ +sub fibIter { + my $n = shift; + return $n if $n < 2; + + my $fibPrev = 1; + my $fib = 1; + ($fibPrev, $fib) = ($fib, $fib + $fibPrev) for 2..$n-1; + $fib; +} diff --git a/Task/Fibonacci-sequence/Perl/fibonacci-sequence-2.pl b/Task/Fibonacci-sequence/Perl/fibonacci-sequence-2.pl new file mode 100644 index 0000000000..42d5bb3a34 --- /dev/null +++ b/Task/Fibonacci-sequence/Perl/fibonacci-sequence-2.pl @@ -0,0 +1,4 @@ +sub fibRec { + my $n = shift; + $n < 2 ? $n : fibRec($n - 1) + fibRec($n - 2); +} diff --git a/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-1.l b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-1.l new file mode 100644 index 0000000000..8456c5b189 --- /dev/null +++ b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-1.l @@ -0,0 +1,4 @@ +(de fibo (N) + (if (>= 2 N) + 1 + (+ (fibo (dec N)) (fibo (- N 2))) ) ) diff --git a/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-2.l b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-2.l new file mode 100644 index 0000000000..6474309a65 --- /dev/null +++ b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-2.l @@ -0,0 +1,7 @@ +(de fibo (N) + (cache '(NIL) (pack (char (hash N)) N) # Use a cache to accelerate + (if (>= 2 N) + N + (+ (fibo (dec N)) (fibo (- N 2))) ) ) ) + +(bench (fibo 1000)) diff --git a/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-3.l b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-3.l new file mode 100644 index 0000000000..499b737f9f --- /dev/null +++ b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-3.l @@ -0,0 +1,4 @@ +0.012 sec +-> 43466557686937456435688527675040625802564660517371780402481729089536555417949 +05189040387984007925516929592259308032263477520968962323987332247116164299644090 +6533187938298969649928516003704476137795166849228875 diff --git a/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-4.l b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-4.l new file mode 100644 index 0000000000..2eff7c24f2 --- /dev/null +++ b/Task/Fibonacci-sequence/PicoLisp/fibonacci-sequence-4.l @@ -0,0 +1,7 @@ +(de fibo (N) + (let (I 1 J 0) + (do N + (let (Tmp J) + (inc 'J I) + (setq I Tmp) ) ) + J) ) diff --git a/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-1.pro b/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-1.pro new file mode 100644 index 0000000000..afafb6f2d4 --- /dev/null +++ b/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-1.pro @@ -0,0 +1,3 @@ +fib(0, 0):-!. +fib(1, 1):-!. +fib(N, X):-N1 is N-1, N2 is N-2, fib(N1, X1), fib(N2, X2), X is X1+X2. diff --git a/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-2.pro b/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-2.pro new file mode 100644 index 0000000000..a7075b9d2e --- /dev/null +++ b/Task/Fibonacci-sequence/Prolog/fibonacci-sequence-2.pro @@ -0,0 +1,13 @@ +:- use_module(lambda). +fib(N, FN) :- + cont_fib(N, _, FN, \_^Y^_^U^(U = Y)). + +cont_fib(N, FN1, FN, Pred) :- + ( N < 2 -> + call(Pred, 0, 1, FN1, FN) + ; + N1 is N - 1, + P = \X^Y^Y^U^(U is X + Y), + cont_fib(N1, FNA, FNB, P), + call(Pred, FNA, FNB, FN1, FN) + ). diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-1.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-1.py new file mode 100644 index 0000000000..e4b44a5611 --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-1.py @@ -0,0 +1,10 @@ +from math import * + +def analytic_fibonacci(n): + sqrt_5 = sqrt(5); + p = (1 + sqrt_5) / 2; + q = 1/p; + return int( (p**n + q**n) / sqrt_5 + 0.5 ) + +for i in range(1,31): + print analytic_fibonacci(i), diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-2.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-2.py new file mode 100644 index 0000000000..caaddca26a --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-2.py @@ -0,0 +1,8 @@ +def fibIter(n): + if n < 2: + return n + fibPrev = 1 + fib = 1 + for num in xrange(2, n): + fibPrev, fib = fib, fib + fibPrev + return fib diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-3.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-3.py new file mode 100644 index 0000000000..2ba85f32be --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-3.py @@ -0,0 +1,5 @@ +def fibRec(n): + if n < 2: + return n + else: + return fibRec(n-1) + fibRec(n-2) diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-4.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-4.py new file mode 100644 index 0000000000..9dc4a0b376 --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-4.py @@ -0,0 +1,11 @@ +def fibMemo(): + pad = {0:0, 1:1} + def func(n): + if n not in pad: + pad[n] = func(n-1) + func(n-2) + return pad[n] + return func + +fm = fibMemo() +for i in range(1,31): + print fm(i), diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-5.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-5.py new file mode 100644 index 0000000000..cd9d70dde3 --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-5.py @@ -0,0 +1,5 @@ +def fibGen(): + f0, f1 = 0, 1 + while True: + yield f0 + f0, f1 = f1, f0+f1 diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-6.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-6.py new file mode 100644 index 0000000000..88ef366fa7 --- /dev/null +++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-6.py @@ -0,0 +1,14 @@ +>>> fg = fibGen() +>>> for x in range(9): + print fg.next() + +0 +1 +1 +2 +3 +5 +8 +13 +21 +>>> diff --git a/Task/Fibonacci-sequence/R/fibonacci-sequence.r b/Task/Fibonacci-sequence/R/fibonacci-sequence.r new file mode 100644 index 0000000000..b08b7416f0 --- /dev/null +++ b/Task/Fibonacci-sequence/R/fibonacci-sequence.r @@ -0,0 +1,39 @@ +# recursive +recfibo <- function(n) { + if ( n < 2 ) n + else Recall(n-1) + Recall(n-2) +} + +# print the first 21 elements +print.table(lapply(0:20, recfibo)) + +# iterative +iterfibo <- function(n) { + if ( n < 2 ) + n + else { + f <- c(0, 1) + for (i in 2:n) { + t <- f[2] + f[2] <- sum(f) + f[1] <- t + } + f[2] + } +} + +print.table(lapply(0:20, iterfibo)) + +# iterative but looping replaced by map-reduce'ing +funcfibo <- function(n) { + if (n < 2) + n + else { + generator <- function(f, ...) { + c(f[2], sum(f)) + } + Reduce(generator, 2:n, c(0,1))[2] + } +} + +print.table(lapply(0:20, funcfibo)) diff --git a/Task/Fibonacci-sequence/REXX/fibonacci-sequence.rexx b/Task/Fibonacci-sequence/REXX/fibonacci-sequence.rexx new file mode 100644 index 0000000000..d5762e28d2 --- /dev/null +++ b/Task/Fibonacci-sequence/REXX/fibonacci-sequence.rexx @@ -0,0 +1,23 @@ +/*REXX program calculates the Nth Fibonacci number, N can be zero or neg*/ +numeric digits 210000 /*prepare for some big 'uns. */ +parse arg x y . /*allow a single number or range.*/ +if x=='' then do; x=-40; y=abs(x); end /*No input? Use range -40 ──► +40*/ +if y=='' then y=x /*if only one number, show fib(n)*/ +w=max(length(x),length(y)) /*used for making output pretty. */ +fw=10 /*minmum maximum width. Ka-razy*/ + do j=x to y; q=fib(j) /*process each Fibonacci request.*/ + fw=max(fw,length(q)) /*fib# length or the max so far. */ + say 'Fibonacci('right(j,w)") = " right(q,fw) /*right justify Q.*/ + if length(q)>10 then say 'Fibonacci('right(j,w)") has a length of" l + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────FIB subroutine (non-recursive)───*/ +fib: procedure; parse arg n; na=abs(n); a=0; b=1 +if na<2 then return na /*handle couple of special cases.*/ + + do k=2 to na; s=a+b /*sum the numbers up to │n│ */ + parse value b s with a b /*faster version of: a=b; s=b */ + end /*k*/ + +if n>0 | na//2==1 then return s /*if positive or odd negative ...*/ + return -s /* return a negative Fib number.*/ diff --git a/Task/Fibonacci-sequence/Racket/fibonacci-sequence.rkt b/Task/Fibonacci-sequence/Racket/fibonacci-sequence.rkt new file mode 100644 index 0000000000..804059a2da --- /dev/null +++ b/Task/Fibonacci-sequence/Racket/fibonacci-sequence.rkt @@ -0,0 +1,6 @@ +(define (fibo number) + (define (fibo-rec number n i) + (if (<= number 0) + i + (fibo-rec (- number 1) (+ n i) n))) + (fibo-rec number 1 0)) diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-1.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-1.rb new file mode 100644 index 0000000000..6bec0b623d --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-1.rb @@ -0,0 +1,6 @@ +def fibIter(n) + return 0 if n == 0 + fibPrev, fib = 1, 1 + (n.abs - 2).times { fibPrev, fib = fib, fib + fibPrev } + fib * (n<0 ? (-1)**(n+1) : 1) +end diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-2.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-2.rb new file mode 100644 index 0000000000..355da2190a --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-2.rb @@ -0,0 +1,9 @@ +def fibRec(n) + if n <= -2 + (-1)**(n+1) * fibRec(n.abs) + elsif n <= 1 + n.abs + else + fibRec(n-1) + fibRec(n-2) + end +end diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-3.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-3.rb new file mode 100644 index 0000000000..13582e37d4 --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-3.rb @@ -0,0 +1,13 @@ +# Use the Hash#default_proc feature to +# lazily calculate the Fibonacci numbers. + +fib = Hash.new do |f, n| + f[n] = if n <= -2 + (-1)**(n+1) * f[n.abs] + elsif n <= 1 + n.abs + else + f[n-1] + f[n-2] + end +end +# examples: fib[10] => 55, fib[-10] => (-55/1) diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-4.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-4.rb new file mode 100644 index 0000000000..1e66c6b641 --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-4.rb @@ -0,0 +1,36 @@ +require 'matrix' + +# To understand why this matrix is useful for Fibonacci numbers, remember +# that the definition of Matrix.**2 for any Matrix[[a, b], [c, d]] is +# is [[a*a + b*c, a*b + b*d], [c*a + d*b, c*b + d*d]]. In other words, the +# lower right element is computing F(k - 2) + F(k - 1) every time M is multiplied +# by itself (it is perhaps easier to understand this by computing M**2, 3, etc, and +# watching the result march up the sequence of Fibonacci numbers). + +M = Matrix[[0, 1], [1,1]] + +# Matrix exponentiation algorithm to compute Fibonacci numbers. +# Let M be Matrix [[0, 1], [1, 1]]. Then, the lower right element of M**k is +# F(k + 1). In other words, the lower right element of M is F(2) which is 1, and the +# lower right element of M**2 is F(3) which is 2, and the lower right element +# of M**3 is F(4) which is 3, etc. +# +# This is a good way to compute F(n) because the Ruby implementation of Matrix.**(n) +# uses O(log n) rather than O(n) matrix multiplications. It works by squaring squares +# ((m**2)**2)... as far as possible +# and then multiplying that by by M**(the remaining number of times). E.g., to compute +# M**19, compute partial = ((M**2)**2) = M**16, and then compute partial*(M**3) = M**19. +# That's only 5 matrix multiplications of M to compute M*19. +def self.fibMatrix(n) + return 0 if n <= 0 # F(0) + return 1 if n == 1 # F(1) + # To get F(n >= 2), compute M**(n - 1) and extract the lower right element. + return CS::lower_right(M**(n - 1)) +end + +# Matrix utility to return +# the lower, right-hand element of a given matrix. +def self.lower_right matrix + return nil if matrix.row_size == 0 + return matrix[matrix.row_size - 1, matrix.column_size - 1] +end diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-5.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-5.rb new file mode 100644 index 0000000000..497a79fe5c --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-5.rb @@ -0,0 +1,11 @@ +require 'generator' + +def fibGen + Generator.new do |g| + f0, f1 = 0, 1 + loop do + g.yield f0 + f0, f1 = f1, f0+f1 + end + end +end diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-6.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-6.rb new file mode 100644 index 0000000000..5898221774 --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-6.rb @@ -0,0 +1,8 @@ +fib = Fiber.new do + a,b = 0,1 + loop do + Fiber.yield a + a,b = b,a+b + end +end +9.times {puts fib.resume} diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-7.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-7.rb new file mode 100644 index 0000000000..b138e466fd --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-7.rb @@ -0,0 +1,4 @@ +def fib_gen + a, b = 1, 1 + lambda {ret, a, b = a, b, a+b; ret} +end diff --git a/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-8.rb b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-8.rb new file mode 100644 index 0000000000..73023d3766 --- /dev/null +++ b/Task/Fibonacci-sequence/Ruby/fibonacci-sequence-8.rb @@ -0,0 +1,4 @@ +def fib + phi = (1 + Math.sqrt(5)) / 2 + ((phi**self - (-1 / phi)**self) / Math.sqrt(5)).to_i +end diff --git a/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-1.snusp b/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-1.snusp new file mode 100644 index 0000000000..7088448fac --- /dev/null +++ b/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-1.snusp @@ -0,0 +1,4 @@ + @!\+++++++++# /<<+>+>-\ +fib\==>>+<!\ ?/\ + #</@>\?-<</@>/>+<-\ + \-/ \ !\ !\ !\ ?/# diff --git a/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-2.snusp b/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-2.snusp new file mode 100644 index 0000000000..0f30582a85 --- /dev/null +++ b/Task/Fibonacci-sequence/SNUSP/fibonacci-sequence-2.snusp @@ -0,0 +1,4 @@ + /========\ />>+<<-\ />+<-\ +fib==!/?!\-?!\->+>+<>-@\=====?/<@\===?/<# + | #+==/ fib(n-2)|+fib(n-1)| + \=====recursion======/!========/ diff --git a/Task/Fibonacci-sequence/Sather/fibonacci-sequence.sa b/Task/Fibonacci-sequence/Sather/fibonacci-sequence.sa new file mode 100644 index 0000000000..fc7d3b220d --- /dev/null +++ b/Task/Fibonacci-sequence/Sather/fibonacci-sequence.sa @@ -0,0 +1,34 @@ +class MAIN is + + -- RECURSIVE -- + fibo(n :INTI):INTI + pre n >= 0 + is + if n < 2.inti then return n; end; + return fibo(n - 2.inti) + fibo(n - 1.inti); + end; + + -- ITERATIVE -- + fibo_iter(n :INTI):INTI + pre n >= 0 + is + n3w :INTI; + + if n < 2.inti then return n; end; + last ::= 0.inti; this ::= 1.inti; + loop (n - 1.inti).times!; + n3w := last + this; + last := this; + this := n3w; + end; + return this; + end; + + main is + loop i ::= 0.upto!(16); + #OUT + fibo(i.inti) + " "; + #OUT + fibo_iter(i.inti) + "\n"; + end; + end; + +end; diff --git a/Task/Fibonacci-sequence/Scala/fibonacci-sequence-1.scala b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-1.scala new file mode 100644 index 0000000000..f12e639ffe --- /dev/null +++ b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-1.scala @@ -0,0 +1,5 @@ +def fib(i:Int):Int = i match{ + case 0 => 0 + case 1 => 1 + case _ => fib(i-1) + fib(i-2) +} diff --git a/Task/Fibonacci-sequence/Scala/fibonacci-sequence-2.scala b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-2.scala new file mode 100644 index 0000000000..2f1e32bd9b --- /dev/null +++ b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-2.scala @@ -0,0 +1,9 @@ +//syntactic sugar for Stream.cons, this is unnecessary but makes the definition prettier +//Stream.cons(head,stream) becomes head::stream +//I think 2.8 will have #:: +class PrettyStream[A](str: =>Stream[A]) { + def ::(hd: A) = Stream.cons(hd, str) +} +implicit def streamToPrettyStream[A](str: =>Stream[A]) = new PrettyStream(str) + +def fib: Stream[Int] = 0 :: 1 :: fib.zip(fib.tail).map{case (a,b) => a + b} diff --git a/Task/Fibonacci-sequence/Scala/fibonacci-sequence-3.scala b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-3.scala new file mode 100644 index 0000000000..9980920fe8 --- /dev/null +++ b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-3.scala @@ -0,0 +1 @@ +def fib: Stream[Int] = 0 #:: 1 #:: fib.zip(fib.tail).map{case (a,b) => a + b} diff --git a/Task/Fibonacci-sequence/Scala/fibonacci-sequence-4.scala b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-4.scala new file mode 100644 index 0000000000..74eb11bfd9 --- /dev/null +++ b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-4.scala @@ -0,0 +1,7 @@ +def fib(i:Int):Int = { + def fib2(i:Int, a:Int, b:Int):Int = i match{ + case 1 => b + case _ => fib2(i-1, b, a+b) + } + fib2(i,1,0) +} diff --git a/Task/Fibonacci-sequence/Scala/fibonacci-sequence-5.scala b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-5.scala new file mode 100644 index 0000000000..1dab8f56f0 --- /dev/null +++ b/Task/Fibonacci-sequence/Scala/fibonacci-sequence-5.scala @@ -0,0 +1,13 @@ +// Fibonacci using BigInt with Stream.foldLeft optimized for GC (Scala v2.9 and above) +// Does not run out of memory for very large Fibonacci numbers +def fib(n:Int) = { + + def series(i:BigInt,j:BigInt):Stream[BigInt] = i #:: series(j, i+j) + + series(1,0).take(n).foldLeft(BigInt("0"))(_+_) +} + +// Small test +(0 to 13) foreach {n => print(fib(n).toString + " ")} + +// result: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 diff --git a/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-1.ss b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-1.ss new file mode 100644 index 0000000000..c9ef09d822 --- /dev/null +++ b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-1.ss @@ -0,0 +1,5 @@ +(define (fib-iter n) + (do ((num 2 (+ num 1)) + (fib-prev 1 fib) + (fib 1 (+ fib fib-prev))) + ((>= num n) fib))) diff --git a/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-2.ss b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-2.ss new file mode 100644 index 0000000000..dea57097d2 --- /dev/null +++ b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-2.ss @@ -0,0 +1,5 @@ +(define (fib-rec n) + (if (< n 2) + n + (+ (fib-rec (- n 1)) + (fib-rec (- n 2))))) diff --git a/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-3.ss b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-3.ss new file mode 100644 index 0000000000..35c0455914 --- /dev/null +++ b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-3.ss @@ -0,0 +1,4 @@ +(define (fib n) + (let loop ((a 0) (b 1) (n n)) + (if (= n 0) a + (loop b (+ a b) (- n 1))))) diff --git a/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-4.ss b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-4.ss new file mode 100644 index 0000000000..64c6335cfc --- /dev/null +++ b/Task/Fibonacci-sequence/Scheme/fibonacci-sequence-4.ss @@ -0,0 +1,19 @@ +;;; Fibonacci numbers using Edsger Dijkstra's algorithm +;;; http://www.cs.utexas.edu/users/EWD/ewd06xx/EWD654.PDF + +(define (fib n) + (define (fib-aux a b p q count) + (cond ((= count 0) b) + ((even? count) + (fib-aux a + b + (+ (* p p) (* q q)) + (+ (* q q) (* 2 p q)) + (/ count 2))) + (else + (fib-aux (+ (* b q) (* a q) (* a p)) + (+ (* b p) (* a q)) + p + q + (- count 1))))) + (fib-aux 1 0 0 1 n)) diff --git a/Task/Fibonacci-sequence/Smalltalk/fibonacci-sequence.st b/Task/Fibonacci-sequence/Smalltalk/fibonacci-sequence.st new file mode 100644 index 0000000000..073c25326d --- /dev/null +++ b/Task/Fibonacci-sequence/Smalltalk/fibonacci-sequence.st @@ -0,0 +1,20 @@ +|fibo| +fibo := [ :i | + |ac t| + ac := Array new: 2. + ac at: 1 put: 0 ; at: 2 put: 1. + ( i < 2 ) + ifTrue: [ ac at: (i+1) ] + ifFalse: [ + 2 to: i do: [ :l | + t := (ac at: 2). + ac at: 2 put: ( (ac at: 1) + (ac at: 2) ). + ac at: 1 put: t + ]. + ac at: 2. + ] +]. + +0 to: 10 do: [ :i | + (fibo value: i) displayNl +] diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-1.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-1.tcl new file mode 100644 index 0000000000..a140700b28 --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-1.tcl @@ -0,0 +1,9 @@ +proc fibiter n { + if {$n < 2} {return $n} + set prev 1 + set fib 1 + for {set i 2} {$i < $n} {incr i} { + lassign [list $fib [incr fib $prev]] prev fib + } + return $fib +} diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-2.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-2.tcl new file mode 100644 index 0000000000..1028b3603d --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-2.tcl @@ -0,0 +1,3 @@ +proc fib {n} { + if {$n < 2} then {expr {$n}} else {expr {[fib [expr {$n-1}]]+[fib [expr {$n-2}]]} } +} diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-3.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-3.tcl new file mode 100644 index 0000000000..e57f9bb9f0 --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-3.tcl @@ -0,0 +1,11 @@ +proc tcl::mathfunc::fib {n} { + if { $n < 2 } { + return $n + } else { + return [expr {fib($n-1) + fib($n-2)}] + } +} + +# or, more tersely + +proc tcl::mathfunc::fib {n} {expr {$n<2 ? $n : fib($n-1) + fib($n-2)}} diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-4.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-4.tcl new file mode 100644 index 0000000000..e1975ae409 --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-4.tcl @@ -0,0 +1,4 @@ +expr {fib(7)} ;# ==> 13 + +namespace path tcl::mathfunc #; or, interp alias {} fib {} tcl::mathfunc::fib +fib 7 ;# ==> 13 diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-5.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-5.tcl new file mode 100644 index 0000000000..ce9f442458 --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-5.tcl @@ -0,0 +1,12 @@ +proc fib-tailrec {n} { + proc fib:inner {a b n} { + if {$n < 1} { + return $a + } elseif {$n == 1} { + return $b + } else { + tailcall fib:inner $b [expr {$a + $b}] [expr {$n - 1}] + } + } + return [fib:inner 0 1 $n] +} diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-6.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-6.tcl new file mode 100644 index 0000000000..32bfa0cacc --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-6.tcl @@ -0,0 +1,17 @@ +proc fibiter n { + if {$n < 0} { + set n [expr {abs($n)}] + set sign [expr {-1**($n+1)}] + } else { + set sign 1 + } + if {$n < 2} {return $n} + set prev 1 + set fib 1 + for {set i 2} {$i < $n} {incr i} { + lassign [list $fib [incr fib $prev]] prev fib + } + return [expr {$sign * $fib}] +} +fibiter -5 ;# ==> 5 +fibiter -6 ;# ==> -8 diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-7.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-7.tcl new file mode 100644 index 0000000000..65ba8a38ca --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-7.tcl @@ -0,0 +1,3 @@ +proc tcl::mathfunc::fib {n} {expr {$n<-1 ? -1**($n+1) * fib(abs($n)) : $n<2 ? $n : fib($n-1) + fib($n-2)}} +expr {fib(-5)} ;# ==> 5 +expr {fib(-6)} ;# ==> -8 diff --git a/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-8.tcl b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-8.tcl new file mode 100644 index 0000000000..47b0c38770 --- /dev/null +++ b/Task/Fibonacci-sequence/Tcl/fibonacci-sequence-8.tcl @@ -0,0 +1 @@ +proc fib n {expr {round((.5 + .5*sqrt(5)) ** $n / sqrt(5))}} diff --git a/Task/File-IO/0DESCRIPTION b/Task/File-IO/0DESCRIPTION new file mode 100644 index 0000000000..f00d5b2486 --- /dev/null +++ b/Task/File-IO/0DESCRIPTION @@ -0,0 +1,3 @@ +{{selection|Short Circuit|Console Program Basics}} + +In this task, the job is to create a file called "output.txt", and place in it the contents of the file "input.txt", ''via an intermediate variable.'' In other words, your program will demonstrate: (1) how to read from a file into a variable, and (2) how to write a variable's contents into a file. Oneliners that skip the intermediate variable are of secondary interest — operating systems have copy commands for that. diff --git a/Task/File-IO/1META.yaml b/Task/File-IO/1META.yaml new file mode 100644 index 0000000000..53d5156105 --- /dev/null +++ b/Task/File-IO/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File handling diff --git a/Task/File-IO/ACL2/file-io.acl2 b/Task/File-IO/ACL2/file-io.acl2 new file mode 100644 index 0000000000..07a0d9d686 --- /dev/null +++ b/Task/File-IO/ACL2/file-io.acl2 @@ -0,0 +1,39 @@ +:set-state-ok t + +(defun read-channel (channel limit state) + (mv-let (ch state) + (read-char$ channel state) + (if (or (null ch) + (zp limit)) + (let ((state (close-input-channel channel state))) + (mv nil state)) + (mv-let (so-far state) + (read-channel channel (1- limit) state) + (mv (cons ch so-far) state))))) + +(defun read-from-file (filename limit state) + (mv-let (channel state) + (open-input-channel filename :character state) + (mv-let (contents state) + (read-channel channel limit state) + (mv (coerce contents 'string) state)))) + +(defun write-channel (channel cs state) + (if (endp cs) + (close-output-channel channel state) + (let ((state (write-byte$ (char-code (first cs)) + channel state))) + (let ((state (write-channel channel + (rest cs) + state))) + state)))) + +(defun write-to-file (filename str state) + (mv-let (channel state) + (open-output-channel filename :byte state) + (write-channel channel (coerce str 'list) state))) + +(defun copy-file (in out state) + (mv-let (contents state) + (read-from-file in (expt 2 40) state) + (write-to-file out contents state))) diff --git a/Task/File-IO/ALGOL-68/file-io.alg b/Task/File-IO/ALGOL-68/file-io.alg new file mode 100644 index 0000000000..9c58769b3a --- /dev/null +++ b/Task/File-IO/ALGOL-68/file-io.alg @@ -0,0 +1,46 @@ +PROC copy file v1 = (STRING in name, out name)VOID: ( + # note: algol68toc-1.18 - can compile, but not run v1 # + INT errno; + FILE in file, out file; + errno := open(in file, in name, stand in channel); + errno := open(out file, out name, stand out channel); + + BOOL in ended := FALSE; + PROC call back ended = (REF FILE f) BOOL: in ended := TRUE; + on logical file end(in file, call back ended); + + STRING line; + WHILE + get(in file, (line, new line)); +# WHILE # NOT in ended DO # break to avoid excess new line # + put(out file, (line, new line)) + OD; +ended: + close(in file); + close(out file) +); + +PROC copy file v2 = (STRING in name, out name)VOID: ( + INT errno; + FILE in file, out file; + errno := open(in file, in name, stand in channel); + errno := open(out file, out name, stand out channel); + + PROC call back ended = (REF FILE f) BOOL: GO TO done; + on logical file end(in file, call back ended); + + STRING line; + DO + get(in file, line); + put(out file, line); + get(in file, new line); + put(out file, new line) + OD; +done: + close(in file); + close(out file) +); + +test:( + copy file v2("input.txt","output.txt") +) diff --git a/Task/File-IO/AWK/file-io.awk b/Task/File-IO/AWK/file-io.awk new file mode 100644 index 0000000000..0d7e046d57 --- /dev/null +++ b/Task/File-IO/AWK/file-io.awk @@ -0,0 +1,5 @@ +BEGIN { + while ( (getline <"input.txt") > 0 ) { + print >"output.txt" + } +} diff --git a/Task/File-IO/Ada/file-io-1.ada b/Task/File-IO/Ada/file-io-1.ada new file mode 100644 index 0000000000..3359b42b09 --- /dev/null +++ b/Task/File-IO/Ada/file-io-1.ada @@ -0,0 +1,24 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Read_And_Write_File_Line_By_Line is + Input, Output : File_Type; +begin + Open (File => Input, + Mode => In_File, + Name => "input.txt"); + Create (File => Output, + Mode => Out_File, + Name => "output.txt"); + loop + declare + Line : String := Get_Line (Input); + begin + -- You can process the contents of Line here. + Put_Line (Output, Line); + end; + end loop; +exception + when End_Error => + Close (Input); + Close (Output); +end Read_And_Write_File_Line_By_Line; diff --git a/Task/File-IO/Ada/file-io-2.ada b/Task/File-IO/Ada/file-io-2.ada new file mode 100644 index 0000000000..e843a6a40d --- /dev/null +++ b/Task/File-IO/Ada/file-io-2.ada @@ -0,0 +1,45 @@ +with Ada.Command_Line, Ada.Text_IO; use Ada.Command_Line, Ada.Text_IO; + +procedure Read_And_Write_File_Line_By_Line is + Read_From : constant String := "input.txt"; + Write_To : constant String := "output.txt"; + + Input, Output : File_Type; +begin + begin + Open (File => Input, + Mode => In_File, + Name => Read_From); + exception + when others => + Put_Line (Standard_Error, + "Can not open the file '" & Read_From & "'. Does it exist?"); + Set_Exit_Status (Failure); + return; + end; + + begin + Create (File => Output, + Mode => Out_File, + Name => Write_To); + exception + when others => + Put_Line (Standard_Error, + "Can not create a file named '" & Write_To & "'."); + Set_Exit_Status (Failure); + return; + end; + + loop + declare + Line : String := Get_Line (Input); + begin + -- You can process the contents of Line here. + Put_Line (Output, Line); + end; + end loop; +exception + when End_Error => + Close (Input); + Close (Output); +end Read_And_Write_File_Line_By_Line; diff --git a/Task/File-IO/Ada/file-io-3.ada b/Task/File-IO/Ada/file-io-3.ada new file mode 100644 index 0000000000..5abb54e502 --- /dev/null +++ b/Task/File-IO/Ada/file-io-3.ada @@ -0,0 +1,20 @@ +with Ada.Sequential_IO; + +procedure Read_And_Write_File_Character_By_Character is + package Char_IO is new Ada.Sequential_IO (Character); + use Char_IO; + + Input, Output : File_Type; + Buffer : Character; +begin + Open (File => Input, Mode => In_File, Name => "input.txt"); + Create (File => Output, Mode => Out_File, Name => "output.txt"); + loop + Read (File => Input, Item => Buffer); + Write (File => Output, Item => Buffer); + end loop; +exception + when End_Error => + Close (Input); + Close (Output); +end Read_And_Write_File_Character_By_Character; diff --git a/Task/File-IO/Ada/file-io-4.ada b/Task/File-IO/Ada/file-io-4.ada new file mode 100644 index 0000000000..43268042a9 --- /dev/null +++ b/Task/File-IO/Ada/file-io-4.ada @@ -0,0 +1,18 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams; + +procedure Using_Text_Streams is + Input, Output : File_Type; + Buffer : Character; +begin + Open (File => Input, Mode => In_File, Name => "input.txt"); + Create (File => Output, Mode => Out_File, Name => "output.txt"); + loop + Buffer := Character'Input (Stream (Input)); + Character'Write (Stream (Output), Buffer); + end loop; +exception + when End_Error => + Close (Input); + Close (Output); +end Using_Text_Streams; diff --git a/Task/File-IO/AppleScript/file-io.applescript b/Task/File-IO/AppleScript/file-io.applescript new file mode 100644 index 0000000000..d121c07a87 --- /dev/null +++ b/Task/File-IO/AppleScript/file-io.applescript @@ -0,0 +1,8 @@ +on copyFile from src into dst + set filedata to read file src + set outfile to open for access dst with write permission + write filedata to outfile + close access outfile +end copyFile + +copyFile from ":input.txt" into ":output.txt" diff --git a/Task/File-IO/AutoHotkey/file-io-1.ahk b/Task/File-IO/AutoHotkey/file-io-1.ahk new file mode 100644 index 0000000000..e827143e9b --- /dev/null +++ b/Task/File-IO/AutoHotkey/file-io-1.ahk @@ -0,0 +1,2 @@ +Loop, Read, input.txt, output.txt + FileAppend, %A_LoopReadLine%`n diff --git a/Task/File-IO/AutoHotkey/file-io-2.ahk b/Task/File-IO/AutoHotkey/file-io-2.ahk new file mode 100644 index 0000000000..4b0b3f48f3 --- /dev/null +++ b/Task/File-IO/AutoHotkey/file-io-2.ahk @@ -0,0 +1,2 @@ +FileRead, var, input.txt +FileAppend, %var%, output.txt diff --git a/Task/File-IO/AutoHotkey/file-io-3.ahk b/Task/File-IO/AutoHotkey/file-io-3.ahk new file mode 100644 index 0000000000..ed4ac10a64 --- /dev/null +++ b/Task/File-IO/AutoHotkey/file-io-3.ahk @@ -0,0 +1 @@ +FileCopy, input.txt, output.txt diff --git a/Task/File-IO/BASIC/file-io.bas b/Task/File-IO/BASIC/file-io.bas new file mode 100644 index 0000000000..f37e07d448 --- /dev/null +++ b/Task/File-IO/BASIC/file-io.bas @@ -0,0 +1,9 @@ + OPEN "INPUT.TXT" FOR INPUT AS #1 + OPEN "OUTPUT.TXT" FOR OUTPUT AS #2 + DO UNTIL EOF(1) + LINE INPUT #1, Data$ + PRINT #2, Data$ + LOOP + CLOSE #1 + CLOSE #2 + SYSTEM diff --git a/Task/File-IO/BBC-BASIC/file-io-1.bbc b/Task/File-IO/BBC-BASIC/file-io-1.bbc new file mode 100644 index 0000000000..cf6f294693 --- /dev/null +++ b/Task/File-IO/BBC-BASIC/file-io-1.bbc @@ -0,0 +1 @@ + *COPY input.txt output.txt diff --git a/Task/File-IO/BBC-BASIC/file-io-2.bbc b/Task/File-IO/BBC-BASIC/file-io-2.bbc new file mode 100644 index 0000000000..d1f8aa2448 --- /dev/null +++ b/Task/File-IO/BBC-BASIC/file-io-2.bbc @@ -0,0 +1,7 @@ + infile% = OPENIN("input.txt") + outfile% = OPENOUT("output.txt") + WHILE NOT EOF#infile% + BPUT #outfile%, BGET#infile% + ENDWHILE + CLOSE #infile% + CLOSE #outfile% diff --git a/Task/File-IO/Babel/file-io.pb b/Task/File-IO/Babel/file-io.pb new file mode 100644 index 0000000000..f91d91223e --- /dev/null +++ b/Task/File-IO/Babel/file-io.pb @@ -0,0 +1,4 @@ +main: + { "input.txt" >>> -- File is now on stack + foo set -- File is now in 'foo' + foo "output.txt" <<< } diff --git a/Task/File-IO/Batch-File/file-io-1.bat b/Task/File-IO/Batch-File/file-io-1.bat new file mode 100644 index 0000000000..37fe528036 --- /dev/null +++ b/Task/File-IO/Batch-File/file-io-1.bat @@ -0,0 +1 @@ +copy input.txt output.txt diff --git a/Task/File-IO/Batch-File/file-io-2.bat b/Task/File-IO/Batch-File/file-io-2.bat new file mode 100644 index 0000000000..e40b8f1cd3 --- /dev/null +++ b/Task/File-IO/Batch-File/file-io-2.bat @@ -0,0 +1 @@ +type input.txt > output.txt diff --git a/Task/File-IO/Batch-File/file-io-3.bat b/Task/File-IO/Batch-File/file-io-3.bat new file mode 100644 index 0000000000..10047edf15 --- /dev/null +++ b/Task/File-IO/Batch-File/file-io-3.bat @@ -0,0 +1 @@ +for /f "" %L in ('more^>output.txt diff --git a/Task/File-IO/Befunge/file-io.bf b/Task/File-IO/Befunge/file-io.bf new file mode 100644 index 0000000000..aa3c579347 --- /dev/null +++ b/Task/File-IO/Befunge/file-io.bf @@ -0,0 +1 @@ +0110"txt.tupni"#@i10"txt.tuptuo"#@o@ diff --git a/Task/File-IO/Bracmat/file-io.bracmat b/Task/File-IO/Bracmat/file-io.bracmat new file mode 100644 index 0000000000..917e371ece --- /dev/null +++ b/Task/File-IO/Bracmat/file-io.bracmat @@ -0,0 +1 @@ +put$(get$"input.txt","output.txt",NEW) diff --git a/Task/File-IO/C++/file-io-1.cpp b/Task/File-IO/C++/file-io-1.cpp new file mode 100644 index 0000000000..9c89036809 --- /dev/null +++ b/Task/File-IO/C++/file-io-1.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +using namespace std; + +int main() { + string line; + ifstream input ( "input.txt" ); + ofstream output ("output.txt"); + + if (output.is_open()) { + if (input.is_open()){ + while (getline (input,line)) { + output << line << endl; + } + input.close(); // Not necessary - will be closed when variable goes out of scope. + } + else { + cout << "input.txt cannot be opened!\n"; + } + output.close(); // Not necessary - will be closed when variable goes out of scope. + } + else { + cout << "output.txt cannot be written to!\n"; + } + return 0; +} diff --git a/Task/File-IO/C++/file-io-2.cpp b/Task/File-IO/C++/file-io-2.cpp new file mode 100644 index 0000000000..71d3bbd13b --- /dev/null +++ b/Task/File-IO/C++/file-io-2.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + std::ifstream input("input.txt"); + if (!input.is_open()) + { + std::cerr << "could not open input.txt for reading.\n"; + return EXIT_FAILURE; + } + + std::ofstream output("output.txt"); + if (!output.is_open()) + { + std::cerr << "could not open output.txt for writing.\n"; + return EXIT_FAILURE; + } + + output << input.rdbuf(); + if (!output) + { + std::cerr << "error copying the data.\n"; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Task/File-IO/C++/file-io-3.cpp b/Task/File-IO/C++/file-io-3.cpp new file mode 100644 index 0000000000..5c1e836b6d --- /dev/null +++ b/Task/File-IO/C++/file-io-3.cpp @@ -0,0 +1,10 @@ +# include +# include + +int main() { + std::ifstream ifile("input.txt"); + std::ofstream ofile("output.txt"); + std::copy(std::istreambuf_iterator(ifile), + std::istreambuf_iterator(), + std::ostreambuf_iterator(ofile)); +} diff --git a/Task/File-IO/C++/file-io-4.cpp b/Task/File-IO/C++/file-io-4.cpp new file mode 100644 index 0000000000..f55955f550 --- /dev/null +++ b/Task/File-IO/C++/file-io-4.cpp @@ -0,0 +1,8 @@ +#include + +int main() +{ + std::ifstream input("input.txt"); + std::ofstream output("output.txt"); + output << input.rdbuf(); +} diff --git a/Task/File-IO/C/file-io-1.c b/Task/File-IO/C/file-io-1.c new file mode 100644 index 0000000000..bd500fc22c --- /dev/null +++ b/Task/File-IO/C/file-io-1.c @@ -0,0 +1,27 @@ +#include + +int main(int argc, char **argv) { + FILE *in, *out; + int c; + + in = fopen("input.txt", "r"); + if (!in) { + fprintf(stderr, "Error opening input.txt for reading.\n"); + return 1; + } + + out = fopen("output.txt", "w"); + if (!out) { + fprintf(stderr, "Error opening output.txt for writing.\n"); + fclose(in); + return 1; + } + + while ((c = fgetc(in)) != EOF) { + fputc(c, out); + } + + fclose(out); + fclose(in); + return 0; +} diff --git a/Task/File-IO/C/file-io-2.c b/Task/File-IO/C/file-io-2.c new file mode 100644 index 0000000000..e3ae526f46 --- /dev/null +++ b/Task/File-IO/C/file-io-2.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +/* we just return a yes/no status; caller can check errno */ +int copy_file(const char *in, const char *out) +{ + int ret = 0; + int fin, fout; + ssize_t len; + char *buf[4096]; /* buffer size, some multiple of block size preferred */ + struct stat st; + + if ((fin = open(in, O_RDONLY)) == -1) return 0; + if (fstat(fin, &st)) goto bail; + + /* open output with same permission */ + fout = open(out, O_WRONLY|O_CREAT|O_TRUNC, st.st_mode & 0777); + if (fout == -1) goto bail; + + while ((len = read(fin, buf, 4096)) > 0) + write(fout, buf, len); + + ret = len ? 0 : 1; /* last read should be 0 */ + +bail: if (fin != -1) close(fin); + if (fout != -1) close(fout); + return ret; +} + +int main() +{ + copy_file("infile", "outfile"); + return 0; +} diff --git a/Task/File-IO/C/file-io-3.c b/Task/File-IO/C/file-io-3.c new file mode 100644 index 0000000000..5a04a308ca --- /dev/null +++ b/Task/File-IO/C/file-io-3.c @@ -0,0 +1,23 @@ +int copy_file(const char *in, const char *out) +{ + int ret = 0; + int fin, fout; + char *bi; + struct stat st; + + if ((fin = open(in, O_RDONLY)) == -1) return 0; + if (fstat(fin, &st)) goto bail; + + fout = open(out, O_WRONLY|O_CREAT|O_TRUNC, st.st_mode & 0777); + if (fout == -1) goto bail; + + bi = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fin, 0); + + ret = (bi == (void*)-1) + ? 0 : (write(fout, bi, st.st_size) == st.st_size); + +bail: if (fin != -1) close(fin); + if (fout != -1) close(fout); + if (bi != (void*)-1) munmap(bi, st.st_size); + return ret; +} diff --git a/Task/File-IO/Clean/file-io-1.clean b/Task/File-IO/Clean/file-io-1.clean new file mode 100644 index 0000000000..fe24ca6fad --- /dev/null +++ b/Task/File-IO/Clean/file-io-1.clean @@ -0,0 +1,19 @@ +import StdEnv + +copyFile fromPath toPath world + # (ok, fromFile, world) = fopen fromPath FReadData world + | not ok = abort ("Cannot open " +++ fromPath +++ " for reading") + # (ok, toFile, world) = fopen toPath FWriteData world + | not ok = abort ("Cannot open " +++ toPath +++ " for writing") + # (fromFile, toFile) = copyData 1024 fromFile toFile + # (ok, world) = fclose fromFile world + | not ok = abort ("Cannot close " +++ fromPath +++ " after reading") + # (ok, world) = fclose toFile world + | not ok = abort ("Cannot close " +++ toPath +++ " after writing") + = world +where + copyData bufferSize fromFile toFile + # (buffer, fromFile) = freads fromFile bufferSize + # toFile = fwrites buffer toFile + | size buffer < bufferSize = (fromFile, toFile) // we're done + = copyData bufferSize fromFile toFile // continue recursively diff --git a/Task/File-IO/Clean/file-io-2.clean b/Task/File-IO/Clean/file-io-2.clean new file mode 100644 index 0000000000..8c53c2e72e --- /dev/null +++ b/Task/File-IO/Clean/file-io-2.clean @@ -0,0 +1 @@ +Start world = copyFile "input.txt" "output.txt" world diff --git a/Task/File-IO/Clojure/file-io-1.clj b/Task/File-IO/Clojure/file-io-1.clj new file mode 100644 index 0000000000..54f6396f69 --- /dev/null +++ b/Task/File-IO/Clojure/file-io-1.clj @@ -0,0 +1,3 @@ +(use 'clojure.java.io) + +(copy (file "input.txt") (file "output.txt")) diff --git a/Task/File-IO/Clojure/file-io-2.clj b/Task/File-IO/Clojure/file-io-2.clj new file mode 100644 index 0000000000..604a093500 --- /dev/null +++ b/Task/File-IO/Clojure/file-io-2.clj @@ -0,0 +1,5 @@ +;; simple file writing +(spit "filename.txt" "your content here") + +;; simple file reading +(slurp "filename.txt") diff --git a/Task/File-IO/ColdFusion/file-io.cfm b/Task/File-IO/ColdFusion/file-io.cfm new file mode 100644 index 0000000000..d284e1d3cf --- /dev/null +++ b/Task/File-IO/ColdFusion/file-io.cfm @@ -0,0 +1,4 @@ + + + + diff --git a/Task/File-IO/Common-Lisp/file-io-1.lisp b/Task/File-IO/Common-Lisp/file-io-1.lisp new file mode 100644 index 0000000000..aa6e2b1bf1 --- /dev/null +++ b/Task/File-IO/Common-Lisp/file-io-1.lisp @@ -0,0 +1,5 @@ +(with-open-file (in #p"input.txt" :direction :input) + (with-open-file (out #p"output.txt" :direction :output) + (loop for line = (read-line in nil 'foo) + until (eq line 'foo) + do (write-line line out)))) diff --git a/Task/File-IO/Common-Lisp/file-io-2.lisp b/Task/File-IO/Common-Lisp/file-io-2.lisp new file mode 100644 index 0000000000..328987264f --- /dev/null +++ b/Task/File-IO/Common-Lisp/file-io-2.lisp @@ -0,0 +1,12 @@ +(defconstant +buffer-size+ (expt 2 16)) + +(with-open-file (in #p"input.txt" :direction :input + :element-type '(unsigned-byte 8)) + (with-open-file (out #p"output.txt" + :direction :output + :element-type (stream-element-type in)) + (loop with buffer = (make-array +buffer-size+ + :element-type (stream-element-type in)) + for size = (read-sequence buffer in) + while (plusp size) + do (write-sequence buffer out :end size)))) diff --git a/Task/File-IO/D/file-io-1.d b/Task/File-IO/D/file-io-1.d new file mode 100644 index 0000000000..80f3709510 --- /dev/null +++ b/Task/File-IO/D/file-io-1.d @@ -0,0 +1,5 @@ +import std.file: copy; + +void main() { + copy("input.txt", "output.txt"); +} diff --git a/Task/File-IO/D/file-io-2.d b/Task/File-IO/D/file-io-2.d new file mode 100644 index 0000000000..72dac05f17 --- /dev/null +++ b/Task/File-IO/D/file-io-2.d @@ -0,0 +1,9 @@ +import tango.io.device.File; + +void main() +{ + auto from = new File("input.txt"); + auto to = new File("output.txt", File.WriteCreate); + to.copy(from).close; + from.close; +} diff --git a/Task/File-IO/D/file-io-3.d b/Task/File-IO/D/file-io-3.d new file mode 100644 index 0000000000..a6be2eaa5d --- /dev/null +++ b/Task/File-IO/D/file-io-3.d @@ -0,0 +1,7 @@ +import tango.io.device.File; + +void main() +{ + auto to = new File("output.txt", File.WriteCreate); + to.copy(new File("input.txt")).close; +} diff --git a/Task/File-IO/Delphi/file-io-1.delphi b/Task/File-IO/Delphi/file-io-1.delphi new file mode 100644 index 0000000000..21f0ae35a5 --- /dev/null +++ b/Task/File-IO/Delphi/file-io-1.delphi @@ -0,0 +1,11 @@ +var + f : TextFile ; + s : string ; +begin + AssignFile(f,[fully qualified file name); + Reset(f); + writeln(f,s); + Reset(f); + ReadLn(F,S); + CloseFile( +end; diff --git a/Task/File-IO/Delphi/file-io-2.delphi b/Task/File-IO/Delphi/file-io-2.delphi new file mode 100644 index 0000000000..82d8ea0baf --- /dev/null +++ b/Task/File-IO/Delphi/file-io-2.delphi @@ -0,0 +1,10 @@ +var + f : File ; + buff : array[1.1024] of byte ; + BytesRead : Integer ; +begin + AssignFile(f,fully qualified file name); + Reset(f,1); + Blockread(f,Buff,SizeOf(Buff),BytesRead); + CloseFile(f); +end; diff --git a/Task/File-IO/Delphi/file-io-3.delphi b/Task/File-IO/Delphi/file-io-3.delphi new file mode 100644 index 0000000000..df88b7d7f7 --- /dev/null +++ b/Task/File-IO/Delphi/file-io-3.delphi @@ -0,0 +1,27 @@ +type + + tAddressBook = Record + FName : string[20]; + LName : string[30]; + Address : string[30]; + City : string[30]; + State : string[2]; + Zip5 : string[5]; + Zip4 : string[4]; + Phone : string[14]; + Deleted : boolean ; + end; + +var + f : file of tAddressBook ; + v : tAddressBook ; + bytes : integer ; +begin + AssignFile(f,fully qualified file name); + Reset(f); + Blockread(f,V,1,Bytes); + Edit(v); + Seek(F,FilePos(f)-1); + BlockWrite(f,v,1,bytes); + CloseFile(f); +end; diff --git a/Task/File-IO/E/file-io.e b/Task/File-IO/E/file-io.e new file mode 100644 index 0000000000..c6e0063edc --- /dev/null +++ b/Task/File-IO/E/file-io.e @@ -0,0 +1 @@ +.setText(.getText()) diff --git a/Task/File-IO/Eiffel/file-io.e b/Task/File-IO/Eiffel/file-io.e new file mode 100644 index 0000000000..d1a2fe6850 --- /dev/null +++ b/Task/File-IO/Eiffel/file-io.e @@ -0,0 +1,33 @@ +class + APPLICATION + +create + make + +feature {NONE} -- Initialization + + make + -- Run application. + do + create input_file.make_open_read ("input.txt") + create output_file.make_open_write ("output.txt") + + from + input_file.read_character + until + input_file.exhausted + loop + output_file.put (input_file.last_character) + input_file.read_character + end + + input_file.close + output_file.close + end + +feature -- Access + + input_file: PLAIN_TEXT_FILE + output_file: PLAIN_TEXT_FILE + +end diff --git a/Task/File-IO/Erlang/file-io.erl b/Task/File-IO/Erlang/file-io.erl new file mode 100644 index 0000000000..16e109351e --- /dev/null +++ b/Task/File-IO/Erlang/file-io.erl @@ -0,0 +1 @@ +file:copy("input.txt","output.txt"). diff --git a/Task/File-IO/Euphoria/file-io-1.euphoria b/Task/File-IO/Euphoria/file-io-1.euphoria new file mode 100644 index 0000000000..d036b75847 --- /dev/null +++ b/Task/File-IO/Euphoria/file-io-1.euphoria @@ -0,0 +1,2 @@ +include std/io.e +write_lines("output.txt", read_lines("input.txt")) diff --git a/Task/File-IO/Euphoria/file-io-2.euphoria b/Task/File-IO/Euphoria/file-io-2.euphoria new file mode 100644 index 0000000000..fcd89422f0 --- /dev/null +++ b/Task/File-IO/Euphoria/file-io-2.euphoria @@ -0,0 +1,16 @@ +integer in,out +object line + +in = open("input.txt","r") +out = open("output.txt","w") + +while 1 do + line = gets(in) + if atom(line) then -- EOF reached + exit + end if + puts(out,line) +end while + +close(out) +close(in) diff --git a/Task/File-IO/Factor/file-io-1.factor b/Task/File-IO/Factor/file-io-1.factor new file mode 100644 index 0000000000..81514d109b --- /dev/null +++ b/Task/File-IO/Factor/file-io-1.factor @@ -0,0 +1,2 @@ +"input.txt" binary file-contents +"output.txt" binary set-file-contents diff --git a/Task/File-IO/Factor/file-io-2.factor b/Task/File-IO/Factor/file-io-2.factor new file mode 100644 index 0000000000..0e5cf05ae8 --- /dev/null +++ b/Task/File-IO/Factor/file-io-2.factor @@ -0,0 +1,4 @@ +[ + "input.txt" binary &dispose + "output.txt" binary stream-copy +] with-destructors diff --git a/Task/File-IO/Factor/file-io-3.factor b/Task/File-IO/Factor/file-io-3.factor new file mode 100644 index 0000000000..5d1ea54936 --- /dev/null +++ b/Task/File-IO/Factor/file-io-3.factor @@ -0,0 +1 @@ +"input.txt" "output.txt" copy-file diff --git a/Task/File-IO/Forth/file-io.fth b/Task/File-IO/Forth/file-io.fth new file mode 100644 index 0000000000..ea758af5b4 --- /dev/null +++ b/Task/File-IO/Forth/file-io.fth @@ -0,0 +1,14 @@ +\ copy-file +: copy-file ( a1 n1 a2 n2 -- ) + r/o open-file throw >r + w/o create-file throw r> + begin + pad maxstring 2 pick read-file throw + ?dup while + pad swap 3 pick write-file throw + repeat + close-file throw + close-file throw ; + +\ Invoke it like this: +s" output.txt" s" input.txt" copy-file diff --git a/Task/File-IO/Fortran/file-io.f b/Task/File-IO/Fortran/file-io.f new file mode 100644 index 0000000000..d1df3d5326 --- /dev/null +++ b/Task/File-IO/Fortran/file-io.f @@ -0,0 +1,21 @@ +program FileIO + + integer, parameter :: out = 123, in = 124 + integer :: err + character(len=1) :: c + + open(out, file="output.txt", status="new", action="write", access="stream", iostat=err) + if ( err == 0 ) then + open(in, file="input.txt", status="old", action="read", access="stream", iostat=err) + if ( err == 0 ) then + err = 0 + do while ( err == 0 ) + read(unit=in, iostat=err) c + if ( err == 0 ) write(out) c + end do + close(in) + end if + close(out) + end if + +end program FileIO diff --git a/Task/File-IO/GAP/file-io.gap b/Task/File-IO/GAP/file-io.gap new file mode 100644 index 0000000000..df5dcc4fb2 --- /dev/null +++ b/Task/File-IO/GAP/file-io.gap @@ -0,0 +1,15 @@ +CopyFile := function(src, dst) + local f, g, line; + f := InputTextFile(src); + g := OutputTextFile(dst, false); + while true do + line := ReadLine(f); + if line = fail then + break + else + WriteLine(g, Chomp(line)); + fi; + od; + CloseStream(f); + CloseStream(g); +end; diff --git a/Task/File-IO/GML/file-io.gml b/Task/File-IO/GML/file-io.gml new file mode 100644 index 0000000000..0778164a48 --- /dev/null +++ b/Task/File-IO/GML/file-io.gml @@ -0,0 +1 @@ +file_copy("input.txt","output.txt") diff --git a/Task/File-IO/GUISS/file-io.guiss b/Task/File-IO/GUISS/file-io.guiss new file mode 100644 index 0000000000..bbc1006cba --- /dev/null +++ b/Task/File-IO/GUISS/file-io.guiss @@ -0,0 +1,2 @@ +Start,My Documents,Rightclick:input.txt,Copy,Menu,Edit,Paste, +Rightclick:Copy of input.txt,Rename,Type:output.txt[enter] diff --git a/Task/File-IO/Go/file-io-1.go b/Task/File-IO/Go/file-io-1.go new file mode 100644 index 0000000000..22b46dac12 --- /dev/null +++ b/Task/File-IO/Go/file-io-1.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "io/ioutil" +) + +func main() { + b, err := ioutil.ReadFile("input.txt") + if err != nil { + fmt.Println(err) + return + } + if err = ioutil.WriteFile("output.txt", b, 0666); err != nil { + fmt.Println(err) + } +} diff --git a/Task/File-IO/Go/file-io-2.go b/Task/File-IO/Go/file-io-2.go new file mode 100644 index 0000000000..ca523a8935 --- /dev/null +++ b/Task/File-IO/Go/file-io-2.go @@ -0,0 +1,37 @@ +package main + +import ( + "io" + "log" + "os" +) + +func CopyFile(out, in string) (err error) { + var inf, outf *os.File + inf, err = os.Open(in) + if err != nil { + return + } + defer func() { + cErr := inf.Close() + if err == nil { + err = cErr + } + }() + outf, err = os.Create(out) + if err != nil { + return + } + _, err = io.Copy(outf, inf) + cErr := outf.Close() + if err == nil { + err = cErr + } + return +} + +func main() { + if err := CopyFile("output.txt", "input.txt"); err != nil { + log.Fatal(err) + } +} diff --git a/Task/File-IO/Groovy/file-io-1.groovy b/Task/File-IO/Groovy/file-io-1.groovy new file mode 100644 index 0000000000..4e5f9b140c --- /dev/null +++ b/Task/File-IO/Groovy/file-io-1.groovy @@ -0,0 +1 @@ +new File('output.txt').write(new File('input.txt').text) diff --git a/Task/File-IO/Groovy/file-io-2.groovy b/Task/File-IO/Groovy/file-io-2.groovy new file mode 100644 index 0000000000..5683f66eac --- /dev/null +++ b/Task/File-IO/Groovy/file-io-2.groovy @@ -0,0 +1 @@ +new AntBuilder().copy(file:'input.txt', toFile:'output.txt', overwrite:true) diff --git a/Task/File-IO/Groovy/file-io-3.groovy b/Task/File-IO/Groovy/file-io-3.groovy new file mode 100644 index 0000000000..65ffd2a747 --- /dev/null +++ b/Task/File-IO/Groovy/file-io-3.groovy @@ -0,0 +1,3 @@ +new File('output.txt').withWriter( w -> + new File('input.txt').withReader( r -> w << r } +} diff --git a/Task/File-IO/Haskell/file-io.hs b/Task/File-IO/Haskell/file-io.hs new file mode 100644 index 0000000000..65698745cd --- /dev/null +++ b/Task/File-IO/Haskell/file-io.hs @@ -0,0 +1 @@ +main = readFile "input.txt" >>= writeFile "output.txt" diff --git a/Task/File-IO/HicEst/file-io-1.hicest b/Task/File-IO/HicEst/file-io-1.hicest new file mode 100644 index 0000000000..1b926be2fc --- /dev/null +++ b/Task/File-IO/HicEst/file-io-1.hicest @@ -0,0 +1,2 @@ +CHARACTER input='input.txt ', output='output.txt ', c, buffer*4096 +SYSTEM(COPY=input//output, ERror=11) ! on error branch to label 11 (not shown) diff --git a/Task/File-IO/HicEst/file-io-2.hicest b/Task/File-IO/HicEst/file-io-2.hicest new file mode 100644 index 0000000000..36123e45c5 --- /dev/null +++ b/Task/File-IO/HicEst/file-io-2.hicest @@ -0,0 +1,7 @@ +OPEN(FIle=input, OLD, ERror=21) ! on error branch to label 21 (not shown) +OPEN(FIle=output) + DO i = 1, 1E300 ! "infinite" loop, exited on end-of-file error + READ( FIle=input, ERror=22) buffer ! on error (end of file) branch to label 22 + WRITE(FIle=output, ERror=23) buffer ! on error branch to label 23 (not shown) + ENDDO +22 WRITE(FIle=output, CLoSe=1) diff --git a/Task/File-IO/HicEst/file-io-3.hicest b/Task/File-IO/HicEst/file-io-3.hicest new file mode 100644 index 0000000000..9e9166b567 --- /dev/null +++ b/Task/File-IO/HicEst/file-io-3.hicest @@ -0,0 +1,5 @@ +OPEN(FIle=input, SEQuential, UNFormatted, OLD, LENgth=len, ERror=31) ! on error branch to label 31 (not shown) +OPEN(FIle=output, SEQuential, UNFormatted, ERror=32) ! on error branch to label 32 (not shown) +ALLOCATE(c, len) +READ(FIle=input, CLoSe=1) c +WRITE(FIle=output, CLoSe=1) c END diff --git a/Task/File-IO/IDL/file-io.idl b/Task/File-IO/IDL/file-io.idl new file mode 100644 index 0000000000..939b4c5098 --- /dev/null +++ b/Task/File-IO/IDL/file-io.idl @@ -0,0 +1,12 @@ +; open two LUNs +openw,unit1,'output.txt,/get +openr,unit2,'input.txt',/get +; how many bytes to read +fs = fstat(unit2) +; make buffer +buff = bytarr(fs.size) +; transfer content +readu,unit2,buff +writeu,unit1,buff +; that's all +close,/all diff --git a/Task/File-IO/Icon/file-io.icon b/Task/File-IO/Icon/file-io.icon new file mode 100644 index 0000000000..607d12011d --- /dev/null +++ b/Task/File-IO/Icon/file-io.icon @@ -0,0 +1,5 @@ +procedure main() +in := open(f := "input.txt","r") | stop("Unable to open ",f) +out := open(f := "output.txt","w") | stop("Unable to open ",f) +while write(out,read(in)) +end diff --git a/Task/File-IO/Io/file-io.io b/Task/File-IO/Io/file-io.io new file mode 100644 index 0000000000..6b1f84104e --- /dev/null +++ b/Task/File-IO/Io/file-io.io @@ -0,0 +1,9 @@ +inf := File with("input.txt") openForReading +outf := File with("output.txt") openForUpdating + +while(l := inf readLine, + outf write(l, "\n") +) + +inf close +outf close diff --git a/Task/File-IO/J/file-io-1.j b/Task/File-IO/J/file-io-1.j new file mode 100644 index 0000000000..faf442ea5d --- /dev/null +++ b/Task/File-IO/J/file-io-1.j @@ -0,0 +1 @@ + 'output.txt' (1!:2~ 1!:1)&< 'input.txt' diff --git a/Task/File-IO/J/file-io-2.j b/Task/File-IO/J/file-io-2.j new file mode 100644 index 0000000000..e642e985c2 --- /dev/null +++ b/Task/File-IO/J/file-io-2.j @@ -0,0 +1,2 @@ +require 'files' +'output.txt' (fwrite~ fread) 'input.txt' diff --git a/Task/File-IO/Java/file-io-1.java b/Task/File-IO/Java/file-io-1.java new file mode 100644 index 0000000000..a55c245424 --- /dev/null +++ b/Task/File-IO/Java/file-io-1.java @@ -0,0 +1,18 @@ +import java.io.*; + +public class FileIODemo { + public static void main(String[] args) { + try { + FileInputStream in = new FileInputStream("input.txt"); + FileOutputStream out = new FileOutputStream("ouput.txt"); + int c; + while ((c = in.read()) != -1) { + out.write(c); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e){ + e.printStackTrace(); + } + } +} diff --git a/Task/File-IO/Java/file-io-2.java b/Task/File-IO/Java/file-io-2.java new file mode 100644 index 0000000000..6271511c3b --- /dev/null +++ b/Task/File-IO/Java/file-io-2.java @@ -0,0 +1,30 @@ +import java.io.*; + +public class FileIODemo2 { + public static void main(String args[]) { + try { + // Probably should wrap with a BufferedInputStream + final InputStream in = new FileInputStream("input.txt"); + try { + // Probably should wrap with a BufferedOutputStream + final OutputStream out = new FileOutputStream("output.txt"); + try { + int c; + while ((c = in.read()) != -1) { + out.write(c); + } + } + finally { + out.close(); + } + } + finally { + in.close(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e){ + e.printStackTrace(); + } + } +} diff --git a/Task/File-IO/Java/file-io-3.java b/Task/File-IO/Java/file-io-3.java new file mode 100644 index 0000000000..2d473fe170 --- /dev/null +++ b/Task/File-IO/Java/file-io-3.java @@ -0,0 +1,26 @@ +import java.io.*; +import java.nio.channels.*; + +public class FileIODemo3 { + public static void main(String args[]) { + try { + final FileChannel in = new FileInputStream("input.txt").getChannel(); + try { + final FileChannel out = new FileOutputStream("output.txt").getChannel(); + try { + out.transferFrom(in, 0, in.size()); + } + finally { + out.close(); + } + } + finally { + in.close(); + } + } + catch (Exception e) { + System.err.println("Exception while trying to copy: "+e); + e.printStackTrace(); // stack trace of place where it happened + } + } +} diff --git a/Task/File-IO/Java/file-io-4.java b/Task/File-IO/Java/file-io-4.java new file mode 100644 index 0000000000..6bccf168c9 --- /dev/null +++ b/Task/File-IO/Java/file-io-4.java @@ -0,0 +1,14 @@ +import java.io.*; +public class Test { + public static void main (String[] args) throws IOException { + BufferedReader br = new BufferedReader(new FileReader("input.txt")); + BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt")); + String line; + while (line = br.readLine() != null) { + bw.write(line); + bw.newLine(); + } + br.close(); + bw.close(); + } +} diff --git a/Task/File-IO/Java/file-io-5.java b/Task/File-IO/Java/file-io-5.java new file mode 100644 index 0000000000..55bc553b31 --- /dev/null +++ b/Task/File-IO/Java/file-io-5.java @@ -0,0 +1,9 @@ +import java.nio.file.*; +public class Copy{ + public static void main(String[] args) throws Exception{ + FileSystem fs = FileSystems.getDefault(); + Path in = fs.getPath("input.txt"); + Path out = fs.getPath("output.txt"); + Files.copy(in, out, StandardCopyOption.REPLACE_EXISTING); + } +} diff --git a/Task/File-IO/JavaScript/file-io-1.js b/Task/File-IO/JavaScript/file-io-1.js new file mode 100644 index 0000000000..bb4358a060 --- /dev/null +++ b/Task/File-IO/JavaScript/file-io-1.js @@ -0,0 +1,15 @@ +var fso = new ActiveXObject("Scripting.FileSystemObject"); +var ForReading = 1, ForWriting = 2; +var f_in = fso.OpenTextFile('input.txt', ForReading); +var f_out = fso.OpenTextFile('output.txt', ForWriting, true); + +// for small files: +// f_out.Write( f_in.ReadAll() ); + +while ( ! f_in.AtEndOfStream) { + // ReadLine() does not include the newline char + f_out.WriteLine( f_in.ReadLine() ); +} + +f_in.Close(); +f_out.Close(); diff --git a/Task/File-IO/JavaScript/file-io-2.js b/Task/File-IO/JavaScript/file-io-2.js new file mode 100644 index 0000000000..88df69175a --- /dev/null +++ b/Task/File-IO/JavaScript/file-io-2.js @@ -0,0 +1,2 @@ +var fs = require('fs'); +require('util').pump(fs.createReadStream('input.txt', {flags:'r'}), fs.createWriteStream('output.txt', {flags:'w+'})); diff --git a/Task/File-IO/K/file-io.k b/Task/File-IO/K/file-io.k new file mode 100644 index 0000000000..efedb77ada --- /dev/null +++ b/Task/File-IO/K/file-io.k @@ -0,0 +1 @@ +`output.txt 0:0:`input.txt diff --git a/Task/File-IO/Lang5/file-io.lang5 b/Task/File-IO/Lang5/file-io.lang5 new file mode 100644 index 0000000000..ddff1d24fa --- /dev/null +++ b/Task/File-IO/Lang5/file-io.lang5 @@ -0,0 +1,7 @@ +: puts(*) . "\n" . ; +: set-file '> swap open ; +: >>contents slurp puts ; +: copy-file + swap set-file 'fdst set fdst fout >>contents fdst close ; + +'output.txt 'input.txt copy-file diff --git a/Task/File-IO/Liberty-BASIC/file-io.liberty b/Task/File-IO/Liberty-BASIC/file-io.liberty new file mode 100644 index 0000000000..601d13164e --- /dev/null +++ b/Task/File-IO/Liberty-BASIC/file-io.liberty @@ -0,0 +1,12 @@ +nomainwin + + open "input.txt" for input as #f1 + qtyBytes = lof( #f1) + source$ = input$( #f1, qtyBytes) + close #f1 + + open "output.txt" for output as #f2 + #f2 source$; + close #f2 + + end diff --git a/Task/File-IO/Lisaac/file-io.lisaac b/Task/File-IO/Lisaac/file-io.lisaac new file mode 100644 index 0000000000..9ba8003c37 --- /dev/null +++ b/Task/File-IO/Lisaac/file-io.lisaac @@ -0,0 +1,32 @@ +Section Header + ++ name := FILE_IO; + +Section Public + +- main <- ( + + e : ENTRY; + + f : STD_FILE; + + s : STRING; + + e := FILE_SYSTEM.get "input.txt"; + (e != NULL).if { + f ?= e.open_read_only; + (f != NULL).if { + s := STRING.create(f.size); + f.read s size (f.size); + f.close; + }; + }; + + (s != NULL).if { + e := FILE_SYSTEM.make_file "output.txt"; + (e != NULL).if { + f ?= e.open; + (f != NULL).if { + f.write s from (s.lower) size (s.count); + f.close; + }; + }; + }; +); diff --git a/Task/File-IO/Logo/file-io.logo b/Task/File-IO/Logo/file-io.logo new file mode 100644 index 0000000000..a6fd4e2cb6 --- /dev/null +++ b/Task/File-IO/Logo/file-io.logo @@ -0,0 +1,10 @@ +to copy :from :to + openread :from + openwrite :to + setread :from + setwrite :to + until [eof?] [print readrawline] + closeall +end + +copy "input.txt "output.txt diff --git a/Task/File-IO/Lua/file-io.lua b/Task/File-IO/Lua/file-io.lua new file mode 100644 index 0000000000..835344702a --- /dev/null +++ b/Task/File-IO/Lua/file-io.lua @@ -0,0 +1,12 @@ +inFile = io.open("input.txt", "r") +data = inFile:read("*all") -- may be abbreviated to "*a"; + -- other options are "*line", + -- or the number of characters to read. +inFile:close() + +outFile = io.open("output.txt", "w") +outfile:write(data) +outfile:close() + +-- Oneliner version: +io.open("output.txt", "w"):write(io.open("input.txt", "r"):read("*a")) diff --git a/Task/File-IO/MAXScript/file-io.max b/Task/File-IO/MAXScript/file-io.max new file mode 100644 index 0000000000..843b951045 --- /dev/null +++ b/Task/File-IO/MAXScript/file-io.max @@ -0,0 +1,8 @@ +inFile = openFile "input.txt" +outFile = createFile "output.txt" +while not EOF inFile do +( + format "%" (readLine inFile) to:outFile +) +close inFile +close outFile diff --git a/Task/File-IO/Mathematica/file-io.mathematica b/Task/File-IO/Mathematica/file-io.mathematica new file mode 100644 index 0000000000..fc8c5c1e56 --- /dev/null +++ b/Task/File-IO/Mathematica/file-io.mathematica @@ -0,0 +1,3 @@ +SetDirectory@NotebookDirectory[]; +If[FileExistsQ["output.txt"], DeleteFile["output.txt"], Print["No output yet"] ]; +CopyFile["input.txt", "output.txt"] diff --git a/Task/File-IO/Modula-3/file-io.mod3 b/Task/File-IO/Modula-3/file-io.mod3 new file mode 100644 index 0000000000..e3a00af007 --- /dev/null +++ b/Task/File-IO/Modula-3/file-io.mod3 @@ -0,0 +1,19 @@ +MODULE FileIO EXPORTS Main; + +IMPORT IO, Rd, Wr; + +<*FATAL ANY*> + +VAR + infile: Rd.T; + outfile: Wr.T; + txt: TEXT; + +BEGIN + infile := IO.OpenRead("input.txt"); + outfile := IO.OpenWrite("output.txt"); + txt := Rd.GetText(infile, LAST(CARDINAL)); + Wr.PutText(outfile, txt); + Rd.Close(infile); + Wr.Close(outfile); +END FileIO. diff --git a/Task/File-IO/PHP/file-io-1.php b/Task/File-IO/PHP/file-io-1.php new file mode 100644 index 0000000000..8c9aa81660 --- /dev/null +++ b/Task/File-IO/PHP/file-io-1.php @@ -0,0 +1,18 @@ + diff --git a/Task/File-IO/PHP/file-io-2.php b/Task/File-IO/PHP/file-io-2.php new file mode 100644 index 0000000000..7f60a3a65a --- /dev/null +++ b/Task/File-IO/PHP/file-io-2.php @@ -0,0 +1,9 @@ + diff --git a/Task/File-IO/Perl/file-io.pl b/Task/File-IO/Perl/file-io.pl new file mode 100644 index 0000000000..80a4a3bf9a --- /dev/null +++ b/Task/File-IO/Perl/file-io.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +open my $fh_in, '<', 'input.txt' or die "could not open for reading: $!"; +open my $fh_out, '>', 'output.txt' or die "could not open for writing: $!"; +# '>' overwrites file, '>>' appends to file, just like in the shell + +binmode $fh_out; # marks filehandle for binary content on systems where that matters + +print $fh_out $_ while <$fh_in>; +# prints current line to file associated with $fh_out filehandle + +# the same, less concise +#while (<$fh_in>) { +# print $fh_out $_; +#}; + +close $fh_in; +close $fh_out; diff --git a/Task/File-IO/PicoLisp/file-io-1.l b/Task/File-IO/PicoLisp/file-io-1.l new file mode 100644 index 0000000000..3e5a369e59 --- /dev/null +++ b/Task/File-IO/PicoLisp/file-io-1.l @@ -0,0 +1,2 @@ +(let V (in "input.txt" (till)) + (out "output.txt" (prin V)) ) diff --git a/Task/File-IO/PicoLisp/file-io-2.l b/Task/File-IO/PicoLisp/file-io-2.l new file mode 100644 index 0000000000..49bba1d732 --- /dev/null +++ b/Task/File-IO/PicoLisp/file-io-2.l @@ -0,0 +1,3 @@ +(in "input.txt" + (out "output.txt" + (echo) ) ) diff --git a/Task/File-IO/Python/file-io-1.py b/Task/File-IO/Python/file-io-1.py new file mode 100644 index 0000000000..1c71355885 --- /dev/null +++ b/Task/File-IO/Python/file-io-1.py @@ -0,0 +1,2 @@ +import shutil +shutil.copyfile('input.txt', 'output.txt') diff --git a/Task/File-IO/Python/file-io-2.py b/Task/File-IO/Python/file-io-2.py new file mode 100644 index 0000000000..2cceea03f7 --- /dev/null +++ b/Task/File-IO/Python/file-io-2.py @@ -0,0 +1,6 @@ +infile = open('input.txt', 'r') +outfile = open('output.txt', 'w') +for line in infile: + outfile.write(line) +outfile.close() +infile.close() diff --git a/Task/File-IO/Python/file-io-3.py b/Task/File-IO/Python/file-io-3.py new file mode 100644 index 0000000000..4c777bdb44 --- /dev/null +++ b/Task/File-IO/Python/file-io-3.py @@ -0,0 +1,20 @@ +import sys +try: + infile = open('input.txt', 'r') +except IOError: + print >> sys.stderr, "Unable to open input.txt for input" + sys.exit(1) +try: + outfile = open('output.txt', 'w') +except IOError: + print >> sys.stderr, "Unable to open output.txt for output" + sys.exit(1) +try: # for finally + try: # for I/O + for line in infile: + outfile.write(line) + except IOError, e: + print >> sys.stderr, "Some I/O Error occurred (reading from input.txt or writing to output.txt)" +finally: + infile.close() + outfile.close() diff --git a/Task/File-IO/Python/file-io-4.py b/Task/File-IO/Python/file-io-4.py new file mode 100644 index 0000000000..fe63cc7137 --- /dev/null +++ b/Task/File-IO/Python/file-io-4.py @@ -0,0 +1,9 @@ +import sys +try: + with open('input.txt') as infile: + with open('output.txt', 'w') as outfile: + for line in infile: + outfile.write(line) +except IOError: + print >> sys.stderr, "Some I/O Error occurred" + sys.exit(1) diff --git a/Task/File-IO/R/file-io-1.r b/Task/File-IO/R/file-io-1.r new file mode 100644 index 0000000000..4f898249d3 --- /dev/null +++ b/Task/File-IO/R/file-io-1.r @@ -0,0 +1,6 @@ +src <- file("input.txt", "r") +dest <- file("output.txt", "w") + +fc <- readLines(src, -1) +writeLines(fc, dest) +close(src); close(dest) diff --git a/Task/File-IO/R/file-io-2.r b/Task/File-IO/R/file-io-2.r new file mode 100644 index 0000000000..12315c5dcc --- /dev/null +++ b/Task/File-IO/R/file-io-2.r @@ -0,0 +1,7 @@ +src <- file("input.txt", "rb") +dest <- file("output.txt", "wb") + +while( length(v <- readBin(src, "raw")) > 0 ) { + writeBin(v, dest) +} +close(src); close(dest) diff --git a/Task/File-IO/R/file-io-3.r b/Task/File-IO/R/file-io-3.r new file mode 100644 index 0000000000..42902bffd7 --- /dev/null +++ b/Task/File-IO/R/file-io-3.r @@ -0,0 +1 @@ +file.copy("input.txt", "output.txt", overwrite = FALSE) diff --git a/Task/File-IO/REXX/file-io-1.rexx b/Task/File-IO/REXX/file-io-1.rexx new file mode 100644 index 0000000000..2d29a5e33f --- /dev/null +++ b/Task/File-IO/REXX/file-io-1.rexx @@ -0,0 +1,11 @@ +/*REXX program to read a file and store the contents into an output file*/ + +ifid = 'input.txt' /*name of the input file. */ +ofid = 'output.txt' /*name of the output file. */ +call lineout ofid,,1 /*insure output starts at line 1.*/ + + do while lines(ifid)\==0 /*read until finished. */ + y = linein(ifid) /*read a record from input. */ + call lineout ofid,y /*write a record to output.nt. */ + end + /*stick a fork in it, we're done.*/ diff --git a/Task/File-IO/REXX/file-io-2.rexx b/Task/File-IO/REXX/file-io-2.rexx new file mode 100644 index 0000000000..24cb5a0064 --- /dev/null +++ b/Task/File-IO/REXX/file-io-2.rexx @@ -0,0 +1,11 @@ +/*REXX program to read a file and store the contents into an output file*/ +/*(same as the 1st example, but is faster because no intermediate step.)*/ + +ifid = 'input.txt' /*name of the input file. */ +ofid = 'output.txt' /*name of the output file. */ +call lineout ofid,,1 /*insure output starts at line 1.*/ + + do while lines(ifid)\==0 /*read until finished. */ + call lineout ofid, linein(ifid) /*read & write in one statement. */ + end /*while*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/File-IO/REXX/file-io-3.rexx b/Task/File-IO/REXX/file-io-3.rexx new file mode 100644 index 0000000000..e3156dde15 --- /dev/null +++ b/Task/File-IO/REXX/file-io-3.rexx @@ -0,0 +1,8 @@ +/*REXX program to read a file and write contents to an output file***** +* 03.09.2012 Walter Pachl (without erase string would be appended) +**********************************************************************/ +ifid='input.txt' /*name of the input file. */ +ofid='output.txt' /*name of the output file. */ +'erase' ofid /* avoid appending */ +s=charin(ifid,,1000000) /* read the input file */ +Call charout ofid,s /* write to output file */ diff --git a/Task/File-IO/Ruby/file-io-1.rb b/Task/File-IO/Ruby/file-io-1.rb new file mode 100644 index 0000000000..3907d023cd --- /dev/null +++ b/Task/File-IO/Ruby/file-io-1.rb @@ -0,0 +1,2 @@ +str = File.open('input.txt', 'rb') {|f| f.read} +File.open('output.txt', 'wb') {|f| f.write str} diff --git a/Task/File-IO/Ruby/file-io-2.rb b/Task/File-IO/Ruby/file-io-2.rb new file mode 100644 index 0000000000..9dbb58f3a1 --- /dev/null +++ b/Task/File-IO/Ruby/file-io-2.rb @@ -0,0 +1,4 @@ +# Only if 'input.txt' is a text file! +# Only if pipe '|' is not first character of path! +str = IO.read('input.txt') +open('output.txt', 'w') {|f| f.write str} diff --git a/Task/File-IO/Ruby/file-io-3.rb b/Task/File-IO/Ruby/file-io-3.rb new file mode 100644 index 0000000000..fc96a7acb4 --- /dev/null +++ b/Task/File-IO/Ruby/file-io-3.rb @@ -0,0 +1,2 @@ +require 'fileutils' +FileUtils.copy_file 'input.txt', 'output.txt' diff --git a/Task/File-IO/Scala/file-io.scala b/Task/File-IO/Scala/file-io.scala new file mode 100644 index 0000000000..5dfc05c3c1 --- /dev/null +++ b/Task/File-IO/Scala/file-io.scala @@ -0,0 +1,6 @@ +import java.nio.file._ + +val input = Paths.get("input.txt") +val output = Paths.get("output.txt") + +Files.copy(input, output) diff --git a/Task/File-IO/Scheme/file-io.ss b/Task/File-IO/Scheme/file-io.ss new file mode 100644 index 0000000000..84d05b1b5c --- /dev/null +++ b/Task/File-IO/Scheme/file-io.ss @@ -0,0 +1,13 @@ +; Open ports for the input and output files +(define in-file (open-input-file "input.txt")) +(define out-file (open-output-file "output.txt")) + +; Read and write characters from the input file +; to the output file one by one until end of file +(do ((c (read-char in-file) (read-char in-file))) + ((eof-object? c)) + (write-char c out-file)) + +; Close the ports +(close-input-port in-file) +(close-output-port out-file) diff --git a/Task/File-IO/Smalltalk/file-io.st b/Task/File-IO/Smalltalk/file-io.st new file mode 100644 index 0000000000..019ecb724a --- /dev/null +++ b/Task/File-IO/Smalltalk/file-io.st @@ -0,0 +1,7 @@ +| in out | +in := FileStream open: 'input.txt' mode: FileStream read. +out := FileStream open: 'output.txt' mode: FileStream write. +[ in atEnd ] + whileFalse: [ + out nextPut: (in next) + ] diff --git a/Task/File-IO/Tcl/file-io-1.tcl b/Task/File-IO/Tcl/file-io-1.tcl new file mode 100644 index 0000000000..cdbf91bf79 --- /dev/null +++ b/Task/File-IO/Tcl/file-io-1.tcl @@ -0,0 +1,6 @@ +set in [open "input.txt" r] +set out [open "output.txt" w] +# Obviously, arbitrary transformations could be added to the data at this point +puts -nonewline $out [read $in] +close $in +close $out diff --git a/Task/File-IO/Tcl/file-io-2.tcl b/Task/File-IO/Tcl/file-io-2.tcl new file mode 100644 index 0000000000..aa9c9489ea --- /dev/null +++ b/Task/File-IO/Tcl/file-io-2.tcl @@ -0,0 +1,5 @@ +set in [open "input.txt" r] +set out [open "output.txt" w] +fcopy $in $out +close $in +close $out diff --git a/Task/File-IO/Tcl/file-io-3.tcl b/Task/File-IO/Tcl/file-io-3.tcl new file mode 100644 index 0000000000..64201afccb --- /dev/null +++ b/Task/File-IO/Tcl/file-io-3.tcl @@ -0,0 +1 @@ +file copy input.txt output.txt diff --git a/Task/File-IO/Tcl/file-io-4.tcl b/Task/File-IO/Tcl/file-io-4.tcl new file mode 100644 index 0000000000..b2722d9252 --- /dev/null +++ b/Task/File-IO/Tcl/file-io-4.tcl @@ -0,0 +1,6 @@ +#open file for writing +set myfile [open "README.TXT" w] +#write something to the file +puts $myfile "This is line 1, so hello world...." +#close the file +close $myfile diff --git a/Task/File-IO/Tcl/file-io-5.tcl b/Task/File-IO/Tcl/file-io-5.tcl new file mode 100644 index 0000000000..06458e9240 --- /dev/null +++ b/Task/File-IO/Tcl/file-io-5.tcl @@ -0,0 +1,9 @@ +#open file for reading +set myfile [open "README.TXT" r] +#read something from the file +gets $myfile mydata +#show what was read from the file +#should print "This is line1, so hello world...." +puts $mydata +#close the file +close $myfile diff --git a/Task/File-modification-time/0DESCRIPTION b/Task/File-modification-time/0DESCRIPTION new file mode 100644 index 0000000000..6ea7b2d37f --- /dev/null +++ b/Task/File-modification-time/0DESCRIPTION @@ -0,0 +1 @@ +This task will attempt to get and set the modification time of a file. diff --git a/Task/File-modification-time/1META.yaml b/Task/File-modification-time/1META.yaml new file mode 100644 index 0000000000..40458d9f21 --- /dev/null +++ b/Task/File-modification-time/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File System Operations diff --git a/Task/File-modification-time/Ada/file-modification-time.ada b/Task/File-modification-time/Ada/file-modification-time.ada new file mode 100644 index 0000000000..3aab748a55 --- /dev/null +++ b/Task/File-modification-time/Ada/file-modification-time.ada @@ -0,0 +1,8 @@ +with Ada.Directories; use Ada.Directories; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; + +procedure File_Time_Test is +begin + Put_Line (Image (Modification_Time ("file_time_test.adb"))); +end File_Time_Test; diff --git a/Task/File-modification-time/AutoHotkey/file-modification-time.ahk b/Task/File-modification-time/AutoHotkey/file-modification-time.ahk new file mode 100644 index 0000000000..c4a6a4d5ab --- /dev/null +++ b/Task/File-modification-time/AutoHotkey/file-modification-time.ahk @@ -0,0 +1,5 @@ +FileGetTime, OutputVar, output.txt +MsgBox % OutputVar +FileSetTime, 20080101, output.txt +FileGetTime, OutputVar, output.txt +MsgBox % OutputVar diff --git a/Task/File-modification-time/BBC-BASIC/file-modification-time.bbc b/Task/File-modification-time/BBC-BASIC/file-modification-time.bbc new file mode 100644 index 0000000000..b676e703c2 --- /dev/null +++ b/Task/File-modification-time/BBC-BASIC/file-modification-time.bbc @@ -0,0 +1,27 @@ + DIM ft{dwLowDateTime%, dwHighDateTime%} + DIM st{wYear{l&,h&}, wMonth{l&,h&}, wDayOfWeek{l&,h&}, \ + \ wDay{l&,h&}, wHour{l&,h&}, wMinute{l&,h&}, \ + \ wSecond{l&,h&}, wMilliseconds{l&,h&} } + + REM File is assumed to exist: + file$ = @tmp$ + "rosetta.tmp" + + REM Get and display the modification time: + file% = OPENIN(file$) + SYS "GetFileTime", @hfile%(file%), 0, 0, ft{} + CLOSE #file% + SYS "FileTimeToSystemTime", ft{}, st{} + date$ = STRING$(16, CHR$0) + time$ = STRING$(16, CHR$0) + SYS "GetDateFormat", 0, 0, st{}, 0, date$, LEN(date$) TO N% + date$ = LEFT$(date$, N%-1) + SYS "GetTimeFormat", 0, 0, st{}, 0, time$, LEN(time$) TO N% + time$ = LEFT$(time$, N%-1) + PRINT date$ " " time$ + + REM Set the modification time to the current time: + SYS "GetSystemTime", st{} + SYS "SystemTimeToFileTime", st{}, ft{} + file% = OPENUP(file$) + SYS "SetFileTime", @hfile%(file%), 0, 0, ft{} + CLOSE #file% diff --git a/Task/File-modification-time/Batch-File/file-modification-time.bat b/Task/File-modification-time/Batch-File/file-modification-time.bat new file mode 100644 index 0000000000..d666fbe52c --- /dev/null +++ b/Task/File-modification-time/Batch-File/file-modification-time.bat @@ -0,0 +1 @@ +for %%f in (file.txt) do echo.%%~tf diff --git a/Task/File-modification-time/C++/file-modification-time.cpp b/Task/File-modification-time/C++/file-modification-time.cpp new file mode 100644 index 0000000000..62bae50bbe --- /dev/null +++ b/Task/File-modification-time/C++/file-modification-time.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +int main( int argc , char *argv[ ] ) { + if ( argc != 2 ) { + std::cerr << "Error! Syntax: moditime !\n" ; + return 1 ; + } + boost::filesystem::path p( argv[ 1 ] ) ; + if ( boost::filesystem::exists( p ) ) { + std::time_t t = boost::filesystem::last_write_time( p ) ; + std::cout << "On " << std::ctime( &t ) << " the file " << argv[ 1 ] + << " was modified the last time!\n" ; + std::cout << "Setting the modification time to now:\n" ; + std::time_t n = std::time( 0 ) ; + boost::filesystem::last_write_time( p , n ) ; + t = boost::filesystem::last_write_time( p ) ; + std::cout << "Now the modification time is " << std::ctime( &t ) << std::endl ; + return 0 ; + } else { + std::cout << "Could not find file " << argv[ 1 ] << '\n' ; + return 2 ; + } +} diff --git a/Task/File-modification-time/C/file-modification-time-1.c b/Task/File-modification-time/C/file-modification-time-1.c new file mode 100644 index 0000000000..b6b34ce879 --- /dev/null +++ b/Task/File-modification-time/C/file-modification-time-1.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +const char *filename = "input.txt"; + +int main() { + struct stat foo; + time_t mtime; + struct utimbuf new_times; + + if (stat(filename, &foo) < 0) { + perror(filename); + return 1; + } + mtime = foo.st_mtime; /* seconds since the epoch */ + + new_times.actime = foo.st_atime; /* keep atime unchanged */ + new_times.modtime = time(NULL); /* set mtime to current time */ + if (utime(filename, &new_times) < 0) { + perror(filename); + return 1; + } + + return 0; +} diff --git a/Task/File-modification-time/C/file-modification-time-2.c b/Task/File-modification-time/C/file-modification-time-2.c new file mode 100644 index 0000000000..aed5fd8453 --- /dev/null +++ b/Task/File-modification-time/C/file-modification-time-2.c @@ -0,0 +1,24 @@ +#include +#include +#include + +const char *filename = "input.txt"; + +int main() { + struct stat foo; + struct timeval new_times[2]; + + if (stat(filename, &foo) < 0) + err(1, "%s", filename); + + /* keep atime unchanged */ + TIMESPEC_TO_TIMEVAL(&new_times[0], &foo.st_atim); + + /* set mtime to current time */ + gettimeofday(&new_times[1], NULL); + + if (utimes(filename, new_times) < 0) + err(1, "%s", filename); + + return 0; +} diff --git a/Task/File-modification-time/C/file-modification-time-3.c b/Task/File-modification-time/C/file-modification-time-3.c new file mode 100644 index 0000000000..94ec386794 --- /dev/null +++ b/Task/File-modification-time/C/file-modification-time-3.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +const char *filename = "input.txt"; + +int main() { + struct stat foo; + struct timespec new_times[2]; + + if (stat(filename, &foo) < 0) { + perror(filename); + return 1; + } + + /* keep atime unchanged */ + new_times[0] = foo.st_atim; + + /* set mtime to current time */ + clock_gettime(CLOCK_REALTIME, &new_times[1]); + + if (utimensat(AT_FDCWD, filename, new_times, 0) < 0) { + perror(filename); + return 1; + } + + return 0; +} diff --git a/Task/File-modification-time/C/file-modification-time-4.c b/Task/File-modification-time/C/file-modification-time-4.c new file mode 100644 index 0000000000..609af7b022 --- /dev/null +++ b/Task/File-modification-time/C/file-modification-time-4.c @@ -0,0 +1,107 @@ +#include +#include +#include +#include + +/* Print "message: last Win32 error" to stderr. */ +void +oops(const wchar_t *message) +{ + wchar_t *buf; + DWORD error; + + buf = NULL; + error = GetLastError(); + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, error, 0, (wchar_t *)&buf, 0, NULL); + + if (buf) { + fwprintf(stderr, L"%ls: %ls", message, buf); + LocalFree(buf); + } else { + /* FormatMessageW failed. */ + fwprintf(stderr, L"%ls: unknown error 0x%x\n", + message, error); + } +} + +int +setmodtime(const wchar_t *path) +{ + FILETIME modtime; + SYSTEMTIME st; + HANDLE fh; + wchar_t date[80], time[80]; + + fh = CreateFileW(path, GENERIC_READ | FILE_WRITE_ATTRIBUTES, + 0, NULL, OPEN_EXISTING, 0, NULL); + if (fh == INVALID_HANDLE_VALUE) { + oops(path); + return 1; + } + + /* + * Use GetFileTime() to get the file modification time. + */ + if (GetFileTime(fh, NULL, NULL, &modtime) == 0) + goto fail; + FileTimeToSystemTime(&modtime, &st); + if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, + date, sizeof date / sizeof date[0]) == 0 || + GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, + time, sizeof time / sizeof time[0]) == 0) + goto fail; + wprintf(L"%ls: Last modified at %s at %s (UTC).\n", + path, date, time); + + /* + * Use SetFileTime() to change the file modification time + * to the current time. + */ + GetSystemTime(&st); + if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, + date, sizeof date / sizeof date[0]) == 0 || + GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, + time, sizeof time / sizeof time[0]) == 0) + goto fail; + SystemTimeToFileTime(&st, &modtime); + if (SetFileTime(fh, NULL, NULL, &modtime) == 0) + goto fail; + wprintf(L"%ls: Changed to %s at %s (UTC).\n", path, date, time); + + CloseHandle(fh); + return 0; + +fail: + oops(path); + CloseHandle(fh); + return 1; +} + +/* + * Show the file modification time, and change it to the current time. + */ +int +main() +{ + int argc, i, r; + wchar_t **argv; + + /* MinGW never provides wmain(argc, argv). */ + argv = CommandLineToArgvW(GetCommandLineW(), &argc); + if (argv == NULL) { + oops(L"CommandLineToArgvW"); + exit(1); + } + + if (argc < 2) { + fwprintf(stderr, L"usage: %ls file...\n", argv[0]); + exit(1); + } + + r = 0; + for (i = 1; argv[i] != NULL; i++) + if (setmodtime(argv[i])) r = 1; + return r; +} diff --git a/Task/File-modification-time/Clojure/file-modification-time.clj b/Task/File-modification-time/Clojure/file-modification-time.clj new file mode 100644 index 0000000000..267765d28e --- /dev/null +++ b/Task/File-modification-time/Clojure/file-modification-time.clj @@ -0,0 +1,8 @@ +(import '(java.io File) + '(java.util Date)) + +(Date. (.lastModified (File. "output.txt"))) +(Date. (.lastModified (File. "docs"))) + +(.setLastModified (File. "output.txt") + (.lastModified (File. "docs"))) diff --git a/Task/File-modification-time/Common-Lisp/file-modification-time-1.lisp b/Task/File-modification-time/Common-Lisp/file-modification-time-1.lisp new file mode 100644 index 0000000000..8e157ce353 --- /dev/null +++ b/Task/File-modification-time/Common-Lisp/file-modification-time-1.lisp @@ -0,0 +1 @@ +(file-write-date "input.txt") diff --git a/Task/File-modification-time/Common-Lisp/file-modification-time-2.lisp b/Task/File-modification-time/Common-Lisp/file-modification-time-2.lisp new file mode 100644 index 0000000000..32c353282a --- /dev/null +++ b/Task/File-modification-time/Common-Lisp/file-modification-time-2.lisp @@ -0,0 +1,6 @@ +(let* ((filename "input.txt") + (stat (sb-posix:stat filename)) + (mtime (sb-posix:stat-mtime stat))) + (sb-posix:utime filename + (sb-posix:stat-atime stat) + (sb-posix:time))) diff --git a/Task/File-modification-time/D/file-modification-time.d b/Task/File-modification-time/D/file-modification-time.d new file mode 100644 index 0000000000..f98b118135 --- /dev/null +++ b/Task/File-modification-time/D/file-modification-time.d @@ -0,0 +1,10 @@ +import std.stdio; +import std.file: getTimes, setTimes, SysTime; + +void main() { + auto fname = "unixdict.txt"; + SysTime fileAccessTime, fileModificationTime; + getTimes(fname, fileAccessTime, fileModificationTime); + writeln(fileAccessTime, "\n", fileModificationTime); + setTimes(fname, fileAccessTime, fileModificationTime); +} diff --git a/Task/File-modification-time/Delphi/file-modification-time.delphi b/Task/File-modification-time/Delphi/file-modification-time.delphi new file mode 100644 index 0000000000..aeb29d35eb --- /dev/null +++ b/Task/File-modification-time/Delphi/file-modification-time.delphi @@ -0,0 +1,16 @@ +procedure GetModifiedDate(const aFilename: string): TDateTime; +var + hFile: Integer; + iDosTime: Integer; +begin + hFile := FileOpen(aFilename, fmOpenRead); + iDosTime := FileGetDate(hFile); + FileClose(hFile); + if (hFile = -1) or (iDosTime = -1) then raise Exception.Create('Cannot read file: ' + sFilename); + Result := FileDateToDateTime(iDosTime); +end; + +procedure ChangeModifiedDate(const aFilename: string; aDateTime: TDateTime); +begin + FileSetDate(aFileName, DateTimeToFileDate(aDateTime)); +end; diff --git a/Task/File-modification-time/E/file-modification-time.e b/Task/File-modification-time/E/file-modification-time.e new file mode 100644 index 0000000000..db7320274f --- /dev/null +++ b/Task/File-modification-time/E/file-modification-time.e @@ -0,0 +1,16 @@ +def strdate(date) { + return E.toString((date)) +} + +def test(type, file) { + def t := file.lastModified() + println(`The following $type called ${file.getPath()} ${ + if (t == 0) { "does not exist." } else { `was modified at ${strdate(t)}` }}`) + println(`The following $type called ${file.getPath()} ${ + escape ne { file.setLastModified(timer.now(), ne); "was modified to current time." } catch _ { "does not exist." }}`) + println(`The following $type called ${file.getPath()} ${ + escape ne { file.setLastModified(t, ne); "was modified to previous time." } catch _ { "does not exist." }}`) +} + +test("file", ) +test("directory", ) diff --git a/Task/File-modification-time/Factor/file-modification-time-1.factor b/Task/File-modification-time/Factor/file-modification-time-1.factor new file mode 100644 index 0000000000..49d63d4af5 --- /dev/null +++ b/Task/File-modification-time/Factor/file-modification-time-1.factor @@ -0,0 +1 @@ +"foo.txt" file-info modified>> . diff --git a/Task/File-modification-time/Factor/file-modification-time-2.factor b/Task/File-modification-time/Factor/file-modification-time-2.factor new file mode 100644 index 0000000000..d5a152f71c --- /dev/null +++ b/Task/File-modification-time/Factor/file-modification-time-2.factor @@ -0,0 +1,3 @@ +USE: io.files.info.unix + +"foo.txt" now 2 hours time+ set-file-modified-time diff --git a/Task/File-modification-time/GUISS/file-modification-time.guiss b/Task/File-modification-time/GUISS/file-modification-time.guiss new file mode 100644 index 0000000000..15ee065262 --- /dev/null +++ b/Task/File-modification-time/GUISS/file-modification-time.guiss @@ -0,0 +1 @@ +Start,My Documents,Rightclick:Icon:Foobar.txt,Properties diff --git a/Task/File-modification-time/Go/file-modification-time.go b/Task/File-modification-time/Go/file-modification-time.go new file mode 100644 index 0000000000..b6d52a1cad --- /dev/null +++ b/Task/File-modification-time/Go/file-modification-time.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" + "syscall" + "time" +) + +var filename = "input.txt" + +func main() { + foo, err := os.Stat(filename) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("mod time was:", foo.ModTime()) + mtime := time.Now() + atime := mtime // a default, because os.Chtimes has an atime parameter. + // but see if there's a real atime that we can preserve. + if ss, ok := foo.Sys().(*syscall.Stat_t); ok { + atime = time.Unix(ss.Atim.Sec, ss.Atim.Nsec) + } + os.Chtimes(filename, atime, mtime) + fmt.Println("mod time now:", mtime) +} diff --git a/Task/File-modification-time/Haskell/file-modification-time-1.hs b/Task/File-modification-time/Haskell/file-modification-time-1.hs new file mode 100644 index 0000000000..6adf155216 --- /dev/null +++ b/Task/File-modification-time/Haskell/file-modification-time-1.hs @@ -0,0 +1,9 @@ +import System.Posix.Files +import System.Posix.Time + +do status <- getFileStatus filename + let atime = accessTime status + mtime = modificationTime status -- seconds since the epoch + curTime <- epochTime + setFileTimes filename atime curTime -- keep atime unchanged + -- set mtime to current time diff --git a/Task/File-modification-time/Haskell/file-modification-time-2.hs b/Task/File-modification-time/Haskell/file-modification-time-2.hs new file mode 100644 index 0000000000..2f0ee28394 --- /dev/null +++ b/Task/File-modification-time/Haskell/file-modification-time-2.hs @@ -0,0 +1,6 @@ +import System.Directory +import System.Time + +do ct <- getModificationTime filename + cal <- toCalendarTime ct + putStrLn (calendarTimeToString cal) diff --git a/Task/File-modification-time/HicEst/file-modification-time.hicest b/Task/File-modification-time/HicEst/file-modification-time.hicest new file mode 100644 index 0000000000..24e76cf28f --- /dev/null +++ b/Task/File-modification-time/HicEst/file-modification-time.hicest @@ -0,0 +1,7 @@ +CHARACTER timestamp*18 + +timestamp = ' ' ! blank timestamp will read: +SYSTEM(FIle="File_modification_time.hic", FileTime=timestamp) ! 20100320141940.525 + +timestamp = '19991231235950' ! set timestamp to Millenium - 10 seconds +SYSTEM(FIle="File_modification_time.hic", FileTime=timestamp) diff --git a/Task/File-modification-time/Icon/file-modification-time.icon b/Task/File-modification-time/Icon/file-modification-time.icon new file mode 100644 index 0000000000..c3cc9071ab --- /dev/null +++ b/Task/File-modification-time/Icon/file-modification-time.icon @@ -0,0 +1,9 @@ +every dir := !["./","/"] do { + if i := stat(f := dir || "input.txt") then { + write("info for ",f ," mtime= ",ctime(i.mtime),", atime=",ctime(i.ctime), ", atime=",ctime(i.atime)) + utime(f,i.atime,i.mtime-1024) + i := stat(f) + write("update for ",f ," mtime= ",ctime(i.mtime),", atime=",ctime(i.ctime), ", atime=",ctime(i.atime)) + } + else stop("failure to stat ",f) + } diff --git a/Task/File-modification-time/J/file-modification-time.j b/Task/File-modification-time/J/file-modification-time.j new file mode 100644 index 0000000000..8519cb7818 --- /dev/null +++ b/Task/File-modification-time/J/file-modification-time.j @@ -0,0 +1,3 @@ + load 'files' + fstamp 'input.txt' +2009 8 24 20 34 30 diff --git a/Task/File-modification-time/Java/file-modification-time.java b/Task/File-modification-time/Java/file-modification-time.java new file mode 100644 index 0000000000..fa8978f550 --- /dev/null +++ b/Task/File-modification-time/Java/file-modification-time.java @@ -0,0 +1,20 @@ +import java.io.File; +import java.util.Date; +public class FileModificationTimeTest { + public static void test(String type, File file) { + long t = file.lastModified(); + System.out.println("The following " + type + " called " + file.getPath() + + (t == 0 ? " does not exist." : " was modified at " + new Date(t).toString() ) + ); + System.out.println("The following " + type + " called " + file.getPath() + + (!file.setLastModified(System.currentTimeMillis()) ? " does not exist." : " was modified to current time." ) + ); + System.out.println("The following " + type + " called " + file.getPath() + + (!file.setLastModified(t) ? " does not exist." : " was modified to previous time." ) + ); + } + public static void main(String args[]) { + test("file", new File("output.txt")); + test("directory", new File("docs")); + } +} diff --git a/Task/File-modification-time/JavaScript/file-modification-time-1.js b/Task/File-modification-time/JavaScript/file-modification-time-1.js new file mode 100644 index 0000000000..1defba87f2 --- /dev/null +++ b/Task/File-modification-time/JavaScript/file-modification-time-1.js @@ -0,0 +1,3 @@ +var fso = new ActiveXObject("Scripting.FileSystemObject"); +var f = fso.GetFile('input.txt'); +var mtime = f.DateLastModified; diff --git a/Task/File-modification-time/JavaScript/file-modification-time-2.js b/Task/File-modification-time/JavaScript/file-modification-time-2.js new file mode 100644 index 0000000000..1e1d9fd55d --- /dev/null +++ b/Task/File-modification-time/JavaScript/file-modification-time-2.js @@ -0,0 +1,2 @@ +var file = document.getElementById("fileInput").files.item(0); +var last_modified = file.lastModifiedDate; diff --git a/Task/File-modification-time/Lua/file-modification-time.lua b/Task/File-modification-time/Lua/file-modification-time.lua new file mode 100644 index 0000000000..6c8fe8ebaa --- /dev/null +++ b/Task/File-modification-time/Lua/file-modification-time.lua @@ -0,0 +1,13 @@ +require "lfs" +local attributes = lfs.attributes("input.txt") +if attributes then + print(path .. " was last modified " .. os.date("%c", attributes.modification) .. ".") + + -- set access and modification time to now ... + lfs.touch("input.txt") + + -- ... or set modification time to now, keep original access time + lfs.touch("input.txt", attributes.access, os.time()) +else + print(path .. " does not exist.") +end diff --git a/Task/File-modification-time/MATLAB/file-modification-time-1.m b/Task/File-modification-time/MATLAB/file-modification-time-1.m new file mode 100644 index 0000000000..f10745d70d --- /dev/null +++ b/Task/File-modification-time/MATLAB/file-modification-time-1.m @@ -0,0 +1,5 @@ + f = dir('output.txt'); % struct f contains file information + f.date % is string containing modification time + f.datenum % numerical format (number of days) + datestr(f.datenum) % is the same as f.date + % see also: stat, lstat diff --git a/Task/File-modification-time/MATLAB/file-modification-time-2.m b/Task/File-modification-time/MATLAB/file-modification-time-2.m new file mode 100644 index 0000000000..1e05981b6c --- /dev/null +++ b/Task/File-modification-time/MATLAB/file-modification-time-2.m @@ -0,0 +1 @@ + system('touch -t 201002032359.59 output.txt'); diff --git a/Task/File-modification-time/MAXScript/file-modification-time.max b/Task/File-modification-time/MAXScript/file-modification-time.max new file mode 100644 index 0000000000..49ecdd08c9 --- /dev/null +++ b/Task/File-modification-time/MAXScript/file-modification-time.max @@ -0,0 +1,2 @@ +-- Returns a string containing the mod date for the file, e.g. "1/29/99 1:52:05 PM" +getFileModDate "C:\myFile.txt" diff --git a/Task/File-modification-time/Mathematica/file-modification-time-1.mathematica b/Task/File-modification-time/Mathematica/file-modification-time-1.mathematica new file mode 100644 index 0000000000..5904df8fbc --- /dev/null +++ b/Task/File-modification-time/Mathematica/file-modification-time-1.mathematica @@ -0,0 +1 @@ + FileDate["file","Modification"] diff --git a/Task/File-modification-time/Mathematica/file-modification-time-2.mathematica b/Task/File-modification-time/Mathematica/file-modification-time-2.mathematica new file mode 100644 index 0000000000..6d37237b9a --- /dev/null +++ b/Task/File-modification-time/Mathematica/file-modification-time-2.mathematica @@ -0,0 +1 @@ + SetFileDate["file",date,"Modification"] diff --git a/Task/File-modification-time/Modula-3/file-modification-time-1.mod3 b/Task/File-modification-time/Modula-3/file-modification-time-1.mod3 new file mode 100644 index 0000000000..3c178b9fcf --- /dev/null +++ b/Task/File-modification-time/Modula-3/file-modification-time-1.mod3 @@ -0,0 +1,27 @@ +MODULE ModTime EXPORTS Main; + +IMPORT IO, Fmt, File, FS, Date, OSError; + +TYPE dateArray = ARRAY [0..5] OF TEXT; + +VAR + file: File.Status; + date: Date.T; + +PROCEDURE DateArray(date: Date.T): dateArray = + BEGIN + RETURN + dateArray{Fmt.Int(date.year), Fmt.Int(ORD(date.month) + 1), Fmt.Int(date.day), + Fmt.Int(date.hour), Fmt.Int(date.minute), Fmt.Int(date.second)}; + END DateArray; + +BEGIN + TRY + file := FS.Status("test.txt"); + date := Date.FromTime(file.modificationTime); + IO.Put(Fmt.FN("%s-%02s-%02s %02s:%02s:%02s", DateArray(date))); + IO.Put("\n"); + EXCEPT + | OSError.E => IO.Put("Error: Failed to get file status.\n"); + END; +END ModTime. diff --git a/Task/File-modification-time/Modula-3/file-modification-time-2.mod3 b/Task/File-modification-time/Modula-3/file-modification-time-2.mod3 new file mode 100644 index 0000000000..1c7159e109 --- /dev/null +++ b/Task/File-modification-time/Modula-3/file-modification-time-2.mod3 @@ -0,0 +1,22 @@ +MODULE SetModTime EXPORTS Main; + +IMPORT Date, FS; + +<*FATAL ANY*> + +VAR + date: Date.T; + +BEGIN + (* Set the modification time to January 1st, 1999 *) + date.year := 1999; + date.month := Date.Month.Jan; + date.day := 1; + date.hour := 0; + date.minute := 0; + date.second := 0; + date.offset := 21601; + date.zone := "CST"; + +FS.SetModificationTime("test.txt", Date.ToTime(date)); +END SetModTime. diff --git a/Task/File-modification-time/PHP/file-modification-time.php b/Task/File-modification-time/PHP/file-modification-time.php new file mode 100644 index 0000000000..398a2288fc --- /dev/null +++ b/Task/File-modification-time/PHP/file-modification-time.php @@ -0,0 +1,9 @@ + diff --git a/Task/File-modification-time/Perl/file-modification-time.pl b/Task/File-modification-time/Perl/file-modification-time.pl new file mode 100644 index 0000000000..0c8fdb2966 --- /dev/null +++ b/Task/File-modification-time/Perl/file-modification-time.pl @@ -0,0 +1,9 @@ +my $mtime = (stat($file))[9]; # seconds since the epoch + +# you should use the more legible version below: +use File::stat qw(stat); +my $mtime = stat($file)->mtime; # seconds since the epoch + +utime(stat($file)->atime, time, $file); +# keep atime unchanged +# set mtime to current time diff --git a/Task/File-modification-time/PicoLisp/file-modification-time.l b/Task/File-modification-time/PicoLisp/file-modification-time.l new file mode 100644 index 0000000000..8882154a06 --- /dev/null +++ b/Task/File-modification-time/PicoLisp/file-modification-time.l @@ -0,0 +1,5 @@ +(let File "test.file" + (and + (info File) + (prinl (stamp (cadr @) (cddr @))) ) # Print date and time in UTC + (call 'touch File) ) # Set modification time to "now" diff --git a/Task/File-modification-time/Python/file-modification-time.py b/Task/File-modification-time/Python/file-modification-time.py new file mode 100644 index 0000000000..ced62311e4 --- /dev/null +++ b/Task/File-modification-time/Python/file-modification-time.py @@ -0,0 +1,13 @@ +import os + +#Get modification time: +modtime = os.path.getmtime('filename') + +#Set the access and modification times: +os.utime('path', (actime, mtime)) + +#Set just the modification time: +os.utime('path', (os.path.getatime('path'), mtime)) + +#Set the access and modification times to the current time: +os.utime('path', None) diff --git a/Task/File-modification-time/R/file-modification-time.r b/Task/File-modification-time/R/file-modification-time.r new file mode 100644 index 0000000000..c430877c7c --- /dev/null +++ b/Task/File-modification-time/R/file-modification-time.r @@ -0,0 +1,7 @@ +# Get the value +file.info(filename)$mtime + +#To set the value, we need to rely on shell commands. The following works under windows. +shell("copy /b /v filename +,,>nul") +# and on Unix (untested) +shell("touch -m filename") diff --git a/Task/File-modification-time/Racket/file-modification-time.rkt b/Task/File-modification-time/Racket/file-modification-time.rkt new file mode 100644 index 0000000000..e15b34742f --- /dev/null +++ b/Task/File-modification-time/Racket/file-modification-time.rkt @@ -0,0 +1,2 @@ +#lang racket +(file-or-directory-modify-seconds "foo.rkt") diff --git a/Task/File-modification-time/Ruby/file-modification-time.rb b/Task/File-modification-time/Ruby/file-modification-time.rb new file mode 100644 index 0000000000..64b695c036 --- /dev/null +++ b/Task/File-modification-time/Ruby/file-modification-time.rb @@ -0,0 +1,11 @@ +#Get modification time: +modtime = File.mtime('filename') + +#Set the access and modification times: +File.utime(actime, mtime, 'path') + +#Set just the modification time: +File.utime(File.atime('path'), mtime, 'path') + +#Set the access and modification times to the current time: +File.utime(nil, nil, 'path') diff --git a/Task/File-modification-time/Smalltalk/file-modification-time.st b/Task/File-modification-time/Smalltalk/file-modification-time.st new file mode 100644 index 0000000000..0d171b3be4 --- /dev/null +++ b/Task/File-modification-time/Smalltalk/file-modification-time.st @@ -0,0 +1,3 @@ +|a| +a := File name: 'input.txt'. +(a lastModifyTime) printNl. diff --git a/Task/File-modification-time/Tcl/file-modification-time.tcl b/Task/File-modification-time/Tcl/file-modification-time.tcl new file mode 100644 index 0000000000..5350d8f0ed --- /dev/null +++ b/Task/File-modification-time/Tcl/file-modification-time.tcl @@ -0,0 +1,5 @@ +# Get the modification time: +set timestamp [file mtime $filename] + +# Set the modification time to ‘now’: +file mtime $filename [clock seconds] diff --git a/Task/File-size/0DESCRIPTION b/Task/File-size/0DESCRIPTION new file mode 100644 index 0000000000..e4d955052f --- /dev/null +++ b/Task/File-size/0DESCRIPTION @@ -0,0 +1 @@ +In this task, the job is to verify the size of a file called "input.txt" for a file in the current working directory and another one in the file system root. diff --git a/Task/File-size/1META.yaml b/Task/File-size/1META.yaml new file mode 100644 index 0000000000..40458d9f21 --- /dev/null +++ b/Task/File-size/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File System Operations diff --git a/Task/File-size/ALGOL-68/file-size.alg b/Task/File-size/ALGOL-68/file-size.alg new file mode 100644 index 0000000000..f52ca1c219 --- /dev/null +++ b/Task/File-size/ALGOL-68/file-size.alg @@ -0,0 +1 @@ +PROC set = (REF FILE file, INT page, line, character)VOID: ~ diff --git a/Task/File-size/Ada/file-size.ada b/Task/File-size/Ada/file-size.ada new file mode 100644 index 0000000000..f845ee30ce --- /dev/null +++ b/Task/File-size/Ada/file-size.ada @@ -0,0 +1,8 @@ +with Ada.Directories; use Ada.Directories; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_File_Size is +begin + Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); + Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); +end Test_File_Size; diff --git a/Task/File-size/AutoHotkey/file-size.ahk b/Task/File-size/AutoHotkey/file-size.ahk new file mode 100644 index 0000000000..b89366a599 --- /dev/null +++ b/Task/File-size/AutoHotkey/file-size.ahk @@ -0,0 +1,4 @@ +FileGetSize, FileSize, input.txt ; Retrieve the size in bytes. +MsgBox, Size of input.txt is %FileSize% bytes +FileGetSize, FileSize, \input.txt, K ; Retrieve the size in Kbytes. +MsgBox, Size of \input.txt is %FileSize% Kbytes diff --git a/Task/File-size/BBC-BASIC/file-size.bbc b/Task/File-size/BBC-BASIC/file-size.bbc new file mode 100644 index 0000000000..beaf22fe3d --- /dev/null +++ b/Task/File-size/BBC-BASIC/file-size.bbc @@ -0,0 +1,11 @@ + file% = OPENIN(@dir$+"input.txt") + IF file% THEN + PRINT "File size = " ; EXT#file% + CLOSE #file% + ENDIF + + file% = OPENIN("\input.txt") + IF file% THEN + PRINT "File size = " ; EXT#file% + CLOSE #file% + ENDIF diff --git a/Task/File-size/Bracmat/file-size.bracmat b/Task/File-size/Bracmat/file-size.bracmat new file mode 100644 index 0000000000..b268bb7fc5 --- /dev/null +++ b/Task/File-size/Bracmat/file-size.bracmat @@ -0,0 +1,14 @@ +(getFileSize= + size +. fil$(!arg,rb) {read in binary mode} + & fil$(,END) {seek to end of file} + & fil$(,TEL):?size {tell where we are} + & fil$(,SET,-1) {seeking to an impossible position closes the file, and fails} + | !size {return the size} +); + +getFileSize$"valid.bra" +113622 + +getFileSize$"c:\\boot.ini" +211 diff --git a/Task/File-size/C++/file-size.cpp b/Task/File-size/C++/file-size.cpp new file mode 100644 index 0000000000..915bae6723 --- /dev/null +++ b/Task/File-size/C++/file-size.cpp @@ -0,0 +1,16 @@ +#include +#include + +std::ios::off_type getFileSize(const char *filename) { + std::ifstream f(filename); + std::ios::pos_type begin = f.tellg(); + f.seekg(0, std::ios::end); + std::ios::pos_type end = f.tellg(); + return end - begin; +} + +int main() { + std::cout << getFileSize("input.txt") << std::endl; + std::cout << getFileSize("/input.txt") << std::endl; + return 0; +} diff --git a/Task/File-size/C/file-size-1.c b/Task/File-size/C/file-size-1.c new file mode 100644 index 0000000000..2a066da8bf --- /dev/null +++ b/Task/File-size/C/file-size-1.c @@ -0,0 +1,19 @@ +#include +#include + +long getFileSize(const char *filename) +{ + long result; + FILE *fh = fopen(filename, "rb"); + fseek(fh, 0, SEEK_END); + result = ftell(fh); + fclose(fh); + return result; +} + +int main(void) +{ + printf("%ld\n", getFileSize("input.txt")); + printf("%ld\n", getFileSize("/input.txt")); + return 0; +} diff --git a/Task/File-size/C/file-size-2.c b/Task/File-size/C/file-size-2.c new file mode 100644 index 0000000000..0f2fa31e79 --- /dev/null +++ b/Task/File-size/C/file-size-2.c @@ -0,0 +1,13 @@ +#include +#include +#include + +int main(void) +{ + struct stat foo; + stat("input.txt", &foo); + printf("%ld\n", foo.st_size); + stat("/input.txt", &foo); + printf("%ld\n", foo.st_size); + return 0; +} diff --git a/Task/File-size/Clean/file-size.clean b/Task/File-size/Clean/file-size.clean new file mode 100644 index 0000000000..9fb153d064 --- /dev/null +++ b/Task/File-size/Clean/file-size.clean @@ -0,0 +1,12 @@ +import StdEnv + +fileSize fileName world + # (ok, file, world) = fopen fileName FReadData world + | not ok = abort "Cannot open file" + # (ok, file) = fseek file 0 FSeekEnd + | not ok = abort "Cannot seek file" + # (size, file) = fposition file + (_, world) = fclose file world + = (size, world) + +Start world = fileSize "input.txt" world diff --git a/Task/File-size/Clojure/file-size.clj b/Task/File-size/Clojure/file-size.clj new file mode 100644 index 0000000000..9fc4b80b82 --- /dev/null +++ b/Task/File-size/Clojure/file-size.clj @@ -0,0 +1,6 @@ +(import '[java.io File]) +(defn show-size [filename] + (println filename "size:" (.length (File. filename)))) + +(show-size "input.txt") +(show-size "/input.txt") diff --git a/Task/File-size/ColdFusion/file-size.cfm b/Task/File-size/ColdFusion/file-size.cfm new file mode 100644 index 0000000000..eac91f8cbd --- /dev/null +++ b/Task/File-size/ColdFusion/file-size.cfm @@ -0,0 +1,9 @@ + + localFile = getFileInfo(expandpath("input.txt")); + rootFile = getFileInfo("/input.txt"); + + + + Size of input.txt is #localFile.size# bytes. + Size of /input.txt is #rootFile.size# bytes. + diff --git a/Task/File-size/Common-Lisp/file-size.lisp b/Task/File-size/Common-Lisp/file-size.lisp new file mode 100644 index 0000000000..3f20b40c8f --- /dev/null +++ b/Task/File-size/Common-Lisp/file-size.lisp @@ -0,0 +1,9 @@ +(with-open-file (stream (make-pathname :name "input.txt") + :direction :input + :if-does-not-exist nil) + (print (if stream (file-length stream) 0))) + +(with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") + :direction :input + :if-does-not-exist nil) + (print (if stream (file-length stream) 0))) diff --git a/Task/File-size/D/file-size-1.d b/Task/File-size/D/file-size-1.d new file mode 100644 index 0000000000..ec974a572a --- /dev/null +++ b/Task/File-size/D/file-size-1.d @@ -0,0 +1,5 @@ +import std.file; + +void main() { + auto len = getSize("data.txt"); +} diff --git a/Task/File-size/D/file-size-2.d b/Task/File-size/D/file-size-2.d new file mode 100644 index 0000000000..2afe352248 --- /dev/null +++ b/Task/File-size/D/file-size-2.d @@ -0,0 +1,35 @@ +import std.stdio, std.path, std.file, std.stream; +// NB: mmfile can treat the file as an array in memory +import std.mmfile; + +string[] generateTwoNames(string name) { + string cwd = curdir ~ sep; // on current directory + string root = sep; // on root + + // remove path, left only basename + name = std.path.getBaseName(name); + + // NB: in D ver.2, getBaseName is alias of basename + return [cwd ~ name, root ~ name]; +} + +void testsize(string fileName1) { + foreach (fileName2; generateTwoNames(fileName1)) { + try { + writefln("File %s has size:", fileName2); + writefln("%10d bytes by std.file.getSize (function),", + std.file.getSize(fileName2)); + writefln("%10d bytes by std.stream (class),", + (new std.stream.File(fileName2)).size); + writefln("%10d bytes by std.mmfile (class).", + (new std.mmfile.MmFile(fileName2)).length); + } catch (Exception e) { + writefln(e.msg); + } + writeln(); + } +} + +void main() { + testsize(r"input.txt"); +} diff --git a/Task/File-size/Delphi/file-size.delphi b/Task/File-size/Delphi/file-size.delphi new file mode 100644 index 0000000000..24d8b81b16 --- /dev/null +++ b/Task/File-size/Delphi/file-size.delphi @@ -0,0 +1,21 @@ +program SizeOfFile; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +function CheckFileSize(const aFilename: string): Integer; +var + lFile: file of Byte; +begin + AssignFile(lFile, aFilename); + FileMode := 0; {Access file in read only mode} + Reset(lFile); + Result := FileSize(lFile); + CloseFile(lFile); +end; + +begin + Writeln('input.txt ', CheckFileSize('input.txt')); + Writeln('\input.txt ', CheckFileSize('\input.txt')); +end. diff --git a/Task/File-size/E/file-size.e b/Task/File-size/E/file-size.e new file mode 100644 index 0000000000..f850a246e7 --- /dev/null +++ b/Task/File-size/E/file-size.e @@ -0,0 +1,3 @@ +for file in [, ] { + println(`The size of $file is ${file.length()} bytes.`) +} diff --git a/Task/File-size/Eiffel/file-size.e b/Task/File-size/Eiffel/file-size.e new file mode 100644 index 0000000000..b1f0ac361d --- /dev/null +++ b/Task/File-size/Eiffel/file-size.e @@ -0,0 +1,21 @@ +class + APPLICATION +create + make +feature {NONE} -- Initialization + make + -- Run application. + do + create input_file.make_open_read ("input.txt") + print(input_file.count) + print("%N") + input_file.close + create environment + input_file.make_open_read(environment.root_directory_name + "input.txt") + print(input_file.count) + input_file.close + end +feature -- Access + input_file: PLAIN_TEXT_FILE + environment:EXECUTION_ENVIRONMENT +end diff --git a/Task/File-size/Erlang/file-size.erl b/Task/File-size/Erlang/file-size.erl new file mode 100644 index 0000000000..fee39d2f56 --- /dev/null +++ b/Task/File-size/Erlang/file-size.erl @@ -0,0 +1,16 @@ +-module(file_size). +-export([file_size/0]). + +-include_lib("kernel/include/file.hrl"). + +file_size() -> + print_file_size("input.txt"), + print_file_size("/input.txt"). + +print_file_size(Filename) -> + case file:read_file_info(Filename) of + {ok, FileInfo} -> + io:format("~s ~p~n", [Filename, FileInfo#file_info.size]); + {error, _} -> + io:format("~s could not be opened~n",[Filename]) + end. diff --git a/Task/File-size/Euphoria/file-size.euphoria b/Task/File-size/Euphoria/file-size.euphoria new file mode 100644 index 0000000000..307dfa9741 --- /dev/null +++ b/Task/File-size/Euphoria/file-size.euphoria @@ -0,0 +1,24 @@ +include file.e + +function file_size(sequence file_name) + object x + x = dir(file_name) + if sequence(x) and length(x) = 1 then + return x[1][D_SIZE] + else + return -1 -- the file does not exist + end if +end function + +procedure test(sequence file_name) + integer size + size = file_size(file_name) + if size < 0 then + printf(1,"%s file does not exist.\n",{file_name}) + else + printf(1,"%s size is %d.\n",{file_name,size}) + end if +end procedure + +test("input.txt") -- in the current working directory +test("/input.txt") -- in the file system root diff --git a/Task/File-size/Factor/file-size.factor b/Task/File-size/Factor/file-size.factor new file mode 100644 index 0000000000..5d7d147096 --- /dev/null +++ b/Task/File-size/Factor/file-size.factor @@ -0,0 +1,4 @@ +"input.txt" file-info size>> . + 1321 +"file-does-not-exist.txt" file-info size>> + "Unix system call ``stat'' failed:"... diff --git a/Task/File-size/Forth/file-size.fth b/Task/File-size/Forth/file-size.fth new file mode 100644 index 0000000000..29fcd1576d --- /dev/null +++ b/Task/File-size/Forth/file-size.fth @@ -0,0 +1,7 @@ +: .filesize ( addr len -- ) 2dup type ." is " + r/o open-file throw + dup file-size throw <# #s #> type ." bytes long." cr + close-file throw ; + + s" input.txt" .filesize +s" /input.txt" .filesize diff --git a/Task/File-size/Go/file-size.go b/Task/File-size/Go/file-size.go new file mode 100644 index 0000000000..8b82412915 --- /dev/null +++ b/Task/File-size/Go/file-size.go @@ -0,0 +1,17 @@ +package main + +import "fmt" +import "os" + +func printFileSize(f string) { + if stat, err := os.Stat(f); err != nil { + fmt.Println(err) + } else { + fmt.Println(stat.Size()) + } +} + +func main() { + printFileSize("input.txt") + printFileSize("/input.txt") +} diff --git a/Task/File-size/Groovy/file-size.groovy b/Task/File-size/Groovy/file-size.groovy new file mode 100644 index 0000000000..54c3c5dcd0 --- /dev/null +++ b/Task/File-size/Groovy/file-size.groovy @@ -0,0 +1,2 @@ +println new File('index.txt').length(); +println new File('/index.txt').length(); diff --git a/Task/File-size/Haskell/file-size-1.hs b/Task/File-size/Haskell/file-size-1.hs new file mode 100644 index 0000000000..779d32578f --- /dev/null +++ b/Task/File-size/Haskell/file-size-1.hs @@ -0,0 +1,5 @@ +import System.IO + +printFileSize filename = withFile filename ReadMode hFileSize >>= print + +main = mapM_ printFileSize ["input.txt", "/input.txt"] diff --git a/Task/File-size/Haskell/file-size-2.hs b/Task/File-size/Haskell/file-size-2.hs new file mode 100644 index 0000000000..c224311283 --- /dev/null +++ b/Task/File-size/Haskell/file-size-2.hs @@ -0,0 +1,6 @@ +import System.Posix.File + +printFileSize filename = do stat <- getFileStatus filename + print (fileSize stat) + +main = mapM_ printFileSize ["input.txt", "/input.txt"] diff --git a/Task/File-size/HicEst/file-size.hicest b/Task/File-size/HicEst/file-size.hicest new file mode 100644 index 0000000000..0a9add89ec --- /dev/null +++ b/Task/File-size/HicEst/file-size.hicest @@ -0,0 +1,2 @@ +READ(FILE="input.txt", LENgth=bytes) ! bytes = -1 if not existent +READ(FILE="C:\input.txt", LENgth=bytes) ! bytes = -1 if not existent diff --git a/Task/File-size/Icon/file-size.icon b/Task/File-size/Icon/file-size.icon new file mode 100644 index 0000000000..f4bf3b4eae --- /dev/null +++ b/Task/File-size/Icon/file-size.icon @@ -0,0 +1,3 @@ +every dir := !["./","/"] do { + write("Size of ",f := dir || "input.txt"," = ",stat(f).size) |stop("failure for to stat ",f) + } diff --git a/Task/File-size/J/file-size.j b/Task/File-size/J/file-size.j new file mode 100644 index 0000000000..8518d4fd75 --- /dev/null +++ b/Task/File-size/J/file-size.j @@ -0,0 +1,2 @@ +require 'files' +fsize 'input.txt';'/input.txt' diff --git a/Task/File-size/Java/file-size.java b/Task/File-size/Java/file-size.java new file mode 100644 index 0000000000..01f34a742e --- /dev/null +++ b/Task/File-size/Java/file-size.java @@ -0,0 +1,10 @@ +import java.io.File; + +public class FileSize +{ + public static void main ( String[] args ) + { + System.out.println("input.txt : " + new File("input.txt").length() + " bytes"); + System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); + } +} diff --git a/Task/File-size/JavaScript/file-size-1.js b/Task/File-size/JavaScript/file-size-1.js new file mode 100644 index 0000000000..77aee13560 --- /dev/null +++ b/Task/File-size/JavaScript/file-size-1.js @@ -0,0 +1,3 @@ +var fso = new ActiveXObject("Scripting.FileSystemObject"); +fso.GetFile('input.txt').Size; +fso.GetFile('c:/input.txt').Size; diff --git a/Task/File-size/JavaScript/file-size-2.js b/Task/File-size/JavaScript/file-size-2.js new file mode 100644 index 0000000000..f5ca071cd4 --- /dev/null +++ b/Task/File-size/JavaScript/file-size-2.js @@ -0,0 +1,14 @@ +var file = document.getElementById("fileInput").files.item(0); //a file input element +if (file) { + var reader = new FileReader(); + reader.readAsText(file, "UTF-8"); + reader.onload = loadedFile; + reader.onerror = errorHandler; +} +function loadedFile(event) { + var fileString = event.target.result; + alert(fileString.length); +} +function errorHandler(event) { + alert(event); +} diff --git a/Task/File-size/K/file-size.k b/Task/File-size/K/file-size.k new file mode 100644 index 0000000000..595fb1cf33 --- /dev/null +++ b/Task/File-size/K/file-size.k @@ -0,0 +1,2 @@ +_size "input.txt" +_size "/input.txt" diff --git a/Task/File-size/Liberty-BASIC/file-size.liberty b/Task/File-size/Liberty-BASIC/file-size.liberty new file mode 100644 index 0000000000..9d72f10f51 --- /dev/null +++ b/Task/File-size/Liberty-BASIC/file-size.liberty @@ -0,0 +1,9 @@ +'input.txt in current directory +OPEN DefaultDir$ + "/input.txt" FOR input AS #m +PRINT "File size: "; lof(#m) +CLOSE #m + +'input.txt in root +OPEN "c:/input.txt" FOR input AS #m +PRINT "File size: "; lof(#m) +CLOSE #m diff --git a/Task/File-size/Lua/file-size.lua b/Task/File-size/Lua/file-size.lua new file mode 100644 index 0000000000..0496ba10c3 --- /dev/null +++ b/Task/File-size/Lua/file-size.lua @@ -0,0 +1,9 @@ +function GetFileSize( filename ) + local fp = io.open( filename ) + if fp == nil then + return nil + end + local filesize = fp:seek( "end" ) + fp:close() + return filesize +end diff --git a/Task/File-size/MATLAB/file-size.m b/Task/File-size/MATLAB/file-size.m new file mode 100644 index 0000000000..42920687d9 --- /dev/null +++ b/Task/File-size/MATLAB/file-size.m @@ -0,0 +1,4 @@ +d1 = dir('input.txt'); +d2 = dir('/input.txt'); +fprintf('Size of input.txt is %d bytes\n', d1.bytes) +fprintf('Size of /input.txt is %d bytes\n', d2.bytes) diff --git a/Task/File-size/MAXScript/file-size.max b/Task/File-size/MAXScript/file-size.max new file mode 100644 index 0000000000..2990da359e --- /dev/null +++ b/Task/File-size/MAXScript/file-size.max @@ -0,0 +1,3 @@ +-- Returns filesize in bytes or 0 if the file is missing +getFileSize "index.txt" +getFileSize "\index.txt" diff --git a/Task/File-size/Mathematica/file-size.mathematica b/Task/File-size/Mathematica/file-size.mathematica new file mode 100644 index 0000000000..5d28e8ec6e --- /dev/null +++ b/Task/File-size/Mathematica/file-size.mathematica @@ -0,0 +1,2 @@ +FileByteCount["input.txt"] +FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]] diff --git a/Task/File-size/Mirah/file-size.mirah b/Task/File-size/Mirah/file-size.mirah new file mode 100644 index 0000000000..4baaa14a7b --- /dev/null +++ b/Task/File-size/Mirah/file-size.mirah @@ -0,0 +1,4 @@ +import java.io.File + +puts File.new('file-size.mirah').length() +puts File.new("./#{File.separator}file-size.mirah").length() diff --git a/Task/File-size/Modula-3/file-size.mod3 b/Task/File-size/Modula-3/file-size.mod3 new file mode 100644 index 0000000000..0a2238cd88 --- /dev/null +++ b/Task/File-size/Modula-3/file-size.mod3 @@ -0,0 +1,16 @@ +MODULE FSize EXPORTS Main; + +IMPORT IO, Fmt, FS, File, OSError; + +VAR fstat: File.Status; + +BEGIN + TRY + fstat := FS.Status("input.txt"); + IO.Put("Size of input.txt: " & Fmt.LongInt(fstat.size) & "\n"); + fstat := FS.Status("/input.txt"); + IO.Put("Size of /input.txt: " & Fmt.LongInt(fstat.size) & "\n"); + EXCEPT + | OSError.E => IO.Put("ERROR: Could not get file status.\n"); + END; +END FSize. diff --git a/Task/File-size/PHP/file-size.php b/Task/File-size/PHP/file-size.php new file mode 100644 index 0000000000..ca29e5da61 --- /dev/null +++ b/Task/File-size/PHP/file-size.php @@ -0,0 +1,4 @@ + diff --git a/Task/File-size/Perl/file-size.pl b/Task/File-size/Perl/file-size.pl new file mode 100644 index 0000000000..216e107f5e --- /dev/null +++ b/Task/File-size/Perl/file-size.pl @@ -0,0 +1,3 @@ +use File::Spec::Functions qw(catfile rootdir); +print -s 'input.txt'; +print -s catfile rootdir, 'input.txt'; diff --git a/Task/File-size/PicoLisp/file-size.l b/Task/File-size/PicoLisp/file-size.l new file mode 100644 index 0000000000..cc599c440d --- /dev/null +++ b/Task/File-size/PicoLisp/file-size.l @@ -0,0 +1,2 @@ +(println (car (info "input.txt"))) +(println (car (info "/input.txt"))) diff --git a/Task/File-size/Python/file-size.py b/Task/File-size/Python/file-size.py new file mode 100644 index 0000000000..26c826ee61 --- /dev/null +++ b/Task/File-size/Python/file-size.py @@ -0,0 +1,4 @@ +import os + +size = os.path.getsize('input.txt') +size = os.path.getsize('/input.txt') diff --git a/Task/File-size/R/file-size.r b/Task/File-size/R/file-size.r new file mode 100644 index 0000000000..2681efb192 --- /dev/null +++ b/Task/File-size/R/file-size.r @@ -0,0 +1,2 @@ +sizeinwd <- file.info('input.txt')[["size"]] +sizeinroot <- file.info('/input.txt')[["size"]] diff --git a/Task/File-size/REXX/file-size.rexx b/Task/File-size/REXX/file-size.rexx new file mode 100644 index 0000000000..842fac6e63 --- /dev/null +++ b/Task/File-size/REXX/file-size.rexx @@ -0,0 +1,13 @@ +/*REXX pgm to verify a file's size (by reading the lines) in CD & root. */ +parse arg iFID . /*let user specify the file ID. */ +if iFID=='' then iFID='FILESIZ.DAT' /*Not specified? Then use default*/ +say 'size of' iFID '=' filesize(iFID) /*current directory.*/ +say 'size of \..\'iFID '=' filesize('\..\'iFID) /* root directory.*/ +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────FILESIZE subroutine─────────────────*/ +filesize: parse arg f + do r=1 while lines(f)\==0 + call linein f + end /*r*/ +return r-1 diff --git a/Task/File-size/Ruby/file-size.rb b/Task/File-size/Ruby/file-size.rb new file mode 100644 index 0000000000..70127ca9b7 --- /dev/null +++ b/Task/File-size/Ruby/file-size.rb @@ -0,0 +1,2 @@ +size = File.size('input.txt') +size = File.size('/input.txt') diff --git a/Task/File-size/Scheme/file-size.ss b/Task/File-size/Scheme/file-size.ss new file mode 100644 index 0000000000..e7573fa09e --- /dev/null +++ b/Task/File-size/Scheme/file-size.ss @@ -0,0 +1,10 @@ +(define (file-size filename) + (call-with-input-file filename (lambda (port) + (let loop ((c (read-char port)) + (count 0)) + (if (eof-object? c) + count + (loop (read-char port) (+ 1 count))))))) + +(file-size "input.txt") +(file-size "/input.txt") diff --git a/Task/File-size/Smalltalk/file-size-1.st b/Task/File-size/Smalltalk/file-size-1.st new file mode 100644 index 0000000000..ad598bb95a --- /dev/null +++ b/Task/File-size/Smalltalk/file-size-1.st @@ -0,0 +1,2 @@ +(File name: 'input.txt') size printNl. +(File name: '/input.txt') size printNl. diff --git a/Task/File-size/Smalltalk/file-size-2.st b/Task/File-size/Smalltalk/file-size-2.st new file mode 100644 index 0000000000..f71c195fe1 --- /dev/null +++ b/Task/File-size/Smalltalk/file-size-2.st @@ -0,0 +1,2 @@ +'input.txt' asFilename fileSize +'/input.txt' asFilename fileSize diff --git a/Task/File-size/Tcl/file-size.tcl b/Task/File-size/Tcl/file-size.tcl new file mode 100644 index 0000000000..6ef6cdc05d --- /dev/null +++ b/Task/File-size/Tcl/file-size.tcl @@ -0,0 +1,2 @@ +file size input.txt +file size /input.txt diff --git a/Task/Filter/0DESCRIPTION b/Task/Filter/0DESCRIPTION new file mode 100644 index 0000000000..b9c54df2db --- /dev/null +++ b/Task/Filter/0DESCRIPTION @@ -0,0 +1,3 @@ +Select certain elements from an Array into a new Array in a generic way. To demonstrate, select all even numbers from an Array. + +As an option, give a second solution which filters destructively, by modifying the original Array rather than creating a new Array. diff --git a/Task/Filter/1META.yaml b/Task/Filter/1META.yaml new file mode 100644 index 0000000000..ee6dd6cc2e --- /dev/null +++ b/Task/Filter/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Iteration +note: Basic language learning diff --git a/Task/Filter/ACL2/filter.acl2 b/Task/Filter/ACL2/filter.acl2 new file mode 100644 index 0000000000..d54f61c980 --- /dev/null +++ b/Task/Filter/ACL2/filter.acl2 @@ -0,0 +1,5 @@ +(defun filter-evens (xs) + (cond ((endp xs) nil) + ((evenp (first xs)) + (cons (first xs) (filter-evens (rest xs)))) + (t (filter-evens (rest xs))))) diff --git a/Task/Filter/ALGOL-68/filter.alg b/Task/Filter/ALGOL-68/filter.alg new file mode 100644 index 0000000000..e535feab0b --- /dev/null +++ b/Task/Filter/ALGOL-68/filter.alg @@ -0,0 +1,23 @@ +MODE TYPE = INT; + +PROC select = ([]TYPE from, PROC(TYPE)BOOL where)[]TYPE: +BEGIN + FLEX[0]TYPE result; + FOR key FROM LWB from TO UPB from DO + IF where(from[key]) THEN + [UPB result+1]TYPE new result; + new result[:UPB result] := result; + new result[UPB new result] := from[key]; + result := new result + FI + OD; + result +END; + +[]TYPE from values = (1,2,3,4,5,6,7,8,9,10); +PROC where even = (TYPE value)BOOL: NOT ODD value; + +print((select(from values, where even), new line)); + +# Or as a simple one line query # +print((select((1,4,9,16,25,36,49,64,81,100), (TYPE x)BOOL: NOT ODD x ), new line)) diff --git a/Task/Filter/AWK/filter.awk b/Task/Filter/AWK/filter.awk new file mode 100644 index 0000000000..031ef1b442 --- /dev/null +++ b/Task/Filter/AWK/filter.awk @@ -0,0 +1,2 @@ +$ awk 'BEGIN{split("1 2 3 4 5 6 7 8 9",a);for(i in a)if(!(a[i]%2))r=r" "a[i];print r}' +4 6 8 2 diff --git a/Task/Filter/ActionScript/filter.as b/Task/Filter/ActionScript/filter.as new file mode 100644 index 0000000000..5b4ce714c0 --- /dev/null +++ b/Task/Filter/ActionScript/filter.as @@ -0,0 +1,6 @@ +var arr:Array = new Array(1, 2, 3, 4, 5); +var evens:Array = new Array(); +for (var i:int = 0; i < arr.length(); i++) { + if (arr[i] % 2 == 0) + evens.push(arr[i]); +} diff --git a/Task/Filter/Ada/filter-1.ada b/Task/Filter/Ada/filter-1.ada new file mode 100644 index 0000000000..3c72c5c6c0 --- /dev/null +++ b/Task/Filter/Ada/filter-1.ada @@ -0,0 +1,32 @@ +with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Array_Selection is + type Array_Type is array (Positive range <>) of Integer; + Null_Array : Array_Type(1..0); + + function Evens (Item : Array_Type) return Array_Type is + begin + if Item'Length > 0 then + if Item(Item'First) mod 2 = 0 then + return Item(Item'First) & Evens(Item((Item'First + 1)..Item'Last)); + else + return Evens(Item((Item'First + 1)..Item'Last)); + end if; + else + return Null_Array; + end if; + end Evens; + + procedure Print(Item : Array_Type) is + begin + for I in Item'range loop + Put(Item(I)); + New_Line; + end loop; + end Print; + + Foo : Array_Type := (1,2,3,4,5,6,7,8,9,10); +begin + Print(Evens(Foo)); +end Array_Selection; diff --git a/Task/Filter/Ada/filter-2.ada b/Task/Filter/Ada/filter-2.ada new file mode 100644 index 0000000000..b031a1ddd2 --- /dev/null +++ b/Task/Filter/Ada/filter-2.ada @@ -0,0 +1,28 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Array_Selection is + type Array_Type is array (Positive range <>) of Integer; + + function Evens (Item : Array_Type) return Array_Type is + Result : Array_Type (1..Item'Length); + Index : Positive := 1; + begin + for I in Item'Range loop + if Item (I) mod 2 = 0 then + Result (Index) := Item (I); + Index := Index + 1; + end if; + end loop; + return Result (1..Index - 1); + end Evens; + + procedure Put (Item : Array_Type) is + begin + for I in Item'range loop + Put (Integer'Image (Item (I))); + end loop; + end Put; +begin + Put (Evens ((1,2,3,4,5,6,7,8,9,10))); + New_Line; +end Array_Selection; diff --git a/Task/Filter/AmigaE/filter.amiga b/Task/Filter/AmigaE/filter.amiga new file mode 100644 index 0000000000..f50fe3cf9f --- /dev/null +++ b/Task/Filter/AmigaE/filter.amiga @@ -0,0 +1,7 @@ +PROC main() + DEF l : PTR TO LONG, r : PTR TO LONG, x + l := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + r := List(ListLen(l)) + SelectList({x}, l, r, `Mod(x,2)=0) + ForAll({x}, r, `WriteF('\d\n', x)) +ENDPROC diff --git a/Task/Filter/AppleScript/filter-1.applescript b/Task/Filter/AppleScript/filter-1.applescript new file mode 100644 index 0000000000..79f9e919a4 --- /dev/null +++ b/Task/Filter/AppleScript/filter-1.applescript @@ -0,0 +1,6 @@ +set array to {1, 2, 3, 4, 5, 6} +set evens to {} +repeat with i in array + if (i mod 2 = 0) then set end of evens to i's contents +end repeat +return evens diff --git a/Task/Filter/AppleScript/filter-2.applescript b/Task/Filter/AppleScript/filter-2.applescript new file mode 100644 index 0000000000..80f56802c2 --- /dev/null +++ b/Task/Filter/AppleScript/filter-2.applescript @@ -0,0 +1,17 @@ +to filter(inList, acceptor) + set outList to {} + repeat with anItem in inList + if acceptor's accept(anItem) then + set end of outList to contents of anItem + end + end + return outList +end + +script isEven + to accept(aNumber) + aNumber mod 2 = 0 + end accept +end script + +filter({1,2,3,4,5,6}, isEven) diff --git a/Task/Filter/AutoHotkey/filter.ahk b/Task/Filter/AutoHotkey/filter.ahk new file mode 100644 index 0000000000..fbac46c554 --- /dev/null +++ b/Task/Filter/AutoHotkey/filter.ahk @@ -0,0 +1,49 @@ +array = 1,2,3,4,5,6,7 +loop, parse, array, `, +{ + if IsEven(A_LoopField) + evens = %evens%,%A_LoopField% +} +stringtrimleft, evens, evens, 1 +msgbox % evens +return + +IsEven(number) +{ + return !mod(number, 2) +} + + +; ----- Another version: always with csv string ------ +array = 1,2,3,4,5,6,7 + +even(s) { + loop, parse, s, `, + if !mod(A_LoopField, 2) + r .= "," A_LoopField + return SubStr(r, 2) +} + +MsgBox % "Array => " array "`n" "Result => " even(array) + + +; ----- Yet another version: with array (requires AutoHotKey_L) ------ +array2 := [1,2,3,4,5,6,7] + +even2(a) { + r := [] + For k, v in a + if !mod(v, 2) + r.Insert(v) + return r +} + +; Add "join" method to string object (just like python) +s_join(o, a) { + Loop, % a.MaxIndex() + r .= o a[A_Index] + return SubStr(r, StrLen(o) + 1) +} +"".base.join := Func("s_join") + +MsgBox % "Array => " ",".join(array2) "`n" "Result => " ",".join(even2(array2)) diff --git a/Task/Filter/BBC-BASIC/filter.bbc b/Task/Filter/BBC-BASIC/filter.bbc new file mode 100644 index 0000000000..ba6ca73edd --- /dev/null +++ b/Task/Filter/BBC-BASIC/filter.bbc @@ -0,0 +1,34 @@ + REM Create the test array: + items% = 1000 + DIM array%(items%) + FOR index% = 1 TO items% + array%(index%) = RND + NEXT + + REM Count the number of filtered items: + filtered% = 0 + FOR index% = 1 TO items% + IF FNfilter(array%(index%)) filtered% += 1 + NEXT + + REM Create a new array containing the filtered items: + DIM new%(filtered%) + filtered% = 0 + FOR index% = 1 TO items% + IF FNfilter(array%(index%)) THEN + filtered% += 1 + new%(filtered%) = array%(index%) + ENDIF + NEXT + + REM Alternatively modify the original array: + filtered% = 0 + FOR index% = 1 TO items% + IF FNfilter(array%(index%)) THEN + filtered% += 1 + array%(filtered%) = array%(index%) + ENDIF + NEXT + END + + DEF FNfilter(A%) = ((A% AND 1) = 0) diff --git a/Task/Filter/Bracmat/filter.bracmat b/Task/Filter/Bracmat/filter.bracmat new file mode 100644 index 0000000000..479ab1d018 --- /dev/null +++ b/Task/Filter/Bracmat/filter.bracmat @@ -0,0 +1,5 @@ +( :?odds +& ( 1 2 3 4 5 6 7 8 9 10 16 25 36 49 64 81 100:? (=.!sjt*1/2:/&!odds !sjt:?odds)$() () + | !odds + ) +) diff --git a/Task/Filter/Brat/filter.brat b/Task/Filter/Brat/filter.brat new file mode 100644 index 0000000000..2635ed6285 --- /dev/null +++ b/Task/Filter/Brat/filter.brat @@ -0,0 +1,2 @@ +#Prints [2, 4, 6, 8, 10] +p 1.to(10).select { x | x % 2 == 0 } diff --git a/Task/Filter/Burlesque/filter.blq b/Task/Filter/Burlesque/filter.blq new file mode 100644 index 0000000000..a6957613a9 --- /dev/null +++ b/Task/Filter/Burlesque/filter.blq @@ -0,0 +1,2 @@ +blsq ) 1 13r@{2.%n!}f[ +{2 4 6 8 10 12} diff --git a/Task/Filter/C++/filter-1.cpp b/Task/Filter/C++/filter-1.cpp new file mode 100644 index 0000000000..e67ad6e721 --- /dev/null +++ b/Task/Filter/C++/filter-1.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include + +int main() { + std::vector ary; + for (int i = 0; i < 10; i++) + ary.push_back(i); + std::vector evens; + std::remove_copy_if(ary.begin(), ary.end(), back_inserter(evens), + std::bind2nd(std::modulus(), 2)); // filter copy + std::copy(evens.begin(), evens.end(), + std::ostream_iterator(std::cout, "\n")); + + return 0; +} diff --git a/Task/Filter/C++/filter-2.cpp b/Task/Filter/C++/filter-2.cpp new file mode 100644 index 0000000000..264fa0e272 --- /dev/null +++ b/Task/Filter/C++/filter-2.cpp @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +using namespace std; + +int main() { + vector ary = {1, 2, 3, 4, 5, 6, 7, 8, 9}; + vector evens; + + copy_if(ary.begin(), ary.end(), back_inserter(evens), + [](int i) { return i % 2 == 0; }); + + // print result + copy(evens.begin(), evens.end(), ostream_iterator(cout, "\n")); +} diff --git a/Task/Filter/C/filter.c b/Task/Filter/C/filter.c new file mode 100644 index 0000000000..94be008896 --- /dev/null +++ b/Task/Filter/C/filter.c @@ -0,0 +1,43 @@ +#include +#include + +int even_sel(int x) { return !(x & 1); } +int tri_sel(int x) { return x % 3; } + +/* using a predicate function sel() to select elements */ +int* grep(int *in, int len, int *outlen, int (*sel)(int), int inplace) +{ + int i, j, *out; + + if (inplace) out = in; + else out = malloc(sizeof(int) * len); + + for (i = j = 0; i < len; i++) + if (sel(in[i])) + out[j++] = in[i]; + + if (!inplace && j < len) + out = realloc(out, sizeof(int) * j); + + *outlen = j; + return out; +} + +int main() +{ + int in[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + int i, len; + + int *even = grep(in, 10, &len, even_sel, 0); + printf("Filtered even:"); + for (i = 0; i < len; i++) printf(" %d", even[i]); + printf("\n"); + + grep(in, 8, &len, tri_sel, 1); + printf("In-place filtered not multiple of 3:"); + for (i = 0; i < len; i++) printf(" %d", in[i]); + + printf("\n"); + + return 0; +} diff --git a/Task/Filter/Clean/filter-1.clean b/Task/Filter/Clean/filter-1.clean new file mode 100644 index 0000000000..58650587bb --- /dev/null +++ b/Task/Filter/Clean/filter-1.clean @@ -0,0 +1,3 @@ +module SelectFromArray + +import StdEnv diff --git a/Task/Filter/Clean/filter-2.clean b/Task/Filter/Clean/filter-2.clean new file mode 100644 index 0000000000..9795c01b26 --- /dev/null +++ b/Task/Filter/Clean/filter-2.clean @@ -0,0 +1,2 @@ +array :: {Int} +array = {x \\ x <- [1 .. 10]} diff --git a/Task/Filter/Clean/filter-3.clean b/Task/Filter/Clean/filter-3.clean new file mode 100644 index 0000000000..79af725ccf --- /dev/null +++ b/Task/Filter/Clean/filter-3.clean @@ -0,0 +1,2 @@ +Start :: {!Int} +Start = {x \\ x <-: array | isEven x} diff --git a/Task/Filter/Clojure/filter.clj b/Task/Filter/Clojure/filter.clj new file mode 100644 index 0000000000..7e8e363bba --- /dev/null +++ b/Task/Filter/Clojure/filter.clj @@ -0,0 +1,4 @@ +;; range and filter create lazy seq's +(filter even? (range 0 100)) +;; vec will convert any type of seq to an array +(vec (filter even? (vec (range 0 100)))) diff --git a/Task/Filter/Common-Lisp/filter-1.lisp b/Task/Filter/Common-Lisp/filter-1.lisp new file mode 100644 index 0000000000..fd60f7cb42 --- /dev/null +++ b/Task/Filter/Common-Lisp/filter-1.lisp @@ -0,0 +1,2 @@ +(remove-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10)) +> (2 4 6 8 10) diff --git a/Task/Filter/Common-Lisp/filter-2.lisp b/Task/Filter/Common-Lisp/filter-2.lisp new file mode 100644 index 0000000000..53be8ff135 --- /dev/null +++ b/Task/Filter/Common-Lisp/filter-2.lisp @@ -0,0 +1,2 @@ +(delete-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10)) +> (2 4 6 8 10) diff --git a/Task/Filter/D/filter-1.d b/Task/Filter/D/filter-1.d new file mode 100644 index 0000000000..7adb1596df --- /dev/null +++ b/Task/Filter/D/filter-1.d @@ -0,0 +1,9 @@ +import std.algorithm; + +void main() { + immutable data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + auto evens = data.filter!(x => x % 2 == 0)(); // lazy + + assert(evens.equal([2, 4, 6, 8, 10])); +} diff --git a/Task/Filter/D/filter-2.d b/Task/Filter/D/filter-2.d new file mode 100644 index 0000000000..63bcc2464a --- /dev/null +++ b/Task/Filter/D/filter-2.d @@ -0,0 +1,10 @@ +import tango.core.Array, tango.io.Stdout; + +void main() { + auto array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + + // removeIf places even elements at the beginnig of the array and returns number of found evens + auto evens = array.removeIf( ( typeof(array[0]) i ) { return (i % 2) == 1; } ); + Stdout("Evens - ")( array[0 .. evens] ).newline; // The order of even elements is preserved + Stdout("Odds - ")( array[evens .. $].sort ).newline; // Unlike odd elements +} diff --git a/Task/Filter/Delphi/filter.delphi b/Task/Filter/Delphi/filter.delphi new file mode 100644 index 0000000000..057ebecf34 --- /dev/null +++ b/Task/Filter/Delphi/filter.delphi @@ -0,0 +1,25 @@ +program FilterEven; + +{$APPTYPE CONSOLE} + +uses SysUtils, Types; + +const + SOURCE_ARRAY: array[0..9] of Integer = (0,1,2,3,4,5,6,7,8,9); +var + i: Integer; + lEvenArray: TIntegerDynArray; +begin + for i in SOURCE_ARRAY do + begin + if not Odd(i) then + begin + SetLength(lEvenArray, Length(lEvenArray) + 1); + lEvenArray[Length(lEvenArray) - 1] := i; + end; + end; + + for i in lEvenArray do + Write(i:3); + Writeln; +end. diff --git a/Task/Filter/E/filter-1.e b/Task/Filter/E/filter-1.e new file mode 100644 index 0000000000..1a92c1f719 --- /dev/null +++ b/Task/Filter/E/filter-1.e @@ -0,0 +1,2 @@ +pragma.enable("accumulator") +accum [] for x ? (x %% 2 <=> 0) in [1,2,3,4,5,6,7,8,9,10] { _.with(x) } diff --git a/Task/Filter/E/filter-2.e b/Task/Filter/E/filter-2.e new file mode 100644 index 0000000000..8c0654bdeb --- /dev/null +++ b/Task/Filter/E/filter-2.e @@ -0,0 +1,5 @@ +var result := [] +for x ? (x %% 2 <=> 0) in [1,2,3,4,5,6,7,8,9,10] { + result with= x +} +result diff --git a/Task/Filter/E/filter-3.e b/Task/Filter/E/filter-3.e new file mode 100644 index 0000000000..e7ca9b11d7 --- /dev/null +++ b/Task/Filter/E/filter-3.e @@ -0,0 +1,2 @@ +def makeSeries := +makeSeries([1,2,3,4,5,6,7,8,9,10]).filter(fn x,_{x %% 2 <=> 0}).asList() diff --git a/Task/Filter/Ela/filter-1.ela b/Task/Filter/Ela/filter-1.ela new file mode 100644 index 0000000000..ee4ea33269 --- /dev/null +++ b/Task/Filter/Ela/filter-1.ela @@ -0,0 +1,3 @@ +open list + +evenList = filter' (\x -> x % 2 == 0) [1..] diff --git a/Task/Filter/Ela/filter-2.ela b/Task/Filter/Ela/filter-2.ela new file mode 100644 index 0000000000..1887f63ea6 --- /dev/null +++ b/Task/Filter/Ela/filter-2.ela @@ -0,0 +1 @@ +evenList = [& x \\ x <- [1..] | x % 2 == 0] diff --git a/Task/Filter/Erlang/filter-1.erl b/Task/Filter/Erlang/filter-1.erl new file mode 100644 index 0000000000..badae05d85 --- /dev/null +++ b/Task/Filter/Erlang/filter-1.erl @@ -0,0 +1,2 @@ +Numbers = lists:seq(1, 5). +EvenNumbers = lists:filter(fun (X) -> X rem 2 == 0 end, Numbers). diff --git a/Task/Filter/Erlang/filter-2.erl b/Task/Filter/Erlang/filter-2.erl new file mode 100644 index 0000000000..6c84a50323 --- /dev/null +++ b/Task/Filter/Erlang/filter-2.erl @@ -0,0 +1 @@ +EvenNumbers = [X || X <- Numbers, X rem 2 == 0]. diff --git a/Task/Filter/Euphoria/filter.euphoria b/Task/Filter/Euphoria/filter.euphoria new file mode 100644 index 0000000000..849195d097 --- /dev/null +++ b/Task/Filter/Euphoria/filter.euphoria @@ -0,0 +1,9 @@ +sequence s, evens +s = {1, 2, 3, 4, 5, 6} +evens = {} +for i = 1 to length(s) do + if remainder(s[i], 2) = 0 then + evens = append(evens, s[i]) + end if +end for +? evens diff --git a/Task/Filter/Factor/filter-1.factor b/Task/Filter/Factor/filter-1.factor new file mode 100644 index 0000000000..87e12e3c20 --- /dev/null +++ b/Task/Filter/Factor/filter-1.factor @@ -0,0 +1,2 @@ +10 iota >array [ even? ] filter . +! prints { 0 2 4 6 8 } diff --git a/Task/Filter/Factor/filter-2.factor b/Task/Filter/Factor/filter-2.factor new file mode 100644 index 0000000000..5c261dbb53 --- /dev/null +++ b/Task/Filter/Factor/filter-2.factor @@ -0,0 +1,2 @@ +10 iota [ even? ] filter . +! prints V{ 0 2 4 5 8 } diff --git a/Task/Filter/Factor/filter-3.factor b/Task/Filter/Factor/filter-3.factor new file mode 100644 index 0000000000..7ba24f859f --- /dev/null +++ b/Task/Filter/Factor/filter-3.factor @@ -0,0 +1,3 @@ +USE: vectors +10 iota >vector [ even? ] filter! . +! prints V{ 0 2 4 5 8 } diff --git a/Task/Filter/Factor/filter-4.factor b/Task/Filter/Factor/filter-4.factor new file mode 100644 index 0000000000..8273b534da --- /dev/null +++ b/Task/Filter/Factor/filter-4.factor @@ -0,0 +1,9 @@ +USE: locals +10 iota >vector [| v | + v [ even? ] filter drop + v pprint " after filter" print + v [ even? ] filter! drop + v pprint " after filter!" print +] call +! V{ 0 1 2 3 4 5 6 7 8 9 } after filter +! V{ 0 2 4 6 8 } after filter! diff --git a/Task/Filter/Fantom/filter.fantom b/Task/Filter/Fantom/filter.fantom new file mode 100644 index 0000000000..e4c9830ac5 --- /dev/null +++ b/Task/Filter/Fantom/filter.fantom @@ -0,0 +1,11 @@ +class Main +{ + Void main () + { + items := [1, 2, 3, 4, 5, 6, 7, 8] + // create a new list with just the even numbers + evens := items.findAll |i| { i.isEven } + // display the result + echo (evens.join(",")) + } +} diff --git a/Task/Filter/Forth/filter.fth b/Task/Filter/Forth/filter.fth new file mode 100644 index 0000000000..d1ea9ee44f --- /dev/null +++ b/Task/Filter/Forth/filter.fth @@ -0,0 +1,16 @@ +: sel ( dest 0 test src len -- dest len ) + cells over + swap do ( dest len test ) + i @ over execute if + i @ 2over cells + ! + >r 1+ r> + then + cell +loop drop ; + +create nums 1 , 2 , 3 , 4 , 5 , 6 , +create evens 6 cells allot + +: .array 0 ?do dup i cells + @ . loop drop ; + +: even? ( n -- ? ) 1 and 0= ; + +evens 0 ' even? nums 6 sel .array \ 2 4 6 diff --git a/Task/Filter/Fortran/filter-1.f b/Task/Filter/Fortran/filter-1.f new file mode 100644 index 0000000000..23cd61bf5f --- /dev/null +++ b/Task/Filter/Fortran/filter-1.f @@ -0,0 +1,9 @@ +module funcs + implicit none +contains + pure function iseven(x) + logical :: iseven + integer, intent(in) :: x + iseven = mod(x, 2) == 0 + end function iseven +end module funcs diff --git a/Task/Filter/Fortran/filter-2.f b/Task/Filter/Fortran/filter-2.f new file mode 100644 index 0000000000..2bd81766be --- /dev/null +++ b/Task/Filter/Fortran/filter-2.f @@ -0,0 +1,43 @@ +program Filter + use funcs + implicit none + + integer, parameter :: N = 100 + integer, dimension(N) :: array + integer, dimension(:), pointer :: filtered + + integer :: i + + forall(i=1:N) array(i) = i + + filtered => filterwith(array, iseven) + print *, filtered + +contains + + function filterwith(ar, testfunc) + integer, dimension(:), pointer :: filterwith + integer, dimension(:), intent(in) :: ar + interface + elemental function testfunc(x) + logical :: testfunc + integer, intent(in) :: x + end function testfunc + end interface + + integer :: i, j, n + + n = count( testfunc(ar) ) + allocate( filterwith(n) ) + + j = 1 + do i = lbound(ar, dim=1), ubound(ar, dim=1) + if ( testfunc(ar(i)) ) then + filterwith(j) = ar(i) + j = j + 1 + end if + end do + + end function filterwith + +end program Filter diff --git a/Task/Filter/GAP/filter.gap b/Task/Filter/GAP/filter.gap new file mode 100644 index 0000000000..558737868e --- /dev/null +++ b/Task/Filter/GAP/filter.gap @@ -0,0 +1,10 @@ +# Built-in + +Filtered([1 .. 100], IsPrime); +# [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ] + +Filtered([1 .. 10], IsEvenInt); +# [ 2, 4, 6, 8, 10 ] + +Filtered([1 .. 10], IsOddInt); +# [ 1, 3, 5, 7, 9 ] diff --git a/Task/Filter/Go/filter.go b/Task/Filter/Go/filter.go new file mode 100644 index 0000000000..e7dc249a24 --- /dev/null +++ b/Task/Filter/Go/filter.go @@ -0,0 +1,40 @@ +package main + +import ( + "fmt" + "math/rand" +) + +func main() { + a := rand.Perm(20) + fmt.Println(a) // show array to filter + fmt.Println(even(a)) // show result of non-destructive filter + fmt.Println(a) // show that original array is unchanged + reduceToEven(&a) // destructive filter + fmt.Println(a) // show that a is now changed + // a is not only changed, it is changed in place. length and capacity + // show that it still has its original allocated capacity but has now + // been reduced in length. + fmt.Println("a len:", len(a), "cap:", cap(a)) +} + +func even(a []int) (r []int) { + for _, e := range a { + if e%2 == 0 { + r = append(r, e) + } + } + return +} + +func reduceToEven(pa *[]int) { + a := *pa + var last int + for _, e := range a { + if e%2 == 0 { + a[last] = e + last++ + } + } + *pa = a[:last] +} diff --git a/Task/Filter/Groovy/filter.groovy b/Task/Filter/Groovy/filter.groovy new file mode 100644 index 0000000000..075463fe8e --- /dev/null +++ b/Task/Filter/Groovy/filter.groovy @@ -0,0 +1 @@ + def evens = [1, 2, 3, 4, 5].findAll{it % 2 == 0} diff --git a/Task/Filter/Haskell/filter-1.hs b/Task/Filter/Haskell/filter-1.hs new file mode 100644 index 0000000000..8dcdb4b38e --- /dev/null +++ b/Task/Filter/Haskell/filter-1.hs @@ -0,0 +1,2 @@ +ary = [1..10] +evens = [x | x <- ary, even x] diff --git a/Task/Filter/Haskell/filter-2.hs b/Task/Filter/Haskell/filter-2.hs new file mode 100644 index 0000000000..b396243aad --- /dev/null +++ b/Task/Filter/Haskell/filter-2.hs @@ -0,0 +1 @@ +evens = filter even ary diff --git a/Task/Filter/Haskell/filter-3.hs b/Task/Filter/Haskell/filter-3.hs new file mode 100644 index 0000000000..f20c5f4b34 --- /dev/null +++ b/Task/Filter/Haskell/filter-3.hs @@ -0,0 +1,6 @@ +import Data.Array + +ary = listArray (1,10) [1..10] +evens = listArray (1,n) l where + n = length l + l = [x | x <- elems ary, even x] diff --git a/Task/Filter/IDL/filter.idl b/Task/Filter/IDL/filter.idl new file mode 100644 index 0000000000..421e9d5562 --- /dev/null +++ b/Task/Filter/IDL/filter.idl @@ -0,0 +1 @@ +result = array[where(NOT array AND 1)] diff --git a/Task/Filter/Icon/filter.icon b/Task/Filter/Icon/filter.icon new file mode 100644 index 0000000000..c2a568aa65 --- /dev/null +++ b/Task/Filter/Icon/filter.icon @@ -0,0 +1,10 @@ +procedure main() + +every put(A := [],1 to 10) # make a list of 1..10 +every put(B := [],iseven(!A)) # make a second list and filter out odd numbers +every writes(!B," ") | write() # show +end + +procedure iseven(x) #: return x if x is even or fail +if x % 2 = 0 then return x +end diff --git a/Task/Filter/J/filter-1.j b/Task/Filter/J/filter-1.j new file mode 100644 index 0000000000..5a6652ecad --- /dev/null +++ b/Task/Filter/J/filter-1.j @@ -0,0 +1 @@ + (#~ f) v diff --git a/Task/Filter/J/filter-2.j b/Task/Filter/J/filter-2.j new file mode 100644 index 0000000000..f80194bdea --- /dev/null +++ b/Task/Filter/J/filter-2.j @@ -0,0 +1,5 @@ + ] v=: 20 ?@$ 100 NB. vector of 20 random integers between 0 and 99 +63 92 51 92 39 15 43 89 36 69 40 16 23 2 29 91 57 43 55 22 + + v #~ -.2| v +92 92 36 40 16 2 22 diff --git a/Task/Filter/J/filter-3.j b/Task/Filter/J/filter-3.j new file mode 100644 index 0000000000..8e38ddd02a --- /dev/null +++ b/Task/Filter/J/filter-3.j @@ -0,0 +1,3 @@ + isEven=: 0 = 2&| NB. verb testing for even numbers + (#~ isEven) v +92 92 36 40 16 2 22 diff --git a/Task/Filter/J/filter-4.j b/Task/Filter/J/filter-4.j new file mode 100644 index 0000000000..9ea0c6232f --- /dev/null +++ b/Task/Filter/J/filter-4.j @@ -0,0 +1,9 @@ + select=: adverb def '(#~ u)' + isPrime=: 1&p: + + isEven select v +92 92 36 40 16 2 22 + isPrime select v +43 89 23 2 29 43 + (isEven *. isPrime) select v +2 diff --git a/Task/Filter/J/filter-5.j b/Task/Filter/J/filter-5.j new file mode 100644 index 0000000000..c2e4e63947 --- /dev/null +++ b/Task/Filter/J/filter-5.j @@ -0,0 +1 @@ + v=: isEven select v diff --git a/Task/Filter/Java/filter.java b/Task/Filter/Java/filter.java new file mode 100644 index 0000000000..c3bfcd2b64 --- /dev/null +++ b/Task/Filter/Java/filter.java @@ -0,0 +1,6 @@ +int[] array = {1, 2, 3, 4, 5 }; +List evensList = new ArrayList(); +for (int i: array) { + if (i % 2 == 0) evensList.add(i); +} +int[] evens = evensList.toArray(new int[0]); diff --git a/Task/Filter/JavaFX-Script/filter.javafx b/Task/Filter/JavaFX-Script/filter.javafx new file mode 100644 index 0000000000..5485e94eb5 --- /dev/null +++ b/Task/Filter/JavaFX-Script/filter.javafx @@ -0,0 +1,2 @@ +def array = [1..100]; +def evens = array[n | n mod 2 == 0]; diff --git a/Task/Filter/JavaScript/filter-1.js b/Task/Filter/JavaScript/filter-1.js new file mode 100644 index 0000000000..21e07441ba --- /dev/null +++ b/Task/Filter/JavaScript/filter-1.js @@ -0,0 +1,2 @@ +var arr = [1,2,3,4,5]; +var evens = arr.filter(function(a) {return a % 2 == 0}); diff --git a/Task/Filter/JavaScript/filter-2.js b/Task/Filter/JavaScript/filter-2.js new file mode 100644 index 0000000000..0d9950d1f0 --- /dev/null +++ b/Task/Filter/JavaScript/filter-2.js @@ -0,0 +1,5 @@ +var arr = [1,2,3,4,5]; +var evens = []; +for (var i=0, ilen=arr.length; i> selectEvenNumbers([0 1 2 3 4 5 6 7 8 9 10]) + +ans = + + 0 2 4 6 8 10 diff --git a/Task/Filter/MAXScript/filter.max b/Task/Filter/MAXScript/filter.max new file mode 100644 index 0000000000..9ab922888d --- /dev/null +++ b/Task/Filter/MAXScript/filter.max @@ -0,0 +1,2 @@ +arr = #(1, 2, 3, 4, 5, 6, 7, 8, 9) +newArr = for i in arr where (mod i 2 == 0) collect i diff --git a/Task/Filter/MUMPS/filter.mumps b/Task/Filter/MUMPS/filter.mumps new file mode 100644 index 0000000000..7ac0235c2e --- /dev/null +++ b/Task/Filter/MUMPS/filter.mumps @@ -0,0 +1,7 @@ +FILTERARRAY + ;NEW I,J,A,B - Not making new, so we can show the values + ;Populate array A + FOR I=1:1:10 SET A(I)=I + ;Move even numbers into B + SET J=0 FOR I=1:1:10 SET:A(I)#2=0 B($INCREMENT(J))=A(I) + QUIT diff --git a/Task/Filter/Mathematica/filter-1.mathematica b/Task/Filter/Mathematica/filter-1.mathematica new file mode 100644 index 0000000000..9d4e4c8a14 --- /dev/null +++ b/Task/Filter/Mathematica/filter-1.mathematica @@ -0,0 +1 @@ +Select[{4, 5, Pi, 2, 1.3, 7, 6, 8.0}, EvenQ] diff --git a/Task/Filter/Mathematica/filter-2.mathematica b/Task/Filter/Mathematica/filter-2.mathematica new file mode 100644 index 0000000000..af524b708c --- /dev/null +++ b/Task/Filter/Mathematica/filter-2.mathematica @@ -0,0 +1 @@ +{4, 2, 6} diff --git a/Task/Filter/Mathematica/filter-3.mathematica b/Task/Filter/Mathematica/filter-3.mathematica new file mode 100644 index 0000000000..fae278cc3d --- /dev/null +++ b/Task/Filter/Mathematica/filter-3.mathematica @@ -0,0 +1 @@ +Select[{4, 5, Pi, 2, 1.3, 7, 6, 8.0}, Mod[#, 2] == 0 &] diff --git a/Task/Filter/Mathematica/filter-4.mathematica b/Task/Filter/Mathematica/filter-4.mathematica new file mode 100644 index 0000000000..722546da82 --- /dev/null +++ b/Task/Filter/Mathematica/filter-4.mathematica @@ -0,0 +1 @@ +{4, 2, 6, 8.} diff --git a/Task/Filter/Maxima/filter.maxima b/Task/Filter/Maxima/filter.maxima new file mode 100644 index 0000000000..f131df0fe8 --- /dev/null +++ b/Task/Filter/Maxima/filter.maxima @@ -0,0 +1,8 @@ +a: makelist(i, i, 1, 20); +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] + +sublist(a, evenp); +[2, 4, 6, 8, 10, 12, 14, 16, 18, 20] + +sublist(a, lambda([n], mod(n, 3) = 0)); +[3, 6, 9, 12, 15, 18] diff --git a/Task/Filter/PHP/filter-1.php b/Task/Filter/PHP/filter-1.php new file mode 100644 index 0000000000..8c1c42f417 --- /dev/null +++ b/Task/Filter/PHP/filter-1.php @@ -0,0 +1,6 @@ +$arr = range(1,5); +$evens = array(); +foreach ($arr as $val){ + if ($val % 2 == 0) $evens[] = $val); +} +print_r($evens); diff --git a/Task/Filter/PHP/filter-2.php b/Task/Filter/PHP/filter-2.php new file mode 100644 index 0000000000..7f84c78422 --- /dev/null +++ b/Task/Filter/PHP/filter-2.php @@ -0,0 +1,4 @@ +function is_even($var) { return(!($var & 1)); } +$arr = range(1,5); +$evens = array_filter($arr, "is_even"); +print_r($evens); diff --git a/Task/Filter/Perl/filter.pl b/Task/Filter/Perl/filter.pl new file mode 100644 index 0000000000..a49b6e7455 --- /dev/null +++ b/Task/Filter/Perl/filter.pl @@ -0,0 +1,2 @@ +my @a = (1, 2, 3, 4, 5, 6); +my @even = grep { $_%2 == 0 } @a; diff --git a/Task/Filter/PicoLisp/filter.l b/Task/Filter/PicoLisp/filter.l new file mode 100644 index 0000000000..635ac93c35 --- /dev/null +++ b/Task/Filter/PicoLisp/filter.l @@ -0,0 +1,2 @@ +(filter '((N) (not (bit? 1 N))) + (1 2 3 4 5 6 7 8 9) ) diff --git a/Task/Filter/Prolog/filter-1.pro b/Task/Filter/Prolog/filter-1.pro new file mode 100644 index 0000000000..e0dbe7c7e8 --- /dev/null +++ b/Task/Filter/Prolog/filter-1.pro @@ -0,0 +1 @@ +evens(D, Es) :- findall(E, (member(E, D), E mod 2 =:= 0), Es). diff --git a/Task/Filter/Prolog/filter-2.pro b/Task/Filter/Prolog/filter-2.pro new file mode 100644 index 0000000000..ede509471a --- /dev/null +++ b/Task/Filter/Prolog/filter-2.pro @@ -0,0 +1,2 @@ +?- evens([1,2,3,4,5,6,7,8,9,10],E). +E = [2, 4, 6, 8, 10] diff --git a/Task/Filter/Prolog/filter-3.pro b/Task/Filter/Prolog/filter-3.pro new file mode 100644 index 0000000000..5cce0edcff --- /dev/null +++ b/Task/Filter/Prolog/filter-3.pro @@ -0,0 +1,5 @@ +?- use_module(library(lambda)). +true. + +?- include((\X^(X mod 2 =:= 0)), [1,2,3,4,5,6,7,8,9], L). +L = [2,4,6,8]. diff --git a/Task/Filter/Prolog/filter-4.pro b/Task/Filter/Prolog/filter-4.pro new file mode 100644 index 0000000000..ef707ceea6 --- /dev/null +++ b/Task/Filter/Prolog/filter-4.pro @@ -0,0 +1,9 @@ +:- use_module(lambda). + +%% filter(Pred, LstIn, LstOut) +%% +filter(_Pre, [], []). + +filter(Pred, [H|T], L) :- + filter(Pred, T, L1), + ( call(Pred,H) -> L = [H|L1]; L = L1). diff --git a/Task/Filter/Prolog/filter-5.pro b/Task/Filter/Prolog/filter-5.pro new file mode 100644 index 0000000000..2d2a27c6fd --- /dev/null +++ b/Task/Filter/Prolog/filter-5.pro @@ -0,0 +1,2 @@ + ?- filter(\X^(X mod 2 =:= 0), [1,2,3,4,5,6,7,8,9], L). +L = [2,4,6,8] . diff --git a/Task/Filter/Python/filter-1.py b/Task/Filter/Python/filter-1.py new file mode 100644 index 0000000000..eccd4d565f --- /dev/null +++ b/Task/Filter/Python/filter-1.py @@ -0,0 +1,5 @@ +values = range(10) +evens = [x for x in values if not x & 1] +ievens = (x for x in values if not x & 1) # lazy +# alternately but less idiomatic: +evens = filter(lambda x: not x & 1, values) diff --git a/Task/Filter/Python/filter-2.py b/Task/Filter/Python/filter-2.py new file mode 100644 index 0000000000..9439bd8586 --- /dev/null +++ b/Task/Filter/Python/filter-2.py @@ -0,0 +1,2 @@ +values = range(10) +evens = values[::2] diff --git a/Task/Filter/Python/filter-3.py b/Task/Filter/Python/filter-3.py new file mode 100644 index 0000000000..c45a89abf0 --- /dev/null +++ b/Task/Filter/Python/filter-3.py @@ -0,0 +1,4 @@ +values = range(10) +values[::2] = [11,13,15,17,19] +print values +11, 1, 13, 3, 15, 5, 17, 7, 19, 9 diff --git a/Task/Filter/R/filter.r b/Task/Filter/R/filter.r new file mode 100644 index 0000000000..e6a0fb5fe5 --- /dev/null +++ b/Task/Filter/R/filter.r @@ -0,0 +1,3 @@ +a <- 1:100 +evennums <- a[ a%%2 == 0 ] +print(evennums) diff --git a/Task/Filter/REXX/filter.rexx b/Task/Filter/REXX/filter.rexx new file mode 100644 index 0000000000..2445770bc4 --- /dev/null +++ b/Task/Filter/REXX/filter.rexx @@ -0,0 +1,26 @@ +/*REXX program selects all even numbers from an array ──► a new array. */ +numeric digits 210000 /*handle past 1m for Fibonacci.*/ +old.= /*the OLD array, all null so far.*/ +new.= /*the NEW array, all null so far.*/ + do j=-40 to 40; old.j=fib(j); end /*put 81 Fibonacci numbs ==> OLD */ +news=0 /*numb. of elements in NEW so far*/ + +/*══════════════════════════════════════════════════════════════════════*/ + do k=-40 while old.k\=='' /*process the OLD array elements.*/ + if old.k//2 \== 0 then iterate /*if element isn't even, skip it.*/ + news=news+1 /*bump the number of NEW elements*/ + new.news=old.k /*assign it to the NEW array. */ + end +/*══════════════════════════════════════════════════════════════════════*/ + + do j=1 for news /*display all the NEW numbers. */ + say 'new.'j "=" new.j + end +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────FIB subroutine (non-recursive)───*/ +fib: procedure; parse arg n; na=abs(n); if na<2 then return na /*special*/ +a=0; b=1 + do j=2 to na; s=a+b; a=b; b=s; end + +if n>0 | na//2==1 then return s /*if positive or odd negative... */ + else return -s /*return a negative Fib number. */ diff --git a/Task/Filter/Ruby/filter-1.rb b/Task/Filter/Ruby/filter-1.rb new file mode 100644 index 0000000000..26014e09f1 --- /dev/null +++ b/Task/Filter/Ruby/filter-1.rb @@ -0,0 +1,9 @@ +# Enumerable#select returns a new array. +ary = [1, 2, 3, 4, 5, 6] +even_ary = ary.select {|elem| elem.even?} +p even_ary # => [2, 4, 6] + +# Enumerable#select also works with Range. +range = 1..6 +even_ary = range.select {|elem| elem.even?} +p even_ary # => [2, 4, 6] diff --git a/Task/Filter/Ruby/filter-2.rb b/Task/Filter/Ruby/filter-2.rb new file mode 100644 index 0000000000..52e014d743 --- /dev/null +++ b/Task/Filter/Ruby/filter-2.rb @@ -0,0 +1,9 @@ +# Integer#even? is new to Ruby 1.8.7. +# Define it for older Ruby. +unless Integer.method_defined? :even? + class Integer + def even? + self % 2 == 0 + end + end +end diff --git a/Task/Filter/Ruby/filter-3.rb b/Task/Filter/Ruby/filter-3.rb new file mode 100644 index 0000000000..95e764511f --- /dev/null +++ b/Task/Filter/Ruby/filter-3.rb @@ -0,0 +1,3 @@ +ary = [1, 2, 3, 4, 5, 6] +ary.select! {|elem| elem.even?} +p ary # => [2, 4, 6] diff --git a/Task/Filter/Ruby/filter-4.rb b/Task/Filter/Ruby/filter-4.rb new file mode 100644 index 0000000000..4415c3bd0d --- /dev/null +++ b/Task/Filter/Ruby/filter-4.rb @@ -0,0 +1,11 @@ +# Array#select! is new to Ruby 1.9.2. +# Define it for older Ruby. +unless Array.method_defined? :select! + class Array + def select! + enum_for(:select!) unless block_given? + delete_if { |elem| not yield elem } + self + end + end +end diff --git a/Task/Filter/Sather/filter.sa b/Task/Filter/Sather/filter.sa new file mode 100644 index 0000000000..8f5d11f3c6 --- /dev/null +++ b/Task/Filter/Sather/filter.sa @@ -0,0 +1,23 @@ +class MARRAY{T} < $ARR{T} is + include ARRAY{T}; + + filter_by(r:ROUT{T}:BOOL):SAME is + o:MARRAY{T} := #; + loop e ::= elt!; + if r.call(e) then + o := o.append(#MARRAY{T}(|e|)); + end; + end; + return o; + end; + +end; + +class MAIN is + main is + a ::= #MARRAY{INT}(|5, 6, 7, 8, 9, 10, 11|); + sel ::= a.filter_by( bind(_.is_even) ); + loop #OUT + sel.elt! + " "; end; + #OUT + "\n"; + end; +end; diff --git a/Task/Filter/Scala/filter.scala b/Task/Filter/Scala/filter.scala new file mode 100644 index 0000000000..641559f601 --- /dev/null +++ b/Task/Filter/Scala/filter.scala @@ -0,0 +1 @@ +(1 to 100).filter(_ % 2 == 0) diff --git a/Task/Filter/Scheme/filter-1.ss b/Task/Filter/Scheme/filter-1.ss new file mode 100644 index 0000000000..037bfedeca --- /dev/null +++ b/Task/Filter/Scheme/filter-1.ss @@ -0,0 +1,2 @@ +> (filter even? '(1 2 3 4 5 6 7 8 9 10)) +(2 4 6 8 10) diff --git a/Task/Filter/Scheme/filter-2.ss b/Task/Filter/Scheme/filter-2.ss new file mode 100644 index 0000000000..dd2443e327 --- /dev/null +++ b/Task/Filter/Scheme/filter-2.ss @@ -0,0 +1,4 @@ +(define (select-even lst) + (filter even? lst)) + +(select-even '(1 2 3 4 5 6 7 8 9 10)) diff --git a/Task/Filter/Smalltalk/filter.st b/Task/Filter/Smalltalk/filter.st new file mode 100644 index 0000000000..639bef2366 --- /dev/null +++ b/Task/Filter/Smalltalk/filter.st @@ -0,0 +1 @@ +#(1 2 3 4 5) select: [:number | number even] diff --git a/Task/Filter/Tcl/filter-1.tcl b/Task/Filter/Tcl/filter-1.tcl new file mode 100644 index 0000000000..1ee1f2397a --- /dev/null +++ b/Task/Filter/Tcl/filter-1.tcl @@ -0,0 +1 @@ +foreach key [array names arr] {if { } then {puts $arr($key)}} diff --git a/Task/Filter/Tcl/filter-2.tcl b/Task/Filter/Tcl/filter-2.tcl new file mode 100644 index 0000000000..acc5bfd290 --- /dev/null +++ b/Task/Filter/Tcl/filter-2.tcl @@ -0,0 +1,5 @@ +foreach {key val} [array get srcArray] { + if {[string is integer -strict $key] && !($key%2)} { + set dstArray($key) $val + } +} diff --git a/Task/Filter/Tcl/filter-3.tcl b/Task/Filter/Tcl/filter-3.tcl new file mode 100644 index 0000000000..938d1dbe00 --- /dev/null +++ b/Task/Filter/Tcl/filter-3.tcl @@ -0,0 +1,3 @@ +foreach {even odd} $srcList { + lappend dstList $even +} diff --git a/Task/Find-common-directory-path/0DESCRIPTION b/Task/Find-common-directory-path/0DESCRIPTION new file mode 100644 index 0000000000..a8519dbfc9 --- /dev/null +++ b/Task/Find-common-directory-path/0DESCRIPTION @@ -0,0 +1,9 @@ +Create a routine that, given a set of strings representing directory paths and a single character directory separator, will return a string representing that part of the directory tree that is common to all the directories. + +Test your routine using the forward slash '/' character as the directory separator and the following three strings as input paths: + '/home/user1/tmp/coverage/test' + '/home/user1/tmp/covert/operator' + '/home/user1/tmp/coven/members' + +Note: The resultant path should be the valid directory '/home/user1/tmp' and not the longest common string '/home/user1/tmp/cove'.
+If your language has a routine that performs this function (even if it does not have a changeable separator character), then mention it as part of the task. diff --git a/Task/Find-common-directory-path/ALGOL-68/find-common-directory-path.alg b/Task/Find-common-directory-path/ALGOL-68/find-common-directory-path.alg new file mode 100644 index 0000000000..ff3184bc61 --- /dev/null +++ b/Task/Find-common-directory-path/ALGOL-68/find-common-directory-path.alg @@ -0,0 +1,58 @@ +# Utilities code # + +CHAR dir sep = "/"; # Assume POSIX # + +PROC dir name = (STRING dir)STRING: ( + STRING out; + FOR pos FROM UPB dir BY -1 TO LWB dir DO + IF dir[pos] = dir sep THEN + out := dir[:pos-1]; + GO TO out exit + FI + OD; + # else: # out:=""; + out exit: out +); + +PROC shortest = ([]STRING string list)STRING: ( + INT min := max int; + INT min key := LWB string list - 1; + FOR key FROM LWB string list TO UPB string list DO + IF UPB string list[key][@1] < min THEN + min := UPB string list[key][@1]; + min key := key + FI + OD; + string list[min key] +); + +# Actual code # + +PROC common prefix = ([]STRING strings)STRING: ( + IF LWB strings EQ UPB strings THEN + # exit: # strings[LWB strings] + ELSE + STRING prefix := shortest(strings); + FOR pos FROM LWB prefix TO UPB prefix DO + CHAR first = prefix[pos]; + FOR key FROM LWB strings+1 TO UPB strings DO + IF strings[key][@1][pos] NE first THEN + prefix := prefix[:pos-1]; + GO TO prefix exit + FI + OD + OD; + prefix exit: prefix + FI +); + +# Test code # + +test:( + []STRING dir list = ( + "/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members" + ); + print((dir name(common prefix(dir list)), new line)) +) diff --git a/Task/Find-common-directory-path/AWK/find-common-directory-path.awk b/Task/Find-common-directory-path/AWK/find-common-directory-path.awk new file mode 100644 index 0000000000..778080f3c5 --- /dev/null +++ b/Task/Find-common-directory-path/AWK/find-common-directory-path.awk @@ -0,0 +1,41 @@ +# Finds the longest common directory of paths[1], paths[2], ..., +# paths[count], where sep is a single-character directory separator. +function common_dir(paths, count, sep, b, c, f, i, j, p) { + if (count < 1) + return "" + + p = "" # Longest common prefix + f = 0 # Final index before last sep + + # Loop for c = each character of paths[1]. + for (i = 1; i <= length(paths[1]); i++) { + c = substr(paths[1], i, 1) + + # If c is not the same in paths[2], ..., paths[count] + # then break both loops. + b = 0 + for (j = 2; j <= count; j++) { + if (c != substr(paths[j], i, 1)) { + b = 1 + break + } + } + if (b) + break + + # Append c to prefix. Update f. + p = p c + if (c == sep) + f = i - 1 + } + + # Return only f characters of prefix. + return substr(p, 1, f) +} + +BEGIN { + a[1] = "/home/user1/tmp/coverage/test" + a[2] = "/home/user1/tmp/covert/operator" + a[3] = "/home/user1/tmp/coven/members" + print common_dir(a, 3, "/") +} diff --git a/Task/Find-common-directory-path/Ada/find-common-directory-path.ada b/Task/Find-common-directory-path/Ada/find-common-directory-path.ada new file mode 100644 index 0000000000..2e5e27c7c6 --- /dev/null +++ b/Task/Find-common-directory-path/Ada/find-common-directory-path.ada @@ -0,0 +1,37 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Common_Path is + function "rem" (A, B : String) return String is + Slash : Integer := A'First; -- At the last slash seen in A + At_A : Integer := A'first; + At_B : Integer := B'first; + begin + loop + if At_A > A'Last then + if At_B > B'Last or else B (At_B) = '/' then + return A; + else + return A (A'First..Slash - 1); + end if; + elsif At_B > B'Last then + if A (At_A) = '/' then -- A cannot be shorter than B here + return B; + else + return A (A'First..Slash - 1); + end if; + elsif A (At_A) /= B (At_B) then + return A (A'First..Slash - 1); + elsif A (At_A) = '/' then + Slash := At_A; + end if; + At_A := At_A + 1; + At_B := At_B + 1; + end loop; + end "rem"; +begin + Put_Line + ( "/home/user1/tmp/coverage/test" rem + "/home/user1/tmp/covert/operator" rem + "/home/user1/tmp/coven/members" + ); +end Test_Common_Path; diff --git a/Task/Find-common-directory-path/AutoHotkey/find-common-directory-path.ahk b/Task/Find-common-directory-path/AutoHotkey/find-common-directory-path.ahk new file mode 100644 index 0000000000..7de09815bd --- /dev/null +++ b/Task/Find-common-directory-path/AutoHotkey/find-common-directory-path.ahk @@ -0,0 +1,15 @@ +Dir1 := "/home/user1/tmp/coverage/test" +Dir2 := "/home/user1/tmp/covert/operator" +Dir3 := "/home/user1/tmp/coven/members" + +StringSplit, Dir1_, Dir1, / +StringSplit, Dir2_, Dir2, / +StringSplit, Dir3_, Dir3, / + +Loop + If (Dir1_%A_Index% = Dir2_%A_Index%) + And (Dir1_%A_Index% = Dir3_%A_Index%) + Result .= (A_Index=1 ? "" : "/") Dir1_%A_Index% + Else Break + +MsgBox, % Result diff --git a/Task/Find-common-directory-path/BASIC/find-common-directory-path.bas b/Task/Find-common-directory-path/BASIC/find-common-directory-path.bas new file mode 100644 index 0000000000..6db1ec53de --- /dev/null +++ b/Task/Find-common-directory-path/BASIC/find-common-directory-path.bas @@ -0,0 +1,52 @@ +DECLARE FUNCTION commonPath$ (paths() AS STRING, pathSep AS STRING) + +DATA "/home/user2", "/home/user1/tmp/covert/operator", "/home/user1/tmp/coven/members" + +DIM x(0 TO 2) AS STRING, n AS INTEGER +FOR n = 0 TO 2 + READ x(n) +NEXT + +PRINT "Common path is '"; commonPath$(x(), "/"); "'" + +FUNCTION commonPath$ (paths() AS STRING, pathSep AS STRING) + DIM tmpint1 AS INTEGER, tmpint2 AS INTEGER, tmpstr1 AS STRING, tmpstr2 AS STRING + DIM L0 AS INTEGER, L1 AS INTEGER, lowerbound AS INTEGER, upperbound AS INTEGER + lowerbound = LBOUND(paths): upperbound = UBOUND(paths) + + IF (lowerbound) = upperbound THEN 'Some quick error checking... + commonPath$ = paths(lowerbound) + ELSEIF lowerbound > upperbound THEN 'How in the...? + commonPath$ = "" + ELSE + tmpstr1 = paths(lowerbound) + + FOR L0 = (lowerbound + 1) TO upperbound 'Find common strings. + tmpstr2 = paths(L0) + tmpint1 = LEN(tmpstr1) + tmpint2 = LEN(tmpstr2) + IF tmpint1 > tmpint2 THEN tmpint1 = tmpint2 + FOR L1 = 1 TO tmpint1 + IF MID$(tmpstr1, L1, 1) <> MID$(tmpstr2, L1, 1) THEN + tmpint1 = L1 - 1 + EXIT FOR + END IF + NEXT + tmpstr1 = LEFT$(tmpstr1, tmpint1) + NEXT + + IF RIGHT$(tmpstr1, 1) <> pathSep THEN + FOR L1 = tmpint1 TO 2 STEP -1 + IF (pathSep) = MID$(tmpstr1, L1, 1) THEN + tmpstr1 = LEFT$(tmpstr1, L1 - 1) + EXIT FOR + END IF + NEXT + IF LEN(tmpstr1) = tmpint1 THEN tmpstr1 = "" + ELSEIF tmpint1 > 1 THEN + tmpstr1 = LEFT$(tmpstr1, tmpint1 - 1) + END IF + + commonPath$ = tmpstr1 + END IF +END FUNCTION diff --git a/Task/Find-common-directory-path/BBC-BASIC/find-common-directory-path.bbc b/Task/Find-common-directory-path/BBC-BASIC/find-common-directory-path.bbc new file mode 100644 index 0000000000..9fd3d4aab9 --- /dev/null +++ b/Task/Find-common-directory-path/BBC-BASIC/find-common-directory-path.bbc @@ -0,0 +1,19 @@ + DIM path$(3) + + path$(1) = "/home/user1/tmp/coverage/test" + path$(2) = "/home/user1/tmp/covert/operator" + path$(3) = "/home/user1/tmp/coven/members" + + PRINT FNcommonpath(path$(), "/") + END + + DEF FNcommonpath(p$(), s$) + LOCAL I%, J%, O% + REPEAT + O% = I% + I% = INSTR(p$(1), s$, I%+1) + FOR J% = 2 TO DIM(p$(), 1) + IF LEFT$(p$(1), I%) <> LEFT$(p$(J%), I%) EXIT REPEAT + NEXT J% + UNTIL I% = 0 + = LEFT$(p$(1), O%-1) diff --git a/Task/Find-common-directory-path/C++/find-common-directory-path.cpp b/Task/Find-common-directory-path/C++/find-common-directory-path.cpp new file mode 100644 index 0000000000..5c95aec102 --- /dev/null +++ b/Task/Find-common-directory-path/C++/find-common-directory-path.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +std::string longestPath( const std::vector & , char ) ; + +int main( ) { + std::string dirs[ ] = { + "/home/user1/tmp/coverage/test" , + "/home/user1/tmp/covert/operator" , + "/home/user1/tmp/coven/members" } ; + std::vector myDirs ( dirs , dirs + 3 ) ; + std::cout << "The longest common path of the given directories is " + << longestPath( myDirs , '/' ) << "!\n" ; + return 0 ; +} + +std::string longestPath( const std::vector & dirs , char separator ) { + std::vector::const_iterator vsi = dirs.begin( ) ; + int maxCharactersCommon = vsi->length( ) ; + std::string compareString = *vsi ; + for ( vsi = dirs.begin( ) + 1 ; vsi != dirs.end( ) ; vsi++ ) { + std::pair p = + std::mismatch( compareString.begin( ) , compareString.end( ) , vsi->begin( ) ) ; + if (( p.first - compareString.begin( ) ) < maxCharactersCommon ) + maxCharactersCommon = p.first - compareString.begin( ) ; + } + std::string::size_type found = compareString.rfind( separator , maxCharactersCommon ) ; + return compareString.substr( 0 , found ) ; +} diff --git a/Task/Find-common-directory-path/C/find-common-directory-path-1.c b/Task/Find-common-directory-path/C/find-common-directory-path-1.c new file mode 100644 index 0000000000..f4317eabeb --- /dev/null +++ b/Task/Find-common-directory-path/C/find-common-directory-path-1.c @@ -0,0 +1,34 @@ +#include + +int common_len(const char *const *names, int n, char sep) +{ + int i, pos; + for (pos = 0; ; pos++) { + for (i = 0; i < n; i++) { + if (names[i][pos] != '\0' && + names[i][pos] == names[0][pos]) + continue; + + /* backtrack */ + while (pos > 0 && names[0][--pos] != sep); + return pos; + } + } + + return 0; +} + +int main() +{ + const char *names[] = { + "/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members", + }; + int len = common_len(names, sizeof(names) / sizeof(const char*), '/'); + + if (!len) printf("No common path\n"); + else printf("Common path: %.*s\n", len, names[0]); + + return 0; +} diff --git a/Task/Find-common-directory-path/C/find-common-directory-path-2.c b/Task/Find-common-directory-path/C/find-common-directory-path-2.c new file mode 100644 index 0000000000..a854866c2b --- /dev/null +++ b/Task/Find-common-directory-path/C/find-common-directory-path-2.c @@ -0,0 +1 @@ +Common path: /home/user1/tmp diff --git a/Task/Find-common-directory-path/Clojure/find-common-directory-path.clj b/Task/Find-common-directory-path/Clojure/find-common-directory-path.clj new file mode 100644 index 0000000000..43b0ce7273 --- /dev/null +++ b/Task/Find-common-directory-path/Clojure/find-common-directory-path.clj @@ -0,0 +1,14 @@ +(use '[clojure.string :only [join,split]]) + +(defn common-prefix [sep paths] + (let [parts-per-path (map #(split % (re-pattern sep)) paths) + parts-per-position (apply map vector parts-per-path)] + (join sep + (for [parts parts-per-position :while (apply = parts)] + (first parts))))) + +(println + (common-prefix "/" + ["/home/user1/tmp/coverage/test" + "/home/user1/tmp/covert/operator" + "/home/user1/tmp/coven/members"])) diff --git a/Task/Find-common-directory-path/D/find-common-directory-path.d b/Task/Find-common-directory-path/D/find-common-directory-path.d new file mode 100644 index 0000000000..45ae459205 --- /dev/null +++ b/Task/Find-common-directory-path/D/find-common-directory-path.d @@ -0,0 +1,15 @@ +import std.stdio, std.string, std.algorithm, std.path, std.array; + +string commonDirPath(in string[] paths, in string sep = "/") +/*pure nothrow*/ { + if (paths.empty) + return null; + return paths.map!(p => p.split(sep)).reduce!commonPrefix.join(sep); +} + +void main() { + auto paths = ["/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members"]; + writeln(`The common path is: "`, paths.commonDirPath, '"'); +} diff --git a/Task/Find-common-directory-path/Factor/find-common-directory-path.factor b/Task/Find-common-directory-path/Factor/find-common-directory-path.factor new file mode 100644 index 0000000000..ae36f2460b --- /dev/null +++ b/Task/Find-common-directory-path/Factor/find-common-directory-path.factor @@ -0,0 +1,11 @@ +: take-shorter ( seq1 seq2 -- shorter ) + [ shorter? ] 2keep ? ; + +: common-head ( seq1 seq2 -- head ) + 2dup mismatch [ nip head ] [ take-shorter ] if* ; + +: common-prefix-1 ( file1 file2 separator -- prefix ) + [ common-head ] dip '[ _ = not ] trim-tail ; + +: common-prefix ( seq separator -- prefix ) + [ ] swap '[ _ common-prefix-1 ] map-reduce ; diff --git a/Task/Find-common-directory-path/GW-BASIC/find-common-directory-path.bas b/Task/Find-common-directory-path/GW-BASIC/find-common-directory-path.bas new file mode 100644 index 0000000000..1aa5832720 --- /dev/null +++ b/Task/Find-common-directory-path/GW-BASIC/find-common-directory-path.bas @@ -0,0 +1,29 @@ +10 REM All GOTO statements can be replaced with EXIT FOR in newer BASICs. + +110 X$ = "/home/user1/tmp/coverage/test" +120 Y$ = "/home/user1/tmp/covert/operator" +130 Z$ = "/home/user1/tmp/coven/members" + +150 A = LEN(X$) +160 IF A > LEN(Y$) THEN A = LEN(Y$) +170 IF A > LEN(Z$) THEN A = LEN(Z$) +180 FOR L0 = 1 TO A +190 IF MID$(X$, L0, 1) <> MID$(Y$, L0, 1) THEN GOTO 210 +200 NEXT +210 A = L0 - 1 + +230 FOR L0 = 1 TO A +240 IF MID$(X$, L0, 1) <> MID$(Z$, L0, 1) THEN GOTO 260 +250 NEXT +260 A = L0 - 1 + +280 IF MID$(X$, L0, 1) <> "/" THEN +290 FOR L0 = A TO 1 STEP -1 +300 IF "/" = MID$(X$, L0, 1) THEN GOTO 340 +310 NEXT +320 END IF + +340 REM Task description says no trailing slash, so... +350 A = L0 - 1 +360 P$ = LEFT$(X$, A) +370 PRINT "Common path is '"; P$; "'" diff --git a/Task/Find-common-directory-path/Go/find-common-directory-path.go b/Task/Find-common-directory-path/Go/find-common-directory-path.go new file mode 100644 index 0000000000..5863a0137b --- /dev/null +++ b/Task/Find-common-directory-path/Go/find-common-directory-path.go @@ -0,0 +1,77 @@ +package main + +import( + "fmt" + "path" + "strings" +) + +func CommonPrefix(sep string, paths ...string) (string) { + // Handle special cases. + switch len(paths) { + case 0: + return "" + case 1: + return path.Clean(paths[0]) + } + + c := []byte(path.Clean(paths[0])) + + // Ignore the first path since it's already in c. + for _, v := range(paths[1:]) { + // Clean up each path before testing it. + v = path.Clean(v) + + // Get the length of the shorter slice. + shorter := len(v) + if len(v) > len(c) { + shorter = len(c) + } + + // Find the first non-common character and copy up to it into c. + for i := 0; i < shorter; i++ { + if v[i] != c[i] { + c = c[0:i] + break + } + } + } + + // Correct for problem caused by prepending the actual common path to the + // list of paths searched through. + for _, v := range(paths) { + if len(v) > len(c) { + if strings.HasPrefix(v, string(c)) { + if len(v) > len(c) + len(sep) { + if v[len(c):len(c)+len(sep)] == sep { + c = append(c, []byte(sep)...) + break + } + } + } + } + } + + // Remove trailing non-seperator characters. + for i := len(c)-1; i >= 0; i-- { + if i + len(sep) > len(c) { + continue + } + + if string(c[i:i+len(sep)]) == sep { + c = c[0:i] + break + } + } + + return string(c) +} + +func main() { + c := CommonPrefix("/", + "/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members", + ) + fmt.Printf("%v\n", c) +} diff --git a/Task/Find-common-directory-path/Groovy/find-common-directory-path-1.groovy b/Task/Find-common-directory-path/Groovy/find-common-directory-path-1.groovy new file mode 100644 index 0000000000..3341cf17a5 --- /dev/null +++ b/Task/Find-common-directory-path/Groovy/find-common-directory-path-1.groovy @@ -0,0 +1,8 @@ +def commonPath = { delim, Object[] paths -> + def pathParts = paths.collect { it.split(delim) } + pathParts.transpose().inject([match:true, commonParts:[]]) { aggregator, part -> + aggregator.match = aggregator.match && part.every { it == part [0] } + if (aggregator.match) { aggregator.commonParts << part[0] } + aggregator + }.commonParts.join(delim) +} diff --git a/Task/Find-common-directory-path/Groovy/find-common-directory-path-2.groovy b/Task/Find-common-directory-path/Groovy/find-common-directory-path-2.groovy new file mode 100644 index 0000000000..91cb99d9ad --- /dev/null +++ b/Task/Find-common-directory-path/Groovy/find-common-directory-path-2.groovy @@ -0,0 +1,10 @@ +println commonPath('/', + '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', + '/home/user1/tmp/coven/members') + +println commonPath('/', + '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/test', + '/home/user1/tmp/coven/test', + '/home/user1/tmp/covers/test') diff --git a/Task/Find-common-directory-path/Haskell/find-common-directory-path.hs b/Task/Find-common-directory-path/Haskell/find-common-directory-path.hs new file mode 100644 index 0000000000..496fa99f0c --- /dev/null +++ b/Task/Find-common-directory-path/Haskell/find-common-directory-path.hs @@ -0,0 +1,23 @@ +import Data.List + +-- Return the common prefix of two lists. +commonPrefix2 (x:xs) (y:ys) | x == y = x : commonPrefix2 xs ys +commonPrefix2 _ _ = [] + +-- Return the common prefix of zero or more lists. +commonPrefix (xs:xss) = foldr commonPrefix2 xs xss +commonPrefix _ = [] + +-- Split a string into path components. +splitPath = groupBy (\_ c -> c /= '/') + +-- Return the common prefix of zero or more paths. +-- Note that '/' by itself is not considered a path component, +-- so "/" and "/foo" are treated as having nothing in common. +commonDirPath = concat . commonPrefix . map splitPath + +main = putStrLn $ commonDirPath [ + "/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members" + ] diff --git a/Task/Find-common-directory-path/HicEst/find-common-directory-path.hicest b/Task/Find-common-directory-path/HicEst/find-common-directory-path.hicest new file mode 100644 index 0000000000..f8a6a8719f --- /dev/null +++ b/Task/Find-common-directory-path/HicEst/find-common-directory-path.hicest @@ -0,0 +1,14 @@ +CHARACTER a='/home/user1/tmp/coverage/test', b='/home/user1/tmp/covert/operator', c='/home/user1/tmp/coven/members' + +minLength = MIN( LEN(a), LEN(b), LEN(c) ) +lastSlash = 0 + +DO i = 1, minLength + IF( (a(i) == b(i)) * (b(i) == c(i)) ) THEN + IF(a(i) == "/") lastSlash = i + ELSEIF( lastSlash ) THEN + WRITE(Messagebox) "Common Directory = ", a(1:lastSlash-1) + ELSE + WRITE(Messagebox, Name) "No common directory for", a, b, c + ENDIF +ENDDO diff --git a/Task/Find-common-directory-path/Icon/find-common-directory-path.icon b/Task/Find-common-directory-path/Icon/find-common-directory-path.icon new file mode 100644 index 0000000000..3200412ac6 --- /dev/null +++ b/Task/Find-common-directory-path/Icon/find-common-directory-path.icon @@ -0,0 +1,20 @@ +procedure main() +write(lcdsubstr(["/home/user1/tmp/coverage/test","/home/user1/tmp/covert/operator","/home/user1/tmp/coven/members"])) +end + +procedure lcdsubstr(sL,d) #: return the longest common sub-string of strings in the list sL delimited by d +local ss + +/d := "/" +reverse(sL[1]) ? { + if tab(find(d)+*d) || allmatch(ss := reverse(tab(0)),sL) then + return ss + } +end + +procedure allmatch(s,L) #: retrun s if it matches all strings in L +local x +every x := !L do + if not match(s,x) then fail +return s +end diff --git a/Task/Find-common-directory-path/J/find-common-directory-path-1.j b/Task/Find-common-directory-path/J/find-common-directory-path-1.j new file mode 100644 index 0000000000..5c8bcf3f7e --- /dev/null +++ b/Task/Find-common-directory-path/J/find-common-directory-path-1.j @@ -0,0 +1,4 @@ +parseDirs =: = <;.2 ] +getCommonPrefix =: {. ;@{.~ 0 i.~ *./@(="1 {.) + +getCommonDirPath=: [: getCommonPrefix parseDirs&> diff --git a/Task/Find-common-directory-path/J/find-common-directory-path-2.j b/Task/Find-common-directory-path/J/find-common-directory-path-2.j new file mode 100644 index 0000000000..221f4d67a4 --- /dev/null +++ b/Task/Find-common-directory-path/J/find-common-directory-path-2.j @@ -0,0 +1,5 @@ + paths=: '/home/user1/tmp/coverage/test';'/home/user1/tmp/covert/operator';'/home/user1/tmp/coven/members' + getCommonPrefix >paths +/home/user1/tmp/cove + '/' getCommonDirPath paths +/home/user1/tmp/ diff --git a/Task/Find-common-directory-path/J/find-common-directory-path-3.j b/Task/Find-common-directory-path/J/find-common-directory-path-3.j new file mode 100644 index 0000000000..339b8ac393 --- /dev/null +++ b/Task/Find-common-directory-path/J/find-common-directory-path-3.j @@ -0,0 +1 @@ +parseDirs =: (PATHSEP_j_&= <;.2 ])@jhostpath diff --git a/Task/Find-common-directory-path/Java/find-common-directory-path.java b/Task/Find-common-directory-path/Java/find-common-directory-path.java new file mode 100644 index 0000000000..6516f14a81 --- /dev/null +++ b/Task/Find-common-directory-path/Java/find-common-directory-path.java @@ -0,0 +1,39 @@ +public class CommonPath { + public static String commonPath(String... paths){ + String commonPath = ""; + String[][] folders = new String[paths.length][]; + for(int i = 0; i < paths.length; i++){ + folders[i] = paths[i].split("/"); //split on file separator + } + for(int j = 0; j < folders[0].length; j++){ + String thisFolder = folders[0][j]; //grab the next folder name in the first path + boolean allMatched = true; //assume all have matched in case there are no more paths + for(int i = 1; i < folders.length && allMatched; i++){ //look at the other paths + if(folders[i].length < j){ //if there is no folder here + allMatched = false; //no match + break; //stop looking because we've gone as far as we can + } + //otherwise + allMatched &= folders[i][j].equals(thisFolder); //check if it matched + } + if(allMatched){ //if they all matched this folder name + commonPath += thisFolder + "/"; //add it to the answer + }else{//otherwise + break;//stop looking + } + } + return commonPath; + } + + public static void main(String[] args){ + String[] paths = { "/home/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members"}; + System.out.println(commonPath(paths)); + + String[] paths2 = { "/hame/user1/tmp/coverage/test", + "/home/user1/tmp/covert/operator", + "/home/user1/tmp/coven/members"}; + System.out.println(commonPath(paths2)); + } +} diff --git a/Task/Find-common-directory-path/Liberty-BASIC/find-common-directory-path.liberty b/Task/Find-common-directory-path/Liberty-BASIC/find-common-directory-path.liberty new file mode 100644 index 0000000000..6fbfe1e557 --- /dev/null +++ b/Task/Find-common-directory-path/Liberty-BASIC/find-common-directory-path.liberty @@ -0,0 +1,25 @@ +path$(1) = "/home/user1/tmp/coverage/test" +path$(2) = "/home/user1/tmp/covert/operator" +path$(3) = "/home/user1/tmp/coven/members" + + +print samepath$(3,"/") +end + +function samepath$(paths,sep$) + d = 1 'directory depth + n = 2 'path$(number) + while 1 + if word$(path$(1),d,sep$) <> word$(path$(n),d,sep$) or word$(path$(1),d,sep$) = "" then exit while + n = n + 1 + if n > paths then + if right$(samepath$,1) <> sep$ and d<>1 then + samepath$ = samepath$ + sep$ + word$(path$(1),d,sep$) + else + samepath$ = samepath$ + word$(path$(1),d,sep$) + end if + n = 2 + d = d + 1 + end if + wend +end function diff --git a/Task/Find-common-directory-path/MUMPS/find-common-directory-path.mumps b/Task/Find-common-directory-path/MUMPS/find-common-directory-path.mumps new file mode 100644 index 0000000000..3af019bd0f --- /dev/null +++ b/Task/Find-common-directory-path/MUMPS/find-common-directory-path.mumps @@ -0,0 +1,15 @@ +FCD + NEW D,SEP,EQ,LONG,DONE,I,J,K,RETURN + SET D(1)="/home/user1/tmp/coverage/test" + SET D(2)="/home/user1/tmp/covert/operator" + SET D(3)="/home/user1/tmp/coven/members" + SET SEP="/" + SET LONG=D(1) + SET DONE=0 + FOR I=1:1:$LENGTH(LONG,SEP) QUIT:DONE SET EQ(I)=1 FOR J=2:1:3 SET EQ(I)=($PIECE(D(J),SEP,I)=$PIECE(LONG,SEP,I))&EQ(I) SET DONE='EQ(I) QUIT:'EQ(I) + SET RETURN="" + FOR K=1:1:I-1 Q:'EQ(K) SET:EQ(K) $PIECE(RETURN,SEP,K)=$PIECE(LONG,SEP,K) + WRITE !,"For the paths:" FOR I=1:1:3 WRITE !,D(I) + WRITE !,"The longest common directory is: ",RETURN + KILL D,SEP,EQ,LONG,DONE,I,J,K,RETURN + QUIT diff --git a/Task/Find-common-directory-path/Mathematica/find-common-directory-path.mathematica b/Task/Find-common-directory-path/Mathematica/find-common-directory-path.mathematica new file mode 100644 index 0000000000..461ff9bb0b --- /dev/null +++ b/Task/Find-common-directory-path/Mathematica/find-common-directory-path.mathematica @@ -0,0 +1,5 @@ +FindCommonDirectory[x_] := If[StringTake[#, -1] != "/", StringTake[#, Max[StringPosition[#, "/"]]], #] & + [Fold[LongestCommonSubsequence, First[x] , Rest[x]]] + +FindCommonDirectory[{"/home/user1/tmp/coverage/test", "/home/user1/tmp/covert/operator", "/home/user1/tmp/coven/members"}] +->"/home/user1/tmp/" diff --git a/Task/Find-common-directory-path/Maxima/find-common-directory-path.maxima b/Task/Find-common-directory-path/Maxima/find-common-directory-path.maxima new file mode 100644 index 0000000000..d569fa6c8a --- /dev/null +++ b/Task/Find-common-directory-path/Maxima/find-common-directory-path.maxima @@ -0,0 +1,11 @@ +scommon(a, b) := block([n: min(slength(a), slength(b))], + substring(a, 1, catch(for i thru n do ( + if not cequal(charat(a, i), charat(b, i)) then throw(i)), n + 1)))$ + +commonpath(u, [l]) := block([s: lreduce(scommon, u), c, n], + n: sposition(if length(l) = 0 then "/" else l[1], sreverse(s)), + if integerp(n) then substring(s, 1, slength(s) - n) else "" +)$ + +commonpath(["c:/files/banister.jpg", "c:/files/bank.xls", "c:/files/banana-recipes.txt"]); +"c:/files" diff --git a/Task/Find-common-directory-path/PHP/find-common-directory-path-1.php b/Task/Find-common-directory-path/PHP/find-common-directory-path-1.php new file mode 100644 index 0000000000..00a8cf41a4 --- /dev/null +++ b/Task/Find-common-directory-path/PHP/find-common-directory-path-1.php @@ -0,0 +1,57 @@ + $path) + { + $dirList[$i] = explode('/', $path); + unset($dirList[$i][0]); + + $arr[$i] = count($dirList[$i]); + } + + $min = min($arr); + + for($i = 0; $i < count($dirList); $i++) + { + while(count($dirList[$i]) > $min) + { + array_pop($dirList[$i]); + } + + $dirList[$i] = '/' . implode('/' , $dirList[$i]); + } + + $dirList = array_unique($dirList); + while(count($dirList) !== 1) + { + $dirList = array_map('dirname', $dirList); + $dirList = array_unique($dirList); + } + reset($dirList); + + return current($dirList); +} + + /* TEST */ + +$dirs = array( + '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', + '/home/user1/tmp/coven/members', +); + + +if('/home/user1/tmp' !== common_path($dirs)) +{ + echo 'test fail'; +} else { + echo 'test success'; +} + +?> diff --git a/Task/Find-common-directory-path/PHP/find-common-directory-path-2.php b/Task/Find-common-directory-path/PHP/find-common-directory-path-2.php new file mode 100644 index 0000000000..2c4518b21f --- /dev/null +++ b/Task/Find-common-directory-path/PHP/find-common-directory-path-2.php @@ -0,0 +1,22 @@ + diff --git a/Task/Find-common-directory-path/Perl/find-common-directory-path.pl b/Task/Find-common-directory-path/Perl/find-common-directory-path.pl new file mode 100644 index 0000000000..daeb8cc518 --- /dev/null +++ b/Task/Find-common-directory-path/Perl/find-common-directory-path.pl @@ -0,0 +1,19 @@ +use List::Util qw(max reduce); +sub compath { + my ($sep, @paths, %hash) = @_; + # Tokenize and tally subpaths + foreach (@paths) { + my @tok = split $sep, substr($_,1); + ++$hash{join $sep, @tok[0..$_]} for (0..$#tok); } + # Return max length subpath or null + my $max = max values %hash; + return '' unless $max == @paths; + my @res = grep {$hash{$_} == $max} keys %hash; + return $sep . reduce { length $a > length $b ? $a : $b } @res; +} + +# Test and display +my @paths = qw(/home/user1/tmp/coverage/test + /home/user1/tmp/covert/operator + /home/user1/tmp/coven/members); +print compath('/', @paths), "\n"; diff --git a/Task/Find-common-directory-path/PicoLisp/find-common-directory-path.l b/Task/Find-common-directory-path/PicoLisp/find-common-directory-path.l new file mode 100644 index 0000000000..24d0893dff --- /dev/null +++ b/Task/Find-common-directory-path/PicoLisp/find-common-directory-path.l @@ -0,0 +1,6 @@ +(de commonPath (Lst Chr) + (glue Chr + (make + (apply find + (mapcar '((L) (split (chop L) Chr)) Lst) + '(@ (or (pass <>) (nil (link (next))))) ) ) ) ) diff --git a/Task/Find-common-directory-path/Python/find-common-directory-path-1.py b/Task/Find-common-directory-path/Python/find-common-directory-path-1.py new file mode 100644 index 0000000000..de00cbb77c --- /dev/null +++ b/Task/Find-common-directory-path/Python/find-common-directory-path-1.py @@ -0,0 +1,4 @@ +>>> import os +>>> os.path.commonprefix(['/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members']) +'/home/user1/tmp/cove' diff --git a/Task/Find-common-directory-path/Python/find-common-directory-path-2.py b/Task/Find-common-directory-path/Python/find-common-directory-path-2.py new file mode 100644 index 0000000000..056d82d5f3 --- /dev/null +++ b/Task/Find-common-directory-path/Python/find-common-directory-path-2.py @@ -0,0 +1,6 @@ +>>> def commonprefix(*args, sep='/'): + return os.path.commonprefix(*args).rpartition(sep)[0] + +>>> commonprefix(['/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members']) +'/home/user1/tmp' diff --git a/Task/Find-common-directory-path/Python/find-common-directory-path-3.py b/Task/Find-common-directory-path/Python/find-common-directory-path-3.py new file mode 100644 index 0000000000..405c572993 --- /dev/null +++ b/Task/Find-common-directory-path/Python/find-common-directory-path-3.py @@ -0,0 +1,16 @@ +>>> from itertools import takewhile +>>> def allnamesequal(name): + return all(n==name[0] for n in name[1:]) + +>>> def commonprefix(paths, sep='/'): + bydirectorylevels = zip(*[p.split(sep) for p in paths]) + return sep.join(x[0] for x in takewhile(allnamesequal, bydirectorylevels)) + +>>> commonprefix(['/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members']) +'/home/user1/tmp' +>>> # And also +>>> commonprefix(['/home/user1/tmp', '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members']) +'/home/user1/tmp' +>>> diff --git a/Task/Find-common-directory-path/R/find-common-directory-path.r b/Task/Find-common-directory-path/R/find-common-directory-path.r new file mode 100644 index 0000000000..867c72fdd6 --- /dev/null +++ b/Task/Find-common-directory-path/R/find-common-directory-path.r @@ -0,0 +1,21 @@ +get_common_dir <- function(paths, delim = "/") +{ + path_chunks <- strsplit(paths, delim) + + i <- 1 + repeat({ + current_chunk <- sapply(path_chunks, function(x) x[i]) + if(any(current_chunk != current_chunk[1])) break + i <- i + 1 + }) + paste(path_chunks[[1]][seq_len(i - 1)], collapse = delim) + +} + +# Example Usage: +paths <- c( + '/home/user1/tmp/coverage/test', + '/home/user1/tmp/covert/operator', + '/home/user1/tmp/coven/members') + +get_common_dir(paths) # "/home/user1/tmp" diff --git a/Task/Find-common-directory-path/REXX/find-common-directory-path.rexx b/Task/Find-common-directory-path/REXX/find-common-directory-path.rexx new file mode 100644 index 0000000000..1e426720e8 --- /dev/null +++ b/Task/Find-common-directory-path/REXX/find-common-directory-path.rexx @@ -0,0 +1,15 @@ +/*REXX program finds common directory path for a list of files. */ +@.= /*define all file lists to null. */ +@.1 = '/home/user1/tmp/coverage/test' +@.2 = '/home/user1/tmp/covert/operator' +@.3 = '/home/user1/tmp/coven/members' +L=length(@.1) + do j=2 while @.j\=='' /*start with the second string. */ + _ = compare(@.j,@.1); if _==0 then iterate /*equal.*/ + L = min(L,_) /*find the minimum equal strings.*/ + end /*j*/ + +common = left(@.1,lastpos('/',@.1,L)) /*find the shortest DIR string.*/ +if right(common,1)=='/' then common=left(common, max(0,length(common)-1)) +say 'common directory path: ' common /*[↑] handle trailing / delimiter*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Find-common-directory-path/Ruby/find-common-directory-path-1.rb b/Task/Find-common-directory-path/Ruby/find-common-directory-path-1.rb new file mode 100644 index 0000000000..3868e92847 --- /dev/null +++ b/Task/Find-common-directory-path/Ruby/find-common-directory-path-1.rb @@ -0,0 +1,6 @@ +require 'abbrev' + +dirs = %w( /home/user1/tmp/coverage/test /home/user1/tmp/covert/operator /home/user1/tmp/coven/members ) + +common_prefix = dirs.abbrev.keys.min_by {|key| key.length}.chop # => "/home/user1/tmp/cove" +common_directory = common_prefix.sub(%r{/[^/]*$}, '') # => "/home/user1/tmp" diff --git a/Task/Find-common-directory-path/Ruby/find-common-directory-path-2.rb b/Task/Find-common-directory-path/Ruby/find-common-directory-path-2.rb new file mode 100644 index 0000000000..efa556ad2a --- /dev/null +++ b/Task/Find-common-directory-path/Ruby/find-common-directory-path-2.rb @@ -0,0 +1,4 @@ +separator = '/' +paths = dirs.collect {|dir| dir.split(separator)} +uncommon_idx = paths.transpose.each_with_index.find {|dirnames, idx| dirnames.uniq.length > 1}.last +common_directory = paths[0][0 ... uncommon_idx].join(separator) # => "/home/user1/tmp" diff --git a/Task/Find-common-directory-path/Tcl/find-common-directory-path.tcl b/Task/Find-common-directory-path/Tcl/find-common-directory-path.tcl new file mode 100644 index 0000000000..05bc97393d --- /dev/null +++ b/Task/Find-common-directory-path/Tcl/find-common-directory-path.tcl @@ -0,0 +1,19 @@ +package require Tcl 8.5 +proc pop {varname} { + upvar 1 $varname var + set var [lassign $var head] + return $head +} + +proc common_prefix {dirs {separator "/"}} { + set parts [split [pop dirs] $separator] + while {[llength $dirs]} { + set r {} + foreach cmp $parts elt [split [pop dirs] $separator] { + if {$cmp ne $elt} break + lappend r $cmp + } + set parts $r + } + return [join $parts $separator] +} diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/0DESCRIPTION b/Task/Find-largest-left-truncatable-prime-in-a-given-base/0DESCRIPTION new file mode 100644 index 0000000000..351df6c231 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/0DESCRIPTION @@ -0,0 +1,12 @@ +A [[Truncatable primes|truncatable prime]] is one where all non-empty substrings that finish at the end of the number (right-substrings) are also primes ''when understood as numbers in a particular base''. The largest such prime in a given (integer) base is therefore computable, provided the base is larger than 2. + +Let's consider what happens in base 10. Obviously the right most digit must be prime, so in base 10 candidates are 2,3,5,7. Putting a digit in the range 1 to base-1 in front of each candidate must result in a prime. So 2 and 5, like the whale and the petunias in ''The Hitchhiker's Guide to the Galaxy'', come into existance only to be extinguished before they have time to realize it. 13,17, ... 83,97 are candidates. Again, putting a digit in the range 1 to base-1 in front of each candidate must be a prime. Repeating until there are no larger candidates finds the largest left truncatable prime. + +Let's work base 3 by hand: + +0 and 1 are not prime so the last digit must be 2. 123 = 510 which is prime, 223 = 810 which is not so 123 is the only candidate. 1123 = 1410 which is not prime, 2123 = 2310 which is, so 2123 is the only candidate. 12123 = 5010 which is not prime, 22123 = 7710 which also is not prime. So there are no more candidates, therefore 23 is the largest left truncatable prime in base 3. + +The task is to reconstruct as much, and possibly more, of the table in [https://oeis.org/A103443 the OEIS] as you are able. + +Related Tasks: +* [[Miller-Rabin primality test]] diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/BBC-BASIC/find-largest-left-truncatable-prime-in-a-given-base.bbc b/Task/Find-largest-left-truncatable-prime-in-a-given-base/BBC-BASIC/find-largest-left-truncatable-prime-in-a-given-base.bbc new file mode 100644 index 0000000000..c7e4af78a4 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/BBC-BASIC/find-largest-left-truncatable-prime-in-a-given-base.bbc @@ -0,0 +1,41 @@ + HIMEM = PAGE + 3000000 + INSTALL @lib$+"HIMELIB" + PROC_himeinit("HIMEkey") + + DIM old$(20000), new$(20000) + h1% = 1 : h2% = 2 : h3% = 3 : h4% = 4 + + FOR base% = 3 TO 17 + PRINT "Base "; base% " : " FN_largest_left_truncated_prime(base%) + NEXT + END + + DEF FN_largest_left_truncated_prime(base%) + LOCAL digit%, i%, new%, old%, prime%, fast%, slow% + fast% = 1 : slow% = 50 + old$() = "" + PROC_hiputdec(1, STR$(base%)) + PROC_hiputdec(2, "1") + REPEAT + new% = 0 : new$() = "" + PROC_hiputdec(3, "0") + FOR digit% = 1 TO base%-1 + SYS `hi_Add`, ^h2%, ^h3%, ^h3% + FOR i% = 0 TO old%-1 + PROC_hiputdec(4, old$(i%)) + SYS `hi_Add`, ^h3%, ^h4%, ^h4% + IF old% OR digit% > 1 THEN + IF old% > 100 THEN + SYS `hi_IsPrime_RB`, ^fast%, ^h4% TO prime% + ELSE + SYS `hi_IsPrime_RB`, ^slow%, ^h4% TO prime% + ENDIF + IF prime% THEN new$(new%) = FN_higetdec(4) : new% += 1 + ENDIF + NEXT + NEXT + SYS `hi_Mul`, ^h1%, ^h2%, ^h2% + SWAP old$(), new$() + SWAP old%, new% + UNTIL old% = 0 + = new$(new%-1) diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/C/find-largest-left-truncatable-prime-in-a-given-base.c b/Task/Find-largest-left-truncatable-prime-in-a-given-base/C/find-largest-left-truncatable-prime-in-a-given-base.c new file mode 100644 index 0000000000..3a51f302e8 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/C/find-largest-left-truncatable-prime-in-a-given-base.c @@ -0,0 +1,64 @@ +#include +#include + +typedef unsigned long ulong; + +ulong small_primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41, + 43,47,53,59,61,67,71,73,79,83,89,97}; + +#define MAX_STACK 128 +mpz_t tens[MAX_STACK], value[MAX_STACK], answer; + +ulong base, seen_depth; + +void add_digit(ulong i) +{ + ulong d; + for (d = 1; d < base; d++) { + mpz_set(value[i], value[i-1]); + mpz_addmul_ui(value[i], tens[i], d); + if (!mpz_probab_prime_p(value[i], 1)) continue; + + if (i > seen_depth || + (i == seen_depth && mpz_cmp(value[i], answer) == 1)) + { + if (!mpz_probab_prime_p(value[i], 50)) continue; + + mpz_set(answer, value[i]); + seen_depth = i; + gmp_fprintf(stderr, "\tb=%lu d=%2lu | %Zd\n", base, i, answer); + } + + add_digit(i+1); + } +} + +void do_base() +{ + ulong i; + mpz_set_ui(answer, 0); + mpz_set_ui(tens[0], 1); + for (i = 1; i < MAX_STACK; i++) + mpz_mul_ui(tens[i], tens[i-1], base); + + for (seen_depth = i = 0; small_primes[i] < base; i++) { + fprintf(stderr, "\tb=%lu digit %lu\n", base, small_primes[i]); + mpz_set_ui(value[0], small_primes[i]); + add_digit(1); + } + gmp_printf("%d: %Zd\n", base, answer); +} + +int main(void) +{ + ulong i; + for (i = 0; i < MAX_STACK; i++) { + mpz_init_set_ui(tens[i], 0); + mpz_init_set_ui(value[i], 0); + } + mpz_init_set_ui(answer, 0); + + for (base = 22; base < 30; base++) do_base(); + + return 0; +} diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Haskell/find-largest-left-truncatable-prime-in-a-given-base.hs b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Haskell/find-largest-left-truncatable-prime-in-a-given-base.hs new file mode 100644 index 0000000000..5cb9405a44 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Haskell/find-largest-left-truncatable-prime-in-a-given-base.hs @@ -0,0 +1,66 @@ +primesTo100 = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] + +-- (eq. to) find2km (2^k * n) = (k,n) +find2km :: Integral a => a -> (Int,a) +find2km n = f 0 n + where f k m + | r == 1 = (k,m) + | otherwise = f (k+1) q + where (q,r) = quotRem m 2 + +-- n is the number to test; a is the (presumably randomly chosen) witness +millerRabinPrimality :: Integer -> Integer -> Bool +millerRabinPrimality n a + | a >= n_ = True + | b0 == 1 || b0 == n_ = True + | otherwise = iter (tail b) + where + n_ = n-1 + (k,m) = find2km n_ + b0 = powMod n a m + b = take k $ iterate (squareMod n) b0 + iter [] = False + iter (x:xs) + | x == 1 = False + | x == n_ = True + | otherwise = iter xs + +-- (eq. to) pow_ (*) (^2) n k = n^k +pow_ :: (Num a, Integral b) => (a->a->a) -> (a->a) -> a -> b -> a +pow_ _ _ _ 0 = 1 +pow_ mul sq x_ n_ = f x_ n_ 1 + where + f x n y + | n == 1 = x `mul` y + | r == 0 = f x2 q y + | otherwise = f x2 q (x `mul` y) + where + (q,r) = quotRem n 2 + x2 = sq x + +mulMod :: Integral a => a -> a -> a -> a +mulMod a b c = (b * c) `mod` a +squareMod :: Integral a => a -> a -> a +squareMod a b = (b * b) `rem` a + +-- (eq. to) powMod m n k = n^k `mod` m +powMod :: Integral a => a -> a -> a -> a +powMod m = pow_ (mulMod m) (squareMod m) + +-- Caller supplies a witness list w, which may be used for MR test. +-- Use faster trial division against a small primes list first, to +-- weed out more obvious composites. +is_prime w n + | n < 100 = n `elem` primesTo100 + | any ((==0).(n`mod`)) primesTo100 = False + | otherwise = all (millerRabinPrimality n) w + +-- final result gets a more thorough Miller-Rabin +left_trunc base = head $ filter (is_prime primesTo100) (reverse hopeful) where + hopeful = extend base $ takeWhile ((x, left_trunc x)) [3..21] diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/J/find-largest-left-truncatable-prime-in-a-given-base.j b/Task/Find-largest-left-truncatable-prime-in-a-given-base/J/find-largest-left-truncatable-prime-in-a-given-base.j new file mode 100644 index 0000000000..d8e11c81be --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/J/find-largest-left-truncatable-prime-in-a-given-base.j @@ -0,0 +1,30 @@ +Filter=: (#~`)(`:6) +Filter=: (#~`)(`:6) + +f=: 3 : 0 +BASE=. y +primes=. (1&p:)Filter +DIGITS=. }. i. x: BASE +R=. 0 +A=. ,0 +while. #A do. + R=. >: R + B=. A + A=. primes , , A +/ BASE #. (_,R) {. ,. DIGITS +end. +>./ B +) +l +NB. f N where N is the base. + (,. f"0) (3+i.8) + 3 23 + 4 4091 + 5 7817 + 6 4836525320399 + 7 817337 + 8 14005650767869 + 9 1676456897 +10 357686312646216567629137 + + f 11 +2276005673 diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Java/find-largest-left-truncatable-prime-in-a-given-base.java b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Java/find-largest-left-truncatable-prime-in-a-given-base.java new file mode 100644 index 0000000000..ba4a2ecd52 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Java/find-largest-left-truncatable-prime-in-a-given-base.java @@ -0,0 +1,51 @@ +import java.math.BigInteger; +import java.util.*; + +class LeftTruncatablePrime +{ + private static List getNextLeftTruncatablePrimes(BigInteger n, int radix, int millerRabinCertainty) + { + List probablePrimes = new ArrayList(); + String baseString = n.equals(BigInteger.ZERO) ? "" : n.toString(radix); + for (int i = 1; i < radix; i++) + { + BigInteger p = new BigInteger(Integer.toString(i, radix) + baseString, radix); + if (p.isProbablePrime(millerRabinCertainty)) + probablePrimes.add(p); + } + return probablePrimes; + } + + public static BigInteger getLargestLeftTruncatablePrime(int radix, int millerRabinCertainty) + { + List lastList = null; + List list = getNextLeftTruncatablePrimes(BigInteger.ZERO, radix, millerRabinCertainty); + while (!list.isEmpty()) + { + lastList = list; + list = new ArrayList(); + for (BigInteger n : lastList) + list.addAll(getNextLeftTruncatablePrimes(n, radix, millerRabinCertainty)); + } + if (lastList == null) + return null; + Collections.sort(lastList); + return lastList.get(lastList.size() - 1); + } + + public static void main(String[] args) + { + int maxRadix = Integer.parseInt(args[0]); + int millerRabinCertainty = Integer.parseInt(args[1]); + for (int radix = 3; radix <= maxRadix; radix++) + { + BigInteger largest = getLargestLeftTruncatablePrime(radix, millerRabinCertainty); + System.out.print("n=" + radix + ": "); + if (largest == null) + System.out.println("No left-truncatable prime"); + else + System.out.println(largest + " (in base " + radix + "): " + largest.toString(radix)); + } + } + +} diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-1.mathematica b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-1.mathematica new file mode 100644 index 0000000000..f7f727e78e --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-1.mathematica @@ -0,0 +1,5 @@ +LargestLeftTruncatablePrimeInBase[n_] := + Max[NestWhile[{Select[ + Flatten@Outer[Function[{a, b}, #[[2]] a + b], + Range[1, n - 1], #[[1]]], PrimeQ], n #[[2]]} &, {{0}, + 1}, #[[1]] != {} &, 1, Infinity, -1][[1]]] diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-2.mathematica b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-2.mathematica new file mode 100644 index 0000000000..ff941a21d0 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Mathematica/find-largest-left-truncatable-prime-in-a-given-base-2.mathematica @@ -0,0 +1 @@ +Do[Print[n, "\t", LargestLeftTruncatablePrimeInBase@n], {n, 3, 17}] diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-1.rb b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-1.rb new file mode 100644 index 0000000000..fba1781ae4 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-1.rb @@ -0,0 +1,22 @@ +# Compute the largest left truncatable prime +# +# Nigel_Galloway +# September 15th., 2012. +# +require 'prime' +BASE = 3 +MAX = 500 +stems = Prime.each(BASE-1).to_a +(1..MAX-1).each {|i| + print "#{stems.length} " + t = [] + b = BASE ** i + stems.each {|z| + (1..BASE-1).each {|n| + c = n*b+z + t.push(c) if c.prime? + }} + break if t.empty? + stems = t +} +puts "The largest left truncatable prime #{"less than #{BASE ** MAX} " if MAX < 500}in base #{BASE} is #{stems.max}" diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-2.rb b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-2.rb new file mode 100644 index 0000000000..4923e46719 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Ruby/find-largest-left-truncatable-prime-in-a-given-base-2.rb @@ -0,0 +1,23 @@ +# Compute the largest left truncatable prime +# +# Nigel_Galloway +# September 15th., 2012. +# +require 'prime' +require 'java' +BASE = 10 +MAX = 500 +stems = Prime.each(BASE-1).to_a +(1..MAX-1).each {|i| + print "#{stems.length} " + t = [] + b = BASE ** i + stems.each {|z| + (1..BASE-1).each {|n| + c = n*b+z + t.push(c) if java.math.BigInteger.new(c.to_s).isProbablePrime(100) + }} + break if t.empty? + stems = t +} +puts "\nThe largest left truncatable prime #{"less than #{BASE ** MAX} " if MAX < 500}in base #{BASE} is #{stems.max}" diff --git a/Task/Find-largest-left-truncatable-prime-in-a-given-base/Tcl/find-largest-left-truncatable-prime-in-a-given-base.tcl b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Tcl/find-largest-left-truncatable-prime-in-a-given-base.tcl new file mode 100644 index 0000000000..7190dba1f8 --- /dev/null +++ b/Task/Find-largest-left-truncatable-prime-in-a-given-base/Tcl/find-largest-left-truncatable-prime-in-a-given-base.tcl @@ -0,0 +1,74 @@ +package require Tcl 8.5 + +proc tcl::mathfunc::modexp {a b n} { + for {set c 1} {$b} {set a [expr {$a*$a%$n}]} { + if {$b & 1} { + set c [expr {$c*$a%$n}] + } + set b [expr {$b >> 1}] + } + return $c +} +# Based on Miller-Rabin primality testing, but with small prime check first +proc is_prime {n {count 10}} { + # fast check against small primes + foreach p { + 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 + } { + if {$n == $p} {return true} + if {$n % $p == 0} {return false} + } + + # write n-1 as 2^s·d with d odd by factoring powers of 2 from n-1 + set d [expr {$n - 1}] + for {set s 0} {$d & 1 == 0} {incr s} { + set d [expr {$d >> 1}] + } + + for {} {$count > 0} {incr count -1} { + set a [expr {2 + int(rand()*($n - 4))}] + set x [expr {modexp($a, $d, $n)}] + if {$x == 1 || $x == $n - 1} continue + for {set r 1} {$r < $s} {incr r} { + set x [expr {modexp($x, 2, $n)}] + if {$x == 1} {return false} + if {$x == $n - 1} break + } + if {$x != $n-1} {return false} + } + return true +} + +proc max_left_truncatable_prime {base} { + set stems {} + for {set i 2} {$i < $base} {incr i} { + if {[is_prime $i]} { + lappend stems $i + } + } + set primes $stems + set size 0 + for {set b $base} {[llength $stems]} {set b [expr {$b * $base}]} { + # Progress monitoring is nice once we get to 10 and beyond... + if {$base > 9} { + puts "\t[llength $stems] candidates at length [incr size]" + } + set primes $stems + set certainty [expr {[llength $primes] > 100 ? 1 : 5}] + set stems {} + foreach s $primes { + for {set i 1} {$i < $base} {incr i} { + set n [expr {$b*$i + $s}] + if {[is_prime $n $certainty]} { + lappend stems $n + } + } + } + } + # Could be several at same length; choose largest + return [tcl::mathfunc::max {*}$primes] +} + +for {set i 3} {$i <= 20} {incr i} { + puts "$i: [max_left_truncatable_prime $i]" +} diff --git a/Task/Find-limit-of-recursion/0DESCRIPTION b/Task/Find-limit-of-recursion/0DESCRIPTION new file mode 100644 index 0000000000..dca806d9af --- /dev/null +++ b/Task/Find-limit-of-recursion/0DESCRIPTION @@ -0,0 +1 @@ +{{selection|Short Circuit|Console Program Basics}}[[Category:Basic language learning]][[Category:Programming environment operations]]Find the limit of recursion. diff --git a/Task/Find-limit-of-recursion/ACL2/find-limit-of-recursion.acl2 b/Task/Find-limit-of-recursion/ACL2/find-limit-of-recursion.acl2 new file mode 100644 index 0000000000..09f371d47c --- /dev/null +++ b/Task/Find-limit-of-recursion/ACL2/find-limit-of-recursion.acl2 @@ -0,0 +1,5 @@ +(defun recursion-limit (x) + (if (zp x) + 0 + (prog2$ (cw "~x0~%" x) + (1+ (recursion-limit (1+ x)))))) diff --git a/Task/Find-limit-of-recursion/AWK/find-limit-of-recursion.awk b/Task/Find-limit-of-recursion/AWK/find-limit-of-recursion.awk new file mode 100644 index 0000000000..07f0f672ee --- /dev/null +++ b/Task/Find-limit-of-recursion/AWK/find-limit-of-recursion.awk @@ -0,0 +1,22 @@ +# syntax: GAWK -f FIND_LIMIT_OF_RECURSION.AWK +# +# version depth messages +# ------------------ ----- -------- +# GAWK 3.1.4 2892 none +# XML GAWK 3.1.4 3026 none +# GAWK 4.0 >999999 +# MAWK 1.3.3 4976 A stack overflow was encountered at +# address 0x7c91224e. +# TAWK-DOS AWK 5.0c 357 stack overflow +# TAWK-WIN AWKW 5.0c 2477 awk stack overflow +# NAWK 20100523 4351 Segmentation fault (core dumped) +# +BEGIN { + x() + print("done") +} +function x() { + print(++n) + if (n > 999999) { return } + x() +} diff --git a/Task/Find-limit-of-recursion/Ada/find-limit-of-recursion.ada b/Task/Find-limit-of-recursion/Ada/find-limit-of-recursion.ada new file mode 100644 index 0000000000..e8e1c4609e --- /dev/null +++ b/Task/Find-limit-of-recursion/Ada/find-limit-of-recursion.ada @@ -0,0 +1,13 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Recursion_Depth is + function Recursion (Depth : Positive) return Positive is + begin + return Recursion (Depth + 1); + exception + when Storage_Error => + return Depth; + end Recursion; +begin + Put_Line ("Recursion depth on this system is" & Integer'Image (Recursion (1))); +end Test_Recursion_Depth; diff --git a/Task/Find-limit-of-recursion/AutoHotkey/find-limit-of-recursion.ahk b/Task/Find-limit-of-recursion/AutoHotkey/find-limit-of-recursion.ahk new file mode 100644 index 0000000000..1b5120edb0 --- /dev/null +++ b/Task/Find-limit-of-recursion/AutoHotkey/find-limit-of-recursion.ahk @@ -0,0 +1,7 @@ +Recurse(0) + +Recurse(x) +{ + TrayTip, Number, %x% + Recurse(x+1) +} diff --git a/Task/Find-limit-of-recursion/AutoIt/find-limit-of-recursion.autoit b/Task/Find-limit-of-recursion/AutoIt/find-limit-of-recursion.autoit new file mode 100644 index 0000000000..bee56a0e4b --- /dev/null +++ b/Task/Find-limit-of-recursion/AutoIt/find-limit-of-recursion.autoit @@ -0,0 +1,7 @@ +;AutoIt Version: 3.2.10.0 +$depth=0 +recurse($depth) +Func recurse($depth) + ConsoleWrite($depth&@CRLF) + Return recurse($depth+1) +EndFunc diff --git a/Task/Find-limit-of-recursion/BASIC/find-limit-of-recursion.bas b/Task/Find-limit-of-recursion/BASIC/find-limit-of-recursion.bas new file mode 100644 index 0000000000..2bd41e4da2 --- /dev/null +++ b/Task/Find-limit-of-recursion/BASIC/find-limit-of-recursion.bas @@ -0,0 +1,6 @@ +10 LET d=0: REM depth +100 PRINT AT 1,1; "Recursion depth: ";d +110 LET d=d+1 +120 GO SUB 100: REM recursion +130 RETURN: REM this is never reached +200 STOP diff --git a/Task/Find-limit-of-recursion/BBC-BASIC/find-limit-of-recursion.bbc b/Task/Find-limit-of-recursion/BBC-BASIC/find-limit-of-recursion.bbc new file mode 100644 index 0000000000..8ba9ab4844 --- /dev/null +++ b/Task/Find-limit-of-recursion/BBC-BASIC/find-limit-of-recursion.bbc @@ -0,0 +1,7 @@ + PROCrecurse(1) + END + + DEF PROCrecurse(depth%) + IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%; + PROCrecurse(depth% + 1) + ENDPROC diff --git a/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-1.bat b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-1.bat new file mode 100644 index 0000000000..0b964642c8 --- /dev/null +++ b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-1.bat @@ -0,0 +1,6 @@ +@echo off +set /a c=c+1 +echo [Depth %c%] Mung until no good +cmd /c mung.cmd +echo [Depth %c%] No good +set /a c=c-1 diff --git a/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-2.bat b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-2.bat new file mode 100644 index 0000000000..375e645b22 --- /dev/null +++ b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-2.bat @@ -0,0 +1,6 @@ +@echo off +set /a c=c+1 +echo [Depth %c%] Mung until no good +call mung.cmd +echo [Depth %c%] No good +set /a c=c-1 diff --git a/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-3.bat b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-3.bat new file mode 100644 index 0000000000..5e61d0b3b2 --- /dev/null +++ b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-3.bat @@ -0,0 +1,8 @@ +@echo off +set c=0 +:mung +set /a c=c+1 +echo [Level %c%] Mung until no good +call :mung +set /a c=c-1 +echo [Level %c%] No good diff --git a/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-4.bat b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-4.bat new file mode 100644 index 0000000000..e1452f6c7f --- /dev/null +++ b/Task/Find-limit-of-recursion/Batch-File/find-limit-of-recursion-4.bat @@ -0,0 +1,9 @@ +@echo off +set c=0 +:mung +set /a c=%1+1 +if %c%==10 goto :eof +echo [Level %c%] Mung until no good +call :mung %c% +set /a c=%1-1 +echo [Level %c%] No good diff --git a/Task/Find-limit-of-recursion/Bracmat/find-limit-of-recursion.bracmat b/Task/Find-limit-of-recursion/Bracmat/find-limit-of-recursion.bracmat new file mode 100644 index 0000000000..535dcae1bf --- /dev/null +++ b/Task/Find-limit-of-recursion/Bracmat/find-limit-of-recursion.bracmat @@ -0,0 +1 @@ +rec=.out$!arg&rec$(!arg+1) diff --git a/Task/Find-limit-of-recursion/C/find-limit-of-recursion-1.c b/Task/Find-limit-of-recursion/C/find-limit-of-recursion-1.c new file mode 100644 index 0000000000..3b5004a74c --- /dev/null +++ b/Task/Find-limit-of-recursion/C/find-limit-of-recursion-1.c @@ -0,0 +1,13 @@ +#include + +void recurse(unsigned int i) +{ + printf("%d\n", i); + recurse(i+1); // 523756 +} + +int main() +{ + recurse(0); + return 0; +} diff --git a/Task/Find-limit-of-recursion/C/find-limit-of-recursion-2.c b/Task/Find-limit-of-recursion/C/find-limit-of-recursion-2.c new file mode 100644 index 0000000000..567aba2628 --- /dev/null +++ b/Task/Find-limit-of-recursion/C/find-limit-of-recursion-2.c @@ -0,0 +1,23 @@ +#include + +char * base; +void get_diff() +{ + char x; + if (base - &x < 200) + printf("%p %d\n", &x, base - &x); +} + +void recur() +{ + get_diff(); + recur(); +} + +int main() +{ + char v = 32; + printf("pos of v: %p\n", base = &v); + recur(); + return 0; +} diff --git a/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-1.cobol b/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-1.cobol new file mode 100644 index 0000000000..a619c8d846 --- /dev/null +++ b/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-1.cobol @@ -0,0 +1,50 @@ +identification division. +program-id. recurse. +data division. +working-storage section. +01 depth-counter pic 9(3). +01 install-address usage is procedure-pointer. +01 install-flag pic x comp-x value 0. +01 status-code pic x(2) comp-5. +01 ind pic s9(9) comp-5. + + +linkage section. +01 err-msg pic x(325). + +procedure division. +100-main. + + set install-address to entry "300-err". + + call "CBL_ERROR_PROC" using install-flag + install-address + returning status-code. + + if status-code not = 0 + display "ERROR INSTALLING ERROR PROC" + stop run + end-if + + move 0 to depth-counter. + display 'Mung until no good.'. + perform 200-mung. + display 'No good.'. + stop run. + +200-mung. + add 1 to depth-counter. + display depth-counter. + perform 200-mung. +300-err. + entry "300-err" using err-msg. + perform varying ind from 1 by 1 + until (err-msg(ind:1) = x"00") or (ind = length of err-msg) + continue + end-perform + + display err-msg(1:ind). + +*> room for a better-than-abrupt death here. + + exit program. diff --git a/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-2.cobol b/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-2.cobol new file mode 100644 index 0000000000..c72adb6338 --- /dev/null +++ b/Task/Find-limit-of-recursion/COBOL/find-limit-of-recursion-2.cobol @@ -0,0 +1,25 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. recurse RECURSIVE. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 Starter PIC S9(8) VALUE 1. + PROCEDURE DIVISION. + Program-Recurse. + CALL "recurse-sub" USING Starter + STOP RUN. + + IDENTIFICATION DIVISION. + PROGRAM-ID. recurse-sub. + DATA DIVISION. + WORKING-STORAGE SECTION. + LINKAGE SECTION. + 01 Countr PIC S9(8). + PROCEDURE DIVISION USING Countr. + Program-Recursive. + DISPLAY Countr + ADD 1 TO Countr + CALL "recurse-sub" USING Countr + + EXIT PROGRAM. + END PROGRAM recurse-sub. + END PROGRAM recurse. diff --git a/Task/Find-limit-of-recursion/Clojure/find-limit-of-recursion.clj b/Task/Find-limit-of-recursion/Clojure/find-limit-of-recursion.clj new file mode 100644 index 0000000000..c70e538fc4 --- /dev/null +++ b/Task/Find-limit-of-recursion/Clojure/find-limit-of-recursion.clj @@ -0,0 +1,5 @@ +=> (def *stack* 0) +=> ((fn overflow [] ((def *stack* (inc *stack*))(overflow)))) +java.lang.StackOverflowError (NO_SOURCE_FILE:0) +=> *stack* +10498 diff --git a/Task/Find-limit-of-recursion/Common-Lisp/find-limit-of-recursion.lisp b/Task/Find-limit-of-recursion/Common-Lisp/find-limit-of-recursion.lisp new file mode 100644 index 0000000000..a0eddcc048 --- /dev/null +++ b/Task/Find-limit-of-recursion/Common-Lisp/find-limit-of-recursion.lisp @@ -0,0 +1,3 @@ +(defun recurse () (recurse)) +(trace recurse) +(recurse) diff --git a/Task/Find-limit-of-recursion/D/find-limit-of-recursion.d b/Task/Find-limit-of-recursion/D/find-limit-of-recursion.d new file mode 100644 index 0000000000..530f28aa5e --- /dev/null +++ b/Task/Find-limit-of-recursion/D/find-limit-of-recursion.d @@ -0,0 +1,10 @@ +import std.c.stdio; + +void recurse(in uint i=0) { + printf("%u ", i); + recurse(i + 1); +} + +void main() { + recurse(); +} diff --git a/Task/Find-limit-of-recursion/DWScript/find-limit-of-recursion.dwscript b/Task/Find-limit-of-recursion/DWScript/find-limit-of-recursion.dwscript new file mode 100644 index 0000000000..eeb0b58605 --- /dev/null +++ b/Task/Find-limit-of-recursion/DWScript/find-limit-of-recursion.dwscript @@ -0,0 +1,14 @@ +var level : Integer; + +procedure Recursive; +begin + Inc(level); + try + Recursive; + except + end; +end; + +Recursive; + +Println('Recursion Level is ' + IntToStr(level)); diff --git a/Task/Find-limit-of-recursion/Delphi/find-limit-of-recursion.delphi b/Task/Find-limit-of-recursion/Delphi/find-limit-of-recursion.delphi new file mode 100644 index 0000000000..e37e0a3141 --- /dev/null +++ b/Task/Find-limit-of-recursion/Delphi/find-limit-of-recursion.delphi @@ -0,0 +1,21 @@ +program Project2; +{$APPTYPE CONSOLE} +uses + SysUtils; + +function Recursive(Level : Integer) : Integer; +begin + try + Level := Level + 1; + Result := Recursive(Level); + except + on E: EStackOverflow do + Result := Level; + end; +end; + +begin + Writeln('Recursion Level is ', Recursive(0)); + Writeln('Press any key to Exit'); + Readln; +end. diff --git a/Task/Find-limit-of-recursion/Emacs-Lisp/find-limit-of-recursion.l b/Task/Find-limit-of-recursion/Emacs-Lisp/find-limit-of-recursion.l new file mode 100644 index 0000000000..52984aef0c --- /dev/null +++ b/Task/Find-limit-of-recursion/Emacs-Lisp/find-limit-of-recursion.l @@ -0,0 +1,6 @@ +(defun my-recurse (n) + (my-recurse (1+ n))) +(my-recurse 1) +=> +enters debugger at (my-recurse 595), +per the default max-lisp-eval-depth 600 in Emacs 24.1 diff --git a/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-1.fth b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-1.fth new file mode 100644 index 0000000000..26a88422f8 --- /dev/null +++ b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-1.fth @@ -0,0 +1,5 @@ +: munge ( n -- n' ) 1+ recurse ; + +: test 0 ['] munge catch if ." Recursion limit at depth " . then ; + +test \ Default gforth: Recursion limit at depth 3817 diff --git a/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-2.fth b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-2.fth new file mode 100644 index 0000000000..16c81eeaf7 --- /dev/null +++ b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-2.fth @@ -0,0 +1 @@ +s" return-stack-cells" environment? ( 0 | potential-depth-of-return-stack -1 ) diff --git a/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-3.fth b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-3.fth new file mode 100644 index 0000000000..de60dbf237 --- /dev/null +++ b/Task/Find-limit-of-recursion/Forth/find-limit-of-recursion-3.fth @@ -0,0 +1,5 @@ +: recur; [ last 2 cells + literal ] @ +bal postpone again ; immediate + +: test dup if 1+ recur; then drop ." I gave up finding a limit!" ; + +1 test diff --git a/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-1.f b/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-1.f new file mode 100644 index 0000000000..fe3c1f7a52 --- /dev/null +++ b/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-1.f @@ -0,0 +1,19 @@ +program recursion_depth + + implicit none + + call recurse (1) + +contains + + recursive subroutine recurse (i) + + implicit none + integer, intent (in) :: i + + write (*, '(i0)') i + call recurse (i + 1) + + end subroutine recurse + +end program recursion_depth diff --git a/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-2.f b/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-2.f new file mode 100644 index 0000000000..051502b2be --- /dev/null +++ b/Task/Find-limit-of-recursion/Fortran/find-limit-of-recursion-2.f @@ -0,0 +1,11 @@ +208914 +208915 +208916 +208917 +208918 +208919 +208920 +208921 +208922 +208923 +Segmentation fault (core dumped) diff --git a/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-1.gap b/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-1.gap new file mode 100644 index 0000000000..bde98fa5f5 --- /dev/null +++ b/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-1.gap @@ -0,0 +1,17 @@ +f := function(n) + return f(n+1); +end; + +# Now loop until an error occurs +f(0); + +# Error message : +# Entering break read-eval-print loop ... +# you can 'quit;' to quit to outer loop, or +# you may 'return;' to continue + +n; +# 4998 + +# quit "brk mode" and return to GAP +quit; diff --git a/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-2.gap b/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-2.gap new file mode 100644 index 0000000000..1260c06af6 --- /dev/null +++ b/Task/Find-limit-of-recursion/GAP/find-limit-of-recursion-2.gap @@ -0,0 +1,3 @@ +SetRecursionTrapInterval(100000); +# No limit (may crash GAP if recursion is not controlled) : +SetRecursionTrapInterval(0); diff --git a/Task/Find-limit-of-recursion/Go/find-limit-of-recursion.go b/Task/Find-limit-of-recursion/Go/find-limit-of-recursion.go new file mode 100644 index 0000000000..a83c85fa80 --- /dev/null +++ b/Task/Find-limit-of-recursion/Go/find-limit-of-recursion.go @@ -0,0 +1,14 @@ +package main + +import "fmt" + +func main() { + r(1) +} + +func r(l int) { + if l % 1000 == 0 { + fmt.Println(l) + } + r(l+1) +} diff --git a/Task/Find-limit-of-recursion/Groovy/find-limit-of-recursion.groovy b/Task/Find-limit-of-recursion/Groovy/find-limit-of-recursion.groovy new file mode 100644 index 0000000000..1becec497d --- /dev/null +++ b/Task/Find-limit-of-recursion/Groovy/find-limit-of-recursion.groovy @@ -0,0 +1,10 @@ +def recurse; +recurse = { + try { + recurse (it + 1) + } catch (StackOverflowError e) { + return it + } +} + +recurse(0) diff --git a/Task/Find-limit-of-recursion/Icon/find-limit-of-recursion.icon b/Task/Find-limit-of-recursion/Icon/find-limit-of-recursion.icon new file mode 100644 index 0000000000..d3d23287b9 --- /dev/null +++ b/Task/Find-limit-of-recursion/Icon/find-limit-of-recursion.icon @@ -0,0 +1,12 @@ +procedure main() +envar := "MSTKSIZE" +write(&errout,"Program to test recursion depth - dependant on the environment variable ",envar," = ",\getenv(envar)|&null) +deepdive() +end + +procedure deepdive() +static d +initial d := 0 +write( d +:= 1) +deepdive() +end diff --git a/Task/Find-limit-of-recursion/Inform-7/find-limit-of-recursion.inf b/Task/Find-limit-of-recursion/Inform-7/find-limit-of-recursion.inf new file mode 100644 index 0000000000..326ecde4f9 --- /dev/null +++ b/Task/Find-limit-of-recursion/Inform-7/find-limit-of-recursion.inf @@ -0,0 +1,7 @@ +Home is a room. + +When play begins: recurse 0. + +To recurse (N - number): + say "[N]."; + recurse N + 1. diff --git a/Task/Find-limit-of-recursion/J/find-limit-of-recursion.j b/Task/Find-limit-of-recursion/J/find-limit-of-recursion.j new file mode 100644 index 0000000000..5c739605b8 --- /dev/null +++ b/Task/Find-limit-of-recursion/J/find-limit-of-recursion.j @@ -0,0 +1 @@ + $:@>: ::] 0 diff --git a/Task/Find-limit-of-recursion/Java/find-limit-of-recursion.java b/Task/Find-limit-of-recursion/Java/find-limit-of-recursion.java new file mode 100644 index 0000000000..55c454a0b1 --- /dev/null +++ b/Task/Find-limit-of-recursion/Java/find-limit-of-recursion.java @@ -0,0 +1,14 @@ +public class RecursionTest { + + private static void recurse(int i) { + try { + recurse(i+1); + } catch (StackOverflowError e) { + System.out.print("Recursion depth on this system is " + i + "."); + } + } + + public static void main(String[] args) { + recurse(0); + } +} diff --git a/Task/Find-limit-of-recursion/JavaScript/find-limit-of-recursion.js b/Task/Find-limit-of-recursion/JavaScript/find-limit-of-recursion.js new file mode 100644 index 0000000000..af8ff815be --- /dev/null +++ b/Task/Find-limit-of-recursion/JavaScript/find-limit-of-recursion.js @@ -0,0 +1,14 @@ +function recurse(depth) +{ + try + { + return recurse(depth + 1); + } + catch(ex) + { + return depth; + } +} + +var maxRecursion = recurse(1); +document.write("Recursion depth on this system is " + maxRecursion); diff --git a/Task/Find-limit-of-recursion/LSL/find-limit-of-recursion.lsl b/Task/Find-limit-of-recursion/LSL/find-limit-of-recursion.lsl new file mode 100644 index 0000000000..89a22d6d48 --- /dev/null +++ b/Task/Find-limit-of-recursion/LSL/find-limit-of-recursion.lsl @@ -0,0 +1,12 @@ +integer iLimit_of_Recursion = 0; +Find_Limit_of_Recursion(integer x) { + llOwnerSay("x="+(string)x); + iLimit_of_Recursion = x; + Find_Limit_of_Recursion(x+1); +} +default { + state_entry() { + Find_Limit_of_Recursion(0); + llOwnerSay("iLimit_of_Recursion="+(string)iLimit_of_Recursion); + } +} diff --git a/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-1.liberty b/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-1.liberty new file mode 100644 index 0000000000..ba9d2272ea --- /dev/null +++ b/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-1.liberty @@ -0,0 +1,8 @@ +'subroutine recursion limit- end up on 475000 + +call test 1 + +sub test n + if n mod 1000 = 0 then locate 1,1: print n + call test n+1 +end sub diff --git a/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-2.liberty b/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-2.liberty new file mode 100644 index 0000000000..cead5c4e58 --- /dev/null +++ b/Task/Find-limit-of-recursion/Liberty-BASIC/find-limit-of-recursion-2.liberty @@ -0,0 +1,5 @@ +'gosub recursion limit- end up on 5767000 +[test] + n = n+1 + if n mod 1000 = 0 then locate 1,1: print n +gosub [test] diff --git a/Task/Find-limit-of-recursion/Logo/find-limit-of-recursion.logo b/Task/Find-limit-of-recursion/Logo/find-limit-of-recursion.logo new file mode 100644 index 0000000000..dd46d6b293 --- /dev/null +++ b/Task/Find-limit-of-recursion/Logo/find-limit-of-recursion.logo @@ -0,0 +1,11 @@ +make "depth 0 + +to recurse + make "depth :depth + 1 + recurse +end + +catch "ERROR [recurse] + ; hit control-C after waiting a while +print error ; 16 Stopping... recurse [make "depth :depth + 1] +(print [Depth reached:] :depth) ; some arbitrarily large number diff --git a/Task/Find-limit-of-recursion/Lua/find-limit-of-recursion.lua b/Task/Find-limit-of-recursion/Lua/find-limit-of-recursion.lua new file mode 100644 index 0000000000..789a1c135a --- /dev/null +++ b/Task/Find-limit-of-recursion/Lua/find-limit-of-recursion.lua @@ -0,0 +1,9 @@ +counter = 0 + +function test() + print("Depth:", counter) + counter = counter + 1 + test() +end + +test() diff --git a/Task/Find-limit-of-recursion/MATLAB/find-limit-of-recursion.m b/Task/Find-limit-of-recursion/MATLAB/find-limit-of-recursion.m new file mode 100644 index 0000000000..ff32c2c866 --- /dev/null +++ b/Task/Find-limit-of-recursion/MATLAB/find-limit-of-recursion.m @@ -0,0 +1,12 @@ +>> get(0,'RecursionLimit') + +ans = + + 500 + +>> set(0,'RecursionLimit',2500) +>> get(0,'RecursionLimit') + +ans = + + 2500 diff --git a/Task/Find-limit-of-recursion/MUMPS/find-limit-of-recursion.mumps b/Task/Find-limit-of-recursion/MUMPS/find-limit-of-recursion.mumps new file mode 100644 index 0000000000..3522894eae --- /dev/null +++ b/Task/Find-limit-of-recursion/MUMPS/find-limit-of-recursion.mumps @@ -0,0 +1,6 @@ +RECURSE + IF $DATA(DEPTH)=1 SET DEPTH=1+DEPTH + IF $DATA(DEPTH)=0 SET DEPTH=1 + WRITE !,DEPTH_" levels down" + DO RECURSE + QUIT diff --git a/Task/Find-limit-of-recursion/Mathematica/find-limit-of-recursion.mathematica b/Task/Find-limit-of-recursion/Mathematica/find-limit-of-recursion.mathematica new file mode 100644 index 0000000000..6074958c58 --- /dev/null +++ b/Task/Find-limit-of-recursion/Mathematica/find-limit-of-recursion.mathematica @@ -0,0 +1 @@ +$RecursionLimit=10^6 diff --git a/Task/Find-limit-of-recursion/Maxima/find-limit-of-recursion.maxima b/Task/Find-limit-of-recursion/Maxima/find-limit-of-recursion.maxima new file mode 100644 index 0000000000..f67af18b60 --- /dev/null +++ b/Task/Find-limit-of-recursion/Maxima/find-limit-of-recursion.maxima @@ -0,0 +1,9 @@ +f(p) := f(n: p + 1)$ +f(0); +Maxima encountered a Lisp error: + Error in PROGN [or a callee]: Bind stack overflow. +Automatically continuing. +To enable the Lisp debugger set *debugger-hook* to nil. + +n; +406 diff --git a/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-1.mod2 b/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-1.mod2 new file mode 100644 index 0000000000..009fca21ba --- /dev/null +++ b/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-1.mod2 @@ -0,0 +1,14 @@ +MODULE recur; + +IMPORT InOut; + +PROCEDURE recursion (a : CARDINAL); + +BEGIN + InOut.Write ('.'); (* just count the dots.... *) + recursion (a + 1) +END recursion; + +BEGIN + recursion (0) +END recur. diff --git a/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-2.mod2 b/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-2.mod2 new file mode 100644 index 0000000000..0c624842fe --- /dev/null +++ b/Task/Find-limit-of-recursion/Modula-2/find-limit-of-recursion-2.mod2 @@ -0,0 +1,8 @@ +jan@Beryllium:~/modula/rosetta$ recur >testfile +Segmentation fault +jan@Beryllium:~/modula/rosetta$ ls -l +-rwxr-xr-x 1 jan users 20032 2011-05-20 00:26 recur* +-rw-r--r-- 1 jan users 194 2011-05-20 00:26 recur.mod +-rw-r--r-- 1 jan users 523264 2011-05-20 00:26 testfile +jan@Beryllium:~/modula/rosetta$ wc testfile + 0 1 523264 testfile diff --git a/Task/Find-limit-of-recursion/PHP/find-limit-of-recursion.php b/Task/Find-limit-of-recursion/PHP/find-limit-of-recursion.php new file mode 100644 index 0000000000..0a726e1d1c --- /dev/null +++ b/Task/Find-limit-of-recursion/PHP/find-limit-of-recursion.php @@ -0,0 +1,7 @@ + + println("Recursion depth on this system is " + i + ".") + } +} +recurseTest(0) diff --git a/Task/Find-limit-of-recursion/Scala/find-limit-of-recursion-2.scala b/Task/Find-limit-of-recursion/Scala/find-limit-of-recursion-2.scala new file mode 100644 index 0000000000..f4e12a13c8 --- /dev/null +++ b/Task/Find-limit-of-recursion/Scala/find-limit-of-recursion-2.scala @@ -0,0 +1,4 @@ +def recurseTailRec(i:Int):Unit={ + if(i%100000==0) println("Recursion depth is " + i + ".") + recurseTailRec(i+1) +} diff --git a/Task/Find-limit-of-recursion/Scheme/find-limit-of-recursion.ss b/Task/Find-limit-of-recursion/Scheme/find-limit-of-recursion.ss new file mode 100644 index 0000000000..6990dadc8e --- /dev/null +++ b/Task/Find-limit-of-recursion/Scheme/find-limit-of-recursion.ss @@ -0,0 +1,4 @@ +(define (recurse number) + (begin (display number) (newline) (recurse (+ number 1)))) + +(recurse 1) diff --git a/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-1.tcl b/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-1.tcl new file mode 100644 index 0000000000..37c2d6bbd2 --- /dev/null +++ b/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-1.tcl @@ -0,0 +1,5 @@ +proc recur i { + puts "This is depth [incr i]" + catch {recur $i}; # Trap error from going too deep +} +recur 0 diff --git a/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-2.tcl b/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-2.tcl new file mode 100644 index 0000000000..5b571d0f11 --- /dev/null +++ b/Task/Find-limit-of-recursion/Tcl/find-limit-of-recursion-2.tcl @@ -0,0 +1,9 @@ +# Increase the maximum depth +interp recursionlimit {} 1000000 +proc recur i { + if {[catch {recur [incr i]}]} { + # If we failed to recurse, print how far we got + puts "Got to depth $i" + } +} +recur 0 diff --git a/Task/Find-the-missing-permutation/0DESCRIPTION b/Task/Find-the-missing-permutation/0DESCRIPTION new file mode 100644 index 0000000000..14272091a2 --- /dev/null +++ b/Task/Find-the-missing-permutation/0DESCRIPTION @@ -0,0 +1,29 @@ +These are all of the permutations of the symbols A, B, C and D, except for one that's not listed. Find that missing permutation. + +(cf. [[Permutations]]) + +There is an obvious method : enumerating all permutations of A, B, C, D, and looking for the missing one. There is an alternate method. Hint : if all permutations were here, how many times would A appear in each position ? What is the parity of this number ? + +

ABCD
+CABD
+ACDB
+DACB
+BCDA
+ACBD
+ADCB
+CDAB
+DABC
+BCAD
+CADB
+CDBA
+CBAD
+ABDC
+ADBC
+BDCA
+DCBA
+BACD
+BADC
+BDAC
+CBDA
+DBCA
+DCAB
diff --git a/Task/Find-the-missing-permutation/Ada/find-the-missing-permutation.ada b/Task/Find-the-missing-permutation/Ada/find-the-missing-permutation.ada new file mode 100644 index 0000000000..0e9e809a6c --- /dev/null +++ b/Task/Find-the-missing-permutation/Ada/find-the-missing-permutation.ada @@ -0,0 +1,51 @@ +with Ada.Text_IO; +procedure Missing_Permutations is + subtype Permutation_Character is Character range 'A' .. 'D'; + + Character_Count : constant := + 1 + Permutation_Character'Pos (Permutation_Character'Last) + - Permutation_Character'Pos (Permutation_Character'First); + + type Permutation_String is + array (1 .. Character_Count) of Permutation_Character; + + procedure Put (Item : Permutation_String) is + begin + for I in Item'Range loop + Ada.Text_IO.Put (Item (I)); + end loop; + end Put; + + Given_Permutations : array (Positive range <>) of Permutation_String := + ("ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", + "ADCB", "CDAB", "DABC", "BCAD", "CADB", "CDBA", + "CBAD", "ABDC", "ADBC", "BDCA", "DCBA", "BACD", + "BADC", "BDAC", "CBDA", "DBCA", "DCAB"); + + Count : array (Permutation_Character, 1 .. Character_Count) of Natural + := (others => (others => 0)); + Max_Count : Positive := 1; + + Missing_Permutation : Permutation_String; +begin + for I in Given_Permutations'Range loop + for Pos in 1 .. Character_Count loop + Count (Given_Permutations (I) (Pos), Pos) := + Count (Given_Permutations (I) (Pos), Pos) + 1; + if Count (Given_Permutations (I) (Pos), Pos) > Max_Count then + Max_Count := Count (Given_Permutations (I) (Pos), Pos); + end if; + end loop; + end loop; + + for Char in Permutation_Character loop + for Pos in 1 .. Character_Count loop + if Count (Char, Pos) < Max_Count then + Missing_Permutation (Pos) := Char; + end if; + end loop; + end loop; + + Ada.Text_IO.Put_Line ("Missing Permutation:"); + Put (Missing_Permutation); +end Missing_Permutations; diff --git a/Task/Find-the-missing-permutation/AutoHotkey/find-the-missing-permutation.ahk b/Task/Find-the-missing-permutation/AutoHotkey/find-the-missing-permutation.ahk new file mode 100644 index 0000000000..3a08c03c08 --- /dev/null +++ b/Task/Find-the-missing-permutation/AutoHotkey/find-the-missing-permutation.ahk @@ -0,0 +1,30 @@ +IncompleteList := "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB" + +CompleteList := Perm( "ABCD" ) +Missing := "" + +Loop, Parse, CompleteList, `n, `r + If !InStr( IncompleteList , A_LoopField ) + Missing .= "`n" A_LoopField + +MsgBox Missing Permutation(s):%Missing% + +;------------------------------------------------- + +; Shortened version of [VxE]'s permutation function +; http://www.autohotkey.com/forum/post-322251.html#322251 +Perm( s , dL="" , t="" , p="") { + StringSplit, m, s, % d := SubStr(dL,1,1) , %t% + IfEqual, m0, 1, return m1 d p + Loop %m0% + { + r := m1 + Loop % m0-2 + x := A_Index + 1, r .= d m%x% + L .= Perm(r, d, t, m%m0% d p)"`n" , mx := m1 + Loop % m0-1 + x := A_Index + 1, m%A_Index% := m%x% + m%m0% := mx + } + return substr(L, 1, -1) +} diff --git a/Task/Find-the-missing-permutation/BBC-BASIC/find-the-missing-permutation.bbc b/Task/Find-the-missing-permutation/BBC-BASIC/find-the-missing-permutation.bbc new file mode 100644 index 0000000000..d88d1e74a3 --- /dev/null +++ b/Task/Find-the-missing-permutation/BBC-BASIC/find-the-missing-permutation.bbc @@ -0,0 +1,12 @@ + DIM perms$(22), miss&(4) + perms$() = "ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", "ADCB", \ + \ "CDAB", "DABC", "BCAD", "CADB", "CDBA", "CBAD", "ABDC", "ADBC", \ + \ "BDCA", "DCBA", "BACD", "BADC", "BDAC", "CBDA", "DBCA", "DCAB" + + FOR i% = 0 TO DIM(perms$(),1) + FOR j% = 1 TO DIM(miss&(),1) + miss&(j%-1) EOR= ASCMID$(perms$(i%),j%) + NEXT + NEXT + PRINT $$^miss&(0) " is missing" + END diff --git a/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-1.blq b/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-1.blq new file mode 100644 index 0000000000..661f08264a --- /dev/null +++ b/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-1.blq @@ -0,0 +1 @@ +ln"ABCD"r@\/\\ diff --git a/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-2.blq b/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-2.blq new file mode 100644 index 0000000000..4a8da64a16 --- /dev/null +++ b/Task/Find-the-missing-permutation/Burlesque/find-the-missing-permutation-2.blq @@ -0,0 +1 @@ +ln)XXtp)><)F:)<]u[/v\[ diff --git a/Task/Find-the-missing-permutation/C++/find-the-missing-permutation.cpp b/Task/Find-the-missing-permutation/C++/find-the-missing-permutation.cpp new file mode 100644 index 0000000000..4c14ff625b --- /dev/null +++ b/Task/Find-the-missing-permutation/C++/find-the-missing-permutation.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include + +static const std::string GivenPermutations[] = { + "ABCD","CABD","ACDB","DACB", + "BCDA","ACBD","ADCB","CDAB", + "DABC","BCAD","CADB","CDBA", + "CBAD","ABDC","ADBC","BDCA", + "DCBA","BACD","BADC","BDAC", + "CBDA","DBCA","DCAB" +}; +static const size_t NumGivenPermutations = sizeof(GivenPermutations) / sizeof(*GivenPermutations); + +int main() +{ + std::vector permutations; + std::string initial = "ABCD"; + permutations.push_back(initial); + + while(true) + { + std::string p = permutations.back(); + std::next_permutation(p.begin(), p.end()); + if(p == permutations.front()) + break; + permutations.push_back(p); + } + + std::vector missing; + std::set given_permutations(GivenPermutations, GivenPermutations + NumGivenPermutations); + std::set_difference(permutations.begin(), permutations.end(), given_permutations.begin(), + given_permutations.end(), std::back_inserter(missing)); + std::copy(missing.begin(), missing.end(), std::ostream_iterator(std::cout, "\n")); + return 0; +} diff --git a/Task/Find-the-missing-permutation/C/find-the-missing-permutation.c b/Task/Find-the-missing-permutation/C/find-the-missing-permutation.c new file mode 100644 index 0000000000..9d71a2bd09 --- /dev/null +++ b/Task/Find-the-missing-permutation/C/find-the-missing-permutation.c @@ -0,0 +1,33 @@ +#include + +#define N 4 +const char *perms[] = { + "ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", "ADCB", "CDAB", + "DABC", "BCAD", "CADB", "CDBA", "CBAD", "ABDC", "ADBC", "BDCA", + "DCBA", "BACD", "BADC", "BDAC", "CBDA", "DBCA", "DCAB", +}; + +int main() +{ + int i, j, n, cnt[N]; + char miss[N]; + + for (n = i = 1; i < N; i++) n *= i; /* n = (N-1)!, # of occurrence */ + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) cnt[j] = 0; + + /* count how many times each letter occur at position i */ + for (j = 0; j < sizeof(perms)/sizeof(const char*); j++) + cnt[perms[j][i] - 'A']++; + + /* letter not occurring (N-1)! times is the missing one */ + for (j = 0; j < N && cnt[j] == n; j++); + + miss[i] = j + 'A'; + } + printf("Missing: %.*s\n", N, miss); + + return 0; + +} diff --git a/Task/Find-the-missing-permutation/Clojure/find-the-missing-permutation.clj b/Task/Find-the-missing-permutation/Clojure/find-the-missing-permutation.clj new file mode 100644 index 0000000000..6778cd92b5 --- /dev/null +++ b/Task/Find-the-missing-permutation/Clojure/find-the-missing-permutation.clj @@ -0,0 +1,6 @@ +(use 'clojure.contrib.combinatorics) +(use 'clojure.set) + +(def given (apply hash-set (partition 4 5 "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB" ))) +(def s1 (apply hash-set (permutations "ABCD"))) +(def missing (difference s1 given)) diff --git a/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-1.coffee b/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-1.coffee new file mode 100644 index 0000000000..5f8bf42fae --- /dev/null +++ b/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-1.coffee @@ -0,0 +1,35 @@ +missing_permutation = (arr) -> + # Find the missing permutation in an array of N! - 1 permutations. + + # We won't validate every precondition, but we do have some basic + # guards. + if arr.length == 0 + throw Error "Need more data" + if arr.length == 1 + return [arr[0][1] + arr[0][0]] + + # Now we know that for each position in the string, elements should appear + # an even number of times (N-1 >= 2). We can use a set to detect the element appearing + # an odd number of times. Detect odd occurrences by toggling admission/expulsion + # to and from the set for each value encountered. At the end of each pass one element + # will remain in the set. + result = '' + for pos in [0...arr[0].length] + set = {} + for permutation in arr + c = permutation[pos] + if set[c] + delete set[c] + else + set[c] = true + for c of set + result += c + break + result + +given = '''ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB''' + +arr = (s for s in given.replace('\n', ' ').split ' ' when s != '') + +console.log missing_permutation(arr) diff --git a/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-2.coffee b/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-2.coffee new file mode 100644 index 0000000000..b2ab004134 --- /dev/null +++ b/Task/Find-the-missing-permutation/CoffeeScript/find-the-missing-permutation-2.coffee @@ -0,0 +1,2 @@ + > coffee missing_permute.coffee +DBAC diff --git a/Task/Find-the-missing-permutation/Common-Lisp/find-the-missing-permutation.lisp b/Task/Find-the-missing-permutation/Common-Lisp/find-the-missing-permutation.lisp new file mode 100644 index 0000000000..4a555f674f --- /dev/null +++ b/Task/Find-the-missing-permutation/Common-Lisp/find-the-missing-permutation.lisp @@ -0,0 +1,14 @@ +(defparameter *permutations* + '("ABCD" "CABD" "ACDB" "DACB" "BCDA" "ACBD" "ADCB" "CDAB" "DABC" "BCAD" "CADB" "CDBA" + "CBAD" "ABDC" "ADBC" "BDCA" "DCBA" "BACD" "BADC" "BDAC" "CBDA" "DBCA" "DCAB")) + +(defun missing-perm (perms) + (let* ((letters (loop for i across (car perms) collecting i)) + (l (/ (1+ (length perms)) (length letters)))) + (labels ((enum (n) (loop for i below n collecting i)) + (least-occurs (pos) + (let ((occurs (loop for i in perms collecting (aref i pos)))) + (cdr (assoc (1- l) (mapcar #'(lambda (letter) + (cons (count letter occurs) letter)) + letters)))))) + (concatenate 'string (mapcar #'least-occurs (enum (length letters))))))) diff --git a/Task/Find-the-missing-permutation/D/find-the-missing-permutation-1.d b/Task/Find-the-missing-permutation/D/find-the-missing-permutation-1.d new file mode 100644 index 0000000000..e0065167af --- /dev/null +++ b/Task/Find-the-missing-permutation/D/find-the-missing-permutation-1.d @@ -0,0 +1,13 @@ +import std.stdio, std.string, std.algorithm, std.array, std.range; + +void main() { + const givenSet = "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC + BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA + DBCA DCAB"d.split().zip(repeat(true)).assocArray(); + + auto p = "ABCD"d.dup; + do { + if (p !in givenSet) + writeln("Missing permutation: ", p); + } while (p.nextPermutation()); +} diff --git a/Task/Find-the-missing-permutation/D/find-the-missing-permutation-2.d b/Task/Find-the-missing-permutation/D/find-the-missing-permutation-2.d new file mode 100644 index 0000000000..3d296ac8c0 --- /dev/null +++ b/Task/Find-the-missing-permutation/D/find-the-missing-permutation-2.d @@ -0,0 +1,40 @@ +import std.stdio, std.string, std.algorithm, std.conv; + +void main() { + const perms = "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC + BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD + BADC BDAC CBDA DBCA DCAB".split(); + + // Version 1: XOR all the ASCII values, the uneven one gets + // flushed out; based on Perl 6 (via Go) + ubyte[4] b; + foreach (perm; perms) + foreach (i, c; perm) + b[i] ^= c; + writeln(cast(char[])b); + + // Version 2 : Sum ASCII values + auto sumr = perms[0].reduce!q{a + b}(); // sum row + foreach (i; 0 .. 4) { + // sum columns + const sumc = reduce!((a,b)=> text(to!int(a) + b[i]))("0",perms); + // see how much it falls short + write(cast(char)(sumr - to!int(sumc) % sumr)); + } + writeln(); + + // Version 3: some sort of checksum, don't ask + // me: translation of Java + enum int len = 4; + int maxCode = len - 1; + foreach_reverse (i; 3 .. len + 1) + maxCode *= i; // maxCode will be 36 + foreach (i; 0 .. len) { + int code = 0; + foreach (p; perms) + code += perms[0].countUntil(p[i]); + + // code will come up 3, 1, 0, 2 short of 36 + write(cast(char)perms[0][maxCode - code]); + } +} diff --git a/Task/Find-the-missing-permutation/Fortran/find-the-missing-permutation.f b/Task/Find-the-missing-permutation/Fortran/find-the-missing-permutation.f new file mode 100644 index 0000000000..a4d07fb9d7 --- /dev/null +++ b/Task/Find-the-missing-permutation/Fortran/find-the-missing-permutation.f @@ -0,0 +1,16 @@ +program missing_permutation + + implicit none + character (4), dimension (23), parameter :: list = & + & (/'ABCD', 'CABD', 'ACDB', 'DACB', 'BCDA', 'ACBD', 'ADCB', 'CDAB', & + & 'DABC', 'BCAD', 'CADB', 'CDBA', 'CBAD', 'ABDC', 'ADBC', 'BDCA', & + & 'DCBA', 'BACD', 'BADC', 'BDAC', 'CBDA', 'DBCA', 'DCAB'/) + integer :: i, j, k + + do i = 1, 4 + j = minloc ((/(count (list (:) (i : i) == list (1) (k : k)), k = 1, 4)/), 1) + write (*, '(a)', advance = 'no') list (1) (j : j) + end do + write (*, *) + +end program missing_permutation diff --git a/Task/Find-the-missing-permutation/GAP/find-the-missing-permutation.gap b/Task/Find-the-missing-permutation/GAP/find-the-missing-permutation.gap new file mode 100644 index 0000000000..d9dd0d5d78 --- /dev/null +++ b/Task/Find-the-missing-permutation/GAP/find-the-missing-permutation.gap @@ -0,0 +1,17 @@ +# our deficient list +L := +[ "ABCD", "CABD", "ACDB", "DACB", "BCDA", + "ACBD", "ADCB", "CDAB", "DABC", "BCAD", + "CADB", "CDBA", "CBAD", "ABDC", "ADBC", + "BDCA", "DCBA", "BACD", "BADC", "BDAC", + "CBDA", "DBCA", "DCAB" ]; + +# convert L to permutations on 1..4 +u := List(L, s -> List([1..4], i -> Position("ABCD", s[i]))); + +# set difference (with all permutations) +v := Difference(PermutationsList([1..4]), u); + +# convert back to letters +s := "ABCD"; +List(v, p -> List(p, i -> s[i])); diff --git a/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-1.go b/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-1.go new file mode 100644 index 0000000000..7b470de5d4 --- /dev/null +++ b/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-1.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "strings" +) + +var given = strings.Split(`ABCD +CABD +ACDB +DACB +BCDA +ACBD +ADCB +CDAB +DABC +BCAD +CADB +CDBA +CBAD +ABDC +ADBC +BDCA +DCBA +BACD +BADC +BDAC +CBDA +DBCA +DCAB`, "\n") + +func main() { + b := make([]byte, len(given[0])) + for i := range b { + m := make(map[byte]int) + for _, p := range given { + m[p[i]]++ + } + for char, count := range m { + if count&1 == 1 { + b[i] = char + break + } + } + } + fmt.Println(string(b)) +} diff --git a/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-2.go b/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-2.go new file mode 100644 index 0000000000..2f0d75f81e --- /dev/null +++ b/Task/Find-the-missing-permutation/Go/find-the-missing-permutation-2.go @@ -0,0 +1,9 @@ +func main() { + b := make([]byte, len(given[0])) + for _, p := range given { + for i, c := range []byte(p) { + b[i] ^= c + } + } + fmt.Println(string(b)) +} diff --git a/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-1.groovy b/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-1.groovy new file mode 100644 index 0000000000..68e8e3687f --- /dev/null +++ b/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-1.groovy @@ -0,0 +1,9 @@ +def fact = { n -> [1,(1..<(n+1)).inject(1) { prod, i -> prod * i }].max() } +def missingPerms +missingPerms = {List elts, List perms -> + perms.empty ? elts.permutations() : elts.collect { e -> + def ePerms = perms.findAll { e == it[0] }.collect { it[1..-1] } + ePerms.size() == fact(elts.size() - 1) ? [] \ + : missingPerms(elts - e, ePerms).collect { [e] + it } + }.sum() +} diff --git a/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-2.groovy b/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-2.groovy new file mode 100644 index 0000000000..c8d4067443 --- /dev/null +++ b/Task/Find-the-missing-permutation/Groovy/find-the-missing-permutation-2.groovy @@ -0,0 +1,6 @@ +def e = 'ABCD' as List +def p = ['ABCD', 'CABD', 'ACDB', 'DACB', 'BCDA', 'ACBD', 'ADCB', 'CDAB', 'DABC', 'BCAD', 'CADB', 'CDBA', + 'CBAD', 'ABDC', 'ADBC', 'BDCA', 'DCBA', 'BACD', 'BADC', 'BDAC', 'CBDA', 'DBCA', 'DCAB'].collect { it as List } + +def mp = missingPerms(e, p) +mp.each { println it } diff --git a/Task/Find-the-missing-permutation/Haskell/find-the-missing-permutation.hs b/Task/Find-the-missing-permutation/Haskell/find-the-missing-permutation.hs new file mode 100644 index 0000000000..2e5fd8597f --- /dev/null +++ b/Task/Find-the-missing-permutation/Haskell/find-the-missing-permutation.hs @@ -0,0 +1,16 @@ +import Data.List +import Control.Monad +import Control.Arrow + +missingPerm :: Eq a => [[a]] -> [[a]] +missingPerm = (\\) =<< permutations . nub . join + +deficientPermsList = ["ABCD","CABD","ACDB","DACB", + "BCDA","ACBD","ADCB","CDAB", + "DABC","BCAD","CADB","CDBA", + "CBAD","ABDC","ADBC","BDCA", + "DCBA","BACD","BADC","BDAC", + "CBDA","DBCA","DCAB"] + +main = do + print $ missingPerm deficientPermsList diff --git a/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-1.icon b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-1.icon new file mode 100644 index 0000000000..c4d7d23d7e --- /dev/null +++ b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-1.icon @@ -0,0 +1,12 @@ +link strings # for permutes + +procedure main() +givens := set![ "ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", "ADCB", "CDAB", "DABC", "BCAD", "CADB", + "CDBA", "CBAD", "ABDC", "ADBC", "BDCA", "DCBA", "BACD", "BADC", "BDAC", "CBDA", "DBCA", "DCAB"] + +every insert(full := set(), permutes("ABCD")) # generate all permutations +givens := full--givens # and difference + +write("The difference is : ") +every write(!givens, " ") +end diff --git a/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-2.icon b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-2.icon new file mode 100644 index 0000000000..b877dd184c --- /dev/null +++ b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-2.icon @@ -0,0 +1,3 @@ +every x := permutes("ABCD") do # generate all permutations + if member(givens,x) then delete(givens,x) # remove givens as they are generated + else insert(givens,x) # add back any not given diff --git a/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-3.icon b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-3.icon new file mode 100644 index 0000000000..06050cc980 --- /dev/null +++ b/Task/Find-the-missing-permutation/Icon/find-the-missing-permutation-3.icon @@ -0,0 +1,12 @@ +link strings + +procedure main() + givens := set("ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", + "ADCB", "CDAB", "DABC", "BCAD", "CADB", "CDBA", + "CBAD", "ABDC", "ADBC", "BDCA", "DCBA", "BACD", + "BADC", "BDAC", "CBDA", "DBCA", "DCAB") + + every p := permutes("ABCD") do + if not member(givens, p) then write(p) + +end diff --git a/Task/Find-the-missing-permutation/J/find-the-missing-permutation-1.j b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-1.j new file mode 100644 index 0000000000..142e629c6f --- /dev/null +++ b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-1.j @@ -0,0 +1,2 @@ +permutations=: A.~ i.@!@# +missingPerms=: -.~ permutations @ {. diff --git a/Task/Find-the-missing-permutation/J/find-the-missing-permutation-2.j b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-2.j new file mode 100644 index 0000000000..183879fa70 --- /dev/null +++ b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-2.j @@ -0,0 +1 @@ +missingPerms=: -.~ (A.~ i.@!@#) @ {. diff --git a/Task/Find-the-missing-permutation/J/find-the-missing-permutation-3.j b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-3.j new file mode 100644 index 0000000000..cd55d08be1 --- /dev/null +++ b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-3.j @@ -0,0 +1,4 @@ +missingPerms=: monad define + item=. {. y + y -.~ item A.~ i.! #item +) diff --git a/Task/Find-the-missing-permutation/J/find-the-missing-permutation-4.j b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-4.j new file mode 100644 index 0000000000..a6194c9fea --- /dev/null +++ b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-4.j @@ -0,0 +1,2 @@ + data -.~ 'ABCD' A.~ i.!4 +DBAC diff --git a/Task/Find-the-missing-permutation/J/find-the-missing-permutation-5.j b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-5.j new file mode 100644 index 0000000000..a487296580 --- /dev/null +++ b/Task/Find-the-missing-permutation/J/find-the-missing-permutation-5.j @@ -0,0 +1,2 @@ + ((i.!4) A. 'ABCD') -. data +DBAC diff --git a/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-1.java b/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-1.java new file mode 100644 index 0000000000..aa433d926f --- /dev/null +++ b/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-1.java @@ -0,0 +1,20 @@ +import java.util.ArrayList; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; + +public class FindMissingPermutation { + public static void main(String[] args) { + Joiner joiner = Joiner.on("").skipNulls(); + ImmutableSet s = ImmutableSet.of("ABCD", "CABD", "ACDB", + "DACB", "BCDA", "ACBD", "ADCB", "CDAB", "DABC", "BCAD", "CADB", + "CDBA", "CBAD", "ABDC", "ADBC", "BDCA", "DCBA", "BACD", "BADC", + "BDAC", "CBDA", "DBCA", "DCAB"); + + for (ArrayList cs : Utils.Permutations(Lists.newArrayList( + 'A', 'B', 'C', 'D'))) + if (!s.contains(joiner.join(cs))) + System.out.println(joiner.join(cs)); + } +} diff --git a/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-2.java b/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-2.java new file mode 100644 index 0000000000..b7fb3ffb37 --- /dev/null +++ b/Task/Find-the-missing-permutation/Java/find-the-missing-permutation-2.java @@ -0,0 +1,24 @@ +public class FindMissingPermutation +{ + public static void main(String[] args) + { + String[] givenPermutations = { "ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", + "ADCB", "CDAB", "DABC", "BCAD", "CADB", "CDBA", + "CBAD", "ABDC", "ADBC", "BDCA", "DCBA", "BACD", + "BADC", "BDAC", "CBDA", "DBCA", "DCAB" }; + String characterSet = givenPermutations[0]; + // Compute n! * (n - 1) / 2 + int maxCode = characterSet.length() - 1; + for (int i = characterSet.length(); i >= 3; i--) + maxCode *= i; + StringBuilder missingPermutation = new StringBuilder(); + for (int i = 0; i < characterSet.length(); i++) + { + int code = 0; + for (String permutation : givenPermutations) + code += characterSet.indexOf(permutation.charAt(i)); + missingPermutation.append(characterSet.charAt(maxCode - code)); + } + System.out.println("Missing permutation: " + missingPermutation.toString()); + } +} diff --git a/Task/Find-the-missing-permutation/JavaScript/find-the-missing-permutation.js b/Task/Find-the-missing-permutation/JavaScript/find-the-missing-permutation.js new file mode 100644 index 0000000000..c9cfadfa72 --- /dev/null +++ b/Task/Find-the-missing-permutation/JavaScript/find-the-missing-permutation.js @@ -0,0 +1,20 @@ +permute = function(v, m){ //v1.0 + for(var p = -1, j, k, f, r, l = v.length, q = 1, i = l + 1; --i; q *= i); + for(x = [new Array(l), new Array(l), new Array(l), new Array(l)], j = q, k = l + 1, i = -1; + ++i < l; x[2][i] = i, x[1][i] = x[0][i] = j /= --k); + for(r = new Array(q); ++p < q;) + for(r[p] = new Array(l), i = -1; ++i < l; !--x[1][i] && (x[1][i] = x[0][i], + x[2][i] = (x[2][i] + 1) % l), r[p][i] = m ? x[3][i] : v[x[3][i]]) + for(x[3][i] = x[2][i], f = 0; !f; f = !f) + for(j = i; j; x[3][--j] == x[2][i] && (x[3][i] = x[2][i] = (x[2][i] + 1) % l, f = 1)); + return r; +}; + +list = [ 'ABCD', 'CABD', 'ACDB', 'DACB', 'BCDA', 'ACBD', 'ADCB', 'CDAB', + 'DABC', 'BCAD', 'CADB', 'CDBA', 'CBAD', 'ABDC', 'ADBC', 'BDCA', + 'DCBA', 'BACD', 'BADC', 'BDAC', 'CBDA', 'DBCA', 'DCAB']; + +all = permute(list[0].split('')).map(function(elem) {return elem.join('')}); + +missing = all.filter(function(elem) {return list.indexOf(elem) == -1}); +print(missing); // ==> DBAC diff --git a/Task/Find-the-missing-permutation/K/find-the-missing-permutation-1.k b/Task/Find-the-missing-permutation/K/find-the-missing-permutation-1.k new file mode 100644 index 0000000000..cb09e1913b --- /dev/null +++ b/Task/Find-the-missing-permutation/K/find-the-missing-permutation-1.k @@ -0,0 +1,24 @@ + split:{1_'(&x=y)_ x:y,x} + + g: ("ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB") + g,:(" CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB") + p: split[g;" "]; + + / All permutations of "ABCD" + perm:{:[1:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]} + p2:a@(perm(#a:"ABCD")); + + / Which permutations in p are there in p2? + p2 _lin p +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 + + / Invert the result + ~p2 _lin p +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 + + / It's the 20th permutation that is missing + &~p2 _lin p +,20 + + p2@&~p2 _lin p +"DBAC" diff --git a/Task/Find-the-missing-permutation/K/find-the-missing-permutation-2.k b/Task/Find-the-missing-permutation/K/find-the-missing-permutation-2.k new file mode 100644 index 0000000000..2e42d5bd51 --- /dev/null +++ b/Task/Find-the-missing-permutation/K/find-the-missing-permutation-2.k @@ -0,0 +1,3 @@ + table:{b@> list = ['ABCD'; +'CABD'; +'ACDB'; +'DACB'; +'BCDA'; +'ACBD'; +'ADCB'; +'CDAB'; +'DABC'; +'BCAD'; +'CADB'; +'CDBA'; +'CBAD'; +'ABDC'; +'ADBC'; +'BDCA'; +'DCBA'; +'BACD'; +'BADC'; +'BDAC'; +'CBDA'; +'DBCA'; +'DCAB'] + +list = + +ABCD +CABD +ACDB +DACB +BCDA +ACBD +ADCB +CDAB +DABC +BCAD +CADB +CDBA +CBAD +ABDC +ADBC +BDCA +DCBA +BACD +BADC +BDAC +CBDA +DBCA +DCAB + +>> findMissingPerms(list) + +ans = + +DBAC diff --git a/Task/Find-the-missing-permutation/Mathematica/find-the-missing-permutation.mathematica b/Task/Find-the-missing-permutation/Mathematica/find-the-missing-permutation.mathematica new file mode 100644 index 0000000000..4877cc1c5f --- /dev/null +++ b/Task/Find-the-missing-permutation/Mathematica/find-the-missing-permutation.mathematica @@ -0,0 +1,7 @@ +ProvidedSet = {"ABCD" , "CABD" , "ACDB" , "DACB" , "BCDA" , "ACBD", +"ADCB" , "CDAB", "DABC", "BCAD" , "CADB", "CDBA" , "CBAD" , "ABDC", +"ADBC" , "BDCA", "DCBA" , "BACD", "BADC", "BDAC" , "CBDA", "DBCA", "DCAB"} + +Part[Complement[ Map[ StringJoin , Permutations[Characters[RandomChoice[ProvidedSet]]]], ProvidedSet], 1] + +->"DBAC" diff --git a/Task/Find-the-missing-permutation/PHP/find-the-missing-permutation.php b/Task/Find-the-missing-permutation/PHP/find-the-missing-permutation.php new file mode 100644 index 0000000000..4800baf881 --- /dev/null +++ b/Task/Find-the-missing-permutation/PHP/find-the-missing-permutation.php @@ -0,0 +1,20 @@ + $val){ + $newArr = $arr; + $newres = $result; + $newres[] = $val; + unset($newArr[$key]); + permut($newArr,$newres); + } + } +} +$givenPerms = Array("ABCD","CABD","ACDB","DACB","BCDA","ACBD","ADCB","CDAB","DABC","BCAD","CADB","CDBA","CBAD","ABDC","ADBC","BDCA","DCBA","BACD","BADC","BDAC","CBDA","DBCA","DCAB"); +$given = Array("A","B","C","D"); +permut($given); +print_r(array_diff($finalres,$givenPerms)); // Array ( [20] => DBAC ) diff --git a/Task/Find-the-missing-permutation/Perl/find-the-missing-permutation.pl b/Task/Find-the-missing-permutation/Perl/find-the-missing-permutation.pl new file mode 100644 index 0000000000..cacdf05da6 --- /dev/null +++ b/Task/Find-the-missing-permutation/Perl/find-the-missing-permutation.pl @@ -0,0 +1,10 @@ +sub check_perm { + my %hash; @hash{@_} = (); + for my $s (@_) { exists $hash{$_} or return $_ + for map substr($s,1) . substr($s,0,1), (1..length $s); } +} + +# Check and display +@perms = qw(ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB); +print check_perm(@perms), "\n"; diff --git a/Task/Find-the-missing-permutation/PicoLisp/find-the-missing-permutation.l b/Task/Find-the-missing-permutation/PicoLisp/find-the-missing-permutation.l new file mode 100644 index 0000000000..1fc3791691 --- /dev/null +++ b/Task/Find-the-missing-permutation/PicoLisp/find-the-missing-permutation.l @@ -0,0 +1,15 @@ +(setq *PermList + (mapcar chop + (quote + "ABCD" "CABD" "ACDB" "DACB" "BCDA" "ACBD" "ADCB" "CDAB" + "DABC" "BCAD" "CADB" "CDBA" "CBAD" "ABDC" "ADBC" "BDCA" + "DCBA" "BACD" "BADC" "BDAC" "CBDA" "DBCA" "DCAB" ) ) ) + +(let (Lst (chop "ABCD") L Lst) + (recur (L) # Permute + (if (cdr L) + (do (length L) + (recurse (cdr L)) + (rot L) ) + (unless (member Lst *PermList) # Check + (prinl Lst) ) ) ) ) diff --git a/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-1.py b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-1.py new file mode 100644 index 0000000000..2fa0bfac83 --- /dev/null +++ b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-1.py @@ -0,0 +1,8 @@ +from itertools import permutations + +given = '''ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB'''.split() + +allPerms = [''.join(x) for x in permutations(given[0])] + +missing = list(set(allPerms) - set(given)) # ['DBAC'] diff --git a/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-2.py b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-2.py new file mode 100644 index 0000000000..dcae5c762f --- /dev/null +++ b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-2.py @@ -0,0 +1,30 @@ +def missing_permutation(arr): + "Find the missing permutation in an array of N! - 1 permutations." + + # We won't validate every precondition, but we do have some basic + # guards. + if len(arr) == 0: raise Exception("Need more data") + if len(arr) == 1: + return [arr[0][1] + arr[0][0]] + + # Now we know that for each position in the string, elements should appear + # an even number of times (N-1 >= 2). We can use a set to detect the element appearing + # an odd number of times. Detect odd occurrences by toggling admission/expulsion + # to and from the set for each value encountered. At the end of each pass one element + # will remain in the set. + missing_permutation = '' + for pos in range(len(arr[0])): + s = set() + for permutation in arr: + c = permutation[pos] + if c in s: + s.remove(c) + else: + s.add(c) + missing_permutation += list(s)[0] + return missing_permutation + +given = '''ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB'''.split() + +print missing_permutation(given) diff --git a/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-3.py b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-3.py new file mode 100644 index 0000000000..4ef9e1dc39 --- /dev/null +++ b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-3.py @@ -0,0 +1,6 @@ +>>> from collections import Counter +>>> given = '''ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB'''.split() +>>> ''.join(Counter(x).most_common()[-1][0] for x in zip(*given)) +'DBAC' +>>> diff --git a/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-4.py b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-4.py new file mode 100644 index 0000000000..d516032335 --- /dev/null +++ b/Task/Find-the-missing-permutation/Python/find-the-missing-permutation-4.py @@ -0,0 +1,18 @@ +>>> from pprint import pprint as pp +>>> pp(list(zip(*given)), width=120) +[('A', 'C', 'A', 'D', 'B', 'A', 'A', 'C', 'D', 'B', 'C', 'C', 'C', 'A', 'A', 'B', 'D', 'B', 'B', 'B', 'C', 'D', 'D'), + ('B', 'A', 'C', 'A', 'C', 'C', 'D', 'D', 'A', 'C', 'A', 'D', 'B', 'B', 'D', 'D', 'C', 'A', 'A', 'D', 'B', 'B', 'C'), + ('C', 'B', 'D', 'C', 'D', 'B', 'C', 'A', 'B', 'A', 'D', 'B', 'A', 'D', 'B', 'C', 'B', 'C', 'D', 'A', 'D', 'C', 'A'), + ('D', 'D', 'B', 'B', 'A', 'D', 'B', 'B', 'C', 'D', 'B', 'A', 'D', 'C', 'C', 'A', 'A', 'D', 'C', 'C', 'A', 'A', 'B')] +>>> pp([Counter(x).most_common() for x in zip(*given)]) +[[('C', 6), ('B', 6), ('A', 6), ('D', 5)], + [('D', 6), ('C', 6), ('A', 6), ('B', 5)], + [('D', 6), ('C', 6), ('B', 6), ('A', 5)], + [('D', 6), ('B', 6), ('A', 6), ('C', 5)]] +>>> pp([Counter(x).most_common()[-1] for x in zip(*given)]) +[('D', 5), ('B', 5), ('A', 5), ('C', 5)] +>>> pp([Counter(x).most_common()[-1][0] for x in zip(*given)]) +['D', 'B', 'A', 'C'] +>>> ''.join([Counter(x).most_common()[-1][0] for x in zip(*given)]) +'DBAC' +>>> diff --git a/Task/Find-the-missing-permutation/R/find-the-missing-permutation-1.r b/Task/Find-the-missing-permutation/R/find-the-missing-permutation-1.r new file mode 100644 index 0000000000..c3f591cc30 --- /dev/null +++ b/Task/Find-the-missing-permutation/R/find-the-missing-permutation-1.r @@ -0,0 +1,12 @@ +library(combinat) + +permute.me <- c("A", "B", "C", "D") +perms <- permn(permute.me) # list of all permutations +perms2 <- matrix(unlist(perms), ncol=length(permute.me), byrow=T) # matrix of all permutations +perms3 <- apply(perms2, 1, paste, collapse="") # vector of all permutations + +incomplete <- c("ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD", "ADCB", "CDAB", + "DABC", "BCAD", "CADB", "CDBA", "CBAD", "ABDC", "ADBC", "BDCA", + "DCBA", "BACD", "BADC", "BDAC", "CBDA", "DBCA", "DCAB") + +setdiff(perms3, incomplete) diff --git a/Task/Find-the-missing-permutation/R/find-the-missing-permutation-2.r b/Task/Find-the-missing-permutation/R/find-the-missing-permutation-2.r new file mode 100644 index 0000000000..aa8d97698d --- /dev/null +++ b/Task/Find-the-missing-permutation/R/find-the-missing-permutation-2.r @@ -0,0 +1 @@ +[1] "DBAC" diff --git a/Task/Find-the-missing-permutation/REXX/find-the-missing-permutation.rexx b/Task/Find-the-missing-permutation/REXX/find-the-missing-permutation.rexx new file mode 100644 index 0000000000..ccad47f419 --- /dev/null +++ b/Task/Find-the-missing-permutation/REXX/find-the-missing-permutation.rexx @@ -0,0 +1,26 @@ +/*REXX program finds a missing permuation from an internal list. */ + +list='ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA', + 'CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB' + +@.=; @abcU='ABCDEFGUIJKLMNOPQRSTUVWXYZ' +things=4 +bunch=4 + do j=1 for things /*build list of permutation obj. */ + $.j=substr(@abcu,j,1) + end /*j*/ +call permset 1 +exit +/*─────────────────────────────────────PERMSET subroutine───────────────*/ +permset:procedure expose $. @. bunch list things; parse arg ? +if ?>bunch then do; _=@.1; do m=2 to bunch + _=_||@.m + end /*m*/ + if wordpos(_,list)==0 then say _ ' is missing from the list.' + end + else do x=1 for things /*construction a new permuation. */ + do k=1 for ?-1; if @.k==$.x then iterate x; end /*k*/ + @.?=$.x + call permset ?+1 + end /*x*/ +return diff --git a/Task/Find-the-missing-permutation/Ruby/find-the-missing-permutation.rb b/Task/Find-the-missing-permutation/Ruby/find-the-missing-permutation.rb new file mode 100644 index 0000000000..0821ec30d7 --- /dev/null +++ b/Task/Find-the-missing-permutation/Ruby/find-the-missing-permutation.rb @@ -0,0 +1,8 @@ +given = %w{ + ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA + CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB +} + +all = given[0].split(//).permutation.collect {|perm| perm.join('')} + +missing = all - given # ["DBAC"] diff --git a/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-1.scala b/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-1.scala new file mode 100644 index 0000000000..3df35d97bc --- /dev/null +++ b/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-1.scala @@ -0,0 +1,40 @@ +def fat(n: Int) = (2 to n).foldLeft(1)(_*_) +def perm[A](x: Int, a: Seq[A]): Seq[A] = if (x == 0) a else { + val n = a.size + val fatN1 = fat(n - 1) + val fatN = fatN1 * n + val p = x / fatN1 % fatN + val (before, Seq(el, after @ _*)) = a splitAt p + el +: perm(x % fatN1, before ++ after) +} +def findMissingPerm(start: String, perms: Array[String]): String = { + for { + i <- 0 until fat(start.size) + p = perm(i, start).mkString + } if (!perms.contains(p)) return p + "" +} +val perms = """ABCD +CABD +ACDB +DACB +BCDA +ACBD +ADCB +CDAB +DABC +BCAD +CADB +CDBA +CBAD +ABDC +ADBC +BDCA +DCBA +BACD +BADC +BDAC +CBDA +DBCA +DCAB""".stripMargin.split("\n") +println(findMissingPerm(perms(0), perms)) diff --git a/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-2.scala b/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-2.scala new file mode 100644 index 0000000000..70aa7f8080 --- /dev/null +++ b/Task/Find-the-missing-permutation/Scala/find-the-missing-permutation-2.scala @@ -0,0 +1,2 @@ +println("missing perms: "+("ABCD".permutations.toSet + --"ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB".stripMargin.split(" ").toSet)) diff --git a/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-1.tcl b/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-1.tcl new file mode 100644 index 0000000000..ddf0b76f51 --- /dev/null +++ b/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-1.tcl @@ -0,0 +1,24 @@ +package require struct::list +package require struct::set + +# Make complete list of permutations of a string of characters +proc allCharPerms s { + set perms {} + set p [struct::list firstperm [split $s {}]] + while {$p ne ""} { + lappend perms [join $p {}] + set p [struct::list nextperm $p] + } + return $perms +} + +# The set of provided permutations (wrapped for convenience) +set have { + ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC + ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB +} +# Get the real list of permutations... +set all [allCharPerms [lindex $have 0]] +# Find the missing one(s)! +set missing [struct::set difference $all $have] +puts "missing permutation(s): $missing" diff --git a/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-2.tcl b/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-2.tcl new file mode 100644 index 0000000000..295f2c271d --- /dev/null +++ b/Task/Find-the-missing-permutation/Tcl/find-the-missing-permutation-2.tcl @@ -0,0 +1,24 @@ +package require struct::list +package require struct::set + +proc foreachPermutation {varName listToPermute body} { + upvar 1 $varName v + set p [struct::list firstperm $listToPermute] + for {} {$p ne ""} {set p [struct::list nextperm $p]} { + set v $p; uplevel 1 $body + } +} + +proc findMissingCharPermutations {set} { + set all {} + foreachPermutation charPerm [split [lindex $set 0] {}] { + lappend all [join $charPerm {}] + } + return [struct::set difference $all $set] +} + +set have { + ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC + ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB +} +set missing [findMissingCharPermutations $have] diff --git a/Task/First-class-environments/0DESCRIPTION b/Task/First-class-environments/0DESCRIPTION new file mode 100644 index 0000000000..f9c3178248 --- /dev/null +++ b/Task/First-class-environments/0DESCRIPTION @@ -0,0 +1,17 @@ +According to [[wp:First-class_object|Wikipedia]], "In computing, a first-class object ... is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable". + +Often this term is used in the context of "first class functions". In an analogous way, a programming language may support "first class environments". + +The environment is minimally, the set of variables accessable to a statement being executed. Change the environments and the same statement could produce different results when executed. + +Often an environment is captured in a [[wp:Closure_(computer_science)|closure]], which encapsulates a function together with an environment. That environment, however, is '''not''' first-class, as it cannot be created, passed etc. independently from the function's code. + +Therefore, a first class environment is a set of variable bindings which can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable. It is like a closure without code. A statement must be able to be executed within a stored first class environment and act according to the environment variable values stored within. + +The task: Build a dozen environments, and a single piece of code to be run repeatedly in each of these envionments. + +Each environment contains the bindings for two variables: A value in the [[Hailstone sequence]], and a count which is incremented until the value drops to 1. The initial hailstone values are 1 through 12, and the count in each environment is zero. + +When the code runs, it calculates the next hailstone step in the current environment (unless the value is already 1) and counts the steps. Then it prints the current value in a tabular form. + +When all hailstone values dropped to 1, processing stops, and the total number of hailstone steps for each environment is printed. diff --git a/Task/First-class-environments/1META.yaml b/Task/First-class-environments/1META.yaml new file mode 100644 index 0000000000..f407ff9d83 --- /dev/null +++ b/Task/First-class-environments/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Classic CS problems and programs diff --git a/Task/First-class-environments/BBC-BASIC/first-class-environments.bbc b/Task/First-class-environments/BBC-BASIC/first-class-environments.bbc new file mode 100644 index 0000000000..62118ae286 --- /dev/null +++ b/Task/First-class-environments/BBC-BASIC/first-class-environments.bbc @@ -0,0 +1,46 @@ + DIM @environ$(12) + @% = 4 : REM Column width + + REM Initialise: + FOR E% = 1 TO 12 + PROCsetenvironment(@environ$(E%)) + seq% = E% + cnt% = 0 + @environ$(E%) = FNgetenvironment + NEXT + + REM Run hailstone sequences: + REPEAT + T% = 0 + FOR E% = 1 TO 12 + PROCsetenvironment(@environ$(E%)) + PRINT seq% ; + IF seq% <> 1 THEN + T% += 1 + cnt% += 1 + IF seq% AND 1 seq% = 3 * seq% + 1 ELSE seq% DIV= 2 + ENDIF + @environ$(E%) = FNgetenvironment + NEXT + PRINT + UNTIL T% = 0 + + REM Print counts: + PRINT "Counts:" + FOR E% = 1 TO 12 + PROCsetenvironment(@environ$(E%)) + PRINT cnt% ; + @environ$(E%) = FNgetenvironment + NEXT + PRINT + END + + DEF FNgetenvironment + LOCAL e$ : e$ = STRING$(216, CHR$0) + SYS "RtlMoveMemory", !^e$, ^@%+108, 216 + = e$ + + DEF PROCsetenvironment(e$) + IF LEN(e$) < 216 e$ = STRING$(216, CHR$0) + SYS "RtlMoveMemory", ^@%+108, !^e$, 216 + ENDPROC diff --git a/Task/First-class-environments/Bracmat/first-class-environments.bracmat b/Task/First-class-environments/Bracmat/first-class-environments.bracmat new file mode 100644 index 0000000000..91f227b7ec --- /dev/null +++ b/Task/First-class-environments/Bracmat/first-class-environments.bracmat @@ -0,0 +1,34 @@ +( (environment=(cnt=0) (seq=)) +& :?environments +& 13:?seq +& whl + ' ( !seq+-1:>0:?seq + & new$environment:?env + & !seq:?(env..seq) + & !env !environments:?environments + ) +& out$(Before !environments) +& whl + ' ( !environments:? (=? (seq=>1) ?) ? + & !environments:?envs + & whl + ' ( !envs:(=?env) ?envs + & ( + ' ( $env + ( + = + . put$(!(its.seq) \t) + & !(its.seq):1 + | 1+!(its.cnt):?(its.cnt) + & 1/2*!(its.seq):~/?(its.seq) + | 3*!(its.seq)+1:?(its.seq) + ) + ) + . + ) + $ + ) + & out$ + ) +& out$(After !environments) +) diff --git a/Task/First-class-environments/C/first-class-environments.c b/Task/First-class-environments/C/first-class-environments.c new file mode 100644 index 0000000000..2b7190a3e7 --- /dev/null +++ b/Task/First-class-environments/C/first-class-environments.c @@ -0,0 +1,36 @@ +#include + +#define JOBS 12 +#define jobs(a) for (switch_to(a = 0); a < JOBS || !printf("\n"); switch_to(++a)) +typedef struct { int seq, cnt; } env_t; + +env_t env[JOBS] = {{0, 0}}; +int *seq, *cnt; + +void hail() +{ + printf("% 4d", *seq); + if (*seq == 1) return; + ++*cnt; + *seq = (*seq & 1) ? 3 * *seq + 1 : *seq / 2; +} + +void switch_to(int id) +{ + seq = &env[id].seq; + cnt = &env[id].cnt; +} + +int main() +{ + int i; + jobs(i) { env[i].seq = i + 1; } + +again: jobs(i) { hail(); } + jobs(i) { if (1 != *seq) goto again; } + + printf("COUNTS:\n"); + jobs(i) { printf("% 4d", *cnt); } + + return 0; +} diff --git a/Task/First-class-environments/Icon/first-class-environments.icon b/Task/First-class-environments/Icon/first-class-environments.icon new file mode 100644 index 0000000000..057aa071dd --- /dev/null +++ b/Task/First-class-environments/Icon/first-class-environments.icon @@ -0,0 +1,24 @@ +link printf + +procedure main() + every put(environment := [], hailenv(1 to 12,0)) # setup environments + printf("Sequences:\n") + while (e := !environment).sequence > 1 do { + every hailstep(!environment) + printf("\n") + } + printf("\nCounts:\n") + every printf("%4d ",(!environment).count) + printf("\n") +end + +record hailenv(sequence,count) + +procedure hailstep(env) + printf("%4d ",env.sequence) + if env.sequence ~= 1 then { + env.count +:= 1 + if env.sequence % 2 = 0 then env.sequence /:= 2 + else env.sequence := 3 * env.sequence + 1 + } +end diff --git a/Task/First-class-environments/J/first-class-environments-1.j b/Task/First-class-environments/J/first-class-environments-1.j new file mode 100644 index 0000000000..09ae7a3517 --- /dev/null +++ b/Task/First-class-environments/J/first-class-environments-1.j @@ -0,0 +1,35 @@ +coclass 'hailstone' + +step=:3 :0 + NB. and determine next element in hailstone sequence + if.1=N do. N return.end. + NB. count how many times this has run when N was not 1 + STEP=:STEP+1 + if.0=2|N do. + N=: N%2 + else. + N=: 1 + 3*N + end. +) + +create=:3 :0 + STEP=: 0 + N=: y +) + +current=:3 :0 + N__y +) + +run1=:3 :0 + step__y'' + STEP__y +) + +run=:3 :0 + old=: '' + while. -. old -: state=: run1"0 y do. + smoutput 4j0 ": current"0 y + old=: state + end. +) diff --git a/Task/First-class-environments/J/first-class-environments-2.j b/Task/First-class-environments/J/first-class-environments-2.j new file mode 100644 index 0000000000..2b9f0c8aa4 --- /dev/null +++ b/Task/First-class-environments/J/first-class-environments-2.j @@ -0,0 +1,22 @@ + environments=: conew&'hailstone'"0 (1+i.12) + run_hailstone_ environments + 1 1 10 2 16 3 22 4 28 5 34 6 + 1 1 5 1 8 10 11 2 14 16 17 3 + 1 1 16 1 4 5 34 1 7 8 52 10 + 1 1 8 1 2 16 17 1 22 4 26 5 + 1 1 4 1 1 8 52 1 11 2 13 16 + 1 1 2 1 1 4 26 1 34 1 40 8 + 1 1 1 1 1 2 13 1 17 1 20 4 + 1 1 1 1 1 1 40 1 52 1 10 2 + 1 1 1 1 1 1 20 1 26 1 5 1 + 1 1 1 1 1 1 10 1 13 1 16 1 + 1 1 1 1 1 1 5 1 40 1 8 1 + 1 1 1 1 1 1 16 1 20 1 4 1 + 1 1 1 1 1 1 8 1 10 1 2 1 + 1 1 1 1 1 1 4 1 5 1 1 1 + 1 1 1 1 1 1 2 1 16 1 1 1 + 1 1 1 1 1 1 1 1 8 1 1 1 + 1 1 1 1 1 1 1 1 4 1 1 1 + 1 1 1 1 1 1 1 1 2 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 +0 1 7 2 5 8 16 3 19 6 14 9 diff --git a/Task/First-class-environments/PicoLisp/first-class-environments.l b/Task/First-class-environments/PicoLisp/first-class-environments.l new file mode 100644 index 0000000000..cda235db88 --- /dev/null +++ b/Task/First-class-environments/PicoLisp/first-class-environments.l @@ -0,0 +1,20 @@ +(let Envs + (mapcar + '((N) (list (cons 'N N) (cons 'Cnt 0))) # Build environments + (range 1 12) ) + (while (find '((E) (job E (> N 1))) Envs) # Until all values are 1: + (for E Envs + (job E # Use environment 'E' + (prin (align 4 N)) + (unless (= 1 N) + (inc 'Cnt) # Increment step count + (setq N + (if (bit? 1 N) # Calculate next hailstone value + (inc (* N 3)) + (/ N 2) ) ) ) ) ) + (prinl) ) + (prinl (need 48 '=)) + (for E Envs # For each environment 'E' + (job E + (prin (align 4 Cnt)) ) ) # print the step count + (prinl) ) diff --git a/Task/First-class-environments/Python/first-class-environments.py b/Task/First-class-environments/Python/first-class-environments.py new file mode 100644 index 0000000000..251b4202a2 --- /dev/null +++ b/Task/First-class-environments/Python/first-class-environments.py @@ -0,0 +1,18 @@ +environments = [{'cnt':0, 'seq':i+1} for i in range(12)] + +code = ''' +print('% 4d' % seq, end='') +if seq != 1: + cnt += 1 + seq = 3 * seq + 1 if seq & 1 else seq // 2 +''' + +while any(env['seq'] > 1 for env in environments): + for env in environments: + exec(code, globals(), env) + print() + +print('Counts') +for env in environments: + print('% 4d' % env['cnt'], end='') +print() diff --git a/Task/First-class-environments/R/first-class-environments.r b/Task/First-class-environments/R/first-class-environments.r new file mode 100644 index 0000000000..54eca12947 --- /dev/null +++ b/Task/First-class-environments/R/first-class-environments.r @@ -0,0 +1,16 @@ +code <- quote( + if (n == 1) n else { + count <- count + 1; + n <- if (n %% 2 == 1) 3 * n + 1 else n/2 + }) + +eprint <- function(envs, var="n") + cat(paste(sprintf("%4d", sapply(envs, `[[`, var)), collapse=" "), "\n") + +envs <- mapply(function(...) list2env(list(...)), n=1:12, count=0) + +while (any(sapply(envs, eval, expr=code) > 1)) {eprint(envs)} +eprint(envs) + +cat("\nCounts:\n") +eprint(envs, "count") diff --git a/Task/First-class-environments/REXX/first-class-environments.rexx b/Task/First-class-environments/REXX/first-class-environments.rexx new file mode 100644 index 0000000000..3a934a62a7 --- /dev/null +++ b/Task/First-class-environments/REXX/first-class-environments.rexx @@ -0,0 +1,35 @@ +/*REXX program illustrates first-class environments (using hailstone #s)*/ +parse arg #envs .; env_.=; if #envs=='' then #envs=12 + +/*═════════════════════════════════════initialize (twelve) environments.*/ + do init=1 for #envs; env_.init=init; end + +/*═════════════════════════════════════process environments until done. */ + do forever until env_.0; env_.0=1 + do k=1 for #envs + env_.k=env_.k hailstone(k) /*where the rubber meets the road*/ + end /*k*/ + end /*forever*/ + +/*═════════════════════════════════════show results in tabular form. */ +count=0; do lines=-1 until _==''; _= + do j=1 for #envs + select + when count== 1 then _=_ right(words(env_.j)-1,3) + when lines==-1 then _=_ right(j,3) + when lines== 0 then _=_ right('',3,'─') + otherwise _=_ right(word(env_.j,lines),3) + end /*select*/ + end /*j*/ + + if count==1 then count=2 + _=strip(_,'T') + if _=='' then count=count+1 + if count==1 then _=copies(' ═══',#envs) + if _\=='' then say substr(_,2) + end /*lines*/ +exit /*stick a fork in it, we're done.*/ + +/*─────────────────────────────────────HAILSTONE (Collatz) subroutine───*/ +hailstone: procedure expose env_.; arg n; _=word(env_.n,words(env_.n)) +if _==1 then return ''; env_.0=0; if _//2==0 then return _%2; return _*3+1 diff --git a/Task/First-class-environments/Ruby/first-class-environments-1.rb b/Task/First-class-environments/Ruby/first-class-environments-1.rb new file mode 100644 index 0000000000..3ab1a5f43a --- /dev/null +++ b/Task/First-class-environments/Ruby/first-class-environments-1.rb @@ -0,0 +1,29 @@ +# Build environments +envs = (1..12).map do |n| + Object.new.instance_eval {@n = n; @cnt = 0; self} +end + +# Until all values are 1: +while envs.find {|e| e.instance_eval {@n} > 1} + envs.each do |e| + e.instance_eval do # Use environment _e_ + printf "%4s", @n + unless 1 == @n + @cnt += 1 # Increment step count + @n = if 1 & @n == 1 # Calculate next hailstone value + @n * 3 + 1 + else + @n / 2 + end + end + end + end + puts +end +puts '=' * 48 +envs.each do |e| # For each environment _e_ + e.instance_eval do + printf "%4s", @cnt # print the step count + end +end +puts diff --git a/Task/First-class-environments/Ruby/first-class-environments-2.rb b/Task/First-class-environments/Ruby/first-class-environments-2.rb new file mode 100644 index 0000000000..570de7d5b0 --- /dev/null +++ b/Task/First-class-environments/Ruby/first-class-environments-2.rb @@ -0,0 +1,38 @@ +# Build environments +envs = (1..12).map do |n| + e = class Object + # This is a new lexical scope with no local variables. + # Create a new binding here. + binding + end + eval(<<-'eos', e).call(n) + n, cnt = nil, 0 + proc {|arg| n = arg} + eos + next e +end + +# Until all values are 1: +while envs.find {|e| eval('n > 1', e)} + envs.each do |e| + eval(<<-'eos', e) # Use environment _e_ + printf "%4s", n + unless 1 == n + cnt += 1 # Increment step count + n = if 1 & n == 1 # Calculate next hailstone value + n * 3 + 1 + else + n / 2 + end + end + eos + end + puts +end +puts '=' * 48 +envs.each do |e| # For each environment _e_ + eval(<<-'eos', e) + printf "%4s", cnt # print the step count + eos +end +puts diff --git a/Task/First-class-environments/Tcl/first-class-environments.tcl b/Task/First-class-environments/Tcl/first-class-environments.tcl new file mode 100644 index 0000000000..9fe14237df --- /dev/null +++ b/Task/First-class-environments/Tcl/first-class-environments.tcl @@ -0,0 +1,31 @@ +package require Tcl 8.5 + +for {set i 1} {$i <= 12} {incr i} { + dict set hailenv hail$i [dict create num $i steps 0] +} +while 1 { + set loopagain false + foreach k [dict keys $hailenv] { + dict with hailenv $k { + puts -nonewline [format %4d $num] + if {$num == 1} { + continue + } elseif {$num & 1} { + set num [expr {3*$num + 1}] + } else { + set num [expr {$num / 2}] + } + set loopagain true + incr steps + } + } + puts "" + if {!$loopagain} break +} +puts "Counts..." +foreach k [dict keys $hailenv] { + dict with hailenv $k { + puts -nonewline [format %4d $steps] + } +} +puts "" diff --git a/Task/First-class-functions-Use-numbers-analogously/0DESCRIPTION b/Task/First-class-functions-Use-numbers-analogously/0DESCRIPTION new file mode 100644 index 0000000000..0b084bd6cf --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/0DESCRIPTION @@ -0,0 +1,21 @@ +In [[First-class functions]], a language is showing how its manipulation of functions is similar to its manipulation of other types. + +This tasks aim is to compare and contrast a languages implementation of First class functions, with its normal handling of numbers. + + +Write a program to create an ordered collection of a mixture of literally typed and expressions producing a real number, together with another ordered collection of their multiplicative inverses. Try and use the following pseudo-code to generate the numbers for the ordered collections: + x = 2.0 + xi = 0.5 + y = 4.0 + yi = 0.25 + z = x + y + zi = 1.0 / ( x + y ) + +Create a function ''multiplier'', that given two numbers as arguments returns a function that when called with one argument, returns the result of multiplying the two arguments to the call to multiplier that created it and the argument in the call: + new_function = multiplier(n1,n2) + # where new_function(m) returns the result of n1 * n2 * m + +Applying the multiplier of a number and its inverse from the two ordered collections of numbers in pairs, show that the result in each case is one.
+'''Compare and contrast the resultant program with the corresponding entry in [[First-class functions]].''' They should be close. + +To paraphrase the task description: Do what was done before, but with numbers rather than functions diff --git a/Task/First-class-functions-Use-numbers-analogously/ALGOL-68/first-class-functions-use-numbers-analogously.alg b/Task/First-class-functions-Use-numbers-analogously/ALGOL-68/first-class-functions-use-numbers-analogously.alg new file mode 100644 index 0000000000..2b16867915 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/ALGOL-68/first-class-functions-use-numbers-analogously.alg @@ -0,0 +1,22 @@ +REAL + x := 2, + xi := 0.5, + y := 4, + yi := 0.25, + z := x + y, + zi := 1 / ( x + y ); + +MODE F = PROC(REAL)REAL; + +PROC multiplier = (REAL n1, n2)F: ((REAL m)REAL: n1 * n2 * m); + +# Numbers as members of collections # +[]REAL num list = (x, y, z), + inv num list = (xi, yi, zi); + +# Apply numbers from list # +FOR key TO UPB num list DO + REAL n = num list[key], + inv n = inv num list[key]; + print ((multiplier(inv n, n)(.5), new line)) +OD diff --git a/Task/First-class-functions-Use-numbers-analogously/Ada/first-class-functions-use-numbers-analogously.ada b/Task/First-class-functions-Use-numbers-analogously/Ada/first-class-functions-use-numbers-analogously.ada new file mode 100644 index 0000000000..ab646a3ef5 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Ada/first-class-functions-use-numbers-analogously.ada @@ -0,0 +1,21 @@ +with Ada.Text_IO; +procedure Firstclass is + generic + n1, n2 : Float; + function Multiplier (m : Float) return Float; + function Multiplier (m : Float) return Float is begin + return n1 * n2 * m; + end Multiplier; + + num, inv : array (1 .. 3) of Float; +begin + num := (2.0, 4.0, 6.0); + inv := (1.0/2.0, 1.0/4.0, 1.0/6.0); + for i in num'Range loop + declare + function new_function is new Multiplier (num (i), inv (i)); + begin + Ada.Text_IO.Put_Line (new_function (0.5)'Img); + end; + end loop; +end Firstclass; diff --git a/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-1.axiom b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-1.axiom new file mode 100644 index 0000000000..f2b3f879c2 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-1.axiom @@ -0,0 +1,5 @@ +(x,xi,y,yi) := (2.0,0.5,4.0,0.25) +(z,zi) := (x+y,1/(x+y)) +(numbers,invers) := ([x,y,z],[xi,yi,zi]) +multiplier(a:Float,b:Float):(Float->Float) == (m +-> a*b*m) +[multiplier(number,inver) 0.5 for number in numbers for inver in invers] diff --git a/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-2.axiom b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-2.axiom new file mode 100644 index 0000000000..d85cbfe669 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-2.axiom @@ -0,0 +1,2 @@ + [0.5,0.5,0.5] + Type: List(Float) diff --git a/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-3.axiom b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-3.axiom new file mode 100644 index 0000000000..2b73dc2a89 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-3.axiom @@ -0,0 +1,3 @@ +mult(n:Float):(Float->Float) == curryLeft(*$Float,n)$MAPPKG3(Float,Float,Float) +[mult(number*inver) 0.5 for number in numbers for inver in invers] +[(mult(number)*mult(inver)) 0.5 for number in numbers for inver in invers] diff --git a/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-4.axiom b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-4.axiom new file mode 100644 index 0000000000..9fa14b4eae --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-4.axiom @@ -0,0 +1 @@ +(map(mult,numbers)*map(mult,invers)) 0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-5.axiom b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-5.axiom new file mode 100644 index 0000000000..4c40802e9d --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Axiom/first-class-functions-use-numbers-analogously-5.axiom @@ -0,0 +1,3 @@ +fns := [sin$Float, cos$Float, (x:Float):Float +-> x^3] +inv := [asin$Float, acos$Float, (x:Float):Float +-> x^(1/3)] +[(f*g) 0.5 for f in fns for g in inv] diff --git a/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-1.bbc b/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-1.bbc new file mode 100644 index 0000000000..e6235dbabf --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-1.bbc @@ -0,0 +1,28 @@ + REM Create some numeric variables: + x = 2 : xi = 1/2 + y = 4 : yi = 0.25 + z = x + y : zi = 1 / (x + y) + + REM Create the collections (here structures are used): + DIM c{x, y, z} + DIM ci{x, y, z} + c.x = x : c.y = y : c.z = z + ci.x = xi : ci.y = yi : ci.z = zi + + REM Create some multiplier functions: + multx = FNmultiplier(c.x, ci.x) + multy = FNmultiplier(c.y, ci.y) + multz = FNmultiplier(c.z, ci.z) + + REM Test applying the compositions: + x = 1.234567 : PRINT x " ", FN(multx)(x) + x = 2.345678 : PRINT x " ", FN(multy)(x) + x = 3.456789 : PRINT x " ", FN(multz)(x) + END + + DEF FNmultiplier(n1,n2) + LOCAL f$, p% + f$ = "(m)=" + STR$n1 + "*" + STR$n2 + "*m" + DIM p% LEN(f$) + 4 + $(p%+4) = f$ : !p% = p%+4 + = p% diff --git a/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-2.bbc b/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-2.bbc new file mode 100644 index 0000000000..5e7b0b0452 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/BBC-BASIC/first-class-functions-use-numbers-analogously-2.bbc @@ -0,0 +1,34 @@ + REM Create some functions and their inverses: + DEF FNsin(a) = SIN(a) + DEF FNasn(a) = ASN(a) + DEF FNcos(a) = COS(a) + DEF FNacs(a) = ACS(a) + DEF FNcube(a) = a^3 + DEF FNroot(a) = a^(1/3) + + dummy = FNsin(1) + + REM Create the collections (here structures are used): + DIM cA{Sin%, Cos%, Cube%} + DIM cB{Asn%, Acs%, Root%} + cA.Sin% = ^FNsin() : cA.Cos% = ^FNcos() : cA.Cube% = ^FNcube() + cB.Asn% = ^FNasn() : cB.Acs% = ^FNacs() : cB.Root% = ^FNroot() + + REM Create some function compositions: + AsnSin% = FNcompose(cB.Asn%, cA.Sin%) + AcsCos% = FNcompose(cB.Acs%, cA.Cos%) + RootCube% = FNcompose(cB.Root%, cA.Cube%) + + REM Test applying the compositions: + x = 1.234567 : PRINT x, FN(AsnSin%)(x) + x = 2.345678 : PRINT x, FN(AcsCos%)(x) + x = 3.456789 : PRINT x, FN(RootCube%)(x) + END + + DEF FNcompose(f%,g%) + LOCAL f$, p% + f$ = "(x)=" + CHR$&A4 + "(&" + STR$~f% + ")(" + \ + \ CHR$&A4 + "(&" + STR$~g% + ")(x))" + DIM p% LEN(f$) + 4 + $(p%+4) = f$ : !p% = p%+4 + = p% diff --git a/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-1.clj b/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-1.clj new file mode 100644 index 0000000000..e9002aa2c8 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-1.clj @@ -0,0 +1,16 @@ +(def x 2.0) +(def xi 0.5) +(def y 4.0) +(def yi 0.25) +(def z (+ x y)) +(def zi (/ 1.0 (+ x y))) + +(def numbers [x y z]) +(def invers [xi yi zi]) + +(defn multiplier [a b] + (fn [m] (* a b m))) + +> (for [[n i] (zipmap numbers invers)] + ((multiplier n i) 0.5)) +(0.5 0.5 0.5) diff --git a/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-2.clj b/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-2.clj new file mode 100644 index 0000000000..4eec9c3164 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Clojure/first-class-functions-use-numbers-analogously-2.clj @@ -0,0 +1,4 @@ +(use 'clojure.contrib.math) +(let [fns [#(Math/sin %) #(Math/cos %) (fn [x] (* x x x))] + inv [#(Math/asin %) #(Math/acos %) #(expt % 1/3)]] + (map #(% 0.5) (map #(comp %1 %2) fns inv))) diff --git a/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-1.lisp b/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-1.lisp new file mode 100644 index 0000000000..7a07c756de --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-1.lisp @@ -0,0 +1,20 @@ +(defun multiplier (f g) + #'(lambda (x) (* f g x))) + +(let* ((x 2.0) + (xi 0.5) + (y 4.0) + (yi 0.25) + (z (+ x y)) + (zi (/ 1.0 (+ x y))) + (numbers (list x y z)) + (inverses (list xi yi zi))) + (loop with value = 0.5 + for number in numbers + for inverse in inverses + for multiplier = (multiplier number inverse) + do (format t "~&(~A * ~A)(~A) = ~A~%" + number + inverse + value + (funcall multiplier value)))) diff --git a/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-2.lisp b/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-2.lisp new file mode 100644 index 0000000000..8f1da1d8ca --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Common-Lisp/first-class-functions-use-numbers-analogously-2.lisp @@ -0,0 +1,13 @@ +(defun compose (f g) (lambda (x) (funcall f (funcall g x)))) +(defun cube (x) (expt x 3)) +(defun cube-root (x) (expt x (/ 3))) + +(loop with value = 0.5 + for function in (list #'sin #'cos #'cube ) + for inverse in (list #'asin #'acos #'cube-root) + for composed = (compose inverse function) + do (format t "~&(~A ∘ ~A)(~A) = ~A~%" + inverse + function + value + (funcall composed value))) diff --git a/Task/First-class-functions-Use-numbers-analogously/D/first-class-functions-use-numbers-analogously.d b/Task/First-class-functions-Use-numbers-analogously/D/first-class-functions-use-numbers-analogously.d new file mode 100644 index 0000000000..b9a14920cf --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/D/first-class-functions-use-numbers-analogously.d @@ -0,0 +1,25 @@ +import std.stdio; + +auto multiplier(double a, double b) +{ + return (double c) => a * b * c; +} + +void main() +{ + double x = 2.0; + double xi = 0.5; + double y = 4.0; + double yi = 0.25; + double z = x + y; + double zi = 1.0 / (z); + + double[3] f = [x, y, z]; + double[3] r = [xi, yi, zi]; + + foreach (i; 0..3) + { + auto mult = multiplier(f[i], r[i]); + writefln("%f * %f * %f == %f", f[i], r[i], 1.0, mult(1)); + } +} diff --git a/Task/First-class-functions-Use-numbers-analogously/E/first-class-functions-use-numbers-analogously.e b/Task/First-class-functions-Use-numbers-analogously/E/first-class-functions-use-numbers-analogously.e new file mode 100644 index 0000000000..ad3368725d --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/E/first-class-functions-use-numbers-analogously.e @@ -0,0 +1,18 @@ +def x := 2.0 +def xi := 0.5 +def y := 4.0 +def yi := 0.25 +def z := x + y +def zi := 1.0 / (x + y) +def forward := [x, y, z ] +def reverse := [xi, yi, zi] + +def multiplier(a, b) { + return fn x { a * b * x } +} + +def s := 0.5 +for i => a in forward { + def b := reverse[i] + println(`s = $s, a = $a, b = $b, multiplier($a, $b)($s) = ${multiplier(a, b)(s)}`) +} diff --git a/Task/First-class-functions-Use-numbers-analogously/Factor/first-class-functions-use-numbers-analogously.factor b/Task/First-class-functions-Use-numbers-analogously/Factor/first-class-functions-use-numbers-analogously.factor new file mode 100644 index 0000000000..f69e1f5a43 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Factor/first-class-functions-use-numbers-analogously.factor @@ -0,0 +1,23 @@ +USING: arrays fry kernel math prettyprint sequences ; +IN: hof +CONSTANT: x 2.0 +CONSTANT: xi 0.5 +CONSTANT: y 4.0 +CONSTANT: yi .25 +: z ( -- z ) + << x y + suffix! >> ; inline +: zi ( -- zi ) + << 1 x y + / suffix! >> ; inline +: numbers ( -- numbers ) + << x y z 3array suffix! >> ; inline +: inverses ( -- inverses ) + << xi yi zi 3array suffix! >> ; inline +CONSTANT: m 0.5 +: multiplyer ( n1 n2 -- q ) + '[ _ _ * * ] ; inline +: go ( n1 n2 -- ) + 2dup [ empty? ] bi@ or not ! either empty + [ + [ [ first ] bi@ multiplyer m swap call . ] + [ [ rest-slice ] bi@ go ] 2bi + ] [ 2drop ] if ; diff --git a/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-1.fantom b/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-1.fantom new file mode 100644 index 0000000000..90e371699f --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-1.fantom @@ -0,0 +1,20 @@ +class Main +{ + static |Float -> Float| combine (Float n1, Float n2) + { + return |Float m -> Float| { n1 * n2 * m } + } + + public static Void main () + { + Float x := 2f + Float xi := 0.5f + Float y := 4f + Float yi := 0.25f + Float z := x + y + Float zi := 1 / (x + y) + echo (combine(x, xi)(0.5f)) + echo (combine(y, yi)(0.5f)) + echo (combine(z, zi)(0.5f)) + } +} diff --git a/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-2.fantom b/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-2.fantom new file mode 100644 index 0000000000..f6f74d040a --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Fantom/first-class-functions-use-numbers-analogously-2.fantom @@ -0,0 +1,4 @@ + static |Obj -> Obj| compose (|Obj -> Obj| fn1, |Obj -> Obj| fn2) + { + return |Obj x -> Obj| { fn2 (fn1 (x)) } + } diff --git a/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-1.go b/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-1.go new file mode 100644 index 0000000000..245daed1a1 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-1.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +func main() { + x := 2. + xi := .5 + y := 4. + yi := .25 + z := x + y + zi := 1 / (x + y) + // point A + + numbers := []float64{x, y, z} + inverses := []float64{xi, yi, zi} + // point B + + mfs := make([]func(float64) float64, len(numbers)) + for i := range mfs { + mfs[i] = multiplier(numbers[i], inverses[i]) + } + // point C + + for _, mf := range mfs { + fmt.Println(mf(1)) + } +} + +func multiplier(n1, n2 float64) func(float64) float64 { + // compute product of n's, store in a new variable + n1n2 := n1 * n2 + // close on variable containing product + return func(m float64) float64 { + return n1n2 * m + } +} diff --git a/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-2.go b/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-2.go new file mode 100644 index 0000000000..53f75cab60 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Go/first-class-functions-use-numbers-analogously-2.go @@ -0,0 +1,48 @@ +package main + +import "fmt" + +func main() { + x := 2. + xi := .5 + y := 4. + yi := .25 + z := func() float64 { return x + y } + zi := func() float64 { return 1 / (x + y) } + // point A + + numbers := []interface{}{&x, &y, z} + inverses := []interface{}{&xi, &yi, zi} + // point B + + mfs := make([]func(n interface{}) float64, len(numbers)) + for i := range mfs { + mfs[i] = multiplier(numbers[i], inverses[i]) + } + // pointC + + for _, mf := range mfs { + fmt.Println(mf(1.)) + } +} + +func multiplier(n1, n2 interface{}) func(interface{}) float64 { + return func(m interface{}) float64 { + // close on interface objects n1, n2, and m + return eval(n1) * eval(n2) * eval(m) + } +} + +// utility function for evaluating multiplier interface objects +func eval(n interface{}) float64 { + switch n.(type) { + case float64: + return n.(float64) + case *float64: + return *n.(*float64) + case func() float64: + return n.(func() float64)() + } + panic("unsupported multiplier type") + return 0 // never reached +} diff --git a/Task/First-class-functions-Use-numbers-analogously/Haskell/first-class-functions-use-numbers-analogously.hs b/Task/First-class-functions-Use-numbers-analogously/Haskell/first-class-functions-use-numbers-analogously.hs new file mode 100644 index 0000000000..fb949211bb --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Haskell/first-class-functions-use-numbers-analogously.hs @@ -0,0 +1,27 @@ +module Main + where + +import Text.Printf + +-- Pseudo code happens to be valid Haskell +x = 2.0 +xi = 0.5 +y = 4.0 +yi = 0.25 +z = x + y +zi = 1.0 / ( x + y ) + +-- Multiplier function +multiplier :: Double -> Double -> Double -> Double +multiplier a b = \m -> a * b * m + +main :: IO () +main = do + let + numbers = [x, y, z] + inverses = [xi, yi, zi] + pairs = zip numbers inverses + print_pair (number, inverse) = + let new_function = multiplier number inverse + in printf "%f * %f * 0.5 = %f\n" number inverse (new_function 0.5) + mapM_ print_pair pairs diff --git a/Task/First-class-functions-Use-numbers-analogously/Icon/first-class-functions-use-numbers-analogously.icon b/Task/First-class-functions-Use-numbers-analogously/Icon/first-class-functions-use-numbers-analogously.icon new file mode 100644 index 0000000000..c481265b5c --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Icon/first-class-functions-use-numbers-analogously.icon @@ -0,0 +1,10 @@ +import Utils + +procedure main(A) + mult := multiplier(get(A),get(A)) # first 2 args define function + every write(mult(!A)) # remaining are passed to new function +end + +procedure multiplier(n1,n2) + return makeProc { repeat inVal := n1 * n2 * (inVal@&source)[1] } +end diff --git a/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-1.j b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-1.j new file mode 100644 index 0000000000..1938942ebb --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-1.j @@ -0,0 +1,11 @@ + x =: 2.0 + xi =: 0.5 + y =: 4.0 + yi =: 0.25 + z =: x + y + zi =: 1.0 % (x + y) NB. / is spelled % in J + + fwd =: x ,y ,z + rev =: xi,yi,zi + + multiplier =: 2 : 'm * n * ]' diff --git a/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-2.j b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-2.j new file mode 100644 index 0000000000..e052c7d2f9 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-2.j @@ -0,0 +1,2 @@ + fwd multiplier rev 0.5 +0.5 0.5 0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-3.j b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-3.j new file mode 100644 index 0000000000..d5349983d2 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/J/first-class-functions-use-numbers-analogously-3.j @@ -0,0 +1,2 @@ + BA unqcol 0.5 +0.5 0.5 0.5 0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-1.mathematica b/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-1.mathematica new file mode 100644 index 0000000000..5c55c7a350 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-1.mathematica @@ -0,0 +1,4 @@ +multiplier[n1_,n2_]:=n1 n2 #& +num={2,4,2+4}; +numi=1/num; +multiplierfuncs = multiplier @@@ Transpose[{num, numi}]; diff --git a/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-2.mathematica b/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-2.mathematica new file mode 100644 index 0000000000..a858f640ad --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Mathematica/first-class-functions-use-numbers-analogously-2.mathematica @@ -0,0 +1 @@ +multiplier[arg__] := Times[arg, #] & diff --git a/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-1.l b/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-1.l new file mode 100644 index 0000000000..b446ca53ec --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-1.l @@ -0,0 +1,12 @@ +(load "@lib/math.l") + +(de multiplier (N1 N2) + (curry (N1 N2) (X) + (*/ N1 N2 X `(* 1.0 1.0)) ) ) + +(let (X 2.0 Xi 0.5 Y 4.0 Yi 0.25 Z (+ X Y) Zi (*/ 1.0 1.0 Z)) + (mapc + '((Num Inv) + (prinl (format ((multiplier Inv Num) 0.5) *Scl)) ) + (list X Y Z) + (list Xi Yi Zi) ) ) diff --git a/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-2.l b/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-2.l new file mode 100644 index 0000000000..86dc405bf7 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/PicoLisp/first-class-functions-use-numbers-analogously-2.l @@ -0,0 +1,17 @@ +(load "@lib/math.l") + +(de compose (F G) + (curry (F G) (X) + (F (G X)) ) ) + +(de cube (X) + (pow X 3.0) ) + +(de cubeRoot (X) + (pow X 0.3333333) ) + +(mapc + '((Fun Inv) + (prinl (format ((compose Inv Fun) 0.5) *Scl)) ) + '(sin cos cube) + '(asin acos cubeRoot) ) diff --git a/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-1.py b/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-1.py new file mode 100644 index 0000000000..840cc2cb70 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-1.py @@ -0,0 +1,15 @@ +IDLE 2.6.1 +>>> # Number literals +>>> x,xi, y,yi = 2.0,0.5, 4.0,0.25 +>>> # Numbers from calculation +>>> z = x + y +>>> zi = 1.0 / (x + y) +>>> # The multiplier function is similar to 'compose' but with numbers +>>> multiplier = lambda n1, n2: (lambda m: n1 * n2 * m) +>>> # Numbers as members of collections +>>> numlist = [x, y, z] +>>> numlisti = [xi, yi, zi] +>>> # Apply numbers from list +>>> [multiplier(inversen, n)(.5) for n, inversen in zip(numlist, numlisti)] +[0.5, 0.5, 0.5] +>>> diff --git a/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-2.py b/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-2.py new file mode 100644 index 0000000000..50219aaf7c --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Python/first-class-functions-use-numbers-analogously-2.py @@ -0,0 +1,15 @@ +>>> # Some built in functions and their inverses +>>> from math import sin, cos, acos, asin +>>> # Add a user defined function and its inverse +>>> cube = lambda x: x * x * x +>>> croot = lambda x: x ** (1/3.0) +>>> # First class functions allow run-time creation of functions from functions +>>> # return function compose(f,g)(x) == f(g(x)) +>>> compose = lambda f1, f2: ( lambda x: f1(f2(x)) ) +>>> # first class functions should be able to be members of collection types +>>> funclist = [sin, cos, cube] +>>> funclisti = [asin, acos, croot] +>>> # Apply functions from lists as easily as integers +>>> [compose(inversef, f)(.5) for f, inversef in zip(funclist, funclisti)] +[0.5, 0.4999999999999999, 0.5] +>>> diff --git a/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-1.r b/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-1.r new file mode 100644 index 0000000000..bbb0d6879b --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-1.r @@ -0,0 +1,14 @@ +multiplier <- function(n1,n2) { (function(m){n1*n2*m}) } +x = 2.0 +xi = 0.5 +y = 4.0 +yi = 0.25 +z = x + y +zi = 1.0 / ( x + y ) +num = c(x,y,z) +inv = c(xi,yi,zi) + +multiplier(num,inv)(0.5) + +Output +[1] 0.5 0.5 0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-2.r b/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-2.r new file mode 100644 index 0000000000..ed21725304 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/R/first-class-functions-use-numbers-analogously-2.r @@ -0,0 +1,2 @@ +sapply(mapply(compose,f1,f2),do.call,list(.5)) +[1] 0.5 0.5 0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/Ruby/first-class-functions-use-numbers-analogously.rb b/Task/First-class-functions-Use-numbers-analogously/Ruby/first-class-functions-use-numbers-analogously.rb new file mode 100644 index 0000000000..bbe4efb5c4 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Ruby/first-class-functions-use-numbers-analogously.rb @@ -0,0 +1,5 @@ +multiplier = proc {|n1, n2| proc {|m| n1 * n2 * m}} +numlist = [x=2, y=4, x+y] +invlist = [0.5, 0.25, 1.0/(x+y)] +p numlist.zip(invlist).map {|n, invn| multiplier[invn, n][0.5]} +# => [0.5, 0.5, 0.5] diff --git a/Task/First-class-functions-Use-numbers-analogously/Scala/first-class-functions-use-numbers-analogously.scala b/Task/First-class-functions-Use-numbers-analogously/Scala/first-class-functions-use-numbers-analogously.scala new file mode 100644 index 0000000000..fe24896839 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Scala/first-class-functions-use-numbers-analogously.scala @@ -0,0 +1,34 @@ +scala> val x = 2.0 +x: Double = 2.0 + +scala> val xi = 0.5 +xi: Double = 0.5 + +scala> val y = 4.0 +y: Double = 4.0 + +scala> val yi = 0.25 +yi: Double = 0.25 + +scala> val z = x + y +z: Double = 6.0 + +scala> val zi = 1.0 / ( x + y ) +zi: Double = 0.16666666666666666 + +scala> val numbers = List(x, y, z) +numbers: List[Double] = List(2.0, 4.0, 6.0) + +scala> val inverses = List(xi, yi, zi) +inverses: List[Double] = List(0.5, 0.25, 0.16666666666666666) + +scala> def multiplier = (n1: Double, n2: Double) => (m: Double) => n1 * n2 * m +multiplier: (Double, Double) => (Double) => Double + +scala> def comp = numbers zip inverses map multiplier.tupled +comp: List[(Double) => Double] + +scala> comp.foreach(f=>println(f(0.5))) +0.5 +0.5 +0.5 diff --git a/Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.ss b/Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.ss new file mode 100644 index 0000000000..fb73861fda --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Scheme/first-class-functions-use-numbers-analogously.ss @@ -0,0 +1,19 @@ +(define x 2.0) +(define xi 0.5) +(define y 4.0) +(define yi 0.25) +(define z (+ x y)) +(define zi (/ (+ x y))) + +(define number (list x y z)) +(define inverse (list xi yi zi)) + +(define (multiplier n1 n2) (lambda (m) (* n1 n2 m))) + +(define m 0.5) +(define (go n1 n2) + (for-each (lambda (n1 n2) + (display ((multiplier n1 n2) m)) + (newline)) + n1 n2)) +(go number inverse) diff --git a/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-1.tcl b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-1.tcl new file mode 100644 index 0000000000..c90b5ab847 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-1.tcl @@ -0,0 +1,4 @@ +package require Tcl 8.5 +proc multiplier {a b} { + list apply {{ab m} {expr {$ab*$m}}} [expr {$a*$b}] +} diff --git a/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-2.tcl b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-2.tcl new file mode 100644 index 0000000000..8dfb21ea36 --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-2.tcl @@ -0,0 +1,4 @@ +% set mult23 [multiplier 2 3] +apply {{ab m} {expr {$ab*$m}}} 6 +% {*}$mult23 5 +30 diff --git a/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-3.tcl b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-3.tcl new file mode 100644 index 0000000000..4cf02fb7ec --- /dev/null +++ b/Task/First-class-functions-Use-numbers-analogously/Tcl/first-class-functions-use-numbers-analogously-3.tcl @@ -0,0 +1,11 @@ +set x 2.0 +set xi 0.5 +set y 4.0 +set yi 0.25 +set z [expr {$x + $y}] +set zi [expr {1.0 / ( $x + $y )}] +set numlist [list $x $y $z] +set numlisti [list $xi $yi $zi] +foreach a $numlist b $numlisti { + puts [format "%g * %g * 0.5 = %g" $a $b [{*}[multiplier $a $b] 0.5]] +} diff --git a/Task/First-class-functions/0DESCRIPTION b/Task/First-class-functions/0DESCRIPTION new file mode 100644 index 0000000000..cbcf7187b6 --- /dev/null +++ b/Task/First-class-functions/0DESCRIPTION @@ -0,0 +1,12 @@ +A language has [[wp:First-class function|first-class functions]] if it can do each of the following without recursively invoking a compiler or interpreter or otherwise [[metaprogramming]]: + +* Create new functions from preexisting functions at run-time +* Store functions in collections +* Use functions as arguments to other functions +* Use functions as return values of other functions + +Write a program to create an ordered collection ''A'' of functions of a real number. At least one function should be built-in and at least one should be user-defined; try using the sine, cosine, and cubing functions. Fill another collection ''B'' with the inverse of each function in ''A''. Implement function composition as in [[Functional Composition]]. Finally, demonstrate that the result of applying the composition of each function in ''A'' and its inverse in ''B'' to a value, is the original value. (Within the limits of computational accuracy). + +(A solution need not actually call the collections "A" and "B". These names are only used in the preceding paragraph for clarity.) + +C.f. [[First-class Numbers]] diff --git a/Task/First-class-functions/1META.yaml b/Task/First-class-functions/1META.yaml new file mode 100644 index 0000000000..c78e2d9a80 --- /dev/null +++ b/Task/First-class-functions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming language concepts diff --git a/Task/First-class-functions/ALGOL-68/first-class-functions.alg b/Task/First-class-functions/ALGOL-68/first-class-functions.alg new file mode 100644 index 0000000000..58a2b063ba --- /dev/null +++ b/Task/First-class-functions/ALGOL-68/first-class-functions.alg @@ -0,0 +1,25 @@ +MODE F = PROC (REAL)REAL; +OP ** = (REAL x, power)REAL: exp(ln(x)*power); + +# Add a user defined function and its inverse # +PROC cube = (REAL x)REAL: x * x * x; +PROC cube root = (REAL x)REAL: x ** (1/3); + +# First class functions allow run-time creation of functions from functions # +# return function compose(f,g)(x) == f(g(x)) # +PROC non standard compose = (F f1, f2)F: (REAL x)REAL: f1(f2(x)); # eg ELLA ALGOL 68RS # +PROC compose = (F f, g)F: ((F f2, g2, REAL x)REAL: f2(g2(x)))(f, g, ); + +# Or the classic "o" functional operator # +PRIO O = 5; +OP (F,F)F O = compose; + +# first class functions should be able to be members of collection types # +[]F func list = (sin, cos, cube); +[]F arc func list = (arc sin, arc cos, cube root); + +# Apply functions from lists as easily as integers # +FOR index TO UPB func list DO + STRUCT(F f, inverse f) this := (func list[index], arc func list[index]); + print(((inverse f OF this O f OF this)(.5), new line)) +OD diff --git a/Task/First-class-functions/ActionScript/first-class-functions.as b/Task/First-class-functions/ActionScript/first-class-functions.as new file mode 100644 index 0000000000..9ac93ce311 --- /dev/null +++ b/Task/First-class-functions/ActionScript/first-class-functions.as @@ -0,0 +1,11 @@ +function compose(f:Function, g:Function):Function { + return function(x:Number) {return f(g(x));}; +} +var functions:Array = [Math.cos, Math.tan, function(x:Number){return x*x;}]; +var inverse:Array = [Math.acos, Math.atan, function(x:Number){return Math.sqrt(x);}]; + +function test() { + for (var i:uint = 0; i < functions.length; i++) { + trace(compose(functions[i], inverse[i])(0.5)); + } +} diff --git a/Task/First-class-functions/Ada/first-class-functions.ada b/Task/First-class-functions/Ada/first-class-functions.ada new file mode 100644 index 0000000000..9b16d00cff --- /dev/null +++ b/Task/First-class-functions/Ada/first-class-functions.ada @@ -0,0 +1,56 @@ +with Ada.Float_Text_IO, + Ada.Integer_Text_IO, + Ada.Text_IO, + Ada.Numerics.Elementary_Functions; + +procedure First_Class_Functions is + use Ada.Float_Text_IO, + Ada.Integer_Text_IO, + Ada.Text_IO, + Ada.Numerics.Elementary_Functions; + + function Sqr (X : Float) return Float is + begin + return X ** 2; + end Sqr; + + type A_Function is access function (X : Float) return Float; + + generic + F, G : A_Function; + function Compose (X : Float) return Float; + + function Compose (X : Float) return Float is + begin + return F (G (X)); + end Compose; + + Functions : array (Positive range <>) of A_Function := (Sin'Access, + Cos'Access, + Sqr'Access); + Inverses : array (Positive range <>) of A_Function := (Arcsin'Access, + Arccos'Access, + Sqrt'Access); +begin + for I in Functions'Range loop + declare + function Identity is new Compose (Functions (I), Inverses (I)); + Test_Value : Float := 0.5; + Result : Float; + begin + Result := Identity (Test_Value); + + if Result = Test_Value then + Put ("Example "); + Put (I, Width => 0); + Put_Line (" is perfect for the given test value."); + else + Put ("Example "); + Put (I, Width => 0); + Put (" is off by"); + Put (abs (Result - Test_Value)); + Put_Line (" for the given test value."); + end if; + end; + end loop; +end First_Class_Functions; diff --git a/Task/First-class-functions/Aikido/first-class-functions.aikido b/Task/First-class-functions/Aikido/first-class-functions.aikido new file mode 100644 index 0000000000..4e13716970 --- /dev/null +++ b/Task/First-class-functions/Aikido/first-class-functions.aikido @@ -0,0 +1,13 @@ +import math + +function compose (f, g) { + return function (x) { return f(g(x)) } +} + +var fn = [Math.sin, Math.cos, function(x) { return x*x*x }] +var inv = [Math.asin, Math.acos, function(x) { return Math.pow(x, 1.0/3) }] + +for (var i=0; i<3; i++) { + var f = compose(inv[i], fn[i]) + println(f(0.5)) // 0.5 +} diff --git a/Task/First-class-functions/AutoHotkey/first-class-functions.ahk b/Task/First-class-functions/AutoHotkey/first-class-functions.ahk new file mode 100644 index 0000000000..f05d3fc055 --- /dev/null +++ b/Task/First-class-functions/AutoHotkey/first-class-functions.ahk @@ -0,0 +1,31 @@ +forward := "sin,cube,cos" +inverse := "Asin,cuberoot,Acos" +StringSplit, forward, forward, `, ; store array length in forward0 +StringSplit, inverse, inverse, `, ; array contents are in inverse1, inverse2... +Loop, % forward0 + MsgBox % map(compose(forward%A_Index%, inverse%A_Index%), 0.500) +Return + +compose(f, g){ + Return map(0, 0, f, g) +} + +map(ab = 0, x = 0 , a = 0, b = 0) +{ + Static + If (a And b) + Return a . "`n" . b + If ab + { + StringSplit, ab, ab, `n + Return %ab1%(%ab2%(x)) + } +} + +cube(x){ + Return x ** 3 +} + +cuberoot(x){ + Return x ** (1 / 3) +} diff --git a/Task/First-class-functions/Axiom/first-class-functions-1.axiom b/Task/First-class-functions/Axiom/first-class-functions-1.axiom new file mode 100644 index 0000000000..4c40802e9d --- /dev/null +++ b/Task/First-class-functions/Axiom/first-class-functions-1.axiom @@ -0,0 +1,3 @@ +fns := [sin$Float, cos$Float, (x:Float):Float +-> x^3] +inv := [asin$Float, acos$Float, (x:Float):Float +-> x^(1/3)] +[(f*g) 0.5 for f in fns for g in inv] diff --git a/Task/First-class-functions/Axiom/first-class-functions-2.axiom b/Task/First-class-functions/Axiom/first-class-functions-2.axiom new file mode 100644 index 0000000000..4beca76c91 --- /dev/null +++ b/Task/First-class-functions/Axiom/first-class-functions-2.axiom @@ -0,0 +1,7 @@ +)abbrev package TESTP TestPackage +TestPackage(T:SetCategory) : with + _*: (List((T->T)),List((T->T))) -> (T -> List T) + == add + import MappingPackage3(T,T,T) + fs * gs == + ((x:T):(List T) +-> [(f*g) x for f in fs for g in gs]) diff --git a/Task/First-class-functions/Axiom/first-class-functions-3.axiom b/Task/First-class-functions/Axiom/first-class-functions-3.axiom new file mode 100644 index 0000000000..4d859a044b --- /dev/null +++ b/Task/First-class-functions/Axiom/first-class-functions-3.axiom @@ -0,0 +1 @@ +(fns * inv) 0.5 diff --git a/Task/First-class-functions/Axiom/first-class-functions-4.axiom b/Task/First-class-functions/Axiom/first-class-functions-4.axiom new file mode 100644 index 0000000000..9f9b617f6e --- /dev/null +++ b/Task/First-class-functions/Axiom/first-class-functions-4.axiom @@ -0,0 +1 @@ +[0.5,0.5,0.5] diff --git a/Task/First-class-functions/BBC-BASIC/first-class-functions.bbc b/Task/First-class-functions/BBC-BASIC/first-class-functions.bbc new file mode 100644 index 0000000000..5e7b0b0452 --- /dev/null +++ b/Task/First-class-functions/BBC-BASIC/first-class-functions.bbc @@ -0,0 +1,34 @@ + REM Create some functions and their inverses: + DEF FNsin(a) = SIN(a) + DEF FNasn(a) = ASN(a) + DEF FNcos(a) = COS(a) + DEF FNacs(a) = ACS(a) + DEF FNcube(a) = a^3 + DEF FNroot(a) = a^(1/3) + + dummy = FNsin(1) + + REM Create the collections (here structures are used): + DIM cA{Sin%, Cos%, Cube%} + DIM cB{Asn%, Acs%, Root%} + cA.Sin% = ^FNsin() : cA.Cos% = ^FNcos() : cA.Cube% = ^FNcube() + cB.Asn% = ^FNasn() : cB.Acs% = ^FNacs() : cB.Root% = ^FNroot() + + REM Create some function compositions: + AsnSin% = FNcompose(cB.Asn%, cA.Sin%) + AcsCos% = FNcompose(cB.Acs%, cA.Cos%) + RootCube% = FNcompose(cB.Root%, cA.Cube%) + + REM Test applying the compositions: + x = 1.234567 : PRINT x, FN(AsnSin%)(x) + x = 2.345678 : PRINT x, FN(AcsCos%)(x) + x = 3.456789 : PRINT x, FN(RootCube%)(x) + END + + DEF FNcompose(f%,g%) + LOCAL f$, p% + f$ = "(x)=" + CHR$&A4 + "(&" + STR$~f% + ")(" + \ + \ CHR$&A4 + "(&" + STR$~g% + ")(x))" + DIM p% LEN(f$) + 4 + $(p%+4) = f$ : !p% = p%+4 + = p% diff --git a/Task/First-class-functions/Bori/first-class-functions-1.bori b/Task/First-class-functions/Bori/first-class-functions-1.bori new file mode 100644 index 0000000000..d4f99636c5 --- /dev/null +++ b/Task/First-class-functions/Bori/first-class-functions-1.bori @@ -0,0 +1,26 @@ +double acos (double d) { return Math.acos(d); } +double asin (double d) { return Math.asin(d); } +double cos (double d) { return Math.cos(d); } +double sin (double d) { return Math.sin(d); } +double croot (double d) { return Math.pow(d, 1/3); } +double cube (double x) { return x * x * x; } + +Var compose (Var f, Var g, double x) +{ + Func ff = f; + Func fg = g; + return ff(fg(x)); +} + +void button1_onClick (Widget widget) +{ + Array arr1 = [ sin, cos, cube ]; + Array arr2 = [ asin, acos, croot ]; + + str s; + for (int i = 1; i <= 3; i++) + { + s << compose(arr1.get(i), arr2.get(i), 0.5) << str.newline; + } + label1.setText(s); +} diff --git a/Task/First-class-functions/Bori/first-class-functions-2.bori b/Task/First-class-functions/Bori/first-class-functions-2.bori new file mode 100644 index 0000000000..62c6563874 --- /dev/null +++ b/Task/First-class-functions/Bori/first-class-functions-2.bori @@ -0,0 +1,3 @@ +0.5 +0.4999999999999999 +0.5000000000000001 diff --git a/Task/First-class-functions/C++/first-class-functions.cpp b/Task/First-class-functions/C++/first-class-functions.cpp new file mode 100644 index 0000000000..87266736d5 --- /dev/null +++ b/Task/First-class-functions/C++/first-class-functions.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +using std::cout; +using std::endl; +using std::vector; +using std::function; +using std::transform; +using std::back_inserter; + +typedef function FunType; + +vector A = {sin, cos, tan, [](double x) { return x*x*x; } }; +vector B = {asin, acos, atan, [](double x) { return exp(log(x)/3); } }; + +template +function compose(function f, function g) { + return [f,g](A x) { return f(g(x)); }; +} + +int main() { + vector composedFuns; + auto exNums = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0}; + + transform(B.begin(), B.end(), + A.begin(), + back_inserter(composedFuns), + compose); + + for (auto num: exNums) + for (auto fun: composedFuns) + cout << u8"f\u207B\u00B9.f(" << num << ") = " << fun(num) << endl; + + return 0; +} diff --git a/Task/First-class-functions/C/first-class-functions-1.c b/Task/First-class-functions/C/first-class-functions-1.c new file mode 100644 index 0000000000..594fc6b3cc --- /dev/null +++ b/Task/First-class-functions/C/first-class-functions-1.c @@ -0,0 +1,72 @@ +#include +#include +#include + +/* declare a typedef for a function pointer */ +typedef double (*Class2Func)(double); + +/*A couple of functions with the above prototype */ +double functionA( double v) +{ + return v*v*v; +} +double functionB(double v) +{ + return exp(log(v)/3); +} + +/* A function taking a function as an argument */ +double Function1( Class2Func f2, double val ) +{ + return f2(val); +} + +/*A function returning a function */ +Class2Func WhichFunc( int idx) +{ + return (idx < 4) ? &functionA : &functionB; +} + +/* A list of functions */ +Class2Func funcListA[] = {&functionA, &sin, &cos, &tan }; +Class2Func funcListB[] = {&functionB, &asin, &acos, &atan }; + +/* Composing Functions */ +double InvokeComposed( Class2Func f1, Class2Func f2, double val ) +{ + return f1(f2(val)); +} + +typedef struct sComposition { + Class2Func f1; + Class2Func f2; +} *Composition; + +Composition Compose( Class2Func f1, Class2Func f2) +{ + Composition comp = malloc(sizeof(struct sComposition)); + comp->f1 = f1; + comp->f2 = f2; + return comp; +} + +double CallComposed( Composition comp, double val ) +{ + return comp->f1( comp->f2(val) ); +} +/** * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +int main(int argc, char *argv[]) +{ + int ix; + Composition c; + + printf("Function1(functionA, 3.0) = %f\n", Function1(WhichFunc(0), 3.0)); + + for (ix=0; ix<4; ix++) { + c = Compose(funcListA[ix], funcListB[ix]); + printf("Compostion %d(0.9) = %f\n", ix, CallComposed(c, 0.9)); + } + + return 0; +} diff --git a/Task/First-class-functions/C/first-class-functions-2.c b/Task/First-class-functions/C/first-class-functions-2.c new file mode 100644 index 0000000000..b70a9b3d7d --- /dev/null +++ b/Task/First-class-functions/C/first-class-functions-2.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +typedef double (*f_dbl)(double); +#define TAGF (f_dbl)0xdeadbeef +#define TAGG (f_dbl)0xbaddecaf + +double dummy(double x) +{ + f_dbl f = TAGF; + f_dbl g = TAGG; + return f(g(x)); +} + +f_dbl composite(f_dbl f, f_dbl g) +{ + size_t len = (void*)composite - (void*)dummy; + f_dbl ret = malloc(len); + char *ptr; + memcpy(ret, dummy, len); + for (ptr = (char*)ret; ptr < (char*)ret + len - sizeof(f_dbl); ptr++) { + if (*(f_dbl*)ptr == TAGF) *(f_dbl*)ptr = f; + else if (*(f_dbl*)ptr == TAGG) *(f_dbl*)ptr = g; + } + return ret; +} + +double cube(double x) +{ + return x * x * x; +} + +/* uncomment next line if your math.h doesn't have cbrt() */ +/* double cbrt(double x) { return pow(x, 1/3.); } */ + +int main() +{ + int i; + double x; + + f_dbl A[3] = { cube, exp, sin }; + f_dbl B[3] = { cbrt, log, asin}; /* not sure about availablity of cbrt() */ + f_dbl C[3]; + + for (i = 0; i < 3; i++) + C[i] = composite(A[i], B[i]); + + for (i = 0; i < 3; i++) { + for (x = .2; x <= 1; x += .2) + printf("C%d(%g) = %g\n", i, x, C[i](x)); + printf("\n"); + } + return 0; +} diff --git a/Task/First-class-functions/C/first-class-functions-3.c b/Task/First-class-functions/C/first-class-functions-3.c new file mode 100644 index 0000000000..df7a645900 --- /dev/null +++ b/Task/First-class-functions/C/first-class-functions-3.c @@ -0,0 +1,17 @@ +C0(0.2) = 0.2 +C0(0.4) = 0.4 +C0(0.6) = 0.6 +C0(0.8) = 0.8 +C0(1) = 1 + +C1(0.2) = 0.2 +C1(0.4) = 0.4 +C1(0.6) = 0.6 +C1(0.8) = 0.8 +C1(1) = 1 + +C2(0.2) = 0.2 +C2(0.4) = 0.4 +C2(0.6) = 0.6 +C2(0.8) = 0.8 +C2(1) = 1 diff --git a/Task/First-class-functions/Clojure/first-class-functions.clj b/Task/First-class-functions/Clojure/first-class-functions.clj new file mode 100644 index 0000000000..4eec9c3164 --- /dev/null +++ b/Task/First-class-functions/Clojure/first-class-functions.clj @@ -0,0 +1,4 @@ +(use 'clojure.contrib.math) +(let [fns [#(Math/sin %) #(Math/cos %) (fn [x] (* x x x))] + inv [#(Math/asin %) #(Math/acos %) #(expt % 1/3)]] + (map #(% 0.5) (map #(comp %1 %2) fns inv))) diff --git a/Task/First-class-functions/CoffeeScript/first-class-functions.coffee b/Task/First-class-functions/CoffeeScript/first-class-functions.coffee new file mode 100644 index 0000000000..e746b068c8 --- /dev/null +++ b/Task/First-class-functions/CoffeeScript/first-class-functions.coffee @@ -0,0 +1,13 @@ +# Functions as values of a variable +cube = (x) -> Math.pow x, 3 +cuberoot = (x) -> Math.pow x, 1 / 3 + +# Higher order function +compose = (f, g) -> (x) -> f g(x) + +# Storing functions in a array +fun = [Math.sin, Math.cos, cube] +inv = [Math.asin, Math.acos, cuberoot] + +# Applying the composition to 0.5 +console.log compose(inv[i], fun[i])(0.5) for i in [0..2]​​​​​​​ diff --git a/Task/First-class-functions/Common-Lisp/first-class-functions-1.lisp b/Task/First-class-functions/Common-Lisp/first-class-functions-1.lisp new file mode 100644 index 0000000000..8f1da1d8ca --- /dev/null +++ b/Task/First-class-functions/Common-Lisp/first-class-functions-1.lisp @@ -0,0 +1,13 @@ +(defun compose (f g) (lambda (x) (funcall f (funcall g x)))) +(defun cube (x) (expt x 3)) +(defun cube-root (x) (expt x (/ 3))) + +(loop with value = 0.5 + for function in (list #'sin #'cos #'cube ) + for inverse in (list #'asin #'acos #'cube-root) + for composed = (compose inverse function) + do (format t "~&(~A ∘ ~A)(~A) = ~A~%" + inverse + function + value + (funcall composed value))) diff --git a/Task/First-class-functions/Common-Lisp/first-class-functions-2.lisp b/Task/First-class-functions/Common-Lisp/first-class-functions-2.lisp new file mode 100644 index 0000000000..d9e1f50324 --- /dev/null +++ b/Task/First-class-functions/Common-Lisp/first-class-functions-2.lisp @@ -0,0 +1,3 @@ +(# ∘ #)(0.5) = 0.5 +(# ∘ #)(0.5) = 0.5 +(# ∘ #)(0.5) = 0.5 diff --git a/Task/First-class-functions/D/first-class-functions-1.d b/Task/First-class-functions/D/first-class-functions-1.d new file mode 100644 index 0000000000..acb3a7699d --- /dev/null +++ b/Task/First-class-functions/D/first-class-functions-1.d @@ -0,0 +1,16 @@ +import std.stdio, std.math, std.typetuple, std.functional; + +enum sin = (in real x) => std.math.sin(x), + asin = (in real x) => std.math.asin(x), + cos = (in real x) => std.math.cos(x), + acos = (in real x) => std.math.acos(x), + cube = (in real x) => x ^^ 3, + cbrt = (in real x) => std.math.cbrt(x); + +void main() { + alias TypeTuple!(sin, cos, cube) dir; + alias TypeTuple!(asin, acos, cbrt) inv; + foreach (i, f; dir) { + writefln("%6.3f", compose!(f, inv[i])(0.5)); + } +} diff --git a/Task/First-class-functions/D/first-class-functions-2.d b/Task/First-class-functions/D/first-class-functions-2.d new file mode 100644 index 0000000000..dee453b91b --- /dev/null +++ b/Task/First-class-functions/D/first-class-functions-2.d @@ -0,0 +1,18 @@ +T delegate(S) compose(T, U, S)(in T function(in U) f, + in U function(in S) g) { + return s => f(g(s)); +} + +void main() { + import std.stdio, std.math, std.range; + + immutable sin = (in real x) => sin(x), + asin = (in real x) => asin(x), + cos = (in real x) => cos(x), + acos = (in real x) => acos(x), + cube = (in real x) => x ^^ 3, + cbrt = (in real x) => cbrt(x); + + foreach (f, g; zip([sin, cos, cube], [asin, acos, cbrt])) + writefln("%6.3f", compose(f, g)(0.5)); +} diff --git a/Task/First-class-functions/Dart/first-class-functions.dart b/Task/First-class-functions/Dart/first-class-functions.dart new file mode 100644 index 0000000000..ea2458a5c1 --- /dev/null +++ b/Task/First-class-functions/Dart/first-class-functions.dart @@ -0,0 +1,13 @@ +cube(x) { return x * x * x; } +inv_cube(x) { return Math.pow(x, 1/3); } + +compo(f1, f2) { + return func(x) { return f1(f2(x));}; +} + +main() { + var funcs = [Math.sin, Math.exp, cube]; + var invs = [Math.asin, Math.log, inv_cube]; + for (int i = 0; i < 3; i++) + print(compo(funcs[i], invs[i])(1)); +} diff --git a/Task/First-class-functions/E/first-class-functions-1.e b/Task/First-class-functions/E/first-class-functions-1.e new file mode 100644 index 0000000000..85e7d58b69 --- /dev/null +++ b/Task/First-class-functions/E/first-class-functions-1.e @@ -0,0 +1,9 @@ +def sin(x) { return x.sin() } +def cos(x) { return x.cos() } +def asin(x) { return x.asin() } +def acos(x) { return x.acos() } +def cube(x) { return x ** 3 } +def curt(x) { return x ** (1/3) } + +def forward := [sin, cos, cube] +def reverse := [asin, acos, curt] diff --git a/Task/First-class-functions/E/first-class-functions-2.e b/Task/First-class-functions/E/first-class-functions-2.e new file mode 100644 index 0000000000..afb9b99308 --- /dev/null +++ b/Task/First-class-functions/E/first-class-functions-2.e @@ -0,0 +1,3 @@ +def compose(f, g) { + return fn x { f(g(x)) } +} diff --git a/Task/First-class-functions/E/first-class-functions-3.e b/Task/First-class-functions/E/first-class-functions-3.e new file mode 100644 index 0000000000..d109ef2e6d --- /dev/null +++ b/Task/First-class-functions/E/first-class-functions-3.e @@ -0,0 +1,9 @@ +? def x := 0.5 \ +> for i => f in forward { +> def g := reverse[i] +> println(`x = $x, f = $f, g = $g, compose($f, $g)($x) = ${compose(f, g)(x)}`) +> } + +x = 0.5, f = , g = , compose(, )(0.5) = 0.5 +x = 0.5, f = , g = , compose(, )(0.5) = 0.4999999999999999 +x = 0.5, f = , g = , compose(, )(0.5) = 0.5000000000000001 diff --git a/Task/First-class-functions/Ela/first-class-functions-1.ela b/Task/First-class-functions/Ela/first-class-functions-1.ela new file mode 100644 index 0000000000..d062322daf --- /dev/null +++ b/Task/First-class-functions/Ela/first-class-functions-1.ela @@ -0,0 +1,10 @@ +open number //sin,cos,asin,acos +open list //zipWith + +cube x = x ** 3 +croot x = x ** (1/3) + +funclist = [sin, cos, cube] +funclisti = [asin, acos, croot] + +zipWith (\f inversef -> (inversef << f) 0.5) funclist funclisti diff --git a/Task/First-class-functions/Ela/first-class-functions-2.ela b/Task/First-class-functions/Ela/first-class-functions-2.ela new file mode 100644 index 0000000000..f8810223cb --- /dev/null +++ b/Task/First-class-functions/Ela/first-class-functions-2.ela @@ -0,0 +1 @@ +(<<) f g x = f (g x) diff --git a/Task/First-class-functions/Ela/first-class-functions-3.ela b/Task/First-class-functions/Ela/first-class-functions-3.ela new file mode 100644 index 0000000000..af1581eee9 --- /dev/null +++ b/Task/First-class-functions/Ela/first-class-functions-3.ela @@ -0,0 +1 @@ +[0.5,0.5,0.499999989671302] diff --git a/Task/First-class-functions/Factor/first-class-functions.factor b/Task/First-class-functions/Factor/first-class-functions.factor new file mode 100644 index 0000000000..6d7359e9f7 --- /dev/null +++ b/Task/First-class-functions/Factor/first-class-functions.factor @@ -0,0 +1,10 @@ +USING: assocs combinators kernel math.functions prettyprint +sequences ; +IN: rosettacode.first-class-functions + +CONSTANT: A { [ sin ] [ cos ] [ 3 ^ ] } +CONSTANT: B { [ asin ] [ acos ] [ 1/3 ^ ] } +: compose-all ( seq1 seq2 -- seq ) [ compose ] 2map ; +: test1 ( -- ) + 0.5 A B compose-all + [ call( x -- y ) ] with map . ; diff --git a/Task/First-class-functions/Fantom/first-class-functions.fantom b/Task/First-class-functions/Fantom/first-class-functions.fantom new file mode 100644 index 0000000000..1cd87b2b00 --- /dev/null +++ b/Task/First-class-functions/Fantom/first-class-functions.fantom @@ -0,0 +1,19 @@ +class FirstClassFns +{ + static |Obj -> Obj| compose (|Obj -> Obj| fn1, |Obj -> Obj| fn2) + { + return |Obj x -> Obj| { fn2 (fn1 (x)) } + } + + public static Void main () + { + cube := |Float a -> Float| { a * a * a } + cbrt := |Float a -> Float| { a.pow(1/3f) } + + |Float->Float|[] fns := [Float#sin.func, Float#cos.func, cube] + |Float->Float|[] inv := [Float#asin.func, Float#acos.func, cbrt] + |Float->Float|[] composed := fns.map |fn, i| { compose(fn, inv[i]) } + + composed.each |fn| { echo (fn(0.5f)) } + } +} diff --git a/Task/First-class-functions/Forth/first-class-functions.fth b/Task/First-class-functions/Forth/first-class-functions.fth new file mode 100644 index 0000000000..25a578dbbf --- /dev/null +++ b/Task/First-class-functions/Forth/first-class-functions.fth @@ -0,0 +1,22 @@ +: compose ( xt1 xt2 -- xt3 ) + >r >r :noname + r> compile, + r> compile, + postpone ; +; + +: cube fdup fdup f* f* ; +: cuberoot 1e 3e f/ f** ; + +: table create does> swap cells + @ ; + +table fn ' fsin , ' fcos , ' cube , +table inverse ' fasin , ' facos , ' cuberoot , + +: main + 3 0 do + i fn i inverse compose ( xt ) + 0.5e execute f. + loop ; + +main \ 0.5 0.5 0.5 diff --git a/Task/First-class-functions/GAP/first-class-functions.gap b/Task/First-class-functions/GAP/first-class-functions.gap new file mode 100644 index 0000000000..22843d757d --- /dev/null +++ b/Task/First-class-functions/GAP/first-class-functions.gap @@ -0,0 +1,36 @@ +# Function composition +Composition := function(f, g) + local h; + h := function(x) + return f(g(x)); + end; + return h; +end; + +# Apply each function in list u, to argument x +ApplyList := function(u, x) + local i, n, v; + n := Size(u); + v := [ ]; + for i in [1 .. n] do + v[i] := u[i](x); + od; + return v; +end; + +# Inverse and Sqrt are in the built-in library. Note that GAP doesn't have real numbers nor floating point numbers. Therefore, Sqrt yields values in cyclotomic fields. +# For example, +# gap> Sqrt(7); +# E(28)^3-E(28)^11-E(28)^15+E(28)^19-E(28)^23+E(28)^27 +# where E(n) is a primitive n-th root of unity +a := [ i -> i + 1, Inverse, Sqrt ]; +# [ function( i ) ... end, , ] +b := [ i -> i - 1, Inverse, x -> x*x ]; +# [ function( i ) ... end, , function( x ) ... end ] + +# Compose each couple +z := ListN(a, b, Composition); + +# Now a test +ApplyList(z, 3); +[ 3, 3, 3 ] diff --git a/Task/First-class-functions/Go/first-class-functions.go b/Task/First-class-functions/Go/first-class-functions.go new file mode 100644 index 0000000000..78328a666b --- /dev/null +++ b/Task/First-class-functions/Go/first-class-functions.go @@ -0,0 +1,27 @@ +package main + +import "math" +import "fmt" + +// user-defined function, per task. Other math functions used are built-in. +func cube(x float64) float64 { return math.Pow(x, 3) } + +// ffType and compose function taken from Function composition task +type ffType func(float64) float64 + +func compose(f, g ffType) ffType { + return func(x float64) float64 { + return f(g(x)) + } +} + +func main() { + // collection A + funclist := []ffType{math.Sin, math.Cos, cube} + // collection B + funclisti := []ffType{math.Asin, math.Acos, math.Cbrt} + for i := 0; i < 3; i++ { + // apply composition and show result + fmt.Println(compose(funclisti[i], funclist[i])(.5)) + } +} diff --git a/Task/First-class-functions/Groovy/first-class-functions-1.groovy b/Task/First-class-functions/Groovy/first-class-functions-1.groovy new file mode 100644 index 0000000000..f61dfba237 --- /dev/null +++ b/Task/First-class-functions/Groovy/first-class-functions-1.groovy @@ -0,0 +1 @@ +def compose = { f, g -> { x -> f(g(x)) } } diff --git a/Task/First-class-functions/Groovy/first-class-functions-2.groovy b/Task/First-class-functions/Groovy/first-class-functions-2.groovy new file mode 100644 index 0000000000..80e0454df9 --- /dev/null +++ b/Task/First-class-functions/Groovy/first-class-functions-2.groovy @@ -0,0 +1,8 @@ +def cube = { it * it * it } +def cubeRoot = { it ** (1/3) } + +funcList = [ Math.&sin, Math.&cos, cube ] +inverseList = [ Math.&asin, Math.&acos, cubeRoot ] + +println [funcList, inverseList].transpose().collect { compose(it[0],it[1]) }.collect{ it(0.5) } +println [inverseList, funcList].transpose().collect { compose(it[0],it[1]) }.collect{ it(0.5) } diff --git a/Task/First-class-functions/Haskell/first-class-functions.hs b/Task/First-class-functions/Haskell/first-class-functions.hs new file mode 100644 index 0000000000..8f0bbeb344 --- /dev/null +++ b/Task/First-class-functions/Haskell/first-class-functions.hs @@ -0,0 +1,8 @@ +Prelude> let cube x = x ^ 3 +Prelude> let croot x = x ** (1/3) +Prelude> let compose f g = \x -> f (g x) -- this is already implemented in Haskell as the "." operator +Prelude> -- we could have written "let compose f g x = f (g x)" but we show this for clarity +Prelude> let funclist = [sin, cos, cube] +Prelude> let funclisti = [asin, acos, croot] +Prelude> zipWith (\f inversef -> (compose inversef f) 0.5) funclist funclisti +[0.5,0.4999999999999999,0.5] diff --git a/Task/First-class-functions/Icon/first-class-functions.icon b/Task/First-class-functions/Icon/first-class-functions.icon new file mode 100644 index 0000000000..c1b3796d76 --- /dev/null +++ b/Task/First-class-functions/Icon/first-class-functions.icon @@ -0,0 +1,17 @@ +link compose +procedure main(arglist) + + fun := [sin,cos,cube] + inv := [asin,acos,cuberoot] + x := 0.5 + every i := 1 to *inv do + write("f(",x,") := ", compose(inv[i],fun[i])(x)) +end + +procedure cube(x) +return x*x*x +end + +procedure cuberoot(x) +return x ^ (1./3) +end diff --git a/Task/First-class-functions/J/first-class-functions-1.j b/Task/First-class-functions/J/first-class-functions-1.j new file mode 100644 index 0000000000..d0666fb95a --- /dev/null +++ b/Task/First-class-functions/J/first-class-functions-1.j @@ -0,0 +1,10 @@ + sin=: 1&o. + cos=: 2&o. + cube=: ^&3 +square=: *: + unqo=: `:6 + unqcol=: `:0 + quot=: 1 :'{.u`''''' + A=: sin`cos`cube`square + B=: monad def'y unqo inv quot'"0 A + BA=. A dyad def'x unqo@(y unqo) quot'"0 B diff --git a/Task/First-class-functions/J/first-class-functions-2.j b/Task/First-class-functions/J/first-class-functions-2.j new file mode 100644 index 0000000000..23f0037b00 --- /dev/null +++ b/Task/First-class-functions/J/first-class-functions-2.j @@ -0,0 +1,4 @@ + A unqcol 0.5 +0.479426 0.877583 0.125 0.25 + BA unqcol 0.5 +0.5 0.5 0.5 0.5 diff --git a/Task/First-class-functions/Java/first-class-functions-1.java b/Task/First-class-functions/Java/first-class-functions-1.java new file mode 100644 index 0000000000..0f86934cab --- /dev/null +++ b/Task/First-class-functions/Java/first-class-functions-1.java @@ -0,0 +1,70 @@ +import java.util.ArrayList; + +public class FirstClass{ + + public interface Function{ + B apply(A x); + } + + public static Function compose( + final Function f, final Function g) { + return new Function() { + @Override public C apply(A x) { + return f.apply(g.apply(x)); + } + }; + } + + public static void main(String[] args){ + ArrayList> functions = + new ArrayList>(); + + functions.add( + new Function(){ + @Override public Double apply(Double x){ + return Math.cos(x); + } + }); + functions.add( + new Function(){ + @Override public Double apply(Double x){ + return Math.tan(x); + } + }); + functions.add( + new Function(){ + @Override public Double apply(Double x){ + return x * x; + } + }); + + ArrayList> inverse = new ArrayList>(); + + inverse.add( + new Function(){ + @Override public Double apply(Double x){ + return Math.acos(x); + } + }); + inverse.add( + new Function(){ + @Override public Double apply(Double x){ + return Math.atan(x); + } + }); + inverse.add( + new Function(){ + @Override public Double apply(Double x){ + return Math.sqrt(x); + } + }); + System.out.println("Compositions:"); + for(int i = 0; i < functions.size(); i++){ + System.out.println(compose(functions.get(i), inverse.get(i)).apply(0.5)); + } + System.out.println("Hard-coded compositions:"); + System.out.println(Math.cos(Math.acos(0.5))); + System.out.println(Math.tan(Math.atan(0.5))); + System.out.println(Math.pow(Math.sqrt(0.5), 2)); + } +} diff --git a/Task/First-class-functions/Java/first-class-functions-2.java b/Task/First-class-functions/Java/first-class-functions-2.java new file mode 100644 index 0000000000..a16b47c6e1 --- /dev/null +++ b/Task/First-class-functions/Java/first-class-functions-2.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.function.Function; + +public class FirstClass{ + + public static Function compose( + final Function f, final Function g) { + return new Function() { + @Override public C apply(A x) { + return f.apply(g.apply(x)); + } + }; + } + + public static void main(String[] args){ + ArrayList> functions = new ArrayList<>(); + + functions.add(Math::cos); + functions.add(Math::tan); + functions.add(x -> x * x); + + ArrayList> inverse = new ArrayList<>(); + + inverse.add(Math::acos); + inverse.add(Math::atan); + inverse.add(Math::sqrt); + System.out.println("Compositions:"); + for(int i = 0; i < functions.size(); i++){ + System.out.println(compose(functions.get(i), inverse.get(i)).apply(0.5)); + } + System.out.println("Hard-coded compositions:"); + System.out.println(Math.cos(Math.acos(0.5))); + System.out.println(Math.tan(Math.atan(0.5))); + System.out.println(Math.pow(Math.sqrt(0.5), 2)); + } +} diff --git a/Task/First-class-functions/JavaScript/first-class-functions.js b/Task/First-class-functions/JavaScript/first-class-functions.js new file mode 100644 index 0000000000..8f8f858412 --- /dev/null +++ b/Task/First-class-functions/JavaScript/first-class-functions.js @@ -0,0 +1,23 @@ +// Functions as values of a variable +var cube = function(x) { + return Math.pow(x, 3); +}; +var cuberoot = function(x) { + return Math.pow(x, 1/3); +}; + +// Higher order function +var compose = function (f, g) { + return function (x) { + return f(g(x)); + }; +}; + +// Storing functions in a array +var fun = [Math.sin, Math.cos, cube]; +var inv = [Math.asin, Math.acos, cuberoot]; + +for (var i = 0; i < 3; i++) { + // Applying the composition to 0.5 + console.log(compose(inv[i], fun[i])(0.5)); +} diff --git a/Task/First-class-functions/Lua/first-class-functions-1.lua b/Task/First-class-functions/Lua/first-class-functions-1.lua new file mode 100644 index 0000000000..8bd722365d --- /dev/null +++ b/Task/First-class-functions/Lua/first-class-functions-1.lua @@ -0,0 +1,9 @@ +function compose(f,g) return function(...) return f(g(...)) end end + +fn = {math.sin, math.cos, function(x) return x^3 end} +inv = {math.asin, math.acos, function(x) return x^(1/3) end} + +for i, v in ipairs(fn) do + local f = compose(v, inv[i]) + print(f(0.5)) +end diff --git a/Task/First-class-functions/Lua/first-class-functions-2.lua b/Task/First-class-functions/Lua/first-class-functions-2.lua new file mode 100644 index 0000000000..05df319f58 --- /dev/null +++ b/Task/First-class-functions/Lua/first-class-functions-2.lua @@ -0,0 +1,3 @@ +0.5 +0.5 +0.5 diff --git a/Task/First-class-functions/Maple/first-class-functions.maple b/Task/First-class-functions/Maple/first-class-functions.maple new file mode 100644 index 0000000000..752a5fec20 --- /dev/null +++ b/Task/First-class-functions/Maple/first-class-functions.maple @@ -0,0 +1,7 @@ +> A := [ sin, cos, x -> x^3 ]: +> B := [ arcsin, arccos, rcurry( surd, 3 ) ]: +> zip( `@`, A, B )( 2/3 ); + [2/3, 2/3, 2/3] + +> zip( `@`, B, A )( 2/3 ); + [2/3, 2/3, 2/3] diff --git a/Task/First-class-functions/Mathematica/first-class-functions-1.mathematica b/Task/First-class-functions/Mathematica/first-class-functions-1.mathematica new file mode 100644 index 0000000000..b5462e9a10 --- /dev/null +++ b/Task/First-class-functions/Mathematica/first-class-functions-1.mathematica @@ -0,0 +1,4 @@ +funcs = {Sin, Cos, #^3 &}; +funcsi = {ArcSin, ArcCos, #^(1/3) &}; +compositefuncs = Composition @@@ Transpose[{funcs, funcsi}]; +Table[i[0.666], {i, compositefuncs}] diff --git a/Task/First-class-functions/Mathematica/first-class-functions-2.mathematica b/Task/First-class-functions/Mathematica/first-class-functions-2.mathematica new file mode 100644 index 0000000000..e21d9b35c9 --- /dev/null +++ b/Task/First-class-functions/Mathematica/first-class-functions-2.mathematica @@ -0,0 +1 @@ +{0.666, 0.666, 0.666} diff --git a/Task/First-class-functions/Mathematica/first-class-functions-3.mathematica b/Task/First-class-functions/Mathematica/first-class-functions-3.mathematica new file mode 100644 index 0000000000..74047d495d --- /dev/null +++ b/Task/First-class-functions/Mathematica/first-class-functions-3.mathematica @@ -0,0 +1,3 @@ +Composition[f,g,h][x] +f@g@h@x +x//h//g//f diff --git a/Task/First-class-functions/Mathematica/first-class-functions-4.mathematica b/Task/First-class-functions/Mathematica/first-class-functions-4.mathematica new file mode 100644 index 0000000000..079261e848 --- /dev/null +++ b/Task/First-class-functions/Mathematica/first-class-functions-4.mathematica @@ -0,0 +1 @@ +f[g[h[x]]] diff --git a/Task/First-class-functions/Maxima/first-class-functions.maxima b/Task/First-class-functions/Maxima/first-class-functions.maxima new file mode 100644 index 0000000000..0f3b0ee18b --- /dev/null +++ b/Task/First-class-functions/Maxima/first-class-functions.maxima @@ -0,0 +1,5 @@ +a: [sin, cos, lambda([x], x^3)]$ +b: [asin, acos, lambda([x], x^(1/3))]$ +compose(f, g) := buildq([f, g], lambda([x], f(g(x))))$ +map(lambda([fun], fun(x)), map(compose, a, b)); +[x, x, x] diff --git a/Task/First-class-functions/Mercury/first-class-functions.mercury b/Task/First-class-functions/Mercury/first-class-functions.mercury new file mode 100644 index 0000000000..b1fdfddacb --- /dev/null +++ b/Task/First-class-functions/Mercury/first-class-functions.mercury @@ -0,0 +1,17 @@ +:- module firstclass. + +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module exception, list, math, std_util. + +main(!IO) :- + Forward = [sin, cos, (func(X) = ln(X))], + Reverse = [asin, acos, (func(X) = exp(X))], + Results = map_corresponding( + (func(F, R) = compose(R, F, 0.5)), + Forward, Reverse), + write_list(Results, ", ", write_float, !IO), + write_string("\n", !IO). diff --git a/Task/First-class-functions/PHP/first-class-functions.php b/Task/First-class-functions/PHP/first-class-functions.php new file mode 100644 index 0000000000..6dd4e35a7c --- /dev/null +++ b/Task/First-class-functions/PHP/first-class-functions.php @@ -0,0 +1,13 @@ +$compose = function ($f, $g) { + return function ($x) use ($f, $g) { + return $f($g($x)); + }; +}; + +$fn = array('sin', 'cos', function ($x) { return pow($x, 3); }); +$inv = array('asin', 'acos', function ($x) { return pow($x, 1/3); }); + +for ($i = 0; $i < 3; $i++) { + $f = $compose($inv[$i], $fn[$i]); + echo $f(0.5), PHP_EOL; +} diff --git a/Task/First-class-functions/Perl/first-class-functions.pl b/Task/First-class-functions/Perl/first-class-functions.pl new file mode 100644 index 0000000000..9b49e18c68 --- /dev/null +++ b/Task/First-class-functions/Perl/first-class-functions.pl @@ -0,0 +1,19 @@ +use Math::Complex ':trig'; + +sub compose { + my ($f, $g) = @_; + + sub { + $f -> ($g -> (@_)); + }; +} + +my $cube = sub { $_[0] ** (3) }; +my $croot = sub { $_[0] ** (1/3) }; + +my @flist1 = ( \&Math::Complex::sin, \&Math::Complex::cos, $cube ); +my @flist2 = ( \&asin, \&acos, $croot ); + +print join "\n", map { + compose($flist1[$_], $flist2[$_]) -> (0.5) +} 0..2; diff --git a/Task/First-class-functions/PicoLisp/first-class-functions.l b/Task/First-class-functions/PicoLisp/first-class-functions.l new file mode 100644 index 0000000000..86dc405bf7 --- /dev/null +++ b/Task/First-class-functions/PicoLisp/first-class-functions.l @@ -0,0 +1,17 @@ +(load "@lib/math.l") + +(de compose (F G) + (curry (F G) (X) + (F (G X)) ) ) + +(de cube (X) + (pow X 3.0) ) + +(de cubeRoot (X) + (pow X 0.3333333) ) + +(mapc + '((Fun Inv) + (prinl (format ((compose Inv Fun) 0.5) *Scl)) ) + '(sin cos cube) + '(asin acos cubeRoot) ) diff --git a/Task/First-class-functions/Prolog/first-class-functions.pro b/Task/First-class-functions/Prolog/first-class-functions.pro new file mode 100644 index 0000000000..fc0c9b04ef --- /dev/null +++ b/Task/First-class-functions/Prolog/first-class-functions.pro @@ -0,0 +1,24 @@ +:- use_module(library(lambda)). + + +compose(F,G, FG) :- + FG = \X^Z^(call(G,X,Y), call(F,Y,Z)). + +cube(X, Y) :- + Y is X ** 3. + +cube_root(X, Y) :- + Y is X ** (1/3). + +first_class :- + L = [sin, cos, cube], + IL = [asin, acos, cube_root], + + % we create the composed functions + maplist(compose, L, IL, Lst), + + % we call the functions + maplist(call, Lst, [0.5,0.5,0.5], R), + + % we display the results + maplist(writeln, R). diff --git a/Task/First-class-functions/Python/first-class-functions.py b/Task/First-class-functions/Python/first-class-functions.py new file mode 100644 index 0000000000..50219aaf7c --- /dev/null +++ b/Task/First-class-functions/Python/first-class-functions.py @@ -0,0 +1,15 @@ +>>> # Some built in functions and their inverses +>>> from math import sin, cos, acos, asin +>>> # Add a user defined function and its inverse +>>> cube = lambda x: x * x * x +>>> croot = lambda x: x ** (1/3.0) +>>> # First class functions allow run-time creation of functions from functions +>>> # return function compose(f,g)(x) == f(g(x)) +>>> compose = lambda f1, f2: ( lambda x: f1(f2(x)) ) +>>> # first class functions should be able to be members of collection types +>>> funclist = [sin, cos, cube] +>>> funclisti = [asin, acos, croot] +>>> # Apply functions from lists as easily as integers +>>> [compose(inversef, f)(.5) for f, inversef in zip(funclist, funclisti)] +[0.5, 0.4999999999999999, 0.5] +>>> diff --git a/Task/First-class-functions/R/first-class-functions-1.r b/Task/First-class-functions/R/first-class-functions-1.r new file mode 100644 index 0000000000..4e84fbc119 --- /dev/null +++ b/Task/First-class-functions/R/first-class-functions-1.r @@ -0,0 +1,10 @@ +cube <- function(x) x^3 +croot <- function(x) x^(1/3) +compose <- function(f, g) function(x){f(g(x))} + +f1 <- c(sin, cos, cube) +f2 <- c(asin, acos, croot) + +for(i in 1:3) { + print(compose(f1[[i]], f2[[i]])(.5)) +} diff --git a/Task/First-class-functions/R/first-class-functions-2.r b/Task/First-class-functions/R/first-class-functions-2.r new file mode 100644 index 0000000000..4c8fde6119 --- /dev/null +++ b/Task/First-class-functions/R/first-class-functions-2.r @@ -0,0 +1 @@ +sapply(mapply(compose,f1,f2),do.call,list(.5)) diff --git a/Task/First-class-functions/Racket/first-class-functions.rkt b/Task/First-class-functions/Racket/first-class-functions.rkt new file mode 100644 index 0000000000..caca291c78 --- /dev/null +++ b/Task/First-class-functions/Racket/first-class-functions.rkt @@ -0,0 +1,10 @@ +#lang racket + +(define (compose f g) (λ (x) (f (g x)))) +(define (cube x) (expt x 3)) +(define (cube-root x) (expt x (/ 1 3))) +(define funlist (list sin cos cube)) +(define ifunlist (list asin acos cube-root)) + +(for ([f funlist] [i ifunlist]) + (displayln ((compose i f) 0.5))) diff --git a/Task/First-class-functions/Ruby/first-class-functions.rb b/Task/First-class-functions/Ruby/first-class-functions.rb new file mode 100644 index 0000000000..f07b17e252 --- /dev/null +++ b/Task/First-class-functions/Ruby/first-class-functions.rb @@ -0,0 +1,12 @@ +irb(main):001:0> cube = proc{|x| x ** 3} +=> # +irb(main):002:0> croot = proc{|x| x ** (1.quo 3)} +=> # +irb(main):003:0> compose = proc {|f,g| proc {|x| f[g[x]]}} +=> # +irb(main):004:0> funclist = [Math.method(:sin), Math.method(:cos), cube] +=> [#, #, #] +irb(main):005:0> invlist = [Math.method(:asin), Math.method(:acos), croot] +=> [#, #, #] +irb(main):006:0> funclist.zip(invlist).map {|f, invf| compose[invf, f][0.5]} +=> [0.5, 0.4999999999999999, 0.5] diff --git a/Task/First-class-functions/Scala/first-class-functions-1.scala b/Task/First-class-functions/Scala/first-class-functions-1.scala new file mode 100644 index 0000000000..faca222548 --- /dev/null +++ b/Task/First-class-functions/Scala/first-class-functions-1.scala @@ -0,0 +1,18 @@ +import math._ + +// functions as values +val cube = (x: Double) => x * x * x +val cuberoot = (x: Double) => pow(x, 1 / 3d) + +// higher order function, as a method +def compose[A,B,C](f: B => C, g: A => B) = (x: A) => f(g(x)) + +// partially applied functions in Lists +val fun = List(sin _, cos _, cube) +val inv = List(asin _, acos _, cuberoot) + +// composing functions from the above Lists +val comp = (fun, inv).zipped map (_ compose _) + +// output results of applying the functions +comp foreach {f => print(f(0.5) + " ")} diff --git a/Task/First-class-functions/Scala/first-class-functions-2.scala b/Task/First-class-functions/Scala/first-class-functions-2.scala new file mode 100644 index 0000000000..3a5a988cdf --- /dev/null +++ b/Task/First-class-functions/Scala/first-class-functions-2.scala @@ -0,0 +1,7 @@ +class SweetFunction[B,C](f: B => C) { + def o[A](g: A => B) = (x: A) => f(g(x)) +} +implicit def sugarOnTop[A,B](f: A => B) = new SweetFunction(f) + +// now functions can be composed thus +println((cube o cube o cuberoot)(0.5)) diff --git a/Task/First-class-functions/Scheme/first-class-functions.ss b/Task/First-class-functions/Scheme/first-class-functions.ss new file mode 100644 index 0000000000..8499762ceb --- /dev/null +++ b/Task/First-class-functions/Scheme/first-class-functions.ss @@ -0,0 +1,16 @@ +(define (compose f g) (lambda (x) (f (g x)))) +(define (cube x) (expt x 3)) +(define (cube-root x) (expt x (/ 1 3))) + +(define function (list sin cos cube)) +(define inverse (list asin acos cube-root)) + +(define x 0.5) +(define (go f g) + (if (not (or (null? f) + (null? g))) + (begin (display ((compose (car f) (car g)) x)) + (newline) + (go (cdr f) (cdr g))))) + +(go function inverse) diff --git a/Task/First-class-functions/Smalltalk/first-class-functions.st b/Task/First-class-functions/Smalltalk/first-class-functions.st new file mode 100644 index 0000000000..c88854b764 --- /dev/null +++ b/Task/First-class-functions/Smalltalk/first-class-functions.st @@ -0,0 +1,23 @@ +|forward reverse composer compounds| +"commodities" +Number extend [ + cube [ ^self raisedTo: 3 ] +]. +Number extend [ + cubeRoot [ ^self raisedTo: (1 / 3) ] +]. + +forward := #( #cos #sin #cube ). +reverse := #( #arcCos #arcSin #cubeRoot ). + +composer := [ :f :g | [ :x | f value: (g value: x) ] ]. + +"let us create composed funcs" +compounds := OrderedCollection new. + +1 to: 3 do: [ :i | + compounds add: ([ :j | composer value: [ :x | x perform: (forward at: j) ] + value: [ :x | x perform: (reverse at: j) ] ] value: i) +]. + +compounds do: [ :r | (r value: 0.5) displayNl ]. diff --git a/Task/First-class-functions/Tcl/first-class-functions.tcl b/Task/First-class-functions/Tcl/first-class-functions.tcl new file mode 100644 index 0000000000..239486070c --- /dev/null +++ b/Task/First-class-functions/Tcl/first-class-functions.tcl @@ -0,0 +1,17 @@ +% namespace path tcl::mathfunc ;# to import functions like abs() etc. +% proc cube x {expr {$x**3}} +% proc croot x {expr {$x**(1/3.)}} +% proc compose {f g} {list apply {{f g x} {{*}$f [{*}$g $x]}} $f $g} + +% compose abs cube ;# returns a partial command, without argument +apply {{f g x} {{*}$f [{*}$g $x]}} abs cube + +% {*}[compose abs cube] -3 ;# applies the partial command to argument -3 +27 + +% set forward [compose [compose sin cos] cube] ;# omitting to print result +% set backward [compose croot [compose acos asin]] +% {*}$forward 0.5 +0.8372297964617733 +% {*}$backward [{*}$forward 0.5] +0.5000000000000017 diff --git a/Task/Five-weekends/0DESCRIPTION b/Task/Five-weekends/0DESCRIPTION new file mode 100644 index 0000000000..e552710c6b --- /dev/null +++ b/Task/Five-weekends/0DESCRIPTION @@ -0,0 +1,14 @@ +The month of October in 2010 has five Fridays, five Saturdays, and five Sundays. + +'''The task''' +# Write a program to show all months that have this same characteristic of five full weekends from the year 1900 through 2100 (Gregorian calendar). +# Show the ''number'' of months with this property (there should be 201). +# Show at least the first and last five dates, in order. + +'''Algorithm suggestions''' +*Count the number of Fridays, Saturdays, and Sundays in every month. +*Find all of the 31-day months that begin on Friday. + +'''Extra credit''' + +Count and/or show all of the years which do not have at least one five-weekend month (there should be 29). diff --git a/Task/Five-weekends/ALGOL-68/five-weekends.alg b/Task/Five-weekends/ALGOL-68/five-weekends.alg new file mode 100644 index 0000000000..cc2191a09b --- /dev/null +++ b/Task/Five-weekends/ALGOL-68/five-weekends.alg @@ -0,0 +1,53 @@ +five_weekends: BEGIN + INT m, year, nfives := 0, not5 := 0; + BOOL no5weekend; + + MODE MONTH = STRUCT( + INT n, + [3]CHAR name + ) # MODE MONTH #; + + []MONTH month = ( + MONTH(13, "Jan"), + MONTH(3, "Mar"), + MONTH(5, "May"), + MONTH(7, "Jul"), + MONTH(8, "Aug"), + MONTH(10, "Oct"), + MONTH(12, "Dec") + ); + + FOR year FROM 1900 TO 2100 DO + IF year = 1905 THEN printf($"..."l$) FI; + no5weekend := TRUE; + FOR m TO UPB month DO + IF n OF month(m) = 13 THEN + IF day_of_week(1, n OF month(m), year-1) = 6 THEN + IF year<1905 OR year > 2096 THEN printf(($g, 5zl$, name OF month(m), year)) FI; + nfives +:= 1; + no5weekend := FALSE + FI + ELSE + IF day_of_week(1, n OF month(m), year) = 6 THEN + IF year<1905 OR year > 2096 THEN printf(($g, 5zl$, name OF month(m), year)) FI; + nfives +:= 1; + no5weekend := FALSE + FI + FI + OD; + IF no5weekend THEN not5 +:= 1 FI + OD; + + printf(($g, g(0)l$, "Number of months with five weekends between 1900 and 2100 = ", nfives)); + printf(($g, g(0)l$, "Number of years between 1900 and 2100 with no five weekend months = ", not5)); + +# contains # + + PROC day_of_week = (INT d, m, y)INT: BEGIN + INT j, k; + j := y OVER 100; + k := y MOD 100; + (d + (m+1)*26 OVER 10 + k + k OVER 4 + j OVER 4 + 5*j) MOD 7 + END # function day_of_week #; + SKIP +END # program five_weekends # diff --git a/Task/Five-weekends/Ada/five-weekends.ada b/Task/Five-weekends/Ada/five-weekends.ada new file mode 100644 index 0000000000..5ba2a0cbb9 --- /dev/null +++ b/Task/Five-weekends/Ada/five-weekends.ada @@ -0,0 +1,23 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Calendar.Formatting; use Ada.Calendar; + +use Ada.Calendar.Formatting; + +procedure Five_Weekends is + Months : Natural := 0; +begin + for Year in Year_Number range 1901..2100 loop + for Month in Month_Number range 1..12 loop + begin + if Day_Of_Week (Formatting.Time_Of (Year, Month, 31)) = Sunday then + Put_Line (Year_Number'Image (Year) & Month_Number'Image (Month)); + Months := Months + 1; + end if; + exception + when Time_Error => + null; + end; + end loop; + end loop; + Put_Line ("Number of months:" & Integer'Image (Months)); +end Five_Weekends; diff --git a/Task/Five-weekends/AppleScript/five-weekends.applescript b/Task/Five-weekends/AppleScript/five-weekends.applescript new file mode 100644 index 0000000000..cde597380c --- /dev/null +++ b/Task/Five-weekends/AppleScript/five-weekends.applescript @@ -0,0 +1,48 @@ +set fiveWeekendMonths to {} +set noFiveWeekendYears to {} + +set someDate to current date +set day of someDate to 1 + +repeat with someYear from 1900 to 2100 + set year of someDate to someYear + set foundOne to false + repeat with someMonth in {January, March, May, July, ¬ + August, October, December} + set month of someDate to someMonth + if weekday of someDate is Friday then + set foundOne to true + set end of fiveWeekendMonths to ¬ + (someYear as text) & "-" & (someMonth as text) + end + end repeat + if not foundOne then + set end of noFiveWeekendYears to someYear + end +end repeat + +set text item delimiters to ", " +set monthList to ¬ + (items 1 thru 5 of fiveWeekendMonths as text) & ", ..." & linefeed & ¬ + " ..., " & (items -5 thru end of fiveWeekendMonths as text) + +set monthCount to count fiveWeekendMonths +set yearCount to count noFiveWeekendYears + +set resultText to ¬ + "Months with five weekends (" & monthCount & "): " & linefeed & ¬ + " " & monthList & linefeed & linefeed & ¬ + "Years with no such months (" & yearCount & "): " + +set y to 1 +repeat while y < yearCount + set final to y+11 + if final > yearCount then + set final to yearCount + end + set resultText to ¬ + resultText & linefeed & ¬ + " " & (items y through final of noFiveWeekendYears as text) + set y to y + 12 +end +resultText diff --git a/Task/Five-weekends/AutoHotkey/five-weekends.ahk b/Task/Five-weekends/AutoHotkey/five-weekends.ahk new file mode 100644 index 0000000000..bbd5fffa32 --- /dev/null +++ b/Task/Five-weekends/AutoHotkey/five-weekends.ahk @@ -0,0 +1,37 @@ +Year := 1900 +End_Year := 2100 +31_Day_Months = 01,03,05,07,08,10,12 + +While Year <= End_Year + { + Loop, Parse, 31_Day_Months, CSV + { + FormatTime, Day, %Year%%A_LoopField%01, dddd + IfEqual, Day, Friday + { + All_Months_With_5_Weekends .= A_LoopField . "/" . Year ", " + 5_Weekend_Count++ + Year_Has_5_Weekend_Month := 1 + } + } + IfEqual, Year_Has_5_Weekend_Month, 0 + { + All_Years_Without_5_Weekend .= Year ", " + No_5_Weekend_Count ++ + } + Year ++ + Year_Has_5_Weekend_Month := 0 + } +; Trim the spaces and comma off the last item. +StringTrimRight, All_Months_With_5_Weekends, All_Months_With_5_Weekends, 5 +StringTrimRight, All_Years_Without_5_Weekend, All_Years_Without_5_Weekend, 4 +MsgBox, +( +Months with 5 day weekends between 1900 and 2100 : %5_Weekend_Count% +%All_Months_With_5_Weekends% +) +MsgBox, +( +Years with no 5 day weekends between 1900 and 2100 : %No_5_Weekend_Count% +%All_Years_Without_5_Weekend% +) diff --git a/Task/Five-weekends/AutoIt/five-weekends.autoit b/Task/Five-weekends/AutoIt/five-weekends.autoit new file mode 100644 index 0000000000..1250cde71c --- /dev/null +++ b/Task/Five-weekends/AutoIt/five-weekends.autoit @@ -0,0 +1,41 @@ +#include +#include +$array = Five_weekends(1) +_ArrayDisplay($array) +$array = Five_weekends(2) +_ArrayDisplay($array) +$array = Five_weekends(3) +_ArrayDisplay($array) + +Func Five_weekends($ret = 1) + If $ret < 1 Or $ret > 3 Then Return SetError(1, 0, 0) + Local $avDateArray[1] + Local $avYearArray[1] + Local $avMonthArray[1] + For $iYear = 1900 To 2100 + Local $checkyear = False + For $iMonth = 1 To 12 + If _DateDaysInMonth($iYear, $iMonth) <> 31 Then ContinueLoop ; Month has less then 31 Days + If _DateToDayOfWeek($iYear, $iMonth, "01") <> 6 Then ContinueLoop ;First Day is not a Friday + _ArrayAdd($avMonthArray, $iYear & "-" & _DateToMonth($iMonth)) + $checkyear = True + For $s = 1 To 31 + Local $Date = _DateToDayOfWeek($iYear, $iMonth, $s) + If $Date = 6 Or $Date = 7 Or $Date = 1 Then ; if Date is Friday, Saturday or Sunday + _ArrayAdd($avDateArray, $iYear & "\" & StringFormat("%02d", $iMonth) & "\" & StringFormat("%02d", $s)) + EndIf + Next + Next + If Not $checkyear Then _ArrayAdd($avYearArray, $iYear) + Next + $avDateArray[0] = UBound($avDateArray) - 1 + $avYearArray[0] = UBound($avYearArray) - 1 + $avMonthArray[0] = UBound($avMonthArray) - 1 + If $ret = 1 Then + Return $avDateArray + ElseIf $ret = 2 Then + Return $avYearArray + ElseIf $ret = 3 Then + Return $avMonthArray + EndIf +EndFunc ;==>Five_weekends diff --git a/Task/Five-weekends/BBC-BASIC/five-weekends.bbc b/Task/Five-weekends/BBC-BASIC/five-weekends.bbc new file mode 100644 index 0000000000..260758692b --- /dev/null +++ b/Task/Five-weekends/BBC-BASIC/five-weekends.bbc @@ -0,0 +1,18 @@ + INSTALL @lib$+"DATELIB" + DIM Month$(12) + Month$() = "","January","February","March","April","May","June", \ + \ "July","August","September","October","November","December" + + num% = 0 + FOR year% = 1900 TO 2100 + PRINT ; year% ": " ; + oldnum% = num% + FOR month% = 1 TO 12 + IF FN_dim(month%,year%) = 31 IF FN_dow(FN_mjd(1,month%,year%)) = 5 THEN + num% += 1 + PRINT Month$(month%), ; + ENDIF + NEXT + IF num% = oldnum% PRINT "(none)" ELSE PRINT + NEXT year% + PRINT "Total = " ; num% diff --git a/Task/Five-weekends/C++/five-weekends.cpp b/Task/Five-weekends/C++/five-weekends.cpp new file mode 100644 index 0000000000..6002ea8d3e --- /dev/null +++ b/Task/Five-weekends/C++/five-weekends.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +using namespace boost::gregorian ; + +void print( const date &d ) { + std::cout << d.year( ) << "-" << d.month( ) << "\n" ; +} + +int main( ) { + greg_month longmonths[ ] = {Jan, Mar , May , Jul , + Aug , Oct , Dec } ; + int monthssize = sizeof ( longmonths ) / sizeof (greg_month ) ; + typedef std::vector DateVector ; + DateVector weekendmonster ; + std::vector years_without_5we_months ; + for ( unsigned short i = 1900 ; i < 2101 ; i++ ) { + bool months_found = false ; //does a given year have 5 weekend months ? + for ( int j = 0 ; j < monthssize ; j++ ) { + date d ( i , longmonths[ j ] , 1 ) ; + if ( d.day_of_week( ) == Friday ) { //for the month to have 5 weekends + weekendmonster.push_back( d ) ; + if ( months_found == false ) + months_found = true ; + } + } + if ( months_found == false ) { + years_without_5we_months.push_back( i ) ; + } + } + std::cout << "Between 1900 and 2100 , there are " << weekendmonster.size( ) + << " months with 5 complete weekends!\n" ; + std::cout << "Months with 5 complete weekends are:\n" ; + std::for_each( weekendmonster.begin( ) , weekendmonster.end( ) , print ) ; + std::cout << years_without_5we_months.size( ) << " years had no months with 5 complete weekends!\n" ; + std::cout << "These are:\n" ; + std::copy( years_without_5we_months.begin( ) , years_without_5we_months.end( ) , + std::ostream_iterator( std::cout , "\n" ) ) ; + std::cout << std::endl ; + return 0 ; +} diff --git a/Task/Five-weekends/C/five-weekends-1.c b/Task/Five-weekends/C/five-weekends-1.c new file mode 100644 index 0000000000..ead2dcf08a --- /dev/null +++ b/Task/Five-weekends/C/five-weekends-1.c @@ -0,0 +1,30 @@ +#include +#include + +static const char *months[] = {"January", "February", "March", "April", "May", + "June", "July", "August", "September", "October", "November", "December"}; +static int long_months[] = {0, 2, 4, 6, 7, 9, 11}; + +int main() { + int n = 0, y, i, m; + struct tm t = {0}; + printf("Months with five weekends:\n"); + for (y = 1900; y <= 2100; y++) { + for (i = 0; i < 7; i++) { + m = long_months[i]; + t.tm_year = y-1900; + t.tm_mon = m; + t.tm_mday = 1; + if (mktime(&t) == -1) { /* date not supported */ + printf("Error: %d %s\n", y, months[m]); + continue; + } + if (t.tm_wday == 5) { /* Friday */ + printf(" %d %s\n", y, months[m]); + n++; + } + } + } + printf("%d total\n", n); + return 0; +} diff --git a/Task/Five-weekends/C/five-weekends-2.c b/Task/Five-weekends/C/five-weekends-2.c new file mode 100644 index 0000000000..655682de0d --- /dev/null +++ b/Task/Five-weekends/C/five-weekends-2.c @@ -0,0 +1,40 @@ +#include +#include + +int check_month(int y, int m) +{ + char buf[1024], *ptr; + int bytes, *a = &m; + + sprintf(buf, "ncal -m %d -M %d", m, y); + FILE *fp = popen(buf, "r"); + if (!fp) return -1; + + bytes = fread(buf, 1, 1024, fp); + fclose(fp); + buf[bytes] = 0; + +#define check_day(x) \ + ptr = strstr(buf, x);\ + if (5 != sscanf(ptr, x" %d %d %d %d %d", a, a, a, a, a)) return 0 + + check_day("Fr"); + check_day("Sa"); + check_day("Su"); + return 1; +} + +int main() +{ + int y, m, cnt = 0; + for (y = 1900; y <= 2100; y++) { + for (m = 1; m <= 12; m++) { + if (check_month(y, m) <= 0) continue; + printf("%d-%02d ", y, m); + if (++cnt % 16 == 0) printf("\n"); + } + } + printf("\nTotal: %d\n", cnt); + + return 0; +} diff --git a/Task/Five-weekends/Clojure/five-weekends.clj b/Task/Five-weekends/Clojure/five-weekends.clj new file mode 100644 index 0000000000..d7819b2384 --- /dev/null +++ b/Task/Five-weekends/Clojure/five-weekends.clj @@ -0,0 +1,11 @@ +(import java.util.GregorianCalendar + java.text.DateFormatSymbols) + +(->> (for [year (range 1900 2101) + month [0 2 4 6 7 9 11] ;; 31 day months + :let [cal (GregorianCalendar. year month 1) + day (.get cal GregorianCalendar/DAY_OF_WEEK)] + :when (= day GregorianCalendar/FRIDAY)] + (println month "-" year)) + count + (println "Total Months: " ,)) diff --git a/Task/Five-weekends/D/five-weekends-1.d b/Task/Five-weekends/D/five-weekends-1.d new file mode 100644 index 0000000000..565483bba2 --- /dev/null +++ b/Task/Five-weekends/D/five-weekends-1.d @@ -0,0 +1,31 @@ +import std.stdio, std.datetime, std.algorithm, std.range; + +Date[] m5w(in Date start, in Date end) pure /*nothrow*/ { + typeof(return) res; + // adjust to 1st day + for (Date when = Date(start.year, start.month, 1); + when < end; + when.add!"months"(1)) + // Such month must have 3+4*7 days and start at friday + // for 5 FULL weekends. + if (when.daysInMonth == 31 && + when.dayOfWeek == DayOfWeek.fri) + res ~= when; + return res; +} + +bool noM5wByYear(in int year) pure { + return m5w(Date(year, 1, 1), Date(year, 12, 31)).empty; +} + +void main() { + immutable m = m5w(Date(1900, 1, 1), Date(2100, 12, 31)); + writeln("There are ", m.length, + " months of which the first and last five are:"); + foreach (d; m[0 .. 5] ~ m[$ - 5 .. $]) + writeln(d.toSimpleString()[0 .. $ - 3]); + + immutable n = iota(1900, 2101).filter!noM5wByYear().walkLength(); + writefln("\nThere are %d years in the range that do not have " ~ + "months with five weekends.", n); +} diff --git a/Task/Five-weekends/D/five-weekends-2.d b/Task/Five-weekends/D/five-weekends-2.d new file mode 100644 index 0000000000..52c17664a8 --- /dev/null +++ b/Task/Five-weekends/D/five-weekends-2.d @@ -0,0 +1,35 @@ +import std.stdio, std.datetime, std.traits; + +void main() { + enum first_year = 1900; + enum last_year = 2100; + + int totalNo5Weekends; + const(Date)[] fiveWeekendMonths; + foreach (year; first_year .. last_year + 1) { + bool has5Weekends = false; + + foreach (month; [EnumMembers!Month]) { + const firstDay = Date(year, month, 1); + if (firstDay.daysInMonth == 31 && + firstDay.dayOfWeek == DayOfWeek.fri) { + has5Weekends = true; + fiveWeekendMonths ~= firstDay; + } + } + + if (!has5Weekends) + totalNo5Weekends++; + } + + writefln("Total 5-weekend months between %d and %d: %d", + first_year, last_year, fiveWeekendMonths.length); + foreach (date; fiveWeekendMonths[0 .. 5]) + writeln(date.month, " ", date.year); + writeln("..."); + foreach (date; fiveWeekendMonths[$ - 5 .. $]) + writeln(date.month, " ", date.year); + + writeln("\nTotal number of years with no 5-weekend months: ", + totalNo5Weekends); +} diff --git a/Task/Five-weekends/Delphi/five-weekends.delphi b/Task/Five-weekends/Delphi/five-weekends.delphi new file mode 100644 index 0000000000..157b37f569 --- /dev/null +++ b/Task/Five-weekends/Delphi/five-weekends.delphi @@ -0,0 +1,34 @@ +program FiveWeekends; + +{$APPTYPE CONSOLE} + +uses SysUtils, DateUtils; + +var + lMonth, lYear: Integer; + lDate: TDateTime; + lFiveWeekendCount: Integer; + lYearsWithout: Integer; + lFiveWeekendFound: Boolean; +begin + for lYear := 1900 to 2100 do + begin + lFiveWeekendFound := False; + for lMonth := 1 to 12 do + begin + lDate := EncodeDate(lYear, lMonth, 1); + if (DaysInMonth(lDate) = 31) and (DayOfTheWeek(lDate) = DayFriday) then + begin + Writeln(FormatDateTime('mmm yyyy', lDate)); + Inc(lFiveWeekendCount); + lFiveWeekendFound := True; + end; + end; + if not lFiveWeekendFound then + Inc(lYearsWithout); + end; + + Writeln; + Writeln(Format('Months with 5 weekends: %d', [lFiveWeekendCount])); + Writeln(Format('Years with no 5 weekend months: %d', [lYearsWithout])); +end. diff --git a/Task/Five-weekends/Erlang/five-weekends-1.erl b/Task/Five-weekends/Erlang/five-weekends-1.erl new file mode 100644 index 0000000000..fda0d02e34 --- /dev/null +++ b/Task/Five-weekends/Erlang/five-weekends-1.erl @@ -0,0 +1,29 @@ +#!/usr/bin/env escript +%% +%% Calculate number of months with five weekends between years 1900-2100 +%% +main(_) -> + Years = [ [{Y,M} || M <- lists:seq(1,12)] || Y <- lists:seq(1900,2100) ], + {CountedYears, {Has5W, TotM5W}} = lists:mapfoldl( + fun(Months, {Has5W, Tot}) -> + WithFive = [M || M <- Months, has_five(M)], + CountM5W = length(WithFive), + {{Months,CountM5W}, {Has5W++WithFive, Tot+CountM5W}} + end, {[], 0}, Years), + io:format("There are ~p months with five full weekends.~n" + "Showing top and bottom 5:~n", + [TotM5W]), + lists:map(fun({Y,M}) -> io:format("~p-~p~n", [Y,M]) end, + lists:sublist(Has5W,1,5) ++ lists:nthtail(TotM5W-5, Has5W)), + No5W = [Y || {[{Y,_M}|_], 0} <- CountedYears], + io:format("The following ~p years do NOT have any five-weekend months:~n", + [length(No5W)]), + lists:map(fun(Y) -> io:format("~p~n", [Y]) end, No5W). + +has_five({Year, Month}) -> + has_five({Year, Month}, calendar:last_day_of_the_month(Year, Month)). + +has_five({Year, Month}, Days) when Days =:= 31 -> + calendar:day_of_the_week({Year, Month, 1}) =:= 5; +has_five({_Year, _Month}, _DaysNot31) -> + false. diff --git a/Task/Five-weekends/Erlang/five-weekends-2.erl b/Task/Five-weekends/Erlang/five-weekends-2.erl new file mode 100644 index 0000000000..cbc70bcf02 --- /dev/null +++ b/Task/Five-weekends/Erlang/five-weekends-2.erl @@ -0,0 +1,51 @@ +-module(five_weekends). + +-export([report/0, print_5w_month/1, print_year_with_no_5w_month/1]). + +report() -> + Years = make_nested_period_list(1900, 2100), + {CountedYears, {All5WMonths, CountOf5WMonths}} = lists:mapfoldl( + fun(SingleYearSublist, {All5WMonths, CountOf5WMonths}) -> + MonthsWith5W = [Month || Month <- SingleYearSublist, if_has_5w(Month)], + CountOf5WMonthsFor1Year = length(MonthsWith5W), + { % Result of map for this year sublist: + {SingleYearSublist,CountOf5WMonthsFor1Year}, + % Accumulate total result for our fold: + {All5WMonths ++ MonthsWith5W, CountOf5WMonths + CountOf5WMonthsFor1Year} + } + end, {[], 0}, Years), + io:format("There are ~p months with five full weekends.~n" + "Showing top and bottom 5:~n", + [CountOf5WMonths]), + lists:map(fun print_5w_month/1, take_nth_first_and_last(5, All5WMonths)), + YearsWithout5WMonths = find_years_without_5w_months(CountedYears), + io:format("The following ~p years do NOT have any five-weekend months:~n", + [length(YearsWithout5WMonths)]), + lists:map(fun print_year_with_no_5w_month/1, YearsWithout5WMonths). + +make_nested_period_list(FromYear, ToYear) -> + [ make_monthtuple_sublist_for_year(Year) || Year <- lists:seq(FromYear, ToYear) ]. + +make_monthtuple_sublist_for_year(Year) -> + [ {Year, Month} || Month <- lists:seq(1,12) ]. + +if_has_5w({Year, Month}) -> + if_has_5w({Year, Month}, calendar:last_day_of_the_month(Year, Month)). + +if_has_5w({Year, Month}, Days) when Days =:= 31 -> + calendar:day_of_the_week({Year, Month, 1}) =:= 5; +if_has_5w({_Year, _Month}, _DaysNot31) -> + false. + +print_5w_month({Year, Month}) -> + io:format("~p-~p~n", [Year, Month]). + +print_year_with_no_5w_month(Year) -> + io:format("~p~n", [Year]). + +take_nth_first_and_last(N, List) -> + Len = length(List), + lists:sublist(List, 1, N) ++ lists:nthtail(Len - N, List). + +find_years_without_5w_months(List) -> + [Y || {[{Y,_M}|_], 0} <- List]. diff --git a/Task/Five-weekends/Euphoria/five-weekends.euphoria b/Task/Five-weekends/Euphoria/five-weekends.euphoria new file mode 100644 index 0000000000..f0a37f5f13 --- /dev/null +++ b/Task/Five-weekends/Euphoria/five-weekends.euphoria @@ -0,0 +1,42 @@ +--Five Weekend task from Rosetta Code wiki +--User:Lnettnay + +include std/datetime.e + +atom numbermonths = 0 +sequence longmonths = {1, 3, 5, 7, 8, 10, 12} +sequence yearsmonths = {} +atom none = 0 +datetime dt + +for year = 1900 to 2100 do + atom flag = 0 + for month = 1 to length(longmonths) do + dt = new(year, longmonths[month], 1) + if weeks_day(dt) = 6 then --Friday is day 6 + flag = 1 + numbermonths += 1 + yearsmonths = append(yearsmonths, {year, longmonths[month]}) + end if + end for + + if flag = 0 then + none += 1 + end if +end for + +puts(1, "Number of months with five full weekends from 1900 to 2100 = ") +? numbermonths + +puts(1, "First five and last five years, months\n") + +for count = 1 to 5 do + ? yearsmonths[count] +end for + +for count = length(yearsmonths) - 4 to length(yearsmonths) do + ? yearsmonths[count] +end for + +puts(1, "Number of years that have no months with five full weekends = ") +? none diff --git a/Task/Five-weekends/Fortran/five-weekends.f b/Task/Five-weekends/Fortran/five-weekends.f new file mode 100644 index 0000000000..8fbab98d3c --- /dev/null +++ b/Task/Five-weekends/Fortran/five-weekends.f @@ -0,0 +1,57 @@ +program Five_weekends + implicit none + + integer :: m, year, nfives = 0, not5 = 0 + logical :: no5weekend + + type month + integer :: n + character(3) :: name + end type month + + type(month) :: month31(7) + + month31(1) = month(13, "Jan") + month31(2) = month(3, "Mar") + month31(3) = month(5, "May") + month31(4) = month(7, "Jul") + month31(5) = month(8, "Aug") + month31(6) = month(10, "Oct") + month31(7) = month(12, "Dec") + + do year = 1900, 2100 + no5weekend = .true. + do m = 1, size(month31) + if(month31(m)%n == 13) then + if(Day_of_week(1, month31(m)%n, year-1) == 6) then + write(*, "(a3, i5)") month31(m)%name, year + nfives = nfives + 1 + no5weekend = .false. + end if + else + if(Day_of_week(1, month31(m)%n, year) == 6) then + write(*,"(a3, i5)") month31(m)%name, year + nfives = nfives + 1 + no5weekend = .false. + end if + end if + end do + if(no5weekend) not5 = not5 + 1 + end do + + write(*, "(a, i0)") "Number of months with five weekends between 1900 and 2100 = ", nfives + write(*, "(a, i0)") "Number of years between 1900 and 2100 with no five weekend months = ", not5 + +contains + +function Day_of_week(d, m, y) + integer :: Day_of_week + integer, intent(in) :: d, m, y + integer :: j, k + + j = y / 100 + k = mod(y, 100) + Day_of_week = mod(d + (m+1)*26/10 + k + k/4 + j/4 + 5*j, 7) + +end function Day_of_week +end program Five_weekends diff --git a/Task/Five-weekends/GAP/five-weekends.gap b/Task/Five-weekends/GAP/five-weekends.gap new file mode 100644 index 0000000000..f48e053e41 --- /dev/null +++ b/Task/Five-weekends/GAP/five-weekends.gap @@ -0,0 +1,33 @@ +# return a list of two lists : +# first is the list of months with five weekends between years y1 and y2 (included) +# second is the list of years without such months, in the same interval +FiveWeekends := function(y1, y2) + local L, yL, badL, d, m, y; + L := [ ]; + badL := [ ]; + for y in [y1 .. y2] do + yL := [ ]; + for m in [1, 3, 5, 7, 8, 10, 12] do + if WeekDay([1, m, y]) = "Fri" then + d := StringDate([1, m, y]); + Add(yL, d{[4 .. 11]}); + fi; + od; + if Length(yL) = 0 then + Add(badL, y); + else + Append(L, yL); + fi; + od; + return [ L, badL ]; +end; + +r := FiveWeekends(1900, 2100);; +n := Length(r[1]); +# 201 +Length(r[2]); +# 29 +r[1]{[1 .. 5]}; +# [ "Mar-1901", "Aug-1902", "May-1903", "Jan-1904", "Jul-1904" ] +r[1]{[n-4 .. n]}; +# [ "Mar-2097", "Aug-2098", "May-2099", "Jan-2100", "Oct-2100" ] diff --git a/Task/Five-weekends/Go/five-weekends.go b/Task/Five-weekends/Go/five-weekends.go new file mode 100644 index 0000000000..b4bdd20ac3 --- /dev/null +++ b/Task/Five-weekends/Go/five-weekends.go @@ -0,0 +1,50 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + var n int // for task item 2 + var first, last time.Time // for task item 3 + haveNone := make([]int, 0, 29) // for extra credit + fmt.Println("Months with five weekends:") // for task item 1 + for year := 1900; year <= 2100; year++ { + var hasOne bool // for extra credit + for _, month := range []time.Month{1, 3, 5, 7, 8, 10, 12} { + t := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC) + if t.Weekday() == time.Friday { + // task item 1: show month + fmt.Println(" ", t.Format("2006 January")) + n++ + hasOne = true + last = t + if first.IsZero() { + first = t + } + } + } + if !hasOne { + haveNone = append(haveNone, year) + } + } + fmt.Println(n, "total\n") // task item 2: number of months + // task item 3 + fmt.Println("First five dates of weekends:") + for i := 0; i < 5; i++ { + fmt.Println(" ", first.Format("Monday, January 2, 2006")) + first = first.Add(7 * 24 * time.Hour) + } + fmt.Println("Last five dates of weekends:") + for i := 0; i < 5; i++ { + fmt.Println(" ", last.Format("Monday, January 2, 2006")) + last = last.Add(7 * 24 * time.Hour) + } + // extra credit + fmt.Println("\nYears with no months with five weekends:") + for _, y := range haveNone { + fmt.Println(" ", y) + } + fmt.Println(len(haveNone), "total") +} diff --git a/Task/Five-weekends/Haskell/five-weekends.hs b/Task/Five-weekends/Haskell/five-weekends.hs new file mode 100644 index 0000000000..94aed6444f --- /dev/null +++ b/Task/Five-weekends/Haskell/five-weekends.hs @@ -0,0 +1,104 @@ +import Data.List (intercalate) + +data DayOfWeek = Monday | Tuesday | Wednesday | Thursday | Friday | + Saturday | Sunday + deriving (Eq, Show) + +-- the whole thing bases upon an infinite list of weeks + +daysFrom1_1_1900 :: [DayOfWeek] +daysFrom1_1_1900 = concat $ repeat [Monday, Tuesday, Wednesday, + Thursday, Friday, Saturday, Sunday] + +data Month = January | February | March | April | May | June | July | + August | September | October | November | December + deriving (Show) + +type Year = Int +type YearCalendar = (Year, [DayOfWeek]) +type MonthlyCalendar = (Year, [(Month, [DayOfWeek])]) + +-- makes groups of 365 or 366 days for each year (infinite list) + +yearsFrom :: [DayOfWeek] -> Year -> [YearCalendar] +yearsFrom s i = (i, yeardays) : yearsFrom rest (i + 1) + where + yeardays = take (leapOrNot i) s + yearlen = length yeardays + rest = drop yearlen s + leapOrNot n = if isLeapYear n then 366 else 365 + +yearsFrom1900 :: [YearCalendar] +yearsFrom1900 = yearsFrom daysFrom1_1_1900 1900 + +-- makes groups of days for each month of the year + +months :: YearCalendar -> MonthlyCalendar +months (y, d) = (y, [(January, january), (February, february), + (March, march), (April, april), (May, may), (June, june), + (July, july), (August, august), (September, september), + (October, october), (November, november), (December, december)]) + where + leapOrNot = if isLeapYear y then 29 else 28 + january = take 31 d + february = take leapOrNot $ drop 31 d + march = take 31 $ drop (31 + leapOrNot) d + april = take 30 $ drop (62 + leapOrNot) d + may = take 31 $ drop (92 + leapOrNot) d + june = take 30 $ drop (123 + leapOrNot) d + july = take 31 $ drop (153 + leapOrNot) d + august = take 31 $ drop (184 + leapOrNot) d + september = take 30 $ drop (215 + leapOrNot) d + october = take 31 $ drop (245 + leapOrNot) d + november = take 30 $ drop (276 + leapOrNot) d + december = take 31 $ drop (306 + leapOrNot) d + +-- see if a year is a leap year + +isLeapYear n + | n `mod` 100 == 0 = n `mod` 400 == 0 + | otherwise = n `mod` 4 == 0 + +-- make a list of the months of a year that have 5 weekends +-- (they must have 31 days and the first day must be Friday) +-- if the year doesn't contain any 5-weekended months, then +-- return the year and an empty list + +whichFiveWeekends :: MonthlyCalendar -> (Year, [Month]) +whichFiveWeekends (y, ms) = (y, map (\(m, _) -> m) found) -- extract the months & leave out their days + where found = filter (\(m, a@(d:ds)) -> and [length a == 31, + d == Friday]) ms + +-- take all days from 1900 until 2100, grouping them by years, then by +-- months, and calculating whether they have any 5-weekended months +-- or not + +calendar :: [MonthlyCalendar] +calendar = map months $ yearsFrom1900 + +fiveWeekends1900To2100 :: [(Year, [Month])] +fiveWeekends1900To2100 = takeWhile (\(y, _) -> y <= 2100) $ + map whichFiveWeekends calendar + +main = do + -- count the number of years with 5 weekends + let answer1 = foldl (\c (_, m) -> c + length m) 0 fiveWeekends1900To2100 + -- take only the years with 5-weekended months + answer2 = filter (\(_, m) -> not $ null m) fiveWeekends1900To2100 + -- take only the years without 5-weekended months + answer30 = filter (\(_, m) -> null m) fiveWeekends1900To2100 + -- count how many years without 5-weekended months there are + answer31 = length answer30 + -- show the years without 5-weekended months + answer32 = intercalate ", " $ map (\(y, m) -> show y) answer30 + putStrLn $ "There are " ++ show answer1 ++ " months with 5 weekends between 1900 and 2100." + putStrLn "\nThe first ones are:" + mapM_ (putStrLn . formatMonth) $ take 5 $ answer2 + putStrLn "\nThe last ones are:" + mapM_ (putStrLn . formatMonth) $ reverse $ take 5 $ reverse answer2 + putStrLn $ "\n" ++ show answer31 ++ " years don't have at least one five-weekened month" + putStrLn "\nThose are:" + putStrLn answer32 + +formatMonth :: (Year, [Month]) -> String +formatMonth (y, m) = show y ++ ": " ++ intercalate ", " [ show x | x <- m ] diff --git a/Task/Five-weekends/Icon/five-weekends.icon b/Task/Five-weekends/Icon/five-weekends.icon new file mode 100644 index 0000000000..fabb71febb --- /dev/null +++ b/Task/Five-weekends/Icon/five-weekends.icon @@ -0,0 +1,26 @@ +link datetime,printf + +procedure main(A) # five weekends + printf( "There are %d months from %d to %d with five full weekends.\n", + *(L := fiveweekends(s := 1900, f := 2100)), s,f) + printf("The first and last five such months are:\n") + every printf("%s\n",L[1 to 5]|"..."|L[-4 to 0]) + printf( "There are %d years without such months as follows:\n", + *(M := Bonus(s,f,L))) + every printf("%s\n",!M) +end + +procedure fiveweekends(start,finish) + L := [] # months years with five weekends FRI-SUN + every year := start to finish & month := 1 to 12 do + if month = (2|4|6|9|11) then next + else if julian(month,1,year) % 7 = 4 then + put(L,sprintf("%d-%d-1",year,month)) + return L +end + +procedure Bonus(start,finish,fwe) +every insert(Y := set(), start to finish) +every insert(F := set(), integer(!fwe ? tab(find("-")))) +return sort(Y--F) +end diff --git a/Task/Five-weekends/Inform-7/five-weekends.inf b/Task/Five-weekends/Inform-7/five-weekends.inf new file mode 100644 index 0000000000..ce8b831ccf --- /dev/null +++ b/Task/Five-weekends/Inform-7/five-weekends.inf @@ -0,0 +1,102 @@ +Calendar is a room. + +When play begins: + let happy month count be 0; + let sad year count be 0; + repeat with Y running from Y1900 to Y2100: + if Y is a sad year, increment the sad year count; + repeat with M running through months: + if M of Y is a happy month: + say "[M] [year number of Y]."; + increment the happy month count; + say "Found [happy month count] month[s] with five weekends and [sad year count] year[s] with no such months."; + end the story. + +Section - Years + +A year is a kind of value. Y1 specifies a year. + +To decide which number is year number of (Y - year): + decide on Y / Y1. + +To decide if (N - number) is divisible by (M - number): + decide on whether or not the remainder after dividing N by M is zero. + +Definition: a year (called Y) is a leap year: + let YN be the year number of Y; + if YN is divisible by 400, yes; + if YN is divisible by 100, no; + if YN is divisible by 4, yes; + no. + +Section - Months + +A month is a kind of value. The months are defined by the Table of Months. + +Table of Months +month month number +January 1 +February 2 +March 3 +April 4 +May 5 +June 6 +July 7 +August 8 +September 9 +October 10 +November 11 +December 12 + +A month has a number called length. The length of a month is usually 31. +September, April, June, and November have length 30. February has length 28. + +To decide which number is number of days in (M - month) of (Y - year): + let L be the length of M; + if M is February and Y is a leap year, decide on L + 1; + otherwise decide on L. + +Section - Weekdays + +A weekday is a kind of value. The weekdays are defined by the Table of Weekdays. + +Table of Weekdays +weekday weekday number +Saturday 0 +Sunday 1 +Monday 2 +Tuesday 3 +Wednesday 4 +Thursday 5 +Friday 6 + +To decide which weekday is weekday of the/-- (N - number) of (M - month) of (Y - year): + let MN be the month number of M; + let YN be the year number of Y; + if MN is less than 3: + increase MN by 12; + decrease YN by 1; + let h be given by Zeller's Congruence; + let WDN be the remainder after dividing h by 7; + decide on the weekday corresponding to a weekday number of WDN in the Table of Weekdays. + +Equation - Zeller's Congruence + h = N + ((MN + 1)*26)/10 + YN + YN/4 + 6*(YN/100) + YN/400 +where h is a number, N is a number, MN is a number, and YN is a number. + +To decide which number is number of (W - weekday) days in (M - month) of (Y - year): + let count be 0; + repeat with N running from 1 to the number of days in M of Y: + if W is the weekday of the N of M of Y, increment count; + decide on count. + +Section - Happy Months and Sad Years + +To decide if (M - month) of (Y - year) is a happy month: + if the number of days in M of Y is 31 and the weekday of the 1st of M of Y is Friday, decide yes; + decide no. + +To decide if (Y - year) is a sad year: + repeat with M running through months: + if M of Y is a happy month, decide no; + decide yes. diff --git a/Task/Five-weekends/J/five-weekends-1.j b/Task/Five-weekends/J/five-weekends-1.j new file mode 100644 index 0000000000..a401b7ac78 --- /dev/null +++ b/Task/Five-weekends/J/five-weekends-1.j @@ -0,0 +1,7 @@ +require 'types/datetime numeric' +find5wkdMonths=: verb define + years=. range 2{. y + months=. 1 3 5 7 8 10 12 + m5w=. (#~ 0 = weekday) >,{years;months;31 NB. 5 full weekends iff 31st is Sunday(0) + >'MMM YYYY' fmtDate toDayNo m5w +) diff --git a/Task/Five-weekends/J/five-weekends-2.j b/Task/Five-weekends/J/five-weekends-2.j new file mode 100644 index 0000000000..709a8c4c01 --- /dev/null +++ b/Task/Five-weekends/J/five-weekends-2.j @@ -0,0 +1,16 @@ + # find5wkdMonths 1900 2100 NB. number of months found +201 + (5&{. , '...' , _5&{.) find5wkdMonths 1900 2100 NB. First and last 5 months found +Mar 1901 +Aug 1902 +May 1903 +Jan 1904 +Jul 1904 +... +Mar 2097 +Aug 2098 +May 2099 +Jan 2100 +Oct 2100 + # (range -. {:"1@(_ ". find5wkdMonths)) 1900 2100 NB. number of years without 5 weekend months +29 diff --git a/Task/Five-weekends/Java/five-weekends.java b/Task/Five-weekends/Java/five-weekends.java new file mode 100644 index 0000000000..bbdbaa3f93 --- /dev/null +++ b/Task/Five-weekends/Java/five-weekends.java @@ -0,0 +1,33 @@ +import java.util.Calendar; +import java.util.GregorianCalendar; + +public class FiveFSS { + private static boolean[] years = new boolean[201]; + //dreizig tage habt september... + private static int[] month31 = {Calendar.JANUARY, Calendar.MARCH, Calendar.MAY, + Calendar.JULY, Calendar.AUGUST, Calendar.OCTOBER, Calendar.DECEMBER}; + + public static void main(String[] args) { + StringBuilder months = new StringBuilder(); + int numMonths = 0; + for (int year = 1900; year <= 2100; year++) { + for (int month : month31) { + Calendar date = new GregorianCalendar(year, month, 1); + if (date.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { + years[year - 1900] = true; + numMonths++; + //months are 0-indexed in Calendar + months.append((date.get(Calendar.MONTH) + 1) + "-" + year +"\n"); + } + } + } + System.out.println("There are "+numMonths+" months with five weekends from 1900 through 2100:"); + System.out.println(months); + System.out.println("Years with no five-weekend months:"); + for (int year = 1900; year <= 2100; year++) { + if(!years[year - 1900]){ + System.out.println(year); + } + } + } +} diff --git a/Task/Five-weekends/JavaScript/five-weekends.js b/Task/Five-weekends/JavaScript/five-weekends.js new file mode 100644 index 0000000000..0aaac76650 --- /dev/null +++ b/Task/Five-weekends/JavaScript/five-weekends.js @@ -0,0 +1,45 @@ +function startsOnFriday(month, year) +{ + // 0 is Sunday, 1 is Monday, ... 5 is Friday, 6 is Saturday + return new Date(year, month, 1).getDay() === 5; +} +function has31Days(month, year) +{ + return new Date(year, month, 31).getDate() === 31; +} +function checkMonths(year) +{ + var month, count = 0; + for (month = 0; month < 12; month += 1) + { + if (startsOnFriday(month, year) && has31Days(month, year)) + { + count += 1; + document.write(year + ' ' + month + '
'); + } + } + return count; +} +function fiveWeekends() +{ + var + startYear = 1900, + endYear = 2100, + year, + monthTotal = 0, + yearsWithoutFiveWeekends = [], + total = 0; + for (year = startYear; year <= endYear; year += 1) + { + monthTotal = checkMonths(year); + total += monthTotal; + // extra credit + if (monthTotal === 0) + yearsWithoutFiveWeekends.push(year); + } + document.write('Total number of months: ' + total + '
'); + document.write('
'); + document.write(yearsWithoutFiveWeekends + '
'); + document.write('Years with no five-weekend months: ' + yearsWithoutFiveWeekends.length + '
'); +} +fiveWeekends(); diff --git a/Task/Five-weekends/MUMPS/five-weekends.mumps b/Task/Five-weekends/MUMPS/five-weekends.mumps new file mode 100644 index 0000000000..ce79c801ef --- /dev/null +++ b/Task/Five-weekends/MUMPS/five-weekends.mumps @@ -0,0 +1,37 @@ +FIVE + ;List and count the months between 1/1900 and 12/2100 that have 5 full weekends + ;Extra credit - list and count years with no months with five full weekends + ;Using the test that the 31st of a month is on a Sunday + ;Uses the VA's public domain routine %DTC (Part of the Kernel) named here DIDTC + NEW YEAR,MONTH,X,Y,CNTMON,NOT,NOTLIST + ; YEAR is the year we're testing + ; MONTH is the month we're testing + ; X is the date in "internal" format, as an input to DOW^DIDTC + ; Y is the day of the week (0=Sunday, 1=Monday...) output from DOW^DIDTC + ; CNTMON is a count of the months that have 5 full weekends + ; NOT is a flag if there were no months with 5 full weekends yet that year + ; NOTLIST is a list of years that do not have any months with 5 full weekends + SET CNTMON=0,NOTLIST="" + WRITE !!,"The following months have five full weekends:" + FOR YEAR=200:1:400 DO ;years since 12/31/1700 epoch + . SET NOT=0 + . FOR MONTH="01","03","05","07","08","10","12" DO + . . SET X=YEAR_MONTH_"31" + . . DO DOW^DIDTC + . . IF (Y=0) DO + . . . SET NOT=NOT+1,CNTMON=CNTMON+1 + . . . WRITE !,MONTH_"-"_(YEAR+1700) + . SET:(NOT=0) NOTLIST=NOTLIST_$SELECT($LENGTH(NOTLIST)>1:",",1:"")_(YEAR+1700) + WRITE !,"For a total of "_CNTMON_" months." + WRITE !!,"There are "_$LENGTH(NOTLIST,",")_" years with no five full weekends in any month." + WRITE !,"They are: "_NOTLIST + KILL YEAR,MONTH,X,Y,CNTMON,NOT,NOTLIST + QUIT +F ;Same logic as the main entry point, shortened format + N R,M,X,Y,C,N,L S C=0,L="" + W !!,"The following months have five full weekends:" + F R=200:1:400 D + . S N=0 F M="01","03","05","07","08","10","12" S X=R_M_"31" D DOW^DIDTC I 'Y S N=N+1,C=C+1 W !,M_"-"_(R+1700) + . S:'N L=L_$S($L(L):",",1:"")_(R+1700) + W !,"For a total of "_C_" months.",!!,"There are "_$L(L,",")_" years with no five full weekends in any month.",!,"They are: "_L + Q diff --git a/Task/Five-weekends/Mathematica/five-weekends.mathematica b/Task/Five-weekends/Mathematica/five-weekends.mathematica new file mode 100644 index 0000000000..07ae0d30cc --- /dev/null +++ b/Task/Five-weekends/Mathematica/five-weekends.mathematica @@ -0,0 +1,8 @@ +years = {1900, 2100}; months = {1 ,3 ,5 ,7 ,8 ,10 ,12}; +result = Select[Tuples[{Range@@years, months}], (DateString[# ~ Join ~ 1, "DayNameShort"] == "Fri")&]; + +Print[result // Length," months with 5 weekends" ]; +Print["First months: ", DateString[#,{"MonthName"," ","Year"}]& /@ result[[1 ;; 5]]]; +Print["Last months: " , DateString[#,{"MonthName"," ","Year"}]& /@ result[[-5 ;; All]]]; +Print[# // Length, " years without 5 weekend months:\n", #] &@ + Complement[Range @@ years, Part[Transpose@result, 1]]; diff --git a/Task/Five-weekends/Maxima/five-weekends.maxima b/Task/Five-weekends/Maxima/five-weekends.maxima new file mode 100644 index 0000000000..5942683fe0 --- /dev/null +++ b/Task/Five-weekends/Maxima/five-weekends.maxima @@ -0,0 +1,17 @@ +left(a, n) := makelist(a[i], i, 1, n)$ +right(a, n) := block([m: length(a)], makelist(a[i], i, m - n + 1, m))$ + +a: [ ]$ +for year from 1900 thru 2100 do + for month in [1, 3, 5, 7, 8, 10, 12] do + if weekday(year, month, 1) = 'friday then + a: endcons([year, month], a)$ + +length(a); +201 + +left(a, 5); +[[1901,3],[1902,8],[1903,5],[1904,1],[1904,7]] + +right(a, 5); +[[2097,3],[2098,8],[2099,5],[2100,1],[2100,10]] diff --git a/Task/Five-weekends/Perl/five-weekends.pl b/Task/Five-weekends/Perl/five-weekends.pl new file mode 100644 index 0000000000..bdf5ebe11b --- /dev/null +++ b/Task/Five-weekends/Perl/five-weekends.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w +use DateTime ; + +my @happymonths ; +my @workhardyears ; +my @longmonths = ( 1 , 3 , 5 , 7 , 8 , 10 , 12 ) ; +my @years = 1900..2100 ; +foreach my $year ( @years ) { + my $countmonths = 0 ; + foreach my $month ( @longmonths ) { + my $dt = DateTime->new( year => $year , + month => $month , + day => 1 ) ; + if ( $dt->day_of_week == 5 ) { + $countmonths++ ; + my $yearfound = $dt->year ; + my $monthfound = $dt->month_name ; + push ( @happymonths , "$yearfound $monthfound" ) ; + } + } + if ( $countmonths == 0 ) { + push ( @workhardyears, $year ) ; + } +} +print "There are " . @happymonths . " months with 5 full weekends!\n" ; +print "The first 5 and the last 5 of them are:\n" ; +foreach my $i ( 0..4 ) { + print "$happymonths[ $i ]\n" ; +} +foreach my $i ( -5..-1 ) { + print "$happymonths[ $i ]\n" ; +} +print "No long weekends in the following " . @workhardyears . " years:\n" ; +map { print "$_\n" } @workhardyears ; diff --git a/Task/Five-weekends/PicoLisp/five-weekends.l b/Task/Five-weekends/PicoLisp/five-weekends.l new file mode 100644 index 0000000000..ae9e320215 --- /dev/null +++ b/Task/Five-weekends/PicoLisp/five-weekends.l @@ -0,0 +1,17 @@ +(setq Lst + (make + (for Y (range 1900 2100) + (for M (range 1 12) + (and + (date Y M 31) + (= "Friday" (day (date Y M 1))) + (link (list (get *Mon M) Y)) ) ) ) ) ) + +(prinl "There are " (length Lst) " months with five weekends:") +(mapc println (head 5 Lst)) +(prinl "...") +(mapc println (tail 5 Lst)) +(prinl) +(setq Lst (diff (range 1900 2100) (uniq (mapcar cadr Lst)))) +(prinl "There are " (length Lst) " years with no five-weekend months:") +(println Lst) diff --git a/Task/Five-weekends/Python/five-weekends-1.py b/Task/Five-weekends/Python/five-weekends-1.py new file mode 100644 index 0000000000..83be85e88c --- /dev/null +++ b/Task/Five-weekends/Python/five-weekends-1.py @@ -0,0 +1,34 @@ +from datetime import timedelta, date + +DAY = timedelta(days=1) +START, STOP = date(1900, 1, 1), date(2101, 1, 1) +WEEKEND = {6, 5, 4} # Sunday is day 6 +FMT = '%Y %m(%B)' + +def fiveweekendspermonth(start=START, stop=STOP): + 'Compute months with five weekends between dates' + + when = start + lastmonth = weekenddays = 0 + fiveweekends = [] + while when < stop: + year, mon, _mday, _h, _m, _s, wday, _yday, _isdst = when.timetuple() + if mon != lastmonth: + if weekenddays >= 15: + fiveweekends.append(when - DAY) + weekenddays = 0 + lastmonth = mon + if wday in WEEKEND: + weekenddays += 1 + when += DAY + return fiveweekends + +dates = fiveweekendspermonth() +indent = ' ' +print('There are %s months of which the first and last five are:' % len(dates)) +print(indent +('\n'+indent).join(d.strftime(FMT) for d in dates[:5])) +print(indent +'...') +print(indent +('\n'+indent).join(d.strftime(FMT) for d in dates[-5:])) + +print('\nThere are %i years in the range that do not have months with five weekends' + % len(set(range(START.year, STOP.year)) - {d.year for d in dates})) diff --git a/Task/Five-weekends/Python/five-weekends-2.py b/Task/Five-weekends/Python/five-weekends-2.py new file mode 100644 index 0000000000..a8c572ecd5 --- /dev/null +++ b/Task/Five-weekends/Python/five-weekends-2.py @@ -0,0 +1,10 @@ +LONGMONTHS = (1, 3, 5, 7, 8, 10, 12) # Jan Mar May Jul Aug Oct Dec +def fiveweekendspermonth2(start=START, stop=STOP): + return [date(yr, month, 31) + for yr in range(START.year, STOP.year) + for month in LONGMONTHS + if date(yr, month, 31).timetuple()[6] == 6 # Sunday + ] + +dates2 = fiveweekendspermonth2() +assert dates2 == dates diff --git a/Task/Five-weekends/REXX/five-weekends-1.rexx b/Task/Five-weekends/REXX/five-weekends-1.rexx new file mode 100644 index 0000000000..f68169e9bc --- /dev/null +++ b/Task/Five-weekends/REXX/five-weekends-1.rexx @@ -0,0 +1,41 @@ +/*REXX program finds months with 5 weekends in them (given a date range)*/ +month. =31 /*month days; Feb. is done later.*/ +month.4=30; month.6=30; month.9=30; month.11=30 /*30-day months*/ +parse arg yStart yStop . /*get the "start" & "stop" years.*/ +if yStart=='' then yStart=1900 /*if not specified, use default. */ +if yStop =='' then yStop =2100 /* " " " " " */ +years=yStop-yStart+1 /*calculate the # of yrs in range*/ +haps=0 /*num of five weekends happenings*/ +yr5.=0 /*if a year has any five-weekends*/ + do y=yStart to yStop /*process the years specified. */ + do m=1 for 12; wd.=0 /*each month, each yr*/ + if m==2 then month.2=28+leapyear(y) /*handle #days in Feb*/ + do d=1 for month.m; dat_=y"-"right(m,2,0)'-'right(d,2,0) + ?=left(date('W', dat_, "I"), 2); upper ? + wd.?=wd.?+1 /*? is 1st 2 chars of weekday*/ + end /*d*/ /*WD.su=# of Sundays in month*/ + if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*5 W.E.s?*/ + haps=haps+1 /*bump ctr*/ + say 'There are five weekends in' y date('M', dat_, "I") + yr5.y=1 /*indicate the year has 5WEs.*/ + end /*m*/ + end /*y*/ +say +say 'There were ' haps " occurrence"s(haps), + 'of five-weekend months in year's(years) yStart'──►'yStop; say +no5s=0 + do y=yStart to yStop; if yr5.y then iterate /*skip if OK*/ + no5s=no5s+1 + say 'Year ' y " doesn't have any five-weekend months." + end /*y*/ +say +say "There are " no5s ' year's(no5s), + "that haven't any five─weekend months in year"s(years) yStart'──►'yStop +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────LEAPYEAR subroutine─────────────────*/ +leapyear: procedure; parse arg y /*year could be: Y, YY, YYY, YYYY*/ +if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY year.*/ +if y//4\==0 then return 0 /* not ÷ by 4? Not a leap year.*/ +return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */ +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural*/ diff --git a/Task/Five-weekends/REXX/five-weekends-2.rexx b/Task/Five-weekends/REXX/five-weekends-2.rexx new file mode 100644 index 0000000000..b14c138556 --- /dev/null +++ b/Task/Five-weekends/REXX/five-weekends-2.rexx @@ -0,0 +1,46 @@ +/*REXX program finds months with 5 weekends in them (given a date range)*/ +month. =31 /*month days; Feb. is done later.*/ +month.4=30; month.6=30; month.9=30; month.11=30 /*30-day months*/ +@months='January February March April May June July August September October November December' +parse arg yStart yStop . /*get the "start" & "stop" years.*/ +if yStart=='' then yStart=1900 /*if not specified, use default. */ +if yStop =='' then yStop =2100 /* " " " " " */ +years=yStop-yStart+1 /*calculate the # of yrs in range*/ +haps=0 /*num of five weekends happenings*/ +yr5.=0 /*if a year has any five-weekends*/ + do y=yStart to yStop /*process the years specified. */ + do m=1 for 12; wd.=0 /*process each month in each year*/ + if m==2 then month.2=28+leapyear(y) /*handle #days in Feb.*/ + do d=1 for month.m + ?=dow(m,d,y) /*get day-of-week for mm/dd/yyyy.*/ + wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, ∙∙∙ 7=Sat */ + end /*d*/ + if wd.1\==5 | wd.6\==5 | wd.7\==5 then iterate /*5 WEs ? */ + haps=haps+1 /*bump ctr*/ + say 'There are five weekends in' y word(@months,m) + yr5.y=1 /*indicate this year has 5 WEs. */ + end /*m*/ + end /*y*/ +say +say 'There were ' haps " occurrence"s(haps), + 'of five-weekend months in year's(years) yStart'──►'yStop; say +no5s=0 + do y=yStart to yStop; if yr5.y then iterate /*skip if OK*/ + no5s=no5s+1 + say 'Year ' y " doesn't have any five-weekend months." + end /*y*/ +say +say "There are " no5s ' year's(no5s), + "that haven't any five─weekend months in year"s(years) yStart'──►'yStop +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────DOW─────────────────────────────────*/ +dow: procedure; parse arg m,d,y; if m<3 then do; m=m+12; y=y-1; end +yL=left(y,2); yr=right(y,2); w=(d+(m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7 +if w==0 then w=7; return w /*Sunday=1, Monday=2, ... Saturday=7*/ +/*──────────────────────────────────LEAPYEAR subroutine─────────────────*/ +leapyear: procedure; parse arg y /*year could be: Y, YY, YYY, YYYY*/ +if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY year.*/ +if y//4\==0 then return 0 /* not ÷ by 4? Not a leap year.*/ +return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */ +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural*/ diff --git a/Task/Five-weekends/REXX/five-weekends-3.rexx b/Task/Five-weekends/REXX/five-weekends-3.rexx new file mode 100644 index 0000000000..e8ca52e33e --- /dev/null +++ b/Task/Five-weekends/REXX/five-weekends-3.rexx @@ -0,0 +1,55 @@ +/* REXX *************************************************************** +* Short(er) solution focussed at the task's description +* Only 7 months can have 5 full weekends +* and it's enough to test if the 1st day of the month is a Friday +* 30.08.2012 Walter Pachl +**********************************************************************/ +Numeric digits 20 +nr5fwe=0 +years_without_5fwe=0 +mnl='Jan Mar May Jul Aug Oct Dec' +ml='1 3 5 7 8 10 12' +Do j=1900 to 2100 + year_has_5fwe=0 + Do mi=1 To words(ml) + m=word(ml,mi) + jd=greg2jul(j m 1) + IF jd//7=4 Then Do /* 1st m j is a Friday */ + nr5fwe=nr5fwe+1 + year_has_5fwe=1 + If j<=1905 | 2095<=j Then + Say word(mnl,mi) j 'has 5 full weekends' + End + End + If j=1905 Then Say '...' + if year_has_5fwe=0 Then years_without_5fwe=years_without_5fwe+1 + End +Say ' ' +Say nr5fwe 'occurrences of 5 full weekends in a month' +Say years_without_5fwe 'years without 5 full weekends' +exit + +greg2jul: Procedure +/*********************************************************************** +* Converts a Gregorian date to the corresponding Julian day number +* 19891101 Walter Pachl REXXified algorithm published in CACM +* (Fliegel & vanFlandern, CACM Vol.11 No.10 October 1968) +* 19891125 PA copy leapyear test into this to avoid the dependency +***********************************************************************/ + numeric digits 12 + Parse Arg yy mm d + If mm<1 | 120) ) | (arg(1)//400=0) diff --git a/Task/Five-weekends/Ruby/five-weekends.rb b/Task/Five-weekends/Ruby/five-weekends.rb new file mode 100644 index 0000000000..99b07a2a28 --- /dev/null +++ b/Task/Five-weekends/Ruby/five-weekends.rb @@ -0,0 +1,21 @@ +require 'date' + +# if the last day of the month falls on a Sunday and the month has 31 days, +# this is the only case where the month has 5 weekends. +start = Date.parse("1900-01-01") +stop = Date.parse("2100-12-31") +dates = (start..stop).find_all do |day| + day.mday == 31 and day.wday == 0 # Ruby 1.9: and day.sunday? +end + +puts "There are #{dates.size} months with 5 weekends from 1900 to 2100:" +puts dates[0, 5].map { |d| d.strftime("%b %Y") }.join("\n") +puts "..." +puts dates[-5, 5].map { |d| d.strftime("%b %Y") }.join("\n") + +years_with_5w = dates.map(&:year) + +years = (1900..2100).to_a - years_with_5w + +puts "There are #{years.size} years without months with 5 weekends:" +puts years.join(", ") diff --git a/Task/Five-weekends/Tcl/five-weekends.tcl b/Task/Five-weekends/Tcl/five-weekends.tcl new file mode 100644 index 0000000000..83f35c22d4 --- /dev/null +++ b/Task/Five-weekends/Tcl/five-weekends.tcl @@ -0,0 +1,22 @@ +package require Tcl 8.5 + +set months {} +set years {} +for {set year 1900} {$year <= 2100} {incr year} { + set count [llength $months] + foreach month {Jan Mar May Jul Aug Oct Dec} { + set date [clock scan "$month/01/$year" -format "%b/%d/%Y" -locale en_US] + if {[clock format $date -format %u] == 5} { + # Month with 31 days that starts on a Friday => has 5 weekends + lappend months "$month $year" + } + } + if {$count == [llength $months]} { + # No change to number of months; year must've been without + lappend years $year + } +} +puts "There are [llength $months] months with five weekends" +puts [join [list {*}[lrange $months 0 4] ... {*}[lrange $months end-4 end]] \n] +puts "There are [llength $years] years without any five-weekend months" +puts [join $years ","] diff --git a/Task/FizzBuzz/FALSE/fizzbuzz.false b/Task/FizzBuzz/FALSE/fizzbuzz.false new file mode 100644 index 0000000000..6b9aca2708 --- /dev/null +++ b/Task/FizzBuzz/FALSE/fizzbuzz.false @@ -0,0 +1,4 @@ +[\$@$@\/*=]d: +[1\$3d;!["Fizz"\%0\]?$5d;!["Buzz"\%0\]?\[$.]?" +"]f: +0[$100<][1+f;!]#% diff --git a/Task/FizzBuzz/Factor/fizzbuzz.factor b/Task/FizzBuzz/Factor/fizzbuzz.factor new file mode 100644 index 0000000000..d9b4ac39c9 --- /dev/null +++ b/Task/FizzBuzz/Factor/fizzbuzz.factor @@ -0,0 +1,7 @@ +USING: math kernel io math.ranges ; +IN: fizzbuzz +: fizz ( n -- str ) 3 divisor? "Fizz" "" ? ; +: buzz ( n -- str ) 5 divisor? "Buzz" "" ? ; +: fizzbuzz ( n -- str ) dup [ fizz ] [ buzz ] bi append [ number>string ] [ nip ] if-empty ; +: main ( -- ) 100 [1,b] [ fizzbuzz print ] each ; +MAIN: main diff --git a/Task/FizzBuzz/Falcon/fizzbuzz.falcon b/Task/FizzBuzz/Falcon/fizzbuzz.falcon new file mode 100644 index 0000000000..0824a8a1a6 --- /dev/null +++ b/Task/FizzBuzz/Falcon/fizzbuzz.falcon @@ -0,0 +1,8 @@ +for i in [1:101] + switch i % 15 + case 0 : > "FizzBuzz" + case 5,10 : > "Buzz" + case 3,6,9,12 : > "Fizz" + default : > i + end +end diff --git a/Task/FizzBuzz/Fantom/fizzbuzz.fantom b/Task/FizzBuzz/Fantom/fizzbuzz.fantom new file mode 100644 index 0000000000..cae73e7ffc --- /dev/null +++ b/Task/FizzBuzz/Fantom/fizzbuzz.fantom @@ -0,0 +1,17 @@ +class FizzBuzz +{ + public static Void main () + { + for (Int i:=1; i <= 100; ++i) + { + if (i % 15 == 0) + echo ("FizzBuzz") + else if (i % 3 == 0) + echo ("Fizz") + else if (i % 5 == 0) + echo ("Buzz") + else + echo (i) + } + } +} diff --git a/Task/FizzBuzz/Frink/fizzbuzz.frink b/Task/FizzBuzz/Frink/fizzbuzz.frink new file mode 100644 index 0000000000..4b6224d9f6 --- /dev/null +++ b/Task/FizzBuzz/Frink/fizzbuzz.frink @@ -0,0 +1,20 @@ +for i = 1 to 100 +{ + flag = false + if i mod 3 == 0 + { + flag = true + print["Fizz"] + } + + if i mod 5 == 0 + { + flag = true + print["Buzz"] + } + + if flag == false + print[i] + + println[] +} diff --git a/Task/FizzBuzz/GAP/fizzbuzz.gap b/Task/FizzBuzz/GAP/fizzbuzz.gap new file mode 100644 index 0000000000..477a8e2503 --- /dev/null +++ b/Task/FizzBuzz/GAP/fizzbuzz.gap @@ -0,0 +1,14 @@ +FizzBuzz := function() + local i; + for i in [1 .. 100] do + if RemInt(i, 15) = 0 then + Print("FizzBuzz\n"); + elif RemInt(i, 3) = 0 then + Print("Fizz\n"); + elif RemInt(i, 5) = 0 then + Print("Buzz\n"); + else + Print(i, "\n"); + fi; + od; +end; diff --git a/Task/FizzBuzz/Gosu/fizzbuzz-1.gosu b/Task/FizzBuzz/Gosu/fizzbuzz-1.gosu new file mode 100644 index 0000000000..2d1fd21bea --- /dev/null +++ b/Task/FizzBuzz/Gosu/fizzbuzz-1.gosu @@ -0,0 +1,21 @@ +for (i in 1..100) { + + if (i % 3 == 0 && i % 5 == 0) { + print("FizzBuzz") + continue + } + + if (i % 3 == 0) { + print("Fizz") + continue + } + + if (i % 5 == 0) { + print("Buzz") + continue + } + + // default + print(i) + +} diff --git a/Task/FizzBuzz/Gosu/fizzbuzz-2.gosu b/Task/FizzBuzz/Gosu/fizzbuzz-2.gosu new file mode 100644 index 0000000000..17668f2213 --- /dev/null +++ b/Task/FizzBuzz/Gosu/fizzbuzz-2.gosu @@ -0,0 +1,4 @@ +// note that compiler reports error (I don't know why) but still it's working +for (i in 1..100) { + print(i % 5 == 0 ? i % 3 == 0 ? "FizzBuzz" : "Buzz" : i % 3 == 0 ? "Fizz" : i) +} diff --git a/Task/FizzBuzz/Groovy/fizzbuzz.groovy b/Task/FizzBuzz/Groovy/fizzbuzz.groovy new file mode 100644 index 0000000000..83fb591e8f --- /dev/null +++ b/Task/FizzBuzz/Groovy/fizzbuzz.groovy @@ -0,0 +1,3 @@ +for (i in 1..100) { + println "${i%3?'':'Fizz'}${i%5?'':'Buzz'}" ?: i +} diff --git a/Task/FizzBuzz/HicEst/fizzbuzz-1.hicest b/Task/FizzBuzz/HicEst/fizzbuzz-1.hicest new file mode 100644 index 0000000000..76a27f4a9a --- /dev/null +++ b/Task/FizzBuzz/HicEst/fizzbuzz-1.hicest @@ -0,0 +1,11 @@ +DO i = 1, 100 + IF( MOD(i, 15) == 0 ) THEN + WRITE() "FizzBuzz" + ELSEIF( MOD(i, 5) == 0 ) THEN + WRITE() "Buzz" + ELSEIF( MOD(i, 3) == 0 ) THEN + WRITE() "Fizz" + ELSE + WRITE() i + ENDIF +ENDDO diff --git a/Task/FizzBuzz/HicEst/fizzbuzz-2.hicest b/Task/FizzBuzz/HicEst/fizzbuzz-2.hicest new file mode 100644 index 0000000000..5d9cf692b3 --- /dev/null +++ b/Task/FizzBuzz/HicEst/fizzbuzz-2.hicest @@ -0,0 +1,9 @@ +CHARACTER string*8 + +DO i = 1, 100 + string = " " + IF( MOD(i, 3) == 0 ) string = "Fizz" + IF( MOD(i, 5) == 0 ) string = TRIM(string) // "Buzz" + IF( string == " ") WRITE(Text=string) i + WRITE() string +ENDDO diff --git a/Task/FizzBuzz/Icon/fizzbuzz-1.icon b/Task/FizzBuzz/Icon/fizzbuzz-1.icon new file mode 100644 index 0000000000..16ded898d7 --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-1.icon @@ -0,0 +1,12 @@ +# straight-forward modulo tester +procedure main() + every i := 1 to 100 do + if i % 15 = 0 then + write("FizzBuzz") + else if i % 5 = 0 then + write("Buzz") + else if i % 3 = 0 then + write("Fizz") + else + write(i) +end diff --git a/Task/FizzBuzz/Icon/fizzbuzz-2.icon b/Task/FizzBuzz/Icon/fizzbuzz-2.icon new file mode 100644 index 0000000000..ecfe7169f8 --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-2.icon @@ -0,0 +1,5 @@ +# idiomatic modulo tester, 1st alternative +procedure main() + every i := 1 to 100 do + write((i % 15 = 0 & "FizzBuzz") | (i % 5 = 0 & "Buzz") | (i % 3 = 0 & "Fizz") | i) +end diff --git a/Task/FizzBuzz/Icon/fizzbuzz-3.icon b/Task/FizzBuzz/Icon/fizzbuzz-3.icon new file mode 100644 index 0000000000..0174f788fd --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-3.icon @@ -0,0 +1,10 @@ +# idiomatic modulo tester, 2nd alternative +procedure main() + every i := 1 to 100 do + write(case 0 of { + i % 15 : "FizzBuzz" + i % 5 : "Buzz" + i % 3 : "Fizz" + default: i + }) +end diff --git a/Task/FizzBuzz/Icon/fizzbuzz-4.icon b/Task/FizzBuzz/Icon/fizzbuzz-4.icon new file mode 100644 index 0000000000..fa888eac99 --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-4.icon @@ -0,0 +1,13 @@ +# straight-forward buffer builder +procedure main() + every i := 1 to 100 do { + s := "" + if i % 3 = 0 then + s ||:= "Fizz" + if i % 5 = 0 then + s ||:= "Buzz" + if s == "" then + s := i + write(s) + } +end diff --git a/Task/FizzBuzz/Icon/fizzbuzz-5.icon b/Task/FizzBuzz/Icon/fizzbuzz-5.icon new file mode 100644 index 0000000000..eb00ffa789 --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-5.icon @@ -0,0 +1,5 @@ +# idiomatic buffer builder, 1st alternative +procedure main() +    every i := 1 to 100 do +        write("" ~== (if i % 3 = 0 then "Fizz" else "") || (if i % 5 == 0 then "Buzz" else "") | i) +end diff --git a/Task/FizzBuzz/Icon/fizzbuzz-6.icon b/Task/FizzBuzz/Icon/fizzbuzz-6.icon new file mode 100644 index 0000000000..360fa81834 --- /dev/null +++ b/Task/FizzBuzz/Icon/fizzbuzz-6.icon @@ -0,0 +1,8 @@ +# idiomatic buffer builder, 2nd alternative +procedure main() +    every i := 1 to 100 do { +        s   := if i%3 = 0 then "Fizz" else "" +        s ||:= if i%5 = 0 then "Buzz" +        write(("" ~= s) | i) +    } +end diff --git a/Task/FizzBuzz/Inform-6/fizzbuzz.inf b/Task/FizzBuzz/Inform-6/fizzbuzz.inf new file mode 100644 index 0000000000..9c763c6339 --- /dev/null +++ b/Task/FizzBuzz/Inform-6/fizzbuzz.inf @@ -0,0 +1,10 @@ +[ Main i; + for(i = 1: i <= 100: i++) + { + if(i % 3 == 0) print "Fizz"; + if(i % 5 == 0) print "Buzz"; + if(i % 3 ~= 0 && i % 5 ~= 0) print i; + + print "^"; + } +]; diff --git a/Task/FizzBuzz/Inform-7/fizzbuzz.inf b/Task/FizzBuzz/Inform-7/fizzbuzz.inf new file mode 100644 index 0000000000..259655c59b --- /dev/null +++ b/Task/FizzBuzz/Inform-7/fizzbuzz.inf @@ -0,0 +1,14 @@ +Home is a room. + +When play begins: + repeat with N running from 1 to 100: + let printed be false; + if the remainder after dividing N by 3 is 0: + say "Fizz"; + now printed is true; + if the remainder after dividing N by 5 is 0: + say "Buzz"; + now printed is true; + if printed is false, say N; + say "."; + end the story. diff --git a/Task/FizzBuzz/Io/fizzbuzz-1.io b/Task/FizzBuzz/Io/fizzbuzz-1.io new file mode 100644 index 0000000000..e7b85a04a2 --- /dev/null +++ b/Task/FizzBuzz/Io/fizzbuzz-1.io @@ -0,0 +1,11 @@ +for(a,1,100, + if(a % 15 == 0) then( + "FizzBuzz" println + ) elseif(a % 3 == 0) then( + "Fizz" println + ) elseif(a % 5 == 0) then( + "Buzz" println + ) else ( + a println + ) +) diff --git a/Task/FizzBuzz/Io/fizzbuzz-2.io b/Task/FizzBuzz/Io/fizzbuzz-2.io new file mode 100644 index 0000000000..2d54801f26 --- /dev/null +++ b/Task/FizzBuzz/Io/fizzbuzz-2.io @@ -0,0 +1,7 @@ +a := 0; b := 0 +for(n, 1, 100, + if(a = (n % 3) == 0, "Fizz" print); + if(b = (n % 5) == 0, "Buzz" print); + if(a not and b not, n print); + "\n" print +) diff --git a/Task/FizzBuzz/Io/fizzbuzz-3.io b/Task/FizzBuzz/Io/fizzbuzz-3.io new file mode 100644 index 0000000000..ddf0d9869c --- /dev/null +++ b/Task/FizzBuzz/Io/fizzbuzz-3.io @@ -0,0 +1,7 @@ +for (n, 1, 100, + fb := list ( + if (n % 3 == 0, "Fizz"), + if (n % 5 == 0, "Buzz")) select (isTrue) + + if (fb isEmpty, n, fb join) println +) diff --git a/Task/FizzBuzz/Ioke/fizzbuzz.ioke b/Task/FizzBuzz/Ioke/fizzbuzz.ioke new file mode 100644 index 0000000000..565ba62816 --- /dev/null +++ b/Task/FizzBuzz/Ioke/fizzbuzz.ioke @@ -0,0 +1,7 @@ +(1..100) each(x, + cond( + (x % 15) zero?, "FizzBuzz" println, + (x % 3) zero?, "Fizz" println, + (x % 5) zero?, "Buzz" println + ) +) diff --git a/Task/FizzBuzz/Iptscrae/fizzbuzz.iptscrae b/Task/FizzBuzz/Iptscrae/fizzbuzz.iptscrae new file mode 100644 index 0000000000..f72d7031f8 --- /dev/null +++ b/Task/FizzBuzz/Iptscrae/fizzbuzz.iptscrae @@ -0,0 +1,10 @@ +; FizzBuzz in Iptscrae +1 a = +{ + "" b = + { "fizz" b &= } a 3 % 0 == IF + { "buzz" b &= } a 5 % 0 == IF + { a ITOA LOGMSG } { b LOGMSG } b STRLEN 0 == IFELSE + a ++ +} +{ a 100 <= } WHILE diff --git a/Task/FizzBuzz/J/fizzbuzz-1.j b/Task/FizzBuzz/J/fizzbuzz-1.j new file mode 100644 index 0000000000..592c724370 --- /dev/null +++ b/Task/FizzBuzz/J/fizzbuzz-1.j @@ -0,0 +1,2 @@ + test =: +/@(1 2 * 0 = 3 5&|~) + (":@]`('Fizz'"_)`('Buzz'"_)`('FizzBuzz'"_) @. test"0) >:i.100 diff --git a/Task/FizzBuzz/J/fizzbuzz-2.j b/Task/FizzBuzz/J/fizzbuzz-2.j new file mode 100644 index 0000000000..eff230eaa9 --- /dev/null +++ b/Task/FizzBuzz/J/fizzbuzz-2.j @@ -0,0 +1 @@ +> }. (<'FizzBuzz') (I.0=15|n)} (<'Buzz') (I.0=5|n)} (<'Fizz') (I.0=3|n)} ":&.> n=: i.101 diff --git a/Task/FizzBuzz/J/fizzbuzz-3.j b/Task/FizzBuzz/J/fizzbuzz-3.j new file mode 100644 index 0000000000..ea1082f9c2 --- /dev/null +++ b/Task/FizzBuzz/J/fizzbuzz-3.j @@ -0,0 +1,5 @@ +Fizz=: 'Fizz' #~ 0 = 3&| +Buzz=: 'Buzz' #~ 0 = 5&| +FizzBuzz=: ": [^:('' -: ]) Fizz,Buzz + +FizzBuzz"0 >: i.100 diff --git a/Task/FizzBuzz/J/fizzbuzz-4.j b/Task/FizzBuzz/J/fizzbuzz-4.j new file mode 100644 index 0000000000..4b811ea712 --- /dev/null +++ b/Task/FizzBuzz/J/fizzbuzz-4.j @@ -0,0 +1,6 @@ +CRT0=: 2 : ' (, 0 = +./)@(0 = m | ]) ;@# n , <@": ' +NB. Rather (, 0 = +./) than (, +:/) because designed for +NB. 3 5 7 CRT0 (;:'Chinese Remainder Period') "0 >: i. */3 5 7 +FizzBuzz=: 3 5 CRT0 (;:'Fizz Buzz') + +FizzBuzz"0 >: i.100 diff --git a/Task/FizzBuzz/J/fizzbuzz-5.j b/Task/FizzBuzz/J/fizzbuzz-5.j new file mode 100644 index 0000000000..9c48851a18 --- /dev/null +++ b/Task/FizzBuzz/J/fizzbuzz-5.j @@ -0,0 +1,6 @@ +'`f b fb' =: ('Fizz'"_) ` ('Buzz'"_) ` (f , b) +'`cm3 cm5 cm15'=: (3&|) ` (5&|) ` (15&|) (0&=@) +FizzBuzz=: ": ` f @. cm3 ` b @. cm5 ` fb @. cm15 NB. also: +FizzBuzz=: ": ` f @. cm3 ` b @. cm5 ` (f,b) @. (cm3 *. cm5) + +FizzBuzz"0 >: i.100 diff --git a/Task/FizzBuzz/Joy/fizzbuzz.joy b/Task/FizzBuzz/Joy/fizzbuzz.joy new file mode 100644 index 0000000000..47eaf2cb93 --- /dev/null +++ b/Task/FizzBuzz/Joy/fizzbuzz.joy @@ -0,0 +1,2 @@ +DEFINE one == [[[dup 15 rem 0 =] "FizzBuzz"] [[dup 3 rem 0 =] "Fizz"] [[dup 5 rem 0 =] "Buzz"] [dup]] cond. +1 [100 <=] [dup one put succ] while. diff --git a/Task/FizzBuzz/Julia/fizzbuzz.julia b/Task/FizzBuzz/Julia/fizzbuzz.julia new file mode 100644 index 0000000000..e769a21619 --- /dev/null +++ b/Task/FizzBuzz/Julia/fizzbuzz.julia @@ -0,0 +1,11 @@ +for i = 1:100 + if i % 15 == 0 + println("FizzBuzz") + elseif i % 3 == 0 + println("Fizz") + elseif i % 5 == 0 + println("Buzz") + else + println(i) + end +end diff --git a/Task/FizzBuzz/K/fizzbuzz.k b/Task/FizzBuzz/K/fizzbuzz.k new file mode 100644 index 0000000000..1592aa685d --- /dev/null +++ b/Task/FizzBuzz/K/fizzbuzz.k @@ -0,0 +1 @@ +`0:\:{:[0=#a:{,/$(:[0=x!3;"Fizz"];:[0=x!5;"Buzz"])}@x;$x;a]}'1_!101 diff --git a/Task/FizzBuzz/Kaya/fizzbuzz.kaya b/Task/FizzBuzz/Kaya/fizzbuzz.kaya new file mode 100644 index 0000000000..88d9563599 --- /dev/null +++ b/Task/FizzBuzz/Kaya/fizzbuzz.kaya @@ -0,0 +1,20 @@ +// fizzbuzz in Kaya +program fizzbuzz; + +Void fizzbuzz(Int size) { + for i in [1..size] { + if (i % 15 == 0) { + putStrLn("FizzBuzz"); + } else if (i % 5 == 0) { + putStrLn("Buzz"); + } else if (i % 3 == 0) { + putStrLn("Fizz"); + } else { + putStrLn( string(i) ); + } + } +} + +Void main() { + fizzbuzz(100); +} diff --git a/Task/FizzBuzz/LOLCODE/fizzbuzz.lol b/Task/FizzBuzz/LOLCODE/fizzbuzz.lol new file mode 100644 index 0000000000..563246d44c --- /dev/null +++ b/Task/FizzBuzz/LOLCODE/fizzbuzz.lol @@ -0,0 +1,18 @@ +HAI 1.3 + +IM IN YR fizz UPPIN YR i TIL BOTH SAEM i AN 100 + I HAS A i ITZ SUM OF i AN 1 BTW, ALL LUPZ START AT 0 :/ + I HAS A mod3 ITZ NOT MOD OF i AN 3 + I HAS A mod5 ITZ NOT MOD OF i AN 5 + + mod3, O RLY?, YA RLY, VISIBLE "Fizz"!, OIC + mod5, O RLY?, YA RLY, VISIBLE "Buzz"!, OIC + + NOT EITHER OF mod3 AN mod5, O RLY? + YA RLY, VISIBLE i! + OIC + + VISIBLE "" +IM OUTTA YR fizz + +KTHXBYE diff --git a/Task/FizzBuzz/Liberty-BASIC/fizzbuzz.liberty b/Task/FizzBuzz/Liberty-BASIC/fizzbuzz.liberty new file mode 100644 index 0000000000..691732ed92 --- /dev/null +++ b/Task/FizzBuzz/Liberty-BASIC/fizzbuzz.liberty @@ -0,0 +1,12 @@ +for i = 1 to 100 + select case + case i mod 15 = 0 + print "FizzBuzz" + case i mod 3 = 0 + print "Fizz" + case i mod 5 = 0 + print "Buzz" + case else + print i + end select +next i diff --git a/Task/FizzBuzz/Logo/fizzbuzz-1.logo b/Task/FizzBuzz/Logo/fizzbuzz-1.logo new file mode 100644 index 0000000000..7a46352cef --- /dev/null +++ b/Task/FizzBuzz/Logo/fizzbuzz-1.logo @@ -0,0 +1,8 @@ +to fizzbuzz :n + output cond [ [[equal? 0 modulo :n 15] "FizzBuzz] + [[equal? 0 modulo :n 5] "Buzz] + [[equal? 0 modulo :n 3] "Fizz] + [else :n] ] +end + +repeat 100 [print fizzbuzz #] diff --git a/Task/FizzBuzz/Logo/fizzbuzz-2.logo b/Task/FizzBuzz/Logo/fizzbuzz-2.logo new file mode 100644 index 0000000000..50a049bb74 --- /dev/null +++ b/Task/FizzBuzz/Logo/fizzbuzz-2.logo @@ -0,0 +1,8 @@ +to fizzbuzz :n + make "c " + if equal? 0 modulo :n 5 [make "c "Buzz] + if equal? 0 modulo :n 3 [make "c word "Fizz :c] + output ifelse equal? :c " [:n] [:c] +end + +repeat 100 [print fizzbuzz repcount] diff --git a/Task/FizzBuzz/M4/fizzbuzz.m4 b/Task/FizzBuzz/M4/fizzbuzz.m4 new file mode 100644 index 0000000000..c7249a215c --- /dev/null +++ b/Task/FizzBuzz/M4/fizzbuzz.m4 @@ -0,0 +1,10 @@ +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$5`'popdef(`$1')$0(`$1',eval($2+$4),$3,$4,`$5')')')') + +for(`x',1,100,1, + `ifelse(eval(x%15==0),1,FizzBuzz, + `ifelse(eval(x%3==0),1,Fizz, + `ifelse(eval(x%5==0),1,Buzz,x)')') +') diff --git a/Task/FizzBuzz/MAXScript/fizzbuzz.max b/Task/FizzBuzz/MAXScript/fizzbuzz.max new file mode 100644 index 0000000000..0ddc7a4e77 --- /dev/null +++ b/Task/FizzBuzz/MAXScript/fizzbuzz.max @@ -0,0 +1,10 @@ +for i in 1 to 100 do +( + case of + ( + (mod i 15 == 0): (print "FizzBuzz") + (mod i 5 == 0): (print "Buzz") + (mod i 3 == 0): (print "Fizz") + default: (print i) + ) +) diff --git a/Task/FizzBuzz/MEL/fizzbuzz.mel b/Task/FizzBuzz/MEL/fizzbuzz.mel new file mode 100644 index 0000000000..398f5157dc --- /dev/null +++ b/Task/FizzBuzz/MEL/fizzbuzz.mel @@ -0,0 +1,11 @@ +for($i=1; $i<=100; $i++) +{ + if($i % 15 == 0) + print "FizzBuzz\n"; + else if ($i % 3 == 0) + print "Fizz\n"; + else if ($i % 5 == 0) + print "Buzz\n"; + else + print ($i + "\n"); +} diff --git a/Task/FizzBuzz/MMIX/fizzbuzz.mmix b/Task/FizzBuzz/MMIX/fizzbuzz.mmix new file mode 100644 index 0000000000..3f2e62edf7 --- /dev/null +++ b/Task/FizzBuzz/MMIX/fizzbuzz.mmix @@ -0,0 +1,63 @@ +t IS $255 +Ja IS $127 + + LOC Data_Segment +data GREG @ + +fizz IS @-Data_Segment + BYTE "Fizz",0,0,0,0 + +buzz IS @-Data_Segment + BYTE "Buzz",0,0,0,0 + +nl IS @-Data_Segment + BYTE #a,0,0,0,0,0,0,0 + +buffer IS @-Data_Segment + + + + LOC #1000 + GREG @ + +% "usual" print integer subroutine +printnum LOC @ + OR $1,$0,0 + SETL $2,buffer+64 + ADDU $2,$2,data + XOR $3,$3,$3 + STBU $3,$2,1 +loop DIV $1,$1,10 + GET $3,rR + ADDU $3,$3,'0' + STBU $3,$2,0 + SUBU $2,$2,1 + PBNZ $1,loop + ADDU t,$2,1 + TRAP 0,Fputs,StdOut + GO Ja,Ja,0 + +Main SETL $0,1 % i = 1 +1H SETL $2,0 % fizz not taken + CMP $1,$0,100 % i <= 100 + BP $1,4F % if no, go to end + DIV $1,$0,3 + GET $1,rR % $1 = mod(i,3) + CSZ $2,$1,1 % $2 = Fizz taken? + BNZ $1,2F % $1 != 0? yes, then skip + ADDU t,data,fizz + TRAP 0,Fputs,StdOut % print "Fizz" +2H DIV $1,$0,5 + GET $1,rR % $1 = mod(i,5) + BNZ $1,3F % $1 != 0? yes, then skip + ADDU t,data,buzz + TRAP 0,Fputs,StdOut % print "Buzz" + JMP 5F % skip print i +3H BP $2,5F % skip if Fizz was taken + GO Ja,printnum % print i +5H ADDU t,data,nl + TRAP 0,Fputs,StdOut % print newline + ADDU $0,$0,1 + JMP 1B % repeat for next i +4H XOR t,t,t + TRAP 0,Halt,0 % exit(0) diff --git a/Task/FizzBuzz/MUMPS/fizzbuzz.mumps b/Task/FizzBuzz/MUMPS/fizzbuzz.mumps new file mode 100644 index 0000000000..deb2a4b7df --- /dev/null +++ b/Task/FizzBuzz/MUMPS/fizzbuzz.mumps @@ -0,0 +1,5 @@ +FIZZBUZZ + NEW I + FOR I=1:1:100 WRITE !,$SELECT(('(I#3)&'(I#5)):"FizzBuzz",'(I#5):"Buzz",'(I#3):"Fizz",1:I) + KILL I + QUIT diff --git a/Task/FizzBuzz/Mathematica/fizzbuzz-1.mathematica b/Task/FizzBuzz/Mathematica/fizzbuzz-1.mathematica new file mode 100644 index 0000000000..267ede743a --- /dev/null +++ b/Task/FizzBuzz/Mathematica/fizzbuzz-1.mathematica @@ -0,0 +1 @@ +Do[Print[Which[Mod[i, 15] == 0, "FizzBuzz", Mod[i, 5] == 0, "Buzz", Mod[i, 3] == 0, "Fizz", True, i]], {i, 100}] diff --git a/Task/FizzBuzz/Mathematica/fizzbuzz-2.mathematica b/Task/FizzBuzz/Mathematica/fizzbuzz-2.mathematica new file mode 100644 index 0000000000..064b59a5f1 --- /dev/null +++ b/Task/FizzBuzz/Mathematica/fizzbuzz-2.mathematica @@ -0,0 +1,4 @@ +fizz[i_] := Mod[i, 3] == 0 +buzz[i_] := Mod[i, 5] == 0 +Range[100] /. {i_ /; fizz[i]&&buzz[i] :> "FizzBuzz", \ + i_?fizz :> "Fizz", i_?buzz :> "Buzz"} diff --git a/Task/FizzBuzz/Mathematica/fizzbuzz-3.mathematica b/Task/FizzBuzz/Mathematica/fizzbuzz-3.mathematica new file mode 100644 index 0000000000..fd173ee18e --- /dev/null +++ b/Task/FizzBuzz/Mathematica/fizzbuzz-3.mathematica @@ -0,0 +1,4 @@ +Table[If[# === "", i, #]&@StringJoin[ + Table[If[Divisible[i, First@nw], Last@nw, ""], + {nw, {{3, "Fizz"}, {5, "Buzz"}}}]], + {i, 1, 100}] diff --git a/Task/FizzBuzz/Maxima/fizzbuzz.maxima b/Task/FizzBuzz/Maxima/fizzbuzz.maxima new file mode 100644 index 0000000000..9f49421665 --- /dev/null +++ b/Task/FizzBuzz/Maxima/fizzbuzz.maxima @@ -0,0 +1,5 @@ +for n thru 100 do + if mod(n, 15) = 0 then disp("FizzBuzz") + elseif mod(n, 3) = 0 then disp("Fizz") + elseif mod(n,5) = 0 then disp("Buzz") + else disp(n); diff --git a/Task/FizzBuzz/Mercury/fizzbuzz.mercury b/Task/FizzBuzz/Mercury/fizzbuzz.mercury new file mode 100644 index 0000000000..589f583b0d --- /dev/null +++ b/Task/FizzBuzz/Mercury/fizzbuzz.mercury @@ -0,0 +1,26 @@ +:- module fizzbuzz. +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. +:- implementation. +:- import_module int, string, bool. + +:- func fizz(int) = bool. +:- func buzz(int) = bool. +fizz(N) = ( if N mod 3 = 0 then yes else no ). +buzz(N) = ( if N mod 5 = 0 then yes else no ). + +:- pred fizzbuzz(int::in, bool::in, bool::in, string::out) is det. +% 3? 5? +fizzbuzz(_, yes, yes, "FizzBuzz"). +fizzbuzz(_, yes, no, "Fizz"). +fizzbuzz(_, no, yes, "Buzz"). +fizzbuzz(N, no, no, S) :- S = from_int(N). + +main(!IO) :- main(1, 100, !IO). + +:- pred main(int::in, int::in, io::di, io::uo) is det. +main(N, To, !IO) :- + io.write_string(S, !IO), io.nl(!IO), + fizzbuzz(N, fizz(N), buzz(N), S), + ( if N < To then main(N + 1, To, !IO) else !:IO = !.IO ). diff --git a/Task/FizzBuzz/Metafont/fizzbuzz.metafont b/Task/FizzBuzz/Metafont/fizzbuzz.metafont new file mode 100644 index 0000000000..d5a0a9b894 --- /dev/null +++ b/Task/FizzBuzz/Metafont/fizzbuzz.metafont @@ -0,0 +1,7 @@ +for i := 1 upto 100: +message if i mod 15 = 0: "FizzBuzz" & +elseif i mod 3 = 0: "Fizz" & +elseif i mod 5 = 0: "Buzz" & +else: decimal i & fi ""; +endfor +end diff --git a/Task/FizzBuzz/Mirah/fizzbuzz.mirah b/Task/FizzBuzz/Mirah/fizzbuzz.mirah new file mode 100644 index 0000000000..57da4b44ae --- /dev/null +++ b/Task/FizzBuzz/Mirah/fizzbuzz.mirah @@ -0,0 +1,19 @@ +1.upto(100) do |n| + print "Fizz" if a = ((n % 3) == 0) + print "Buzz" if b = ((n % 5) == 0) + print n unless (a || b) + print "\n" +end + +# a little more straight forward +1.upto(100) do |n| + if (n % 15) == 0 + puts "FizzBuzz" + elsif (n % 5) == 0 + puts "Buzz" + elsif (n % 3) == 0 + puts "Fizz" + else + puts n + end +end diff --git a/Task/FizzBuzz/Modula-3/fizzbuzz.mod3 b/Task/FizzBuzz/Modula-3/fizzbuzz.mod3 new file mode 100644 index 0000000000..405779601e --- /dev/null +++ b/Task/FizzBuzz/Modula-3/fizzbuzz.mod3 @@ -0,0 +1,18 @@ +MODULE Fizzbuzz EXPORTS Main; + +IMPORT IO; + +BEGIN + FOR i := 1 TO 100 DO + IF i MOD 15 = 0 THEN + IO.Put("FizzBuzz\n"); + ELSIF i MOD 5 = 0 THEN + IO.Put("Buzz\n"); + ELSIF i MOD 3 = 0 THEN + IO.Put("Fizz\n"); + ELSE + IO.PutInt(i); + IO.Put("\n"); + END; + END; +END Fizzbuzz. diff --git a/Task/Flatten-a-list/0DESCRIPTION b/Task/Flatten-a-list/0DESCRIPTION new file mode 100644 index 0000000000..378c856c3d --- /dev/null +++ b/Task/Flatten-a-list/0DESCRIPTION @@ -0,0 +1,6 @@ +Write a function to flatten the nesting in an arbitrary [[wp:List (computing)|list]] of values. Your program should work on the equivalent of this list: + [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +Where the correct result would be the list: + [1, 2, 3, 4, 5, 6, 7, 8] + +C.f. [[Tree traversal]] diff --git a/Task/Flatten-a-list/ACL2/flatten-a-list.acl2 b/Task/Flatten-a-list/ACL2/flatten-a-list.acl2 new file mode 100644 index 0000000000..93e7f6c74c --- /dev/null +++ b/Task/Flatten-a-list/ACL2/flatten-a-list.acl2 @@ -0,0 +1,5 @@ +(defun flatten (tr) + (cond ((null tr) nil) + ((atom tr) (list tr)) + (t (append (flatten (first tr)) + (flatten (rest tr)))))) diff --git a/Task/Flatten-a-list/ALGOL-68/flatten-a-list.alg b/Task/Flatten-a-list/ALGOL-68/flatten-a-list.alg new file mode 100644 index 0000000000..974c56e757 --- /dev/null +++ b/Task/Flatten-a-list/ALGOL-68/flatten-a-list.alg @@ -0,0 +1,4 @@ +main:( + [][][]INT list = ((1), 2, ((3,4), 5), ((())), (((6))), 7, 8, ()); + print((list, new line)) +) diff --git a/Task/Flatten-a-list/ActionScript/flatten-a-list.as b/Task/Flatten-a-list/ActionScript/flatten-a-list.as new file mode 100644 index 0000000000..b4f1f6be97 --- /dev/null +++ b/Task/Flatten-a-list/ActionScript/flatten-a-list.as @@ -0,0 +1,13 @@ +function flatten(input:Array):Array { + var output:Array = new Array(); + for (var i:uint = 0; i < input.length; i++) { + //typeof returns "object" when applied to arrays. This line recursively evaluates nested arrays, + // although it may break if the array contains objects that are not arrays. + if (typeof input[i]=="object") { + output=output.concat(flatten(input[i])); + } else { + output.push(input[i]); + } + } + return output; +} diff --git a/Task/Flatten-a-list/Aikido/flatten-a-list.aikido b/Task/Flatten-a-list/Aikido/flatten-a-list.aikido new file mode 100644 index 0000000000..2bb0737b9c --- /dev/null +++ b/Task/Flatten-a-list/Aikido/flatten-a-list.aikido @@ -0,0 +1,22 @@ +function flatten (list, result) { + foreach item list { + if (typeof(item) == "vector") { + flatten (item, result) + } else { + result.append (item) + } + } +} + +var l = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +var newl = [] +flatten (l, newl) + +// print out the nicely formatted result list +print ('[') +var comma = "" +foreach item newl { + print (comma + item) + comma = ", " +} +println("]") diff --git a/Task/Flatten-a-list/AppleScript/flatten-a-list.applescript b/Task/Flatten-a-list/AppleScript/flatten-a-list.applescript new file mode 100644 index 0000000000..723b212c25 --- /dev/null +++ b/Task/Flatten-a-list/AppleScript/flatten-a-list.applescript @@ -0,0 +1,11 @@ +my_flatten({{1}, 2, {{3, 4}, 5}, {{{}}}, {{{6}}}, 7, 8, {}}) + +on my_flatten(aList) + if class of aList is not list then + return {aList} + else if length of aList is 0 then + return aList + else + return my_flatten(first item of aList) & (my_flatten(rest of aList)) + end if +end my_flatten diff --git a/Task/Flatten-a-list/AutoHotkey/flatten-a-list.ahk b/Task/Flatten-a-list/AutoHotkey/flatten-a-list.ahk new file mode 100644 index 0000000000..c86825ff9a --- /dev/null +++ b/Task/Flatten-a-list/AutoHotkey/flatten-a-list.ahk @@ -0,0 +1,52 @@ +list := object(1, object(1, 1), 2, 2, 3, object(1, object(1, 3, 2, 4) +, 2, 5), 4, object(1, object(1, object(1, object()))), 5 +, object(1, object(1, 6)), 6, 7, 7, 8, 9, object()) +msgbox % objPrint(list) ; (( 1 ) 2 (( 3 4 ) 5 )(((())))(( 6 )) 7 8 ()) +msgbox % objPrint(objFlatten(list)) ; ( 1 2 3 4 5 6 7 8 ) +return + +!r::reload +!q::exitapp + +objPrint(ast, reserved=0) +{ + if !isobject(ast) + return " " ast " " + + if !reserved + reserved := object("seen" . &ast, 1) ; to keep track of unique objects within top object + + enum := ast._newenum() + while enum[key, value] + { + if reserved["seen" . &value] + continue ; don't copy repeat objects (circular references) +; string .= key . ": " . objPrint(value, reserved) + string .= objPrint(value, reserved) + } + return "(" string ")" +} + + +objFlatten(ast) +{ + if !isobject(ast) + return ast + + flat := object() ; flat object + + enum := ast._newenum() + while enum[key, value] + { + if !isobject(value) + flat._Insert(value) + else + { + next := objFlatten(value) + loop % next._MaxIndex() + flat._Insert(next[A_Index]) + + } + } + return flat +} diff --git a/Task/Flatten-a-list/Bracmat/flatten-a-list.bracmat b/Task/Flatten-a-list/Bracmat/flatten-a-list.bracmat new file mode 100644 index 0000000000..bec60e0c93 --- /dev/null +++ b/Task/Flatten-a-list/Bracmat/flatten-a-list.bracmat @@ -0,0 +1,7 @@ +( (myList = ((1), 2, ((3,4), 5), ((())), (((6))), 7, 8, ())) +& put$("Unevaluated:") +& lst$myList +& !myList:?myList { the expression !list evaluates myList } +& put$("Flattened:") +& lst$myList +) diff --git a/Task/Flatten-a-list/Brat/flatten-a-list.brat b/Task/Flatten-a-list/Brat/flatten-a-list.brat new file mode 100644 index 0000000000..a3cc8a5c08 --- /dev/null +++ b/Task/Flatten-a-list/Brat/flatten-a-list.brat @@ -0,0 +1,12 @@ +array.prototype.flatten = { + true? my.empty? + { [] } + { true? my.first.array? + { my.first.flatten + my.rest.flatten } + { [my.first] + my.rest.flatten } + } +} + +list = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +p "List: #{list}" +p "Flattened: #{list.flatten}" diff --git a/Task/Flatten-a-list/Burlesque/flatten-a-list.blq b/Task/Flatten-a-list/Burlesque/flatten-a-list.blq new file mode 100644 index 0000000000..0d582fdca5 --- /dev/null +++ b/Task/Flatten-a-list/Burlesque/flatten-a-list.blq @@ -0,0 +1,2 @@ +blsq ) {{1} 2 {{3 4} 5} {{{}}} {{{6}}} 7 8 {}}{\[}{)to{"Block"==}ay}w! +{1 2 3 4 5 6 7 8} diff --git a/Task/Flatten-a-list/C++/flatten-a-list-1.cpp b/Task/Flatten-a-list/C++/flatten-a-list-1.cpp new file mode 100644 index 0000000000..ac627be93d --- /dev/null +++ b/Task/Flatten-a-list/C++/flatten-a-list-1.cpp @@ -0,0 +1,23 @@ +#include +#include + +typedef std::list anylist; + +void flatten(std::list& list) +{ + typedef anylist::iterator iterator; + + iterator current = list.begin(); + while (current != list.end()) + { + if (current->type() == typeid(anylist)) + { + iterator next = current; + ++next; + list.splice(next, boost::any_cast(*current)); + current = list.erase(current); + } + else + ++current; + } +} diff --git a/Task/Flatten-a-list/C++/flatten-a-list-2.cpp b/Task/Flatten-a-list/C++/flatten-a-list-2.cpp new file mode 100644 index 0000000000..d6b1193291 --- /dev/null +++ b/Task/Flatten-a-list/C++/flatten-a-list-2.cpp @@ -0,0 +1,104 @@ +#include +#include + +// ******************* +// * the list parser * +// ******************* + +void skipwhite(char const** s) +{ + while (**s && std::isspace((unsigned char)**s)) + { + ++*s; + } +} + +anylist create_anylist_i(char const** s) +{ + anylist result; + skipwhite(s); + if (**s != '[') + throw "Not a list"; + ++*s; + while (true) + { + skipwhite(s); + if (!**s) + throw "Error"; + else if (**s == ']') + { + ++*s; + return result; + } + else if (**s == '[') + result.push_back(create_anylist_i(s)); + else if (std::isdigit((unsigned char)**s)) + { + int i = 0; + while (std::isdigit((unsigned char)**s)) + { + i = 10*i + (**s - '0'); + ++*s; + } + result.push_back(i); + } + else + throw "Error"; + + skipwhite(s); + if (**s != ',' && **s != ']') + throw "Error"; + if (**s == ',') + ++*s; + } +} + +anylist create_anylist(char const* i) +{ + return create_anylist_i(&i); +} + +// ************************* +// * printing nested lists * +// ************************* + +void print_list(anylist const& list); + +void print_item(boost::any const& a) +{ + if (a.type() == typeid(int)) + std::cout << boost::any_cast(a); + else if (a.type() == typeid(anylist)) + print_list(boost::any_cast(a)); + else + std::cout << "???"; +} + +void print_list(anylist const& list) +{ + std::cout << '['; + anylist::const_iterator iter = list.begin(); + while (iter != list.end()) + { + print_item(*iter); + ++iter; + if (iter != list.end()) + std::cout << ", "; + } + std::cout << ']'; +} + +// *************************** +// * The actual test program * +// *************************** + +int main() +{ + anylist list = + create_anylist("[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]"); + print_list(list); + std::cout << "\n"; + flatten(list); + print_list(list); + std::cout << "\n"; +} diff --git a/Task/Flatten-a-list/C/flatten-a-list.c b/Task/Flatten-a-list/C/flatten-a-list.c new file mode 100644 index 0000000000..259c38ef05 --- /dev/null +++ b/Task/Flatten-a-list/C/flatten-a-list.c @@ -0,0 +1,118 @@ +#include +#include +#include + +typedef struct list_t list_t, *list; +struct list_t{ + int is_list, ival; /* ival is either the integer value or list length */ + list *lst; +}; + +list new_list() +{ + list x = malloc(sizeof(list_t)); + x->ival = 0; + x->is_list = 1; + x->lst = 0; + return x; +} + +void append(list parent, list child) +{ + parent->lst = realloc(parent->lst, sizeof(list) * (parent->ival + 1)); + parent->lst[parent->ival++] = child; +} + +list from_string(char *s, char **e, list parent) +{ + list ret = 0; + if (!parent) parent = new_list(); + + while (*s != '\0') { + if (*s == ']') { + if (e) *e = s + 1; + return parent; + } + if (*s == '[') { + ret = new_list(); + ret->is_list = 1; + ret->ival = 0; + append(parent, ret); + from_string(s + 1, &s, ret); + continue; + } + if (*s >= '0' && *s <= '9') { + ret = new_list(); + ret->is_list = 0; + ret->ival = strtol(s, &s, 10); + append(parent, ret); + continue; + } + s++; + } + + if (e) *e = s; + return parent; +} + +void show_list(list l) +{ + int i; + if (!l) return; + if (!l->is_list) { + printf("%d", l->ival); + return; + } + + printf("["); + for (i = 0; i < l->ival; i++) { + show_list(l->lst[i]); + if (i < l->ival - 1) printf(", "); + } + printf("]"); +} + +list flatten(list from, list to) +{ + int i; + list t; + + if (!to) to = new_list(); + if (!from->is_list) { + t = new_list(); + *t = *from; + append(to, t); + } else + for (i = 0; i < from->ival; i++) + flatten(from->lst[i], to); + return to; +} + +void delete_list(list l) +{ + int i; + if (!l) return; + if (l->is_list && l->ival) { + for (i = 0; i < l->ival; i++) + delete_list(l->lst[i]); + free(l->lst); + } + + free(l); +} + +int main() +{ + list l = from_string("[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []", 0, 0); + + printf("Nested: "); + show_list(l); + printf("\n"); + + list flat = flatten(l, 0); + printf("Flattened: "); + show_list(flat); + + /* delete_list(l); delete_list(flat); */ + return 0; +} diff --git a/Task/Flatten-a-list/Clojure/flatten-a-list-1.clj b/Task/Flatten-a-list/Clojure/flatten-a-list-1.clj new file mode 100644 index 0000000000..608bc9f0a9 --- /dev/null +++ b/Task/Flatten-a-list/Clojure/flatten-a-list-1.clj @@ -0,0 +1,6 @@ +(defn flatten [coll] + (lazy-seq + (when-let [s (seq coll)] + (if (coll? (first s)) + (concat (flatten (first s)) (flatten (rest s))) + (cons (first s) (flatten (rest s))))))) diff --git a/Task/Flatten-a-list/Clojure/flatten-a-list-2.clj b/Task/Flatten-a-list/Clojure/flatten-a-list-2.clj new file mode 100644 index 0000000000..b86a3956b4 --- /dev/null +++ b/Task/Flatten-a-list/Clojure/flatten-a-list-2.clj @@ -0,0 +1,3 @@ +(defn flatten [x] + (filter (complement sequential?) + (rest (tree-seq sequential? seq x)))) diff --git a/Task/Flatten-a-list/CoffeeScript/flatten-a-list-1.coffee b/Task/Flatten-a-list/CoffeeScript/flatten-a-list-1.coffee new file mode 100644 index 0000000000..bc346d1714 --- /dev/null +++ b/Task/Flatten-a-list/CoffeeScript/flatten-a-list-1.coffee @@ -0,0 +1,10 @@ +flatten = (arr) -> + arr.reduce ((xs, el) -> + if Array.isArray el + xs.concat flatten el + else + xs.concat [el]), [] + +# test +list = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +console.log flatten list diff --git a/Task/Flatten-a-list/CoffeeScript/flatten-a-list-2.coffee b/Task/Flatten-a-list/CoffeeScript/flatten-a-list-2.coffee new file mode 100644 index 0000000000..5fbe78f991 --- /dev/null +++ b/Task/Flatten-a-list/CoffeeScript/flatten-a-list-2.coffee @@ -0,0 +1,2 @@ +> coffee foo.coffee +[ 1, 2, 3, 4, 5, 6, 7, 8 ] diff --git a/Task/Flatten-a-list/Common-Lisp/flatten-a-list.lisp b/Task/Flatten-a-list/Common-Lisp/flatten-a-list.lisp new file mode 100644 index 0000000000..70be5aee45 --- /dev/null +++ b/Task/Flatten-a-list/Common-Lisp/flatten-a-list.lisp @@ -0,0 +1,4 @@ +(defun flatten (structure) + (cond ((null structure) nil) + ((atom structure) `(,structure)) + (t (mapcan #'flatten structure)))) diff --git a/Task/Flatten-a-list/D/flatten-a-list-1.d b/Task/Flatten-a-list/D/flatten-a-list-1.d new file mode 100644 index 0000000000..fa2e7813c4 --- /dev/null +++ b/Task/Flatten-a-list/D/flatten-a-list-1.d @@ -0,0 +1,43 @@ +import std.stdio, std.algorithm, std.conv, std.range; + +struct TreeList(T) { + union { // A tagged union + TreeList[] arr; // it's a node + T data; // it's a leaf + } + bool isArray = true; // = contains an arr on default. + + static TreeList opCall(A...)(A items) /*const*/ pure nothrow { + TreeList result; + + foreach (i, el; items) + static if (is(A[i] == T)) { + TreeList item; + item.isArray = false; + item.data = el; + result.arr ~= item; + } else + result.arr ~= el; + + return result; + } + + string toString() const { + return isArray ? text(arr) : text(data); + } +} + +T[] flatten(T)(in TreeList!T t) /*pure nothrow*/ { + if (t.isArray) + return t.arr.map!flatten().join(); + else + return [t.data]; +} + +void main() { + alias TreeList!int L; + static assert(L.sizeof == 12); + auto l = L(L(1), 2, L(L(3,4), 5), L(L(L())), L(L(L(6))),7,8,L()); + writeln(l); + writeln(flatten(l)); +} diff --git a/Task/Flatten-a-list/D/flatten-a-list-2.d b/Task/Flatten-a-list/D/flatten-a-list-2.d new file mode 100644 index 0000000000..28b6550a65 --- /dev/null +++ b/Task/Flatten-a-list/D/flatten-a-list-2.d @@ -0,0 +1,19 @@ +import std.stdio, std.variant, std.range, std.algorithm; + +alias T = Algebraic!(int, This[]); + +int[] flatten(T t) { + return t.peek!int ? [t.get!int] : t.get!(T[])().map!flatten.join; +} + +void main() { + T([T([ T(1) ]), + T(2), + T([ T([ T(3), T(4) ]), T(5) ]), + T([ T([ T( T[].init ) ]) ]), + T([ T([ T([ T(6) ]) ]) ]), + T(7), + T(8), + T( T[].init ) + ]).flatten.writeln; +} diff --git a/Task/Flatten-a-list/E/flatten-a-list-1.e b/Task/Flatten-a-list/E/flatten-a-list-1.e new file mode 100644 index 0000000000..3b23281b92 --- /dev/null +++ b/Task/Flatten-a-list/E/flatten-a-list-1.e @@ -0,0 +1,11 @@ +def flatten(nested) { + def flat := [].diverge() + def recur(x) { + switch (x) { + match list :List { for elem in list { recur(elem) } } + match other { flat.push(other) } + } + } + recur(nested) + return flat.snapshot() +} diff --git a/Task/Flatten-a-list/E/flatten-a-list-2.e b/Task/Flatten-a-list/E/flatten-a-list-2.e new file mode 100644 index 0000000000..613957be78 --- /dev/null +++ b/Task/Flatten-a-list/E/flatten-a-list-2.e @@ -0,0 +1,2 @@ +? flatten([[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]) +# value: [1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/Ela/flatten-a-list-1.ela b/Task/Flatten-a-list/Ela/flatten-a-list-1.ela new file mode 100644 index 0000000000..48c0d2c6f3 --- /dev/null +++ b/Task/Flatten-a-list/Ela/flatten-a-list-1.ela @@ -0,0 +1,9 @@ +xs = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] + +flat = flat' [] + where flat' n [] = n + flat' n (x::xs) + | x is List = flat' (flat' n xs) x + | else = x :: flat' n xs + +flat xs diff --git a/Task/Flatten-a-list/Ela/flatten-a-list-2.ela b/Task/Flatten-a-list/Ela/flatten-a-list-2.ela new file mode 100644 index 0000000000..7a800ba6fa --- /dev/null +++ b/Task/Flatten-a-list/Ela/flatten-a-list-2.ela @@ -0,0 +1,4 @@ +flat [] = [] +flat (x::xs) + | x is List = flat x ++ flat xs + | else = x :: flat xs diff --git a/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l new file mode 100644 index 0000000000..ce5691a9a9 --- /dev/null +++ b/Task/Flatten-a-list/Emacs-Lisp/flatten-a-list.l @@ -0,0 +1,6 @@ +(defun flatten (mylist) + (cond + ((null mylist) nil) + ((atom mylist) (list mylist)) + (t + (append (flatten (car mylist)) (flatten (cdr mylist)))))) diff --git a/Task/Flatten-a-list/Erlang/flatten-a-list.erl b/Task/Flatten-a-list/Erlang/flatten-a-list.erl new file mode 100644 index 0000000000..ec7e0eb8f6 --- /dev/null +++ b/Task/Flatten-a-list/Erlang/flatten-a-list.erl @@ -0,0 +1,3 @@ +flatten([]) -> []; +flatten([H|T]) -> flatten(H) ++ flatten(T); +flatten(H) -> [H]. diff --git a/Task/Flatten-a-list/Euphoria/flatten-a-list.euphoria b/Task/Flatten-a-list/Euphoria/flatten-a-list.euphoria new file mode 100644 index 0000000000..983fdfbf09 --- /dev/null +++ b/Task/Flatten-a-list/Euphoria/flatten-a-list.euphoria @@ -0,0 +1,21 @@ +sequence a = {{1}, 2, {{3, 4}, 5}, {{{}}}, {{{6}}}, 7, 8, {}} + +function flatten( object s ) + sequence res = {} + if sequence( s ) then + for i = 1 to length( s ) do + sequence c = flatten( s[ i ] ) + if length( c ) > 0 then + res &= c + end if + end for + else + if length( s ) > 0 then + res = { s } + end if + end if + return res +end function + +? a +? flatten(a) diff --git a/Task/Flatten-a-list/Fantom/flatten-a-list.fantom b/Task/Flatten-a-list/Fantom/flatten-a-list.fantom new file mode 100644 index 0000000000..101fae7d98 --- /dev/null +++ b/Task/Flatten-a-list/Fantom/flatten-a-list.fantom @@ -0,0 +1,25 @@ +class Main +{ + // uses recursion to flatten a list + static List myflatten (List items) + { + List result := [,] + items.each |item| + { + if (item is List) + result.addAll (myflatten(item)) + else + result.add (item) + } + return result + } + + public static Void main () + { + List sample := [[1], 2, [[3,4], 5], [[[,]]], [[[6]]], 7, 8, [,]] + // there is a built-in flatten method for lists + echo ("Flattened list 1: " + sample.flatten) + // or use the function 'myflatten' + echo ("Flattened list 2: " + myflatten (sample)) + } +} diff --git a/Task/Flatten-a-list/Frink/flatten-a-list.frink b/Task/Flatten-a-list/Frink/flatten-a-list.frink new file mode 100644 index 0000000000..24eb40ad74 --- /dev/null +++ b/Task/Flatten-a-list/Frink/flatten-a-list.frink @@ -0,0 +1,2 @@ +a = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +println[flatten[a]] diff --git a/Task/Flatten-a-list/GAP/flatten-a-list.gap b/Task/Flatten-a-list/GAP/flatten-a-list.gap new file mode 100644 index 0000000000..ec0f219e77 --- /dev/null +++ b/Task/Flatten-a-list/GAP/flatten-a-list.gap @@ -0,0 +1 @@ +Flat([[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]); diff --git a/Task/Flatten-a-list/Go/flatten-a-list-1.go b/Task/Flatten-a-list/Go/flatten-a-list-1.go new file mode 100644 index 0000000000..bf3e4c4cc8 --- /dev/null +++ b/Task/Flatten-a-list/Go/flatten-a-list-1.go @@ -0,0 +1,33 @@ +package main + +import "fmt" + +func list(s ...interface{}) []interface{} { + return s +} + +func main() { + s := list(list(1), + 2, + list(list(3, 4), 5), + list(list(list())), + list(list(list(6))), + 7, + 8, + list(), + ) + fmt.Println(s) + fmt.Println(flatten(s)) +} + +func flatten(s []interface{}) (r []int) { + for _, e := range s { + switch i := e.(type) { + case int: + r = append(r, i) + case []interface{}: + r = append(r, flatten(i)...) + } + } + return +} diff --git a/Task/Flatten-a-list/Go/flatten-a-list-2.go b/Task/Flatten-a-list/Go/flatten-a-list-2.go new file mode 100644 index 0000000000..6d4545d8f9 --- /dev/null +++ b/Task/Flatten-a-list/Go/flatten-a-list-2.go @@ -0,0 +1,10 @@ +func flatten(s []interface{}) (r []interface{}) { + for _, e := range s { + if i, ok := e.([]interface{}); ok { + r = append(r, flatten(i)...) + } else { + r = append(r, e) + } + } + return +} diff --git a/Task/Flatten-a-list/Groovy/flatten-a-list.groovy b/Task/Flatten-a-list/Groovy/flatten-a-list.groovy new file mode 100644 index 0000000000..22dd8f3660 --- /dev/null +++ b/Task/Flatten-a-list/Groovy/flatten-a-list.groovy @@ -0,0 +1 @@ +assert [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []].flatten() == [1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/Haskell/flatten-a-list-1.hs b/Task/Flatten-a-list/Haskell/flatten-a-list-1.hs new file mode 100644 index 0000000000..ae17e9286b --- /dev/null +++ b/Task/Flatten-a-list/Haskell/flatten-a-list-1.hs @@ -0,0 +1,24 @@ +import Data.Tree + +-- [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +-- implemented as multiway tree: + +-- Data.Tree represents trees where nodes have values too, unlike the trees in our problem. +-- so we use a list as that value, where a node will have an empty list value, +-- and a leaf will have a one-element list value and no subtrees +list :: Tree [Int] +list = Node [] [ + Node [] [Node [1] []], + Node [2] [], + Node [] [ + Node [] [ Node [3] [],Node [4] []], + Node [5] [] + ], + Node [] [Node [] [Node [] []]], + Node [] [Node [] [Node [6] []]], + Node [7] [], + Node [8] [], + Node [] [] + ] + +flattenList = concat.flatten diff --git a/Task/Flatten-a-list/Haskell/flatten-a-list-2.hs b/Task/Flatten-a-list/Haskell/flatten-a-list-2.hs new file mode 100644 index 0000000000..a46d4fba81 --- /dev/null +++ b/Task/Flatten-a-list/Haskell/flatten-a-list-2.hs @@ -0,0 +1,16 @@ +data Tree a = Leaf a | Node [Tree a] + +flatten :: Tree a -> [a] +flatten (Leaf x) = [x] +flatten (Node xs) = concatMap flatten xs + +main = print $ flatten $ Node [Node [Leaf 1], + Leaf 2, + Node [Node [Leaf 3, Leaf 4], Leaf 5], + Node [Node [Node []]], + Node [Node [Node [Leaf 6]]], + Leaf 7, + Leaf 8, + Node []] + +-- output: [1,2,3,4,5,6,7,8] diff --git a/Task/Flatten-a-list/Haskell/flatten-a-list-3.hs b/Task/Flatten-a-list/Haskell/flatten-a-list-3.hs new file mode 100644 index 0000000000..f418c4d075 --- /dev/null +++ b/Task/Flatten-a-list/Haskell/flatten-a-list-3.hs @@ -0,0 +1,17 @@ +data NestedList a = NList [NestedList a] | Entry a + +flatten :: NestedList a -> [a] +flatten nl = flatten' nl [] + where + -- By passing through a list which the results will be preprended to we allow efficient lazy evaluation + flatten' :: NestedList a -> [a] -> [a] + flatten' (Entry a) cont = a:cont + flatten' (NList entries) cont = foldr flatten' cont entries + +example :: NestedList Int +example = NList [ NList [Entry 1], Entry 2, NList [NList [Entry 3, Entry 4], Entry 5], NList [NList [NList []]], NList [ NList [ NList [Entry 6]]], Entry 7, Entry 8, NList []] + +main :: IO () +main = print $ flatten example + +-- output [1,2,3,4,5,6,7,8] diff --git a/Task/Flatten-a-list/Icon/flatten-a-list-1.icon b/Task/Flatten-a-list/Icon/flatten-a-list-1.icon new file mode 100644 index 0000000000..bdd544621b --- /dev/null +++ b/Task/Flatten-a-list/Icon/flatten-a-list-1.icon @@ -0,0 +1,5 @@ +link strings # for compress,deletec,pretrim + +procedure sflatten(s) # uninteresting string solution +return pretrim(trim(compress(deletec(s,'[ ]'),',') ,','),',') +end diff --git a/Task/Flatten-a-list/Icon/flatten-a-list-2.icon b/Task/Flatten-a-list/Icon/flatten-a-list-2.icon new file mode 100644 index 0000000000..f0df077775 --- /dev/null +++ b/Task/Flatten-a-list/Icon/flatten-a-list-2.icon @@ -0,0 +1,9 @@ +procedure flatten(L) # in the spirt of the problem a structure +local l,x + +l := [] +every x := !L do + if type(x) == "list" then l |||:= flatten(x) + else put(l,x) +return l +end diff --git a/Task/Flatten-a-list/Icon/flatten-a-list-3.icon b/Task/Flatten-a-list/Icon/flatten-a-list-3.icon new file mode 100644 index 0000000000..e26ff33d3c --- /dev/null +++ b/Task/Flatten-a-list/Icon/flatten-a-list-3.icon @@ -0,0 +1,11 @@ +procedure main() +write(sflatten(" [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]")) +writelist(flatten( [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []])) +end + +procedure writelist(L) +writes("[") +every writes(" ",image(!L)) +write(" ]") +return +end diff --git a/Task/Flatten-a-list/Ioke/flatten-a-list.ioke b/Task/Flatten-a-list/Ioke/flatten-a-list.ioke new file mode 100644 index 0000000000..8aeb7a84a7 --- /dev/null +++ b/Task/Flatten-a-list/Ioke/flatten-a-list.ioke @@ -0,0 +1,3 @@ +iik> [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] flatten +[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] flatten ++> [1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/J/flatten-a-list-1.j b/Task/Flatten-a-list/J/flatten-a-list-1.j new file mode 100644 index 0000000000..673d98eabd --- /dev/null +++ b/Task/Flatten-a-list/J/flatten-a-list-1.j @@ -0,0 +1 @@ +flatten =: [: ; flatten(List list) { + List retVal = new LinkedList(); + flatten(list, retVal); + return retVal; + } + + public static void flatten(List fromTreeList, List toFlatList) { + for (Object item : fromTreeList) { + if (item instanceof List) { + flatten((List) item, toFlatList); + } else { + toFlatList.add(item); + } + } + } +} diff --git a/Task/Flatten-a-list/Java/flatten-a-list-2.java b/Task/Flatten-a-list/Java/flatten-a-list-2.java new file mode 100644 index 0000000000..a4eca7171e --- /dev/null +++ b/Task/Flatten-a-list/Java/flatten-a-list-2.java @@ -0,0 +1,16 @@ +import static java.util.Arrays.asList; +import java.util.List; + +public final class FlattenTestMain { + + public static void main(String[] args) { + List treeList = a(a(1), 2, a(a(3, 4), 5), a(a(a())), a(a(a(6))), 7, 8, a()); + List flatList = FlattenUtil.flatten(treeList); + System.out.println(treeList); + System.out.println("flatten: " + flatList); + } + + private static List a(Object... a) { + return asList(a); + } +} diff --git a/Task/Flatten-a-list/JavaScript/flatten-a-list.js b/Task/Flatten-a-list/JavaScript/flatten-a-list.js new file mode 100644 index 0000000000..f8702dcc52 --- /dev/null +++ b/Task/Flatten-a-list/JavaScript/flatten-a-list.js @@ -0,0 +1,5 @@ +function flatten(arr){ + return arr.reduce(function(acc, val){ + return acc.concat(val.constructor === Array ? flatten(val) : val); + },[]); +} diff --git a/Task/Flatten-a-list/Julia/flatten-a-list.julia b/Task/Flatten-a-list/Julia/flatten-a-list.julia new file mode 100644 index 0000000000..5d423fde4b --- /dev/null +++ b/Task/Flatten-a-list/Julia/flatten-a-list.julia @@ -0,0 +1,10 @@ +julia> t = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +8-element Int32 Array: + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 diff --git a/Task/Flatten-a-list/K/flatten-a-list.k b/Task/Flatten-a-list/K/flatten-a-list.k new file mode 100644 index 0000000000..92cbdf1e4c --- /dev/null +++ b/Task/Flatten-a-list/K/flatten-a-list.k @@ -0,0 +1 @@ +,//((1); 2; ((3;4); 5); ((())); (((6))); 7; 8; ()) diff --git a/Task/Flatten-a-list/Logo/flatten-a-list.logo b/Task/Flatten-a-list/Logo/flatten-a-list.logo new file mode 100644 index 0000000000..450434338f --- /dev/null +++ b/Task/Flatten-a-list/Logo/flatten-a-list.logo @@ -0,0 +1,13 @@ +to flatten :l + if not list? :l [output :l] + if empty? :l [output []] + output sentence flatten first :l flatten butfirst :l +end + +; using a template iterator (map combining results into a sentence) +to flatten :l + output map.se [ifelse or not list? ? empty? ? [?] [flatten ?]] :l +end + +make "a [[1] 2 [[3 4] 5] [[[]]] [[[6]]] 7 8 []] +show flatten :a diff --git a/Task/Flatten-a-list/Logtalk/flatten-a-list.logtalk b/Task/Flatten-a-list/Logtalk/flatten-a-list.logtalk new file mode 100644 index 0000000000..808f10babc --- /dev/null +++ b/Task/Flatten-a-list/Logtalk/flatten-a-list.logtalk @@ -0,0 +1,13 @@ +flatten(List, Flatted) :- + flatten(List, [], Flatted). + +flatten(Var, Tail, [Var| Tail]) :- + var(Var), + !. +flatten([], Flatted, Flatted) :- + !. +flatten([Head| Tail], List, Flatted) :- + !, + flatten(Tail, List, Aux), + flatten(Head, Aux, Flatted). +flatten(Head, Tail, [Head| Tail]). diff --git a/Task/Flatten-a-list/Lua/flatten-a-list.lua b/Task/Flatten-a-list/Lua/flatten-a-list.lua new file mode 100644 index 0000000000..b3d93de3de --- /dev/null +++ b/Task/Flatten-a-list/Lua/flatten-a-list.lua @@ -0,0 +1,14 @@ +function flatten(list) + if type(list) ~= "table" then return {list} end + local flat_list = {} + for _, elem in ipairs(list) do + for _, val in ipairs(flatten(elem)) do + flat_list[#flat_list + 1] = val + end + end + return flat_list +end + +test_list = {{1}, 2, {{3,4}, 5}, {{{}}}, {{{6}}}, 7, 8, {}} + +print(table.concat(flatten(test_list), ",")) diff --git a/Task/Flatten-a-list/Mathematica/flatten-a-list.mathematica b/Task/Flatten-a-list/Mathematica/flatten-a-list.mathematica new file mode 100644 index 0000000000..80a99f31b3 --- /dev/null +++ b/Task/Flatten-a-list/Mathematica/flatten-a-list.mathematica @@ -0,0 +1 @@ +Flatten[{{1}, 2, {{3, 4}, 5}, {{{}}}, {{{6}}}, 7, 8, {}}] diff --git a/Task/Flatten-a-list/Maxima/flatten-a-list.maxima b/Task/Flatten-a-list/Maxima/flatten-a-list.maxima new file mode 100644 index 0000000000..5dfeec005e --- /dev/null +++ b/Task/Flatten-a-list/Maxima/flatten-a-list.maxima @@ -0,0 +1,2 @@ +flatten([[[1, 2, 3], 4, [5, [6, 7]], 8], [[9, 10], 11], 12]); +/* [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] */ diff --git a/Task/Flatten-a-list/Mirah/flatten-a-list.mirah b/Task/Flatten-a-list/Mirah/flatten-a-list.mirah new file mode 100644 index 0000000000..66416daf8e --- /dev/null +++ b/Task/Flatten-a-list/Mirah/flatten-a-list.mirah @@ -0,0 +1,24 @@ +import java.util.ArrayList +import java.util.List +import java.util.Collection + +def flatten(list: Collection) + flatten(list, ArrayList.new) +end +def flatten(source: Collection, result: List) + + source.each do |x| + if x.kind_of?(Collection) + flatten(Collection(x), result) + else + result.add(x) + result # if branches must return same type + end + end + result +end + +# creating a list-of-list-of-list fails currently, so constructor calls are needed +source = [[1], 2, [[3, 4], 5], [[ArrayList.new]], [[[6]]], 7, 8, ArrayList.new] + +puts flatten(source) diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-1.php b/Task/Flatten-a-list/PHP/flatten-a-list-1.php new file mode 100644 index 0000000000..06596d9660 --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-1.php @@ -0,0 +1,4 @@ +/* Note: This code is only for PHP 4. + It won't work on PHP 5 due to the change in behavior of array_merge(). */ +while (array_filter($lst, 'is_array')) + $lst = call_user_func_array('array_merge', $lst); diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-2.php b/Task/Flatten-a-list/PHP/flatten-a-list-2.php new file mode 100644 index 0000000000..5c58d5fad4 --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-2.php @@ -0,0 +1,16 @@ + diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-3.php b/Task/Flatten-a-list/PHP/flatten-a-list-3.php new file mode 100644 index 0000000000..4e7f4ccc5e --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-3.php @@ -0,0 +1,10 @@ + diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-4.php b/Task/Flatten-a-list/PHP/flatten-a-list-4.php new file mode 100644 index 0000000000..679c01c13c --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-4.php @@ -0,0 +1,14 @@ +flattened[] = $x; +} + +function flatten($ary) { + $obj = (object)array('flattened' => array()); + array_walk_recursive($ary, 'flatten_helper', $obj); + return $obj->flattened; +} + +$lst = array(array(1), 2, array(array(3, 4), 5), array(array(array())), array(array(array(6))), 7, 8, array()); +var_dump(flatten($lst)); +?> diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-5.php b/Task/Flatten-a-list/PHP/flatten-a-list-5.php new file mode 100644 index 0000000000..39676ca799 --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-5.php @@ -0,0 +1,5 @@ + diff --git a/Task/Flatten-a-list/PHP/flatten-a-list-6.php b/Task/Flatten-a-list/PHP/flatten-a-list-6.php new file mode 100644 index 0000000000..25a6737617 --- /dev/null +++ b/Task/Flatten-a-list/PHP/flatten-a-list-6.php @@ -0,0 +1,13 @@ + diff --git a/Task/Flatten-a-list/Perl/flatten-a-list.pl b/Task/Flatten-a-list/Perl/flatten-a-list.pl new file mode 100644 index 0000000000..ac9e88bb2a --- /dev/null +++ b/Task/Flatten-a-list/Perl/flatten-a-list.pl @@ -0,0 +1,6 @@ +sub flatten { + map { ref eq 'ARRAY' ? flatten(@$_) : $_ } @_ +} + +my @lst = ([1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []); +print flatten(@lst), "\n"; diff --git a/Task/Flatten-a-list/PicoLisp/flatten-a-list-1.l b/Task/Flatten-a-list/PicoLisp/flatten-a-list-1.l new file mode 100644 index 0000000000..232fb0ffac --- /dev/null +++ b/Task/Flatten-a-list/PicoLisp/flatten-a-list-1.l @@ -0,0 +1,6 @@ +(de flatten (X) + (make # Build a list + (recur (X) # recursively over 'X' + (if (atom X) + (link X) # Put atoms into the result + (mapc recurse X) ) ) ) ) # or recurse on sub-lists diff --git a/Task/Flatten-a-list/PicoLisp/flatten-a-list-2.l b/Task/Flatten-a-list/PicoLisp/flatten-a-list-2.l new file mode 100644 index 0000000000..e827764d3d --- /dev/null +++ b/Task/Flatten-a-list/PicoLisp/flatten-a-list-2.l @@ -0,0 +1,2 @@ +(de flatten (X) + (fish atom X) ) diff --git a/Task/Flatten-a-list/Prolog/flatten-a-list.pro b/Task/Flatten-a-list/Prolog/flatten-a-list.pro new file mode 100644 index 0000000000..5d45b54a2a --- /dev/null +++ b/Task/Flatten-a-list/Prolog/flatten-a-list.pro @@ -0,0 +1,11 @@ +flatten(List, FlatList) :- + flatten(List, [], FlatList). + +flatten(Var, T, [Var|T]) :- + var(Var), !. +flatten([], T, T) :- !. +flatten([H|T], TailList, List) :- !, + flatten(H, FlatTail, List), + flatten(T, TailList, FlatTail). + +flatten(NonList, T, [NonList|T]). diff --git a/Task/Flatten-a-list/Python/flatten-a-list-1.py b/Task/Flatten-a-list/Python/flatten-a-list-1.py new file mode 100644 index 0000000000..775c064adc --- /dev/null +++ b/Task/Flatten-a-list/Python/flatten-a-list-1.py @@ -0,0 +1,7 @@ +>>> def flatten(lst): + return sum( ([x] if not isinstance(x, list) else flatten(x) + for x in lst), [] ) + +>>> lst = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +>>> flatten(lst) +[1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/Python/flatten-a-list-2.py b/Task/Flatten-a-list/Python/flatten-a-list-2.py new file mode 100644 index 0000000000..93eb895187 --- /dev/null +++ b/Task/Flatten-a-list/Python/flatten-a-list-2.py @@ -0,0 +1,14 @@ +>>> def flat(lst): + i=0 + while i>> lst = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +>>> flat(lst) +>>> lst +[1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/Python/flatten-a-list-3.py b/Task/Flatten-a-list/Python/flatten-a-list-3.py new file mode 100644 index 0000000000..b1e465991b --- /dev/null +++ b/Task/Flatten-a-list/Python/flatten-a-list-3.py @@ -0,0 +1,12 @@ +>>> def flatten(lst): + for x in lst: + if isinstance(x, list): + for x in flatten(x): + yield x + else: + yield x + + +>>>lst = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []] +>>>print list(flatten(lst)) +[1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/R/flatten-a-list.r b/Task/Flatten-a-list/R/flatten-a-list.r new file mode 100644 index 0000000000..67e949c177 --- /dev/null +++ b/Task/Flatten-a-list/R/flatten-a-list.r @@ -0,0 +1,3 @@ +x <- list(list(1), 2, list(list(3, 4), 5), list(list(list())), list(list(list(6))), 7, 8, list()) + +unlist(x) diff --git a/Task/Flatten-a-list/REXX/flatten-a-list-1.rexx b/Task/Flatten-a-list/REXX/flatten-a-list-1.rexx new file mode 100644 index 0000000000..53ab977b1a --- /dev/null +++ b/Task/Flatten-a-list/REXX/flatten-a-list-1.rexx @@ -0,0 +1,9 @@ +/*REXX program to demonstrate how to flatten a list. */ + +y = '[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]' + +z = '['changestr(' ',space(translate(y,,'[,]')),", ")']' + +say ' input =' y +say 'output =' z + /*stick a fork in it, we're done.*/ diff --git a/Task/Flatten-a-list/REXX/flatten-a-list-2.rexx b/Task/Flatten-a-list/REXX/flatten-a-list-2.rexx new file mode 100644 index 0000000000..659f1b7c5d --- /dev/null +++ b/Task/Flatten-a-list/REXX/flatten-a-list-2.rexx @@ -0,0 +1,12 @@ +/*REXX program to demonstrate how to flatten a list. */ + +y = '[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]' + +z=translate(y,,'[,]') /*change brackets & commas to blanks*/ +z=space(z) /*remove extraneous blanks*/ +z=changestr(' ',z,", ") /*change blanks to "comma blank"*/ +z='['z"]" /*add brackets*/ + +say ' input =' y +say 'output =' z + /*stick a fork in it, we're done.*/ diff --git a/Task/Flatten-a-list/Racket/flatten-a-list-1.rkt b/Task/Flatten-a-list/Racket/flatten-a-list-1.rkt new file mode 100644 index 0000000000..bf3d12f785 --- /dev/null +++ b/Task/Flatten-a-list/Racket/flatten-a-list-1.rkt @@ -0,0 +1,2 @@ +#lang racket +(flatten '(1 (2 (3 4 5) (6 7)) 8 9)) diff --git a/Task/Flatten-a-list/Racket/flatten-a-list-2.rkt b/Task/Flatten-a-list/Racket/flatten-a-list-2.rkt new file mode 100644 index 0000000000..2cc794db1d --- /dev/null +++ b/Task/Flatten-a-list/Racket/flatten-a-list-2.rkt @@ -0,0 +1 @@ +'(1 2 3 4 5 6 7 8 9) diff --git a/Task/Flatten-a-list/Racket/flatten-a-list-3.rkt b/Task/Flatten-a-list/Racket/flatten-a-list-3.rkt new file mode 100644 index 0000000000..23d561f717 --- /dev/null +++ b/Task/Flatten-a-list/Racket/flatten-a-list-3.rkt @@ -0,0 +1,6 @@ +#lang racket +(define (flatten l) + (cond [(empty? l) null] + [(not (list? l)) (list l)] + [else (append (flatten (first l)) (flatten (rest l)))])) +(flatten '(1 (2 (3 4 5) (6 7)) 8 9)) diff --git a/Task/Flatten-a-list/Ruby/flatten-a-list.rb b/Task/Flatten-a-list/Ruby/flatten-a-list.rb new file mode 100644 index 0000000000..6049f443b3 --- /dev/null +++ b/Task/Flatten-a-list/Ruby/flatten-a-list.rb @@ -0,0 +1,2 @@ +flat = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []].flatten +p flat # => [1, 2, 3, 4, 5, 6, 7, 8] diff --git a/Task/Flatten-a-list/Scala/flatten-a-list.scala b/Task/Flatten-a-list/Scala/flatten-a-list.scala new file mode 100644 index 0000000000..486666c387 --- /dev/null +++ b/Task/Flatten-a-list/Scala/flatten-a-list.scala @@ -0,0 +1,5 @@ +def flatList(l: List[_]): List[Any] = l match { + case Nil => Nil + case (head: List[_]) :: tail => flatList(head) ::: flatList(tail) + case head :: tail => head :: flatList(tail) +} diff --git a/Task/Flatten-a-list/Scheme/flatten-a-list.ss b/Task/Flatten-a-list/Scheme/flatten-a-list.ss new file mode 100644 index 0000000000..0d3bbb32b6 --- /dev/null +++ b/Task/Flatten-a-list/Scheme/flatten-a-list.ss @@ -0,0 +1,8 @@ +> (define (flatten x) + (cond ((null? x) '()) + ((not (pair? x)) (list x)) + (else (append (flatten (car x)) + (flatten (cdr x)))))) + +> (flatten '((1) 2 ((3 4) 5) ((())) (((6))) 7 8 ())) +(1 2 3 4 5 6 7 8) diff --git a/Task/Flatten-a-list/Smalltalk/flatten-a-list.st b/Task/Flatten-a-list/Smalltalk/flatten-a-list.st new file mode 100644 index 0000000000..53be4e7607 --- /dev/null +++ b/Task/Flatten-a-list/Smalltalk/flatten-a-list.st @@ -0,0 +1,22 @@ +OrderedCollection extend [ + flatten [ |f| + f := OrderedCollection new. + self do: [ :i | + i isNumber + ifTrue: [ f add: i ] + ifFalse: [ |t| + t := (OrderedCollection withAll: i) flatten. + f addAll: t + ] + ]. + ^ f + ] +]. + + +|list| +list := OrderedCollection + withAll: { {1} . 2 . { {3 . 4} . 5 } . + {{{}}} . {{{6}}} . 7 . 8 . {} }. + +(list flatten) printNl. diff --git a/Task/Flatten-a-list/Tcl/flatten-a-list-1.tcl b/Task/Flatten-a-list/Tcl/flatten-a-list-1.tcl new file mode 100644 index 0000000000..f97f3a062a --- /dev/null +++ b/Task/Flatten-a-list/Tcl/flatten-a-list-1.tcl @@ -0,0 +1,10 @@ +proc flatten list { + for {set old {}} {$old ne $list} {} { + set old $list + set list [join $list] + } + return $list +} + +puts [flatten {{1} 2 {{3 4} 5} {{{}}} {{{6}}} 7 8 {}}] +# ===> 1 2 3 4 5 6 7 8 diff --git a/Task/Flatten-a-list/Tcl/flatten-a-list-2.tcl b/Task/Flatten-a-list/Tcl/flatten-a-list-2.tcl new file mode 100644 index 0000000000..2e6c73f75f --- /dev/null +++ b/Task/Flatten-a-list/Tcl/flatten-a-list-2.tcl @@ -0,0 +1,6 @@ +proc flatten {data} { + while { $data != [set data [join $data]] } { } + return $data +} +puts [flatten {{1} 2 {{3 4} 5} {{{}}} {{{6}}} 7 8 {}}] +# ===> 1 2 3 4 5 6 7 8 diff --git a/Task/Flow-control-structures/0DESCRIPTION b/Task/Flow-control-structures/0DESCRIPTION new file mode 100644 index 0000000000..fe63203d02 --- /dev/null +++ b/Task/Flow-control-structures/0DESCRIPTION @@ -0,0 +1,2 @@ +{{Control Structures}} +In this task, we document common flow-control structures. One common example of a flow-control structure is the goto construct. Note that [[Conditional Structures]] and [[Iteration|Loop Structures]] have their own articles/categories. diff --git a/Task/Flow-control-structures/1META.yaml b/Task/Flow-control-structures/1META.yaml new file mode 100644 index 0000000000..8af673b2be --- /dev/null +++ b/Task/Flow-control-structures/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Control Structures diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-1.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-1.6502 new file mode 100644 index 0000000000..5df487518f --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-1.6502 @@ -0,0 +1,2 @@ + JMP $8000 ;immediately JuMP to $8000 and begin executing + ;instructions there. diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-2.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-2.6502 new file mode 100644 index 0000000000..9e95ca87f0 --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-2.6502 @@ -0,0 +1,2 @@ + JMP ($8000) ;immediately JuMP to the address in memory locations + ;$8000 and $8001 diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-3.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-3.6502 new file mode 100644 index 0000000000..6c731c4965 --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-3.6502 @@ -0,0 +1 @@ + JSR $8000 ;Jump to SubRoutine diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-4.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-4.6502 new file mode 100644 index 0000000000..7ac93d176e --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-4.6502 @@ -0,0 +1 @@ + RTS ;ReTurn from Subroutine diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-5.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-5.6502 new file mode 100644 index 0000000000..7e921526af --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-5.6502 @@ -0,0 +1 @@ + BRK ;BReaK diff --git a/Task/Flow-control-structures/6502-Assembly/flow-control-structures-6.6502 b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-6.6502 new file mode 100644 index 0000000000..e4396764a3 --- /dev/null +++ b/Task/Flow-control-structures/6502-Assembly/flow-control-structures-6.6502 @@ -0,0 +1 @@ + RTI ;ReTurn from Interrupt diff --git a/Task/Flow-control-structures/ALGOL-68/flow-control-structures-1.alg b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-1.alg new file mode 100644 index 0000000000..8f6476a785 --- /dev/null +++ b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-1.alg @@ -0,0 +1,12 @@ +( + FOR j TO 1000 DO + FOR i TO j-1 DO + IF random > 0.999 THEN + printf(($"Exited when: i="g(0)", j="g(0)l$,i,j)); + done + FI + # etc. # + OD + OD; + done: EMPTY +); diff --git a/Task/Flow-control-structures/ALGOL-68/flow-control-structures-2.alg b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-2.alg new file mode 100644 index 0000000000..298d690978 --- /dev/null +++ b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-2.alg @@ -0,0 +1,12 @@ +STRING medal = ( + []PROC VOID award = (gold,silver,bronze); + + award[ 1 + ENTIER (random*3)]; + + gold: "Gold" EXIT + silver: "Silver" EXIT + bronze: "Bronze" + +); + +print(("Medal awarded: ",medal, new line)); diff --git a/Task/Flow-control-structures/ALGOL-68/flow-control-structures-3.alg b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-3.alg new file mode 100644 index 0000000000..e0b63c3779 --- /dev/null +++ b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-3.alg @@ -0,0 +1,21 @@ +STRING final state = ( + INT condition; + PROC do something = VOID: condition := 1 + ENTIER (3 * random); + + state1: + do something; + CASE condition IN + state 1, state 2 + OUT + state n + ESAC + EXIT + + state 2: + "State Two" + EXIT + + state n: + "State N" +); +print(("Final state: ",final state, new line)); diff --git a/Task/Flow-control-structures/ALGOL-68/flow-control-structures-4.alg b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-4.alg new file mode 100644 index 0000000000..591eac4ed4 --- /dev/null +++ b/Task/Flow-control-structures/ALGOL-68/flow-control-structures-4.alg @@ -0,0 +1,22 @@ +# example from: http://www.xs4all.nl/~jmvdveer/algol.html - GPL # +determine first generation; +WHILE can represent next generation +DO calculate next generation; + print next generation +OD. + +determine first generation: + INT previous := 1, current := 3. + +can represent next generation: + current <= max int - previous. + +calculate next generation: + INT new = current + previous; + previous := current; + current := new. + +print next generation: + printf (($lz","3z","3z","2z-d$, current, + $xz","3z","3z","2z-d$, previous, + $xd.n(real width - 1)d$, current / previous)). diff --git a/Task/Flow-control-structures/AWK/flow-control-structures.awk b/Task/Flow-control-structures/AWK/flow-control-structures.awk new file mode 100644 index 0000000000..4c1defa851 --- /dev/null +++ b/Task/Flow-control-structures/AWK/flow-control-structures.awk @@ -0,0 +1,5 @@ +$ awk 'BEGIN{for(i=1;;i++){if(i%2)continue; if(i>=10)break; print i}}' +2 +4 +6 +8 diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-1.ada b/Task/Flow-control-structures/Ada/flow-control-structures-1.ada new file mode 100644 index 0000000000..1e174b3ea8 --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-1.ada @@ -0,0 +1,3 @@ +<> + Put_Line("Hello, World"); + goto Top; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-2.ada b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada new file mode 100644 index 0000000000..15f5e64b2f --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-2.ada @@ -0,0 +1,8 @@ +Outer: + loop + -- do something + loop + -- do something else + exit Outer; -- exits both the inner and outer loops + end loop; + end loop; diff --git a/Task/Flow-control-structures/Ada/flow-control-structures-3.ada b/Task/Flow-control-structures/Ada/flow-control-structures-3.ada new file mode 100644 index 0000000000..1af014edb3 --- /dev/null +++ b/Task/Flow-control-structures/Ada/flow-control-structures-3.ada @@ -0,0 +1,7 @@ +select + delay 10.0; + Put_Line ("Cannot finish this in 10s"); +then abort + -- do some lengthy calculation + ... +end select; diff --git a/Task/Flow-control-structures/AutoHotkey/flow-control-structures.ahk b/Task/Flow-control-structures/AutoHotkey/flow-control-structures.ahk new file mode 100644 index 0000000000..83fe84a6ca --- /dev/null +++ b/Task/Flow-control-structures/AutoHotkey/flow-control-structures.ahk @@ -0,0 +1,14 @@ +MsgBox, calling Label1 +Gosub, Label1 +MsgBox, Label1 subroutine finished +Goto Label2 +MsgBox, calling Label2 ; this part is never reached +Return + +Label1: + MsgBox, Label1 +Return + +Label2: + MsgBox, Label2 will not return to calling routine +Return diff --git a/Task/Flow-control-structures/BBC-BASIC/flow-control-structures.bbc b/Task/Flow-control-structures/BBC-BASIC/flow-control-structures.bbc new file mode 100644 index 0000000000..1f190065d5 --- /dev/null +++ b/Task/Flow-control-structures/BBC-BASIC/flow-control-structures.bbc @@ -0,0 +1,11 @@ + GOSUB subroutine + + (loop) + PRINT "Infinite loop" + GOTO loop + END + + (subroutine) + PRINT "In subroutine" + WAIT 100 + RETURN diff --git a/Task/Flow-control-structures/C++/flow-control-structures-1.cpp b/Task/Flow-control-structures/C++/flow-control-structures-1.cpp new file mode 100644 index 0000000000..46d274248a --- /dev/null +++ b/Task/Flow-control-structures/C++/flow-control-structures-1.cpp @@ -0,0 +1,8 @@ +#include + +int main() +{ + LOOP: + std::cout << "Hello, World!\n"; + goto LOOP; +} diff --git a/Task/Flow-control-structures/C++/flow-control-structures-2.cpp b/Task/Flow-control-structures/C++/flow-control-structures-2.cpp new file mode 100644 index 0000000000..b8a04cffe4 --- /dev/null +++ b/Task/Flow-control-structures/C++/flow-control-structures-2.cpp @@ -0,0 +1,71 @@ +#include +#include + +void foo() +{ + std::cout << "Going to throw an exception.\n"; + throw 7; // almost any object can be thrown, including ints + std::throw << "This output will never execute.\n"; +} + +void bar() +{ + std::cout << "Going to call foo().\n"; + foo(); + std::cout << "This will be skipped by the exception coming from foo.\n"; +} + +void baz() +{ + try // everything thrown from inside the following code block + { // will be covered by the following catch clauses + std::cout << "Going to call bar().\n"; + bar(); + std::cout << "This will be skipped by the exception coming from foo.\n"; + } + catch(...) // a simple catch-all, but doesn't give access to the thrown exception + { + std::cout << "An exception occured. I'll just throw it on.\n"; + throw; // without an argument, the caught exception is re-thrown + } + std::cout << "This will not be executed due to the re-throw in the catch block\n"; +} + +void foobar() +{ + try + { + baz(); + } + catch(char const* s) + { + std::cout << "If foo had thrown a char const*, this code would be executed.\n"; + std::cout << "In that case, the thrown char const* would read " << s << ".\n"; + } + catch(int i) + { + std::cout << "Caught an int, with value " << i << " (should be 7).\n"; + std::cout << "Not rethrowing the int.\n"; + } + catch(...) + { + std::cout << "This catch-all doesn't get invoked because the catch(int) above\n" + << "already took care of the exception (even if it had rethrown the\n" + << "exception, this catch-all would not be invoked, because it's\n" + << "only invoked for exceptions coming from the try block.\n"; + } + std::cout << "This will be executed, since the exception was handled above, and not rethrown.\n"; +} + +int main() +{ + try + { + foobar(); + } + catch(...) + { + std::cout << "The main function never sees the exception, because it's completely handled\n" + << "inside foobar(). Thus this catch-all block never gets invoked.\n"; + } +} diff --git a/Task/Flow-control-structures/C/flow-control-structures.c b/Task/Flow-control-structures/C/flow-control-structures.c new file mode 100644 index 0000000000..f5758b07a8 --- /dev/null +++ b/Task/Flow-control-structures/C/flow-control-structures.c @@ -0,0 +1,13 @@ +int main() +{ + int i,j; + for (j=1; j<1000; j++) { + for (i=0; i ( i -- a+i ) + 2DUP @ 0 SWAP WITHIN IF + SWAP 1+ CELLS + + ELSE + 1 THROW + THEN ; + +8 checked-array myarray + +: safe-access ( i -- a[i] ) + ['] myarray CATCH 1 = IF ." Out of bounds!" 0 THEN ; diff --git a/Task/Flow-control-structures/GW-BASIC/flow-control-structures.bas b/Task/Flow-control-structures/GW-BASIC/flow-control-structures.bas new file mode 100644 index 0000000000..da6c52dcc7 --- /dev/null +++ b/Task/Flow-control-structures/GW-BASIC/flow-control-structures.bas @@ -0,0 +1,7 @@ +10 LET a=1 +20 IF a=2 THEN PRINT "This is a conditional statement" +30 IF a=1 THEN GOTO 50: REM a conditional jump +40 PRINT "This statement will be skipped" +50 PRINT ("Hello" AND (1=2)): REM This does not print +100 PRINT "Endless loop" +110 GOTO 100:REM an unconditional jump diff --git a/Task/Flow-control-structures/Go/flow-control-structures-1.go b/Task/Flow-control-structures/Go/flow-control-structures-1.go new file mode 100644 index 0000000000..48458c245d --- /dev/null +++ b/Task/Flow-control-structures/Go/flow-control-structures-1.go @@ -0,0 +1,4 @@ +func main() { +inf: + goto inf +} diff --git a/Task/Flow-control-structures/Go/flow-control-structures-2.go b/Task/Flow-control-structures/Go/flow-control-structures-2.go new file mode 100644 index 0000000000..525b620c55 --- /dev/null +++ b/Task/Flow-control-structures/Go/flow-control-structures-2.go @@ -0,0 +1,18 @@ +import "os" + +func processFile() { + f, err := os.Open("file") + if err != nil { + // (probably do something with the error) + return // no need to close file, it didn't open + } + defer f.Close() // file is open. no matter what, close it on return + var lucky bool + // some processing + if (lucky) { + // f.Close() will get called here + return + } + // more processing + // f.Close() will get called here too +} diff --git a/Task/Flow-control-structures/Go/flow-control-structures-3.go b/Task/Flow-control-structures/Go/flow-control-structures-3.go new file mode 100644 index 0000000000..8b19d87e86 --- /dev/null +++ b/Task/Flow-control-structures/Go/flow-control-structures-3.go @@ -0,0 +1,16 @@ +package main + +import "fmt" + +func printOnes() { + for { + fmt.Println("1") + } +} + +func main() { + go printOnes() + for { + fmt.Println("0") + } +} diff --git a/Task/Flow-control-structures/Go/flow-control-structures-4.go b/Task/Flow-control-structures/Go/flow-control-structures-4.go new file mode 100644 index 0000000000..d67abf29c2 --- /dev/null +++ b/Task/Flow-control-structures/Go/flow-control-structures-4.go @@ -0,0 +1,8 @@ +func answer(phone1, phone2 chan int) { + select { + case <-phone1: + // talk on phone one + case <-phone2: + // talk on phone two + } +} diff --git a/Task/Flow-control-structures/Haskell/flow-control-structures.hs b/Task/Flow-control-structures/Haskell/flow-control-structures.hs new file mode 100644 index 0000000000..1e33b0d14c --- /dev/null +++ b/Task/Flow-control-structures/Haskell/flow-control-structures.hs @@ -0,0 +1,12 @@ +import Control.Monad +import Control.Monad.Trans +import Control.Monad.Exit + +main = do + runExitTMaybe $ do + forM_ [1..5] $ \x -> do + forM_ [1..5] $ \y -> do + lift $ print (x, y) + when (x == 3 && y == 2) $ + exitWith () + putStrLn "Done." diff --git a/Task/Flow-control-structures/HicEst/flow-control-structures.hicest b/Task/Flow-control-structures/HicEst/flow-control-structures.hicest new file mode 100644 index 0000000000..2b10338be5 --- /dev/null +++ b/Task/Flow-control-structures/HicEst/flow-control-structures.hicest @@ -0,0 +1,17 @@ +1 GOTO 2 ! branch to label + +2 READ(FIle=name, IOStat=ios, ERror=3) something ! on error branch to label 3 + +3 ALARM(delay, n) ! n=2...9 simulate F2 to F9 keys: call asynchronously "Alarm"-SUBROUTINES F2...F9 with a delay + +4 ALARM( 1 ) ! lets HicEst wait at this statement for any keyboard or mouse event + +5 SYSTEM(WAIT=1000) ! msec + +6 XEQ('CALL my_subroutine', *7) ! executes command string, on error branch to label 7 + +7 y = EXP(1E100, *8) ! on error branch to label 8 + +8 y = LOG( 0 , *9) ! on error branch to label 9 + +9 ALARM( 999 ) ! quit HicEst immediately diff --git a/Task/Flow-control-structures/IDL/flow-control-structures-1.idl b/Task/Flow-control-structures/IDL/flow-control-structures-1.idl new file mode 100644 index 0000000000..923abc0010 --- /dev/null +++ b/Task/Flow-control-structures/IDL/flow-control-structures-1.idl @@ -0,0 +1,3 @@ +test: +..some code here +goto, test diff --git a/Task/Flow-control-structures/IDL/flow-control-structures-2.idl b/Task/Flow-control-structures/IDL/flow-control-structures-2.idl new file mode 100644 index 0000000000..e15678644c --- /dev/null +++ b/Task/Flow-control-structures/IDL/flow-control-structures-2.idl @@ -0,0 +1 @@ +on_error, test diff --git a/Task/Flow-control-structures/IDL/flow-control-structures-3.idl b/Task/Flow-control-structures/IDL/flow-control-structures-3.idl new file mode 100644 index 0000000000..79b51aba20 --- /dev/null +++ b/Task/Flow-control-structures/IDL/flow-control-structures-3.idl @@ -0,0 +1 @@ +on_ioerror, test diff --git a/Task/Flow-control-structures/IDL/flow-control-structures-4.idl b/Task/Flow-control-structures/IDL/flow-control-structures-4.idl new file mode 100644 index 0000000000..bf3fdcd662 --- /dev/null +++ b/Task/Flow-control-structures/IDL/flow-control-structures-4.idl @@ -0,0 +1 @@ +break diff --git a/Task/Flow-control-structures/IDL/flow-control-structures-5.idl b/Task/Flow-control-structures/IDL/flow-control-structures-5.idl new file mode 100644 index 0000000000..44c5d7d65e --- /dev/null +++ b/Task/Flow-control-structures/IDL/flow-control-structures-5.idl @@ -0,0 +1 @@ +continue diff --git a/Task/Flow-control-structures/Icon/flow-control-structures-1.icon b/Task/Flow-control-structures/Icon/flow-control-structures-1.icon new file mode 100644 index 0000000000..0778a8cde1 --- /dev/null +++ b/Task/Flow-control-structures/Icon/flow-control-structures-1.icon @@ -0,0 +1,9 @@ + if x := every i := 1 to *container do { # * is the 'length' operator + if container[i] ~== y then + write("item ", i, " is not interesting") + else + break a + } then + write("found item ", x) + else + write("did not find an item") diff --git a/Task/Flow-control-structures/Icon/flow-control-structures-2.icon b/Task/Flow-control-structures/Icon/flow-control-structures-2.icon new file mode 100644 index 0000000000..63b26b307a --- /dev/null +++ b/Task/Flow-control-structures/Icon/flow-control-structures-2.icon @@ -0,0 +1 @@ + break break next diff --git a/Task/Flow-control-structures/Icon/flow-control-structures-3.icon b/Task/Flow-control-structures/Icon/flow-control-structures-3.icon new file mode 100644 index 0000000000..f2f6d29be6 --- /dev/null +++ b/Task/Flow-control-structures/Icon/flow-control-structures-3.icon @@ -0,0 +1 @@ + x := ftn() diff --git a/Task/Flow-control-structures/Icon/flow-control-structures-4.icon b/Task/Flow-control-structures/Icon/flow-control-structures-4.icon new file mode 100644 index 0000000000..73853a7ecb --- /dev/null +++ b/Task/Flow-control-structures/Icon/flow-control-structures-4.icon @@ -0,0 +1,8 @@ + &error := 1 + mayErrorOut() + if &error == 1 then + &error := 0 # clear the trap + else { + # deal with the fault + handleError(&errornumber, &errortext, &errorvalue) # keyword values containing facts about the failure + } diff --git a/Task/Flow-control-structures/Icon/flow-control-structures-5.icon b/Task/Flow-control-structures/Icon/flow-control-structures-5.icon new file mode 100644 index 0000000000..712785ac08 --- /dev/null +++ b/Task/Flow-control-structures/Icon/flow-control-structures-5.icon @@ -0,0 +1 @@ + runerr(errnumber, errorvalue) # choose an error number and supply the offending value diff --git a/Task/Flow-control-structures/J/flow-control-structures.j b/Task/Flow-control-structures/J/flow-control-structures.j new file mode 100644 index 0000000000..9dd68ef690 --- /dev/null +++ b/Task/Flow-control-structures/J/flow-control-structures.j @@ -0,0 +1,2 @@ + 2 * 1 2 3 +2 4 6 diff --git a/Task/Flow-control-structures/Java/flow-control-structures-1.java b/Task/Flow-control-structures/Java/flow-control-structures-1.java new file mode 100644 index 0000000000..31303b1432 --- /dev/null +++ b/Task/Flow-control-structures/Java/flow-control-structures-1.java @@ -0,0 +1,33 @@ +switch (xx) { + case 1: + case 2: + /* 1 & 2 both come here... */ + ... + break; + case 4: + /* 4 comes here... */ + ... + break; + case 5: + /* 5 comes here... */ + ... + break; + default: + /* everything else */ + break; +} + +for (int i = 0; i < 10; ++i) { + ... + if (some_condition) { break; } + ... +} + +_Time_: do { + for (int i = 0; i < 10; ++i) { + ... + if (some_condition) { break _Time_; /* terminate the do-while loop */} + ... + } + ... +} while (thisCondition); diff --git a/Task/Flow-control-structures/Java/flow-control-structures-2.java b/Task/Flow-control-structures/Java/flow-control-structures-2.java new file mode 100644 index 0000000000..7100a905d5 --- /dev/null +++ b/Task/Flow-control-structures/Java/flow-control-structures-2.java @@ -0,0 +1,25 @@ +while (condition) { + ... + if (someCondition) { continue; /* skip to beginning of this loop */ } + ... +} + +top: for (int 1 = 0; i < 10; ++i) { + ... + middle: for (int j = 0; j < 10; ++j) { + ... + bottom: for (int k = 0; k < 10; ++k) { + ... + if (top_condition) { continue top; /* restart outer loop */ } + ... + if (middle_condition) { continue middle; /* restart middle loop */ } + ... + if (bottom_condition) { continue bottom; /* restart bottom loop */ } + ... + if (bottom_condition) { continue; /* this will also restart bottom loop */ } + ... + } + ... + } + .... +} diff --git a/Task/Flow-control-structures/Lua/flow-control-structures.lua b/Task/Flow-control-structures/Lua/flow-control-structures.lua new file mode 100644 index 0000000000..587a9fd0cf --- /dev/null +++ b/Task/Flow-control-structures/Lua/flow-control-structures.lua @@ -0,0 +1,5 @@ +i = 0 +while true do + i = i + 1 + if i > 10 then break end +end diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-1.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-1.mumps new file mode 100644 index 0000000000..3793b81740 --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-1.mumps @@ -0,0 +1 @@ +GOTO LABEL^ROUTINE diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-2.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-2.mumps new file mode 100644 index 0000000000..45b328cedb --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-2.mumps @@ -0,0 +1 @@ +GOTO THERE diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-3.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-3.mumps new file mode 100644 index 0000000000..4e47e7f09e --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-3.mumps @@ -0,0 +1,2 @@ + Read "Do you really wish to halt (Y/N)?",Q#1 + IF Q="Y"!Q="y" HALT diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-4.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-4.mumps new file mode 100644 index 0000000000..05563408f7 --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-4.mumps @@ -0,0 +1 @@ +JOB LABEL^ROUTINE diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-5.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-5.mumps new file mode 100644 index 0000000000..4f73ee0852 --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-5.mumps @@ -0,0 +1 @@ +JOB THERE diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-6.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-6.mumps new file mode 100644 index 0000000000..8d98fd6e77 --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-6.mumps @@ -0,0 +1 @@ + JOB LABEL^ROUTINE diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-7.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-7.mumps new file mode 100644 index 0000000000..8a7f6dd89d --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-7.mumps @@ -0,0 +1,2 @@ +FOR I=1:1:1 QUIT:NoLoop DO YesLoop +QUIT Returnvalue diff --git a/Task/Flow-control-structures/MUMPS/flow-control-structures-8.mumps b/Task/Flow-control-structures/MUMPS/flow-control-structures-8.mumps new file mode 100644 index 0000000000..9ffa924be7 --- /dev/null +++ b/Task/Flow-control-structures/MUMPS/flow-control-structures-8.mumps @@ -0,0 +1,4 @@ + SET A="SET %=$INCREMENT(I)" + SET I=0 + XECUTE A + WRITE I diff --git a/Task/Flow-control-structures/Maxima/flow-control-structures.maxima b/Task/Flow-control-structures/Maxima/flow-control-structures.maxima new file mode 100644 index 0000000000..0ce9fa95cc --- /dev/null +++ b/Task/Flow-control-structures/Maxima/flow-control-structures.maxima @@ -0,0 +1,8 @@ +/* goto */ +block(..., label, ..., go(label), ...); + +/* throw, which is like trapping errors, and can do non-local jumps to return a value */ +catch(..., throw(value), ...); + +/* error trapping */ +errcatch(..., error("Bad luck!"), ...); diff --git a/Task/Flow-control-structures/PHP/flow-control-structures.php b/Task/Flow-control-structures/PHP/flow-control-structures.php new file mode 100644 index 0000000000..97f2e48259 --- /dev/null +++ b/Task/Flow-control-structures/PHP/flow-control-structures.php @@ -0,0 +1,7 @@ + diff --git a/Task/Flow-control-structures/Perl/flow-control-structures.pl b/Task/Flow-control-structures/Perl/flow-control-structures.pl new file mode 100644 index 0000000000..f060e32a40 --- /dev/null +++ b/Task/Flow-control-structures/Perl/flow-control-structures.pl @@ -0,0 +1,3 @@ +FORK: +# some code +goto FORK; diff --git a/Task/Flow-control-structures/Python/flow-control-structures-1.py b/Task/Flow-control-structures/Python/flow-control-structures-1.py new file mode 100644 index 0000000000..a838c32da1 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-1.py @@ -0,0 +1,10 @@ +# Search for an odd factor of a using brute force: +for i in range(n): + if (n%2) == 0: + continue + if (n%i) == 0: + result = i + break +else: + result = None + print "No odd factors found" diff --git a/Task/Flow-control-structures/Python/flow-control-structures-10.py b/Task/Flow-control-structures/Python/flow-control-structures-10.py new file mode 100644 index 0000000000..554efdfdfc --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-10.py @@ -0,0 +1,13 @@ +# Let's call our custom error "StupidError"; it inherits from the Exception class + +class StupidError(Exception): pass + +# Try it out. +try: + raise StupidError("Segfault") # here, we manually 'raise' the error within the try block +except StupidError, details: # 'details' is the StupidError object we create in the try block. + print 'Something stupid occurred:', details # so we access the value we had stored for it... + + +# Output : +# Something stupid occurred: Segfault diff --git a/Task/Flow-control-structures/Python/flow-control-structures-11.py b/Task/Flow-control-structures/Python/flow-control-structures-11.py new file mode 100644 index 0000000000..a42a9cd4c2 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-11.py @@ -0,0 +1,20 @@ + i = 101 + for i in range(4): # loop 4 times + print "I will always be seen." + if i % 2 == 0: + continue # continue goes back to the loop beginning for a new iteration. + print "I'll only be seen every other time." + else: + print "Loop done" + + # Output: + # I will always be seen. + # I will always be seen. + # I'll only be seen every other time. + # I will always be seen. + # I will always be seen. + # I'll only be seen every other time. + # Loop done + +if(__name__ == "__main__"): + main() diff --git a/Task/Flow-control-structures/Python/flow-control-structures-12.py b/Task/Flow-control-structures/Python/flow-control-structures-12.py new file mode 100644 index 0000000000..c58f0aa631 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-12.py @@ -0,0 +1,9 @@ +class Quitting(Exception): pass +max = 10 +with open("some_file") as myfile: + exit_counter = 0 + for line in myfile: + exit_counter += 1 + if exit_counter > max: + raise Quitting + print line, diff --git a/Task/Flow-control-structures/Python/flow-control-structures-2.py b/Task/Flow-control-structures/Python/flow-control-structures-2.py new file mode 100644 index 0000000000..833331338e --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-2.py @@ -0,0 +1 @@ +class MyException(Exception): pass diff --git a/Task/Flow-control-structures/Python/flow-control-structures-3.py b/Task/Flow-control-structures/Python/flow-control-structures-3.py new file mode 100644 index 0000000000..9315dab573 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-3.py @@ -0,0 +1,3 @@ +class MyVirtual(object): + def __init__(self): + raise NotImplementedError diff --git a/Task/Flow-control-structures/Python/flow-control-structures-4.py b/Task/Flow-control-structures/Python/flow-control-structures-4.py new file mode 100644 index 0000000000..5b07598875 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-4.py @@ -0,0 +1,6 @@ +try: + temp = 0/0 +# 'except' catches any errors that may have been raised between the code of 'try' and 'except' +except: # Note: catch all handler ... NOT RECOMMENDED + print "An error occurred." +# Output : "An error occurred" diff --git a/Task/Flow-control-structures/Python/flow-control-structures-5.py b/Task/Flow-control-structures/Python/flow-control-structures-5.py new file mode 100644 index 0000000000..b5879890f6 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-5.py @@ -0,0 +1,6 @@ +try: + temp = 0/0 +# here, 'except' catches a specific type of error raised within the try block. +except ZeroDivisionError: + print "You've divided by zero!" +# Output : "You've divided by zero!" diff --git a/Task/Flow-control-structures/Python/flow-control-structures-6.py b/Task/Flow-control-structures/Python/flow-control-structures-6.py new file mode 100644 index 0000000000..9bdc7895d7 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-6.py @@ -0,0 +1,11 @@ +try: + temp = 0/0 +except: + print "An error occurred." +# here, 'finally' executes when the try - except block ends, regardless of whether an error was raised or not +# useful in areas such as closing opened file streams in the try block whether they were successfully opened or not +finally: + print "End of 'try' block..." +# Output : +# An error occurred +# End of 'try' block... diff --git a/Task/Flow-control-structures/Python/flow-control-structures-7.py b/Task/Flow-control-structures/Python/flow-control-structures-7.py new file mode 100644 index 0000000000..07be497d99 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-7.py @@ -0,0 +1,8 @@ +try: + try: + pass + except (MyException1, MyOtherException): + pass + except SomeOtherException: +finally: + do_some_cleanup() # run in any case, whether any exceptions were thrown or not diff --git a/Task/Flow-control-structures/Python/flow-control-structures-8.py b/Task/Flow-control-structures/Python/flow-control-structures-8.py new file mode 100644 index 0000000000..ad67009b59 --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-8.py @@ -0,0 +1,9 @@ +try: + temp = 1/1 # not a division by zero error +except ZeroDivisionError: # so... it is not caught + print "You've divided by zero." +# here, 'else' executes when no exceptions are caught... +else: + print "No apparent error occurred." +# Output : +# No apparent error occurred. diff --git a/Task/Flow-control-structures/Python/flow-control-structures-9.py b/Task/Flow-control-structures/Python/flow-control-structures-9.py new file mode 100644 index 0000000000..6f20fd655e --- /dev/null +++ b/Task/Flow-control-structures/Python/flow-control-structures-9.py @@ -0,0 +1,20 @@ +i = 0 +while 1: # infinite loop + try: + temp2 = 0/i # will raise a ZeroDivisionError first. + temp = math.sqrt(i) + + break # 'break' will break out of the while loop + except ValueError: # + print "Imaginary Number! Breaking out of loop" + break # 'break' out of while loop + except ZeroDivisionError: + print "You've divided by zero. Decrementing i and continuing..." + i-=1 # we decrement i. + # we 'continue', everything within the try - except block will be executed again, + # this time however, ZeroDivisionError would not be raised again. + continue # Note that removing it, replacing it with 'pass' would perform the equivalent + # see below for a better example +# Output : +# You've divided by zero. Decrementing i and continuing... +# Imaginary Number! Breaking out of loop diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-1.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-1.rexx new file mode 100644 index 0000000000..8a7bc14fe6 --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-1.rexx @@ -0,0 +1,3 @@ +exit + +exit expression diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-2.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-2.rexx new file mode 100644 index 0000000000..0a3389143e --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-2.rexx @@ -0,0 +1,3 @@ +return + +return expression diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-3.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-3.rexx new file mode 100644 index 0000000000..a1b1bb61f7 --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-3.rexx @@ -0,0 +1,39 @@ +signal on error +signal on failure +signal on halt +signal on lostdigits +signal on notready +signal on novalue +signal on syntax + +signal off error +signal off failure +signal off halt +signal off lostdigits +signal off notready +signal off novalue +signal off syntax + ∙ + ∙ + ∙ +signal on novalue + ∙ + ∙ +x=oopsay+1 + ∙ + ∙ + ∙ +novalue: say +say '*** error! ***' +say +say 'undefined REXX variable' condition("D") +say +say 'in line' sigl +say +say 'REXX source statement is:' +say sourceline(sigl) +say +exit 13 + ∙ + ∙ + ∙ diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-4.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-4.rexx new file mode 100644 index 0000000000..2d48764256 --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-4.rexx @@ -0,0 +1,22 @@ + do j=1 to 10 + say 'j=' j + if j>5 then leave + say 'negative j=' -j + end +say 'end of the DO loop for j.' + ∙ + ∙ + ∙ +ouch=60 +sum=0 + + do k=0 to 100 by 3 + say 'k=' k + + do m=1 to k + if m=ouch then leave k + sum=sum+m + end + + end +say 'sum=' sum diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-5.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-5.rexx new file mode 100644 index 0000000000..3786c044f1 --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-5.rexx @@ -0,0 +1,24 @@ +sum=0 + + do j=1 to 1000 + if j//3==0 | j//7==0 then iterate + sum=sum+j + end + + /*shows sum of 1k numbers except those divisible by 3 or 7.*/ +say 'sum='sum + ∙ + ∙ + ∙ +numeric digits 5000 +prod=0 + + do k=1 to 2000 + + do m=1 to k + if m>99 then iterate k + prod=prod*m + end + + end +say 'prod=' prod diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-6.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-6.rexx new file mode 100644 index 0000000000..4c764baae8 --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-6.rexx @@ -0,0 +1,18 @@ +numeric digits 1000 /*prepare for some gihugeic numbers.*/ + ∙ + ∙ + ∙ +n=4 +call factorial n +say n'!=' result +exit + + +factorial: parse arg x +!=1 + + do j=2 to x + !=!*j + end + +return ! diff --git a/Task/Flow-control-structures/REXX/flow-control-structures-7.rexx b/Task/Flow-control-structures/REXX/flow-control-structures-7.rexx new file mode 100644 index 0000000000..94691d591e --- /dev/null +++ b/Task/Flow-control-structures/REXX/flow-control-structures-7.rexx @@ -0,0 +1,25 @@ + ∙ + ∙ + ∙ +prod=1 +a=7 /*or somesuch.*/ +b=3 /* likewise. */ + +op='**' /*or whatever.*/ + ∙ + ∙ + ∙ + select + when op=='+' then r=a+b /*add. */ + when op=='-' then r=a-b /*subtract. */ + when op=='*' then do; r=a*b; prod=prod*r; end /*multiply.*/ + when op=='*' then r=a*b /*multiply. */ + when op=='/' & b\=0 then r=a/b /*divide. */ + when op=='%' & b\=0 then r=a/b /*interger divide. */ + when op=='//' & b\=0 then r=a/b /*modulus (remainder). */ + when op=='||' then r=a||b /*concatenation. */ + when op=='caw' then r=xyz(a,b) /*call the XYZ subroutine*/ + otherwise r='[n/a]' /*signify not applicable.*/ + end + +say 'result for' a op b "=" r diff --git a/Task/Flow-control-structures/Ruby/flow-control-structures-1.rb b/Task/Flow-control-structures/Ruby/flow-control-structures-1.rb new file mode 100644 index 0000000000..d964f7bfe2 --- /dev/null +++ b/Task/Flow-control-structures/Ruby/flow-control-structures-1.rb @@ -0,0 +1,13 @@ +begin + # some code that may raise an exception +rescue ExceptionClassA => a + # handle code +rescue ExceptionClassB, ExceptionClassC => b_or_c + # handle ... +rescue + # handle all other exceptions +else + # when no exception occurred, execute this code +ensure + # execute this code always +end diff --git a/Task/Flow-control-structures/Ruby/flow-control-structures-2.rb b/Task/Flow-control-structures/Ruby/flow-control-structures-2.rb new file mode 100644 index 0000000000..4f4c6215ec --- /dev/null +++ b/Task/Flow-control-structures/Ruby/flow-control-structures-2.rb @@ -0,0 +1,3 @@ +values = ["1", "2.3", /pattern/] +result = values.map {|v| Integer(v) rescue Float(v) rescue String(v)} +# => [1, 2.3, "(?-mix:pattern)"] diff --git a/Task/Flow-control-structures/Ruby/flow-control-structures-3.rb b/Task/Flow-control-structures/Ruby/flow-control-structures-3.rb new file mode 100644 index 0000000000..04348a15b4 --- /dev/null +++ b/Task/Flow-control-structures/Ruby/flow-control-structures-3.rb @@ -0,0 +1,17 @@ +def some_method + # ... + if some_condition + throw :get_me_out_of_here + end + # ... +end + +catch :get_me_out_of_here do + for ... + for ... + some_method + end + end +end + +puts "continuing after catching the throw" diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-1.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-1.tcl new file mode 100644 index 0000000000..527ceee36d --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-1.tcl @@ -0,0 +1 @@ +after 1000 {myroutine x} diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-2.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-2.tcl new file mode 100644 index 0000000000..db74dde3a6 --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-2.tcl @@ -0,0 +1 @@ +after cancel myroutine diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-3.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-3.tcl new file mode 100644 index 0000000000..eaa28f8f66 --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-3.tcl @@ -0,0 +1,8 @@ +package require Tk +proc update {} { + .clockface configure -text [clock format [clock seconds]] + after 1000 update ; # call yourself in a second +} +# now just create the 'clockface' and call ;update' once: +pack [label .clockface] +update diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-4.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-4.tcl new file mode 100644 index 0000000000..a03cc814e7 --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-4.tcl @@ -0,0 +1,5 @@ +if {[catch { ''... code that might give error ...'' } result]} { + puts "Error was $result" +} else { + ''... process $result ...'' +} diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-5.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-5.tcl new file mode 100644 index 0000000000..c18d59fa01 --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-5.tcl @@ -0,0 +1,10 @@ +try { + # Just a silly example... + set f [open $filename] + expr 1/0 + string length [read $f] +} trap {ARITH DIVZERO} {} { + puts "divided by zero" +} finally { + close $f +} diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-6.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-6.tcl new file mode 100644 index 0000000000..789a5abd9b --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-6.tcl @@ -0,0 +1,8 @@ +proc forfilelines {linevar filename code} { + upvar $linevar line ; # connect local variable line to caller's variable + set filechan [open $filename] + while {[gets $filechan line] != -1} { + uplevel 1 $code ; # Run supplied code in caller's scope + } + close $filechan +} diff --git a/Task/Flow-control-structures/Tcl/flow-control-structures-7.tcl b/Task/Flow-control-structures/Tcl/flow-control-structures-7.tcl new file mode 100644 index 0000000000..4e55b72a88 --- /dev/null +++ b/Task/Flow-control-structures/Tcl/flow-control-structures-7.tcl @@ -0,0 +1,3 @@ +forfilelines myline mydata.txt { + puts [string length $myline] +} diff --git a/Task/Floyds-triangle/0DESCRIPTION b/Task/Floyds-triangle/0DESCRIPTION new file mode 100644 index 0000000000..6372b0d521 --- /dev/null +++ b/Task/Floyds-triangle/0DESCRIPTION @@ -0,0 +1,14 @@ +[[wp:Floyd's triangle|Floyd's triangle]] lists the natural numbers in a right triangle aligned to the left where +* the first row is just 1 +* successive rows start towards the left with the next number followed by successive naturals listing one more number than the line above. + +The first few lines of a Floyd triangle looks like this: +
 1
+ 2  3
+ 4  5  6
+ 7  8  9 10
+11 12 13 14 15
+ +The task is to: +# Write a program to generate and display here the first n lines of a Floyd triangle.
(Use n=5 and n=14 rows). +# Ensure that when displayed in a monospace font, the numbers line up in vertical columns as shown and that only one space separates numbers of the last row. diff --git a/Task/Floyds-triangle/AWK/floyds-triangle.awk b/Task/Floyds-triangle/AWK/floyds-triangle.awk new file mode 100644 index 0000000000..a0b8a3b6ab --- /dev/null +++ b/Task/Floyds-triangle/AWK/floyds-triangle.awk @@ -0,0 +1,17 @@ +# syntax: GAWK -f FLOYDS_TRIANGLE.AWK rows +BEGIN { + rows = ARGV[1] + if (rows !~ /^[0-9]+$/) { + print("rows invalid or missing from command line") + exit(1) + } + width = length(rows * (rows + 1) / 2) + 1 # width of last n + for (i=1; i<=rows; i++) { + cols++ + for (j=1; j<=cols; j++) { + printf("%*d",width,++n) + } + printf("\n") + } + exit(0) +} diff --git a/Task/Floyds-triangle/Ada/floyds-triangle.ada b/Task/Floyds-triangle/Ada/floyds-triangle.ada new file mode 100644 index 0000000000..9e6b226408 --- /dev/null +++ b/Task/Floyds-triangle/Ada/floyds-triangle.ada @@ -0,0 +1,23 @@ +with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line; + +procedure Floyd_Triangle is + + Rows: constant Positive := Integer'Value(Ada.Command_Line.Argument(1)); + Current: Positive := 1; + Width: array(1 .. Rows) of Positive; + +begin + -- compute the width for the different columns + for I in Width'Range loop + Width(I) := Integer'Image(I + (Rows * (Rows-1))/2)'Length; + end loop; + + -- output the triangle + for Line in 1 .. Rows loop + for Column in 1 .. Line loop + Ada.Integer_Text_IO.Put(Current, Width => Width(Column)); + Current := Current + 1; + end loop; + Ada.Text_IO.New_Line; + end loop; +end Floyd_Triangle; diff --git a/Task/Floyds-triangle/BBC-BASIC/floyds-triangle.bbc b/Task/Floyds-triangle/BBC-BASIC/floyds-triangle.bbc new file mode 100644 index 0000000000..2663014a3b --- /dev/null +++ b/Task/Floyds-triangle/BBC-BASIC/floyds-triangle.bbc @@ -0,0 +1,12 @@ + n = 14 + num = 1 + last = (n^2 - n + 2) DIV 2 + FOR row = 1 TO n + col = last + FOR num = num TO num + row - 1 + @% = LEN(STR$(col)) + 1 : REM set column width + PRINT num ; + col += 1 + NEXT + PRINT + NEXT row diff --git a/Task/Floyds-triangle/Bracmat/floyds-triangle.bracmat b/Task/Floyds-triangle/Bracmat/floyds-triangle.bracmat new file mode 100644 index 0000000000..081c52ab69 --- /dev/null +++ b/Task/Floyds-triangle/Bracmat/floyds-triangle.bracmat @@ -0,0 +1,26 @@ + ( ( floyd + = lowerLeftCorner lastInColumn lastInRow row i W w + . put$(str$("Floyd " !arg ":\n")) + & !arg*(!arg+-1)*1/2+1 + : ?lowerLeftCorner + : ?lastInColumn + & 1:?lastInRow:?row:?i + & whl + ' ( !row:~>!arg + & @(!lastInColumn:? [?W) + & @(!i:? [?w) + & whl'(!w+1:~>!W:?w&put$" ") + & put$!i + & ( !i: + +void t(int n) +{ + int i, j, c, len; + + i = n * (n - 1) / 2; + for (len = c = 1; c < i; c *= 10, len++); + c -= i; // c is the col where width changes + +#define SPEED_MATTERS 0 +#if SPEED_MATTERS // in case we really, really wanted to print huge triangles often + char tmp[32], s[4096], *p; + + sprintf(tmp, "%*d", len, 0); + + inline void inc_numstr(void) { + int k = len; + + redo: if (!k--) return; + + if (tmp[k] == '9') { + tmp[k] = '0'; + goto redo; + } + + if (++tmp[k] == '!') + tmp[k] = '1'; + } + + for (p = s, i = 1; i <= n; i++) { + for (j = 1; j <= i; j++) { + inc_numstr(); + __builtin_memcpy(p, tmp + 1 - (j >= c), len - (j < c)); + p += len - (j < c); + + *(p++) = (i - j)? ' ' : '\n'; + + if (p - s + len >= 4096) { + fwrite(s, 1, p - s, stdout); + p = s; + } + } + } + + fwrite(s, 1, p - s, stdout); +#else // NO_IT_DOESN'T + int num; + for (num = i = 1; i <= n; i++) + for (j = 1; j <= i; j++) + printf("%*d%c", len - (j < c), num++, i - j ? ' ':'\n'); +#endif +} + +int main(void) +{ + t(5), t(14); + + // maybe not + // t(10000); + return 0; +} diff --git a/Task/Floyds-triangle/D/floyds-triangle.d b/Task/Floyds-triangle/D/floyds-triangle.d new file mode 100644 index 0000000000..7af73975cf --- /dev/null +++ b/Task/Floyds-triangle/D/floyds-triangle.d @@ -0,0 +1,16 @@ +import std.stdio, std.conv; + +void floydTriangle(in uint n) { + immutable lowerLeftCorner = n * (n - 1) / 2 + 1; + foreach (r; 0 .. n) + foreach (c; 0 .. r + 1) + writef("%*d%c", + text(lowerLeftCorner + c).length, + r * (r + 1) / 2 + c + 1, + c == r ? '\n' : ' '); +} + +void main() { + floydTriangle(5); + floydTriangle(14); +} diff --git a/Task/Floyds-triangle/Go/floyds-triangle.go b/Task/Floyds-triangle/Go/floyds-triangle.go new file mode 100644 index 0000000000..c400e93ebb --- /dev/null +++ b/Task/Floyds-triangle/Go/floyds-triangle.go @@ -0,0 +1,27 @@ +package main + +import "fmt" + +func main() { + floyd(5) + floyd(14) +} + +func floyd(n int) { + fmt.Printf("Floyd %d:\n", n) + lowerLeftCorner := n*(n-1)/2 + 1 + lastInColumn := lowerLeftCorner + lastInRow := 1 + for i, row := 1, 1; row <= n; i++ { + w := len(fmt.Sprint(lastInColumn)) + if i < lastInRow { + fmt.Printf("%*d ", w, i) + lastInColumn++ + } else { + fmt.Printf("%*d\n", w, i) + row++ + lastInRow += row + lastInColumn = lowerLeftCorner + } + } +} diff --git a/Task/Floyds-triangle/Haskell/floyds-triangle-1.hs b/Task/Floyds-triangle/Haskell/floyds-triangle-1.hs new file mode 100644 index 0000000000..5d1c9b9b32 --- /dev/null +++ b/Task/Floyds-triangle/Haskell/floyds-triangle-1.hs @@ -0,0 +1,12 @@ +import Data.List +import Control.Monad +import Control.Arrow + +alignR :: Int -> Integer -> String +alignR n = (\s -> replicate (n - length s) ' ' ++ s). show + +floydTriangle = liftM2 (zipWith (liftM2 (.) enumFromTo ((pred.). (+)))) (scanl (+) 1) id [1..] + +formatFT n = mapM_ (putStrLn. unwords. zipWith alignR ws) t where + t = take n floydTriangle + ws = map (length. show) $ last t diff --git a/Task/Floyds-triangle/Haskell/floyds-triangle-2.hs b/Task/Floyds-triangle/Haskell/floyds-triangle-2.hs new file mode 100644 index 0000000000..c528462f83 --- /dev/null +++ b/Task/Floyds-triangle/Haskell/floyds-triangle-2.hs @@ -0,0 +1,22 @@ +*Main> formatFT 5 + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 + +*Main> formatFT 14 + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 +16 17 18 19 20 21 +22 23 24 25 26 27 28 +29 30 31 32 33 34 35 36 +37 38 39 40 41 42 43 44 45 +46 47 48 49 50 51 52 53 54 55 +56 57 58 59 60 61 62 63 64 65 66 +67 68 69 70 71 72 73 74 75 76 77 78 +79 80 81 82 83 84 85 86 87 88 89 90 91 +92 93 94 95 96 97 98 99 100 101 102 103 104 105 diff --git a/Task/Floyds-triangle/J/floyds-triangle-1.j b/Task/Floyds-triangle/J/floyds-triangle-1.j new file mode 100644 index 0000000000..ca08e3769b --- /dev/null +++ b/Task/Floyds-triangle/J/floyds-triangle-1.j @@ -0,0 +1,2 @@ +require 'strings' +floyd=: [: rplc&(' 0';' ')"1@":@(* ($ $ +/\@,)) >:/~@:i. diff --git a/Task/Floyds-triangle/J/floyds-triangle-2.j b/Task/Floyds-triangle/J/floyds-triangle-2.j new file mode 100644 index 0000000000..9a5eb1b907 --- /dev/null +++ b/Task/Floyds-triangle/J/floyds-triangle-2.j @@ -0,0 +1,21 @@ + floyd 5 + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 + floyd 14 + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 +16 17 18 19 20 21 +22 23 24 25 26 27 28 +29 30 31 32 33 34 35 36 +37 38 39 40 41 42 43 44 45 +46 47 48 49 50 51 52 53 54 55 +56 57 58 59 60 61 62 63 64 65 66 +67 68 69 70 71 72 73 74 75 76 77 78 +79 80 81 82 83 84 85 86 87 88 89 90 91 +92 93 94 95 96 97 98 99 100 101 102 103 104 105 diff --git a/Task/Floyds-triangle/J/floyds-triangle-3.j b/Task/Floyds-triangle/J/floyds-triangle-3.j new file mode 100644 index 0000000000..3a6b2ecf05 --- /dev/null +++ b/Task/Floyds-triangle/J/floyds-triangle-3.j @@ -0,0 +1 @@ +floyd=: [: ({.~ i.&1@E.~&' 0')"1@":@(* ($ $ +/\@,)) >:/~@:i. diff --git a/Task/Floyds-triangle/Java/floyds-triangle.java b/Task/Floyds-triangle/Java/floyds-triangle.java new file mode 100644 index 0000000000..5cdc28155c --- /dev/null +++ b/Task/Floyds-triangle/Java/floyds-triangle.java @@ -0,0 +1,21 @@ +public class Floyd { + public static void main(String[] args){ + System.out.println("5 rows:"); + printTriangle(5); + System.out.println("14 rows:"); + printTriangle(14); + } + + private static void printTriangle(int n){ + for(int rowNum = 1, printMe = 1, numsPrinted = 0; + rowNum <= n; printMe++){ + int cols = (int)Math.ceil(Math.log10(n*(n-1)/2 + numsPrinted + 2)); + System.out.printf("%"+cols+"d ", printMe); + if(++numsPrinted == rowNum){ + System.out.println(); + rowNum++; + numsPrinted = 0; + } + } + } +} diff --git a/Task/Floyds-triangle/JavaScript/floyds-triangle.js b/Task/Floyds-triangle/JavaScript/floyds-triangle.js new file mode 100644 index 0000000000..1f1a207190 --- /dev/null +++ b/Task/Floyds-triangle/JavaScript/floyds-triangle.js @@ -0,0 +1,36 @@ +#!/usr/bin/env js + +function main() { + print('Floyd 5:'); + floyd(5); + print('\nFloyd 14:'); + floyd(14); +} + + +function padLeft(s, w) { + for (s = String(s); s.length < w; s = ' ' + s); + return s; +} + + +function floyd(nRows) { + var lowerLeft = nRows * (nRows - 1) / 2 + 1; + var lowerRight = nRows * (nRows + 1) / 2; + + var colWidths = []; + for (var col = lowerLeft; col <= lowerRight; col++) { + colWidths.push(String(col).length); + } + + var num = 1; + for (var row = 0; row < nRows; row++) { + var line = []; + for (var col = 0; col <= row; col++, num++) { + line.push(padLeft(num, colWidths[col])); + } + print(line.join(' ')); + } +} + +main(); diff --git a/Task/Floyds-triangle/Julia/floyds-triangle.julia b/Task/Floyds-triangle/Julia/floyds-triangle.julia new file mode 100644 index 0000000000..b9c84241be --- /dev/null +++ b/Task/Floyds-triangle/Julia/floyds-triangle.julia @@ -0,0 +1,6 @@ +#floyd(n) creates an n-row floyd's triangle counting from 1 to (n/2+.5)*n +function floyd(n) + x = 1 + dig(x,line,n) = (while line < n; x+=line; line+= 1 end; return ndigits(x)+1) + for line = 1:n, i = 1:line; print(lpad(x,dig(x,line,n)," ")); x+=1; i==line && print("\n") end +end diff --git a/Task/Floyds-triangle/Liberty-BASIC/floyds-triangle.liberty b/Task/Floyds-triangle/Liberty-BASIC/floyds-triangle.liberty new file mode 100644 index 0000000000..b44eab075c --- /dev/null +++ b/Task/Floyds-triangle/Liberty-BASIC/floyds-triangle.liberty @@ -0,0 +1,17 @@ +input "Number of rows needed:- "; rowsNeeded + +dim colWidth(rowsNeeded) ' 5 rows implies 5 columns + +for col=1 to rowsNeeded + colWidth(col) = len(str$(col + rowsNeeded*(rowsNeeded-1)/2)) +next + +currentNumber =1 + +for row=1 to rowsNeeded + for col=1 to row + print right$( " "+str$( currentNumber), colWidth(col)); " "; + currentNumber = currentNumber + 1 + next + print +next diff --git a/Task/Floyds-triangle/Lua/floyds-triangle.lua b/Task/Floyds-triangle/Lua/floyds-triangle.lua new file mode 100644 index 0000000000..4255946fe6 --- /dev/null +++ b/Task/Floyds-triangle/Lua/floyds-triangle.lua @@ -0,0 +1,19 @@ +function print_floyd(rows) + local c = 1 + local h = rows*(rows-1)/2 + for i=1,rows do + local s = "" + for j=1,i do + for k=1, #tostring(h+j)-#tostring(c) do + s = s .. " " + end + if j ~= 1 then s = s .. " " end + s = s .. tostring(c) + c = c + 1 + end + print(s) + end +end + +print_floyd(5) +print_floyd(14) diff --git a/Task/Floyds-triangle/Mathematica/floyds-triangle.mathematica b/Task/Floyds-triangle/Mathematica/floyds-triangle.mathematica new file mode 100644 index 0000000000..fd00d98a6d --- /dev/null +++ b/Task/Floyds-triangle/Mathematica/floyds-triangle.mathematica @@ -0,0 +1,4 @@ +f=Function[n, + Most/@(Range@@@Partition[FindSequenceFunction[{1,2,4,7,11}]/@Range[n+1],2,1])] +TableForm[f@5,TableAlignments->Right,TableSpacing->{1,1}] +TableForm[f@14,TableAlignments->Right,TableSpacing->{1,1}] diff --git a/Task/Floyds-triangle/Perl/floyds-triangle.pl b/Task/Floyds-triangle/Perl/floyds-triangle.pl new file mode 100644 index 0000000000..6d9c9838db --- /dev/null +++ b/Task/Floyds-triangle/Perl/floyds-triangle.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +sub displayFloydTriangle { + my $numRows = shift; + print "\ndisplaying a $numRows row Floyd's triangle:\n\n"; + my $maxVal = int($numRows * ($numRows + 1) / 2); # calculate the max value. + my $digit = 0; + foreach my $row (1 .. $numRows) { + my $col = 0; + my $output = ''; + foreach (1 .. $row) { + ++$digit; + ++$col; + my $colMaxDigit = $maxVal - $numRows + $col; + $output .= sprintf " %*d", length($colMaxDigit), $digit; + } + print "$output\n"; + } + return; +} + +# ==== Main ================================================ +my @counts; +@counts = @ARGV; +@counts = (5, 14) unless @ARGV; + +foreach my $count (@counts) { + displayFloydTriangle($count); +} + +0; +__END__ diff --git a/Task/Floyds-triangle/PicoLisp/floyds-triangle-1.l b/Task/Floyds-triangle/PicoLisp/floyds-triangle-1.l new file mode 100644 index 0000000000..5016e71802 --- /dev/null +++ b/Task/Floyds-triangle/PicoLisp/floyds-triangle-1.l @@ -0,0 +1,9 @@ +(de floyd (N) + (let LLC (/ (* N (dec N)) 2) + (for R N + (for C R + (prin + (align + (length (+ LLC C)) + (+ C (/ (* R (dec R)) 2)) ) ) + (if (= C R) (prinl) (space)) ) ) ) ) diff --git a/Task/Floyds-triangle/PicoLisp/floyds-triangle-2.l b/Task/Floyds-triangle/PicoLisp/floyds-triangle-2.l new file mode 100644 index 0000000000..b7fc972a4e --- /dev/null +++ b/Task/Floyds-triangle/PicoLisp/floyds-triangle-2.l @@ -0,0 +1,10 @@ +(de floyd (N) + (let + (Rows + (make + (for ((I . L) (range 1 (/ (* N (inc N)) 2)) L) + (link (cut I 'L)) ) ) + Fmt (mapcar length (last Rows)) ) + (map inc (cdr Fmt)) + (for R Rows + (apply tab R Fmt) ) ) ) diff --git a/Task/Floyds-triangle/Python/floyds-triangle-1.py b/Task/Floyds-triangle/Python/floyds-triangle-1.py new file mode 100644 index 0000000000..db333eb941 --- /dev/null +++ b/Task/Floyds-triangle/Python/floyds-triangle-1.py @@ -0,0 +1,42 @@ +>>> def floyd(rowcount=5): + rows = [[1]] + while len(rows) < rowcount: + n = rows[-1][-1] + 1 + rows.append(list(range(n, n + len(rows[-1]) + 1))) + return rows + +>>> floyd() +[[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]] +>>> def pfloyd(rows=[[1], [2, 3], [4, 5, 6], [7, 8, 9, 10]]): + colspace = [len(str(n)) for n in rows[-1]] + for row in rows: + print( ' '.join('%*i' % space_n for space_n in zip(colspace, row))) + + +>>> pfloyd() +1 +2 3 +4 5 6 +7 8 9 10 +>>> pfloyd(floyd(5)) + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 +>>> pfloyd(floyd(14)) + 1 + 2 3 + 4 5 6 + 7 8 9 10 +11 12 13 14 15 +16 17 18 19 20 21 +22 23 24 25 26 27 28 +29 30 31 32 33 34 35 36 +37 38 39 40 41 42 43 44 45 +46 47 48 49 50 51 52 53 54 55 +56 57 58 59 60 61 62 63 64 65 66 +67 68 69 70 71 72 73 74 75 76 77 78 +79 80 81 82 83 84 85 86 87 88 89 90 91 +92 93 94 95 96 97 98 99 100 101 102 103 104 105 +>>> diff --git a/Task/Floyds-triangle/Python/floyds-triangle-2.py b/Task/Floyds-triangle/Python/floyds-triangle-2.py new file mode 100644 index 0000000000..54452c6cb2 --- /dev/null +++ b/Task/Floyds-triangle/Python/floyds-triangle-2.py @@ -0,0 +1,3 @@ +def floyd(rowcount=5): + return [list(range(i*(i-1)//2+1, i*(i+1)//2+1)) + for i in range(1, rowcount+1)] diff --git a/Task/Floyds-triangle/REXX/floyds-triangle-1.rexx b/Task/Floyds-triangle/REXX/floyds-triangle-1.rexx new file mode 100644 index 0000000000..dff7567923 --- /dev/null +++ b/Task/Floyds-triangle/REXX/floyds-triangle-1.rexx @@ -0,0 +1,22 @@ +/* REXX *************************************************************** +* Parse Arg rowcount +* 12.07.2012 Walter Pachl - translated from Python +**********************************************************************/ +Parse Arg rowcount +col=0 +ll='' /* last line of triangle */ +Do j=rowcount*(rowcount-1)/2+1 to rowcount*(rowcount+1)/2 + col=col+1 /* column number */ + ll=ll j /* build last line */ + len.col=length(j) /* remember length of column */ + End +Do i=1 To rowcount-1 /* now do and output the rest */ + ol='' + col=0 + Do j=i*(i-1)/2+1 to i*(i+1)/2 /* elements of line i */ + col=col+1 + ol=ol right(j,len.col) /* element in proper length */ + end + Say ol /* output ith line */ + end +Say ll /* output last line */ diff --git a/Task/Floyds-triangle/REXX/floyds-triangle-2.rexx b/Task/Floyds-triangle/REXX/floyds-triangle-2.rexx new file mode 100644 index 0000000000..b860685544 --- /dev/null +++ b/Task/Floyds-triangle/REXX/floyds-triangle-2.rexx @@ -0,0 +1,12 @@ +/*REXX program constructs & displays Floyd's triangle for any # of rows.*/ +parse arg rows .; if rows=='' then rows=1 /*assume 1 row is not given*/ +mV=rows * (rows+1) % 2 /*calculate the max value. */ +say 'displaying a' rows "row Floyd's triangle:"; say +#=1 + do r=1 for rows; i=0; _='' + do #=# for r; i=i+1 + _=_ right(#, length(mV-rows+i)) + end /*#*/ + say _ + end /*r*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Floyds-triangle/Racket/floyds-triangle.rkt b/Task/Floyds-triangle/Racket/floyds-triangle.rkt new file mode 100644 index 0000000000..8b423c2e2c --- /dev/null +++ b/Task/Floyds-triangle/Racket/floyds-triangle.rkt @@ -0,0 +1,18 @@ +#lang racket +(require math) + +(define (tri n) + (if (zero? n) 0 (triangle-number n))) + +(define (floyd n) + (define (width x) (string-length (~a x))) + (define (~n x c) (~a x + #:width (width (+ (tri (- n 1)) 1 c)) + #:align 'right #:left-pad-string " ")) + (for ([r n]) + (for ([c (+ r 1)]) + (display (~a (~n (+ (tri r) 1 c) c) " "))) + (newline))) + +(floyd 5) +(floyd 14) diff --git a/Task/Floyds-triangle/Ruby/floyds-triangle.rb b/Task/Floyds-triangle/Ruby/floyds-triangle.rb new file mode 100644 index 0000000000..eb049f210c --- /dev/null +++ b/Task/Floyds-triangle/Ruby/floyds-triangle.rb @@ -0,0 +1,14 @@ +raise ArgumentError, "Usage: #{$0} ROWS" unless + ARGV.length == 1 && (rows = ARGV[0].to_i) > 0 + +max = (rows * (rows + 1)) / 2 +widths = ((max - rows + 1)..max).map {|n| n.to_s.length + 1} + +n = 0 +rows.times do |r| + (r+1).times do |i| + n += 1 + print "%#{widths[i]}d" % n + end + print "\n" +end diff --git a/Task/Floyds-triangle/Scala/floyds-triangle.scala b/Task/Floyds-triangle/Scala/floyds-triangle.scala new file mode 100644 index 0000000000..96b0213451 --- /dev/null +++ b/Task/Floyds-triangle/Scala/floyds-triangle.scala @@ -0,0 +1,20 @@ +def floydstriangle( n:Int ) { + val s = (1 to n) + val t = s map {i => (s take(i-1) sum) + 1} + + (s zip t) foreach { n => + var m = n._2; + + for( i <- 0 until n._1 ) { + val w = (t.last + i).toString.length + 1 // Column width from last row + print(" " + m takeRight w ) + m+=1 + } + + print("\n") + } +} + +// Test +floydstriangle(5) +floydstriangle(14) diff --git a/Task/Floyds-triangle/Tcl/floyds-triangle.tcl b/Task/Floyds-triangle/Tcl/floyds-triangle.tcl new file mode 100644 index 0000000000..9d732fc369 --- /dev/null +++ b/Task/Floyds-triangle/Tcl/floyds-triangle.tcl @@ -0,0 +1,19 @@ +proc floydTriangle n { + # Compute the column widths + for {set i [expr {$n*($n-1)/2+1}]} {$i <= $n*($n+1)/2} {incr i} { + lappend w [string length $i] + } + # Print the triangle + for {set i 0; set j 1} {$j <= $n} {incr j} { + for {set p -1; set k 0} {$k < $j} {incr k} { + puts -nonewline [format "%*d " [lindex $w [incr p]] [incr i]] + } + puts "" + } +} + +# Demonstration +puts "Floyd 5:" +floydTriangle 5 +puts "Floyd 14:" +floydTriangle 14 diff --git a/Task/Forest-fire/Icon/forest-fire.icon b/Task/Forest-fire/Icon/forest-fire.icon new file mode 100644 index 0000000000..b48cd5854d --- /dev/null +++ b/Task/Forest-fire/Icon/forest-fire.icon @@ -0,0 +1,73 @@ +link graphics,printf + +$define EDGE 0 +$define EMPTY 1 +$define TREE 2 +$define FIRE 3 + +global Colours,Width,Height,ProbTree,ProbFire,ProbInitialTree,Forest,oldForest + +procedure main() # forest fire + + Height := 400 # Window height + Width := 400 # Window width + ProbInitialTree := .10 # intial probability of trees + ProbTree := .01 # ongoing probability of trees + ProbFire := ProbTree/50. # probability of fire + Rounds := 500 # rounds to evolve + + setup_forest() + every 1 to Rounds do { + show_forest() + evolve_forest() + } + printf("Forest fire %d x %d rounds=%d p.initial=%r p/f=%r/%r fps=%r\n", + Width,Height,Rounds,ProbInitialTree,ProbTree,ProbFire, + Rounds/(&time/1000.)) # stats + WDone() +end + +procedure setup_forest() #: setup the forest + + Colours := table() # define colours + Colours[EDGE] := "black" + Colours[EMPTY] := "grey" + Colours[TREE] := "green" + Colours[FIRE] := "red" + + WOpen("label=Forest Fire", "bg=black", + "size=" || Width+2 || "," || Height+2) | # add for border + stop("Unable to open Window") + every !(Forest := list(Height)) := list(Width,EMPTY) # default + every ( Forest[1,1 to Width] | Forest[Height,1 to Width] | + Forest[1 to Height,1] | Forest[1 to Height,Width] ) := EDGE + every r := 2 to Height-1 & c := 2 to Width-1 do + if probability(ProbInitialTree) then Forest[r,c] := TREE +end + +procedure show_forest() #: show Forest - drawn changes only + every r := 2 to *Forest-1 & c := 2 to *Forest[r]-1 do + if /oldForest | oldForest[r,c] ~= Forest[r,c] then { + WAttrib("fg=" || Colours[Forest[r,c]]) + DrawPoint(r,c) + } +end + +procedure evolve_forest() #: evolve forest + old := oldForest := list(*Forest) # freeze copy + every old[i := 1 to *Forest] := copy(Forest[i]) # deep copy + + every r := 2 to *Forest-1 & c := 2 to *Forest[r]-1 do + Forest[r,c] := case old[r,c] of { # apply rules + FIRE : EMPTY + TREE : if probability(ProbFire) | + ( old[r-1, c-1 to c+1] | + old[r,c-1|c+1] | + old[r+1,c-1 to c+1] ) = FIRE then FIRE + EMPTY: if probability(ProbTree) then TREE + } +end + +procedure probability(P) #: succeed with probability P +if ?0 <= P then return +end diff --git a/Task/Forest-fire/J/forest-fire-1.j b/Task/Forest-fire/J/forest-fire-1.j new file mode 100644 index 0000000000..5d603d12b2 --- /dev/null +++ b/Task/Forest-fire/J/forest-fire-1.j @@ -0,0 +1,21 @@ +NB. states: 0 empty, 1 tree, _1 fire +dims =:10 10 + + tessellate=: 0,0,~0,.0,.~ 3 3 >./@,;._3 ] + mask=: tessellate dims$1 + chance=: 1 :'(> ? bind (dims$0)) bind (mask*m)' + +start=: 0.5 chance +grow =: 0.01 chance +fire =: 0.001 chance + + spread=: [: tessellate 0&> + + step=: grow [`]@.(|@])"0 >.&0 * _1 ^ fire +. spread + + run=:3 :0 + forest=. start'' + for.i.y do. + smoutput ' #o' {~ forest=. step forest + end. + ) diff --git a/Task/Forest-fire/J/forest-fire-2.j b/Task/Forest-fire/J/forest-fire-2.j new file mode 100644 index 0000000000..42e0012661 --- /dev/null +++ b/Task/Forest-fire/J/forest-fire-2.j @@ -0,0 +1,20 @@ + run 2 + + ##### # + # # + ### #### + # # # # + ##### # + ## # # + # # + o## # + + + ##### # + # # + ### #### + # # # # + ##### # + ## # # + o # + o# # diff --git a/Task/Forest-fire/JAMES-II-Rule-based-Cellular-Automata/forest-fire.james b/Task/Forest-fire/JAMES-II-Rule-based-Cellular-Automata/forest-fire.james new file mode 100644 index 0000000000..6dae1bb850 --- /dev/null +++ b/Task/Forest-fire/JAMES-II-Rule-based-Cellular-Automata/forest-fire.james @@ -0,0 +1,17 @@ +@caversion 1; + +dimensions 2; + +state EMPTY, TREE, BURNING; + +// an empty cell grows a tree with a chance of p = 5 % +rule{EMPTY} [0.05] : -> TREE; + +// a burning cell turns to a burned cell +rule{BURNING}: -> EMPTY; + +// a tree starts burning if there is at least one neighbor burning +rule{TREE} : BURNING{1,} -> BURNING; + +// a tree is hit by lightning with a change of f = 0.006 % +rule{TREE} [0.00006] : -> BURNING; diff --git a/Task/Forest-fire/Liberty-BASIC/forest-fire.liberty b/Task/Forest-fire/Liberty-BASIC/forest-fire.liberty new file mode 100644 index 0000000000..77a0e2a71e --- /dev/null +++ b/Task/Forest-fire/Liberty-BASIC/forest-fire.liberty @@ -0,0 +1,41 @@ +'[RC] Forest Fire + dim oldgen(200,200), newgen(200,200) + p =0.99 + f =0.9999 + + nomainwin + WindowWidth = 200 + WindowHeight = 200 + open "Forest Fire" for graphics_nsb_nf as #1 + #1 "trapclose [quit]" + #1 "down ; fill brown ; flush" + + p =0.99 + f =0.9999 + + for generation = 1 to 200 + for x = 1 to 199 + for y = 1 to 199 + scan 'we can break early + select case oldgen(x,y) + case 0 + if rnd(0) > p then newgen(x,y) = 1 : #1 "color green ; set "; x; " "; y + case 2 + newgen(x,y) = 0 : #1 "color brown ; set "; x; " "; y + case 1 + if oldgen(x-1,y-1) = 2 or oldgen(x-1,y) = 2 or oldgen(x-1,y+1) = 2_ + or oldgen(x,y-1) = 2 or oldgen(x,y+1) = 2 or oldgen(x+1,y-1) = 2_ + or oldgen(x+1,y) = 2 or oldgen(x+1,y+1) = 2 or rnd(0) > f then + #1 "color red ; set "; x; " "; y + newgen(x,y) = 2 + end if + end select + oldgen(x-1,y-1)=newgen(x-1,y-1) + next y + next x + next generation + + + [quit] + close #1 + end diff --git a/Task/Forest-fire/Mathematica/forest-fire.mathematica b/Task/Forest-fire/Mathematica/forest-fire.mathematica new file mode 100644 index 0000000000..7b03ab7475 --- /dev/null +++ b/Task/Forest-fire/Mathematica/forest-fire.mathematica @@ -0,0 +1,8 @@ +evolve[nbhd_List, k_] := 0 /; nbhd[[2, 2]] == 2 (*burning->empty*) +evolve[nbhd_List, k_] := 2 /; nbhd[[2, 2]] == 1 && Max@nbhd == 2 (*near_burning&nonempty->burning*) +evolve[nbhd_List, k_] := RandomChoice[{f, 1 - f} -> {2, nbhd[[2, 2]]}] /; nbhd[[2, 2]] == 1 && Max@nbhd < 2 (*spontaneously combusting tree*) +evolve[nbhd_List, k_] := RandomChoice[{p, 1 - p} -> {1, nbhd[[2, 2]]}] /; nbhd[[2, 2]] == 0 (*random tree growth*) + +r = 100; c = 100; p = 10^-2; f = 10^-4; +init = RandomInteger[BernoulliDistribution[0.05], {r, c}]; +MatrixPlot[CellularAutomaton[{evolve, {}, {1, 1}}, {init, 0}, {{{300}}}], ColorRules -> {0 -> White, 1 -> Green, 2 -> Red}, Frame -> False] diff --git a/Task/Fork/0DESCRIPTION b/Task/Fork/0DESCRIPTION new file mode 100644 index 0000000000..a9ed59b4b7 --- /dev/null +++ b/Task/Fork/0DESCRIPTION @@ -0,0 +1 @@ +In this task, the goal is to spawn a new [[process]] which can run simultaneously with, and independently of, the original parent process. diff --git a/Task/Fork/1META.yaml b/Task/Fork/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Fork/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Fork/ALGOL-68/fork.alg b/Task/Fork/ALGOL-68/fork.alg new file mode 100644 index 0000000000..0965b33bec --- /dev/null +++ b/Task/Fork/ALGOL-68/fork.alg @@ -0,0 +1,11 @@ +main: +( + INT pid; + IF (pid:=fork)=0 THEN + print("This is new process") + ELIF pid>0 THEN + print("This is the original process") + ELSE + print("ERROR: Something went wrong") + FI +) diff --git a/Task/Fork/Ada/fork.ada b/Task/Fork/Ada/fork.ada new file mode 100644 index 0000000000..0b074ad899 --- /dev/null +++ b/Task/Fork/Ada/fork.ada @@ -0,0 +1,18 @@ +with Ada.Text_IO, + POSIX.Process_Identification, + POSIX.Unsafe_Process_Primitives; + +procedure Fork is + use Ada.Text_IO, + POSIX.Process_Identification, + POSIX.Unsafe_Process_Primitives; +begin + if Fork = Null_Process_ID then + Put_Line ("This is the new process."); + else + Put_Line ("This is the original process."); + end if; +exception + when others => + Put_Line ("Something went wrong."); +end Fork; diff --git a/Task/Fork/Aikido/fork.aikido b/Task/Fork/Aikido/fork.aikido new file mode 100644 index 0000000000..3ba2b8fe07 --- /dev/null +++ b/Task/Fork/Aikido/fork.aikido @@ -0,0 +1,12 @@ + var pid = fork() + switch (pid) { + case <0: + println ("fork error") + break + case 0: + println ("child") + break + default: + println ("parent") + break + } diff --git a/Task/Fork/AutoHotkey/fork.ahk b/Task/Fork/AutoHotkey/fork.ahk new file mode 100644 index 0000000000..b0e8e7c87e --- /dev/null +++ b/Task/Fork/AutoHotkey/fork.ahk @@ -0,0 +1,4 @@ +MsgBox, 4, Fork, Start another process? +IfMsgBox, Yes + Run, %A_AhkPath% "%A_ScriptFullPath%" +MsgBox, 0, Fork, Stop this process. diff --git a/Task/Fork/C++/fork.cpp b/Task/Fork/C++/fork.cpp new file mode 100644 index 0000000000..d939a36bfd --- /dev/null +++ b/Task/Fork/C++/fork.cpp @@ -0,0 +1,22 @@ +#include +#include + +int main() +{ + pid_t pid = fork(); + + if (pid == 0) + { + std::cout << "This is the new process\n"; + } + else if (pid > 0) + { + std::cout << "This is the original process\n"; + } + else + { + std::cerr << "ERROR: Something went wrong\n"; + } + + return 0; +} diff --git a/Task/Fork/C/fork-1.c b/Task/Fork/C/fork-1.c new file mode 100644 index 0000000000..3e564cc2bf --- /dev/null +++ b/Task/Fork/C/fork-1.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include + +int main() +{ + pid_t pid; + + if (!(pid = fork())) { + usleep(10000); + printf("\tchild process: done\n"); + } else if (pid < 0) { + err(1, "fork error"); + } else { + printf("waiting for child %d...\n", (int)pid); + printf("child %d finished\n", (int)wait(0)); + } + + return 0; +} diff --git a/Task/Fork/C/fork-2.c b/Task/Fork/C/fork-2.c new file mode 100644 index 0000000000..25af3dc9c0 --- /dev/null +++ b/Task/Fork/C/fork-2.c @@ -0,0 +1,3 @@ +waiting for child 3604... + child process: done +child 3604 finished diff --git a/Task/Fork/Clojure/fork-1.clj b/Task/Fork/Clojure/fork-1.clj new file mode 100644 index 0000000000..1f22dcba59 --- /dev/null +++ b/Task/Fork/Clojure/fork-1.clj @@ -0,0 +1,2 @@ +(require '[clojure.java.shell :as shell]) +(shell/sh "echo" "foo") ; evaluates to {:exit 0, :out "foo\n", :err ""} diff --git a/Task/Fork/Clojure/fork-2.clj b/Task/Fork/Clojure/fork-2.clj new file mode 100644 index 0000000000..93a1015495 --- /dev/null +++ b/Task/Fork/Clojure/fork-2.clj @@ -0,0 +1,7 @@ +(let [search (future (shell/sh "find" "." "-name" "needle.*" :dir haystack))] + (while (and (other-stuff-to-do?) (not (future-done? search))) + (do-other-stuff)) + (let [{:keys [exit out err]} @search] + (if (zero? exit) + (do-something-with out) + (report-errors-in err)))) diff --git a/Task/Fork/Common-Lisp/fork.lisp b/Task/Fork/Common-Lisp/fork.lisp new file mode 100644 index 0000000000..88387282cb --- /dev/null +++ b/Task/Fork/Common-Lisp/fork.lisp @@ -0,0 +1,5 @@ +(let ((pid (sb-posix:fork))) + (cond + ((zerop pid) (write-line "This is the new process.")) + ((plusp pid) (write-line "This is the original process.")) + (t (error "Something went wrong while forking.")))) diff --git a/Task/Fork/Erlang/fork-1.erl b/Task/Fork/Erlang/fork-1.erl new file mode 100644 index 0000000000..0bd5539a98 --- /dev/null +++ b/Task/Fork/Erlang/fork-1.erl @@ -0,0 +1,9 @@ +-module(fork). +-export([start/0]). + +start() -> + spawn(fork,child,[]), + io:format("This is the original process~n"). + +child() -> + io:format("This is the new process~n"). diff --git a/Task/Fork/Erlang/fork-2.erl b/Task/Fork/Erlang/fork-2.erl new file mode 100644 index 0000000000..d93552f0ec --- /dev/null +++ b/Task/Fork/Erlang/fork-2.erl @@ -0,0 +1,2 @@ +c(fork). +fork:start(). diff --git a/Task/Fork/Factor/fork.factor b/Task/Fork/Factor/fork.factor new file mode 100644 index 0000000000..530549e1b0 --- /dev/null +++ b/Task/Fork/Factor/fork.factor @@ -0,0 +1,3 @@ +USING: unix unix.process ; + +[ "Hello form child" print flush 0 _exit ] [ drop "Hi from parent" print flush ] with-fork diff --git a/Task/Fork/Fexl/fork-1.fexl b/Task/Fork/Fexl/fork-1.fexl new file mode 100644 index 0000000000..3c8d5e4bc1 --- /dev/null +++ b/Task/Fork/Fexl/fork-1.fexl @@ -0,0 +1,2 @@ +fork \pid +print "pid = ";print pid;nl; diff --git a/Task/Fork/Fexl/fork-2.fexl b/Task/Fork/Fexl/fork-2.fexl new file mode 100644 index 0000000000..4d1b386e0d --- /dev/null +++ b/Task/Fork/Fexl/fork-2.fexl @@ -0,0 +1,87 @@ +# (spawn child_fn next) +# Fork the child function as a process and return its pid, stdin, stdout, and +# stderr. +\spawn = + ( + ### Use error-checking versions of system routines + \pipe = + (\next + pipe \status\read\write + long_lt status 0 (die "pipe failed"); + next read write + ) + + \dup2 = + (\oldfd\newfd\next + dup2 oldfd newfd \status + long_lt status 0 (die "dup2 failed"); + next + ) + + \fdopen = + (\fd\mode\next + fdopen fd mode next; + die "fdopen failed" + ) + + \fork = + (\next + fork \pid + long_lt pid 0 (die "fork failed"); + next pid + ) + + # Now here's the spawn function itself. + \child_fn\next + + # First flush the parent's stdout and stderr to avoid any pending output + # accidentally getting pushed into the child's input. I've noticed this + # can happen when your script output is sent to a file or pipe instead of + # a console. + get_stdout \fh fflush fh \_ + get_stderr \fh fflush fh \_ + + # Now create a series of pipes, each with a read and write side. + pipe \r_in\w_in + pipe \r_out\w_out + pipe \r_err\w_err + + fork \pid + long_eq pid 0 + ( + # Child process. + + # Duplicate one side of each pipe into stdin, stdout, and stderr + # as appropriate. + dup2 r_in 0; + dup2 w_out 1; + dup2 w_err 2; + + # Close unused file handles. They're all unused because we duped the + # ones we need. Also, we must close w_in or the child hangs waiting + # for stdin to close. + close r_in; close w_in; + close r_out; close w_out; + close r_err; close w_err; + + # Now run the child function, which can use stdin, stdout, and stderr + # normally. + child_fn + ) + ( + # Parent process. Open the opposite side of each pipe into three new + # file handles. + fdopen w_in "w" \child_in + fdopen r_out "r" \child_out + fdopen r_err "r" \child_err + + # Close unused file handles. We don't close the ones we fdopened + # because they are still in play (i.e. fdopen does not dup). + close r_in; + close w_out; + close w_err; + + # Return the child's pid, stdin, stdout, and stderr. + next pid child_in child_out child_err + ) + ) diff --git a/Task/Fork/Fexl/fork-3.fexl b/Task/Fork/Fexl/fork-3.fexl new file mode 100644 index 0000000000..721deee1a4 --- /dev/null +++ b/Task/Fork/Fexl/fork-3.fexl @@ -0,0 +1,72 @@ +\test_pipe = +(\next +print "== test_pipe";nl; + +### Handy + +# Echo entire contents of stream fh to stdout. +\file_print == + (\fh\next + fgetc fh \ch + long_lt ch 0 next; + putchar ch; + file_print fh next + ) + +# Show a stream with a descriptive label. +\show_stream = + (\label\fh\next + print "[ ";print label;print ":";nl; + file_print fh; + print "]";nl; + next + ) + +### Here is a child function to try with spawn. + +\child_fn = + (\next + print "Hello from child.";nl; + get_stdin \stdin + show_stream "input from parent" stdin; + print "Good bye from child.";nl; + die "Oops the child had an error!"; + next + ) + +# Spawn the child. +spawn child_fn \pid\child_in\child_out\child_err + +# Now we can communicate with the child through its three file handles. +print "Hello from parent, child pid = ";print pid;print ".";nl; + +# Say something to the child. +( +# Override print routines for convenience. +\print = (fwrite child_in) +\nl = (print NL) + +# Start talking. +print "Hello child, I am your parent!";nl; +print "OK, nice talking with you.";nl; +); + +print "The parent is now done talking to the child.";nl; + +# Now show the child's stdout and stderr streams. +show_stream "output from child" child_out; +show_stream "error from child" child_err; + +# Wait for child to finish. +wait \pid\status +# LATER shift and logical bit operators +# LATER WEXITSTATUS and other wait macros +\status = (long_div status 256) + +print "Child ";print pid;print " exited with status "; + print status;print ".";nl; +print "Good bye from parent.";nl; + +print "test_pipe completed successfully.";nl; +next +) diff --git a/Task/Fork/Fexl/fork-4.fexl b/Task/Fork/Fexl/fork-4.fexl new file mode 100644 index 0000000000..87652269cf --- /dev/null +++ b/Task/Fork/Fexl/fork-4.fexl @@ -0,0 +1 @@ +test_pipe; diff --git a/Task/Fork/Go/fork.go b/Task/Fork/Go/fork.go new file mode 100644 index 0000000000..1158d010a6 --- /dev/null +++ b/Task/Fork/Go/fork.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Printf("PID: %v\n", os.Getpid()) + if len(os.Args) < 2 { + fmt.Println("Done.") + return + } + cp, err := os.StartProcess(os.Args[0], nil, + &os.ProcAttr{Files: []*os.File{nil, os.Stdout}}, + ) + if err != nil { + fmt.Println(err) + } + // Child process running independently at this point. + // We have its PID and can print it. + fmt.Printf("Child's PID: %v\n", cp.Pid) + if _, err = cp.Wait(); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Fork/Groovy/fork.groovy b/Task/Fork/Groovy/fork.groovy new file mode 100644 index 0000000000..1e4d4aeacc --- /dev/null +++ b/Task/Fork/Groovy/fork.groovy @@ -0,0 +1,17 @@ +println "BEFORE PROCESS" +Process p = Runtime.runtime.exec(''' +C:/cygwin/bin/sh -c " +/usr/bin/date +'BEFORE LOOP: %T'; +for i in 1 2 3 4 ; do + /usr/bin/sleep 1; + /usr/bin/echo \$i; +done; +/usr/bin/date +'AFTER LOOP: %T'" +''') +p.consumeProcessOutput(System.out, System.err) +(0..<8).each { + Thread.sleep(500) + print '.' +} +p.waitFor() +println "AFTER PROCESS" diff --git a/Task/Fork/Haskell/fork.hs b/Task/Fork/Haskell/fork.hs new file mode 100644 index 0000000000..c7164ee049 --- /dev/null +++ b/Task/Fork/Haskell/fork.hs @@ -0,0 +1,5 @@ +import System.Posix.Process + +main = do + forkProcess (putStrLn "This is the new process") + putStrLn "This is the original process" diff --git a/Task/Fork/HicEst/fork.hicest b/Task/Fork/HicEst/fork.hicest new file mode 100644 index 0000000000..27367249c8 --- /dev/null +++ b/Task/Fork/HicEst/fork.hicest @@ -0,0 +1,11 @@ +SYSTEM( RUN ) + +WRITE(Messagebox='?Y', IOStat=ios) "Another Fork?" +IF(ios == 2) ALARM(999) ! quit immediately + +! assume this script is stored as 'Fork.hic' +SYSTEM(SHell='Fork.hic') + +BEEP("c e g 'c") +WRITE(Messagebox="!") "Waiting ..." +ALARM(999) ! quit immediately diff --git a/Task/Fork/Icon/fork.icon b/Task/Fork/Icon/fork.icon new file mode 100644 index 0000000000..932cdcbc31 --- /dev/null +++ b/Task/Fork/Icon/fork.icon @@ -0,0 +1,8 @@ +procedure main() + if (fork()|runerr(500)) = 0 then + write("child") + else { + delay(1000) + write("parent") + } +end diff --git a/Task/Fork/Lua/fork.lua b/Task/Fork/Lua/fork.lua new file mode 100644 index 0000000000..beba95a067 --- /dev/null +++ b/Task/Fork/Lua/fork.lua @@ -0,0 +1,10 @@ +local posix = require 'posix' + +local pid = posix.fork() +if pid == 0 then + print("child process") +elseif pid > 0 then + print("parent process") +else + error("unable to fork") +end diff --git a/Task/Fork/Mathematica/fork.mathematica b/Task/Fork/Mathematica/fork.mathematica new file mode 100644 index 0000000000..68e0cbcba6 --- /dev/null +++ b/Task/Fork/Mathematica/fork.mathematica @@ -0,0 +1,5 @@ +commandstring = First[$CommandLine] <> " -noprompt -run \"Put[Factorial[20],ToFileName[$TemporaryDirectory,ToString[temp1]]];Quit[]\"" +->"MathKernel -noprompt -run \"Put[Factorial[20],ToFileName[$TemporaryDirectory,ToString[temp1]]];Quit[]\"" + +Run[commandstring] +->0 diff --git a/Task/Fork/PHP/fork.php b/Task/Fork/PHP/fork.php new file mode 100644 index 0000000000..af1bf2875c --- /dev/null +++ b/Task/Fork/PHP/fork.php @@ -0,0 +1,9 @@ + 0) + echo "This is the original process\n"; +else + echo "ERROR: Something went wrong\n"; +?> diff --git a/Task/Fork/Perl/fork-1.pl b/Task/Fork/Perl/fork-1.pl new file mode 100644 index 0000000000..bd3688807d --- /dev/null +++ b/Task/Fork/Perl/fork-1.pl @@ -0,0 +1,25 @@ +FORK: +if ($pid = fork()) { + # parent code +} elsif (defined($pid)) { + setsid; # tells apache to let go of this process and let it run solo + # disconnect ourselves from input, output, and errors + close(STDOUT); + close(STDIN); + close(STDERR); + # re-open to /dev/null to prevent irrelevant warn messages. + open(STDOUT, '>/dev/null'); + open(STDIN, '>/dev/null'); + open(STDERR, '>>/home/virtual/logs/err.log'); + + # child code + + exit; # important to exit +} elsif($! =~ /emporar/){ + warn '[' . localtime() . "] Failed to Fork - Will try again in 10 seconds.\n"; + sleep(10); + goto FORK; +} else { + warn '[' . localtime() . "] Unable to fork - $!"; + exit(0); +} diff --git a/Task/Fork/Perl/fork-2.pl b/Task/Fork/Perl/fork-2.pl new file mode 100644 index 0000000000..409c4023c2 --- /dev/null +++ b/Task/Fork/Perl/fork-2.pl @@ -0,0 +1,9 @@ +use Proc::Fork; +run_fork { + child { + # child code ... + } + parent { + # parent code ... + } +}; diff --git a/Task/Fork/Perl/fork-3.pl b/Task/Fork/Perl/fork-3.pl new file mode 100644 index 0000000000..bcc06bcc08 --- /dev/null +++ b/Task/Fork/Perl/fork-3.pl @@ -0,0 +1,8 @@ +use Proc::Fork; +# parent code ... +run_fork { + child { + # child code ... + } +}; +# parent code continues ... diff --git a/Task/Fork/Perl/fork-4.pl b/Task/Fork/Perl/fork-4.pl new file mode 100644 index 0000000000..90fac81630 --- /dev/null +++ b/Task/Fork/Perl/fork-4.pl @@ -0,0 +1,15 @@ +use Proc::Fork; +run_fork { + child { + # child code ... + } + parent { + # parent code ... + } + retry { + # retry code ... + } + error { + # error handling ... + } +}; diff --git a/Task/Fork/PicoLisp/fork.l b/Task/Fork/PicoLisp/fork.l new file mode 100644 index 0000000000..56779d49b2 --- /dev/null +++ b/Task/Fork/PicoLisp/fork.l @@ -0,0 +1,3 @@ +(unless (fork) # In child process + (println *Pid) # Print the child's PID + (bye) ) # and terminate diff --git a/Task/Fork/Python/fork.py b/Task/Fork/Python/fork.py new file mode 100644 index 0000000000..c3a5e0a9bf --- /dev/null +++ b/Task/Fork/Python/fork.py @@ -0,0 +1,7 @@ +import os + +pid = os.fork() +if pid > 0: + # parent code +else: + # child code diff --git a/Task/Fork/REXX/fork.rexx b/Task/Fork/REXX/fork.rexx new file mode 100644 index 0000000000..ff794792b8 --- /dev/null +++ b/Task/Fork/REXX/fork.rexx @@ -0,0 +1 @@ +child = fork() diff --git a/Task/Fork/Ruby/fork-1.rb b/Task/Fork/Ruby/fork-1.rb new file mode 100644 index 0000000000..5a9cbd4267 --- /dev/null +++ b/Task/Fork/Ruby/fork-1.rb @@ -0,0 +1,6 @@ +pid = fork +if pid + # parent code +else + # child code +end diff --git a/Task/Fork/Ruby/fork-2.rb b/Task/Fork/Ruby/fork-2.rb new file mode 100644 index 0000000000..a0d308f2b4 --- /dev/null +++ b/Task/Fork/Ruby/fork-2.rb @@ -0,0 +1,4 @@ +fork do + # child code +end +# parent code diff --git a/Task/Fork/Smalltalk/fork.st b/Task/Fork/Smalltalk/fork.st new file mode 100644 index 0000000000..678c214f73 --- /dev/null +++ b/Task/Fork/Smalltalk/fork.st @@ -0,0 +1,10 @@ +'Here I am' displayNl. +|a| +a := [ + (Delay forSeconds: 2) wait . + 1 to: 100 do: [ :i | i displayNl ] +] fork. +'Child will start after 2 seconds' displayNl. +"wait to avoid terminating first the parent; + a better way should use semaphores" +(Delay forSeconds: 10) wait. diff --git a/Task/Fork/Tcl/fork.tcl b/Task/Fork/Tcl/fork.tcl new file mode 100644 index 0000000000..a73e04db36 --- /dev/null +++ b/Task/Fork/Tcl/fork.tcl @@ -0,0 +1,19 @@ +package require Expect +# or +package require Tclx + +for {set i 0} {$i < 100} {incr i} { + set pid [fork] + switch $pid { + -1 { + puts "Fork attempt #$i failed." + } + 0 { + puts "I am child process #$i." + exit + } + default { + puts "The parent just spawned child process #$i." + } + } +} diff --git a/Task/Formal-power-series/0DESCRIPTION b/Task/Formal-power-series/0DESCRIPTION new file mode 100644 index 0000000000..606a514ad1 --- /dev/null +++ b/Task/Formal-power-series/0DESCRIPTION @@ -0,0 +1,17 @@ +A ''power series'' is an infinite sum of the form + +a_0 + a_1 \cdot x + a_2 \cdot x^2 + a_3 \cdot x^3 + \cdots + +The ''ai'' are called the ''coefficients'' of the series. Such sums can be added, multiplied etc., where the new coefficients of the powers of ''x'' are calculated according to the usual rules. + +If one is not interested in evaluating such a series for particular values of ''x'', or in other words, if convergence doesn't play a role, then such a collection of coefficients is called ''formal power series''. It can be treated like a new kind of number. + +'''Task''': Implement formal power series as a numeric type. Operations should at least include ''addition'', ''multiplication'', ''division'' and additionally non-numeric operations like ''differentiation'' and ''integration'' (with an integration constant of zero). Take care that your implementation deals with the potentially infinite number of coefficients. + +As an example, define the power series of sine and cosine in terms of each other using integration, as in + +\sin x = \int_0^x \cos t\, dt + +\cos x = 1 - \int_0^x \sin t\, dt + +'''Goals''': Demonstrate how the language handles new numeric types and delayed (or ''lazy'') evaluation. diff --git a/Task/Formal-power-series/1META.yaml b/Task/Formal-power-series/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Formal-power-series/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Formal-power-series/Ada/formal-power-series-1.ada b/Task/Formal-power-series/Ada/formal-power-series-1.ada new file mode 100644 index 0000000000..66ea38df78 --- /dev/null +++ b/Task/Formal-power-series/Ada/formal-power-series-1.ada @@ -0,0 +1,23 @@ +with Generic_Rational; + +generic + with package Rational_Numbers is new Generic_Rational (<>); +package Generic_Taylor_Series is + use Rational_Numbers; + type Taylor_Series is array (Natural range <>) of Rational; + + function "+" (A : Taylor_Series) return Taylor_Series; + function "-" (A : Taylor_Series) return Taylor_Series; + + function "+" (A, B : Taylor_Series) return Taylor_Series; + function "-" (A, B : Taylor_Series) return Taylor_Series; + function "*" (A, B : Taylor_Series) return Taylor_Series; + + function Integral (A : Taylor_Series) return Taylor_Series; + function Differential (A : Taylor_Series) return Taylor_Series; + + function Value (A : Taylor_Series; X : Rational) return Rational; + + Zero : constant Taylor_Series := (0 => Rational_Numbers.Zero); + One : constant Taylor_Series := (0 => Rational_Numbers.One); +end Generic_Taylor_Series; diff --git a/Task/Formal-power-series/Ada/formal-power-series-2.ada b/Task/Formal-power-series/Ada/formal-power-series-2.ada new file mode 100644 index 0000000000..0497fbb420 --- /dev/null +++ b/Task/Formal-power-series/Ada/formal-power-series-2.ada @@ -0,0 +1,103 @@ +package body Generic_Taylor_Series is + function Normalize (A : Taylor_Series) return Taylor_Series is + begin + for Power in reverse A'Range loop + if A (Power) /= 0 then + return A (0..Power); + end if; + end loop; + return Zero; + end Normalize; + + function "+" (A : Taylor_Series) return Taylor_Series is + begin + return A; + end "+"; + + function "-" (A : Taylor_Series) return Taylor_Series is + Result : Taylor_Series (A'Range); + begin + for Power in A'Range loop + Result (Power) := -A (Power); + end loop; + return Result; + end "-"; + + function "+" (A, B : Taylor_Series) return Taylor_Series is + begin + if A'Last > B'Last then + return B + A; + else + declare + Result : Taylor_Series (0..B'Last); + begin + for Power in A'Range loop + Result (Power) := A (Power) + B (Power); + end loop; + for Power in A'Last + 1..B'Last loop + Result (Power) := B (Power); + end loop; + return Normalize (Result); + end; + end if; + end "+"; + + function "-" (A, B : Taylor_Series) return Taylor_Series is + begin + return A + (-B); + end "-"; + + function "*" (A, B : Taylor_Series) return Taylor_Series is + Result : Taylor_Series (0..A'Last + B'Last); + begin + for I in A'Range loop + for J in B'Range loop + Result (I + J) := A (I) * B (J); + end loop; + end loop; + return Normalize (Result); + end "*"; + + function Integral (A : Taylor_Series) return Taylor_Series is + begin + if A = Zero then + return Zero; + else + declare + Result : Taylor_Series (0..A'Last + 1); + begin + for Power in A'Range loop + Result (Power + 1) := A (Power) / Number (Power + 1); + end loop; + Result (0) := Rational_Numbers.Zero; + return Result; + end; + end if; + end Integral; + + function Differential (A : Taylor_Series) return Taylor_Series is + begin + if A'Length = 1 then + return Zero; + else + declare + Result : Taylor_Series (0..A'Last - 1); + begin + for Power in Result'Range loop + Result (Power) := A (Power + 1) * Number (Power); + end loop; + return Result; + end; + end if; + end Differential; + + function Value (A : Taylor_Series; X : Rational) return Rational is + Sum : Rational := A (A'Last); + begin + for Power in reverse 0..A'Last - 1 loop + Sum := Sum * X + A (Power); + end loop; + return Sum; + end Value; + +end Generic_Taylor_Series; diff --git a/Task/Formal-power-series/Ada/formal-power-series-3.ada b/Task/Formal-power-series/Ada/formal-power-series-3.ada new file mode 100644 index 0000000000..827f87910d --- /dev/null +++ b/Task/Formal-power-series/Ada/formal-power-series-3.ada @@ -0,0 +1,53 @@ +with Ada.Text_IO; use Ada.Text_IO; + +with Generic_Taylor_Series; +with Generic_Rational; + +procedure Test_Taylor_Series is + package Integer_Rationals is new Generic_Rational (Integer); + package Integer_Taylor_Series is new Generic_Taylor_Series (Integer_Rationals); + use Integer_Taylor_Series; + -- Procedure to print a series + procedure Put (A : Taylor_Series) is + use Integer_Rationals; + procedure Put (A : Rational) is + begin + if Numerator (A) = 1 then + Put (" 1"); + else + Put (Integer'Image (Numerator (A))); + end if; + if Denominator (A) /= 1 then + Put (" /"); + Put (Integer'Image (Denominator (A))); + end if; + end Put; + begin + if A (0) /= 0 then + Put (A (0)); + end if; + for Power in 1..A'Last loop + if A (Power) > 0 then + Put (" +"); + Put (A (Power)); + Put (" X **" & Integer'Image (Power)); + elsif A (Power) < 0 then + Put (" -"); + Put (abs A (Power)); + Put (" X **" & Integer'Image (Power)); + end if; + end loop; + end Put; + -- Cosine generator + function Cos (N : Natural) return Taylor_Series is + begin + if N = 0 then + return One; + else + return One - Integral (Integral (Cos (N - 1))); + end if; + end Cos; +begin + Put ("Cos ="); Put (Cos (5)); Put_Line (" ..."); + Put ("Sin ="); Put (Integral (Cos (5))); Put_Line (" ..."); +end Test_Taylor_Series; diff --git a/Task/Formal-power-series/C/formal-power-series.c b/Task/Formal-power-series/C/formal-power-series.c new file mode 100644 index 0000000000..e00fb53717 --- /dev/null +++ b/Task/Formal-power-series/C/formal-power-series.c @@ -0,0 +1,142 @@ +#include +#include +#include /* for NaN */ + +enum fps_type { + FPS_CONST = 0, + FPS_ADD, + FPS_SUB, + FPS_MUL, + FPS_DIV, + FPS_DERIV, + FPS_INT, +}; + +typedef struct fps_t *fps; +typedef struct fps_t { + int type; + fps s1, s2; + double a0; +} fps_t; + +fps fps_new() +{ + fps x = malloc(sizeof(fps_t)); + x->a0 = 0; + x->s1 = x->s2 = 0; + x->type = 0; + return x; +} + +/* language limit of C; when self or mutual recursive definition is needed, + * one has to be defined, then defined again after it's used. See how + * sin and cos are defined this way below + */ +void fps_redefine(fps x, int op, fps y, fps z) +{ + x->type = op; + x->s1 = y; + x->s2 = z; +} + +fps _binary(fps x, fps y, int op) +{ + fps s = fps_new(); + s->s1 = x; + s->s2 = y; + s->type = op; + return s; +} + +fps _unary(fps x, int op) +{ + fps s = fps_new(); + s->s1 = x; + s->type = op; + return s; +} + +/* Taking the n-th term of series. This is where actual work is done. */ +double term(fps x, int n) +{ + double ret = 0; + int i; + + switch (x->type) { + case FPS_CONST: return n > 0 ? 0 : x->a0; + case FPS_ADD: + ret = term(x->s1, n) + term(x->s2, n); break; + + case FPS_SUB: + ret = term(x->s1, n) - term(x->s2, n); break; + + case FPS_MUL: + for (i = 0; i <= n; i++) + ret += term(x->s1, i) * term(x->s2, n - i); + break; + + case FPS_DIV: + if (! term(x->s2, 0)) return NAN; + + ret = term(x->s1, n); + for (i = 1; i <= n; i++) + ret -= term(x->s2, i) * term(x, n - i) / term(x->s2, 0); + break; + + case FPS_DERIV: + ret = n * term(x->s1, n + 1); + break; + + case FPS_INT: + if (!n) return x->a0; + ret = term(x->s1, n - 1) / n; + break; + + default: + fprintf(stderr, "Unknown operator %d\n", x->type); + exit(1); + } + + return ret; +} + +#define _add(x, y) _binary(x, y, FPS_ADD) +#define _sub(x, y) _binary(x, y, FPS_SUB) +#define _mul(x, y) _binary(x, y, FPS_MUL) +#define _div(x, y) _binary(x, y, FPS_DIV) +#define _integ(x) _unary(x, FPS_INT) +#define _deriv(x) _unary(x, FPS_DERIV) + +fps fps_const(double a0) +{ + fps x = fps_new(); + x->type = FPS_CONST; + x->a0 = a0; + return x; +} + +int main() +{ + int i; + fps one = fps_const(1); + fps fcos = fps_new(); /* cosine */ + fps fsin = _integ(fcos); /* sine */ + fps ftan = _div(fsin, fcos); /* tangent */ + + /* redefine cos to complete the mutual recursion; maybe it looks + * better if I said + * *fcos = *( _sub(one, _integ(fsin)) ); + */ + fps_redefine(fcos, FPS_SUB, one, _integ(fsin)); + + fps fexp = fps_const(1); /* exponential */ + /* make exp recurse on self */ + fps_redefine(fexp, FPS_INT, fexp, 0); + + printf("Sin:"); for (i = 0; i < 10; i++) printf(" %g", term(fsin, i)); + printf("\nCos:"); for (i = 0; i < 10; i++) printf(" %g", term(fcos, i)); + printf("\nTan:"); for (i = 0; i < 10; i++) printf(" %g", term(ftan, i)); + printf("\nExp:"); for (i = 0; i < 10; i++) printf(" %g", term(fexp, i)); + + return 0; +} diff --git a/Task/Formal-power-series/Clojure/formal-power-series-1.clj b/Task/Formal-power-series/Clojure/formal-power-series-1.clj new file mode 100644 index 0000000000..eed68c591a --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-1.clj @@ -0,0 +1,8 @@ +(defn ps+ [ps0 ps1] + (letfn [(+zs [ps] (concat ps (repeat :z))) + (notz? [a] (not= :z a)) + (nval [a] (if (notz? a) a 0)) + (z+ [a0 a1] (if (= :z a0 a1) :z (+ (nval a0) (nval a1))))] + (take-while notz? (map z+ (+zs ps0) (+zs ps1))))) + +(defn ps- [ps0 ps1] (ps+ ps0 (map - ps1))) diff --git a/Task/Formal-power-series/Clojure/formal-power-series-2.clj b/Task/Formal-power-series/Clojure/formal-power-series-2.clj new file mode 100644 index 0000000000..2300fd929e --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-2.clj @@ -0,0 +1,9 @@ +(defn ps* + ([ps0 ps1] (ps* [0] ps0 ps1)) + ([[a0 & resta] [p0 & rest0] [p1 & rest1 :as ps1]] + (lazy-seq + (cons + (+ a0 (* p0 p1)) + (let [mrest1 (if (or (nil? rest1) (zero? p0)) nil, (map #(* p0 %) rest1)) + accum (cond (nil? resta) mrest1, (nil? mrest1) resta, :else (ps+ resta mrest1))] + (if (nil? rest0) accum, (ps* (or accum [0]) rest0 ps1))))))) diff --git a/Task/Formal-power-series/Clojure/formal-power-series-3.clj b/Task/Formal-power-series/Clojure/formal-power-series-3.clj new file mode 100644 index 0000000000..db942a145b --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-3.clj @@ -0,0 +1,7 @@ +(defn indexed [ps] (map vector (iterate inc 0) ps)) + +(defn differentiate [ps] + (drop 1 (for [[n a] (indexed ps)] (* n a)))) + +(defn integrate [ps] + (cons 0 (for [[n a] (indexed ps)] (/ a (inc n))))) diff --git a/Task/Formal-power-series/Clojure/formal-power-series-4.clj b/Task/Formal-power-series/Clojure/formal-power-series-4.clj new file mode 100644 index 0000000000..4a6badcd99 --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-4.clj @@ -0,0 +1,5 @@ +(println (ps+ [1 2] [3 4 5])) +; (4 6 5) + +(println (ps* [1 2] [3 4 5])) +; (3 10 13 10) diff --git a/Task/Formal-power-series/Clojure/formal-power-series-5.clj b/Task/Formal-power-series/Clojure/formal-power-series-5.clj new file mode 100644 index 0000000000..6a6d7937e1 --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-5.clj @@ -0,0 +1,14 @@ +(def nfacts (iterate (fn [[f n]] [(* f n) (inc n)]) [1 1])) +(def facts (map first nfacts)) + +(def sin (map / (cycle [0 1 0 -1]) facts)) +(def cos (map / (cycle [1 0 -1 0]) facts)) + +(println (take 10 sin)) +; (0 1 0 -1/6 0 1/120 0 -1/5040 0 1/362880) + +(println (take 10 (integrate cos))) +; (0 1 0 -1/6 0 1/120 0 -1/5040 0 1/362880) + +(println (take 20 (ps+ (ps* sin sin) (ps* cos cos)))) +; (1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) diff --git a/Task/Formal-power-series/Clojure/formal-power-series-6.clj b/Task/Formal-power-series/Clojure/formal-power-series-6.clj new file mode 100644 index 0000000000..0b7cc0ea31 --- /dev/null +++ b/Task/Formal-power-series/Clojure/formal-power-series-6.clj @@ -0,0 +1,7 @@ +(letfn [(fsin [] (lazy-seq (integrate (fcos)))) + (fcos [] (ps- [1] (integrate (fsin))))] + (def sinx (fsin)) + (def cosx (fcos))) + +(println (take 10 sinx)) +; (0 1 0 -1/6 0 1/120 0 -1/5040 0 1/362880) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-1.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-1.lisp new file mode 100644 index 0000000000..8343465d72 --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-1.lisp @@ -0,0 +1,7 @@ +(defpackage #:formal-power-series + (:nicknames #:fps) + (:use "COMMON-LISP") + (:shadow + #:+ #:- #:* #:/)) + +(in-package #:formal-power-series) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-2.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-2.lisp new file mode 100644 index 0000000000..cff7e2c831 --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-2.lisp @@ -0,0 +1,15 @@ +(defstruct promise + thunk value) + +(defmacro delay (form) + `(make-promise :thunk #'(lambda () ,form))) + +(defun force (object) + (cond + ((not (promise-p object)) + object) + ((null (promise-thunk object)) + (promise-value object)) + (t (let ((val (funcall (promise-thunk object)))) + (setf (promise-thunk object) nil + (promise-value object) val))))) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-3.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-3.lisp new file mode 100644 index 0000000000..f2a8448f9a --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-3.lisp @@ -0,0 +1,15 @@ +(defstruct lons + lar + ldr) + +(defun lar (lons) + (lons-lar lons)) + +(defun ldr (lons) + (if (not (promise-p (lons-ldr lons))) + (lons-ldr lons) + (setf (lons-ldr lons) + (force (lons-ldr lons))))) + +(defmacro lons (lar ldr) + `(make-lons :lar ,lar :ldr (delay ,ldr))) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-4.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-4.lisp new file mode 100644 index 0000000000..a5f834ebd3 --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-4.lisp @@ -0,0 +1,27 @@ +(defun invoke-with-lons (function lons) + (funcall function (lar lons) (ldr lons))) + +(defmacro with-lons ((lar ldr) lons &body body) + `(invoke-with-lons #'(lambda (,lar ,ldr) ,@body) ,lons)) + +(defun maplar (function llist &rest llists) + (let ((llists (list* llist llists))) + (if (some 'null llists) nil + (lons (apply function (cl:mapcar 'lar llists)) + (apply 'maplar function (cl:mapcar 'ldr llists)))))) + +(defun take (n llist) + (if (zerop n) '() + (lons (lar llist) + (take (1- n) (ldr llist))))) + +(defun force-list (llist) + (do ((fl '() (cons (lar l) fl)) + (l llist (ldr l))) + ((null l) (nreverse fl)))) + +(defun repeat (x) + (lons x (repeat x))) + +(defun up-from (n) + (lons n (up-from (1+ n)))) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-5.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-5.lisp new file mode 100644 index 0000000000..1fbf0e2c83 --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-5.lisp @@ -0,0 +1,65 @@ +(defstruct (series (:constructor series (coeffs)) (:conc-name)) + coeffs) + +(defgeneric negate (f) + (:method (f) + (cl:- f)) + (:method ((f series)) + (series (maplar 'negate (coeffs f))))) + +(defgeneric + (f g) + (:method (f g) + (cl:+ f g)) + (:method (f (g series)) + (series (lons (+ f (lar (coeffs g))) (ldr (coeffs g))))) + (:method ((f series) g) + (+ g f)) + (:method ((f series) (g series)) + (series (maplar '+ (coeffs f) (coeffs g))))) + +(defun - (f g) + (+ f (negate g))) + +(defun series-* (f g) + (with-lons (f ft) (coeffs f) + (with-lons (g gt) (coeffs g) + (series (lons (* f g) + (coeffs (+ (* (series ft) + (series gt)) + (* f (series gt))))))))) + +(defgeneric * (f g) + (:method (f g) + (cl:* f g)) + (:method ((f series) g) + (series (maplar #'(lambda (x) (* x g)) (coeffs f)))) + (:method (f (g series)) + (* g f)) + (:method ((f series) (g series)) + (series-* f g))) + +(defun series-/ (f g) + (with-lons (f ft) (coeffs f) + (with-lons (g gt) (coeffs g) + (let ((qs nil)) + (setf qs (lons (/ f g) + (maplar #'(lambda (x) (/ x g)) + (coeffs (- (series ft) + (* (series qs) + (series gt))))))))))) + +(defgeneric / (f g) + (:method (f g) + (cl:/ f g)) + (:method ((f series) g) + (series (maplar #'(lambda (x) (/ x g)) (coeffs f)))) + (:method (f (g series)) + (/ (series (lons f (repeat 0))) g)) + (:method ((f series) (g series)) + (series-/ f g))) + +(defun int (f) + (series (lons 0 (maplar '/ (coeffs (force f)) (up-from 1))))) + +(defun diff (f) + (series (maplar '* (ldr (coeffs f)) (up-from 1)))) diff --git a/Task/Formal-power-series/Common-Lisp/formal-power-series-6.lisp b/Task/Formal-power-series/Common-Lisp/formal-power-series-6.lisp new file mode 100644 index 0000000000..a4252f1ab5 --- /dev/null +++ b/Task/Formal-power-series/Common-Lisp/formal-power-series-6.lisp @@ -0,0 +1,6 @@ +(defparameter *sinx* + (locally (declare (special *cosx*)) + (delay (int (force *cosx*))))) + +(defparameter *cosx* + (delay (- 1 (int *sinx*)))) diff --git a/Task/Formal-power-series/Elisa/formal-power-series-1.elisa b/Task/Formal-power-series/Elisa/formal-power-series-1.elisa new file mode 100644 index 0000000000..a79cf3e7f8 --- /dev/null +++ b/Task/Formal-power-series/Elisa/formal-power-series-1.elisa @@ -0,0 +1,59 @@ +component FormalPowerSeries(Number); + type PowerSeries; + PowerSeries(Size = integer) -> PowerSeries; + + + PowerSeries -> PowerSeries; + - PowerSeries -> PowerSeries; + + PowerSeries + PowerSeries -> PowerSeries; + PowerSeries - PowerSeries -> PowerSeries; + PowerSeries * PowerSeries -> PowerSeries; + + Integral(PowerSeries) -> PowerSeries; + Differential(PowerSeries) -> PowerSeries; + + Zero -> PowerSeries; + One -> PowerSeries; + + Array(PowerSeries) -> array(Number); + begin + PowerSeries(Size) = PowerSeries:[T = array(Number, Size); Size]; + + + A = A; + + - A = [ C = PowerSeries(A.Size); + [ i = 1 .. A.Size; C.T[i] := - A.T[i] ]; + C]; + + A + B = [ if A.Size > B.Size then return(B + A); + C = PowerSeries(B.Size); + [ i = 1 .. A.Size; C.T[i] := A.T[i] + B.T[i] ]; + [ i = (A.Size +1) .. B.Size; C.T[i] := B.T[i] ]; + C]; + + A - B = A + (- B ); + + A * B = [ C = PowerSeries(A.Size + B.Size - 1); + [ i = 1 .. A.Size; + [j = 1.. B.Size; + C.T[i + j - 1] := C.T[i + j - 1] + A.T[i] * B.T[j] ] ]; + C]; + + Integral(A) = [ if A.Size == 0 then return (A); + C = PowerSeries(A.Size + 1); + [ i = 1 .. A.Size; C.T[i +1] := A.T[i] / Number( i )]; + C.T[1]:= Number(0); + C ]; + + Differential(A) = [ if A.Size == 1 then return (A); + C = PowerSeries(A.Size - 1); + [ i = 1 .. C.Size; C.T[i] := A.T[i + 1] * Number( i )]; + C ]; + + Zero = [ C = PowerSeries (1); C.T[1]:= Number(0); C]; + One = [ C = PowerSeries (1); C.T[1]:= Number(1); C]; + + Array(PowerSeries) -> array(Number); + Array(TS) = TS.T; + +end component FormalPowerSeries; diff --git a/Task/Formal-power-series/Elisa/formal-power-series-2.elisa b/Task/Formal-power-series/Elisa/formal-power-series-2.elisa new file mode 100644 index 0000000000..da3026a00d --- /dev/null +++ b/Task/Formal-power-series/Elisa/formal-power-series-2.elisa @@ -0,0 +1,28 @@ +use RationalNumbers; +use FormalPowerSeries(Rational); + + X => symbol; + term + term => term; + term / term => term; + term * term => term; + symbol ** integer => term; + + Output(text,PowerSeries) -> term; + Output(Name,PS) = [ E1 := term:symbol(Name); E2:= null(term); + [ i = 1..size(Array(PS)); + Num = Numerator(Array(PS)[i]); + if Num <> 0 then + [ E2:= term: Num / term: Denominator(Array(PS)[i]) * X ** (i-1); + E1:= E1 + E2 ]; + ]; + E1]; + + Cos(integer) -> PowerSeries; + Cos(Limit) = [ if Limit == 1 then return(One); + ( One - Integral(Integral(Cos (Limit - 1)))) ]; + + Sin(integer) -> PowerSeries; + Sin(Limit) = Integral(Cos (Limit)); + + Output("cos = ",Cos(5))? + Output("sin = ",Sin(5))? diff --git a/Task/Formal-power-series/Elisa/formal-power-series-3.elisa b/Task/Formal-power-series/Elisa/formal-power-series-3.elisa new file mode 100644 index 0000000000..871d82f7e7 --- /dev/null +++ b/Task/Formal-power-series/Elisa/formal-power-series-3.elisa @@ -0,0 +1,2 @@ +cos = + 1 / 1 * X ** 0 + -1 / 2 * X ** 2 + 1 / 24 * X ** 4 + -1 / 720 * X ** 6 + 1 / 40320 * X ** 8 +sin = + 1 / 1 * X ** 1 + -1 / 6 * X ** 3 + 1 / 120 * X ** 5 + -1 / 5040 * X ** 7 + 1 / 362880 * X ** 9 diff --git a/Task/Formal-power-series/Go/formal-power-series.go b/Task/Formal-power-series/Go/formal-power-series.go new file mode 100644 index 0000000000..804c12c4de --- /dev/null +++ b/Task/Formal-power-series/Go/formal-power-series.go @@ -0,0 +1,232 @@ +package main + +import ( + "fmt" + "math" +) + +// Task: Formal power series type +// +// Go does not have a concept of numeric types other than the built in +// integers, floating points, and so on. Nor does it have function or +// operator overloading, or operator defintion. The type use to implement +// fps here is an interface with a single method, extract. +// While not named in the task description, extract is described in the +// WP article as "important." In fact, by representing a way to index +// all of the coefficients of a fps, any type that implements the interface +// represents a formal power series. + +type fps interface { + extract(int) float64 +} + +// Task: Operations on FPS +// +// Separate operations are implemented with separate extract methods. +// This requires each operation on the fps type to have a concrete type. +// Executing a fps operation is the act of instantiating the concrete type. +// This is implemented here with constructor functions that construct a +// new fps from fps arguments. + +// Constructor functions are shown here as a group, followed by concrete +// type definitions and associated extract methods. + +func one() fps { + return &oneFps{} +} + +func add(s1, s2 fps) fps { + return &sum{s1: s1, s2: s2} +} + +func sub(s1, s2 fps) fps { + return &diff{s1: s1, s2: s2} +} + +func mul(s1, s2 fps) fps { + return &prod{s1: s1, s2: s2} +} + +func div(s1, s2 fps) fps { + return &quo{s1: s1, s2: s2} +} + +func differentiate(s1 fps) fps { + return &deriv{s1: s1} +} + +func integrate(s1 fps) fps { + return &integ{s1: s1} +} + +// Example: Mutually recursive defintion of sine and cosine. +// This is a constructor just as those above. It is nullary and returns +// two fps. Note sin and cos implemented as instances of other fps defined +// above, and so do not need new concrete types. Note also the constant +// term of the integration fps provides the case that terminates recursion +// of the extract function. +func sinCos() (fps, fps) { + sin := &integ{} + cos := sub(one(), integrate(sin)) + sin.s1 = cos + return sin, cos +} + +// Following are type definitions and extract methods for fps operators +// (constructor functions) just defined. +// +// Goal: lazy evaluation +// +// Go has no built in support for lazy evaluation, so we make it from +// scratch here. Types contain, at a minimum, their fps operands and +// representation neccessary to implement lazy evaluation. Typically +// this is a coefficient slice, although constant terms are not stored, +// so in the case of a constant fps, no slice is needed at all. +// Coefficients are generated only as they are requested. Computed +// coefficients are stored in the slice and if requested subsequently, +// are returned immediately rather than recomputed. +// +// Types can also contain any other intermediate values useful for +// computing coefficients. + +// Constant one: A constant is a nullary function and no coefficent +// storage is needed so an empty struct is used for the type. +type oneFps struct{} + +// The extract method implements the fps interface. It simply has to +// return 1 for the first term and return 0 for all other terms. +func (*oneFps) extract(n int) float64 { + if n == 0 { + return 1 + } + return 0 +} + +// Addition is a binary function so the sum type stores its two fps operands +// and its computed terms. +type sum struct { + s []float64 + s1, s2 fps +} + +func (s *sum) extract(n int) float64 { + for i := len(s.s); i <= n; i++ { + s.s = append(s.s, s.s1.extract(i)+s.s2.extract(i)) + } + return s.s[n] +} + +// Subtraction and other binary operations are similar. +// (The common field definitions could be factored out with an embedded +// struct, but the clutter of the extra syntax required doesn't seem +// to be worthwhile.) +type diff struct { + s []float64 + s1, s2 fps +} + +func (s *diff) extract(n int) float64 { + for i := len(s.s); i <= n; i++ { + s.s = append(s.s, s.s1.extract(i)-s.s2.extract(i)) + } + return s.s[n] +} + +type prod struct { + s []float64 + s1, s2 fps +} + +func (s *prod) extract(n int) float64 { + for i := len(s.s); i <= n; i++ { + c := 0. + for k := 0; k <= i; k++ { + c += s.s1.extract(k) * s.s1.extract(n-k) + } + s.s = append(s.s, c) + } + return s.s[n] +} + +// Note a couple of fields in addition to those of other binary operators. +// They simply optimize computations a bit. +type quo struct { + s1, s2 fps + inv float64 // optimizes a divide + c []float64 // saves multiplications + s []float64 +} + +// WP formula. Note the limitation s2[0] cannot be 0. In this case +// the function returns NaN for all terms. The switch statement catches +// this case and avoids storing a slice of all NaNs. +func (s *quo) extract(n int) float64 { + switch { + case len(s.s) > 0: + case !math.IsInf(s.inv, 1): + a0 := s.s2.extract(0) + s.inv = 1 / a0 + if a0 != 0 { + break + } + fallthrough + default: + return math.NaN() + } + for i := len(s.s); i <= n; i++ { + c := 0. + for k := 1; k <= i; k++ { + c += s.s2.extract(k) * s.c[n-k] + } + c = s.s1.extract(i) - c*s.inv + s.c = append(s.c, c) + s.s = append(s.s, c*s.inv) + } + return s.s[n] +} + +// Note differentiation and integration are unary so their types contain +// only a single fps operand. + +type deriv struct { + s []float64 + s1 fps +} + +func (s *deriv) extract(n int) float64 { + for i := len(s.s); i <= n; { + i++ + s.s = append(s.s, float64(i)*s.s1.extract(i)) + } + return s.s[n] +} + +type integ struct { + s []float64 + s1 fps +} + +func (s *integ) extract(n int) float64 { + if n == 0 { + return 0 // constant term C=0 + } + // with constant term handled, s starts at 1 + for i := len(s.s) + 1; i <= n; i++ { + s.s = append(s.s, s.s1.extract(i-1)/float64(i)) + } + return s.s[n-1] +} + +// Demonstrate working sin, cos. +func main() { + // Format several terms in a way that is easy to compare visually. + partialSeries := func(f fps) (s string) { + for i := 0; i < 6; i++ { + s = fmt.Sprintf("%s %8.5f ", s, f.extract(i)) + } + return + } + sin, cos := sinCos() + fmt.Println("sin:", partialSeries(sin)) + fmt.Println("cos:", partialSeries(cos)) +} diff --git a/Task/Formal-power-series/Haskell/formal-power-series.hs b/Task/Formal-power-series/Haskell/formal-power-series.hs new file mode 100644 index 0000000000..4f7dd25327 --- /dev/null +++ b/Task/Formal-power-series/Haskell/formal-power-series.hs @@ -0,0 +1,25 @@ +newtype Series a = S { coeffs :: [a] } deriving (Eq, Show) +-- Invariant: coeffs must be an infinite list + +instance Num a => Num (Series a) where + fromInteger n = S $ fromInteger n : repeat 0 + negate (S fs) = S $ map negate fs + S fs + S gs = S $ zipWith (+) fs gs + S (f:ft) * S gs@(g:gt) = S $ f*g : coeffs (S ft * S gs + S (map (f*) gt)) + +instance Fractional a => Fractional (Series a) where + fromRational n = S $ fromRational n : repeat 0 + S (f:ft) / S (g:gt) = S qs where qs = f/g : map (/g) (coeffs (S ft - S qs * S gt)) + +-- utility function to convert from a finite polynomial +fromFiniteList xs = S (xs ++ repeat 0) + +int (S fs) = S $ 0 : zipWith (/) fs [1..] + +diff (S (_:ft)) = S $ zipWith (*) ft [1..] + +sinx,cosx :: Series Rational +sinx = int cosx +cosx = 1 - int sinx + +fiboS = 1 / fromFiniteList [1,-1,-1] diff --git a/Task/Formal-power-series/J/formal-power-series.j b/Task/Formal-power-series/J/formal-power-series.j new file mode 100644 index 0000000000..505736c58d --- /dev/null +++ b/Task/Formal-power-series/J/formal-power-series.j @@ -0,0 +1,7 @@ +Ai=: (i.@] =/ i.@[ -/ i.@>:@-)&# +divide=: [ +/ .*~ [:%.&.x: ] +/ .* Ai +diff=: 1 }. ] * i.@# +intg=: 0 , ] % 1 + i.@# +mult=: +//.@(*/) +plus=: +/@,: +minus=: -/@,: diff --git a/Task/Formal-power-series/Lua/formal-power-series.lua b/Task/Formal-power-series/Lua/formal-power-series.lua new file mode 100644 index 0000000000..cf054db1a3 --- /dev/null +++ b/Task/Formal-power-series/Lua/formal-power-series.lua @@ -0,0 +1,56 @@ +powerseries = setmetatable({ +__add = function(z1, z2) return powerseries(function(n) return z1.coeff(n) + z2.coeff(n) end) end, +__sub = function(z1, z2) return powerseries(function(n) return z1.coeff(n) - z2.coeff(n) end) end, +__mul = function(z1, z2) return powerseries(function(n) + local ret = 0 + for i = 0, n do + ret = ret + z1.coeff(i) * z2.coeff(n-i) + end + return ret +end) end, +__div = function(z1, z2) return powerseries(function(n) + local ret = z1.coeff(n) + local function coeffs(a) + local c = z1.coeff(a) + for j = 0, a - 1 do c = c - coeffs(j) * z2.coeff(a-j) end + return c / z2.coeff(0) + end + for i = 0, n-1 do + ret = ret - coeffs(i) * z2.coeff(n-i) + end + return ret / z2.coeff(0) +end) end, +__pow = function(z1, p) -- for a series z, z^n returns the nth derivative of z. negative values take integrals. + if p == 0 then return z1 + elseif p > 0 then return powerseries(function(i) return z1.coeff(i+1)*(i+1) end)^(p-1) + else return powerseries(function(i) return z1.coeff(i-1)/i end)^(p+1) + end +end, +__unm = function(z1) return powerseries(function(n) return -z1.coeff(n) end) end, +__index = function(z, n) return z.coeff(n) end, +__call = function(z, n) + local ret = 0 + for i = 0, 15 do --we do 20 terms, which is simpler than trying to check error bounds + ret = ret + z[i]*(n^i) + end + return ret +end}, +{__call = function(z, f) return setmetatable({coeff = f}, z) end}) + +cosine = powerseries(function(n) + if(n == 0) then return 1 + else return -((sine^(-1))[n]) --defer to the integral of sine function + end +end) + +sine = powerseries(function(n) + if(n == 0) then return 0 + else return (cosine^(-1))[n] --defer to the integral of cosine function + end +end) + +print(sine[1], sine[3], sine[5], sine[7], cosine[0], cosine[2], cosine[4], cosine[6]) +print(sine(math.pi/3), sine(math.pi/2), cosine(math.pi/3), cosine(math.pi/2)) + +tangent = sine / cosine +print(tangent(math.pi/3), tangent(math.pi/4), tangent(math.pi/6)) --something like 30000 function calls! diff --git a/Task/Formal-power-series/Maxima/formal-power-series.maxima b/Task/Formal-power-series/Maxima/formal-power-series.maxima new file mode 100644 index 0000000000..6dfde4216f --- /dev/null +++ b/Task/Formal-power-series/Maxima/formal-power-series.maxima @@ -0,0 +1,14 @@ +deftaylor(f(x), sum(n! * x^n, n, 0, inf))$ + +taylor(f(x), x, 0, 10); +/ * 1 + x + 2 * x^2 + 6 * x^3 + 24 * x^4 + 120 * x^5 + 720 * x^6 + 5040 * x^7 + 40320 * x^8 + 362880 * x^9 + 3628800 * x^10 + ... * / + +taylor(f(x)^2, x, 0, 10); +/ * 1 + 2 * x + 5 * x^2 + 16 * x^3 + 64 * x^4 + 312 * x^5 + 1812 * x^6 + 12288 * x^7 + 95616 * x^8 + 840960 * x^9 + 8254080 * x^10 + ... * / + + +deftaylor(fcos(x), sum((-1)^n * x^(2 * n) / (2 * n)!, n, 0, inf))$ +deftaylor(fsin(x), sum((-1)^n * x^(2 * n + 1) / (2 * n + 1)!, n, 0, inf))$ + +taylor(fcos(x)^2 + fsin(x)^2, x, 0, 20); +/ * 1 + ... * / diff --git a/Task/Formal-power-series/PicoLisp/formal-power-series-1.l b/Task/Formal-power-series/PicoLisp/formal-power-series-1.l new file mode 100644 index 0000000000..c9e4eeb5cc --- /dev/null +++ b/Task/Formal-power-series/PicoLisp/formal-power-series-1.l @@ -0,0 +1,6 @@ +(de lazy Args + (def (car Args) + (list (cadr Args) + (cons 'cache (lit (cons)) + (list 'pack (list 'char (list 'hash (caadr Args))) (caadr Args)) + (cddr Args) ) ) ) ) diff --git a/Task/Formal-power-series/PicoLisp/formal-power-series-2.l b/Task/Formal-power-series/PicoLisp/formal-power-series-2.l new file mode 100644 index 0000000000..112bab4757 --- /dev/null +++ b/Task/Formal-power-series/PicoLisp/formal-power-series-2.l @@ -0,0 +1,59 @@ +(scl 20) + +(de fpsOne (N) + (if (=0 N) 1.0 0) ) + +(de fpsInverse (N X) + (last + (make + (let Res1 (- (link (*/ 1.0 1.0 (X 0)))) + (for I N + (link + (*/ + (sum '((Res J) (*/ (X J) Res 1.0)) + (made) + (range I 1) ) + Res1 + 1.0 ) ) ) ) ) ) ) + +(de fpsAdd (N X Y) + (+ (X N) (Y N)) ) + +(de fpsSub (N X Y) + (- (X N) (Y N)) ) + +(de fpsMul (N X Y) + (sum + '((I) + (*/ (X I) (Y (- N I)) 1.0) ) + (range 0 N) ) ) + +(de fpsDiv (N X Y) + (sum + '((I) + (*/ (X I) (fpsInverse (- N I) Y) 1.0) ) + (range 0 N) ) ) + +(de fpsDifferentiate (N) + (curry (X) (N) + (* (X (inc N)) N) ) ) + +(de fpsIntegrate (X) + (curry (X) (N) + (or + (=0 N) + (*/ (X (dec N)) N) ) ) ) + +(lazy fpsSin (N) + ((fpsIntegrate fpsCos) N) ) + +(lazy fpsCos (N) + (fpsSub N fpsOne (fpsIntegrate fpsSin)) ) + +(lazy fpsTan (N) + (fpsDiv N fpsSin fpsCos) ) + +(lazy fpsExp (N) + (if (=0 N) + 1.0 + ((fpsIntegrate fpsExp) N) ) ) diff --git a/Task/Formal-power-series/PicoLisp/formal-power-series-3.l b/Task/Formal-power-series/PicoLisp/formal-power-series-3.l new file mode 100644 index 0000000000..3f853eba23 --- /dev/null +++ b/Task/Formal-power-series/PicoLisp/formal-power-series-3.l @@ -0,0 +1,19 @@ +(prin "SIN:") +(for N (range 1 11 2) + (prin " " (round (fpsSin N) 9)) ) +(prinl) + +(prin "COS:") +(for N (range 0 10 2) + (prin " " (round (fpsCos N) 9)) ) +(prinl) + +(prin "TAN:") +(for N (range 1 13 2) + (prin " " (round (fpsTan N) 7)) ) +(prinl) + +(prin "EXP:") +(for N (range 0 6) + (prin " " (round (fpsExp N) 7)) ) +(prinl) diff --git a/Task/Formal-power-series/Python/formal-power-series-1.py b/Task/Formal-power-series/Python/formal-power-series-1.py new file mode 100644 index 0000000000..4c78cebe89 --- /dev/null +++ b/Task/Formal-power-series/Python/formal-power-series-1.py @@ -0,0 +1,96 @@ +''' \ +For a discussion on pipe() and head() see + http://paddy3118.blogspot.com/2009/05/pipe-fitting-with-python-generators.html +''' + +from itertools import islice +from fractions import Fraction +from functools import reduce +try: + from itertools import izip as zip # for 2.6 +except: + pass + +def head(n): + ''' return a generator that passes through at most n items + ''' + return lambda seq: islice(seq, n) + +def pipe(gen, *cmds): + ''' pipe(a,b,c,d, ...) -> yield from ...d(c(b(a))) + ''' + return reduce(lambda gen, cmd: cmd(gen), cmds, gen) + +def sinepower(): + n = 0 + fac = 1 + sign = +1 + zero = 0 + yield zero + while True: + n +=1 + fac *= n + yield Fraction(1, fac*sign) + sign = -sign + n +=1 + fac *= n + yield zero +def cosinepower(): + n = 0 + fac = 1 + sign = +1 + yield Fraction(1,fac) + zero = 0 + while True: + n +=1 + fac *= n + yield zero + sign = -sign + n +=1 + fac *= n + yield Fraction(1, fac*sign) +def pluspower(*powergenerators): + for elements in zip(*powergenerators): + yield sum(elements) +def minuspower(*powergenerators): + for elements in zip(*powergenerators): + yield elements[0] - sum(elements[1:]) +def mulpower(fgen,ggen): + 'From: http://en.wikipedia.org/wiki/Power_series#Multiplication_and_division' + a,b = [],[] + for f,g in zip(fgen, ggen): + a.append(f) + b.append(g) + yield sum(f*g for f,g in zip(a, reversed(b))) +def constpower(n): + yield n + while True: + yield 0 +def diffpower(gen): + 'differentiatiate power series' + next(gen) + for n, an in enumerate(gen, start=1): + yield an*n +def intgpower(k=0): + 'integrate power series with constant k' + def _intgpower(gen): + yield k + for n, an in enumerate(gen, start=1): + yield an * Fraction(1,n) + return _intgpower + + +print("cosine") +c = list(pipe(cosinepower(), head(10))) +print(c) +print("sine") +s = list(pipe(sinepower(), head(10))) +print(s) +# integrate cosine +integc = list(pipe(cosinepower(),intgpower(0), head(10))) +# 1 - (integrate sine) +integs1 = list(minuspower(pipe(constpower(1), head(10)), + pipe(sinepower(),intgpower(0), head(10)))) + +assert s == integc, "The integral of cos should be sin" +assert c == integs1, "1 minus the integral of sin should be cos" diff --git a/Task/Formal-power-series/Python/formal-power-series-2.py b/Task/Formal-power-series/Python/formal-power-series-2.py new file mode 100644 index 0000000000..d554b3f8ba --- /dev/null +++ b/Task/Formal-power-series/Python/formal-power-series-2.py @@ -0,0 +1,58 @@ +from itertools import islice, tee +from fractions import Fraction +try: + from itertools import izip as zip # for 2.6 +except: + pass + +def pluspower(*powergenerators): + for elements in zip(*powergenerators): + yield sum(elements) +def minuspower(*powergenerators): + for elements in zip(*powergenerators): + yield elements[0] - sum(elements[1:]) +def mulpower(fgen,ggen): + 'From: http://en.wikipedia.org/wiki/Power_series#Multiplication_and_division' + a,b = [],[] + for f,g in zip(fgen, ggen): + a.append(f) + b.append(g) + yield sum(f*g for f,g in zip(a, reversed(b))) +def constpower(n): + yield n + while True: + yield 0 +def diffpower(gen): + 'differentiatiate power series' + next(gen) + for n, an in enumerate(gen, start=1): + yield an*n +def intgpower(gen): + 'integrate power series with bounds from 0 to x' + yield 0 + for n, an in enumerate(gen, start=1): + yield an * Fraction(1,n) + + +def sine_cosine_series(): + def deferred_sin(): + for i in sinx_temp: + yield i + def deferred_cos(): + for i in cosx_temp: + yield i + + sinx_result, sinx_copy1 = tee(deferred_sin(), 2) + cosx_result, cosx_copy1 = tee(deferred_cos(), 2) + + sinx_temp = intgpower(cosx_copy1) + cosx_temp = minuspower(constpower(1), intgpower(sinx_copy1)) + + return sinx_result, cosx_result + +sinx, cosx = sine_cosine_series() + +print("cosine") +print(list(islice(sinx, 10))) +print("sine") +print(list(islice(cosx, 10))) diff --git a/Task/Formal-power-series/Scheme/formal-power-series-1.ss b/Task/Formal-power-series/Scheme/formal-power-series-1.ss new file mode 100644 index 0000000000..b33f072b49 --- /dev/null +++ b/Task/Formal-power-series/Scheme/formal-power-series-1.ss @@ -0,0 +1,23 @@ +(define-syntax lons + (syntax-rules () + ((_ lar ldr) (delay (cons lar (delay ldr)))))) + +(define (lar lons) + (car (force lons))) + +(define (ldr lons) + (force (cdr (force lons)))) + +(define (lap proc . llists) + (lons (apply proc (map lar llists)) (apply lap proc (map ldr llists)))) + +(define (take n llist) + (if (zero? n) + (list) + (cons (lar llist) (take (- n 1) (ldr llist))))) + +(define (iota n) + (lons n (iota (+ n 1)))) + +(define (repeat n) + (lons n (repeat n))) diff --git a/Task/Formal-power-series/Scheme/formal-power-series-2.ss b/Task/Formal-power-series/Scheme/formal-power-series-2.ss new file mode 100644 index 0000000000..b9709c72a8 --- /dev/null +++ b/Task/Formal-power-series/Scheme/formal-power-series-2.ss @@ -0,0 +1,31 @@ +(define (fps+ . llists) + (apply lap + llists)) + +(define (fps- . llists) + (apply lap - llists)) + +(define (fps* . llists) + (define (*fps* p q) + (let ((larp (lar p)) (larq (lar q)) (ldrp (ldr p)) (ldrq (ldr q))) + (lons (* larp larq) + (fps+ (lap (lambda (p) (* p larp)) ldrq) + (lap (lambda (p) (* p larq)) ldrp) + (lons 0 (*fps* ldrp ldrq)))))) + (cond ((null? llists) (lons 1 (repeat 0))) + ((null? (cdr llists)) (car llists)) + (else + (apply fps* (cons (*fps* (car llists) (cadr llists)) (cddr llists)))))) + +(define (fps/ n . llists) + (define (*fps/ n d) + (let ((q (/ (lar n) (lar d)))) + (lons q (*fps/ (fps- (ldr n) (lap (lambda (p) (* p q)) (ldr d))) d)))) + (if (null? llists) + (*fps/ (lons 1 (repeat 0)) n) + (*fps/ n (apply fps* llists)))) + +(define (fpsint llist) + (lons 0 (lap * llist (lap / (iota 1))))) + +(define (fpsdif llist) + (lap * (iota 1) (ldr llist))) diff --git a/Task/Formal-power-series/Scheme/formal-power-series-3.ss b/Task/Formal-power-series/Scheme/formal-power-series-3.ss new file mode 100644 index 0000000000..e6213ffad8 --- /dev/null +++ b/Task/Formal-power-series/Scheme/formal-power-series-3.ss @@ -0,0 +1,11 @@ +(define fpscos + (fps- (lons 1 (repeat 0)) (fpsint (delay (force fpssin))))) + +(define fpssin + (fpsint (delay (force fpscos)))) + +(display (take 10 fpssin)) +(newline) + +(display (take 10 fpscos)) +(newline) diff --git a/Task/Formal-power-series/Scheme/formal-power-series-4.ss b/Task/Formal-power-series/Scheme/formal-power-series-4.ss new file mode 100644 index 0000000000..5918e2bf48 --- /dev/null +++ b/Task/Formal-power-series/Scheme/formal-power-series-4.ss @@ -0,0 +1,8 @@ +(display (take 10 (fps+ (fps* fpssin fpssin) (fps* fpscos fpscos)))) +(newline) + +(define fpstan + (fps/ fpssin fpscos)) + +(display (take 10 fpstan)) +(newline) diff --git a/Task/Formal-power-series/Tcl/formal-power-series-1.tcl b/Task/Formal-power-series/Tcl/formal-power-series-1.tcl new file mode 100644 index 0000000000..833d9fa97a --- /dev/null +++ b/Task/Formal-power-series/Tcl/formal-power-series-1.tcl @@ -0,0 +1,137 @@ +package require TclOO + +oo::class create PowerSeries { + variable name + constructor {{body {}} args} { + # Use the body to adapt the methods of the _object_ + oo::objdefine [self] $body + # Use the rest to configure variables in the object + foreach {var val} $args { + set [my varname $var] $val + } + # Guess the name if not already set + if {![info exists [my varname name]]} { + set name [namespace tail [self]] + } + } + method name {} { + return $name + } + method term i { + return 0 + } + method limit {} { + return inf + } + + # A pretty-printer, that prints the first $terms non-zero terms + method print {terms} { + set result "${name}(x) == " + set limit [my limit] + if {$limit == 0} { + # Special case + return $result[my term 0] + } + set tCount 0 + for {set i 0} {$tCount<$terms && $i<=$limit} {incr i} { + set t [my term $i] + if {$t == 0} continue + incr tCount + set t [format %.4g $t] + if {$t eq "1" && $i != 0} {set t ""} + if {$i == 0} { + append result "$t + " + } elseif {$i == 1} { + append result "${t}x + " + } else { + set p [string map { + 0 \u2070 1 \u00b9 2 \u00b2 3 \u00b3 4 \u2074 + 5 \u2075 6 \u2076 7 \u2077 8 \u2078 9 \u2079 + } $i] + append result "${t}x$p + " + } + } + return [string trimright $result "+ "] + } + + # Evaluate (a prefix of) the series at a particular x + # The terms parameter gives the number; 5 is enough for show + method evaluate {x {terms 5}} { + set result 0 + set limit [my limit] + set tCount 0 + for {set i 0} {$tCount<$terms && $i<=$limit} {incr i} { + set t [my term $i] + if {$t == 0} continue + incr tCount + set result [expr {$result + $t * ($x ** $i)}] + } + return $result + } + + # Operations to build new sequences from old ones + method add {s} { + PowerSeries new { + variable S1 S2 + method limit {} {expr {max([$S1 limit],[$S2 limit])}} + method term i { + set t1 [expr {$i>[$S1 limit] ? 0 : [$S1 term $i]}] + set t2 [expr {$i>[$S2 limit] ? 0 : [$S2 term $i]}] + expr {$t1 + $t2} + } + } S1 [self] S2 $s name "$name+[$s name]" + } + method subtract {s} { + PowerSeries new { + variable S1 S2 + method limit {} {expr {max([$S1 limit],[$S2 limit])}} + method term i { + set t1 [expr {$i>[$S1 limit] ? 0 : [$S1 term $i]}] + set t2 [expr {$i>[$S2 limit] ? 0 : [$S2 term $i]}] + expr {$t1 - $t2} + } + } S1 [self] S2 $s name "$name-[$s name]" + } + method integrate {{Name ""}} { + if {$Name eq ""} {set Name "Integrate\[[my name]\]"} + PowerSeries new { + variable S limit + method limit {} { + if {[info exists limit]} {return $limit} + try { + return [expr {[$S limit] + 1}] + } on error {} { + # If the limit spirals out of control, it's infinite! + return [set limit inf] + } + } + method term i { + if {$i == 0} {return 0} + set t [$S term [expr {$i-1}]] + expr {$t / double($i)} + } + } S [self] name $Name + } + method differentiate {{Name ""}} { + if {$Name eq ""} {set Name "Differentiate\[[my name]\]"} + PowerSeries new { + variable S + method limit {} {expr {[$S limit] ? [$S limit] - 1 : 0}} + method term i {expr {[incr i] * [$S term $i]}} + } S [self] name $Name + } + # Special constructor for making constants + self method constant n { + PowerSeries new { + variable n + method limit {} {return 0} + method term i {return $n} + } n $n name $n + } +} + +# Define the two power series in terms of each other +PowerSeries create cos ;# temporary dummy object... +rename [cos integrate "sin"] sin +cos destroy ;# remove the dummy to make way for the real one... +rename [[PowerSeries constant 1] subtract [sin integrate]] cos diff --git a/Task/Formal-power-series/Tcl/formal-power-series-2.tcl b/Task/Formal-power-series/Tcl/formal-power-series-2.tcl new file mode 100644 index 0000000000..2a17a8cf96 --- /dev/null +++ b/Task/Formal-power-series/Tcl/formal-power-series-2.tcl @@ -0,0 +1,8 @@ +% sin print 7 +sin(x) == x + -0.1667x³ + 0.008333x⁵ + -0.0001984x⁷ + 2.756e-06x⁹ + -2.505e-08x¹¹ + 1.606e-10x¹³ +% cos print 7 +1-Integrate[sin](x) == 1 + -0.5x² + 0.04167x⁴ + -0.001389x⁶ + 2.48e-05x⁸ + -2.756e-07x¹⁰ + 2.088e-09x¹² +% sin evaluate [expr acos(0)] +1.0000035425842861 +% cos evaluate [expr acos(0)] +2.473727636463901e-5 diff --git a/Task/Formatted-numeric-output/0DESCRIPTION b/Task/Formatted-numeric-output/0DESCRIPTION new file mode 100644 index 0000000000..020b11157b --- /dev/null +++ b/Task/Formatted-numeric-output/0DESCRIPTION @@ -0,0 +1,3 @@ +Express a number in decimal as a fixed-length string with leading zeros. + +For example, the number 7.125 could be expressed as "00007.125". diff --git a/Task/Formatted-numeric-output/1META.yaml b/Task/Formatted-numeric-output/1META.yaml new file mode 100644 index 0000000000..b94a3d25d9 --- /dev/null +++ b/Task/Formatted-numeric-output/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Text processing +note: Basic language learning diff --git a/Task/Formatted-numeric-output/ALGOL-68/formatted-numeric-output.alg b/Task/Formatted-numeric-output/ALGOL-68/formatted-numeric-output.alg new file mode 100644 index 0000000000..4632b5bbc5 --- /dev/null +++ b/Task/Formatted-numeric-output/ALGOL-68/formatted-numeric-output.alg @@ -0,0 +1,17 @@ +main:( + REAL r=exp(pi)-pi; + print((r,newline)); + printf(($g(-16,4)l$,-r)); + printf(($g(-16,4)l$,r)); + printf(($g( 16,4)l$,r)); + printf(($g( 16,4,1)l$,r)); + printf(($-dddd.ddddl$,-r)); + printf(($-dddd.ddddl$,r)); + printf(($+dddd.ddddl$,r)); + printf(($ddddd.ddddl$,r)); + printf(($zzzzd.ddddl$,r)); + printf(($zzzz-d.ddddl$,r)); + printf(($zzzz-d.ddddedl$,r)); + printf(($zzzz-d.ddddeddl$,r)); + printf(($4z-d.4de4dl$,r)) +) diff --git a/Task/Formatted-numeric-output/AWK/formatted-numeric-output.awk b/Task/Formatted-numeric-output/AWK/formatted-numeric-output.awk new file mode 100644 index 0000000000..da1bd07549 --- /dev/null +++ b/Task/Formatted-numeric-output/AWK/formatted-numeric-output.awk @@ -0,0 +1,9 @@ +BEGIN { + r=7.125 + printf " %9.3f\n",-r + printf " %9.3f\n",r + printf " %-9.3f\n",r + printf " %09.3f\n",-r + printf " %09.3f\n",r + printf " %-09.3f\n",r +} diff --git a/Task/Formatted-numeric-output/Ada/formatted-numeric-output.ada b/Task/Formatted-numeric-output/Ada/formatted-numeric-output.ada new file mode 100644 index 0000000000..3c82a0ffb5 --- /dev/null +++ b/Task/Formatted-numeric-output/Ada/formatted-numeric-output.ada @@ -0,0 +1,14 @@ +with Ada.Text_Io.Editing; use Ada.Text_Io.Editing; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Zero_Fill is + Pic_String: String := "<999999.99>"; + Pic : Picture := To_Picture(Pic_String); + type Money is delta 0.01 digits 8; + package Money_Output is new Decimal_Output(Money); + use Money_Output; + + Value : Money := 37.25; +begin + Put(Item => Value, Pic => Pic); +end Zero_Fill; diff --git a/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-1.amiga b/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-1.amiga new file mode 100644 index 0000000000..b004a5352b --- /dev/null +++ b/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-1.amiga @@ -0,0 +1,19 @@ +PROC newRealF(es, fl, digit, len=0, zeros=TRUE) + DEF s, t, i + IF (len = 0) OR (len < (digit+3)) + RETURN RealF(es, fl, digit) + ELSE + s := String(len) + t := RealF(es, fl, digit) + FOR i := 0 TO len-EstrLen(t)-1 DO StrAdd(s, IF zeros THEN '0' ELSE ' ') + StrAdd(s, t) + StrCopy(es, s) + DisposeLink(s) + DisposeLink(t) + ENDIF +ENDPROC es + +PROC main() + DEF s[100] : STRING + WriteF('\s\n', newRealF(s, 7.125, 3,9)) +ENDPROC diff --git a/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-2.amiga b/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-2.amiga new file mode 100644 index 0000000000..afc571f71f --- /dev/null +++ b/Task/Formatted-numeric-output/AmigaE/formatted-numeric-output-2.amiga @@ -0,0 +1,2 @@ + 'ZF15.9' ⎕FMT 7.125 +00007.125000000 diff --git a/Task/Formatted-numeric-output/AutoHotkey/formatted-numeric-output.ahk b/Task/Formatted-numeric-output/AutoHotkey/formatted-numeric-output.ahk new file mode 100644 index 0000000000..6f774106b9 --- /dev/null +++ b/Task/Formatted-numeric-output/AutoHotkey/formatted-numeric-output.ahk @@ -0,0 +1,8 @@ +MsgBox % pad(7.25,7) ; 0007.25 +MsgBox % pad(-7.25,7) ; -007.25 + +pad(x,len) { ; pad with 0's from left to len chars + IfLess x,0, Return "-" pad(SubStr(x,2),len-1) + VarSetCapacity(p,len,Asc("0")) + Return SubStr(p x,1-len) +} diff --git a/Task/Formatted-numeric-output/BBC-BASIC/formatted-numeric-output.bbc b/Task/Formatted-numeric-output/BBC-BASIC/formatted-numeric-output.bbc new file mode 100644 index 0000000000..4a62561da6 --- /dev/null +++ b/Task/Formatted-numeric-output/BBC-BASIC/formatted-numeric-output.bbc @@ -0,0 +1,11 @@ + PRINT FNformat(PI, 9, 3) + PRINT FNformat(-PI, 9, 3) + END + + DEF FNformat(n, sl%, dp%) + LOCAL @% + @% = &1020000 OR dp% << 8 + IF n >= 0 THEN + = RIGHT$(STRING$(sl%,"0") + STR$(n), sl%) + ENDIF + = "-" + RIGHT$(STRING$(sl%,"0") + STR$(-n), sl%-1) diff --git a/Task/Formatted-numeric-output/C++/formatted-numeric-output.cpp b/Task/Formatted-numeric-output/C++/formatted-numeric-output.cpp new file mode 100644 index 0000000000..ebc87f897b --- /dev/null +++ b/Task/Formatted-numeric-output/C++/formatted-numeric-output.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl; + return 0; +} diff --git a/Task/Formatted-numeric-output/C/formatted-numeric-output.c b/Task/Formatted-numeric-output/C/formatted-numeric-output.c new file mode 100644 index 0000000000..318a700a45 --- /dev/null +++ b/Task/Formatted-numeric-output/C/formatted-numeric-output.c @@ -0,0 +1,11 @@ +#include +main(){ + float r=7.125; + printf(" %9.3f\n",-r); + printf(" %9.3f\n",r); + printf(" %-9.3f\n",r); + printf(" %09.3f\n",-r); + printf(" %09.3f\n",r); + printf(" %-09.3f\n",r); + return 0; +} diff --git a/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-1.clj b/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-1.clj new file mode 100644 index 0000000000..d4567299af --- /dev/null +++ b/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-1.clj @@ -0,0 +1 @@ +(cl-format true "~9,3,,,'0F" 7.125) diff --git a/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-2.clj b/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-2.clj new file mode 100644 index 0000000000..73d1f49dde --- /dev/null +++ b/Task/Formatted-numeric-output/Clojure/formatted-numeric-output-2.clj @@ -0,0 +1 @@ +(printf "%09.3f" 7.125) ; format works the same way (without side the effect of printing) diff --git a/Task/Formatted-numeric-output/Common-Lisp/formatted-numeric-output.lisp b/Task/Formatted-numeric-output/Common-Lisp/formatted-numeric-output.lisp new file mode 100644 index 0000000000..827ffbcbff --- /dev/null +++ b/Task/Formatted-numeric-output/Common-Lisp/formatted-numeric-output.lisp @@ -0,0 +1 @@ +(format t "~9,3,,,'0F" 7.125) diff --git a/Task/Formatted-numeric-output/D/formatted-numeric-output.d b/Task/Formatted-numeric-output/D/formatted-numeric-output.d new file mode 100644 index 0000000000..de4d922915 --- /dev/null +++ b/Task/Formatted-numeric-output/D/formatted-numeric-output.d @@ -0,0 +1,11 @@ +import std.stdio; + +void main() { + immutable r = 7.125; + writefln(" %9.3f", -r); + writefln(" %9.3f", r); + writefln(" %-9.3f", r); + writefln(" %09.3f", -r); + writefln(" %09.3f", r); + writefln(" %-09.3f", r); +} diff --git a/Task/Formatted-numeric-output/Delphi/formatted-numeric-output.delphi b/Task/Formatted-numeric-output/Delphi/formatted-numeric-output.delphi new file mode 100644 index 0000000000..81ced3132a --- /dev/null +++ b/Task/Formatted-numeric-output/Delphi/formatted-numeric-output.delphi @@ -0,0 +1,19 @@ +program FormattedNumericOutput; + +{$APPTYPE CONSOLE} + +uses + SysUtils; + +const + fVal = 7.125; + +begin + Writeln(FormatFloat('0000#.000',fVal)); + Writeln(FormatFloat('0000#.0000000',fVal)); + Writeln(FormatFloat('##.0000000',fVal)); + Writeln(FormatFloat('0',fVal)); + Writeln(FormatFloat('#.#E-0',fVal)); + Writeln(FormatFloat('#,##0.00;;Zero',fVal)); + Readln; +end. diff --git a/Task/Formatted-numeric-output/Eiffel/formatted-numeric-output.e b/Task/Formatted-numeric-output/Eiffel/formatted-numeric-output.e new file mode 100644 index 0000000000..5280754cff --- /dev/null +++ b/Task/Formatted-numeric-output/Eiffel/formatted-numeric-output.e @@ -0,0 +1,67 @@ +note + description : "{ +2 Examples are given. +The first example uses the standard library's FORMAT_DOUBLE class. +The second example uses the AEL_PRINTF class from the freely available +Amalasoft Eiffel Library (AEL). + +See additional comments in the code. +}" + +class APPLICATION + +inherit + AEL_PRINTF -- Optional, see below + +create + make + +feature {NONE} -- Initialization + + make + -- Run application. + do + print_formatted_std (7.125) + print_formatted_ael (7.125) + end + + --|-------------------------------------------------------------- + + print_formatted_std (v: REAL_64) + -- Print the value 'v' as a zero-padded string in a fixed + -- overall width of 9 places and, with a precision of + -- to 3 places to the right of the decimal point. + -- Use the FORMAT_DOUBLE class from the standard library + local + fmt: FORMAT_DOUBLE + do + create fmt.make (9, 3) + fmt.zero_fill + print (fmt.formatted (v) + "%N") + end + + --|-------------------------------------------------------------- + + print_formatted_ael (v: REAL_64) + -- Print the value 'v' as a zero-padded string in a fixed + -- overall width of 9 places and, with a precision of + -- to 3 places to the right of the decimal point. + -- Use the AEL_PRINTF class from the Amalasoft Eiffel Library + -- freely available from www.amalasoft.com + do + -- printf accepts a format string and an argument list + -- The argument list is a container (often a manifest + -- array) of values corresponding to the type of the format + -- specified in the format string argument. + -- When only one argument is needed, then there is also the + -- option to use just the value, without the container. + -- In this example, the line would be: + -- printf ("%%09.3f%N", v) + -- The more deliberate form is used in the actual example, + -- as it is more representative of common usage, when there + -- are multiple value arguments. + + printf ("%%09.3f%N", << v >>) + end + +end diff --git a/Task/Formatted-numeric-output/Euphoria/formatted-numeric-output.euphoria b/Task/Formatted-numeric-output/Euphoria/formatted-numeric-output.euphoria new file mode 100644 index 0000000000..fafcbcf613 --- /dev/null +++ b/Task/Formatted-numeric-output/Euphoria/formatted-numeric-output.euphoria @@ -0,0 +1,7 @@ +constant r = 7.125 +printf(1,"%9.3f\n",-r) +printf(1,"%9.3f\n",r) +printf(1,"%-9.3f\n",r) +printf(1,"%09.3f\n",-r) +printf(1,"%09.3f\n",r) +printf(1,"%-09.3f\n",r) diff --git a/Task/Formatted-numeric-output/Fantom/formatted-numeric-output.fantom b/Task/Formatted-numeric-output/Fantom/formatted-numeric-output.fantom new file mode 100644 index 0000000000..2b35d350dc --- /dev/null +++ b/Task/Formatted-numeric-output/Fantom/formatted-numeric-output.fantom @@ -0,0 +1,7 @@ +class Main +{ + public static Void main() + { + echo (7.125.toStr.padl(9, '0')) + } +} diff --git a/Task/Formatted-numeric-output/Forth/formatted-numeric-output-1.fth b/Task/Formatted-numeric-output/Forth/formatted-numeric-output-1.fth new file mode 100644 index 0000000000..3ef3dd3af0 --- /dev/null +++ b/Task/Formatted-numeric-output/Forth/formatted-numeric-output-1.fth @@ -0,0 +1,8 @@ +\ format 'n' digits of the double word 'd' +: #n ( d n -- d ) 0 ?do # loop ; + +\ ud.0 prints an unsigned double +: ud.0 ( d n -- ) <# 1- #n #s #> type ; + +\ d.0 prints a signed double +: d.0 ( d n -- ) >r tuck dabs <# r> 1- #n #s rot sign #> type ; diff --git a/Task/Formatted-numeric-output/Forth/formatted-numeric-output-2.fth b/Task/Formatted-numeric-output/Forth/formatted-numeric-output-2.fth new file mode 100644 index 0000000000..96599ce0ed --- /dev/null +++ b/Task/Formatted-numeric-output/Forth/formatted-numeric-output-2.fth @@ -0,0 +1,4 @@ +Type: 123 s>d 8 ud.0 +Result: 00000123 ok +Type: -123 s>d 8 d.0 +Result: -00000123 ok diff --git a/Task/Formatted-numeric-output/Fortran/formatted-numeric-output.f b/Task/Formatted-numeric-output/Fortran/formatted-numeric-output.f new file mode 100644 index 0000000000..7c6b1dbf7e --- /dev/null +++ b/Task/Formatted-numeric-output/Fortran/formatted-numeric-output.f @@ -0,0 +1,2 @@ +INTEGER :: number = 7125 +WRITE(*,"(I8.8)") number ! Prints 00007125 diff --git a/Task/Formatted-numeric-output/Go/formatted-numeric-output.go b/Task/Formatted-numeric-output/Go/formatted-numeric-output.go new file mode 100644 index 0000000000..53c7ea98bd --- /dev/null +++ b/Task/Formatted-numeric-output/Go/formatted-numeric-output.go @@ -0,0 +1 @@ +fmt.Printf("%09.3f", 7.125) diff --git a/Task/Formatted-numeric-output/Groovy/formatted-numeric-output.groovy b/Task/Formatted-numeric-output/Groovy/formatted-numeric-output.groovy new file mode 100644 index 0000000000..3751d53228 --- /dev/null +++ b/Task/Formatted-numeric-output/Groovy/formatted-numeric-output.groovy @@ -0,0 +1 @@ +printf ("%09.3f", 7.125) diff --git a/Task/Formatted-numeric-output/Haskell/formatted-numeric-output.hs b/Task/Formatted-numeric-output/Haskell/formatted-numeric-output.hs new file mode 100644 index 0000000000..147d05bbac --- /dev/null +++ b/Task/Formatted-numeric-output/Haskell/formatted-numeric-output.hs @@ -0,0 +1,3 @@ +import Text.Printf +main = + printf "%09.3f" 7.125 diff --git a/Task/Formatted-numeric-output/HicEst/formatted-numeric-output.hicest b/Task/Formatted-numeric-output/HicEst/formatted-numeric-output.hicest new file mode 100644 index 0000000000..0d5c822e1c --- /dev/null +++ b/Task/Formatted-numeric-output/HicEst/formatted-numeric-output.hicest @@ -0,0 +1 @@ +WRITE(ClipBoard, Format='i5.5, F4.3') INT(7.125), MOD(7.125, 1) ! 00007.125 diff --git a/Task/Formatted-numeric-output/IDL/formatted-numeric-output.idl b/Task/Formatted-numeric-output/IDL/formatted-numeric-output.idl new file mode 100644 index 0000000000..b24839e67a --- /dev/null +++ b/Task/Formatted-numeric-output/IDL/formatted-numeric-output.idl @@ -0,0 +1,3 @@ +n = 7.125 +print, n, format='(f08.3)' +;==> 0007.125 diff --git a/Task/Formatted-numeric-output/Icon/formatted-numeric-output.icon b/Task/Formatted-numeric-output/Icon/formatted-numeric-output.icon new file mode 100644 index 0000000000..012bfce364 --- /dev/null +++ b/Task/Formatted-numeric-output/Icon/formatted-numeric-output.icon @@ -0,0 +1,10 @@ +link printf + +procedure main() + +every r := &pi | -r | 100-r do { + write(r," <=== no printf") + every p := "|%r|" | "|%9.3r|" | "|%-9.3r|" | "|%0.3r|" | "|%e|" | "|%d|" do + write(sprintf(p,r)," <=== sprintf ",p) +} +end diff --git a/Task/Formatted-numeric-output/J/formatted-numeric-output.j b/Task/Formatted-numeric-output/J/formatted-numeric-output.j new file mode 100644 index 0000000000..7a7cd3837d --- /dev/null +++ b/Task/Formatted-numeric-output/J/formatted-numeric-output.j @@ -0,0 +1,2 @@ + 'r<0>9.3' (8!:2) 7.125 +00007.125 diff --git a/Task/Formatted-numeric-output/Java/formatted-numeric-output-1.java b/Task/Formatted-numeric-output/Java/formatted-numeric-output-1.java new file mode 100644 index 0000000000..630ad504cc --- /dev/null +++ b/Task/Formatted-numeric-output/Java/formatted-numeric-output-1.java @@ -0,0 +1,6 @@ +public class Printing{ + public static void main(String[] args){ + double printer = 7.125; + System.out.printf("%09.3f",printer);//System.out.format works the same way + } +} diff --git a/Task/Formatted-numeric-output/Java/formatted-numeric-output-2.java b/Task/Formatted-numeric-output/Java/formatted-numeric-output-2.java new file mode 100644 index 0000000000..34c5064ae9 --- /dev/null +++ b/Task/Formatted-numeric-output/Java/formatted-numeric-output-2.java @@ -0,0 +1,21 @@ +import java.text.DecimalFormat; +import java.text.NumberFormat; + +public class Format { + public static void main(String[] args){ + NumberFormat numForm = new DecimalFormat(); + numForm.setMinimumIntegerDigits(9); + //Maximum also available for Integer digits and Fraction digits + numForm.setGroupingUsed(false);//stops it from inserting commas + System.out.println(numForm.format(7.125)); + + //example of Fraction digit options + numForm.setMinimumIntegerDigits(5); + numForm.setMinimumFractionDigits(5); + System.out.println(numForm.format(7.125)); + numForm.setMinimumFractionDigits(0); + numForm.setMaximumFractionDigits(2); + System.out.println(numForm.format(7.125)); + System.out.println(numForm.format(7.135));//rounds to even + } +} diff --git a/Task/Formatted-numeric-output/JavaScript/formatted-numeric-output.js b/Task/Formatted-numeric-output/JavaScript/formatted-numeric-output.js new file mode 100644 index 0000000000..4d1f797beb --- /dev/null +++ b/Task/Formatted-numeric-output/JavaScript/formatted-numeric-output.js @@ -0,0 +1,3 @@ +var n = 123; +var str = ("00000" + n).slice(-5); +alert(str); diff --git a/Task/Formatted-numeric-output/Liberty-BASIC/formatted-numeric-output.liberty b/Task/Formatted-numeric-output/Liberty-BASIC/formatted-numeric-output.liberty new file mode 100644 index 0000000000..bfb5b52016 --- /dev/null +++ b/Task/Formatted-numeric-output/Liberty-BASIC/formatted-numeric-output.liberty @@ -0,0 +1,20 @@ +for i =1 to 10 + n =rnd( 1) *10^( int( 10 *rnd(1)) -2) + print "Raw number ="; n; "Using custom function ="; FormattedPrint$( n, 16, 5) +next i +end + +function FormattedPrint$( n, length, decPlaces) + format$ ="#." + for i =1 to decPlaces + format$ =format$ +"#" + next i + + n$ =using( format$, n) ' remove leading spaces if less than 3 figs left of decimal + ' add leading zeros + for i =1 to len( n$) + c$ =mid$( n$, i, 1) + if c$ =" " or c$ ="%" then nn$ =nn$ +"0" else nn$ =nn$ +c$ + next i + FormattedPrint$ =right$( "000000000000" +nn$, length) ' chop to required length +end function diff --git a/Task/Formatted-numeric-output/Logo/formatted-numeric-output-1.logo b/Task/Formatted-numeric-output/Logo/formatted-numeric-output-1.logo new file mode 100644 index 0000000000..736441f523 --- /dev/null +++ b/Task/Formatted-numeric-output/Logo/formatted-numeric-output-1.logo @@ -0,0 +1,4 @@ +to zpad :num :width :precision + output map [ifelse ? = "| | ["0] [?]] form :num :width :precision +end +print zpad 7.125 9 3 ; 00007.125 diff --git a/Task/Formatted-numeric-output/Logo/formatted-numeric-output-2.logo b/Task/Formatted-numeric-output/Logo/formatted-numeric-output-2.logo new file mode 100644 index 0000000000..21a9c859ab --- /dev/null +++ b/Task/Formatted-numeric-output/Logo/formatted-numeric-output-2.logo @@ -0,0 +1 @@ +print form 7.125 -1 "|%09.3f| ; 00007.125 diff --git a/Task/Formatted-numeric-output/Lua/formatted-numeric-output-1.lua b/Task/Formatted-numeric-output/Lua/formatted-numeric-output-1.lua new file mode 100644 index 0000000000..ad1f3d5293 --- /dev/null +++ b/Task/Formatted-numeric-output/Lua/formatted-numeric-output-1.lua @@ -0,0 +1,9 @@ +function digits(n) return math.floor(math.log(n) / math.log(10))+1 end +function fixedprint(num, digs) --digs = number of digits before decimal point + for i = 1, digs - digits(num) do + io.write"0" + end + print(num) +end + +fixedprint(7.125, 5) --> 00007.125 diff --git a/Task/Formatted-numeric-output/Lua/formatted-numeric-output-2.lua b/Task/Formatted-numeric-output/Lua/formatted-numeric-output-2.lua new file mode 100644 index 0000000000..c3ec074cfb --- /dev/null +++ b/Task/Formatted-numeric-output/Lua/formatted-numeric-output-2.lua @@ -0,0 +1 @@ + print(string.format("%09.3d",7.125)) diff --git a/Task/Formatted-numeric-output/MATLAB/formatted-numeric-output.m b/Task/Formatted-numeric-output/MATLAB/formatted-numeric-output.m new file mode 100644 index 0000000000..28782b16fd --- /dev/null +++ b/Task/Formatted-numeric-output/MATLAB/formatted-numeric-output.m @@ -0,0 +1,2 @@ +>> disp(sprintf('%09.3f',7.125)) +00007.125 diff --git a/Task/Formatted-numeric-output/Mathematica/formatted-numeric-output.mathematica b/Task/Formatted-numeric-output/Mathematica/formatted-numeric-output.mathematica new file mode 100644 index 0000000000..c1128a131e --- /dev/null +++ b/Task/Formatted-numeric-output/Mathematica/formatted-numeric-output.mathematica @@ -0,0 +1,2 @@ +StringJoin[ToString /@ PadLeft[Characters[ToString[ 7.125]], 9]] +->"00007.125" diff --git a/Task/Formatted-numeric-output/Mercury/formatted-numeric-output.mercury b/Task/Formatted-numeric-output/Mercury/formatted-numeric-output.mercury new file mode 100644 index 0000000000..442996253b --- /dev/null +++ b/Task/Formatted-numeric-output/Mercury/formatted-numeric-output.mercury @@ -0,0 +1,11 @@ +:- module formatted_numeric_output. +:- interface. +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module list, string. + +main(!IO) :- + io.format("%09.3f\n", [f(7.125)], !IO). diff --git a/Task/Formatted-numeric-output/Modula-3/formatted-numeric-output.mod3 b/Task/Formatted-numeric-output/Modula-3/formatted-numeric-output.mod3 new file mode 100644 index 0000000000..5f280f27e8 --- /dev/null +++ b/Task/Formatted-numeric-output/Modula-3/formatted-numeric-output.mod3 @@ -0,0 +1 @@ +IO.Put(Fmt.Pad("7.125\n", length := 10, padChar := '0')); diff --git a/Task/Formatted-numeric-output/PHP/formatted-numeric-output-1.php b/Task/Formatted-numeric-output/PHP/formatted-numeric-output-1.php new file mode 100644 index 0000000000..d0ef91a60e --- /dev/null +++ b/Task/Formatted-numeric-output/PHP/formatted-numeric-output-1.php @@ -0,0 +1 @@ +echo str_pad(7.125, 9, '0', STR_PAD_LEFT); diff --git a/Task/Formatted-numeric-output/PHP/formatted-numeric-output-2.php b/Task/Formatted-numeric-output/PHP/formatted-numeric-output-2.php new file mode 100644 index 0000000000..3ccf253e0e --- /dev/null +++ b/Task/Formatted-numeric-output/PHP/formatted-numeric-output-2.php @@ -0,0 +1 @@ +printf("%09.3f\n", 7.125); diff --git a/Task/Formatted-numeric-output/Perl/formatted-numeric-output.pl b/Task/Formatted-numeric-output/Perl/formatted-numeric-output.pl new file mode 100644 index 0000000000..6f1b042f5c --- /dev/null +++ b/Task/Formatted-numeric-output/Perl/formatted-numeric-output.pl @@ -0,0 +1 @@ +printf "%09.3f\n", 7.125; diff --git a/Task/Formatted-numeric-output/PicoLisp/formatted-numeric-output.l b/Task/Formatted-numeric-output/PicoLisp/formatted-numeric-output.l new file mode 100644 index 0000000000..74c1cb4b16 --- /dev/null +++ b/Task/Formatted-numeric-output/PicoLisp/formatted-numeric-output.l @@ -0,0 +1,2 @@ +(pad 9 (format 7125 3)) +(pad 9 (format 7125 3 ",")) # European format diff --git a/Task/Formatted-numeric-output/Python/formatted-numeric-output-1.py b/Task/Formatted-numeric-output/Python/formatted-numeric-output-1.py new file mode 100644 index 0000000000..6f9b1ed616 --- /dev/null +++ b/Task/Formatted-numeric-output/Python/formatted-numeric-output-1.py @@ -0,0 +1,10 @@ +from math import pi, exp +r = exp(pi)-pi +print r +print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r) +print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r) +print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r) +print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r) +print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r) +print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r) +print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r) diff --git a/Task/Formatted-numeric-output/Python/formatted-numeric-output-2.py b/Task/Formatted-numeric-output/Python/formatted-numeric-output-2.py new file mode 100644 index 0000000000..1ca03ffc9d --- /dev/null +++ b/Task/Formatted-numeric-output/Python/formatted-numeric-output-2.py @@ -0,0 +1,10 @@ +from math import pi, exp +r = exp(pi)-pi +print(r) +print("e={0:e} f={0:f} g={0:g} G={0:G} s={0!s} r={0!r}!".format(r)) +print("e={0:9.4e} f={0:9.4f} g={0:9.4g}!".format(-r)) +print("e={0:9.4e} f={0:9.4f} g={0:9.4g}!".format(r)) +print("e={0:-9.4e} f={0:-9.4f} g={0:-9.4g}!".format(r)) +print("e={0:09.4e} f={0:09.4f} g={0:09.4g}!".format(-r)) +print("e={0:09.4e} f={0:09.4f} g={0:09.4g}!".format(r)) +print("e={0:-09.4e} f={0:-09.4f} g={0:-09.4g}!".format(r)) diff --git a/Task/Formatted-numeric-output/R/formatted-numeric-output-1.r b/Task/Formatted-numeric-output/R/formatted-numeric-output-1.r new file mode 100644 index 0000000000..cb3421c0af --- /dev/null +++ b/Task/Formatted-numeric-output/R/formatted-numeric-output-1.r @@ -0,0 +1,28 @@ +> sprintf("%f", pi) +[1] "3.141593" +> sprintf("%.3f", pi) +[1] "3.142" +> sprintf("%1.0f", pi) +[1] "3" +> sprintf("%5.1f", pi) +[1] " 3.1" +> sprintf("%05.1f", pi) +[1] "003.1" +> sprintf("%+f", pi) +[1] "+3.141593" +> sprintf("% f", pi) +[1] " 3.141593" +> sprintf("%-10f", pi)# left justified +[1] "3.141593 " +> sprintf("%e", pi) +[1] "3.141593e+00" +> sprintf("%E", pi) +[1] "3.141593E+00" +> sprintf("%g", pi) +[1] "3.14159" +> sprintf("%g", 1e6 * pi) # -> exponential +[1] "3.14159e+06" +> sprintf("%.9g", 1e6 * pi) # -> "fixed" +[1] "3141592.65" +> sprintf("%G", 1e-6 * pi) +[1] "3.14159E-06" diff --git a/Task/Formatted-numeric-output/R/formatted-numeric-output-2.r b/Task/Formatted-numeric-output/R/formatted-numeric-output-2.r new file mode 100644 index 0000000000..12d7cb226c --- /dev/null +++ b/Task/Formatted-numeric-output/R/formatted-numeric-output-2.r @@ -0,0 +1,2 @@ +formatC(x, width=9, flag="0") +# "00007.125" diff --git a/Task/Formatted-numeric-output/REXX/formatted-numeric-output.rexx b/Task/Formatted-numeric-output/REXX/formatted-numeric-output.rexx new file mode 100644 index 0000000000..ff99a47aec --- /dev/null +++ b/Task/Formatted-numeric-output/REXX/formatted-numeric-output.rexx @@ -0,0 +1,60 @@ +/*REXX program shows various ways to add leading zeroes to numbers. */ +a=7.125 +b=translate(format(a,10),0,' ') +say 'a=' a +say 'b=' b +say + +c=8.37 +d=right(c,20,0) +say 'c=' c +say 'd=' d +say + +e=19.46 +f='000000'e +say 'e=' e +say 'f=' f +say + +g=18.25e+1 +h=000000||g +say 'g=' g +say 'h=' h +say + +i=45.2 +j=translate(' 'i,0," ") +say 'i=' i +say 'j=' j +say + +k=36.007 +l=insert(00000000,k,0) +say 'k=' k +say 'l=' l +say + +m=.10055 +n=copies(0,20)m +say 'm=' m +say 'n=' n +say + +p=4.060 +q=0000000000000||p +say 'p=' p +say 'q=' q +say + +r=876 +s=substr(r+10000000,2) +say 'r=' r +say 's=' s +say + +t=13.02 +u=reverse(reverse(t)000000000) +say 't=' t +say 'u=' u + /*stick a fork in it, we're done.*/ diff --git a/Task/Formatted-numeric-output/Ruby/formatted-numeric-output.rb b/Task/Formatted-numeric-output/Ruby/formatted-numeric-output.rb new file mode 100644 index 0000000000..64eb341b18 --- /dev/null +++ b/Task/Formatted-numeric-output/Ruby/formatted-numeric-output.rb @@ -0,0 +1 @@ +printf " %09.3f\n", 7.125 diff --git a/Task/Formatted-numeric-output/Sather/formatted-numeric-output-1.sa b/Task/Formatted-numeric-output/Sather/formatted-numeric-output-1.sa new file mode 100644 index 0000000000..75f02c6a47 --- /dev/null +++ b/Task/Formatted-numeric-output/Sather/formatted-numeric-output-1.sa @@ -0,0 +1,6 @@ +class MAIN is + main is + #OUT + #FMT("", 7.1257) + "\n"; + #OUT + #FMT("", 7.1254) + "\n"; + end; +end; diff --git a/Task/Formatted-numeric-output/Sather/formatted-numeric-output-2.sa b/Task/Formatted-numeric-output/Sather/formatted-numeric-output-2.sa new file mode 100644 index 0000000000..d49ac79efc --- /dev/null +++ b/Task/Formatted-numeric-output/Sather/formatted-numeric-output-2.sa @@ -0,0 +1 @@ + #OUT + #FMT("%09.3f", 7.125) + "\n"; diff --git a/Task/Formatted-numeric-output/Scala/formatted-numeric-output.scala b/Task/Formatted-numeric-output/Scala/formatted-numeric-output.scala new file mode 100644 index 0000000000..26ce63d546 --- /dev/null +++ b/Task/Formatted-numeric-output/Scala/formatted-numeric-output.scala @@ -0,0 +1 @@ +println("%09.3f".format(7.125)) //-> 00007.125 diff --git a/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-1.st b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-1.st new file mode 100644 index 0000000000..9137785295 --- /dev/null +++ b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-1.st @@ -0,0 +1,2 @@ +Transcript show: (7.125 printPaddedWith: $0 to: 3.6); cr. +"output: 007.125000" diff --git a/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-2.st b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-2.st new file mode 100644 index 0000000000..0e4b71581d --- /dev/null +++ b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-2.st @@ -0,0 +1,2 @@ +(7.123 asFixedPoint:3) printOn: Transcript leftPaddedTo: 9 with: $0 +"output: 00007.125" diff --git a/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-3.st b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-3.st new file mode 100644 index 0000000000..b548eb050f --- /dev/null +++ b/Task/Formatted-numeric-output/Smalltalk/formatted-numeric-output-3.st @@ -0,0 +1 @@ +PrintfScanf new printf:'%08.3f' arguments: { 7.125 } diff --git a/Task/Formatted-numeric-output/Tcl/formatted-numeric-output.tcl b/Task/Formatted-numeric-output/Tcl/formatted-numeric-output.tcl new file mode 100644 index 0000000000..5630df9e1f --- /dev/null +++ b/Task/Formatted-numeric-output/Tcl/formatted-numeric-output.tcl @@ -0,0 +1,2 @@ +set number 7.342 +format "%08.3f" $number diff --git a/Task/Forward-difference/0DESCRIPTION b/Task/Forward-difference/0DESCRIPTION new file mode 100644 index 0000000000..cd1a663440 --- /dev/null +++ b/Task/Forward-difference/0DESCRIPTION @@ -0,0 +1,9 @@ +Provide code that produces a list of numbers which is the n-th order forward difference, given a non-negative integer (specifying the order) and a list of numbers. The first-order forward difference of a list of numbers (A) is a new list (B) where Bn = An+1 - An. List B should have one fewer element as a result. The second-order forward difference of A will be the same as the first-order forward difference of B. That new list will have two fewer elements than A and one less than B. The goal of this task is to repeat this process up to the desired order. + +For a more formal description, see the related [http://mathworld.wolfram.com/ForwardDifference.html Mathworld article]. + +Algorithmic options: +*Iterate through all previous forward differences and re-calculate a new array each time. +*Use this formula (from [[wp:Forward difference|Wikipedia]]): +:\Delta^n [f](x)= \sum_{k=0}^n {n \choose k} (-1)^{n-k} f(x+k) +:([[Pascal's Triangle]] may be useful for this option) diff --git a/Task/Forward-difference/1META.yaml b/Task/Forward-difference/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Forward-difference/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Forward-difference/ALGOL-68/forward-difference.alg b/Task/Forward-difference/ALGOL-68/forward-difference.alg new file mode 100644 index 0000000000..f676d6e7e8 --- /dev/null +++ b/Task/Forward-difference/ALGOL-68/forward-difference.alg @@ -0,0 +1,21 @@ +main:( + MODE LISTREAL = [1:0]REAL; + + OP - = (LISTREAL a,b)LISTREAL: ( + [UPB a]REAL out; + FOR i TO UPB out DO out[i]:=a[i]-b[i] OD; + out + ); + + FORMAT real fmt=$zzz-d.d$; + FORMAT repeat fmt = $n(UPB s-1)(f(real fmt)",")f(real fmt)$; + FORMAT list fmt = $"("f(UPB s=1|real fmt|repeat fmt)")"$; + + FLEX [1:0] REAL s := (90, 47, 58, 29, 22, 32, 55, 5, 55, 73); + + printf((list fmt,s,$";"l$)); + TO UPB s-1 DO + s := s[2:] - s[:UPB s-1]; + printf((list fmt,s,$";"l$)) + OD +) diff --git a/Task/Forward-difference/APL/forward-difference.apl b/Task/Forward-difference/APL/forward-difference.apl new file mode 100644 index 0000000000..e2f8e80170 --- /dev/null +++ b/Task/Forward-difference/APL/forward-difference.apl @@ -0,0 +1,9 @@ + list ← 90 47 58 29 22 32 55 5 55 73 + + fd ← {⍺=0:⍵⋄(⍺-1)∇(1↓⍵)-(¯1↓⍵)} + + 1 fd list +¯43 11 ¯29 ¯7 10 23 ¯50 50 18 + + 2 fd list +54 ¯40 22 17 13 ¯73 100 ¯32 diff --git a/Task/Forward-difference/AWK/forward-difference-1.awk b/Task/Forward-difference/AWK/forward-difference-1.awk new file mode 100644 index 0000000000..38cc61c82a --- /dev/null +++ b/Task/Forward-difference/AWK/forward-difference-1.awk @@ -0,0 +1,20 @@ +#!/usr/bin/awk -f +BEGIN { + if (p<1) {p = 1}; +} + +function diff(s, p) { + n = split(s, a, " "); + for (j = 1; j <= p; j++) { + for(i = 1; i <= n-j; i++) { + a[i] = a[i+1] - a[i]; + } + } + s = ""; + for (i = 1; i <= n-p; i++) s = s" "a[i]; + return s; +} + +{ + print diff($0, p); +} diff --git a/Task/Forward-difference/AWK/forward-difference-2.awk b/Task/Forward-difference/AWK/forward-difference-2.awk new file mode 100644 index 0000000000..bab8d3196a --- /dev/null +++ b/Task/Forward-difference/AWK/forward-difference-2.awk @@ -0,0 +1,27 @@ +#!/usr/bin/awk -f +BEGIN { + if (p<1) {p = 1}; +} + +function diff(s, p) { + # pascal triangled with sign changes + b[1] = (p%2) ? 1 : -1; + for (j=1; j < p; j++) { + b[j+1] = -b[j]*(p-j)/j; + }; + + n = split(s, a, " "); + s = ""; + for (j = 1; j <= n-p+1; j++) { + c = 0; + for(i = 1; i <= p; i++) { + c += b[i]*a[j+i-1]; + } + s = s" "c; + } + return s; +} + +{ + print diff($0, p); +} diff --git a/Task/Forward-difference/Ada/forward-difference.ada b/Task/Forward-difference/Ada/forward-difference.ada new file mode 100644 index 0000000000..c45044ebfe --- /dev/null +++ b/Task/Forward-difference/Ada/forward-difference.ada @@ -0,0 +1,50 @@ +with Ada.Text_Io; +with Ada.Float_Text_Io; use Ada.Float_Text_Io; +with Ada.containers.Vectors; + +procedure Forward_Difference is + package Flt_Vect is new Ada.Containers.Vectors(Positive, Float); + use Flt_Vect; + procedure Print(Item : Vector) is + begin + if not Item.Is_Empty then + Ada.Text_IO.Put('['); + for I in 1..Item.Length loop + Put(Item => Item.Element(Positive(I)), Fore => 1, Aft => 1, Exp => 0); + if Positive(I) < Positive(Item.Length) then + Ada.Text_Io.Put(", "); + end if; + end loop; + Ada.Text_Io.Put_line("]"); + else + Ada.Text_IO.Put_Line("Empty List"); + end if; + + end Print; + + function Diff(Item : Vector; Num_Passes : Natural) return Vector is + A : Vector := Item; + B : Vector := Empty_Vector; + begin + if not A.Is_Empty then + for I in 1..Num_Passes loop + for I in 1..Natural(A.Length) - 1 loop + B.Append(A.Element(I + 1) - A.Element(I)); + end loop; + Move(Target => A, Source => B); + end loop; + end if; + return A; + end Diff; + Values : array(1..10) of Float := (90.0, 47.0, 58.0, 29.0, 22.0, 32.0, 55.0, 5.0, 55.0, 73.0); + A : Vector; +begin + for I in Values'range loop + A.Append(Values(I)); -- Fill the vector + end loop; + Print(Diff(A, 1)); + Print(Diff(A, 2)); + Print(Diff(A, 9)); + Print(Diff(A, 10)); + print(Diff(A, 0)); +end Forward_Difference; diff --git a/Task/Forward-difference/AutoHotkey/forward-difference.ahk b/Task/Forward-difference/AutoHotkey/forward-difference.ahk new file mode 100644 index 0000000000..3d2d2f5310 --- /dev/null +++ b/Task/Forward-difference/AutoHotkey/forward-difference.ahk @@ -0,0 +1,17 @@ +MsgBox % diff("2,3,4,3",1) +MsgBox % diff("2,3,4,3",2) +MsgBox % diff("2,3,4,3",3) +MsgBox % diff("2,3,4,3",4) + +diff(list,ord) { ; high order forward differences of a list + Loop %ord% { + L = + Loop Parse, list, `, %A_Space%%A_Tab% + If (A_Index=1) + p := A_LoopField + Else + L .= "," A_LoopField-p, p := A_LoopField + list := SubStr(L,2) + } + Return list +} diff --git a/Task/Forward-difference/BBC-BASIC/forward-difference.bbc b/Task/Forward-difference/BBC-BASIC/forward-difference.bbc new file mode 100644 index 0000000000..a48819203d --- /dev/null +++ b/Task/Forward-difference/BBC-BASIC/forward-difference.bbc @@ -0,0 +1,30 @@ + DIM A(9) + A() = 90.0, 47.0, 58.0, 29.0, 22.0, 32.0, 55.0, 5.0, 55.0, 73.0 + PRINT "Original array: " FNshowarray(A()) + PROCforward_difference(1, A(), B()) + PRINT "Forward diff 1: " FNshowarray(B()) + PROCforward_difference(2, A(), C()) + PRINT "Forward diff 2: " FNshowarray(C()) + PROCforward_difference(9, A(), D()) + PRINT "Forward diff 9: " FNshowarray(D()) + END + + DEF PROCforward_difference(n%, a(), RETURN b()) + LOCAL c%, i%, j% + DIM b(DIM(a(),1) - n%) + FOR i% = 0 TO DIM(b(),1) + b(i%) = a(i% + n%) + c% = 1 + FOR j% = 1 TO n% + c% = -INT(c% * (n% - j% + 1) / j% + 0.5) + b(i%) += c% * a(i% + n% - j%) + NEXT + NEXT + ENDPROC + + DEF FNshowarray(a()) + LOCAL i%, a$ + FOR i% = 0 TO DIM(a(),1) + a$ += STR$(a(i%)) + ", " + NEXT + = LEFT$(LEFT$(a$)) diff --git a/Task/Forward-difference/C++/forward-difference-1.cpp b/Task/Forward-difference/C++/forward-difference-1.cpp new file mode 100644 index 0000000000..a1c64c929c --- /dev/null +++ b/Task/Forward-difference/C++/forward-difference-1.cpp @@ -0,0 +1,111 @@ +#include +#include +#include + +// calculate first order forward difference +// requires: +// * InputIterator is an input iterator +// * OutputIterator is an output iterator +// * The value type of InputIterator is copy-constructible and assignable +// * The value type of InputIterator supports operator - +// * The result type of operator- is assignable to the value_type of OutputIterator +// returns: The iterator following the output sequence +template + OutputIterator forward_difference(InputIterator first, InputIterator last, + OutputIterator dest) +{ + // special case: for empty sequence, do nothing + if (first == last) + return dest; + + typedef typename std::iterator_traits::value_type value_type; + + value_type temp = *first++; + while (first != last) + { + value_type temp2 = *first++; + *dest++ = temp2 - temp; + temp = temp2; + } + + return dest; +} + +// calculate n-th order forward difference. +// requires: +// * InputIterator is an input iterator +// * OutputIterator is an output iterator +// * The value type of InputIterator is copy-constructible and assignable +// * The value type of InputIterator supports operator - +// * The result type of operator- is assignable to the value_type of InputIterator +// * The result type of operator- is assignable to the value_type of OutputIterator +// * order >= 0 +// returns: The iterator following the output sequence +template + OutputIterator nth_forward_difference(int order, + InputIterator first, InputIterator last, + OutputIterator dest) +{ + // special case: If order == 0, just copy input to output + if (order == 0) + return std::copy(first, last, dest); + + // second special case: If order == 1, just forward to the first-order function + if (order == 1) + return forward_difference(first, last, dest); + + // intermediate results are stored in a vector + typedef typename std::iterator_traits::value_type value_type; + std::vector temp_storage; + + // fill the vector with the result of the first order forward difference + forward_difference(first, last, std::back_inserter(temp_storage)); + + // the next n-2 iterations work directly on the vector + typename std::vector::iterator begin = temp_storage.begin(), + end = temp_storage.end(); + for (int i = 1; i < order-1; ++i) + end = forward_difference(begin, end, begin); + + // the final iteration writes directly to the output iterator + return forward_difference(begin, end, dest); +} + +// example usage code +#include + +int main() +{ + double array[10] = { 90.0, 47.0, 58.0, 29.0, 22.0, 32.0, 55.0, 5.0, 55.0, 73.0 }; + + // this stores the results in the vector dest + std::vector dest; + nth_forward_difference(1, array, array+10, std::back_inserter(dest)); + + // outut dest + std::copy(dest.begin(), dest.end(), std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + // however, the results can also be output as they are calculated + nth_forward_difference(2, array, array+10, std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + nth_forward_difference(9, array, array+10, std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + nth_forward_difference(10, array, array+10, std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + nth_forward_difference(0, array, array+10, std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + // finally, the results can also be written into the original array + // (which of course destroys the original content) + double* end = nth_forward_difference(3, array, array+10, array); + + for (double* p = array; p < end; ++p) + std::cout << *p << " "; + std::cout << std::endl; + + return 0; +} diff --git a/Task/Forward-difference/C++/forward-difference-2.cpp b/Task/Forward-difference/C++/forward-difference-2.cpp new file mode 100644 index 0000000000..be989875eb --- /dev/null +++ b/Task/Forward-difference/C++/forward-difference-2.cpp @@ -0,0 +1,16 @@ +#include +#include +// Calculate the Forward Difference of a series if integers showing each order +// +// Nigel Galloway. August 20th., 2012 +// +int main() { + int x[] = {NULL,-43,11,-29,-7,10,23,-50,50,18}; + const int N = sizeof(x) / sizeof(int) - 1; + for (int ord = 0; ord < N - 1; ord++) { + std::adjacent_difference(x+1, x + N + 1 - ord, x); + for (int i = 1; i < N - ord; i++) std::cout << x[i] << ' '; + std::cout << std::endl; + } + return 0; +} diff --git a/Task/Forward-difference/C++/forward-difference-3.cpp b/Task/Forward-difference/C++/forward-difference-3.cpp new file mode 100644 index 0000000000..db95ab888e --- /dev/null +++ b/Task/Forward-difference/C++/forward-difference-3.cpp @@ -0,0 +1,13 @@ +#include +#include +// Calculate the Forward Difference of a series if integers +// +// Nigel Galloway. August 20th., 2012 +// +int main() { + int x[] = {NULL,-43,11,-29,-7,10,23,-50,50,18}; + const int N = sizeof(x) / sizeof(int) - 1; + for (int ord = 0; ord < N - 1; ord++) std::adjacent_difference(x+1, x + N + 1 - ord, x); + std::cout << x[1] << std::endl; + return 0; +} diff --git a/Task/Forward-difference/C++/forward-difference-4.cpp b/Task/Forward-difference/C++/forward-difference-4.cpp new file mode 100644 index 0000000000..61cc9a49ac --- /dev/null +++ b/Task/Forward-difference/C++/forward-difference-4.cpp @@ -0,0 +1,14 @@ +#include +#include +// Calculate the Forward Difference of a series if integers using Pascal's Triangle +// For this example the 9th line of Pascal's Triangle is stored in P. +// +// Nigel Galloway. August 20th., 2012 +// +int main() { + const int P[] = {1,-8,28,-56,70,-56,28,-8,1}; + int x[] = {-43,11,-29,-7,10,23,-50,50,18}; + std::transform(x, x + sizeof(x) / sizeof(int), P, x, std::multiplies()); + std::cout << std::accumulate(x, x + sizeof(x) / sizeof(int), 0) << std::endl; + return 0; +} diff --git a/Task/Forward-difference/C-sharp/forward-difference.cs b/Task/Forward-difference/C-sharp/forward-difference.cs new file mode 100644 index 0000000000..a34823d75b --- /dev/null +++ b/Task/Forward-difference/C-sharp/forward-difference.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +class Program +{ + static IEnumerable ForwardDifference(IEnumerable sequence, uint order = 1u) + { + switch (order) + { + case 0u: + return sequence; + case 1u: + return sequence.Skip(1).Zip(sequence, (next, current) => next - current); + default: + return ForwardDifference(ForwardDifference(sequence), order - 1u); + } + } + + static void Main() + { + IEnumerable sequence = new[] { 90, 47, 58, 29, 22, 32, 55, 5, 55, 73 }; + do + { + Console.WriteLine(string.Join(", ", sequence)); + } while ((sequence = ForwardDifference(sequence)).Any()); + } +} diff --git a/Task/Forward-difference/C/forward-difference-1.c b/Task/Forward-difference/C/forward-difference-1.c new file mode 100644 index 0000000000..cfadcb3c51 --- /dev/null +++ b/Task/Forward-difference/C/forward-difference-1.c @@ -0,0 +1,39 @@ +#include +#include +#include + +double* fwd_diff(double* x, unsigned int len, unsigned int order) +{ + unsigned int i, j; + double* y; + + /* handle two special cases */ + if (order >= len) return 0; + + y = malloc(sizeof(double) * len); + if (!order) { + memcpy(y, x, sizeof(double) * len); + return y; + } + + /* first order diff goes from x->y, later ones go from y->y */ + for (j = 0; j < order; j++, x = y) + for (i = 0, len--; i < len; i++) + y[i] = x[i + 1] - x[i]; + + y = realloc(y, sizeof(double) * len); + return y; +} + +int main(void) +{ + double *y, x[] = {90, 47, 58, 29, 22, 32, 55, 5, 55, 73}; + int i, len = sizeof(x) / sizeof(x[0]); + + y = fwd_diff(x, len, 1); + for (i = 0; i < len - 1; i++) + printf("%g ", y[i]); + putchar('\n'); + + return 0; +} diff --git a/Task/Forward-difference/C/forward-difference-2.c b/Task/Forward-difference/C/forward-difference-2.c new file mode 100644 index 0000000000..f8e75c60d1 --- /dev/null +++ b/Task/Forward-difference/C/forward-difference-2.c @@ -0,0 +1,33 @@ +#include + +int* binomCoeff(int n) { + int *b = calloc(n+1,sizeof(int)); + int j; + b[0] = n%2 ? -1 : 1; + for (j=1 ; j<=n; j++) + b[j] = -b[j-1]*(n+1-j)/j; + + return(b); +}; + +main () { + double array[] = { 90, 47, 58, 29, 22, 32, 55, 5, 55, 73 }; + size_t lenArray = sizeof(array)/sizeof(array[0]); + + int p = 4; // order + int *b = binomCoeff(p); // pre-compute binomial coefficients for order p + + int j, k; + + // compute p-th difference + for (k=0 ; k < lenArray; k++) + for (array[k] *= b[0], j=1 ; j<=p; j++) + array[k] += b[j] * array[k+j]; + + free(b); + + // resulting series is shorter by p elements + lenArray -= p; + for (k=0 ; k < lenArray; k++) printf("%f ",array[k]); + printf("\n"); +} diff --git a/Task/Forward-difference/Clojure/forward-difference.clj b/Task/Forward-difference/Clojure/forward-difference.clj new file mode 100644 index 0000000000..3749a4122f --- /dev/null +++ b/Task/Forward-difference/Clojure/forward-difference.clj @@ -0,0 +1,2 @@ +(defn fwd-diff [nums order] + (nth (iterate #(map - (next %) %) nums) order)) diff --git a/Task/Forward-difference/CoffeeScript/forward-difference.coffee b/Task/Forward-difference/CoffeeScript/forward-difference.coffee new file mode 100644 index 0000000000..9729103d50 --- /dev/null +++ b/Task/Forward-difference/CoffeeScript/forward-difference.coffee @@ -0,0 +1,11 @@ +forward_difference = (arr, n) -> + # Find the n-th order forward difference for arr using + # a straightforward recursive algorithm. + # Assume arr is integers and n <= arr.length. + return arr if n == 0 + arr = forward_difference(arr, n-1) + (arr[i+1] - arr[i] for i in [0...arr.length - 1]) + +arr = [-1, 0, 1, 8, 27, 64, 125, 216] +for n in [0..arr.length] + console.log n, forward_difference arr, n diff --git a/Task/Forward-difference/Common-Lisp/forward-difference.lisp b/Task/Forward-difference/Common-Lisp/forward-difference.lisp new file mode 100644 index 0000000000..998a025e90 --- /dev/null +++ b/Task/Forward-difference/Common-Lisp/forward-difference.lisp @@ -0,0 +1,7 @@ +(defun forward-difference (list) + (mapcar #'- (rest list) list)) + +(defun nth-forward-difference (list n) + (setf list (copy-list list)) + (loop repeat n do (map-into list #'- (rest list) list)) + (subseq list 0 (- (length list) n))) diff --git a/Task/Forward-difference/D/forward-difference-1.d b/Task/Forward-difference/D/forward-difference-1.d new file mode 100644 index 0000000000..a5e6e4031b --- /dev/null +++ b/Task/Forward-difference/D/forward-difference-1.d @@ -0,0 +1,20 @@ +import std.stdio; + +T[] forwardDifference(T)(in T[] data, in int level) pure nothrow + in { + assert(level >= 0 && level < data.length); + } body { + //auto result = data.dup; // not nothrow + auto result = data ~ []; // slower + foreach (i; 0 .. level) + foreach (j, ref el; result[0 .. $ - i - 1]) + el = result[j + 1] - el; + result.length -= level; + return result; + } + +void main() { + auto data = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5]; + foreach (level; 0 .. data.length) + writeln(forwardDifference(data, level)); +} diff --git a/Task/Forward-difference/D/forward-difference-2.d b/Task/Forward-difference/D/forward-difference-2.d new file mode 100644 index 0000000000..5d44301d88 --- /dev/null +++ b/Task/Forward-difference/D/forward-difference-2.d @@ -0,0 +1,13 @@ +import std.stdio, std.algorithm, std.range, std.array; + +auto forwardDifference(Range)(Range d, in int level) { + foreach (_; 0 .. level) + d = zip(d[1 .. $], d).map!q{ a[0] - a[1] }().array(); + return d; +} + +void main() { + auto data = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5]; + foreach (level; 0 .. data.length) + writeln(forwardDifference(data, level)); +} diff --git a/Task/Forward-difference/D/forward-difference-3.d b/Task/Forward-difference/D/forward-difference-3.d new file mode 100644 index 0000000000..c30c2b0fff --- /dev/null +++ b/Task/Forward-difference/D/forward-difference-3.d @@ -0,0 +1,12 @@ +import std.stdio; + +T[] forwardDifference(T)(T[] s, in int n) pure { + foreach (_; 0 .. n) + s[] -= s[1 .. $]; + return s[0 .. $ - n]; +} +void main() { + immutable A = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5]; + foreach (level; 0 .. A.length) + writeln(forwardDifference(A.dup, level)); +} diff --git a/Task/Forward-difference/D/forward-difference-4.d b/Task/Forward-difference/D/forward-difference-4.d new file mode 100644 index 0000000000..767393125b --- /dev/null +++ b/Task/Forward-difference/D/forward-difference-4.d @@ -0,0 +1,8 @@ +import std.stdio, std.range; + +void main() { + auto D = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5]; + auto R = recurrence!q{(a[n-1].dup[] -= a[n-1][1..$])[0..$-1]}(D); + foreach (di; take(R, D.length)) + writeln(di); +} diff --git a/Task/Forward-difference/E/forward-difference.e b/Task/Forward-difference/E/forward-difference.e new file mode 100644 index 0000000000..63efdb0cab --- /dev/null +++ b/Task/Forward-difference/E/forward-difference.e @@ -0,0 +1,32 @@ +pragma.enable("accumulator") +/** Single step. */ +def forwardDifference(seq :List) { + return accum [] for i in 0..(seq.size() - 2) { + _.with(seq[i + 1] - seq[i]) + } +} + +/** Iterative implementation of the goal. */ +def nthForwardDifference1(var seq :List, n :(int >= 0)) { + for _ in 1..n { seq := forwardDifference(seq) } + return seq +} + +/** Imperative implementation of the goal. */ +def nthForwardDifference2(seq :List, n :(int >= 0)) { + def buf := seq.diverge() + def finalSize := seq.size() - n + for lim in (finalSize..!seq.size()).descending() { + for i in 0..!lim { + buf[i] := buf[i + 1] - buf[i] + } + } + return buf.run(0, finalSize) +} + +? def sampleData := [90, 47, 58, 29, 22, 32, 55, 5, 55, 73] +> for n in 0..10 { +> def r1 := nthForwardDifference1(sampleData, n) +> require(r1 == nthForwardDifference2(sampleData, n)) +> println(r1) +> } diff --git a/Task/Forward-difference/Factor/forward-difference.factor b/Task/Forward-difference/Factor/forward-difference.factor new file mode 100644 index 0000000000..632f9a2419 --- /dev/null +++ b/Task/Forward-difference/Factor/forward-difference.factor @@ -0,0 +1,9 @@ +USING: kernel math math.vectors sequences ; +IN: rosetacode + +: 1-order ( seq -- seq' ) + [ rest-slice ] keep v- ; + +: n-order ( seq n -- seq' ) + dup 0 <= + [ drop ] [ [ 1-order ] times ] if ; diff --git a/Task/Forward-difference/Forth/forward-difference.fth b/Task/Forward-difference/Forth/forward-difference.fth new file mode 100644 index 0000000000..2bb23d9b85 --- /dev/null +++ b/Task/Forward-difference/Forth/forward-difference.fth @@ -0,0 +1,15 @@ +: forward-difference + dup 0 + ?do + swap rot over i 1+ - 0 + ?do dup i cells + dup cell+ @ over @ - swap ! loop + swap rot + loop - +; + +create a + 90 , 47 , 58 , 29 , 22 , 32 , 55 , 5 , 55 , 73 , + +: test a 10 9 forward-difference bounds ?do i ? loop ; + +test diff --git a/Task/Forward-difference/Fortran/forward-difference-1.f b/Task/Forward-difference/Fortran/forward-difference-1.f new file mode 100644 index 0000000000..4e2dfce528 --- /dev/null +++ b/Task/Forward-difference/Fortran/forward-difference-1.f @@ -0,0 +1,20 @@ +MODULE DIFFERENCE + IMPLICIT NONE + + CONTAINS + + SUBROUTINE Fdiff(a, n) + INTEGER, INTENT(IN) :: a(:), n + INTEGER :: b(SIZE(a)) + INTEGER :: i, j, arraysize + + b = a + arraysize = SIZE(b) + DO i = arraysize-1, arraysize-n, -1 + DO j = 1, i + b(j) = b(j+1) - b(j) + END DO + END DO + WRITE (*,*) b(1:arraysize-n) + END SUBROUTINE Fdiff +END MODULE DIFFERENCE diff --git a/Task/Forward-difference/Fortran/forward-difference-2.f b/Task/Forward-difference/Fortran/forward-difference-2.f new file mode 100644 index 0000000000..1dc4ec74ca --- /dev/null +++ b/Task/Forward-difference/Fortran/forward-difference-2.f @@ -0,0 +1,13 @@ +PROGRAM TEST + + USE DIFFERENCE + IMPLICIT NONE + + INTEGER :: array(10) = (/ 90, 47, 58, 29, 22, 32, 55, 5, 55, 73 /) + INTEGER :: i + + DO i = 1, 9 + CALL Fdiff(array, i) + END DO + + END PROGRAM TEST diff --git a/Task/Forward-difference/Go/forward-difference.go b/Task/Forward-difference/Go/forward-difference.go new file mode 100644 index 0000000000..7a245e9460 --- /dev/null +++ b/Task/Forward-difference/Go/forward-difference.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +func main() { + a := []int{90, 47, 58, 29, 22, 32, 55, 5, 55, 73} + fmt.Println(a) + fmt.Println(fd(a, 9)) +} + +func fd(a []int, ord int) []int { + for i := 0; i < ord; i++ { + for j := 0; j < len(a)-i-1; j++ { + a[j] = a[j+1] - a[j] + } + } + return a[:len(a)-ord] +} diff --git a/Task/Forward-difference/Haskell/forward-difference.hs b/Task/Forward-difference/Haskell/forward-difference.hs new file mode 100644 index 0000000000..d068eaeb30 --- /dev/null +++ b/Task/Forward-difference/Haskell/forward-difference.hs @@ -0,0 +1,15 @@ +forwardDifference xs = zipWith (-) (tail xs) xs + +nthForwardDifference xs n = iterate forwardDifference xs !! n + +> take 10 (iterate forwardDifference [90, 47, 58, 29, 22, 32, 55, 5, 55, 73]) +[[90,47,58,29,22,32,55,5,55,73], + [-43,11,-29,-7,10,23,-50,50,18], + [54,-40,22,17,13,-73,100,-32], + [-94,62,-5,-4,-86,173,-132], + [156,-67,1,-82,259,-305], + [-223,68,-83,341,-564], + [291,-151,424,-905], + [-442,575,-1329], + [1017,-1904], + [-2921]] diff --git a/Task/Forward-difference/HicEst/forward-difference-1.hicest b/Task/Forward-difference/HicEst/forward-difference-1.hicest new file mode 100644 index 0000000000..83e9a5903e --- /dev/null +++ b/Task/Forward-difference/HicEst/forward-difference-1.hicest @@ -0,0 +1,12 @@ +REAL :: n=10, list(n) + +list = ( 90, 47, 58, 29, 22, 32, 55, 5, 55, 73 ) +WRITE(Format='i1, (i6)') 0, list + +DO i = 1, n-1 + ALIAS(list,1, diff,n-i) ! rename list(1 ... n-i) with diff + diff = list($+1) - diff ! $ is the running left hand array index + WRITE(Format='i1, (i6)') i, diff +ENDDO + +END diff --git a/Task/Forward-difference/HicEst/forward-difference-2.hicest b/Task/Forward-difference/HicEst/forward-difference-2.hicest new file mode 100644 index 0000000000..eb2eefc020 --- /dev/null +++ b/Task/Forward-difference/HicEst/forward-difference-2.hicest @@ -0,0 +1,10 @@ +0 90 47 58 29 22 32 55 5 55 73 +1 -43 11 -29 -7 10 23 -50 50 18 +2 54 -40 22 17 13 -73 100 -32 +3 -94 62 -5 -4 -86 173 -132 +4 156 -67 1 -82 259 -305 +5 -223 68 -83 341 -564 +6 291 -151 424 -905 +7 -442 575 -1329 +8 1017 -1904 +9 -2921 diff --git a/Task/Forward-difference/IDL/forward-difference.idl b/Task/Forward-difference/IDL/forward-difference.idl new file mode 100644 index 0000000000..2706d4006a --- /dev/null +++ b/Task/Forward-difference/IDL/forward-difference.idl @@ -0,0 +1,8 @@ +print,(x = randomu(seed,8)*100) + 15.1473 58.0953 82.7465 16.8637 97.7182 59.7856 17.7699 74.9154 +print,ts_diff(x,1) + -42.9479 -24.6513 65.8828 -80.8545 37.9326 42.0157 -57.1455 0.000000 +print,ts_diff(x,2) + -18.2967 -90.5341 146.737 -118.787 -4.08316 99.1613 0.000000 0.000000 +print,ts_diff(x,3) + 72.2374 -237.271 265.524 -114.704 -103.244 0.000000 0.000000 0.000000 diff --git a/Task/Forward-difference/Icon/forward-difference.icon b/Task/Forward-difference/Icon/forward-difference.icon new file mode 100644 index 0000000000..33285a05d8 --- /dev/null +++ b/Task/Forward-difference/Icon/forward-difference.icon @@ -0,0 +1,17 @@ +procedure main(A) # Compute all forward difference orders for argument list + every order := 1 to (*A-1) do showList(order, fdiff(A, order)) +end + +procedure fdiff(A, order) + every 1 to order do { + every put(B := [], A[i := 2 to *A] - A[i-1]) + A := B + } + return A +end + +procedure showList(order, L) + writes(right(order,3),": ") + every writes(!L," ") + write() +end diff --git a/Task/Forward-difference/J/forward-difference-1.j b/Task/Forward-difference/J/forward-difference-1.j new file mode 100644 index 0000000000..44436fb55f --- /dev/null +++ b/Task/Forward-difference/J/forward-difference-1.j @@ -0,0 +1 @@ +fd=: 2&(-~/\) diff --git a/Task/Forward-difference/J/forward-difference-2.j b/Task/Forward-difference/J/forward-difference-2.j new file mode 100644 index 0000000000..4f1db90cd7 --- /dev/null +++ b/Task/Forward-difference/J/forward-difference-2.j @@ -0,0 +1 @@ +fd=:}.-}:^: diff --git a/Task/Forward-difference/J/forward-difference-3.j b/Task/Forward-difference/J/forward-difference-3.j new file mode 100644 index 0000000000..e19dc6020c --- /dev/null +++ b/Task/Forward-difference/J/forward-difference-3.j @@ -0,0 +1,7 @@ + list =: 90 47 58 29 22 32 55 5 55 73 NB. Some numbers + + 1 fd list +_43 11 _29 _7 10 23 _50 50 18 + + 2 fd list +54 _40 22 17 13 _73 100 _32 diff --git a/Task/Forward-difference/J/forward-difference-4.j b/Task/Forward-difference/J/forward-difference-4.j new file mode 100644 index 0000000000..daabcf4bb3 --- /dev/null +++ b/Task/Forward-difference/J/forward-difference-4.j @@ -0,0 +1,17 @@ + 1 2 3 fd list NB. First, second, and third forward differences (simultaneously) +43 _11 29 7 _10 _23 50 _50 _18 +54 _40 22 17 13 _73 100 _32 0 +94 _62 5 4 86 _173 132 0 0 + + a: fd list NB. All forward differences + 90 47 58 29 22 32 55 5 55 73 + 43 _11 29 7 _10 _23 50 _50 _18 0 + 54 _40 22 17 13 _73 100 _32 0 0 + 94 _62 5 4 86 _173 132 0 0 0 + 156 _67 1 _82 259 _305 0 0 0 0 + 223 _68 83 _341 564 0 0 0 0 0 + 291 _151 424 _905 0 0 0 0 0 0 + 442 _575 1329 0 0 0 0 0 0 0 +1017 _1904 0 0 0 0 0 0 0 0 +2921 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 diff --git a/Task/Forward-difference/Java/forward-difference.java b/Task/Forward-difference/Java/forward-difference.java new file mode 100644 index 0000000000..b041f1993d --- /dev/null +++ b/Task/Forward-difference/Java/forward-difference.java @@ -0,0 +1,27 @@ +import java.util.Arrays; +public class FD { + public static void main(String args[]) { + double[] a = {90, 47, 58, 29, 22, 32, 55, 5, 55, 73}; + System.out.println(Arrays.toString(dif(a, 1))); + System.out.println(Arrays.toString(dif(a, 2))); + System.out.println(Arrays.toString(dif(a, 9))); + System.out.println(Arrays.toString(dif(a, 10))); //let's test + System.out.println(Arrays.toString(dif(a, 11))); + System.out.println(Arrays.toString(dif(a, -1))); + System.out.println(Arrays.toString(dif(a, 0))); + } + + public static double[] dif(double[] a, int n) { + if (n < 0) + return null; // if the programmer was dumb + + for (int i = 0; i < n && a.length > 0; i++) { + double[] b = new double[a.length - 1]; + for (int j = 0; j < b.length; j++){ + b[j] = a[j+1] - a[j]; + } + a = b; //"recurse" + } + return a; + } +} diff --git a/Task/Forward-difference/Logo/forward-difference.logo b/Task/Forward-difference/Logo/forward-difference.logo new file mode 100644 index 0000000000..689cecbce5 --- /dev/null +++ b/Task/Forward-difference/Logo/forward-difference.logo @@ -0,0 +1,12 @@ +to fwd.diff :l + if empty? :l [output []] + if empty? bf :l [output []] + output fput (first bf :l)-(first :l) fwd.diff bf :l +end +to nth.fwd.diff :n :l + if :n = 0 [output :l] + output nth.fwd.diff :n-1 fwd.diff :l +end + +show nth.fwd.diff 9 [90 47 58 29 22 32 55 5 55 73] +[-2921] diff --git a/Task/Forward-difference/Lua/forward-difference.lua b/Task/Forward-difference/Lua/forward-difference.lua new file mode 100644 index 0000000000..c0d487ac17 --- /dev/null +++ b/Task/Forward-difference/Lua/forward-difference.lua @@ -0,0 +1,5 @@ +function dif(a, b, ...) + if(b) then return b-a, dif(b, ...) end +end +function dift(t) return {dif(unpack(t))} end +print(unpack(dift{1,3,6,10,15})) diff --git a/Task/Forward-difference/MATLAB/forward-difference-1.m b/Task/Forward-difference/MATLAB/forward-difference-1.m new file mode 100644 index 0000000000..e0126dd9c9 --- /dev/null +++ b/Task/Forward-difference/MATLAB/forward-difference-1.m @@ -0,0 +1 @@ +Y = diff(X,n); diff --git a/Task/Forward-difference/MATLAB/forward-difference-2.m b/Task/Forward-difference/MATLAB/forward-difference-2.m new file mode 100644 index 0000000000..71ea9d133a --- /dev/null +++ b/Task/Forward-difference/MATLAB/forward-difference-2.m @@ -0,0 +1,5 @@ +diff([1 2 3 4 5]) + +ans = + + 1 1 1 1 diff --git a/Task/Forward-difference/Mathematica/forward-difference-1.mathematica b/Task/Forward-difference/Mathematica/forward-difference-1.mathematica new file mode 100644 index 0000000000..1961175591 --- /dev/null +++ b/Task/Forward-difference/Mathematica/forward-difference-1.mathematica @@ -0,0 +1,2 @@ +i={3,5,12,1,6,19,6,2,4,9}; +Differences[i] diff --git a/Task/Forward-difference/Mathematica/forward-difference-2.mathematica b/Task/Forward-difference/Mathematica/forward-difference-2.mathematica new file mode 100644 index 0000000000..92f75ad72a --- /dev/null +++ b/Task/Forward-difference/Mathematica/forward-difference-2.mathematica @@ -0,0 +1 @@ +{2, 7, -11, 5, 13, -13, -4, 2, 5} diff --git a/Task/Forward-difference/Mathematica/forward-difference-3.mathematica b/Task/Forward-difference/Mathematica/forward-difference-3.mathematica new file mode 100644 index 0000000000..a8e83fa64d --- /dev/null +++ b/Task/Forward-difference/Mathematica/forward-difference-3.mathematica @@ -0,0 +1,2 @@ +i={3,5,12,1,6,19,6,2,4,9}; +Differences[i,n] diff --git a/Task/Forward-difference/Maxima/forward-difference.maxima b/Task/Forward-difference/Maxima/forward-difference.maxima new file mode 100644 index 0000000000..6b5a977beb --- /dev/null +++ b/Task/Forward-difference/Maxima/forward-difference.maxima @@ -0,0 +1 @@ +ldiff(u, n) := block([m: length(u)], for j thru n do u: makelist(u[i + 1] - u[i], i, 1, m - j), u); diff --git a/Task/Forward-difference/PHP/forward-difference.php b/Task/Forward-difference/PHP/forward-difference.php new file mode 100644 index 0000000000..6f1863d091 --- /dev/null +++ b/Task/Forward-difference/PHP/forward-difference.php @@ -0,0 +1,43 @@ +rand()->int()); + $this->spec(forwardDiff($expected))->shouldEqual(array()); + } + + function _should_give_diff_of_two_elem_as_single_elem() { + $twoNums = array($this->rand()->int(), $this->rand()->int()); + $expected = array($twoNums[1] - $twoNums[0]); + $this->spec(forwardDiff($twoNums))->shouldEqual($expected); + } + + function _should_compute_correct_forward_diff_for_longer_arrays() { + $diffInput = array(10, 2, 9, 6, 5); + $expected = array(-8, 7, -3, -1); + $this->spec(forwardDiff($diffInput))->shouldEqual($expected); + } + + function _should_apply_more_than_once_if_specified() { + $diffInput = array(4, 6, 9, 3, 4); + $expectedAfter1 = array(2, 3, -6, 1); + $expectedAfter2 = array(1, -9, 7); + $this->spec(forwardDiff($diffInput, 1))->shouldEqual($expectedAfter1); + $this->spec(forwardDiff($diffInput, 2))->shouldEqual($expectedAfter2); + } + + function _should_return_array_unaltered_if_no_times() { + $this->spec(forwardDiff($expected = array(1,2,3), 0))->shouldEqual($expected); + } + +} diff --git a/Task/Forward-difference/Perl/forward-difference.pl b/Task/Forward-difference/Perl/forward-difference.pl new file mode 100644 index 0000000000..48447b68f0 --- /dev/null +++ b/Task/Forward-difference/Perl/forward-difference.pl @@ -0,0 +1,10 @@ +sub dif { + my @s = @_; + map { $s[$_+1] - $s[$_] } 0 .. $#s-1 +} + +sub difn { + my ($n, @s) = @_; + @s = dif @s foreach 1..$n; + @s +} diff --git a/Task/Forward-difference/PicoLisp/forward-difference.l b/Task/Forward-difference/PicoLisp/forward-difference.l new file mode 100644 index 0000000000..10f495a64c --- /dev/null +++ b/Task/Forward-difference/PicoLisp/forward-difference.l @@ -0,0 +1,5 @@ +(de fdiff (Lst) + (mapcar - (cdr Lst) Lst) ) + +(for (L (90 47 58 29 22 32 55 5 55 73) L (fdiff L)) + (println L) ) diff --git a/Task/Forward-difference/Python/forward-difference.py b/Task/Forward-difference/Python/forward-difference.py new file mode 100644 index 0000000000..d62fa2f8b3 --- /dev/null +++ b/Task/Forward-difference/Python/forward-difference.py @@ -0,0 +1,24 @@ +>>> dif = lambda s: [x-s[i] for i,x in enumerate(s[1:])] +>>> # or, dif = lambda s: [x-y for x,y in zip(s[1:],s)] +>>> difn = lambda s, n: difn(dif(s), n-1) if n else s + +>>> s = [90, 47, 58, 29, 22, 32, 55, 5, 55, 73] +>>> difn(s, 0) +[90, 47, 58, 29, 22, 32, 55, 5, 55, 73] +>>> difn(s, 1) +[-43, 11, -29, -7, 10, 23, -50, 50, 18] +>>> difn(s, 2) +[54, -40, 22, 17, 13, -73, 100, -32] + +>>> from pprint import pprint +>>> pprint( [difn(s, i) for i in xrange(10)] ) +[[90, 47, 58, 29, 22, 32, 55, 5, 55, 73], + [-43, 11, -29, -7, 10, 23, -50, 50, 18], + [54, -40, 22, 17, 13, -73, 100, -32], + [-94, 62, -5, -4, -86, 173, -132], + [156, -67, 1, -82, 259, -305], + [-223, 68, -83, 341, -564], + [291, -151, 424, -905], + [-442, 575, -1329], + [1017, -1904], + [-2921]] diff --git a/Task/Forward-difference/R/forward-difference.r b/Task/Forward-difference/R/forward-difference.r new file mode 100644 index 0000000000..fbba5ca935 --- /dev/null +++ b/Task/Forward-difference/R/forward-difference.r @@ -0,0 +1,21 @@ +forwarddif <- function(a, n) { + if ( n == 1 ) + a[2:length(a)] - a[1:length(a)-1] + else { + r <- forwarddif(a, 1) + forwarddif(r, n-1) + } +} + +fdiff <- function(a, n) { + r <- a + for(i in 1:n) { + r <- r[2:length(r)] - r[1:length(r)-1] + } + r +} + +v <- c(90, 47, 58, 29, 22, 32, 55, 5, 55, 73) + +print(forwarddif(v, 9)) +print(fdiff(v, 9)) diff --git a/Task/Forward-difference/REXX/forward-difference-1.rexx b/Task/Forward-difference/REXX/forward-difference-1.rexx new file mode 100644 index 0000000000..b421308627 --- /dev/null +++ b/Task/Forward-difference/REXX/forward-difference-1.rexx @@ -0,0 +1,44 @@ +/*REXX program to compute the forward difference of a list of numbers.*/ +/* ┌───────────────────────────────────────────────────────────────────┐ + │ /\ n n n-k │ + │ {delta} / \ n [ƒ] (x) ≡ Σ Ç ∙ (-1) ∙ ƒ(x+k) │ + │ /____\ k=0 k │ + │ │ + │ {n=order} {Ç=comb or binomial coeff.} │ + └───────────────────────────────────────────────────────────────────┘*/ +numeric digits 100 /*ensure enough accuracy. */ +arg numbers ',' ord /*input: x1 x2 x3 x4 ... ,ORD */ +if numbers=='' then numbers='90 47 58 29 22 32 55 5 55 73' /*default?*/ +w=words(numbers) /*set W to # of numbers in list.*/ + + do i=1 for w /*validate input (valid numbers?)*/ + @.i=word(numbers,i) /*assign the next # in the list. */ + if \datatype(@.i,'N') then call ser @.i "isn't a valid number" + @.i=@.i/1 /*normalize the #, prettify the #*/ + end /*i*/ +/*═════════════════════════════════════════process the (optional) input.*/ +if w==0 then call ser 'no numbers were specified' +if ord\=='' & ord<0 then call ser ord "(ner) can't be negative" +if ord\=='' & ord>w then call ser ord "(ner) can't be greater than" w +say right(w 'numbers: ' numbers,64) /*sloppy way to do a header, ... */ +say right(copies('─',length(numbers)),64) /* and the header fence.*/ +if ord=='' then do; bot=0; top=w; end /*define default ners.*/ + else do; bot=n; top=n; end /*just a specific ner?*/ +/*═════════════════════════════════════════where da rubber meets da road*/ + do order=bot to top; do r=1 for w; !.r=@.r; end; $= + do j=1 for order; d=!.j; do k=j+1 to w /*order diff.*/ + parse value !.k !.k-d with d !.k + end /*k*/ + end /*j*/ + do i=order+1 to w /*build list.*/ + $=$ !.i/1 /*append it. */ + end /*i*/ + if $=='' then $='[null]' /*pretty null*/ + what=right(order,length(w))th(order)'-order' /*nice format*/ + say what 'forward difference vector = ' strip($) /*display it.*/ + end /*o*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SER subroutine──────────────────────*/ +ser: say; say '*** error! ***'; say arg(1); say; exit 13 +/*──────────────────────────────────TH subroutine───────────────────────*/ +th: parse arg ?; return word('th st nd rd',1+?//10*(?//100%10\==1)*(?//10<4)) diff --git a/Task/Forward-difference/REXX/forward-difference-2.rexx b/Task/Forward-difference/REXX/forward-difference-2.rexx new file mode 100644 index 0000000000..ea46c43523 --- /dev/null +++ b/Task/Forward-difference/REXX/forward-difference-2.rexx @@ -0,0 +1,35 @@ +/* REXX *************************************************************** +* Forward differences +* 18.08.2012 Walter Pachl derived from PL/I +**********************************************************************/ +Do n=-1 To 11 + Call differences '90 47 58 29 22 32 55 5 55 73',n + End +Exit + +differences: Procedure + Parse Arg a,n + m=words(a) + Select + When n<0 Then Say 'n is negative:' n '<' 0 + When n>m Then Say 'n is too large:' n '>' m + Otherwise Do + Do i=1 By 1 while a<>'' + Parse Var a a.i a + End + Do i = 1 to n; + t = a.i; + Do j = i+1 to m; + u = a.j + a.j = a.j-t; + t = u; + end; + end; + ol='' + Do k=n+1 to m + ol=ol a.k + End + Say n ol + End + End + Return diff --git a/Task/Forward-difference/Ruby/forward-difference-1.rb b/Task/Forward-difference/Ruby/forward-difference-1.rb new file mode 100644 index 0000000000..c65b3364f3 --- /dev/null +++ b/Task/Forward-difference/Ruby/forward-difference-1.rb @@ -0,0 +1,7 @@ +def dif(s) + s.each_cons(2).collect { |x, y| y - x } +end + +def difn(s, n) + n.times.inject(s) { |s, | dif(s) } +end diff --git a/Task/Forward-difference/Ruby/forward-difference-2.rb b/Task/Forward-difference/Ruby/forward-difference-2.rb new file mode 100644 index 0000000000..9adbef0b5b --- /dev/null +++ b/Task/Forward-difference/Ruby/forward-difference-2.rb @@ -0,0 +1,2 @@ +p dif([1, 23, 45, 678]) # => [22, 22, 633] +p difn([1, 23, 45, 678], 2) # => [0, 611] diff --git a/Task/Forward-difference/Scala/forward-difference-1.scala b/Task/Forward-difference/Scala/forward-difference-1.scala new file mode 100644 index 0000000000..8015e4964d --- /dev/null +++ b/Task/Forward-difference/Scala/forward-difference-1.scala @@ -0,0 +1,3 @@ +def fdiff(xs: List[Int]) = (xs.tail, xs).zipped.map(_ - _) + +def fdiffn(i: Int, xs: List[Int]): List[Int] = if (i == 1) fdiff(xs) else fdiffn(i - 1, fdiff(xs)) diff --git a/Task/Forward-difference/Scala/forward-difference-2.scala b/Task/Forward-difference/Scala/forward-difference-2.scala new file mode 100644 index 0000000000..3f2ddbbfac --- /dev/null +++ b/Task/Forward-difference/Scala/forward-difference-2.scala @@ -0,0 +1,2 @@ +val l=List(90,47,58,29,22,32,55,5,55,73) +(1 to 9)foreach(x=>println(fdiffn(x,l))) diff --git a/Task/Forward-difference/Scheme/forward-difference.ss b/Task/Forward-difference/Scheme/forward-difference.ss new file mode 100644 index 0000000000..39c0497825 --- /dev/null +++ b/Task/Forward-difference/Scheme/forward-difference.ss @@ -0,0 +1,11 @@ +(define (forward-diff lst) + (if (or (null? lst) (null? (cdr lst))) + '() + (cons (- (cadr lst) (car lst)) + (forward-diff (cdr lst))))) + +(define (nth-forward-diff n xs) + (if (= n 0) + xs + (nth-forward-diff (- n 1) + (forward-diff xs)))) diff --git a/Task/Forward-difference/Smalltalk/forward-difference.st b/Task/Forward-difference/Smalltalk/forward-difference.st new file mode 100644 index 0000000000..2eb78c6342 --- /dev/null +++ b/Task/Forward-difference/Smalltalk/forward-difference.st @@ -0,0 +1,13 @@ +Array extend [ + difference [ + ^self allButFirst with: self allButLast collect: [ :a :b | a - b ] + ] + + nthOrderDifference: n [ + ^(1 to: n) inject: self into: [ :old :unused | old difference ] + ] +] + +s := #(90 47 58 29 22 32 55 5 55 73) +1 to: s size - 1 do: [ :i | + (s nthOrderDifference: i) printNl ] diff --git a/Task/Forward-difference/Tcl/forward-difference.tcl b/Task/Forward-difference/Tcl/forward-difference.tcl new file mode 100644 index 0000000000..0cea04d2a0 --- /dev/null +++ b/Task/Forward-difference/Tcl/forward-difference.tcl @@ -0,0 +1,23 @@ +proc do_fwd_diff {list} { + set previous [lindex $list 0] + set new [list] + foreach current [lrange $list 1 end] { + lappend new [expr {$current - $previous}] + set previous $current + } + return $new +} + +proc fwd_diff {list order} { + while {$order >= 1} { + set list [do_fwd_diff $list] + incr order -1 + } + return $list +} + +set a {90.5 47 58 29 22 32 55 5 55 73.5} + +for {set order 0} {$order <= 10} {incr order} { + puts [format "%d\t%s" $order [fwd_diff $a $order]] +} diff --git a/Task/Four-bit-adder/0DESCRIPTION b/Task/Four-bit-adder/0DESCRIPTION new file mode 100644 index 0000000000..004f380d65 --- /dev/null +++ b/Task/Four-bit-adder/0DESCRIPTION @@ -0,0 +1,23 @@ +The aim of this task is to "''simulate''" a four-bit adder "chip". This "chip" can be realized using four [[wp:Adder_(electronics)#Full_adder|1-bit full adder]]s. Each of these 1-bit full adders can be with two [[wp:Adder_(electronics)#Half_adder|half adder]]s and an ''or'' [[wp:Logic gate|gate]]. Finally a half adder can be made using a ''xor'' gate and an ''and'' gate. The ''xor'' gate can be made using two ''not''s, two ''and''s and one ''or''. + +'''Not''', '''or''' and '''and''', the only allowed "gates" for the task, can be "imitated" by using the [[Bitwise operations|bitwise operators]] of your language. If there is not a ''bit type'' in your language, to be sure that the ''not'' does not "invert" all the other bits of the basic type (e.g. a byte) we are not interested in, you can use an extra ''nand'' (''and'' then ''not'') with the constant 1 on one input. + +Instead of optimizing and reducing the number of gates used for the final 4-bit adder, build it in the most straightforward way, ''connecting'' the other "constructive blocks", in turn made of "simpler" and "smaller" ones. + +{| +|+Schematics of the "constructive blocks" +!Xor gate done with ands, ors and nots +!A half adder +!A full adder +!A 4-bit adder +|- +|[[File:xor.png|frameless|Xor gate done with ands, ors and nots]] +|[[File:halfadder.png|frameless|A half adder]] +|[[File:fulladder.png|frameless|A full adder]] +|[[File:4bitsadder.png|frameless|A 4-bit adder]] +|} + +Solutions should try to be as descriptive as possible, making it as easy as possible to identify "connections" between higher-order "blocks". It is not mandatory to replicate the syntax of higher-order blocks in the atomic "gate" blocks, i.e. basic "gate" operations can be performed as usual bitwise operations, or they can be "wrapped" in a ''block'' in order to expose the same syntax of higher-order blocks, at implementers' choice. + +To test the implementation, show the sum of two four-bit numbers (in binary). +
diff --git a/Task/Four-bit-adder/1META.yaml b/Task/Four-bit-adder/1META.yaml new file mode 100644 index 0000000000..f78a27fcb1 --- /dev/null +++ b/Task/Four-bit-adder/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Electronics diff --git a/Task/Four-bit-adder/Ada/four-bit-adder-1.ada b/Task/Four-bit-adder/Ada/four-bit-adder-1.ada new file mode 100644 index 0000000000..5130d77f0d --- /dev/null +++ b/Task/Four-bit-adder/Ada/four-bit-adder-1.ada @@ -0,0 +1,23 @@ +type Four_Bits is array (1..4) of Boolean; + +procedure Half_Adder (Input_1, Input_2 : Boolean; Output, Carry : out Boolean) is +begin + Output := Input_1 xor Input_2; + Carry := Input_1 and Input_2; +end Half_Adder; + +procedure Full_Adder (Input_1, Input_2 : Boolean; Output : out Boolean; Carry : in out Boolean) is + T_1, T_2, T_3 : Boolean; +begin + Half_Adder (Input_1, Input_2, T_1, T_2); + Half_Adder (Carry, T_1, Output, T_3); + Carry := T_2 or T_3; +end Full_Adder; + +procedure Four_Bits_Adder (A, B : Four_Bits; C : out Four_Bits; Carry : in out Boolean) is +begin + Full_Adder (A (4), B (4), C (4), Carry); + Full_Adder (A (3), B (3), C (3), Carry); + Full_Adder (A (2), B (2), C (2), Carry); + Full_Adder (A (1), B (1), C (1), Carry); +end Four_Bits_Adder; diff --git a/Task/Four-bit-adder/Ada/four-bit-adder-2.ada b/Task/Four-bit-adder/Ada/four-bit-adder-2.ada new file mode 100644 index 0000000000..cf3dba5841 --- /dev/null +++ b/Task/Four-bit-adder/Ada/four-bit-adder-2.ada @@ -0,0 +1,52 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_4_Bit_Adder is + + -- The definitions from above + + function Image (Bit : Boolean) return Character is + begin + if Bit then + return '1'; + else + return '0'; + end if; + end Image; + + function Image (X : Four_Bits) return String is + begin + return Image (X (1)) & Image (X (2)) & Image (X (3)) & Image (X (4)); + end Image; + + A, B, C : Four_Bits; Carry : Boolean; +begin + for I_1 in Boolean'Range loop + for I_2 in Boolean'Range loop + for I_3 in Boolean'Range loop + for I_4 in Boolean'Range loop + for J_1 in Boolean'Range loop + for J_2 in Boolean'Range loop + for J_3 in Boolean'Range loop + for J_4 in Boolean'Range loop + A := (I_1, I_2, I_3, I_4); + B := (J_1, J_2, J_3, J_4); + Carry := False; + Four_Bits_Adder (A, B, C, Carry); + Put_Line + ( Image (A) + & " + " + & Image (B) + & " = " + & Image (C) + & " " + & Image (Carry) + ); + end loop; + end loop; + end loop; + end loop; + end loop; + end loop; + end loop; + end loop; +end Test_4_Bit_Adder; diff --git a/Task/Four-bit-adder/BBC-BASIC/four-bit-adder.bbc b/Task/Four-bit-adder/BBC-BASIC/four-bit-adder.bbc new file mode 100644 index 0000000000..7f8e70a40f --- /dev/null +++ b/Task/Four-bit-adder/BBC-BASIC/four-bit-adder.bbc @@ -0,0 +1,45 @@ + @% = 2 + PRINT "1100 + 1100 = "; + PROC4bitadd(1,1,0,0, 1,1,0,0, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1100 + 1101 = "; + PROC4bitadd(1,1,0,0, 1,1,0,1, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1100 + 1110 = "; + PROC4bitadd(1,1,0,0, 1,1,1,0, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1100 + 1111 = "; + PROC4bitadd(1,1,0,0, 1,1,1,1, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1101 + 0000 = "; + PROC4bitadd(1,1,0,1, 0,0,0,0, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1101 + 0001 = "; + PROC4bitadd(1,1,0,1, 0,0,0,1, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1101 + 0010 = "; + PROC4bitadd(1,1,0,1, 0,0,1,0, e,d,c,b,a) : PRINT e,d,c,b,a + PRINT "1101 + 0011 = "; + PROC4bitadd(1,1,0,1, 0,0,1,1, e,d,c,b,a) : PRINT e,d,c,b,a + END + + DEF PROC4bitadd(a3&, a2&, a1&, a0&, b3&, b2&, b1&, b0&, \ + \ RETURN c3&, RETURN s3&, RETURN s2&, RETURN s1&, RETURN s0&) + LOCAL c0&, c1&, c2& + PROCfulladder(a0&, b0&, 0, s0&, c0&) + PROCfulladder(a1&, b1&, c0&, s1&, c1&) + PROCfulladder(a2&, b2&, c1&, s2&, c2&) + PROCfulladder(a3&, b3&, c2&, s3&, c3&) + ENDPROC + + DEF PROCfulladder(a&, b&, c&, RETURN s&, RETURN c1&) + LOCAL x&, y&, z& + PROChalfadder(a&, c&, x&, y&) + PROChalfadder(x&, b&, s&, z&) + c1& = y& OR z& + ENDPROC + + DEF PROChalfadder(a&, b&, RETURN s&, RETURN c&) + s& = FNxorgate(a&, b&) + c& = a& AND b& + ENDPROC + + DEF FNxorgate(a&, b&) + LOCAL c&, d& + c& = a& AND NOT b& + d& = b& AND NOT a& + = c& OR d& diff --git a/Task/Four-bit-adder/C/four-bit-adder.c b/Task/Four-bit-adder/C/four-bit-adder.c new file mode 100644 index 0000000000..9ac6b2205d --- /dev/null +++ b/Task/Four-bit-adder/C/four-bit-adder.c @@ -0,0 +1,70 @@ +#include + +typedef char pin_t; +#define IN const pin_t * +#define OUT pin_t * +#define PIN(X) pin_t _##X; pin_t *X = & _##X; +#define V(X) (*(X)) + +/* a NOT that does not soil the rest of the host of the single bit */ +#define NOT(X) (~(X)&1) + +/* a shortcut to "implement" a XOR using only NOT, AND and OR gates, as + task requirements constrain */ +#define XOR(X,Y) ((NOT(X)&(Y)) | ((X)&NOT(Y))) + +void halfadder(IN a, IN b, OUT s, OUT c) +{ + V(s) = XOR(V(a), V(b)); + V(c) = V(a) & V(b); +} + +void fulladder(IN a, IN b, IN ic, OUT s, OUT oc) +{ + PIN(ps); PIN(pc); PIN(tc); + + halfadder(/*INPUT*/a, b, /*OUTPUT*/ps, pc); + halfadder(/*INPUT*/ps, ic, /*OUTPUT*/s, tc); + V(oc) = V(tc) | V(pc); +} + +void fourbitsadder(IN a0, IN a1, IN a2, IN a3, + IN b0, IN b1, IN b2, IN b3, + OUT o0, OUT o1, OUT o2, OUT o3, + OUT overflow) +{ + PIN(zero); V(zero) = 0; + PIN(tc0); PIN(tc1); PIN(tc2); + + fulladder(/*INPUT*/a0, b0, zero, /*OUTPUT*/o0, tc0); + fulladder(/*INPUT*/a1, b1, tc0, /*OUTPUT*/o1, tc1); + fulladder(/*INPUT*/a2, b2, tc1, /*OUTPUT*/o2, tc2); + fulladder(/*INPUT*/a3, b3, tc2, /*OUTPUT*/o3, overflow); +} + + +int main() +{ + PIN(a0); PIN(a1); PIN(a2); PIN(a3); + PIN(b0); PIN(b1); PIN(b2); PIN(b3); + PIN(s0); PIN(s1); PIN(s2); PIN(s3); + PIN(overflow); + + V(a3) = 0; V(b3) = 1; + V(a2) = 0; V(b2) = 1; + V(a1) = 1; V(b1) = 1; + V(a0) = 0; V(b0) = 0; + + fourbitsadder(a0, a1, a2, a3, /* INPUT */ + b0, b1, b2, b3, + s0, s1, s2, s3, /* OUTPUT */ + overflow); + + printf("%d%d%d%d + %d%d%d%d = %d%d%d%d, overflow = %d\n", + V(a3), V(a2), V(a1), V(a0), + V(b3), V(b2), V(b1), V(b0), + V(s3), V(s2), V(s1), V(s0), + V(overflow)); + + return 0; +} diff --git a/Task/Four-bit-adder/Clojure/four-bit-adder-1.clj b/Task/Four-bit-adder/Clojure/four-bit-adder-1.clj new file mode 100644 index 0000000000..b13da6dfd5 --- /dev/null +++ b/Task/Four-bit-adder/Clojure/four-bit-adder-1.clj @@ -0,0 +1,34 @@ +(ns rosettacode.adder + (:use clojure.test)) + +(defn xor-gate [a b] + (or (and a (not b)) (and b (not a)))) + +(defn half-adder [a b] + "output: (S C)" + (cons (xor-gate a b) (list (and a b)))) + +(defn full-adder [a b c] + "output: (C S)" + (let [HA-ca (half-adder c a) + HA-ca->sb (half-adder (first HA-ca) b)] + (cons (or (second HA-ca) (second HA-ca->sb)) + (list (first HA-ca->sb))))) + +(defn n-bit-adder + "first bits on the list are low order bits +1 = true +2 = false true +3 = true true +4 = false false true..." + can add numbers of different bit-length + ([a-bits b-bits] (n-bit-adder a-bits b-bits false)) + ([a-bits b-bits carry] + (let [added (full-adder (first a-bits) (first b-bits) carry)] + (if(and (nil? a-bits) (nil? b-bits)) + (if carry (list carry) '()) + (cons (second added) (n-bit-adder (next a-bits) (next b-bits) (first added))))))) + +;use: +(n-bit-adder [true true true true true true] [true true true true true true]) +=> (false true true true true true true) diff --git a/Task/Four-bit-adder/Clojure/four-bit-adder-2.clj b/Task/Four-bit-adder/Clojure/four-bit-adder-2.clj new file mode 100644 index 0000000000..50ba978fa4 --- /dev/null +++ b/Task/Four-bit-adder/Clojure/four-bit-adder-2.clj @@ -0,0 +1,51 @@ +(ns rosetta.fourbit) + +;; a bit is represented as a boolean (true/false) +;; a word is a big-endian vector of bits [true false true true] = 11 +;; multiple values are returned as vectors + +(defn or-gate [a b] + (or a b)) + +(defn and-gate [a b] + (and a b)) + +(defn not-gate [a] + (not a)) + +(defn xor-gate [a b] + (or-gate (and-gate (not-gate a) b) (and-gate a (not-gate b)))) + +(defn half-adder [a b] + "result is [carry sum]" + (let [carry (and-gate a b) + sum (xor-gate a b)] + [carry sum])) + +(defn full-adder [a b c0] + "result is [carry sum]" + (let [[ca sa] (half-adder c0 a) + [cb sb] (half-adder sa b)] + [(or-gate ca cb) sb])) + +(defn nbit-adder [va vb] + "va and vb should be big endian bit vectors of the same size. The result +is a bit vector having one more bit (carry) than args." + {:pre [(= (count va) (count vb))]} + (let [[c sums] (reduce (fn [[carry sums] [a b]] + (let [[c s] (full-adder a b carry)] + [c (conj sums s)])) + ;; initial value: false carry and an empty list of sums + [false ()] + ;; rseq is constant-time reverse for vectors + (map vector (rseq va) (rseq vb)))] + (vec (conj sums c)))) + +(defn four-bit-adder [a4 a3 a2 a1 b4 b3 b2 b1] + "Returns [carry s4 s3 s2 s1]" + (nbit-adder [a4 a3 a2 a1] [b4 b3 b2 b1])) + +(comment +(four-bit-adder false true true false true false true true) +;; [true false false false true] +) diff --git a/Task/Four-bit-adder/CoffeeScript/four-bit-adder.coffee b/Task/Four-bit-adder/CoffeeScript/four-bit-adder.coffee new file mode 100644 index 0000000000..3da34d7516 --- /dev/null +++ b/Task/Four-bit-adder/CoffeeScript/four-bit-adder.coffee @@ -0,0 +1,39 @@ +# ATOMIC GATES +not_gate = (bit) -> + [1, 0][bit] + +and_gate = (bit1, bit2) -> + bit1 and bit2 + +or_gate = (bit1, bit2) -> + bit1 or bit2 + +# COMPOSED GATES +xor_gate = (A, B) -> + X = and_gate A, not_gate(B) + Y = and_gate not_gate(A), B + or_gate X, Y + +half_adder = (A, B) -> + S = xor_gate A, B + C = and_gate A, B + [S, C] + +full_adder = (C0, A, B) -> + [SA, CA] = half_adder C0, A + [SB, CB] = half_adder SA, B + S = SB + C = or_gate CA, CB + [S, C] + +n_bit_adder = (n) -> + (A_bits, B_bits) -> + s = [] + C = 0 + for i in [0...n] + [S, C] = full_adder C, A_bits[i], B_bits[i] + s.push S + [s, C] + +adder = n_bit_adder(4) +console.log adder [1, 0, 1, 0], [0, 1, 1, 0] diff --git a/Task/Four-bit-adder/D/four-bit-adder.d b/Task/Four-bit-adder/D/four-bit-adder.d new file mode 100644 index 0000000000..65dfb09955 --- /dev/null +++ b/Task/Four-bit-adder/D/four-bit-adder.d @@ -0,0 +1,67 @@ +import std.stdio, std.traits; + +void fourBitsAdder(T)(in T a0, in T a1, in T a2, in T a3, + in T b0, in T b1, in T b2, in T b3, + out T o0, out T o1, + out T o2, out T o3, + out T overflow) pure nothrow { + + // A XOR using only NOT, AND and OR, as task requires + static T xor(in T x, in T y) pure nothrow { + return (~x & y) | (x & ~y); + } + + static void halfAdder(in T a, in T b, + out T s, out T c) pure nothrow { + s = xor(a, b); + // s = a ^ b; // a natural XOR in D + c = a & b; + } + + static void fullAdder(in T a, in T b, in T ic, + out T s, out T oc) pure nothrow { + T ps, pc, tc; + + halfAdder(/*input*/a, b, /*output*/ps, pc); + halfAdder(/*input*/ps, ic, /*output*/s, tc); + oc = tc | pc; + } + + T zero, tc0, tc1, tc2; + + fullAdder(/*input*/a0, b0, zero, /*output*/o0, tc0); + fullAdder(/*input*/a1, b1, tc0, /*output*/o1, tc1); + fullAdder(/*input*/a2, b2, tc1, /*output*/o2, tc2); + fullAdder(/*input*/a3, b3, tc2, /*output*/o3, overflow); +} + +void main() { + alias size_t T; + static assert(isUnsigned!T); + + enum T one = T.max, + zero = T.min, + a0 = zero, a1 = one, a2 = zero, a3 = zero, + b0 = zero, b1 = one, b2 = one, b3 = one; + T s0, s1, s2, s3, overflow; + + fourBitsAdder(/*input*/ a0, a1, a2, a3, + /*input*/ b0, b1, b2, b3, + /*output*/s0, s1, s2, s3, overflow); + + writefln(" a3 %032b", a3); + writefln(" a2 %032b", a2); + writefln(" a1 %032b", a1); + writefln(" a0 %032b", a0); + writefln(" +"); + writefln(" b3 %032b", b3); + writefln(" b2 %032b", b2); + writefln(" b1 %032b", b1); + writefln(" b0 %032b", b0); + writefln(" ="); + writefln(" s3 %032b", s3); + writefln(" s2 %032b", s2); + writefln(" s1 %032b", s1); + writefln(" s0 %032b", s0); + writefln("overflow %032b", overflow); +} diff --git a/Task/Four-bit-adder/Fortran/four-bit-adder.f b/Task/Four-bit-adder/Fortran/four-bit-adder.f new file mode 100644 index 0000000000..b8c31bfdc1 --- /dev/null +++ b/Task/Four-bit-adder/Fortran/four-bit-adder.f @@ -0,0 +1,77 @@ +module logic + implicit none + +contains + +function xor(a, b) + logical :: xor + logical, intent(in) :: a, b + + xor = (a .and. .not. b) .or. (b .and. .not. a) +end function xor + +function halfadder(a, b, c) + logical :: halfadder + logical, intent(in) :: a, b + logical, intent(out) :: c + + halfadder = xor(a, b) + c = a .and. b +end function halfadder + +function fulladder(a, b, c0, c1) + logical :: fulladder + logical, intent(in) :: a, b, c0 + logical, intent(out) :: c1 + logical :: c2, c3 + + fulladder = halfadder(halfadder(c0, a, c2), b, c3) + c1 = c2 .or. c3 +end function fulladder + +subroutine fourbitadder(a, b, s) + logical, intent(in) :: a(0:3), b(0:3) + logical, intent(out) :: s(0:4) + logical :: c0, c1, c2 + + s(0) = fulladder(a(0), b(0), .false., c0) + s(1) = fulladder(a(1), b(1), c0, c1) + s(2) = fulladder(a(2), b(2), c1, c2) + s(3) = fulladder(a(3), b(3), c2, s(4)) +end subroutine fourbitadder +end module + +program Four_bit_adder + use logic + implicit none + + logical, dimension(0:3) :: a, b + logical, dimension(0:4) :: s + integer, dimension(0:3) :: ai, bi + integer, dimension(0:4) :: si + integer :: i, j + + do i = 0, 15 + a(0) = btest(i, 0); a(1) = btest(i, 1); a(2) = btest(i, 2); a(3) = btest(i, 3) + where(a) + ai = 1 + else where + ai = 0 + end where + do j = 0, 15 + b(0) = btest(j, 0); b(1) = btest(j, 1); b(2) = btest(j, 2); b(3) = btest(j, 3) + where(b) + bi = 1 + else where + bi = 0 + end where + call fourbitadder(a, b, s) + where (s) + si = 1 + elsewhere + si = 0 + end where + write(*, "(4i1,a,4i1,a,5i1)") ai(3:0:-1), " + ", bi(3:0:-1), " = ", si(4:0:-1) + end do + end do +end program diff --git a/Task/Four-bit-adder/Go/four-bit-adder-1.go b/Task/Four-bit-adder/Go/four-bit-adder-1.go new file mode 100644 index 0000000000..cd1395ca0e --- /dev/null +++ b/Task/Four-bit-adder/Go/four-bit-adder-1.go @@ -0,0 +1,31 @@ +package main + +import "fmt" + +func xor(a, b byte) byte { + return a&(^b) | b&(^a) +} + +func ha(a, b byte) (s, c byte) { + return xor(a, b), a & b +} + +func fa(a, b, c0 byte) (s, c1 byte) { + sa, ca := ha(a, c0) + s, cb := ha(sa, b) + c1 = ca | cb + return +} + +func add4(a3, a2, a1, a0, b3, b2, b1, b0 byte) (v, s3, s2, s1, s0 byte) { + s0, c0 := fa(a0, b0, 0) + s1, c1 := fa(a1, b1, c0) + s2, c2 := fa(a2, b2, c1) + s3, v = fa(a3, b3, c2) + return +} + +func main() { + // add 10+9 result should be 1 0 0 1 1 + fmt.Println(add4(1, 0, 1, 0, 1, 0, 0, 1)) +} diff --git a/Task/Four-bit-adder/Go/four-bit-adder-2.go b/Task/Four-bit-adder/Go/four-bit-adder-2.go new file mode 100644 index 0000000000..e92a378b23 --- /dev/null +++ b/Task/Four-bit-adder/Go/four-bit-adder-2.go @@ -0,0 +1,129 @@ +package main + +import "fmt" + +// A wire is modeled as a channel of booleans. +// You can feed it a single value without blocking. +// Reading a value blocks until a value is available. +type Wire chan bool +func MakeWire() Wire { + return make(Wire,1) +} + +// A source for zero values. +func Zero() Wire { + r := MakeWire() + go func() { + for { + r <- false + } + }() + return r +} + +// And gate. +func And(a,b Wire) Wire { + r := MakeWire() + go func() { + for { + x := <-a + y := <-b + r <- (x && y) + } + }() + return r +} + +// Or gate. +func Or(a,b Wire) Wire { + r := MakeWire() + go func() { + for { + x := <-a + y := <-b + r <- (x || y) + } + }() + return r +} + +// Not gate. +func Not(a Wire) Wire { + r := MakeWire() + go func() { + for { + x := <-a + r <- !x + } + }() + return r +} + +// Split a wire in two. +func Split(a Wire) (Wire,Wire) { + r1 := MakeWire() + r2 := MakeWire() + go func() { + for { + x := <-a + r1 <- x + r2 <- x + } + }() + return r1, r2 +} + +// Xor gate, composed of Or, And and Not gates. +func Xor(a,b Wire) Wire { + a1,a2 := Split(a) + b1,b2 := Split(b) + return Or(And(Not(a1),b1),And(a2,Not(b2))) +} + +// A half adder, composed of two splits and an And and Xor gate. +func HalfAdder(a,b Wire) (sum,carry Wire) { + a1,a2 := Split(a) + b1,b2 := Split(b) + carry = And(a1,b1) + sum = Xor(a2,b2) + return +} + +// A full adder, composed of two half adders, and an Or gate. +func FullAdder(a,b,carryIn Wire) (result,carryOut Wire) { + s1,c1 := HalfAdder(carryIn,a) + result,c2 := HalfAdder(b,s1) + carryOut = Or(c1,c2) + return +} + +// A four bit adder, composed of a zero source, and four full adders. +func FourBitAdder(a1,a2,a3,a4 Wire, b1,b2,b3,b4 Wire) (r1,r2,r3,r4 Wire, carry Wire) { + carry = Zero() + r1,carry = FullAdder(a1,b1,carry) + r2,carry = FullAdder(a2,b2,carry) + r3,carry = FullAdder(a3,b3,carry) + r4,carry = FullAdder(a4,b4,carry) + return +} + +func main() { + // Create wires + a1 := MakeWire() + a2 := MakeWire() + a3 := MakeWire() + a4 := MakeWire() + b1 := MakeWire() + b2 := MakeWire() + b3 := MakeWire() + b4 := MakeWire() + // Construct circuit + r1,r2,r3,r4, carry := FourBitAdder(a1,a2,a3,a4, b1,b2,b3,b4) + // Feed it some values + a4 <- false; a3 <- false; a2 <- true; a1 <- false // 0010 + b4 <- true; b3 <- true; b2 <- true; b1 <- false // 1110 + B := map[bool]int { false: 0, true: 1 } + // Read the result + fmt.Printf("0010 + 1110 = %d%d%d%d (carry = %d)\n", + B[<-r4],B[<-r3],B[<-r2],B[<-r1], B[<-carry]) +} diff --git a/Task/Four-bit-adder/Haskell/four-bit-adder-1.hs b/Task/Four-bit-adder/Haskell/four-bit-adder-1.hs new file mode 100644 index 0000000000..d6871e39e7 --- /dev/null +++ b/Task/Four-bit-adder/Haskell/four-bit-adder-1.hs @@ -0,0 +1,7 @@ +import Control.Arrow + +bor, band :: Int -> Int -> Int +bor = max +band = min +bnot :: Int -> Int +bnot = (1-) diff --git a/Task/Four-bit-adder/Haskell/four-bit-adder-2.hs b/Task/Four-bit-adder/Haskell/four-bit-adder-2.hs new file mode 100644 index 0000000000..79fb0b6749 --- /dev/null +++ b/Task/Four-bit-adder/Haskell/four-bit-adder-2.hs @@ -0,0 +1,3 @@ +nand, xor :: Int -> Int -> Int +nand = (bnot.).band +xor a b = uncurry nand. (nand a &&& nand b) $ nand a b diff --git a/Task/Four-bit-adder/Haskell/four-bit-adder-3.hs b/Task/Four-bit-adder/Haskell/four-bit-adder-3.hs new file mode 100644 index 0000000000..3017d9a643 --- /dev/null +++ b/Task/Four-bit-adder/Haskell/four-bit-adder-3.hs @@ -0,0 +1,4 @@ +halfAdder = uncurry band &&& uncurry xor +fullAdder (c, a, b) = (\(cy,s) -> first (bor cy) $ halfAdder (b, s)) $ halfAdder (c, a) + +adder4 as = foldr (\(f,a,b) (cy,bs) -> second(:bs) $ f (cy,a,b)) (0,[]). zip3 (replicate 4 fullAdder) as diff --git a/Task/Four-bit-adder/Haskell/four-bit-adder-4.hs b/Task/Four-bit-adder/Haskell/four-bit-adder-4.hs new file mode 100644 index 0000000000..bdfc0be5fb --- /dev/null +++ b/Task/Four-bit-adder/Haskell/four-bit-adder-4.hs @@ -0,0 +1,2 @@ +*Main> adder4 [1,0,1,0] [1,1,1,1] +(1,[1,0,0,1]) diff --git a/Task/Four-bit-adder/J/four-bit-adder-1.j b/Task/Four-bit-adder/J/four-bit-adder-1.j new file mode 100644 index 0000000000..71bcba8752 --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-1.j @@ -0,0 +1,6 @@ +and=: *. +or=: +. +not=: -. +xor=: (and not) or (and not)~ +hadd=: and ,"0 xor +add=: ((({.,0:)@[ or {:@[ hadd {.@]), }.@])/@hadd diff --git a/Task/Four-bit-adder/J/four-bit-adder-2.j b/Task/Four-bit-adder/J/four-bit-adder-2.j new file mode 100644 index 0000000000..3e43ce1695 --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-2.j @@ -0,0 +1,2 @@ + 1 1 1 1 add 0 1 1 1 +1 0 1 1 0 diff --git a/Task/Four-bit-adder/J/four-bit-adder-3.j b/Task/Four-bit-adder/J/four-bit-adder-3.j new file mode 100644 index 0000000000..ad42213751 --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-3.j @@ -0,0 +1 @@ + add"1/~#:i.16 diff --git a/Task/Four-bit-adder/J/four-bit-adder-4.j b/Task/Four-bit-adder/J/four-bit-adder-4.j new file mode 100644 index 0000000000..1257da390f --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-4.j @@ -0,0 +1,17 @@ + ,"2 ' ',"1 -.&' '@":"1 add"1/~#:i.16 + 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 + 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 + 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 + 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 + 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 + 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 + 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 + 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 + 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 + 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 + 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 + 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 + 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 + 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 + 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 + 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 diff --git a/Task/Four-bit-adder/J/four-bit-adder-5.j b/Task/Four-bit-adder/J/four-bit-adder-5.j new file mode 100644 index 0000000000..a3f4cabbae --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-5.j @@ -0,0 +1 @@ +add=: ((({.,0:)@[ or {:@[ hadd {.@]), }.@])/@hadd"1 diff --git a/Task/Four-bit-adder/J/four-bit-adder-6.j b/Task/Four-bit-adder/J/four-bit-adder-6.j new file mode 100644 index 0000000000..cfa60afe83 --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-6.j @@ -0,0 +1 @@ + add/~#:i.16 diff --git a/Task/Four-bit-adder/J/four-bit-adder-7.j b/Task/Four-bit-adder/J/four-bit-adder-7.j new file mode 100644 index 0000000000..33b1aa9381 --- /dev/null +++ b/Task/Four-bit-adder/J/four-bit-adder-7.j @@ -0,0 +1 @@ + +/~i.10 diff --git a/Task/Four-bit-adder/Java/four-bit-adder.java b/Task/Four-bit-adder/Java/four-bit-adder.java new file mode 100644 index 0000000000..c9de02cb42 --- /dev/null +++ b/Task/Four-bit-adder/Java/four-bit-adder.java @@ -0,0 +1,147 @@ +public class GateLogic +{ + // Basic gate interfaces + public interface OneInputGate + { boolean eval(boolean input); } + + public interface TwoInputGate + { boolean eval(boolean input1, boolean input2); } + + public interface MultiGate + { boolean[] eval(boolean... inputs); } + + // Create NOT + public static OneInputGate NOT = new OneInputGate() { + public boolean eval(boolean input) + { return !input; } + }; + + // Create AND + public static TwoInputGate AND = new TwoInputGate() { + public boolean eval(boolean input1, boolean input2) + { return input1 && input2; } + }; + + // Create OR + public static TwoInputGate OR = new TwoInputGate() { + public boolean eval(boolean input1, boolean input2) + { return input1 || input2; } + }; + + // Create XOR + public static TwoInputGate XOR = new TwoInputGate() { + public boolean eval(boolean input1, boolean input2) + { + return OR.eval( + AND.eval(input1, NOT.eval(input2)), + AND.eval(NOT.eval(input1), input2) + ); + } + }; + + // Create HALF_ADDER + public static MultiGate HALF_ADDER = new MultiGate() { + public boolean[] eval(boolean... inputs) + { + if (inputs.length != 2) + throw new IllegalArgumentException(); + return new boolean[] { + XOR.eval(inputs[0], inputs[1]), // Output bit + AND.eval(inputs[0], inputs[1]) // Carry bit + }; + } + }; + + // Create FULL_ADDER + public static MultiGate FULL_ADDER = new MultiGate() { + public boolean[] eval(boolean... inputs) + { + if (inputs.length != 3) + throw new IllegalArgumentException(); + // Inputs: CarryIn, A, B + // Outputs: S, CarryOut + boolean[] haOutputs1 = HALF_ADDER.eval(inputs[0], inputs[1]); + boolean[] haOutputs2 = HALF_ADDER.eval(haOutputs1[0], inputs[2]); + return new boolean[] { + haOutputs2[0], // Output bit + OR.eval(haOutputs1[1], haOutputs2[1]) // Carry bit + }; + } + }; + + public static MultiGate buildAdder(final int numBits) + { + return new MultiGate() { + public boolean[] eval(boolean... inputs) + { + // Inputs: A0, A1, A2..., B0, B1, B2... + if (inputs.length != (numBits << 1)) + throw new IllegalArgumentException(); + boolean[] outputs = new boolean[numBits + 1]; + boolean[] faInputs = new boolean[3]; + boolean[] faOutputs = null; + for (int i = 0; i < numBits; i++) + { + faInputs[0] = (faOutputs == null) ? false : faOutputs[1]; // CarryIn + faInputs[1] = inputs[i]; // Ai + faInputs[2] = inputs[numBits + i]; // Bi + faOutputs = FULL_ADDER.eval(faInputs); + outputs[i] = faOutputs[0]; // Si + } + if (faOutputs != null) + outputs[numBits] = faOutputs[1]; // CarryOut + return outputs; + } + }; + } + + public static void main(String[] args) + { + int numBits = Integer.parseInt(args[0]); + int firstNum = Integer.parseInt(args[1]); + int secondNum = Integer.parseInt(args[2]); + int maxNum = 1 << numBits; + if ((firstNum < 0) || (firstNum >= maxNum)) + { + System.out.println("First number is out of range"); + return; + } + if ((secondNum < 0) || (secondNum >= maxNum)) + { + System.out.println("Second number is out of range"); + return; + } + + MultiGate multiBitAdder = buildAdder(numBits); + // Convert input numbers into array of bits + boolean[] inputs = new boolean[numBits << 1]; + String firstNumDisplay = ""; + String secondNumDisplay = ""; + for (int i = 0; i < numBits; i++) + { + boolean firstBit = ((firstNum >>> i) & 1) == 1; + boolean secondBit = ((secondNum >>> i) & 1) == 1; + inputs[i] = firstBit; + inputs[numBits + i] = secondBit; + firstNumDisplay = (firstBit ? "1" : "0") + firstNumDisplay; + secondNumDisplay = (secondBit ? "1" : "0") + secondNumDisplay; + } + + boolean[] outputs = multiBitAdder.eval(inputs); + int outputNum = 0; + String outputNumDisplay = ""; + String outputCarryDisplay = null; + for (int i = numBits; i >= 0; i--) + { + outputNum = (outputNum << 1) | (outputs[i] ? 1 : 0); + if (i == numBits) + outputCarryDisplay = outputs[i] ? "1" : "0"; + else + outputNumDisplay += (outputs[i] ? "1" : "0"); + } + System.out.println("numBits=" + numBits); + System.out.println("A=" + firstNumDisplay + " (" + firstNum + "), B=" + secondNumDisplay + " (" + secondNum + "), S=" + outputCarryDisplay + " " + outputNumDisplay + " (" + outputNum + ")"); + return; + } + +} diff --git a/Task/Four-bit-adder/JavaScript/four-bit-adder-1.js b/Task/Four-bit-adder/JavaScript/four-bit-adder-1.js new file mode 100644 index 0000000000..45517c83b5 --- /dev/null +++ b/Task/Four-bit-adder/JavaScript/four-bit-adder-1.js @@ -0,0 +1,14 @@ +function acceptedBinFormat(bin) { + if (bin == 1 || bin === 0 || bin === '0') + return true; + else + return bin; +} + +function arePseudoBin() { + var args = [].slice.call(arguments), len = args.length; + while(len--) + if (acceptedBinFormat(args[len]) !== true) + throw new Error('argument must be 0, \'0\', 1, or \'1\', argument ' + len + ' was ' + args[len]); + return true; +} diff --git a/Task/Four-bit-adder/JavaScript/four-bit-adder-2.js b/Task/Four-bit-adder/JavaScript/four-bit-adder-2.js new file mode 100644 index 0000000000..4cc32fe3af --- /dev/null +++ b/Task/Four-bit-adder/JavaScript/four-bit-adder-2.js @@ -0,0 +1,72 @@ +// basic building blocks allowed by the rules are ~, &, and |, we'll fake these +// in a way that makes what they do (at least when you use them) more obvious +// than the other available options do. + +function not(a) { + if (arePseudoBin(a)) + return a == 1 ? 0 : 1; +} + +function and(a, b) { + if (arePseudoBin(a, b)) + return a + b < 2 ? 0 : 1; +} + +function nand(a, b) { + if (arePseudoBin(a, b)) + return not(and(a, b)); +} + +function or(a, b) { + if (arePseudoBin(a, b)) + return nand(nand(a,a), nand(b,b)); +} + +function xor(a, b) { + if (arePseudoBin(a, b)) + return nand(nand(nand(a,b), a), nand(nand(a,b), b)); +} + +function halfAdder(a, b) { + if (arePseudoBin(a, b)) + return { carry: and(a, b), sum: xor(a, b) }; +} + +function fullAdder(a, b, c) { + if (arePseudoBin(a, b, c)) { + var h0 = halfAdder(a, b), + h1 = halfAdder(h0.sum, c); + return {carry: or(h0.carry, h1.carry), sum: h1.sum }; + } +} + +function fourBitAdder(a, b) { + if (typeof a.length == 'undefined' || typeof b.length == 'undefined') + throw new Error('bad values'); + // not sure if the rules allow this, but we need to pad the values + // if they're too short and trim them if they're too long + var inA = Array(4), + inB = Array(4), + out = Array(4), + i = 4, + pass; + + while (i--) { + inA[i] = a[i] != 1 ? 0 : 1; + inB[i] = b[i] != 1 ? 0 : 1; + } + + // now we can start adding... I'd prefer to do this in a loop, + // but that wouldn't be "connecting the other 'constructive blocks', + // in turn made of 'simpler' and 'smaller' ones" + + pass = halfAdder(inA[3], inB[3]); + out[3] = pass.sum; + pass = fullAdder(inA[2], inB[2], pass.carry); + out[2] = pass.sum; + pass = fullAdder(inA[1], inB[1], pass.carry); + out[1] = pass.sum; + pass = fullAdder(inA[0], inB[0], pass.carry); + out[0] = pass.sum; + return out.join(''); +} diff --git a/Task/Four-bit-adder/JavaScript/four-bit-adder-3.js b/Task/Four-bit-adder/JavaScript/four-bit-adder-3.js new file mode 100644 index 0000000000..9cfecd9474 --- /dev/null +++ b/Task/Four-bit-adder/JavaScript/four-bit-adder-3.js @@ -0,0 +1 @@ +fourBitAdder('1010', '0101'); // 1111 (15) diff --git a/Task/Four-bit-adder/JavaScript/four-bit-adder-4.js b/Task/Four-bit-adder/JavaScript/four-bit-adder-4.js new file mode 100644 index 0000000000..23e0ec28e4 --- /dev/null +++ b/Task/Four-bit-adder/JavaScript/four-bit-adder-4.js @@ -0,0 +1,11 @@ +// run this in your browsers console +var outer = inner = 16, a, b; + +while(outer--) { + a = (8|outer).toString(2); + while(inner--) { + b = (8|inner).toString(2); + console.log(a + ' + ' + b + ' = ' + fourBitAdder(a, b)); + } + inner = outer; +} diff --git a/Task/Four-bit-adder/MATLAB/four-bit-adder-1.m b/Task/Four-bit-adder/MATLAB/four-bit-adder-1.m new file mode 100644 index 0000000000..45db4582a0 --- /dev/null +++ b/Task/Four-bit-adder/MATLAB/four-bit-adder-1.m @@ -0,0 +1,64 @@ +function [S,v] = fourBitAdder(input1,input2) + + %Make sure that only 4-Bit numbers are being added. This assumes that + %if input1 and input2 are a vector of multiple decimal numbers, then + %the binary form of these vectors are an n by 4 matrix. + assert((size(input1,2) == 4) && (size(input2,2) == 4),'This will only work on 4-Bit Numbers'); + + %Converts MATLAB binary strings to matricies of 1 and 0 + function mat = binStr2Mat(binStr) + mat = zeros(size(binStr)); + for i = (1:numel(binStr)) + mat(i) = str2double(binStr(i)); + end + end + + %XOR decleration + function AxorB = xor(A,B) + AxorB = or(and(A,not(B)),and(B,not(A))); + end + + %Half-Adder decleration + function [S,C] = halfAdder(A,B) + S = xor(A,B); + C = and(A,B); + end + + %Full-Adder decleration + function [S,Co] = fullAdder(A,B,Ci) + [SAdder1,CAdder1] = halfAdder(Ci,A); + [S,CAdder2] = halfAdder(SAdder1,B); + Co = or(CAdder1,CAdder2); + end + + %The rest of this code is the 4-bit adder + + binStrFlag = false; %A flag to determine if the original input was a binary string + + %If either of the inputs was a binary string, convert it to a matrix of + %1's and 0's. + if ischar(input1) + input1 = binStr2Mat(input1); + binStrFlag = true; + end + if ischar(input2) + input2 = binStr2Mat(input2); + binStrFlag = true; + end + + %This does the addition + S = zeros(size(input1)); + + [S(:,4),Co] = fullAdder(input1(:,4),input2(:,4),0); + [S(:,3),Co] = fullAdder(input1(:,3),input2(:,3),Co); + [S(:,2),Co] = fullAdder(input1(:,2),input2(:,2),Co); + [S(:,1),v] = fullAdder(input1(:,1),input2(:,1),Co); + + %If the original inputs were binary strings, convert the output of the + %4-bit adder to a binary string with the same formatting as the + %original binary strings. + if binStrFlag + S = num2str(S); + v = num2str(v); + end +end %fourBitAdder diff --git a/Task/Four-bit-adder/MATLAB/four-bit-adder-2.m b/Task/Four-bit-adder/MATLAB/four-bit-adder-2.m new file mode 100644 index 0000000000..0997b6b22d --- /dev/null +++ b/Task/Four-bit-adder/MATLAB/four-bit-adder-2.m @@ -0,0 +1,54 @@ +>> [S,V] = fourBitAdder([0 0 0 1],[1 1 1 1]) + +S = + + 0 0 0 0 + + +V = + + 1 + +>> [S,V] = fourBitAdder([0 0 0 1;0 0 1 0],[0 0 0 1;0 0 0 1]) + +S = + + 0 0 1 0 + 0 0 1 1 + + +V = + + 0 + 0 + +>> [S,V] = fourBitAdder(dec2bin(10,4),dec2bin(1,4)) + +S = + +1 0 1 1 + + +V = + +0 + +>> [S,V] = fourBitAdder(dec2bin([10 11],4),dec2bin([1 1],4)) + +S = + +1 0 1 1 +1 1 0 0 + + +V = + +0 +0 + +>> bin2dec(S) + +ans = + + 11 + 12 diff --git a/Task/Four-bit-adder/MUMPS/four-bit-adder.mumps b/Task/Four-bit-adder/MUMPS/four-bit-adder.mumps new file mode 100644 index 0000000000..fea2e614f0 --- /dev/null +++ b/Task/Four-bit-adder/MUMPS/four-bit-adder.mumps @@ -0,0 +1,14 @@ +XOR(Y,Z) ;Uses logicals - i.e., 0 is false, anything else is true (1 is used if setting a value) + QUIT (Y&'Z)!('Y&Z) +HALF(W,X) + QUIT $$XOR(W,X)_"^"_(W&X) +FULL(U,V,CF) + NEW F1,F2 + S F1=$$HALF(U,V) + S F2=$$HALF($P(F1,"^",1),CF) + QUIT $P(F2,"^",1)_"^"_($P(F1,"^",2)!($P(F2,"^",2))) +FOUR(Y,Z,C4) + NEW S,I,T + FOR I=4:-1:1 SET T=$$FULL($E(Y,I),$E(Z,I),C4),$E(S,I)=$P(T,"^",1),C4=$P(T,"^",2) + K I,T + QUIT S_"^"_C4 diff --git a/Task/Four-bit-adder/Mathematica/four-bit-adder-1.mathematica b/Task/Four-bit-adder/Mathematica/four-bit-adder-1.mathematica new file mode 100644 index 0000000000..db113e919d --- /dev/null +++ b/Task/Four-bit-adder/Mathematica/four-bit-adder-1.mathematica @@ -0,0 +1,16 @@ +and[a_, b_] := Max[a, b]; +or[a_, b_] := Min[a, b]; +not[a_] := 1 - a; +xor[a_, b_] := or[and[a, not[b]], and[b, not[a]]]; +halfadder[a_, b_] := {xor[a, b], and[a, b]}; +fulladder[a_, b_, c0_] := Module[{s, c, c1}, + {s, c} = halfadder[c0, a]; + {s, c1} = halfadder[s, b]; + {s, or[c, c1]}]; +fourbitadder[{a3_, a2_, a1_, a0_}, {b3_, b2_, b1_, b0_}] := + Module[{s0, s1, s2, s3, c0, c1, c2, c3}, + {s0, c0} = fulladder[a0, b0, 0]; + {s1, c1} = fulladder[a1, b1, c0]; + {s2, c2} = fulladder[a2, b2, c1]; + {s3, c3} = fulladder[a3, b3, c2]; + {{s3, s2, s1, s0}, c3}]; diff --git a/Task/Four-bit-adder/Mathematica/four-bit-adder-2.mathematica b/Task/Four-bit-adder/Mathematica/four-bit-adder-2.mathematica new file mode 100644 index 0000000000..95eaef17c0 --- /dev/null +++ b/Task/Four-bit-adder/Mathematica/four-bit-adder-2.mathematica @@ -0,0 +1 @@ +fourbitadder[{1, 0, 1, 0}, {1, 1, 1, 1}] diff --git a/Task/Four-bit-adder/PicoLisp/four-bit-adder.l b/Task/Four-bit-adder/PicoLisp/four-bit-adder.l new file mode 100644 index 0000000000..408681e82e --- /dev/null +++ b/Task/Four-bit-adder/PicoLisp/four-bit-adder.l @@ -0,0 +1,23 @@ +(de halfAdder (A B) #> (Carry . Sum) + (cons + (and A B) + (xor A B) ) ) + +(de fullAdder (A B C) #> (Carry . Sum) + (let (Ha1 (halfAdder C A) Ha2 (halfAdder (cdr Ha1) B)) + (cons + (or (car Ha1) (car Ha2)) + (cdr Ha2) ) ) ) + +(de 4bitsAdder (A4 A3 A2 A1 B4 B3 B2 B1) #> (V S4 S3 S2 S1) + (let + (Fa1 (fullAdder A1 B1) + Fa2 (fullAdder A2 B2 (car Fa1)) + Fa3 (fullAdder A3 B3 (car Fa2)) + Fa4 (fullAdder A4 B4 (car Fa3)) ) + (list + (car Fa4) + (cdr Fa4) + (cdr Fa3) + (cdr Fa2) + (cdr Fa1) ) ) ) diff --git a/Task/Four-bit-adder/Python/four-bit-adder.py b/Task/Four-bit-adder/Python/four-bit-adder.py new file mode 100644 index 0000000000..e9c6995e5f --- /dev/null +++ b/Task/Four-bit-adder/Python/four-bit-adder.py @@ -0,0 +1,35 @@ +def xor(a, b): return (a and not b) or (b and not a) + +def ha(a, b): return xor(a, b), a and b # sum, carry + +def fa(a, b, ci): + s0, c0 = ha(ci, a) + s1, c1 = ha(s0, b) + return s1, c0 or c1 # sum, carry + +def fa4(a, b): + width = 4 + ci = [None] * width + co = [None] * width + s = [None] * width + for i in range(width): + s[i], co[i] = fa(a[i], b[i], co[i-1] if i else 0) + return s, co[-1] + +def int2bus(n, width=4): + return [int(c) for c in "{0:0{1}b}".format(n, width)[::-1]] + +def bus2int(b): + return sum(1 << i for i, bit in enumerate(b) if bit) + +def test_fa4(): + width = 4 + tot = [None] * (width + 1) + for a in range(2**width): + for b in range(2**width): + tot[:width], tot[width] = fa4(int2bus(a), int2bus(b)) + assert a + b == bus2int(tot), "totals don't match: %i + %i != %s" % (a, b, tot) + + +if __name__ == '__main__': + test_fa4() diff --git a/Task/Four-bit-adder/REXX/four-bit-adder.rexx b/Task/Four-bit-adder/REXX/four-bit-adder.rexx new file mode 100644 index 0000000000..83af5d1ce0 --- /dev/null +++ b/Task/Four-bit-adder/REXX/four-bit-adder.rexx @@ -0,0 +1,35 @@ +/*REXX program shows (all) the sums of a full 4-bit adder (with carry).*/ +call hdr1; call hdr2 + + do j=0 for 16 + do m=0 for 4; a.m=bit(j,m); end + do k=0 for 16 + do m=0 for 4; b.m=bit(k,m); end + sc=4bitAdder(a.,b.) + z=a.3 a.2 a.1 a.0 '_+_' b.3 b.2 b.1 b.0 '_=_' sc ',' s.3 s.2 s.1 s.0 + say translate(space(z,0),,'_') + end /*k*/ + end /*j*/ + +call hdr2; call hdr1 +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────subroutines/functions───────────────*/ +hdr1: say 'aaaa + bbbb = c, sum [c=carry]'; return +hdr2: say '════ ════ ══════' ; return +bit: procedure; arg x,y; return substr(reverse(x2b(d2x(x))),y+1,1) + +/*──────────────────────────────────HALFADDER subroutine-───────────────*/ +halfAdder: procedure expose c; parse arg x,y; c=x & y; return x && y + +/*──────────────────────────────────FULLADDER subroutine-───────────────*/ +fullAdder: procedure expose c; parse arg x,y,fc +_1=halfAdder(fc,x); c1=c +_2=halfAdder(_1,y); c=c | c1; return _2 + +/*──────────────────────────────────3BITADDER subroutine-───────────────*/ +4bitAdder: procedure expose s. a. b.; carry.=0 + do j=0 for 4; n=j-1 + s.j=fullAdder(a.j, b.j, carry.n); carry.j=c + end /*j*/ +return c diff --git a/Task/Four-bit-adder/Ruby/four-bit-adder.rb b/Task/Four-bit-adder/Ruby/four-bit-adder.rb new file mode 100644 index 0000000000..78ac8483cc --- /dev/null +++ b/Task/Four-bit-adder/Ruby/four-bit-adder.rb @@ -0,0 +1,55 @@ +# returns pair [sum, carry] +def four_bit_adder(a, b) + a_bits = binary_string_to_bits(a,4) + b_bits = binary_string_to_bits(b,4) + + s0, c0 = full_adder(a_bits[0], b_bits[0], 0) + s1, c1 = full_adder(a_bits[1], b_bits[1], c0) + s2, c2 = full_adder(a_bits[2], b_bits[2], c1) + s3, c3 = full_adder(a_bits[3], b_bits[3], c2) + + [bits_to_binary_string([s0, s1, s2, s3]), c3.to_s] +end + +# returns pair [sum, carry] +def full_adder(a, b, c0) + s, c = half_adder(c0, a) + s, c1 = half_adder(s, b) + [s, _or(c,c1)] +end + +# returns pair [sum, carry] +def half_adder(a, b) + [xor(a, b), _and(a,b)] +end + +def xor(a, b) + _or(_and(a, _not(b)), _and(_not(a), b)) +end + +# "and", "or" and "not" are Ruby keywords +def _and(a, b); a & b; end +def _or(a, b); a | b; end +def _not(a); ~a & 1; end + +def int_to_binary_string(n, length) + ("0"*length + n.to_s(2))[-length .. -1] +end +def binary_string_to_bits(s, length) + (s.reverse + "0"*length)[0..length-1].chars.map(&:to_i) +end +def bits_to_binary_string(bits) + bits.map(&:to_s).reverse.join("") +end + +puts " A B A B C S sum" +0.upto(15) do |a| + 0.upto(15) do |b| + bin_a = int_to_binary_string(a, 4) + bin_b = int_to_binary_string(b, 4) + sum, carry = four_bit_adder(bin_a, bin_b) + puts "%2d + %2d = %s + %s = %s %s = %2d" % [ + a, b, bin_a, bin_b, carry, sum, (carry + sum).to_i(2) + ] + end +end diff --git a/Task/Four-bit-adder/Sather/four-bit-adder.sa b/Task/Four-bit-adder/Sather/four-bit-adder.sa new file mode 100644 index 0000000000..b78c5779f1 --- /dev/null +++ b/Task/Four-bit-adder/Sather/four-bit-adder.sa @@ -0,0 +1,138 @@ +-- a "pin" can be connected only to one component +-- that "sets" it to 0 or 1, while it can be "read" +-- ad libitum. (Tristate logic is not taken into account) +-- This class does the proper checking, assuring the "circuit" +-- and the connections are described correctly. Currently can make +-- hard the implementation of a latch +class PIN is + private attr v:INT; + readonly attr name:STR; + private attr connected:BOOL; + + create(n:STR):SAME is -- n = conventional name for this "pin" + res ::= new; + res.name := n; + res.connected := false; + return res; + end; + + val:INT is + if self.connected.not then + #ERR + "pin " + self.name + " is undefined\n"; + return 0; -- could return a random bit to "simulate" undefined + -- behaviour + else + return self.v; + end; + end; + + -- connect ... + val(v:INT) is + if self.connected then + #ERR + "pin " + self.name + " is already 'assigned'\n"; + else + self.connected := true; + self.v := v.band(1); + end; + end; + + -- connect to existing pin + val(v:PIN) is + self.val(v.val); + end; +end; + +-- XOR "block" +class XOR is + readonly attr xor :PIN; + + create(a, b:PIN):SAME is + res ::= new; + res.xor := #PIN("xor output"); + l ::= a.val.bnot.band(1).band(b.val); + r ::= a.val.band(b.val.bnot.band(1)); + res.xor.val := r.bor(l); + return res; + end; +end; + +-- HALF ADDER "block" +class HALFADDER is + readonly attr s, c:PIN; + + create(a, b:PIN):SAME is + res ::= new; + res.s := #PIN("halfadder sum output"); + res.c := #PIN("halfadder carry output"); + res.s.val := #XOR(a, b).xor.val; + res.c.val := a.val.band(b.val); + return res; + end; +end; + +-- FULL ADDER "block" +class FULLADDER is + readonly attr s, c:PIN; + + create(a, b, ic:PIN):SAME is + res ::= new; + res.s := #PIN("fulladder sum output"); + res.c := #PIN("fulladder carry output"); + halfadder1 ::= #HALFADDER(a, b); + halfadder2 ::= #HALFADDER(halfadder1.s, ic); + res.s.val := halfadder2.s; + res.c.val := halfadder2.c.val.bor(halfadder1.c.val); + return res; + end; +end; + +-- FOUR BITS ADDER "block" +class FOURBITSADDER is + readonly attr s0, s1, s2, s3, v :PIN; + + create(a0, a1, a2, a3, b0, b1, b2, b3:PIN):SAME is + res ::= new; + res.s0 := #PIN("4-bits-adder sum outbut line 0"); + res.s1 := #PIN("4-bits-adder sum outbut line 1"); + res.s2 := #PIN("4-bits-adder sum outbut line 2"); + res.s3 := #PIN("4-bits-adder sum outbut line 3"); + res.v := #PIN("4-bits-adder overflow output"); + zero ::= #PIN("zero/mass pin"); + zero.val := 0; + fa0 ::= #FULLADDER(a0, b0, zero); + fa1 ::= #FULLADDER(a1, b1, fa0.c); + fa2 ::= #FULLADDER(a2, b2, fa1.c); + fa3 ::= #FULLADDER(a3, b3, fa2.c); + res.v.val := fa3.c; + res.s0.val := fa0.s; + res.s1.val := fa1.s; + res.s2.val := fa2.s; + res.s3.val := fa3.s; + return res; + end; +end; + +-- testing -- + +class MAIN is + main is + a0 ::= #PIN("a0 in"); b0 ::= #PIN("b0 in"); + a1 ::= #PIN("a1 in"); b1 ::= #PIN("b1 in"); + a2 ::= #PIN("a2 in"); b2 ::= #PIN("b2 in"); + a3 ::= #PIN("a3 in"); b3 ::= #PIN("b3 in"); + ov ::= #PIN("overflow"); + + a0.val := 1; b0.val := 1; + a1.val := 1; b1.val := 1; + a2.val := 0; b2.val := 0; + a3.val := 0; b3.val := 1; + + fba ::= #FOURBITSADDER(a0,a1,a2,a3,b0,b1,b2,b3); + #OUT + #FMT("%d%d%d%d", a3.val, a2.val, a1.val, a0.val) + + " + " + + #FMT("%d%d%d%d", b3.val, b2.val, b1.val, b0.val) + + " = " + + #FMT("%d%d%d%d", fba.s3.val, fba.s2.val, fba.s1.val, fba.s0.val) + + ", overflow = " + fba.v.val + "\n"; + end; +end; diff --git a/Task/Four-bit-adder/Scala/four-bit-adder-1.scala b/Task/Four-bit-adder/Scala/four-bit-adder-1.scala new file mode 100644 index 0000000000..d64747eb86 --- /dev/null +++ b/Task/Four-bit-adder/Scala/four-bit-adder-1.scala @@ -0,0 +1,26 @@ +object FourBitAdder { + type Nibble=(Boolean, Boolean, Boolean, Boolean) + + def xor(a:Boolean, b:Boolean)=(!a)&&b || a&&(!b) + + def halfAdder(a:Boolean, b:Boolean)={ + val s=xor(a,b) + val c=a && b + (s, c) + } + + def fullAdder(a:Boolean, b:Boolean, cIn:Boolean)={ + val (s1, c1)=halfAdder(a, cIn) + val (s, c2)=halfAdder(s1, b) + val cOut=c1 || c2 + (s, cOut) + } + + def fourBitAdder(a:Nibble, b:Nibble)={ + val (s0, c0)=fullAdder(a._4, b._4, false) + val (s1, c1)=fullAdder(a._3, b._3, c0) + val (s2, c2)=fullAdder(a._2, b._2, c1) + val (s3, cOut)=fullAdder(a._1, b._1, c2) + ((s3, s2, s1, s0), cOut) + } +} diff --git a/Task/Four-bit-adder/Scala/four-bit-adder-2.scala b/Task/Four-bit-adder/Scala/four-bit-adder-2.scala new file mode 100644 index 0000000000..821fd65f3b --- /dev/null +++ b/Task/Four-bit-adder/Scala/four-bit-adder-2.scala @@ -0,0 +1,15 @@ +object FourBitAdderTest { + import FourBitAdder._ + def main(args: Array[String]): Unit = { + println("%4s %4s %4s %2s".format("A","B","S","C")) + for(a <- 0 to 15; b <- 0 to 15){ + val (s, cOut)=fourBitAdder(a,b) + println("%4s + %4s = %4s %2d".format(nibbleToString(a),nibbleToString(b),nibbleToString(s),cOut.toInt)) + } + } + + implicit def toInt(b:Boolean):Int=if (b) 1 else 0 + implicit def intToBool(i:Int):Boolean=if (i==0) false else true + implicit def intToNibble(i:Int):Nibble=((i>>>3)&1, (i>>>2)&1, (i>>>1)&1, i&1) + def nibbleToString(n:Nibble):String="%d%d%d%d".format(n._1.toInt, n._2.toInt, n._3.toInt, n._4.toInt) +} diff --git a/Task/Four-bit-adder/Tcl/four-bit-adder-1.tcl b/Task/Four-bit-adder/Tcl/four-bit-adder-1.tcl new file mode 100644 index 0000000000..f351f8e6ff --- /dev/null +++ b/Task/Four-bit-adder/Tcl/four-bit-adder-1.tcl @@ -0,0 +1,65 @@ +package require Tcl 8.5 + +# Create our little language +proc pins args { + # Just declaration... + foreach p $args {upvar 1 $p v} +} +proc gate {name pins body} { + foreach p $pins { + lappend args _$p + append v " \$_$p $p" + } + proc $name $args "upvar 1 $v;$body" +} + +# Fundamental gates; these are the only ones that use Tcl math ops +gate not {x out} { + set out [expr {1 & ~$x}] +} +gate and {x y out} { + set out [expr {$x & $y}] +} +gate or {x y out} { + set out [expr {$x | $y}] +} +gate GND pin { + set pin 0 +} + +# Composite gates: XOR +gate xor {x y out} { + pins nx ny x_ny nx_y + + not x nx + not y ny + and x ny x_ny + and nx y nx_y + or x_ny nx_y out +} + +# Composite gates: half adder +gate halfadd {a b sum carry} { + xor a b sum + and a b carry +} + +# Composite gates: full adder +gate fulladd {a b c0 sum c1} { + pins sum_ac carry_ac carry_sb + + halfadd c0 a sum_ac carry_ac + halfadd sum_ac b sum carry_sb + or carry_ac carry_sb c1 +} + +# Composite gates: 4-bit adder +gate 4add {a0 a1 a2 a3 b0 b1 b2 b3 s0 s1 s2 s3 v} { + pins c0 c1 c2 c3 + + GND c0 + fulladd a0 b0 c0 s0 c1 + fulladd a1 b1 c1 s1 c2 + fulladd a2 b2 c2 s2 c3 + fulladd a3 b3 c3 s3 v +} diff --git a/Task/Four-bit-adder/Tcl/four-bit-adder-2.tcl b/Task/Four-bit-adder/Tcl/four-bit-adder-2.tcl new file mode 100644 index 0000000000..e732fe4018 --- /dev/null +++ b/Task/Four-bit-adder/Tcl/four-bit-adder-2.tcl @@ -0,0 +1,13 @@ +# Simple driver for the circuit +proc 4add_driver {a b} { + lassign [split $a {}] a3 a2 a1 a0 + lassign [split $b {}] b3 b2 b1 b0 + lassign [split 00000 {}] s3 s2 s1 s0 v + + 4add a0 a1 a2 a3 b0 b1 b2 b3 s0 s1 s2 s3 v + + return "$s3$s2$s1$s0 overflow=$v" +} +set a 1011 +set b 0110 +puts $a+$b=[4add_driver $a $b] diff --git a/Task/Fractal-tree/0DESCRIPTION b/Task/Fractal-tree/0DESCRIPTION new file mode 100644 index 0000000000..b8844d4f56 --- /dev/null +++ b/Task/Fractal-tree/0DESCRIPTION @@ -0,0 +1,6 @@ +Generate and draw a fractal tree. + +To draw a fractal tree is simple: +# Draw the trunk +# At the end of the trunk, split by some angle and draw two branches +# Repeat at the end of each branch until a sufficient level of branching is reached diff --git a/Task/Fractal-tree/1META.yaml b/Task/Fractal-tree/1META.yaml new file mode 100644 index 0000000000..bc00dfb25e --- /dev/null +++ b/Task/Fractal-tree/1META.yaml @@ -0,0 +1,7 @@ +--- +category: +- Raster graphics operations +- Recursion +note: Fractals +requires: +- Graphics diff --git a/Task/Fractal-tree/BASIC256/fractal-tree.basic256 b/Task/Fractal-tree/BASIC256/fractal-tree.basic256 new file mode 100644 index 0000000000..5e10ba50e8 --- /dev/null +++ b/Task/Fractal-tree/BASIC256/fractal-tree.basic256 @@ -0,0 +1,45 @@ +graphsize 300,300 + +level = 12 : len =63 # initial values +x = 230: y = 285 +rotation = pi/2 + +A1 = pi/27 : A2 = pi/8 # constants which determine shape +C1 = 0.7 : C2 = 0.85 + +dim xs(level+1) : dim ys(level+1) # stacks + +fastgraphics +color black +rect 0,0,graphwidth,graphheight +refresh +color green +gosub tree +refresh +imgsave "Fractal_tree_BASIC-256.png", "PNG" +end + +tree: + xs[level] = x : ys[level] = y + gosub putline + if level>0 then + level = level - 1 + len = len*C1 + rotation = rotation - A1 + gosub tree + len = len/C1*C2 + rotation = rotation + A1 + A2 + gosub tree + rotation = rotation - A2 + len = len/C2 + level = level + 1 + end if + x = xs[level] : y = ys[level] + return + +putline: + yn = -sin(rotation)*len + y + xn = cos(rotation)*len + x + line x,y,xn,yn + x = xn : y = yn + return diff --git a/Task/Fractal-tree/BBC-BASIC/fractal-tree.bbc b/Task/Fractal-tree/BBC-BASIC/fractal-tree.bbc new file mode 100644 index 0000000000..d04238c276 --- /dev/null +++ b/Task/Fractal-tree/BBC-BASIC/fractal-tree.bbc @@ -0,0 +1,22 @@ + Spread = 25 + Scale = 0.76 + SizeX% = 400 + SizeY% = 300 + Depth% = 10 + + VDU 23,22,SizeX%;SizeY%;8,16,16,128 + + PROCbranch(SizeX%, 0, SizeY%/2, 90, Depth%) + END + + DEF PROCbranch(x1, y1, size, angle, depth%) + LOCAL x2, y2 + x2 = x1 + size * COSRAD(angle) + y2 = y1 + size * SINRAD(angle) + VDU 23,23,depth%;0;0;0; + LINE x1, y1, x2, y2 + IF depth% > 0 THEN + PROCbranch(x2, y2, size * Scale, angle - Spread, depth% - 1) + PROCbranch(x2, y2, size * Scale, angle + Spread, depth% - 1) + ENDIF + ENDPROC diff --git a/Task/Fractal-tree/C/fractal-tree.c b/Task/Fractal-tree/C/fractal-tree.c new file mode 100644 index 0000000000..738c6b6886 --- /dev/null +++ b/Task/Fractal-tree/C/fractal-tree.c @@ -0,0 +1,101 @@ +#include +#ifdef WITH_CAIRO +#include +#else +#include +#endif +#include +#include +#include +#include + +#ifdef WITH_CAIRO +#define PI 3.1415926535 +#endif + +#define SIZE 800 // determines size of window +#define SCALE 5 // determines how quickly branches shrink (higher value means faster shrinking) +#define BRANCHES 14 // number of branches +#define ROTATION_SCALE 0.75 // determines how slowly the angle between branches shrinks (higher value means slower shrinking) +#define INITIAL_LENGTH 50 // length of first branch + +double rand_fl(){ + return (double)rand() / (double)RAND_MAX; +} + +void draw_tree(SDL_Surface * surface, double offsetx, double offsety, + double directionx, double directiony, double size, + double rotation, int depth) { +#ifdef WITH_CAIRO + cairo_surface_t *surf = cairo_image_surface_create_for_data( surface->pixels, + CAIRO_FORMAT_RGB24, + surface->w, surface->h, + surface->pitch ); + cairo_t *ct = cairo_create(surf); + + cairo_set_line_width(ct, 1); + cairo_set_source_rgba(ct, 0,0,0,1); + cairo_move_to(ct, (int)offsetx, (int)offsety); + cairo_line_to(ct, (int)(offsetx + directionx * size), (int)(offsety + directiony * size)); + cairo_stroke(ct); +#else + sge_AALine(surface, + (int)offsetx, (int)offsety, + (int)(offsetx + directionx * size), (int)(offsety + directiony * size), + SDL_MapRGB(surface->format, 0, 0, 0)); +#endif + if (depth > 0){ + // draw left branch + draw_tree(surface, + offsetx + directionx * size, + offsety + directiony * size, + directionx * cos(rotation) + directiony * sin(rotation), + directionx * -sin(rotation) + directiony * cos(rotation), + size * rand_fl() / SCALE + size * (SCALE - 1) / SCALE, + rotation * ROTATION_SCALE, + depth - 1); + + // draw right branch + draw_tree(surface, + offsetx + directionx * size, + offsety + directiony * size, + directionx * cos(-rotation) + directiony * sin(-rotation), + directionx * -sin(-rotation) + directiony * cos(-rotation), + size * rand_fl() / SCALE + size * (SCALE - 1) / SCALE, + rotation * ROTATION_SCALE, + depth - 1); + } +} + +void render(SDL_Surface * surface){ + SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 255, 255, 255)); + draw_tree(surface, + surface->w / 2.0, + surface->h - 10.0, + 0.0, -1.0, + INITIAL_LENGTH, + PI / 8, + BRANCHES); + SDL_UpdateRect(surface, 0, 0, 0, 0); +} + +int main(){ + SDL_Surface * screen; + SDL_Event evt; + + SDL_Init(SDL_INIT_VIDEO); + + srand((unsigned)time(NULL)); + + screen = SDL_SetVideoMode(SIZE, SIZE, 32, SDL_HWSURFACE); + + render(screen); + while(1){ + if (SDL_PollEvent(&evt)){ + if(evt.type == SDL_QUIT) break; + } + SDL_Delay(1); + } + SDL_Quit(); + return 0; +} diff --git a/Task/Fractal-tree/Clojure/fractal-tree.clj b/Task/Fractal-tree/Clojure/fractal-tree.clj new file mode 100644 index 0000000000..29b3ffb91b --- /dev/null +++ b/Task/Fractal-tree/Clojure/fractal-tree.clj @@ -0,0 +1,26 @@ +(import '[java.awt Color Graphics] + 'javax.swing.JFrame) + +(defn deg-to-radian [deg] (* deg Math/PI 1/180)) +(defn cos-deg [angle] (Math/cos (deg-to-radian angle))) +(defn sin-deg [angle] (Math/sin (deg-to-radian angle))) + +(defn draw-tree [^Graphics g, x y angle depth] + (when (pos? depth) + (let [x2 (+ x (int (* depth 10 (cos-deg angle)))) + y2 (+ y (int (* depth 10 (sin-deg angle))))] + (.drawLine g x y x2 y2) + (draw-tree g x2 y2 (- angle 20) (dec depth)) + (recur g x2 y2 (+ angle 20) (dec depth))))) + +(defn fractal-tree [depth] + (doto (proxy [JFrame] [] + (paint [g] + (.setColor g Color/BLACK) + (draw-tree g 400 500 -90 depth))) + (.setBounds 100 100 800 600) + (.setResizable false) + (.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE) + (.show))) + +(fractal-tree 9) diff --git a/Task/Fractal-tree/D/fractal-tree.d b/Task/Fractal-tree/D/fractal-tree.d new file mode 100644 index 0000000000..3fda982d13 --- /dev/null +++ b/Task/Fractal-tree/D/fractal-tree.d @@ -0,0 +1,43 @@ +import dfl.all; +import std.math; + +class FractalTree: Form { + + private const double DEG_TO_RAD = PI / 180.0; + + this() { + width = 600; + height = 500; + text = "Fractal Tree"; + backColor = Color(0xFF, 0xFF, 0xFF); + startPosition = FormStartPosition.CENTER_SCREEN; + formBorderStyle = FormBorderStyle.FIXED_DIALOG; + maximizeBox = false; + } + + private void drawTree(Graphics g, Pen p, int x1, int y1, double angle, int depth) { + if (depth == 0) return; + int x2 = x1 + cast(int) (cos(angle * DEG_TO_RAD) * depth * 10.0); + int y2 = y1 + cast(int) (sin(angle * DEG_TO_RAD) * depth * 10.0); + g.drawLine(p, x1, y1, x2, y2); + drawTree(g, p, x2, y2, angle - 20, depth - 1); + drawTree(g, p, x2, y2, angle + 20, depth - 1); + } + + protected override void onPaint(PaintEventArgs ea){ + super.onPaint(ea); + Pen p = new Pen(Color(0, 0xAA, 0)); + drawTree(ea.graphics, p, 300, 450, -90, 9); + } +} + +int main() { + int result = 0; + try { + Application.run(new FractalTree); + } catch(Object o) { + msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR); + result = 1; + } + return result; +} diff --git a/Task/Fractal-tree/Fantom/fractal-tree.fantom b/Task/Fractal-tree/Fantom/fractal-tree.fantom new file mode 100644 index 0000000000..f17c358b7d --- /dev/null +++ b/Task/Fractal-tree/Fantom/fractal-tree.fantom @@ -0,0 +1,35 @@ +using fwt +using gfx + +class FractalCanvas : Canvas +{ + new make () : super() {} + + Void drawTree (Graphics g, Int x1, Int y1, Int angle, Int depth) + { + if (depth == 0) return + Int x2 := x1 + (angle.toFloat.toRadians.cos * depth * 10.0).toInt; + Int y2 := y1 + (angle.toFloat.toRadians.sin * depth * 10.0).toInt; + g.drawLine(x1, y1, x2, y2); + drawTree(g, x2, y2, angle - 20, depth - 1); + drawTree(g, x2, y2, angle + 20, depth - 1); + } + + override Void onPaint (Graphics g) + { + drawTree (g, 400, 500, -90, 9) + } +} + +class FractalTree +{ + public static Void main () + { + Window + { + title = "Fractal Tree" + size = Size(800, 600) + FractalCanvas(), + }.open + } +} diff --git a/Task/Fractal-tree/Go/fractal-tree.go b/Task/Fractal-tree/Go/fractal-tree.go new file mode 100644 index 0000000000..1773279976 --- /dev/null +++ b/Task/Fractal-tree/Go/fractal-tree.go @@ -0,0 +1,37 @@ +package main + +// Files required to build supporting package raster are found in: +// * Bitmap +// * Grayscale image +// * Xiaolin Wu's line algorithm +// * Write a PPM file + +import ( + "math" + "raster" +) + +const ( + width = 400 + height = 300 + depth = 8 + angle = 12 + length = 50 + frac = .8 +) + +func main() { + g := raster.NewGrmap(width, height) + ftree(g, width/2, height*9/10, length, 0, depth) + g.Bitmap().WritePpmFile("ftree.ppm") +} + +func ftree(g *raster.Grmap, x, y, distance, direction float64, depth int) { + x2 := x + distance*math.Sin(direction*math.Pi/180) + y2 := y - distance*math.Cos(direction*math.Pi/180) + g.AaLine(x, y, x2, y2) + if depth > 0 { + ftree(g, x2, y2, distance*frac, direction-angle, depth-1) + ftree(g, x2, y2, distance*frac, direction+angle, depth-1) + } +} diff --git a/Task/Fractal-tree/Haskell/fractal-tree.hs b/Task/Fractal-tree/Haskell/fractal-tree.hs new file mode 100644 index 0000000000..89e9632527 --- /dev/null +++ b/Task/Fractal-tree/Haskell/fractal-tree.hs @@ -0,0 +1,29 @@ +import Graphics.HGL.Window +import Graphics.HGL.Run +import Control.Arrow +import Control.Monad +import Data.List + +enumBase :: Int -> Int -> [[Int]] +enumBase n = mapM (enumFromTo 0). replicate n. pred + +psPlus (a,b) (p,q) = (a+p, b+q) + +toInt :: Double -> Int +toInt = fromIntegral.round + +intPoint = toInt *** toInt + +pts n = + map (map (intPoint.psPlus (100,0)). ((0,300):). scanl1 psPlus. ((r,300):). zipWith (\h a -> (h*cos a, h*sin a)) rs) hs + where + [r,h,sr,sh] = [50, pi/5, 0.9, 0.75] + rs = take n $ map (r*) $ iterate(*sr) sr + lhs = map (map (((-1)**).fromIntegral)) $ enumBase n 2 + rhs = take n $ map (h*) $ iterate(*sh) 1 + hs = map (scanl1 (+). zipWith (*)rhs) lhs + +fractalTree :: Int -> IO () +fractalTree n = + runWindow "Fractal Tree" (500,600) + (\w -> setGraphic w (overGraphics ( map polyline $ pts (n-1))) >> getKey w) diff --git a/Task/Fractal-tree/Icon/fractal-tree.icon b/Task/Fractal-tree/Icon/fractal-tree.icon new file mode 100644 index 0000000000..bda5612dbf --- /dev/null +++ b/Task/Fractal-tree/Icon/fractal-tree.icon @@ -0,0 +1,18 @@ +procedure main() +WOpen("size=800,600", "bg=black", "fg=white") | stop("*** cannot open window") +drawtree(400,500,-90,9) +WDone() +end + +link WOpen + +procedure drawtree(x,y,angle,depth) +if depth > 0 then { + x2 := integer(x + cos(dtor(angle)) * depth * 10) + y2 := integer(y + sin(dtor(angle)) * depth * 10) + DrawLine(x,y,x2,y2) + drawtree(x2,y2,angle-20, depth-1) + drawtree(x2,y2,angle+20, depth-1) + } +return +end diff --git a/Task/Fractal-tree/J/fractal-tree.j b/Task/Fractal-tree/J/fractal-tree.j new file mode 100644 index 0000000000..77e6ef7a4e --- /dev/null +++ b/Task/Fractal-tree/J/fractal-tree.j @@ -0,0 +1,24 @@ +require'gl2' + +L0=: 50 NB. initial length +A0=: 1r8p1 NB. initial angle: pi divided by 8 +dL=: 0.9 NB. shrink factor for length +dA=: 0.75 NB. shrink factor for angle +N=: 14 NB. number of branches + +L=: L0*dL^1+i.N NB. lengths of line segments + +NB. relative angles of successive line segments +A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N + +NB. end points for each line segment +P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A + +P_C_paint=: gllines_jgl2_ bind (10 + ,/"2 P-"1<./,/P) +wd 0 :0 + pc P closeok; + xywh 0 0 250 300; + cc C isigraph rightmove bottommove; + pas 0 0; + pshow; +) diff --git a/Task/Fractal-tree/Java/fractal-tree.java b/Task/Fractal-tree/Java/fractal-tree.java new file mode 100644 index 0000000000..2edd98acea --- /dev/null +++ b/Task/Fractal-tree/Java/fractal-tree.java @@ -0,0 +1,32 @@ +import java.awt.Color; +import java.awt.Graphics; +import javax.swing.JFrame; + +public class FractalTree extends JFrame { + + public FractalTree() { + super("Fractal Tree"); + setBounds(100, 100, 800, 600); + setResizable(false); + setDefaultCloseOperation(EXIT_ON_CLOSE); + } + + private void drawTree(Graphics g, int x1, int y1, double angle, int depth) { + if (depth == 0) return; + int x2 = x1 + (int) (Math.cos(Math.toRadians(angle)) * depth * 10.0); + int y2 = y1 + (int) (Math.sin(Math.toRadians(angle)) * depth * 10.0); + g.drawLine(x1, y1, x2, y2); + drawTree(g, x2, y2, angle - 20, depth - 1); + drawTree(g, x2, y2, angle + 20, depth - 1); + } + + @Override + public void paint(Graphics g) { + g.setColor(Color.BLACK); + drawTree(g, 400, 500, -90, 9); + } + + public static void main(String[] args) { + new FractalTree().setVisible(true); + } +} diff --git a/Task/Fractal-tree/JavaScript/fractal-tree.js b/Task/Fractal-tree/JavaScript/fractal-tree.js new file mode 100644 index 0000000000..e4733b70ee --- /dev/null +++ b/Task/Fractal-tree/JavaScript/fractal-tree.js @@ -0,0 +1,33 @@ + + + + + + diff --git a/Task/Fractal-tree/Liberty-BASIC/fractal-tree.liberty b/Task/Fractal-tree/Liberty-BASIC/fractal-tree.liberty new file mode 100644 index 0000000000..bf5de3240e --- /dev/null +++ b/Task/Fractal-tree/Liberty-BASIC/fractal-tree.liberty @@ -0,0 +1,36 @@ + NoMainWin +sw = 640 : sh = 480 +WindowWidth = sw+8 : WindowHeight = sh+31 +UpperLeftX = (DisplayWidth -sw)/2 +UpperLeftY = (DisplayHeight-sh)/2 +Open"Fractal Tree" For Graphics_nf_nsb As #g +#g "Down; Color darkgreen; TrapClose halt" +h$ = "#g" + +'initial assignments +initAngle = Acs(-1)*1.5 'radian equivalent of 270 degrees + theta = 29 * (Acs(-1)/180) 'convert 29 degrees to radians + length = 110 'length in pixels + depth = 25 'max recursion depth + 'draw the tree + Call tree h$, 320, 470, initAngle, theta, length, depth + #g "Flush; when leftButtonDown halt" 'L-click to exit + Wait + +Sub halt handle$ + Close #handle$ + End +End Sub + +Sub tree h$, x, y, initAngle, theta, length, depth + Scan + newX = Cos(initAngle) * length + x + newY = Sin(initAngle) * length + y + #h$ "Line ";x;" ";y;" ";newX;" ";newY + length = length * .78 + depth = depth - 1 + If depth > 0 Then + Call tree h$, newX, newY, initAngle-theta, theta, length, depth + Call tree h$, newX, newY, initAngle+theta, theta, length, depth + End If +End Sub diff --git a/Task/Fractal-tree/Logo/fractal-tree.logo b/Task/Fractal-tree/Logo/fractal-tree.logo new file mode 100644 index 0000000000..d6e7cf18f6 --- /dev/null +++ b/Task/Fractal-tree/Logo/fractal-tree.logo @@ -0,0 +1,14 @@ +to tree :depth :length :scale :angle + if :depth=0 [stop] + setpensize round :depth/2 + forward :length + right :angle + tree :depth-1 :length*:scale :scale :angle + left 2*:angle + tree :depth-1 :length*:scale :scale :angle + right :angle + back :length +end + +clearscreen +tree 10 80 0.7 30 diff --git a/Task/Fractal-tree/Mathematica/fractal-tree.mathematica b/Task/Fractal-tree/Mathematica/fractal-tree.mathematica new file mode 100644 index 0000000000..f9fe7cb59f --- /dev/null +++ b/Task/Fractal-tree/Mathematica/fractal-tree.mathematica @@ -0,0 +1,17 @@ +fractalTree[ + pt : {_, _}, \[Theta]orient_: \[Pi]/2, \[Theta]sep_: \[Pi]/9, + depth_Integer: 9] := Module[{pt2}, + If[depth == 0, Return[]]; + pt2 = pt + {Cos[\[Theta]orient], Sin[\[Theta]orient]}*depth; + DeleteCases[ + Flatten@{ + Line[{pt, pt2}], + fractalTree[pt2, \[Theta]orient - \[Theta]sep, \[Theta]sep, + depth - 1], + fractalTree[pt2, \[Theta]orient + \[Theta]sep, \[Theta]sep, + depth - 1] + }, + Null + ] + ] +Graphics[fractalTree[{0, 0}, \[Pi]/2, \[Pi]/9]] diff --git a/Task/Fractal-tree/PHP/fractal-tree.php b/Task/Fractal-tree/PHP/fractal-tree.php new file mode 100644 index 0000000000..65e31417b3 --- /dev/null +++ b/Task/Fractal-tree/PHP/fractal-tree.php @@ -0,0 +1,30 @@ + diff --git a/Task/Fractal-tree/Perl/fractal-tree.pl b/Task/Fractal-tree/Perl/fractal-tree.pl new file mode 100644 index 0000000000..98716035da --- /dev/null +++ b/Task/Fractal-tree/Perl/fractal-tree.pl @@ -0,0 +1,30 @@ +use GD::Simple; + +my ($width, $height) = (1000,1000); # image dimension +my $scale = 6/10; # branch scale relative to trunk +my $length = 400; # trunk size + +my $img = GD::Simple->new($width,$height); +$img->fgcolor('black'); +$img->penSize(1,1); + +tree($width/2, $height, $length, 270); + +print $img->png; + + +sub tree +{ + my ($x, $y, $len, $angle) = @_; + + return if $len < 1; + + $img->moveTo($x,$y); + $img->angle($angle); + $img->line($len); + + ($x, $y) = $img->curPos(); + + tree($x, $y, $len*$scale, $angle+35); + tree($x, $y, $len*$scale, $angle-35); +} diff --git a/Task/Fractal-tree/PicoLisp/fractal-tree.l b/Task/Fractal-tree/PicoLisp/fractal-tree.l new file mode 100644 index 0000000000..213614c158 --- /dev/null +++ b/Task/Fractal-tree/PicoLisp/fractal-tree.l @@ -0,0 +1,15 @@ +(load "@lib/math.l") + +(de fractalTree (Img X Y A D) + (unless (=0 D) + (let (R (*/ A pi 180.0) DX (*/ (cos R) D 0.2) DY (*/ (sin R) D 0.2)) + (brez Img X Y DX DY) + (fractalTree Img (+ X DX) (+ Y DY) (+ A 30.0) (dec D)) + (fractalTree Img (+ X DX) (+ Y DY) (- A 30.0) (dec D)) ) ) ) + +(let Img (make (do 300 (link (need 400 0)))) # Create image 400 x 300 + (fractalTree Img 200 300 -90.0 10) # Draw tree + (out "img.pbm" # Write to bitmap file + (prinl "P1") + (prinl 400 " " 300) + (mapc prinl Img) ) ) diff --git a/Task/Fractal-tree/Prolog/fractal-tree.pro b/Task/Fractal-tree/Prolog/fractal-tree.pro new file mode 100644 index 0000000000..3897ad55f3 --- /dev/null +++ b/Task/Fractal-tree/Prolog/fractal-tree.pro @@ -0,0 +1,19 @@ +fractal :- + new(D, window('Fractal')), + send(D, size, size(800, 600)), + drawTree(D, 400, 500, -90, 9), + send(D, open). + + +drawTree(_D, _X, _Y, _Angle, 0). + +drawTree(D, X1, Y1, Angle, Depth) :- + X2 is X1 + cos(Angle * pi / 180.0) * Depth * 10.0, + Y2 is Y1 + sin(Angle * pi / 180.0) * Depth * 10.0, + new(Line, line(X1, Y1, X2, Y2, none)), + send(D, display, Line), + A1 is Angle - 30, + A2 is Angle + 30, + De is Depth - 1, + drawTree(D, X2, Y2, A1, De), + drawTree(D, X2, Y2, A2, De). diff --git a/Task/Fractal-tree/Python/fractal-tree.py b/Task/Fractal-tree/Python/fractal-tree.py new file mode 100644 index 0000000000..0736b023e8 --- /dev/null +++ b/Task/Fractal-tree/Python/fractal-tree.py @@ -0,0 +1,23 @@ +import pygame, math + +pygame.init() +window = pygame.display.set_mode((600, 600)) +pygame.display.set_caption("Fractal Tree") +screen = pygame.display.get_surface() + +def drawTree(x1, y1, angle, depth): + if depth: + x2 = x1 + int(math.cos(math.radians(angle)) * depth * 10.0) + y2 = y1 + int(math.sin(math.radians(angle)) * depth * 10.0) + pygame.draw.line(screen, (255,255,255), (x1, y1), (x2, y2), 2) + drawTree(x2, y2, angle - 20, depth - 1) + drawTree(x2, y2, angle + 20, depth - 1) + +def input(event): + if event.type == pygame.QUIT: + exit(0) + +drawTree(300, 550, -90, 9) +pygame.display.flip() +while True: + input(pygame.event.wait()) diff --git a/Task/Fractal-tree/Ruby/fractal-tree.rb b/Task/Fractal-tree/Ruby/fractal-tree.rb new file mode 100644 index 0000000000..895a226af8 --- /dev/null +++ b/Task/Fractal-tree/Ruby/fractal-tree.rb @@ -0,0 +1,19 @@ +Shoes.app(:title => "Fractal Tree", :width => 600, :height => 600) do + background "#fff" + stroke "#000" + @deg_to_rad = Math::PI / 180.0 + + def drawTree(x1, y1, angle, depth) + if depth != 0 + x2 = x1 + (Math.cos(angle * @deg_to_rad) * depth * 10.0).to_i + y2 = y1 + (Math.sin(angle * @deg_to_rad) * depth * 10.0).to_i + + line x1, y1, x2, y2 + + drawTree(x2, y2, angle - 20, depth - 1) + drawTree(x2, y2, angle + 20, depth - 1) + end + end + + drawTree(300,550,-90,9) +end diff --git a/Task/Fractal-tree/Scala/fractal-tree.scala b/Task/Fractal-tree/Scala/fractal-tree.scala new file mode 100644 index 0000000000..7e0754a463 --- /dev/null +++ b/Task/Fractal-tree/Scala/fractal-tree.scala @@ -0,0 +1,31 @@ +import swing._ +import java.awt.{RenderingHints, BasicStroke, Color} + +object FractalTree extends SimpleSwingApplication { + val DEPTH = 9 + + def top = new MainFrame { + contents = new Panel { + preferredSize = new Dimension(600, 500) + + override def paintComponent(g: Graphics2D) { + draw(300, 460, -90, DEPTH) + + def draw(x1: Int, y1: Int, angle: Double, depth: Int) { + if (depth > 0) { + val x2 = x1 + (math.cos(angle.toRadians) * depth * 10).toInt + val y2 = y1 + (math.sin(angle.toRadians) * depth * 10).toInt + + g.setColor(Color.getHSBColor(0.25f - depth * 0.125f / DEPTH, 0.9f, 0.6f)) + g.setStroke(new BasicStroke(depth)) + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) + g.drawLine(x1, y1, x2, y2) + + draw(x2, y2, angle - 20, depth - 1) + draw(x2, y2, angle + 20, depth - 1) + } + } + } + } + } +} diff --git a/Task/Fractal-tree/Tcl/fractal-tree.tcl b/Task/Fractal-tree/Tcl/fractal-tree.tcl new file mode 100644 index 0000000000..6a1e211a10 --- /dev/null +++ b/Task/Fractal-tree/Tcl/fractal-tree.tcl @@ -0,0 +1,32 @@ +package require Tk + +set SIZE 800 +set SCALE 4.0 +set BRANCHES 14 +set ROTATION_SCALE 0.85 +set INITIAL_LENGTH 50.0 + +proc draw_tree {w x y dx dy size theta depth} { + global SCALE ROTATION_SCALE + $w create line $x $y [expr {$x + $dx*$size}] [expr {$y + $dy*$size}] + if {[incr depth -1] >= 0} { + set x [expr {$x + $dx*$size}] + set y [expr {$y + $dy*$size}] + set ntheta [expr {$theta * $ROTATION_SCALE}] + + # Draw left branch + draw_tree $w $x $y \ + [expr {$dx*cos($theta) + $dy*sin($theta)}] \ + [expr {$dy*cos($theta) - $dx*sin($theta)}] \ + [expr {$size * (rand() + $SCALE - 1) / $SCALE}] $ntheta $depth + # Draw right branch + draw_tree $w $x $y \ + [expr {$dx*cos(-$theta) + $dy*sin(-$theta)}] \ + [expr {$dy*cos(-$theta) - $dx*sin(-$theta)}] \ + [expr {$size * (rand() + $SCALE - 1) / $SCALE}] $ntheta $depth + } +} + +pack [canvas .c -width $SIZE -height $SIZE] +draw_tree .c [expr {$SIZE/2}] [expr {$SIZE-10}] 0.0 -1.0 $INITIAL_LENGTH \ + [expr {3.1415927 / 8}] $BRANCHES diff --git a/Task/Function-composition/0DESCRIPTION b/Task/Function-composition/0DESCRIPTION new file mode 100644 index 0000000000..ad9306e434 --- /dev/null +++ b/Task/Function-composition/0DESCRIPTION @@ -0,0 +1,6 @@ +Create a function, compose, whose two arguments ''f'' and ''g'', are both functions with one argument. The result of compose is to be a function of one argument, (lets call the argument ''x''), which works like applying function ''f'' to the result of applying function ''g'' to ''x'', i.e, +: compose(''f'', ''g'') (''x'') = ''f''(''g''(''x'')) + +Reference: [[wp:Function composition (computer science)|Function composition]] + +Hint: In some languages, implementing compose correctly requires creating a [[wp:Closure (computer science)|closure]]. diff --git a/Task/Function-composition/1META.yaml b/Task/Function-composition/1META.yaml new file mode 100644 index 0000000000..a017bb0cdf --- /dev/null +++ b/Task/Function-composition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Higher-order functions diff --git a/Task/Function-composition/ALGOL-68/function-composition-1.alg b/Task/Function-composition/ALGOL-68/function-composition-1.alg new file mode 100644 index 0000000000..fda92e99d7 --- /dev/null +++ b/Task/Function-composition/ALGOL-68/function-composition-1.alg @@ -0,0 +1,10 @@ +MODE F = PROC(REAL)REAL; # ALGOL 68 is strong typed # + +# As a procedure for real to real functions # +PROC compose = (F f, g)F: (REAL x)REAL: f(g(x)); + +OP (F,F)F O = compose; # or an OPerator that can be overloaded # + +# Example use: # +F sin arc sin = compose(sin, arc sin); +print((sin arc sin(0.5), (sin O arc sin)(0.5), new line)) diff --git a/Task/Function-composition/ALGOL-68/function-composition-2.alg b/Task/Function-composition/ALGOL-68/function-composition-2.alg new file mode 100644 index 0000000000..c9129b53bf --- /dev/null +++ b/Task/Function-composition/ALGOL-68/function-composition-2.alg @@ -0,0 +1,11 @@ +MODE F = PROC(REAL)REAL; # ALGOL 68 is strong typed # + +# As a procedure for real to real functions # +PROC compose = (F f, g)F: ((F f2, g2, REAL x)REAL: f2(g2(x)))(f, g, ); # Curry # + +PRIO O = 7; +OP (F,F)F O = compose; # or an OPerator that can be overloaded # + +# Example use: # +F sin arc sin = compose(sin, arc sin); +print((sin arc sin(0.5), (sin O arc sin)(0.5), new line)) diff --git a/Task/Function-composition/ActionScript/function-composition.as b/Task/Function-composition/ActionScript/function-composition.as new file mode 100644 index 0000000000..22065df90a --- /dev/null +++ b/Task/Function-composition/ActionScript/function-composition.as @@ -0,0 +1,6 @@ +function compose(f:Function, g:Function):Function { + return function(x:Object) {return f(g(x));}; +} +function test() { + trace(compose(Math.atan, Math.tan)(0.5)); +} diff --git a/Task/Function-composition/Ada/function-composition-1.ada b/Task/Function-composition/Ada/function-composition-1.ada new file mode 100644 index 0000000000..2241acbfe6 --- /dev/null +++ b/Task/Function-composition/Ada/function-composition-1.ada @@ -0,0 +1,13 @@ +generic + type Argument is private; +package Functions is + type Primitive_Operation is not null + access function (Value : Argument) return Argument; + type Func (<>) is private; + function "*" (Left : Func; Right : Argument) return Argument; + function "*" (Left : Func; Right : Primitive_Operation) return Func; + function "*" (Left, Right : Primitive_Operation) return Func; + function "*" (Left, Right : Func) return Func; +private + type Func is array (Positive range <>) of Primitive_Operation; +end Functions; diff --git a/Task/Function-composition/Ada/function-composition-2.ada b/Task/Function-composition/Ada/function-composition-2.ada new file mode 100644 index 0000000000..d841a9d408 --- /dev/null +++ b/Task/Function-composition/Ada/function-composition-2.ada @@ -0,0 +1,25 @@ +package body Functions is + function "*" (Left : Func; Right : Argument) return Argument is + Result : Argument := Right; + begin + for I in reverse Left'Range loop + Result := Left (I) (Result); + end loop; + return Result; + end "*"; + + function "*" (Left, Right : Func) return Func is + begin + return Left & Right; + end "*"; + + function "*" (Left : Func; Right : Primitive_Operation) return Func is + begin + return Left & (1 => Right); + end "*"; + + function "*" (Left, Right : Primitive_Operation) return Func is + begin + return (Left, Right); + end "*"; +end Functions; diff --git a/Task/Function-composition/Ada/function-composition-3.ada b/Task/Function-composition/Ada/function-composition-3.ada new file mode 100644 index 0000000000..8f0533961e --- /dev/null +++ b/Task/Function-composition/Ada/function-composition-3.ada @@ -0,0 +1,12 @@ +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; +with Functions; + +procedure Test_Compose is + package Float_Functions is new Functions (Float); + use Float_Functions; + + Sin_Arcsin : Func := Sin'Access * Arcsin'Access; +begin + Put_Line (Float'Image (Sin_Arcsin * 0.5)); +end Test_Compose; diff --git a/Task/Function-composition/Aikido/function-composition.aikido b/Task/Function-composition/Aikido/function-composition.aikido new file mode 100644 index 0000000000..bf78b58db4 --- /dev/null +++ b/Task/Function-composition/Aikido/function-composition.aikido @@ -0,0 +1,8 @@ +import math + +function compose (f, g) { + return function (x) { return f(g(x)) } +} + +var func = compose(Math.sin, Math.asin) +println (func(0.5)) // 0.5 diff --git a/Task/Function-composition/Argile/function-composition.argile b/Task/Function-composition/Argile/function-composition.argile new file mode 100644 index 0000000000..89eca2f83a --- /dev/null +++ b/Task/Function-composition/Argile/function-composition.argile @@ -0,0 +1,43 @@ +use std, math + +let my_asin = new Function (.::. -> real {asin x}) +let my__sin = new Function (.::. -> real { sin x}) +let sinasin = my__sin o my_asin +print sin asin 0.5 +print *my__sin 0.0 +print *sinasin 0.5 +~my_asin +~my__sin +~sinasin + +=: o := -> Function {compose f g} + +.:compose :. -> Function + use array + let d = (new array of 2 Function) + (d[0]) = f ; (d[1]) = g + let c = new Function (.::. -> real { + *fg[0]( *fg[1](x) ) + }) (d) + c.del = .::.{free any} + c + +class Function + function(any)(real)->(real) func + any data + function(any) del + +=: * := -> real + Cgen "(*("(f.func)"))("(f.data)", "(x)")" + +.: del Function :. + unless f.del is nil + call f.del with f.data + free f +=: ~ := {del Function f} + +.: new Function real func> ():. -> Function + let f = new Function + f.func = func + f.data = data + f diff --git a/Task/Function-composition/AutoHotkey/function-composition.ahk b/Task/Function-composition/AutoHotkey/function-composition.ahk new file mode 100644 index 0000000000..b4459becb1 --- /dev/null +++ b/Task/Function-composition/AutoHotkey/function-composition.ahk @@ -0,0 +1,5 @@ +MsgBox % compose("sin","cos",1.5) + +compose(f,g,x) { ; function composition + Return %f%(%g%(x)) +} diff --git a/Task/Function-composition/BBC-BASIC/function-composition.bbc b/Task/Function-composition/BBC-BASIC/function-composition.bbc new file mode 100644 index 0000000000..84f4ed0673 --- /dev/null +++ b/Task/Function-composition/BBC-BASIC/function-composition.bbc @@ -0,0 +1,17 @@ + REM Create some functions for testing: + DEF FNsqr(a) = SQR(a) + DEF FNabs(a) = ABS(a) + + REM Create the function composition: + SqrAbs = FNcompose(FNsqr(), FNabs()) + + REM Test calling the composition: + x = -2 : PRINT ; x, FN(SqrAbs)(x) + END + + DEF FNcompose(RETURN f%, RETURN g%) + LOCAL f$, p% : DIM p% 7 : p%!0 = f% : p%!4 = g% + f$ = "(x)=" + CHR$&A4 + "(&" + STR$~p% + ")(" + \ + \ CHR$&A4 + "(&" + STR$~(p%+4) + ")(x))" + DIM p% LEN(f$) + 4 : $(p%+4) = f$ : !p% = p%+4 + = p% diff --git a/Task/Function-composition/Bori/function-composition-1.bori b/Task/Function-composition/Bori/function-composition-1.bori new file mode 100644 index 0000000000..15fa769ab0 --- /dev/null +++ b/Task/Function-composition/Bori/function-composition-1.bori @@ -0,0 +1,9 @@ +double sin (double v) { return Math.sin(v); } +double asin (double v) { return Math.asin(v); } +Var compose (Func f, Func g, double d) { return f(g(d)); } + +void button1_onClick (Widget widget) +{ + double d = compose(sin, asin, 0.5); + label1.setText(d.toString(9)); +} diff --git a/Task/Function-composition/Bori/function-composition-2.bori b/Task/Function-composition/Bori/function-composition-2.bori new file mode 100644 index 0000000000..d9168c21f4 --- /dev/null +++ b/Task/Function-composition/Bori/function-composition-2.bori @@ -0,0 +1 @@ +0.500000000 diff --git a/Task/Function-composition/Brat/function-composition.brat b/Task/Function-composition/Brat/function-composition.brat new file mode 100644 index 0000000000..f4e4a5e907 --- /dev/null +++ b/Task/Function-composition/Brat/function-composition.brat @@ -0,0 +1,7 @@ +compose = { f, g | { x | f g x } } + +#Test +add1 = { x | x + 1 } +double = { x | x * 2 } +b = compose(->double ->add1) +p b 1 #should print 4 diff --git a/Task/Function-composition/C++/function-composition-1.cpp b/Task/Function-composition/C++/function-composition-1.cpp new file mode 100644 index 0000000000..03598efb99 --- /dev/null +++ b/Task/Function-composition/C++/function-composition-1.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +// functor class to be returned by compose function +template +class compose_functor : + public std::unary_function +{ +protected: + Fun1 f; + Fun2 g; + +public: + compose_functor(const Fun1& _f, const Fun2& _g) + : f(_f), g(_g) { } + + typename Fun1::result_type + operator()(const typename Fun2::argument_type& x) const + { return f(g(x)); } +}; + +// we wrap it in a function so the compiler infers the template arguments +// whereas if we used the class directly we would have to specify them explicitly +template +inline compose_functor +compose(const Fun1& f, const Fun2& g) +{ return compose_functor(f, g); } + +int main() { + std::cout << compose(std::ptr_fun(::sin), std::ptr_fun(::asin))(0.5) << std::endl; + + return 0; +} diff --git a/Task/Function-composition/C++/function-composition-2.cpp b/Task/Function-composition/C++/function-composition-2.cpp new file mode 100644 index 0000000000..3e3e86ace1 --- /dev/null +++ b/Task/Function-composition/C++/function-composition-2.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +template +std::function compose(std::function f, std::function g) { + return [f,g](A x) { return f(g(x)); }; +} + +int main() { + std::function f = sin; + std::function g = asin; + std::cout << compose(f, g)(0.5) << std::endl; + + return 0; +} diff --git a/Task/Function-composition/C++/function-composition-3.cpp b/Task/Function-composition/C++/function-composition-3.cpp new file mode 100644 index 0000000000..840f3b493b --- /dev/null +++ b/Task/Function-composition/C++/function-composition-3.cpp @@ -0,0 +1,9 @@ +#include +#include +#include + +int main() { + std::cout << __gnu_cxx::compose1(std::ptr_fun(::sin), std::ptr_fun(::asin))(0.5) << std::endl; + + return 0; +} diff --git a/Task/Function-composition/C/function-composition.c b/Task/Function-composition/C/function-composition.c new file mode 100644 index 0000000000..bf9bd73497 --- /dev/null +++ b/Task/Function-composition/C/function-composition.c @@ -0,0 +1,64 @@ +#include + +/* generic interface for functors from double to double */ +typedef struct double_to_double { + double (*fn)(struct double_to_double *, double); +} double_to_double; + +#define CALL(f, x) f->fn(f, x) + + +/* functor returned by compose */ +typedef struct compose_functor { + double (*fn)(struct compose_functor *, double); + double_to_double *f; + double_to_double *g; +} compose_functor; +/* function to be used in "fn" in preceding functor */ +double compose_call(compose_functor *this, double x) { + return CALL(this->f, CALL(this->g, x)); +} +/* returns functor that is the composition of functors + f & g. caller is responsible for deallocating memory */ +double_to_double *compose(double_to_double *f, + double_to_double *g) { + compose_functor *result = malloc(sizeof(compose_functor)); + result->fn = &compose_call; + result->f = f; + result->g = g; + return (double_to_double *)result; +} + + + +#include + +/* we can make functors for sin and asin by using + the following as "fn" in a functor */ +double sin_call(double_to_double *this, double x) { + return sin(x); +} +double asin_call(double_to_double *this, double x) { + return asin(x); +} + + + +#include + +int main() { + double_to_double *my_sin = malloc(sizeof(double_to_double)); + my_sin->fn = &sin_call; + double_to_double *my_asin = malloc(sizeof(double_to_double)); + my_asin->fn = &asin_call; + + double_to_double *sin_asin = compose(my_sin, my_asin); + + printf("%f\n", CALL(sin_asin, 0.5)); /* prints "0.500000" */ + + free(sin_asin); + free(my_sin); + free(my_asin); + + return 0; +} diff --git a/Task/Function-composition/Clojure/function-composition.clj b/Task/Function-composition/Clojure/function-composition.clj new file mode 100644 index 0000000000..fab52c6a57 --- /dev/null +++ b/Task/Function-composition/Clojure/function-composition.clj @@ -0,0 +1,7 @@ +(defn compose [f g] + (fn [x] + (f (g x)))) + +; Example +(def inc2 (compose inc inc)) +(println (inc2 5)) ; prints 7 diff --git a/Task/Function-composition/Common-Lisp/function-composition-1.lisp b/Task/Function-composition/Common-Lisp/function-composition-1.lisp new file mode 100644 index 0000000000..2baf7ea8b6 --- /dev/null +++ b/Task/Function-composition/Common-Lisp/function-composition-1.lisp @@ -0,0 +1 @@ +(defun compose (f g) (lambda (x) (funcall f (funcall g x)))) diff --git a/Task/Function-composition/Common-Lisp/function-composition-2.lisp b/Task/Function-composition/Common-Lisp/function-composition-2.lisp new file mode 100644 index 0000000000..17f62f41a6 --- /dev/null +++ b/Task/Function-composition/Common-Lisp/function-composition-2.lisp @@ -0,0 +1,5 @@ +>(defun compose (f g) (lambda (x) (funcall f (funcall g x)))) +COMPOSE +>(let ((sin-asin (compose #'sin #'asin)))) + (funcall sin-asin 0.5)) +0.5 diff --git a/Task/Function-composition/Common-Lisp/function-composition-3.lisp b/Task/Function-composition/Common-Lisp/function-composition-3.lisp new file mode 100644 index 0000000000..c36764ef6a --- /dev/null +++ b/Task/Function-composition/Common-Lisp/function-composition-3.lisp @@ -0,0 +1,2 @@ +(defun compose (f g) + (eval `(lambda (x) (funcall ',f (funcall ',g x)))) diff --git a/Task/Function-composition/Common-Lisp/function-composition-4.lisp b/Task/Function-composition/Common-Lisp/function-composition-4.lisp new file mode 100644 index 0000000000..fb4ff22804 --- /dev/null +++ b/Task/Function-composition/Common-Lisp/function-composition-4.lisp @@ -0,0 +1,6 @@ +CL-USER> (defmacro compose (fn-name &rest args) + (labels ((rec1 (args) + (if (= (length args) 1) + `(funcall ,@args x) + `(funcall ,(first args) ,(rec1 (rest args)))))) + `(defun ,fn-name (x) ,(rec1 args)))) diff --git a/Task/Function-composition/D/function-composition.d b/Task/Function-composition/D/function-composition.d new file mode 100644 index 0000000000..d8b11597dd --- /dev/null +++ b/Task/Function-composition/D/function-composition.d @@ -0,0 +1,11 @@ +import std.stdio; + +T delegate(S) compose(T, U, S)(in T delegate(U) f, + in U delegate(S) g) { + return s => f(g(s)); +} + +void main() { + writeln(compose((int x) => x + 15, (int x) => x ^^ 2)(10)); + writeln(compose((int x) => x ^^ 2, (int x) => x + 15)(10)); +} diff --git a/Task/Function-composition/Delphi/function-composition.delphi b/Task/Function-composition/Delphi/function-composition.delphi new file mode 100644 index 0000000000..a5ac841c08 --- /dev/null +++ b/Task/Function-composition/Delphi/function-composition.delphi @@ -0,0 +1,36 @@ +program AnonCompose; + +{$APPTYPE CONSOLE} + +type + TFunc = reference to function(Value: Integer): Integer; + +function Compose(F, G: TFunc): TFunc; +begin + Result:= function(Value: Integer): Integer + begin + Result:= F(G(Value)); + end +end; + +var + Func1, Func2, Func3: TFunc; + +begin + Func1:= + function(Value: Integer): Integer + begin + Result:= Value * 2; + end; + + Func2:= + function(Value: Integer): Integer + begin + Result:= Value * 3; + end; + + Func3:= Compose(Func1, Func2); + + Writeln(Func3(6)); // 36 = 6 * 3 * 2 + Readln; +end. diff --git a/Task/Function-composition/Dylan/function-composition.dylan b/Task/Function-composition/Dylan/function-composition.dylan new file mode 100644 index 0000000000..6d6637fbab --- /dev/null +++ b/Task/Function-composition/Dylan/function-composition.dylan @@ -0,0 +1,3 @@ +define method compose(f,g) + method(x) f(g(x)) end +end; diff --git a/Task/Function-composition/E/function-composition.e b/Task/Function-composition/E/function-composition.e new file mode 100644 index 0000000000..a439a6d479 --- /dev/null +++ b/Task/Function-composition/E/function-composition.e @@ -0,0 +1,3 @@ +def compose(f, g) { + return fn x { return f(g(x)) } +} diff --git a/Task/Function-composition/Ela/function-composition.ela b/Task/Function-composition/Ela/function-composition.ela new file mode 100644 index 0000000000..1325a8ecc0 --- /dev/null +++ b/Task/Function-composition/Ela/function-composition.ela @@ -0,0 +1 @@ +compose f g x = f (g x) diff --git a/Task/Function-composition/Erlang/function-composition-1.erl b/Task/Function-composition/Erlang/function-composition-1.erl new file mode 100644 index 0000000000..ec47d3660d --- /dev/null +++ b/Task/Function-composition/Erlang/function-composition-1.erl @@ -0,0 +1,7 @@ +-module(fn). +-export([compose/1, multicompose/2]). + +compose(F,G) -> fun(X) -> F(G(X)) end. + +multicompose(Fs) -> + lists:foldl(fun compose/2, fun(X) -> X end, Fs). diff --git a/Task/Function-composition/Erlang/function-composition-2.erl b/Task/Function-composition/Erlang/function-composition-2.erl new file mode 100644 index 0000000000..0abc150547 --- /dev/null +++ b/Task/Function-composition/Erlang/function-composition-2.erl @@ -0,0 +1,6 @@ +1> (fn:compose(fun math:sin/1, fun math:asin/1))(0.5). +0.5 +2> Sin_asin_plus1 = fn:multicompose([fun math:sin/1, fun math:asin/1, fun(X) -> X + 1 end]). +#Fun +82> Sin_asin_plus1(0.5). +1.5 diff --git a/Task/Function-composition/Factor/function-composition.factor b/Task/Function-composition/Factor/function-composition.factor new file mode 100644 index 0000000000..a6bba12313 --- /dev/null +++ b/Task/Function-composition/Factor/function-composition.factor @@ -0,0 +1,4 @@ +( scratchpad ) [ 2 * ] [ 1 + ] compose . +[ 2 * 1 + ] +( scratchpad ) 4 [ 2 * ] [ 1 + ] compose call . +9 diff --git a/Task/Function-composition/Fantom/function-composition.fantom b/Task/Function-composition/Fantom/function-composition.fantom new file mode 100644 index 0000000000..c2a1613f0f --- /dev/null +++ b/Task/Function-composition/Fantom/function-composition.fantom @@ -0,0 +1,15 @@ +class Compose +{ + static |Obj -> Obj| compose (|Obj -> Obj| fn1, |Obj -> Obj| fn2) + { + return |Obj x -> Obj| { fn2 (fn1 (x)) } + } + + public static Void main () + { + double := |Int x -> Int| { 2 * x } + |Int -> Int| quad := compose(double, double) + echo ("Double 3 = ${double(3)}") + echo ("Quadruple 3 = ${quad (3)}") + } +} diff --git a/Task/Function-composition/Forth/function-composition.fth b/Task/Function-composition/Forth/function-composition.fth new file mode 100644 index 0000000000..77fa8609e3 --- /dev/null +++ b/Task/Function-composition/Forth/function-composition.fth @@ -0,0 +1,9 @@ +: compose ( xt1 xt2 -- xt3 ) + >r >r :noname + r> compile, + r> compile, + postpone ; +; + +' 2* ' 1+ compose ( xt ) +3 swap execute . \ 7 diff --git a/Task/Function-composition/GAP/function-composition.gap b/Task/Function-composition/GAP/function-composition.gap new file mode 100644 index 0000000000..7ee68ea407 --- /dev/null +++ b/Task/Function-composition/GAP/function-composition.gap @@ -0,0 +1,7 @@ +Composition := function(f, g) + return x -> f(g(x)); +end; + +h := Composition(x -> x+1, x -> x*x); +h(5); +# 26 diff --git a/Task/Function-composition/Go/function-composition-1.go b/Task/Function-composition/Go/function-composition-1.go new file mode 100644 index 0000000000..c24155d313 --- /dev/null +++ b/Task/Function-composition/Go/function-composition-1.go @@ -0,0 +1,11 @@ +// Go doesn't have generics, but sometimes a type definition helps +// readability and maintainability. This example is written to +// the following function type, which uses float64. +type ffType func(float64) float64 + +// compose function requested by task +func compose(f, g ffType) ffType { + return func(x float64) float64 { + return f(g(x)) + } +} diff --git a/Task/Function-composition/Go/function-composition-2.go b/Task/Function-composition/Go/function-composition-2.go new file mode 100644 index 0000000000..2ab4150ed4 --- /dev/null +++ b/Task/Function-composition/Go/function-composition-2.go @@ -0,0 +1,17 @@ +package main + +import "math" +import "fmt" + +type ffType func(float64) float64 + +func compose(f, g ffType) ffType { + return func(x float64) float64 { + return f(g(x)) + } +} + +func main() { + sin_asin := compose(math.Sin, math.Asin) + fmt.Println(sin_asin(.5)) +} diff --git a/Task/Function-composition/Groovy/function-composition-1.groovy b/Task/Function-composition/Groovy/function-composition-1.groovy new file mode 100644 index 0000000000..f61dfba237 --- /dev/null +++ b/Task/Function-composition/Groovy/function-composition-1.groovy @@ -0,0 +1 @@ +def compose = { f, g -> { x -> f(g(x)) } } diff --git a/Task/Function-composition/Groovy/function-composition-2.groovy b/Task/Function-composition/Groovy/function-composition-2.groovy new file mode 100644 index 0000000000..f7b345aab1 --- /dev/null +++ b/Task/Function-composition/Groovy/function-composition-2.groovy @@ -0,0 +1,15 @@ +def sq = { it * it } +def plus1 = { it + 1 } +def minus1 = { it - 1 } + +def plus1sqd = compose(sq,plus1) +def sqminus1 = compose(minus1,sq) +def identity = compose(plus1,minus1) +def plus1sqdminus1 = compose(minus1,compose(sq,plus1)) +def identity2 = compose(Math.&sin,Math.&asin) + +println "(x+1)**2 = (0+1)**2 = " + plus1sqd(0) +println "x**2-1 = 20**2-1 = " + sqminus1(20) +println "(x+1)-1 = (12+1)-1 = " + identity(12) +println "(x+1)**2-1 = (3+1)**2-1 = " + plus1sqdminus1(3) +println "sin(asin(x)) = sin(asin(1)) = " + identity2(1) diff --git a/Task/Function-composition/Haskell/function-composition-1.hs b/Task/Function-composition/Haskell/function-composition-1.hs new file mode 100644 index 0000000000..1325a8ecc0 --- /dev/null +++ b/Task/Function-composition/Haskell/function-composition-1.hs @@ -0,0 +1 @@ +compose f g x = f (g x) diff --git a/Task/Function-composition/Haskell/function-composition-2.hs b/Task/Function-composition/Haskell/function-composition-2.hs new file mode 100644 index 0000000000..9f1c0fb929 --- /dev/null +++ b/Task/Function-composition/Haskell/function-composition-2.hs @@ -0,0 +1,4 @@ +Prelude> let compose f g x = f (g x) +Prelude> let sin_asin = compose sin asin +Prelude> sin_asin 0.5 +0.5 diff --git a/Task/Function-composition/Icon/function-composition-1.icon b/Task/Function-composition/Icon/function-composition-1.icon new file mode 100644 index 0000000000..c1327e10cc --- /dev/null +++ b/Task/Function-composition/Icon/function-composition-1.icon @@ -0,0 +1,2 @@ + x @ f # use this syntax in Icon instead of the Unicon f(x) to call co-expressions + every push(fL := [],!rfL) # use this instead of reverse(fL) as the Icon reverse applies only to strings diff --git a/Task/Function-composition/Icon/function-composition-2.icon b/Task/Function-composition/Icon/function-composition-2.icon new file mode 100644 index 0000000000..0f867f392e --- /dev/null +++ b/Task/Function-composition/Icon/function-composition-2.icon @@ -0,0 +1,31 @@ +procedure main(arglist) + h := compose(sqrt,abs) + k := compose(integer,"sqrt",ord) + m := compose("-",k) + every write(i := -2 to 2, " h=(sqrt,abs)-> ", h(i)) + every write(c := !"1@Q", " k=(integer,\"sqrt\",ord)-> ", k(c)) + write(c := "1"," m=(\"-\",k) -> ",m(c)) +end + +invocable all # permit string invocations + +procedure compose(fL[]) #: compose(f1,f2,...) returns the functional composition of f1,f2,... as a co-expression + local x,f,saveSource + + every case type(x := !fL) of { + "procedure"|"co-expression": &null # procedures and co-expressions are fine + "string" : if not proc(x,1) then runnerr(123,fL) # as are invocable strings (unary operators, and procedures) + default: runerr(123,fL) + } + + fL := reverse(fL) # reverse and isolate from mutable side-effects + cf := create { saveSource := &source # don't forget where we came from + repeat { + x := (x@saveSource)[1] # return result and resume here + saveSource := &source # ... + every f := !fL do x := f(x) # apply the list of 'functions' + } + } + return (@cf, cf) # 'prime' the co-expr before returning it + +end diff --git a/Task/Function-composition/J/function-composition-1.j b/Task/Function-composition/J/function-composition-1.j new file mode 100644 index 0000000000..acfe539152 --- /dev/null +++ b/Task/Function-composition/J/function-composition-1.j @@ -0,0 +1 @@ +compose =: @ diff --git a/Task/Function-composition/J/function-composition-2.j b/Task/Function-composition/J/function-composition-2.j new file mode 100644 index 0000000000..f36ea61b95 --- /dev/null +++ b/Task/Function-composition/J/function-composition-2.j @@ -0,0 +1 @@ +f compose g diff --git a/Task/Function-composition/J/function-composition-3.j b/Task/Function-composition/J/function-composition-3.j new file mode 100644 index 0000000000..87c39ee331 --- /dev/null +++ b/Task/Function-composition/J/function-composition-3.j @@ -0,0 +1,3 @@ +f=: >.@(1&o.)@%: +g=: 1&+@|@(2&o.) +h=: f@g diff --git a/Task/Function-composition/J/function-composition-4.j b/Task/Function-composition/J/function-composition-4.j new file mode 100644 index 0000000000..f36ad85339 --- /dev/null +++ b/Task/Function-composition/J/function-composition-4.j @@ -0,0 +1,2 @@ + (f, g, h) 1p1 +1 2 1 diff --git a/Task/Function-composition/Java/function-composition-1.java b/Task/Function-composition/Java/function-composition-1.java new file mode 100644 index 0000000000..1348d3dba2 --- /dev/null +++ b/Task/Function-composition/Java/function-composition-1.java @@ -0,0 +1,33 @@ +public class Compose { + + // Java doesn't have function type so we define an interface + // of function objects instead + public interface Fun { + B call(A x); + } + + public static Fun compose(final Fun f, final Fun g) { + return new Fun() { + public C call(A x) { + return f.call(g.call(x)); + } + }; + } + + public static void main(String[] args) { + Fun sin = new Fun() { + public Double call(Double x) { + return Math.sin(x); + } + }; + Fun asin = new Fun() { + public Double call(Double x) { + return Math.asin(x); + } + }; + + Fun sin_asin = compose(sin, asin); + + System.out.println(sin_asin.call(0.5)); // prints "0.5" + } +} diff --git a/Task/Function-composition/Java/function-composition-2.java b/Task/Function-composition/Java/function-composition-2.java new file mode 100644 index 0000000000..349e6a1858 --- /dev/null +++ b/Task/Function-composition/Java/function-composition-2.java @@ -0,0 +1,13 @@ +import java.util.function.Function; + +public class Compose { + public static Function compose(Function f, Function g) { + return x -> f.apply(g.apply(x)); + } + + public static void main(String[] args) { + Function sin_asin = compose(Math::sin, Math::asin); + + System.out.println(sin_asin.apply(0.5)); // prints "0.5" + } +} diff --git a/Task/Function-composition/JavaScript/function-composition-1.js b/Task/Function-composition/JavaScript/function-composition-1.js new file mode 100644 index 0000000000..d738b5d210 --- /dev/null +++ b/Task/Function-composition/JavaScript/function-composition-1.js @@ -0,0 +1,5 @@ +function compose(f, g) { + return function(x) { + return f(g(x)); + }; +} diff --git a/Task/Function-composition/JavaScript/function-composition-2.js b/Task/Function-composition/JavaScript/function-composition-2.js new file mode 100644 index 0000000000..9e51baf2be --- /dev/null +++ b/Task/Function-composition/JavaScript/function-composition-2.js @@ -0,0 +1,2 @@ +var id = compose(Math.sin, Math.asin); +print(id(0.5)); // 0.5 diff --git a/Task/Function-composition/Joy/function-composition.joy b/Task/Function-composition/Joy/function-composition.joy new file mode 100644 index 0000000000..e86a8f2184 --- /dev/null +++ b/Task/Function-composition/Joy/function-composition.joy @@ -0,0 +1 @@ +g f diff --git a/Task/Function-composition/K/function-composition-1.k b/Task/Function-composition/K/function-composition-1.k new file mode 100644 index 0000000000..ca1dd3329d --- /dev/null +++ b/Task/Function-composition/K/function-composition-1.k @@ -0,0 +1 @@ +compose: {x@y@z} diff --git a/Task/Function-composition/K/function-composition-2.k b/Task/Function-composition/K/function-composition-2.k new file mode 100644 index 0000000000..9cff3f65a0 --- /dev/null +++ b/Task/Function-composition/K/function-composition-2.k @@ -0,0 +1,3 @@ + sin_asin: compose[_sin;_asin] + sin_asin 0.5 +0.5 diff --git a/Task/Function-composition/LOLCODE/function-composition.lol b/Task/Function-composition/LOLCODE/function-composition.lol new file mode 100644 index 0000000000..a78dcb387c --- /dev/null +++ b/Task/Function-composition/LOLCODE/function-composition.lol @@ -0,0 +1,27 @@ +HAI 1.3 + +I HAS A fx, I HAS A gx + +HOW IZ I composin YR f AN YR g + fx R f, gx R g + HOW IZ I composed YR x + FOUND YR I IZ fx YR I IZ gx YR x MKAY MKAY + IF U SAY SO + FOUND YR composed +IF U SAY SO + +HOW IZ I incin YR num + FOUND YR SUM OF num AN 1 +IF U SAY SO + +HOW IZ I sqrin YR num + FOUND YR PRODUKT OF num AN num +IF U SAY SO + +I HAS A incsqrin ITZ I IZ composin YR incin AN YR sqrin MKAY +VISIBLE I IZ incsqrin YR 10 MKAY BTW, prints 101 + +I HAS A sqrincin ITZ I IZ composin YR sqrin AN YR incin MKAY +VISIBLE I IZ sqrincin YR 10 MKAY BTW, prints 121 + +KTHXBYE diff --git a/Task/Function-composition/Lua/function-composition.lua b/Task/Function-composition/Lua/function-composition.lua new file mode 100644 index 0000000000..46cf72a920 --- /dev/null +++ b/Task/Function-composition/Lua/function-composition.lua @@ -0,0 +1 @@ +function compose(f, g) return function(...) return f(g(...)) end end diff --git a/Task/Function-composition/Mathematica/function-composition-1.mathematica b/Task/Function-composition/Mathematica/function-composition-1.mathematica new file mode 100644 index 0000000000..b454e15057 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-1.mathematica @@ -0,0 +1,2 @@ +Composition[f, g][x] +Composition[f, g, h, i][x] diff --git a/Task/Function-composition/Mathematica/function-composition-2.mathematica b/Task/Function-composition/Mathematica/function-composition-2.mathematica new file mode 100644 index 0000000000..f5ec9dd0c9 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-2.mathematica @@ -0,0 +1,2 @@ +f[g[x]] +f[g[h[i[x]]]] diff --git a/Task/Function-composition/Mathematica/function-composition-3.mathematica b/Task/Function-composition/Mathematica/function-composition-3.mathematica new file mode 100644 index 0000000000..03b8d37a79 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-3.mathematica @@ -0,0 +1,2 @@ +compose[f_, g_][x_] := f[g[x]] +compose[Sin, Cos][r] diff --git a/Task/Function-composition/Mathematica/function-composition-4.mathematica b/Task/Function-composition/Mathematica/function-composition-4.mathematica new file mode 100644 index 0000000000..6f1e5464ea --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-4.mathematica @@ -0,0 +1 @@ +Sin[Cos[r]] diff --git a/Task/Function-composition/Mathematica/function-composition-5.mathematica b/Task/Function-composition/Mathematica/function-composition-5.mathematica new file mode 100644 index 0000000000..74047d495d --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-5.mathematica @@ -0,0 +1,3 @@ +Composition[f,g,h][x] +f@g@h@x +x//h//g//f diff --git a/Task/Function-composition/Mathematica/function-composition-6.mathematica b/Task/Function-composition/Mathematica/function-composition-6.mathematica new file mode 100644 index 0000000000..079261e848 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-6.mathematica @@ -0,0 +1 @@ +f[g[h[x]]] diff --git a/Task/Function-composition/Mathematica/function-composition-7.mathematica b/Task/Function-composition/Mathematica/function-composition-7.mathematica new file mode 100644 index 0000000000..0a17447419 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-7.mathematica @@ -0,0 +1,2 @@ +Composition[f, Identity, g] +Composition[f, InverseFunction[f], h][x] diff --git a/Task/Function-composition/Mathematica/function-composition-8.mathematica b/Task/Function-composition/Mathematica/function-composition-8.mathematica new file mode 100644 index 0000000000..4f922182c7 --- /dev/null +++ b/Task/Function-composition/Mathematica/function-composition-8.mathematica @@ -0,0 +1,2 @@ +f[g[x]] +h[x] diff --git a/Task/Function-composition/Maxima/function-composition.maxima b/Task/Function-composition/Maxima/function-composition.maxima new file mode 100644 index 0000000000..a052ccdf85 --- /dev/null +++ b/Task/Function-composition/Maxima/function-composition.maxima @@ -0,0 +1,8 @@ +/* built-in */ +load(to_poly_solver); + +compose_functions([sin, cos]); +/* lambda([%g0],sin(cos(%g0)))*/ + +/* An implementation, to show a use of buildq */ +compose(f, g) := buildq([f, g], lambda([x], f(g(x)))); diff --git a/Task/Function-composition/PHP/function-composition-1.php b/Task/Function-composition/PHP/function-composition-1.php new file mode 100644 index 0000000000..d29f1077e2 --- /dev/null +++ b/Task/Function-composition/PHP/function-composition-1.php @@ -0,0 +1,8 @@ + diff --git a/Task/Function-composition/PHP/function-composition-2.php b/Task/Function-composition/PHP/function-composition-2.php new file mode 100644 index 0000000000..c51239a900 --- /dev/null +++ b/Task/Function-composition/PHP/function-composition-2.php @@ -0,0 +1,8 @@ + diff --git a/Task/Function-composition/Perl/function-composition.pl b/Task/Function-composition/Perl/function-composition.pl new file mode 100644 index 0000000000..ad720e7704 --- /dev/null +++ b/Task/Function-composition/Perl/function-composition.pl @@ -0,0 +1,10 @@ +sub compose { + my ($f, $g) = @_; + + sub { + $f -> ($g -> (@_)) + }; +} + +use Math::Trig; +print compose(sub {sin $_[0]}, \&asin)->(0.5), "\n"; diff --git a/Task/Function-composition/PicoLisp/function-composition-1.l b/Task/Function-composition/PicoLisp/function-composition-1.l new file mode 100644 index 0000000000..12c8ac78cd --- /dev/null +++ b/Task/Function-composition/PicoLisp/function-composition-1.l @@ -0,0 +1,3 @@ +(de compose (F G) + (curry (F G) (X) + (F (G X)) ) ) diff --git a/Task/Function-composition/PicoLisp/function-composition-2.l b/Task/Function-composition/PicoLisp/function-composition-2.l new file mode 100644 index 0000000000..f39f1b77e9 --- /dev/null +++ b/Task/Function-composition/PicoLisp/function-composition-2.l @@ -0,0 +1,3 @@ +(def 'a (compose inc dec)) +(def 'b (compose 'inc 'dec)) +(def 'c (compose '((A) (inc A)) '((B) (dec B)))) diff --git a/Task/Function-composition/PicoLisp/function-composition-3.l b/Task/Function-composition/PicoLisp/function-composition-3.l new file mode 100644 index 0000000000..c4a5eb110a --- /dev/null +++ b/Task/Function-composition/PicoLisp/function-composition-3.l @@ -0,0 +1,8 @@ +: (a 7) +-> 7 + +: (b 7) +-> 7 + +: (c 7) +-> 7 diff --git a/Task/Function-composition/Prolog/function-composition.pro b/Task/Function-composition/Prolog/function-composition.pro new file mode 100644 index 0000000000..2eea24860f --- /dev/null +++ b/Task/Function-composition/Prolog/function-composition.pro @@ -0,0 +1,4 @@ +:- use_module(lambda). + +compose(F,G, FG) :- + FG = \X^Z^(call(G,X,Y), call(F,Y,Z)). diff --git a/Task/Function-composition/Python/function-composition-1.py b/Task/Function-composition/Python/function-composition-1.py new file mode 100644 index 0000000000..511c1a1b26 --- /dev/null +++ b/Task/Function-composition/Python/function-composition-1.py @@ -0,0 +1 @@ +compose = lambda f, g: lambda x: f( g(x) ) diff --git a/Task/Function-composition/Python/function-composition-2.py b/Task/Function-composition/Python/function-composition-2.py new file mode 100644 index 0000000000..f983ac7de1 --- /dev/null +++ b/Task/Function-composition/Python/function-composition-2.py @@ -0,0 +1,6 @@ +>>> compose = lambda f, g: lambda x: f( g(x) ) +>>> from math import sin, asin +>>> sin_asin = compose(sin, asin) +>>> sin_asin(0.5) +0.5 +>>> diff --git a/Task/Function-composition/R/function-composition.r b/Task/Function-composition/R/function-composition.r new file mode 100644 index 0000000000..056987d05e --- /dev/null +++ b/Task/Function-composition/R/function-composition.r @@ -0,0 +1,3 @@ +compose <- function(f,g) function(x) { f(g(x)) } +r <- compose(sin, cos) +print(r(.5)) diff --git a/Task/Function-composition/REXX/function-composition.rexx b/Task/Function-composition/REXX/function-composition.rexx new file mode 100644 index 0000000000..b6d9ef1667 --- /dev/null +++ b/Task/Function-composition/REXX/function-composition.rexx @@ -0,0 +1,2 @@ +compose: procedure; parse arg f,g,x; interpret 'return' f"(" g'(' x "))" +exit /*control never gets here, but this was added just in case.*/ diff --git a/Task/Function-composition/Racket/function-composition.rkt b/Task/Function-composition/Racket/function-composition.rkt new file mode 100644 index 0000000000..a980f09e30 --- /dev/null +++ b/Task/Function-composition/Racket/function-composition.rkt @@ -0,0 +1,2 @@ + (define (compose f g) + (lambda (x) (f (g x)))) diff --git a/Task/Function-composition/Ruby/function-composition.rb b/Task/Function-composition/Ruby/function-composition.rb new file mode 100644 index 0000000000..b9f58f62fe --- /dev/null +++ b/Task/Function-composition/Ruby/function-composition.rb @@ -0,0 +1,8 @@ +def compose(f,g) + lambda {|x| f[g[x]]} +end +s = compose(Math.method(:sin), Math.method(:cos)) +p s[0.5] # => 0.769196354841008 + +# verify +p Math.sin(Math.cos(0.5)) # => 0.769196354841008 diff --git a/Task/Function-composition/Scala/function-composition-1.scala b/Task/Function-composition/Scala/function-composition-1.scala new file mode 100644 index 0000000000..07d230b2c8 --- /dev/null +++ b/Task/Function-composition/Scala/function-composition-1.scala @@ -0,0 +1,4 @@ +def compose[A](f: A => A, g: A => A) = { x: A => f(g(x)) } + +def add1(x: Int) = x+1 +val add2 = compose(add1, add1) diff --git a/Task/Function-composition/Scala/function-composition-2.scala b/Task/Function-composition/Scala/function-composition-2.scala new file mode 100644 index 0000000000..c08f7dad2c --- /dev/null +++ b/Task/Function-composition/Scala/function-composition-2.scala @@ -0,0 +1,7 @@ +class Composable[A](f: A => A) { + def o (g: A => A) = compose(f, g) +} + +implicit def toComposable[A](f: A => A) = new Composable(f) + +val add3 = (add1 _) o add2 diff --git a/Task/Function-composition/Scheme/function-composition-1.ss b/Task/Function-composition/Scheme/function-composition-1.ss new file mode 100644 index 0000000000..df40ceb80b --- /dev/null +++ b/Task/Function-composition/Scheme/function-composition-1.ss @@ -0,0 +1,5 @@ +(define (compose f g) (lambda (x) (f (g x)))) + +;; or: + +(define ((compose f g) x) (f (g x))) diff --git a/Task/Function-composition/Scheme/function-composition-2.ss b/Task/Function-composition/Scheme/function-composition-2.ss new file mode 100644 index 0000000000..b5a9592782 --- /dev/null +++ b/Task/Function-composition/Scheme/function-composition-2.ss @@ -0,0 +1,2 @@ +(display ((compose sin asin) 0.5)) +(newline) diff --git a/Task/Function-composition/Scheme/function-composition-3.ss b/Task/Function-composition/Scheme/function-composition-3.ss new file mode 100644 index 0000000000..2eb3c4fe4e --- /dev/null +++ b/Task/Function-composition/Scheme/function-composition-3.ss @@ -0,0 +1 @@ +0.5 diff --git a/Task/Function-composition/Smalltalk/function-composition.st b/Task/Function-composition/Smalltalk/function-composition.st new file mode 100644 index 0000000000..bdb60abd43 --- /dev/null +++ b/Task/Function-composition/Smalltalk/function-composition.st @@ -0,0 +1,6 @@ +| composer fg | +composer := [ :f :g | [ :x | f value: (g value: x) ] ]. +fg := composer value: [ :x | x + 1 ] + value: [ :x | x * x ]. + +(fg value:3) displayNl. diff --git a/Task/Function-composition/Tcl/function-composition.tcl b/Task/Function-composition/Tcl/function-composition.tcl new file mode 100644 index 0000000000..47cf1c3e52 --- /dev/null +++ b/Task/Function-composition/Tcl/function-composition.tcl @@ -0,0 +1,10 @@ +package require Tcl 8.5 +namespace path {::tcl::mathfunc} + +proc compose {f g} { + list apply [list {f g x} {{*}$f [{*}$g $x]}] $f $g] +} + +set sin_asin [compose sin asin] +{*}$sin_asin 0.5 ;# ==> 0.5 +{*}[compose abs int] -3.14 ;# ==> 3 diff --git a/Task/Function-definition/0DESCRIPTION b/Task/Function-definition/0DESCRIPTION new file mode 100644 index 0000000000..4536c60b3f --- /dev/null +++ b/Task/Function-definition/0DESCRIPTION @@ -0,0 +1,6 @@ +A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. + +Write a definition of a function called "multiply" that takes two arguments and returns their product. +(Argument types should be chosen so as not to distract from showing how functions are created and values returned). + +See also:[[Function prototype]] diff --git a/Task/Function-definition/1META.yaml b/Task/Function-definition/1META.yaml new file mode 100644 index 0000000000..e316a9ad81 --- /dev/null +++ b/Task/Function-definition/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Functions and subroutines +note: Basic language learning diff --git a/Task/Function-definition/ACL2/function-definition.acl2 b/Task/Function-definition/ACL2/function-definition.acl2 new file mode 100644 index 0000000000..d6f8ee8e5b --- /dev/null +++ b/Task/Function-definition/ACL2/function-definition.acl2 @@ -0,0 +1 @@ +(defun multiply (a b) (* a b)) diff --git a/Task/Function-definition/ALGOL-68/function-definition.alg b/Task/Function-definition/ALGOL-68/function-definition.alg new file mode 100644 index 0000000000..0d918793f5 --- /dev/null +++ b/Task/Function-definition/ALGOL-68/function-definition.alg @@ -0,0 +1,4 @@ +PROC multiply = ( LONG REAL a, b ) LONG REAL: +( + a * b +) diff --git a/Task/Function-definition/APL/function-definition.apl b/Task/Function-definition/APL/function-definition.apl new file mode 100644 index 0000000000..5123e2a85b --- /dev/null +++ b/Task/Function-definition/APL/function-definition.apl @@ -0,0 +1 @@ + multiply ← × diff --git a/Task/Function-definition/AWK/function-definition.awk b/Task/Function-definition/AWK/function-definition.awk new file mode 100644 index 0000000000..723e56810f --- /dev/null +++ b/Task/Function-definition/AWK/function-definition.awk @@ -0,0 +1,7 @@ +function multiply(a, b) +{ + return a*b +} +BEGIN { + print multiply(5, 6) +} diff --git a/Task/Function-definition/ActionScript/function-definition.as b/Task/Function-definition/ActionScript/function-definition.as new file mode 100644 index 0000000000..fccfcdcf50 --- /dev/null +++ b/Task/Function-definition/ActionScript/function-definition.as @@ -0,0 +1,3 @@ +function multiply(a:Number, b:Number):Number { + return a * b; +} diff --git a/Task/Function-definition/Ada/function-definition-1.ada b/Task/Function-definition/Ada/function-definition-1.ada new file mode 100644 index 0000000000..7b9a9915ba --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-1.ada @@ -0,0 +1 @@ +function Multiply (A, B : Float) return Float; diff --git a/Task/Function-definition/Ada/function-definition-2.ada b/Task/Function-definition/Ada/function-definition-2.ada new file mode 100644 index 0000000000..5322430102 --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-2.ada @@ -0,0 +1,4 @@ +function Multiply (A, B : Float) return Float is +begin + return A * B; +end Multiply; diff --git a/Task/Function-definition/Ada/function-definition-3.ada b/Task/Function-definition/Ada/function-definition-3.ada new file mode 100644 index 0000000000..557ff024e7 --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-3.ada @@ -0,0 +1 @@ +function Multiply(A, B: Float) return Float is (A * B); diff --git a/Task/Function-definition/Ada/function-definition-4.ada b/Task/Function-definition/Ada/function-definition-4.ada new file mode 100644 index 0000000000..6d7e9b17f1 --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-4.ada @@ -0,0 +1,3 @@ +generic + type Number is digits <>; +function Multiply (A, B : Number) return Number; diff --git a/Task/Function-definition/Ada/function-definition-5.ada b/Task/Function-definition/Ada/function-definition-5.ada new file mode 100644 index 0000000000..28d97ba934 --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-5.ada @@ -0,0 +1,4 @@ +function Multiply (A, B : Number) return Number is +begin + return A * B; +end Multiply; diff --git a/Task/Function-definition/Ada/function-definition-6.ada b/Task/Function-definition/Ada/function-definition-6.ada new file mode 100644 index 0000000000..1bff1e4b18 --- /dev/null +++ b/Task/Function-definition/Ada/function-definition-6.ada @@ -0,0 +1,7 @@ +with Multiply; +... +function Multiply_Integer is new Multiply(Number => Integer); +use Multiply_Integer; -- If you must + +type My_Integer is Range -100..100; +function Multiply_My_Integer is new Multiply(My_Integer); diff --git a/Task/Function-definition/AmigaE/function-definition.amiga b/Task/Function-definition/AmigaE/function-definition.amiga new file mode 100644 index 0000000000..61f330047c --- /dev/null +++ b/Task/Function-definition/AmigaE/function-definition.amiga @@ -0,0 +1,11 @@ +PROC my_molt(a,b) +-> other statements if needed... here they are not +ENDPROC a*b -> return value + +-> or simplier + +PROC molt(a,b) IS a*b + +PROC main() + WriteF('\d\n', my_molt(10,20)) +ENDPROC diff --git a/Task/Function-definition/AppleScript/function-definition.applescript b/Task/Function-definition/AppleScript/function-definition.applescript new file mode 100644 index 0000000000..143248de7f --- /dev/null +++ b/Task/Function-definition/AppleScript/function-definition.applescript @@ -0,0 +1,3 @@ +on multiply(a, b) + return a * b +end diff --git a/Task/Function-definition/Applesoft-BASIC/function-definition-1.bas b/Task/Function-definition/Applesoft-BASIC/function-definition-1.bas new file mode 100644 index 0000000000..779a663f7e --- /dev/null +++ b/Task/Function-definition/Applesoft-BASIC/function-definition-1.bas @@ -0,0 +1,2 @@ +10 DEF FN MULTIPLY(P) = P(P) * P(P+1) +20 P(1) = 611 : P(2) = 78 : PRINT FN MULTIPLY(1) diff --git a/Task/Function-definition/Applesoft-BASIC/function-definition-2.bas b/Task/Function-definition/Applesoft-BASIC/function-definition-2.bas new file mode 100644 index 0000000000..f3df87cf46 --- /dev/null +++ b/Task/Function-definition/Applesoft-BASIC/function-definition-2.bas @@ -0,0 +1 @@ +47658 diff --git a/Task/Function-definition/Argile/function-definition-1.argile b/Task/Function-definition/Argile/function-definition-1.argile new file mode 100644 index 0000000000..fdd3cf8fff --- /dev/null +++ b/Task/Function-definition/Argile/function-definition-1.argile @@ -0,0 +1,2 @@ +use std +.: multiply :. -> real {a * b} diff --git a/Task/Function-definition/Argile/function-definition-2.argile b/Task/Function-definition/Argile/function-definition-2.argile new file mode 100644 index 0000000000..89db343543 --- /dev/null +++ b/Task/Function-definition/Argile/function-definition-2.argile @@ -0,0 +1,2 @@ +use std +=: multiply [...] := -> real {Cgen a (@@1 (Cgen " * " b))} diff --git a/Task/Function-definition/AutoHotkey/function-definition.ahk b/Task/Function-definition/AutoHotkey/function-definition.ahk new file mode 100644 index 0000000000..73150dbcc0 --- /dev/null +++ b/Task/Function-definition/AutoHotkey/function-definition.ahk @@ -0,0 +1,5 @@ +MsgBox % multiply(10,2) + +multiply(multiplicand, multiplier) { + Return (multiplicand * multiplier) +} diff --git a/Task/Function-definition/AutoIt/function-definition.autoit b/Task/Function-definition/AutoIt/function-definition.autoit new file mode 100644 index 0000000000..8f7aa326ad --- /dev/null +++ b/Task/Function-definition/AutoIt/function-definition.autoit @@ -0,0 +1,7 @@ +#AutoIt Version: 3.2.10.0 +$I=11 +$J=12 +MsgBox(0,"Multiply", $I &" * "& $J &" = " & product($I,$J)) +Func product($a,$b) + Return $a * $b +EndFunc diff --git a/Task/Function-definition/BASIC/function-definition.bas b/Task/Function-definition/BASIC/function-definition.bas new file mode 100644 index 0000000000..bc37ff7dde --- /dev/null +++ b/Task/Function-definition/BASIC/function-definition.bas @@ -0,0 +1,5 @@ +DECLARE FUNCTION multiply% (a AS INTEGER, b AS INTEGER) + +FUNCTION multiply% (a AS INTEGER, b AS INTEGER) + multiply = a * b +END FUNCTION diff --git a/Task/Function-definition/BBC-BASIC/function-definition-1.bbc b/Task/Function-definition/BBC-BASIC/function-definition-1.bbc new file mode 100644 index 0000000000..66b5c1ffdc --- /dev/null +++ b/Task/Function-definition/BBC-BASIC/function-definition-1.bbc @@ -0,0 +1,4 @@ +PRINT FNmultiply(6,7) +END + +DEF FNmultiply(a,b) = a * b diff --git a/Task/Function-definition/BBC-BASIC/function-definition-2.bbc b/Task/Function-definition/BBC-BASIC/function-definition-2.bbc new file mode 100644 index 0000000000..e07d78ad5c --- /dev/null +++ b/Task/Function-definition/BBC-BASIC/function-definition-2.bbc @@ -0,0 +1,4 @@ +DEF FNmultiply(a,b) +LOCAL c +c = a * b += c diff --git a/Task/Function-definition/Batch-File/function-definition.bat b/Task/Function-definition/Batch-File/function-definition.bat new file mode 100644 index 0000000000..bf1998de29 --- /dev/null +++ b/Task/Function-definition/Batch-File/function-definition.bat @@ -0,0 +1,11 @@ +@ECHO OFF +SET /A result = 0 +CALL :multiply 2 3 +ECHO %result% +GOTO :eof + +:multiply + SET /A result = %1 * %2 + GOTO :eof + +:eof diff --git a/Task/Function-definition/Boo/function-definition.boo b/Task/Function-definition/Boo/function-definition.boo new file mode 100644 index 0000000000..3770c500ca --- /dev/null +++ b/Task/Function-definition/Boo/function-definition.boo @@ -0,0 +1,4 @@ +def multiply(x as int, y as int): + return x * y + +print multiply(3, 2) diff --git a/Task/Function-definition/Bracmat/function-definition.bracmat b/Task/Function-definition/Bracmat/function-definition.bracmat new file mode 100644 index 0000000000..573d3d6bb8 --- /dev/null +++ b/Task/Function-definition/Bracmat/function-definition.bracmat @@ -0,0 +1,2 @@ +multiply=a b.!arg:(?a.?b)&!a*!b; +out$multiply$(123456789.987654321); { writes 121932631112635269 to standard output } diff --git a/Task/Function-definition/Brat/function-definition.brat b/Task/Function-definition/Brat/function-definition.brat new file mode 100644 index 0000000000..9ce9978724 --- /dev/null +++ b/Task/Function-definition/Brat/function-definition.brat @@ -0,0 +1,3 @@ +multiply = { x, y | x * y } + +p multiply 3 14 #Prints 42 diff --git a/Task/Function-definition/C++/function-definition-1.cpp b/Task/Function-definition/C++/function-definition-1.cpp new file mode 100644 index 0000000000..588ca144c0 --- /dev/null +++ b/Task/Function-definition/C++/function-definition-1.cpp @@ -0,0 +1,4 @@ +inline double multiply(double a, double b) +{ + return a*b; +} diff --git a/Task/Function-definition/C++/function-definition-2.cpp b/Task/Function-definition/C++/function-definition-2.cpp new file mode 100644 index 0000000000..39b6e00b7e --- /dev/null +++ b/Task/Function-definition/C++/function-definition-2.cpp @@ -0,0 +1,5 @@ +template + Number multiply(Number a, Number b) +{ + return a*b; +} diff --git a/Task/Function-definition/C/function-definition-1.c b/Task/Function-definition/C/function-definition-1.c new file mode 100644 index 0000000000..913181688d --- /dev/null +++ b/Task/Function-definition/C/function-definition-1.c @@ -0,0 +1,4 @@ +double multiply(double a, double b) +{ + return a * b; +} diff --git a/Task/Function-definition/C/function-definition-2.c b/Task/Function-definition/C/function-definition-2.c new file mode 100644 index 0000000000..9c27bf2653 --- /dev/null +++ b/Task/Function-definition/C/function-definition-2.c @@ -0,0 +1 @@ +#define MULTIPLY(X, Y) ((X) * (Y)) diff --git a/Task/Function-definition/C/function-definition-3.c b/Task/Function-definition/C/function-definition-3.c new file mode 100644 index 0000000000..93bf9257d4 --- /dev/null +++ b/Task/Function-definition/C/function-definition-3.c @@ -0,0 +1 @@ +x = MULTIPLY(x + z, y); diff --git a/Task/Function-definition/C/function-definition-4.c b/Task/Function-definition/C/function-definition-4.c new file mode 100644 index 0000000000..edd4950558 --- /dev/null +++ b/Task/Function-definition/C/function-definition-4.c @@ -0,0 +1 @@ +x = ((x + z) * (y)); diff --git a/Task/Function-definition/COBOL/function-definition.cobol b/Task/Function-definition/COBOL/function-definition.cobol new file mode 100644 index 0000000000..01787f448e --- /dev/null +++ b/Task/Function-definition/COBOL/function-definition.cobol @@ -0,0 +1,29 @@ + * Multiply in COBOL + + IDENTIFICATION DIVISION. + PROGRAM-ID. myTest. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 x PIC 9(3) VALUE 3. + 01 y PIC 9(3) VALUE 2. + 01 z PIC 9(9). + PROCEDURE DIVISION. + CALL "myMultiply" USING + BY CONTENT x, BY CONTENT y, + BY REFERENCE z. + DISPLAY z. + STOP RUN. + END PROGRAM myTest. + + IDENTIFICATION DIVISION. + PROGRAM-ID. myMultiply. + DATA DIVISION. + WORKING-STORAGE SECTION. + LINKAGE SECTION. + 01 x PIC 9(3). + 01 y PIC 9(3). + 01 z PIC 9(9). + PROCEDURE DIVISION USING x, y, z. + MULTIPLY x BY y GIVING z. + EXIT PROGRAM. + END PROGRAM myMultiply. diff --git a/Task/Function-definition/Clay/function-definition.clay b/Task/Function-definition/Clay/function-definition.clay new file mode 100644 index 0000000000..cdd1ed603e --- /dev/null +++ b/Task/Function-definition/Clay/function-definition.clay @@ -0,0 +1 @@ +multiply(x,y) = x * y; diff --git a/Task/Function-definition/Clojure/function-definition-1.clj b/Task/Function-definition/Clojure/function-definition-1.clj new file mode 100644 index 0000000000..0533243044 --- /dev/null +++ b/Task/Function-definition/Clojure/function-definition-1.clj @@ -0,0 +1,4 @@ +(defn multiply [x y] + (* x y)) + +(multiply 4 5) diff --git a/Task/Function-definition/Clojure/function-definition-2.clj b/Task/Function-definition/Clojure/function-definition-2.clj new file mode 100644 index 0000000000..cd2a6629e5 --- /dev/null +++ b/Task/Function-definition/Clojure/function-definition-2.clj @@ -0,0 +1,8 @@ +(defn multiply + ([] 1) + ([x] x) + ([x y] (* x y)) + ([x y & more] + (reduce * (* x y) more))) + +(multiply 2 3 4 5) ; 120 diff --git a/Task/Function-definition/CoffeeScript/function-definition.coffee b/Task/Function-definition/CoffeeScript/function-definition.coffee new file mode 100644 index 0000000000..f66becf9fd --- /dev/null +++ b/Task/Function-definition/CoffeeScript/function-definition.coffee @@ -0,0 +1 @@ +multiply = (a, b) -> a * b diff --git a/Task/Function-definition/ColdFusion/function-definition.cfm b/Task/Function-definition/ColdFusion/function-definition.cfm new file mode 100644 index 0000000000..2dc4b3e36a --- /dev/null +++ b/Task/Function-definition/ColdFusion/function-definition.cfm @@ -0,0 +1,5 @@ + + + + + diff --git a/Task/Function-definition/Common-Lisp/function-definition-1.lisp b/Task/Function-definition/Common-Lisp/function-definition-1.lisp new file mode 100644 index 0000000000..3cc375b58d --- /dev/null +++ b/Task/Function-definition/Common-Lisp/function-definition-1.lisp @@ -0,0 +1,4 @@ +(defun multiply (a b) + (* a b)) + +(multiply 2 3) diff --git a/Task/Function-definition/Common-Lisp/function-definition-2.lisp b/Task/Function-definition/Common-Lisp/function-definition-2.lisp new file mode 100644 index 0000000000..7898a47309 --- /dev/null +++ b/Task/Function-definition/Common-Lisp/function-definition-2.lisp @@ -0,0 +1,4 @@ +(define-compiler-macro multiply (&whole expr a b) + (if (and (constantp a) (constantp b)) + (* (eval a) (eval b)) + expr)) ;; no macro recursion if we just return expr; the job is done! diff --git a/Task/Function-definition/Common-Lisp/function-definition-3.lisp b/Task/Function-definition/Common-Lisp/function-definition-3.lisp new file mode 100644 index 0000000000..a0ceaf5818 --- /dev/null +++ b/Task/Function-definition/Common-Lisp/function-definition-3.lisp @@ -0,0 +1 @@ +;;; terrific example coming diff --git a/Task/Function-definition/D/function-definition.d b/Task/Function-definition/D/function-definition.d new file mode 100644 index 0000000000..c540b0799c --- /dev/null +++ b/Task/Function-definition/D/function-definition.d @@ -0,0 +1,26 @@ +// A function: +int multiply1(int a, int b) { + return a * b; +} + +// Functions like "multiply1" can be evaluated at compile time if +// they are called where a compile-time constant result is asked for: +enum result = multiply1(2, 3); // Evaluated at compile time. +int[multiply1(2, 4)] array; // Evaluated at compile time. + +// A templated function: +T multiply2(T)(T a, T b) { + return a * b; +} + +// Compile-time multiplication can also be done using templates: +template multiply3(int a, int b) { + enum multiply3 = a * b; +} + +pragma(msg, multiply3!(2, 3)); // Prints "6" during compilation. + +void main() { + import std.stdio; + writeln("2 * 3 = ", result); +} diff --git a/Task/Function-definition/DWScript/function-definition.dwscript b/Task/Function-definition/DWScript/function-definition.dwscript new file mode 100644 index 0000000000..cb5f75b904 --- /dev/null +++ b/Task/Function-definition/DWScript/function-definition.dwscript @@ -0,0 +1,4 @@ +function Multiply(a, b : Integer) : Integer; +begin + Result := a * b; +end; diff --git a/Task/Function-definition/Delphi/function-definition.delphi b/Task/Function-definition/Delphi/function-definition.delphi new file mode 100644 index 0000000000..90baf44d11 --- /dev/null +++ b/Task/Function-definition/Delphi/function-definition.delphi @@ -0,0 +1,4 @@ +function Multiply(a, b: Integer): Integer; +begin + Result := a * b; +end; diff --git a/Task/Function-definition/E/function-definition-1.e b/Task/Function-definition/E/function-definition-1.e new file mode 100644 index 0000000000..5526786106 --- /dev/null +++ b/Task/Function-definition/E/function-definition-1.e @@ -0,0 +1,3 @@ +def multiply(a, b) { + return a * b +} diff --git a/Task/Function-definition/E/function-definition-2.e b/Task/Function-definition/E/function-definition-2.e new file mode 100644 index 0000000000..ce5c771099 --- /dev/null +++ b/Task/Function-definition/E/function-definition-2.e @@ -0,0 +1 @@ +def multiply := fn a, b { a * b } diff --git a/Task/Function-definition/Efene/function-definition.efene b/Task/Function-definition/Efene/function-definition.efene new file mode 100644 index 0000000000..7731cc8f14 --- /dev/null +++ b/Task/Function-definition/Efene/function-definition.efene @@ -0,0 +1,8 @@ +multiply = fn (A, B) { + A * B +} + +@public +run = fn () { + io.format("~p~n", [multiply(2, 5)]) +} diff --git a/Task/Function-definition/Ela/function-definition-1.ela b/Task/Function-definition/Ela/function-definition-1.ela new file mode 100644 index 0000000000..db2f0131d9 --- /dev/null +++ b/Task/Function-definition/Ela/function-definition-1.ela @@ -0,0 +1 @@ +multiply x y = x * y diff --git a/Task/Function-definition/Ela/function-definition-2.ela b/Task/Function-definition/Ela/function-definition-2.ela new file mode 100644 index 0000000000..e6136121e4 --- /dev/null +++ b/Task/Function-definition/Ela/function-definition-2.ela @@ -0,0 +1 @@ +\x y -> x * y diff --git a/Task/Function-definition/Erlang/function-definition.erl b/Task/Function-definition/Erlang/function-definition.erl new file mode 100644 index 0000000000..d4807b20de --- /dev/null +++ b/Task/Function-definition/Erlang/function-definition.erl @@ -0,0 +1 @@ +multiply(A,B) -> A*B. diff --git a/Task/Function-definition/Euphoria/function-definition-1.euphoria b/Task/Function-definition/Euphoria/function-definition-1.euphoria new file mode 100644 index 0000000000..dbefbdbb00 --- /dev/null +++ b/Task/Function-definition/Euphoria/function-definition-1.euphoria @@ -0,0 +1,3 @@ +function multiply( atom a, atom b ) + return a * b +end function diff --git a/Task/Function-definition/Euphoria/function-definition-2.euphoria b/Task/Function-definition/Euphoria/function-definition-2.euphoria new file mode 100644 index 0000000000..c58bdd4f0e --- /dev/null +++ b/Task/Function-definition/Euphoria/function-definition-2.euphoria @@ -0,0 +1,12 @@ +function multiply( object a, object b ) + return a * b +end function + +sequence a = {1,2,3,4} +sequence b = {5,6,7,8} + +? multiply( 9, 9 ) +? multiply( 3.14159, 3.14159 ) +? multiply( a, b ) +? multiply( a, 7 ) +? multiply( 10.39564, b ) diff --git a/Task/Function-definition/FALSE/function-definition.false b/Task/Function-definition/FALSE/function-definition.false new file mode 100644 index 0000000000..dde46991c4 --- /dev/null +++ b/Task/Function-definition/FALSE/function-definition.false @@ -0,0 +1,3 @@ +[*] {anonymous function to multiply the top two items on the stack} +m: {binding the function to one of the 26 available symbol names} +2 3m;! {executing the function, yielding 6} diff --git a/Task/Function-definition/Factor/function-definition.factor b/Task/Function-definition/Factor/function-definition.factor new file mode 100644 index 0000000000..3b040c5e38 --- /dev/null +++ b/Task/Function-definition/Factor/function-definition.factor @@ -0,0 +1 @@ +: multiply ( a b -- a*b ) * ; diff --git a/Task/Function-definition/Falcon/function-definition.falcon b/Task/Function-definition/Falcon/function-definition.falcon new file mode 100644 index 0000000000..d635445b0d --- /dev/null +++ b/Task/Function-definition/Falcon/function-definition.falcon @@ -0,0 +1,3 @@ +function sayHiTo( name ) + > "Hi ", name +end diff --git a/Task/Function-definition/Fantom/function-definition.fantom b/Task/Function-definition/Fantom/function-definition.fantom new file mode 100644 index 0000000000..1dca32e47a --- /dev/null +++ b/Task/Function-definition/Fantom/function-definition.fantom @@ -0,0 +1,8 @@ +class FunctionDefinition +{ + public static Void main () + { + multiply := |Int a, Int b -> Int| { a * b } + echo ("Multiply 2 and 4: ${multiply(2, 4)}") + } +} diff --git a/Task/Function-definition/Fexl/function-definition-1.fexl b/Task/Function-definition/Fexl/function-definition-1.fexl new file mode 100644 index 0000000000..4fe0dec939 --- /dev/null +++ b/Task/Function-definition/Fexl/function-definition-1.fexl @@ -0,0 +1 @@ +\multiply=(\x\y * x y) diff --git a/Task/Function-definition/Fexl/function-definition-2.fexl b/Task/Function-definition/Fexl/function-definition-2.fexl new file mode 100644 index 0000000000..8744e6e82e --- /dev/null +++ b/Task/Function-definition/Fexl/function-definition-2.fexl @@ -0,0 +1 @@ +\multiply=* diff --git a/Task/Function-definition/Forth/function-definition.fth b/Task/Function-definition/Forth/function-definition.fth new file mode 100644 index 0000000000..f4eff8c6f5 --- /dev/null +++ b/Task/Function-definition/Forth/function-definition.fth @@ -0,0 +1,2 @@ +: fmultiply ( F: a b -- F: c ) F* ; +: multiply ( a b -- c ) * ; diff --git a/Task/Function-definition/Fortran/function-definition-1.f b/Task/Function-definition/Fortran/function-definition-1.f new file mode 100644 index 0000000000..6530c5319a --- /dev/null +++ b/Task/Function-definition/Fortran/function-definition-1.f @@ -0,0 +1,4 @@ +FUNCTION MULTIPLY(X,Y) +REAL MULTIPLY, X, Y +MULTIPLY = X * Y +END diff --git a/Task/Function-definition/Fortran/function-definition-2.f b/Task/Function-definition/Fortran/function-definition-2.f new file mode 100644 index 0000000000..7a09110cd2 --- /dev/null +++ b/Task/Function-definition/Fortran/function-definition-2.f @@ -0,0 +1,8 @@ +module elemFunc +contains + elemental function multiply(x, y) + real, intent(in) :: x, y + real :: multiply + multiply = x * y + end function multiply +end module elemFunc diff --git a/Task/Function-definition/Fortran/function-definition-3.f b/Task/Function-definition/Fortran/function-definition-3.f new file mode 100644 index 0000000000..2732739225 --- /dev/null +++ b/Task/Function-definition/Fortran/function-definition-3.f @@ -0,0 +1,10 @@ +program funcDemo + use elemFunc + + real :: a = 20.0, b = 30.0, c + real, dimension(5) :: x = (/ 1.0, 2.0, 3.0, 4.0, 5.0 /), y = (/ 32.0, 16.0, 8.0, 4.0, 2.0 /), z + + c = multiply(a,b) ! works with either function definition above + + z = multiply(x,y) ! element-wise invocation only works with elemental function +end program funcDemo diff --git a/Task/Function-definition/Fortran/function-definition-4.f b/Task/Function-definition/Fortran/function-definition-4.f new file mode 100644 index 0000000000..8e6692f2ba --- /dev/null +++ b/Task/Function-definition/Fortran/function-definition-4.f @@ -0,0 +1,2 @@ +c = multiply(y=b, x=a) ! the same as multiply(a, b) +z = multiply(y=x, x=y) ! the same as multiply(y, x) diff --git a/Task/Function-definition/Fortran/function-definition-5.f b/Task/Function-definition/Fortran/function-definition-5.f new file mode 100644 index 0000000000..95fcb20391 --- /dev/null +++ b/Task/Function-definition/Fortran/function-definition-5.f @@ -0,0 +1,8 @@ +module elemFunc +contains + elemental function multiply(x, y) result(z) + real, intent(in) :: x, y + real :: z + z = x * y + end function multiply +end module elemFunc diff --git a/Task/Function-definition/Frink/function-definition.frink b/Task/Function-definition/Frink/function-definition.frink new file mode 100644 index 0000000000..be54360f8d --- /dev/null +++ b/Task/Function-definition/Frink/function-definition.frink @@ -0,0 +1 @@ +multiply[x,y] := x*y diff --git a/Task/Function-definition/GML/function-definition.gml b/Task/Function-definition/GML/function-definition.gml new file mode 100644 index 0000000000..455754a714 --- /dev/null +++ b/Task/Function-definition/GML/function-definition.gml @@ -0,0 +1,4 @@ +#define multiply +a = argument0 +b = argument1 +return(a * b) diff --git a/Task/Function-definition/Go/function-definition-1.go b/Task/Function-definition/Go/function-definition-1.go new file mode 100644 index 0000000000..91eeb60b3d --- /dev/null +++ b/Task/Function-definition/Go/function-definition-1.go @@ -0,0 +1,3 @@ +func multiply(a, b float64) float64 { + return a * b +} diff --git a/Task/Function-definition/Go/function-definition-2.go b/Task/Function-definition/Go/function-definition-2.go new file mode 100644 index 0000000000..b644cc7b32 --- /dev/null +++ b/Task/Function-definition/Go/function-definition-2.go @@ -0,0 +1,4 @@ +func multiply(a, b float64) (z float64) { + z = a * b + return +} diff --git a/Task/Function-definition/Golfscript/function-definition.golf b/Task/Function-definition/Golfscript/function-definition.golf new file mode 100644 index 0000000000..b2067e300e --- /dev/null +++ b/Task/Function-definition/Golfscript/function-definition.golf @@ -0,0 +1 @@ +{*}:multiply; diff --git a/Task/Function-definition/Groovy/function-definition-1.groovy b/Task/Function-definition/Groovy/function-definition-1.groovy new file mode 100644 index 0000000000..eb21afe57d --- /dev/null +++ b/Task/Function-definition/Groovy/function-definition-1.groovy @@ -0,0 +1 @@ +def multiply = { x, y -> x * y } diff --git a/Task/Function-definition/Groovy/function-definition-2.groovy b/Task/Function-definition/Groovy/function-definition-2.groovy new file mode 100644 index 0000000000..46799a47db --- /dev/null +++ b/Task/Function-definition/Groovy/function-definition-2.groovy @@ -0,0 +1 @@ +println "x * y = 20 * 50 = ${multiply 20, 50}" diff --git a/Task/Function-definition/Haskell/function-definition-1.hs b/Task/Function-definition/Haskell/function-definition-1.hs new file mode 100644 index 0000000000..fb17becbdc --- /dev/null +++ b/Task/Function-definition/Haskell/function-definition-1.hs @@ -0,0 +1 @@ +multiply = (*) diff --git a/Task/Function-definition/Haskell/function-definition-2.hs b/Task/Function-definition/Haskell/function-definition-2.hs new file mode 100644 index 0000000000..5f2bfd8475 --- /dev/null +++ b/Task/Function-definition/Haskell/function-definition-2.hs @@ -0,0 +1 @@ +multiply = \ x y -> x*y diff --git a/Task/Function-definition/Haxe/function-definition.haxe b/Task/Function-definition/Haxe/function-definition.haxe new file mode 100644 index 0000000000..b52441485b --- /dev/null +++ b/Task/Function-definition/Haxe/function-definition.haxe @@ -0,0 +1,3 @@ +function multiply(x:Float, y:Float):Float{ + return x * y; +} diff --git a/Task/Function-definition/HicEst/function-definition.hicest b/Task/Function-definition/HicEst/function-definition.hicest new file mode 100644 index 0000000000..2db2131a54 --- /dev/null +++ b/Task/Function-definition/HicEst/function-definition.hicest @@ -0,0 +1,3 @@ +FUNCTION multiply(a, b) + multiply = a * b +END diff --git a/Task/Function-definition/IDL/function-definition-1.idl b/Task/Function-definition/IDL/function-definition-1.idl new file mode 100644 index 0000000000..6922d732fa --- /dev/null +++ b/Task/Function-definition/IDL/function-definition-1.idl @@ -0,0 +1,3 @@ +function multiply ,a,b + return, a* b +end diff --git a/Task/Function-definition/IDL/function-definition-2.idl b/Task/Function-definition/IDL/function-definition-2.idl new file mode 100644 index 0000000000..f10f86267d --- /dev/null +++ b/Task/Function-definition/IDL/function-definition-2.idl @@ -0,0 +1,3 @@ +function multiply ,a,b + return, product([a, b]) +end diff --git a/Task/Function-definition/IDL/function-definition-3.idl b/Task/Function-definition/IDL/function-definition-3.idl new file mode 100644 index 0000000000..61097ca879 --- /dev/null +++ b/Task/Function-definition/IDL/function-definition-3.idl @@ -0,0 +1,3 @@ +function multiply ,a,b + return, a # b +end diff --git a/Task/Function-definition/Icon/function-definition.icon b/Task/Function-definition/Icon/function-definition.icon new file mode 100644 index 0000000000..30b6691a16 --- /dev/null +++ b/Task/Function-definition/Icon/function-definition.icon @@ -0,0 +1,3 @@ +procedure multiply(a,b) +return a * b +end diff --git a/Task/Function-definition/Inform-6/function-definition.inf b/Task/Function-definition/Inform-6/function-definition.inf new file mode 100644 index 0000000000..3d2c117a76 --- /dev/null +++ b/Task/Function-definition/Inform-6/function-definition.inf @@ -0,0 +1,3 @@ +[ multiply a b; + return a * b; +]; diff --git a/Task/Function-definition/Inform-7/function-definition.inf b/Task/Function-definition/Inform-7/function-definition.inf new file mode 100644 index 0000000000..7ca554e519 --- /dev/null +++ b/Task/Function-definition/Inform-7/function-definition.inf @@ -0,0 +1,2 @@ +To decide which number is (A - number) multiplied by (B - number): + decide on A * B. diff --git a/Task/Function-definition/Io/function-definition.io b/Task/Function-definition/Io/function-definition.io new file mode 100644 index 0000000000..3944636c42 --- /dev/null +++ b/Task/Function-definition/Io/function-definition.io @@ -0,0 +1 @@ +multiply := method(a,b,a*b) diff --git a/Task/Function-definition/J/function-definition-1.j b/Task/Function-definition/J/function-definition-1.j new file mode 100644 index 0000000000..aa6e69d91b --- /dev/null +++ b/Task/Function-definition/J/function-definition-1.j @@ -0,0 +1 @@ +multiply=: * diff --git a/Task/Function-definition/J/function-definition-2.j b/Task/Function-definition/J/function-definition-2.j new file mode 100644 index 0000000000..95dace35b7 --- /dev/null +++ b/Task/Function-definition/J/function-definition-2.j @@ -0,0 +1,3 @@ +multiply=: dyad define + x * y +) diff --git a/Task/Function-definition/Java/function-definition.java b/Task/Function-definition/Java/function-definition.java new file mode 100644 index 0000000000..78966004b1 --- /dev/null +++ b/Task/Function-definition/Java/function-definition.java @@ -0,0 +1,5 @@ +public class Math +{ + public static int multiply( int a, int b) { return a*b; } + public static double multiply(double a, double b) { return a*b; } +} diff --git a/Task/Function-definition/JavaScript/function-definition-1.js b/Task/Function-definition/JavaScript/function-definition-1.js new file mode 100644 index 0000000000..857d0eafeb --- /dev/null +++ b/Task/Function-definition/JavaScript/function-definition-1.js @@ -0,0 +1 @@ +function multiply(a,b) { return a*b } diff --git a/Task/Function-definition/JavaScript/function-definition-2.js b/Task/Function-definition/JavaScript/function-definition-2.js new file mode 100644 index 0000000000..d2f1f34400 --- /dev/null +++ b/Task/Function-definition/JavaScript/function-definition-2.js @@ -0,0 +1,3 @@ +var multiply = function (a, b) { + return a * b; +}; diff --git a/Task/Function-definition/Joy/function-definition.joy b/Task/Function-definition/Joy/function-definition.joy new file mode 100644 index 0000000000..c5417943c9 --- /dev/null +++ b/Task/Function-definition/Joy/function-definition.joy @@ -0,0 +1 @@ +DEFINE multiply == * . diff --git a/Task/Function-definition/Julia/function-definition.julia b/Task/Function-definition/Julia/function-definition.julia new file mode 100644 index 0000000000..21a2c8f154 --- /dev/null +++ b/Task/Function-definition/Julia/function-definition.julia @@ -0,0 +1,3 @@ +function multiply(a::Number,b::Number) + return a*b +end diff --git a/Task/Function-definition/Kaya/function-definition.kaya b/Task/Function-definition/Kaya/function-definition.kaya new file mode 100644 index 0000000000..438dae4b16 --- /dev/null +++ b/Task/Function-definition/Kaya/function-definition.kaya @@ -0,0 +1,11 @@ +program test; + +// A function definition in Kaya: +Int multiply(Int a, Int b) { + return a * b; +} + +// And calling a function: +Void main() { + putStrLn(string( multiply(2, 3) )); +} diff --git a/Task/Function-definition/LSE64/function-definition.lse64 b/Task/Function-definition/LSE64/function-definition.lse64 new file mode 100644 index 0000000000..9fead20c18 --- /dev/null +++ b/Task/Function-definition/LSE64/function-definition.lse64 @@ -0,0 +1,2 @@ +multiply : * +multiply. : *. # floating point diff --git a/Task/Function-definition/Liberty-BASIC/function-definition.liberty b/Task/Function-definition/Liberty-BASIC/function-definition.liberty new file mode 100644 index 0000000000..e6cab61d88 --- /dev/null +++ b/Task/Function-definition/Liberty-BASIC/function-definition.liberty @@ -0,0 +1,11 @@ +' define & call a function + +print multiply( 3, 1.23456) + +wait + +function multiply( m1, m2) + multiply =m1 *m2 +end function + +end diff --git a/Task/Function-definition/Locomotive-Basic/function-definition.bas b/Task/Function-definition/Locomotive-Basic/function-definition.bas new file mode 100644 index 0000000000..115deeea43 --- /dev/null +++ b/Task/Function-definition/Locomotive-Basic/function-definition.bas @@ -0,0 +1,2 @@ +10 DEF FNmultiply(x,y)=x*y +20 PRINT FNmultiply(2,PI) diff --git a/Task/Function-definition/Logo/function-definition.logo b/Task/Function-definition/Logo/function-definition.logo new file mode 100644 index 0000000000..cb07bb7d78 --- /dev/null +++ b/Task/Function-definition/Logo/function-definition.logo @@ -0,0 +1,3 @@ +to multiply :x :y + output :x * :y +end diff --git a/Task/Function-definition/Lua/function-definition.lua b/Task/Function-definition/Lua/function-definition.lua new file mode 100644 index 0000000000..39a9929f0c --- /dev/null +++ b/Task/Function-definition/Lua/function-definition.lua @@ -0,0 +1,3 @@ +function multiply( a, b ) + return a * b +end diff --git a/Task/Function-definition/Lucid/function-definition.lucid b/Task/Function-definition/Lucid/function-definition.lucid new file mode 100644 index 0000000000..b94b630664 --- /dev/null +++ b/Task/Function-definition/Lucid/function-definition.lucid @@ -0,0 +1 @@ +multiply(x,y) = x * y diff --git a/Task/Function-definition/M4/function-definition.m4 b/Task/Function-definition/M4/function-definition.m4 new file mode 100644 index 0000000000..07a6db0c4f --- /dev/null +++ b/Task/Function-definition/M4/function-definition.m4 @@ -0,0 +1,3 @@ +define(`multiply',`eval($1*$2)') + +multiply(2,3) diff --git a/Task/Function-definition/MATLAB/function-definition.m b/Task/Function-definition/MATLAB/function-definition.m new file mode 100644 index 0000000000..efd709df93 --- /dev/null +++ b/Task/Function-definition/MATLAB/function-definition.m @@ -0,0 +1,3 @@ +function C = multiply(A,B) + C = A*B; +end diff --git a/Task/Function-definition/MAXScript/function-definition.max b/Task/Function-definition/MAXScript/function-definition.max new file mode 100644 index 0000000000..bc92cc2fd3 --- /dev/null +++ b/Task/Function-definition/MAXScript/function-definition.max @@ -0,0 +1,4 @@ +fn multiply a b = +( + a * b +) diff --git a/Task/Function-definition/MUMPS/function-definition.mumps b/Task/Function-definition/MUMPS/function-definition.mumps new file mode 100644 index 0000000000..b7ced2adb5 --- /dev/null +++ b/Task/Function-definition/MUMPS/function-definition.mumps @@ -0,0 +1,2 @@ +MULTIPLY(A,B);Returns the product of A and B + QUIT A*B diff --git a/Task/Function-definition/Make/function-definition-1.make b/Task/Function-definition/Make/function-definition-1.make new file mode 100644 index 0000000000..fbc48ae2ac --- /dev/null +++ b/Task/Function-definition/Make/function-definition-1.make @@ -0,0 +1,5 @@ +A=1 +B=1 + +multiply: + @expr $(A) \* $(B) diff --git a/Task/Function-definition/Make/function-definition-2.make b/Task/Function-definition/Make/function-definition-2.make new file mode 100644 index 0000000000..d960f4f0c3 --- /dev/null +++ b/Task/Function-definition/Make/function-definition-2.make @@ -0,0 +1,2 @@ +make -f mul.mk multiply A=100 B=3 +> 300 diff --git a/Task/Function-definition/Make/function-definition-3.make b/Task/Function-definition/Make/function-definition-3.make new file mode 100644 index 0000000000..3074d29620 --- /dev/null +++ b/Task/Function-definition/Make/function-definition-3.make @@ -0,0 +1,11 @@ +A=1 +B=1 + +define multiply + expr $(1) \* $(2) +endef + +do: + @$(call multiply, $(A), $(B)) + +|gmake -f mul.mk do A=5 B=3 diff --git a/Task/Function-definition/Mathematica/function-definition-1.mathematica b/Task/Function-definition/Mathematica/function-definition-1.mathematica new file mode 100644 index 0000000000..78866cfbd0 --- /dev/null +++ b/Task/Function-definition/Mathematica/function-definition-1.mathematica @@ -0,0 +1 @@ +multiply[a_,b_]:=a*b diff --git a/Task/Function-definition/Mathematica/function-definition-2.mathematica b/Task/Function-definition/Mathematica/function-definition-2.mathematica new file mode 100644 index 0000000000..434eeea0c9 --- /dev/null +++ b/Task/Function-definition/Mathematica/function-definition-2.mathematica @@ -0,0 +1 @@ +multiply=#1*#2& diff --git a/Task/Function-definition/Metafont/function-definition-1.metafont b/Task/Function-definition/Metafont/function-definition-1.metafont new file mode 100644 index 0000000000..caf18fe9a9 --- /dev/null +++ b/Task/Function-definition/Metafont/function-definition-1.metafont @@ -0,0 +1 @@ +primarydef a mult b = a * b enddef; diff --git a/Task/Function-definition/Metafont/function-definition-2.metafont b/Task/Function-definition/Metafont/function-definition-2.metafont new file mode 100644 index 0000000000..86c206febd --- /dev/null +++ b/Task/Function-definition/Metafont/function-definition-2.metafont @@ -0,0 +1 @@ +t := 3 mult 5; show t; end diff --git a/Task/Function-definition/Metafont/function-definition-3.metafont b/Task/Function-definition/Metafont/function-definition-3.metafont new file mode 100644 index 0000000000..c3f7bbe9dd --- /dev/null +++ b/Task/Function-definition/Metafont/function-definition-3.metafont @@ -0,0 +1,4 @@ +def mult(expr a, b) = (a * b) enddef; +t := mult(2,3); +show t; +end diff --git a/Task/Function-definition/Modula-2/function-definition.mod2 b/Task/Function-definition/Modula-2/function-definition.mod2 new file mode 100644 index 0000000000..0123fcdc54 --- /dev/null +++ b/Task/Function-definition/Modula-2/function-definition.mod2 @@ -0,0 +1,4 @@ +PROCEDURE Multiply(a, b: INTEGER): INTEGER; +BEGIN + RETURN a * b +END Multiply; diff --git a/Task/Function-definition/Modula-3/function-definition.mod3 b/Task/Function-definition/Modula-3/function-definition.mod3 new file mode 100644 index 0000000000..291e757c81 --- /dev/null +++ b/Task/Function-definition/Modula-3/function-definition.mod3 @@ -0,0 +1,4 @@ +PROCEDURE Multiply(a, b: INTEGER): INTEGER = +BEGIN + RETURN a * b; +END Multiply; diff --git a/Task/Function-definition/PHP/function-definition.php b/Task/Function-definition/PHP/function-definition.php new file mode 100644 index 0000000000..95481dbe0b --- /dev/null +++ b/Task/Function-definition/PHP/function-definition.php @@ -0,0 +1,4 @@ +function multiply( $a, $b ) +{ + return $a * $b; +} diff --git a/Task/Function-definition/Perl/function-definition-1.pl b/Task/Function-definition/Perl/function-definition-1.pl new file mode 100644 index 0000000000..37f9aff94c --- /dev/null +++ b/Task/Function-definition/Perl/function-definition-1.pl @@ -0,0 +1 @@ +sub multiply { return $_[0] * $_[1] } diff --git a/Task/Function-definition/Perl/function-definition-2.pl b/Task/Function-definition/Perl/function-definition-2.pl new file mode 100644 index 0000000000..9a08c7a330 --- /dev/null +++ b/Task/Function-definition/Perl/function-definition-2.pl @@ -0,0 +1 @@ +sub multiply { $_[0] * $_[1] } diff --git a/Task/Function-definition/Perl/function-definition-3.pl b/Task/Function-definition/Perl/function-definition-3.pl new file mode 100644 index 0000000000..a84104fbe8 --- /dev/null +++ b/Task/Function-definition/Perl/function-definition-3.pl @@ -0,0 +1,5 @@ +sub multiply( $$ ) +{ + my ($a, $b) = @_; + return $a * $b; +} diff --git a/Task/Function-definition/Perl/function-definition-4.pl b/Task/Function-definition/Perl/function-definition-4.pl new file mode 100644 index 0000000000..5d6a0e217f --- /dev/null +++ b/Task/Function-definition/Perl/function-definition-4.pl @@ -0,0 +1,4 @@ +use signatures; +sub multiply ($x, $y) { + return $x * $y; +} diff --git a/Task/Function-definition/PicoLisp/function-definition.l b/Task/Function-definition/PicoLisp/function-definition.l new file mode 100644 index 0000000000..2841bd8ab0 --- /dev/null +++ b/Task/Function-definition/PicoLisp/function-definition.l @@ -0,0 +1,2 @@ +(de multiply (A B) + (* A B) ) diff --git a/Task/Function-definition/Python/function-definition-1.py b/Task/Function-definition/Python/function-definition-1.py new file mode 100644 index 0000000000..387ae2cba3 --- /dev/null +++ b/Task/Function-definition/Python/function-definition-1.py @@ -0,0 +1,2 @@ +def multiply(a, b): + return a * b diff --git a/Task/Function-definition/Python/function-definition-2.py b/Task/Function-definition/Python/function-definition-2.py new file mode 100644 index 0000000000..176bc1cfda --- /dev/null +++ b/Task/Function-definition/Python/function-definition-2.py @@ -0,0 +1 @@ +multiply = lambda a, b: a * b diff --git a/Task/Function-definition/Python/function-definition-3.py b/Task/Function-definition/Python/function-definition-3.py new file mode 100644 index 0000000000..44c703f284 --- /dev/null +++ b/Task/Function-definition/Python/function-definition-3.py @@ -0,0 +1,8 @@ +class Multiply: + def __init__(self): + pass + def __call__(self, a, b): + return a * b + +multiply = Multiply() +print multiply(2, 4) # prints 8 diff --git a/Task/Function-definition/R/function-definition-1.r b/Task/Function-definition/R/function-definition-1.r new file mode 100644 index 0000000000..1635da8de4 --- /dev/null +++ b/Task/Function-definition/R/function-definition-1.r @@ -0,0 +1 @@ +mult <- function(a,b) a*b diff --git a/Task/Function-definition/R/function-definition-2.r b/Task/Function-definition/R/function-definition-2.r new file mode 100644 index 0000000000..a09bdca53e --- /dev/null +++ b/Task/Function-definition/R/function-definition-2.r @@ -0,0 +1,5 @@ +mult <- function(a,b) { + a*b + # or: + # return(a*b) +} diff --git a/Task/Function-definition/REXX/function-definition-1.rexx b/Task/Function-definition/REXX/function-definition-1.rexx new file mode 100644 index 0000000000..a476639d66 --- /dev/null +++ b/Task/Function-definition/REXX/function-definition-1.rexx @@ -0,0 +1 @@ +multiply: return arg(1) * arg(2) /*return the product of the two arguments.*/ diff --git a/Task/Function-definition/REXX/function-definition-2.rexx b/Task/Function-definition/REXX/function-definition-2.rexx new file mode 100644 index 0000000000..569b050f96 --- /dev/null +++ b/Task/Function-definition/REXX/function-definition-2.rexx @@ -0,0 +1 @@ +multiply: return arg(1) * arg(2) / 1 /*return with a normalized product of 2 args. */ diff --git a/Task/Function-definition/Racket/function-definition-1.rkt b/Task/Function-definition/Racket/function-definition-1.rkt new file mode 100644 index 0000000000..a214af010e --- /dev/null +++ b/Task/Function-definition/Racket/function-definition-1.rkt @@ -0,0 +1,2 @@ +(define (mutiply a b) + (* a b)) diff --git a/Task/Function-definition/Racket/function-definition-2.rkt b/Task/Function-definition/Racket/function-definition-2.rkt new file mode 100644 index 0000000000..0fbdd2cf33 --- /dev/null +++ b/Task/Function-definition/Racket/function-definition-2.rkt @@ -0,0 +1 @@ +(define multiply (lambda (a b) (* a b))) diff --git a/Task/Function-definition/Ruby/function-definition.rb b/Task/Function-definition/Ruby/function-definition.rb new file mode 100644 index 0000000000..bd514f6b2e --- /dev/null +++ b/Task/Function-definition/Ruby/function-definition.rb @@ -0,0 +1,3 @@ +def multiply(a, b) + a * b +end diff --git a/Task/Function-definition/SNUSP/function-definition.snusp b/Task/Function-definition/SNUSP/function-definition.snusp new file mode 100644 index 0000000000..813f44fd10 --- /dev/null +++ b/Task/Function-definition/SNUSP/function-definition.snusp @@ -0,0 +1,4 @@ ++1>++2=@\=>+++3=@\==@\=.=# prints '6' + | | \=itoa=@@@+@+++++# + \=======!\==!/===?\<# + \>+<-/ diff --git a/Task/Function-definition/Sather/function-definition.sa b/Task/Function-definition/Sather/function-definition.sa new file mode 100644 index 0000000000..d1c29172d3 --- /dev/null +++ b/Task/Function-definition/Sather/function-definition.sa @@ -0,0 +1,8 @@ +class MAIN is + -- we cannot have "functions" (methods) outside classes + mult(a, b:FLT):FLT is return a*b; end; + + main is + #OUT + mult(5.2, 3.4) + "\n"; + end; +end; diff --git a/Task/Function-definition/Scala/function-definition.scala b/Task/Function-definition/Scala/function-definition.scala new file mode 100644 index 0000000000..fa5235bc79 --- /dev/null +++ b/Task/Function-definition/Scala/function-definition.scala @@ -0,0 +1 @@ +def multiply(a: Int, b: Int) = a * b diff --git a/Task/Function-definition/Scheme/function-definition-1.ss b/Task/Function-definition/Scheme/function-definition-1.ss new file mode 100644 index 0000000000..e4eaee03d9 --- /dev/null +++ b/Task/Function-definition/Scheme/function-definition-1.ss @@ -0,0 +1 @@ +(define multiply *) diff --git a/Task/Function-definition/Scheme/function-definition-2.ss b/Task/Function-definition/Scheme/function-definition-2.ss new file mode 100644 index 0000000000..e782fc60de --- /dev/null +++ b/Task/Function-definition/Scheme/function-definition-2.ss @@ -0,0 +1,2 @@ +(define (multiply a b) + (* a b)) diff --git a/Task/Function-definition/Smalltalk/function-definition.st b/Task/Function-definition/Smalltalk/function-definition.st new file mode 100644 index 0000000000..cbefbff925 --- /dev/null +++ b/Task/Function-definition/Smalltalk/function-definition.st @@ -0,0 +1,2 @@ +|mul| +mul := [ :a :b | a * b ]. diff --git a/Task/Function-definition/Tcl/function-definition-1.tcl b/Task/Function-definition/Tcl/function-definition-1.tcl new file mode 100644 index 0000000000..c3df305d45 --- /dev/null +++ b/Task/Function-definition/Tcl/function-definition-1.tcl @@ -0,0 +1,3 @@ +proc multiply { arg1 arg2 } { + return [expr {$arg1 * $arg2}] +} diff --git a/Task/Function-definition/Tcl/function-definition-2.tcl b/Task/Function-definition/Tcl/function-definition-2.tcl new file mode 100644 index 0000000000..b453d53c1a --- /dev/null +++ b/Task/Function-definition/Tcl/function-definition-2.tcl @@ -0,0 +1,8 @@ +proc tcl::mathfunc::multiply {arg1 arg2} { + return [expr {$arg1 * $arg2}] +} + +# Demonstrating... +if {multiply(6, 9) == 42} { + puts "Welcome, Citizens of Golgafrincham from the B-Ark!" +} diff --git a/Task/Function-frequency/0DESCRIPTION b/Task/Function-frequency/0DESCRIPTION new file mode 100644 index 0000000000..aa412d7240 --- /dev/null +++ b/Task/Function-frequency/0DESCRIPTION @@ -0,0 +1,6 @@ +Display - for a program or runtime environment (whatever suites the style of your language) - the top ten most frequently occurring functions (or also identifiers or tokens, if preferred). + +This is a static analysis: The question is not how often each function is +actually executed at runtime, but how often it is used by the programmer. + +Besides its practical usefulness, the intent of this task is to show how to do self-inspection within the language. diff --git a/Task/Function-frequency/1META.yaml b/Task/Function-frequency/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Function-frequency/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Function-frequency/ACL2/function-frequency.acl2 b/Task/Function-frequency/ACL2/function-frequency.acl2 new file mode 100644 index 0000000000..cce6c609f5 --- /dev/null +++ b/Task/Function-frequency/ACL2/function-frequency.acl2 @@ -0,0 +1,63 @@ +(in-package "ACL2") + +(set-state-ok t) + +(defun read-all-objects (limit channel state) + (mv-let (eof obj state) + (read-object channel state) + (if (or eof (zp limit)) + (mv nil state) + (mv-let (so-far state) + (read-all-objects (- limit 1) channel state) + (mv (cons obj so-far) state))))) + +(defun list-starters (xs) + (cond ((endp xs) nil) + ((consp (first xs)) + (append (if (symbolp (first (first xs))) + (list (first (first xs))) + nil) + (list-starters (rest (first xs))) + (list-starters (rest xs)))) + (t (list-starters (rest xs))))) + +(defun invoked-functions (filename state) + (mv-let (channel state) + (open-input-channel filename :object state) + (mv-let (code state) + (read-all-objects 1000 channel state) + (mv (list-starters code) state)))) + +(defun increment-for (key alist) + (cond ((endp alist) (list (cons key 1))) + ((equal key (car (first alist))) + (cons (cons key (1+ (cdr (first alist)))) + (rest alist))) + (t (cons (first alist) + (increment-for key (rest alist)))))) + +(defun symbol-freq-table (symbols) + (if (endp symbols) + nil + (increment-for (first symbols) + (symbol-freq-table (rest symbols))))) + +(defun insert-freq-table (pair alist) + (cond ((endp alist) + (list pair)) + ((> (cdr pair) (cdr (first alist))) + (cons pair alist)) + (t (cons (first alist) + (insert-freq-table pair (rest alist)))))) + +(defun isort-freq-table (alist) + (if (endp alist) + nil + (insert-freq-table (first alist) + (isort-freq-table (rest alist))))) + +(defun main (state) + (mv-let (fns state) + (invoked-functions "function-freq.lisp" state) + (mv (take 10 (isort-freq-table + (symbol-freq-table fns))) state))) diff --git a/Task/Function-frequency/BBC-BASIC/function-frequency.bbc b/Task/Function-frequency/BBC-BASIC/function-frequency.bbc new file mode 100644 index 0000000000..d38ab091f9 --- /dev/null +++ b/Task/Function-frequency/BBC-BASIC/function-frequency.bbc @@ -0,0 +1,47 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(1,0) : REM Descending + + Valid$ = "0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_`abcdefghijklmnopqrstuvwxyz" + DIM func$(1000), cnt%(1000) + nFunc% = 0 + + file% = OPENIN("*.bbc") + WHILE NOT EOF#file% + ll% = BGET#file% + no% = BGET#file% + 256*BGET#file% + INPUT #file%, l$ + + i% = 1 + REPEAT + j% = INSTR(l$, CHR$&A4, i%) : REM Token for 'FN' + k% = INSTR(l$, CHR$&F2, i%) : REM Token for 'PROC' + IF k% IF j%=0 OR j%>k% THEN + i% = k% + f$ = "PROC" + ELSE + i% = j% + f$ = "FN" + ENDIF + IF i% THEN + REPEAT + i% += 1 + f$ += MID$(l$, i%, 1) + UNTIL INSTR(Valid$, MID$(l$, i%+1, 1)) = 0 + FOR j% = 0 TO nFunc%-1 + IF f$ = func$(j%) EXIT FOR + NEXT + IF j% >= nFunc% nFunc% += 1 + func$(j%) = f$ + cnt%(j%) += 1 + ENDIF + UNTIL i%=0 + ENDWHILE + CLOSE #file% + + C% = nFunc% + CALL Sort%, cnt%(0), func$(0) + + IF C% > 10 C% = 10 + FOR i% = 0 TO C%-1 + PRINT func$(i%) " (" ; cnt%(i%) ")" + NEXT diff --git a/Task/Function-frequency/C/function-frequency.c b/Task/Function-frequency/C/function-frequency.c new file mode 100644 index 0000000000..0481d1bc01 --- /dev/null +++ b/Task/Function-frequency/C/function-frequency.c @@ -0,0 +1,251 @@ +#define _POSIX_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +struct functionInfo { + char* name; + int timesCalled; + char marked; +}; +void addToList(struct functionInfo** list, struct functionInfo toAdd, \ + size_t* numElements, size_t* allocatedSize) +{ + static const char* keywords[32] = {"auto", "break", "case", "char", "const", \ + "continue", "default", "do", "double", \ + "else", "enum", "extern", "float", "for", \ + "goto", "if", "int", "long", "register", \ + "return", "short", "signed", "sizeof", \ + "static", "struct", "switch", "typedef", \ + "union", "unsigned", "void", "volatile", \ + "while" + }; + int i; + /* If the "function" being called is actually a keyword, then ignore it */ + for (i = 0; i < 32; i++) { + if (!strcmp(toAdd.name, keywords[i])) { + return; + } + } + if (!*list) { + *allocatedSize = 10; + *list = calloc(*allocatedSize, sizeof(struct functionInfo)); + if (!*list) { + printf("Failed to allocate %lu elements of %lu bytes each.\n", \ + *allocatedSize, sizeof(struct functionInfo)); + abort(); + } + (*list)[0].name = malloc(strlen(toAdd.name)+1); + if (!(*list)[0].name) { + printf("Failed to allocate %lu bytes.\n", strlen(toAdd.name)+1); + abort(); + } + strcpy((*list)[0].name, toAdd.name); + (*list)[0].timesCalled = 1; + (*list)[0].marked = 0; + *numElements = 1; + } else { + char found = 0; + unsigned int i; + for (i = 0; i < *numElements; i++) { + if (!strcmp((*list)[i].name, toAdd.name)) { + found = 1; + (*list)[i].timesCalled++; + break; + } + } + if (!found) { + struct functionInfo* newList = calloc((*allocatedSize)+10, \ + sizeof(struct functionInfo)); + if (!newList) { + printf("Failed to allocate %lu elements of %lu bytes each.\n", \ + (*allocatedSize)+10, sizeof(struct functionInfo)); + abort(); + } + memcpy(newList, *list, (*allocatedSize)*sizeof(struct functionInfo)); + free(*list); + *allocatedSize += 10; + *list = newList; + (*list)[*numElements].name = malloc(strlen(toAdd.name)+1); + if (!(*list)[*numElements].name) { + printf("Failed to allocate %lu bytes.\n", strlen(toAdd.name)+1); + abort(); + } + strcpy((*list)[*numElements].name, toAdd.name); + (*list)[*numElements].timesCalled = 1; + (*list)[*numElements].marked = 0; + (*numElements)++; + } + } +} +void printList(struct functionInfo** list, size_t numElements) +{ + char maxSet = 0; + unsigned int i; + size_t maxIndex = 0; + for (i = 0; i<10; i++) { + maxSet = 0; + size_t j; + for (j = 0; j (*list)[maxIndex].timesCalled) { + if (!(*list)[j].marked) { + maxSet = 1; + maxIndex = j; + } + } + } + (*list)[maxIndex].marked = 1; + printf("%s() called %d times.\n", (*list)[maxIndex].name, \ + (*list)[maxIndex].timesCalled); + } +} +void freeList(struct functionInfo** list, size_t numElements) +{ + size_t i; + for (i = 0; i>fPAD ( ca u -- ; u < 51 ) + PAD 80 blank s" create " PAD swap MOVE + s" 1 , DOES> 1 swap +! ;" PAD 57 + swap MOVE + WORD# min PAD 7 + swap MOVE ; + +: funcmpl ( ca u -- ) + >>fPAD current @ DEFS current ! + PAD 80 evaluate current ! ; + +: >>kPAD ( ca u -- ; ) + PAD 80 blank s" : " PAD swap MOVE + s" parse-name funcmpl ;" PAD 59 + swap MOVE + WORD# min PAD 2 + swap MOVE ; + +: keycmpl ( ca u -- ) + >>kPAD current @ KEYS current ! + PAD 80 evaluate current ! ; + +\ --- Interpreter +: intp BEGIN parse-name dup + WHILE ( ca u ) + 2dup KEYS search-wordlist + IF execute 2drop + ELSE DEFS search-wordlist IF execute THEN + THEN + REPEAT 2drop ; + +: run BEGIN refill WHILE intp REPEAT ; + +\ --- Lists&Rings +warnings OFF +: LIST ( node -- ) ]] BEGIN @ dup WHILE >R [[ ; immediate +warnings ON +: LOOP-LIST ( -- ) ]] R> REPEAT drop [[ ; immediate + +: empty-ring? ( node -- f ) dup @ = ; +: RING ( node -- ) ]] dup BEGIN @ 2dup <> WHILE 2>R [[ ; immediate +: LOOP-RING ( -- ) ]] 2R> REPEAT 2drop [[ ; immediate + +: new-node ( -- node ) + here dup , ; +: do-link ( node new-node -- ; do link after current node ) + over @ over ! swap ! ; + +\ --- Sorting.. +: nt>freq ( nt -- n ;frequency of uses ) + name>int >BODY @ ; + +: @maxfreq ( wid -- n ;maximum frequency ) + 0 swap cell+ + LIST ( max ) + I nt>freq 2dup < + IF nip ELSE drop THEN + LOOP-LIST ; + + 2 cells constant RING# +: rings-vec ( u -- a size ; create vector of rings ) + here over 1+ 0 + DO new-node drop 0 , LOOP + swap RING# * ; + +: populate-by ( a wid -- ) + cell+ + LIST + dup I nt>freq RING# * + \ root-node + new-node I , \ new-node + do-link + LOOP-LIST drop ; + +\ --- Display TOP +: node>nt cell+ @ ; + +: .ring ( root-node -- ) + 0 swap + RING + dup 0= IF I node>nt nt>freq . THEN + space I node>nt name>string type + 1+ + LOOP-RING drop cr ; + +: .top ( a size n -- ) + -rot BOUNDS swap + ?DO ( n ) + I empty-ring? 0= IF 1- I .ring THEN + dup 0= IF drop UNLOOP EXIT THEN + [ RING# negate ] LITERAL +LOOP drop ; + +: args>top# ( -- n ) + 1 arg 2dup 0 0 d<> + IF >float + IF f>d d>s dup 0= IF drop 4 THEN + ELSE 4 THEN + ELSE 2drop 4 THEN ; + + +\ --- KEYS behaviour + variable cmpl? cmpl? OFF + 2variable cword +here WORD# allot 0 cword 2! + +current @ KEYS current ! +: create + cmpl? @ + IF cword 2@ keycmpl + ELSE parse-name funcmpl THEN ; + +: constant + cmpl? @ + IF cword 2@ keycmpl + ELSE parse-name funcmpl THEN ; + +: variable parse-name funcmpl ; +: value parse-name funcmpl ; +: defer parse-name funcmpl ; + +: ( BEGIN >in @ [char] ) parse nip >in @ rot - = + WHILE refill 0= IF exit THEN REPEAT ; +: \ 10 parse 2drop ; +: \G 10 parse 2drop ; +: S" [char] " parse 2drop ; +: ." [char] " parse 2drop ; + +: ['] + parse-name DEFS search-wordlist IF execute THEN ; +: postpone + parse-name DEFS search-wordlist IF execute THEN ; + +: ; cmpl? OFF ; +: : warnings OFF + parse-name + cword 2@ drop WORD# rot umin dup >R MOVE + cword 2@ drop R> cword 2! + cword 2@ cmpl? @ + IF keycmpl \ `:' inside def. = a defining word + ELSE funcmpl THEN + cmpl? ON + warnings ON +; +current ! + +\ Run, ruuun! +stdin ' run execute-parsing-file DEFS @maxfreq rings-vec over DEFS populate-by args>top# .top bye diff --git a/Task/Function-frequency/Go/function-frequency.go b/Task/Function-frequency/Go/function-frequency.go new file mode 100644 index 0000000000..b15d25fa3b --- /dev/null +++ b/Task/Function-frequency/Go/function-frequency.go @@ -0,0 +1,60 @@ +package main + +import ( + "fmt" + "go/ast" + "go/parser" + "go/token" + "io/ioutil" + "os" + "sort" +) + +func main() { + if len(os.Args) != 2 { + fmt.Println("usage ff ") + return + } + src, err := ioutil.ReadFile(os.Args[1]) + if err != nil { + fmt.Println(err) + return + } + fs := token.NewFileSet() + a, err := parser.ParseFile(fs, os.Args[1], src, 0) + if err != nil { + fmt.Println(err) + return + } + f := fs.File(a.Pos()) + m := make(map[string]int) + ast.Inspect(a, func(n ast.Node) bool { + if ce, ok := n.(*ast.CallExpr); ok { + start := f.Offset(ce.Pos()) + end := f.Offset(ce.Lparen) + m[string(src[start:end])]++ + } + return true + }) + cs := make(calls, 0, len(m)) + for k, v := range m { + cs = append(cs, &call{k, v}) + } + sort.Sort(cs) + for i, c := range cs { + fmt.Printf("%-20s %4d\n", c.expr, c.count) + if i == 9 { + break + } + } +} + +type call struct { + expr string + count int +} +type calls []*call + +func (c calls) Len() int { return len(c) } +func (c calls) Swap(i, j int) { c[i], c[j] = c[j], c[i] } +func (c calls) Less(i, j int) bool { return c[i].count > c[j].count } diff --git a/Task/Function-frequency/J/function-frequency.j b/Task/Function-frequency/J/function-frequency.j new file mode 100644 index 0000000000..92c6835acb --- /dev/null +++ b/Task/Function-frequency/J/function-frequency.j @@ -0,0 +1,29 @@ + PRIMITIVES=: ;:'! !. !: " ". ": # #. #: $ $. $: % %. %: & &. &.: &: * *. *: + +. +: , ,. ,: - -. -: . .. .: / /. /: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: : :. :: ; ;. ;: < <. <: = =. =: > >. >: ? ?. ...' + + Filter=: (#~`)(`:6) + + NB. monad top10 . y is a character vector of much j source code + top10=: 10 {. \:~@:((#;{.)/.~@:(e.&PRIMITIVES Filter@:;:)) + + top10 JSOURCE NB. JSOURCE are the j Zeckendorf verbs. +┌─┬──┐ +│6│=.│ +├─┼──┤ +│5│=:│ +├─┼──┤ +│4│@:│ +├─┼──┤ +│3│~ │ +├─┼──┤ +│3│: │ +├─┼──┤ +│3│+ │ +├─┼──┤ +│3│$ │ +├─┼──┤ +│2│|.│ +├─┼──┤ +│2│i.│ +├─┼──┤ +│2│/ │ +└─┴──┘ diff --git a/Task/Function-frequency/Mathematica/function-frequency.mathematica b/Task/Function-frequency/Mathematica/function-frequency.mathematica new file mode 100644 index 0000000000..4735829422 --- /dev/null +++ b/Task/Function-frequency/Mathematica/function-frequency.mathematica @@ -0,0 +1 @@ +programCount[fn_] := Reverse[If[Length[#] > 10, Take[#, -10], #] &[SortBy[Tally[Cases[DownValues[fn], s_Symbol, \[Infinity], Heads -> True]], Last]]] diff --git a/Task/Function-frequency/PicoLisp/function-frequency.l b/Task/Function-frequency/PicoLisp/function-frequency.l new file mode 100644 index 0000000000..e5f1734e75 --- /dev/null +++ b/Task/Function-frequency/PicoLisp/function-frequency.l @@ -0,0 +1,9 @@ +(let Freq NIL + (for "L" (filter pair (extract getd (all))) + (for "F" + (filter atom + (fish '((X) (or (circ? X) (getd X))) + "L" ) ) + (accu 'Freq "F" 1) ) ) + (for X (head 10 (flip (by cdr sort Freq))) + (tab (-7 4) (car X) (cdr X)) ) ) diff --git a/Task/Function-frequency/Python/function-frequency.py b/Task/Function-frequency/Python/function-frequency.py new file mode 100644 index 0000000000..347a3b0eee --- /dev/null +++ b/Task/Function-frequency/Python/function-frequency.py @@ -0,0 +1,23 @@ +import ast + +class CallCountingVisitor(ast.NodeVisitor): + + def __init__(self): + self.calls = {} + + def visit_Call(self, node): + if isinstance(node.func, ast.Name): + fun_name = node.func.id + call_count = self.calls.get(fun_name, 0) + self.calls[fun_name] = call_count + 1 + self.generic_visit(node) + +filename = input('Enter a filename to parse: ') +with open(filename, encoding='utf-8') as f: + contents = f.read() +root = ast.parse(contents, filename=filename) #NOTE: this will throw a SyntaxError if the file isn't valid Python code +visitor = CallCountingVisitor() +visitor.visit(root) +top10 = sorted(visitor.calls.items(), key=lambda x: x[1], reverse=True)[:10] +for name, count in top10: + print(name,'called',count,'times') diff --git a/Task/Function-frequency/REXX/function-frequency.rexx b/Task/Function-frequency/REXX/function-frequency.rexx new file mode 100644 index 0000000000..8b2f8a1370 --- /dev/null +++ b/Task/Function-frequency/REXX/function-frequency.rexx @@ -0,0 +1,48 @@ +/*REXX pgm counts frequency of various subroutine/function invocations. */ +?.=0 /*initialize all funky counters. */ + do j=1 to 10 + factorial = !(j) + factorial_R = !r(j) + fibonacci = fib(j) + fibonacci_R = fibR(j) + hofstadterQ = hofsQ(j) + width = length(j) + length(length(j**j)) + end /*j*/ + +say 'number of invocations for ! (factorial) = ' ?.! +say 'number of invocations for ! recursive = ' ?.!r +say 'number of invocations for Fibonacci = ' ?.fib +say 'number of invocations for Fib recursive = ' ?.fibR +say 'number of invocations for Hofstadter Q = ' ?.hofsQ +say 'number of invocations for LENGTH = ' ?.length +exit /*stick a fork in it, we're done.*/ + +/*─────────────────────────────────────! (factorial) subroutine─────────*/ +!: procedure expose ?.; ?.!=?.!+1; parse arg x; !=1 + do j=2 to x; !=!*j; end; return ! + +/*─────────────────────────────────────!r (factorial) subroutine────────*/ +!r: procedure expose ?.; ?.!r=?.!r+1; parse arg x; if x<2 then return 1 + return x * !R(x-1) + +/*──────────────────────────────────FIB subroutine (non─recursive)──────*/ +fib: procedure expose ?.; ?.fib=?.fib+1; parse arg n; na=abs(n); a=0; b=1 + if na<2 then return na /*test for couple special cases. */ + do j=2 to na; s=a+b; a=b; b=s; end + if n>0 | na//2==1 then return s /*if positive or odd negative... */ + else return -s /*return a negative Fib number. */ + +/*──────────────────────────────────FIBR subroutine (recursive)─────────*/ +fibR: procedure expose ?.; ?.fibR=?.fibr+1; parse arg n; na=abs(n); s=1 + if na<2 then return na /*handle a couple special cases. */ + if n <0 then if n//2==0 then s=-1 + return (fibR(na-1)+fibR(na-2))*s + +/*──────────────────────────────────HOFSQ subroutine (recursive)────────*/ +hofsQ: procedure expose ?.; ?.hofsq=?.hofsq+1; parse arg n + if n<2 then return 1 + return hofsQ(n - hofsQ(n - 1)) + hofsQ(n - hofsQ(n - 2)) + +/*──────────────────────────────────LENGTH subroutine───────────────────*/ +length: procedure expose ?.; ?.length=?.length+1 + return 'LENGTH'(arg(1)) diff --git a/Task/Function-frequency/Tcl/function-frequency.tcl b/Task/Function-frequency/Tcl/function-frequency.tcl new file mode 100644 index 0000000000..8f2e517a9a --- /dev/null +++ b/Task/Function-frequency/Tcl/function-frequency.tcl @@ -0,0 +1,28 @@ +package require Tcl 8.6 + +proc examine {filename} { + global cmds + set RE "(?:^|\[\[\{\])\[\\w:.\]+" + set f [open $filename] + while {[gets $f line] >= 0} { + set line [string trim $line] + if {$line eq "" || [string match "#*" $line]} { + continue + } + foreach cmd [regexp -all -inline $RE $line] { + incr cmds([string trim $cmd "\{\["]) + } + } + close $f +} + +# Parse each file on the command line +foreach filename $argv { + examine $filename +} +# Get the command list in order of frequency +set cmdinfo [lsort -stride 2 -index 1 -integer -decreasing [array get cmds]] +# Print the top 10 (two list items per entry, so 0-19, not 0-9) +foreach {cmd count} [lrange $cmdinfo 0 19] { + puts [format "%-20s%d" $cmd $count] +} diff --git a/Task/Function-prototype/0DESCRIPTION b/Task/Function-prototype/0DESCRIPTION new file mode 100644 index 0000000000..db020a0b1c --- /dev/null +++ b/Task/Function-prototype/0DESCRIPTION @@ -0,0 +1,12 @@ +Some languages provide the facility to declare functions and subroutines through the use of [[wp:Function prototype|function prototyping]]. The task is to demonstrate the methods available for declaring prototypes within the language. The provided solutions should include: + +* An explanation of any placement restrictions for prototype declarations +* A prototype declaration for a function that does not require arguments +* A prototype declaration for a function that requires two arguments +* A prototype declaration for a function that utilizes varargs +* A prototype declaration for a function that utilizes optional arguments +* A prototype declaration for a function that utilizes named parameters +* Example of prototype declarations for subroutines or procedures (if these differ from functions) +* An explanation and example of any special forms of prototyping not covered by the above + +Languages that do not provide function prototyping facilities should be omitted from this task. diff --git a/Task/Function-prototype/Ada/function-prototype-1.ada b/Task/Function-prototype/Ada/function-prototype-1.ada new file mode 100644 index 0000000000..06fb630bb4 --- /dev/null +++ b/Task/Function-prototype/Ada/function-prototype-1.ada @@ -0,0 +1,6 @@ +function noargs return Integer; +function twoargs (a, b : Integer) return Integer; +-- varargs do not exist +function optionalargs (a, b : Integer := 0) return Integer; +-- all parameters are always named, only calling by name differs +procedure dostuff (a : Integer); diff --git a/Task/Function-prototype/Ada/function-prototype-2.ada b/Task/Function-prototype/Ada/function-prototype-2.ada new file mode 100644 index 0000000000..9d68054fa6 --- /dev/null +++ b/Task/Function-prototype/Ada/function-prototype-2.ada @@ -0,0 +1,5 @@ +type Box; -- tell Ada a box exists (undefined yet) +type accBox is access Box; -- define a pointer to a box +type Box is record -- later define what a box is + next : accBox; -- including that a box holds access to other boxes +end record; diff --git a/Task/Function-prototype/Ada/function-prototype-3.ada b/Task/Function-prototype/Ada/function-prototype-3.ada new file mode 100644 index 0000000000..43e971a85f --- /dev/null +++ b/Task/Function-prototype/Ada/function-prototype-3.ada @@ -0,0 +1,4 @@ +package Stack is + procedure Push(Object:Integer); + function Pull return Integer; +end Stack; diff --git a/Task/Function-prototype/Ada/function-prototype-4.ada b/Task/Function-prototype/Ada/function-prototype-4.ada new file mode 100644 index 0000000000..070d9a600a --- /dev/null +++ b/Task/Function-prototype/Ada/function-prototype-4.ada @@ -0,0 +1,13 @@ +package body Stack is + + procedure Push(Object:Integer) is + begin + -- implementation goes here + end; + + function Pull return Integer; + begin + -- implementation goes here + end; + +end Stack; diff --git a/Task/Function-prototype/Ada/function-prototype-5.ada b/Task/Function-prototype/Ada/function-prototype-5.ada new file mode 100644 index 0000000000..8709c94fd0 --- /dev/null +++ b/Task/Function-prototype/Ada/function-prototype-5.ada @@ -0,0 +1,8 @@ +with Stack; +procedure Main is + N:integer:=5; +begin + Push(N); + ... + N := Pull; +end Main; diff --git a/Task/Function-prototype/C/function-prototype.c b/Task/Function-prototype/C/function-prototype.c new file mode 100644 index 0000000000..f789ceb56c --- /dev/null +++ b/Task/Function-prototype/C/function-prototype.c @@ -0,0 +1,5 @@ +int noargs(); /* Declare a function with no arguments that returns an integer */ +int twoargs(int a,int b); /* Declare a function with no arguments that returns an integer */ +int twoargs(int ,int); /* Parameter names are optional in a prototype definition */ +int anyargs(...); /* An ellipsis can be used to declare a function that accepts varargs */ +int atleastoneargs(int, ...); /* One mandatory integer argument followed by varargs */ diff --git a/Task/Function-prototype/Common-Lisp/function-prototype-1.lisp b/Task/Function-prototype/Common-Lisp/function-prototype-1.lisp new file mode 100644 index 0000000000..a799d3fddf --- /dev/null +++ b/Task/Function-prototype/Common-Lisp/function-prototype-1.lisp @@ -0,0 +1,13 @@ +;; An empty lambda list () takes 0 parameters. +(defun 0args () + (format t "Called 0args~%")) + +;; This lambda list (a b) takes 2 parameters. +(defun 2args (a b) + (format t "Called 2args with ~A and ~A~%" a b)) + +;; Local variables from lambda lists may have declarations. +;; This function takes 2 arguments, which must be integers. +(defun 2ints (i j) + (declare (type integer i j)) + (/ (+ i j) 2)) diff --git a/Task/Function-prototype/Common-Lisp/function-prototype-2.lisp b/Task/Function-prototype/Common-Lisp/function-prototype-2.lisp new file mode 100644 index 0000000000..e762275594 --- /dev/null +++ b/Task/Function-prototype/Common-Lisp/function-prototype-2.lisp @@ -0,0 +1,8 @@ +;; Rest parameter, for variadic functions: r is a list of arguments. +(a b &rest r) + +;; Optional parameter: i defaults to 3, (f 1 2) is same as (f 1 2 3). +(a b &optional (i 3)) + +;; Keyword parameters: (f 1 2 :c 3 :d 4) is same as (f 1 2 :d 4 :c 3). +(a b &key c d) diff --git a/Task/Function-prototype/D/function-prototype.d b/Task/Function-prototype/D/function-prototype.d new file mode 100644 index 0000000000..82c8666306 --- /dev/null +++ b/Task/Function-prototype/D/function-prototype.d @@ -0,0 +1,47 @@ +/// Declare a function with no arguments that returns an integer. +int noArgs(); + +/// Declare a function with no arguments that returns an integer. +int twoArgs(int a, int b); + +/// Parameter names are optional in a prototype definition. +int twoArgs2(int, int); + +/// An ellipsis can be used to declare a function that accepts +/// C-style varargs. +int anyArgs(...); + +/// One mandatory integer argument followed by C-style varargs. +int atLeastOneArg(int, ...); + +/// Declare a function that accepts any number of integers. +void anyInts(int[] a...); + +/// Declare a function that accepts D-style varargs. +void anyArgs2(TArgs...)(TArgs args); + +/// Declare a function that accepts two or more D-style varargs. +void anyArgs3(TArgs...)(TArgs args) if (TArgs.length > 2); + +/// Currently D doesn't support named arguments. + +/// One implementation. +int twoArgs(int a, int b) { + return a + b; +} + +interface SomeInterface { + void foo(); + void foo(int, int); + + // Varargs + void foo(...); // C-style. + void foo(int[] a...); + void bar(T...)(T args); // D-style. + + // Optional arguments are only supported if a default is provided, + // the default arg(s) has/have to be at the end of the args list. + void foo(int a, int b = 10); +} + +void main() {} diff --git a/Task/Function-prototype/Perl/function-prototype.pl b/Task/Function-prototype/Perl/function-prototype.pl new file mode 100644 index 0000000000..4034ccb497 --- /dev/null +++ b/Task/Function-prototype/Perl/function-prototype.pl @@ -0,0 +1,2 @@ +sub noargs(); # Declare a function with no arguments +sub twoargs($$); # Declare a function with two scalar arguments. The two sigils act as argument type placeholders diff --git a/Task/GUI-Maximum-window-dimensions/0DESCRIPTION b/Task/GUI-Maximum-window-dimensions/0DESCRIPTION new file mode 100644 index 0000000000..09041c4ab2 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/0DESCRIPTION @@ -0,0 +1,11 @@ +The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without srolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations and menubars. The idea is to determine the physical display parameters for the maximum height and width of the usable display area in pixels (without scrolling). The values calculated should represent the usable desktop area of a window maximized to fit the the screen. + +=== Considerations === + +==== Multiple Monitors ==== + +For multiple monitors, the values calculated should represent the size of the usable display area on the monitor which is related to the task (ie the monitor which would display a window if such instructions were given). + +==== Tiling Window Managers ==== + +For a tiling window manager, the values calculated should represent the maximum height and width of the display area of the maximum size a window can be created (without scrolling). This would typically be a full screen window (minus any areas occupied by desktop bars), unless the window manager has restrictions that prevents the creation of a full screen window, in which case the values represent the usable area of the desktop that occupies the maximum permissible window size (without scrolling). diff --git a/Task/GUI-Maximum-window-dimensions/1META.yaml b/Task/GUI-Maximum-window-dimensions/1META.yaml new file mode 100644 index 0000000000..4c5ed293ba --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/1META.yaml @@ -0,0 +1,4 @@ +--- +note: GUI +requires: +- Graphics diff --git a/Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada b/Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada new file mode 100644 index 0000000000..bba418fc82 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada @@ -0,0 +1,27 @@ +with Gtk.Main; +with Glib; +with Gtk.Window; use Gtk.Window; +with Gtk.Enums; use Gtk.Enums; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Max_Size is + + Win : Gtk_Window; + Win_W, Win_H : Glib.Gint; + package Int_Io is new Integer_IO (Glib.Gint); + Hid : Gtk.Main.Quit_Handler_Id; + +begin + Gtk.Main.Init; + Gtk_New (Win); + Initialize (Win, Window_Toplevel); + Maximize (Win); + Show (Win); + Get_Size (Win, Win_W, Win_H); + Put ("Maximum dimensions of window : W "); + Int_Io.Put (Win_W, Width => 4); + Put (" x H "); + Int_Io.Put (Win_H, Width => 4); + New_Line; + Hid := Gtk.Main.Quit_Add_Destroy (0, Win); +end Max_Size; diff --git a/Task/GUI-Maximum-window-dimensions/BBC-BASIC/gui-maximum-window-dimensions.bbc b/Task/GUI-Maximum-window-dimensions/BBC-BASIC/gui-maximum-window-dimensions.bbc new file mode 100644 index 0000000000..9860c6d873 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/BBC-BASIC/gui-maximum-window-dimensions.bbc @@ -0,0 +1,5 @@ + SPI_GETWORKAREA = 48 + DIM rc{l%,t%,r%,b%} + SYS "SystemParametersInfo", SPI_GETWORKAREA, 0, rc{}, 0 + PRINT "Maximum width = " ; rc.r% - rc.l% + PRINT "Maximum height = " ; rc.b% - rc.t% diff --git a/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-1.egl b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-1.egl new file mode 100644 index 0000000000..bc7b40f449 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-1.egl @@ -0,0 +1,5 @@ +browser Browser{}; +bvh int = browser.getViewportHeight(); +bvw int = browser.getViewportWidth(); +SysLib.writeStdout("ViewportHeight: " + bvh); +SysLib.writeStdout("ViewportWidth: " + bvw); diff --git a/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-2.egl b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-2.egl new file mode 100644 index 0000000000..8079f1ca5c --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-2.egl @@ -0,0 +1,2 @@ +FMain.Maximized = True +FMain.Visible = False ' The form can be invisible diff --git a/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-3.egl b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-3.egl new file mode 100644 index 0000000000..b9a1b98527 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-3.egl @@ -0,0 +1,7 @@ +PUBLIC SUB _new() + +END + +PUBLIC SUB Form_Open() + +END diff --git a/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-4.egl b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-4.egl new file mode 100644 index 0000000000..62c047491e --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/EGL/gui-maximum-window-dimensions-4.egl @@ -0,0 +1,3 @@ +PUBLIC SUB Form_Resize() + PRINT "The maximum window size that can be used without scrolling is "; FMain.Width; " x "; FMain.Height +END diff --git a/Task/GUI-Maximum-window-dimensions/Haskell/gui-maximum-window-dimensions.hs b/Task/GUI-Maximum-window-dimensions/Haskell/gui-maximum-window-dimensions.hs new file mode 100644 index 0000000000..eb60356a84 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Haskell/gui-maximum-window-dimensions.hs @@ -0,0 +1,52 @@ +import Graphics.UI.Gtk +import Control.Monad (when) +import Control.Monad.Trans (liftIO) + +maximumWindowDimensions :: IO () +maximumWindowDimensions = do + -- initialize the internal state of the GTK toolkit + initGUI + -- create a window + window <- windowNew + -- quit the application when the window is closed + on window objectDestroy mainQuit + -- query the size of the window when its dimensions change + on window configureEvent printSize + -- get the screen the window will be drawn upon + screen <- windowGetScreen window + -- get the size of the screen + x <- screenGetWidth screen + y <- screenGetHeight screen + -- print the dimensions of the screen + putStrLn ("The screen is " ++ show x ++ " pixels wide and " ++ + show y ++ " pixels tall for an undecorated fullscreen window.") + -- maximize the window and show it. printSize will then be called + windowMaximize window + widgetShowAll window + -- run the main GTK loop. + -- close the window manually. + mainGUI + +-- On my Xfce4 desktop, the configure_event is called three times when a +-- top level window is maximized. The first time, the window size +-- returned is the size prior to maximizing, and the last two times +-- it is the size after maximizing. +-- If the window is (un)maximized manually, the size returned is always +-- the size of the unmaximized window. +-- That means: either GTK or Xfce4 does not handle window maximization +-- correctly, or the GTK bindings for Haskell are buggy, or there is an +-- error in this program. + +printSize :: EventM EConfigure Bool +printSize = do + -- get the window that has been resized + w <- eventWindow + -- is the window maximized? + s <- liftIO $ drawWindowGetState w + when (WindowStateMaximized `elem` s) $ do + -- get the size of the window that has been resized + (x, y) <- eventSize + -- print the dimensions out + liftIO $ putStrLn ("The inner window region is now " ++ show x ++ + " pixels wide and " ++ show y ++ " pixels tall.") + return True diff --git a/Task/GUI-Maximum-window-dimensions/Icon/gui-maximum-window-dimensions.icon b/Task/GUI-Maximum-window-dimensions/Icon/gui-maximum-window-dimensions.icon new file mode 100644 index 0000000000..94f52f1961 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Icon/gui-maximum-window-dimensions.icon @@ -0,0 +1,11 @@ +link graphics + +procedure main() # Window size + +W := WOpen("canvas=hidden") +dh := WAttrib("displayheight") +dw := WAttrib("displaywidth") +WClose(W) + +write("The display size is w=",dw,", h=",dh) +end diff --git a/Task/GUI-Maximum-window-dimensions/Mathematica/gui-maximum-window-dimensions.mathematica b/Task/GUI-Maximum-window-dimensions/Mathematica/gui-maximum-window-dimensions.mathematica new file mode 100644 index 0000000000..a98faa9138 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Mathematica/gui-maximum-window-dimensions.mathematica @@ -0,0 +1,2 @@ +Differences@Transpose@SystemInformation["Devices"][[1, 2, 1, 1, 2]] +->{{1260, 951}} diff --git a/Task/GUI-Maximum-window-dimensions/Perl/gui-maximum-window-dimensions.pl b/Task/GUI-Maximum-window-dimensions/Perl/gui-maximum-window-dimensions.pl new file mode 100644 index 0000000000..b3fd347667 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Perl/gui-maximum-window-dimensions.pl @@ -0,0 +1,8 @@ +use strict; +use warnings; +use Tk; + +sub get_size { + my $mw = MainWindow->new(); + return ($mw->maxsize); +} diff --git a/Task/GUI-Maximum-window-dimensions/PicoLisp/gui-maximum-window-dimensions.l b/Task/GUI-Maximum-window-dimensions/PicoLisp/gui-maximum-window-dimensions.l new file mode 100644 index 0000000000..5046048efd --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/PicoLisp/gui-maximum-window-dimensions.l @@ -0,0 +1,9 @@ +(let Frame (java "javax.swing.JFrame" T "Window") + (java Frame 'setExtendedState + (java (public "javax.swing.JFrame" 'MAXIMIZED_BOTH)) ) + (java Frame 'setVisible T) + (wait 200) + (let Size (java (java Frame 'getContentPane) 'getSize) + (prinl "Width: " (java (public Size 'width))) + (prinl "Height: " (java (public Size 'height))) ) + (java Frame 'dispose) ) diff --git a/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-1.tcl b/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-1.tcl new file mode 100644 index 0000000000..9f3663d097 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-1.tcl @@ -0,0 +1,11 @@ +package require Tk +proc maxSize {} { + # Need a dummy window; max window can be changed by scripts + set top .__defaultMaxSize__ + if {![winfo exists $top]} { + toplevel $top + wm withdraw $top + } + # Default max size of window is value we want + return [wm maxsize $top] +} diff --git a/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-2.tcl b/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-2.tcl new file mode 100644 index 0000000000..0d38937381 --- /dev/null +++ b/Task/GUI-Maximum-window-dimensions/Tcl/gui-maximum-window-dimensions-2.tcl @@ -0,0 +1,15 @@ +TYPE syswindowstru + screenheight AS INTEGER + screenwidth AS INTEGER + maxheight AS INTEGER + maxwidth AS INTEGER +END TYPE + +DIM syswindow AS syswindowstru + +' Determine the height and width of the screen + +syswindow.screenwidth = Screen.Width / Screen.TwipsPerPixelX +syswindow.screenheight=Screen.Height / Screen.TwipsPerPixelY + +' Make adjustments for window decorations and menubars diff --git a/Task/GUI-component-interaction/0DESCRIPTION b/Task/GUI-component-interaction/0DESCRIPTION new file mode 100644 index 0000000000..659ad47102 --- /dev/null +++ b/Task/GUI-component-interaction/0DESCRIPTION @@ -0,0 +1,20 @@ +Almost every application needs to communicate with the user in some way. +Therefore, a substantial part of the code deals with the interaction of program +logic with GUI components. Typically, the following is needed: + +* put values into input fields under program control +* read and check input from the user +* pop up dialogs to query the user for further information + +The task: For a minimal "application", write a program that presents a form with +three components to the user: A numeric input field ("Value") and two buttons +("increment" and "random"). + +The field is initialized to zero. The user may manually enter a new value into +the field, or increment its value with the "increment" button. Entering a +non-numeric value should be either impossible, or issue an error message. + +Pressing the "random" button presents a confirmation dialog, and resets the +field's value to a random value if the answer is "Yes". + +(This task may be regarded as an extension of the task [[Simple windowed application]]). diff --git a/Task/GUI-component-interaction/1META.yaml b/Task/GUI-component-interaction/1META.yaml new file mode 100644 index 0000000000..4c5ed293ba --- /dev/null +++ b/Task/GUI-component-interaction/1META.yaml @@ -0,0 +1,4 @@ +--- +note: GUI +requires: +- Graphics diff --git a/Task/GUI-component-interaction/Ada/gui-component-interaction.ada b/Task/GUI-component-interaction/Ada/gui-component-interaction.ada new file mode 100644 index 0000000000..152d546473 --- /dev/null +++ b/Task/GUI-component-interaction/Ada/gui-component-interaction.ada @@ -0,0 +1,158 @@ +with Ada.Numerics.Discrete_Random; +with Ada.Strings.Fixed; +with Gtk.Main; +with Gtk.Handlers; +with Gtk.Button; +with Gtk.Window; +with Gtk.GEntry; +with Gtk.Editable; +with Gtk.Box; +with Gtk.Widget; +with Glib.Values; +with Gtkada.Dialogs; + +procedure Interaction is + + The_Value : Natural := 0; + + package Natural_Random is new Ada.Numerics.Discrete_Random (Natural); + RNG : Natural_Random.Generator; + + Main_Window : Gtk.Window.Gtk_Window; + Content : Gtk.Box.Gtk_Vbox; + Increment_Button : Gtk.Button.Gtk_Button; + Random_Button : Gtk.Button.Gtk_Button; + Entry_Field : Gtk.GEntry.Gtk_Entry; + + package Entry_Callbacks is new Gtk.Handlers.Callback + (Gtk.GEntry.Gtk_Entry_Record); + + package Button_Callbacks is new Gtk.Handlers.Callback + (Gtk.Button.Gtk_Button_Record); + + package Window_Callbacks is new Gtk.Handlers.Return_Callback + (Gtk.Window.Gtk_Window_Record, Boolean); + + -- update displayed text + procedure Update_Entry is + begin + Gtk.GEntry.Set_Text + (The_Entry => Entry_Field, + Text => + Ada.Strings.Fixed.Trim + (Source => Natural'Image (The_Value), + Side => Ada.Strings.Both)); + end Update_Entry; + + -- read from text entry + procedure Update_Value is + begin + The_Value := Natural'Value (Gtk.GEntry.Get_Text (Entry_Field)); + exception + when Constraint_Error => + The_Value := 0; + end Update_Value; + + -- make sure that only numbers are entered + procedure On_Insert_Text + (Object : access Gtk.GEntry.Gtk_Entry_Record'Class; + Params : Glib.Values.GValues) + is + Length : constant Glib.Gint := + Glib.Values.Get_Int (Glib.Values.Nth (Params, 2)); + Text : constant String := + Glib.Values.Get_String (Glib.Values.Nth (Params, 1), Length); + begin + declare + Number : Natural; + begin + Number := Natural'Value (Text); + exception + when Constraint_Error => + -- refuse values that are not parsable + Gtk.Handlers.Emit_Stop_By_Name + (Object => Object, + Name => Gtk.Editable.Signal_Insert_Text); + end; + end On_Insert_Text; + + -- Callback for click event + procedure On_Increment_Click + (Object : access Gtk.Button.Gtk_Button_Record'Class) + is + begin + Update_Value; + The_Value := The_Value + 1; + Update_Entry; + end On_Increment_Click; + + -- Callback for click event + procedure On_Random_Click + (Object : access Gtk.Button.Gtk_Button_Record'Class) + is + use type Gtkada.Dialogs.Message_Dialog_Buttons; + begin + if Gtkada.Dialogs.Message_Dialog + (Msg => "Really reset to random value?", + Dialog_Type => Gtkada.Dialogs.Confirmation, + Buttons => Gtkada.Dialogs.Button_Yes or + Gtkada.Dialogs.Button_No, + Default_Button => Gtkada.Dialogs.Button_Yes) = + Gtkada.Dialogs.Button_Yes + then + The_Value := Natural_Random.Random (RNG); + Update_Entry; + end if; + end On_Random_Click; + + -- Callback for delete event + function On_Main_Window_Delete + (Object : access Gtk.Window.Gtk_Window_Record'Class) + return Boolean + is + begin + Gtk.Main.Main_Quit; + return True; + end On_Main_Window_Delete; + +begin + -- initialize random number generator + Natural_Random.Reset (RNG); + + Gtk.Main.Init; + + Gtk.GEntry.Gtk_New (Widget => Entry_Field); + Update_Entry; + Entry_Callbacks.Connect + (Widget => Entry_Field, + Name => Gtk.Editable.Signal_Insert_Text, + Cb => On_Insert_Text'Access); + + Gtk.Button.Gtk_New (Button => Increment_Button, Label => "Increment"); + Gtk.Button.Gtk_New (Button => Random_Button, Label => "Random"); + + Button_Callbacks.Connect + (Widget => Increment_Button, + Name => Gtk.Button.Signal_Clicked, + Marsh => Button_Callbacks.To_Marshaller (On_Increment_Click'Access)); + Button_Callbacks.Connect + (Widget => Random_Button, + Name => Gtk.Button.Signal_Clicked, + Marsh => Button_Callbacks.To_Marshaller (On_Random_Click'Access)); + + Gtk.Box.Gtk_New_Vbox (Box => Content); + Gtk.Box.Add (Container => Content, Widget => Entry_Field); + Gtk.Box.Add (Container => Content, Widget => Increment_Button); + Gtk.Box.Add (Container => Content, Widget => Random_Button); + + Gtk.Window.Gtk_New (Window => Main_Window); + Gtk.Window.Add (Container => Main_Window, Widget => Content); + + Window_Callbacks.Connect + (Widget => Main_Window, + Name => Gtk.Widget.Signal_Delete_Event, + Cb => On_Main_Window_Delete'Access); + Gtk.Window.Show_All (Widget => Main_Window); + + Gtk.Main.Main; +end Interaction; diff --git a/Task/GUI-component-interaction/AutoHotkey/gui-component-interaction.ahk b/Task/GUI-component-interaction/AutoHotkey/gui-component-interaction.ahk new file mode 100644 index 0000000000..2e23545235 --- /dev/null +++ b/Task/GUI-component-interaction/AutoHotkey/gui-component-interaction.ahk @@ -0,0 +1,56 @@ +GUI, add, Edit,Number w50 vUserInput, 0 ; Number Specifies Numbers-only, but other characters can still be pasted in, + ; Making our own check necessary. (MakeSure) + +GUI, add, Button, gIncrement, Increment ; Instead of an increment button, the UpDown control could be used, but this was not specified. +GUI, add, Button, gRando, Random +Gui, Show, W200 y200, Title ; Shows the GUI with a width and height of 200px +SetTimer, MakeSure, 1000 ; Runs MakeSure every second +return ; End Auto-Execute Section + + +Increment: +Gui, Submit, NoHide +; The above line assigns all variables associated with controls to the state of that control, but leaves the GUI visible. +If UserInput is not Number +{ + MsgBox, %userInput% is not a number. + GUIControl,,UserInput, 0 ; Reset the Edit control to 0 +} +Else +{ + UserInput++ + GUIControl,, UserInput, %UserInput% ; Sets the value of the Edit control +} +return + + + +Rando: +MsgBox, 4, Title, Are you sure you want to randomize? ; Specify your own title. 4 means YesNo +IfMsgBox, Yes +{ + Random, UserInput, 1, 999 ; random number from 1-999 + GUIControl,, UserInput, %UserInput% ; Sets the value of the Edit control +} +return + + + +MakeSure: +Gui, Submit, NoHide +If UserInput is not Number +{ + If (UserInput<>"") + { + Msgbox Error! Numbers Only! + GUIControl,, UserInput, 0 + } +} +return + + + +GUIClose: +ExitApp ; Makes sure the script exits when the window is closed, + ; Otherwise the script is persistent because it contains + ; a timer. diff --git a/Task/GUI-component-interaction/BBC-BASIC/gui-component-interaction.bbc b/Task/GUI-component-interaction/BBC-BASIC/gui-component-interaction.bbc new file mode 100644 index 0000000000..f74aaaed8b --- /dev/null +++ b/Task/GUI-component-interaction/BBC-BASIC/gui-component-interaction.bbc @@ -0,0 +1,30 @@ + INSTALL @lib$+"WINLIB2" + INSTALL @lib$+"WINLIB5" + + IDYES = 6 + ES_NUMBER = 8192 + MB_YESNO = 4 + + form% = FN_newdialog("Rosetta Code", 100, 100, 100, 52, 8, 1000) + PROC_static(form%, "Value:", 100, 10, 10, 24, 14, 0) + PROC_editbox(form%, "0", 101, 40, 8, 52, 14, ES_NUMBER) + PROC_pushbutton(form%, "Increment", FN_setproc(PROCinc), 7, 30, 40, 16, 0) + PROC_pushbutton(form%, "Random", FN_setproc(PROCrandom), 52, 30, 40, 16, 0) + PROC_showdialog(form%) + + REPEAT + WAIT 1 + UNTIL !form% = 0 + QUIT + + DEF PROCinc + LOCAL number% + SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% + SYS "SetDlgItemInt", !form%, 101, number% + 1, 1 + ENDPROC + + DEF PROCrandom + LOCAL reply% + SYS "MessageBox", !form%, "Set to a random value?", "Confirm", MB_YESNO TO reply% + IF reply% = IDYES THEN SYS "SetDlgItemInt", !form%, 101, RND(10000), 1 + ENDPROC diff --git a/Task/GUI-component-interaction/C++/gui-component-interaction-1.cpp b/Task/GUI-component-interaction/C++/gui-component-interaction-1.cpp new file mode 100644 index 0000000000..fd023f38bd --- /dev/null +++ b/Task/GUI-component-interaction/C++/gui-component-interaction-1.cpp @@ -0,0 +1,22 @@ +#ifndef INTERACTION_H +#define INTERACTION_H +#include + +class QPushButton ; +class QLineEdit ; +class QVBoxLayout ; +class MyWidget : public QWidget { + Q_OBJECT + +public : + MyWidget( QWidget *parent = 0 ) ; +private : + QLineEdit *entryField ; + QPushButton *increaseButton ; + QPushButton *randomButton ; + QVBoxLayout *myLayout ; +private slots : + void doIncrement( ) ; + void findRandomNumber( ) ; +} ; +#endif diff --git a/Task/GUI-component-interaction/C++/gui-component-interaction-2.cpp b/Task/GUI-component-interaction/C++/gui-component-interaction-2.cpp new file mode 100644 index 0000000000..0167fb1755 --- /dev/null +++ b/Task/GUI-component-interaction/C++/gui-component-interaction-2.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include +#include //for the srand initialization +#include //for the random number +#include "interaction.h" + +MyWidget::MyWidget (QWidget *parent ) : QWidget( parent ) { + myLayout = new QVBoxLayout( ) ; + entryField = new QLineEdit( "0" ) ; + QRegExp rx( "\\d+" ) ; + QValidator *myvalidator = new QRegExpValidator( rx , this ) ; + entryField->setValidator( myvalidator ) ; + increaseButton = new QPushButton( "increase" ) ; + connect( increaseButton, SIGNAL( clicked( ) ) , + this , SLOT( doIncrement( ) )) ; + randomButton = new QPushButton( "random" ) ; + connect( randomButton , SIGNAL( clicked( ) ) , + this , SLOT ( findRandomNumber( ) )) ; + myLayout->addWidget( entryField ) ; + myLayout->addWidget( increaseButton ) ; + myLayout->addWidget( randomButton ) ; + setLayout( myLayout ) ; +} + +void MyWidget::doIncrement( ) { + bool ok ; + int zahl = entryField->text( ).toInt( &ok, 10 ) ; + entryField->setText( QString( "%1").arg( ++zahl ) ) ; +} + +void MyWidget::findRandomNumber( ) { + QMessageBox msgBox( this ) ; + msgBox.setText( "Do you want to create a random number ?" ) ; + msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No ) ; + int ret = msgBox.exec( ) ; + switch ( ret ) { + case QMessageBox::Yes : + srand( time( 0 ) ) ; + int zahl = random( ) ; + entryField->setText( QString( "%1" ).arg( zahl )) ; + break ; + } +} diff --git a/Task/GUI-component-interaction/C++/gui-component-interaction-3.cpp b/Task/GUI-component-interaction/C++/gui-component-interaction-3.cpp new file mode 100644 index 0000000000..670d76bdf4 --- /dev/null +++ b/Task/GUI-component-interaction/C++/gui-component-interaction-3.cpp @@ -0,0 +1,9 @@ +#include +#include "interaction.h" + +int main( int argc , char *argv[ ] ) { + QApplication app( argc, argv ) ; + MyWidget theWidget ; + theWidget.show( ) ; + return app.exec( ) ; +} diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-1.delphi b/Task/GUI-component-interaction/Delphi/gui-component-interaction-1.delphi new file mode 100644 index 0000000000..7e547c13ea --- /dev/null +++ b/Task/GUI-component-interaction/Delphi/gui-component-interaction-1.delphi @@ -0,0 +1 @@ +FILE: Unit1.pas diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-2.delphi b/Task/GUI-component-interaction/Delphi/gui-component-interaction-2.delphi new file mode 100644 index 0000000000..e4e70e8515 --- /dev/null +++ b/Task/GUI-component-interaction/Delphi/gui-component-interaction-2.delphi @@ -0,0 +1,51 @@ +unit Unit1; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls; + +type + TForm1 = class(TForm) + EditInputField: TEdit; + ButtonRandom: TButton; + ButtonIncrement: TButton; + procedure EditInputFieldChange(Sender: TObject); + procedure ButtonIncrementClick(Sender: TObject); + procedure ButtonRandomClick(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.dfm} + +procedure TForm1.EditInputFieldChange(Sender: TObject); +begin + TRY + StrToInt(EditInputField.Text); + EXCEPT + ShowMessage('Error! The Input Value is not numeric!'); + EditInputField.Text := '0'; + END; +end; + +procedure TForm1.ButtonIncrementClick(Sender: TObject); +begin + EditInputField.text := IntToStr(StrToInt(EditInputField.Text) + 1); +end; + +procedure TForm1.ButtonRandomClick(Sender: TObject); +begin + Randomize; + EditInputField.Text := IntToStr(Random(High(Integer))); +end; + +end. diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-3.delphi b/Task/GUI-component-interaction/Delphi/gui-component-interaction-3.delphi new file mode 100644 index 0000000000..f21180497e --- /dev/null +++ b/Task/GUI-component-interaction/Delphi/gui-component-interaction-3.delphi @@ -0,0 +1 @@ +FILE: Unit1.dfm (No manual interaction!!! Will automatically be generated/modified when editing the GUI) diff --git a/Task/GUI-component-interaction/Delphi/gui-component-interaction-4.delphi b/Task/GUI-component-interaction/Delphi/gui-component-interaction-4.delphi new file mode 100644 index 0000000000..70a7476849 --- /dev/null +++ b/Task/GUI-component-interaction/Delphi/gui-component-interaction-4.delphi @@ -0,0 +1,43 @@ +object Form1: TForm1 + Left = 1899 + Top = 212 + Width = 266 + Height = 172 + Caption = 'Form1' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + PixelsPerInch = 96 + TextHeight = 13 + object EditInputField: TEdit + Left = 16 + Top = 16 + Width = 121 + Height = 21 + TabOrder = 0 + Text = '0' + OnChange = EditInputFieldChange + end + object ButtonRandom: TButton + Left = 96 + Top = 56 + Width = 75 + Height = 25 + Caption = 'Random' + TabOrder = 1 + OnClick = ButtonRandomClick + end + object ButtonIncrement: TButton + Left = 16 + Top = 56 + Width = 75 + Height = 25 + Caption = 'Increment' + TabOrder = 2 + OnClick = ButtonIncrementClick + end +end diff --git a/Task/GUI-component-interaction/Fantom/gui-component-interaction.fantom b/Task/GUI-component-interaction/Fantom/gui-component-interaction.fantom new file mode 100644 index 0000000000..cb71510963 --- /dev/null +++ b/Task/GUI-component-interaction/Fantom/gui-component-interaction.fantom @@ -0,0 +1,65 @@ +using fwt +using gfx + +class GuiComponent +{ + public static Void main () + { + Window + { + title = "Rosetta Code: Gui component" + size = Size(350, 200) + textField := Text + { + onModify.add |Event e| + { + Text thisText := e.widget + if (thisText.text != "") // if nonempty string + { + try (thisText.text.toInt) // try converting to int + catch thisText.text = "" // clear field if does not work + } + } + } + GridPane + { + numCols = 1 + textField, + Button + { + text = "increment" + onAction.add |Event e| + { // make sure there is a number to increment, else set field to 0 + if (textField.text == "") + { + textField.text = "0" + } + else + { + try + { + Int x := textField.text.toInt + textField.text = (x+1).toStr + } + catch + { + textField.text = "0" + } + } + } + }, + Button + { + text = "random" + onAction.add |Event e| + { + if (Dialog.openQuestion(e.window, "Make number random?", null, Dialog.yesNo) == Dialog.yes) + { + textField.text = Int.random(1..10000).toStr + } + } + }, + }, + }.open + } +} diff --git a/Task/GUI-component-interaction/Haskell/gui-component-interaction-1.hs b/Task/GUI-component-interaction/Haskell/gui-component-interaction-1.hs new file mode 100644 index 0000000000..e1e412cd55 --- /dev/null +++ b/Task/GUI-component-interaction/Haskell/gui-component-interaction-1.hs @@ -0,0 +1,26 @@ +import Graphics.UI.WX +import System.Random + +main :: IO () +main = start $ do + frm <- frame [text := "Interact"] + fld <- textEntry frm [text := "0", on keyboard := checkKeys] + inc <- button frm [text := "increment", on command := increment fld] + ran <- button frm [text := "random", on command := (randReplace fld frm)] + set frm [layout := margin 5 $ floatCentre $ column 2 + [centre $ widget fld, row 2 [widget inc, widget ran]]] + +increment :: Textual w => w -> IO () +increment field = do + val <- get field text + when ((not . null) val) $ set field [text := show $ 1 + read val] + +checkKeys :: EventKey -> IO () +checkKeys (EventKey key _ _) = + when (elem (show key) $ "Backspace" : map show [0..9]) propagateEvent + +randReplace :: Textual w => w -> Window a -> IO () +randReplace field frame = do + answer <- confirmDialog frame "Random" "Generate a random number?" True + when answer $ getStdRandom (randomR (1,100)) >>= \num -> + set field [text := show (num :: Int)] diff --git a/Task/GUI-component-interaction/Haskell/gui-component-interaction-2.hs b/Task/GUI-component-interaction/Haskell/gui-component-interaction-2.hs new file mode 100644 index 0000000000..7bfedfd2de --- /dev/null +++ b/Task/GUI-component-interaction/Haskell/gui-component-interaction-2.hs @@ -0,0 +1,107 @@ +import gui +$include "guih.icn" + +# Provides a basic message dialog +class MessageDialog : Dialog (message) + method component_setup () + label := Label ("label="||message, "pos=20,20") + add (label) + button := TextButton("label=OK", "pos=100,60") + button.connect (self, "dispose", ACTION_EVENT) + add (button) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + attrib ("size=200,100", "bg=light gray") + end + + initially (message) + self.Dialog.initially() + self.message := message +end + +# Provides a basic yes/no question dialog +class QuestionDialog : Dialog (answer, message) + method answered_yes () + return answer == "yes" + end + + method answer_yes () + answer := "yes" + dispose () + end + + method answer_no () + answer := "no" + dispose () + end + + method component_setup () + label := Label ("label="||message, "pos=20,20") + add (label) + buttonYes := TextButton("label=Yes", "pos=40,60") + buttonYes.connect (self, "answer_yes", ACTION_EVENT) + add (buttonYes) + buttonNo := TextButton("label=No", "pos=120,60") + buttonNo.connect (self, "answer_no", ACTION_EVENT) + add (buttonNo) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + attrib ("size=200,100", "bg=light gray") + end + + initially (message) + self.Dialog.initially() + self.answer := "no" + self.message := message +end + +# The main window, displays the different components +class WindowApp : Dialog (field, value) + method increment () + value +:= 1 + field.set_contents (string(value)) + end + + method random () + query := QuestionDialog ("Set to random?") + query.show_modal () + if query.answered_yes () then { + value := ?100 + field.set_contents (string(value)) + } + end + + method handle_text_field () + if not(integer(field.get_contents ())) + then { + warning := MessageDialog ("Not a number") + warning.show_modal () + field.set_contents (string(value)) + } + else { + value := integer(field.get_contents ()) + } + end + + method component_setup () + value := 0 + field := TextField("contents="||value, "pos=20,20", "size=150") + field.connect (self, "handle_text_field", TEXTFIELD_CHANGED_EVENT) + add (field) + button1 := TextButton("label=Increment", "pos=20,60", "size=70") + button1.connect (self, "increment", ACTION_EVENT) + add (button1) + button2 := TextButton("label=Random", "pos=100,60", "size=70") + button2.connect (self, "random", ACTION_EVENT) + add (button2) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + attrib ("size=200,100", "bg=light gray") + end +end + +# create and show the window +procedure main () + w := WindowApp () + w.show_modal () +end diff --git a/Task/GUI-component-interaction/J/gui-component-interaction-1.j b/Task/GUI-component-interaction/J/gui-component-interaction-1.j new file mode 100644 index 0000000000..dcd2487d40 --- /dev/null +++ b/Task/GUI-component-interaction/J/gui-component-interaction-1.j @@ -0,0 +1,32 @@ +INTERACT=: 0 : 0 +pc interact closeok; +xywh 6 6 48 12;cc Value edit; +xywh 6 18 48 12;cc increment button;cn "+"; +xywh 6 30 48 12;cc random button;cn "?"; +pas 6 6;pcenter; +rem form end; +) + +interact_run=: 3 : 0 + wd INTERACT + wd 'set Value 0;' + wd 'pshow;' +) + +interact_close=: 3 : 0 + wd'pclose' +) + +interact_Value_button=: 3 : 0 + wd 'set Value ' , ": {. 0 ". Value +) + +interact_increment_button=: 3 : 0 + wd 'set Value ' , ": 1 + {. 0 ". Value +) + +interact_random_button=: 3 : 0 + if. 0 = 2 wdquery 'Confirm';'Reset to random number?' do. + wd 'set Value ' , ": ?100 + end. +) diff --git a/Task/GUI-component-interaction/J/gui-component-interaction-2.j b/Task/GUI-component-interaction/J/gui-component-interaction-2.j new file mode 100644 index 0000000000..627b35345d --- /dev/null +++ b/Task/GUI-component-interaction/J/gui-component-interaction-2.j @@ -0,0 +1 @@ +interact_run'' diff --git a/Task/GUI-component-interaction/Java/gui-component-interaction.java b/Task/GUI-component-interaction/Java/gui-component-interaction.java new file mode 100644 index 0000000000..643611a4fb --- /dev/null +++ b/Task/GUI-component-interaction/Java/gui-component-interaction.java @@ -0,0 +1,93 @@ +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class Interact extends JFrame{ + final JTextField numberField; + final JButton incButton, randButton; + + public Interact(){ + //stop the GUI threads when the user hits the X button + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + numberField = new JTextField(); + incButton = new JButton("Increment"); + randButton = new JButton("Random"); + + numberField.setText("0");//start at 0 + + //listen for button presses in the text field + numberField.addKeyListener(new KeyListener(){ + @Override + public void keyTyped(KeyEvent e) { + //if the entered character is not a digit + if(!Character.isDigit(e.getKeyChar())){ + //eat the event (i.e. stop it from being processed) + e.consume(); + } + } + @Override + public void keyReleased(KeyEvent e){} + @Override + public void keyPressed(KeyEvent e){} + }); + + //listen for button clicks on the increment button + incButton.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent e) { + String text = numberField.getText(); + if(text.isEmpty()){ + numberField.setText("1"); + }else{ + numberField.setText((Long.valueOf(text) + 1) + ""); + } + } + }); + + //listen for button clicks on the random button + randButton.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent e) { + //show a dialog and if they answer "Yes" + if(JOptionPane.showConfirmDialog(null, "Are you sure?") == + JOptionPane.YES_OPTION){ + //set the text field text to a random positive long + numberField.setText(Long.toString((long)(Math.random() + * Long.MAX_VALUE))); + } + } + }); + + //arrange the components in a grid with 2 rows and 1 column + setLayout(new GridLayout(2, 1)); + + //a secondary panel for arranging both buttons in one grid space in the window + JPanel buttonPanel = new JPanel(); + + //the buttons are in a grid with 1 row and 2 columns + buttonPanel.setLayout(new GridLayout(1, 2)); + //add the buttons + buttonPanel.add(incButton); + buttonPanel.add(randButton); + + //put the number field on top of the buttons + add(numberField); + add(buttonPanel); + //size the window appropriately + pack(); + + } + + public static void main(String[] args){ + new Interact().setVisible(true); + } +} diff --git a/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-1.liberty b/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-1.liberty new file mode 100644 index 0000000000..00d7a2d548 --- /dev/null +++ b/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-1.liberty @@ -0,0 +1,56 @@ +nomainwin + textbox #demo.val, 20, 50, 90, 24 + button #demo.inc, "Increment", [btnIncrement], UL, 20, 90, 90, 24 + button #demo.rnd, "Random", [btnRandom], UL, 20, 120, 90, 24 + open "Rosetta Task: GUI component interaction" for window as #demo + #demo "trapclose [quit]" + validNum$ = "0123456789." + #demo.val 0 +wait + +[quit] + close #demo +end + +[btnIncrement] + #demo.val "!contents? nVal$" + nVal$ = trim$(nVal$) + if left$(nVal$, 1) = "-" then + neg = 1 + nVal$ = mid$(nVal$, 2) + else + neg = 0 + end if + validNum = 1 + nDecs = 0 + for i = 1 to len(nVal$) + if instr(validNum$, mid$(nVal$, i, 1)) = 0 then + validNum = 0 + end if + if mid$(nVal$, i, 1) = "." then + nDecs = nDecs + 1 + end if + next i + if nDecs > 1 then + validNum = 0 + end if + if neg = 1 then + nVal$ = "-";nVal$ + end if + if validNum = 0 then + notice nVal$;" does not appear to be a valid number. " + _ + "(Commas are not allowed.)" + else + nVal = val(nVal$) + nVal = nVal + 1 + end if + #demo.val nVal +wait + +[btnRandom] + confirm "Reset value to random number";yn$ + if yn$ = "yes" then + nVal = int(rnd(1) * 100) + 1 + #demo.val nVal + end if +wait diff --git a/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-2.liberty b/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-2.liberty new file mode 100644 index 0000000000..6f6ecd00ec --- /dev/null +++ b/Task/GUI-component-interaction/Liberty-BASIC/gui-component-interaction-2.liberty @@ -0,0 +1,27 @@ +nomainwin + stylebits #demo.val, _ES_NUMBER, 0, 0, 0 + textbox #demo.val, 20, 50, 90, 24 + button #demo.inc, "Increment", [btnIncrement], UL, 20, 90, 90, 24 + button #demo.rnd, "Random", [btnRandom], UL, 20, 120, 90, 24 + open "Rosetta Task: GUI component interaction" for window as #demo + #demo "trapclose [quit]" + #demo.val 0 +wait + +[quit] + close #demo +end + +[btnIncrement] + #demo.val "!contents? nVal" + nVal = nVal + 1 + #demo.val nVal +wait + +[btnRandom] + confirm "Reset value to random number";yn$ + if yn$ = "yes" then + nVal = int(rnd(1) * 100) + 1 + #demo.val nVal + end if +wait diff --git a/Task/GUI-component-interaction/Mathematica/gui-component-interaction.mathematica b/Task/GUI-component-interaction/Mathematica/gui-component-interaction.mathematica new file mode 100644 index 0000000000..ddecc53a91 --- /dev/null +++ b/Task/GUI-component-interaction/Mathematica/gui-component-interaction.mathematica @@ -0,0 +1,8 @@ +Manipulate[Null, {{value, 0}, InputField[Dynamic[value], Number] &}, + Row@{Button["increment", value++], + Button["random", + If[DialogInput[ + Column@{"Are you sure?", + Row@{Button["Yes", DialogReturn[True]], + Button["No", DialogReturn[False]]}}], + value = RandomInteger@10000], Method -> "Queued"]}] diff --git a/Task/GUI-component-interaction/PicoLisp/gui-component-interaction.l b/Task/GUI-component-interaction/PicoLisp/gui-component-interaction.l new file mode 100644 index 0000000000..24528796eb --- /dev/null +++ b/Task/GUI-component-interaction/PicoLisp/gui-component-interaction.l @@ -0,0 +1,18 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l") + +(de start () + (and (app) (zero *Number)) + (action + (html 0 "Increment" "@lib.css" NIL + (form NIL + (gui '(+Var +NumField) '*Number 20 "Value") + (gui '(+JS +Button) "increment" + '(inc '*Number) ) + (gui '(+Button) "random" + '(ask "Reset to a random value?" + (setq *Number (rand)) ) ) ) ) ) ) + +(server 8080 "!start") +(wait) diff --git a/Task/GUI-component-interaction/Prolog/gui-component-interaction.pro b/Task/GUI-component-interaction/Prolog/gui-component-interaction.pro new file mode 100644 index 0000000000..258e30717f --- /dev/null +++ b/Task/GUI-component-interaction/Prolog/gui-component-interaction.pro @@ -0,0 +1,81 @@ +dialog('GUI_Interaction', + [ object := + GUI_Interaction, + parts := + [ GUI_Interaction := + dialog('Rosetta Code'), + Input_field := + text_item(input_field), + Increment := + button(increment), + Random := + button(random) + ], + modifications := + [ Input_field := [ label := 'Value :', + length := 28 + ] + ], + layout := + [ area(Input_field, + area(54, 24, 251, 24)), + area(Increment, + area(54, 90, 80, 24)), + area(Random, + area(230, 90, 80, 24)) + ], + behaviour := + + [ + Increment := [ + message := message(@prolog, + increment, + Input_field ) + ], + Random := [ + message := message(@prolog, + my_random, + Input_field) + ], + Input_field := [ + message := message(@prolog, + input, + GUI_Interaction, + Increment, + @receiver, + @arg1) + ] + ] + + ]). + +gui_component :- + make_dialog(S, 'GUI_Interaction'), + send(S, open). + + +increment(Input) :- + get(Input, selection, V), + atom_number(V, Val), + Val1 is Val + 1, + send(Input, selection, Val1). + +my_random(Input) :- + new(D, dialog('GUI Interaction')), + send(D, append(label(lbl,'Confirm your choice !'))), + send(D, append(button(ok, message(D, return, ok)))), + send(D, append(button(cancel, message(D, return, ko)))), + send(D, default_button(ok)), + get(D, confirm, Rval), + free(D), + ( Rval = ok + -> X is random(10000), + send(Input, selection, X) + ). + + +input(Gui, Btn, Input, Selection) :- + catch( (term_to_atom(T, Selection), number(T), send(Gui, focus, Btn)), + _, + ( send(@display, inform, 'Please type a number !'), + send(Input,clear))). diff --git a/Task/GUI-component-interaction/R/gui-component-interaction.r b/Task/GUI-component-interaction/R/gui-component-interaction.r new file mode 100644 index 0000000000..538b7e7920 --- /dev/null +++ b/Task/GUI-component-interaction/R/gui-component-interaction.r @@ -0,0 +1,30 @@ +library(gWidgets) +options(guiToolkit="RGtk2") ## using gWidgtsRGtk2 + +w <- gwindow("Interaction") + +g <- ggroup(cont=w, horizontal=FALSE) +e <- gedit(0, cont=g, coerce.with=as.numeric) +bg <- ggroup(cont=g) + +inc_btn <- gbutton("increment", cont=bg) +rdm_btn <- gbutton("random", cont=bg) + +addHandlerChanged(e, handler=function(h,...) { + val <- svalue(e) + if(is.na(val)) + galert("You need to enter a number", parent=w) +}) + +addHandlerChanged(inc_btn, handler=function(h,...) { + val <- svalue(e) + if(is.na(val)) + galert("Can't increment if not a number", parent=w) + else + svalue(e) <- val + 1 +}) + +addHandlerChanged(rdm_btn, handler=function(h,...) { + if(gconfirm("Really replace value?")) + svalue(e) <- sample(1:1000, 1) +}) diff --git a/Task/GUI-component-interaction/Ruby/gui-component-interaction.rb b/Task/GUI-component-interaction/Ruby/gui-component-interaction.rb new file mode 100644 index 0000000000..6dd193ea9e --- /dev/null +++ b/Task/GUI-component-interaction/Ruby/gui-component-interaction.rb @@ -0,0 +1,19 @@ +Shoes.app do + stack do + @textbox = edit_line + + @textbox.change do + @textbox.text = @textbox.text.gsub(/[^\d]/, '') and alert "Input must be a number!" if @textbox.text !~ /^\d*$/ + end + + flow do + button "Increment" do + @textbox.text = @textbox.text.to_i + 1 + end + + button "Random" do + @textbox.text = rand 5000 if confirm "Do you want a random number?" + end + end + end +end diff --git a/Task/GUI-component-interaction/Scala/gui-component-interaction.scala b/Task/GUI-component-interaction/Scala/gui-component-interaction.scala new file mode 100644 index 0000000000..bc5d42d0dc --- /dev/null +++ b/Task/GUI-component-interaction/Scala/gui-component-interaction.scala @@ -0,0 +1,46 @@ +import scala.swing._ +import scala.swing.Swing._ +import scala.swing.event._ + +object Interact extends SimpleSwingApplication { + def top = new MainFrame { + title = "Rosetta Code >>> Task: component interaction | Language: Scala" + + val numberField = new TextField { text = "0" } // start at 0 + + val incButton = new Button { text = "Increment" } + val randButton = new Button { text = "Random" } + + // arrange buttons in a grid with 1 row, 2 columns + val buttonPanel = new GridPanel(1, 2) { + contents ++= List(incButton, randButton) + } + + // arrange text field and button panel in a grid with 2 row, 1 column + contents = new GridPanel(2, 1) { + contents ++= List(numberField, buttonPanel) + } + + // listen for keys pressed in numberField and button clicks + listenTo(numberField.keys, incButton, randButton) + reactions += { + case kt: KeyTyped if (!kt.char.isDigit) => // if the entered char isn't a digit ... + kt.consume // ... eat the event (i.e. stop it from being processed) + case ButtonClicked(`incButton`) => + if (numberField.text.isEmpty()) numberField.text = "0" + // we use BigInt to avoid long overflow/number format exception + val biNumber = new BigInt(new java.math.BigInteger(numberField.text)) + numberField.text = "" + (biNumber+1) + case ButtonClicked(`randButton`) => + import Dialog._ + numberField.text = showOptions(buttonPanel, + message = "Are you sure?", + title = "Choose an option!", + entries = List("Yes", "No", "Cancel"), + initial = 2) match { + case Result.Yes => (Long.MaxValue * Math.random).toLong.toString + case _ => numberField.text + } + } + } +} diff --git a/Task/GUI-component-interaction/Smalltalk/gui-component-interaction.st b/Task/GUI-component-interaction/Smalltalk/gui-component-interaction.st new file mode 100644 index 0000000000..8b46af8d23 --- /dev/null +++ b/Task/GUI-component-interaction/Smalltalk/gui-component-interaction.st @@ -0,0 +1,18 @@ +|top input vh incButton rndButton| + +vh := ValueHolder with:0. + +top := StandardSystemView label:'Rosetta GUI interaction'. +top extent:300@100. +top add:((Label label:'Value:') origin: 0 @ 10 corner: 100 @ 40). +top add:(input := EditField origin: 102 @ 10 corner: 1.0 @ 40). +input model:(TypeConverter onNumberValue:vh). +input acceptOnLostFocus:true; acceptOnReturn:true. + +top add:((incButton := Button label:'Inc') origin: 10 @ 50 corner: 100 @ 80). +top add:((rndButton := Button label:'Rnd') origin: 110 @ 50 corner: 210 @ 80). + +incButton action:[ vh value: (vh value + 1) ]. +rndButton action:[ vh value: Random nextInteger ]. + +top open diff --git a/Task/GUI-component-interaction/Tcl/gui-component-interaction.tcl b/Task/GUI-component-interaction/Tcl/gui-component-interaction.tcl new file mode 100644 index 0000000000..e9f29175e0 --- /dev/null +++ b/Task/GUI-component-interaction/Tcl/gui-component-interaction.tcl @@ -0,0 +1,35 @@ +package require Tk + +###--- Our data Model! ---### +# A single variable will do just fine +set field 0 + +###--- Lay out the GUI components in our View ---### +# We use the Ttk widget set here; it looks much better on Windows and OSX + +# First, a quick hack to make things look even nicer +place [ttk::frame .bg] -relwidth 1 -relheight 1 + +# A labelled frame containing an entry field constrained to use numbers +pack [ttk::labelframe .val -text "Value"] +pack [ttk::entry .val.ue -textvariable field \ + -validate key -invalidcommand bell \ + -validatecommand {string is integer %P}] +# Now, a pair of buttons +pack [ttk::button .inc -text "increment" -command step] +pack [ttk::button .rnd -text "random" -command random] + +###--- Now we define the behaviors, the Controller ---### +# How to respond to a click on the "increment" button +proc step {} { + global field + incr field +} +# How to respond to a click on the "random" button +proc random {} { + global field + if {[tk_messageBox -type yesno -parent . \ + -message "Reset to random?"] eq "yes"} { + set field [expr {int(rand() * 5000)}] + } +} diff --git a/Task/GUI-enabling-disabling-of-controls/0DESCRIPTION b/Task/GUI-enabling-disabling-of-controls/0DESCRIPTION new file mode 100644 index 0000000000..9458dae01e --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/0DESCRIPTION @@ -0,0 +1,22 @@ +In addition to fundamental [[GUI component interaction]], an application should +dynamically enable and disable GUI components, to give some guidance to the +user, and prohibit (inter)actions which are inappropriate in the current state +of the application. + +The task: Similar to the task [[GUI component interaction]] write a program that +presents a form with three components to the user: A numeric input field +("Value") and two buttons ("increment" and "decrement"). + +The field is initialized to zero. The user may manually enter a new value into +the field, increment its value with the "increment" button, or decrement the +value with the "decrement" button. + +The input field should be enabled only when its value is zero. The "increment" +button only as long as the field's value is less then 10: When the value 10 is +reached, the button should go into a disabled state. Analogously, the +"decrement" button should be enabled only as long as the value is greater than +zero. + +Effectively, the user can now either increment up to 10, or down to zero. +Manually entering values outside that range is still legal, but the buttons +should reflect that and enable/disable accordingly. diff --git a/Task/GUI-enabling-disabling-of-controls/1META.yaml b/Task/GUI-enabling-disabling-of-controls/1META.yaml new file mode 100644 index 0000000000..4c5ed293ba --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/1META.yaml @@ -0,0 +1,4 @@ +--- +note: GUI +requires: +- Graphics diff --git a/Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.ada b/Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.ada new file mode 100644 index 0000000000..e64a63f3fe --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Ada/gui-enabling-disabling-of-controls.ada @@ -0,0 +1,169 @@ +with Ada.Strings.Fixed; +with Gtk.Main; +with Gtk.Handlers; +with Gtk.Button; +with Gtk.Window; +with Gtk.GEntry; +with Gtk.Editable; +with Gtk.Box; +with Gtk.Widget; +with Glib.Values; + +procedure Disabling is + type My_Natural is range 0 .. 10; + + The_Value : My_Natural := 0; + + Main_Window : Gtk.Window.Gtk_Window; + Content : Gtk.Box.Gtk_Vbox; + Increment_Button : Gtk.Button.Gtk_Button; + Decrement_Button : Gtk.Button.Gtk_Button; + Entry_Field : Gtk.GEntry.Gtk_Entry; + + package Entry_Callbacks is new Gtk.Handlers.Callback + (Gtk.GEntry.Gtk_Entry_Record); + + package Button_Callbacks is new Gtk.Handlers.Callback + (Gtk.Button.Gtk_Button_Record); + + package Window_Callbacks is new Gtk.Handlers.Return_Callback + (Gtk.Window.Gtk_Window_Record, Boolean); + + -- update displayed text + procedure Update_Entry is + begin + Gtk.GEntry.Set_Text + (The_Entry => Entry_Field, + Text => + Ada.Strings.Fixed.Trim + (Source => My_Natural'Image (The_Value), + Side => Ada.Strings.Both)); + end Update_Entry; + + procedure Check_Value is + begin + Gtk.Widget.Set_Sensitive + (Gtk.Widget.Gtk_Widget (Decrement_Button), + The_Value > 0); + Gtk.Widget.Set_Sensitive + (Gtk.Widget.Gtk_Widget (Increment_Button), + The_Value < 10); + Gtk.Widget.Set_Sensitive + (Gtk.Widget.Gtk_Widget (Entry_Field), + The_Value = 0); + end Check_Value; + + procedure On_Changed_Text + (Object : access Gtk.GEntry.Gtk_Entry_Record'Class; + Params : Glib.Values.GValues) + is + pragma Unreferenced (Params, Object); + begin + The_Value := My_Natural'Value (Gtk.GEntry.Get_Text (Entry_Field)); + Check_Value; + Update_Entry; + exception + when Constraint_Error => + The_Value := 0; + end On_Changed_Text; + + -- make sure that only numbers are entered + procedure On_Insert_Text + (Object : access Gtk.GEntry.Gtk_Entry_Record'Class; + Params : Glib.Values.GValues) + is + Length : constant Glib.Gint := + Glib.Values.Get_Int (Glib.Values.Nth (Params, 2)); + Text : constant String := + Glib.Values.Get_String (Glib.Values.Nth (Params, 1), Length); + begin + declare + Number : My_Natural; + pragma Unreferenced (Number); + begin + Number := My_Natural'Value (Text); + exception + when Constraint_Error => + -- refuse values that are not parsable + Gtk.Handlers.Emit_Stop_By_Name + (Object => Object, + Name => Gtk.Editable.Signal_Insert_Text); + end; + end On_Insert_Text; + + -- Callback for click event + procedure On_Increment_Click + (Object : access Gtk.Button.Gtk_Button_Record'Class) + is + pragma Unreferenced (Object); + begin + The_Value := The_Value + 1; + Check_Value; + Update_Entry; + end On_Increment_Click; + + -- Callback for click event + procedure On_Decrement_Click + (Object : access Gtk.Button.Gtk_Button_Record'Class) + is + pragma Unreferenced (Object); + begin + The_Value := The_Value - 1; + Check_Value; + Update_Entry; + end On_Decrement_Click; + + -- Callback for delete event + function On_Main_Window_Delete + (Object : access Gtk.Window.Gtk_Window_Record'Class) + return Boolean + is + pragma Unreferenced (Object); + begin + Gtk.Main.Main_Quit; + return True; + end On_Main_Window_Delete; + +begin + + Gtk.Main.Init; + + Gtk.GEntry.Gtk_New (Widget => Entry_Field); + Entry_Callbacks.Connect + (Widget => Entry_Field, + Name => Gtk.Editable.Signal_Insert_Text, + Cb => On_Insert_Text'Access); + Entry_Callbacks.Connect + (Widget => Entry_Field, + Name => Gtk.Editable.Signal_Changed, + Cb => On_Changed_Text'Access); + + Gtk.Button.Gtk_New (Button => Increment_Button, Label => "Increment"); + Gtk.Button.Gtk_New (Button => Decrement_Button, Label => "Decrement"); + + Button_Callbacks.Connect + (Widget => Increment_Button, + Name => Gtk.Button.Signal_Clicked, + Marsh => Button_Callbacks.To_Marshaller (On_Increment_Click'Access)); + Button_Callbacks.Connect + (Widget => Decrement_Button, + Name => Gtk.Button.Signal_Clicked, + Marsh => Button_Callbacks.To_Marshaller (On_Decrement_Click'Access)); + + Gtk.Box.Gtk_New_Vbox (Box => Content); + Gtk.Box.Add (Container => Content, Widget => Entry_Field); + Gtk.Box.Add (Container => Content, Widget => Increment_Button); + Gtk.Box.Add (Container => Content, Widget => Decrement_Button); + + Gtk.Window.Gtk_New (Window => Main_Window); + Gtk.Window.Add (Container => Main_Window, Widget => Content); + + Window_Callbacks.Connect + (Widget => Main_Window, + Name => Gtk.Widget.Signal_Delete_Event, + Cb => On_Main_Window_Delete'Access); + Gtk.Window.Show_All (Widget => Main_Window); + Update_Entry; + + Gtk.Main.Main; +end Disabling; diff --git a/Task/GUI-enabling-disabling-of-controls/AutoHotkey/gui-enabling-disabling-of-controls.ahk b/Task/GUI-enabling-disabling-of-controls/AutoHotkey/gui-enabling-disabling-of-controls.ahk new file mode 100644 index 0000000000..2a4e738899 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/AutoHotkey/gui-enabling-disabling-of-controls.ahk @@ -0,0 +1,45 @@ +GUI, Add, Edit, w150 number vValue, 0 ; Number specifies a numbers-only edit field. +GUI, Add, button,, Increment +GUI, Add, button, xp+70 yp, Decrement ; xp+70 and yp are merely positioning options +GUI, Show, w200 y200, Title ; Shows the GUI. Add your own title if you wish +SetTimer, EnableDisable, 100 ; Sets EnableDisable to run 10 times per second (100ms) +return ; ----------End Auto-Execute Section---------- + +ButtonIncrement: + GUI, Submit, NoHide ; "Set the contents of each variable to the contents of their corresponding controls without hiding the GUI" + If ( value < 10 ) ; Just in case EnableDisable didn't disable the button it in time. + Value++ ; Increment Value + GUIControl,, Value, %value% ; "Set the text of the control which alters the variable 'value' to the contents of 'value'" +return + + +ButtonDecrement: + GUI, Submit, Nohide + If value > 0 + Value-- + GuiControl,, Value, %value% +return + + +EnableDisable: + GUI, Submit, Nohide + If ( value < 10 ) + GuiControl, enable, Increment + Else + GuiControl, disable, Increment + + If ( value > 0) + GuiControl, enable, Decrement + Else + GuiControl, disable, Decrement + + If ( value = 0 ) + GuiControl, enable, Edit1 + Else + GuiControl, disable, Edit1 +return + + +GuiClose: + ExitApp +; Ensures the script ends when the GUI is closed. diff --git a/Task/GUI-enabling-disabling-of-controls/BBC-BASIC/gui-enabling-disabling-of-controls.bbc b/Task/GUI-enabling-disabling-of-controls/BBC-BASIC/gui-enabling-disabling-of-controls.bbc new file mode 100644 index 0000000000..a2343c808e --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/BBC-BASIC/gui-enabling-disabling-of-controls.bbc @@ -0,0 +1,37 @@ + INSTALL @lib$+"WINLIB2" + INSTALL @lib$+"WINLIB5" + ES_NUMBER = 8192 + + form% = FN_newdialog("Rosetta Code", 100, 100, 100, 52, 8, 1000) + idInc% = FN_setproc(PROCinc) + idDec% = FN_setproc(PROCdec) + + PROC_static(form%, "Value:", 100, 10, 10, 24, 14, 0) + PROC_editbox(form%, "0", 101, 40, 8, 52, 14, ES_NUMBER) + PROC_pushbutton(form%, "Increment", idInc%, 7, 30, 40, 16, 0) + PROC_pushbutton(form%, "Decrement", idDec%, 52, 30, 40, 16, 0) + PROC_showdialog(form%) + + REPEAT + WAIT 1 + SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% + SYS "GetDlgItem", !form%, 101 TO hedit% + SYS "EnableWindow", hedit%, number% = 0 + SYS "GetDlgItem", !form%, idInc% TO hinc% + SYS "EnableWindow", hinc%, number% < 10 + SYS "GetDlgItem", !form%, idDec% TO hdec% + SYS "EnableWindow", hdec%, number% > 0 + UNTIL !form% = 0 + QUIT + + DEF PROCinc + LOCAL number% + SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% + SYS "SetDlgItemInt", !form%, 101, number% + 1, 1 + ENDPROC + + DEF PROCdec + LOCAL number% + SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% + SYS "SetDlgItemInt", !form%, 101, number% - 1, 1 + ENDPROC diff --git a/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-1.cpp b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-1.cpp new file mode 100644 index 0000000000..7ac38156c2 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-1.cpp @@ -0,0 +1,30 @@ +#ifndef TASK_H +#define TASK_H + +#include + +class QPushButton ; +class QString ; +class QLineEdit ; +class QLabel ; +class QVBoxLayout ; +class QHBoxLayout ; + +class MyWidget : public QWidget { + + Q_OBJECT +public: + MyWidget( QWidget *parent = 0 ) ; +private slots: + void buttonChange( const QString & ) ; + void addField( ) ; + void subtractField( ) ; +private : + QVBoxLayout *thisWidgetLayout ; + QLabel *instruction ; + QPushButton *increment ; + QPushButton *decrement ; + QLineEdit *entryField ; + QHBoxLayout *lowerPart ; +} ; +#endif diff --git a/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-2.cpp b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-2.cpp new file mode 100644 index 0000000000..f748431ebb --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-2.cpp @@ -0,0 +1,54 @@ +#include +#include +#include "task.h" + +MyWidget::MyWidget ( QWidget *parent ) + : QWidget( parent ) { + thisWidgetLayout = new QVBoxLayout ( this ) ; + instruction = new QLabel ; + instruction->setText( "Enter a number between 1 and 10 ! Numbers above 10 are decremented, below 0 incremented!" ) ; + instruction->setWordWrap( true ) ; + lowerPart = new QHBoxLayout ; + entryField = new QLineEdit( "0" ) ; + increment = new QPushButton( "Increment" ) ; + decrement = new QPushButton( "Decrement" ) ; + increment->setDefault( true ) ; + connect( entryField , SIGNAL ( textChanged ( const QString & ) ) , + this , SLOT ( buttonChange( const QString & )) ) ; + connect( entryField , SIGNAL ( textEdited ( const QString & ) ) , + this , SLOT ( buttonChange( const QString & )) ) ; + connect( increment , SIGNAL ( clicked( ) ) , this , + SLOT ( addField( ) )) ; + connect( decrement , SIGNAL ( clicked( ) ) , this , + SLOT ( subtractField( ))) ; + lowerPart->addWidget( entryField ) ; + lowerPart->addWidget( increment ) ; + lowerPart->addWidget( decrement ) ; + thisWidgetLayout->addWidget( instruction ) ; + thisWidgetLayout->addLayout( lowerPart ) ; + setLayout( thisWidgetLayout ) ; +} + +void MyWidget::buttonChange( const QString & text ) { + bool ok ; + increment->setEnabled( text.toInt( &ok, 10 ) < 10 ) ; + increment->setDisabled( text.toInt( &ok, 10 ) > 9 ) ; + decrement->setEnabled( text.toInt( &ok, 10 ) > 0 ) ; + decrement->setDisabled( text.toInt( &ok, 10 ) <= 0 ) ; + if ( ! ( text == "0" ) ) + entryField->setReadOnly( true ) ; +} + +void MyWidget::addField( ) { + bool ok ; + int number = entryField->text( ).toInt( &ok , 10 ) ; + number++ ; + entryField->setText( QString("%1").arg( number )) ; +} + +void MyWidget::subtractField( ) { + bool ok ; + int number = entryField->text( ).toInt( &ok , 10 ) ; + number-- ; + entryField->setText( QString("%1").arg( number )) ; +} diff --git a/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-3.cpp b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-3.cpp new file mode 100644 index 0000000000..89254c629b --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/C++/gui-enabling-disabling-of-controls-3.cpp @@ -0,0 +1,9 @@ +#include +#include "task.h" + +int main( int argc, char *argv[ ] ) { + QApplication app( argc , argv ) ; + MyWidget theWidget ; + theWidget.show( ) ; + return app.exec( ) ; +} diff --git a/Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.delphi b/Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.delphi new file mode 100644 index 0000000000..7ac16dc33d --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Delphi/gui-enabling-disabling-of-controls.delphi @@ -0,0 +1,31 @@ +type + TForm1 = class(TForm) + MaskEditValue: TMaskEdit; // Set Editmask on: "99;0; " + SpeedButtonIncrement: TSpeedButton; + SpeedButtonDecrement: TSpeedButton; + procedure MaskEditValueChange(Sender: TObject); + procedure SpeedButtonDecrementClick(Sender: TObject); + procedure SpeedButtonIncrementClick(Sender: TObject); + end; + +var + Form1: TForm1; + +implementation + +procedure TForm1.MaskEditValueChange(Sender: TObject); +begin + TMaskEdit(Sender).Enabled := StrToIntDef(Trim(TMaskEdit(Sender).Text), 0) = 0; + SpeedButtonIncrement.Enabled := StrToIntDef(Trim(TMaskEdit(Sender).Text), 0) < 10; + SpeedButtonDecrement.Enabled := StrToIntDef(Trim(TMaskEdit(Sender).Text), 0) > 0; +end; + +procedure TForm1.SpeedButtonDecrementClick(Sender: TObject); +begin + MaskEditValue.Text := IntToStr(Pred(StrToIntDef(Trim(MaskEditValue.Text), 0))); +end; + +procedure TForm1.SpeedButtonIncrementClick(Sender: TObject); +begin + MaskEditValue.Text := IntToStr(Succ(StrToIntDef(Trim(MaskEditValue.Text), 0))); +end; diff --git a/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-1.fantom b/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-1.fantom new file mode 100644 index 0000000000..9b045aa8db --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-1.fantom @@ -0,0 +1,68 @@ +using fwt +using gfx + +class Main +{ + public static Void main () + { + Window + { + textField := Text + { + text = "0" + } + incButton := Button + { + text = "increment" + onAction.add |Event e| + { + if (textField.text != "") + { + try + { + Int value := textField.text.toInt + if (value < 10) value += 1 + textField.text = value.toStr + } + catch {} + } + } + } + decButton := Button + { + text = "decrement" + onAction.add |Event e| + { + if (textField.text != "") + { + try + { + Int value := textField.text.toInt + if (value > 0) value -= 1 + textField.text = value.toStr + } + catch {} + } + } + } + // add a listener for modifications to the text field + // which updates the button visibilities + textField.onModify.add |Event e| + { + try + { + Int value := textField.text.toInt + incButton.enabled = (value < 10) // update whether button can be used + decButton.enabled = (value > 0) // update whether button can be used + } + catch textField.text = "0" // reset if not an int + } + EdgePane + { + top = textField + left = incButton + right = decButton + }, + }.open + } +} diff --git a/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-2.fantom b/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-2.fantom new file mode 100644 index 0000000000..7262f779e2 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Fantom/gui-enabling-disabling-of-controls-2.fantom @@ -0,0 +1,87 @@ +import gui +$include "guih.icn" + +class MessageDialog : Dialog (message) + method component_setup () + label := Label ("label="||message, "pos=20,20") + add (label) + button := TextButton("label=OK", "pos=100,60") + button.connect (self, "dispose", ACTION_EVENT) + add (button) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + attrib ("size=200,100", "bg=light gray") + end + + initially (message) + self.Dialog.initially() + self.message := message +end + +class WindowApp : Dialog (button1, button2, field, value) + method set_enabled () + if value = 0 + then field.clear_is_shaded () + else field.set_is_shaded () + if value <= 0 + then button2.set_is_shaded () + else button2.clear_is_shaded () + if value >= 10 + then button1.set_is_shaded () + else button1.clear_is_shaded () + end + + method increment () + value +:= 1 + field.set_contents (string(value)) + set_enabled () + end + + method decrement () + value -:= 1 + field.set_contents (string(value)) + set_enabled () + end + + method handle_text_field () + if not(integer(field.get_contents ())) + then { + warning := MessageDialog ("Not a number") + warning.show_modal () + field.set_contents (string(value)) + } + else { + n := integer (field.get_contents ()) + if not (0 <= n <= 10) + then { + warning := MessageDialog ("Not in range") + warning.show_modal () + field.set_contents (string(value)) + } + } + value := integer (field.get_contents ()) # must be ok + set_enabled () + end + + method component_setup () + value := 0 + field := TextField("contents="||value, "pos=20,20", "size=150") + field.connect (self, "handle_text_field", TEXTFIELD_CHANGED_EVENT) + add (field) + button1 := TextButton("label=Increment", "pos=20,60", "size=70") + button1.connect (self, "increment", ACTION_EVENT) + add (button1) + button2 := TextButton("label=Decrement", "pos=100,60", "size=70") + button2.connect (self, "decrement", ACTION_EVENT) + add (button2) + + connect (self, "dispose", CLOSE_BUTTON_EVENT) + attrib ("size=200,100", "bg=light gray") + set_enabled () + end +end + +procedure main () + w := WindowApp () + w.show_modal () +end diff --git a/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-1.j b/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-1.j new file mode 100644 index 0000000000..35f52428b0 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-1.j @@ -0,0 +1,24 @@ +task_run=: wd bind (noun define) + pc task nosize; + xywh 6 30 48 12;cc decrement button;cn "-"; + xywh 6 18 48 12;cc increment button;cn "+"; + xywh 6 6 48 12;cc Value edit; set Value 0; + pas 6 6;pcenter; + pshow; +) + +task_close=: wd bind 'pclose' + +task_Value_button=: update=: verb define + wd 'set Value ',":n=.{.0".Value + wd 'setenable Value ',":n=0 + wd 'setenable increment ',":n<10 + wd 'setenable decrement ',":n>0 +) + +task_increment_button=:verb define + update Value=:":1+0".Value +) +task_decrement_button=:verb define + update Value=:":_1+0".Value +) diff --git a/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-2.j b/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-2.j new file mode 100644 index 0000000000..7f02804a3a --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/J/gui-enabling-disabling-of-controls-2.j @@ -0,0 +1 @@ + task_run'' diff --git a/Task/GUI-enabling-disabling-of-controls/Java/gui-enabling-disabling-of-controls.java b/Task/GUI-enabling-disabling-of-controls/Java/gui-enabling-disabling-of-controls.java new file mode 100644 index 0000000000..42b637a4f7 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Java/gui-enabling-disabling-of-controls.java @@ -0,0 +1,153 @@ +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class Interact extends JFrame{ + final JTextField numberField; + final JButton incButton, decButton; + + public Interact(){ + //stop the GUI threads when the user hits the X button + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + numberField = new JTextField(); + incButton = new JButton("Increment"); + decButton = new JButton("Decrement"); + + numberField.setText("0");//start at 0 + decButton.setEnabled(false);//we're already at 0 + + //listen for button presses in the text field + numberField.addKeyListener(new KeyListener(){ + @Override + public void keyTyped(KeyEvent e) { + //if the entered character is not a digit + if(!Character.isDigit(e.getKeyChar())){ + //eat the event (i.e. stop it from being processed) + e.consume(); + }else if(Character.isDigit(e.getKeyChar())){ + //This method is executed from the event thread and updating the GUI + //from there doesn't always work. invokeLater will ensure that the + //GUI is updated + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + String text = numberField.getText(); + if(text.isEmpty()){//default to 0 when all text is erased + numberField.setText("0"); + decButton.setEnabled(false); + incButton.setEnabled(true); + return; + } + if(Long.valueOf(text) <= 0){ + decButton.setEnabled(false); + incButton.setEnabled(true); + }else if(Long.valueOf(text) >= 10){ + incButton.setEnabled(false); + decButton.setEnabled(true); + }else{ + incButton.setEnabled(true); + decButton.setEnabled(true); + } + } + }); + } + } + @Override + public void keyReleased(KeyEvent e){} + @Override + public void keyPressed(KeyEvent e){ + //backspace and delete don't register in keyTyped because they don't + //display a Unicode character, so they must be handled here + if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE || + e.getKeyCode() == KeyEvent.VK_DELETE){ + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + String text = numberField.getText(); + if(text.isEmpty()){ + numberField.setText("0"); + decButton.setEnabled(false); + incButton.setEnabled(true); + return; + } + if(Long.valueOf(text) <= 0){ + decButton.setEnabled(false); + incButton.setEnabled(true); + }else if(Long.valueOf(text) >= 10){ + incButton.setEnabled(false); + decButton.setEnabled(true); + }else{ + incButton.setEnabled(true); + decButton.setEnabled(true); + } + } + }); + } + } + }); + + //listen for button clicks on the increment button + incButton.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent e) { + String text = numberField.getText(); + numberField.setText((Long.valueOf(text) + 1) + ""); + if(Long.valueOf(text) + 1 >= 10){ + incButton.setEnabled(false); + } + + if(Long.valueOf(text) + 1 > 0){ + decButton.setEnabled(true); + } + } + }); + + //listen for button clicks on the random button + decButton.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent e) { + String text = numberField.getText(); + numberField.setText((Long.valueOf(text) - 1) + ""); + if(Long.valueOf(text) - 1 <= 0){ + decButton.setEnabled(false); + } + + if(Long.valueOf(text) - 1 < 10){ + incButton.setEnabled(true); + } + } + }); + + //arrange the components in a grid with 2 rows and 1 column + setLayout(new GridLayout(2, 1)); + + //a secondary panel for arranging both buttons in one grid space in the window + JPanel buttonPanel = new JPanel(); + + //the buttons are in a grid with 1 row and 2 columns + buttonPanel.setLayout(new GridLayout(1, 2)); + //add the buttons + buttonPanel.add(incButton); + buttonPanel.add(decButton); + + //put the number field on top of the buttons + add(numberField); + add(buttonPanel); + //size the window appropriately + pack(); + + } + + public static void main(String[] args){ + new Interact().setVisible(true); + } +} diff --git a/Task/GUI-enabling-disabling-of-controls/Liberty-BASIC/gui-enabling-disabling-of-controls.liberty b/Task/GUI-enabling-disabling-of-controls/Liberty-BASIC/gui-enabling-disabling-of-controls.liberty new file mode 100644 index 0000000000..b459f2ffa7 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Liberty-BASIC/gui-enabling-disabling-of-controls.liberty @@ -0,0 +1,80 @@ +nomainwin + textbox #demo.val, 20, 50, 90, 24 + button #demo.dec, "Decrement", [btnDecrement], UL, 20, 90, 90, 24 + button #demo.inc, "Increment", [btnIncrement], UL, 20, 120, 90, 24 + statictext #demo.txt, "Positive or negative whole numbers only.", 20, 170, 240, 24 + open "Rosetta Task: GUI enabling/disabling of controls" for window as #demo + #demo "trapclose [quit]" + #demo.val 0 + #demo.dec "!disable" +wait + +[quit] + close #demo +end + +[btnDecrement] + validNum = validNum() + if validNum = 0 then + #demo.val "!contents? nVal$" + notice nVal$;" does not appear to be a valid whole number." + else + #demo.val "!contents? nVal" + if nVal > 0 then + nVal = nVal - 1 + end if + end if + #demo.val nVal + call disEnableControls nVal +wait + +[btnIncrement] + validNum = validNum() + if validNum = 0 then + #demo.val "!contents? nVal$" + notice nVal$;" does not appear to be a valid whole number." + else + #demo.val "!contents? nVal" + if nVal < 10 then + nVal = nVal + 1 + end if + end if + #demo.val nVal + call disEnableControls nVal +wait + +Function validNum() + validNum$ = "0123456789" + #demo.val "!contents? nVal$" + nVal$ = trim$(nVal$) + if left$(nVal$, 1) = "-" then + neg = 1 + nVal$ = mid$(nVal$, 2) + else + neg = 0 + end if + validNum = 1 + for i = 1 to len(nVal$) + if instr(validNum$, mid$(nVal$, i, 1)) = 0 then + validNum = 0 + end if + next i +End Function + +Sub disEnableControls nVal + if nVal > 9 then + #demo.inc "!disable" + else + #demo.inc "!enable" + end if + if nVal < 1 then + #demo.dec "!disable" + else + #demo.dec "!enable" + end if + if nVal = 0 then + #demo.val "!enable" + else + #demo.val "!disable" + end if +End Sub diff --git a/Task/GUI-enabling-disabling-of-controls/Mathematica/gui-enabling-disabling-of-controls.mathematica b/Task/GUI-enabling-disabling-of-controls/Mathematica/gui-enabling-disabling-of-controls.mathematica new file mode 100644 index 0000000000..802193595f --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Mathematica/gui-enabling-disabling-of-controls.mathematica @@ -0,0 +1,5 @@ +Manipulate[Null, {{value, 0}, + InputField[Dynamic[value], Number, + Enabled -> Dynamic[value == 0]] &}, + Row@{Button["increment", value++, Enabled -> Dynamic[value < 10]], + Button["decrement", value--, Enabled -> Dynamic[value > 0]]}] diff --git a/Task/GUI-enabling-disabling-of-controls/PicoLisp/gui-enabling-disabling-of-controls.l b/Task/GUI-enabling-disabling-of-controls/PicoLisp/gui-enabling-disabling-of-controls.l new file mode 100644 index 0000000000..d95da485d1 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/PicoLisp/gui-enabling-disabling-of-controls.l @@ -0,0 +1,17 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l") + +(de start () + (and (app) (zero *Number)) + (action + (html 0 "Enable/Disable" "@lib.css" NIL + (form NIL + (gui '(+Var +Able +NumField) '*Number '(=0 *Number) 20 "Value") + (gui '(+Able +JS +Button) '(> 10 *Number) "increment" + '(inc '*Number) ) + (gui '(+Able +JS +Button) '(gt0 *Number) "decrement" + '(dec '*Number) ) ) ) ) ) + +(server 8080 "!start") +(wait) diff --git a/Task/GUI-enabling-disabling-of-controls/Prolog/gui-enabling-disabling-of-controls.pro b/Task/GUI-enabling-disabling-of-controls/Prolog/gui-enabling-disabling-of-controls.pro new file mode 100644 index 0000000000..ca0b8aea8c --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Prolog/gui-enabling-disabling-of-controls.pro @@ -0,0 +1,98 @@ +dialog('GUI_Interaction', + [ object := + GUI_Interaction, + parts := + [ GUI_Interaction := + dialog('Rosetta Code'), + Name := label(name, 'Value :'), + Input_field := + text_item(input_field, '0'), + Increment := + button(increment), + Decrement := + button(decrement) + ], + modifications := + [ Input_field := [ label := 'Value :', + length := 28, + show_label := @off + ], + Decrement := [active := @off] + ], + layout := + [ area(Name, + area(50, 26, 25, 24)), + area(Input_field, + area(95, 24, 200, 24)), + area(Increment, + area(50, 90, 80, 24)), + area(Decrement, + area(230, 90, 80, 24)) + ], + behaviour := + + [ + Increment := [ + message := message(@prolog, + increment, + Increment, + Decrement, + Input_field ) + ], + Decrement := [ + message := message(@prolog, + decrement, + Increment, + Decrement, + Input_field) + ], + Input_field := [ + message := message(@prolog, + input, + Increment, + Decrement, + @receiver, + @arg1) + ] + ] + + ]). + +gui_component :- + make_dialog(S, 'GUI_Interaction'), + send(S, open). + + +increment(Incr, Decr, Input) :- + get(Input, selection, V), + atom_number(V, Val), + Val1 is Val + 1, + send(Input, selection, Val1), + test(Val1, Incr, Decr, Input). + +decrement(Incr, Decr, Input) :- + get(Input, selection, V), + atom_number(V, Val), + Val1 is Val - 1, + send(Input, selection, Val1), + test(Val1, Incr, Decr, Input). + + + +input(Incr, Decr, Input, Selection) :- + catch( (term_to_atom(T, Selection), number(T)), + _, + ( send(@display, inform, 'Please type a number !'), + T = 0, + send(Input,selection, T))), + test(T, Incr, Decr, Input). + + +test(V, Incr, Decr, Input) :- + ( V = 0 -> send(Input, active, @on); send(Input, active, @off)), + send(Incr, active, @on), + send(Decr, active, @on), + ( V < 1 + -> send(Decr, active, @off) + ; V > 9 + -> send(Incr, active, @off)). diff --git a/Task/GUI-enabling-disabling-of-controls/R/gui-enabling-disabling-of-controls.r b/Task/GUI-enabling-disabling-of-controls/R/gui-enabling-disabling-of-controls.r new file mode 100644 index 0000000000..bf1bd4e0b2 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/R/gui-enabling-disabling-of-controls.r @@ -0,0 +1,26 @@ +library(gWidgets) +options(guiToolkit="RGtk2") ## using gWidgtsRGtk2 + +w <- gwindow("Disable components") + +g <- ggroup(cont=w, horizontal=FALSE) +e <- gedit("0", cont=g, coerce.with=as.numeric) +bg <- ggroup(cont=g) + +down_btn <- gbutton("-", cont=bg) +up_btn <- gbutton("+", cont=bg) + +update_ctrls <- function(h,...) { + val <- svalue(e) + enabled(down_btn) <- val >= 0 + enabled(up_btn) <- val <= 10 +} + +rement <- function(h,...) { + svalue(e) <- svalue(e) + h$action + update_ctrls(h,...) +} + +addHandlerChanged(e, handler=update_ctrls) +addHandlerChanged(down_btn, handler=rement, action=-1) +addHandlerChanged(up_btn, handler=rement, action=1) diff --git a/Task/GUI-enabling-disabling-of-controls/Ruby/gui-enabling-disabling-of-controls.rb b/Task/GUI-enabling-disabling-of-controls/Ruby/gui-enabling-disabling-of-controls.rb new file mode 100644 index 0000000000..5ca6c0e0a4 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Ruby/gui-enabling-disabling-of-controls.rb @@ -0,0 +1,15 @@ +Shoes.app do + @number = edit_line + @number.change {update_controls} + + @incr = button('Increment') {update_controls(@number.text.to_i + 1)} + @decr = button('Decrement') {update_controls(@number.text.to_i - 1)} + + def update_controls(value = @number.text.to_i) + @number.text = value + @incr.state = value.to_i >= 10 ? "disabled" : nil + @decr.state = value.to_i <= 0 ? "disabled" : nil + end + + update_controls 0 +end diff --git a/Task/GUI-enabling-disabling-of-controls/Scala/gui-enabling-disabling-of-controls.scala b/Task/GUI-enabling-disabling-of-controls/Scala/gui-enabling-disabling-of-controls.scala new file mode 100644 index 0000000000..9c856fad77 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Scala/gui-enabling-disabling-of-controls.scala @@ -0,0 +1,73 @@ +import scala.swing._ +import scala.swing.Swing._ +import scala.swing.event._ + +object Enabling extends SimpleSwingApplication { + def top = new MainFrame { + title = "Rosetta Code >>> Task: GUI enabling/disabling of controls | Language: Scala" + + val numberField = new TextField { text = "0" } // start at 0 + + val incButton = new Button("Increment") + + val decButton = new Button { + text = "Decrement" + enabled = false + } + + // arrange buttons in a grid with 1 row, 2 columns + val buttonPanel = new GridPanel(1, 2) { + contents ++= List(incButton, decButton) + } + + // arrange text field and button panel in a grid with 2 row, 1 column + contents = new GridPanel(2, 1) { + contents ++= List(numberField, buttonPanel) + } + + // backspace and delete don't cause a display of any Unicode char - + // therefore we need to catch them apart from the others + val specialKeys = List(Key.BackSpace, Key.Delete) + + // listen for keys pressed in numberField and button clicks + listenTo(numberField.keys, incButton, decButton) + reactions += { + case kt: KeyTyped => + if (!kt.char.isDigit) // if the entered char isn't a digit ... + kt.consume // ... eat the event (i.e. stop it from being processed) + else { + Swing.onEDT(switching) // ensure GUI-updating + } + case KeyPressed(_,kp,_,_) if (!specialKeys.filter(_==kp).isEmpty) => + Swing.onEDT(switching) // ensure GUI-updating + case ButtonClicked(`incButton`) => + numberField.text = "" + (java.lang.Long.valueOf(numberField.text)+1) + switching + case ButtonClicked(`decButton`) => + numberField.text = "" + (java.lang.Long.valueOf(numberField.text)-1) + switching + } + + def switching: Unit = { + val s = numberField.text match { + case "" => "0" + case _ => numberField.text + } + val n = java.lang.Long.valueOf(s) + numberField.text = "" + n + if (java.lang.Long.valueOf(numberField.text) <= 0) { + numberField.enabled = true + incButton.enabled = true + decButton.enabled = false + } else if (java.lang.Long.valueOf(numberField.text) >= 10) { + numberField.enabled = false + incButton.enabled = false + decButton.enabled = true + } else { + numberField.enabled = false + incButton.enabled = true + decButton.enabled = true + } + } + } +} diff --git a/Task/GUI-enabling-disabling-of-controls/Smalltalk/gui-enabling-disabling-of-controls.st b/Task/GUI-enabling-disabling-of-controls/Smalltalk/gui-enabling-disabling-of-controls.st new file mode 100644 index 0000000000..18b24839fb --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Smalltalk/gui-enabling-disabling-of-controls.st @@ -0,0 +1,20 @@ +|top input vh incButton decButton| + +vh := ValueHolder with:0. + +top := StandardSystemView label:'Rosetta GUI interaction'. +top extent:300@100. +top add:((Label label:'Value:') origin: 0 @ 10 corner: 100 @ 40). +top add:(input := EditField origin: 102 @ 10 corner: 1.0 @ 40). +input model:(TypeConverter onNumberValue:vh). +input enableChannel:(BlockValue with:[:v | v = 0] argument:vh). + +top add:((incButton := Button label:'Inc') origin: 10 @ 50 corner: 100 @ 80). +top add:((decButton := Button label:'Dec') origin: 110 @ 50 corner: 210 @ 80). + +incButton action:[ vh value: (vh value + 1) ]. +incButton enableChannel:(BlockValue with:[:v | v < 10] argument:vh). +decButton action:[ vh value: (vh value - 1) ]. +decButton enableChannel:(BlockValue with:[:v | v > 0] argument:vh). + +top open diff --git a/Task/GUI-enabling-disabling-of-controls/Tcl/gui-enabling-disabling-of-controls.tcl b/Task/GUI-enabling-disabling-of-controls/Tcl/gui-enabling-disabling-of-controls.tcl new file mode 100644 index 0000000000..06298a2aa2 --- /dev/null +++ b/Task/GUI-enabling-disabling-of-controls/Tcl/gui-enabling-disabling-of-controls.tcl @@ -0,0 +1,31 @@ +package require Tk + +# Model +set field 0 + +# View +place [ttk::frame .bg] -relwidth 1 -relheight 1; # Hack to make things look nice +pack [ttk::labelframe .val -text "Value"] +pack [ttk::entry .val.ue -textvariable field \ + -validate key -invalidcommand bell \ + -validatecommand {string is integer %P}] +pack [ttk::button .inc -text "increment" -command up] +pack [ttk::button .dec -text "decrement" -command down] + +# Controller +proc up {} { + global field + incr field +} +proc down {} { + global field + incr field -1 +} +# Attach this controller to the Model; easier than manual calling +trace add variable field write updateEnables +proc updateEnables {args} { + global field + .inc state [expr {$field < 10 ? "!disabled" : "disabled"}] + .dec state [expr {$field > 0 ? "!disabled" : "disabled"}] +} +updateEnables; # Force initial state of buttons diff --git a/Task/Galton-box-animation/0DESCRIPTION b/Task/Galton-box-animation/0DESCRIPTION new file mode 100644 index 0000000000..404850e927 --- /dev/null +++ b/Task/Galton-box-animation/0DESCRIPTION @@ -0,0 +1,9 @@ +Generate an animated simulation of [[wp:Bean_machine|Sir Francis Galton's device]]. An example can be found to the right. [[File:Galtonbox-Unicon.PNG|thumb|Example of a Galton Box at the end of animation.]] + +In a Galton box, there are a set of pins arranged in a triangular pattern. A number of balls are dropped so that they fall in line with the top pin, deflecting to the left or the right of the pin. The ball continues to fall to the left or right of subsequent pins before arriving at one of the collection points between and to the sides of the bottom row of pins. + +For the purpose of this task the box should have at least 5 pins on the bottom row. Your solution can use graphics or ASCII animation. Provide a sample of the output/display such as a screenshot. + +Your solution can have either one or more balls in flight at the same time. If multiple balls are in flight, ensure they don't interfere with each other. + +Your solution should allow users to specify the number of balls or it should run until full or a preset limit. Optionally, display the number of balls. diff --git a/Task/Galton-box-animation/AutoHotkey/galton-box-animation.ahk b/Task/Galton-box-animation/AutoHotkey/galton-box-animation.ahk new file mode 100644 index 0000000000..c52c8e89d0 --- /dev/null +++ b/Task/Galton-box-animation/AutoHotkey/galton-box-animation.ahk @@ -0,0 +1,89 @@ +AutoTrim Off +; User settings +bottompegs := 6 +SleepTime := 200 +fallspace := 30 + +; create the board +out := (pad2 := Space(bottompegs*2+1)) "`n" +Loop % bottompegs +{ + out .= Space(bottompegs-A_Index+1) + Loop % A_Index + out .= "* " + out .= Space(bottompegs-A_Index+1) . "`n" +} +StringTrimRight, strboard, out, 1 ; remove last newline +Loop % fallspace-1 + strboard .= "`n" . pad2 +strboard .= "`n" +Loop % bottompegs*2+1 + strboard .= "=" + +; Create Gui +Gui Font, , Consolas +Gui -Caption +Gui Margin, 0, 0 +Gui, Add, edit, -VScroll vE, % strboard +Gui Show +Loop +{ + ballX := bottompegs+1, BallY := 1 + strboard := ChangeChar(strboard, BallX, ballY, "O") + GuiControl,, E, % strboard + sleep SleepTime + ; Make ball fall and bounce + Loop % bottompegs + { + strboard := ChangeChar(strboard, BallX, BallY, " ") + ballY += 1 + ballX += RandAdd() + ; MsgBox % ballX ", " ballY + GuiControl,, E, % strboard := ChangeChar(strboard, ballX, ballY, "O") + sleep SleepTime + } + ; now fall to the bottom + While GetChar(strboard, BallX, BallY+1) = A_Space + { + strboard := ChangeChar(strboard, BallX, BallY, " ") + BallY += 1 + strboard := ChangeChar(strboard, BallX, BallY, "O") + GuiControl,, E, % strboard + sleep SleepTime + } +} +~Esc:: +GuiClose: +ExitApp + +Space(n){ + If n + return " " Space(n-1) + return "" +} +RandAdd(){ + Random, n, 3, 4 + return (n=3 ? -1 : 1) +} + +GetChar(s, x, y){ + Loop Parse, s, `n + if (A_Index = y) + return SubStr(A_LoopField, x, 1) +} +ChangeChar(s, x, y, c){ + Loop Parse, s, `n + { + If (A_Index = y) + { + Loop Parse, A_LoopField + If (A_Index = x) + out .= c + else out .= A_LoopField + } + else out .= A_LoopField + out .= "`n" + } + StringTrimRight, out, out, 1 ; removes the last newline + return out +} diff --git a/Task/Galton-box-animation/BASIC256/galton-box-animation.basic256 b/Task/Galton-box-animation/BASIC256/galton-box-animation.basic256 new file mode 100644 index 0000000000..14214d2ee8 --- /dev/null +++ b/Task/Galton-box-animation/BASIC256/galton-box-animation.basic256 @@ -0,0 +1,116 @@ +graphsize 150,125 +fastgraphics +color black +rect 0,0,graphwidth,graphheight +refresh + +N = 10 # number of balls +M = 5 # number of pins in last row +dim ball(N,5) # (pos_x to center, level, x, y, direction} +dim cnt(M+1) + +rad = 6 +slow = 0.3 +diamond = {0,rad,rad,0,0,-rad,-rad,0} +stepx = {rad/sqr(2),rad/2,rad/2,(1-1/sqr(2))*rad,0} +stepy = {(1-1/sqr(2))*rad,rad/2,rad/2,rad/sqr(2),rad} +CX = graphwidth/2 : CY = graphheight/2 +iters = 0 + +# Draw pins +for i = 1 to M + y = 3*rad*i + for j = 1 to i + dx = (j-i\2-1)*4*rad + ((i-1)%2)*2*rad + color purple + stamp CX+dx,y,1.0,diamond + color darkpurple + stamp CX+dx,y,0.6,diamond + next j +next i +gosub saverefresh + +R = 0 : C = 0 +font "Tahoma",10,50 +do + # Release ball + if R=0.5 then + ball[b,4] = 1 + else + ball[b,4] = -1 + end if + ball[b,0] = ball[b,0] + ball[b,4] + else + if ball[b,4]<>0 then + gosub eraseball + i = (ball[b,0]+M)/2 + cnt[i] = cnt[i] + 1 + ball[b,4] = 0 + C = C + 1 + end if + end if + next b + # Draw counter + color green + y = 3*rad*(M+1) + for j = 0 to M + dx = (j-(M+1)\2)*4*rad + (M%2)*2*rad + stamp CX+dx,y,{-1.2*rad,0,1.2*rad,0,1.2*rad,2*cnt[j],-1.2*rad,2*cnt[j]} + next j + gosub saverefresh +until C >= N +end + +moveball: + if ball[b,1]>M then return + gosub eraseball + if ball[b,4]<>0.0 then + ball[b,2] = ball[b,2]+ball[b,4]*stepx[it] + ball[b,3] = ball[b,3]+stepy[it] + else + ball[b,3] = ball[b,3]+rad + end if + gosub drawball + +drawball: + color darkgreen + circle ball[b,2],ball[b,3],rad-1 + color green + circle ball[b,2],ball[b,3],rad-2 + return + +eraseball: + color black + circle ball[b,2],ball[b,3],rad-1 + return + +saverefresh: + num$ = string(iters) + for k = 1 to 4-length(num$) + num$ = "0"+num$ + next k + imgsave num$+"-Galton_box_BASIC-256.png", "PNG" + iters = iters + 1 + refresh + return diff --git a/Task/Galton-box-animation/BBC-BASIC/galton-box-animation.bbc b/Task/Galton-box-animation/BBC-BASIC/galton-box-animation.bbc new file mode 100644 index 0000000000..27a6db9ecb --- /dev/null +++ b/Task/Galton-box-animation/BBC-BASIC/galton-box-animation.bbc @@ -0,0 +1,49 @@ + maxBalls% = 10 + DIM ballX%(maxBalls%), ballY%(maxBalls%) + + VDU 23,22,180;400;8,16,16,128 + ORIGIN 180,0 + OFF + + REM Draw the pins: + GCOL 9 + FOR row% = 1 TO 7 + FOR col% = 1 TO row% + CIRCLE FILL 40*col% - 20*row% - 20, 800 - 40*row%, 12 + NEXT + NEXT row% + + REM Animate + last% = 0 + tick% = 0 + GCOL 3,3 + REPEAT + IF RND(10) = 5 IF (tick% - last%) > 10 THEN + FOR ball% = 1 TO maxBalls% + IF ballY%(ball%) = 0 THEN + ballX%(ball%) = 0 + ballY%(ball%) = 800 + last% = tick% + EXIT FOR + ENDIF + NEXT + ENDIF + FOR ball% = 1 TO maxBalls% + IF ballY%(ball%) CIRCLE FILL ballX%(ball%), ballY%(ball%), 12 + IF POINT(ballX%(ball%),ballY%(ball%)-10) = 12 OR ballY%(ball%) < 12 THEN + IF ballY%(ball%) > 500 END + ballY%(ball%) = 0 + ENDIF + NEXT + WAIT 2 + FOR ball% = 1 TO maxBalls% + IF ballY%(ball%) THEN + CIRCLE FILL ballX%(ball%), ballY%(ball%), 12 + ballY%(ball%) -= 4 + IF POINT(ballX%(ball%),ballY%(ball%)-10) = 9 THEN + ballX%(ball%) += 40 * (RND(2) - 1.5) + ENDIF + ENDIF + NEXT + tick% += 1 + UNTIL FALSE diff --git a/Task/Galton-box-animation/C/galton-box-animation.c b/Task/Galton-box-animation/C/galton-box-animation.c new file mode 100644 index 0000000000..af5e4530ea --- /dev/null +++ b/Task/Galton-box-animation/C/galton-box-animation.c @@ -0,0 +1,90 @@ +#include +#include +#include + +#define BALLS 1024 +int n, w, h = 45, *x, *y, cnt = 0; +char *b; + +#define B(y, x) b[(y)*w + x] +#define C(y, x) ' ' == b[(y)*w + x] +#define V(i) B(y[i], x[i]) +inline int rnd(int a) { return (rand()/(RAND_MAX/a))%a; } + +void show_board() +{ + int i, j; + for (puts("\033[H"), i = 0; i < h; i++, putchar('\n')) + for (j = 0; j < w; j++, putchar(' ')) + printf(B(i, j) == '*' ? + C(i - 1, j) ? "\033[32m%c\033[m" : + "\033[31m%c\033[m" : "%c", B(i, j)); +} + +void init() +{ + int i, j; + puts("\033[H\033[J"); + b = malloc(w * h); + memset(b, ' ', w * h); + + x = malloc(sizeof(int) * BALLS * 2); + y = x + BALLS; + + for (i = 0; i < n; i++) + for (j = -i; j <= i; j += 2) + B(2 * i+2, j + w/2) = '*'; + srand(time(0)); +} + +void move(int idx) +{ + int xx = x[idx], yy = y[idx], c, kill = 0, sl = 3, o = 0; + + if (yy < 0) return; + if (yy == h - 1) { y[idx] = -1; return; } + + switch(c = B(yy + 1, xx)) { + case ' ': yy++; break; + case '*': sl = 1; + default: if (xx < w - 1 && C(yy, xx + 1) && C(yy + 1, xx + 1)) + if (!rnd(sl++)) o = 1; + if (xx && C(yy, xx - 1) && C(yy + 1, xx - 1)) + if (!rnd(sl++)) o = -1; + if (!o) kill = 1; + xx += o; + } + + c = V(idx); V(idx) = ' '; + idx[y] = yy, idx[x] = xx; + B(yy, xx) = c; + if (kill) idx[y] = -1; +} + +int run(void) +{ + static int step = 0; + int i; + for (i = 0; i < cnt; i++) move(i); + if (2 == ++step && cnt < BALLS) { + step = 0; + x[cnt] = w/2; + y[cnt] = 0; + if (V(cnt) != ' ') return 0; + V(cnt) = rnd(80) + 43; + cnt++; + } + return 1; +} + +int main(int c, char **v) +{ + if (c < 2 || (n = atoi(v[1])) <= 3) n = 5; + if (n >= 20) n = 20; + w = n * 2 + 1; + init(); + + do { show_board(), usleep(60000); } while (run()); + + return 0; +} diff --git a/Task/Galton-box-animation/D/galton-box-animation.d b/Task/Galton-box-animation/D/galton-box-animation.d new file mode 100644 index 0000000000..15c0af7dc7 --- /dev/null +++ b/Task/Galton-box-animation/D/galton-box-animation.d @@ -0,0 +1,109 @@ +import std.stdio, std.algorithm, std.random, std.array; + +enum int boxW = 41, boxH = 37; // Galton box width and height. +enum int pinsBaseW = 19; // Pins triangle base size. +enum int nMaxBalls = 55; // Number of balls. + +static assert(boxW >= 2 && boxH >= 2); +static assert((boxW - 4) >= (pinsBaseW * 2 - 1)); +static assert((boxH - 3) >= pinsBaseW); +enum centerH = pinsBaseW + (boxW - (pinsBaseW * 2 - 1)) / 2 - 1; + +alias CellBaseType = char; +enum Cell : CellBaseType { empty = ' ', + ball = 'o', + wall = '|', + corner = '+', + floor = '-', + pin = '.' } + +Cell[boxW][boxH] box; // Galton box. Will be printed upside-down. + +struct Ball { + int x, y; // Position. + + this(in int x_, in int y_) nothrow + in { + assert(box[y_][x_] == Cell.empty); + } body { + this.x = x_; + this.y = y_; + box[y][x] = Cell.ball; + } + + nothrow const invariant() { + assert(x >= 0 && x < boxW && y >= 0 && y < boxH); + assert(box[y][x] == Cell.ball); + } + + void doStep() { + if (y <= 0) + return; // Reached the bottom of the box. + + with (Cell) { + final switch (box[y - 1][x]) { + case empty: + box[y][x] = Cell.empty; + y--; + box[y][x] = Cell.ball; + break; + case ball, wall, corner, floor: + // It's frozen. (It always piles on other balls). + break; + case pin: + box[y][x] = Cell.empty; + y--; + if (box[y][x - 1] == Cell.empty && + box[y][x + 1] == Cell.empty) { + x += uniform(0, 2) * 2 - 1; + box[y][x] = Cell.ball; + return; + } else if (box[y][x - 1] == Cell.empty) + x++; + else + x--; + box[y][x] = Cell.ball; + break; + } + } + } +} + +void initializeBox() { + // Set ceiling and floor: + box[0] = Cell.corner ~ [Cell.floor].replicate(boxW - 2) + ~ Cell.corner; + box[$ - 1] = box[0][]; + + // Set walls: + foreach (r; 1 .. boxH - 1) + box[r][0] = box[r][$ - 1] = Cell.wall; + + // Set pins: + foreach (nPins; 1 .. pinsBaseW + 1) + foreach (pin; 0 .. nPins) + box[boxH - 2 - nPins][centerH + 1 - nPins + pin * 2] + = Cell.pin; +} + +void drawBox() { + foreach_reverse (ref row; box) + writeln(cast(CellBaseType[])row); +} + +void main() { + initializeBox(); + Ball[] balls; + + foreach (const i; 0 .. nMaxBalls + boxH) { + writefln("\nStep %d:", i); + if (i < nMaxBalls) + balls ~= Ball(centerH, boxH - 2); // Add ball. + drawBox(); + + // Next step for the simulation. + // Frozen balls are kept in balls array for simplicity. + foreach (ref b; balls) + b.doStep(); + } +} diff --git a/Task/Galton-box-animation/Icon/galton-box-animation.icon b/Task/Galton-box-animation/Icon/galton-box-animation.icon new file mode 100644 index 0000000000..c60210559b --- /dev/null +++ b/Task/Galton-box-animation/Icon/galton-box-animation.icon @@ -0,0 +1,65 @@ +link graphics + +global pegsize, pegsize2, height, width, delay + +procedure main(args) # galton box simulation from Unicon book + pegsize2 := (pegsize := 10) * 2 # pegs & steps + delay := 2 # ms delay + setup_galtonwindow(pegsize) + n := integer(args[1]) | 100 # balls to drop + every 1 to n do galton(pegsize) + WDone() +end + +procedure setup_galtonwindow(n) # Draw n levels of pegs, +local xpos, ypos, i, j + # Pegboard size is 2n-1 square + # Expected max value of histogram is (n, n/2)/2^n + # ... approximate with something simpler? + + height := n*n/2*pegsize + (width := (2*n+1)*pegsize) + Window("size=" || width || "," || height, "fg=grayish-white") + WAttrib("fg=dark-grey") + every ypos := (i := 1 to n) * pegsize2 do { + xpos := width/2 - (i - 1) * pegsize - pegsize/2 - pegsize2 + every 1 to i do + FillArc(xpos +:= pegsize2, ypos, pegsize, pegsize) + } + WAttrib("fg=black","drawop=reverse") # set drawing mode for balls +end + +procedure galton(n) # drop a ball into the galton box +local xpos, ypos, oldx, oldy + xpos := oldx := width/2 - pegsize/2 + ypos := oldy := pegsize + every 1 to n do { # For every ball... + xpos +:= ((?2 = 1) | -1) * pegsize # +/- pegsize + animate(.oldx, .oldy, oldx := xpos, oldy := ypos +:= pegsize2) + } + animate(xpos, ypos, xpos, ypos + 40) # Now the ball falls ... + animate(xpos, ypos+40, xpos, ypos + 200) # ... to the floor + draw_ball(xpos) # Record this ball +end + +procedure animate(xfrom, yfrom, xto, yto) + animate_actual(xfrom, yfrom, xto, yfrom, 4) + animate_actual(xto, yfrom, xto, yto, 10) +end + + +procedure animate_actual(xfrom, yfrom, xto, yto, steps) # attribs already set +local x, y, xstep, ystep, lastx, lasty + x -:= xstep := (xto - (x := xfrom))/steps + y -:= ystep := (yto - (y := yfrom))/steps + every 1 to steps do { + FillArc(lastx := x +:= xstep, lasty := y +:= ystep, pegsize, pegsize) + WDelay(delay) # wait in ms + FillArc(x, y, pegsize, pegsize) + } +end + +procedure draw_ball(x) +static ballcounts +initial ballcounts := table(0) + FillArc(x, height-(ballcounts[x] +:= 1)*pegsize, pegsize, pegsize) +end diff --git a/Task/Galton-box-animation/J/galton-box-animation-1.j b/Task/Galton-box-animation/J/galton-box-animation-1.j new file mode 100644 index 0000000000..0faa9c2fc4 --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-1.j @@ -0,0 +1 @@ +initpins=: '* ' {~ '1'&i.@(-@|. |."_1 [: ":@-.&0"1 <:~/~)@i. diff --git a/Task/Galton-box-animation/J/galton-box-animation-10.j b/Task/Galton-box-animation/J/galton-box-animation-10.j new file mode 100644 index 0000000000..7743d06f55 --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-10.j @@ -0,0 +1,17 @@ + nxt&.>^:a: <7 (init ' ',.' ',.~ initpins) 5 +┌─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐ +│ o │ │ │ │ │ │ │ │ │ │ │ │ │ │ +│ o │ o │ o │ o │ o │ o │ o │ o │ *o │ * │ * │ * │ * │ * │ +│ o │ o │ o │ o │ o │ o │ o │ *o │ *o* │ *o* │ * * │ * * │ * * │ * * │ +│ o │ o │ o │ o │ o │ o │ *o │ * *o │ * * *o │ * *o* │ * *o* │ * * * │ * * * │ * * * │ +│ o │ o │ o │ o │ o │ *o │ * *o │ * *o* │ * *o* * │ * * * *o │ * *o* * │ * *o* * │ * * * * │ * * * * │ +│ o │ o │ o │ o │ o* │ o* * │ *o* * │ * *o* * │ * * *o* * │ * *o* * * │ * * * * *o │ * * *o* * │ * *o* * * │ * * * * * │ +│ o │ o │ o │ *o │ *o* │ * *o* │ * * *o* │ * * *o* * │ o │ o │ o │ o │ o │ o │ +│ │ o │ *o │ * *o │ * *o* │ * *o* * │ * * *o* * │ o │ o │ o │ o │ o │ o │ o │ +│ * │ * │ * * │ * * * │ * * * * │ * * * * * │ │ │ │ o │ o o │ o o o │ o │ o o │ +│ * * │ * * │ * * * │ * * * * │ * * * * * │ │ │ │ │ │ │ │ o o o │ o o o │ +│ * * * │ * * * │ * * * * │ * * * * * │ │ │ │ │ │ │ │ │ │ │ +│ * * * * │ * * * * │ * * * * * │ │ │ │ │ │ │ │ │ │ │ │ +│ * * * * * │ * * * * * │ │ │ │ │ │ │ │ │ │ │ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +└─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┘ diff --git a/Task/Galton-box-animation/J/galton-box-animation-2.j b/Task/Galton-box-animation/J/galton-box-animation-2.j new file mode 100644 index 0000000000..1a3b2f8533 --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-2.j @@ -0,0 +1,5 @@ + initpins 4 + * + * * + * * * +* * * * diff --git a/Task/Galton-box-animation/J/galton-box-animation-3.j b/Task/Galton-box-animation/J/galton-box-animation-3.j new file mode 100644 index 0000000000..e411cd080c --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-3.j @@ -0,0 +1 @@ +initSpins=: [: }.@|. (1- 2&^@>:) ]\ [: ,] (,~ ,.~)@]^:[ ,: bind '* ' diff --git a/Task/Galton-box-animation/J/galton-box-animation-4.j b/Task/Galton-box-animation/J/galton-box-animation-4.j new file mode 100644 index 0000000000..b98b1f08ce --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-4.j @@ -0,0 +1 @@ +init=: ' ',. ' ',.~ ] ,~ ' ',~ ' o' {~ (# ' ' ~: 1&{.) diff --git a/Task/Galton-box-animation/J/galton-box-animation-5.j b/Task/Galton-box-animation/J/galton-box-animation-5.j new file mode 100644 index 0000000000..f890b9fc42 --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-5.j @@ -0,0 +1,9 @@ + 3 (init initpins) 4 + o + o + o + + * + * * + * * * + * * * * diff --git a/Task/Galton-box-animation/J/galton-box-animation-6.j b/Task/Galton-box-animation/J/galton-box-animation-6.j new file mode 100644 index 0000000000..e60d5648ea --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-6.j @@ -0,0 +1 @@ +bounce=: (C.~ ] <"1@:+ 0 1 -~/~ ? @: (2"0))"1 [: I. 'o*'&E."1&.|: diff --git a/Task/Galton-box-animation/J/galton-box-animation-7.j b/Task/Galton-box-animation/J/galton-box-animation-7.j new file mode 100644 index 0000000000..c2e2e17afa --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-7.j @@ -0,0 +1,4 @@ +shift=: 4 :0 + fill=. {.0#,y + x |.!.fill y +) diff --git a/Task/Galton-box-animation/J/galton-box-animation-8.j b/Task/Galton-box-animation/J/galton-box-animation-8.j new file mode 100644 index 0000000000..60e1582c7e --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-8.j @@ -0,0 +1,10 @@ +pins=: '*'&= +balls=: 'o'&= + +bounce=: (C.~ 0 1 <@(-/~) [: (+ ?@2:"0) I.)"1 + +nxt=: ' ',~ [: clean ' *o' {~ pins + 2 * _1 shift balls bounce balls *. 1 shift pins + +clean2=: ({. , -.&' '"1&.|:&.|.@}.)~ 1 + >./@(# | '*' i:~"1 |:) +clean1=: #~ 1 1 -.@E. *./"1@:=&' ' +clean=: clean1@clean2 diff --git a/Task/Galton-box-animation/J/galton-box-animation-9.j b/Task/Galton-box-animation/J/galton-box-animation-9.j new file mode 100644 index 0000000000..8855f22fcd --- /dev/null +++ b/Task/Galton-box-animation/J/galton-box-animation-9.j @@ -0,0 +1,8 @@ + nxt nxt 3 (init initpins) 4 + + o + o + o* + * * + * * * + * * * * diff --git a/Task/Galton-box-animation/PicoLisp/galton-box-animation-1.l b/Task/Galton-box-animation/PicoLisp/galton-box-animation-1.l new file mode 100644 index 0000000000..728a0295e5 --- /dev/null +++ b/Task/Galton-box-animation/PicoLisp/galton-box-animation-1.l @@ -0,0 +1,25 @@ +(de galtonBox (Pins Height) + (let (Bins (need (inc (* 2 Pins)) 0) X 0 Y 0) + (until (= Height (apply max Bins)) + (call 'clear) + (cond + ((=0 Y) (setq X (inc Pins) Y 1)) + ((> (inc 'Y) Pins) + (inc (nth Bins X)) + (zero Y) ) ) + ((if (rand T) inc dec) 'X) + (for Row Pins + (for Col (+ Pins Row 1) + (let D (dec (- Col (- Pins Row))) + (prin + (cond + ((and (= X Col) (= Y Row)) "o") + ((and (gt0 D) (bit? 1 D)) ".") + (T " ") ) ) ) ) + (prinl) ) + (prinl) + (for H (range Height 1) + (for B Bins + (prin (if (>= B H) "o" " ")) ) + (prinl) ) + (wait 200) ) ) ) diff --git a/Task/Galton-box-animation/PicoLisp/galton-box-animation-2.l b/Task/Galton-box-animation/PicoLisp/galton-box-animation-2.l new file mode 100644 index 0000000000..311ddf69a4 --- /dev/null +++ b/Task/Galton-box-animation/PicoLisp/galton-box-animation-2.l @@ -0,0 +1 @@ +(galtonBox 9 11) diff --git a/Task/Galton-box-animation/Prolog/galton-box-animation.pro b/Task/Galton-box-animation/Prolog/galton-box-animation.pro new file mode 100644 index 0000000000..d379ba79b9 --- /dev/null +++ b/Task/Galton-box-animation/Prolog/galton-box-animation.pro @@ -0,0 +1,198 @@ +:- dynamic tubes/1. +:- dynamic balls/2. +:- dynamic stop/1. + +% number of rows of pins (0 -> 9) +row(9). + +galton_box :- + retractall(tubes(_)), + retractall(balls(_,_)), + retractall(stop(_)), + assert(stop(@off)), + new(D, window('Galton Box')), + send(D, size, size(520,700)), + display_pins(D), + new(ChTubes, chain), + assert(tubes(ChTubes)), + display_tubes(D, ChTubes), + new(Balls, chain), + new(B, ball(D)), + send(Balls, append, B), + assert(balls(Balls, D)), + send(D, done_message, and(message(ChTubes, clear), + message(ChTubes, free), + message(Balls, for_all, message(@arg1, free)), + message(Balls, clear), + message(Balls, free), + message(@receiver, destroy))), + send(D, open). + +% class pin, balls travel between pins +:- pce_begin_class(pin, circle, "pin"). + +initialise(P, Pos) :-> + send(P, send_super, initialise, 18), + send(P, fill_pattern, new(_, colour(@default, 0, 0, 0))), + get(Pos, x, X), + get(Pos, y, Y), + send(P, geometry, x := X, y := Y). +:- pce_end_class. + + +% class tube, balls fall in them +:- pce_begin_class(tube, path, "tube where balls fall"). + +variable(indice, any, both, "index of the tube in the list"). +variable(balls, any, both, "number of balls inside"). + +initialise(P, Ind, D) :-> + row(Row), + send(P, send_super, initialise, kind := poly), + send(P, slot, balls, 0), + send(P, slot, indice, Ind), + X0 is 228 - Row * 20 + Ind * 40, + X1 is X0 + 20, + Y1 is 600, Y0 is 350, + send_list(P, append, [point(X0, Y0), point(X0, Y1), + point(X1,Y1), point(X1,Y0)]), + send(D, display, P). + +% animation stop when a tube is full +add_ball(P) :-> + get(P, slot, balls, B), + B1 is B+1, + send(P, slot, balls, B1), + ( B1 = 12 + -> retract(stop(_)), assert(stop(@on)) + ; true). +:- pce_end_class. + + +% class ball +:- pce_begin_class(ball, circle, "ball"). + +variable(angle, any, both, "angle of the ball with the pin"). +variable(dir, any, both, "left / right"). +variable(pin, point, both, "pin under the ball when it falls"). +variable(position, point, both, "position of the ball"). +variable(max_descent, any, both, "max descent"). +variable(state, any, both, "in_pins / in_tube"). +variable(window, any, both, "window to display"). +variable(mytimer, timer, both, "timer of the animation"). + +initialise(P, W) :-> + send(P, send_super, initialise, 18), + send(P, pen, 0), + send(P, state, in_pins), + send(P, fill_pattern, new(_, colour(@default, 65535, 0, 0))), + Ang is 3 * pi / 2, + send(P, slot, angle, Ang), + send(P, slot, window, W), + send(P, geometry, x := 250, y := 30), + send(P, pin, point(250, 50)), + send(P, choose_dir), + send(P, mytimer, new(_, timer(0.005, message(P, move_ball)))), + send(W, display, P), + send(P?mytimer, start). + +% method called when the object is destroyed +% first the timer is stopped +% then all the resources are freed +unlink(P) :-> + send(P?mytimer, stop), + send(P, send_super, unlink). + +choose_dir(P) :-> + I is random(2), + ( I = 1 -> Dir = left; Dir = right), + send(P, dir, Dir). + +move_ball(P) :-> + get(P, state, State), + ( State = in_pins + -> send(P, move_ball_in_pins) + ; send(P, move_ball_in_tube)). + +move_ball_in_pins(P) :-> + get(P, slot, angle, Ang), + get(P, slot, pin, Pin), + get(P, slot, dir, Dir), + ( Dir = left -> Ang1 is Ang-0.15 ; Ang1 is Ang + 0.15), + get(Pin, x, PX), + get(Pin, y, PY), + X is 21 * cos(Ang1) + PX, + Y is 21 * sin(Ang1) + PY, + send(P, geometry, x := X, y := Y), + send(P?window, display, P), + ( abs(Ang1 - pi) < 0.1 + -> PX1 is PX - 20, + send(P, next_move, PX1, PY) + ; abs(Ang1 - 2 * pi) < 0.1 + -> PX1 is PX + 20, + send(P, next_move, PX1, PY) + ; send(P, slot, angle, Ang1)). + +next_move(P, PX, PY) :-> + row(Row), + + Ang2 is 3 * pi / 2, + PY1 is PY + 30, + ( PY1 =:= (Row + 1) * 30 + 50 + -> send(P, slot, state, in_tube), + NumTube is round((PX - 228 + Row * 20) / 40), + tubes(ChTubes), + get(ChTubes, find, + message(@prolog, same_value,@arg1?indice, NumTube), + Tube), + send(Tube, add_ball), + get(Tube, slot, balls, Balls), + Max_descent is 600 - Balls * 20, + send(P, slot, max_descent, Max_descent), + send(P, slot, position, point(PX, PY)) + ; send(P, choose_dir), + send(P, slot, angle, Ang2), + send(P, slot, pin, point(PX, PY1))). + +move_ball_in_tube(P) :-> + get(P, slot, position, Descente), + get(Descente, x, PX1), + get(Descente, y, PY), + PY1 is PY+4, + send(P, geometry, x := PX1, y := PY1), + get(P, slot, max_descent, Max_descent), + ( Max_descent =< PY1 + -> send(P?mytimer, stop), + ( stop(@off) -> send(@prolog, next_ball); true) + ; send(P, slot, position, point(PX1, PY1))), + send(P?window, display, P). + +:- pce_end_class. + + +next_ball :- + retract(balls(Balls, D)), + new(B, ball(D)), + send(Balls, append, B), + assert(balls(Balls, D)). + +% test to find the appropriate tube +same_value(V, V). + +display_pins(D) :- + row(Row), + forall(between(0, Row, I), + ( Start is 250 - I * 20, + Y is I * 30 + 50, + forall(between(0, I, J), + ( X is Start + J * 40, + new(P, pin(point(X,Y))), + send(D, display, P))))). + +display_tubes(D, Ch) :- + row(Row), + Row1 is Row+1, + forall(between(0, Row1, I), + ( new(T, tube(I, D)), + send(Ch, append, T), + send(D, display, T))). diff --git a/Task/Galton-box-animation/Ruby/galton-box-animation.rb b/Task/Galton-box-animation/Ruby/galton-box-animation.rb new file mode 100644 index 0000000000..6a1fb79e84 --- /dev/null +++ b/Task/Galton-box-animation/Ruby/galton-box-animation.rb @@ -0,0 +1,77 @@ +$rows_of_pins = 12 +$width = $rows_of_pins * 10 + ($rows_of_pins+1)*14 + +Shoes.app( + :width => $width + 14, + :title => "Galton Box" +) do + @bins = Array.new($rows_of_pins+1, 0) + + @x_coords = Array.new($rows_of_pins) {Array.new} + @y_coords = Array.new($rows_of_pins) + stack(:width => $width) do + stroke gray + fill gray + 1.upto($rows_of_pins) do |row| + y = 14 + 24*row + @y_coords[row-1] = y + row.times do |i| + x = $width / 2 + (i - 0.5*row)*24 + 14 + @x_coords[row-1] << x + oval x+2, y, 6 + end + end + end + @y_coords << @y_coords[-1] + 24 + @x_coords << @x_coords[-1].map {|x| x-12} + [@x_coords[-1][-1]+12] + + @balls = stack(:width => $width) do + stroke red + fill red + end.move(0,0) + + @histogram = stack(:width => $width) do + nostroke + fill black + end.move(0, @y_coords[-1] + 10) + + @paused = false + keypress do |key| + case key + when "\x11", :control_q + exit + when "\x10", :control_p + @paused = !@paused + end + end + + @ball_row = 0 + @ball_col = 0 + animate(2*$rows_of_pins) do + if not @paused + y = @y_coords[@ball_row] - 12 + x = @x_coords[@ball_row][@ball_col] + @balls.clear {oval x, y, 10} + @ball_row += 1 + if @ball_row <= $rows_of_pins + @ball_col += 1 if rand >= 0.5 + else + @bins[@ball_col] += 1 + @ball_row = @ball_col = 0 + update_histogram + end + end + end + + def update_histogram + y = @y_coords[-1] + 10 + @histogram.clear do + @bins.each_with_index do |num, i| + if num > 0 + x = @x_coords[-1][i] + rect x-6, 0, 24, num + end + end + end + end +end diff --git a/Task/Galton-box-animation/Tcl/galton-box-animation.tcl b/Task/Galton-box-animation/Tcl/galton-box-animation.tcl new file mode 100644 index 0000000000..e7a15886a0 --- /dev/null +++ b/Task/Galton-box-animation/Tcl/galton-box-animation.tcl @@ -0,0 +1,101 @@ +package require Tcl 8.6 + +oo::class create GaltonBox { + variable b w h n x y cnt step dropping + + constructor {BALLS {NUMPEGS 5} {HEIGHT 24}} { + set n $NUMPEGS + set w [expr {$n*2 + 1}] + set h $HEIGHT + puts -nonewline "\033\[H\033\[J" + set x [set y [lrepeat $BALLS 0]] + set cnt 0 + set step 0 + set dropping 1 + + set b [lrepeat $h [lrepeat $w " "]] + for {set i 0} {$i < $n} {incr i} { + for {set j [expr {-$i}]} {$j <= $i} {incr j 2} { + lset b [expr {2*$i+2}] [expr {$j+$w/2}] "*" + } + } + } + + method show {} { + puts -nonewline "\033\[H" + set oldrow {} + foreach row $b { + foreach char $row oldchar $oldrow { + if {$char ne "*"} { + puts -nonewline "$char " + } elseif {$oldchar eq " "} { + puts -nonewline "\033\[32m*\033\[m " + } else { + puts -nonewline "\033\[31m*\033\[m " + } + } + set oldrow $row + puts "" + } + } + + method Move idx { + set xx [lindex $x $idx] + set yy [lindex $y $idx] + set kill 0 + + if {$yy < 0} {return 0} + if {$yy == $h-1} { + lset y $idx -1 + return 0 + } + + switch [lindex $b [incr yy] $xx] { + "*" { + incr xx [expr {2*int(2 * rand()) - 1}] + if {[lindex $b [incr yy -1] $xx] ne " "} { + set dropping 0 + } + } + "o" { + incr yy -1 + set kill 1 + } + } + + set c [lindex $b [lindex $y $idx] [lindex $x $idx]] + lset b [lindex $y $idx] [lindex $x $idx] " " + lset b $yy $xx $c + if {$kill} { + lset y $idx -1 + } else { + lset y $idx $yy + } + lset x $idx $xx + return [expr {!$kill}] + } + + method step {} { + set moving 0 + for {set i 0} {$i < $cnt} {incr i} { + set moving [expr {[my Move $i] || $moving}] + } + if {2 == [incr step] && $cnt < [llength $x] && $dropping} { + set step 0 + lset x $cnt [expr {$w / 2}] + lset y $cnt 0 + if {[lindex $b [lindex $y $cnt] [lindex $x $cnt]] ne " "} { + return 0 + } + lset b [lindex $y $cnt] [lindex $x $cnt] "o" + incr cnt + } + return [expr {($moving || $dropping)}] + } +} + +GaltonBox create board 1024 {*}$argv +while true { + board show + if {[board step]} {after 60} break +} diff --git a/Task/Gamma-function/0DESCRIPTION b/Task/Gamma-function/0DESCRIPTION new file mode 100644 index 0000000000..c45331ac78 --- /dev/null +++ b/Task/Gamma-function/0DESCRIPTION @@ -0,0 +1,10 @@ +{{omit from|GAP}} +Implement one algorithm (or more) to compute the [[wp:Gamma function|Gamma]] (\Gamma) function (in the real field only). If your language has the function as builtin or you know a library which has it, compare your implementation's results with the results of the builtin/library function. +The Gamma function can be defined as: + +:\Gamma(x) = \displaystyle\int_0^\infty t^{x-1}e^{-t} dt + +This suggests a straightforward (but inefficient) way of computing the \Gamma through numerical integration. +Better suggested methods: +* [[wp:Lanczos approximation|Lanczos approximation]] +* [[wp:Stirling's approximation|Stirling's approximation]] diff --git a/Task/Gamma-function/1META.yaml b/Task/Gamma-function/1META.yaml new file mode 100644 index 0000000000..8d1c0603c8 --- /dev/null +++ b/Task/Gamma-function/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations diff --git a/Task/Gamma-function/ALGOL-68/gamma-function.alg b/Task/Gamma-function/ALGOL-68/gamma-function.alg new file mode 100644 index 0000000000..f9bb19c359 --- /dev/null +++ b/Task/Gamma-function/ALGOL-68/gamma-function.alg @@ -0,0 +1,131 @@ +# Coefficients used by the GNU Scientific Library # +[]LONG REAL p = ( LONG 0.99999 99999 99809 93, + LONG 676.52036 81218 851, + -LONG 1259.13921 67224 028, + LONG 771.32342 87776 5313, + -LONG 176.61502 91621 4059, + LONG 12.50734 32786 86905, + -LONG 0.13857 10952 65720 12, + LONG 9.98436 95780 19571 6e-6, + LONG 1.50563 27351 49311 6e-7); + +PROC lanczos gamma = (LONG REAL in z)LONG REAL: ( + # Reflection formula # + LONG REAL z := in z; + IF z < LONG 0.5 THEN + long pi / (long sin(long pi*z)*lanczos gamma(1-z)) + ELSE + z -:= 1; + LONG REAL x := p[1]; + FOR i TO UPB p - 1 DO x +:= p[i+1]/(z+i) OD; + LONG REAL t = z + UPB p - LONG 1.5; + long sqrt(2*long pi) * t**(z+LONG 0.5) * long exp(-t) * x + FI +); + +PROC taylor gamma = (LONG REAL x)LONG REAL: +BEGIN # good for values between 0 and 1 # + []LONG REAL a = + ( LONG 1.00000 00000 00000 00000, + LONG 0.57721 56649 01532 86061, + -LONG 0.65587 80715 20253 88108, + -LONG 0.04200 26350 34095 23553, + LONG 0.16653 86113 82291 48950, + -LONG 0.04219 77345 55544 33675, + -LONG 0.00962 19715 27876 97356, + LONG 0.00721 89432 46663 09954, + -LONG 0.00116 51675 91859 06511, + -LONG 0.00021 52416 74114 95097, + LONG 0.00012 80502 82388 11619, + -LONG 0.00002 01348 54780 78824, + -LONG 0.00000 12504 93482 14267, + LONG 0.00000 11330 27231 98170, + -LONG 0.00000 02056 33841 69776, + LONG 0.00000 00061 16095 10448, + LONG 0.00000 00050 02007 64447, + -LONG 0.00000 00011 81274 57049, + LONG 0.00000 00001 04342 67117, + LONG 0.00000 00000 07782 26344, + -LONG 0.00000 00000 03696 80562, + LONG 0.00000 00000 00510 03703, + -LONG 0.00000 00000 00020 58326, + -LONG 0.00000 00000 00005 34812, + LONG 0.00000 00000 00001 22678, + -LONG 0.00000 00000 00000 11813, + LONG 0.00000 00000 00000 00119, + LONG 0.00000 00000 00000 00141, + -LONG 0.00000 00000 00000 00023, + LONG 0.00000 00000 00000 00002 + ); + LONG REAL y = x - 1; + LONG REAL sum := a [UPB a]; + FOR n FROM UPB a - 1 DOWNTO LWB a DO + sum := sum * y + a [n] + OD; + 1/sum +END # taylor gamma #; + +LONG REAL long e = long exp(1); + +PROC sterling gamma = (LONG REAL n)LONG REAL: +( # improves for values much greater then 1 # + long sqrt(2*long pi/n)*(n/long e)**n +); + +PROC factorial = (LONG INT n)LONG REAL: +( + IF n=0 OR n=1 THEN 1 + ELIF n=2 THEN 2 + ELSE n*factorial(n-1) FI +); + +REF[]LONG REAL fm := NIL; + +PROC sponge gamma = (LONG REAL x)LONG REAL: +( + INT a = 12; # alter to get required precision # + REF []LONG REAL fm := NIL; + LONG REAL res; + + IF fm :=: REF[]LONG REAL(NIL) THEN + fm := HEAP[0:a-1]LONG REAL; + fm[0] := long sqrt(LONG 2*long pi); + FOR k TO a-1 DO + fm[k] := (((k-1) MOD 2=0) | 1 | -1) * long exp(a-k) * + (a-k) **(k-LONG 0.5) / factorial(k-1) + OD + FI; + res := fm[0]; + FOR k TO a-1 DO + res +:= fm[k] / ( x + k ) + OD; + res *:= long exp(-(x+a)) * (x+a)**(x + LONG 0.5); + res/x +); + +FORMAT real fmt = $g(-real width, real width - 2)$; +FORMAT long real fmt16 = $g(-17, 17 - 2)$; # accurate to about 16 decimal places # + +[]STRING methods = ("Genie", "Lanczos", "Sponge", "Taylor","Stirling"); + +printf(($11xg12xg12xg13xg13xgl$,methods)); + +FORMAT sample fmt = $"gamma("g(-3,1)")="f(real fmt)n(UPB methods-1)(", "f(long real fmt16))l$; +FORMAT sqr sample fmt = $"gamma("g(-3,1)")**2="f(real fmt)n(UPB methods-1)(", "f(long real fmt16))l$; +FORMAT sample exp fmt = $"gamma("g(-3)")="g(-15,11,0)n(UPB methods-1)(","g(-18,14,0))l$; + +PROC sample = (LONG REAL x)[]LONG REAL: + (gamma(SHORTEN x), lanczos gamma(x), sponge gamma(x), taylor gamma(x), sterling gamma(x)); + +FOR i FROM 1 TO 20 DO + LONG REAL x = i / LONG 10; + printf((sample fmt, x, sample(x))); + IF i = 5 THEN # insert special case of a half # + printf((sqr sample fmt, + x, gamma(SHORTEN x)**2, lanczos gamma(x)**2, sponge gamma(x)**2, + taylor gamma(x)**2, sterling gamma(x)**2)) + FI +OD; +FOR x FROM 10 BY 10 TO 70 DO + printf((sample exp fmt, x, sample(x))) +OD diff --git a/Task/Gamma-function/Ada/gamma-function-1.ada b/Task/Gamma-function/Ada/gamma-function-1.ada new file mode 100644 index 0000000000..e752faf793 --- /dev/null +++ b/Task/Gamma-function/Ada/gamma-function-1.ada @@ -0,0 +1,41 @@ +function Gamma (X : Long_Float) return Long_Float is + A : constant array (0..29) of Long_Float := + ( 1.00000_00000_00000_00000, + 0.57721_56649_01532_86061, + -0.65587_80715_20253_88108, + -0.04200_26350_34095_23553, + 0.16653_86113_82291_48950, + -0.04219_77345_55544_33675, + -0.00962_19715_27876_97356, + 0.00721_89432_46663_09954, + -0.00116_51675_91859_06511, + -0.00021_52416_74114_95097, + 0.00012_80502_82388_11619, + -0.00002_01348_54780_78824, + -0.00000_12504_93482_14267, + 0.00000_11330_27231_98170, + -0.00000_02056_33841_69776, + 0.00000_00061_16095_10448, + 0.00000_00050_02007_64447, + -0.00000_00011_81274_57049, + 0.00000_00001_04342_67117, + 0.00000_00000_07782_26344, + -0.00000_00000_03696_80562, + 0.00000_00000_00510_03703, + -0.00000_00000_00020_58326, + -0.00000_00000_00005_34812, + 0.00000_00000_00001_22678, + -0.00000_00000_00000_11813, + 0.00000_00000_00000_00119, + 0.00000_00000_00000_00141, + -0.00000_00000_00000_00023, + 0.00000_00000_00000_00002 + ); + Y : constant Long_Float := X - 1.0; + Sum : Long_Float := A (A'Last); +begin + for N in reverse A'First..A'Last - 1 loop + Sum := Sum * Y + A (N); + end loop; + return 1.0 / Sum; +end Gamma; diff --git a/Task/Gamma-function/Ada/gamma-function-2.ada b/Task/Gamma-function/Ada/gamma-function-2.ada new file mode 100644 index 0000000000..156df18998 --- /dev/null +++ b/Task/Gamma-function/Ada/gamma-function-2.ada @@ -0,0 +1,9 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Gamma; + +procedure Test_Gamma is +begin + for I in 1..10 loop + Put_Line (Long_Float'Image (Gamma (Long_Float (I) / 3.0))); + end loop; +end Test_Gamma; diff --git a/Task/Gamma-function/AutoHotkey/gamma-function.ahk b/Task/Gamma-function/AutoHotkey/gamma-function.ahk new file mode 100644 index 0000000000..82fea87c09 --- /dev/null +++ b/Task/Gamma-function/AutoHotkey/gamma-function.ahk @@ -0,0 +1,82 @@ +/* +Here is the upper incomplete Gamma function. Omitting or setting +the second parameter to 0 we get the (complete) Gamma function. +The code is based on: "Computation of Special Functions" Zhang and Jin, +John Wiley and Sons, 1996 +*/ + +SetFormat FloatFast, 0.9e + +Loop 10 + MsgBox % GAMMA(A_Index/3) "`n" GAMMA(A_Index*10) + +GAMMA(a,x=0) { ; upper incomplete gamma: Integral(t**(a-1)*e**-t, t = x..inf) + If (a > 171 || x < 0) + Return 2.e308 ; overflow + + xam := x > 0 ? -x+a*ln(x) : 0 + If (xam > 700) + Return 2.e308 ; overflow + + If (x > 1+a) { ; no need for gamma(a) + t0 := 0, k := 60 + Loop 60 + t0 := (k-a)/(1+k/(x+t0)), --k + Return exp(xam) / (x+t0) + } + + r := 1, ga := 1.0 ; compute ga = gamma(a) ... + If (a = round(a)) ; if integer: factorial + If (a > 0) + Loop % a-1 + ga *= A_Index + Else ; negative integer + ga := 1.7976931348623157e+308 ; Dmax + Else { ; not integer + If (abs(a) > 1) { + z := abs(a) + m := floor(z) + Loop %m% + r *= (z-A_Index) + z -= m + } + Else + z := a + + gr := ((((((((((((((((((((((( 0.14e-14 + *z - 0.54e-14) *z - 0.206e-13) *z + 0.51e-12) + *z - 0.36968e-11) *z + 0.77823e-11) *z + 0.1043427e-9) + *z - 0.11812746e-8) *z + 0.50020075e-8) *z + 0.6116095e-8) + *z - 0.2056338417e-6) *z + 0.1133027232e-5) *z - 0.12504934821e-5) + *z - 0.201348547807e-4) *z + 0.1280502823882e-3) *z - 0.2152416741149e-3) + *z - 0.11651675918591e-2) *z + 0.7218943246663e-2) *z - 0.9621971527877e-2) + *z - 0.421977345555443e-1) *z + 0.1665386113822915) *z - 0.420026350340952e-1) + *z - 0.6558780715202538) *z + 0.5772156649015329) *z + 1 + + ga := 1.0/(gr*z) * r + If (a < -1) + ga := -3.1415926535897931/(a*ga*sin(3.1415926535897931*a)) + } + + If (x = 0) ; complete gamma requested + Return ga + + s := 1/a ; here x <= 1+a + r := s + Loop 60 { + r *= x/(a+A_Index) + s += r + If (abs(r/s) < 1.e-15) + break + } + Return ga - exp(xam)*s +} + +/* +The 10 results shown: +2.678938535e+000 1.354117939e+000 1.0 8.929795115e-001 9.027452930e-001 +3.628800000e+005 1.216451004e+017 8.841761994e+030 2.039788208e+046 6.082818640e+062 + +1.000000000e+000 1.190639348e+000 1.504575489e+000 2.000000000e+000 2.778158479e+000 +1.386831185e+080 1.711224524e+098 8.946182131e+116 1.650795516e+136 9.332621544e+155 +*/ diff --git a/Task/Gamma-function/BBC-BASIC/gamma-function.bbc b/Task/Gamma-function/BBC-BASIC/gamma-function.bbc new file mode 100644 index 0000000000..f0b0f50a71 --- /dev/null +++ b/Task/Gamma-function/BBC-BASIC/gamma-function.bbc @@ -0,0 +1,23 @@ + *FLOAT64 + INSTALL @lib$+"FNUSING" + + FOR x = 0.1 TO 2.05 STEP 0.1 + PRINT FNusing("#.#",x), FNusing("##.############", FNgamma(x)) + NEXT + END + + DEF FNgamma(z) = EXP(FNlngamma(z)) + + DEF FNlngamma(z) + LOCAL a, b, i%, lz() + DIM lz(6) + lz() = 1.000000000190015, 76.18009172947146, -86.50532032941677, \ + \ 24.01409824083091, -1.231739572450155, 0.0012086509738662, -0.000005395239385 + IF z < 0.5 THEN = LN(PI / SIN(PI * z)) - FNlngamma(1.0 - z) + z -= 1.0 + b = z + 5.5 + a = lz(0) + FOR i% = 1 TO 6 + a += lz(i%) / (z + i%) + NEXT + = (LNSQR(2*PI) + LN(a) - b) + LN(b) * (z+0.5) diff --git a/Task/Gamma-function/C/gamma-function.c b/Task/Gamma-function/C/gamma-function.c new file mode 100644 index 0000000000..81dcdc28a9 --- /dev/null +++ b/Task/Gamma-function/C/gamma-function.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* very simple approximation */ +double st_gamma(double x) +{ + return sqrt(2.0*M_PI/x)*pow(x/M_E, x); +} + +#define A 12 +double sp_gamma(double z) +{ + const int a = A; + static double c_space[A]; + static double *c = NULL; + int k; + double accm; + + if ( c == NULL ) { + double k1_factrl = 1.0; /* (k - 1)!*(-1)^k with 0!==1*/ + c = c_space; + c[0] = sqrt(2.0*M_PI); + for(k=1; k < a; k++) { + c[k] = exp(a-k) * pow(a-k, k-0.5) / k1_factrl; + k1_factrl *= -k; + } + } + accm = c[0]; + for(k=1; k < a; k++) { + accm += c[k] / ( z + k ); + } + accm *= exp(-(z+a)) * pow(z+a, z+0.5); /* Gamma(z+1) */ + return accm/z; +} + +int main() +{ + double x; + + + printf("%15s%15s%15s%15s\n", "Stirling", "Spouge", "GSL", "libm"); + for(x=1.0; x <= 10.0; x+=1.0) { + printf("%15.8lf%15.8lf%15.8lf%15.8lf\n", st_gamma(x/3.0), sp_gamma(x/3.0), + gsl_sf_gamma(x/3.0), tgamma(x/3.0)); + } + return 0; +} diff --git a/Task/Gamma-function/Clojure/gamma-function-1.clj b/Task/Gamma-function/Clojure/gamma-function-1.clj new file mode 100644 index 0000000000..909629892a --- /dev/null +++ b/Task/Gamma-function/Clojure/gamma-function-1.clj @@ -0,0 +1,15 @@ +(defn gamma + "Returns Gamma(z + 1 = number) using Lanczos approximation." + [number] + (if (< number 0.5) + (/ Math/PI (* (Math/sin (* Math/PI number)) + (gamma (- 1 number)))) + (let [n (dec number) + c [0.99999999999980993 676.5203681218851 -1259.1392167224028 + 771.32342877765313 -176.61502916214059 12.507343278686905 + -0.13857109526572012 9.9843695780195716e-6 1.5056327351493116e-7]] + (* (Math/sqrt (* 2 Math/PI)) + (Math/pow (+ n 7 0.5) (+ n 0.5)) + (Math/exp (- (+ n 7 0.5))) + (+ (first c) + (apply + (map-indexed #(/ %2 (+ n %1 1)) (next c)))))))) diff --git a/Task/Gamma-function/Clojure/gamma-function-2.clj b/Task/Gamma-function/Clojure/gamma-function-2.clj new file mode 100644 index 0000000000..acb2845b30 --- /dev/null +++ b/Task/Gamma-function/Clojure/gamma-function-2.clj @@ -0,0 +1 @@ +(map #(printf "%.1f %.4f\n" % (gamma %)) (map #(float (/ % 10)) (range 1 31))) diff --git a/Task/Gamma-function/Common-Lisp/gamma-function.lisp b/Task/Gamma-function/Common-Lisp/gamma-function.lisp new file mode 100644 index 0000000000..2fde51a014 --- /dev/null +++ b/Task/Gamma-function/Common-Lisp/gamma-function.lisp @@ -0,0 +1,26 @@ +; Taylor series coefficients +(defconstant tcoeff + '( 1.00000000000000000000 0.57721566490153286061 -0.65587807152025388108 + -0.04200263503409523553 0.16653861138229148950 -0.04219773455554433675 + -0.00962197152787697356 0.00721894324666309954 -0.00116516759185906511 + -0.00021524167411495097 0.00012805028238811619 -0.00002013485478078824 + -0.00000125049348214267 0.00000113302723198170 -0.00000020563384169776 + 0.00000000611609510448 0.00000000500200764447 -0.00000000118127457049 + 0.00000000010434267117 0.00000000000778226344 -0.00000000000369680562 + 0.00000000000051003703 -0.00000000000002058326 -0.00000000000000534812 + 0.00000000000000122678 -0.00000000000000011813 0.00000000000000000119 + 0.00000000000000000141 -0.00000000000000000023 0.00000000000000000002)) + +; number of coefficients +(defconstant numcoeff (length tcoeff)) + +(defun gamma (x) + (let ((y (- x 1.0)) + (sum (nth (- numcoeff 1) tcoeff))) + (loop for i from (- numcoeff 2) downto 0 do + (setf sum (+ (* sum y) (nth i tcoeff)))) + (/ 1.0 sum))) + +(loop for i from 1 to 10 + do ( + format t "~12,10f~%" (gamma (/ i 3.0)))) diff --git a/Task/Gamma-function/D/gamma-function.d b/Task/Gamma-function/D/gamma-function.d new file mode 100644 index 0000000000..5648911d59 --- /dev/null +++ b/Task/Gamma-function/D/gamma-function.d @@ -0,0 +1,28 @@ +import std.stdio, std.mathspecial; + +real myGamma(in real x) pure nothrow { + static immutable real[30] table = [ + 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108, +-0.04200263503409523553, 0.16653861138229148950, -0.04219773455554433675, +-0.00962197152787697356, 0.00721894324666309954, -0.00116516759185906511, +-0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824, +-0.00000125049348214267, 0.00000113302723198170, -0.00000020563384169776, + 0.00000000611609510448, 0.00000000500200764447, -0.00000000118127457049, + 0.00000000010434267117, 0.00000000000778226344, -0.00000000000369680562, + 0.00000000000051003703, -0.00000000000002058326, -0.00000000000000534812, + 0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119, + 0.00000000000000000141, -0.00000000000000000023, 0.00000000000000000002]; + + immutable real y = x - 1.0L; + real sm = table[$ - 1]; + foreach_reverse (immutable an; table[0 .. $ - 1]) + sm = sm * y + an; + return 1.0L / sm; +} + +void main() { + foreach (immutable i; 1 .. 11) { + immutable real x = i / 3.0L; + writefln("%f: %20.19e %20.19e", x, myGamma(x), gamma(x)); + } +} diff --git a/Task/Gamma-function/Fortran/gamma-function.f b/Task/Gamma-function/Fortran/gamma-function.f new file mode 100644 index 0000000000..9e40c1fc16 --- /dev/null +++ b/Task/Gamma-function/Fortran/gamma-function.f @@ -0,0 +1,98 @@ +program ComputeGammaInt + + implicit none + + integer :: i + + write(*, "(3A15)") "Simpson", "Lanczos", "Builtin" + do i=1, 10 + write(*, "(3F15.8)") my_gamma(i/3.0), lacz_gamma(i/3.0), gamma(i/3.0) + end do + +contains + + pure function intfuncgamma(x, y) result(z) + real :: z + real, intent(in) :: x, y + + z = x**(y-1.0) * exp(-x) + end function intfuncgamma + + + function my_gamma(a) result(g) + real :: g + real, intent(in) :: a + + real, parameter :: small = 1.0e-4 + integer, parameter :: points = 100000 + + real :: infty, dx, p, sp(2, points), x + integer :: i + logical :: correction + + x = a + + correction = .false. + ! value with x<1 gives \infty, so we use + ! \Gamma(x+1) = x\Gamma(x) + ! to avoid the problem + if ( x < 1.0 ) then + correction = .true. + x = x + 1 + end if + + ! find a "reasonable" infinity... + ! we compute this integral indeed + ! \int_0^M dt t^{x-1} e^{-t} + ! where M is such that M^{x-1} e^{-M} ≤ \epsilon + infty = 1.0e4 + do while ( intfuncgamma(infty, x) > small ) + infty = infty * 10.0 + end do + + ! using simpson + dx = infty/real(points) + sp = 0.0 + forall(i=1:points/2-1) sp(1, 2*i) = intfuncgamma(2.0*(i)*dx, x) + forall(i=1:points/2) sp(2, 2*i - 1) = intfuncgamma((2.0*(i)-1.0)*dx, x) + g = (intfuncgamma(0.0, x) + 2.0*sum(sp(1,:)) + 4.0*sum(sp(2,:)) + & + intfuncgamma(infty, x))*dx/3.0 + + if ( correction ) g = g/a + + end function my_gamma + + + recursive function lacz_gamma(a) result(g) + real, intent(in) :: a + real :: g + + real, parameter :: pi = 3.14159265358979324 + integer, parameter :: cg = 7 + + ! these precomputed values are taken by the sample code in Wikipedia, + ! and the sample itself takes them from the GNU Scientific Library + real, dimension(0:8), parameter :: p = & + (/ 0.99999999999980993, 676.5203681218851, -1259.1392167224028, & + 771.32342877765313, -176.61502916214059, 12.507343278686905, & + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7 /) + + real :: t, w, x + integer :: i + + x = a + + if ( x < 0.5 ) then + g = pi / ( sin(pi*x) * lacz_gamma(1.0-x) ) + else + x = x - 1.0 + t = p(0) + do i=1, cg+2 + t = t + p(i)/(x+real(i)) + end do + w = x + real(cg) + 0.5 + g = sqrt(2.0*pi) * w**(x+0.5) * exp(-w) * t + end if + end function lacz_gamma + +end program ComputeGammaInt diff --git a/Task/Gamma-function/Go/gamma-function.go b/Task/Gamma-function/Go/gamma-function.go new file mode 100644 index 0000000000..128c909d93 --- /dev/null +++ b/Task/Gamma-function/Go/gamma-function.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + fmt.Println(" x math.Gamma Lanczos7") + for _, x := range []float64{-.5, .1, .5, 1, 1.5, 2, 3, 10, 140, 170} { + fmt.Printf("%5.1f %24.16g %24.16g\n", x, math.Gamma(x), lanczos7(x)) + } +} + +func lanczos7(z float64) float64 { + t := z + 6.5 + x := .99999999999980993 + + 676.5203681218851/z - + 1259.1392167224028/(z+1) + + 771.32342877765313/(z+2) - + 176.61502916214059/(z+3) + + 12.507343278686905/(z+4) - + .13857109526572012/(z+5) + + 9.9843695780195716e-6/(z+6) + + 1.5056327351493116e-7/(z+7) + return math.Sqrt2 * math.SqrtPi * math.Pow(t, z-.5) * math.Exp(-t) * x +} diff --git a/Task/Gamma-function/Groovy/gamma-function.groovy b/Task/Gamma-function/Groovy/gamma-function.groovy new file mode 100644 index 0000000000..a6c75a54de --- /dev/null +++ b/Task/Gamma-function/Groovy/gamma-function.groovy @@ -0,0 +1,14 @@ +a = [ 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108, + -0.04200263503409523553, 0.16653861138229148950, -0.04219773455554433675, + -0.00962197152787697356, 0.00721894324666309954, -0.00116516759185906511, + -0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824, + -0.00000125049348214267, 0.00000113302723198170, -0.00000020563384169776, + 0.00000000611609510448, 0.00000000500200764447, -0.00000000118127457049, + 0.00000000010434267117, 0.00000000000778226344, -0.00000000000369680562, + 0.00000000000051003703, -0.00000000000002058326, -0.00000000000000534812, + 0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119, + 0.00000000000000000141, -0.00000000000000000023, 0.00000000000000000002].reverse() + +def gamma = { 1.0 / a.inject(0) { sm, a_i -> sm * (it - 1) + a_i } } + +(1..10).each{ printf("% 1.9e\n", gamma(it / 3.0)) } diff --git a/Task/Gamma-function/Haskell/gamma-function.hs b/Task/Gamma-function/Haskell/gamma-function.hs new file mode 100644 index 0000000000..4b26d301e4 --- /dev/null +++ b/Task/Gamma-function/Haskell/gamma-function.hs @@ -0,0 +1,10 @@ +cof :: [Double] +cof = [76.18009172947146,-86.50532032941677,24.01409824083091,-1.231739572450155,0.001208650973866179,-0.000005395239384953] + +ser :: Double +ser = 1.000000000190015 + +gammaln :: Double -> Double +gammaln xx = let tmp' = (xx+5.5) - (xx+0.5)*log(xx+5.5) + ser' = ser + sum (zipWith (/) cof [xx+1..]) + in -tmp' + log(2.5066282746310005 * ser' / xx) diff --git a/Task/Gamma-function/J/gamma-function-1.j b/Task/Gamma-function/J/gamma-function-1.j new file mode 100644 index 0000000000..194026643e --- /dev/null +++ b/Task/Gamma-function/J/gamma-function-1.j @@ -0,0 +1 @@ +gamma=: !@<: diff --git a/Task/Gamma-function/J/gamma-function-2.j b/Task/Gamma-function/J/gamma-function-2.j new file mode 100644 index 0000000000..b19e14d293 --- /dev/null +++ b/Task/Gamma-function/J/gamma-function-2.j @@ -0,0 +1,3 @@ +sbase =: %:@(2p1&%) * %&1x1 ^ ] +scorr =: 1 1r12 1r288 _139r51840 _571r2488320&p.@% +stirlg=: sbase * scorr diff --git a/Task/Gamma-function/J/gamma-function-3.j b/Task/Gamma-function/J/gamma-function-3.j new file mode 100644 index 0000000000..494ac2e436 --- /dev/null +++ b/Task/Gamma-function/J/gamma-function-3.j @@ -0,0 +1,6 @@ + (,. stirlg ,. gamma) 10 1p1 1x1 1.5 1 + 10 362880 362880 +3.14159 2.28803 2.28804 +2.71828 1.56746 1.56747 + 1.5 0.886155 0.886227 + 1 0.999499 1 diff --git a/Task/Gamma-function/Java/gamma-function.java b/Task/Gamma-function/Java/gamma-function.java new file mode 100644 index 0000000000..2983f22550 --- /dev/null +++ b/Task/Gamma-function/Java/gamma-function.java @@ -0,0 +1,31 @@ +public class GammaFunction { + + public double st_gamma(double x){ + return Math.sqrt(2*Math.PI/x)*Math.pow((x/Math.E), x); + } + + public double la_gamma(double x){ + double[] p = {0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7}; + int g = 7; + if(x < 0.5) return Math.PI / (Math.sin(Math.PI * x)*la_gamma(1-x)); + + x -= 1; + double a = p[0]; + double t = x+g+0.5; + for(int i = 1; i < p.length; i++){ + a += p[i]/(x+i); + } + + return Math.sqrt(2*Math.PI)*Math.pow(t, x+0.5)*Math.exp(-t)*a; + } + + public static void main(String[] args) { + GammaFunction test = new GammaFunction(); + System.out.println("Gamma \t\tStirling \t\tLanczos"); + for(double i = 1; i <= 20; i += 1){ + System.out.println("" + i/10.0 + "\t\t" + test.st_gamma(i/10.0) + "\t" + test.la_gamma(i/10.0)); + } + } +} diff --git a/Task/Gamma-function/Lua/gamma-function.lua b/Task/Gamma-function/Lua/gamma-function.lua new file mode 100644 index 0000000000..7941b39719 --- /dev/null +++ b/Task/Gamma-function/Lua/gamma-function.lua @@ -0,0 +1,11 @@ +gamma, coeff, quad, qui, set = 0.577215664901, -0.65587807152056, -0.042002635033944, 0.16653861138228, -0.042197734555571 +function recigamma(z) + return z + gamma * z^2 + coeff * z^3 + quad * z^4 + qui * z^5 + set * z^6 +end + +function gammafunc(z) + if z == 1 then return 1 + elseif math.abs(z) <= 0.5 then return 1 / recigamma(z) + else return (z - 1) * gammafunc(z-1) + end +end diff --git a/Task/Gamma-function/Mathematica/gamma-function.mathematica b/Task/Gamma-function/Mathematica/gamma-function.mathematica new file mode 100644 index 0000000000..b09b561dd6 --- /dev/null +++ b/Task/Gamma-function/Mathematica/gamma-function.mathematica @@ -0,0 +1 @@ +Gamma[x] diff --git a/Task/Gamma-function/Maxima/gamma-function.maxima b/Task/Gamma-function/Maxima/gamma-function.maxima new file mode 100644 index 0000000000..6d4eae0f24 --- /dev/null +++ b/Task/Gamma-function/Maxima/gamma-function.maxima @@ -0,0 +1,21 @@ +fpprec: 30$ + +gamma_coeff(n) := block([a: makelist(1, n)], + a[2]: bfloat(%gamma), + for k from 3 thru n do + a[k]: bfloat((sum((-1)^j * zeta(j) * a[k - j], j, 2, k - 1) - a[2] * a[k - 1]) / (1 - k * a[1])), + a)$ + +poleval(a, x) := block([y: 0], + for k from length(a) thru 1 step -1 do + y: y * x + a[k], + y)$ + +gc: gamma_coeff(20)$ + +gamma_approx(x) := block([y: 1], + while x > 2 do (x: x - 1, y: y * x), + y / (poleval(gc, x - 1)))$ + +gamma_approx(12.3b0) - gamma(12.3b0); +/* -9.25224705314470500985141176997b-15 */ diff --git a/Task/Gamma-function/Modula-3/gamma-function.mod3 b/Task/Gamma-function/Modula-3/gamma-function.mod3 new file mode 100644 index 0000000000..0a77f00405 --- /dev/null +++ b/Task/Gamma-function/Modula-3/gamma-function.mod3 @@ -0,0 +1,37 @@ +MODULE Gamma EXPORTS Main; + +FROM IO IMPORT Put; +FROM Fmt IMPORT Extended, Style; + +PROCEDURE Taylor(x: EXTENDED): EXTENDED = + CONST a = ARRAY [0..29] OF EXTENDED { + 1.00000000000000000000X0, 0.57721566490153286061X0, + -0.65587807152025388108X0, -0.04200263503409523553X0, + 0.16653861138229148950X0, -0.04219773455554433675X0, + -0.00962197152787697356X0, 0.00721894324666309954X0, + -0.00116516759185906511X0, -0.00021524167411495097X0, + 0.00012805028238811619X0, -0.00002013485478078824X0, + -0.00000125049348214267X0, 0.00000113302723198170X0, + -0.00000020563384169776X0, 0.00000000611609510448X0, + 0.00000000500200764447X0, -0.00000000118127457049X0, + 0.00000000010434267117X0, 0.00000000000778226344X0, + -0.00000000000369680562X0, 0.00000000000051003703X0, + -0.00000000000002058326X0, -0.00000000000000534812X0, + 0.00000000000000122678X0, -0.00000000000000011813X0, + 0.00000000000000000119X0, 0.00000000000000000141X0, + -0.00000000000000000023X0, 0.00000000000000000002X0 }; + VAR y := x - 1.0X0; + sum := a[LAST(a)]; + + BEGIN + FOR i := LAST(a) - 1 TO FIRST(a) BY -1 DO + sum := sum * y + a[i]; + END; + RETURN 1.0X0 / sum; + END Taylor; + +BEGIN + FOR i := 1 TO 10 DO + Put(Extended(Taylor(FLOAT(i, EXTENDED) / 3.0X0), style := Style.Sci) & "\n"); + END; +END Gamma. diff --git a/Task/Gamma-function/Perl/gamma-function.pl b/Task/Gamma-function/Perl/gamma-function.pl new file mode 100644 index 0000000000..9760ce5ad3 --- /dev/null +++ b/Task/Gamma-function/Perl/gamma-function.pl @@ -0,0 +1,44 @@ +my @coeff = reverse ; +sub Gamma { + my $x = shift; + my $s; + $s = $s*($x-1) + $_ for @coeff; + return 1 / $s; +} + +for (1 .. 10) { + $_ /= 3; + printf "Gamma(%.5f) ≈ %.14e\n", $_, Gamma($_); +} + +__DATA__ +1.00000000000000000000 +0.57721566490153286061 +-0.65587807152025388108 +-0.04200263503409523553 +0.16653861138229148950 +-0.04219773455554433675 +-0.00962197152787697356 +0.00721894324666309954 +-0.00116516759185906511 +-0.00021524167411495097 +0.00012805028238811619 +-0.00002013485478078824 +-0.00000125049348214267 +0.00000113302723198170 +-0.00000020563384169776 +0.00000000611609510448 +0.00000000500200764447 +-0.00000000118127457049 +0.00000000010434267117 +0.00000000000778226344 +-0.00000000000369680562 +0.00000000000051003703 +-0.00000000000002058326 +-0.00000000000000534812 +0.00000000000000122678 +-0.00000000000000011813 +0.00000000000000000119 +0.00000000000000000141 +-0.00000000000000000023 +0.00000000000000000002 diff --git a/Task/Gamma-function/PicoLisp/gamma-function.l b/Task/Gamma-function/PicoLisp/gamma-function.l new file mode 100644 index 0000000000..3902a1409c --- /dev/null +++ b/Task/Gamma-function/PicoLisp/gamma-function.l @@ -0,0 +1,20 @@ +(scl 28) + +(de *A + ~(flip + (1.00000000000000000000 0.57721566490153286061 -0.65587807152025388108 + -0.04200263503409523553 0.16653861138229148950 -0.04219773455554433675 + -0.00962197152787697356 0.00721894324666309954 -0.00116516759185906511 + -0.00021524167411495097 0.00012805028238811619 -0.00002013485478078824 + -0.00000125049348214267 0.00000113302723198170 -0.00000020563384169776 + 0.00000000611609510448 0.00000000500200764447 -0.00000000118127457049 + 0.00000000010434267117 0.00000000000778226344 -0.00000000000369680562 + 0.00000000000051003703 -0.00000000000002058326 -0.00000000000000534812 + 0.00000000000000122678 -0.00000000000000011813 0.00000000000000000119 + 0.00000000000000000141 -0.00000000000000000023 0.00000000000000000002 ) ) ) + +(de gamma (X) + (let (Y (- X 1.0) Sum (car *A)) + (for A (cdr *A) + (setq Sum (+ A (*/ Sum Y 1.0))) ) + (*/ 1.0 1.0 Sum) ) ) diff --git a/Task/Gamma-function/Python/gamma-function.py b/Task/Gamma-function/Python/gamma-function.py new file mode 100644 index 0000000000..514313015e --- /dev/null +++ b/Task/Gamma-function/Python/gamma-function.py @@ -0,0 +1,22 @@ +_a = ( 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108, + -0.04200263503409523553, 0.16653861138229148950, -0.04219773455554433675, + -0.00962197152787697356, 0.00721894324666309954, -0.00116516759185906511, + -0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824, + -0.00000125049348214267, 0.00000113302723198170, -0.00000020563384169776, + 0.00000000611609510448, 0.00000000500200764447, -0.00000000118127457049, + 0.00000000010434267117, 0.00000000000778226344, -0.00000000000369680562, + 0.00000000000051003703, -0.00000000000002058326, -0.00000000000000534812, + 0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119, + 0.00000000000000000141, -0.00000000000000000023, 0.00000000000000000002 + ) +def gamma (x): + y = float(x) - 1.0; + sm = _a[-1]; + for an in _a[-2::-1]: + sm = sm * y + an; + return 1.0 / sm; + + +if __name__ == '__main__': + for i in range(1,11): + print " %20.14e" % gamma(i/3.0) diff --git a/Task/Gamma-function/R/gamma-function.r b/Task/Gamma-function/R/gamma-function.r new file mode 100644 index 0000000000..b7002b6c90 --- /dev/null +++ b/Task/Gamma-function/R/gamma-function.r @@ -0,0 +1,50 @@ +stirling <- function(z) sqrt(2*pi/z) * (exp(-1)*z)^z + +nemes <- function(z) sqrt(2*pi/z) * (exp(-1)*(z + (12*z - (10*z)^-1)^-1))^z + +lanczos <- function(z) +{ + if(length(z) > 1) + { + sapply(z, lanczos) + } else + { + g <- 7 + p <- c(0.99999999999980993, 676.5203681218851, -1259.1392167224028, + 771.32342877765313, -176.61502916214059, 12.507343278686905, + -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7) + z <- as.complex(z) + if(Re(z) < 0.5) + { + pi / (sin(pi*z) * lanczos(1-z)) + } else + { + z <- z - 1 + x <- p[1] + sum(p[-1]/seq.int(z+1, z+g+1)) + tt <- z + g + 0.5 + sqrt(2*pi) * tt^(z+0.5) * exp(-tt) * x + } + } +} + +spouge <- function(z, a=49) +{ + if(length(z) > 1) + { + sapply(z, spouge) + } else + { + z <- z-1 + k <- seq.int(1, a-1) + ck <- rep(c(1, -1), len=a-1) / factorial(k-1) * (a-k)^(k-0.5) * exp(a-k) + (z + a)^(z+0.5) * exp(-z - a) * (sqrt(2*pi) + sum(ck/(z+k))) + } +} + +# Checks +z <- (1:10)/3 +all.equal(gamma(z), stirling(z)) # Mean relative difference: 0.07181942 +all.equal(gamma(z), nemes(z)) # Mean relative difference: 0.003460549 +all.equal(as.complex(gamma(z)), lanczos(z)) # TRUE +all.equal(gamma(z), spouge(z)) # TRUE +data.frame(z=z, stirling=stirling(z), nemes=nemes(z), lanczos=lanczos(z), spouge=spouge(z), builtin=gamma(z)) diff --git a/Task/Gamma-function/REXX/gamma-function.rexx b/Task/Gamma-function/REXX/gamma-function.rexx new file mode 100644 index 0000000000..37abdfca58 --- /dev/null +++ b/Task/Gamma-function/REXX/gamma-function.rexx @@ -0,0 +1,70 @@ +/*REXX pgm calculates GAMMA using Taylor series coefficients, ≈80 digits*/ + /*The GAMMA function symbol is the Greek cap letter: Γ */ +numeric digits 82 /*able to use extended precision.*/ +parse arg y . /*allow specification of Γ arg.*/ + /*either show a range or a */ + do j=word(y 1,1) to word(y 9,1) /* single gamma value(s). */ + say 'gamma('j") =" gamma(j) /*compute gamma of J and display.*/ + end /*j*/ +exit /*stick a fork in it, we're done.*/ + +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────────GAMMA subroutine=──────────────────*/ +gamma: procedure; parse arg x; xm=x-1; sum=0 + #.1= 1 /*#.2 is the Euler-Mascheroni constant.*/ + /*coefficients thanks to: Arne Fransén and Staffan Wrigge.*/ + #.2= 0.57721566490153286060651209008240243104215933593992359880576723488486772677766467 + #.3=-0.65587807152025388107701951514539048127976638047858434729236244568387083835372210 + #.4=-0.04200263503409523552900393487542981871139450040110609352206581297618009687597599 + #.5= 0.16653861138229148950170079510210523571778150224717434057046890317899386605647425 + #.6=-0.04219773455554433674820830128918739130165268418982248637691887327545901118558900 + #.7=-0.00962197152787697356211492167234819897536294225211300210513886262731167351446074 + #.8= 0.00721894324666309954239501034044657270990480088023831800109478117362259497415854 + #.9=-0.00116516759185906511211397108401838866680933379538405744340750527562002584816653 +#.10=-0.00021524167411495097281572996305364780647824192337833875035026748908563946371678 +#.11= 0.00012805028238811618615319862632816432339489209969367721490054583804120355204347 +#.12=-0.00002013485478078823865568939142102181838229483329797911526116267090822918618897 +#.13=-0.00000125049348214267065734535947383309224232265562115395981534992315749121245561 +#.14= 0.00000113302723198169588237412962033074494332400483862107565429550539546040842730 +#.15=-0.00000020563384169776071034501541300205728365125790262933794534683172533245680371 +#.16= 0.00000000611609510448141581786249868285534286727586571971232086732402927723507435 +#.17= 0.00000000500200764446922293005566504805999130304461274249448171895337887737472132 +#.18=-0.00000000118127457048702014458812656543650557773875950493258759096189263169643391 +#.19= 0.00000000010434267116911005104915403323122501914007098231258121210871073927347588 +#.20= 0.00000000000778226343990507125404993731136077722606808618139293881943550732692987 +#.21=-0.00000000000369680561864220570818781587808576623657096345136099513648454655443000 +#.22= 0.00000000000051003702874544759790154813228632318027268860697076321173501048565735 +#.23=-0.00000000000002058326053566506783222429544855237419746091080810147188058196444349 +#.24=-0.00000000000000534812253942301798237001731872793994898971547812068211168095493211 +#.25= 0.00000000000000122677862823826079015889384662242242816545575045632136601135999606 +#.26=-0.00000000000000011812593016974587695137645868422978312115572918048478798375081233 +#.27= 0.00000000000000000118669225475160033257977724292867407108849407966482711074006109 +#.28= 0.00000000000000000141238065531803178155580394756670903708635075033452562564122263 +#.29=-0.00000000000000000022987456844353702065924785806336992602845059314190367014889830 +#.30= 0.00000000000000000001714406321927337433383963370267257066812656062517433174649858 +#.31= 0.00000000000000000000013373517304936931148647813951222680228750594717618947898583 +#.32=-0.00000000000000000000020542335517666727893250253513557337960820379352387364127301 +#.33= 0.00000000000000000000002736030048607999844831509904330982014865311695836363370165 +#.34=-0.00000000000000000000000173235644591051663905742845156477979906974910879499841377 +#.35=-0.00000000000000000000000002360619024499287287343450735427531007926413552145370486 +#.36= 0.00000000000000000000000001864982941717294430718413161878666898945868429073668232 +#.37=-0.00000000000000000000000000221809562420719720439971691362686037973177950067567580 +#.38= 0.00000000000000000000000000012977819749479936688244144863305941656194998646391332 +#.39= 0.00000000000000000000000000000118069747496652840622274541550997151855968463784158 +#.40=-0.00000000000000000000000000000112458434927708809029365467426143951211941179558301 +#.41= 0.00000000000000000000000000000012770851751408662039902066777511246477487720656005 +#.42=-0.00000000000000000000000000000000739145116961514082346128933010855282371056899245 +#.43= 0.00000000000000000000000000000000001134750257554215760954165259469306393008612196 +#.44= 0.00000000000000000000000000000000004639134641058722029944804907952228463057968680 +#.45=-0.00000000000000000000000000000000000534733681843919887507741819670989332090488591 +#.46= 0.00000000000000000000000000000000000032079959236133526228612372790827943910901464 +#.47=-0.00000000000000000000000000000000000000444582973655075688210159035212464363740144 +#.48=-0.00000000000000000000000000000000000000131117451888198871290105849438992219023663 +#.49= 0.00000000000000000000000000000000000000016470333525438138868182593279063941453996 +#.50=-0.00000000000000000000000000000000000000001056233178503581218600561071538285049997 +#.51= 0.00000000000000000000000000000000000000000026784429826430494783549630718908519485 +#.52= 0.00000000000000000000000000000000000000000002424715494851782689673032938370921241 + do j=52 by -1 to 1 + sum = sum * xm + #.j + end /*j*/ +return 1/sum diff --git a/Task/Gamma-function/Ruby/gamma-function.rb b/Task/Gamma-function/Ruby/gamma-function.rb new file mode 100644 index 0000000000..1da44f221e --- /dev/null +++ b/Task/Gamma-function/Ruby/gamma-function.rb @@ -0,0 +1,17 @@ +$a = [ 1.00000_00000_00000_00000, 0.57721_56649_01532_86061, -0.65587_80715_20253_88108, + -0.04200_26350_34095_23553, 0.16653_86113_82291_48950, -0.04219_77345_55544_33675, + -0.00962_19715_27876_97356, 0.00721_89432_46663_09954, -0.00116_51675_91859_06511, + -0.00021_52416_74114_95097, 0.00012_80502_82388_11619, -0.00002_01348_54780_78824, + -0.00000_12504_93482_14267, 0.00000_11330_27231_98170, -0.00000_02056_33841_69776, + 0.00000_00061_16095_10448, 0.00000_00050_02007_64447, -0.00000_00011_81274_57049, + 0.00000_00001_04342_67117, 0.00000_00000_07782_26344, -0.00000_00000_03696_80562, + 0.00000_00000_00510_03703, -0.00000_00000_00020_58326, -0.00000_00000_00005_34812, + 0.00000_00000_00001_22678, -0.00000_00000_00000_11813, 0.00000_00000_00000_00119, + 0.00000_00000_00000_00141, -0.00000_00000_00000_00023, 0.00000_00000_00000_00002 ] + +def gamma(x) + y = Float(x) - 1 + 1.0 / $a.reverse.inject {|sum, an| sum * y + an} +end + +(1..10).each {|i| puts format("%.14e", gamma(i/3.0))} diff --git a/Task/Gamma-function/Scala/gamma-function.scala b/Task/Gamma-function/Scala/gamma-function.scala new file mode 100644 index 0000000000..b5711c0914 --- /dev/null +++ b/Task/Gamma-function/Scala/gamma-function.scala @@ -0,0 +1,26 @@ +import java.util.Locale._ + +object Gamma { + def stGamma(x:Double):Double=math.sqrt(2*math.Pi/x)*math.pow((x/math.E), x) + + def laGamma(x:Double):Double={ + val p=Seq(676.5203681218851, -1259.1392167224028, 771.32342877765313, + -176.61502916214059, 12.507343278686905, -0.13857109526572012, + 9.9843695780195716e-6, 1.5056327351493116e-7) + + if(x < 0.5) { + math.Pi/(math.sin(math.Pi*x)*laGamma(1-x)) + } else { + val x2=x-1 + val t=x2+7+0.5 + val a=p.zipWithIndex.foldLeft(0.99999999999980993)((r,v) => r+v._1/(x2+v._2+1)) + math.sqrt(2*math.Pi)*math.pow(t, x2+0.5)*math.exp(-t)*a + } + } + + def main(args: Array[String]): Unit = { + println("Gamma Stirling Lanczos") + for(x <- 0.1 to 2.0 by 0.1) + println("%.1f -> %.16f %.16f".formatLocal(ENGLISH, x, stGamma(x), laGamma(x))) + } +} diff --git a/Task/Gamma-function/Tcl/gamma-function.tcl b/Task/Gamma-function/Tcl/gamma-function.tcl new file mode 100644 index 0000000000..4aa1a38ec2 --- /dev/null +++ b/Task/Gamma-function/Tcl/gamma-function.tcl @@ -0,0 +1,35 @@ +package require math +package require math::calculus + +# gamma(1) and gamma(1.5) + +set f 1.0 +set f2 [expr {sqrt(acos(-1.))/2.}] + +for {set x 1.0} {$x <= 10.0} {set x [expr {$x + 0.5}]} { + + # method 1 - numerical integration, Romberg's method, special + # case for an improper integral + + set g1 [math::calculus::romberg \ + [list apply {{x t} {expr {$t ** ($x-1) * exp(-$t)}}} $x] \ + 0 1 -relerror 1e-8] + set g2 [math::calculus::romberg_infinity \ + [list apply {{x t} {expr {$t ** ($x-1) * exp(-$t)}}} $x] \ + 1 Inf -relerror 1e-8] + set gamma [expr {[lindex $g1 0] + [lindex $g2 0]}] + + # method 2 - library function + + set libgamma [expr {exp([math::ln_Gamma $x])}] + + # method 3 - special forms for integer and half-integer arguments + + if {$x == entier($x)} { + puts [format {%4.1f %13.6f %13.6f %13.6f} $x $gamma $libgamma $f] + set f [expr $f * $x] + } else { + puts [format {%4.1f %13.6f %13.6f %13.6f} $x $gamma $libgamma $f2] + set f2 [expr $f2 * $x] + } +} diff --git a/Task/Generator-Exponential/0DESCRIPTION b/Task/Generator-Exponential/0DESCRIPTION new file mode 100644 index 0000000000..452b80ac47 --- /dev/null +++ b/Task/Generator-Exponential/0DESCRIPTION @@ -0,0 +1,14 @@ +A generator is an executable entity (like a function or procedure) that contains code that yields a sequence of values, one at a time, so that each time you call the generator, the next value in the sequence is provided. Generators are often built on top of coroutines or objects so that the internal state of the object is handled “naturally”. Generators are often used in situations where a sequence is potentially infinite, and where it is possible to construct the next value of the sequence with only minimal state. + +'''Task description''' + +# Create a function that returns a generation of the m'th powers of the positive integers starting from zero, in order, and without obvious or simple upper limit. (Any upper limit to the generator should not be stated in the source but should be down to factors such as the languages natural integer size limit or computational time/size). +# Use it to create a generator of: +:# Squares. +:# Cubes. +# Create a new generator that filters all cubes from the generator of squares. +# Drop the first 20 values from this last generator of filtered results then show the next 10 values +Note that this task ''requires'' the use of generators in the calculation of the result. + +'''See also''' +* [[wp:Generator (computer_science)|Generator]] diff --git a/Task/Generator-Exponential/ALGOL-68/generator-exponential-1.alg b/Task/Generator-Exponential/ALGOL-68/generator-exponential-1.alg new file mode 100644 index 0000000000..5dbed0ca6c --- /dev/null +++ b/Task/Generator-Exponential/ALGOL-68/generator-exponential-1.alg @@ -0,0 +1,63 @@ +MODE YIELDVALUE = PROC(VALUE)VOID; +MODE GENVALUE = PROC(YIELDVALUE)VOID; + +PROC gen filtered = (GENVALUE gen candidate, gen exclude, YIELDVALUE yield)VOID: ( + VALUE candidate; SEMA have next exclude = LEVEL 0; + VALUE exclude; SEMA get next exclude = LEVEL 0; + BOOL initialise exclude := TRUE; + + PAR ( # run each generator in a different thread # +# Thread 1 # + # FOR VALUE next exclude IN # gen exclude( # ) DO # + ## (VALUE next exclude)VOID: ( + DOWN get next exclude; exclude := next exclude; + IF candidate <= exclude THEN + UP have next exclude + ELSE + UP get next exclude + FI + # OD #)), +# Thread 2 # + # FOR VALUE next candidate IN # gen candidate( # ) DO # + ## (VALUE next candidate)VOID: ( + candidate := next candidate; + IF initialise exclude ORF candidate > exclude THEN + UP get next exclude; + DOWN have next exclude; # wait for result # + initialise exclude := FALSE + FI; + IF candidate < exclude THEN + yield(candidate) + FI + # OD #)) + ) +); + +PROC gen slice = (GENVALUE t, VALUE start, stop, YIELDVALUE yield)VOID: ( + INT index := 0; + # FOR VALUE i IN # t( # ) DO # + ## (VALUE i)VOID: ( + IF index >= stop THEN done + ELIF index >= start THEN yield(i) FI; + index +:= 1 + # OD # )); + done: SKIP +); + +PROC get list = (GENVALUE gen)[]VALUE: ( + INT upb := 0; + INT ups := 2; + FLEX [ups]VALUE out; + # FOR VALUE i IN # gen( # ) DO # + ## (VALUE i)VOID:( + upb +:= 1; + IF upb > ups THEN # dynamically grow the array 50% # + [ups +:= ups OVER 2]VALUE append; append[:upb-1] := out; out := append + FI; + out[upb] := i + # OD # )) + out[:upb] +); + +PROC powers = (VALUE m, YIELDVALUE yield)VOID: + FOR n FROM 0 DO yield(n ** m) OD; diff --git a/Task/Generator-Exponential/ALGOL-68/generator-exponential-2.alg b/Task/Generator-Exponential/ALGOL-68/generator-exponential-2.alg new file mode 100644 index 0000000000..29d4f39ea7 --- /dev/null +++ b/Task/Generator-Exponential/ALGOL-68/generator-exponential-2.alg @@ -0,0 +1,9 @@ +#!/usr/local/bin/a68g --script # + +MODE VALUE = INT; +PR READ "Template.Generator.a68" PR + +GENVALUE squares = powers(2,), cubes = powers(3,); +GENVALUE fil = gen filtered(squares, cubes,); + +printf(($g(0)x$, get list(gen slice(fil, 20, 30, )) )) diff --git a/Task/Generator-Exponential/Ada/generator-exponential-1.ada b/Task/Generator-Exponential/Ada/generator-exponential-1.ada new file mode 100644 index 0000000000..dc6f42e439 --- /dev/null +++ b/Task/Generator-Exponential/Ada/generator-exponential-1.ada @@ -0,0 +1,23 @@ +package Generator is + + type Generator is tagged private; + procedure Reset (Gen : in out Generator); + function Get_Next (Gen : access Generator) return Natural; + + type Generator_Function is access function (X : Natural) return Natural; + procedure Set_Generator_Function (Gen : in out Generator; + Func : Generator_Function); + + procedure Skip (Gen : access Generator'Class; Count : Positive := 1); + +private + + function Identity (X : Natural) return Natural; + + type Generator is tagged record + Last_Source : Natural := 0; + Last_Value : Natural := 0; + Gen_Func : Generator_Function := Identity'Access; + end record; + +end Generator; diff --git a/Task/Generator-Exponential/Ada/generator-exponential-2.ada b/Task/Generator-Exponential/Ada/generator-exponential-2.ada new file mode 100644 index 0000000000..61afe4d60f --- /dev/null +++ b/Task/Generator-Exponential/Ada/generator-exponential-2.ada @@ -0,0 +1,19 @@ +package Generator.Filtered is + + type Filtered_Generator is new Generator with private; + procedure Reset (Gen : in out Filtered_Generator); + function Get_Next (Gen : access Filtered_Generator) return Natural; + + procedure Set_Source (Gen : in out Filtered_Generator; + Source : access Generator); + procedure Set_Filter (Gen : in out Filtered_Generator; + Filter : access Generator); + +private + + type Filtered_Generator is new Generator with record + Last_Filter : Natural := 0; + Source, Filter : access Generator; + end record; + +end Generator.Filtered; diff --git a/Task/Generator-Exponential/Ada/generator-exponential-3.ada b/Task/Generator-Exponential/Ada/generator-exponential-3.ada new file mode 100644 index 0000000000..40576c38eb --- /dev/null +++ b/Task/Generator-Exponential/Ada/generator-exponential-3.ada @@ -0,0 +1,62 @@ +package body Generator is + + -------------- + -- Identity -- + -------------- + + function Identity (X : Natural) return Natural is + begin + return X; + end Identity; + + ---------- + -- Skip -- + ---------- + + procedure Skip (Gen : access Generator'Class; Count : Positive := 1) is + Val : Natural; + pragma Unreferenced (Val); + begin + for I in 1 .. Count loop + Val := Gen.Get_Next; + end loop; + end Skip; + + ----------- + -- Reset -- + ----------- + + procedure Reset (Gen : in out Generator) is + begin + Gen.Last_Source := 0; + Gen.Last_Value := 0; + end Reset; + + -------------- + -- Get_Next -- + -------------- + + function Get_Next (Gen : access Generator) return Natural is + begin + Gen.Last_Source := Gen.Last_Source + 1; + Gen.Last_Value := Gen.Gen_Func (Gen.Last_Source); + return Gen.Last_Value; + end Get_Next; + + ---------------------------- + -- Set_Generator_Function -- + ---------------------------- + + procedure Set_Generator_Function + (Gen : in out Generator; + Func : Generator_Function) + is + begin + if Func = null then + Gen.Gen_Func := Identity'Access; + else + Gen.Gen_Func := Func; + end if; + end Set_Generator_Function; + +end Generator; diff --git a/Task/Generator-Exponential/Ada/generator-exponential-4.ada b/Task/Generator-Exponential/Ada/generator-exponential-4.ada new file mode 100644 index 0000000000..07b1dcaa7b --- /dev/null +++ b/Task/Generator-Exponential/Ada/generator-exponential-4.ada @@ -0,0 +1,59 @@ +package body Generator.Filtered is + + ----------- + -- Reset -- + ----------- + + procedure Reset (Gen : in out Filtered_Generator) is + begin + Reset (Generator (Gen)); + Gen.Source.Reset; + Gen.Filter.Reset; + Gen.Last_Filter := 0; + end Reset; + + -------------- + -- Get_Next -- + -------------- + + function Get_Next (Gen : access Filtered_Generator) return Natural is + Next_Source : Natural := Gen.Source.Get_Next; + Next_Filter : Natural := Gen.Last_Filter; + begin + loop + if Next_Source > Next_Filter then + Gen.Last_Filter := Gen.Filter.Get_Next; + Next_Filter := Gen.Last_Filter; + elsif Next_Source = Next_Filter then + Next_Source := Gen.Source.Get_Next; + else + return Next_Source; + end if; + end loop; + end Get_Next; + + ---------------- + -- Set_Source -- + ---------------- + + procedure Set_Source + (Gen : in out Filtered_Generator; + Source : access Generator) + is + begin + Gen.Source := Source; + end Set_Source; + + ---------------- + -- Set_Filter -- + ---------------- + + procedure Set_Filter + (Gen : in out Filtered_Generator; + Filter : access Generator) + is + begin + Gen.Filter := Filter; + end Set_Filter; + +end Generator.Filtered; diff --git a/Task/Generator-Exponential/Ada/generator-exponential-5.ada b/Task/Generator-Exponential/Ada/generator-exponential-5.ada new file mode 100644 index 0000000000..b09de0d1ba --- /dev/null +++ b/Task/Generator-Exponential/Ada/generator-exponential-5.ada @@ -0,0 +1,35 @@ +with Ada.Text_IO; +with Generator.Filtered; + +procedure Generator_Test is + + function Square (X : Natural) return Natural is + begin + return X * X; + end Square; + + function Cube (X : Natural) return Natural is + begin + return X * X * X; + end Cube; + + G1, G2 : aliased Generator.Generator; + F : aliased Generator.Filtered.Filtered_Generator; + +begin + + G1.Set_Generator_Function (Func => Square'Unrestricted_Access); + G2.Set_Generator_Function (Func => Cube'Unrestricted_Access); + + F.Set_Source (G1'Unrestricted_Access); + F.Set_Filter (G2'Unrestricted_Access); + + F.Skip (20); + + for I in 1 .. 10 loop + Ada.Text_IO.Put ("I:" & Integer'Image (I)); + Ada.Text_IO.Put (", F:" & Integer'Image (F.Get_Next)); + Ada.Text_IO.New_Line; + end loop; + +end Generator_Test; diff --git a/Task/Generator-Exponential/C++/generator-exponential.cpp b/Task/Generator-Exponential/C++/generator-exponential.cpp new file mode 100644 index 0000000000..0947a2fe9a --- /dev/null +++ b/Task/Generator-Exponential/C++/generator-exponential.cpp @@ -0,0 +1,66 @@ +#include +using namespace std; + +template +class Generator +{ +public: + virtual T operator()() = 0; +}; + +// Does nothing unspecialized +template +class PowersGenerator: Generator {}; + +// Specialize with other types, or provide a generic version of pow +template +class PowersGenerator: Generator +{ +public: + int i; + PowersGenerator() { i = 1; } + virtual int operator()() + { + int o = 1; + for(int j = 0; j < P; ++j) o *= i; + ++i; + return o; + } +}; + +// Only works with non-decreasing generators +template +class Filter: Generator +{ +public: + G gen; + F filter; + T lastG, lastF; + + Filter() { lastG = gen(); lastF = filter(); } + + virtual T operator()() + { + while(lastG >= lastF) + { + if(lastG == lastF) + lastG = gen(); + lastF = filter(); + } + + T out = lastG; + lastG = gen(); + return out; + } +}; + +int main() +{ + Filter, PowersGenerator> gen; + + for(int i = 0; i < 20; ++i) + gen(); + + for(int i = 20; i < 30; ++i) + cout << i << ": " << gen() << endl; +} diff --git a/Task/Generator-Exponential/C-sharp/generator-exponential-1.cs b/Task/Generator-Exponential/C-sharp/generator-exponential-1.cs new file mode 100644 index 0000000000..2fdae5326c --- /dev/null +++ b/Task/Generator-Exponential/C-sharp/generator-exponential-1.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace RosettaGenerator +{ + class ClosureStyle + { + static void Main(string[] args) + { + Func squaresGenerator = PowerGeneratorAsClosure(2); + Func cubesGenerator = PowerGeneratorAsClosure(3); + + Func filter = FilterAsClosure(squaresGenerator, cubesGenerator); + + foreach (int i in Enumerable.Range(0, 20)) + filter(); + foreach (int i in Enumerable.Range(21, 10)) + Console.Write(filter() + " "); + Console.WriteLine(); + } + + public static Func PowerGeneratorAsClosure(int exponent) + { + int x = 0; + return () => { return (int)Math.Pow(x++, exponent); }; + } + + public static Func FilterAsClosure(Func squaresGenerator, Func cubesGenerator) + { + int squareValue; + int cubeValue = cubesGenerator(); + return () => + { + while (true) + { + squareValue = squaresGenerator(); + while (squareValue > cubeValue) + cubeValue = cubesGenerator(); + if (squareValue < cubeValue) + return squareValue; + } + }; + } + } +} diff --git a/Task/Generator-Exponential/C-sharp/generator-exponential-2.cs b/Task/Generator-Exponential/C-sharp/generator-exponential-2.cs new file mode 100644 index 0000000000..00330b3ccd --- /dev/null +++ b/Task/Generator-Exponential/C-sharp/generator-exponential-2.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace RosettaGenerator +{ + class ListStyle + { + static void Main(string[] args) + { + IEnumerator squaresGenerator = PowerGeneratorAsList(2); + IEnumerator cubesGenerator = PowerGeneratorAsList(3); + + IEnumerable filter = FilterAsList(squaresGenerator, cubesGenerator); + + foreach (int value in filter.Skip(20).Take(10)) + Console.Write(value + " "); + Console.WriteLine(); + } + + public static IEnumerator PowerGeneratorAsList(int exponent) + { + int x = 0; + while (true) + yield return (int)Math.Pow(x++, exponent); + } + + public static IEnumerable FilterAsList(IEnumerator squaresGenerator, IEnumerator cubesGenerator) + { + int squareValue; + int cubeValue = cubesGenerator.Current; + while (true) + { + squareValue = squaresGenerator.Current; + while (squareValue > cubeValue) + { + cubesGenerator.MoveNext(); + cubeValue = cubesGenerator.Current; + } + if (squareValue < cubeValue) + yield return squareValue; + squaresGenerator.MoveNext(); + } + } + } +} diff --git a/Task/Generator-Exponential/C/generator-exponential-1.c b/Task/Generator-Exponential/C/generator-exponential-1.c new file mode 100644 index 0000000000..82fc4c6333 --- /dev/null +++ b/Task/Generator-Exponential/C/generator-exponential-1.c @@ -0,0 +1,162 @@ +#include /* int64_t, PRId64 */ +#include /* exit() */ +#include /* printf() */ + +#include /* co_{active,create,delete,switch}() */ + + + +/* A generator that yields values of type int64_t. */ +struct gen64 { + cothread_t giver; /* this cothread calls yield64() */ + cothread_t taker; /* this cothread calls next64() */ + int64_t given; + void (*free)(struct gen64 *); + void *garbage; +}; + +/* Yields a value. */ +inline void +yield64(struct gen64 *gen, int64_t value) +{ + gen->given = value; + co_switch(gen->taker); +} + +/* Returns the next value that the generator yields. */ +inline int64_t +next64(struct gen64 *gen) +{ + gen->taker = co_active(); + co_switch(gen->giver); + return gen->given; +} + +static void +gen64_free(struct gen64 *gen) +{ + co_delete(gen->giver); +} + +struct gen64 *entry64; + +/* + * Creates a cothread for the generator. The first call to next64(gen) + * will enter the cothread; the entry function must copy the pointer + * from the global variable struct gen64 *entry64. + * + * Use gen->free(gen) to free the cothread. + */ +inline void +gen64_init(struct gen64 *gen, void (*entry)(void)) +{ + if ((gen->giver = co_create(4096, entry)) == NULL) { + /* Perhaps malloc() failed */ + fputs("co_create: Cannot create cothread\n", stderr); + exit(1); + } + gen->free = gen64_free; + entry64 = gen; +} + + + +/* + * Generates the powers 0**m, 1**m, 2**m, .... + */ +void +powers(struct gen64 *gen, int64_t m) +{ + int64_t base, exponent, n, result; + + for (n = 0;; n++) { + /* + * This computes result = base**exponent, where + * exponent is a nonnegative integer. The result + * is the product of repeated squares of base. + */ + base = n; + exponent = m; + for (result = 1; exponent != 0; exponent >>= 1) { + if (exponent & 1) result *= base; + base *= base; + } + yield64(gen, result); + } + /* NOTREACHED */ +} + +/* stuff for squares_without_cubes() */ +#define ENTRY(name, code) static void name(void) { code; } +ENTRY(enter_squares, powers(entry64, 2)) +ENTRY(enter_cubes, powers(entry64, 3)) + +struct swc { + struct gen64 cubes; + struct gen64 squares; + void (*old_free)(struct gen64 *); +}; + +static void +swc_free(struct gen64 *gen) +{ + struct swc *f = gen->garbage; + f->cubes.free(&f->cubes); + f->squares.free(&f->squares); + f->old_free(gen); +} + +/* + * Generates the squares 0**2, 1**2, 2**2, ..., but removes the squares + * that equal the cubes 0**3, 1**3, 2**3, .... + */ +void +squares_without_cubes(struct gen64 *gen) +{ + struct swc f; + int64_t c, s; + + gen64_init(&f.cubes, enter_cubes); + c = next64(&f.cubes); + + gen64_init(&f.squares, enter_squares); + s = next64(&f.squares); + + /* Allow other cothread to free this generator. */ + f.old_free = gen->free; + gen->garbage = &f; + gen->free = swc_free; + + for (;;) { + while (c < s) + c = next64(&f.cubes); + if (c != s) + yield64(gen, s); + s = next64(&f.squares); + } + /* NOTREACHED */ +} + +ENTRY(enter_squares_without_cubes, squares_without_cubes(entry64)) + +/* + * Look at the sequence of numbers that are squares but not cubes. + * Drop the first 20 numbers, then print the next 10 numbers. + */ +int +main() +{ + struct gen64 gen; + int i; + + gen64_init(&gen, enter_squares_without_cubes); + + for (i = 0; i < 20; i++) + next64(&gen); + for (i = 0; i < 9; i++) + printf("%" PRId64 ", ", next64(&gen)); + printf("%" PRId64 "\n", next64(&gen)); + + gen.free(&gen); /* Free memory. */ + return 0; +} diff --git a/Task/Generator-Exponential/C/generator-exponential-2.c b/Task/Generator-Exponential/C/generator-exponential-2.c new file mode 100644 index 0000000000..a3ef638ea7 --- /dev/null +++ b/Task/Generator-Exponential/C/generator-exponential-2.c @@ -0,0 +1,74 @@ +#include +#include +#include + +typedef int (*seq_func)(void *); +#define SEQ_BASE seq_func f; int output + +/* sort of polymorphing data structure */ +typedef struct { SEQ_BASE; } gen_t; + +int seq_next(void *state) +{ + return ((gen_t*)state)->output = (*(seq_func*)state)(state); +} + +typedef struct { + SEQ_BASE; + int pos, n; +} power_gen_t; + +int power_next(void *s) +{ + return (int)pow(++((power_gen_t*)s)->pos, ((power_gen_t*)s)->n); +} + +void *power_seq(int n) +{ + power_gen_t *s = malloc(sizeof(power_gen_t)); + s->output = -1; + s->f = power_next; + s->n = n; + s->pos = -1; + return s; +} + +typedef struct { + SEQ_BASE; + void *in, *without; +} filter_gen_t; + +int filter_next(void *s) +{ + gen_t *in = ((filter_gen_t*)s)->in, *wo = ((filter_gen_t*)s)->without; + + do{ + seq_next(in); + while (wo->output < in->output) + seq_next(wo); + } while(wo->output == in->output); + + return in->output; +} + +void* filter_seq(gen_t *in, gen_t *without) +{ + filter_gen_t *filt = malloc(sizeof(filter_gen_t)); + filt->in = in; + filt->without = without; + filt->f = filter_next; + filt->output = -1; + return filt; +} + +int main() +{ + int i; + void *s = filter_seq(power_seq(2), power_seq(3)); + + for (i = 0; i < 20; i++) seq_next(s); + for (i = 0; i < 10; i++) + printf("%d\n", seq_next(s)); + + return 0; +} diff --git a/Task/Generator-Exponential/C/generator-exponential-3.c b/Task/Generator-Exponential/C/generator-exponential-3.c new file mode 100644 index 0000000000..91e1234705 --- /dev/null +++ b/Task/Generator-Exponential/C/generator-exponential-3.c @@ -0,0 +1,10 @@ +529 +576 +625 +676 +784 +841 +900 +961 +1024 +1089 diff --git a/Task/Generator-Exponential/Common-Lisp/generator-exponential.lisp b/Task/Generator-Exponential/Common-Lisp/generator-exponential.lisp new file mode 100644 index 0000000000..eccd6642cf --- /dev/null +++ b/Task/Generator-Exponential/Common-Lisp/generator-exponential.lisp @@ -0,0 +1,21 @@ +(defun take (seq &optional (n 1)) + (values-list (loop repeat n collect (funcall seq)))) + +(defun power-seq (n) + (let ((x 0)) + (lambda () (expt (incf x) n)))) + +(defun filter-seq (s1 s2) ;; remove s2 from s1 + (let ((x1 (take s1)) (x2 (take s2))) + (lambda () + (tagbody g + (if (= x1 x2) + (progn (setf x1 (take s1) x2 (take s2)) (go g))) + (if (> x1 x2) + (progn (setf x2 (take s2)) (go g)))) + + (prog1 x1 (setf x1 (take s1)))))) + +(let ((2not3 (filter-seq (power-seq 2) (power-seq 3)))) + (take 2not3 20) ;; drop 20 + (princ (multiple-value-list (take 2not3 10)))) diff --git a/Task/Generator-Exponential/D/generator-exponential-1.d b/Task/Generator-Exponential/D/generator-exponential-1.d new file mode 100644 index 0000000000..16e4cf2e97 --- /dev/null +++ b/Task/Generator-Exponential/D/generator-exponential-1.d @@ -0,0 +1,61 @@ +import std.stdio, std.bigint, std.range, std.algorithm; + +struct Filtered(R1, R2) if (is(ElementType!R1 == ElementType!R2)) { + R1 s1; + R2 s2; + alias ElementType!R1 T; + T current, source, filter; + + this(R1 r1, R2 r2) { + s1 = r1; + s2 = r2; + source = s1.front(); + filter = s2.front(); + _next(); + } + + const bool empty = false; + @property T front() { return current; } + void popFront() { _next(); } + + private void _next() { + while (true) { + if (source > filter) { + s2.popFront(); + filter = s2.front(); + continue; + } else if (source < filter) { + current = source; + s1.popFront(); + source = s1.front(); + break; + } + s1.popFront(); + source = s1.front(); + } + } +} + +auto filtered(R1, R2)(R1 r1, R2 r2) +if (is(ElementType!R1 == ElementType!R2)) { + return Filtered!(R1, R2)(r1, r2); +} + +struct Count(T) { + T n; + const bool empty = false; + @property T front() { return n; } + void popFront() { /* n++; */ n += 1; } +} + +Count!T count(T)(T start) { return Count!T(start); } +Count!T count(T)() { return Count!T(cast(T)0); } + +void main() { + auto squares = count!BigInt().map!q{a ^^ 2}(); + auto cubes = count!BigInt().map!q{a ^^ 3}(); + auto f = filtered(squares, cubes); + + popFrontN(f, 20); + writeln(take(f, 10)); +} diff --git a/Task/Generator-Exponential/D/generator-exponential-2.d b/Task/Generator-Exponential/D/generator-exponential-2.d new file mode 100644 index 0000000000..e968e8e2d8 --- /dev/null +++ b/Task/Generator-Exponential/D/generator-exponential-2.d @@ -0,0 +1,33 @@ +import std.stdio, std.traits; + +auto powers(in double e) pure nothrow { + double i = 0.0; + return () => i++ ^^ e; +} + +auto filter(D)(D af, D bf) if (isCallable!D) { + double a = af(), b = bf(); + return { + double r; + while (true) { + if (a < b) { + r = a; + a = af(); + break; + } + if (b == a) + a = af(); + b = bf(); + } + return r; + }; +} + +void main() { + auto fgen = filter(powers(2), powers(3)); + foreach (i; 0 .. 20) + fgen(); + foreach (i; 0 .. 10) + write(fgen(), " "); + writeln(); +} diff --git a/Task/Generator-Exponential/E/generator-exponential.e b/Task/Generator-Exponential/E/generator-exponential.e new file mode 100644 index 0000000000..b843ba08ce --- /dev/null +++ b/Task/Generator-Exponential/E/generator-exponential.e @@ -0,0 +1,35 @@ +def genPowers(exponent) { + var i := -1 + return def powerGenerator() { + return (i += 1) ** exponent + } +} + +def filtered(source, filter) { + var fval := filter() + return def filterGenerator() { + while (true) { + def sval := source() + while (sval > fval) { + fval := filter() + } + if (sval < fval) { + return sval + } + } + } +} + +def drop(n, gen) { + for _ in 1..n { gen() } +} + + +def squares := genPowers(2) +def cubes := genPowers(3) +def squaresNotCubes := filtered(squares, cubes) +drop(20, squaresNotCubes) +for _ in 1..10 { + print(`${squaresNotCubes()} `) +} +println() diff --git a/Task/Generator-Exponential/Fantom/generator-exponential.fantom b/Task/Generator-Exponential/Fantom/generator-exponential.fantom new file mode 100644 index 0000000000..99d2c4a406 --- /dev/null +++ b/Task/Generator-Exponential/Fantom/generator-exponential.fantom @@ -0,0 +1,40 @@ +class Main +{ + // Create and return a function which generates mth powers when called + |->Int| make_generator (Int m) + { + current := 0 + return |->Int| + { + current += 1 + return (current-1).pow (m) + } + } + + |->Int| squares_without_cubes () + { + squares := make_generator (2) + cubes := make_generator (3) + c := cubes.call + return |->Int| + { + while (true) + { + s := squares.call + while (c < s) { c = cubes.call } + if (c != s) return s + } + return 0 + } + } + + Void main () + { + swc := squares_without_cubes () + 20.times { swc.call } // drop 20 values + 10.times // display the next 10 + { + echo (swc.call) + } + } +} diff --git a/Task/Generator-Exponential/Go/generator-exponential-1.go b/Task/Generator-Exponential/Go/generator-exponential-1.go new file mode 100644 index 0000000000..ac37011913 --- /dev/null +++ b/Task/Generator-Exponential/Go/generator-exponential-1.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "math" +) + +// note: exponent not limited to ints +func newPowGen(e float64) func() float64 { + var i float64 + return func() (r float64) { + r = math.Pow(i, e) + i++ + return + } +} + +// given two functions af, bf, both monotonically increasing, return a +// new function that returns values of af not returned by bf. +func newMonoIncA_NotMonoIncB_Gen(af, bf func() float64) func() float64 { + a, b := af(), bf() + return func() (r float64) { + for { + if a < b { + r = a + a = af() + break + } + if b == a { + a = af() + } + b = bf() + } + return + } +} + +func main() { + fGen := newMonoIncA_NotMonoIncB_Gen(newPowGen(2), newPowGen(3)) + for i := 0; i < 20; i++ { + fGen() + } + for i := 0; i < 10; i++ { + fmt.Print(fGen(), " ") + } + fmt.Println() +} diff --git a/Task/Generator-Exponential/Go/generator-exponential-2.go b/Task/Generator-Exponential/Go/generator-exponential-2.go new file mode 100644 index 0000000000..b91c77e18b --- /dev/null +++ b/Task/Generator-Exponential/Go/generator-exponential-2.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "math" +) + +func newPowGen(e float64) chan float64 { + ch := make(chan float64) + go func() { + for i := 0.; ; i++ { + ch <- math.Pow(i, e) + } + }() + return ch +} + +// given two input channels, a and b, both known to return monotonically +// increasing values, supply on channel c values of a not returned by b. +func newMonoIncA_NotMonoIncB_Gen(a, b chan float64) chan float64 { + ch := make(chan float64) + go func() { + for va, vb := <-a, <-b; ; { + switch { + case va < vb: + ch <- va + fallthrough + case va == vb: + va = <-a + default: + vb = <-b + + } + } + }() + return ch +} + +func main() { + ch := newMonoIncA_NotMonoIncB_Gen(newPowGen(2), newPowGen(3)) + for i := 0; i < 20; i++ { + <-ch + } + for i := 0; i < 10; i++ { + fmt.Print(<-ch, " ") + } + fmt.Println() +} diff --git a/Task/Generator-Exponential/Haskell/generator-exponential.hs b/Task/Generator-Exponential/Haskell/generator-exponential.hs new file mode 100644 index 0000000000..e2e9cac720 --- /dev/null +++ b/Task/Generator-Exponential/Haskell/generator-exponential.hs @@ -0,0 +1,12 @@ +powers m = map (^ m) [0..] + +filtered (x:xs) (y:ys) | x > y = filtered (x:xs) ys + | x < y = x : filtered xs (y:ys) + | otherwise = filtered xs (y:ys) + +squares = powers 2 +cubes = powers 3 +f = filtered squares cubes + +main :: IO () +main = print $ take 10 $ drop 20 $ f diff --git a/Task/Generator-Exponential/Icon/generator-exponential.icon b/Task/Generator-Exponential/Icon/generator-exponential.icon new file mode 100644 index 0000000000..02be188afe --- /dev/null +++ b/Task/Generator-Exponential/Icon/generator-exponential.icon @@ -0,0 +1,25 @@ +procedure main() + +write("Non-cube Squares (21st to 30th):") +every (k := 0, s := noncubesquares()) do + if(k +:= 1) > 30 then break + else write(20 < k," : ",s) +end + +procedure mthpower(m) #: generate i^m for i = 0,1,... +while (/i := 0) | (i +:= 1) do suspend i^m +end + +procedure noncubesquares() #: filter for squares that aren't cubes +cu := create mthpower(3) # co-expressions so that we can +sq := create mthpower(2) # ... get our results where we need + +repeat { + if c === s then ( c := @cu , s := @sq ) + else if s > c then c := @cu + else { + suspend s + s := @sq + } + } +end diff --git a/Task/Generator-Exponential/J/generator-exponential-1.j b/Task/Generator-Exponential/J/generator-exponential-1.j new file mode 100644 index 0000000000..498a3b47ef --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-1.j @@ -0,0 +1,10 @@ +coclass 'mthPower' + N=: 0 + create=: 3 :0 + M=: y + ) + next=: 3 :0 + n=. N + N=: N+1 + n^M + ) diff --git a/Task/Generator-Exponential/J/generator-exponential-2.j b/Task/Generator-Exponential/J/generator-exponential-2.j new file mode 100644 index 0000000000..2c7aaa51b8 --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-2.j @@ -0,0 +1,2 @@ +stateySquare=: 2 conew 'mthPower' +stateyCube=: 3 conew 'mthPower' diff --git a/Task/Generator-Exponential/J/generator-exponential-3.j b/Task/Generator-Exponential/J/generator-exponential-3.j new file mode 100644 index 0000000000..30ac7103ae --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-3.j @@ -0,0 +1,6 @@ +coclass 'uncubicalSquares' + N=: 0 + next=: 3 :0"0 + while. (-: <.) 3 %: *: n=. N do. N=: N+1 end. N=: N+1 + *: n + ) diff --git a/Task/Generator-Exponential/J/generator-exponential-4.j b/Task/Generator-Exponential/J/generator-exponential-4.j new file mode 100644 index 0000000000..1a191cabbb --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-4.j @@ -0,0 +1,2 @@ + next__g i.10 [ next__g i.20 [ g=: conew 'uncubicalSquares' +529 576 625 676 784 841 900 961 1024 1089 diff --git a/Task/Generator-Exponential/J/generator-exponential-5.j b/Task/Generator-Exponential/J/generator-exponential-5.j new file mode 100644 index 0000000000..fde3a0adee --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-5.j @@ -0,0 +1,4 @@ +mthPower=: 1 :'^&m@i.' +squares=: 2 mthPower +cubes=: 3 mthPower +uncubicalSquares=: squares -. cubes diff --git a/Task/Generator-Exponential/J/generator-exponential-6.j b/Task/Generator-Exponential/J/generator-exponential-6.j new file mode 100644 index 0000000000..009c321a00 --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-6.j @@ -0,0 +1 @@ +uncubicalSquares=: {. squares@<.@p.~&3 1.1 -. cubes diff --git a/Task/Generator-Exponential/J/generator-exponential-7.j b/Task/Generator-Exponential/J/generator-exponential-7.j new file mode 100644 index 0000000000..c082560560 --- /dev/null +++ b/Task/Generator-Exponential/J/generator-exponential-7.j @@ -0,0 +1,2 @@ +20 }. uncubicalSquares 30 NB. the 21st through 30th uncubical square +529 576 625 676 784 841 900 961 1024 1089 diff --git a/Task/Generator-Exponential/JavaScript/generator-exponential.js b/Task/Generator-Exponential/JavaScript/generator-exponential.js new file mode 100644 index 0000000000..99962e28ef --- /dev/null +++ b/Task/Generator-Exponential/JavaScript/generator-exponential.js @@ -0,0 +1,36 @@ +function PowersGenerator(m) { + var n=0; + while(1) { + yield Math.pow(n, m); + n += 1; + } +} + +function FilteredGenerator(g, f){ + var value = g.next(); + var filter = f.next(); + + while(1) { + if( value < filter ) { + yield value; + value = g.next(); + } else if ( value > filter ) { + filter = f.next(); + } else { + value = g.next(); + filter = f.next(); + } + } +} + + + +var squares = PowersGenerator(2); +var cubes = PowersGenerator(3); + +var filtered = FilteredGenerator(squares, cubes); + + + +for( var x = 0; x < 20; x++ ) filtered.next() +for( var x = 20; x < 30; x++ ) console.logfiltered.next()); diff --git a/Task/Generator-Exponential/Lua/generator-exponential.lua b/Task/Generator-Exponential/Lua/generator-exponential.lua new file mode 100644 index 0000000000..effb7f0815 --- /dev/null +++ b/Task/Generator-Exponential/Lua/generator-exponential.lua @@ -0,0 +1,38 @@ +--could be done with a coroutine, but a simple closure works just as well. +local function powgen(m) + local count = 0 + return function() + count = count + 1 + return count^m + end +end + +local squares = powgen(2) +local cubes = powgen(3) + +local cowrap,coyield = coroutine.wrap, coroutine.yield + +local function filter(f,g) + return cowrap(function() + local ff,gg = f(), g() + while true do + if ff == gg then + ff,gg = f(), g() + elseif ff < gg then + coyield(ff) + ff = f() + else + gg = g() + end + end + end) +end + +filter = filter(squares,cubes) + +for i = 1,30 do + local result = filter() + if i > 20 then + print(result) + end +end diff --git a/Task/Generator-Exponential/Perl/generator-exponential.pl b/Task/Generator-Exponential/Perl/generator-exponential.pl new file mode 100644 index 0000000000..dd3a724bba --- /dev/null +++ b/Task/Generator-Exponential/Perl/generator-exponential.pl @@ -0,0 +1,37 @@ +# gen_pow($m) creates and returns an anonymous subroutine that will +# generate and return the powers 0**m, 1**m, 2**m, ... +sub gen_pow { + my $m = shift; + my $e = 0; + return sub { return $e++ ** $m; }; +} + +# gen_filter($g1, $g2) generates everything returned from $g1 that +# is not also returned from $g2. Both $g1 and $g2 must be references +# to subroutines that generate numbers in increasing order. gen_filter +# creates and returns an anonymous subroutine. +sub gen_filter { + my($g1, $g2) = @_; + my $v1; + my $v2 = $g2->(); + return sub { + for (;;) { + $v1 = $g1->(); + $v2 = $g2->() while $v1 > $v2; + return $v1 unless $v1 == $v2; + } + }; +} + +# Create generators. +my $squares = gen_pow(2); +my $cubes = gen_pow(3); +my $squares_without_cubes = gen_filter($squares, $cubes); + +# Drop 20 values. +$squares_without_cubes->() for (1..20); + +# Print 10 values. +my @answer; +push @answer, $squares_without_cubes->() for (1..10); +print "[", join(", ", @answer), "]\n"; diff --git a/Task/Generator-Exponential/PicoLisp/generator-exponential.l b/Task/Generator-Exponential/PicoLisp/generator-exponential.l new file mode 100644 index 0000000000..dc8fef0a40 --- /dev/null +++ b/Task/Generator-Exponential/PicoLisp/generator-exponential.l @@ -0,0 +1,16 @@ +(de powers (M) + (co (intern (pack 'powers M)) + (for (I 0 (inc 'I)) + (yield (** I M)) ) ) ) + +(de filtered (N M) + (co 'filtered + (let (V (powers N) F (powers M)) + (loop + (if (> V F) + (setq F (powers M)) + (and (> F V) (yield V)) + (setq V (powers N)) ) ) ) ) ) + +(do 20 (filtered 2 3)) +(do 10 (println (filtered 2 3))) diff --git a/Task/Generator-Exponential/Python/generator-exponential.py b/Task/Generator-Exponential/Python/generator-exponential.py new file mode 100644 index 0000000000..e8b1b2df1f --- /dev/null +++ b/Task/Generator-Exponential/Python/generator-exponential.py @@ -0,0 +1,19 @@ +from itertools import islice, count + +def powers(m): + for n in count(): + yield n ** m + +def filtered(s1, s2): + v, f = next(s1), next(s2) + while True: + if v > f: + f = next(s2) + continue + elif v < f: + yield v + v = next(s1) + +squares, cubes = powers(2), powers(3) +f = filtered(squares, cubes) +print(list(islice(f, 20, 30))) diff --git a/Task/Generator-Exponential/REXX/generator-exponential.rexx b/Task/Generator-Exponential/REXX/generator-exponential.rexx new file mode 100644 index 0000000000..6c5e4c8a8e --- /dev/null +++ b/Task/Generator-Exponential/REXX/generator-exponential.rexx @@ -0,0 +1,47 @@ +/*REXX program to show how to use a generator (also known as iterators).*/ +numeric digits 10000 /*just in case we need big 'uns. */ +parse arg show; show = word(show 0, 1) /*show this many.*/ +@gen.= /*generators start from scratch. */ + do j=1 to show; call tell 'squares' ,gen_squares(j) ; end + do j=1 to show; call tell 'cubes' ,gen_cubes(j) ; end + do j=1 to show; call tell 'sq¬cubes',gen_sqNcubes(j) ; end + if show>0 then say 'dropping 1st ──► 20th values.' + do j=1 to 20; drop @gen.sqNcubes.j ; end + do j=20+1 for 10 ; call tell 'sq¬cubes',gen_sqNcubes(j) ; end +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────gen_powers iterator──────────────*/ +gen_powers: procedure expose @gen.; parse arg x,p; if x=='' then return +if @gen.powers.x.p=='' then @gen.powers.x.p=x**p; return @gen.powers.x.p +/*─────────────────────────────────────gen_squares iterator─────────────*/ +gen_squares: procedure expose @gen.; parse arg x; if x=='' then return +if @gen.squares.x=='' then do; call gen_powers x,2 + @gen.squares.x=@gen.powers.x.2 + end +return @gen.squares.x +/*─────────────────────────────────────gen_cubes iterator───────────────*/ +gen_cubes: procedure expose @gen.; parse arg x; if x=='' then return +if @gen.cubes.j=='' then do; call gen_powers x,3 + @gen.cubes.x=@gen.powers.x.3 + end +return @gen.cubes.x +/*─────────────────────────────────────gen_squares not cubes iterator───*/ +gen_sqNcubes: procedure expose @gen.; parse arg x; if x=='' then return +s=0 +if @gen.sqNcubes.x=='' then do j=1 to x + if @gen.sqNcubes\=='' then do; sq=sq+1 + iterate + end + do s=s+1 /*slow way to weed out cubes*/ + ?=gen_squares(s) + do c=1 until gen_cubes(c)>? + if gen_cubes(c)==? then iterate s + end /*c*/ + leave + end /*s*/ + @gen.sqNcubes.x=? + @gen.sqNcubes.x=@gen.squares.s + end /*j*/ +return @gen.sqNcubes.x +/*──────────────────────────────────TELL subroutine─────────────────────*/ +tell: if j==1 then say /* [↓] format args to be aligned.*/ + say right(arg(1),20) right(j,5) right(arg(2),20); return diff --git a/Task/Generator-Exponential/Racket/generator-exponential.rkt b/Task/Generator-Exponential/Racket/generator-exponential.rkt new file mode 100644 index 0000000000..3d96d37e5c --- /dev/null +++ b/Task/Generator-Exponential/Racket/generator-exponential.rkt @@ -0,0 +1,23 @@ +#lang racket + +(require racket/generator) + +;; this is a function that returns a powers generator, not a generator +(define (powers m) + (generator () + (for ([n (in-naturals)]) (yield (expt n m))))) + +(define squares (powers 2)) +(define cubes (powers 3)) + +;; same here +(define (filtered g1 g2) + (generator () + (let loop ([n1 (g1)] [n2 (g2)]) + (cond [(< n1 n2) (yield n1) (loop (g1) n2)] + [(> n1 n2) (loop n1 (g2))] + [else (loop (g1) (g2))])))) + +(for/list ([x (in-producer (filtered squares cubes) (lambda (_) #f))] + [i 30] #:when (>= i 20)) + x) diff --git a/Task/Generator-Exponential/Ruby/generator-exponential-1.rb b/Task/Generator-Exponential/Ruby/generator-exponential-1.rb new file mode 100644 index 0000000000..a3782e8176 --- /dev/null +++ b/Task/Generator-Exponential/Ruby/generator-exponential-1.rb @@ -0,0 +1,21 @@ +# This solution cheats and uses only one generator! + +def powers(m) + return enum_for(:powers, m) unless block_given? + + n = 0 + loop { yield n ** m; n += 1 } +end + +def squares_without_cubes + return enum_for(:squares_without_cubes) unless block_given? + + cubes = powers(3) + c = cubes.next + powers(2) do |s| + (c = cubes.next) until c >= s + yield s unless c == s + end +end + +p squares_without_cubes.take(30).drop(20) diff --git a/Task/Generator-Exponential/Ruby/generator-exponential-2.rb b/Task/Generator-Exponential/Ruby/generator-exponential-2.rb new file mode 100644 index 0000000000..0e6c6d01a9 --- /dev/null +++ b/Task/Generator-Exponential/Ruby/generator-exponential-2.rb @@ -0,0 +1,25 @@ +# This solution uses three generators. + +def powers(m) + return enum_for(:powers, m) unless block_given? + + n = 0 + loop { yield n ** m; n += 1 } +end + +def squares_without_cubes + return enum_for(:squares_without_cubes) unless block_given? + + cubes = powers(3) + c = cubes.next + squares = powers(2) + loop do + s = squares.next + (c = cubes.next) until c >= s + yield s unless c == s + end +end + +answer = squares_without_cubes +20.times { answer.next } +p (1..10).map { answer.next } diff --git a/Task/Generator-Exponential/Scala/generator-exponential-1.scala b/Task/Generator-Exponential/Scala/generator-exponential-1.scala new file mode 100644 index 0000000000..89a7b1b664 --- /dev/null +++ b/Task/Generator-Exponential/Scala/generator-exponential-1.scala @@ -0,0 +1,14 @@ +object Generators { + def main(args: Array[String]): Unit = { + def squares(n:Int=0):Stream[Int]=(n*n) #:: squares(n+1) + def cubes(n:Int=0):Stream[Int]=(n*n*n) #:: cubes(n+1) + + def filtered(s:Stream[Int], c:Stream[Int]):Stream[Int]={ + if(s.head>c.head) filtered(s, c.tail) + else if(s.headch) => filtered2(s, ct) + case (sh#::st, ch#::_) if (sh sh #:: filtered2(st, c) + case (_#::st, _) => filtered2(st, c) +} diff --git a/Task/Generator-Exponential/Scheme/generator-exponential-1.ss b/Task/Generator-Exponential/Scheme/generator-exponential-1.ss new file mode 100644 index 0000000000..8e72b6dd0f --- /dev/null +++ b/Task/Generator-Exponential/Scheme/generator-exponential-1.ss @@ -0,0 +1,27 @@ +(define (power-seq n) + (let ((i 0)) + (lambda () + (set! i (+ 1 i)) + (expt i n)))) + +(define (filter-seq m n) + (let* ((s1 (power-seq m)) (s2 (power-seq n)) + (a 0) (b 0)) + (lambda () + (set! a (s1)) + (let loop () + (if (>= a b) (begin + (cond ((> a b) (set! b (s2))) + ((= a b) (set! a (s1)))) + (loop)))) + a))) + +(let loop ((seq (filter-seq 2 3)) (i 0)) + (if (< i 30) + (begin + (if (> i 20) + (begin + (display (seq)) + (newline)) + (seq)) + (loop seq (+ 1 i))))) diff --git a/Task/Generator-Exponential/Scheme/generator-exponential-2.ss b/Task/Generator-Exponential/Scheme/generator-exponential-2.ss new file mode 100644 index 0000000000..10bd1555bc --- /dev/null +++ b/Task/Generator-Exponential/Scheme/generator-exponential-2.ss @@ -0,0 +1,9 @@ +576 +625 +676 +784 +841 +900 +961 +1024 +1089 diff --git a/Task/Generator-Exponential/Tcl/generator-exponential.tcl b/Task/Generator-Exponential/Tcl/generator-exponential.tcl new file mode 100644 index 0000000000..37ebc252de --- /dev/null +++ b/Task/Generator-Exponential/Tcl/generator-exponential.tcl @@ -0,0 +1,31 @@ +package require Tcl 8.6 + +proc powers m { + yield + for {set n 0} true {incr n} { + yield [expr {$n ** $m}] + } +} +coroutine squares powers 2 +coroutine cubes powers 3 +coroutine filtered apply {{s1 s2} { + yield + set f [$s2] + set v [$s1] + while true { + if {$v > $f} { + set f [$s2] + continue + } elseif {$v < $f} { + yield $v + } + set v [$s1] + } +}} squares cubes + +# Drop 20 +for {set i 0} {$i<20} {incr i} {filtered} +# Take/print 10 +for {} {$i<30} {incr i} { + puts [filtered] +} diff --git a/Task/Generic-swap/0DESCRIPTION b/Task/Generic-swap/0DESCRIPTION new file mode 100644 index 0000000000..12724a48e2 --- /dev/null +++ b/Task/Generic-swap/0DESCRIPTION @@ -0,0 +1,13 @@ +The task is to write a generic swap function or operator which exchanges the values of two variables (or, more generally, any two storage places that can be assigned), regardless of their types. If your solution language is statically typed please describe the way your language provides genericity. + +If variables are typed in the given language, it is permissible that the two variables be constrained to having a mutually compatible type, such that each is permitted to hold the value previously stored in the other without a type violation. That is to say, solutions do not have to be capable of exchanging, say, a string and integer value, if the underlying storage locations are not attributed with types that permit such an exchange. + +Generic swap is a task which brings together a few separate issues in programming language semantics. + +Dynamically typed languages deal with values in a generic way quite readily, but do not necessarily make it easy to write a function to destructively swap two variables, because this requires indirection upon storage places or upon the syntax designating storage places. + +Functional languages, whether static or dynamic, do not necessarily allow a destructive operation such as swapping two variables regardless of their generic capabilities. + +Some static languages have difficulties with generic programming due to a lack of support for ([[Parametric Polymorphism]]). + +Do your best! diff --git a/Task/Generic-swap/1META.yaml b/Task/Generic-swap/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Generic-swap/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Generic-swap/ACL2/generic-swap.acl2 b/Task/Generic-swap/ACL2/generic-swap.acl2 new file mode 100644 index 0000000000..286375fc0a --- /dev/null +++ b/Task/Generic-swap/ACL2/generic-swap.acl2 @@ -0,0 +1,6 @@ +(defun swap (pair) + (cons (cdr pair) + (car pair))) + +(let ((p (cons 1 2))) + (cw "Before: ~x0~%After: ~x1~%" p (swap p))) diff --git a/Task/Generic-swap/ALGOL-68/generic-swap.alg b/Task/Generic-swap/ALGOL-68/generic-swap.alg new file mode 100644 index 0000000000..90e01ac751 --- /dev/null +++ b/Task/Generic-swap/ALGOL-68/generic-swap.alg @@ -0,0 +1,13 @@ +MODE GENMODE = STRING; + +GENMODE v1:="Francis Gary Powers", v2:="Vilyam Fisher"; + +PRIO =:= = 1; + +OP =:= = (REF GENMODE v1, v2)VOID: ( + GENMODE tmp:=v1; v1:=v2; v2:=tmp +); + +v1 =:= v2; + +print(("v1: ",v1, ", v2: ", v2, new line)) diff --git a/Task/Generic-swap/Ada/generic-swap-1.ada b/Task/Generic-swap/Ada/generic-swap-1.ada new file mode 100644 index 0000000000..ab53b47489 --- /dev/null +++ b/Task/Generic-swap/Ada/generic-swap-1.ada @@ -0,0 +1,10 @@ +generic + type Swap_Type is private; -- Generic parameter +procedure Generic_Swap(Left : in out Swap_Type; Right : in out Swap_Type); + +procedure Generic_Swap(Left : in out Swap_Type; Right : in out Swap_Type) is + Temp : Swap_Type := Left; +begin + Left := Right; + Right := Temp; +end Generic_Swap; diff --git a/Task/Generic-swap/Ada/generic-swap-2.ada b/Task/Generic-swap/Ada/generic-swap-2.ada new file mode 100644 index 0000000000..dbd56a4d7f --- /dev/null +++ b/Task/Generic-swap/Ada/generic-swap-2.ada @@ -0,0 +1,7 @@ +with Generic_Swap; +... +type T is ... +package T_Swap is new Generic_Swap(Swap_Type => T); +A,B:T; +... +T_Swap(A,B); diff --git a/Task/Generic-swap/AmigaE/generic-swap.amiga b/Task/Generic-swap/AmigaE/generic-swap.amiga new file mode 100644 index 0000000000..b236114d35 --- /dev/null +++ b/Task/Generic-swap/AmigaE/generic-swap.amiga @@ -0,0 +1,16 @@ +PROC swap(a,b) IS b,a + +PROC main() + DEF v1, v2, x + v1 := 10 + v2 := 20 + v1, v2 := swap(v1,v2) + WriteF('\d \d\n', v1,v2) -> 20 10 + v1 := [ 10, 20, 30, 40 ] + v2 := [ 50, 60, 70, 80 ] + v1, v2 := swap(v1,v2) + ForAll({x}, v1, `WriteF('\d ',x)) -> 50 60 70 80 + WriteF('\n') + ForAll({x}, v2, `WriteF('\d ',x)) -> 10 20 30 40 + WriteF('\n') +ENDPROC diff --git a/Task/Generic-swap/AppleScript/generic-swap.applescript b/Task/Generic-swap/AppleScript/generic-swap.applescript new file mode 100644 index 0000000000..94f9338fae --- /dev/null +++ b/Task/Generic-swap/AppleScript/generic-swap.applescript @@ -0,0 +1 @@ +set {x,y} to {y,x} diff --git a/Task/Generic-swap/AutoHotkey/generic-swap.ahk b/Task/Generic-swap/AutoHotkey/generic-swap.ahk new file mode 100644 index 0000000000..0606e9cddd --- /dev/null +++ b/Task/Generic-swap/AutoHotkey/generic-swap.ahk @@ -0,0 +1,6 @@ +Swap(ByRef Left, ByRef Right) +{ + temp := Left + Left := Right + Right := temp +} diff --git a/Task/Generic-swap/BBC-BASIC/generic-swap-1.bbc b/Task/Generic-swap/BBC-BASIC/generic-swap-1.bbc new file mode 100644 index 0000000000..abc7e98eff --- /dev/null +++ b/Task/Generic-swap/BBC-BASIC/generic-swap-1.bbc @@ -0,0 +1,7 @@ + a = 1.23 : b = 4.56 + SWAP a,b + PRINT a,b + + a$ = "Hello " : b$ = "world!" + SWAP a$,b$ + PRINT a$,b$ diff --git a/Task/Generic-swap/BBC-BASIC/generic-swap-2.bbc b/Task/Generic-swap/BBC-BASIC/generic-swap-2.bbc new file mode 100644 index 0000000000..a4ed1f7ec8 --- /dev/null +++ b/Task/Generic-swap/BBC-BASIC/generic-swap-2.bbc @@ -0,0 +1,15 @@ + a = 1.23 : b = 4.56 + PROCswap(^a,^b, 5) + PRINT a,b + + a$ = "Hello " : b$ = "world!" + PROCswap(^a$,^b$, 6) + PRINT a$,b$ + END + + DEF PROCswap(a%, b%, s%) + LOCAL i% + FOR i% = 0 TO s%-1 + SWAP a%?i%,b%?i% + NEXT + ENDPROC diff --git a/Task/Generic-swap/Batch-File/generic-swap.bat b/Task/Generic-swap/Batch-File/generic-swap.bat new file mode 100644 index 0000000000..98df8c35b6 --- /dev/null +++ b/Task/Generic-swap/Batch-File/generic-swap.bat @@ -0,0 +1,17 @@ +@echo off +setlocal enabledelayedexpansion +set a=1 +set b=woof +echo %a% +echo %b% +call :swap a b +echo %a% +echo %b% +goto :eof + +:swap +set temp1=!%1! +set temp2=!%2! +set %1=%temp2% +set %2=%temp1% +goto :eof diff --git a/Task/Generic-swap/Bracmat/generic-swap.bracmat b/Task/Generic-swap/Bracmat/generic-swap.bracmat new file mode 100644 index 0000000000..d6e75cf858 --- /dev/null +++ b/Task/Generic-swap/Bracmat/generic-swap.bracmat @@ -0,0 +1 @@ +(!a.!b):(?b.?a) diff --git a/Task/Generic-swap/Burlesque/generic-swap.blq b/Task/Generic-swap/Burlesque/generic-swap.blq new file mode 100644 index 0000000000..3a3e3a6750 --- /dev/null +++ b/Task/Generic-swap/Burlesque/generic-swap.blq @@ -0,0 +1 @@ +\/ diff --git a/Task/Generic-swap/C++/generic-swap-1.cpp b/Task/Generic-swap/C++/generic-swap-1.cpp new file mode 100644 index 0000000000..522819779f --- /dev/null +++ b/Task/Generic-swap/C++/generic-swap-1.cpp @@ -0,0 +1,6 @@ +template void swap(T& left, T& right) +{ + T tmp(left); + left = right; + right = tmp; +} diff --git a/Task/Generic-swap/C++/generic-swap-2.cpp b/Task/Generic-swap/C++/generic-swap-2.cpp new file mode 100644 index 0000000000..c08dc0ab26 --- /dev/null +++ b/Task/Generic-swap/C++/generic-swap-2.cpp @@ -0,0 +1 @@ +std::swap(x,y); diff --git a/Task/Generic-swap/C/generic-swap-1.c b/Task/Generic-swap/C/generic-swap-1.c new file mode 100644 index 0000000000..b79e5e53c0 --- /dev/null +++ b/Task/Generic-swap/C/generic-swap-1.c @@ -0,0 +1,6 @@ +void swap(void *va, void *vb, size_t s) +{ + char t, *a = (char*)va, *b = (char*)vb; + while(--s) + t = a[s], a[s] = b[s], b[s] = t; +} diff --git a/Task/Generic-swap/C/generic-swap-2.c b/Task/Generic-swap/C/generic-swap-2.c new file mode 100644 index 0000000000..b5ae9ea72e --- /dev/null +++ b/Task/Generic-swap/C/generic-swap-2.c @@ -0,0 +1 @@ +#define Swap(X,Y) do{ __typeof__ (X) _T = X; X = Y; Y = _T; }while(0) diff --git a/Task/Generic-swap/C/generic-swap-3.c b/Task/Generic-swap/C/generic-swap-3.c new file mode 100644 index 0000000000..df67c3ab55 --- /dev/null +++ b/Task/Generic-swap/C/generic-swap-3.c @@ -0,0 +1,32 @@ +#include + +#define Swap(X,Y) do{ __typeof__ (X) _T = X; X = Y; Y = _T; }while(0) + +struct test +{ + int a, b, c; +}; + + +int main() +{ + struct test t = { 1, 2, 3 }; + struct test h = { 4, 5, 6 }; + double alfa = 0.45, omega = 9.98; + + struct test *pt = &t; + struct test *th = &h; + + printf("%d %d %d\n", t.a, t.b, t.c ); + Swap(t, h); + printf("%d %d %d\n", t.a, t.b, t.c ); + printf("%d %d %d\n", h.a, h.b, h.c ); + + printf("%lf\n", alfa); + Swap(alfa, omega); + printf("%lf\n", alfa); + + printf("%d\n", pt->a); + Swap(pt, th); + printf("%d\n", pt->a); +} diff --git a/Task/Generic-swap/CMake/generic-swap-1.cmake b/Task/Generic-swap/CMake/generic-swap-1.cmake new file mode 100644 index 0000000000..a9e79a3efd --- /dev/null +++ b/Task/Generic-swap/CMake/generic-swap-1.cmake @@ -0,0 +1,5 @@ +function(swap var1 var2) + set(_SWAP_TEMPORARY "${${var1}}") + set(${var1} "${${var2}}" PARENT_SCOPE) + set(${var2} "${_SWAP_TEMPORARY}" PARENT_SCOPE) +endfunction(swap) diff --git a/Task/Generic-swap/CMake/generic-swap-2.cmake b/Task/Generic-swap/CMake/generic-swap-2.cmake new file mode 100644 index 0000000000..c79033de97 --- /dev/null +++ b/Task/Generic-swap/CMake/generic-swap-2.cmake @@ -0,0 +1,5 @@ +set(x 42) +set(y "string") +swap(x y) +message(STATUS ${x}) # -- string +message(STATUS ${y}) # -- 42 diff --git a/Task/Generic-swap/CMake/generic-swap-3.cmake b/Task/Generic-swap/CMake/generic-swap-3.cmake new file mode 100644 index 0000000000..115baf4011 --- /dev/null +++ b/Task/Generic-swap/CMake/generic-swap-3.cmake @@ -0,0 +1,5 @@ +set(x 42) +set(_SWAP_TEMPORARY "string") +swap(x _SWAP_TEMPORARY) +message(STATUS ${x}) # -- 42 +message(STATUS ${_SWAP_TEMPORARY}) # -- 42 diff --git a/Task/Generic-swap/CMake/generic-swap-4.cmake b/Task/Generic-swap/CMake/generic-swap-4.cmake new file mode 100644 index 0000000000..b2a7856d24 --- /dev/null +++ b/Task/Generic-swap/CMake/generic-swap-4.cmake @@ -0,0 +1,3 @@ +string(TOUPPER CACHE x) +set(y "string") +swap(x y) # CMake Error... set given invalid arguments for CACHE mode. diff --git a/Task/Generic-swap/Clojure/generic-swap.clj b/Task/Generic-swap/Clojure/generic-swap.clj new file mode 100644 index 0000000000..08ac1aa4e2 --- /dev/null +++ b/Task/Generic-swap/Clojure/generic-swap.clj @@ -0,0 +1,3 @@ +(defn swap [pair] (reverse pair)) ; returns a list +(defn swap [[a b]] '(b a)) ; returns a list +(defn swap [[a b]] [b a]) ; returns a vector diff --git a/Task/Generic-swap/ColdFusion/generic-swap.cfm b/Task/Generic-swap/ColdFusion/generic-swap.cfm new file mode 100644 index 0000000000..217ebbe0b6 --- /dev/null +++ b/Task/Generic-swap/ColdFusion/generic-swap.cfm @@ -0,0 +1,3 @@ + + + diff --git a/Task/Generic-swap/Common-Lisp/generic-swap.lisp b/Task/Generic-swap/Common-Lisp/generic-swap.lisp new file mode 100644 index 0000000000..a0ecf50ad7 --- /dev/null +++ b/Task/Generic-swap/Common-Lisp/generic-swap.lisp @@ -0,0 +1,3 @@ +(rotatef a b) + +(psetq a b b a) diff --git a/Task/Generic-swap/D/generic-swap.d b/Task/Generic-swap/D/generic-swap.d new file mode 100644 index 0000000000..8d928a5c32 --- /dev/null +++ b/Task/Generic-swap/D/generic-swap.d @@ -0,0 +1,24 @@ +import std.algorithm: swap; // from Phobos standard library + +// The D solution uses templates and it's similar to the C++ one: +void mySwap(T)(ref T left, ref T right) { + auto temp = left; + left = right; + right = temp; +} + +void main() { + import std.stdio; + + int[] a = [10, 20]; + writeln(a); + + // The std.algorithm standard library module + // contains a generic swap: + swap(a[0], a[1]); + writeln(a); + + // Using mySwap: + mySwap(a[0], a[1]); + writeln(a); +} diff --git a/Task/Generic-swap/Delphi/generic-swap.delphi b/Task/Generic-swap/Delphi/generic-swap.delphi new file mode 100644 index 0000000000..b9e19f587b --- /dev/null +++ b/Task/Generic-swap/Delphi/generic-swap.delphi @@ -0,0 +1,8 @@ +procedure Swap_T(var a, b: T); +var + temp: T; +begin + temp := a; + a := b; + b := temp; +end; diff --git a/Task/Generic-swap/E/generic-swap-1.e b/Task/Generic-swap/E/generic-swap-1.e new file mode 100644 index 0000000000..95ad0defdd --- /dev/null +++ b/Task/Generic-swap/E/generic-swap-1.e @@ -0,0 +1,5 @@ +def swap(&left, &right) { + def t := left + left := right + right := t +} diff --git a/Task/Generic-swap/E/generic-swap-2.e b/Task/Generic-swap/E/generic-swap-2.e new file mode 100644 index 0000000000..aaa458f3b0 --- /dev/null +++ b/Task/Generic-swap/E/generic-swap-2.e @@ -0,0 +1,3 @@ +def swap([left, right]) { + return [right, left] +} diff --git a/Task/Generic-swap/Erlang/generic-swap-1.erl b/Task/Generic-swap/Erlang/generic-swap-1.erl new file mode 100644 index 0000000000..4532f9283d --- /dev/null +++ b/Task/Generic-swap/Erlang/generic-swap-1.erl @@ -0,0 +1,4 @@ +1> L = [a, 2]. +[a,2] +2> lists:reverse(L). +[2,a] diff --git a/Task/Generic-swap/Erlang/generic-swap-2.erl b/Task/Generic-swap/Erlang/generic-swap-2.erl new file mode 100644 index 0000000000..9d931cb8d9 --- /dev/null +++ b/Task/Generic-swap/Erlang/generic-swap-2.erl @@ -0,0 +1,4 @@ +1> T = {2,a}. +{2,a} +2> list_to_tuple(lists:reverse(tuple_to_list(T))). +{a,2} diff --git a/Task/Generic-swap/Factor/generic-swap.factor b/Task/Generic-swap/Factor/generic-swap.factor new file mode 100644 index 0000000000..c57f82380d --- /dev/null +++ b/Task/Generic-swap/Factor/generic-swap.factor @@ -0,0 +1 @@ +swap diff --git a/Task/Generic-swap/Falcon/generic-swap.falcon b/Task/Generic-swap/Falcon/generic-swap.falcon new file mode 100644 index 0000000000..a7166be810 --- /dev/null +++ b/Task/Generic-swap/Falcon/generic-swap.falcon @@ -0,0 +1,3 @@ +a = 1 +b = 2 +a,b = arr = b,a diff --git a/Task/Generic-swap/Forth/generic-swap.fth b/Task/Generic-swap/Forth/generic-swap.fth new file mode 100644 index 0000000000..c57f82380d --- /dev/null +++ b/Task/Generic-swap/Forth/generic-swap.fth @@ -0,0 +1 @@ +swap diff --git a/Task/Generic-swap/Fortran/generic-swap.f b/Task/Generic-swap/Fortran/generic-swap.f new file mode 100644 index 0000000000..b296c1bc16 --- /dev/null +++ b/Task/Generic-swap/Fortran/generic-swap.f @@ -0,0 +1,43 @@ +MODULE Genericswap + IMPLICIT NONE + + INTERFACE Swap + MODULE PROCEDURE Swapint, Swapreal, Swapstring + END INTERFACE + +CONTAINS + + SUBROUTINE Swapint(a, b) + INTEGER, INTENT(IN OUT) :: a, b + INTEGER :: temp + temp = a ; a = b ; b = temp + END SUBROUTINE Swapint + + SUBROUTINE Swapreal(a, b) + REAL, INTENT(IN OUT) :: a, b + REAL :: temp + temp = a ; a = b ; b = temp + END SUBROUTINE Swapreal + + SUBROUTINE Swapstring(a, b) + CHARACTER(*), INTENT(IN OUT) :: a, b + CHARACTER(len(a)) :: temp + temp = a ; a = b ; b = temp + END SUBROUTINE Swapstring +END MODULE Genericswap + +PROGRAM EXAMPLE + USE Genericswap + IMPLICIT NONE + INTEGER :: i1 = 1, i2 = 2 + REAL :: r1 = 1.0, r2 = 2.0 + CHARACTER(3) :: s1="abc", s2="xyz" + + CALL Swap(i1, i2) + CALL Swap(r1, r2) + CALL Swap(s1, s2) + + WRITE(*,*) i1, i2 ! Prints 2 and 1 + WRITE(*,*) r1, r2 ! Prints 2.0 and 1.0 + WRITE(*,*) s1, s2 ! Prints xyz and abc +END PROGRAM EXAMPLE diff --git a/Task/Generic-swap/Frink/generic-swap.frink b/Task/Generic-swap/Frink/generic-swap.frink new file mode 100644 index 0000000000..efe07b34fe --- /dev/null +++ b/Task/Generic-swap/Frink/generic-swap.frink @@ -0,0 +1 @@ +[b,a] = [a,b] diff --git a/Task/Generic-swap/Gecho/generic-swap-1.gecho b/Task/Generic-swap/Gecho/generic-swap-1.gecho new file mode 100644 index 0000000000..97228d30a7 --- /dev/null +++ b/Task/Generic-swap/Gecho/generic-swap-1.gecho @@ -0,0 +1 @@ +1 !0 2 !1 diff --git a/Task/Generic-swap/Gecho/generic-swap-2.gecho b/Task/Generic-swap/Gecho/generic-swap-2.gecho new file mode 100644 index 0000000000..aa0522c47d --- /dev/null +++ b/Task/Generic-swap/Gecho/generic-swap-2.gecho @@ -0,0 +1 @@ +&0 &1 !0 pop !1 diff --git a/Task/Generic-swap/Go/generic-swap-1.go b/Task/Generic-swap/Go/generic-swap-1.go new file mode 100644 index 0000000000..053b49fb51 --- /dev/null +++ b/Task/Generic-swap/Go/generic-swap-1.go @@ -0,0 +1 @@ +a, b = b, a diff --git a/Task/Generic-swap/Go/generic-swap-2.go b/Task/Generic-swap/Go/generic-swap-2.go new file mode 100644 index 0000000000..9f01fb77e9 --- /dev/null +++ b/Task/Generic-swap/Go/generic-swap-2.go @@ -0,0 +1,14 @@ +package main + +import "fmt" + +func swap(a, b *interface{}) { + *a, *b = *b, *a +} + +func main() { + var a, b interface{} = 3, "four" + fmt.Println(a, b) + swap(&a, &b) + fmt.Println(a, b) +} diff --git a/Task/Generic-swap/Go/generic-swap-3.go b/Task/Generic-swap/Go/generic-swap-3.go new file mode 100644 index 0000000000..88be72578f --- /dev/null +++ b/Task/Generic-swap/Go/generic-swap-3.go @@ -0,0 +1,51 @@ +package main + +import ( + "fmt" + "reflect" +) + +func swap(a, b interface{}) error { + ta := reflect.TypeOf(a) + tb := reflect.TypeOf(b) + if ta != tb { + return fmt.Errorf("swap args are different types: %v and %v", ta, tb) + } + if ta.Kind() != reflect.Ptr { + return fmt.Errorf("swap args must be pointers") + } + ea := reflect.ValueOf(a).Elem() + eb := reflect.ValueOf(b).Elem() + temp := reflect.New(ea.Type()).Elem() + temp.Set(ea) + ea.Set(eb) + eb.Set(temp) + return nil +} + +func main() { + a, b := 3, "cats" + fmt.Println("a b:", a, b) + err := swap(a, b) + fmt.Println(err, "\n") + + c, d := 3, 4 + fmt.Println("c d:", c, d) + err = swap(c, d) + fmt.Println(err, "\n") + + e, f := 3, 4 + fmt.Println("e f:", e, f) + swap(&e, &f) + fmt.Println("e f:", e, f, "\n") + + type mult struct { + int + string + } + + g, h := mult{3, "cats"}, mult{4, "dogs"} + fmt.Println("g h:", g, h) + swap(&g, &h) + fmt.Println("g h:", g, h) +} diff --git a/Task/Generic-swap/Groovy/generic-swap-1.groovy b/Task/Generic-swap/Groovy/generic-swap-1.groovy new file mode 100644 index 0000000000..6b4feabce2 --- /dev/null +++ b/Task/Generic-swap/Groovy/generic-swap-1.groovy @@ -0,0 +1 @@ +(a, b) = [b, a] diff --git a/Task/Generic-swap/Groovy/generic-swap-2.groovy b/Task/Generic-swap/Groovy/generic-swap-2.groovy new file mode 100644 index 0000000000..9b3699dd01 --- /dev/null +++ b/Task/Generic-swap/Groovy/generic-swap-2.groovy @@ -0,0 +1,3 @@ +def swap(a, b) { + [b, a] +} diff --git a/Task/Generic-swap/Groovy/generic-swap-3.groovy b/Task/Generic-swap/Groovy/generic-swap-3.groovy new file mode 100644 index 0000000000..e14d5605e9 --- /dev/null +++ b/Task/Generic-swap/Groovy/generic-swap-3.groovy @@ -0,0 +1,3 @@ +def (x, y) = swap(1, 3) +assert x == 3 +assert y == 1 diff --git a/Task/Generic-swap/Groovy/generic-swap-4.groovy b/Task/Generic-swap/Groovy/generic-swap-4.groovy new file mode 100644 index 0000000000..35213a68b0 --- /dev/null +++ b/Task/Generic-swap/Groovy/generic-swap-4.groovy @@ -0,0 +1,8 @@ +def listSwap = { a, i, j -> + assert (0..<(a.size())).containsAll([i,j]); + a[[j,i]] = a[[i,j]] +} + +def list = [2,4,6,8] +listSwap(list, 1, 3) +assert list == [2,8,6,4] diff --git a/Task/Generic-swap/Haskell/generic-swap.hs b/Task/Generic-swap/Haskell/generic-swap.hs new file mode 100644 index 0000000000..e2426a9479 --- /dev/null +++ b/Task/Generic-swap/Haskell/generic-swap.hs @@ -0,0 +1,2 @@ +swap :: (a, b) -> (b, a) +swap (x, y) = (y, x) diff --git a/Task/Generic-swap/IDL/generic-swap.idl b/Task/Generic-swap/IDL/generic-swap.idl new file mode 100644 index 0000000000..4e6181b12b --- /dev/null +++ b/Task/Generic-swap/IDL/generic-swap.idl @@ -0,0 +1,5 @@ +pro swap, a, b + c = temporary(a) + a = temporary(b) + b = temporary(c) +end diff --git a/Task/Generic-swap/Icon/generic-swap.icon b/Task/Generic-swap/Icon/generic-swap.icon new file mode 100644 index 0000000000..cffb59c400 --- /dev/null +++ b/Task/Generic-swap/Icon/generic-swap.icon @@ -0,0 +1,8 @@ +procedure main() + x := 1 + y := 2 + x :=: y + write(x," ",y) + # swap that will reverse if surrounding expression fails + if x <-> y & x < y then write(x, " ", y) +end diff --git a/Task/Generic-swap/J/generic-swap-1.j b/Task/Generic-swap/J/generic-swap-1.j new file mode 100644 index 0000000000..bb080ad01c --- /dev/null +++ b/Task/Generic-swap/J/generic-swap-1.j @@ -0,0 +1,4 @@ + (<2 4) C. 2 3 5 7 11 13 17 19 +2 3 11 7 5 13 17 19 + (<0 3)&C.&.;:'Roses are red. Violets are blue.' +Violets are red. Roses are blue. diff --git a/Task/Generic-swap/J/generic-swap-2.j b/Task/Generic-swap/J/generic-swap-2.j new file mode 100644 index 0000000000..49bac54510 --- /dev/null +++ b/Task/Generic-swap/J/generic-swap-2.j @@ -0,0 +1,4 @@ + |.2 3 +3 2 + |.&.;:'one two' +two one diff --git a/Task/Generic-swap/J/generic-swap-3.j b/Task/Generic-swap/J/generic-swap-3.j new file mode 100644 index 0000000000..1504a6c11c --- /dev/null +++ b/Task/Generic-swap/J/generic-swap-3.j @@ -0,0 +1,6 @@ +destructiveSwap=:4 :0 + t=. do y + (y)=: do x + (x)=: t + i.0 0 NB. result is meaningless +) diff --git a/Task/Generic-swap/J/generic-swap-4.j b/Task/Generic-swap/J/generic-swap-4.j new file mode 100644 index 0000000000..ad7bf01697 --- /dev/null +++ b/Task/Generic-swap/J/generic-swap-4.j @@ -0,0 +1,7 @@ + V1=: 'cat' + V2=: 7 + 'V1' destructiveSwap 'V2' + V1 +7 + V2 +cat diff --git a/Task/Generic-swap/Java/generic-swap.java b/Task/Generic-swap/Java/generic-swap.java new file mode 100644 index 0000000000..536a460c63 --- /dev/null +++ b/Task/Generic-swap/Java/generic-swap.java @@ -0,0 +1,9 @@ +class Pair { + T first; + T second; +} +public static void swap(Pair p) { + T temp = p.first; + p.first = p.second; + p.second = temp; +} diff --git a/Task/Generic-swap/JavaScript/generic-swap-1.js b/Task/Generic-swap/JavaScript/generic-swap-1.js new file mode 100644 index 0000000000..32d2874a4d --- /dev/null +++ b/Task/Generic-swap/JavaScript/generic-swap-1.js @@ -0,0 +1,5 @@ +function swap(arr) { + var tmp = arr[0]; + arr[0] = arr[1]; + arr[1] = tmp; +} diff --git a/Task/Generic-swap/JavaScript/generic-swap-2.js b/Task/Generic-swap/JavaScript/generic-swap-2.js new file mode 100644 index 0000000000..27d11419f8 --- /dev/null +++ b/Task/Generic-swap/JavaScript/generic-swap-2.js @@ -0,0 +1,9 @@ +function swap(aName, bName) { + return ('(function(){ arguments[0] = aName; aName = bName; bName = arguments[0] })()' + .replace(/aName/g, aName) + .replace(/bName/g, bName) + ) +} +var x = 1 +var y = 2 +eval(swap('x', 'y')) diff --git a/Task/Generic-swap/Joy/generic-swap.joy b/Task/Generic-swap/Joy/generic-swap.joy new file mode 100644 index 0000000000..c57f82380d --- /dev/null +++ b/Task/Generic-swap/Joy/generic-swap.joy @@ -0,0 +1 @@ +swap diff --git a/Task/Generic-swap/LOLCODE/generic-swap.lol b/Task/Generic-swap/LOLCODE/generic-swap.lol new file mode 100644 index 0000000000..09efe3e3a7 --- /dev/null +++ b/Task/Generic-swap/LOLCODE/generic-swap.lol @@ -0,0 +1,11 @@ +HAI 1.3 + +I HAS A foo ITZ "kittehz" +I HAS A bar ITZ 42 + +foo, foo R bar, bar R IT + +VISIBLE foo BTW, 42 +VISIBLE bar BTW, kittehz + +KTHXBYE diff --git a/Task/Generic-swap/Lang5/generic-swap.lang5 b/Task/Generic-swap/Lang5/generic-swap.lang5 new file mode 100644 index 0000000000..56317acf4b --- /dev/null +++ b/Task/Generic-swap/Lang5/generic-swap.lang5 @@ -0,0 +1,2 @@ +swap # stack +reverse # array diff --git a/Task/Generic-swap/Lhogho/generic-swap.lhogho b/Task/Generic-swap/Lhogho/generic-swap.lhogho new file mode 100644 index 0000000000..079554b73a --- /dev/null +++ b/Task/Generic-swap/Lhogho/generic-swap.lhogho @@ -0,0 +1,11 @@ +to swap :s1 :s2 + local "t + make "t thing :s1 + make :s1 thing :s2 + make :s2 :t +end + +make "a 4 +make "b "dog +swap "a "b ; pass the names of the variables to swap +show list :a :b ; [dog 4] diff --git a/Task/Generic-swap/Lisaac/generic-swap.lisaac b/Task/Generic-swap/Lisaac/generic-swap.lisaac new file mode 100644 index 0000000000..9013582c22 --- /dev/null +++ b/Task/Generic-swap/Lisaac/generic-swap.lisaac @@ -0,0 +1 @@ +(a, b) := (b, a); diff --git a/Task/Generic-swap/Logo/generic-swap.logo b/Task/Generic-swap/Logo/generic-swap.logo new file mode 100644 index 0000000000..20f6f6acb9 --- /dev/null +++ b/Task/Generic-swap/Logo/generic-swap.logo @@ -0,0 +1,10 @@ +to swap :s1 :s2 + localmake "t thing :s1 + make :s1 thing :s2 + make :s2 :t +end + +make "a 4 +make "b "dog +swap "a "b ; pass the names of the variables to swap +show list :a :b ; [dog 4] diff --git a/Task/Generic-swap/Logtalk/generic-swap-1.logtalk b/Task/Generic-swap/Logtalk/generic-swap-1.logtalk new file mode 100644 index 0000000000..26081abec0 --- /dev/null +++ b/Task/Generic-swap/Logtalk/generic-swap-1.logtalk @@ -0,0 +1,6 @@ +:- object(paws). + + :- public(swap/4). + swap(First, Second, Second, First). + +:- end_object. diff --git a/Task/Generic-swap/Logtalk/generic-swap-2.logtalk b/Task/Generic-swap/Logtalk/generic-swap-2.logtalk new file mode 100644 index 0000000000..22511bffe7 --- /dev/null +++ b/Task/Generic-swap/Logtalk/generic-swap-2.logtalk @@ -0,0 +1,8 @@ +| ?- paws::swap(apples, oranges, X, Y). +X = oranges +Y = apples +yes + +| ?- paws::swap(3.14, ext(lgt), X, Y). +X = ext(lgt) +Y = 3.14 diff --git a/Task/Generic-swap/Lua/generic-swap-1.lua b/Task/Generic-swap/Lua/generic-swap-1.lua new file mode 100644 index 0000000000..6a4b28db2d --- /dev/null +++ b/Task/Generic-swap/Lua/generic-swap-1.lua @@ -0,0 +1,2 @@ +x, y = y, x -- swap the values inside x and y +t[1], t[2] = t[2], t[1] -- swap the first and second values inside table t diff --git a/Task/Generic-swap/Lua/generic-swap-2.lua b/Task/Generic-swap/Lua/generic-swap-2.lua new file mode 100644 index 0000000000..62d3bd99af --- /dev/null +++ b/Task/Generic-swap/Lua/generic-swap-2.lua @@ -0,0 +1,4 @@ +x, y = 3, 4 +print(x, y) --> 3 4 +x, y = y, x -- swap +print(x, y) --> 4 3 diff --git a/Task/Generic-swap/M4/generic-swap.m4 b/Task/Generic-swap/M4/generic-swap.m4 new file mode 100644 index 0000000000..dccbca98bd --- /dev/null +++ b/Task/Generic-swap/M4/generic-swap.m4 @@ -0,0 +1,8 @@ +define(`def2', `define(`$1',`$2')define(`$3',`$4')')dnl +define(`swap', `def2(`$1',defn(`$2'),`$2',defn(`$1'))')dnl +dnl +define(`a',`x')dnl +define(`b',`y')dnl +a b +swap(`a',`b') +a b diff --git a/Task/Generic-swap/MATLAB/generic-swap.m b/Task/Generic-swap/MATLAB/generic-swap.m new file mode 100644 index 0000000000..1d1ac56756 --- /dev/null +++ b/Task/Generic-swap/MATLAB/generic-swap.m @@ -0,0 +1,17 @@ +>> a = [30 40 50 60 70] + +a = + + 30 40 50 60 70 + +>> a([1 3]) = a([3 1]) %Single swap + +a = + + 50 40 30 60 70 + +>> a([1 2 4 3]) = a([2 3 1 4]) %Multiple swap, a.k.a permutation. + +a = + + 40 30 60 50 70 diff --git a/Task/Generic-swap/MAXScript/generic-swap.max b/Task/Generic-swap/MAXScript/generic-swap.max new file mode 100644 index 0000000000..c21c3c88c2 --- /dev/null +++ b/Task/Generic-swap/MAXScript/generic-swap.max @@ -0,0 +1 @@ +swap a b diff --git a/Task/Generic-swap/Maple/generic-swap.maple b/Task/Generic-swap/Maple/generic-swap.maple new file mode 100644 index 0000000000..dfc4849f27 --- /dev/null +++ b/Task/Generic-swap/Maple/generic-swap.maple @@ -0,0 +1,13 @@ +> a, b := 2, "foo": +> a; + 2 + +> b; + "foo" + +> a, b := b, a: # SWAP +> a; + "foo" + +> b; + 2 diff --git a/Task/Generic-swap/Mathematica/generic-swap.mathematica b/Task/Generic-swap/Mathematica/generic-swap.mathematica new file mode 100644 index 0000000000..4a27990e5a --- /dev/null +++ b/Task/Generic-swap/Mathematica/generic-swap.mathematica @@ -0,0 +1,2 @@ +swap[a_, b_] := {a, b} = {b, a} +SetAttributes[swap, HoldAll] diff --git a/Task/Generic-swap/Maxima/generic-swap.maxima b/Task/Generic-swap/Maxima/generic-swap.maxima new file mode 100644 index 0000000000..b70e1dde0c --- /dev/null +++ b/Task/Generic-swap/Maxima/generic-swap.maxima @@ -0,0 +1,16 @@ +a: 10$ +b: 20$ + +/* A simple way to swap values */ +[a, b]: [b, a]$ + +a; /* 20 */ +b; /* 10 */ + +/* A macro to hide this */ +swap(x, y) ::= buildq([x, y], ([x, y]: [y, x], 'done))$ + +swap(a, b)$ + +a; /* 10 */ +b; /* 20 */ diff --git a/Task/Generic-swap/Metafont/generic-swap-1.metafont b/Task/Generic-swap/Metafont/generic-swap-1.metafont new file mode 100644 index 0000000000..7c5f8a9725 --- /dev/null +++ b/Task/Generic-swap/Metafont/generic-swap-1.metafont @@ -0,0 +1,12 @@ +vardef swap(suffix a, b) = + save ?; string s_; + if boolean a: boolean ? + elseif numeric a: numeric ? % this one could be omitted + elseif pair a: pair ? + elseif path a: path ? + elseif pen a: pen ? + elseif picture a: picture ? + elseif string a: string ? + elseif transform a: transform ? fi; + ? := a; a := b; b := ? +enddef; diff --git a/Task/Generic-swap/Metafont/generic-swap-2.metafont b/Task/Generic-swap/Metafont/generic-swap-2.metafont new file mode 100644 index 0000000000..0f036b5942 --- /dev/null +++ b/Task/Generic-swap/Metafont/generic-swap-2.metafont @@ -0,0 +1,12 @@ +j := 10; +i := 5; +show j, i; +swap(j,i); +show j, i; + +boolean truth[]; +truth1 := true; +truth2 := false; +show truth1, truth2; +swap(truth1,truth2); +show truth1, truth2; diff --git a/Task/Generic-swap/Modula-3/generic-swap-1.mod3 b/Task/Generic-swap/Modula-3/generic-swap-1.mod3 new file mode 100644 index 0000000000..7e1f5ed6c9 --- /dev/null +++ b/Task/Generic-swap/Modula-3/generic-swap-1.mod3 @@ -0,0 +1,5 @@ +GENERIC INTERFACE GenericSwap(Elem); + +PROCEDURE Swap(VAR left: Elem.T; VAR right: Elem.T); + +END GenericSwap. diff --git a/Task/Generic-swap/Modula-3/generic-swap-2.mod3 b/Task/Generic-swap/Modula-3/generic-swap-2.mod3 new file mode 100644 index 0000000000..51dbab18c9 --- /dev/null +++ b/Task/Generic-swap/Modula-3/generic-swap-2.mod3 @@ -0,0 +1,11 @@ +GENERIC MODULE GenericSwap(Elem); + +PROCEDURE Swap(VAR left: Elem.T; VAR right: Elem.T) = + VAR temp: Elem.T := left; + BEGIN + left := right; + right := temp; + END Swap; + +BEGIN +END GenericSwap. diff --git a/Task/Generic-swap/Modula-3/generic-swap-3.mod3 b/Task/Generic-swap/Modula-3/generic-swap-3.mod3 new file mode 100644 index 0000000000..4f55434fea --- /dev/null +++ b/Task/Generic-swap/Modula-3/generic-swap-3.mod3 @@ -0,0 +1 @@ +INTERFACE IntSwap = GenericSwap(Integer) END IntSwap. diff --git a/Task/Generic-swap/Modula-3/generic-swap-4.mod3 b/Task/Generic-swap/Modula-3/generic-swap-4.mod3 new file mode 100644 index 0000000000..e6eda0bf6e --- /dev/null +++ b/Task/Generic-swap/Modula-3/generic-swap-4.mod3 @@ -0,0 +1 @@ +MODULE IntSwap = GenericSwap(Integer) END IntSwap. diff --git a/Task/Generic-swap/Modula-3/generic-swap-5.mod3 b/Task/Generic-swap/Modula-3/generic-swap-5.mod3 new file mode 100644 index 0000000000..b4ccfd3a99 --- /dev/null +++ b/Task/Generic-swap/Modula-3/generic-swap-5.mod3 @@ -0,0 +1,12 @@ +MODULE Main; + +IMPORT IntSwap, IO, Fmt; + +VAR left := 10; + right := 20; + +BEGIN + IO.Put("Left = " & Fmt.Int(left) & "\n"); + IntSwap.Swap(left, right); + IO.Put("Left = " & Fmt.Int(left) & "\n"); +END Main. diff --git a/Task/Generic-swap/PHP/generic-swap.php b/Task/Generic-swap/PHP/generic-swap.php new file mode 100644 index 0000000000..7c53258635 --- /dev/null +++ b/Task/Generic-swap/PHP/generic-swap.php @@ -0,0 +1,3 @@ +function swap(&$a, &$b) { + list($a, $b) = array($b, $a); +} diff --git a/Task/Generic-swap/Perl/generic-swap-1.pl b/Task/Generic-swap/Perl/generic-swap-1.pl new file mode 100644 index 0000000000..0842c8d68a --- /dev/null +++ b/Task/Generic-swap/Perl/generic-swap-1.pl @@ -0,0 +1 @@ +($y, $x) = ($x, $y); diff --git a/Task/Generic-swap/Perl/generic-swap-2.pl b/Task/Generic-swap/Perl/generic-swap-2.pl new file mode 100644 index 0000000000..9706ab4189 --- /dev/null +++ b/Task/Generic-swap/Perl/generic-swap-2.pl @@ -0,0 +1 @@ +sub swap {@_[0, 1] = @_[1, 0]} diff --git a/Task/Generic-swap/PicoLisp/generic-swap.l b/Task/Generic-swap/PicoLisp/generic-swap.l new file mode 100644 index 0000000000..7dde9ee046 --- /dev/null +++ b/Task/Generic-swap/PicoLisp/generic-swap.l @@ -0,0 +1,7 @@ +(let (A 1 B 2) + (xchg 'A 'B) + (println A B) ) + +(let (Lst1 '(a b c) Lst2 '(d e f)) + (xchg (cdr Lst1) (cdr Lst2)) + (println Lst1 Lst2) ) diff --git a/Task/Generic-swap/Prolog/generic-swap.pro b/Task/Generic-swap/Prolog/generic-swap.pro new file mode 100644 index 0000000000..09084c6a7c --- /dev/null +++ b/Task/Generic-swap/Prolog/generic-swap.pro @@ -0,0 +1,5 @@ +swap(A,B,B,A). + +?- swap(1,2,X,Y). +X = 2, +Y = 1. diff --git a/Task/Generic-swap/Python/generic-swap-1.py b/Task/Generic-swap/Python/generic-swap-1.py new file mode 100644 index 0000000000..053b49fb51 --- /dev/null +++ b/Task/Generic-swap/Python/generic-swap-1.py @@ -0,0 +1 @@ +a, b = b, a diff --git a/Task/Generic-swap/Python/generic-swap-2.py b/Task/Generic-swap/Python/generic-swap-2.py new file mode 100644 index 0000000000..d8d9cb3db5 --- /dev/null +++ b/Task/Generic-swap/Python/generic-swap-2.py @@ -0,0 +1,2 @@ +def swap(a, b): + return b, a diff --git a/Task/Generic-swap/R/generic-swap.r b/Task/Generic-swap/R/generic-swap.r new file mode 100644 index 0000000000..5b89254578 --- /dev/null +++ b/Task/Generic-swap/R/generic-swap.r @@ -0,0 +1,6 @@ +swap <- function(name1, name2, envir = parent.env(environment())) +{ + temp <- get(name1, pos = envir) + assign(name1, get(name2, pos = envir), pos = envir) + assign(name2, temp, pos = envir) +} diff --git a/Task/Generic-swap/REXX/generic-swap-1.rexx b/Task/Generic-swap/REXX/generic-swap-1.rexx new file mode 100644 index 0000000000..45adc1d8e1 --- /dev/null +++ b/Task/Generic-swap/REXX/generic-swap-1.rexx @@ -0,0 +1,6 @@ +a = 'some value' +b = 6 + +_temp_ = a + a = b + b = _temp_ diff --git a/Task/Generic-swap/REXX/generic-swap-2.rexx b/Task/Generic-swap/REXX/generic-swap-2.rexx new file mode 100644 index 0000000000..9d42c5887f --- /dev/null +++ b/Task/Generic-swap/REXX/generic-swap-2.rexx @@ -0,0 +1,4 @@ +a = -199e-12 +b = 12. + +parse value a b with b a /*swaps A and B */ diff --git a/Task/Generic-swap/Racket/generic-swap.rkt b/Task/Generic-swap/Racket/generic-swap.rkt new file mode 100644 index 0000000000..a7affafdf1 --- /dev/null +++ b/Task/Generic-swap/Racket/generic-swap.rkt @@ -0,0 +1,24 @@ +#lang racket/load + +(module swap racket + (provide swap) + + ;; a simple macro to swap two variables + (define-syntax-rule (swap a b) + (let ([tmp a]) + (set! a b) + (set! b tmp)))) + +;; works fine in a statically typed setting +(module typed typed/racket + (require 'swap) + + (: x Integer) + (define x 3) + + (: y Integer) + (define y 4) + + (swap x y) + (printf "x is ~a~n" x) + (printf "y is ~a~n" y)) diff --git a/Task/Generic-swap/Ruby/generic-swap-1.rb b/Task/Generic-swap/Ruby/generic-swap-1.rb new file mode 100644 index 0000000000..053b49fb51 --- /dev/null +++ b/Task/Generic-swap/Ruby/generic-swap-1.rb @@ -0,0 +1 @@ +a, b = b, a diff --git a/Task/Generic-swap/Ruby/generic-swap-2.rb b/Task/Generic-swap/Ruby/generic-swap-2.rb new file mode 100644 index 0000000000..c71f124bc9 --- /dev/null +++ b/Task/Generic-swap/Ruby/generic-swap-2.rb @@ -0,0 +1,3 @@ +def swap(a, b) + return b, a +end diff --git a/Task/Generic-swap/Ruby/generic-swap-3.rb b/Task/Generic-swap/Ruby/generic-swap-3.rb new file mode 100644 index 0000000000..e36a5367af --- /dev/null +++ b/Task/Generic-swap/Ruby/generic-swap-3.rb @@ -0,0 +1,5 @@ +x = 42 +y = "string" +x, y = swap x, y +puts x # prints string +puts y # prints 42 diff --git a/Task/Generic-swap/Sather/generic-swap-1.sa b/Task/Generic-swap/Sather/generic-swap-1.sa new file mode 100644 index 0000000000..e0fd3fe16a --- /dev/null +++ b/Task/Generic-swap/Sather/generic-swap-1.sa @@ -0,0 +1,7 @@ +class SWAP{T} is + swap(inout a, inout b:T) is + t ::= a; + a := b; + b := t; + end; +end; diff --git a/Task/Generic-swap/Sather/generic-swap-2.sa b/Task/Generic-swap/Sather/generic-swap-2.sa new file mode 100644 index 0000000000..34eb442ec6 --- /dev/null +++ b/Task/Generic-swap/Sather/generic-swap-2.sa @@ -0,0 +1,8 @@ +class MAIN is + main is + x ::= 10; + y ::= 20; + SWAP{INT}::swap(inout x, inout y); + #OUT + x + ", " + y + "\n"; + end; +end; diff --git a/Task/Generic-swap/Scala/generic-swap.scala b/Task/Generic-swap/Scala/generic-swap.scala new file mode 100644 index 0000000000..c2ca58d580 --- /dev/null +++ b/Task/Generic-swap/Scala/generic-swap.scala @@ -0,0 +1 @@ +def swap[A,B](a: A, b: B): (B, A) = (b, a) diff --git a/Task/Generic-swap/Scheme/generic-swap.ss b/Task/Generic-swap/Scheme/generic-swap.ss new file mode 100644 index 0000000000..83790d5550 --- /dev/null +++ b/Task/Generic-swap/Scheme/generic-swap.ss @@ -0,0 +1,39 @@ +; swap elements of a vector +; vector-swap! is not part of r5rs, so we define it +(define (vector-swap! v i j) +(let ((a (vector-ref v i)) (b (vector-ref v j))) +(vector-set! v i b) +(vector-set! v j a))) + +(let ((vec (vector 1 2 3 4 5))) + (vector-swap! vec 0 4) + vec) +; #(5 2 3 4 1) + + +; we can swap also in lists +(define (list-swap! v i j) +(let* ((x (list-tail v i)) + (y (list-tail v j)) + (a (car x)) + (b (car y))) +(set-car! x b) +(set-car! y a))) + +(let ((lis (list 1 2 3 4 5))) + (list-swap! lis 0 4) + lis) +; (5 2 3 4 1) + + +; using macros (will work on variables, not on vectors or lists) +(define-syntax swap! +(syntax-rules () +((_ a b) + (let ((tmp a)) + (set! a b) + (set! b tmp))))) + +; try it +(let ((a 1) (b 2)) (swap! a b) (list a b)) +; (2 1) diff --git a/Task/Generic-swap/Smalltalk/generic-swap.st b/Task/Generic-swap/Smalltalk/generic-swap.st new file mode 100644 index 0000000000..c2dd9da358 --- /dev/null +++ b/Task/Generic-swap/Smalltalk/generic-swap.st @@ -0,0 +1,8 @@ +OrderedCollection extend [ + swap: a and: b [ + |t| + t := self at: a. + self at: a put: (self at: b). + self at: b put: t + ] +] diff --git a/Task/Generic-swap/Tcl/generic-swap-1.tcl b/Task/Generic-swap/Tcl/generic-swap-1.tcl new file mode 100644 index 0000000000..ddaa9cc589 --- /dev/null +++ b/Task/Generic-swap/Tcl/generic-swap-1.tcl @@ -0,0 +1,4 @@ +proc swap {aName bName} { + upvar 1 $aName a $bName b + lassign [list $a $b] b a +} diff --git a/Task/Generic-swap/Tcl/generic-swap-2.tcl b/Task/Generic-swap/Tcl/generic-swap-2.tcl new file mode 100644 index 0000000000..5647ce43eb --- /dev/null +++ b/Task/Generic-swap/Tcl/generic-swap-2.tcl @@ -0,0 +1,4 @@ +proc swap {aName bName} { + upvar 1 $aName a $bName b + foreach {b a} [list $a $b] break +} diff --git a/Task/Generic-swap/Tcl/generic-swap-3.tcl b/Task/Generic-swap/Tcl/generic-swap-3.tcl new file mode 100644 index 0000000000..73ca47a2b2 --- /dev/null +++ b/Task/Generic-swap/Tcl/generic-swap-3.tcl @@ -0,0 +1,5 @@ +set a 1 +set b 2 +puts "before\ta=$a\tb=$b" +swap a b +puts "after\ta=$a\tb=$b" diff --git a/Task/Globally-replace-text-in-several-files/0DESCRIPTION b/Task/Globally-replace-text-in-several-files/0DESCRIPTION new file mode 100644 index 0000000000..e386c7cb60 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/0DESCRIPTION @@ -0,0 +1 @@ +The task is to replace every occurring instance of a piece of text in a group of text files with another one. For this task we want to replace the text "Goodbye London!" with "Hello New York!" for a list of files. diff --git a/Task/Globally-replace-text-in-several-files/AWK/globally-replace-text-in-several-files.awk b/Task/Globally-replace-text-in-several-files/AWK/globally-replace-text-in-several-files.awk new file mode 100644 index 0000000000..8a5e0076da --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/AWK/globally-replace-text-in-several-files.awk @@ -0,0 +1,28 @@ +# syntax: GAWK -f GLOBALLY_REPLACE_TEXT_IN_SEVERAL_FILES.AWK filename(s) +BEGIN { + old_text = "Goodbye London!" + new_text = "Hello New York!" +} +BEGINFILE { + nfiles_in++ + text_found = 0 + delete arr +} +{ if (gsub(old_text,new_text,$0) > 0) { + text_found++ + } + arr[FNR] = $0 +} +ENDFILE { + if (text_found > 0) { + nfiles_out++ + close(FILENAME) + for (i=1; i<=FNR; i++) { + printf("%s\n",arr[i]) >FILENAME + } + } +} +END { + printf("files: %d read, %d updated\n",nfiles_in,nfiles_out) + exit(0) +} diff --git a/Task/Globally-replace-text-in-several-files/Ada/globally-replace-text-in-several-files.ada b/Task/Globally-replace-text-in-several-files/Ada/globally-replace-text-in-several-files.ada new file mode 100644 index 0000000000..b94cd89572 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Ada/globally-replace-text-in-several-files.ada @@ -0,0 +1,60 @@ +with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories; + +procedure Global_Replace is + + subtype U_String is Ada.Strings.Unbounded.Unbounded_String; + function "+"(S: String) return U_String renames + Ada.Strings.Unbounded.To_Unbounded_String; + function "-"(U: U_String) return String renames + Ada.Strings.Unbounded.To_String; + + procedure String_Replace(S: in out U_String; Pattern, Replacement: String) is + -- example: if S is "Mary had a XX lamb", then String_Replace(S, "X", "little"); + -- will turn S into "Mary had a littlelittle lamb" + -- and String_Replace(S, "Y", "small"); will not change S + + Index : Natural; + begin + loop + Index := Ada.Strings.Unbounded.Index(Source => S, Pattern => Pattern); + exit when Index = 0; + Ada.Strings.Unbounded.Replace_Slice + (Source => S, Low => Index, High => Index+Pattern'Length-1, + By => Replacement); + end loop; + end String_Replace; + + procedure File_Replace(Filename: String; Pattern, Replacement: String) is + -- applies String_Rplace to each line in the file with the given Filename + -- propagates any exceptions, when, e.g., the file does not exist + + I_File, O_File: Ada.Text_IO.File_Type; + Line: U_String; + Tmp_Name: String := Filename & ".tmp"; + -- name of temporary file; if that file already exists, it will be overwritten + begin + Ada.Text_IO.Open(I_File, Ada.Text_IO.In_File, Filename); + Ada.Text_IO.Create(O_File, Ada.Text_IO.Out_File, Tmp_Name); + while not Ada.Text_IO.End_Of_File(I_File) loop + Line := +Ada.Text_IO.Get_Line(I_File); + String_Replace(Line, Pattern, Replacement); + Ada.Text_IO.Put_Line(O_File, -Line); + end loop; + Ada.Text_IO.Close(I_File); + Ada.Text_IO.Close(O_File); + Ada.Directories.Delete_File(Filename); + Ada.Directories.Rename(Old_Name => Tmp_Name, New_Name => Filename); + end File_Replace; + + Pattern: String := Ada.Command_Line.Argument(1); + Replacement: String := Ada.Command_Line.Argument(2); + +begin + Ada.Text_IO.Put_Line("Replacing """ & Pattern + & """ by """ & Replacement & """ in" + & Integer'Image(Ada.Command_Line.Argument_Count - 2) + & " files."); + for I in 3 .. Ada.Command_Line.Argument_Count loop + File_Replace(Ada.Command_Line.Argument(I), Pattern, Replacement); + end loop; +end Global_Replace; diff --git a/Task/Globally-replace-text-in-several-files/AutoHotkey/globally-replace-text-in-several-files.ahk b/Task/Globally-replace-text-in-several-files/AutoHotkey/globally-replace-text-in-several-files.ahk new file mode 100644 index 0000000000..5b062b0302 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/AutoHotkey/globally-replace-text-in-several-files.ahk @@ -0,0 +1,10 @@ +SetWorkingDir %A_ScriptDir% ; Change the working directory to the script's location +listFiles := "a.txt|b.txt|c.txt" ; Define a list of files in the current working directory +loop, Parse, listFiles, | +{ + ; The above parses the list based on the | character + fileread, contents, %A_LoopField% ; Read the file + fileDelete, %A_LoopField% ; Delete the file + stringReplace, contents, contents, Goodbye London!, Hello New York!, All ; replace all occurrences + fileAppend, %contents%, %A_LoopField% ; Re-create the file with new contents +} diff --git a/Task/Globally-replace-text-in-several-files/BASIC/globally-replace-text-in-several-files.bas b/Task/Globally-replace-text-in-several-files/BASIC/globally-replace-text-in-several-files.bas new file mode 100644 index 0000000000..466733029b --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/BASIC/globally-replace-text-in-several-files.bas @@ -0,0 +1,38 @@ +CONST matchtext = "Goodbye London!" +CONST repltext = "Hello New York!" +CONST matchlen = LEN(matchtext) + +DIM L0 AS INTEGER, x AS INTEGER, filespec AS STRING, linein AS STRING + +L0 = 1 +WHILE LEN(COMMAND$(L0)) + filespec = DIR$(COMMAND$(L0)) + WHILE LEN(filespec) + OPEN filespec FOR BINARY AS 1 + linein = SPACE$(LOF(1)) + GET #1, 1, linein + DO + x = INSTR(linein, matchtext) + IF x THEN + linein = LEFT$(linein, x - 1) & repltext & MID$(linein, x + matchlen) + ' If matchtext and repltext are of equal length (as in this example) + ' then you can replace the above line with this: + ' MID$(linein, x) = repltext + ' This is somewhat more efficient than having to rebuild the string. + ELSE + EXIT DO + END IF + LOOP + ' If matchtext and repltext are of equal length (as in this example), or repltext + ' is longer than matchtext, you could just write back to the file while it's open + ' in BINARY mode, like so: + ' PUT #1, 1, linein + ' But since there's no way to reduce the file size via BINARY and PUT, we do this: + CLOSE + OPEN filespec FOR OUTPUT AS 1 + PRINT #1, linein; + CLOSE + filespec = DIR$ + WEND + L0 += 1 +WEND diff --git a/Task/Globally-replace-text-in-several-files/BBC-BASIC/globally-replace-text-in-several-files.bbc b/Task/Globally-replace-text-in-several-files/BBC-BASIC/globally-replace-text-in-several-files.bbc new file mode 100644 index 0000000000..2ba89c1941 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/BBC-BASIC/globally-replace-text-in-several-files.bbc @@ -0,0 +1,30 @@ + FindThis$ = "Goodbye London!" + ReplaceWith$ = "Hello New York!" + + DIM Files$(3) + Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt" + + FOR f% = 0 TO DIM(Files$(),1) + infile$ = Files$(f%) + infile% = OPENIN(infile$) + IF infile%=0 ERROR 100, "Failed to open file " + infile$ + tmpfile$ = @tmp$+"replace.txt" + tmpfile% = OPENOUT(tmpfile$) + + WHILE NOT EOF#infile% + INPUT #infile%, a$ + IF ASCa$=10 a$ = MID$(a$,2) + l% = LEN(FindThis$) + REPEAT + here% = INSTR(a$, FindThis$) + IF here% a$ = LEFT$(a$,here%-1) + ReplaceWith$ + MID$(a$,here%+l%) + UNTIL here% = 0 + PRINT #tmpfile%, a$ : BPUT #tmpfile%,10 + ENDWHILE + CLOSE #infile% + CLOSE #tmpfile% + + OSCLI "DEL """ + infile$ + """" + OSCLI "REN """ + tmpfile$ + """ """ + infile$ + """" + NEXT + END diff --git a/Task/Globally-replace-text-in-several-files/C++/globally-replace-text-in-several-files.cpp b/Task/Globally-replace-text-in-several-files/C++/globally-replace-text-in-several-files.cpp new file mode 100644 index 0000000000..30bc9a8488 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/C++/globally-replace-text-in-several-files.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +int main( int argc , char *argv[ ] ) { + boost::regex to_be_replaced( "Goodbye London\\s*!" ) ; + std::string replacement( "Hello New York!" ) ; + for ( int i = 1 ; i < argc ; i++ ) { + std::ifstream infile ( argv[ i ] ) ; + if ( infile ) { + std::string filetext( (std::istreambuf_iterator( infile )) , + std::istreambuf_iterator( ) ) ; + std::string changed ( boost::regex_replace( filetext , to_be_replaced , replacement )) ; + infile.close( ) ; + std::ofstream outfile( argv[ i ] , std::ios_base::out | std::ios_base::trunc ) ; + if ( outfile.is_open( ) ) { + outfile << changed ; + outfile.close( ) ; + } + } + else + std::cout << "Can't find file " << argv[ i ] << " !\n" ; + } + return 0 ; +} diff --git a/Task/Globally-replace-text-in-several-files/C/globally-replace-text-in-several-files.c b/Task/Globally-replace-text-in-several-files/C/globally-replace-text-in-several-files.c new file mode 100644 index 0000000000..bc077a36bf --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/C/globally-replace-text-in-several-files.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len) +{ + ptrdiff_t i; + char *start = buf; + while (start + len < buf_end) { + for (i = 0; i < len; i++) + if (start[i] != pat[i]) break; + + if (i == len) return (char *)start; + start++; + } + return 0; +} + +int replace(const char *from, const char *to, const char *fname) +{ +#define bail(msg) { warn(msg" '%s'", fname); goto done; } + struct stat st; + int ret = 0; + char *buf = 0, *start, *end; + size_t len = strlen(from), nlen = strlen(to); + int fd = open(fname, O_RDWR); + + if (fd == -1) bail("Can't open"); + if (fstat(fd, &st) == -1) bail("Can't stat"); + if (!(buf = malloc(st.st_size))) bail("Can't alloc"); + if (read(fd, buf, st.st_size) != st.st_size) bail("Bad read"); + + start = buf; + end = find_match(start, buf + st.st_size, from, len); + if (!end) goto done; /* no match found, don't change file */ + + ftruncate(fd, 0); + lseek(fd, 0, 0); + do { + write(fd, start, end - start); /* write content before match */ + write(fd, to, nlen); /* write replacement of match */ + start = end + len; /* skip to end of match */ + /* find match again */ + end = find_match(start, buf + st.st_size, from, len); + } while (end); + + /* write leftover after last match */ + if (start < buf + st.st_size) + write(fd, start, buf + st.st_size - start); + +done: + if (fd != -1) close(fd); + if (buf) free(buf); + return ret; +} + +int main() +{ + const char *from = "Goodbye, London!"; + const char *to = "Hello, New York!"; + const char * files[] = { "test1.txt", "test2.txt", "test3.txt" }; + int i; + + for (i = 0; i < sizeof(files)/sizeof(char*); i++) + replace(from, to, files[i]); + + return 0; +} diff --git a/Task/Globally-replace-text-in-several-files/D/globally-replace-text-in-several-files.d b/Task/Globally-replace-text-in-several-files/D/globally-replace-text-in-several-files.d new file mode 100644 index 0000000000..d81eca33e2 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/D/globally-replace-text-in-several-files.d @@ -0,0 +1,8 @@ +import std.file, std.array; + +void main() { + auto from = "Goodbye London!", to = "Hello, New York!"; + foreach (fn; "a.txt b.txt c.txt".split()) { + write(fn, replace(cast(string)read(fn), from, to)); + } +} diff --git a/Task/Globally-replace-text-in-several-files/Go/globally-replace-text-in-several-files.go b/Task/Globally-replace-text-in-several-files/Go/globally-replace-text-in-several-files.go new file mode 100644 index 0000000000..4b74d62377 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Go/globally-replace-text-in-several-files.go @@ -0,0 +1,51 @@ +package main + +import ( + "bytes" + "io/ioutil" + "log" + "os" +) + +func main() { + gRepNFiles("Goodbye London!", "Hello New York!", []string{ + "a.txt", + "b.txt", + "c.txt", + }) +} + +func gRepNFiles(olds, news string, files []string) { + oldb := []byte(olds) + newb := []byte(news) + for _, fn := range files { + if err := gRepFile(oldb, newb, fn); err != nil { + log.Println(err) + } + } +} + +func gRepFile(oldb, newb []byte, fn string) (err error) { + var f *os.File + if f, err = os.OpenFile(fn, os.O_RDWR, 0); err != nil { + return + } + defer func() { + if cErr := f.Close(); err == nil { + err = cErr + } + }() + var b []byte + if b, err = ioutil.ReadAll(f); err != nil { + return + } + if bytes.Index(b, oldb) < 0 { + return + } + r := bytes.Replace(b, oldb, newb, -1) + if err = f.Truncate(0); err != nil { + return + } + _, err = f.WriteAt(r, 0) + return +} diff --git a/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-1.hs b/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-1.hs new file mode 100644 index 0000000000..c94d726fc6 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-1.hs @@ -0,0 +1,21 @@ +import Data.List (tails, elemIndices, isPrefixOf) + +replace :: String -> String -> String -> String +replace [] _ xs = xs +replace _ [] xs = xs +replace _ _ [] = [] +replace a b xs = replAll + where + -- make substrings, dropping one element each time + xtails = tails xs + -- what substrings begin with the string to replace? + -- get their indices + matches = elemIndices True $ map (isPrefixOf a) xtails + -- replace one occurrence + repl ys n = take n ys ++ b ++ drop (n + length b) ys + -- replace all occurrences consecutively + replAll = foldl repl xs matches + +replaceInFiles a1 a2 files = do + f <- mapM readFile files + return $ map (replace a1 a2) f diff --git a/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-2.hs b/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-2.hs new file mode 100644 index 0000000000..8cecb85b36 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Haskell/globally-replace-text-in-several-files-2.hs @@ -0,0 +1,5 @@ +replace _ _ [] = [] +replace a b xx@(x:xs) = + if isPrefixOf a xx + then b ++ replace a b (drop (length a) xx) + else x : replace a b xs diff --git a/Task/Globally-replace-text-in-several-files/Icon/globally-replace-text-in-several-files.icon b/Task/Globally-replace-text-in-several-files/Icon/globally-replace-text-in-several-files.icon new file mode 100644 index 0000000000..7809bb0c23 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Icon/globally-replace-text-in-several-files.icon @@ -0,0 +1,15 @@ +procedure main() +globalrepl("Goodbye London","Hello New York","a.txt","b.txt") # variable args for files +end + +procedure globalrepl(old,new,files[]) + +every fn := !files do + if s := reads(f := open(fn,"bu"),stat(f).size) then { + writes(seek(f,1),replace(s,old,new)) + close(f) + } + else write(&errout,"Unable to open ",fn) +end + +link strings # for replace diff --git a/Task/Globally-replace-text-in-several-files/J/globally-replace-text-in-several-files.j b/Task/Globally-replace-text-in-several-files/J/globally-replace-text-in-several-files.j new file mode 100644 index 0000000000..f5bc81c868 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/J/globally-replace-text-in-several-files.j @@ -0,0 +1,2 @@ +require'strings' +(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files diff --git a/Task/Globally-replace-text-in-several-files/Liberty-BASIC/globally-replace-text-in-several-files.liberty b/Task/Globally-replace-text-in-several-files/Liberty-BASIC/globally-replace-text-in-several-files.liberty new file mode 100644 index 0000000000..1a77066c52 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Liberty-BASIC/globally-replace-text-in-several-files.liberty @@ -0,0 +1,36 @@ +nomainwin + +file$( 1) ="data1.txt" +file$( 2) ="data2.txt" +file$( 3) ="data3.txt" + + +for i =1 to 3 + open file$( i) for input as #i + orig$ =input$( #i, lof( #i)) + close #i + + dummy$ =FindReplace$( orig$, "Goodbye London!", "Hello New York!", 1) + + open "RC" +file$( i) for output as #o + #o dummy$; + close #o +next i + +end + +function FindReplace$( FindReplace$, find$, replace$, replaceAll) +' Target string, string to find, string to replace it with, flag 0/1 for 'replace all occurrences'. + if ( ( FindReplace$ <>"") and ( find$ <>"") ) then + fLen =len( find$) + rLen =len( replace$) + do + fPos =instr( FindReplace$, find$, fPos) + if not( fPos) then exit function + pre$ =left$( FindReplace$, fPos -1) + post$ =mid$( FindReplace$, fPos +fLen) + FindReplace$ =pre$ +replace$ +post$ + fPos =fPos +( rLen -fLen) +1 + loop while (replaceAll) + end if +end function diff --git a/Task/Globally-replace-text-in-several-files/Lua/globally-replace-text-in-several-files.lua b/Task/Globally-replace-text-in-several-files/Lua/globally-replace-text-in-several-files.lua new file mode 100644 index 0000000000..80df753965 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Lua/globally-replace-text-in-several-files.lua @@ -0,0 +1,12 @@ +filenames = { "f1.txt", "f2.txt" } + +for _, fn in pairs( filenames ) do + fp = io.open( fn, "r" ) + str = fp:read( "*all" ) + str = string.gsub( str, "Goodbye London!", "Hello New York!" ) + fp:close() + + fp = io.open( fn, "w+" ) + fp:write( str ) + fp:close() +end diff --git a/Task/Globally-replace-text-in-several-files/Perl/globally-replace-text-in-several-files.pl b/Task/Globally-replace-text-in-several-files/Perl/globally-replace-text-in-several-files.pl new file mode 100644 index 0000000000..6a6819ef97 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Perl/globally-replace-text-in-several-files.pl @@ -0,0 +1 @@ +perl -pi -e "s/Goodbye London\!/Hello New York\!/g;" a.txt b.txt c.txt diff --git a/Task/Globally-replace-text-in-several-files/PicoLisp/globally-replace-text-in-several-files.l b/Task/Globally-replace-text-in-several-files/PicoLisp/globally-replace-text-in-several-files.l new file mode 100644 index 0000000000..c43904ff23 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/PicoLisp/globally-replace-text-in-several-files.l @@ -0,0 +1,6 @@ +(for File '(a.txt b.txt c.txt) + (call 'mv File (tmp File)) + (out File + (in (tmp File) + (while (echo "Goodbye London!") + (prin "Hello New York!") ) ) ) ) diff --git a/Task/Globally-replace-text-in-several-files/Python/globally-replace-text-in-several-files.py b/Task/Globally-replace-text-in-several-files/Python/globally-replace-text-in-several-files.py new file mode 100644 index 0000000000..f84cb27e4d --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Python/globally-replace-text-in-several-files.py @@ -0,0 +1,4 @@ +import fileinput + +for line in fileinput.input(inplace=True): + print(line.replace('Goodbye London!', 'Hello New York!'), end='') diff --git a/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-1.rexx b/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-1.rexx new file mode 100644 index 0000000000..927d3ee7e2 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-1.rexx @@ -0,0 +1,28 @@ +/*REXX program to read the files specified and globally replace a string*/ +old = 'Goodbye London!' /*old text to be replaced. */ +new = 'Hello New York!' /*new text used for replacement. */ +parse arg fileList; files=words(fileList); pad=left('',20) + hdr='────── file' /*eyecatcher.*/ + do f=1 for files; aFile=translate(word(fileList,f),,','); say; say + say hdr' is being read: ' aFile pad "("f 'out of' files "files)." + call linein aFile,1,0 /*position the file for input. */ + changes=0 /*# changes in the file (so far).*/ + + do j=1 while lines(aFile)\==0 /*read a file (if it exists). */ + @.j = linein(aFile) /*read a record from the file. */ + if pos(old,@.j)==0 then iterate /*Anything to change? No, skip.*/ + changes = changes+1 /*bump the change counter. */ + @.j = changestr(old,@.j,new) /*change this record, old ──► new*/ + end /*j*/ + + say hdr ' was read: ' aFile", with " j-1 'records.' + if changes == 0 then do + say hdr ' not changed: ' aFile + iterate /*f*/ + end + call lineout aFile,,1 /*position the file for output. */ + say hdr 'being changed: ' aFile + do r=1 for j-1; call lineout aFile,@.r; end /*re-write file.*/ + say hdr 'was changed: ' aFile " with" changes 'lines changed.' + end /*f*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-2.rexx b/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-2.rexx new file mode 100644 index 0000000000..87cbb1dbe6 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/REXX/globally-replace-text-in-several-files-2.rexx @@ -0,0 +1,92 @@ +/* REXX *************************************************************** +* Copy all files *.txt to *.rpl +* replacing all occurrences of old by new +* Execute in the directory containing the files to ne processed +* 16.01.2013 Walter Pachl +* ...if file names contain blanks +**********************************************************************/ +Parse Arg a +If a='?' Then Do + Do i=2 To 5 + Say substr(sourceline(i),3) + End + Exit + End +'dir *.rpl' +Say 'May I erase *.rpl?' +Parse Upper Pull answer +If answer='Y' | answer='J' Then + 'erase *.rpl' +Else Do + Say 'Giving up..' + Exit + End +old='Goodbye London!' +new='Hello New York!' +dir='dir.dir' +'dir *.* >' dir +Do While lines(dir)>0 + Parse Value linein(dir) With 37 f + Select + When f='' |, + left(f,1)='.' |, + pos(' Bytes',f)>0 Then Iterate + When right(f,4)='.txt' Then + Call replace + Otherwise + Say left(f,50) 'not eligible for replacing' + End + End +Exit + +replace: +/* REXX *************************************************************** +* Copy a file fn.txt to fn.rpl +* replacing all occurrences of old by new +**********************************************************************/ +oid=fn(f)'.rpl' +cnt.=0 +Do ii=1 By 1 While lines(f)>0 + l=linein(f) + ol=repl(l,new,old) + Call lineout oid,ol + End +Call lineout f +Call lineout oid +Select + When cnt.0changes=0 Then Do + 'erase' oid + Say left(f,50) 'no changes' + End + When cnt.0changes=1 Then + Say left(f,50) '1 change' + Otherwise + Say left(f '->' oid,50) cnt.0changes 'changes' + End +Return + +fn: Procedure +/* REXX *************************************************************** +* Get the file name of a file id +**********************************************************************/ +parse Arg fid +Parse Var fid fn '.' ft +Return fn + +repl: Procedure Expose cnt. +/* REXX *************************************************************** +* Replace an old string by a new one +**********************************************************************/ + Parse Arg s,new,old + ol='' + Do Until p=0 + p=pos(old,s) + If p>0 Then Do + ol=ol||left(s,p-1)||new + s=substr(s,p+length(old)) + cnt.0changes=cnt.0changes+1 + End + Else + ol=ol||s + End + Return ol diff --git a/Task/Globally-replace-text-in-several-files/Tcl/globally-replace-text-in-several-files.tcl b/Task/Globally-replace-text-in-several-files/Tcl/globally-replace-text-in-several-files.tcl new file mode 100644 index 0000000000..324f10d983 --- /dev/null +++ b/Task/Globally-replace-text-in-several-files/Tcl/globally-replace-text-in-several-files.tcl @@ -0,0 +1,15 @@ +package require Tcl 8.5 +package require fileutil + +# Parameters to the replacement +set from "Goodbye London!" +set to "Hello New York!" +# Which files to replace +set fileList [list a.txt b.txt c.txt] + +# Make a command fragment that performs the replacement on a supplied string +set replacementCmd [list string map [list $from $to]] +# Apply the replacement to the contents of each file +foreach filename $fileList { + fileutil::updateInPlace $filename $replacementCmd +} diff --git a/Task/Gray-code/0DESCRIPTION b/Task/Gray-code/0DESCRIPTION new file mode 100644 index 0000000000..e526d86fbe --- /dev/null +++ b/Task/Gray-code/0DESCRIPTION @@ -0,0 +1,21 @@ +[[wp:Gray code|Gray code]] is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is also useful for generating inputs for [[wp:Karnaugh map|Karnaugh maps]] in order from left to right or top to bottom. + +Create functions to encode a number to and decode a number from Gray code. Display the normal binary representations, Gray code representations, and decoded Gray code values for all 5-bit binary numbers (0-31 inclusive, leading 0's not necessary). + +There are many possible Gray codes. The following encodes what is called "binary reflected Gray code." + +Encoding (MSB is bit 0, b is binary, g is Gray code): +
if b[i-1] = 1
+   g[i] = not b[i]
+else
+   g[i] = b[i]
+Or: +
g = b xor (b logically right shifted 1 time)
+Decoding (MSB is bit 0, b is binary, g is Gray code): +
b[0] = g[0]
+
+for other bits:
+b[i] = g[i] xor b[i-1]
+ +;Reference +* [http://www.wisc-online.com/Objects/ViewObject.aspx?ID=IAU8307 Converting Between Gray and Binary Codes]. It includes step-by-step animations. diff --git a/Task/Gray-code/Ada/gray-code.ada b/Task/Gray-code/Ada/gray-code.ada new file mode 100644 index 0000000000..49d5eda70b --- /dev/null +++ b/Task/Gray-code/Ada/gray-code.ada @@ -0,0 +1,47 @@ +with Ada.Text_IO, Interfaces; +use Ada.Text_IO, Interfaces; + +procedure Gray is + + Bits : constant := 5; -- Change only this line for 6 or 7-bit encodings + subtype Values is Unsigned_8 range 0 .. 2 ** Bits - 1; + package Values_Io is new Ada.Text_IO.Modular_IO (Values); + + function Encode (Binary : Values) return Values is + begin + return Binary xor Shift_Right (Binary, 1); + end Encode; + pragma Inline (Encode); + + function Decode (Gray : Values) return Values is + Binary, Bit : Values; + Mask : Values := 2 ** (Bits - 1); + begin + Bit := Gray and Mask; + Binary := Bit; + for I in 2 .. Bits loop + Bit := Shift_Right (Bit, 1); + Mask := Shift_Right (Mask, 1); + Bit := (Gray and Mask) xor Bit; + Binary := Binary + Bit; + end loop; + return Binary; + end Decode; + pragma Inline (Decode); + + HT : constant Character := Character'Val (9); + J : Values; +begin + Put_Line ("Num" & HT & "Binary" & HT & HT & "Gray" & HT & HT & "decoded"); + for I in Values'Range loop + J := Encode (I); + Values_Io.Put (I, 4); + Put (": " & HT); + Values_Io.Put (I, Bits + 2, 2); + Put (" =>" & HT); + Values_Io.Put (J, Bits + 2, 2); + Put (" => " & HT); + Values_Io.Put (Decode (J), 4); + New_Line; + end loop; +end Gray; diff --git a/Task/Gray-code/AutoHotkey/gray-code.ahk b/Task/Gray-code/AutoHotkey/gray-code.ahk new file mode 100644 index 0000000000..858b66fd88 --- /dev/null +++ b/Task/Gray-code/AutoHotkey/gray-code.ahk @@ -0,0 +1,23 @@ +gray_encode(n){ + return n ^ (n >> 1) +} + +gray_decode(n){ + p := n + while (n >>= 1) + p ^= n + return p +} + +BinString(n){ + Loop 5 + If ( n & ( 1 << (A_Index-1) ) ) + o := "1" . o + else o := "0" . o + return o +} + +Loop 32 + n:=A_Index-1, out .= n " : " BinString(n) " => " BinString(e:=gray_encode(n)) + . " => " BinString(gray_decode(e)) " => " BinString(n) "`n" +MsgBox % clipboard := out diff --git a/Task/Gray-code/BBC-BASIC/gray-code.bbc b/Task/Gray-code/BBC-BASIC/gray-code.bbc new file mode 100644 index 0000000000..534f47439b --- /dev/null +++ b/Task/Gray-code/BBC-BASIC/gray-code.bbc @@ -0,0 +1,15 @@ + INSTALL @lib$+"STRINGLIB" + + PRINT " Decimal Binary Gray Decoded" + FOR number% = 0 TO 31 + gray% = FNgrayencode(number%) + PRINT number% " " FN_tobase(number%, 2, 5) ; + PRINT " " FN_tobase(gray%, 2, 5) FNgraydecode(gray%) + NEXT + END + + DEF FNgrayencode(B%) = B% EOR (B% >>> 1) + + DEF FNgraydecode(G%) : LOCAL B% + REPEAT B% EOR= G% : G% = G% >>> 1 : UNTIL G% = 0 + = B% diff --git a/Task/Gray-code/C++/gray-code.cpp b/Task/Gray-code/C++/gray-code.cpp new file mode 100644 index 0000000000..fb9d327a02 --- /dev/null +++ b/Task/Gray-code/C++/gray-code.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + +uint32_t gray_encode(uint32_t b) +{ + return b ^ (b >> 1); +} + +uint32_t gray_decode(uint32_t g) +{ + for (uint32_t bit = 1U << 31; bit > 1; bit >>= 1) + { + if (g & bit) g ^= bit >> 1; + } + return g; +} + +std::string to_binary(int value) // utility function +{ + const std::bitset<32> bs(value); + const std::string str(bs.to_string()); + const size_t pos(str.find('1')); + return pos == std::string::npos ? "0" : str.substr(pos); +} + +int main() +{ + std::cout << "Number\tBinary\tGray\tDecoded\n"; + for (uint32_t n = 0; n < 32; ++n) + { + uint32_t g = gray_encode(n); + uint32_t b = gray_decode(g); + + std::cout << n << "\t" << to_binary(n) << "\t" << to_binary(g) << "\t" << b << "\n"; + } +} diff --git a/Task/Gray-code/C-sharp/gray-code.cs b/Task/Gray-code/C-sharp/gray-code.cs new file mode 100644 index 0000000000..04b8fdc549 --- /dev/null +++ b/Task/Gray-code/C-sharp/gray-code.cs @@ -0,0 +1,23 @@ +using System; + +public class Gray { + public static ulong grayEncode(ulong n) { + return n^(n>>1); + } + + public static ulong grayDecode(ulong n) { + ulong i=1<<8*64-2; //long is 64-bit + ulong p, b=p=n&i; + + while((i>>=1)>0) + b|=p=n&i^p>>1; + return b; + } + + public static void Main(string[] args) { + Console.WriteLine("Number\tBinary\tGray\tDecoded"); + for(ulong i=0;i<32;i++) { + Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}", i, Convert.ToString((long)i, 2), Convert.ToString((long)grayEncode(i), 2), grayDecode(grayEncode(i)))); + } + } +} diff --git a/Task/Gray-code/C/gray-code-1.c b/Task/Gray-code/C/gray-code-1.c new file mode 100644 index 0000000000..d03463fc53 --- /dev/null +++ b/Task/Gray-code/C/gray-code-1.c @@ -0,0 +1,9 @@ +int gray_encode(int n) { + return n ^ (n >> 1); +} + +int gray_decode(int n) { + int p = n; + while (n >>= 1) p ^= n; + return p; +} diff --git a/Task/Gray-code/C/gray-code-2.c b/Task/Gray-code/C/gray-code-2.c new file mode 100644 index 0000000000..c260e31906 --- /dev/null +++ b/Task/Gray-code/C/gray-code-2.c @@ -0,0 +1,24 @@ +#include + +/* Simple bool formatter, only good on range 0..31 */ +void fmtbool(int n, char *buf) { + char *b = buf + 5; + *b=0; + do { + *--b = '0' + (n & 1); + n >>= 1; + } while (b != buf); +} + +int main(int argc, char **argv) { + int i,g,b; + char bi[6],bg[6],bb[6]; + + for (i=0 ; i<32 ; i++) { + g = gray_encode(i); + b = gray_decode(g); + fmtbool(i,bi); fmtbool(g,bg); fmtbool(b,bb); + printf("%2d : %5s => %5s => %5s : %2d\n", i, bi, bg, bb, b); + } + return 0; +} diff --git a/Task/Gray-code/CoffeeScript/gray-code.coffee b/Task/Gray-code/CoffeeScript/gray-code.coffee new file mode 100644 index 0000000000..efb98bee83 --- /dev/null +++ b/Task/Gray-code/CoffeeScript/gray-code.coffee @@ -0,0 +1,10 @@ +gray_encode = (n) -> + n ^ (n >> 1) + +gray_decode = (g) -> + n = g + n ^= g while g >>= 1 + n + +for i in [0..32] + console.log gray_decode gray_encode(i) diff --git a/Task/Gray-code/Common-Lisp/gray-code.lisp b/Task/Gray-code/Common-Lisp/gray-code.lisp new file mode 100644 index 0000000000..9caa2a55f1 --- /dev/null +++ b/Task/Gray-code/Common-Lisp/gray-code.lisp @@ -0,0 +1,11 @@ +(defun gray-encode (n) + (logxor n (ash n -1))) + +(defun gray-decode (n) + (do ((p n (logxor p n))) + ((zerop n) p) + (setf n (ash n -1)))) + +(loop for i to 31 do + (let* ((g (gray-encode i)) (b (gray-decode g))) + (format t "~2d:~6b =>~6b =>~6b :~2d~%" i i g b b))) diff --git a/Task/Gray-code/D/gray-code-1.d b/Task/Gray-code/D/gray-code-1.d new file mode 100644 index 0000000000..db8eb9bf63 --- /dev/null +++ b/Task/Gray-code/D/gray-code-1.d @@ -0,0 +1,23 @@ +import std.stdio; + +T enGray(T)(in T n) pure nothrow { + return n ^ (n >>> 1); +} + +T deGray(T)(in T n) pure nothrow { + enum T MSB = (cast(T)1) << (T.sizeof * 8 - 1); + + auto res = (n & MSB) ; + foreach (bit; 1 .. T.sizeof * 8) + res += (n ^ (res >>> 1)) & (MSB >>> bit); + return res; +} + +void main() { + writeln("num bits encoded decoded"); + foreach (i; 0 .. 32) { + immutable encoded = enGray(i); + writefln("%2d: %5b ==> %5b : %2d", + i, i, encoded, deGray(encoded)); + } +} diff --git a/Task/Gray-code/D/gray-code-2.d b/Task/Gray-code/D/gray-code-2.d new file mode 100644 index 0000000000..8d1cd3ba43 --- /dev/null +++ b/Task/Gray-code/D/gray-code-2.d @@ -0,0 +1,37 @@ +import std.stdio, std.conv, std.algorithm; + +T[] gray(int N : 1, T)() { return [to!T(0), 1]; } + +/// recursively generate gray encoding mapping table +T[] gray(int N, T)() pure nothrow { + assert(N <= T.sizeof * 8, "N exceed number of bit of T"); + enum T M = to!T(2) ^^ (N - 1); + T[] g = gray!(N - 1, T)(); + foreach (i; 0 .. M) + g ~= M + g[M - i - 1]; + return g; +} + +T[][] grayDict(int N, T)() { + T[][] dict = [gray!(N, T)(), [0]]; + // append inversed gray encoding mapping + foreach (i; 1 .. dict[0].length) + dict[1] ~= countUntil(dict[0], i); + return dict; +} + +enum M { Encode = 0, Decode = 1 }; + +T gray(int N, T)(in T n, in int mode=M.Encode) { + // generated at compile time + enum dict = grayDict!(N, T)(); + return dict[mode][n]; +} + +void main() { + foreach (i; 0 .. 32) { + immutable encoded = gray!(5)(i, M.Encode); + immutable decoded = gray!(5)(encoded, M.Decode); + writefln("%2d: %5b => %5b : %2d", i, i, encoded, decoded); + } +} diff --git a/Task/Gray-code/D/gray-code-3.d b/Task/Gray-code/D/gray-code-3.d new file mode 100644 index 0000000000..d9300f9c87 --- /dev/null +++ b/Task/Gray-code/D/gray-code-3.d @@ -0,0 +1,11 @@ +import std.stdio, std.algorithm, std.range; + +string[] g(in uint n) /*pure nothrow*/ { + return n ? g(n - 1).map!q{'0' ~ a}().array() ~ + g(n - 1).retro().map!q{'1' ~ a}().array() + : [""]; +} + +void main() { + writeln(g(4)); +} diff --git a/Task/Gray-code/DWScript/gray-code.dwscript b/Task/Gray-code/DWScript/gray-code.dwscript new file mode 100644 index 0000000000..4c8d548247 --- /dev/null +++ b/Task/Gray-code/DWScript/gray-code.dwscript @@ -0,0 +1,23 @@ +function Encode(v : Integer) : Integer; +begin + Result := v xor (v shr 1); +end; + +function Decode(v : Integer) : Integer; +begin + Result := 0; + while v>0 do begin + Result := Result xor v; + v := v shr 1; + end; +end; + +PrintLn('decimal binary gray decoded'); + +var i : Integer; +for i:=0 to 31 do begin + var g := Encode(i); + var d := Decode(g); + PrintLn(Format(' %2d %s %s %s %2d', + [i, IntToBin(i, 5), IntToBin(g, 5), IntToBin(d, 5), d])); +end; diff --git a/Task/Gray-code/Delphi/gray-code.delphi b/Task/Gray-code/Delphi/gray-code.delphi new file mode 100644 index 0000000000..8135e559a3 --- /dev/null +++ b/Task/Gray-code/Delphi/gray-code.delphi @@ -0,0 +1,45 @@ +program GrayCode; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +function Encode(v: Integer): Integer; +begin + Result := v xor (v shr 1); +end; + +function Decode(v: Integer): Integer; +begin + Result := 0; + while v > 0 do + begin + Result := Result xor v; + v := v shr 1; + end; +end; + +function IntToBin(aValue: LongInt; aDigits: Integer): string; +begin + Result := StringOfChar('0', aDigits); + while aValue > 0 do + begin + if (aValue and 1) = 1 then + Result[aDigits] := '1'; + Dec(aDigits); + aValue := aValue shr 1; + end; +end; + +var + i, g, d: Integer; +begin + Writeln('decimal binary gray decoded'); + + for i := 0 to 31 do + begin + g := Encode(i); + d := Decode(g); + Writeln(Format(' %2d %s %s %s %2d', [i, IntToBin(i, 5), IntToBin(g, 5), IntToBin(d, 5), d])); + end; +end. diff --git a/Task/Gray-code/Erlang/gray-code-1.erl b/Task/Gray-code/Erlang/gray-code-1.erl new file mode 100644 index 0000000000..b4d9d60082 --- /dev/null +++ b/Task/Gray-code/Erlang/gray-code-1.erl @@ -0,0 +1,9 @@ +-module(gray). +-export([encode/1, decode/1]). + +encode(N) -> N bxor (N bsr 1). + +decode(G) -> decode(G,0). + +decode(0,N) -> N; +decode(G,N) -> decode(G bsr 1, G bxor N). diff --git a/Task/Gray-code/Erlang/gray-code-2.erl b/Task/Gray-code/Erlang/gray-code-2.erl new file mode 100644 index 0000000000..84a8d87e83 --- /dev/null +++ b/Task/Gray-code/Erlang/gray-code-2.erl @@ -0,0 +1,11 @@ +-module(testgray). + +test_encode(N) -> + G = gray:encode(N), + D = gray:decode(G), + io:fwrite("~2B : ~5.2.0B : ~5.2.0B : ~5.2.0B : ~2B~n", [N, N, G, D, D]). + +test_encode(N, N) -> []; +test_encode(I, N) when I < N -> test_encode(I), test_encode(I+1, N). + +main(_) -> test_encode(0,32). diff --git a/Task/Gray-code/Euphoria/gray-code.euphoria b/Task/Gray-code/Euphoria/gray-code.euphoria new file mode 100644 index 0000000000..de7e45db6e --- /dev/null +++ b/Task/Gray-code/Euphoria/gray-code.euphoria @@ -0,0 +1,34 @@ +function gray_encode(integer n) + return xor_bits(n,floor(n/2)) +end function + +function gray_decode(integer n) + integer g + g = 0 + while n > 0 do + g = xor_bits(g,n) + n = floor(n/2) + end while + return g +end function + +function dcb(integer n) + atom d,m + d = 0 + m = 1 + while n do + d += remainder(n,2)*m + n = floor(n/2) + m *= 10 + end while + return d +end function + +integer j +for i = #0 to #1F do + printf(1,"%05d => ",dcb(i)) + j = gray_encode(i) + printf(1,"%05d => ",dcb(j)) + j = gray_decode(j) + printf(1,"%05d\n",dcb(j)) +end for diff --git a/Task/Gray-code/Factor/gray-code-1.factor b/Task/Gray-code/Factor/gray-code-1.factor new file mode 100644 index 0000000000..35cf7850c5 --- /dev/null +++ b/Task/Gray-code/Factor/gray-code-1.factor @@ -0,0 +1,16 @@ +USING: math.ranges locals ; +IN: rosetta-gray + +: gray-encode ( n -- n' ) dup -1 shift bitxor ; + +:: gray-decode ( n! -- n' ) + n :> p! + [ n -1 shift dup n! 0 = not ] [ + p n bitxor p! + ] while + p ; + +: main ( -- ) + -1 32 [a,b] [ dup [ >bin ] [ gray-encode ] bi [ >bin ] [ gray-decode ] bi 4array . ] each ; + +MAIN: main diff --git a/Task/Gray-code/Factor/gray-code-2.factor b/Task/Gray-code/Factor/gray-code-2.factor new file mode 100644 index 0000000000..0373e2cfa3 --- /dev/null +++ b/Task/Gray-code/Factor/gray-code-2.factor @@ -0,0 +1,34 @@ +{ -1 "-1" "0" 0 } +{ 0 "0" "0" 0 } +{ 1 "1" "1" 1 } +{ 2 "10" "11" 2 } +{ 3 "11" "10" 3 } +{ 4 "100" "110" 4 } +{ 5 "101" "111" 5 } +{ 6 "110" "101" 6 } +{ 7 "111" "100" 7 } +{ 8 "1000" "1100" 8 } +{ 9 "1001" "1101" 9 } +{ 10 "1010" "1111" 10 } +{ 11 "1011" "1110" 11 } +{ 12 "1100" "1010" 12 } +{ 13 "1101" "1011" 13 } +{ 14 "1110" "1001" 14 } +{ 15 "1111" "1000" 15 } +{ 16 "10000" "11000" 16 } +{ 17 "10001" "11001" 17 } +{ 18 "10010" "11011" 18 } +{ 19 "10011" "11010" 19 } +{ 20 "10100" "11110" 20 } +{ 21 "10101" "11111" 21 } +{ 22 "10110" "11101" 22 } +{ 23 "10111" "11100" 23 } +{ 24 "11000" "10100" 24 } +{ 25 "11001" "10101" 25 } +{ 26 "11010" "10111" 26 } +{ 27 "11011" "10110" 27 } +{ 28 "11100" "10010" 28 } +{ 29 "11101" "10011" 29 } +{ 30 "11110" "10001" 30 } +{ 31 "11111" "10000" 31 } +{ 32 "100000" "110000" 32 } diff --git a/Task/Gray-code/Forth/gray-code.fth b/Task/Gray-code/Forth/gray-code.fth new file mode 100644 index 0000000000..7425be01a6 --- /dev/null +++ b/Task/Gray-code/Forth/gray-code.fth @@ -0,0 +1,21 @@ +: >gray ( n -- n ) dup 2/ xor ; + +: gray> ( n -- n ) + 0 1 31 lshift ( g b mask ) + begin + >r + 2dup 2/ xor + r@ and or + r> 1 rshift + dup 0= + until + drop nip ; + +: test + 2 base ! + 32 0 do + cr i dup 5 .r ." ==> " + >gray dup 5 .r ." ==> " + gray> 5 .r + loop + decimal ; diff --git a/Task/Gray-code/Fortran/gray-code.f b/Task/Gray-code/Fortran/gray-code.f new file mode 100644 index 0000000000..3eacf616cd --- /dev/null +++ b/Task/Gray-code/Fortran/gray-code.f @@ -0,0 +1,46 @@ + PROGRAM GRAY + IMPLICIT NONE + INTEGER IGRAY,I,J,K + CHARACTER*5 A,B,C + DO 10 I=0,31 + J=IGRAY(I,1) + K=IGRAY(J,-1) + CALL BINARY(A,I,5) + CALL BINARY(B,J,5) + CALL BINARY(C,K,5) + PRINT 99,I,A,B,C,K + 10 CONTINUE + 99 FORMAT(I2,3H : ,A5,4H => ,A5,4H => ,A5,3H : ,I2) + END + + FUNCTION IGRAY(N,D) + IMPLICIT NONE + INTEGER D,K,N,IGRAY + IF(D.LT.0) GO TO 10 + IGRAY=IEOR(N,ISHFT(N,-1)) + RETURN + 10 K=N + IGRAY=0 + 20 IGRAY=IEOR(IGRAY,K) + K=K/2 + IF(K.NE.0) GO TO 20 + END + + SUBROUTINE BINARY(S,N,K) + IMPLICIT NONE + INTEGER I,K,L,N + CHARACTER*(*) S + L=LEN(S) + DO 10 I=0,K-1 +C The following line may replace the next block-if, +C on machines using ASCII code : +C S(L-I:L-I)=CHAR(48+IAND(1,ISHFT(N,-I))) +C On EBCDIC machines, use 240 instead of 48. + IF(BTEST(N,I)) THEN + S(L-I:L-I)='1' + ELSE + S(L-I:L-I)='0' + END IF + 10 CONTINUE + S(1:L-K)='' + END diff --git a/Task/Gray-code/Frink/gray-code.frink b/Task/Gray-code/Frink/gray-code.frink new file mode 100644 index 0000000000..a145daca00 --- /dev/null +++ b/Task/Gray-code/Frink/gray-code.frink @@ -0,0 +1,6 @@ +for i=0 to 31 +{ + gray = binaryToGray[i] + back = grayToBinary[gray] + println[(i->binary) + "\t" + (gray->binary) + "\t" + (back->binary)] +} diff --git a/Task/Gray-code/Go/gray-code.go b/Task/Gray-code/Go/gray-code.go new file mode 100644 index 0000000000..63ff4469ca --- /dev/null +++ b/Task/Gray-code/Go/gray-code.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +func enc(b int) int { + return b ^ b>>1 +} + +func dec(g int) (b int) { + for ; g != 0; g >>= 1 { + b ^= g + } + return +} + +func main() { + fmt.Println("decimal binary gray decoded") + for b := 0; b < 32; b++ { + g := enc(b) + d := dec(g) + fmt.Printf(" %2d %05b %05b %05b %2d\n", b, b, g, d, d) + } +} diff --git a/Task/Gray-code/Groovy/gray-code-1.groovy b/Task/Gray-code/Groovy/gray-code-1.groovy new file mode 100644 index 0000000000..a078acd707 --- /dev/null +++ b/Task/Gray-code/Groovy/gray-code-1.groovy @@ -0,0 +1,10 @@ +def grayEncode = { i -> + i ^ (i >>> 1) +} + +def grayDecode; +grayDecode = { int code -> + if(code <= 0) return 0 + def h = grayDecode(code >>> 1) + return (h << 1) + ((code ^ h) & 1) +} diff --git a/Task/Gray-code/Groovy/gray-code-2.groovy b/Task/Gray-code/Groovy/gray-code-2.groovy new file mode 100644 index 0000000000..b4ae8182ad --- /dev/null +++ b/Task/Gray-code/Groovy/gray-code-2.groovy @@ -0,0 +1,21 @@ +def binary = { i, minBits = 1 -> + def remainder = i + def bin = [] + while (remainder > 0 || bin.size() <= minBits) { + bin << (remainder & 1) + remainder >>>= 1 + } + bin +} + +println "number binary gray code decode" +println "====== ====== ========= ======" +(0..31).each { + def code = grayEncode(it) + def decode = grayDecode(code) + def iB = binary(it, 5) + def cB = binary(code, 5) + printf(" %2d %1d%1d%1d%1d%1d %1d%1d%1d%1d%1d %2d", + it, iB[4],iB[3],iB[2],iB[1],iB[0], cB[4],cB[3],cB[2],cB[1],cB[0], decode) + println() +} diff --git a/Task/Gray-code/Haskell/gray-code.hs b/Task/Gray-code/Haskell/gray-code.hs new file mode 100644 index 0000000000..d475840cf8 --- /dev/null +++ b/Task/Gray-code/Haskell/gray-code.hs @@ -0,0 +1,28 @@ +module Main where + +main = mapM_ (putStrLn . flip grayconvstr 5) [0..31] + +-- Convert number to bit list, MSB first. Second argument is minimum width. +num2bin :: (Integral t) => t -> t -> [t] +num2bin n w = num2bin' n w [] where + num2bin' n w acc | n <= 0 && w <= 0 = acc + | otherwise = num2bin' m (w-1) (b:acc) + where (m, b) = divMod n 2 + +xor2 :: (Integral t) => t -> t -> t +xor2 x y = (x + y) `mod` 2 + +bin2gray :: (Integral t) => [t] -> [t] +bin2gray [] = [] +bin2gray (x:xs) = x : zipWith xor2 xs (x:xs) + +gray2bin :: (Integral t) => [t] -> [t] +gray2bin = scanl1 xor2 + +-- Prettyprinting, since it is in the task description... +grayconvstr :: (Integral t, Show t) => t -> t -> String +grayconvstr n w = (show n) ++ ": " ++ (show b) ++ " => " ++ (show g) ++ " => " ++ (show u) + where + b = num2bin n w + g = bin2gray b + u = gray2bin g diff --git a/Task/Gray-code/J/gray-code-1.j b/Task/Gray-code/J/gray-code-1.j new file mode 100644 index 0000000000..483558fa53 --- /dev/null +++ b/Task/Gray-code/J/gray-code-1.j @@ -0,0 +1 @@ +G2B=: ~:/\&.|: diff --git a/Task/Gray-code/J/gray-code-2.j b/Task/Gray-code/J/gray-code-2.j new file mode 100644 index 0000000000..37a3e94936 --- /dev/null +++ b/Task/Gray-code/J/gray-code-2.j @@ -0,0 +1,39 @@ + n=:i.32 + G2B=: ~:/\&.|: + (,: ,.@".&.>) 'n';'#:n';'G2B inv#:n';'#.G2B G2B inv#:n' ++--+---------+----------+----------------+ +|n |#:n |G2B inv#:n|#.G2B G2B inv#:n| ++--+---------+----------+----------------+ +| 0|0 0 0 0 0|0 0 0 0 0 | 0 | +| 1|0 0 0 0 1|0 0 0 0 1 | 1 | +| 2|0 0 0 1 0|0 0 0 1 1 | 2 | +| 3|0 0 0 1 1|0 0 0 1 0 | 3 | +| 4|0 0 1 0 0|0 0 1 1 0 | 4 | +| 5|0 0 1 0 1|0 0 1 1 1 | 5 | +| 6|0 0 1 1 0|0 0 1 0 1 | 6 | +| 7|0 0 1 1 1|0 0 1 0 0 | 7 | +| 8|0 1 0 0 0|0 1 1 0 0 | 8 | +| 9|0 1 0 0 1|0 1 1 0 1 | 9 | +|10|0 1 0 1 0|0 1 1 1 1 |10 | +|11|0 1 0 1 1|0 1 1 1 0 |11 | +|12|0 1 1 0 0|0 1 0 1 0 |12 | +|13|0 1 1 0 1|0 1 0 1 1 |13 | +|14|0 1 1 1 0|0 1 0 0 1 |14 | +|15|0 1 1 1 1|0 1 0 0 0 |15 | +|16|1 0 0 0 0|1 1 0 0 0 |16 | +|17|1 0 0 0 1|1 1 0 0 1 |17 | +|18|1 0 0 1 0|1 1 0 1 1 |18 | +|19|1 0 0 1 1|1 1 0 1 0 |19 | +|20|1 0 1 0 0|1 1 1 1 0 |20 | +|21|1 0 1 0 1|1 1 1 1 1 |21 | +|22|1 0 1 1 0|1 1 1 0 1 |22 | +|23|1 0 1 1 1|1 1 1 0 0 |23 | +|24|1 1 0 0 0|1 0 1 0 0 |24 | +|25|1 1 0 0 1|1 0 1 0 1 |25 | +|26|1 1 0 1 0|1 0 1 1 1 |26 | +|27|1 1 0 1 1|1 0 1 1 0 |27 | +|28|1 1 1 0 0|1 0 0 1 0 |28 | +|29|1 1 1 0 1|1 0 0 1 1 |29 | +|30|1 1 1 1 0|1 0 0 0 1 |30 | +|31|1 1 1 1 1|1 0 0 0 0 |31 | ++--+---------+----------+----------------+ diff --git a/Task/Gray-code/Java/gray-code-1.java b/Task/Gray-code/Java/gray-code-1.java new file mode 100644 index 0000000000..e949f3388e --- /dev/null +++ b/Task/Gray-code/Java/gray-code-1.java @@ -0,0 +1,21 @@ +public class Gray { + public static long grayEncode(long n){ + return n ^ (n >>> 1); + } + + public static long grayDecode(long n) { + long p = n; + while ((n >>>= 1) != 0) + p ^= n; + return p; + } + public static void main(String[] args){ + System.out.println("i\tBinary\tGray\tDecoded"); + for(int i = -1; i < 32;i++){ + System.out.print(i +"\t"); + System.out.print(Integer.toBinaryString(i) + "\t"); + System.out.print(Long.toBinaryString(grayEncode(i))+ "\t"); + System.out.println(grayDecode(grayEncode(i))); + } + } +} diff --git a/Task/Gray-code/Java/gray-code-2.java b/Task/Gray-code/Java/gray-code-2.java new file mode 100644 index 0000000000..9af15aa133 --- /dev/null +++ b/Task/Gray-code/Java/gray-code-2.java @@ -0,0 +1,12 @@ +public static long grayEncode(long n){ + long result = 0; + for(int exp = 0; n > 0; n /= 2, exp++){ + long nextHighestBit = (n >> 1) & 1; + if(nextHighestBit == 1){ + result += ((n & 1) == 0) ? (1 << exp) : 0; //flip the bit + }else{ + result += (n & 1) * (1 << exp); //"n & 1" is "this bit", don't flip it + } + } + return result; +} diff --git a/Task/Gray-code/Java/gray-code-3.java b/Task/Gray-code/Java/gray-code-3.java new file mode 100644 index 0000000000..f66a0a2cd5 --- /dev/null +++ b/Task/Gray-code/Java/gray-code-3.java @@ -0,0 +1,11 @@ +public static BigInteger grayDecode(BigInteger n){ + String nBits = n.toString(2); + String result = nBits.substring(0, 1); + for(int i = 1; i < nBits.length(); i++){ + //bin[i] = gray[i] ^ bin[i-1] + + //XOR with characters + result += nBits.charAt(i) != result.charAt(i - 1) ? "1" : "0"; + } + return new BigInteger(result, 2); +} diff --git a/Task/Gray-code/K/gray-code-1.k b/Task/Gray-code/K/gray-code-1.k new file mode 100644 index 0000000000..6621fccdc4 --- /dev/null +++ b/Task/Gray-code/K/gray-code-1.k @@ -0,0 +1,8 @@ + xor: {~x=y} + gray:{x[0],xor':x} + + / variant: using shift + gray1:{(x[0],xor[1_ x;-1_ x])} + + / variant: iterative + gray2:{x[0],{:[x[y-1]=1;~x[y];x[y]]}[x]'1+!(#x)-1} diff --git a/Task/Gray-code/K/gray-code-2.k b/Task/Gray-code/K/gray-code-2.k new file mode 100644 index 0000000000..45fe1d5e76 --- /dev/null +++ b/Task/Gray-code/K/gray-code-2.k @@ -0,0 +1 @@ + g2b:xor\ diff --git a/Task/Gray-code/K/gray-code-3.k b/Task/Gray-code/K/gray-code-3.k new file mode 100644 index 0000000000..d3abe67d27 --- /dev/null +++ b/Task/Gray-code/K/gray-code-3.k @@ -0,0 +1,9 @@ + gray\1 0 0 0 0 +(1 0 0 0 0 + 1 1 0 0 0 + 1 0 1 0 0 + 1 1 1 1 0 + 1 0 0 0 1 + 1 1 0 0 1 + 1 0 1 0 1 + 1 1 1 1 1) diff --git a/Task/Gray-code/K/gray-code-4.k b/Task/Gray-code/K/gray-code-4.k new file mode 100644 index 0000000000..97781d26c7 --- /dev/null +++ b/Task/Gray-code/K/gray-code-4.k @@ -0,0 +1 @@ + g2b1:*|{gray x}\ diff --git a/Task/Gray-code/K/gray-code-5.k b/Task/Gray-code/K/gray-code-5.k new file mode 100644 index 0000000000..a349671bc5 --- /dev/null +++ b/Task/Gray-code/K/gray-code-5.k @@ -0,0 +1 @@ + g2b2:{c:#x;b:c#0;b[0]:x[0];i:1;do[#x;b[i]:xor[x[i];b[i-1]];i+:1];b} diff --git a/Task/Gray-code/K/gray-code-6.k b/Task/Gray-code/K/gray-code-6.k new file mode 100644 index 0000000000..09447da06b --- /dev/null +++ b/Task/Gray-code/K/gray-code-6.k @@ -0,0 +1,7 @@ + gray:{x[0],xor':x} + g2b:xor\ + / using allcomb instead of 2_vs'!32 for nicer presentation + allcomb:{+(x#y)_vs!_ y^x} + a:(+allcomb . 5 2) + `0:,/{n:2_sv x;gg:gray x;gb:g2b gg;n2:2_sv gb; + ,/$((2$n)," : ",$x," -> ",$gg," -> ",$gb," : ",(2$n2),"\n") }'a diff --git a/Task/Gray-code/K/gray-code-7.k b/Task/Gray-code/K/gray-code-7.k new file mode 100644 index 0000000000..89e57ebeed --- /dev/null +++ b/Task/Gray-code/K/gray-code-7.k @@ -0,0 +1,32 @@ + 0 : 00000 -> 00000 -> 00000 : 0 + 1 : 00001 -> 00001 -> 00001 : 1 + 2 : 00010 -> 00011 -> 00010 : 2 + 3 : 00011 -> 00010 -> 00011 : 3 + 4 : 00100 -> 00110 -> 00100 : 4 + 5 : 00101 -> 00111 -> 00101 : 5 + 6 : 00110 -> 00101 -> 00110 : 6 + 7 : 00111 -> 00100 -> 00111 : 7 + 8 : 01000 -> 01100 -> 01000 : 8 + 9 : 01001 -> 01101 -> 01001 : 9 +10 : 01010 -> 01111 -> 01010 : 10 +11 : 01011 -> 01110 -> 01011 : 11 +12 : 01100 -> 01010 -> 01100 : 12 +13 : 01101 -> 01011 -> 01101 : 13 +14 : 01110 -> 01001 -> 01110 : 14 +15 : 01111 -> 01000 -> 01111 : 15 +16 : 10000 -> 11000 -> 10000 : 16 +17 : 10001 -> 11001 -> 10001 : 17 +18 : 10010 -> 11011 -> 10010 : 18 +19 : 10011 -> 11010 -> 10011 : 19 +20 : 10100 -> 11110 -> 10100 : 20 +21 : 10101 -> 11111 -> 10101 : 21 +22 : 10110 -> 11101 -> 10110 : 22 +23 : 10111 -> 11100 -> 10111 : 23 +24 : 11000 -> 10100 -> 11000 : 24 +25 : 11001 -> 10101 -> 11001 : 25 +26 : 11010 -> 10111 -> 11010 : 26 +27 : 11011 -> 10110 -> 11011 : 27 +28 : 11100 -> 10010 -> 11100 : 28 +29 : 11101 -> 10011 -> 11101 : 29 +30 : 11110 -> 10001 -> 11110 : 30 +31 : 11111 -> 10000 -> 11111 : 31 diff --git a/Task/Gray-code/Liberty-BASIC/gray-code.liberty b/Task/Gray-code/Liberty-BASIC/gray-code.liberty new file mode 100644 index 0000000000..14888831e6 --- /dev/null +++ b/Task/Gray-code/Liberty-BASIC/gray-code.liberty @@ -0,0 +1,55 @@ + for r =0 to 31 + print " Decimal "; using( "###", r); " is "; + B$ =dec2Bin$( r) + print " binary "; B$; ". Binary "; B$; + G$ =Bin2Gray$( dec2Bin$( r)) + print " is "; G$; " in Gray code, or "; + B$ =Gray2Bin$( G$) + print B$; " in pure binary." + next r + + end + + function Bin2Gray$( bin$) ' Given a binary number as a string, returns Gray code as a string. + g$ =left$( bin$, 1) + for i =2 to len( bin$) + bitA =val( mid$( bin$, i -1, 1)) + bitB =val( mid$( bin$, i, 1)) + AXorB =bitA xor bitB + g$ =g$ +str$( AXorB) + next i + Bin2Gray$ =g$ + end function + + function Gray2Bin$( g$) ' Given a Gray code as a string, returns equivalent binary num. + ' as a string + gl =len( g$) + b$ =left$( g$, 1) + for i =2 to len( g$) + bitA =val( mid$( b$, i -1, 1)) + bitB =val( mid$( g$, i, 1)) + AXorB =bitA xor bitB + b$ =b$ +str$( AXorB) + next i + Gray2Bin$ =right$( b$, gl) + end function + + function dec2Bin$( num) ' Given an integer decimal, returns binary equivalent as a string + n =num + dec2Bin$ ="" + while ( num >0) + dec2Bin$ =str$( num mod 2) +dec2Bin$ + num =int( num /2) + wend + if ( n >255) then nBits =16 else nBits =8 + dec2Bin$ =right$( "0000000000000000" +dec2Bin$, nBits) ' Pad to 8 bit or 16 bit + end function + + function bin2Dec( b$) ' Given a binary number as a string, returns decimal equivalent num. + t =0 + d =len( b$) + for k =d to 1 step -1 + t =t +val( mid$( b$, k, 1)) *2^( d -k) + next k + bin2Dec =t + end function diff --git a/Task/Gray-code/Logo/gray-code-1.logo b/Task/Gray-code/Logo/gray-code-1.logo new file mode 100644 index 0000000000..a81e4b0547 --- /dev/null +++ b/Task/Gray-code/Logo/gray-code-1.logo @@ -0,0 +1,13 @@ +to gray_encode :number + output bitxor :number lshift :number -1 +end + +to gray_decode :code + local "value + make "value 0 + while [:code > 0] [ + make "value bitxor :code :value + make "code lshift :code -1 + ] + output :value +end diff --git a/Task/Gray-code/Logo/gray-code-2.logo b/Task/Gray-code/Logo/gray-code-2.logo new file mode 100644 index 0000000000..52082ae58f --- /dev/null +++ b/Task/Gray-code/Logo/gray-code-2.logo @@ -0,0 +1,29 @@ +to format :str :width [pad (char 32)] + while [(count :str) < :width] [ + make "str word :pad :str + ] + output :str +end + +; Output binary representation of a number +to binary :number [:width 1] + local "bits + ifelse [:number = 0] [ + make "bits 0 + ] [ + make "bits " + while [:number > 0] [ + make "bits word (bitand :number 1) :bits + make "number lshift :number -1 + ] + ] + output (format :bits :width 0) +end + +repeat 32 [ + make "num repcount - 1 + make "gray gray_encode :num + make "decoded gray_decode :gray + print (sentence (format :num 2) ": (binary :num 5) ": (binary :gray 5) ": + (binary :decoded 5) ": (format :decoded 2)) ] +bye diff --git a/Task/Gray-code/Lua/gray-code-1.lua b/Task/Gray-code/Lua/gray-code-1.lua new file mode 100644 index 0000000000..e8d2f1cd2d --- /dev/null +++ b/Task/Gray-code/Lua/gray-code-1.lua @@ -0,0 +1,18 @@ +local _M = {} + +local bit = require('bit') +local math = require('math') + +_M.encode = function(number) + return bit.bxor(number, bit.rshift(number, 1)); +end + +_M.decode = function(gray_code) + local value = 0 + while gray_code > 0 do + gray_code, value = bit.rshift(gray_code, 1), bit.bxor(gray_code, value) + end + return value +end + +return _M diff --git a/Task/Gray-code/Lua/gray-code-2.lua b/Task/Gray-code/Lua/gray-code-2.lua new file mode 100644 index 0000000000..13c1ac640c --- /dev/null +++ b/Task/Gray-code/Lua/gray-code-2.lua @@ -0,0 +1,24 @@ +local bit = require 'bit' +local gray = require 'gray' + +-- simple binary string formatter +local function to_bit_string(n, width) + width = width or 1 + local output = "" + while n > 0 do + output = bit.band(n,1) .. output + n = bit.rshift(n,1) + end + while #output < width do + output = '0' .. output + end + return output +end + +for i = 0,31 do + g = gray.encode(i); + gd = gray.decode(g); + print(string.format("%2d : %s => %s => %s : %2d", i, + to_bit_string(i,5), to_bit_string(g, 5), + to_bit_string(gd,5), gd)) +end diff --git a/Task/Gray-code/Mathematica/gray-code.mathematica b/Task/Gray-code/Mathematica/gray-code.mathematica new file mode 100644 index 0000000000..72759ee4f9 --- /dev/null +++ b/Task/Gray-code/Mathematica/gray-code.mathematica @@ -0,0 +1,2 @@ +graycode[n_]:=BitXor[n,BitShiftRight[n]] +graydecode[n_]:=Fold[BitXor,0,FixedPointList[BitShiftRight,n]] diff --git a/Task/Gray-code/Perl/gray-code.pl b/Task/Gray-code/Perl/gray-code.pl new file mode 100644 index 0000000000..508df105b1 --- /dev/null +++ b/Task/Gray-code/Perl/gray-code.pl @@ -0,0 +1,20 @@ +sub bin2gray +{ + return $_[0] ^ ($_[0] >> 1); +} + +sub gray2bin +{ + my ($num)= @_; + my $bin= $num; + while( $num >>= 1 ) { + # a bit ends up flipped iff an odd number of bits to its left is set. + $bin ^= $num; # different from the suggested algorithm; + } # avoids using bit mask and explicit bittery + return $bin; +} + +for (0..31) { + my $gr= bin2gray($_); + printf "%d\t%b\t%b\t%b\n", $_, $_, $gr, gray2bin($gr); +} diff --git a/Task/Gray-code/PicoLisp/gray-code-1.l b/Task/Gray-code/PicoLisp/gray-code-1.l new file mode 100644 index 0000000000..aaf9d8b9a8 --- /dev/null +++ b/Task/Gray-code/PicoLisp/gray-code-1.l @@ -0,0 +1,10 @@ +(de grayEncode (N) + (bin (x| N (>> 1 N))) ) + +(de grayDecode (G) + (bin + (pack + (let X 0 + (mapcar + '((C) (setq X (x| X (format C)))) + (chop G) ) ) ) ) ) diff --git a/Task/Gray-code/PicoLisp/gray-code-2.l b/Task/Gray-code/PicoLisp/gray-code-2.l new file mode 100644 index 0000000000..5871917471 --- /dev/null +++ b/Task/Gray-code/PicoLisp/gray-code-2.l @@ -0,0 +1,4 @@ +(prinl " Binary Gray Decoded") +(for I (range 0 31) + (let G (grayEncode I) + (tab (4 9 9 9) I (bin I) G (grayDecode G)) ) ) diff --git a/Task/Gray-code/Python/gray-code-1.py b/Task/Gray-code/Python/gray-code-1.py new file mode 100644 index 0000000000..cc9dceb597 --- /dev/null +++ b/Task/Gray-code/Python/gray-code-1.py @@ -0,0 +1,17 @@ +>>> def int2bin(n): + 'From positive integer to list of binary bits, msb at index 0' + if n: + bits = [] + while n: + n,remainder = divmod(n, 2) + bits.insert(0, remainder) + return bits + else: return [0] + + +>>> def bin2int(bits): + 'From binary bits, msb at index 0 to integer' + i = 0 + for bit in bits: + i = i * 2 + bit + return i diff --git a/Task/Gray-code/Python/gray-code-2.py b/Task/Gray-code/Python/gray-code-2.py new file mode 100644 index 0000000000..f6bd8f451d --- /dev/null +++ b/Task/Gray-code/Python/gray-code-2.py @@ -0,0 +1,7 @@ +>>> def bin2gray(bits): + return bits[:1] + [i ^ ishift for i, ishift in zip(bits[:-1], bits[1:])] + +>>> def gray2bin(bits): + b = [bits[0]] + for nextb in bits[1:]: b.append(b[-1] ^ nextb) + return b diff --git a/Task/Gray-code/Python/gray-code-3.py b/Task/Gray-code/Python/gray-code-3.py new file mode 100644 index 0000000000..4bb03622cd --- /dev/null +++ b/Task/Gray-code/Python/gray-code-3.py @@ -0,0 +1,27 @@ +>>> for i in range(16): + print('int:%2i -> bin:%12r -> gray:%12r -> bin:%12r -> int:%2i' % + ( i, + int2bin(i), + bin2gray(int2bin(i)), + gray2bin(bin2gray(int2bin(i))), + bin2int(gray2bin(bin2gray(int2bin(i)))) + )) + + +int: 0 -> bin: [0] -> gray: [0] -> bin: [0] -> int: 0 +int: 1 -> bin: [1] -> gray: [1] -> bin: [1] -> int: 1 +int: 2 -> bin: [1, 0] -> gray: [1, 1] -> bin: [1, 0] -> int: 2 +int: 3 -> bin: [1, 1] -> gray: [1, 0] -> bin: [1, 1] -> int: 3 +int: 4 -> bin: [1, 0, 0] -> gray: [1, 1, 0] -> bin: [1, 0, 0] -> int: 4 +int: 5 -> bin: [1, 0, 1] -> gray: [1, 1, 1] -> bin: [1, 0, 1] -> int: 5 +int: 6 -> bin: [1, 1, 0] -> gray: [1, 0, 1] -> bin: [1, 1, 0] -> int: 6 +int: 7 -> bin: [1, 1, 1] -> gray: [1, 0, 0] -> bin: [1, 1, 1] -> int: 7 +int: 8 -> bin:[1, 0, 0, 0] -> gray:[1, 1, 0, 0] -> bin:[1, 0, 0, 0] -> int: 8 +int: 9 -> bin:[1, 0, 0, 1] -> gray:[1, 1, 0, 1] -> bin:[1, 0, 0, 1] -> int: 9 +int:10 -> bin:[1, 0, 1, 0] -> gray:[1, 1, 1, 1] -> bin:[1, 0, 1, 0] -> int:10 +int:11 -> bin:[1, 0, 1, 1] -> gray:[1, 1, 1, 0] -> bin:[1, 0, 1, 1] -> int:11 +int:12 -> bin:[1, 1, 0, 0] -> gray:[1, 0, 1, 0] -> bin:[1, 1, 0, 0] -> int:12 +int:13 -> bin:[1, 1, 0, 1] -> gray:[1, 0, 1, 1] -> bin:[1, 1, 0, 1] -> int:13 +int:14 -> bin:[1, 1, 1, 0] -> gray:[1, 0, 0, 1] -> bin:[1, 1, 1, 0] -> int:14 +int:15 -> bin:[1, 1, 1, 1] -> gray:[1, 0, 0, 0] -> bin:[1, 1, 1, 1] -> int:15 +>>> diff --git a/Task/Gray-code/REXX/gray-code.rexx b/Task/Gray-code/REXX/gray-code.rexx new file mode 100644 index 0000000000..93ea003347 --- /dev/null +++ b/Task/Gray-code/REXX/gray-code.rexx @@ -0,0 +1,25 @@ +/*REXX program to convert decimal───> binary ───> gray code ───> binary.*/ +parse arg N .; if N=='' then N=31 /*Not specified? Then use default*/ +L=max(1,length(strip(x2b(d2x(N)),'L',0))) /*for cell width formatting.*/ +w=14 /*used for cell width formatting.*/ +_=center('binary',w,'─') /*2nd and 4th part of the header.*/ +say center('decimal',w,'─')">" _">" center('gray code',w,'─')">" _ /*hdr*/ + + do j=0 to N; b=right(x2b(d2x(j)),L,0) /*handle 0 ──► N.*/ + g=b2gray(b) /*convert binary to gray code. */ + a=gray2b(g) /*convert gray code to binary. */ + say center(j,w+1) center(b,w+1) center(g,w+1) center(a,w+1) /*tell*/ + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────────B2GRAY subroutine──────────────────*/ +b2gray: procedure; parse arg x +$=left(x,1); do b=2 to length(x) + $=$||(substr(x,b-1,1) && substr(x,b,1)) + end /*b*/ /* && is eXclusive OR*/ +return $ +/*───────────────────────────────────GRAY2B subroutine──────────────────*/ +gray2b: procedure; parse arg x +$=left(x,1); do g=2 to length(x) + $=$ || (right($,1) && substr(x,g,1)) + end /*g*/ /* && is eXclusive OR*/ +return $ diff --git a/Task/Gray-code/Racket/gray-code.rkt b/Task/Gray-code/Racket/gray-code.rkt new file mode 100644 index 0000000000..c1b31ef9e9 --- /dev/null +++ b/Task/Gray-code/Racket/gray-code.rkt @@ -0,0 +1,18 @@ +#lang racket + +(define (gray-encode n) (bitwise-xor n (arithmetic-shift n -1))) + +(define (gray-decode n) + (letrec ([loop (lambda(g bits) + (if (> bits 0) + (loop (bitwise-xor g bits) (arithmetic-shift bits -1)) + g))]) + (loop 0 n))) + +(define (to-bin n) (format "~b" n)) +(define (show-table) + (for ([i (in-range 1 32)]) + (printf "~a | ~a | ~a ~n" + (~r i #:min-width 2 #:pad-string "0") + (~a (to-bin(gray-encode i)) #:width 5 #:align 'right #:pad-string "0") + (~a (to-bin (gray-decode(gray-encode i))) #:width 5 #:align 'right #:pad-string "0")))) diff --git a/Task/Gray-code/Ruby/gray-code.rb b/Task/Gray-code/Ruby/gray-code.rb new file mode 100644 index 0000000000..e3af40f625 --- /dev/null +++ b/Task/Gray-code/Ruby/gray-code.rb @@ -0,0 +1,26 @@ +class Integer + # Converts a normal integer to a Gray code. + def to_gray + raise Math::DomainError, "integer is negative" if self < 0 + self ^ (self >> 1) + end + + # Converts a Gray code to a normal integer. + def from_gray + raise Math::DomainError, "integer is negative" if self < 0 + recurse = proc do |i| + next 0 if i == 0 + o = recurse[i >> 1] << 1 + o | (i[0] ^ o[1]) + end + recurse[self] + end +end + + +(0..31).each do |number| + encoded = number.to_gray + decoded = encoded.from_gray + printf("%2d: %5b => %5b => %5b: %2d\n", + number, number, encoded, decoded, decoded) +end diff --git a/Task/Gray-code/Scala/gray-code-1.scala b/Task/Gray-code/Scala/gray-code-1.scala new file mode 100644 index 0000000000..18ef13822a --- /dev/null +++ b/Task/Gray-code/Scala/gray-code-1.scala @@ -0,0 +1,6 @@ +def encode(n: Int) = (n ^ (n >>> 1)).toBinaryString +def decode(s: String) = Integer.parseInt( s.scanLeft(0)(_ ^ _.asDigit).tail.mkString , 2) + +println("decimal binary gray decoded") +for (i <- 0 to 31; g = encode(i)) + println("%7d %6s %5s %7s".format(i, i.toBinaryString, g, decode(g))) diff --git a/Task/Gray-code/Scala/gray-code-2.scala b/Task/Gray-code/Scala/gray-code-2.scala new file mode 100644 index 0000000000..4ade6004fe --- /dev/null +++ b/Task/Gray-code/Scala/gray-code-2.scala @@ -0,0 +1,19 @@ +def encode(n: Long) = n ^ (n >>> 1) + +def decode(n: Long) = { + var g = 0L + var bits = n + while (bits > 0) { + g ^= bits + bits >>= 1 + } + g +} + +def toBin(n: Long) = ("0000" + n.toBinaryString) takeRight 5 + +println("decimal binary gray decoded") +for (i <- 0 until 32) { + val g = encode(i) + println("%7d %6s %5s %7s".format(i, toBin(i), toBin(g), decode(g))) +} diff --git a/Task/Gray-code/Scala/gray-code-3.scala b/Task/Gray-code/Scala/gray-code-3.scala new file mode 100644 index 0000000000..7a9f315042 --- /dev/null +++ b/Task/Gray-code/Scala/gray-code-3.scala @@ -0,0 +1,4 @@ +def decode(n:Long)={ + def calc(g:Long,bits:Long):Long=if (bits>0) calc(g^bits, bits>>1) else g + calc(0, n) +} diff --git a/Task/Gray-code/Tcl/gray-code-1.tcl b/Task/Gray-code/Tcl/gray-code-1.tcl new file mode 100644 index 0000000000..87d92c79da --- /dev/null +++ b/Task/Gray-code/Tcl/gray-code-1.tcl @@ -0,0 +1,14 @@ +namespace eval gray { + proc encode n { + expr {$n ^ $n >> 1} + } + proc decode n { + # Compute some bit at least as large as MSB + set i [expr {2**int(ceil(log($n+1)/log(2)))}] + set b [set bprev [expr {$n & $i}]] + while {[set i [expr {$i >> 1}]]} { + set b [expr {$b | [set bprev [expr {$n & $i ^ $bprev >> 1}]]}] + } + return $b + } +} diff --git a/Task/Gray-code/Tcl/gray-code-2.tcl b/Task/Gray-code/Tcl/gray-code-2.tcl new file mode 100644 index 0000000000..1c533dd035 --- /dev/null +++ b/Task/Gray-code/Tcl/gray-code-2.tcl @@ -0,0 +1,6 @@ +package require Tcl 8.6; # Just for %b format specifier +for {set i 0} {$i < 32} {incr i} { + set g [gray::encode $i] + set b [gray::decode $g] + puts [format "%2d: %05b => %05b => %05b : %2d" $i $i $g $b $b] +} diff --git a/Task/Grayscale-image/0DESCRIPTION b/Task/Grayscale-image/0DESCRIPTION new file mode 100644 index 0000000000..f9585e1bc6 --- /dev/null +++ b/Task/Grayscale-image/0DESCRIPTION @@ -0,0 +1,5 @@ +Many image processing algorithms are defined for [[wp:Grayscale|grayscale]] (or else monochromatic) images. Extend the data storage type defined [[Basic_bitmap_storage|on this page]] to support grayscale images. Define two operations, one to convert a color image to a grayscale image and one for the backward conversion. To get luminance of a color use the formula recommended by [http://www.cie.co.at/index_ie.html CIE]: + +L = 0.2126·R + 0.7152·G + 0.0722·B + +When using floating-point arithmetic make sure that rounding errors would not cause run-time problems or else distorted results when calculated luminance is stored as an unsigned integer. diff --git a/Task/Grayscale-image/1META.yaml b/Task/Grayscale-image/1META.yaml new file mode 100644 index 0000000000..58807afa1b --- /dev/null +++ b/Task/Grayscale-image/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Image processing diff --git a/Task/Grayscale-image/Ada/grayscale-image-1.ada b/Task/Grayscale-image/Ada/grayscale-image-1.ada new file mode 100644 index 0000000000..27852dea71 --- /dev/null +++ b/Task/Grayscale-image/Ada/grayscale-image-1.ada @@ -0,0 +1 @@ +type Grayscale_Image is array (Positive range <>, Positive range <>) of Luminance; diff --git a/Task/Grayscale-image/Ada/grayscale-image-2.ada b/Task/Grayscale-image/Ada/grayscale-image-2.ada new file mode 100644 index 0000000000..3e5ca8c12a --- /dev/null +++ b/Task/Grayscale-image/Ada/grayscale-image-2.ada @@ -0,0 +1,20 @@ +function Grayscale (Picture : Image) return Grayscale_Image is + type Extended_Luminance is range 0..10_000_000; + Result : Grayscale_Image (Picture'Range (1), Picture'Range (2)); + Color : Pixel; +begin + for I in Picture'Range (1) loop + for J in Picture'Range (2) loop + Color := Picture (I, J); + Result (I, J) := + Luminance + ( ( 2_126 * Extended_Luminance (Color.R) + + 7_152 * Extended_Luminance (Color.G) + + 722 * Extended_Luminance (Color.B) + ) + / 10_000 + ); + end loop; + end loop; + return Result; +end Grayscale; diff --git a/Task/Grayscale-image/Ada/grayscale-image-3.ada b/Task/Grayscale-image/Ada/grayscale-image-3.ada new file mode 100644 index 0000000000..144dffb62e --- /dev/null +++ b/Task/Grayscale-image/Ada/grayscale-image-3.ada @@ -0,0 +1,10 @@ +function Color (Picture : Grayscale_Image) return Image is + Result : Image (Picture'Range (1), Picture'Range (2)); +begin + for I in Picture'Range (1) loop + for J in Picture'Range (2) loop + Result (I, J) := (others => Picture (I, J)); + end loop; + end loop; + return Result; +end Color; diff --git a/Task/Grayscale-image/BASIC256/grayscale-image.basic256 b/Task/Grayscale-image/BASIC256/grayscale-image.basic256 new file mode 100644 index 0000000000..61dba2bd03 --- /dev/null +++ b/Task/Grayscale-image/BASIC256/grayscale-image.basic256 @@ -0,0 +1,23 @@ +w = 143 +h = 188 +name$ = "Mona_Lisa.jpg" +graphsize w,h +imgload w/2, h/2, name$ +fastgraphics + +for x = 0 to w-1 + for y = 0 to h-1 + p = pixel(x,y) + b = p % 256 + p = p \256 + g = p % 256 + p = p \ 256 + r = p % 256 + l = 0.2126*r + 0.7152*g + 0.0722*b + color rgb(l,l,l) + plot x,y + next y + refresh +next x + +imgsave "Grey_"+name$,"jpg" diff --git a/Task/Grayscale-image/BBC-BASIC/grayscale-image.bbc b/Task/Grayscale-image/BBC-BASIC/grayscale-image.bbc new file mode 100644 index 0000000000..eaad327fb0 --- /dev/null +++ b/Task/Grayscale-image/BBC-BASIC/grayscale-image.bbc @@ -0,0 +1,29 @@ + Width% = 200 + Height% = 200 + + VDU 23,22,Width%;Height%;8,16,16,128 + *display c:\lena + + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + rgb% = FNgetpixel(x%,y%) + r% = rgb% >> 16 + g% = (rgb% >> 8) AND &FF + b% = rgb% AND &FF + l% = INT(0.3*r% + 0.59*g% + 0.11*b% + 0.5) + PROCsetpixel(x%,y%,l%,l%,l%) + NEXT + NEXT y% + END + + DEF PROCsetpixel(x%,y%,r%,g%,b%) + COLOUR 1,r%,g%,b% + GCOL 1 + LINE x%*2,y%*2,x%*2,y%*2 + ENDPROC + + DEF FNgetpixel(x%,y%) + LOCAL col% + col% = TINT(x%*2,y%*2) + SWAP ?^col%,?(^col%+2) + = col% diff --git a/Task/Grayscale-image/C/grayscale-image-1.c b/Task/Grayscale-image/C/grayscale-image-1.c new file mode 100644 index 0000000000..96785c4a0b --- /dev/null +++ b/Task/Grayscale-image/C/grayscale-image-1.c @@ -0,0 +1,12 @@ +typedef unsigned char luminance; +typedef luminance pixel1[1]; +typedef struct { + unsigned int width; + unsigned int height; + luminance *buf; +} grayimage_t; +typedef grayimage_t *grayimage; + +grayimage alloc_grayimg(unsigned int, unsigned int); +grayimage tograyscale(image); +image tocolor(grayimage); diff --git a/Task/Grayscale-image/C/grayscale-image-2.c b/Task/Grayscale-image/C/grayscale-image-2.c new file mode 100644 index 0000000000..19780bf584 --- /dev/null +++ b/Task/Grayscale-image/C/grayscale-image-2.c @@ -0,0 +1,9 @@ +grayimage alloc_grayimg(unsigned int width, unsigned int height) +{ + grayimage img; + img = malloc(sizeof(grayimage_t)); + img->buf = malloc(width*height*sizeof(pixel1)); + img->width = width; + img->height = height; + return img; +} diff --git a/Task/Grayscale-image/C/grayscale-image-3.c b/Task/Grayscale-image/C/grayscale-image-3.c new file mode 100644 index 0000000000..f03eb72c4d --- /dev/null +++ b/Task/Grayscale-image/C/grayscale-image-3.c @@ -0,0 +1,23 @@ +grayimage tograyscale(image img) +{ + unsigned int x, y; + grayimage timg; + double rc, gc, bc, l; + unsigned int ofs; + + timg = alloc_grayimg(img->width, img->height); + + for(x=0; x < img->width; x++) + { + for(y=0; y < img->height; y++) + { + ofs = (y * img->width) + x; + rc = (double) img->buf[ofs][0]; + gc = (double) img->buf[ofs][1]; + bc = (double) img->buf[ofs][2]; + l = 0.2126*rc + 0.7152*gc + 0.0722*bc; + timg->buf[ofs][0] = (luminance) (l+0.5); + } + } + return timg; +} diff --git a/Task/Grayscale-image/C/grayscale-image-4.c b/Task/Grayscale-image/C/grayscale-image-4.c new file mode 100644 index 0000000000..79978805ce --- /dev/null +++ b/Task/Grayscale-image/C/grayscale-image-4.c @@ -0,0 +1,22 @@ +image tocolor(grayimage img) +{ + unsigned int x, y; + image timg; + luminance l; + unsigned int ofs; + + timg = alloc_img(img->width, img->height); + + for(x=0; x < img->width; x++) + { + for(y=0; y < img->height; y++) + { + ofs = (y * img->width) + x; + l = img->buf[ofs][0]; + timg->buf[ofs][0] = l; + timg->buf[ofs][1] = l; + timg->buf[ofs][2] = l; + } + } + return timg; +} diff --git a/Task/Grayscale-image/C/grayscale-image-5.c b/Task/Grayscale-image/C/grayscale-image-5.c new file mode 100644 index 0000000000..fe5bb5a3e0 --- /dev/null +++ b/Task/Grayscale-image/C/grayscale-image-5.c @@ -0,0 +1 @@ +#define free_grayimg(IMG) free_img((image)(IMG)) diff --git a/Task/Grayscale-image/Common-Lisp/grayscale-image.lisp b/Task/Grayscale-image/Common-Lisp/grayscale-image.lisp new file mode 100644 index 0000000000..47d05a73da --- /dev/null +++ b/Task/Grayscale-image/Common-Lisp/grayscale-image.lisp @@ -0,0 +1,23 @@ +(in-package #:rgb-pixel-buffer) + +(defun rgb-to-gray-image (rgb-image) + (flet ((rgb-to-gray (rgb-value) + (round (+ (* 0.2126 (rgb-pixel-red rgb-value)) + (* 0.7152 (rgb-pixel-green rgb-value)) + (* 0.0722 (rgb-pixel-blue rgb-value)))))) + (let ((gray-image (make-array (array-dimensions rgb-image) :element-type '(unsigned-byte 8)))) + (dotimes (i (array-total-size rgb-image)) + (setf (row-major-aref gray-image i) (rgb-to-gray (row-major-aref rgb-image i)))) + gray-image))) + +(export 'rgb-to-gray-image) + + +(defun grayscale-image-to-pgm-file (image file-name &optional (max-value 255)) + (with-open-file (p file-name :direction :output + :if-exists :supersede) + (format p "P2 ~&~A ~A ~&~A" (array-dimension image 1) (array-dimension image 0) max-value) + (dotimes (i (array-total-size image)) + (print (row-major-aref image i) p)))) + +(export 'grayscale-image-to-pgm-file) diff --git a/Task/Grayscale-image/D/grayscale-image.d b/Task/Grayscale-image/D/grayscale-image.d new file mode 100644 index 0000000000..46bb1a284c --- /dev/null +++ b/Task/Grayscale-image/D/grayscale-image.d @@ -0,0 +1,117 @@ +module grayscale_image; + +import core.stdc.stdio, std.array, std.algorithm, std.string, std.ascii; +public import bitmap; + +struct Gray { + ubyte c; + enum black = Gray(0); + enum white = Gray(255); + alias c this; +} + + +Image!Color loadPGM(Color)(Image!Color img, in string fileName) { + static int readNum(FILE* f) nothrow { + int n; + while (!fscanf(f, "%d ", &n)) { + if ((n = fgetc(f)) == '#') { + while ((n = fgetc(f)) != '\n') + if (n == EOF) + return 0; + } else + return 0; + } + return n; + } + + scope(exit) if (fin) fclose(fin); + if (img is null) + img = new Image!Color(); + + auto fin = fopen(fileName.toStringz(), "rb"); + if (!fin) + throw new Exception("Can't open input file."); + + if (fgetc(fin) != 'P' || + fgetc(fin) != '5' || + !isWhite(fgetc(fin))) + throw new Exception("Not a PGM (PPM P5) image."); + + immutable int nc = readNum(fin); + immutable int nr = readNum(fin); + immutable int maxVal = readNum(fin); + if (nc <= 0 || nr <= 0 || maxVal <= 0) + throw new Exception("Wrong input image sizes."); + img.allocate(nc, nr); + auto pix = new ubyte[img.image.length]; + + immutable count = fread(pix.ptr, 1, nc * nr, fin); + if (count != nc * nr) + throw new Exception("Wrong number of items read."); + + pix.copy(img.image); + return img; +} + + +void savePGM(Color)(in Image!Color img, in string fileName) +in { + assert(img !is null); + assert(!fileName.empty); + assert(img.nx > 0 && img.ny > 0 && + img.image.length == img.nx * img.ny, + "Wrong image."); +} body { + auto fout = fopen(fileName.toStringz(), "wb"); + if (fout == null) + throw new Exception("File can't be opened."); + fprintf(fout, "P5\n%d %d\n255\n", img.nx, img.ny); + auto pix = new ubyte[img.image.length]; + foreach (i, ref p; pix) + p = cast(typeof(pix[0]))img.image[i]; + immutable count = fwrite(pix.ptr, ubyte.sizeof, + img.nx * img.ny, fout); + if (count != img.nx * img.ny) + new Exception("Wrong number of items written."); + fclose(fout); +} + + +Gray lumCIE(in RGB c) pure nothrow { + return Gray(cast(ubyte)(0.2126 * c.r + + 0.7152 * c.g + + 0.0722 * c.b + 0.5)); +} + +Gray lumAVG(in RGB c) pure nothrow { + return Gray(cast(ubyte)(0.3333 * c.r + + 0.3333 * c.g + + 0.3333 * c.b + 0.5)); +} + +Image!Gray rgb2grayImage(alias Conv=lumCIE)(in Image!RGB im) { + auto result = new typeof(return)(im.nx, im.ny); + foreach (i, immutable rgb; im.image) + result.image[i] = Conv(rgb); + return result; +} + +Image!RGB gray2rgbImage(in Image!Gray im) { + auto result = new typeof(return)(im.nx, im.ny); + foreach (i, immutable gr; im.image) + result.image[i] = RGB(gr, gr, gr); + return result; +} + +version (grayscale_image_main) { + void main() { + auto im1 = new Image!Gray(); + im1.loadPGM("lena.pgm"); + gray2rgbImage(im1).savePPM6("lena_rgb.ppm"); + + auto img2 = new Image!RGB(); + img2.loadPPM6("quantum_frog.ppm"); + img2.rgb2grayImage().savePGM("quantum_frog_grey.pgm"); + } +} diff --git a/Task/Grayscale-image/Euphoria/grayscale-image.euphoria b/Task/Grayscale-image/Euphoria/grayscale-image.euphoria new file mode 100644 index 0000000000..3b93fdd8c1 --- /dev/null +++ b/Task/Grayscale-image/Euphoria/grayscale-image.euphoria @@ -0,0 +1,20 @@ +function to_gray(sequence image) + sequence color + for i = 1 to length(image) do + for j = 1 to length(image[i]) do + color = and_bits(image[i][j], {#FF0000,#FF00,#FF}) / + {#010000,#0100,#01} -- unpack color triple + image[i][j] = floor(0.2126*color[1] + 0.7152*color[2] + 0.0722*color[3]) + end for + end for + return image +end function + +function to_color(sequence image) + for i = 1 to length(image) do + for j = 1 to length(image[i]) do + image[i][j] = image[i][j]*#010101 + end for + end for + return image +end function diff --git a/Task/Grayscale-image/Forth/grayscale-image.fth b/Task/Grayscale-image/Forth/grayscale-image.fth new file mode 100644 index 0000000000..f20162b8e5 --- /dev/null +++ b/Task/Grayscale-image/Forth/grayscale-image.fth @@ -0,0 +1,56 @@ +\ grayscale bitmap (without word-alignment for scan lines) + +\ bdim, bwidth, bdata all work with graymaps + +: graymap ( w h -- gmp ) + 2dup * bdata allocate throw + dup >r 2! r> ; + +: gxy ( x y gmp -- addr ) + dup bwidth rot * rot + swap bdata + ; + +: g@ ( x y gmp -- c ) gxy c@ ; +: g! ( c x y bmp -- ) gxy c! ; + +: gfill ( c gmp -- ) + dup bdata swap bdim * rot fill ; + +: gshow ( gmp -- ) + dup bdim + 0 do cr + dup 0 do + over i j rot g@ if [char] * emit else space then + loop + loop + 2drop ; + +\ RGB <-> Grayscale +: lum>rgb ( 0..255 -- pixel ) + dup 8 lshift or + dup 8 lshift or ; + +: pixel>rgb ( pixel -- r g b ) + 256 /mod 256 /mod ; +: rgb>lum ( pixel -- 0..255 ) + pixel>rgb + 722 * swap + 7152 * + swap + 2126 * + 10000 / ; + +: bitmap>graymap ( bmp -- gmp ) + dup bdim graymap + dup bdim nip 0 do + dup bwidth 0 do + over i j rot b@ rgb>lum + over i j rot g! + loop + loop nip ; + +: graymap>bitmap ( gmp -- bmp ) + dup bdim bitmap + dup bdim nip 0 do + dup bwidth 0 do + over i j rot g@ lum>rgb + over i j rot b! + loop + loop nip ; diff --git a/Task/Grayscale-image/Fortran/grayscale-image-1.f b/Task/Grayscale-image/Fortran/grayscale-image-1.f new file mode 100644 index 0000000000..d11eb2ab9f --- /dev/null +++ b/Task/Grayscale-image/Fortran/grayscale-image-1.f @@ -0,0 +1,4 @@ +type scimage + integer, dimension(:,:), pointer :: channel + integer :: width, height +end type scimage diff --git a/Task/Grayscale-image/Fortran/grayscale-image-2.f b/Task/Grayscale-image/Fortran/grayscale-image-2.f new file mode 100644 index 0000000000..850e8a4a50 --- /dev/null +++ b/Task/Grayscale-image/Fortran/grayscale-image-2.f @@ -0,0 +1,7 @@ +interface alloc_img + module procedure alloc_img_rgb, alloc_img_sc +end interface + +interface free_img + module procedure free_img_rgb, free_img_sc +end interface diff --git a/Task/Grayscale-image/Fortran/grayscale-image-3.f b/Task/Grayscale-image/Fortran/grayscale-image-3.f new file mode 100644 index 0000000000..0508ae4a36 --- /dev/null +++ b/Task/Grayscale-image/Fortran/grayscale-image-3.f @@ -0,0 +1,3 @@ +interface assignment(=) + module procedure rgbtosc, sctorgb +end interface diff --git a/Task/Grayscale-image/Fortran/grayscale-image-4.f b/Task/Grayscale-image/Fortran/grayscale-image-4.f new file mode 100644 index 0000000000..34ff5972aa --- /dev/null +++ b/Task/Grayscale-image/Fortran/grayscale-image-4.f @@ -0,0 +1,45 @@ +subroutine alloc_img_sc(img, w, h) + type(scimage) :: img + integer, intent(in) :: w, h + + allocate(img%channel(w, h)) + img%width = w + img%height = h +end subroutine alloc_img_sc + +subroutine free_img_sc(img) + type(scimage) :: img + + if ( associated(img%channel) ) deallocate(img%channel) +end subroutine free_img_sc + +subroutine rgbtosc(sc, colored) + type(rgbimage), intent(in) :: colored + type(scimage), intent(inout) :: sc + + if ( ( .not. valid_image(sc) ) .and. valid_image(colored) ) then + call alloc_img(sc, colored%width, colored%height) + end if + + if ( valid_image(sc) .and. valid_image(colored) ) then + sc%channel = floor(0.2126*colored%red + 0.7152*colored%green + & + 0.0722*colored%blue) + end if + +end subroutine rgbtosc + +subroutine sctorgb(colored, sc) + type(scimage), intent(in) :: sc + type(rgbimage), intent(inout) :: colored + + if ( ( .not. valid_image(colored) ) .and. valid_image(sc) ) then + call alloc_img_rgb(colored, sc%width, sc%height) + end if + + if ( valid_image(sc) .and. valid_image(colored) ) then + colored%red = sc%channel + colored%green = sc%channel + colored%blue = sc%channel + end if + +end subroutine sctorgb diff --git a/Task/Grayscale-image/Fortran/grayscale-image-5.f b/Task/Grayscale-image/Fortran/grayscale-image-5.f new file mode 100644 index 0000000000..c56b8a036c --- /dev/null +++ b/Task/Grayscale-image/Fortran/grayscale-image-5.f @@ -0,0 +1,9 @@ +type(scimage) :: gray +type(rgbimage) :: animage + ! ... here we "load" or create animage + ! while gray must be created or initialized to null + ! or errors can arise... + call init_img(gray) + gray = animage + animage = gray + call output_ppm(an_unit, animage) diff --git a/Task/Grayscale-image/Go/grayscale-image.go b/Task/Grayscale-image/Go/grayscale-image.go new file mode 100644 index 0000000000..179ae3c8b9 --- /dev/null +++ b/Task/Grayscale-image/Go/grayscale-image.go @@ -0,0 +1,100 @@ +package raster + +import ( + "math" + "math/rand" +) + +// Grmap parallels Bitmap, but with an element type of uint16 +// in place of Pixel. +type Grmap struct { + Comments []string + rows, cols int + px []uint16 + pxRow [][]uint16 +} + +// NewGrmap constructor. +func NewGrmap(x, y int) (b *Grmap) { + g := &Grmap{ + Comments: []string{creator}, // creator a const in bitmap source file + rows: y, + cols: x, + px: make([]uint16, x*y), + pxRow: make([][]uint16, y), + } + x0, x1 := 0, x + for i := range g.pxRow { + g.pxRow[i] = g.px[x0:x1] + x0, x1 = x1, x1+x + } + return g +} + +func (b *Grmap) Extent() (cols, rows int) { + return b.cols, b.rows +} + +func (g *Grmap) Fill(c uint16) { + for i := range g.px { + g.px[i] = c + } +} + +func (g *Grmap) SetPx(x, y int, c uint16) bool { + defer func() { recover() }() + g.pxRow[y][x] = c + return true +} + +func (g *Grmap) GetPx(x, y int) (uint16, bool) { + defer func() { recover() }() + return g.pxRow[y][x], true +} + +// Grmap method of Bitmap, converts (color) Bitmap to (grayscale) Grmap +func (b *Bitmap) Grmap() *Grmap { + g := NewGrmap(b.cols, b.rows) + g.Comments = append([]string{}, b.Comments...) + for i, p := range b.px { + g.px[i] = uint16((int64(p.R)*2126 + int64(p.G)*7152 + int64(p.B)*722) * + math.MaxUint16 / (math.MaxUint8 * 10000)) + } + return g +} + +// Bitmap method Grmap, converts Grmap to Bitmap. All pixels in the resulting +// color Bitmap will be (very nearly) shades of gray. +func (g *Grmap) Bitmap() *Bitmap { + b := NewBitmap(g.cols, g.rows) + b.Comments = append([]string{}, g.Comments...) + for i, p := range g.px { + roundedSum := int(p) * 3 * math.MaxUint8 / math.MaxUint16 + rounded := uint8(roundedSum / 3) + remainder := roundedSum % 3 + b.px[i].R = rounded + b.px[i].G = rounded + b.px[i].B = rounded + if remainder > 0 { + odd := rand.Intn(3) + switch odd + (remainder * 3) { + case 3: + b.px[i].R++ + case 4: + b.px[i].G++ + case 5: + b.px[i].B++ + case 6: + b.px[i].G++ + b.px[i].B++ + case 7: + b.px[i].R++ + b.px[i].B++ + case 8: + b.px[i].R++ + b.px[i].G++ + } + } + } + return b +} diff --git a/Task/Grayscale-image/Haskell/grayscale-image.hs b/Task/Grayscale-image/Haskell/grayscale-image.hs new file mode 100644 index 0000000000..c40a40d61d --- /dev/null +++ b/Task/Grayscale-image/Haskell/grayscale-image.hs @@ -0,0 +1,18 @@ +module Bitmap.Gray(module Bitmap.Gray) where + +import Bitmap +import Control.Monad.ST + +newtype Gray = Gray Int deriving (Eq, Ord) + +instance Color Gray where + luminance (Gray x) = x + black = Gray 0 + white = Gray 255 + toNetpbm = map $ toEnum . luminance + fromNetpbm = map $ Gray . fromEnum + netpbmMagicNumber _ = "P5" + netpbmMaxval _ = "255" + +toGrayImage :: Color c => Image s c -> ST s (Image s Gray) +toGrayImage = mapImage $ Gray . luminance diff --git a/Task/Grayscale-image/J/grayscale-image-1.j b/Task/Grayscale-image/J/grayscale-image-1.j new file mode 100644 index 0000000000..a213f5543d --- /dev/null +++ b/Task/Grayscale-image/J/grayscale-image-1.j @@ -0,0 +1,6 @@ +NB. converts the image to grayscale according to formula +NB. L = 0.2126*R + 0.7152*G + 0.0722*B +toGray=: [: <. +/ .*"1&0.2126 0.7152 0.0722 + +NB. converts grayscale image to the color image, with all channels equal +toColor=: 3 & $"0 diff --git a/Task/Grayscale-image/J/grayscale-image-2.j b/Task/Grayscale-image/J/grayscale-image-2.j new file mode 100644 index 0000000000..ff34afa681 --- /dev/null +++ b/Task/Grayscale-image/J/grayscale-image-2.j @@ -0,0 +1 @@ +viewRGB toColor toGray myimg diff --git a/Task/Grayscale-image/Java/grayscale-image.java b/Task/Grayscale-image/Java/grayscale-image.java new file mode 100644 index 0000000000..10171964eb --- /dev/null +++ b/Task/Grayscale-image/Java/grayscale-image.java @@ -0,0 +1,23 @@ +void convertToGrayscale(final BufferedImage image){ + for(int i=0; i> 24) & 255; + int red = (color >> 16) & 255; + int green = (color >> 8) & 255; + int blue = (color) & 255; + + final int lum = (int)(0.2126 * red + 0.7152 * green + 0.0722 * blue); + + alpha = (alpha << 24); + red = (lum << 16); + green = (lum << 8); + blue = lum; + + color = alpha + red + green + blue; + + image.setRGB(i,j,color); + } + } +} diff --git a/Task/Grayscale-image/JavaScript/grayscale-image.js b/Task/Grayscale-image/JavaScript/grayscale-image.js new file mode 100644 index 0000000000..c5c4d9df66 --- /dev/null +++ b/Task/Grayscale-image/JavaScript/grayscale-image.js @@ -0,0 +1,38 @@ + + diff --git a/Task/Grayscale-image/Lua/grayscale-image.lua b/Task/Grayscale-image/Lua/grayscale-image.lua new file mode 100644 index 0000000000..1ae16f71ff --- /dev/null +++ b/Task/Grayscale-image/Lua/grayscale-image.lua @@ -0,0 +1,26 @@ +function ConvertToGrayscaleImage( bitmap ) + local size_x, size_y = #bitmap, #bitmap[1] + local gray_im = {} + + for i = 1, size_x do + gray_im[i] = {} + for j = 1, size_y do + gray_im[i][j] = math.floor( 0.2126*bitmap[i][j][1] + 0.7152*bitmap[i][j][2] + 0.0722*bitmap[i][j][3] ) + end + end + + return gray_im +end + +function ConvertToColorImage( gray_im ) + local size_x, size_y = #gray_im, #gray_im[1] + local bitmap = Allocate_Bitmap( size_x, size_y ) -- this function is defined at http://rosettacode.org/wiki/Basic_bitmap_storage#Lua + + for i = 1, size_x do + for j = 1, size_y do + bitmap[i][j] = { gray_im[i][j], gray_im[i][j], gray_im[i][j] } + end + end + + return bitmap +end diff --git a/Task/Grayscale-image/MATLAB/grayscale-image.m b/Task/Grayscale-image/MATLAB/grayscale-image.m new file mode 100644 index 0000000000..df7de2334b --- /dev/null +++ b/Task/Grayscale-image/MATLAB/grayscale-image.m @@ -0,0 +1,2 @@ +function [grayImage] = colortograyscale(inputImage) + grayImage = rgb2gray(inputImage); diff --git a/Task/Grayscale-image/Mathematica/grayscale-image.mathematica b/Task/Grayscale-image/Mathematica/grayscale-image.mathematica new file mode 100644 index 0000000000..3c5d046134 --- /dev/null +++ b/Task/Grayscale-image/Mathematica/grayscale-image.mathematica @@ -0,0 +1,2 @@ +toGrayscale[rgb_Image] := ImageApply[#.{0.2126, 0.7152, 0.0722}&, rgb] +toFakeRGB[L_Image] := ImageApply[{#, #, #}&, L] diff --git a/Task/Grayscale-image/PHP/grayscale-image.php b/Task/Grayscale-image/PHP/grayscale-image.php new file mode 100644 index 0000000000..66cd097d1c --- /dev/null +++ b/Task/Grayscale-image/PHP/grayscale-image.php @@ -0,0 +1,21 @@ +class BitmapGrayscale extends Bitmap { + public function toGrayscale(){ + for ($i = 0; $i < $this->h; $i++){ + for ($j = 0; $j < $this->w; $j++){ + $l = ($this->data[$j][$i][0] * 0.2126) + + ($this->data[$j][$i][1] * 0.7152) + + ($this->data[$j][$i][2] * 0.0722); + $l = round($l); + $this->data[$j][$i] = array($l,$l,$l); + } + } + } +} + +$b = new BitmapGrayscale(16,16); +$b->fill(0,0,null,null, array(255,255,0)); +$b->setPixel(0, 15, array(255,0,0)); +$b->setPixel(0, 14, array(0,255,0)); +$b->setPixel(0, 13, array(0,0,255)); +$b->toGrayscale(); +$b->writeP6('p6-grayscale.ppm'); diff --git a/Task/Grayscale-image/Perl/grayscale-image.pl b/Task/Grayscale-image/Perl/grayscale-image.pl new file mode 100644 index 0000000000..32e61eaebb --- /dev/null +++ b/Task/Grayscale-image/Perl/grayscale-image.pl @@ -0,0 +1,27 @@ +#! /usr/bin/perl + +use strict; +use Image::Imlib2; + +sub tograyscale +{ + my $img = shift; + my $gimg = Image::Imlib2->new($img->width, $img->height); + for ( my $x = 0; $x < $gimg->width; $x++ ) { + for ( my $y = 0; $y < $gimg->height; $y++ ) { + my ( $r, $g, $b, $a ) = $img->query_pixel($x, $y); + my $gray = int(0.2126 * $r + 0.7152 * $g + 0.0722 * $b); + # discard alpha info... + $gimg->set_color($gray, $gray, $gray, 255); + $gimg->draw_point($x, $y); + } + } + return $gimg; +} + +my $animage = Image::Imlib2->load("Lenna100.jpg"); +my $gscale = tograyscale($animage); +$gscale->set_quality(80); +$gscale->save("Lennagray.jpg"); + +exit 0; diff --git a/Task/Grayscale-image/PicoLisp/grayscale-image-1.l b/Task/Grayscale-image/PicoLisp/grayscale-image-1.l new file mode 100644 index 0000000000..98f0e9a7be --- /dev/null +++ b/Task/Grayscale-image/PicoLisp/grayscale-image-1.l @@ -0,0 +1,23 @@ +# Convert color image (PPM) to greyscale image (PGM) +(de ppm->pgm (Ppm) + (mapcar + '((Y) + (mapcar + '((C) + (/ + (+ + (* (car C) 2126) # Red + (* (cadr C) 7152) # Green + (* (caddr C) 722) ) # Blue + 10000 ) ) + Y ) ) + Ppm ) ) + +# Convert greyscale image (PGM) to color image (PPM) +(de pgm->ppm (Pgm) + (mapcar + '((Y) + (mapcar + '((G) (list G G G)) + Y ) ) + Pgm ) ) diff --git a/Task/Grayscale-image/PicoLisp/grayscale-image-2.l b/Task/Grayscale-image/PicoLisp/grayscale-image-2.l new file mode 100644 index 0000000000..ff1ae80feb --- /dev/null +++ b/Task/Grayscale-image/PicoLisp/grayscale-image-2.l @@ -0,0 +1,26 @@ +# Write greyscale image (PGM) to file +(de pgmWrite (Pgm File) + (out File + (prinl "P5") + (prinl (length (car Pgm)) " " (length Pgm)) + (prinl 255) + (for Y Pgm (apply wr Y)) ) ) + +# Create an empty image of 120 x 90 pixels +(setq *Ppm (make (do 90 (link (need 120))))) + +# Fill background with green color +(ppmFill *Ppm 0 255 0) + +# Draw a diagonal line +(for I 80 (ppmSetPixel *Ppm I I 0 0 0)) + + +# Convert to greyscale image (PGM) +(setq *Pgm (ppm->pgm *Ppm)) + +# Write greyscale image to .pgm file +(pgmWrite *Pgm "img.pgm") + +# Convert to color image and write to .ppm file +(ppmWrite (pgm->ppm *Pgm) "img.ppm") diff --git a/Task/Grayscale-image/Python/grayscale-image.py b/Task/Grayscale-image/Python/grayscale-image.py new file mode 100644 index 0000000000..3b45bd4cf7 --- /dev/null +++ b/Task/Grayscale-image/Python/grayscale-image.py @@ -0,0 +1,53 @@ +# String masquerading as ppm file (version P3) +import io +ppmfileout = io.StringIO('') + +def togreyscale(self): + for h in range(self.height): + for w in range(self.width): + r, g, b = self.get(w, h) + l = int(0.2126 * r + 0.7152 * g + 0.0722 * b) + self.set(w, h, Colour(l, l, l)) + +Bitmap.togreyscale = togreyscale + + +# Draw something simple +bitmap = Bitmap(4, 4, white) +bitmap.fillrect(1, 0, 1, 2, Colour(127, 0, 63)) +bitmap.set(3, 3, Colour(0, 127, 31)) +print('Colour:') +# Write to the open 'file' handle +bitmap.writeppmp3(ppmfileout) +print(ppmfileout.getvalue()) +print('Grey:') +bitmap.togreyscale() +ppmfileout = io.StringIO('') +bitmap.writeppmp3(ppmfileout) +print(ppmfileout.getvalue()) + + +''' +The print statement above produces the following output : + +Colour: +P3 +# generated from Bitmap.writeppmp3 +4 4 +255 + 255 255 255 255 255 255 255 255 255 0 127 31 + 255 255 255 255 255 255 255 255 255 255 255 255 + 255 255 255 127 0 63 255 255 255 255 255 255 + 255 255 255 127 0 63 255 255 255 255 255 255 + +Grey: +P3 +# generated from Bitmap.writeppmp3 +4 4 +254 + 254 254 254 254 254 254 254 254 254 93 93 93 + 254 254 254 254 254 254 254 254 254 254 254 254 + 254 254 254 31 31 31 254 254 254 254 254 254 + 254 254 254 31 31 31 254 254 254 254 254 254 + +''' diff --git a/Task/Grayscale-image/R/grayscale-image.r b/Task/Grayscale-image/R/grayscale-image.r new file mode 100644 index 0000000000..c7c6d33a37 --- /dev/null +++ b/Task/Grayscale-image/R/grayscale-image.r @@ -0,0 +1,33 @@ +# Conversion from Grey to RGB uses the following code +setAs("pixmapGrey", "pixmapRGB", +function(from, to){ + z = new(to, as(from, "pixmap")) + z@red = from@grey + z@green = from@grey + z@blue = from@grey + z@channels = c("red", "green", "blue") + z +}) + +# Conversion from RGB to grey uses built-in coefficients of 0.3, 0.59, 0.11. To see this, type +getMethods(addChannels) + +# We can override this behaviour with +setMethod("addChannels", "pixmapRGB", +function(object, coef=NULL){ + if(is.null(coef)) coef = c(0.2126, 0.7152, 0.0722) + z = new("pixmapGrey", object) + z@grey = coef[1] * object@red + coef[2] * object@green + + coef[3] * object@blue + z@channels = "grey" + z +}) + +# Colour image +plot(p1 <- pixmapRGB(c(c(1,0,0,0,0,1), c(0,1,0,0,1,0), c(0,0,1,1,0,0)), nrow=6, ncol=6)) + +#Convert to grey +plot(p2 <- as(p1, "pixmapGrey")) + +# Convert back to "colour" +plot(p3 <- as(p2, "pixmapRGB")) diff --git a/Task/Grayscale-image/REXX/grayscale-image.rexx b/Task/Grayscale-image/REXX/grayscale-image.rexx new file mode 100644 index 0000000000..afbe8ea833 --- /dev/null +++ b/Task/Grayscale-image/REXX/grayscale-image.rexx @@ -0,0 +1,16 @@ +/*REXX program to convert a RGB image to grayscale. */ +blue='00 00 ff'x /*define the blue color. */ +image.=blue /*set the entire IMAGE to blue. */ + width= 60 /* width of the IMAGE. */ +height=100 /*height " " " */ + + do j=1 for width + do k=1 for height + r= left(image.j.k,1) ; r=c2d(r) /*extract red & convert*/ + g=substr(image.j.k,2,1) ; g=c2d(g) /* " green " " */ + b= right(image.j.k,1) ; b=c2d(b) /* " blue " " */ + ddd=right(trunc(.2126*r + .7152*g + .0722*b),3,0) /*──► greyscale.*/ + image.j.k=right(d2c(ddd,6),3,0) /*... and transform back.*/ + end /*j*/ + end /*k*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Grayscale-image/Ruby/grayscale-image.rb b/Task/Grayscale-image/Ruby/grayscale-image.rb new file mode 100644 index 0000000000..3b49d6fa58 --- /dev/null +++ b/Task/Grayscale-image/Ruby/grayscale-image.rb @@ -0,0 +1,18 @@ +class RGBColour + def to_grayscale + luminosity = Integer(0.2126*@red + 0.7152*@green + 0.0722*@blue) + self.class.new(luminosity, luminosity, luminosity) + end +end + +class Pixmap + def to_grayscale + gray = self.class.new(@width, @height) + @width.times do |x| + @height.times do |y| + gray[x,y] = self[x,y].to_grayscale + end + end + gray + end +end diff --git a/Task/Grayscale-image/Scala/grayscale-image.scala b/Task/Grayscale-image/Scala/grayscale-image.scala new file mode 100644 index 0000000000..feb828b7aa --- /dev/null +++ b/Task/Grayscale-image/Scala/grayscale-image.scala @@ -0,0 +1,10 @@ +object BitmapOps { + def luminosity(c:Color)=(0.2126*c.getRed + 0.7152*c.getGreen + 0.0722*c.getBlue+0.5).toInt + + def grayscale(bm:RgbBitmap)={ + val image=new RgbBitmap(bm.width, bm.height) + for(x <- 0 until bm.width; y <- 0 until bm.height; l=luminosity(bm.getPixel(x,y))) + image.setPixel(x, y, new Color(l,l,l)) + image + } +} diff --git a/Task/Grayscale-image/Tcl/grayscale-image.tcl b/Task/Grayscale-image/Tcl/grayscale-image.tcl new file mode 100644 index 0000000000..73d36a7c9d --- /dev/null +++ b/Task/Grayscale-image/Tcl/grayscale-image.tcl @@ -0,0 +1,13 @@ +package require Tk + +proc grayscale image { + set w [image width $image] + set h [image height $image] + for {set x 0} {$x<$w} {incr x} { + for {set y 0} {$y<$h} {incr y} { + lassign [$image get $x $y] r g b + set l [expr {int(0.2126*$r + 0.7152*$g + 0.0722*$b)}] + $image put [format "#%02x%02x%02x" $l $l $l] -to $x $y + } + } +} diff --git a/Task/Greatest-common-divisor/0DESCRIPTION b/Task/Greatest-common-divisor/0DESCRIPTION new file mode 100644 index 0000000000..eaac028def --- /dev/null +++ b/Task/Greatest-common-divisor/0DESCRIPTION @@ -0,0 +1 @@ +This task requires the finding of the greatest common divisor of two integers. diff --git a/Task/Greatest-common-divisor/1META.yaml b/Task/Greatest-common-divisor/1META.yaml new file mode 100644 index 0000000000..e2564807ec --- /dev/null +++ b/Task/Greatest-common-divisor/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Recursion +note: Arithmetic operations diff --git a/Task/Greatest-common-divisor/ACL2/greatest-common-divisor.acl2 b/Task/Greatest-common-divisor/ACL2/greatest-common-divisor.acl2 new file mode 100644 index 0000000000..b8c821e7a7 --- /dev/null +++ b/Task/Greatest-common-divisor/ACL2/greatest-common-divisor.acl2 @@ -0,0 +1,8 @@ +(include-book "arithmetic-3/floor-mod/floor-mod" :dir :system) + +(defun gcd$ (x y) + (declare (xargs :guard (and (natp x) (natp y)))) + (cond ((or (not (natp x)) (< y 0)) + nil) + ((zp y) x) + (t (gcd$ y (mod x y))))) diff --git a/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg b/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg new file mode 100644 index 0000000000..2e357e0524 --- /dev/null +++ b/Task/Greatest-common-divisor/ALGOL-68/greatest-common-divisor.alg @@ -0,0 +1,17 @@ +PROC gcd = (INT a, b) INT: ( + IF a = 0 THEN + b + ELIF b = 0 THEN + a + ELIF a > b THEN + gcd(b, a MOD b) + ELSE + gcd(a, b MOD a) + FI +); +test:( + INT a = 33, b = 77; + printf(($x"The gcd of"g" and "g" is "gl$,a,b,gcd(a,b))); + INT c = 49865, d = 69811; + printf(($x"The gcd of"g" and "g" is "gl$,c,d,gcd(c,d))) +) diff --git a/Task/Greatest-common-divisor/AWK/greatest-common-divisor.awk b/Task/Greatest-common-divisor/AWK/greatest-common-divisor.awk new file mode 100644 index 0000000000..d85099e87c --- /dev/null +++ b/Task/Greatest-common-divisor/AWK/greatest-common-divisor.awk @@ -0,0 +1,7 @@ +$ awk 'func gcd(p,q){return(q?gcd(q,(p%q)):p)}{print gcd($1,$2)}' +12 16 +4 +22 33 +11 +45 67 +1 diff --git a/Task/Greatest-common-divisor/ActionScript/greatest-common-divisor.as b/Task/Greatest-common-divisor/ActionScript/greatest-common-divisor.as new file mode 100644 index 0000000000..5d788c4fde --- /dev/null +++ b/Task/Greatest-common-divisor/ActionScript/greatest-common-divisor.as @@ -0,0 +1,20 @@ +//Euclidean algorithm +function gcd(a:int,b:int):int +{ + var tmp:int; + //Swap the numbers so a >= b + if(a < b) + { + tmp = a; + a = b; + b = tmp; + } + //Find the gcd + while(b != 0) + { + tmp = a % b; + a = b; + b = tmp; + } + return a; +} diff --git a/Task/Greatest-common-divisor/Ada/greatest-common-divisor.ada b/Task/Greatest-common-divisor/Ada/greatest-common-divisor.ada new file mode 100644 index 0000000000..2175f4f609 --- /dev/null +++ b/Task/Greatest-common-divisor/Ada/greatest-common-divisor.ada @@ -0,0 +1,21 @@ +with Ada.Text_Io; use Ada.Text_Io; + +procedure Gcd_Test is + function Gcd (A, B : Integer) return Integer is + M : Integer := A; + N : Integer := B; + T : Integer; + begin + while N /= 0 loop + T := M; + M := N; + N := T mod N; + end loop; + return M; + end Gcd; + +begin + Put_Line("GCD of 100, 5 is" & Integer'Image(Gcd(100, 5))); + Put_Line("GCD of 5, 100 is" & Integer'Image(Gcd(5, 100))); + Put_Line("GCD of 7, 23 is" & Integer'Image(Gcd(7, 23))); +end Gcd_Test; diff --git a/Task/Greatest-common-divisor/Alore/greatest-common-divisor-1.alore b/Task/Greatest-common-divisor/Alore/greatest-common-divisor-1.alore new file mode 100644 index 0000000000..4d1ae8100d --- /dev/null +++ b/Task/Greatest-common-divisor/Alore/greatest-common-divisor-1.alore @@ -0,0 +1,6 @@ +def gcd(a as Int, b as Int) as Int + while b != 0 + a,b = b, a mod b + end + return Abs(a) +end diff --git a/Task/Greatest-common-divisor/Alore/greatest-common-divisor-2.alore b/Task/Greatest-common-divisor/Alore/greatest-common-divisor-2.alore new file mode 100644 index 0000000000..4c247b32a5 --- /dev/null +++ b/Task/Greatest-common-divisor/Alore/greatest-common-divisor-2.alore @@ -0,0 +1,14 @@ +_GCD(18, 12) +_GCD(1071, 1029) +_GCD(3528, 3780) + +Func _GCD($ia, $ib) + Local $ret = "GCD of " & $ia & " : " & $ib & " = " + Local $imod + While True + $imod = Mod($ia, $ib) + If $imod = 0 Then Return ConsoleWrite($ret & $ib & @CRLF) + $ia = $ib + $ib = $imod + WEnd +EndFunc ;==>_GCD diff --git a/Task/Greatest-common-divisor/AutoHotkey/greatest-common-divisor.ahk b/Task/Greatest-common-divisor/AutoHotkey/greatest-common-divisor.ahk new file mode 100644 index 0000000000..80b3078058 --- /dev/null +++ b/Task/Greatest-common-divisor/AutoHotkey/greatest-common-divisor.ahk @@ -0,0 +1,3 @@ +GCD(a,b) { + Return b=0 ? Abs(a) : Gcd(b,mod(a,b)) +} diff --git a/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-1.bas b/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-1.bas new file mode 100644 index 0000000000..b6f0b81b2f --- /dev/null +++ b/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-1.bas @@ -0,0 +1,13 @@ +function gcd(a%, b%) + if a > b then + factor = a + else + factor = b + end if + for l = factor to 1 step -1 + if a mod l = 0 and b mod l = 0 then + gcd = l + end if + next l + gcd = 1 +end function diff --git a/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-2.bas b/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-2.bas new file mode 100644 index 0000000000..c34f5699fa --- /dev/null +++ b/Task/Greatest-common-divisor/BASIC/greatest-common-divisor-2.bas @@ -0,0 +1,6 @@ +function gcd(a%, b%) + if a = 0 gcd = b + if b = 0 gcd = a + if a > b gcd = gcd(b, a mod b) + gcd = gcd(a, b mod a) +end function diff --git a/Task/Greatest-common-divisor/BBC-BASIC/greatest-common-divisor.bbc b/Task/Greatest-common-divisor/BBC-BASIC/greatest-common-divisor.bbc new file mode 100644 index 0000000000..e373c2197b --- /dev/null +++ b/Task/Greatest-common-divisor/BBC-BASIC/greatest-common-divisor.bbc @@ -0,0 +1,8 @@ + DEF FN_GCD_Iterative_Euclid(A%, B%) + LOCAL C% + WHILE B% + C% = A% + A% = B% + B% = C% MOD B% + ENDWHILE + = ABS(A%) diff --git a/Task/Greatest-common-divisor/Batch-File/greatest-common-divisor.bat b/Task/Greatest-common-divisor/Batch-File/greatest-common-divisor.bat new file mode 100644 index 0000000000..0e0cb9dc2e --- /dev/null +++ b/Task/Greatest-common-divisor/Batch-File/greatest-common-divisor.bat @@ -0,0 +1,22 @@ +:: gcd.cmd +@echo off +:gcd +if "%2" equ "" goto :instructions +if "%1" equ "" goto :instructions + +if %2 equ 0 ( + set final=%1 + goto :done +) +set /a res = %1 %% %2 +call :gcd %2 %res% +goto :eof + +:done +echo gcd=%final% +goto :eof + +:instructions +echo Syntax: +echo GCD {a} {b} +echo. diff --git a/Task/Greatest-common-divisor/Bc/greatest-common-divisor-1.bc b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-1.bc new file mode 100644 index 0000000000..41b0960409 --- /dev/null +++ b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-1.bc @@ -0,0 +1,17 @@ +define even(a) +{ + if ( a % 2 == 0 ) { + return(1); + } else { + return(0); + } +} + +define abs(a) +{ + if (a<0) { + return(-a); + } else { + return(a); + } +} diff --git a/Task/Greatest-common-divisor/Bc/greatest-common-divisor-2.bc b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-2.bc new file mode 100644 index 0000000000..a824a2b264 --- /dev/null +++ b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-2.bc @@ -0,0 +1,9 @@ +define gcd_iter(u, v) +{ + while(v) { + t = u; + u = v; + v = t % v; + } + return(abs(u)); +} diff --git a/Task/Greatest-common-divisor/Bc/greatest-common-divisor-3.bc b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-3.bc new file mode 100644 index 0000000000..803034fc78 --- /dev/null +++ b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-3.bc @@ -0,0 +1,8 @@ +define gcd(u, v) +{ + if (v) { + return ( gcd(v, u%v) ); + } else { + return (abs(u)); + } +} diff --git a/Task/Greatest-common-divisor/Bc/greatest-common-divisor-4.bc b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-4.bc new file mode 100644 index 0000000000..4140e0cd96 --- /dev/null +++ b/Task/Greatest-common-divisor/Bc/greatest-common-divisor-4.bc @@ -0,0 +1,32 @@ +define gcd_bin(u, v) +{ + u = abs(u); + v = abs(v); + if ( u < v ) { + t = u; u = v; v = t; + } + if ( v == 0 ) { return(u); } + k = 1; + while (even(u) && even(v)) { + u = u / 2; v = v / 2; + k = k * 2; + } + if ( even(u) ) { + t = -v; + } else { + t = u; + } + while (t) { + while (even(t)) { + t = t / 2; + } + + if (t > 0) { + u = t; + } else { + v = -t; + } + t = u - v; + } + return (u * k); +} diff --git a/Task/Greatest-common-divisor/Befunge/greatest-common-divisor.bf b/Task/Greatest-common-divisor/Befunge/greatest-common-divisor.bf new file mode 100644 index 0000000000..064901c9a3 --- /dev/null +++ b/Task/Greatest-common-divisor/Befunge/greatest-common-divisor.bf @@ -0,0 +1,2 @@ +#v&< @.$< +:<\g05%p05:_^# diff --git a/Task/Greatest-common-divisor/Bracmat/greatest-common-divisor.bracmat b/Task/Greatest-common-divisor/Bracmat/greatest-common-divisor.bracmat new file mode 100644 index 0000000000..97fb0f5c52 --- /dev/null +++ b/Task/Greatest-common-divisor/Bracmat/greatest-common-divisor.bracmat @@ -0,0 +1 @@ +(gcd=a b.!arg:(?a.?b)&!b*den$(!a*!b^-1)^-1); diff --git a/Task/Greatest-common-divisor/C/greatest-common-divisor-1.c b/Task/Greatest-common-divisor/C/greatest-common-divisor-1.c new file mode 100644 index 0000000000..496c80c421 --- /dev/null +++ b/Task/Greatest-common-divisor/C/greatest-common-divisor-1.c @@ -0,0 +1,10 @@ +int +gcd_iter(int u, int v) { + int t; + while (v) { + t = u; + u = v; + v = t % v; + } + return u < 0 ? -u : u; /* abs(u) */ +} diff --git a/Task/Greatest-common-divisor/C/greatest-common-divisor-2.c b/Task/Greatest-common-divisor/C/greatest-common-divisor-2.c new file mode 100644 index 0000000000..f56c2a022a --- /dev/null +++ b/Task/Greatest-common-divisor/C/greatest-common-divisor-2.c @@ -0,0 +1,7 @@ +int +gcd(int u, int v) { + if (v) + return gcd(v, u % v); + else + return u < 0 ? -u : u; /* abs(u) */ +} diff --git a/Task/Greatest-common-divisor/C/greatest-common-divisor-3.c b/Task/Greatest-common-divisor/C/greatest-common-divisor-3.c new file mode 100644 index 0000000000..cac7051021 --- /dev/null +++ b/Task/Greatest-common-divisor/C/greatest-common-divisor-3.c @@ -0,0 +1,34 @@ +int +gcd_bin(int u, int v) { + int t, k; + + u = u < 0 ? -u : u; /* abs(u) */ + v = v < 0 ? -v : v; + if (u < v) { + t = u; + u = v; + v = t; + } + if (v == 0) + return u; + + k = 1; + while (u & 1 == 0 && v & 1 == 0) { /* u, v - even */ + u >>= 1; v >>= 1; + k <<= 1; + } + + t = (u & 1) ? -v : u; + while (t) { + while (t & 1 == 0) + t >>= 1; + + if (t > 0) + u = t; + else + v = -t; + + t = u - v; + } + return u * k; +} diff --git a/Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cobol b/Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cobol new file mode 100644 index 0000000000..a2e5df7080 --- /dev/null +++ b/Task/Greatest-common-divisor/COBOL/greatest-common-divisor.cobol @@ -0,0 +1,28 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. GCD. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 A PIC 9(10) VALUE ZEROES. + 01 B PIC 9(10) VALUE ZEROES. + 01 TEMP PIC 9(10) VALUE ZEROES. + + PROCEDURE DIVISION. + Begin. + DISPLAY "Enter first number, max 10 digits." + ACCEPT A + DISPLAY "Enter second number, max 10 digits." + ACCEPT B + IF A < B + MOVE B TO TEMP + MOVE A TO B + MOVE TEMP TO B + END-IF + + PERFORM UNTIL B = 0 + MOVE A TO TEMP + MOVE B TO A + DIVIDE TEMP BY B GIVING TEMP REMAINDER B + END-PERFORM + DISPLAY "The gcd is " A + STOP RUN. diff --git a/Task/Greatest-common-divisor/Clojure/greatest-common-divisor.clj b/Task/Greatest-common-divisor/Clojure/greatest-common-divisor.clj new file mode 100644 index 0000000000..47c2b66bbe --- /dev/null +++ b/Task/Greatest-common-divisor/Clojure/greatest-common-divisor.clj @@ -0,0 +1,6 @@ +(defn gcd + "(gcd a b) computes the greatest common divisor of a and b." + [a b] + (if (zero? b) + a + (recur b (mod a b)))) diff --git a/Task/Greatest-common-divisor/Cobra/greatest-common-divisor.cobra b/Task/Greatest-common-divisor/Cobra/greatest-common-divisor.cobra new file mode 100644 index 0000000000..c7bd1b9aa8 --- /dev/null +++ b/Task/Greatest-common-divisor/Cobra/greatest-common-divisor.cobra @@ -0,0 +1,12 @@ +class Rosetta + def gcd(u as number, v as number) as number + u, v = u.abs, v.abs + while v > 0 + u, v = v, u % v + return u + + def main + print "gcd of [12] and [8] is [.gcd(12, 8)]" + print "gcd of [12] and [-8] is [.gcd(12, -8)]" + print "gcd of [96] and [27] is [.gcd(27, 96)]" + print "gcd of [51] and [34] is [.gcd(34, 51)]" diff --git a/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-1.coffee b/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-1.coffee new file mode 100644 index 0000000000..19cf6bd574 --- /dev/null +++ b/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-1.coffee @@ -0,0 +1,3 @@ +gcd = (x, y) -> + return x if y == 0 + gcd(y, x % y) diff --git a/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-2.coffee b/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-2.coffee new file mode 100644 index 0000000000..7a900f861b --- /dev/null +++ b/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-2.coffee @@ -0,0 +1,9 @@ +ggt = (x,y) -> + max_teiler = Math.min(x,y) + ggt = 0 + for teiler in [1..max_teiler] + if x % teiler == 0 and y % teiler == 0 + ggt = teiler + return ggt + +alert ggt(40902,24140) diff --git a/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-1.lisp b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-1.lisp new file mode 100644 index 0000000000..47a4a8a277 --- /dev/null +++ b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-1.lisp @@ -0,0 +1,2 @@ +CL-USER> (gcd 2345 5432) +7 diff --git a/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-2.lisp b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-2.lisp new file mode 100644 index 0000000000..d4eba491ba --- /dev/null +++ b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-2.lisp @@ -0,0 +1,3 @@ +(defun gcd2 (a b) + (do () ((zerop b) (abs a)) + (shiftf a b (mod a b)))) diff --git a/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-3.lisp b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-3.lisp new file mode 100644 index 0000000000..835e20ebdc --- /dev/null +++ b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-3.lisp @@ -0,0 +1,3 @@ +(defun gcd2 (a b) + (if (zerop b) a + (gcd2 b (mod a b)))) diff --git a/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-4.lisp b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-4.lisp new file mode 100644 index 0000000000..49f8d8ce80 --- /dev/null +++ b/Task/Greatest-common-divisor/Common-Lisp/greatest-common-divisor-4.lisp @@ -0,0 +1,5 @@ +(defun gcd2 (a b) + (loop for x = a then y + and y = b then (mod x y) + until (zerop y) + finally (return x))) diff --git a/Task/Greatest-common-divisor/D/greatest-common-divisor.d b/Task/Greatest-common-divisor/D/greatest-common-divisor.d new file mode 100644 index 0000000000..49d2f710e2 --- /dev/null +++ b/Task/Greatest-common-divisor/D/greatest-common-divisor.d @@ -0,0 +1,12 @@ +import std.stdio, std.numeric; + +long myGCD(in long x, in long y) pure nothrow { + if (y == 0) + return x; + return myGCD(y, x % y); +} + +void main() { + writeln(gcd(15, 10)); // from Phobos + writeln(myGCD(15, 10)); +} diff --git a/Task/Greatest-common-divisor/DWScript/greatest-common-divisor.dwscript b/Task/Greatest-common-divisor/DWScript/greatest-common-divisor.dwscript new file mode 100644 index 0000000000..dc8d25cc21 --- /dev/null +++ b/Task/Greatest-common-divisor/DWScript/greatest-common-divisor.dwscript @@ -0,0 +1 @@ +PrintLn(Gcd(231, 210)); diff --git a/Task/Greatest-common-divisor/Dc/greatest-common-divisor.dc b/Task/Greatest-common-divisor/Dc/greatest-common-divisor.dc new file mode 100644 index 0000000000..ca79ba1bd6 --- /dev/null +++ b/Task/Greatest-common-divisor/Dc/greatest-common-divisor.dc @@ -0,0 +1 @@ +[dSa%Lard0 a b) (gcd (- a b) b)) + (t a))) diff --git a/Task/Greatest-common-divisor/Erlang/greatest-common-divisor.erl b/Task/Greatest-common-divisor/Erlang/greatest-common-divisor.erl new file mode 100644 index 0000000000..49faf59dd0 --- /dev/null +++ b/Task/Greatest-common-divisor/Erlang/greatest-common-divisor.erl @@ -0,0 +1,4 @@ +gcd(0,B) -> abs(B); +gcd(A,0) -> abs(A); +gcd(A,B) when A > B -> gcd(B, A rem B); +gcd(A,B) -> gcd(A, B rem A). diff --git a/Task/Greatest-common-divisor/Euler-Math-Toolbox/greatest-common-divisor.euler b/Task/Greatest-common-divisor/Euler-Math-Toolbox/greatest-common-divisor.euler new file mode 100644 index 0000000000..7dac2aa065 --- /dev/null +++ b/Task/Greatest-common-divisor/Euler-Math-Toolbox/greatest-common-divisor.euler @@ -0,0 +1,13 @@ +>ggt(123456795,1234567851) + 33 +>function myggt (n:index, m:index) ... +$ if nmyggt(123456795,1234567851) + 33 diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.euphoria b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.euphoria new file mode 100644 index 0000000000..2e11788ed5 --- /dev/null +++ b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-1.euphoria @@ -0,0 +1,13 @@ +function gcd_iter(integer u, integer v) + integer t + while v do + t = u + u = v + v = remainder(t, v) + end while + if u < 0 then + return -u + else + return u + end if +end function diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.euphoria b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.euphoria new file mode 100644 index 0000000000..d51bc2317f --- /dev/null +++ b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-2.euphoria @@ -0,0 +1,9 @@ +function gcd(integer u, integer v) + if v then + return gcd(v, remainder(u, v)) + elsif u < 0 then + return -u + else + return u + end if +end function diff --git a/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.euphoria b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.euphoria new file mode 100644 index 0000000000..d12a0a7c69 --- /dev/null +++ b/Task/Greatest-common-divisor/Euphoria/greatest-common-divisor-3.euphoria @@ -0,0 +1,40 @@ +function gcd_bin(integer u, integer v) + integer t, k + if u < 0 then -- abs(u) + u = -u + end if + if v < 0 then -- abs(v) + v = -v + end if + if u < v then + t = u + u = v + v = t + end if + if v = 0 then + return u + end if + k = 1 + while and_bits(u,1) = 0 and and_bits(v,1) = 0 do + u = floor(u/2) -- u >>= 1 + v = floor(v/2) -- v >>= 1 + k *= 2 -- k <<= 1 + end while + if and_bits(u,1) then + t = -v + else + t = u + end if + while t do + while and_bits(t, 1) = 0 do + t = floor(t/2) + end while + if t > 0 then + u = t + else + v = -t + end if + t = u - v + end while + return u * k +end function diff --git a/Task/Greatest-common-divisor/FALSE/greatest-common-divisor.false b/Task/Greatest-common-divisor/FALSE/greatest-common-divisor.false new file mode 100644 index 0000000000..2484b72908 --- /dev/null +++ b/Task/Greatest-common-divisor/FALSE/greatest-common-divisor.false @@ -0,0 +1 @@ +10 15$ [0=~][$@$@$@\/*-$]#%. { gcd(10,15)=5 } diff --git a/Task/Greatest-common-divisor/Factor/greatest-common-divisor.factor b/Task/Greatest-common-divisor/Factor/greatest-common-divisor.factor new file mode 100644 index 0000000000..ee753bcc3f --- /dev/null +++ b/Task/Greatest-common-divisor/Factor/greatest-common-divisor.factor @@ -0,0 +1,4 @@ +: gcd ( a b -- c ) + [ abs ] [ + [ nip ] [ mod ] 2bi gcd + ] if-zero ; diff --git a/Task/Greatest-common-divisor/Fantom/greatest-common-divisor.fantom b/Task/Greatest-common-divisor/Fantom/greatest-common-divisor.fantom new file mode 100644 index 0000000000..14e2b46fba --- /dev/null +++ b/Task/Greatest-common-divisor/Fantom/greatest-common-divisor.fantom @@ -0,0 +1,20 @@ +class Main +{ + static Int gcd (Int a, Int b) + { + a = a.abs + b = b.abs + while (b > 0) + { + t := a + a = b + b = t % b + } + return a + } + + public static Void main() + { + echo ("GCD of 51, 34 is: " + gcd(51, 34)) + } +} diff --git a/Task/Greatest-common-divisor/Forth/greatest-common-divisor.fth b/Task/Greatest-common-divisor/Forth/greatest-common-divisor.fth new file mode 100644 index 0000000000..2b4444b13c --- /dev/null +++ b/Task/Greatest-common-divisor/Forth/greatest-common-divisor.fth @@ -0,0 +1,2 @@ +: gcd ( a b -- n ) + begin dup while tuck mod repeat drop ; diff --git a/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-1.f b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-1.f new file mode 100644 index 0000000000..40b2bf2c86 --- /dev/null +++ b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-1.f @@ -0,0 +1,10 @@ +recursive function gcd_rec(u, v) result(gcd) + integer :: gcd + integer, intent(in) :: u, v + + if (mod(u, v) /= 0) then + gcd = gcd_rec(v, mod(u, v)) + else + gcd = v + end if +end function gcd_rec diff --git a/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-2.f b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-2.f new file mode 100644 index 0000000000..39cdafacc9 --- /dev/null +++ b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-2.f @@ -0,0 +1,12 @@ +subroutine gcd_iter(value, u, v) + integer, intent(out) :: value + integer, intent(inout) :: u, v + integer :: t + + do while( v /= 0 ) + t = u + u = v + v = mod(t, v) + enddo + value = abs(u) +end subroutine gcd_iter diff --git a/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f new file mode 100644 index 0000000000..1f3e317959 --- /dev/null +++ b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f @@ -0,0 +1,15 @@ +function gcd(v, t) + integer :: gcd + integer, intent(in) :: v, t + integer :: c, b, a + + b = t + a = v + do + c = mod(a, b) + if ( c == 0) exit + a = b + b = c + end do + gcd = b ! abs(b) +end function gcd diff --git a/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-4.f b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-4.f new file mode 100644 index 0000000000..c5657150cf --- /dev/null +++ b/Task/Greatest-common-divisor/Fortran/greatest-common-divisor-4.f @@ -0,0 +1,40 @@ +subroutine gcd_bin(value, u, v) + integer, intent(out) :: value + integer, intent(inout) :: u, v + integer :: k, t + + u = abs(u) + v = abs(v) + if( u < v ) then + t = u + u = v + v = t + endif + if( v == 0 ) then + value = u + return + endif + k = 1 + do while( (mod(u, 2) == 0).and.(mod(v, 2) == 0) ) + u = u / 2 + v = v / 2 + k = k * 2 + enddo + if( (mod(u, 2) == 0) ) then + t = u + else + t = -v + endif + do while( t /= 0 ) + do while( (mod(t, 2) == 0) ) + t = t / 2 + enddo + if( t > 0 ) then + u = t + else + v = -t + endif + t = u - v + enddo + value = u * k +end subroutine gcd_bin diff --git a/Task/Greatest-common-divisor/Frink/greatest-common-divisor-1.frink b/Task/Greatest-common-divisor/Frink/greatest-common-divisor-1.frink new file mode 100644 index 0000000000..5f3dcda643 --- /dev/null +++ b/Task/Greatest-common-divisor/Frink/greatest-common-divisor-1.frink @@ -0,0 +1 @@ +println[gcd[12345,98765]] diff --git a/Task/Greatest-common-divisor/Frink/greatest-common-divisor-2.frink b/Task/Greatest-common-divisor/Frink/greatest-common-divisor-2.frink new file mode 100644 index 0000000000..c4243cbd50 --- /dev/null +++ b/Task/Greatest-common-divisor/Frink/greatest-common-divisor-2.frink @@ -0,0 +1,19 @@ +# Built-in +GcdInt(35, 42); +# 7 + +# Euclidean algorithm +GcdInteger := function(a, b) + local c; + a := AbsInt(a); + b := AbsInt(b); + while b > 0 do + c := a; + a := b; + b := RemInt(c, b); + od; + return a; +end; + +GcdInteger(35, 42); +# 7 diff --git a/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-1.genyris b/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-1.genyris new file mode 100644 index 0000000000..bf551c73ab --- /dev/null +++ b/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-1.genyris @@ -0,0 +1,6 @@ +def gcd (u v) + u = (abs u) + v = (abs v) + cond + (equal? v 0) u + else (gcd v (% u v)) diff --git a/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-2.genyris b/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-2.genyris new file mode 100644 index 0000000000..aa00ee9ff5 --- /dev/null +++ b/Task/Greatest-common-divisor/Genyris/greatest-common-divisor-2.genyris @@ -0,0 +1,8 @@ +def gcd (u v) + u = (abs u) + v = (abs v) + while (not (equal? v 0)) + var tmp (% u v) + u = v + v = tmp + u diff --git a/Task/Greatest-common-divisor/Go/greatest-common-divisor-1.go b/Task/Greatest-common-divisor/Go/greatest-common-divisor-1.go new file mode 100644 index 0000000000..b8f3f6ad9f --- /dev/null +++ b/Task/Greatest-common-divisor/Go/greatest-common-divisor-1.go @@ -0,0 +1,15 @@ +package main + +import "fmt" + +func gcd(x, y int) int { + for y != 0 { + x, y = y, x%y + } + return x +} + +func main() { + fmt.Println(gcd(33, 77)) + fmt.Println(gcd(49865, 69811)) +} diff --git a/Task/Greatest-common-divisor/Go/greatest-common-divisor-2.go b/Task/Greatest-common-divisor/Go/greatest-common-divisor-2.go new file mode 100644 index 0000000000..e62de01eb0 --- /dev/null +++ b/Task/Greatest-common-divisor/Go/greatest-common-divisor-2.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "math/big" +) + +func gcd(x, y int64) int64 { + return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64() +} + +func main() { + fmt.Println(gcd(33, 77)) + fmt.Println(gcd(49865, 69811)) +} diff --git a/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-1.groovy b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-1.groovy new file mode 100644 index 0000000000..fdedda5634 --- /dev/null +++ b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-1.groovy @@ -0,0 +1,2 @@ +def gcdR +gcdR = { m, n -> m = m.abs(); n = n.abs(); n == 0 ? m : m%n == 0 ? n : gcdR(n, m%n) } diff --git a/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-2.groovy b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-2.groovy new file mode 100644 index 0000000000..d113953a92 --- /dev/null +++ b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-2.groovy @@ -0,0 +1 @@ +def gcdI = { m, n -> m = m.abs(); n = n.abs(); n == 0 ? m : { while(m%n != 0) { t=n; n=m%n; m=t }; n }() } diff --git a/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-3.groovy b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-3.groovy new file mode 100644 index 0000000000..00ddcda5a8 --- /dev/null +++ b/Task/Greatest-common-divisor/Groovy/greatest-common-divisor-3.groovy @@ -0,0 +1,9 @@ +println " R I" +println "gcd(28, 0) = ${gcdR(28, 0)} == ${gcdI(28, 0)}" +println "gcd(0, 28) = ${gcdR(0, 28)} == ${gcdI(0, 28)}" +println "gcd(0, -28) = ${gcdR(0, -28)} == ${gcdI(0, -28)}" +println "gcd(70, -28) = ${gcdR(70, -28)} == ${gcdI(70, -28)}" +println "gcd(70, 28) = ${gcdR(70, 28)} == ${gcdI(70, 28)}" +println "gcd(28, 70) = ${gcdR(28, 70)} == ${gcdI(28, 70)}" +println "gcd(800, 70) = ${gcdR(800, 70)} == ${gcdI(800, 70)}" +println "gcd(27, -70) = ${gcdR(27, -70)} == ${gcdI(27, -70)}" diff --git a/Task/Greatest-common-divisor/Haskell/greatest-common-divisor.hs b/Task/Greatest-common-divisor/Haskell/greatest-common-divisor.hs new file mode 100644 index 0000000000..4a87199613 --- /dev/null +++ b/Task/Greatest-common-divisor/Haskell/greatest-common-divisor.hs @@ -0,0 +1,5 @@ +gcd :: (Integral a) => a -> a -> a +gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined" +gcd x y = gcd' (abs x) (abs y) where + gcd' a 0 = a + gcd' a b = gcd' b (a `rem` b) diff --git a/Task/Greatest-common-divisor/HicEst/greatest-common-divisor.hicest b/Task/Greatest-common-divisor/HicEst/greatest-common-divisor.hicest new file mode 100644 index 0000000000..516ef7da63 --- /dev/null +++ b/Task/Greatest-common-divisor/HicEst/greatest-common-divisor.hicest @@ -0,0 +1,14 @@ +FUNCTION gcd(a, b) + IF(b == 0) THEN + gcd = ABS(a) + ELSE + aa = a + gcd = b + DO i = 1, 1E100 + r = ABS(MOD(aa, gcd)) + IF( r == 0 ) RETURN + aa = gcd + gcd = r + ENDDO + ENDIF + END diff --git a/Task/Greatest-common-divisor/Icon/greatest-common-divisor-1.icon b/Task/Greatest-common-divisor/Icon/greatest-common-divisor-1.icon new file mode 100644 index 0000000000..12a8b8d67d --- /dev/null +++ b/Task/Greatest-common-divisor/Icon/greatest-common-divisor-1.icon @@ -0,0 +1,4 @@ +link numbers # gcd is part of the Icon Programming Library +procedure main(args) + write(gcd(arg[1], arg[2])) | "Usage: gcd n m") +end diff --git a/Task/Greatest-common-divisor/Icon/greatest-common-divisor-2.icon b/Task/Greatest-common-divisor/Icon/greatest-common-divisor-2.icon new file mode 100644 index 0000000000..60e7b632d1 --- /dev/null +++ b/Task/Greatest-common-divisor/Icon/greatest-common-divisor-2.icon @@ -0,0 +1,12 @@ +procedure gcd(i,j) #: greatest common divisor + local r + + if (i | j) < 1 then runerr(501) + + repeat { + r := i % j + if r = 0 then return j + i := j + j := r + } +end diff --git a/Task/Greatest-common-divisor/J/greatest-common-divisor-1.j b/Task/Greatest-common-divisor/J/greatest-common-divisor-1.j new file mode 100644 index 0000000000..1cf1253329 --- /dev/null +++ b/Task/Greatest-common-divisor/J/greatest-common-divisor-1.j @@ -0,0 +1 @@ +x+.y diff --git a/Task/Greatest-common-divisor/J/greatest-common-divisor-2.j b/Task/Greatest-common-divisor/J/greatest-common-divisor-2.j new file mode 100644 index 0000000000..ea9ec8b3f0 --- /dev/null +++ b/Task/Greatest-common-divisor/J/greatest-common-divisor-2.j @@ -0,0 +1,2 @@ + 12 +. 30 +6 diff --git a/Task/Greatest-common-divisor/Java/greatest-common-divisor-1.java b/Task/Greatest-common-divisor/Java/greatest-common-divisor-1.java new file mode 100644 index 0000000000..a0f3314018 --- /dev/null +++ b/Task/Greatest-common-divisor/Java/greatest-common-divisor-1.java @@ -0,0 +1,9 @@ +public static long gcd(long a, long b){ + long factor= Math.max(a, b); + for(long loop= factor;loop > 1;loop--){ + if(a % loop == 0 && b % loop == 0){ + return loop; + } + } + return 1; +} diff --git a/Task/Greatest-common-divisor/Java/greatest-common-divisor-2.java b/Task/Greatest-common-divisor/Java/greatest-common-divisor-2.java new file mode 100644 index 0000000000..fd052dc42b --- /dev/null +++ b/Task/Greatest-common-divisor/Java/greatest-common-divisor-2.java @@ -0,0 +1,10 @@ +public static int gcd(int a, int b) //valid for positive integers. +{ + while(b > 0) + { + int c = a % b; + a = b; + b = c; + } + return a; +} diff --git a/Task/Greatest-common-divisor/Java/greatest-common-divisor-3.java b/Task/Greatest-common-divisor/Java/greatest-common-divisor-3.java new file mode 100644 index 0000000000..2a2c95592e --- /dev/null +++ b/Task/Greatest-common-divisor/Java/greatest-common-divisor-3.java @@ -0,0 +1,30 @@ +public static long gcd(long u, long v){ + long t, k; + + if (v == 0) return u; + + u = Math.abs(u); + v = Math.abs(v); + if (u < v){ + t = u; + u = v; + v = t; + } + + for(k = 1; (u & 1) == 0 && (v & 1) == 0; k <<= 1){ + u >>= 1; v >>= 1; + } + + t = (u & 1) != 0 ? -v : u; + while (t != 0){ + while ((t & 1) == 0) t >>= 1; + + if (t > 0) + u = t; + else + v = -t; + + t = u - v; + } + return u * k; +} diff --git a/Task/Greatest-common-divisor/Java/greatest-common-divisor-4.java b/Task/Greatest-common-divisor/Java/greatest-common-divisor-4.java new file mode 100644 index 0000000000..ae9336d388 --- /dev/null +++ b/Task/Greatest-common-divisor/Java/greatest-common-divisor-4.java @@ -0,0 +1,6 @@ +public static long gcd(long a, long b){ + if(a == 0) return b; + if(b == 0) return a; + if(a > b) return gcd(b, a % b); + return gcd(a, b % a); +} diff --git a/Task/Greatest-common-divisor/Java/greatest-common-divisor-5.java b/Task/Greatest-common-divisor/Java/greatest-common-divisor-5.java new file mode 100644 index 0000000000..a28a6452c7 --- /dev/null +++ b/Task/Greatest-common-divisor/Java/greatest-common-divisor-5.java @@ -0,0 +1,5 @@ +import java.math.BigInteger; + +public static long gcd(long a, long b){ + return BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).longValue(); +} diff --git a/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-1.js b/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-1.js new file mode 100644 index 0000000000..f0c9597bce --- /dev/null +++ b/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-1.js @@ -0,0 +1,11 @@ +function gcd(a,b) { + if (a < 0) a = -a; + if (b < 0) b = -b; + if (b > a) {var temp = a; a = b; b = temp;} + while (true) { + a %= b; + if (a == 0) return b; + b %= a; + if (b == 0) return a; + } +} diff --git a/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-2.js b/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-2.js new file mode 100644 index 0000000000..ff62f38e98 --- /dev/null +++ b/Task/Greatest-common-divisor/JavaScript/greatest-common-divisor-2.js @@ -0,0 +1,7 @@ +function gcd_rec(a, b) { + if (b) { + return gcd_rec(b, a % b); + } else { + return Math.abs(a); + } +} diff --git a/Task/Greatest-common-divisor/Joy/greatest-common-divisor.joy b/Task/Greatest-common-divisor/Joy/greatest-common-divisor.joy new file mode 100644 index 0000000000..cd08ad982e --- /dev/null +++ b/Task/Greatest-common-divisor/Joy/greatest-common-divisor.joy @@ -0,0 +1 @@ +DEFINE gcd == [0 >] [dup rollup rem] while pop. diff --git a/Task/Greatest-common-divisor/K/greatest-common-divisor.k b/Task/Greatest-common-divisor/K/greatest-common-divisor.k new file mode 100644 index 0000000000..77ef5d0aa0 --- /dev/null +++ b/Task/Greatest-common-divisor/K/greatest-common-divisor.k @@ -0,0 +1 @@ +gcd:{:[~x;y;_f[y;x!y]]} diff --git a/Task/Greatest-common-divisor/Liberty-BASIC/greatest-common-divisor.liberty b/Task/Greatest-common-divisor/Liberty-BASIC/greatest-common-divisor.liberty new file mode 100644 index 0000000000..8365c29b97 --- /dev/null +++ b/Task/Greatest-common-divisor/Liberty-BASIC/greatest-common-divisor.liberty @@ -0,0 +1,12 @@ +'iterative Euclid algorithm +print GCD(-2,16) +end + +function GCD(a,b) + while b + c = a + a = b + b = c mod b + wend + GCD = abs(a) + end function diff --git a/Task/Greatest-common-divisor/Logo/greatest-common-divisor.logo b/Task/Greatest-common-divisor/Logo/greatest-common-divisor.logo new file mode 100644 index 0000000000..736360b8e5 --- /dev/null +++ b/Task/Greatest-common-divisor/Logo/greatest-common-divisor.logo @@ -0,0 +1,4 @@ +to gcd :a :b + if :b = 0 [output :a] + output gcd :b modulo :a :b +end diff --git a/Task/Greatest-common-divisor/Lua/greatest-common-divisor.lua b/Task/Greatest-common-divisor/Lua/greatest-common-divisor.lua new file mode 100644 index 0000000000..04864e57a2 --- /dev/null +++ b/Task/Greatest-common-divisor/Lua/greatest-common-divisor.lua @@ -0,0 +1,15 @@ +function gcd(a,b) + if b ~= 0 then + return gcd(b, a % b) + else + return math.abs(a) + end +end + +function demo(a,b) + print("GCD of " .. a .. " and " .. b .. " is " .. gcd(a, b)) +end + +demo(100, 5) +demo(5, 100) +demo(7, 23) diff --git a/Task/Greatest-common-divisor/Lucid/greatest-common-divisor.lucid b/Task/Greatest-common-divisor/Lucid/greatest-common-divisor.lucid new file mode 100644 index 0000000000..2009dba57a --- /dev/null +++ b/Task/Greatest-common-divisor/Lucid/greatest-common-divisor.lucid @@ -0,0 +1,6 @@ +gcd(n,m) where + z = [% n, m %] fby if x > y then [% x - y, y %] else [% x, y - x%] fi; + x = hd(z); + y = hd(tl(z)); + gcd(n, m) = (x asa x*y eq 0) fby eod; +end diff --git a/Task/Greatest-common-divisor/MATLAB/greatest-common-divisor.m b/Task/Greatest-common-divisor/MATLAB/greatest-common-divisor.m new file mode 100644 index 0000000000..3ff1904c28 --- /dev/null +++ b/Task/Greatest-common-divisor/MATLAB/greatest-common-divisor.m @@ -0,0 +1,2 @@ +function [gcdValue] = greatestcommondivisor(integer1, integer2) + gcdValue = gcd(integer1, integer2); diff --git a/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-1.max b/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-1.max new file mode 100644 index 0000000000..eac8f0d24c --- /dev/null +++ b/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-1.max @@ -0,0 +1,10 @@ +fn gcdIter a b = +( + while b > 0 do + ( + c = mod a b + a = b + b = c + ) + abs a +) diff --git a/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-2.max b/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-2.max new file mode 100644 index 0000000000..5757a50fe8 --- /dev/null +++ b/Task/Greatest-common-divisor/MAXScript/greatest-common-divisor-2.max @@ -0,0 +1,4 @@ +fn gcdRec a b = +( + if b > 0 then gcdRec b (mod a b) else abs a +) diff --git a/Task/Greatest-common-divisor/MIPS-Assembly/greatest-common-divisor.mips b/Task/Greatest-common-divisor/MIPS-Assembly/greatest-common-divisor.mips new file mode 100644 index 0000000000..acbb441b37 --- /dev/null +++ b/Task/Greatest-common-divisor/MIPS-Assembly/greatest-common-divisor.mips @@ -0,0 +1,14 @@ +gcd: + # a0 and a1 are the two integer parameters + # return value is in v0 + move $t0, $a0 + move $t1, $a1 +loop: + beq $t1, $0, done + div $t0, $t1 + move $t0, $t1 + mfhi $t1 + j loop +done: + move $v0, $t0 + jr $ra diff --git a/Task/Greatest-common-divisor/MUMPS/greatest-common-divisor.mumps b/Task/Greatest-common-divisor/MUMPS/greatest-common-divisor.mumps new file mode 100644 index 0000000000..02f2d30aeb --- /dev/null +++ b/Task/Greatest-common-divisor/MUMPS/greatest-common-divisor.mumps @@ -0,0 +1,7 @@ +GCD(A,B) + QUIT:((A/1)'=(A\1))!((B/1)'=(B\1)) 0 + SET:A<0 A=-A + SET:B<0 B=-B + IF B'=0 + FOR SET T=A#B,A=B,B=T QUIT:B=0 ;ARGUEMENTLESS FOR NEEDS TWO SPACES + QUIT A diff --git a/Task/Greatest-common-divisor/Maple/greatest-common-divisor-1.maple b/Task/Greatest-common-divisor/Maple/greatest-common-divisor-1.maple new file mode 100644 index 0000000000..096fdb2eda --- /dev/null +++ b/Task/Greatest-common-divisor/Maple/greatest-common-divisor-1.maple @@ -0,0 +1 @@ +igcd( a, b ) diff --git a/Task/Greatest-common-divisor/Maple/greatest-common-divisor-2.maple b/Task/Greatest-common-divisor/Maple/greatest-common-divisor-2.maple new file mode 100644 index 0000000000..a2dbb7ea18 --- /dev/null +++ b/Task/Greatest-common-divisor/Maple/greatest-common-divisor-2.maple @@ -0,0 +1,2 @@ +> igcd( 24, 15 ); + 3 diff --git a/Task/Greatest-common-divisor/Mathematica/greatest-common-divisor.mathematica b/Task/Greatest-common-divisor/Mathematica/greatest-common-divisor.mathematica new file mode 100644 index 0000000000..65c05a3541 --- /dev/null +++ b/Task/Greatest-common-divisor/Mathematica/greatest-common-divisor.mathematica @@ -0,0 +1 @@ +GCD[a, b] diff --git a/Task/Greatest-common-divisor/Maxima/greatest-common-divisor.maxima b/Task/Greatest-common-divisor/Maxima/greatest-common-divisor.maxima new file mode 100644 index 0000000000..8f2999e4f4 --- /dev/null +++ b/Task/Greatest-common-divisor/Maxima/greatest-common-divisor.maxima @@ -0,0 +1,6 @@ +/* There is a function gcd(a, b) in Maxima, but one can rewrite it */ +gcd2(a, b) := block([a: abs(a), b: abs(b)], while b # 0 do [a, b]: [b, mod(a, b)], a)$ + +/* both will return 2^97 * 3^48 */ +gcd(100!, 6^100), factor; +gcd2(100!, 6^100), factor; diff --git a/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-1.mod2 b/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-1.mod2 new file mode 100644 index 0000000000..1f27734d34 --- /dev/null +++ b/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-1.mod2 @@ -0,0 +1,26 @@ +MODULE ggTkgV; + +FROM InOut IMPORT ReadCard, WriteCard, WriteLn, WriteString, WriteBf; + +VAR x, y, u, v : CARDINAL; + +BEGIN + WriteString ("x = "); WriteBf; ReadCard (x); + WriteString ("y = "); WriteBf; ReadCard (y); + u := x; + v := y; + WHILE x # y DO + (* ggT (x, y) = ggT (x0, y0), x * v + y * u = 2 * x0 * y0 *) + IF x > y THEN + x := x - y; + u := u + v + ELSE + y := y - x; + v := v + u + END + END; + WriteString ("ggT ="); WriteCard (x, 6); WriteLn; + WriteString ("kgV ="); WriteCard ((u+v) DIV 2, 6); WriteLn; + WriteString ("u ="); WriteCard (u, 6); WriteLn; + WriteString ("v ="); WriteCard (v , 6); WriteLn +END ggTkgV. diff --git a/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-2.mod2 b/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-2.mod2 new file mode 100644 index 0000000000..8d901040bf --- /dev/null +++ b/Task/Greatest-common-divisor/Modula-2/greatest-common-divisor-2.mod2 @@ -0,0 +1,14 @@ +jan@Beryllium:~/modula/Wirth/PIM$ ggtkgv +x = 12 +y = 20 +ggT = 4 +kgV = 60 +u = 44 +v = 76 +jan@Beryllium:~/modula/Wirth/PIM$ ggtkgv +x = 123 +y = 255 +ggT = 3 +kgV = 10455 +u = 13773 +v = 7137 diff --git a/Task/Greatest-common-divisor/Modula-3/greatest-common-divisor.mod3 b/Task/Greatest-common-divisor/Modula-3/greatest-common-divisor.mod3 new file mode 100644 index 0000000000..6b074806ad --- /dev/null +++ b/Task/Greatest-common-divisor/Modula-3/greatest-common-divisor.mod3 @@ -0,0 +1,22 @@ +MODULE GCD EXPORTS Main; + +IMPORT IO, Fmt; + +PROCEDURE GCD(a, b: CARDINAL): CARDINAL = + BEGIN + IF a = 0 THEN + RETURN b; + ELSIF b = 0 THEN + RETURN a; + ELSIF a > b THEN + RETURN GCD(b, a MOD b); + ELSE + RETURN GCD(a, b MOD a); + END; + END GCD; + +BEGIN + IO.Put("GCD of 100, 5 is " & Fmt.Int(GCD(100, 5)) & "\n"); + IO.Put("GCD of 5, 100 is " & Fmt.Int(GCD(5, 100)) & "\n"); + IO.Put("GCD of 7, 23 is " & Fmt.Int(GCD(7, 23)) & "\n"); +END GCD. diff --git a/Task/Greatest-common-divisor/PHP/greatest-common-divisor-1.php b/Task/Greatest-common-divisor/PHP/greatest-common-divisor-1.php new file mode 100644 index 0000000000..b3ebab08f7 --- /dev/null +++ b/Task/Greatest-common-divisor/PHP/greatest-common-divisor-1.php @@ -0,0 +1,12 @@ +function gcdIter($n, $m) { + while(true) { + if($n == $m) { + return $m; + } + if($n > $m) { + $n -= $m; + } else { + $m -= $n; + } + } +} diff --git a/Task/Greatest-common-divisor/PHP/greatest-common-divisor-2.php b/Task/Greatest-common-divisor/PHP/greatest-common-divisor-2.php new file mode 100644 index 0000000000..cc56029c30 --- /dev/null +++ b/Task/Greatest-common-divisor/PHP/greatest-common-divisor-2.php @@ -0,0 +1,7 @@ +function gcdRec($n, $m) { + if($m > 0) { + return gcdRec($m, $n % $m); + } else { + return abs($n); + } +} diff --git a/Task/Greatest-common-divisor/Perl/greatest-common-divisor-1.pl b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-1.pl new file mode 100644 index 0000000000..e52b7ee20d --- /dev/null +++ b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-1.pl @@ -0,0 +1,7 @@ +sub gcd_iter($$) { + my ($u, $v) = @_; + while ($v) { + ($u, $v) = ($v, $u % $v); + } + return abs($u); +} diff --git a/Task/Greatest-common-divisor/Perl/greatest-common-divisor-2.pl b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-2.pl new file mode 100644 index 0000000000..3eab6bafde --- /dev/null +++ b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-2.pl @@ -0,0 +1,8 @@ +sub gcd($$) { + my ($u, $v) = @_; + if ($v) { + return gcd($v, $u % $v); + } else { + return abs($u); + } +} diff --git a/Task/Greatest-common-divisor/Perl/greatest-common-divisor-3.pl b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-3.pl new file mode 100644 index 0000000000..286876632a --- /dev/null +++ b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-3.pl @@ -0,0 +1,30 @@ +sub gcd_bin($$) { + my ($u, $v) = @_; + $u = abs($u); + $v = abs($v); + if ($u < $v) { + ($u, $v) = ($v, $u); + } + if ($v == 0) { + return $u; + } + my $k = 1; + while ($u & 1 == 0 && $v & 1 == 0) { + $u >>= 1; + $v >>= 1; + $k <<= 1; + } + my $t = ($u & 1) ? -$v : $u; + while ($t) { + while ($t & 1 == 0) { + $t >>= 1; + } + if ($t > 0) { + $u = $t; + } else { + $v = -$t; + } + $t = $u - $v; + } + return $u * $k; +} diff --git a/Task/Greatest-common-divisor/Perl/greatest-common-divisor-4.pl b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-4.pl new file mode 100644 index 0000000000..44b9d860ed --- /dev/null +++ b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-4.pl @@ -0,0 +1,9 @@ +use Benchmark qw(cmpthese); + +my $u = 40902; +my $v = 24140; +cmpthese(-5, { + 'gcd' => sub { gcd($u, $v); }, + 'gcd_iter' => sub { gcd_iter($u, $v); }, + 'gcd_bin' => sub { gcd_bin($u, $v); }, +}); diff --git a/Task/Greatest-common-divisor/Perl/greatest-common-divisor-5.pl b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-5.pl new file mode 100644 index 0000000000..2da40af913 --- /dev/null +++ b/Task/Greatest-common-divisor/Perl/greatest-common-divisor-5.pl @@ -0,0 +1,5 @@ +use Math::BigInt; + +sub gcd($$) { + Math::BigInt::bgcd(@_)->numify(); +} diff --git a/Task/Greatest-common-divisor/PicoLisp/greatest-common-divisor.l b/Task/Greatest-common-divisor/PicoLisp/greatest-common-divisor.l new file mode 100644 index 0000000000..5327fe08cd --- /dev/null +++ b/Task/Greatest-common-divisor/PicoLisp/greatest-common-divisor.l @@ -0,0 +1,5 @@ +(de gcd (A B) + (until (=0 B) + (let M (% A B) + (setq A B B M) ) ) + (abs A) ) diff --git a/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-1.pro b/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-1.pro new file mode 100644 index 0000000000..e2adb66e43 --- /dev/null +++ b/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-1.pro @@ -0,0 +1,4 @@ +gcd(X, 0, X):- !. +gcd(0, X, X):- !. +gcd(X, Y, D):- X > Y, !, Z is X mod Y, gcd(Y, Z, D). +gcd(X, Y, D):- Z is Y mod X, gcd(X, Z, D). diff --git a/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-2.pro b/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-2.pro new file mode 100644 index 0000000000..05f3f02178 --- /dev/null +++ b/Task/Greatest-common-divisor/Prolog/greatest-common-divisor-2.pro @@ -0,0 +1,4 @@ +gcd(X, 0, X):- !. +gcd(0, X, X):- !. +gcd(X, Y, D):- X =< Y, !, Z is Y - X, gcd(X, Z, D). +gcd(X, Y, D):- gcd(Y, X, D). diff --git a/Task/Greatest-common-divisor/Python/greatest-common-divisor-1.py b/Task/Greatest-common-divisor/Python/greatest-common-divisor-1.py new file mode 100644 index 0000000000..7e11c7bc08 --- /dev/null +++ b/Task/Greatest-common-divisor/Python/greatest-common-divisor-1.py @@ -0,0 +1 @@ +from fractions import gcd diff --git a/Task/Greatest-common-divisor/Python/greatest-common-divisor-2.py b/Task/Greatest-common-divisor/Python/greatest-common-divisor-2.py new file mode 100644 index 0000000000..3cb5083b14 --- /dev/null +++ b/Task/Greatest-common-divisor/Python/greatest-common-divisor-2.py @@ -0,0 +1,4 @@ +def gcd_iter(u, v): + while v: + u, v = v, u % v + return abs(u) diff --git a/Task/Greatest-common-divisor/Python/greatest-common-divisor-3.py b/Task/Greatest-common-divisor/Python/greatest-common-divisor-3.py new file mode 100644 index 0000000000..f60300f854 --- /dev/null +++ b/Task/Greatest-common-divisor/Python/greatest-common-divisor-3.py @@ -0,0 +1,2 @@ +def gcd(u, v): + return gcd(v, u % v) if v else abs(u) diff --git a/Task/Greatest-common-divisor/Python/greatest-common-divisor-4.py b/Task/Greatest-common-divisor/Python/greatest-common-divisor-4.py new file mode 100644 index 0000000000..8c4db487a5 --- /dev/null +++ b/Task/Greatest-common-divisor/Python/greatest-common-divisor-4.py @@ -0,0 +1,23 @@ +def gcd_bin(u, v): + u, v = abs(u), abs(v) # u >= 0, v >= 0 + if u < v: + u, v = v, u # u >= v >= 0 + if v == 0: + return u + + # u >= v > 0 + k = 1 + while u & 1 == 0 and v & 1 == 0: # u, v - even + u >>= 1; v >>= 1 + k <<= 1 + + t = -v if u & 1 else u + while t: + while t & 1 == 0: + t >>= 1 + if t > 0: + u = t + else: + v = -t + t = u - v + return u * k diff --git a/Task/Greatest-common-divisor/R/greatest-common-divisor-1.r b/Task/Greatest-common-divisor/R/greatest-common-divisor-1.r new file mode 100644 index 0000000000..8670374edd --- /dev/null +++ b/Task/Greatest-common-divisor/R/greatest-common-divisor-1.r @@ -0,0 +1,3 @@ +"%gcd%" <- function(u, v) { + ifelse(u %% v != 0, v %gcd% (u%%v), v) +} diff --git a/Task/Greatest-common-divisor/R/greatest-common-divisor-2.r b/Task/Greatest-common-divisor/R/greatest-common-divisor-2.r new file mode 100644 index 0000000000..d44c0f05df --- /dev/null +++ b/Task/Greatest-common-divisor/R/greatest-common-divisor-2.r @@ -0,0 +1,6 @@ +"%gcd%" <- function(v, t) { + while ( (c <- v%%t) != 0 ) { + v <- t + t <- c + } +} diff --git a/Task/Greatest-common-divisor/R/greatest-common-divisor-3.r b/Task/Greatest-common-divisor/R/greatest-common-divisor-3.r new file mode 100644 index 0000000000..e2b41c8f09 --- /dev/null +++ b/Task/Greatest-common-divisor/R/greatest-common-divisor-3.r @@ -0,0 +1 @@ +print(50 %gcd% 75) diff --git a/Task/Greatest-common-divisor/REXX/greatest-common-divisor-1.rexx b/Task/Greatest-common-divisor/REXX/greatest-common-divisor-1.rexx new file mode 100644 index 0000000000..9a6020b6b0 --- /dev/null +++ b/Task/Greatest-common-divisor/REXX/greatest-common-divisor-1.rexx @@ -0,0 +1,18 @@ +/*REXX pgm finds GCD (Greatest Common Divisor) of any number of integers*/ +numeric digits 2000 /*handle up to 2K digit numbers.*/ +call gcd 0 0 ; call gcd 55 0 ; call gcd 0 66 +call gcd 7,21 ; call gcd 41,47 ; call gcd 99 , 51 +call gcd 24, -8 ; call gcd -36, 9 ; call gcd -54, -6 +call gcd 14 0 7 ; call gcd 14 7 0 ; call gcd 0 14 7 +call gcd 15 10 20 30 55 ; call gcd 137438691328 2305843008139952128 /*◄──two perfect numbers.*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────GCD subroutine──────────────────────*/ +gcd: procedure; $=; do i=1 for arg(); $=$ arg(i); end /*arg list.*/ +parse var $ x z .; if x=0 then x=z; x=abs(x) /*handle special 0 case.*/ + + do j=2 to words($); y=abs(word($,j)); if y=0 then iterate + do until _==0; _=x//y; x=y; y=_; end /*◄── the heavy lifting.*/ + end /*j*/ + +say 'GCD (Greatest Common Divisor) of ' translate(space($),",",' ') " is " x +return x diff --git a/Task/Greatest-common-divisor/REXX/greatest-common-divisor-2.rexx b/Task/Greatest-common-divisor/REXX/greatest-common-divisor-2.rexx new file mode 100644 index 0000000000..c5bcad2b1d --- /dev/null +++ b/Task/Greatest-common-divisor/REXX/greatest-common-divisor-2.rexx @@ -0,0 +1,46 @@ +/* REXX *************************************************************** +* using PL/I code extended to many arguments +* 17.08.2012 Walter Pachl +* 18.08.2012 gcd(0,0)=0 +**********************************************************************/ +numeric digits 300 /*handle up to 300 digit numbers.*/ +Call test 7,21 ,'7 ' +Call test 4,7 ,'1 ' +Call test 24,-8 ,'8' +Call test 55,0 ,'55' +Call test 99,15 ,'3 ' +Call test 15,10,20,30,55,'5' +Call test 496,8128 ,'16' +Call test 496,8128 ,'8' /* test wrong expectation */ +Call test 0,0 ,'0' /* by definition */ +Exit + +test: +/********************************************************************** +* Test the gcd function +**********************************************************************/ +n=arg() /* Number of arguments */ +gcde=arg(n) /* Expected result */ +gcdx=gcd(arg(1),arg(2)) /* gcd of the first 2 numbers */ +Do i=2 To n-2 /* proceed with all te others */ + If arg(i+1)<>0 Then + gcdx=gcd(gcdx,arg(i+1)) + End +If gcdx=arg(arg()) Then /* result is as expected */ + tag='as expected' +Else /* result is not correct */ + Tag='*** wrong. expected:' gcde +numbers=arg(1) /* build sting to show the input */ +Do i=2 To n-1 + numbers=numbers 'and' arg(i) + End +say left('the GCD of' numbers 'is',45) right(gcdx,3) tag +Return + +GCD: procedure +/********************************************************************** +* Recursive procedure as shown in PL/I +**********************************************************************/ +Parse Arg a,b +if b = 0 then return abs(a) +return GCD(b,a//b) diff --git a/Task/Greatest-common-divisor/Racket/greatest-common-divisor-1.rkt b/Task/Greatest-common-divisor/Racket/greatest-common-divisor-1.rkt new file mode 100644 index 0000000000..5d93f28db2 --- /dev/null +++ b/Task/Greatest-common-divisor/Racket/greatest-common-divisor-1.rkt @@ -0,0 +1,3 @@ +#lang racket + +(gcd 14 63) diff --git a/Task/Greatest-common-divisor/Racket/greatest-common-divisor-2.rkt b/Task/Greatest-common-divisor/Racket/greatest-common-divisor-2.rkt new file mode 100644 index 0000000000..560a898d63 --- /dev/null +++ b/Task/Greatest-common-divisor/Racket/greatest-common-divisor-2.rkt @@ -0,0 +1,17 @@ +#lang racket + +;; given two nonnegative integers, produces their greatest +;; common divisor using Euclid's algorithm +(define (gcd a b) + (if (= b 0) + a + (gcd b (modulo a b)))) + +;; some test cases! +(module+ test + (require rackunit) + (check-equal? (gcd (* 2 3 3 7 7) + (* 3 3 7 11)) + (* 3 3 7)) + (check-equal? (gcd 0 14) 14) + (check-equal? (gcd 13 0) 13)) diff --git a/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-1.rb b/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-1.rb new file mode 100644 index 0000000000..e9fb6662f9 --- /dev/null +++ b/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-1.rb @@ -0,0 +1,4 @@ +irb(main):001:0> require 'rational'#Not necessary in Ruby 1.9+ +=> true +irb(main):002:0> 40902.gcd(24140) +=> 34 diff --git a/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-2.rb b/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-2.rb new file mode 100644 index 0000000000..7b07a25f06 --- /dev/null +++ b/Task/Greatest-common-divisor/Ruby/greatest-common-divisor-2.rb @@ -0,0 +1,7 @@ +def gcd(u, v) + u, v = u.abs, v.abs + while v > 0 + u, v = v, u % v + end + u +end diff --git a/Task/Greatest-common-divisor/Sather/greatest-common-divisor-1.sa b/Task/Greatest-common-divisor/Sather/greatest-common-divisor-1.sa new file mode 100644 index 0000000000..0cefe57587 --- /dev/null +++ b/Task/Greatest-common-divisor/Sather/greatest-common-divisor-1.sa @@ -0,0 +1,52 @@ +class MATH is + + gcd_iter(u, v:INT):INT is + loop while!( v.bool ); + t ::= u; u := v; v := t % v; + end; + return u.abs; + end; + + gcd(u, v:INT):INT is + if v.bool then return gcd(v, u%v); end; + return u.abs; + end; + + + private swap(inout a, inout b:INT) is + t ::= a; + a := b; + b := t; + end; + + gcd_bin(u, v:INT):INT is + t:INT; + + u := u.abs; v := v.abs; + if u < v then swap(inout u, inout v); end; + if v = 0 then return u; end; + k ::= 1; + loop while!( u.is_even and v.is_even ); + u := u / 2; v := v / 2; + k := k * 2; + end; + if u.is_even then + t := -v; + else + t := u; + end; + loop while!( t.bool ); + loop while!( t.is_even ); + t := t / 2; + end; + if t > 0 then + u := t; + else + v := -t; + end; + t := u - v; + end; + return u * k; + end; + +end; diff --git a/Task/Greatest-common-divisor/Sather/greatest-common-divisor-2.sa b/Task/Greatest-common-divisor/Sather/greatest-common-divisor-2.sa new file mode 100644 index 0000000000..05af4a3efb --- /dev/null +++ b/Task/Greatest-common-divisor/Sather/greatest-common-divisor-2.sa @@ -0,0 +1,11 @@ +class MAIN is + main is + a ::= 40902; + b ::= 24140; + #OUT + MATH::gcd_iter(a, b) + "\n"; + #OUT + MATH::gcd(a, b) + "\n"; + #OUT + MATH::gcd_bin(a, b) + "\n"; + -- built in + #OUT + a.gcd(b) + "\n"; + end; +end; diff --git a/Task/Greatest-common-divisor/Scala/greatest-common-divisor-1.scala b/Task/Greatest-common-divisor/Scala/greatest-common-divisor-1.scala new file mode 100644 index 0000000000..4bde51cf54 --- /dev/null +++ b/Task/Greatest-common-divisor/Scala/greatest-common-divisor-1.scala @@ -0,0 +1 @@ +def gcd(a: Int, b: Int): Int = if (b == 0) a.abs else gcd(b, a % b) diff --git a/Task/Greatest-common-divisor/Scala/greatest-common-divisor-2.scala b/Task/Greatest-common-divisor/Scala/greatest-common-divisor-2.scala new file mode 100644 index 0000000000..00607a8985 --- /dev/null +++ b/Task/Greatest-common-divisor/Scala/greatest-common-divisor-2.scala @@ -0,0 +1,7 @@ +@tailrec +def gcd(a: Int, b: Int): Int = { + b match { + case 0 => a + case _ => gcd(b, (a % b)) + } +} diff --git a/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.ss b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.ss new file mode 100644 index 0000000000..f340f4ee9e --- /dev/null +++ b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-1.ss @@ -0,0 +1,4 @@ +(define (gcd a b) + (if (= b 0) + a + (gcd b (modulo a b)))) diff --git a/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.ss b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.ss new file mode 100644 index 0000000000..bf005ae726 --- /dev/null +++ b/Task/Greatest-common-divisor/Scheme/greatest-common-divisor-2.ss @@ -0,0 +1 @@ +(gcd a b) diff --git a/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-1.st b/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-1.st new file mode 100644 index 0000000000..7b31a0e7b2 --- /dev/null +++ b/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-1.st @@ -0,0 +1 @@ +(40902 gcd: 24140) displayNl diff --git a/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-2.st b/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-2.st new file mode 100644 index 0000000000..d176e1aed6 --- /dev/null +++ b/Task/Greatest-common-divisor/Smalltalk/greatest-common-divisor-2.st @@ -0,0 +1,15 @@ +|gcd_iter| + +gcd_iter := [ :a :b | + |u v| + u := a. v := b. + [ v > 0 ] + whileTrue: [ |t| + t := u. + u := v. + v := t rem: v + ]. + u abs +]. + +(gcd_iter value: 40902 value: 24140) printNl. diff --git a/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-1.tcl b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-1.tcl new file mode 100644 index 0000000000..7a33558183 --- /dev/null +++ b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-1.tcl @@ -0,0 +1,8 @@ +package require Tcl 8.5 +namespace path {::tcl::mathop ::tcl::mathfunc} +proc gcd_iter {p q} { + while {$q != 0} { + lassign [list $q [% $p $q]] p q + } + abs $p +} diff --git a/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-2.tcl b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-2.tcl new file mode 100644 index 0000000000..6951d5ef44 --- /dev/null +++ b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-2.tcl @@ -0,0 +1,6 @@ +proc gcd {p q} { + if {$q == 0} { + return $p + } + gcd $q [expr {$p % $q}] +} diff --git a/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-3.tcl b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-3.tcl new file mode 100644 index 0000000000..c595caf102 --- /dev/null +++ b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-3.tcl @@ -0,0 +1,6 @@ +proc gcd {p q} { + if {$q == 0} { + return $p + } + tailcall gcd $q [expr {$p % $q}] +} diff --git a/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-4.tcl b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-4.tcl new file mode 100644 index 0000000000..3ec0fca76e --- /dev/null +++ b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-4.tcl @@ -0,0 +1,22 @@ +package require Tcl 8.5 +namespace path {::tcl::mathop ::tcl::mathfunc} +proc gcd_bin {p q} { + if {$p == $q} {return [abs $p]} + set p [abs $p] + if {$q == 0} {return $p} + set q [abs $q] + if {$p < $q} {lassign [list $q $p] p q} + set k 1 + while {($p & 1) == 0 && ($q & 1) == 0} { + set p [>> $p 1] + set q [>> $q 1] + set k [<< $k 1] + } + set t [expr {$p & 1 ? -$q : $p}] + while {$t} { + while {$t & 1 == 0} {set t [>> $t 1]} + if {$t > 0} {set p $t} {set q [- $t]} + set t [- $p $q] + } + return [* $p $k] +} diff --git a/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-5.tcl b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-5.tcl new file mode 100644 index 0000000000..a44153f43a --- /dev/null +++ b/Task/Greatest-common-divisor/Tcl/greatest-common-divisor-5.tcl @@ -0,0 +1,3 @@ +foreach proc {gcd_iter gcd gcd_bin} { + puts [format "%-8s - %s" $proc [time {$proc $u $v} 100000]] +} diff --git a/Task/Greatest-element-of-a-list/0DESCRIPTION b/Task/Greatest-element-of-a-list/0DESCRIPTION new file mode 100644 index 0000000000..050070239f --- /dev/null +++ b/Task/Greatest-element-of-a-list/0DESCRIPTION @@ -0,0 +1 @@ +Create a function that returns the maximum value in a provided set of values, where the number of values may not be known until runtime. diff --git a/Task/Greatest-element-of-a-list/1META.yaml b/Task/Greatest-element-of-a-list/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Greatest-element-of-a-list/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Greatest-element-of-a-list/ACL2/greatest-element-of-a-list.acl2 b/Task/Greatest-element-of-a-list/ACL2/greatest-element-of-a-list.acl2 new file mode 100644 index 0000000000..fe6d3da415 --- /dev/null +++ b/Task/Greatest-element-of-a-list/ACL2/greatest-element-of-a-list.acl2 @@ -0,0 +1,5 @@ +(defun maximum (xs) + (if (endp (rest xs)) + (first xs) + (max (first xs) + (maximum (rest xs))))) diff --git a/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg b/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg new file mode 100644 index 0000000000..15570e56dd --- /dev/null +++ b/Task/Greatest-element-of-a-list/ALGOL-68/greatest-element-of-a-list.alg @@ -0,0 +1,30 @@ +# substitute any array type with a scalar element # +MODE FLT = REAL; + +# create an exception for the case of an empty array # +PROC raise empty array = VOID:( + GO TO except empty array +); + +PROC max = ([]FLT item)FLT: +BEGIN + IF LWB item > UPB item THEN + raise empty array; SKIP + ELSE + FLT max element := item[LWB item]; + + FOR i FROM LWB item + 1 TO UPB item DO + IF item[i] > max element THEN + max element := item[i] + FI + OD; + max element + FI +END # max #; + +test:( + []FLT buf = (-275.0, -111.19, 0.0, -1234568.0, pi, -pi); + print((max(buf),new line)) EXIT + except empty array: + SKIP +) diff --git a/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-1.apl b/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-1.apl new file mode 100644 index 0000000000..ab345d8fe1 --- /dev/null +++ b/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-1.apl @@ -0,0 +1,2 @@ +LIST←2 4 6 3 8 +⌈/LIST diff --git a/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-2.apl b/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-2.apl new file mode 100644 index 0000000000..45a4fb75db --- /dev/null +++ b/Task/Greatest-element-of-a-list/APL/greatest-element-of-a-list-2.apl @@ -0,0 +1 @@ +8 diff --git a/Task/Greatest-element-of-a-list/AWK/greatest-element-of-a-list.awk b/Task/Greatest-element-of-a-list/AWK/greatest-element-of-a-list.awk new file mode 100644 index 0000000000..bf31839c84 --- /dev/null +++ b/Task/Greatest-element-of-a-list/AWK/greatest-element-of-a-list.awk @@ -0,0 +1,2 @@ +$ awk 'func max(a){for(i in a)if(a[i]>r)r=a[i];return r}BEGIN{a[0]=42;a[1]=33;a[2]=21;print max(a)}' +42 diff --git a/Task/Greatest-element-of-a-list/ActionScript/greatest-element-of-a-list.as b/Task/Greatest-element-of-a-list/ActionScript/greatest-element-of-a-list.as new file mode 100644 index 0000000000..d89af0e962 --- /dev/null +++ b/Task/Greatest-element-of-a-list/ActionScript/greatest-element-of-a-list.as @@ -0,0 +1,7 @@ +function max(... args):Number +{ + var curMax:Number = -Infinity; + for(var i:uint = 0; i < args.length; i++) + curMax = Math.max(curMax, args[i]); + return curMax; +} diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.ada b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.ada new file mode 100644 index 0000000000..cc9ef7f578 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-1.ada @@ -0,0 +1,28 @@ +with Ada.Text_Io; + +procedure Max_Test is + -- substitute any array type with a scalar element + type Flt_Array is array (Natural range <>) of Float; + + -- Create an exception for the case of an empty array + Empty_Array : Exception; + + function Max(Item : Flt_Array) return Float is + Max_Element : Float := Float'First; + begin + if Item'Length = 0 then + raise Empty_Array; + end if; + + for I in Item'range loop + if Item(I) > Max_Element then + Max_Element := Item(I); + end if; + end loop; + return Max_Element; + end Max; + + Buf : Flt_Array := (-275.0, -111.19, 0.0, -1234568.0, 3.14159, -3.14159); +begin + Ada.Text_IO.Put_Line(Float'Image(Max(Buf))); +end Max_Test; diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.ada b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.ada new file mode 100644 index 0000000000..11b8d9376e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-2.ada @@ -0,0 +1,4 @@ +generic + type Item is digits <>; + type Items_Array is array (Positive range <>) of Item; +function Generic_Max (List : Items_Array) return Item; diff --git a/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.ada b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.ada new file mode 100644 index 0000000000..68fbe4483e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Ada/greatest-element-of-a-list-3.ada @@ -0,0 +1,8 @@ +function Generic_Max (List : Items_Array) return Item is + Result : Item := List (List'First); +begin + for Index in List'First + 1..List'Last loop + Result := Item'Max (Result, List (Index)); + end loop; + return Result; +end Generic_Max; diff --git a/Task/Greatest-element-of-a-list/Aime/greatest-element-of-a-list.aime b/Task/Greatest-element-of-a-list/Aime/greatest-element-of-a-list.aime new file mode 100644 index 0000000000..a6a987cdc8 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Aime/greatest-element-of-a-list.aime @@ -0,0 +1,18 @@ +integer +lmax(list l) +{ + integer i, max; + + max = l_q_integer(l, 0); + + i = 1; + while (i < l_length(l)) { + if (max < l_q_integer(l, i)) { + max = l_q_integer(l, i); + } + + i += 1; + } + + return max; +} diff --git a/Task/Greatest-element-of-a-list/AppleScript/greatest-element-of-a-list.applescript b/Task/Greatest-element-of-a-list/AppleScript/greatest-element-of-a-list.applescript new file mode 100644 index 0000000000..61e8dd101c --- /dev/null +++ b/Task/Greatest-element-of-a-list/AppleScript/greatest-element-of-a-list.applescript @@ -0,0 +1,7 @@ +on max(aList) + set _curMax to first item of aList + repeat with i in (rest of aList) + if i > _curMax then set _curMax to contents of i + end repeat + return _curMax +end max diff --git a/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-1.ahk b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-1.ahk new file mode 100644 index 0000000000..23652aaf79 --- /dev/null +++ b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-1.ahk @@ -0,0 +1,4 @@ +list = 1,5,17,-2 +Loop Parse, list, `, + x := x < A_LoopField ? A_LoopField : x +MsgBox Max = %x% diff --git a/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-2.ahk b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-2.ahk new file mode 100644 index 0000000000..6595047775 --- /dev/null +++ b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-2.ahk @@ -0,0 +1,5 @@ +list = 1,5,17,-2 +StringSplit, list, list,`, ; creates a pseudo-array +Loop % List0 + x := x < List%A_Index% ? List%A_Index% : x +MsgBox Max = %x% diff --git a/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-3.ahk b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-3.ahk new file mode 100644 index 0000000000..854fe8d819 --- /dev/null +++ b/Task/Greatest-element-of-a-list/AutoHotkey/greatest-element-of-a-list-3.ahk @@ -0,0 +1,4 @@ +List := [1,5,17,-2] +For each, value in List + x := x < value ? value : x +MsgBox Max = %x% diff --git a/Task/Greatest-element-of-a-list/BASIC/greatest-element-of-a-list.bas b/Task/Greatest-element-of-a-list/BASIC/greatest-element-of-a-list.bas new file mode 100644 index 0000000000..163b223699 --- /dev/null +++ b/Task/Greatest-element-of-a-list/BASIC/greatest-element-of-a-list.bas @@ -0,0 +1,46 @@ +DECLARE SUB addVal (value AS INTEGER) +DECLARE FUNCTION findMax% () + +REDIM SHARED vals(0) AS INTEGER +DIM SHARED valCount AS INTEGER +DIM x AS INTEGER, y AS INTEGER + +valCount = -1 + +'''''begin test run +RANDOMIZE TIMER +FOR x = 1 TO 10 + y = INT(RND * 100) + addVal y + PRINT y; " "; +NEXT +PRINT ": "; findMax +'''''end test run + +SUB addVal (value AS INTEGER) + DIM tmp AS INTEGER + IF valCount > -1 THEN + 'this is needed for BASICs that don't support REDIM PRESERVE + REDIM v2(valCount) AS INTEGER + FOR tmp = 0 TO valCount + v2(tmp) = vals(tmp) + NEXT + END IF + valCount = valCount + 1 + REDIM vals(valCount) + IF valCount > 0 THEN + 'also needed for BASICs that don't support REDIM PRESERVE + FOR tmp = 0 TO valCount - 1 + vals(tmp) = v2(tmp) + NEXT + END IF + vals(valCount) = value +END SUB + +FUNCTION findMax% + DIM tmp1 AS INTEGER, tmp2 AS INTEGER + FOR tmp1 = 0 TO valCount + IF vals(tmp1) > tmp2 THEN tmp2 = vals(tmp1) + NEXT + findMax = tmp2 +END FUNCTION diff --git a/Task/Greatest-element-of-a-list/BBC-BASIC/greatest-element-of-a-list.bbc b/Task/Greatest-element-of-a-list/BBC-BASIC/greatest-element-of-a-list.bbc new file mode 100644 index 0000000000..6d32b3c6fa --- /dev/null +++ b/Task/Greatest-element-of-a-list/BBC-BASIC/greatest-element-of-a-list.bbc @@ -0,0 +1,12 @@ + ListOfValues$ = "13, 0, -6, 2, 37, -10, 12" + PRINT "Maximum value = " ; FNmax(ListOfValues$) + END + + DEF FNmax(list$) + LOCAL index%, number, max + REPEAT + number = VAL(MID$(list$, index%+1)) + IF number > max THEN max = number + index% = INSTR(list$, ",", index%+1) + UNTIL index% = 0 + = max diff --git a/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-1.bat b/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-1.bat new file mode 100644 index 0000000000..9fd5dd3884 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-1.bat @@ -0,0 +1,17 @@ +::max.cmd +@echo off +setlocal enabledelayedexpansion +set a=.%~1 +if "%a%" equ "." set /p a="Input stream: " +call :max res %a% +echo %res% +endlocal +goto :eof + +:max +set %1=%2 +:loop +shift /2 +if "%2" equ "" goto :eof +if %2 gtr !%1! set res=%2 +goto loop diff --git a/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-2.bat b/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-2.bat new file mode 100644 index 0000000000..6b2814bdb7 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Batch-File/greatest-element-of-a-list-2.bat @@ -0,0 +1,6 @@ +>max "123 456 3 234243 12" +234243 + +>max +Input stream: 5 4 3 2 67 1 +67 diff --git a/Task/Greatest-element-of-a-list/Burlesque/greatest-element-of-a-list.blq b/Task/Greatest-element-of-a-list/Burlesque/greatest-element-of-a-list.blq new file mode 100644 index 0000000000..2eda379a84 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Burlesque/greatest-element-of-a-list.blq @@ -0,0 +1,2 @@ +blsq ) {88 99 77 66 55}>] +99 diff --git a/Task/Greatest-element-of-a-list/C++/greatest-element-of-a-list.cpp b/Task/Greatest-element-of-a-list/C++/greatest-element-of-a-list.cpp new file mode 100644 index 0000000000..913547ae22 --- /dev/null +++ b/Task/Greatest-element-of-a-list/C++/greatest-element-of-a-list.cpp @@ -0,0 +1,7 @@ +#include +#include + +template Ty max(unsigned int count, Ty values[]) { + assert(count > 0); + return *std::max_element(values, values + count); +} diff --git a/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-1.c b/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-1.c new file mode 100644 index 0000000000..b5395f2d73 --- /dev/null +++ b/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-1.c @@ -0,0 +1,11 @@ +#include + +float max(unsigned int count, float values[]) { + assert(count > 0); + unsigned int idx; + float themax = values[0]; + for(i = 1; i < count; ++i) { + themax = values[i] > themax ? values[i] : themax; + } + return themax; +} diff --git a/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-2.c b/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-2.c new file mode 100644 index 0000000000..48ea5c09ab --- /dev/null +++ b/Task/Greatest-element-of-a-list/C/greatest-element-of-a-list-2.c @@ -0,0 +1,14 @@ +#include + +#define MAX(A,...) ({ inline __typeof__ (A) _max_(__typeof__ (A) a, ...) {\ + va_list l; int i,c; const char *s = #__VA_ARGS__; __typeof__ (A) max = a;\ + __typeof__ (A) t;\ + for(c=1;*s!=0;s++) if (*s==',') c++;\ + va_start(l, a);\ + for(i=0;i<=c;i++) {\ + if ((t=va_arg(l,__typeof__ (A))) > max) max = t;\ + }\ + va_end(l); return max;\ +}\ +_max_((A),__VA_ARGS__);\ +}) diff --git a/Task/Greatest-element-of-a-list/CMake/greatest-element-of-a-list.cmake b/Task/Greatest-element-of-a-list/CMake/greatest-element-of-a-list.cmake new file mode 100644 index 0000000000..b3ce1ad2b1 --- /dev/null +++ b/Task/Greatest-element-of-a-list/CMake/greatest-element-of-a-list.cmake @@ -0,0 +1,19 @@ +# max(var [value1 value2...]) sets var to the maximum of a list of +# integers. If list is empty, sets var to NO. +function(max var) + set(first YES) + set(choice NO) + foreach(item ${ARGN}) + if(first) + set(choice ${item}) + set(first NO) + elseif(choice LESS ${item}) + set(choice ${item}) + endif() + endforeach(item) + set(${var} ${choice} PARENT_SCOPE) +endfunction(max) + +set(list 33 11 44 22 66 55) +max(maximum ${list}) +message(STATUS "maximum of ${list} => ${maximum}") diff --git a/Task/Greatest-element-of-a-list/Clojure/greatest-element-of-a-list.clj b/Task/Greatest-element-of-a-list/Clojure/greatest-element-of-a-list.clj new file mode 100644 index 0000000000..a082b8010e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Clojure/greatest-element-of-a-list.clj @@ -0,0 +1,3 @@ +(max 1 2 3 4) ; evaluates to 4 +;; If the values are already in a collection, use apply: +(apply max [1 2 3 4]) ; evaluates to 4 diff --git a/Task/Greatest-element-of-a-list/CoffeeScript/greatest-element-of-a-list.coffee b/Task/Greatest-element-of-a-list/CoffeeScript/greatest-element-of-a-list.coffee new file mode 100644 index 0000000000..0adabb461f --- /dev/null +++ b/Task/Greatest-element-of-a-list/CoffeeScript/greatest-element-of-a-list.coffee @@ -0,0 +1,16 @@ +# using Math library +max1 = (list) -> + Math.max.apply null, list + +# using no libraries +max2 = (list) -> + maxVal = list[0] + for value in list + maxVal = value if value > maxVal + maxVal + + + +# Test it +a = [0,1,2,5,4]; +alert(max1(a)+". The answer is "+max2(a)); diff --git a/Task/Greatest-element-of-a-list/Common-Lisp/greatest-element-of-a-list.lisp b/Task/Greatest-element-of-a-list/Common-Lisp/greatest-element-of-a-list.lisp new file mode 100644 index 0000000000..733e7465f7 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Common-Lisp/greatest-element-of-a-list.lisp @@ -0,0 +1,4 @@ +(max 1 2 3 4) +(reduce #'max values) ; find max of a list +(loop for x in values + maximize x) ; alternative way to find max of a list diff --git a/Task/Greatest-element-of-a-list/D/greatest-element-of-a-list.d b/Task/Greatest-element-of-a-list/D/greatest-element-of-a-list.d new file mode 100644 index 0000000000..ec6e1d9f1d --- /dev/null +++ b/Task/Greatest-element-of-a-list/D/greatest-element-of-a-list.d @@ -0,0 +1,7 @@ +import std.stdio, std.algorithm; + +void main() { + auto items = [9, 4, 3, 8, 5]; + auto m = reduce!max(items); + writeln(m); +} diff --git a/Task/Greatest-element-of-a-list/Dart/greatest-element-of-a-list.dart b/Task/Greatest-element-of-a-list/Dart/greatest-element-of-a-list.dart new file mode 100644 index 0000000000..433b000642 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Dart/greatest-element-of-a-list.dart @@ -0,0 +1,10 @@ +/*This is a function which returns the greatest element in a list of numbers */ +num findGreatestElement(List list){ + num greatestElement = list[0]; + for (num element in list){ + if (element>greatestElement) { + greatestElement = element; + } + } + return greatestElement; +} diff --git a/Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.delphi b/Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.delphi new file mode 100644 index 0000000000..95f08199a7 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Delphi/greatest-element-of-a-list.delphi @@ -0,0 +1,2 @@ +Math.MaxIntValue(); // Array of Integer +Math.MaxValue(); // Array of floating point (Single, Double or Extended) diff --git a/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-1.e b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-1.e new file mode 100644 index 0000000000..fce8387da1 --- /dev/null +++ b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-1.e @@ -0,0 +1,5 @@ +pragma.enable("accumulator") # non-finalized syntax feature + +def max([first] + rest) { + return accum first for x in rest { _.max(x) } +} diff --git a/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-2.e b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-2.e new file mode 100644 index 0000000000..554e8544f3 --- /dev/null +++ b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-2.e @@ -0,0 +1,2 @@ +? max([1, 2, 3]) +# value: 3 diff --git a/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-3.e b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-3.e new file mode 100644 index 0000000000..aec720cf37 --- /dev/null +++ b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-3.e @@ -0,0 +1,6 @@ +def max([var bestSoFar] + rest) { + for x ? (x > bestSoFar) in rest { + bestSoFar := x + } + return bestSoFar +} diff --git a/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-4.e b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-4.e new file mode 100644 index 0000000000..d359cb9208 --- /dev/null +++ b/Task/Greatest-element-of-a-list/E/greatest-element-of-a-list-4.e @@ -0,0 +1,5 @@ +? max([1, 3, 2]) +# value: 3 + +? max([[1].asSet(), [2].asSet(), [1, 2].asSet()]) +# value: [1, 2].asSet() diff --git a/Task/Greatest-element-of-a-list/Efene/greatest-element-of-a-list.efene b/Task/Greatest-element-of-a-list/Efene/greatest-element-of-a-list.efene new file mode 100644 index 0000000000..97f1c21b56 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Efene/greatest-element-of-a-list.efene @@ -0,0 +1,23 @@ +list_max = fn ([Head:Rest]) { + list_max(Rest, Head) +} + +list_max = fn ([], Res) { + Res +} +fn ([Head:Rest], Max) when Head > Max { + list_max(Rest, Head) +} +fn ([_Head:Rest], Max) { + list_max(Rest, Max) +} + +list_max1 = fn ([H:T]) { + lists.foldl(fn erlang.max:2, H, T) +} + +@public +run = fn () { + io.format("~p~n", [list_max([9, 4, 3, 8, 5])]) + io.format("~p~n", [list_max1([9, 4, 3, 8, 5])]) +} diff --git a/Task/Greatest-element-of-a-list/Ela/greatest-element-of-a-list.ela b/Task/Greatest-element-of-a-list/Ela/greatest-element-of-a-list.ela new file mode 100644 index 0000000000..090fa81db5 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Ela/greatest-element-of-a-list.ela @@ -0,0 +1,6 @@ +open list + +findBy p (x::xs) = foldl (\x y | p x y -> x | else -> y) x xs +maximum = findBy (>) + +maximum [1..10] diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.l b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.l new file mode 100644 index 0000000000..0964b341c8 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-1.l @@ -0,0 +1,7 @@ +(defun max (first-arg &rest more-args) + (if more-args + (let ((max-rest (apply 'max more-args))) + (if (> first-arg max-rest) + first-arg + max-rest)) + first-arg)) diff --git a/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.l b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.l new file mode 100644 index 0000000000..ab413bf019 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Emacs-Lisp/greatest-element-of-a-list-2.l @@ -0,0 +1,2 @@ +(max 2 7 5) +7 diff --git a/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-1.erl b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-1.erl new file mode 100644 index 0000000000..7db76c95c5 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-1.erl @@ -0,0 +1,7 @@ +list_max([Head|Rest]) -> + list_max(Rest, Head). + +list_max([], Res) -> Res; +list_max([Head|Rest], Max) when Head > Max -> + list_max(Rest, Head); +list_max([_Head|Rest], Max) -> list_max(Rest, Max). diff --git a/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-2.erl b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-2.erl new file mode 100644 index 0000000000..f284c183ae --- /dev/null +++ b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-2.erl @@ -0,0 +1 @@ +list_max([H|T]) -> lists:foldl(fun erlang:max/2, H, T). diff --git a/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-3.erl b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-3.erl new file mode 100644 index 0000000000..b7bf5bf86e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Erlang/greatest-element-of-a-list-3.erl @@ -0,0 +1,2 @@ +>list_max([9,4,3,8,5]). +9 diff --git a/Task/Greatest-element-of-a-list/Euler-Math-Toolbox/greatest-element-of-a-list.euler b/Task/Greatest-element-of-a-list/Euler-Math-Toolbox/greatest-element-of-a-list.euler new file mode 100644 index 0000000000..5eec617789 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Euler-Math-Toolbox/greatest-element-of-a-list.euler @@ -0,0 +1,3 @@ +>v=random(1,100); +>max(v) + 0.997492478596 diff --git a/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.euphoria b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.euphoria new file mode 100644 index 0000000000..ec23fe2912 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-1.euphoria @@ -0,0 +1,25 @@ +function aeval( sequence sArr, integer id ) + for i = 1 to length( sArr ) do + sArr[ i ] = call_func( id, { sArr[ i ] } ) + end for + return sArr +end function + +object biggun +function biggest( object elem ) + if compare(elem, biggun) > 0 then + biggun = elem + end if + return elem +end function + +biggun = 0 +object a +a = aeval( {1,1234,62,234,12,34,6}, routine_id("biggest") ) +printf( 1, "%d\n", biggun ) + +sequence s +s = {"antelope", "dog", "cat", "cow", "wolf", "wolverine", "aardvark"} +biggun = "ant" +a = aeval( s, routine_id("biggest") ) +printf( 1, "%s\n", {biggun} ) diff --git a/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.euphoria b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.euphoria new file mode 100644 index 0000000000..f9fcbb94d6 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Euphoria/greatest-element-of-a-list-2.euphoria @@ -0,0 +1,16 @@ +function get_biggest(sequence s) + object biggun + biggun = s[1] + for i = 2 to length(s) do + if compare(s[i], biggun) > 0 then + biggun = s[i] + end if + end for + return biggun +end function + +constant numbers = {1,1234,62,234,12,34,6} +printf(1,"%d\n",get_biggest(numbers)) + +constant animals = {"ant", "antelope", "dog", "cat", "cow", "wolf", "wolverine", "aardvark"} +printf(1,"%s\n",{get_biggest(animals)}) diff --git a/Task/Greatest-element-of-a-list/Factor/greatest-element-of-a-list.factor b/Task/Greatest-element-of-a-list/Factor/greatest-element-of-a-list.factor new file mode 100644 index 0000000000..d2df3cef3e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Factor/greatest-element-of-a-list.factor @@ -0,0 +1 @@ +: supremum ( seq -- elt ) [ ] [ max ] map-reduce ; diff --git a/Task/Greatest-element-of-a-list/Fancy/greatest-element-of-a-list.fancy b/Task/Greatest-element-of-a-list/Fancy/greatest-element-of-a-list.fancy new file mode 100644 index 0000000000..d2e9b9507b --- /dev/null +++ b/Task/Greatest-element-of-a-list/Fancy/greatest-element-of-a-list.fancy @@ -0,0 +1 @@ +[1,-2,2,4,6,-4,-1,5] max println # => 6 diff --git a/Task/Greatest-element-of-a-list/Fantom/greatest-element-of-a-list.fantom b/Task/Greatest-element-of-a-list/Fantom/greatest-element-of-a-list.fantom new file mode 100644 index 0000000000..216a57e42e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Fantom/greatest-element-of-a-list.fantom @@ -0,0 +1,9 @@ +class Greatest +{ + public static Void main () + { + Int[] values := [1,2,3,4,5,6,7,8,9] + Int greatest := values.max + echo (greatest) + } +} diff --git a/Task/Greatest-element-of-a-list/Forth/greatest-element-of-a-list.fth b/Task/Greatest-element-of-a-list/Forth/greatest-element-of-a-list.fth new file mode 100644 index 0000000000..5454142cd3 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Forth/greatest-element-of-a-list.fth @@ -0,0 +1,6 @@ +: array-max ( addr len -- max ) + dup 0= if nip exit then + over @ rot cell+ rot 1- + cells bounds ?do i @ max cell +loop ; + +: stack-max ( n ... m count -- max ) 1 ?do max loop ; diff --git a/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-1.f b/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-1.f new file mode 100644 index 0000000000..b3f9ba565c --- /dev/null +++ b/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-1.f @@ -0,0 +1,9 @@ +program test_maxval + +integer,dimension(5),parameter :: x = [10,100,7,1,2] +real,dimension(5),parameter :: y = [5.0,60.0,1.0,678.0,0.0] + +write(*,'(I5)') maxval(x) +write(*,'(F5.1)') maxval(y) + +end program test_maxval diff --git a/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-2.f b/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-2.f new file mode 100644 index 0000000000..3950f0c663 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Fortran/greatest-element-of-a-list-2.f @@ -0,0 +1,22 @@ +program test_max + + implicit none + + write (*, '(i0)') & + & max (1, 2, 3) + write (*, '(f3.1)') & + & max (1.0, 2.0, 3.0) + write (*, '(a)') & + & max ('a', 'b', 'c') + write (*, '(a)') & + & max ('abc', 'bca', 'cab') + write (*, '(i0, 2 (1x, i0))') & + & max ([1, 8, 6], [7, 5, 3], [4, 2, 9]) + write (*, '(f3.1, 2 (1x, f3.1))') & + & max ([1.0, 8.0, 6.0], [7.0, 5.0, 3.0], [4.0, 2.0, 9.0]) + write (*, '(a, 2 (1x, a))') & + & max (['a', 'h', 'f'], ['g', 'e', 'c'], ['d', 'b', 'i']) + write (*, '(a, 2 (1x, a))') & + & max (['abc', 'hig', 'fde'], ['ghi', 'efd', 'cab'], ['def', 'bca', 'igh']) + +end program test_max diff --git a/Task/Greatest-element-of-a-list/Frink/greatest-element-of-a-list.frink b/Task/Greatest-element-of-a-list/Frink/greatest-element-of-a-list.frink new file mode 100644 index 0000000000..2cfc2343e8 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Frink/greatest-element-of-a-list.frink @@ -0,0 +1 @@ +println[max[[1,2,3,5,10,20]]] diff --git a/Task/Greatest-element-of-a-list/GAP/greatest-element-of-a-list.gap b/Task/Greatest-element-of-a-list/GAP/greatest-element-of-a-list.gap new file mode 100644 index 0000000000..eabda1c836 --- /dev/null +++ b/Task/Greatest-element-of-a-list/GAP/greatest-element-of-a-list.gap @@ -0,0 +1,6 @@ +# Built-in + +L := List([1 .. 100], n -> Random(1, 10)); + +MaximumList(L); +# 10 diff --git a/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-1.go b/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-1.go new file mode 100644 index 0000000000..b96a6ee0c0 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-1.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +// function, per task description +func largest(a []int) (lg int, ok bool) { + if len(a) == 0 { + return + } + lg = a[0] + for _, e := range a[1:] { + if e > lg { + lg = e + } + } + return lg, true +} + +func main() { + // random size slice + rand.Seed(time.Now().UnixNano()) + a := make([]int, rand.Intn(11)) + for i := range a { + a[i] = rand.Intn(101) - 100 // fill with random numbers + } + + fmt.Println(a) + lg, ok := largest(a) + if ok { + fmt.Println(lg) + } else { + fmt.Println("empty list. no maximum.") + } +} diff --git a/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-2.go b/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-2.go new file mode 100644 index 0000000000..563ff2f853 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Go/greatest-element-of-a-list-2.go @@ -0,0 +1,64 @@ +package main + +import ( + "fmt" + "math" + "math/rand" + "time" +) + +// Function, per task description. Interesting with the float64 type because +// of the NaN value. NaNs do not compare to other values, so the result of +// a "largest" function on a set containing a NaN might be open to +// interpretation. The solution provided here is to return the largest +// of the non-NaNs, and also return a bool indicating the presense of a NaN. +func largest(s map[float64]bool) (lg float64, ok, nan bool) { + if len(s) == 0 { + return + } + for e := range s { + switch { + case math.IsNaN(e): + nan = true + case !ok || e > lg: + lg = e + ok = true + } + } + return +} + +func main() { + rand.Seed(time.Now().UnixNano()) + // taking "set" literally from task description + s := map[float64]bool{} + // pick number of elements to add to set + n := rand.Intn(11) + // add random numbers, also throw in an occasional NaN or Inf. + for i := 0; i < n; i++ { + switch rand.Intn(10) { + case 0: + s[math.NaN()] = true + case 1: + s[math.Inf(1)] = true + default: + s[rand.ExpFloat64()] = true + } + } + + fmt.Print("s:") + for e := range s { + fmt.Print(" ", e) + } + fmt.Println() + switch lg, ok, nan := largest(s); { + case ok && !nan: + fmt.Println("largest:", lg) + case ok: + fmt.Println("largest:", lg, "(NaN present in data)") + case nan: + fmt.Println("no largest, all data NaN") + default: + fmt.Println("no largest, empty set") + } +} diff --git a/Task/Greatest-element-of-a-list/Golfscript/greatest-element-of-a-list.golf b/Task/Greatest-element-of-a-list/Golfscript/greatest-element-of-a-list.golf new file mode 100644 index 0000000000..aa8ebd6ec0 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Golfscript/greatest-element-of-a-list.golf @@ -0,0 +1,2 @@ +{$-1=}:max; +[1 4 8 42 6 3]max # Example usage diff --git a/Task/Greatest-element-of-a-list/Groovy/greatest-element-of-a-list.groovy b/Task/Greatest-element-of-a-list/Groovy/greatest-element-of-a-list.groovy new file mode 100644 index 0000000000..ad05d99264 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Groovy/greatest-element-of-a-list.groovy @@ -0,0 +1 @@ +println ([2,4,0,3,1,2,-12].max()) diff --git a/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-1.hs b/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-1.hs new file mode 100644 index 0000000000..5d0101fa46 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-1.hs @@ -0,0 +1 @@ +my_max = maximum diff --git a/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-2.hs b/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-2.hs new file mode 100644 index 0000000000..1281a9b220 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Haskell/greatest-element-of-a-list-2.hs @@ -0,0 +1 @@ +my_max = foldl1 max diff --git a/Task/Greatest-element-of-a-list/HicEst/greatest-element-of-a-list.hicest b/Task/Greatest-element-of-a-list/HicEst/greatest-element-of-a-list.hicest new file mode 100644 index 0000000000..1abd6649cc --- /dev/null +++ b/Task/Greatest-element-of-a-list/HicEst/greatest-element-of-a-list.hicest @@ -0,0 +1,22 @@ + max_value = MAX( -123, 234.56, 345.678, -456E3, -455) ! built-in function MAX(...) + +! or for an array: + max_value = MAX( array_of_values ) + +! or to find a maximum value in a file named filename: + CHARACTER List, filename='Greatest element of a list.hic' ! filename contains this script + REAL values(1) ! unknown number of values, allocate more below + + OPEN(FIle=filename, BINary, LENgth=len) + ALLOCATE(values, len/2) ! number of values <= half byte count of file + ! read all values, returns item count in values_found: + READ(FIle=filename, ItemS=values_found, CLoSe=1) values ! no Format needed for plain text numbers + + max_value = MAX(values) + + ! write values found in filename and result to spreadsheet type dialog window: + DLG(Text=values, Text=max_value, TItle=values_found) + + WRITE(ClipBoard, Name) max_value, values_found, values ! pasted to line below + ! max_value=345.678; values_found=30; values(1)=-123; values(2)=234.56; values(3)=345.678; values(4)=-456E3; values(5)=-455; values(6)=1; values(7)=2; values(8)=1; values(9)=0; values(10)=0; ...truncated + END diff --git a/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list.icon b/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list.icon new file mode 100644 index 0000000000..9f2fe0d13a --- /dev/null +++ b/Task/Greatest-element-of-a-list/Icon/greatest-element-of-a-list.icon @@ -0,0 +1,12 @@ +procedure main() + local l + l := [7,8,6,9,4,5,2,3,1] + write(max(l)) +end + +procedure max(l) + local max + max := l[1] + every max <:= !l + return max +end diff --git a/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-1.j b/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-1.j new file mode 100644 index 0000000000..e979537449 --- /dev/null +++ b/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-1.j @@ -0,0 +1 @@ + >./ diff --git a/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-2.j b/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-2.j new file mode 100644 index 0000000000..a32d50c29d --- /dev/null +++ b/Task/Greatest-element-of-a-list/J/greatest-element-of-a-list-2.j @@ -0,0 +1,4 @@ + >./ 1 2 3 2 1 +3 + >./'' NB. Maximum value of an empty list = identity element (or neutral) of max = -∞ +__ diff --git a/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-1.java b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-1.java new file mode 100644 index 0000000000..4d2b20caa8 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-1.java @@ -0,0 +1,10 @@ +public static float max(float[] values) throws NoSuchElementException { + if (values.length == 0) + throw new NoSuchElementException(); + float themax = values[0]; + for (int idx = 1; idx < values.length; ++idx) { + if (values[idx] > themax) + themax = values[idx]; + } + return themax; +} diff --git a/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-2.java b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-2.java new file mode 100644 index 0000000000..3a7961a142 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-2.java @@ -0,0 +1,6 @@ +public static float max(float[] values) throws NoSuchElementException { + if (values.length == 0) + throw new NoSuchElementException(); + Arrays.sort(values);//sorts the values in ascending order + return values[values.length-1]; +} diff --git a/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-3.java b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-3.java new file mode 100644 index 0000000000..e123cabf16 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-3.java @@ -0,0 +1,11 @@ +import java.util.List; +import java.util.Collections; +import java.util.Arrays; + +public static > T max(List values) { + return Collections.max(values); +} + +public static > T max(T[] values) { + return Collections.max(Arrays.asList(values)); +} diff --git a/Task/Greatest-element-of-a-list/JavaScript/greatest-element-of-a-list.js b/Task/Greatest-element-of-a-list/JavaScript/greatest-element-of-a-list.js new file mode 100644 index 0000000000..1d847ca14c --- /dev/null +++ b/Task/Greatest-element-of-a-list/JavaScript/greatest-element-of-a-list.js @@ -0,0 +1,8 @@ +function max(arr) +{ + return Math.max.apply(null, arr); +} + +// Test it +a = [0,1,2,5,4]; +alert(max(a)); diff --git a/Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.julia b/Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.julia new file mode 100644 index 0000000000..a765d0e6ce --- /dev/null +++ b/Task/Greatest-element-of-a-list/Julia/greatest-element-of-a-list.julia @@ -0,0 +1,11 @@ +julia> max([1,3,3,7]) +7 + +julia> max([pi,e+2/5,cos(6)/5,sqrt(91/10)]) +3.141592653589793 + +julia> max([1,6,Inf]) +Inf + +julia> max(Float64[]) +-Inf diff --git a/Task/Greatest-element-of-a-list/K/greatest-element-of-a-list.k b/Task/Greatest-element-of-a-list/K/greatest-element-of-a-list.k new file mode 100644 index 0000000000..afd252707f --- /dev/null +++ b/Task/Greatest-element-of-a-list/K/greatest-element-of-a-list.k @@ -0,0 +1,2 @@ + |/ 6 1 7 4 +7 diff --git a/Task/Greatest-element-of-a-list/Liberty-BASIC/greatest-element-of-a-list.liberty b/Task/Greatest-element-of-a-list/Liberty-BASIC/greatest-element-of-a-list.liberty new file mode 100644 index 0000000000..b0ff5c84c5 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Liberty-BASIC/greatest-element-of-a-list.liberty @@ -0,0 +1,12 @@ +aList$= "1 15 -5 6 39 1.5 14" + +maxVal = val(word$(aList$, 1)) +token$ = "?" +while token$ <> "" + index = index + 1 + token$ = word$(aList$, index) + aVal = val(token$) + if aVal > maxVal then maxVal = aVal +wend + +print "maxVal = ";maxVal diff --git a/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-1.logo b/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-1.logo new file mode 100644 index 0000000000..cc70a0d042 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-1.logo @@ -0,0 +1,5 @@ +to max :a :b +output ifelse :a > :b [:a] [:b] +end + +print reduce "max [...] diff --git a/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-2.logo b/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-2.logo new file mode 100644 index 0000000000..51cdbfd8db --- /dev/null +++ b/Task/Greatest-element-of-a-list/Logo/greatest-element-of-a-list-2.logo @@ -0,0 +1,5 @@ +to max [:inputs] 2 +if emptyp :inputs ~ + [(throw "error [not enough inputs to max])] +output reduce [ifelse ?1 > ?2 [?1] [?2]] :inputs +end diff --git a/Task/Greatest-element-of-a-list/Logtalk/greatest-element-of-a-list.logtalk b/Task/Greatest-element-of-a-list/Logtalk/greatest-element-of-a-list.logtalk new file mode 100644 index 0000000000..43048ae3ad --- /dev/null +++ b/Task/Greatest-element-of-a-list/Logtalk/greatest-element-of-a-list.logtalk @@ -0,0 +1,9 @@ +max([X| Xs], Max) :- + max(Xs, X, Max). + +max([], Max, Max). +max([X| Xs], Aux, Max) :- + ( X @> Aux -> + max(Xs, X, Max) + ; max(Xs, Aux, Max) + ). diff --git a/Task/Greatest-element-of-a-list/Lua/greatest-element-of-a-list.lua b/Task/Greatest-element-of-a-list/Lua/greatest-element-of-a-list.lua new file mode 100644 index 0000000000..18cc81b20f --- /dev/null +++ b/Task/Greatest-element-of-a-list/Lua/greatest-element-of-a-list.lua @@ -0,0 +1,13 @@ +-- Table to store values +local values = {} +-- Read in the first number from stdin +local new_val = io.read"*n" +-- Append all numbers passed in +-- until there are no more numbers (io.read'*n' = nil) +while new_val do + values[#values+1] = new_val + new_val = io.read"*n" +end + +-- Print the max +print(math.max(unpack(values))) diff --git a/Task/Greatest-element-of-a-list/MATLAB/greatest-element-of-a-list.m b/Task/Greatest-element-of-a-list/MATLAB/greatest-element-of-a-list.m new file mode 100644 index 0000000000..55a18628cc --- /dev/null +++ b/Task/Greatest-element-of-a-list/MATLAB/greatest-element-of-a-list.m @@ -0,0 +1,2 @@ +function [maxValue] = findmax(setOfValues) + maxValue = max(setOfValues); diff --git a/Task/Greatest-element-of-a-list/MAXScript/greatest-element-of-a-list.max b/Task/Greatest-element-of-a-list/MAXScript/greatest-element-of-a-list.max new file mode 100644 index 0000000000..f5e89312a2 --- /dev/null +++ b/Task/Greatest-element-of-a-list/MAXScript/greatest-element-of-a-list.max @@ -0,0 +1,10 @@ +fn MaxValue AnArray = +( + if AnArray.count != 0 then + ( + local maxVal = 0 + for i in AnArray do if i > maxVal then maxVal = i + maxVal + ) + else undefined +) diff --git a/Task/Greatest-element-of-a-list/MUMPS/greatest-element-of-a-list.mumps b/Task/Greatest-element-of-a-list/MUMPS/greatest-element-of-a-list.mumps new file mode 100644 index 0000000000..45cc0ba52d --- /dev/null +++ b/Task/Greatest-element-of-a-list/MUMPS/greatest-element-of-a-list.mumps @@ -0,0 +1,5 @@ +MV(A,U) + ;A is a list of values separated by the string U + NEW MAX,T,I + FOR I=1:1 SET T=$PIECE(A,U,I) QUIT:T="" S MAX=$SELECT(($DATA(MAX)=0):T,(MAX=T):MAX) + QUIT MAX diff --git a/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-1.maple b/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-1.maple new file mode 100644 index 0000000000..fae9ac7d49 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-1.maple @@ -0,0 +1,11 @@ +> max( { 1, 2, Pi, exp(1) } ); # set + Pi + +> max( [ 1, 2, Pi, exp(1) ] ); # list + Pi + +> max( 1, 2, Pi, exp(1) ); # sequence + Pi + +> max( Array( [ 1, 2, Pi, exp(1) ] ) ); # Array + Pi diff --git a/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-2.maple b/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-2.maple new file mode 100644 index 0000000000..0f7b460b1e --- /dev/null +++ b/Task/Greatest-element-of-a-list/Maple/greatest-element-of-a-list-2.maple @@ -0,0 +1,2 @@ +> A := Array([1,2,4/5,3,11]): rtable_scanblock( A, [rtable_dims(A)], Maximum ); + 11 diff --git a/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-1.mathematica b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-1.mathematica new file mode 100644 index 0000000000..a55b6e64fc --- /dev/null +++ b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-1.mathematica @@ -0,0 +1,4 @@ +Max[1, 3, 3, 7] +Max[Pi,E+2/5,17 Cos[6]/5,Sqrt[91/10]] +Max[1,6,Infinity] +Max[] diff --git a/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-2.mathematica b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-2.mathematica new file mode 100644 index 0000000000..e0f0636b8c --- /dev/null +++ b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-2.mathematica @@ -0,0 +1,4 @@ + 7 + 17 Cos[6]/5 + Infinity +-Infinity diff --git a/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-3.mathematica b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-3.mathematica new file mode 100644 index 0000000000..a396d4eb25 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-3.mathematica @@ -0,0 +1,4 @@ +Max[Max[],Max[a,b,c]] +Max[Max[a],Max[b,c]] +Max[Max[a,b],Max[c]] +Max[Max[a,b,c],Max[]] diff --git a/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-4.mathematica b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-4.mathematica new file mode 100644 index 0000000000..4825b3c27f --- /dev/null +++ b/Task/Greatest-element-of-a-list/Mathematica/greatest-element-of-a-list-4.mathematica @@ -0,0 +1 @@ +Max[Max[], Max[-4, -3]] diff --git a/Task/Greatest-element-of-a-list/Maxima/greatest-element-of-a-list.maxima b/Task/Greatest-element-of-a-list/Maxima/greatest-element-of-a-list.maxima new file mode 100644 index 0000000000..9b5bc12134 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Maxima/greatest-element-of-a-list.maxima @@ -0,0 +1,8 @@ +: makelist(random(1000), 50)$ + +/* Three solutions */ +lreduce(max, u); + +apply(max, u); + +lmax(u); diff --git a/Task/Greatest-element-of-a-list/Metafont/greatest-element-of-a-list.metafont b/Task/Greatest-element-of-a-list/Metafont/greatest-element-of-a-list.metafont new file mode 100644 index 0000000000..7be93241c9 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Metafont/greatest-element-of-a-list.metafont @@ -0,0 +1,3 @@ +show max(4,5,20,1); +show max((12,3), (10,10), (25,5)); +show max("hello", "world", "Hello World"); diff --git a/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-1.mod3 b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-1.mod3 new file mode 100644 index 0000000000..1872fec855 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-1.mod3 @@ -0,0 +1,7 @@ +GENERIC INTERFACE Maximum(Elem); + +EXCEPTION Empty; + +PROCEDURE Max(READONLY a: ARRAY OF Elem.T): Elem.T RAISES {Empty}; + +END Maximum. diff --git a/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-2.mod3 b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-2.mod3 new file mode 100644 index 0000000000..cfff1f0738 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-2.mod3 @@ -0,0 +1,18 @@ +GENERIC MODULE Maximum(Elem); + +PROCEDURE Max(READONLY arr: ARRAY OF Elem.T): Elem.T RAISES {Empty} = + VAR max := FIRST(Elem.T); + BEGIN + IF NUMBER(arr) = 0 THEN + RAISE Empty; + END; + FOR i := FIRST(arr) TO LAST(arr) DO + IF arr[i] > max THEN + max := arr[i]; + END; + END; + RETURN max; + END Max; + +BEGIN +END Maximum. diff --git a/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-3.mod3 b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-3.mod3 new file mode 100644 index 0000000000..69ec89823f --- /dev/null +++ b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-3.mod3 @@ -0,0 +1 @@ +INTERFACE RealMax = Maximum(Real) END RealMax. diff --git a/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-4.mod3 b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-4.mod3 new file mode 100644 index 0000000000..7b4caa3241 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-4.mod3 @@ -0,0 +1 @@ +MODULE RealMax = Maximum(Real) END RealMax. diff --git a/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-5.mod3 b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-5.mod3 new file mode 100644 index 0000000000..e077b515d3 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Modula-3/greatest-element-of-a-list-5.mod3 @@ -0,0 +1,9 @@ +MODULE Main; + +IMPORT RealMax, IO, Fmt; + +VAR realarr := ARRAY [1..5] OF REAL {1.1, 1.0, 0.0, 2.4, 3.3}; + +BEGIN + IO.Put(Fmt.Real(RealMax.Max(realarr)) & "\n"); +END Main. diff --git a/Task/Greatest-element-of-a-list/PHP/greatest-element-of-a-list.php b/Task/Greatest-element-of-a-list/PHP/greatest-element-of-a-list.php new file mode 100644 index 0000000000..fc3ca0dde2 --- /dev/null +++ b/Task/Greatest-element-of-a-list/PHP/greatest-element-of-a-list.php @@ -0,0 +1 @@ +max($values) diff --git a/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-1.pl b/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-1.pl new file mode 100644 index 0000000000..07e1c95451 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-1.pl @@ -0,0 +1,8 @@ +sub max { + my @list = @_; + my $themax = $list[0]; + foreach ( @list ) { + $themax = $_ > $themax ? $_ : $themax; + } + return $themax; +} diff --git a/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-2.pl b/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-2.pl new file mode 100644 index 0000000000..78d130a7ae --- /dev/null +++ b/Task/Greatest-element-of-a-list/Perl/greatest-element-of-a-list-2.pl @@ -0,0 +1,3 @@ +use List::Util qw(max); + +max(@values); diff --git a/Task/Greatest-element-of-a-list/PicoLisp/greatest-element-of-a-list.l b/Task/Greatest-element-of-a-list/PicoLisp/greatest-element-of-a-list.l new file mode 100644 index 0000000000..e8d75c7834 --- /dev/null +++ b/Task/Greatest-element-of-a-list/PicoLisp/greatest-element-of-a-list.l @@ -0,0 +1,6 @@ +: (max 2 4 1 3) # Return the maximal argument +-> 4 +: (apply max (2 4 1 3)) # Apply to a list +-> 4 +: (maxi abs (2 -4 -1 3)) # Maximum according to given function +-> -4 diff --git a/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-1.pro b/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-1.pro new file mode 100644 index 0000000000..a9f3185d3b --- /dev/null +++ b/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-1.pro @@ -0,0 +1,2 @@ + ?- max_list([1, 2, 10, 3, 0, 7, 9, 5], M). +M = 10. diff --git a/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-2.pro b/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-2.pro new file mode 100644 index 0000000000..9616cdbd77 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Prolog/greatest-element-of-a-list-2.pro @@ -0,0 +1,11 @@ +max_list([H|T], Max) :- + max_list(T, H, Max). + +max_list([], Max, Max). + +max_list([H|T], Max0, Max) :- + H > Max0, !, + max_list(T, H, Max). + +max_list([_|T], Max0, Max) :- + max_list(T, Max0, Max). diff --git a/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-1.py b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-1.py new file mode 100644 index 0000000000..eddf657a66 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-1.py @@ -0,0 +1 @@ +max(values) diff --git a/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-2.py b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-2.py new file mode 100644 index 0000000000..286a2a079b --- /dev/null +++ b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-2.py @@ -0,0 +1,4 @@ +>>> floatstrings = ['1\n', ' 2.3\n', '4.5e-1\n', '0.01e4\n', '-1.2'] +>>> max(floatstrings, key = float) +'0.01e4\n' +>>> diff --git a/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-3.py b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-3.py new file mode 100644 index 0000000000..985a526991 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Python/greatest-element-of-a-list-3.py @@ -0,0 +1,3 @@ +>>> max(float(x) for x in floatstrings) +100.0 +>>> diff --git a/Task/Greatest-element-of-a-list/R/greatest-element-of-a-list.r b/Task/Greatest-element-of-a-list/R/greatest-element-of-a-list.r new file mode 100644 index 0000000000..bcbfe7f9bd --- /dev/null +++ b/Task/Greatest-element-of-a-list/R/greatest-element-of-a-list.r @@ -0,0 +1,2 @@ +v <- c(1, 2, 100, 50, 0) +print(max(v)) # 100 diff --git a/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-1.rexx b/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-1.rexx new file mode 100644 index 0000000000..07eedf5437 --- /dev/null +++ b/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-1.rexx @@ -0,0 +1,11 @@ +/*REXX program finds the greatest element in a list (of numbers). */ + /* [↓] list of first twenty reversed primes*/ +y = '2 3 5 7 11 31 71 91 32 92 13 73 14 34 74 35 95 16 76 17' + +big = word(y,1) /*choose a initial biggest number*/ + do j=2 to words(y) /*traipse through the list. */ + big = max(big, word(y,j)) + end /*j*/ + +say 'the biggest value in a list of' words(y) "numbers is:" big + /*stick a fork in it, we're done.*/ diff --git a/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-2.rexx b/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-2.rexx new file mode 100644 index 0000000000..0f5564e5ec --- /dev/null +++ b/Task/Greatest-element-of-a-list/REXX/greatest-element-of-a-list-2.rexx @@ -0,0 +1,14 @@ +/*REXX program finds the greatest element in an array (of numbers). */ +y.1 = 2; y.2 = 3; y.3 = 5; y.4 = 7; y.5 = 11 +y.6 = 31; y.7 = 71; y.8 = 91; y.9 = 32; y.10 = 92 +y.11 = 13; y.12 = 73; y.13 = 14; y.14 = 34; y.15 = 74 +y.16 = 35; y.17 = 95; y.18 = 16; y.19 = 76; y.20 = 17 + +big = y.1 /*choose a initial biggest number*/ +items = 20 /*number of elements in the array*/ + do j=2 to items /*traipse through the array. */ + big = max(big, y.j) /*use a BIF for finding the max. */ + end /*j*/ + +say 'the biggest value in an array of' items "elements is:" big + /*stick a fork in it, we're done.*/ diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-1.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-1.rkt new file mode 100644 index 0000000000..5286094a58 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-1.rkt @@ -0,0 +1 @@ + (max 12 9 8 17 1) diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-2.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-2.rkt new file mode 100644 index 0000000000..d193859153 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-2.rkt @@ -0,0 +1 @@ + 17 diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-3.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-3.rkt new file mode 100644 index 0000000000..adb127c764 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-3.rkt @@ -0,0 +1 @@ + (apply max '(12 9 8 17 1)) diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-4.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-4.rkt new file mode 100644 index 0000000000..d193859153 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-4.rkt @@ -0,0 +1 @@ + 17 diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-5.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-5.rkt new file mode 100644 index 0000000000..7b2458b691 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-5.rkt @@ -0,0 +1,10 @@ +(define (my-max l) + (define (max-h l greatest) + (cond [(empty? l) greatest] + [(> (first l) greatest) + (max-h (rest l) (first l))] + [else + (max-h (rest l) greatest)])) + (if (empty? l) + empty + (max-h l (first l)))) diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-6.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-6.rkt new file mode 100644 index 0000000000..13a90b0105 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-6.rkt @@ -0,0 +1 @@ + (my-max '(12 9 8 17 1)) diff --git a/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-7.rkt b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-7.rkt new file mode 100644 index 0000000000..d193859153 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Racket/greatest-element-of-a-list-7.rkt @@ -0,0 +1 @@ + 17 diff --git a/Task/Greatest-element-of-a-list/Ruby/greatest-element-of-a-list.rb b/Task/Greatest-element-of-a-list/Ruby/greatest-element-of-a-list.rb new file mode 100644 index 0000000000..dffdaeae40 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Ruby/greatest-element-of-a-list.rb @@ -0,0 +1 @@ +values.max diff --git a/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-1.scala b/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-1.scala new file mode 100644 index 0000000000..d68af188b1 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-1.scala @@ -0,0 +1 @@ +List(1,2,3,4) reduceLeft { _ max _ } diff --git a/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-2.scala b/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-2.scala new file mode 100644 index 0000000000..5939b5ac38 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Scala/greatest-element-of-a-list-2.scala @@ -0,0 +1 @@ +List(1,2,3,4).max diff --git a/Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.ss b/Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.ss new file mode 100644 index 0000000000..91011b95fa --- /dev/null +++ b/Task/Greatest-element-of-a-list/Scheme/greatest-element-of-a-list.ss @@ -0,0 +1,2 @@ +(max 1 2 3 4) +(apply max values) ; find max of a list diff --git a/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-1.st b/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-1.st new file mode 100644 index 0000000000..22e3e4a213 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-1.st @@ -0,0 +1 @@ +#(1 2 3 4 20 10 9 8) fold: [:a :b | a max: b] "returns 20" diff --git a/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-2.st b/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-2.st new file mode 100644 index 0000000000..65279b18b6 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Smalltalk/greatest-element-of-a-list-2.st @@ -0,0 +1 @@ +#(1 2 3 4 20 10 9 8) max. "returns 20" diff --git a/Task/Greatest-element-of-a-list/Tcl/greatest-element-of-a-list.tcl b/Task/Greatest-element-of-a-list/Tcl/greatest-element-of-a-list.tcl new file mode 100644 index 0000000000..6b57eadcd5 --- /dev/null +++ b/Task/Greatest-element-of-a-list/Tcl/greatest-element-of-a-list.tcl @@ -0,0 +1,4 @@ +package require Tcl 8.5 + +set values {4 3 2 7 8 9} +::tcl::mathfunc::max {*}$values ;# ==> 9 diff --git a/Task/Greatest-subsequential-sum/0DESCRIPTION b/Task/Greatest-subsequential-sum/0DESCRIPTION new file mode 100644 index 0000000000..28a0e35add --- /dev/null +++ b/Task/Greatest-subsequential-sum/0DESCRIPTION @@ -0,0 +1 @@ +Given a sequence of integers, find a continuous subsequence which maximizes the sum of its elements, that is, the elements of no other single subsequence add up to a value larger than this one. An empty subsequence is considered to have the sum 0; thus if all elements are negative, the result must be the empty sequence. diff --git a/Task/Greatest-subsequential-sum/1META.yaml b/Task/Greatest-subsequential-sum/1META.yaml new file mode 100644 index 0000000000..d81f2567b2 --- /dev/null +++ b/Task/Greatest-subsequential-sum/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Arithmetic operations diff --git a/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg b/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg new file mode 100644 index 0000000000..71d6e84d21 --- /dev/null +++ b/Task/Greatest-subsequential-sum/ALGOL-68/greatest-subsequential-sum.alg @@ -0,0 +1,29 @@ +main: +( + []INT a = (-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1); + + INT begin max, end max, max sum, sum; + + sum := 0; + begin max := 0; + end max := -1; + max sum := 0; + + + FOR begin FROM LWB a TO UPB a DO + sum := 0; + FOR end FROM begin TO UPB a DO + sum +:= a[end]; + IF sum > max sum THEN + max sum := sum; + begin max := begin; + end max := end + FI + OD + OD; + + FOR i FROM begin max TO end max DO + print(a[i]) + OD + +) diff --git a/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-1.awk b/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-1.awk new file mode 100644 index 0000000000..5ea6bb986d --- /dev/null +++ b/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-1.awk @@ -0,0 +1,28 @@ +# Finds the subsequence of ary[1] to ary[len] with the greatest sum. +# Sets subseq[1] to subseq[n] and returns n. Also sets subseq["sum"]. +# An empty subsequence has sum 0. +function maxsubseq(subseq, ary, len, b, bp, bs, c, cp, i) { + b = 0 # best sum + c = 0 # current sum + bp = 0 # position of best subsequence + bn = 0 # length of best subsequence + cp = 1 # position of current subsequence + + for (i = 1; i <= len; i++) { + c += ary[i] + if (c < 0) { + c = 0 + cp = i + 1 + } + if (c > b) { + b = c + bp = cp + bn = i + 1 - cp + } + } + + for (i = 1; i <= bn; i++) + subseq[i] = ary[bp + i - 1] + subseq["sum"] = b + return bn +} diff --git a/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-2.awk b/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-2.awk new file mode 100644 index 0000000000..d2a233d9f4 --- /dev/null +++ b/Task/Greatest-subsequential-sum/AWK/greatest-subsequential-sum-2.awk @@ -0,0 +1,26 @@ +# Joins the elements ary[1] to ary[len] in a string. +function join(ary, len, i, s) { + s = "[" + for (i = 1; i <= len; i++) { + s = s ary[i] + if (i < len) + s = s ", " + } + s = s "]" + return s +} + +# Demonstrates maxsubseq(). +function try(str, ary, len, max, maxlen) { + len = split(str, ary) + print "Array: " join(ary, len) + maxlen = maxsubseq(max, ary, len) + print " Maximal subsequence: " \ + join(max, maxlen) ", sum " max["sum"] +} + +BEGIN { + try("-1 -2 -3 -4 -5") + try("0 1 2 -3 3 -1 0 -4 0 -1 -4 2") + try("-1 -2 3 5 6 -2 -1 4 -4 2 -1") +} diff --git a/Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.ada b/Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.ada new file mode 100644 index 0000000000..dbeeb90b2f --- /dev/null +++ b/Task/Greatest-subsequential-sum/Ada/greatest-subsequential-sum.ada @@ -0,0 +1,38 @@ +with Ada.Text_Io; use Ada.Text_Io; + +procedure Max_Subarray is + type Int_Array is array (Positive range <>) of Integer; + Empty_Error : Exception; + function Max(Item : Int_Array) return Int_Array is + Start : Positive; + Finis : Positive; + Max_Sum : Integer := Integer'First; + Sum : Integer; + begin + if Item'Length = 0 then + raise Empty_Error; + end if; + + for I in Item'range loop + Sum := 0; + for J in I..Item'Last loop + Sum := Sum + Item(J); + if Sum > Max_Sum then + Max_Sum := Sum; + Start := I; + Finis := J; + end if; + end loop; + end loop; + return Item(Start..Finis); + end Max; + A : Int_Array := (-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1); + B : Int_Array := Max(A); +begin + for I in B'range loop + Put_Line(Integer'Image(B(I))); + end loop; +exception + when Empty_Error => + Put_Line("Array being analyzed has no elements."); +end Max_Subarray; diff --git a/Task/Greatest-subsequential-sum/AutoHotkey/greatest-subsequential-sum.ahk b/Task/Greatest-subsequential-sum/AutoHotkey/greatest-subsequential-sum.ahk new file mode 100644 index 0000000000..a1043f1162 --- /dev/null +++ b/Task/Greatest-subsequential-sum/AutoHotkey/greatest-subsequential-sum.ahk @@ -0,0 +1,11 @@ +seq = -1,-2,3,5,6,-2,-1,4,-4,2,-1 +max := sum := start := 0 +Loop Parse, seq, `, + If (max < sum+=A_LoopField) + max := sum, a := start, b := A_Index + Else If sum <= 0 + sum := 0, start := A_Index +; read out the best subsequence +Loop Parse, seq, `, + s .= A_Index > a && A_Index <= b ? A_LoopField "," : "" +MsgBox % "Max = " max "`n[" SubStr(s,1,-1) "]" diff --git a/Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.autoit b/Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.autoit new file mode 100644 index 0000000000..88f11ce2ce --- /dev/null +++ b/Task/Greatest-subsequential-sum/AutoIt/greatest-subsequential-sum.autoit @@ -0,0 +1,36 @@ +Local $iArray[11] = [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1] +GREAT_SUB($iArray) +Local $iArray[5] = [-1, -2, -3, -4, -5] +GREAT_SUB($iArray) +Local $iArray[15] = [7, -6, -8, 5, -2, -6, 7, 4, 8, -9, -3, 2, 6, -4, -6] +GREAT_SUB($iArray) + +Func GREAT_SUB($iArray) + Local $iSUM = 0, $iBEGIN_MAX = 0, $iEND_MAX = -1, $iMAX_SUM = 0 + For $i = 0 To UBound($iArray) - 1 + $iSUM = 0 + For $k = $i To UBound($iArray) - 1 + $iSUM += $iArray[$k] + If $iSUM > $iMAX_SUM Then + $iMAX_SUM = $iSUM + $iEND_MAX = $k + $iBEGIN_MAX = $i + EndIf + Next + Next + ConsoleWrite("> Array: [") + For $i = 0 To UBound($iArray) - 1 + If $iArray[$i] > 0 Then ConsoleWrite("+") + ConsoleWrite($iArray[$i]) + If $i <> UBound($iArray) - 1 Then ConsoleWrite(",") + Next + ConsoleWrite("]" & @CRLF & "+>Maximal subsequence: [") + $iSUM = 0 + For $i = $iBEGIN_MAX To $iEND_MAX + $iSUM += $iArray[$i] + If $iArray[$i] > 0 Then ConsoleWrite("+") + ConsoleWrite($iArray[$i]) + If $i <> $iEND_MAX Then ConsoleWrite(",") + Next + ConsoleWrite("]" & @CRLF & "!>SUM of subsequence: " & $iSUM & @CRLF) +EndFunc ;==>GREAT_SUB diff --git a/Task/Greatest-subsequential-sum/BBC-BASIC/greatest-subsequential-sum.bbc b/Task/Greatest-subsequential-sum/BBC-BASIC/greatest-subsequential-sum.bbc new file mode 100644 index 0000000000..255de0908d --- /dev/null +++ b/Task/Greatest-subsequential-sum/BBC-BASIC/greatest-subsequential-sum.bbc @@ -0,0 +1,36 @@ + DIM A%(11) : A%() = 0, 1, 2, -3, 3, -1, 0, -4, 0, -1, -4, 2 + PRINT FNshowarray(A%()) " -> " FNmaxsubsequence(A%()) + DIM B%(10) : B%() = -1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1 + PRINT FNshowarray(B%()) " -> " FNmaxsubsequence(B%()) + DIM C%(4) : C%() = -1, -2, -3, -4, -5 + PRINT FNshowarray(C%()) " -> " FNmaxsubsequence(C%()) + END + + DEF FNmaxsubsequence(a%()) + LOCAL a%, b%, i%, j%, m%, s%, a$ + a% = 1 + FOR i% = 0 TO DIM(a%(),1) + s% = 0 + FOR j% = i% TO DIM(a%(),1) + s% += a%(j%) + IF s% > m% THEN + m% = s% + a% = i% + b% = j% + ENDIF + NEXT + NEXT i% + IF a% > b% THEN = "[]" + a$ = "[" + FOR i% = a% TO b% + a$ += STR$(a%(i%)) + ", " + NEXT + = LEFT$(LEFT$(a$)) + "]" + + DEF FNshowarray(a%()) + LOCAL i%, a$ + a$ = "[" + FOR i% = 0 TO DIM(a%(),1) + a$ += STR$(a%(i%)) + ", " + NEXT + = LEFT$(LEFT$(a$)) + "]" diff --git a/Task/Greatest-subsequential-sum/Bracmat/greatest-subsequential-sum.bracmat b/Task/Greatest-subsequential-sum/Bracmat/greatest-subsequential-sum.bracmat new file mode 100644 index 0000000000..aea39e46f6 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Bracmat/greatest-subsequential-sum.bracmat @@ -0,0 +1,22 @@ +( 0:?max + & :?seq + & -1 -2 3 5 6 -2 -1 4 -4 2 -1 + : ? + [%( ( + = s sum + . ( sum + = A + . !arg:%?A ?arg&!A+sum$!arg + | 0 + ) + & ( sum$!sjt:>!max:?max + & !sjt:?seq + | + ) + ) + $ + & ~ + ) + ? +| !seq +) diff --git a/Task/Greatest-subsequential-sum/C++/greatest-subsequential-sum.cpp b/Task/Greatest-subsequential-sum/C++/greatest-subsequential-sum.cpp new file mode 100644 index 0000000000..dab2b64859 --- /dev/null +++ b/Task/Greatest-subsequential-sum/C++/greatest-subsequential-sum.cpp @@ -0,0 +1,89 @@ +#include // for std::pair +#include // for std::iterator_traits +#include // for std::cout +#include // for output operator and std::endl +#include // for std::copy +#include // for std::output_iterator + +// Function template max_subseq +// +// Given a sequence of integers, find a subsequence which maximizes +// the sum of its elements, that is, the elements of no other single +// subsequence add up to a value larger than this one. +// +// Requirements: +// * ForwardIterator is a forward iterator +// * ForwardIterator's value_type is less-than comparable and addable +// * default-construction of value_type gives the neutral element +// (zero) +// * operator+ and operator< are compatible (i.e. if a>zero and +// b>zero, then a+b>zero, and if a + std::pair + max_subseq(ForwardIterator begin, ForwardIterator end) +{ + typedef typename std::iterator_traits::value_type + value_type; + + ForwardIterator seq_begin = begin, seq_end = seq_begin; + value_type seq_sum = value_type(); + ForwardIterator current_begin = begin; + value_type current_sum = value_type(); + + value_type zero = value_type(); + + for (ForwardIterator iter = begin; iter != end; ++iter) + { + value_type value = *iter; + if (zero < value) + { + if (current_sum < zero) + { + current_sum = zero; + current_begin = iter; + } + } + else + { + if (seq_sum < current_sum) + { + seq_begin = current_begin; + seq_end = iter; + seq_sum = current_sum; + } + } + current_sum += value; + } + + if (seq_sum < current_sum) + { + seq_begin = current_begin; + seq_end = end; + seq_sum = current_sum; + } + + return std::make_pair(seq_begin, seq_end); +} + +// the test array +int array[] = { -1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1 }; + +// function template to find the one-past-end pointer to the array +template int* end(T (&arr)[N]) { return arr+N; } + +int main() +{ + // find the subsequence + std::pair seq = max_subseq(array, end(array)); + + // output it + std::copy(seq.first, seq.second, std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + + return 0; +} diff --git a/Task/Greatest-subsequential-sum/C/greatest-subsequential-sum.c b/Task/Greatest-subsequential-sum/C/greatest-subsequential-sum.c new file mode 100644 index 0000000000..33d2fce0fc --- /dev/null +++ b/Task/Greatest-subsequential-sum/C/greatest-subsequential-sum.c @@ -0,0 +1,48 @@ +#include "stdio.h" + +typedef struct Range { + int start, end, sum; +} Range; + +Range maxSubseq(const int sequence[], const int len) { + int maxSum = 0, thisSum = 0, i = 0; + int start = 0, end = -1, j; + + for (j = 0; j < len; j++) { + thisSum += sequence[j]; + if (thisSum < 0) { + i = j + 1; + thisSum = 0; + } else if (thisSum > maxSum) { + maxSum = thisSum; + start = i; + end = j; + } + } + + Range r; + if (start <= end && start >= 0 && end >= 0) { + r.start = start; + r.end = end + 1; + r.sum = maxSum; + } else { + r.start = 0; + r.end = 0; + r.sum = 0; + } + return r; +} + +int main(int argc, char **argv) { + int a[] = {-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1}; + int alength = sizeof(a)/sizeof(a[0]); + + Range r = maxSubseq(a, alength); + printf("Max sum = %d\n", r.sum); + int i; + for (i = r.start; i < r.end; i++) + printf("%d ", a[i]); + printf("\n"); + + return 0; +} diff --git a/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-1.clj b/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-1.clj new file mode 100644 index 0000000000..9c6aa6aeaf --- /dev/null +++ b/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-1.clj @@ -0,0 +1,4 @@ +(defn max-subseq-sum [coll] + (->> (take-while seq (iterate rest coll)) ; tails + (mapcat #(reductions conj [] %)) ; inits + (apply max-key #(reduce + %)))) ; max sum diff --git a/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-2.clj b/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-2.clj new file mode 100644 index 0000000000..aecdcae2b9 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Clojure/greatest-subsequential-sum-2.clj @@ -0,0 +1,2 @@ +user> (max-subseq-sum [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]) +[3 5 6 -2 -1 4] diff --git a/Task/Greatest-subsequential-sum/CoffeeScript/greatest-subsequential-sum.coffee b/Task/Greatest-subsequential-sum/CoffeeScript/greatest-subsequential-sum.coffee new file mode 100644 index 0000000000..9f6981d752 --- /dev/null +++ b/Task/Greatest-subsequential-sum/CoffeeScript/greatest-subsequential-sum.coffee @@ -0,0 +1,18 @@ +max_sum_seq = (sequence) -> + # This runs in linear time. + [sum_start, sum, max_sum, max_start, max_end] = [0, 0, 0, 0, 0] + for n, i in sequence + sum += n + if sum > max_sum + max_sum = sum + max_start = sum_start + max_end = i + 1 + if sum < 0 # start new sequence + sum = 0 + sum_start = i + 1 + sequence[max_start...max_end] + +# tests +console.log max_sum_seq [-1, 0, 15, 3, -9, 12, -4] +console.log max_sum_seq [-1] +console.log max_sum_seq [4, -10, 3] diff --git a/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-1.lisp b/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-1.lisp new file mode 100644 index 0000000000..8939ac5abe --- /dev/null +++ b/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-1.lisp @@ -0,0 +1,19 @@ +(defun max-subseq (list) + (let ((best-sum 0) (current-sum 0) (end 0)) + ;; determine the best sum, and the end of the max subsequence + (do ((list list (rest list)) + (i 0 (1+ i))) + ((endp list)) + (setf current-sum (max 0 (+ current-sum (first list)))) + (when (> current-sum best-sum) + (setf end i + best-sum current-sum))) + ;; take the subsequence of list ending at end, and remove elements + ;; from the beginning until the subsequence sums to best-sum. + (let* ((sublist (subseq list 0 (1+ end))) + (sum (reduce #'+ sublist))) + (do ((start 0 (1+ start)) + (sublist sublist (rest sublist)) + (sum sum (- sum (first sublist)))) + ((or (endp sublist) (eql sum best-sum)) + (values best-sum sublist start (1+ end))))))) diff --git a/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-2.lisp b/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-2.lisp new file mode 100644 index 0000000000..17d3f83482 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Common-Lisp/greatest-subsequential-sum-2.lisp @@ -0,0 +1,7 @@ +(defun max-subseq (seq) + (loop for subsequence in (mapcon (lambda (x) (maplist #'reverse (reverse x))) seq) + for sum = (reduce #'+ subsequence :initial-value 0) + with max-subsequence + maximizing sum into max + if (= sum max) do (setf max-subsequence subsequence) + finally (return max-subsequence)))) diff --git a/Task/Greatest-subsequential-sum/D/greatest-subsequential-sum.d b/Task/Greatest-subsequential-sum/D/greatest-subsequential-sum.d new file mode 100644 index 0000000000..898ef780ef --- /dev/null +++ b/Task/Greatest-subsequential-sum/D/greatest-subsequential-sum.d @@ -0,0 +1,30 @@ +import std.stdio; + +inout(T[]) maxSubseq(T)(inout T[] sequence) pure nothrow { + int maxSum, thisSum, i, start, end = -1; + + foreach (j, x; sequence) { + thisSum += x; + if (thisSum < 0) { + i = j + 1; + thisSum = 0; + } else if (thisSum > maxSum) { + maxSum = thisSum; + start = i; + end = j; + } + } + + if (start <= end && start >= 0 && end >= 0) + return sequence[start .. end + 1]; + else + return []; +} + +void main() { + const a1 = [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]; + writeln("Maximal subsequence: ", maxSubseq(a1)); + + const a2 = [-1, -2, -3, -5, -6, -2, -1, -4, -4, -2, -1]; + writeln("Maximal subsequence: ", maxSubseq(a2)); +} diff --git a/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-1.e b/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-1.e new file mode 100644 index 0000000000..232d658b0a --- /dev/null +++ b/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-1.e @@ -0,0 +1,44 @@ +pragma.enable("accumulator") + +def maxSubseq(seq) { + def size := seq.size() + + # Collect all intervals of indexes whose values are positive + def intervals := { + var intervals := [] + var first := 0 + while (first < size) { + var next := first + def seeing := seq[first] > 0 + while (next < size && (seq[next] > 0) == seeing) { + next += 1 + } + if (seeing) { # record every positive interval + intervals with= first..!next + } + first := next + } + intervals + } + + # For recording the best result found + var maxValue := 0 + var maxInterval := 0..!0 + + # Try all subsequences beginning and ending with such intervals. + for firstIntervalIx => firstInterval in intervals { + for lastInterval in intervals(firstIntervalIx) { + def interval := + (firstInterval.getOptStart())..!(lastInterval.getOptBound()) + def value := + accum 0 for i in interval { _ + seq[i] } + if (value > maxValue) { + maxValue := value + maxInterval := interval + } + } + } + + return ["value" => maxValue, + "indexes" => maxInterval] +} diff --git a/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-2.e b/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-2.e new file mode 100644 index 0000000000..ed0257c299 --- /dev/null +++ b/Task/Greatest-subsequential-sum/E/greatest-subsequential-sum-2.e @@ -0,0 +1,8 @@ +def seq := [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1] +def [=> value, => indexes] := maxSubseq(seq) +println(`$\ +Sequence: $seq +Maximum subsequence sum: $value +Indexes: ${indexes.getOptStart()}..${indexes.getOptBound().previous()} +Subsequence: ${seq(indexes.getOptStart(), indexes.getOptBound())} +`) diff --git a/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-1.euler b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-1.euler new file mode 100644 index 0000000000..7e9f4c6672 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-1.euler @@ -0,0 +1,23 @@ +>function %maxsubs (v,n) ... +$if n==1 then +$ if (v[1]<0) then return {zeros(1,0),zeros(1,0)} +$ else return {v,v}; +$ endif; +$endif; +${v1,v2}=%maxsubs(v[1:n-1],n-1); +$m1=sum(v1); m2=sum(v2); m3=m2+v[n]; +$if m3>0 then v3=v2|v[n]; else v3=zeros(1,0); endif; +$if m3>m1 then return {v2|v[n],v3}; +$else return {v1,v3}; +$endif; +$endfunction +>function maxsubs (v) ... +${v1,v2}=%maxsubs(v,cols(v)); +$return v1 +$endfunction +>maxsubs([0, 1, 2, -3, 3, -1, 0, -4, 0, -1, -4]) + [ 0 1 2 ] +>maxsubs([-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]) + [ 3 5 6 -2 -1 4 ] +>maxsubs([-1, -2, -3, -4, -5]) + Empty matrix of size 1x0 diff --git a/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-2.euler b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-2.euler new file mode 100644 index 0000000000..e036fcf63b --- /dev/null +++ b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-2.euler @@ -0,0 +1,19 @@ +>function maxsubsbrute (v) ... +$ n=cols(v); +$ A=zeros(n*(n-1),n); +$ k=1; +$ for i=1 to n-1; +$ for j=i to n; +$ A[k,i:j]=1; +$ k=k+1; +$ end; +$ end; +$ k1=extrema((A.v')')[4]; +$ return v[nonzeros(A[k1])]; +$ endfunction +>maxsubsbrute([0, 1, 2, -3, 3, -1, 0, -4, 0, -1, -4]) + [ 0 1 2 ] +>maxsubsbrute([-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]) + [ 3 5 6 -2 -1 4 ] +>maxsubsbrute([-1, -2, -3, -4, -5]) + Empty matrix of size 1x0 diff --git a/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-3.euler b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-3.euler new file mode 100644 index 0000000000..49cae70975 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Euler-Math-Toolbox/greatest-subsequential-sum-3.euler @@ -0,0 +1,8 @@ +>function test ... +$ loop 1 to 10000000 +$ v=intrandom(1,intrandom(6)+6,20)-10; +$ if sum(maxsubs(v))!=sum(maxsubsbrute(v)) then +$ v, error("Found a wrong test example"); +$ endif; +$ endfunction +>test diff --git a/Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.euphoria b/Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.euphoria new file mode 100644 index 0000000000..633d69cf06 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Euphoria/greatest-subsequential-sum.euphoria @@ -0,0 +1,22 @@ +function maxSubseq(sequence s) + integer sum, maxsum, first, last + maxsum = 0 + first = 1 + last = 0 + for i = 1 to length(s) do + sum = 0 + for j = i to length(s) do + sum += s[j] + if sum > maxsum then + maxsum = sum + first = i + last = j + end if + end for + end for + return s[first..last] +end function + +? maxSubseq({-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1}) +? maxSubseq({}) +? maxSubseq({-1, -5, -3}) diff --git a/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-1.factor b/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-1.factor new file mode 100644 index 0000000000..f69f33b0d3 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-1.factor @@ -0,0 +1,9 @@ +USING: kernel locals math math.order sequences ; + +:: max-with-index ( elt0 ind0 elt1 ind1 -- elt ind ) +elt0 elt1 < [ elt1 ind1 ] [ elt0 ind0 ] if ; +: last-of-max ( accseq -- ind ) -1 swap -1 [ max-with-index ] reduce-index nip ; + +: max-subseq ( seq -- subseq ) +dup 0 [ + 0 max ] accumulate swap suffix last-of-max head +dup 0 [ + ] accumulate swap suffix [ neg ] map last-of-max tail ; diff --git a/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-2.factor b/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-2.factor new file mode 100644 index 0000000000..cec468a5cd --- /dev/null +++ b/Task/Greatest-subsequential-sum/Factor/greatest-subsequential-sum-2.factor @@ -0,0 +1,3 @@ +( scratchpad ) { -1 -2 3 5 6 -2 -1 4 -4 2 -1 } max-subseq dup sum swap . . +{ 3 5 6 -2 -1 4 } +15 diff --git a/Task/Greatest-subsequential-sum/Forth/greatest-subsequential-sum.fth b/Task/Greatest-subsequential-sum/Forth/greatest-subsequential-sum.fth new file mode 100644 index 0000000000..378df2114a --- /dev/null +++ b/Task/Greatest-subsequential-sum/Forth/greatest-subsequential-sum.fth @@ -0,0 +1,24 @@ +2variable best +variable best-sum + +: sum ( array len -- sum ) + 0 -rot cells over + swap do i @ + cell +loop ; + +: max-sub ( array len -- sub len ) + over 0 best 2! 0 best-sum ! + dup 1 do \ foreach length + 2dup i - cells over + swap do \ foreach start + i j sum + dup best-sum @ > if + best-sum ! + i j best 2! + else drop then + cell +loop + loop + 2drop best 2@ ; + +: .array ." [" dup 0 ?do over i cells + @ . loop ." ] = " sum . ; + +create test -1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1 , + +test 11 max-sub .array \ [3 5 6 -2 -1 4 ] = 15 diff --git a/Task/Greatest-subsequential-sum/Fortran/greatest-subsequential-sum.f b/Task/Greatest-subsequential-sum/Fortran/greatest-subsequential-sum.f new file mode 100644 index 0000000000..bf37b7f4d3 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Fortran/greatest-subsequential-sum.f @@ -0,0 +1,16 @@ +program MaxSubSeq + implicit none + + integer, parameter :: an = 11 + integer, dimension(an) :: a = (/ -1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1 /) + + integer, dimension(an,an) :: mix + integer :: i, j + integer, dimension(2) :: m + + forall(i=1:an,j=1:an) mix(i,j) = sum(a(i:j)) + m = maxloc(mix) + ! a(m(1):m(2)) is the wanted subsequence + print *, a(m(1):m(2)) + +end program MaxSubSeq diff --git a/Task/Greatest-subsequential-sum/Go/greatest-subsequential-sum.go b/Task/Greatest-subsequential-sum/Go/greatest-subsequential-sum.go new file mode 100644 index 0000000000..40cbf45930 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Go/greatest-subsequential-sum.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +func gss(s []int) ([]int, int) { + var best, start, end, sum, sumStart int + for i, x := range s { + sum += x + switch { + case sum > best: + best = sum + start = sumStart + end = i + 1 + case sum < 0: + sum = 0 + sumStart = i + 1 + } + } + return s[start:end], best +} + +var testCases = [][]int{ + {-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1}, + {-1, 1, 2, -5, -6}, + {}, + {-1, -2, -1}, +} + +func main() { + for _, c := range testCases { + fmt.Println("Input: ", c) + subSeq, sum := gss(c) + fmt.Println("Sub seq:", subSeq) + fmt.Println("Sum: ", sum, "\n") + } +} diff --git a/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-1.hs b/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-1.hs new file mode 100644 index 0000000000..64765f0cfe --- /dev/null +++ b/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-1.hs @@ -0,0 +1,10 @@ +import Data.List (inits, tails, maximumBy) +import Data.Ord (comparing) + +subseqs :: [a] -> [[a]] +subseqs = concatMap inits . tails + +maxsubseq :: (Ord a, Num a) => [a] -> [a] +maxsubseq = maximumBy (comparing sum) . subseqs + +main = print $ maxsubseq [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1] diff --git a/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-2.hs b/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-2.hs new file mode 100644 index 0000000000..c6f37c67bb --- /dev/null +++ b/Task/Greatest-subsequential-sum/Haskell/greatest-subsequential-sum-2.hs @@ -0,0 +1,7 @@ +maxsubseq = mss_ (0,[]) (0,[]) where + mss_ _ x [] = x + mss_ here sofar (x:xs) = mss a b xs where + a = max (0,[]) (fst here + x, snd here ++ [x]) + b = max sofar a + +main = print $ maxsubseq [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1] diff --git a/Task/Greatest-subsequential-sum/Icon/greatest-subsequential-sum.icon b/Task/Greatest-subsequential-sum/Icon/greatest-subsequential-sum.icon new file mode 100644 index 0000000000..38cf6b2edd --- /dev/null +++ b/Task/Greatest-subsequential-sum/Icon/greatest-subsequential-sum.icon @@ -0,0 +1,22 @@ +procedure main() +L1 := [-1,-2,3,5,6,-2,-1,4,-4,2,-1] # sample list +L := [-1,1,2,3,4,-11]|||L1 # prepend a local maximum into the mix +write(ximage(maxsubseq(L))) +end + +link ximage # to show lists + +procedure maxsubseq(L) #: return the subsequence of L with maximum positive sum +local i,maxglobal,maxglobalI,maxlocal,maxlocalI + +maxglobal := maxlocal := 0 # global and local maxima + +every i := 1 to *L do { + if (maxlocal := max(maxlocal +L[i],0)) > 0 then + if /maxlocalI then maxlocalI := [i,i] else maxlocalI[2] := i # local maxima subscripts + else maxlocalI := &null # reset subsequence + if maxglobal <:= maxlocal then # global maxima + maxglobalI := copy(maxlocalI) + } +return L[(\maxglobalI)[1]:maxglobalI[2]] | [] # return sub-sequence or empty list +end diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-1.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-1.j new file mode 100644 index 0000000000..b698033cb5 --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-1.j @@ -0,0 +1,5 @@ +maxss=: monad define + AS =. 0,; <:/~@i.&.> #\y + MX =. (= >./) AS +/ . * y + y #~ {. MX#AS +) diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-2.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-2.j new file mode 100644 index 0000000000..2d47c1bcd6 --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-2.j @@ -0,0 +1,2 @@ + maxss _1 _2 3 5 6 _2 _1 4 _4 2 _1 +3 5 6 _2 _1 4 diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-3.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-3.j new file mode 100644 index 0000000000..4e382b8115 --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-3.j @@ -0,0 +1 @@ +maxs=: [:>./(0>.+)/\. diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-4.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-4.j new file mode 100644 index 0000000000..e1be51c9d5 --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-4.j @@ -0,0 +1,2 @@ + maxs _1 _2 3 5 6 _2 _1 4 _4 2 _1 +15 diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-5.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-5.j new file mode 100644 index 0000000000..0506eb2539 --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-5.j @@ -0,0 +1,5 @@ +maxSS=:monad define + sums=: (0>.+)/\. y + start=: sums i. max=: >./ sums + max (] {.~ #@] |&>: (= +/\) i. 1:) y}.~start +) diff --git a/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-6.j b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-6.j new file mode 100644 index 0000000000..7179329e7a --- /dev/null +++ b/Task/Greatest-subsequential-sum/J/greatest-subsequential-sum-6.j @@ -0,0 +1,4 @@ +maxSS2=:monad define + start=. (i. >./) (0>.+)/\. y + ({.~ # |&>: [: (i.>./@,&0) +/\) y}.~start +) diff --git a/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-1.java b/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-1.java new file mode 100644 index 0000000000..a1f0635c65 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-1.java @@ -0,0 +1,57 @@ +import java.util.Scanner; +import java.util.ArrayList; + +public class Sub{ + private static int[] indices; + + public static void main(String[] args){ + ArrayList array= new ArrayList(); //the main set + Scanner in = new Scanner(System.in); + while(in.hasNextLong()) array.add(in.nextLong()); + long highSum= Long.MIN_VALUE;//start the sum at the lowest possible value + ArrayList highSet= new ArrayList(); + //loop through all possible subarray sizes including 0 + for(int subSize= 0;subSize<= array.size();subSize++){ + indices= new int[subSize]; + for(int i= 0;i< subSize;i++) indices[i]= i; + do{ + long sum= 0;//this subarray sum variable + ArrayList temp= new ArrayList();//this subarray + //sum it and save it + for(long index:indices) {sum+= array.get(index); temp.add(array.get(index));} + if(sum > highSum){//if we found a higher sum + highSet= temp; //keep track of it + highSum= sum; + } + }while(nextIndices(array));//while we haven't tested all subarrays + } + System.out.println("Sum: " + highSum + "\nSet: " + + highSet); + } + /** + * Computes the next set of choices from the previous. The + * algorithm tries to increment the index of the final choice + * first. Should that fail (index goes out of bounds), it + * tries to increment the next-to-the-last index, and resets + * the last index to one more than the next-to-the-last. + * Should this fail the algorithm keeps starting at an earlier + * choice until it runs off the start of the choice list without + * Finding a legal set of indices for all the choices. + * + * @return true unless all choice sets have been exhausted. + * @author James Heliotis + */ + + private static boolean nextIndices(ArrayList a) { + for(int i= indices.length-1;i >= 0;--i){ + indices[i]++; + for(int j=i+1;j < indices.length;++j){ + indices[j]= indices[j - 1] + 1;//reset the last failed try + } + if(indices[indices.length - 1] < a.size()){//if this try went out of bounds + return true; + } + } + return false; + } +} diff --git a/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-2.java b/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-2.java new file mode 100644 index 0000000000..f0ba5f447b --- /dev/null +++ b/Task/Greatest-subsequential-sum/Java/greatest-subsequential-sum-2.java @@ -0,0 +1,12 @@ +private static int BiggestSubsum(int[] t) { + int sum = 0; + int maxsum = 0; + + for (int i : t) { + sum += i; + if (sum < 0) + sum = 0; + maxsum = sum > maxsum ? sum : maxsum; + } + return maxsum; +} diff --git a/Task/Greatest-subsequential-sum/JavaScript/greatest-subsequential-sum.js b/Task/Greatest-subsequential-sum/JavaScript/greatest-subsequential-sum.js new file mode 100644 index 0000000000..2db3d8bbf5 --- /dev/null +++ b/Task/Greatest-subsequential-sum/JavaScript/greatest-subsequential-sum.js @@ -0,0 +1,25 @@ +function MaximumSubsequence( population ) { + var maxValue = 0; + var subsequence = []; + + for( var i=0, len=population.length; i < len; i++ ) { + for( var j=i; j <= len; j++ ) { + var subsequence = population.slice(i,j); + var value = sumValues(subsequence); + if( value > maxValue ) { + maxValue = value; + greatest = subsequence; + }; + } + } + + return greatest; +} + +function sumValues(arr) { + var result = 0; + for( var i=0, len=arr.length; i < len; i++) { + result += arr[i]; + } + return result; +} diff --git a/Task/Greatest-subsequential-sum/Liberty-BASIC/greatest-subsequential-sum.liberty b/Task/Greatest-subsequential-sum/Liberty-BASIC/greatest-subsequential-sum.liberty new file mode 100644 index 0000000000..ba134afebe --- /dev/null +++ b/Task/Greatest-subsequential-sum/Liberty-BASIC/greatest-subsequential-sum.liberty @@ -0,0 +1,52 @@ +'Greatest_subsequential_sum + +N= 20 'number of elements + +randomize 0.52 +for K = 1 to 5 + a$ = using("##",int(rnd(1)*12)-5) + for i=2 to N + a$ = a$ +","+using("##",int(rnd(1)*12)-5) + next + call maxsumseq a$ +next K + +sub maxsumseq a$ + sum=0 + maxsum=0 + sumStart=1 + end1 =0 + start1 =1 + + token$="*" + i=0 + while 1 + i=i+1 + token$=word$(a$, i, ",") + if token$ ="" then exit while 'end of stream + x=val(token$) + sum=sum+x + if maxsum0 then + print "Maximum sum subsequense: ";start1 ;" to "; end1 + else + print "Maximum sum subsequense: is empty" + end if + print "Maximum sum ";maxsum + print +end sub diff --git a/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua b/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua new file mode 100644 index 0000000000..23551e0e51 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Lua/greatest-subsequential-sum.lua @@ -0,0 +1,14 @@ +function sumt(t, start, last) return start <= last and t[start] + sumt(t, start+1, last) or 0 end +function maxsub(ary, idx) + local idx = idx or 1 + if not ary[idx] then return {} end + local maxsum, last = 0, idx + for i = idx, #ary do + if sumt(ary, idx, i) > maxsum then maxsum, last = sumt(ary, idx, i), i end + end + local v = maxsub(ary, idx + 1) + if maxsum < sumt(v, 1, #v) then return v end + local ret = {} + for i = idx, last do ret[#ret+1] = ary[i] end + return ret +end diff --git a/Task/Greatest-subsequential-sum/M4/greatest-subsequential-sum.m4 b/Task/Greatest-subsequential-sum/M4/greatest-subsequential-sum.m4 new file mode 100644 index 0000000000..09060c659f --- /dev/null +++ b/Task/Greatest-subsequential-sum/M4/greatest-subsequential-sum.m4 @@ -0,0 +1,16 @@ +divert(-1) +define(`setrange',`ifelse(`$3',`',$2,`define($1[$2],$3)`'setrange($1, + incr($2),shift(shift(shift($@))))')') +define(`asize',decr(setrange(`a',1,-1,-2,3,5,6,-2,-1,4,-4,2,-1))) +define(`get',`defn(`$1[$2]')') +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')') +define(`maxsum',0) +for(`x',1,asize, + `define(`sum',0)`'for(`y',x,asize, + `define(`sum',eval(sum+get(`a',y)))`'ifelse(eval(sum>maxsum),1, + `define(`maxsum',sum)`'define(`xmax',x)`'define(`ymax',y)')')') +divert +for(`x',xmax,ymax,`get(`a',x) ') diff --git a/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-1.mathematica b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-1.mathematica new file mode 100644 index 0000000000..415523b9a3 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-1.mathematica @@ -0,0 +1,5 @@ +Sequences[m_]:=Prepend[Flatten[Table[Partition[Range[m],n,1],{n,m}],1],{}] +MaximumSubsequence[x_List]:=Module[{sums}, + sums={x[[#]],Total[x[[#]]]}&/@Sequences[Length[x]]; + First[First[sums[[Ordering[sums,-1,#1[[2]]<#2[[2]]&]]]]] +] diff --git a/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-2.mathematica b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-2.mathematica new file mode 100644 index 0000000000..99ce8f8283 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-2.mathematica @@ -0,0 +1 @@ +MaximumSubsequence[x_List]:=Last@SortBy[Flatten[Table[x[[a;;b]], {b,Length[x]}, {a,b}],1],Total] diff --git a/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-3.mathematica b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-3.mathematica new file mode 100644 index 0000000000..baf6f87397 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Mathematica/greatest-subsequential-sum-3.mathematica @@ -0,0 +1,5 @@ +MaximumSubsequence[{-1,-2,3,5,6,-2,-1,4,-4,2,-1}] +MaximumSubsequence[{2,4,5}] +MaximumSubsequence[{2,-4,3}] +MaximumSubsequence[{4}] +MaximumSubsequence[{}] diff --git a/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-1.mathprog b/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-1.mathprog new file mode 100644 index 0000000000..90e87bb019 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-1.mathprog @@ -0,0 +1,36 @@ +/*Special ordered set of type N + + Nigel_Galloway + January 26th, 2012 +*/ + +param Lmax; +param Lmin; +set SOS; +param Sx{SOS}; +var db{Lmin..Lmax,SOS}, binary; + +maximize s : sum{q in (Lmin..Lmax),t in (0..q-1), z in SOS: z > (q-1)} Sx[z-t]*db[q,z]; +sos1 : sum{t in (Lmin..Lmax),z in SOS: z > (t-1)} db[t,z] = 1; +solve; + +for{t in (Lmin..Lmax),z in SOS: db[t,z] == 1} { + printf "\nA sub-sequence of length %d sums to %f:\n", t,s; + printf{q in (z-t+1)..z} " %f", Sx[q]; +} +printf "\n\n"; + +data; +param Lmin := 1; +param Lmax := 6; +param: +SOS: Sx := + 1 7 + 2 4 + 3 -11 + 4 6 + 5 3 + 6 1 +; + +end; diff --git a/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-2.mathprog b/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-2.mathprog new file mode 100644 index 0000000000..3958b83a49 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Mathprog/greatest-subsequential-sum-2.mathprog @@ -0,0 +1,38 @@ +GLPSOL: GLPK LP/MIP Solver, v4.47 +Parameter(s) specified in the command line: + --math GSS.mod +Reading model section from GSS.mod... +Reading data section from GSS.mod... +38 lines were read +Generating s... +Generating sos1... +Model has been successfully generated +GLPK Integer Optimizer, v4.47 +2 rows, 21 columns, 41 non-zeros +21 integer variables, all of which are binary +Preprocessing... +1 row, 21 columns, 21 non-zeros +21 integer variables, all of which are binary +Scaling... + A: min|aij| = 1.000e+000 max|aij| = 1.000e+000 ratio = 1.000e+000 +Problem data seem to be well scaled +Constructing initial basis... +Size of triangular part = 1 +Solving LP relaxation... +GLPK Simplex Optimizer, v4.47 +1 row, 21 columns, 21 non-zeros +* 0: obj = 1.000000000e+001 infeas = 0.000e+000 (0) +* 1: obj = 1.100000000e+001 infeas = 0.000e+000 (0) +OPTIMAL SOLUTION FOUND +Integer optimization begins... ++ 1: mip = not found yet <= +inf (1; 0) ++ 1: >>>>> 1.100000000e+001 <= 1.100000000e+001 0.0% (1; 0) ++ 1: mip = 1.100000000e+001 <= tree is empty 0.0% (0; 1) +INTEGER OPTIMAL SOLUTION FOUND +Time used: 0.0 secs +Memory used: 0.1 Mb (135491 bytes) + +A sub-sequence of length 2 sums to 11.000000: + 7.000000 4.000000 + +Model has been successfully processed diff --git a/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-1.php b/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-1.php new file mode 100644 index 0000000000..ea14960035 --- /dev/null +++ b/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-1.php @@ -0,0 +1,38 @@ + $max_sum) { + $max_sum = $sum; + $max_start = $sum_start; + $max_len = $i + 1 - $max_start; + } + if ($sum < 0) { # start new sequence + $sum = 0; + $sum_start = $i + 1; + } + } + return array_slice($sequence, $max_start, $max_len); +} + +function print_array($arr) { + if (count($arr) > 0) { + echo join(" ", $arr); + } else { + echo "(empty)"; + } + echo '
'; +} +// tests +print_array(max_sum_seq(array(-1, 0, 15, 3, -9, 12, -4))); +print_array(max_sum_seq(array(-1))); +print_array(max_sum_seq(array(4, -10, 3))); +?> diff --git a/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-2.php b/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-2.php new file mode 100644 index 0000000000..7c6a2e5f27 --- /dev/null +++ b/Task/Greatest-subsequential-sum/PHP/greatest-subsequential-sum-2.php @@ -0,0 +1,3 @@ +0 15 3 -9 12 +(empty) +4 diff --git a/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-1.pl b/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-1.pl new file mode 100644 index 0000000000..b4423a3da1 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-1.pl @@ -0,0 +1,21 @@ +use strict; + +sub max_sub(\@) { + my ($a, $maxs, $maxe, $s, $sum, $maxsum) = shift; + foreach (0 .. $#$a) { + my $t = $sum + $a->[$_]; + ($s, $sum) = $t > 0 ? ($s, $t) : ($_ + 1, 0); + + if ($maxsum < $sum) { + $maxsum = $sum; + ($maxs, $maxe) = ($s, $_ + 1) + } + } + @$a[$maxs .. $maxe - 1] +} + +my @a = map { int(rand(20) - 10) } 1 .. 10; +my @b = (-1) x 10; + +print "seq: @a\nmax: [ @{[max_sub @a]} ]\n"; +print "seq: @b\nmax: [ @{[max_sub @b]} ]\n"; diff --git a/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-2.pl b/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-2.pl new file mode 100644 index 0000000000..05f1858aa8 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Perl/greatest-subsequential-sum-2.pl @@ -0,0 +1,19 @@ +use strict; + +my @a = (-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1); + +my @maxsubarray; +my $maxsum = 0; + +foreach my $begin (0..$#a) { + foreach my $end ($begin..$#a) { + my $sum = 0; + $sum += $_ foreach @a[$begin..$end]; + if($sum > $maxsum) { + $maxsum = $sum; + @maxsubarray = @a[$begin..$end]; + } + } +} + +print "@maxsubarray\n"; diff --git a/Task/Greatest-subsequential-sum/PicoLisp/greatest-subsequential-sum.l b/Task/Greatest-subsequential-sum/PicoLisp/greatest-subsequential-sum.l new file mode 100644 index 0000000000..e253afacbd --- /dev/null +++ b/Task/Greatest-subsequential-sum/PicoLisp/greatest-subsequential-sum.l @@ -0,0 +1,3 @@ +(maxi '((L) (apply + L)) + (mapcon '((L) (maplist reverse (reverse L))) + (-1 -2 3 5 6 -2 -1 4 -4 2 -1) ) ) diff --git a/Task/Greatest-subsequential-sum/Prolog/greatest-subsequential-sum.pro b/Task/Greatest-subsequential-sum/Prolog/greatest-subsequential-sum.pro new file mode 100644 index 0000000000..b33126f359 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Prolog/greatest-subsequential-sum.pro @@ -0,0 +1,55 @@ +:- use_module(library(chr)). + +:- chr_constraint + init_chr/2, + seq/2, + % gss(Deb, Len, TT) + gss/3, + % gsscur(Deb, Len, TT, IdCur) + gsscur/4, + memoseq/3, + clean/0, + greatest_subsequence/0. + + +greatest_subsequence <=> + L = [-1 , -2 , 3 , 5 , 6 , -2 , -1 , 4 , -4 , 2 , -1], + init_chr(1, L), + find_chr_constraint(gss(Deb, Len, V)), + clean, + writeln(L), + forall(between(1, Len, I), + ( J is I+Deb-1, nth1(J, L, N), format('~w ', [N]))), + format('==> ~w ~n', [V]). + +% destroy last constraint gss +clean \ gss(_,_,_) <=> true. +clean <=> true. + +init_chr_end @ init_chr(_, []) <=> gss(0, 0, 0), gsscur(1,0,0,1). + +init_chr_loop @ init_chr(N, [H|T]) <=> seq(N, H), N1 is N+1, init_chr(N1, T). + +% here, we memorize the list +gsscur_with_negative @ gsscur(Deb, Len, TT, N), seq(N, V) <=> V =< 0 | + memoseq(Deb, Len, TT), + TT1 is TT + V, + N1 is N+1, + % if TT1 becomes negative, + % we begin a new subsequence + ( TT1 < 0 -> gsscur(N1,0,0,N1) + ; Len1 is Len + 1, gsscur(Deb, Len1, TT1, N1)). + +gsscur_with_positive @ gsscur(Deb, Len, TT, N), seq(N, V) <=> V > 0 | + TT1 is TT + V, + N1 is N+1, + Len1 is Len + 1, + gsscur(Deb, Len1, TT1, N1). + +gsscur_end @ gsscur(Deb, Len, TT, _N) <=> memoseq(Deb, Len, TT). + +memoseq(_DC, _LC, TTC), gss(D, L, TT) <=> TTC =< TT | + gss(D, L, TT). + +memoseq(DC, LC, TTC), gss(_D, _L, TT) <=> TTC > TT | + gss(DC, LC, TTC). diff --git a/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-1.py b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-1.py new file mode 100644 index 0000000000..2323317c97 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-1.py @@ -0,0 +1,4 @@ +def maxsubseq(seq): + return max((seq[begin:end] for begin in xrange(len(seq)+1) + for end in xrange(begin, len(seq)+1)), + key=sum) diff --git a/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-2.py b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-2.py new file mode 100644 index 0000000000..8e18e2e896 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-2.py @@ -0,0 +1,8 @@ +def maxsum(sequence): + """Return maximum sum.""" + maxsofar, maxendinghere = 0, 0 + for x in sequence: + # invariant: ``maxendinghere`` and ``maxsofar`` are accurate for ``x[0..i-1]`` + maxendinghere = max(maxendinghere + x, 0) + maxsofar = max(maxsofar, maxendinghere) + return maxsofar diff --git a/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-3.py b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-3.py new file mode 100644 index 0000000000..31b9997aab --- /dev/null +++ b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-3.py @@ -0,0 +1,14 @@ +def maxsumseq(sequence): + start, end, sum_start = -1, -1, -1 + maxsum_, sum_ = 0, 0 + for i, x in enumerate(sequence): + sum_ += x + if maxsum_ < sum_: # found maximal subsequence so far + maxsum_ = sum_ + start, end = sum_start, i + elif sum_ < 0: # start new sequence + sum_ = 0 + sum_start = i + assert maxsum_ == maxsum(sequence) + assert maxsum_ == sum(sequence[start + 1:end + 1]) + return sequence[start + 1:end + 1] diff --git a/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-4.py b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-4.py new file mode 100644 index 0000000000..903496b649 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-4.py @@ -0,0 +1,14 @@ +def maxsumit(iterable): + maxseq = seq = [] + start, end, sum_start = -1, -1, -1 + maxsum_, sum_ = 0, 0 + for i, x in enumerate(iterable): + seq.append(x); sum_ += x + if maxsum_ < sum_: + maxseq = seq; maxsum_ = sum_ + start, end = sum_start, i + elif sum_ < 0: + seq = []; sum_ = 0 + sum_start = i + assert maxsum_ == sum(maxseq[:end - start]) + return maxseq[:end - start] diff --git a/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-5.py b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-5.py new file mode 100644 index 0000000000..e51dc76dd9 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Python/greatest-subsequential-sum-5.py @@ -0,0 +1,17 @@ +f = maxsumit +assert f([]) == [] +assert f([-1]) == [] +assert f([0]) == [] +assert f([1]) == [1] +assert f([1, 0]) == [1] +assert f([0, 1]) == [0, 1] +assert f([0, 1, 0]) == [0, 1] +assert f([2]) == [2] +assert f([2, -1]) == [2] +assert f([-1, 2]) == [2] +assert f([-1, 2, -1]) == [2] +assert f([2, -1, 3]) == [2, -1, 3] +assert f([2, -1, 3, -1]) == [2, -1, 3] +assert f([-1, 2, -1, 3]) == [2, -1, 3] +assert f([-1, 2, -1, 3, -1]) == [2, -1, 3] +assert f([-1, 1, 2, -5, -6]) == [1,2] diff --git a/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-1.r b/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-1.r new file mode 100644 index 0000000000..a3bd7335c9 --- /dev/null +++ b/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-1.r @@ -0,0 +1,7 @@ +max.subseq <- function(x) { + cumulative <- cumsum(x) + min.cumulative.so.far <- Reduce(min, cumulative, accumulate=TRUE) + end <- which.max(cumulative-min.cumulative.so.far) + begin <- which.min(c(0, cumulative[1:end])) + if (end >= begin) x[begin:end] else x[c()] +} diff --git a/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-2.r b/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-2.r new file mode 100644 index 0000000000..e879b59c06 --- /dev/null +++ b/Task/Greatest-subsequential-sum/R/greatest-subsequential-sum-2.r @@ -0,0 +1,2 @@ +> max.subseq(c(-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1)) +[1] 3 5 6 -2 -1 4 diff --git a/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-1.rexx b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-1.rexx new file mode 100644 index 0000000000..32ca88cc3d --- /dev/null +++ b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-1.rexx @@ -0,0 +1,20 @@ +/*REXX program finds the shortest greatest continous subsequence sum.*/ +arg @ /*get the arugment LIST (if any).*/ +say 'words='words(@) ' list='@ /*show WORDS and LIST to console.*/ +sum=word(@,1) /*a "starter" sum (of a sequence)*/ +w=words(@) /*number of words in the list. */ +at=1 /*where the sequence starts at. */ +L=0 /*the length of the sequence. */ + /*process the list. */ + do j=1 for w; f=word(@,j) + do k=j to w; s=f + do m=j+1 to k + s=s+word(@,m) + end /*m*/ + if s>sum then do; sum=s; at=j; L=k-j+1; end + end /*k*/ + end /*j*/ + +seq=subword(@,at,L); if seq=='' then seq="[NULL]" +say; say 'sum='word(sum 0,1)/1 " sequence="seq + /*stick a fork in it, we're done.*/ diff --git a/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-2.rexx b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-2.rexx new file mode 100644 index 0000000000..becc81213a --- /dev/null +++ b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-2.rexx @@ -0,0 +1,21 @@ +/*REXX program finds the longest greatest continous subsequence sum. */ +arg @ /*get the arugment LIST (if any).*/ +say 'words='words(@) ' list='@ /*show WORDS and LIST to console.*/ +sum=word(@,1) /*a "starter" sum (of a sequence)*/ +w=words(@) /*number of words in the list. */ +at=1 /*where the sequence starts at. */ +L=0 /*the length of the sequence. */ + /*process the list. */ + do j=1 for w; f=word(@,j) + do k=j to w; s=f + do m=j+1 to k + s=s+word(@,m) + end /*m*/ + _=k-j+1 + if (s==sum & _>L) | s>sum then do; sum=s; at=j; L=_; end + end /*k*/ + end /*j*/ + +seq=subword(@,at,L); if seq=='' then seq="[NULL]" +say; say 'sum='word(sum 0,1)/1 " sequence="seq + /*stick a fork in it, we're done.*/ diff --git a/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-3.rexx b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-3.rexx new file mode 100644 index 0000000000..f47281bea8 --- /dev/null +++ b/Task/Greatest-subsequential-sum/REXX/greatest-subsequential-sum-3.rexx @@ -0,0 +1,31 @@ +/* REXX *************************************************************** +* 09.08.2012 Walter Pachl translated Pascal algorithm to Rexx +**********************************************************************/ + s=' -1 -2 3 5 6 -2 -1 4 -4 2 -1' + maxSum = 0 + seqStart = 0 + seqEnd = -1 + do i = 1 To words(s) + seqSum = 0 + Do j = i to words(s) + seqSum = seqSum + word(s,j) + if seqSum > maxSum then Do + maxSum = seqSum + seqStart = i + seqEnd = j + end + end + end + Say 'Sequence:' + Say s + Say 'Subsequence with greatest sum: ' + If seqend (+ sum i) max-sum) + (values (cons i seq) (cons i seq) (+ sum i) (+ sum i))] + [(< (+ sum i) 0) + (values '() max-seq 0 max-sum)] + [else + (values (cons i seq) max-seq (+ sum i) max-sum)]))) + (values (reverse result) max-sum)) diff --git a/Task/Greatest-subsequential-sum/Racket/greatest-subsequential-sum-2.rkt b/Task/Greatest-subsequential-sum/Racket/greatest-subsequential-sum-2.rkt new file mode 100644 index 0000000000..e2da34caa6 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Racket/greatest-subsequential-sum-2.rkt @@ -0,0 +1,3 @@ +> (max-subseq '(-1 -2 3 5 6 -2 -1 4 -4 2 -1)) +'(3 5 6 -2 -1 4) +15 diff --git a/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-1.rb b/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-1.rb new file mode 100644 index 0000000000..631c3ca373 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-1.rb @@ -0,0 +1,14 @@ +Infinity = 1.0/0 +def subarray_sum(arr) + max, slice = -Infinity, [] + arr.each_with_index do |n, i| + (i...arr.length).each do |j| + sum = arr[i..j].inject(0) { |x, sum| sum += x } + if sum > max + max = sum + slice = arr[i..j] + end + end + end + [max, slice] +end diff --git a/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-2.rb b/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-2.rb new file mode 100644 index 0000000000..5643779875 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Ruby/greatest-subsequential-sum-2.rb @@ -0,0 +1,30 @@ +# the trick is that at any point +# in the iteration if starting a new chain is +# better than your current score with this element +# added to it, then do so. +# the interesting part is proving the math behind it +Infinity = 1.0/0 +def subarray_sum(arr) + curr,max = -Infinity,-Infinity + first,last= 0,0 + arr.each_with_index do |e,i| + curr = e + curr + if(e>curr) + curr = e + first=i + end + if(curr > max) + max = curr + last=i + end + end + return max,arr[first...last+1] +end + +input=[1,2,3,4,5,-8,-9,-20,40,25,-5] +p subarray_sum(input) +=>[65, [40, 25]] + +input=[-3, -1] +p subarray_sum(input) +=>[-1, [-1]] diff --git a/Task/Greatest-subsequential-sum/Scala/greatest-subsequential-sum.scala b/Task/Greatest-subsequential-sum/Scala/greatest-subsequential-sum.scala new file mode 100644 index 0000000000..a5427a58a5 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Scala/greatest-subsequential-sum.scala @@ -0,0 +1,25 @@ +def maxSubseq(l: List[Int]) = l.scanRight(Nil : List[Int]) { + case (el, acc) if acc.sum + el < 0 => Nil + case (el, acc) => el :: acc +} max Ordering.by((_: List[Int]).sum) + +def biggestMaxSubseq(l: List[Int]) = l.scanRight(Nil : List[Int]) { + case (el, acc) if acc.sum + el < 0 => Nil + case (el, acc) => el :: acc +} max Ordering.by((ss: List[Int]) => (ss.sum, ss.length)) + +def biggestMaxSubseq[N](l: List[N])(implicit n: Numeric[N]) = { + import n._ + l.scanRight(Nil : List[N]) { + case (el, acc) if acc.sum + el < zero => Nil + case (el, acc) => el :: acc + } max Ordering.by((ss: List[N]) => (ss.sum, ss.length)) +} + +def linearBiggestMaxSubseq[N](l: List[N])(implicit n: Numeric[N]) = { + import n._ + l.scanRight((zero, Nil : List[N])) { + case (el, (acc, _)) if acc + el < zero => (zero, Nil) + case (el, (acc, ss)) => (acc + el, el :: ss) + } max Ordering.by((t: (N, List[N])) => (t._1, t._2.length)) _2 +} diff --git a/Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.ss b/Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.ss new file mode 100644 index 0000000000..e42244588b --- /dev/null +++ b/Task/Greatest-subsequential-sum/Scheme/greatest-subsequential-sum.ss @@ -0,0 +1,11 @@ +(define (maxsubseq in) + (let loop + ((_sum 0) (_seq (list)) (maxsum 0) (maxseq (list)) (l in)) + (if (null? l) + (cons maxsum (reverse maxseq)) + (let* ((x (car l)) (sum (+ _sum x)) (seq (cons x _seq))) + (if (> sum 0) + (if (> sum maxsum) + (loop sum seq sum seq (cdr l)) + (loop sum seq maxsum maxseq (cdr l))) + (loop 0 (list) maxsum maxseq (cdr l))))))) diff --git a/Task/Greatest-subsequential-sum/Tcl/greatest-subsequential-sum.tcl b/Task/Greatest-subsequential-sum/Tcl/greatest-subsequential-sum.tcl new file mode 100644 index 0000000000..c8151c5455 --- /dev/null +++ b/Task/Greatest-subsequential-sum/Tcl/greatest-subsequential-sum.tcl @@ -0,0 +1,69 @@ +package require Tcl 8.5 +set a {-1 -2 3 5 6 -2 -1 4 -4 2 -1} + +# from the Perl solution +proc maxsumseq1 {a} { + set len [llength $a] + set maxsum 0 + + for {set start 0} {$start < $len} {incr start} { + for {set end $start} {$end < $len} {incr end} { + set sum 0 + incr sum [expr [join [lrange $a $start $end] +]] + if {$sum > $maxsum} { + set maxsum $sum + set maxsumseq [lrange $a $start $end] + } + } + } + return $maxsumseq +} + +# from the Python solution +proc maxsumseq2 {sequence} { + set start -1 + set end -1 + set maxsum_ 0 + set sum_ 0 + for {set i 0} {$i < [llength $sequence]} {incr i} { + set x [lindex $sequence $i] + incr sum_ $x + if {$maxsum_ < $sum_} { + set maxsum_ $sum_ + set end $i + } elseif {$sum_ < 0} { + set sum_ 0 + set start $i + } + } + assert {$maxsum_ == [maxsum $sequence]} + assert {$maxsum_ == [sum [lrange $sequence [expr {$start + 1}] $end]]} + return [lrange $sequence [expr {$start + 1}] $end] +} + +proc maxsum {sequence} { + set maxsofar 0 + set maxendinghere 0 + foreach x $sequence { + set maxendinghere [expr {max($maxendinghere + $x, 0)}] + set maxsofar [expr {max($maxsofar, $maxendinghere)}] + } + return $maxsofar +} + +proc assert {condition {message "Assertion failed!"}} { + if { ! [uplevel 1 [list expr $condition]]} { + return -code error $message + } +} + +proc sum list { + expr [join $list +] +} + + +puts "sequence: $a" +puts "maxsumseq1: [maxsumseq1 $a]" +puts [time {maxsumseq1 $a} 1000] +puts "maxsumseq2: [maxsumseq2 $a]" +puts [time {maxsumseq2 $a} 1000] diff --git a/Task/Greyscale-bars-Display/0DESCRIPTION b/Task/Greyscale-bars-Display/0DESCRIPTION new file mode 100644 index 0000000000..cf435b551c --- /dev/null +++ b/Task/Greyscale-bars-Display/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display. + +For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars) + +For the second quarter down, we start with white and step down through 14 shades of gray, getting darker until we have black on the right hand side of the display. (This gives a total of 16 bars). + +Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter. diff --git a/Task/Greyscale-bars-Display/1META.yaml b/Task/Greyscale-bars-Display/1META.yaml new file mode 100644 index 0000000000..2ccd87d281 --- /dev/null +++ b/Task/Greyscale-bars-Display/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Test card diff --git a/Task/Greyscale-bars-Display/ActionScript/greyscale-bars-display.as b/Task/Greyscale-bars-Display/ActionScript/greyscale-bars-display.as new file mode 100644 index 0000000000..eb58596dd5 --- /dev/null +++ b/Task/Greyscale-bars-Display/ActionScript/greyscale-bars-display.as @@ -0,0 +1,26 @@ +package +{ + import flash.display.Sprite; + + [SWF(width="640", height="480")] + public class GreyscaleBars extends Sprite + { + + public function GreyscaleBars() + { + _drawRow(8, 0); + _drawRow(16, stage.stageHeight/4, true); + _drawRow(32, stage.stageHeight/2); + _drawRow(64, stage.stageHeight/4 * 3, true); + } + + private function _drawRow(nbSteps : uint, startingY : uint, reverse : Boolean = false) : void { + + for (var i : int = 0; i < nbSteps; i++) { + graphics.beginFill(0x00, reverse ? 1 - (i/nbSteps) : (i/nbSteps)); + graphics.drawRect(i * stage.stageWidth / nbSteps, startingY, stage.stageWidth/nbSteps, stage.stageHeight/4); + graphics.endFill(); + } + } + } +} diff --git a/Task/Greyscale-bars-Display/Ada/greyscale-bars-display.ada b/Task/Greyscale-bars-Display/Ada/greyscale-bars-display.ada new file mode 100644 index 0000000000..105486b936 --- /dev/null +++ b/Task/Greyscale-bars-Display/Ada/greyscale-bars-display.ada @@ -0,0 +1,85 @@ +with Gtk.Window; use Gtk.Window; +with Gtk.Enums; +with Gtk.Handlers; +with Gtk.Main; +with Gdk; +with Gdk.Event; +with Glib; use Glib; +with Cairo; use Cairo; +with Gdk.Cairo; +pragma Elaborate_All (Gtk.Handlers); + +procedure Greyscale is + + Win : Gtk_Window; + Width : constant := 640; + Height : constant := 512; + + package Handlers is new Gtk.Handlers.Callback (Gtk_Window_Record); + package Event_Cb is new Gtk.Handlers.Return_Callback ( + Widget_Type => Gtk_Window_Record, + Return_Type => Boolean); + + procedure Quit (Win : access Gtk_Window_Record'Class) is + pragma Warnings (Off, Win); + begin + Gtk.Main.Main_Quit; + end Quit; + + function Expose + (Drawing : access Gtk_Window_Record'Class; + Event : Gdk.Event.Gdk_Event) + return Boolean + is + subtype Dub is Glib.Gdouble; + Cr : Cairo_Context; + Revert : Boolean; + Grey : Dub; + DH : constant Dub := Dub (Height) / 4.0; + X, Y, DW : Dub; + N : Natural; + + begin + Cr := Gdk.Cairo.Create (Get_Window (Drawing)); + for Row in 1 .. 4 loop + + N := 2 ** (Row + 2); + Revert := (Row mod 2) = 0; + DW := Dub (Width) / Dub (N); + X := 0.0; + Y := DH * Dub (Row - 1); + for B in 0 .. (N - 1) loop + Grey := Dub (B) / Dub (N - 1); + if Revert then + Grey := 1.0 - Grey; + end if; + Cairo.Set_Source_Rgb (Cr, Grey, Grey, Grey); + Cairo.Rectangle (Cr, X, Y, DW, DH); + Cairo.Fill (Cr); + X := X + DW; + end loop; + end loop; + Cairo.Destroy (Cr); + return False; + end Expose; + +begin + Gtk.Main.Set_Locale; + Gtk.Main.Init; + + Gtk_New (Win); + Gtk.Window.Initialize (Win, Gtk.Enums.Window_Toplevel); + Set_Title (Win, "Greyscale with GTKAda"); + Set_Default_Size (Win, Width, Height); + Set_App_Paintable (Win, True); + -- Attach handlers + Handlers.Connect (Win, "destroy", Handlers.To_Marshaller (Quit'Access)); + Event_Cb.Connect + (Win, + "expose_event", + Event_Cb.To_Marshaller (Expose'Access)); + + Show_All (Win); + + Gtk.Main.Main; +end Greyscale; diff --git a/Task/Greyscale-bars-Display/AutoHotkey/greyscale-bars-display.ahk b/Task/Greyscale-bars-Display/AutoHotkey/greyscale-bars-display.ahk new file mode 100644 index 0000000000..a21f98c885 --- /dev/null +++ b/Task/Greyscale-bars-Display/AutoHotkey/greyscale-bars-display.ahk @@ -0,0 +1,56 @@ +h := A_ScreenHeight +w := A_ScreenWidth +pToken := gdip_Startup() +hdc := CreateCompatibleDC() +hbm := CreateDIBSection(w, h) +obm := SelectObject(hdc, hbm) +G := Gdip_GraphicsFromHDC(hdc) + +OnExit, Exit + +Gui +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop +hwnd := WinExist() +Gui Show, NA + +columnHeight := h/4 + +Loop 4 +{ + columnY := (A_Index-1) * columnHeight + columnCount := 2**(A_Index+2) + colorgap := 255 / (columnCount-1) + columnWidth := w/ColumnCount + If (A_Index & 1) + colorComp := 0 + else + colorComp := 255 + ,colorgap *= -1 + MsgBox % colorGap * columnCount + Loop % columnCount + { + columnX := (A_Index-1) * columnWidth + pBrush := Gdip_BrushCreateSolid(QColor(colorComp, colorComp, colorComp)) + Gdip_FillRectangle(G, pBrush, columnX, columnY, columnWidth, columnHeight) + Gdip_DeleteBrush(pBrush) + colorComp += colorgap + } + SetFormat, IntegerFast, hex + SetFormat, IntegerFast, D +} + +UpdateLayeredWindow(hwnd, hdc, 0, 0, W, H) + +SelectObject(hdc, obm) +DeleteObject(hbm) +DeleteDC(hdc) +Gdip_DeleteGraphics(G) +Return + +Esc:: +Exit: +Gdip_Shutdown(pToken) +ExitApp + +QColor(r, g, b){ + return 0xFF000000 | (r << 16) | (g << 8) | (b) +} diff --git a/Task/Greyscale-bars-Display/BASIC256/greyscale-bars-display.basic256 b/Task/Greyscale-bars-Display/BASIC256/greyscale-bars-display.basic256 new file mode 100644 index 0000000000..2be188c05a --- /dev/null +++ b/Task/Greyscale-bars-Display/BASIC256/greyscale-bars-display.basic256 @@ -0,0 +1,10 @@ +h=ceil(graphheight/4) +for row=1 to 4 + w=ceil(graphwidth/(8*row)) + c=255/(8*row-1) + for n = 0 to (8*row-1) + color 255-c*n,255-c*n,255-c*n + if row/2 = int(row/2) then color c*n,c*n,c*n + rect n*w,h*(row-1),w,h + next n +next row diff --git a/Task/Greyscale-bars-Display/BBC-BASIC/greyscale-bars-display.bbc b/Task/Greyscale-bars-Display/BBC-BASIC/greyscale-bars-display.bbc new file mode 100644 index 0000000000..3be9fb87f6 --- /dev/null +++ b/Task/Greyscale-bars-Display/BBC-BASIC/greyscale-bars-display.bbc @@ -0,0 +1,14 @@ +MODE 8:REM 640 x 512 pixel display mode: BBC BASIC gives 2 graphics points per pixel +REM (0,0) is the bottom left of the display +GCOL 1 :REM Select colour one for drawing +FOR row%=1 TO 4 + n%=2^(row%+2) + w%=1280/n% + py%=256*(4-row%) + FOR b%=0 TO n%-1 + g%=255*b%/(n%-1) + IF n%=16 OR n%=64 THEN g%=255-g% + COLOUR 1,g%,g%,g% : REM Reprogram colour 1 to the grey we want + RECTANGLE FILL w%*b%,py%,w%,256 + NEXT b% +NEXT row% diff --git a/Task/Greyscale-bars-Display/C++/greyscale-bars-display-1.cpp b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-1.cpp new file mode 100644 index 0000000000..37de50fe09 --- /dev/null +++ b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-1.cpp @@ -0,0 +1,14 @@ +#ifndef MYWIDGET_H +#define MYWIDGET_H +#include + +class QPaintEvent ; + +class MyWidget : public QWidget { +public : + MyWidget( ) ; + +protected : + void paintEvent( QPaintEvent * ) ; +} ; +#endif diff --git a/Task/Greyscale-bars-Display/C++/greyscale-bars-display-2.cpp b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-2.cpp new file mode 100644 index 0000000000..a6bc82d936 --- /dev/null +++ b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-2.cpp @@ -0,0 +1,34 @@ +#include +#include "greytones.h" + +MyWidget::MyWidget( ) { + setGeometry( 0, 0 , 640 , 480 ) ; +} + +void MyWidget::paintEvent ( QPaintEvent * ) { + QBrush myBrush( Qt::SolidPattern ) ; + QPainter myPaint( this ) ; + int run = 0 ; //how often have we run through the loop ? + int colorcomp = 0 ; + for ( int columncount = 8 ; columncount < 128 ; columncount *= 2 ) { + int colorgap = 255 / columncount ; + int columnwidth = 640 / columncount ; // 640 being the window width + int columnheight = 480 / 4 ; //we're looking at quarters + if ( run % 2 == 0 ) { //we start with black columns + colorcomp = 0 ; + } + else { //we start with white columns + colorcomp = 255 ; + colorgap *= -1 ; //we keep subtracting color values + } + int ystart = 0 + columnheight * run ; //determines the y coordinate of the first column per row + int xstart = 0 ; + for ( int i = 0 ; i < columncount ; i++ ) { + myBrush.setColor( QColor( colorcomp, colorcomp , colorcomp ) ) ; + myPaint.fillRect( xstart , ystart , columnwidth , columnheight , myBrush ) ; + xstart += columnwidth ; + colorcomp += colorgap ; //we choose the next color + } + run++ ; + } +} diff --git a/Task/Greyscale-bars-Display/C++/greyscale-bars-display-3.cpp b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-3.cpp new file mode 100644 index 0000000000..7cb9bbbce7 --- /dev/null +++ b/Task/Greyscale-bars-Display/C++/greyscale-bars-display-3.cpp @@ -0,0 +1,10 @@ +#include +#include "greytones.h" + +int main( int argc, char * argv[ ] ) { + QApplication app( argc , argv ) ; + MyWidget window ; + window.setWindowTitle( QApplication::translate( "greyScales" , "grey scales demonstration" ) ) ; + window.show( ) ; + return app.exec( ) ; +} diff --git a/Task/Greyscale-bars-Display/C/greyscale-bars-display.c b/Task/Greyscale-bars-Display/C/greyscale-bars-display.c new file mode 100644 index 0000000000..0d3e1ec89d --- /dev/null +++ b/Task/Greyscale-bars-Display/C/greyscale-bars-display.c @@ -0,0 +1,35 @@ +#include +/* do some greyscale plotting */ +void gsplot (cairo_t *cr,int x,int y,double s) { + cairo_set_source_rgb (cr,s,s,s); + cairo_move_to (cr,x+0.5,y); + cairo_rel_line_to (cr,0,1); + cairo_stroke (cr); +} +/* make a shaded widget */ +gboolean expose_event (GtkWidget *widget,GdkEventExpose *event,gpointer data) { + int r,c,x=0; + cairo_t *cr; + cr = gdk_cairo_create (widget->window); + cairo_scale (cr,5,50); + cairo_set_line_width (cr,1); + for (r=0;r<4;r++) { + c = (r&1)*64-(r%2); + do gsplot (cr,x++%64,r,c/(1<<(3-r))/(8*(1<function grayscale(y1,y2,n,direction=1) ... +$ loop 0 to n-1; +$ s=#/(n-1); barcolor(rgb(s,s,s)); +$ if direction==1 then plotbar(#/n,y1,1/n,y2-y1); +$ else plotbar(1-(#+1)/n,y1,1/n,y2-y1); +$ endif; +$ end; +$endfunction +>function grayscales () ... +$ aspect(2); barstyle("#"); +$ window(0,0,1023,1023); margin(0); setplot(0,1,0,1); +$ clg; +$ hold on; +$ grayscale(3/4,1,8,1); +$ grayscale(1/2,3/4,14,-1); +$ grayscale(1/4,1/2,32,1); +$ grayscale(0,1/4,64,-1); +$ hold off; +$endfunction +>grayscales: diff --git a/Task/Greyscale-bars-Display/Haskell/greyscale-bars-display.hs b/Task/Greyscale-bars-Display/Haskell/greyscale-bars-display.hs new file mode 100644 index 0000000000..06806dc614 --- /dev/null +++ b/Task/Greyscale-bars-Display/Haskell/greyscale-bars-display.hs @@ -0,0 +1,58 @@ +import Graphics.UI.Gtk +import Graphics.UI.Gtk.Gdk.GC +import Control.Monad.Trans (liftIO) + +-- click on the window to exit. + +main = do + initGUI + + window <- windowNew + + buf <- pixbufNewFromXPMData bars + + widgetAddEvents window [ButtonPressMask] + on window objectDestroy mainQuit + on window exposeEvent (paint buf) + on window buttonPressEvent $ + liftIO $ do { widgetDestroy window; return True } + + windowFullscreen window + widgetShowAll window + + mainGUI + +paint :: Pixbuf -> EventM EExpose Bool +paint buf = do + pix <- eventWindow + liftIO $ do + (sx, sy) <- drawableGetSize pix + newBuf <- pixbufScaleSimple buf sx sy InterpNearest + gc <- gcNewWithValues pix newGCValues + drawPixbuf pix gc newBuf 0 0 0 0 (-1) (-1) RgbDitherNone 0 0 + return True + +bars :: [String] +bars = [ + "64 4 65 1 1 1"," c None","A c #000000", + "C c #080808","D c #0C0C0C","E c #101010","F c #141414", + "G c #181818","H c #1C1C1C","I c #202020","J c #242424", + "K c #282828","L c #2C2C2C","M c #303030","N c #343434", + "O c #383838","P c #3C3C3C","Q c #404040","R c #444444", + "S c #484848","T c #4C4C4C","U c #505050","V c #545454", + "W c #585858","X c #5C5C5C","Y c #606060","Z c #646464", + "a c #686868","b c #6C6C6C","c c #707070","d c #747474", + "e c #787878","f c #7C7C7C","g c #808080","h c #848484", + "i c #888888","j c #8C8C8C","k c #909090","l c #949494", + "m c #989898","n c #9C9C9C","o c #A0A0A0","p c #A4A4A4", + "q c #A8A8A8","r c #ACACAC","s c #B0B0B0","t c #B4B4B4", + "u c #B8B8B8","v c #BCBCBC","w c #C0C0C0","x c #C4C4C4", + "y c #C8C8C8","z c #CCCCCC","0 c #D0D0D0","1 c #D4D4D4", + "2 c #D8D8D8","3 c #DCDCDC","4 c #E0E0E0","5 c #E4E4E4", + "6 c #E8E8E8","7 c #ECECEC","8 c #F0F0F0","9 c #F4F4F4", + ". c #F8F8F8","+ c #FCFCFC","* c #FFFFFF", + "AAAAAAAAJJJJJJJJRRRRRRRRZZZZZZZZhhhhhhhhppppppppxxxxxxxx********", + "****88881111xxxxttttppppllllhhhhddddZZZZVVVVRRRRNNNNJJJJFFFFAAAA", + "AADDFFHHJJLLNNPPRRTTVVXXZZbbddffhhjjllnnpprrttvvxxzz11336688..**", + "*+.9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCA" + ] diff --git a/Task/Greyscale-bars-Display/Icon/greyscale-bars-display.icon b/Task/Greyscale-bars-Display/Icon/greyscale-bars-display.icon new file mode 100644 index 0000000000..5904d02dbd --- /dev/null +++ b/Task/Greyscale-bars-Display/Icon/greyscale-bars-display.icon @@ -0,0 +1,31 @@ +link graphics,printf,numbers + +procedure main() + DrawTestCard(GreyScale_TestCard()) + WDone() +end + +procedure greyscale(l,h,s) #: generate s greys over range l:h + every i := round(l to h+1 by ((h-l)/(s-1.))) do + suspend sprintf("%d,%d,%d",i,i,i) # return rgb black-grey-white +end + +procedure GreyScale_TestCard() #: return greyscale testcard + TC := testcard(,"GreyScale Test Card", + width := 800, height := 600, + list(numbands := 4) ) + maxv := 2^16-1 # largest colour value + every (iv := [], i := 1 to numbands) do { # for each band + every put(v := [], greyscale(0,maxv,2^(2+i))) # compute greyscale + put(iv, if i%2 = 0 then v else reverse(v)) # switch directions + } + + every r := height/numbands * ((i := 1 to numbands)-1) + 1 do { + TC.bands[i] := band(r,[]) + every c := width/(*iv[i]) * ((j := 1 to *iv[i])-1) + 1 do + put(TC.bands[i].bars, bar( c, iv[i,j])) + put((TC.bands[i]).bars, bar(width)) # right sentinal + } + put(TC.bands,band(height)) # bottom sentinal + return TC +end diff --git a/Task/Greyscale-bars-Display/J/greyscale-bars-display.j b/Task/Greyscale-bars-Display/J/greyscale-bars-display.j new file mode 100644 index 0000000000..6b908df7ee --- /dev/null +++ b/Task/Greyscale-bars-Display/J/greyscale-bars-display.j @@ -0,0 +1,7 @@ + load 'viewmat' + size=. 2{.".wd'qm' NB. J6 + size=. getscreenwh_jgtk_ '' NB. J7 + rows=. (2^3+i.4),._1^i.4 + bars=. ((64%{.)#[:(<:@|%~i.)*/)"1 rows + togreyscale=. (256#. [:<.255 255 255&*)"0 + 'rgb' viewmat (4<.@%~{:size)# (64<.@%~{.size)#"1 togreyscale bars diff --git a/Task/Greyscale-bars-Display/Java/greyscale-bars-display.java b/Task/Greyscale-bars-Display/Java/greyscale-bars-display.java new file mode 100644 index 0000000000..3509cb5535 --- /dev/null +++ b/Task/Greyscale-bars-Display/Java/greyscale-bars-display.java @@ -0,0 +1,46 @@ +import javax.swing.* ; +import java.awt.* ; + +public class Greybars extends JFrame { + private int width ; + private int height ; + + public Greybars( ) { + super( "grey bars example!" ) ; + width = 640 ; + height = 320 ; + setSize( width , height ) ; + setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ) ; + setVisible( true ) ; + } + + public void paint ( Graphics g ) { + int run = 0 ; + int colorcomp = 0 ; //component of the color + for ( int columncount = 8 ; columncount < 128 ; columncount *= 2 ) { + int colorgap = 255 / columncount ; //by this gap we change the background color + int columnwidth = width / columncount ; + int columnheight = height / 4 ; + if ( run % 2 == 0 ) //switches color directions with every for loop + colorcomp = 0 ; + else { + colorcomp = 255 ; + colorgap *= -1 ; + } + int ystart = 0 + columnheight * run ; + int xstart = 0 ; + for ( int i = 0 ; i < columncount ; i++ ) { + Color nextColor = new Color( colorcomp, colorcomp, colorcomp ) ; + g.setColor( nextColor ) ; + g.fillRect( xstart , ystart , columnwidth , columnheight ) ; + xstart += columnwidth ; + colorcomp += colorgap ; + } + run++ ; + } + } + + public static void main( String[ ] args ) { + Greybars gb = new Greybars( ) ; + } +} diff --git a/Task/Greyscale-bars-Display/JavaScript/greyscale-bars-display.js b/Task/Greyscale-bars-Display/JavaScript/greyscale-bars-display.js new file mode 100644 index 0000000000..d4777d10be --- /dev/null +++ b/Task/Greyscale-bars-Display/JavaScript/greyscale-bars-display.js @@ -0,0 +1,29 @@ + + + diff --git a/Task/Greyscale-bars-Display/Liberty-BASIC/greyscale-bars-display.liberty b/Task/Greyscale-bars-Display/Liberty-BASIC/greyscale-bars-display.liberty new file mode 100644 index 0000000000..43ad9dd0d0 --- /dev/null +++ b/Task/Greyscale-bars-Display/Liberty-BASIC/greyscale-bars-display.liberty @@ -0,0 +1,31 @@ +nomainwin + +WindowWidth =DisplayWidth +WindowHeight =DisplayHeight + +open "Grey bars" for graphics_fs_nsb as #w + +#w "trapclose [quit]" +#w "down" + +bars =4 ' alter for more, finer bars. + +for group =0 to bars -1 + for i = 0 to 2^( 3 +group) -1 + #w "place "; WindowWidth *i /( 2^( 3 +group)); " "; WindowHeight *group /bars + if ( group =0) or ( group =2) then + g$ =str$( int( 255 *i /(2^( 3 +group)-1))) + else + g$ =str$( 255 -int( 255 *i /(2^( 3 +group)-1))) + end if + grey$ =g$ +" " +g$ +" " +g$ + #w "backcolor "; grey$ + '#w "color "; grey$ 'rem out for outlined areas.. + #w "boxfilled "; WindowWidth *( i +1) /8 ; " "; WindowHeight *( group +1) /bars + next i +next group + +wait +[quit] +close #w +end diff --git a/Task/Greyscale-bars-Display/Mathematica/greyscale-bars-display.mathematica b/Task/Greyscale-bars-Display/Mathematica/greyscale-bars-display.mathematica new file mode 100644 index 0000000000..5174b0cac4 --- /dev/null +++ b/Task/Greyscale-bars-Display/Mathematica/greyscale-bars-display.mathematica @@ -0,0 +1,5 @@ +CreateDocument[ Graphics[ Flatten@Table[ +{ If[EvenQ[#3], GrayLevel[ 1. - j/#1 ], GrayLevel[ j/#1 ]], + Rectangle[{j #2, 7*#3}, {#2 (j + 1), (#3 + 1) 7}]}, {j, 0, #1}] & @@@ + {{7, 8, 3}, {15, 4, 2}, {31, 2, 1}, {63, 1, 0} } +,ImageSize -> Full], WindowFrame -> "Frameless", WindowSize -> Full] diff --git a/Task/Greyscale-bars-Display/PicoLisp/greyscale-bars-display.l b/Task/Greyscale-bars-Display/PicoLisp/greyscale-bars-display.l new file mode 100644 index 0000000000..c4995e1b58 --- /dev/null +++ b/Task/Greyscale-bars-Display/PicoLisp/greyscale-bars-display.l @@ -0,0 +1,16 @@ +(let Pgm # Create PGM of 384 x 288 pixels + (make + (for N 4 + (let L + (make + (for I (* N 8) + (let C (*/ (dec I) 255 (dec (* N 8))) + (unless (bit? 1 N) + (setq C (- 255 C)) ) + (do (/ 48 N) (link C)) ) ) ) + (do 72 (link L)) ) ) ) + (out '(display) # Pipe to ImageMagick + (prinl "P5") # NetPBM format + (prinl (length (car Pgm)) " " (length Pgm)) + (prinl 255) + (for Y Pgm (apply wr Y)) ) ) diff --git a/Task/Greyscale-bars-Display/Python/greyscale-bars-display.py b/Task/Greyscale-bars-Display/Python/greyscale-bars-display.py new file mode 100644 index 0000000000..9b54fdea5d --- /dev/null +++ b/Task/Greyscale-bars-Display/Python/greyscale-bars-display.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +#four gray scaled stripes 8:16:32:64 in Python 2.7.1 + +from livewires import * + +horiz=640; vert=480; pruh=vert/4; dpp=255.0 +begin_graphics(width=horiz,height=vert,title="Gray stripes",background=Colour.black) + +def ty_pruhy(each): + hiy=each[0]*pruh; loy=hiy-pruh + krok=horiz/each[1]; piecol=255.0/(each[1]-1) + for x in xrange(0,each[1]): + barva=Colour(piecol*x/dpp,piecol*x/dpp,piecol*x/dpp ); set_colour(barva) + if each[2]: + box(x*krok,hiy,x*krok+krok,loy,filled=1) + else: + box(horiz-x*krok,hiy,horiz-((x+1)*krok),loy,filled=1) + +# main +source=[[4,8,True],[3,16,False],[2,32,True],[1,64,False]] +for each in source: + ty_pruhy(each) + +while keys_pressed() != [' ']: # press spacebar to close window + pass diff --git a/Task/Greyscale-bars-Display/R/greyscale-bars-display-1.r b/Task/Greyscale-bars-Display/R/greyscale-bars-display-1.r new file mode 100644 index 0000000000..b28ed9cf44 --- /dev/null +++ b/Task/Greyscale-bars-Display/R/greyscale-bars-display-1.r @@ -0,0 +1,7 @@ +mat <- matrix(c(rep(1:8, each = 8) / 8, + rep(16:1, each = 4) / 16, + rep(1:32, each = 2) / 32, + rep(64:1, each = 1) / 64), + nrow = 4, byrow = TRUE) +par(mar = rep(0, 4)) +image(t(mat[4:1, ]), col = gray(1:64/64), axes = FALSE) diff --git a/Task/Greyscale-bars-Display/R/greyscale-bars-display-2.r b/Task/Greyscale-bars-Display/R/greyscale-bars-display-2.r new file mode 100644 index 0000000000..80fb1a5036 --- /dev/null +++ b/Task/Greyscale-bars-Display/R/greyscale-bars-display-2.r @@ -0,0 +1,11 @@ +grayscalesImage <- function(nrow = 4) { + X <- matrix(NA, nrow = nrow, ncol = 2^(nrow + 2)) + for (i in 1:nrow) { + X[i, ] <- rep(1:2^(i + 2), each = 2^(nrow - i)) / 2^(i + 2) + if (i %% 2 == 0) X[i, ] <- rev(X[i, ]) + } + par(mar = rep(0, 4)) + image(t(X[nrow:1, ]), col = gray(1:ncol(X) / ncol(X)), axes = FALSE) +} +## Example ## +grayscalesImage(6) # produces image shown in screenshot to the right diff --git a/Task/Greyscale-bars-Display/Racket/greyscale-bars-display.rkt b/Task/Greyscale-bars-Display/Racket/greyscale-bars-display.rkt new file mode 100644 index 0000000000..8094211505 --- /dev/null +++ b/Task/Greyscale-bars-Display/Racket/greyscale-bars-display.rkt @@ -0,0 +1,20 @@ +#lang racket/gui +(require slideshow/pict) + +(define-values (*width* *height*) (values 400 40)) + +(define (shades inc) + (for/list ([scale (in-range 0 (+ 1 inc) inc)]) + (round (* 255 scale)))) + +(define (grays increment direction) + (define colors (shades increment)) + (apply hc-append + ((if (eq? direction 'right) identity reverse) + (for/list ([c colors]) + (colorize (filled-rectangle + (/ *width* (length colors)) *height*) + (make-color c c c)))))) + +(vc-append (grays 1/8 'right) (grays 1/16 'left) + (grays 1/32 'right) (grays 1/64 'left)) diff --git a/Task/Greyscale-bars-Display/Scala/greyscale-bars-display-1.scala b/Task/Greyscale-bars-Display/Scala/greyscale-bars-display-1.scala new file mode 100644 index 0000000000..b5e0d65192 --- /dev/null +++ b/Task/Greyscale-bars-Display/Scala/greyscale-bars-display-1.scala @@ -0,0 +1,19 @@ +import scala.swing._ + +class GreyscaleBars extends Component { + override def paintComponent(g:Graphics2D)={ + val barHeight=size.height>>2 + for(run <- 0 to 3; colCount=8< +#include +#include +#include + +struct GuessNumberIterator : std::iterator { + int i; + GuessNumberIterator() { } + GuessNumberIterator(int _i) : i(_i) { } + GuessNumberIterator& operator++() { ++i; return *this; } + GuessNumberIterator operator++(int) { + GuessNumberIterator tmp = *this; ++(*this); return tmp; } + bool operator==(const GuessNumberIterator& y) { return i == y.i; } + bool operator!=(const GuessNumberIterator& y) { return i != y.i; } + int operator*() { + std::cout << "Is your number less than or equal to " << i << "? "; + std::string s; + std::cin >> s; + return (s != "" && (s[0] == 'y' || s[0] == 'Y')) ? 0 : -1; + } + GuessNumberIterator& operator--() { --i; return *this; } + GuessNumberIterator operator--(int) { + GuessNumberIterator tmp = *this; --(*this); return tmp; } + GuessNumberIterator& operator+=(int n) { i += n; return *this; } + GuessNumberIterator& operator-=(int n) { i -= n; return *this; } + GuessNumberIterator operator+(int n) { + GuessNumberIterator tmp = *this; return tmp += n; } + GuessNumberIterator operator-(int n) { + GuessNumberIterator tmp = *this; return tmp -= n; } + int operator-(const GuessNumberIterator &y) { return i - y.i; } + int operator[](int n) { return *(*this + n); } + bool operator<(const GuessNumberIterator &y) { return i < y.i; } + bool operator>(const GuessNumberIterator &y) { return i > y.i; } + bool operator<=(const GuessNumberIterator &y) { return i <= y.i; } + bool operator>=(const GuessNumberIterator &y) { return i >= y.i; } +}; +inline GuessNumberIterator operator+(int n, GuessNumberIterator &i) { return i + n; } + +const int lower = 0; +const int upper = 100; + +int main() { + std::cout << "Instructions:\n" + << "Think of integer number from " << lower << " (inclusive) to " + << upper << " (exclusive) and\n" + << "I will guess it. After each guess, I will ask you if it is less than\n" + << "or equal to some number, and you will respond with \"yes\" or \"no\".\n"; + int answer = std::lower_bound(GuessNumberIterator(lower), GuessNumberIterator(upper), 0).i; + std::cout << "Your number is " << answer << ".\n"; + return 0; +} diff --git a/Task/Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c b/Task/Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c new file mode 100644 index 0000000000..51b5237c56 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c @@ -0,0 +1,30 @@ +#include + +int main(){ + int bounds[ 2 ] = {1, 100}; + char input[ 2 ] = " "; + /* second char is for the newline from hitting [return] */ + int choice = (bounds[ 0 ] + bounds[ 1 ]) / 2; + /* using a binary search */ + + printf( "Choose a number between %d and %d.\n", bounds[ 0 ], bounds[ 1 ] ); + + do{ + switch( input[ 0 ] ){ + case 'H': + bounds[ 1 ] = choice; + break; + case 'L': + bounds[ 0 ] = choice; + break; + case 'Y': + printf( "\nAwwwright\n" ); + return 0; + } + choice = (bounds[ 0 ] + bounds[ 1 ]) / 2; + + printf( "Is the number %d? (Y/H/L) ", choice ); + }while( scanf( "%1s", input ) == 1 ); + + return 0; +} diff --git a/Task/Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj b/Task/Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj new file mode 100644 index 0000000000..aa07cc2eca --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj @@ -0,0 +1,14 @@ +(require '[clojure.string :as str]) + +(defn guess-game [low high] + (printf "Think of a number between %s and %s.\n (use (h)igh (l)ow (c)orrect)\n" low high) + (loop [guess (/ (inc (- high low)) 2) + [step & more] (next (iterate #(/ % 2) guess))] + (printf "I guess %s\n=> " (Math/round (float guess))) + (flush) + (case (first (str/lower-case (read))) + \h (recur (- guess step) more) + \l (recur (+ guess step) more) + \c (println "Huzzah!") + (do (println "Invalid input.") + (recur guess step))))) diff --git a/Task/Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d b/Task/Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d new file mode 100644 index 0000000000..5c2b200bf7 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d @@ -0,0 +1,42 @@ +import std.stdio, std.string; + +void main() { + immutable mnOrig = 1, mxOrig = 10; + int mn = mnOrig, mx = mxOrig; + + writefln( + "Think of a number between %d and %d and wait for me to guess it. + On every guess of mine you should state whether the guess was + too high, too low, or equal to your number by typing h, l, or =", + mn, mx); + + LOOP: for (int i = 1; ; i++) { + immutable guess = (mn + mx) / 2; + writef("Guess %2d is: %2d. The score for which is (h,l,=): ", + i, guess); + immutable string txt = readln().strip().toLower(); + + switch (txt) { + case "h": + mx = guess - 1; + break; + case "l": + mn = guess + 1; + break; + case "=": + writeln(" Yeehaw!!"); + break LOOP; + default: + writefln(" I don't understand your input '%s'.", + txt); + continue LOOP; + } + + if (mn > mx || mn < mnOrig || mx > mxOrig) { + writeln("Please check your scoring as" ~ + " I cannot find the value"); + break; + } + } + writeln("\nThanks for keeping score."); +} diff --git a/Task/Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria b/Task/Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria new file mode 100644 index 0000000000..ac7852afb7 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria @@ -0,0 +1,31 @@ +include get.e +include wildcard.e + +sequence Respons +integer min, max, Guess +min = 0 +max = 100 + +printf(1,"Think of a number between %d and %d.\n",{min,max}) +puts(1,"On every guess of mine you should state whether my guess was\n") +puts(1,"too high, too low, or equal to your number by typing 'h', 'l', or '='\n") + +while 1 do + if max < min then + puts(1,"I think something is strange here...\n") + exit + end if + Guess = floor((max-min)/2+min) + printf(1,"My guess is %d, is this correct? ", Guess) + Respons = upper(prompt_string("")) + if Respons[1] = 'H' then + max = Guess-1 + elsif Respons[1] = 'L' then + min = Guess+1 + elsif Respons[1] = '=' then + puts(1,"I did it!\n") + exit + else + puts(1,"I do not understand that...\n") + end if +end while diff --git a/Task/Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom b/Task/Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom new file mode 100644 index 0000000000..26d2e108ad --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom @@ -0,0 +1,36 @@ +class Main +{ + public static Void main () + { + Int lowerLimit := 1 + Int higherLimit := 100 + + echo ("Think of a number between 1 and 100") + echo ("Press 'enter' when ready") + Env.cur.in.readLine + + while (true) + { + if (higherLimit < lowerLimit) + { // check that player is not cheating! + echo ("Something has gone wrong ... I give up") + break + } + myGuess := (higherLimit + lowerLimit) / 2 + echo ("My guess is $myGuess") + echo ("Enter 'H' if your number is higher, 'L' if lower, or 'E' if equal") + switch (Env.cur.in.readLine.trim.upper) + { + case "E": + echo ("I got it correct - thankyou!") + break // game over + case "H": + lowerLimit = myGuess + 1 + case "L": + higherLimit = myGuess - 1 + default: + echo ("Pardon? Let's try that again") + } + } + } +} diff --git a/Task/Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f b/Task/Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f new file mode 100644 index 0000000000..84385b75ae --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f @@ -0,0 +1,38 @@ +program Guess_a_number_Player + implicit none + + integer, parameter :: limit = 100 + integer :: guess, mx = limit, mn = 1 + real :: rnum + character(1) :: score + + write(*, "(a, i0, a)") "Think of a number between 1 and ", limit, & + " and I will try to guess it." + write(*, "(a)") "You score my guess by entering: h if my guess is higher than that number" + write(*, "(a)") " l if my guess is lower than that number" + write(*, "(a/)") " c if my guess is the same as that number" + + call random_seed + call random_number(rnum) + guess = rnum * limit + 1 + do + write(*, "(a, i0, a,)", advance='no') "My quess is: ", guess, " Score(h, l or c)?: " + read*, score + select case(score) + case("l", "L") + mn = guess + guess = (mx-guess+1) / 2 + mn + + case("h", "H") + mx = guess + guess = mx - (guess-mn+1) / 2 + + case("c", "C") + write(*, "(a)") "I solved it!" + exit + + case default + write(*, "(a)") "I did not understand that" + end select + end do +end program diff --git a/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go b/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go new file mode 100644 index 0000000000..49ac043dca --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "sort" +) + +func main() { + lower, upper := 0, 100 + fmt.Printf(`Instructions: +Think of integer number from %d (inclusive) to %d (exclusive) and +I will guess it. After each guess, I will ask you if it is less than +or equal to some number, and you will respond with "yes" or "no". +`, lower, upper) + answer := sort.Search(upper-lower, func (i int) bool { + fmt.Printf("Is your number less than or equal to %d? ", lower+i) + s := "" + fmt.Scanf("%s", &s) + return s != "" && s[0] == 'y' + }) + fmt.Printf("Your number is %d.\n", lower+answer) +} diff --git a/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go b/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go new file mode 100644 index 0000000000..21bb57f690 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go @@ -0,0 +1,38 @@ +package main + +import ( + "bufio" + "fmt" + "os" +) + +func main() { + lower, upper := 1, 100 + fmt.Printf(`Instructions: +Think of integer number from %d (inclusive) to %d (inclusive) and I will guess it. +After each guess, you respond with l,h,or c depending on +if my guess was too low, too high, or correct. +Press enter when you are thinking of a number. `, lower, upper) + in := bufio.NewReader(os.Stdin) + in.ReadString('\n') + for { + guess := (upper+lower)/2 + fmt.Printf("My guess: %d (l/h/c) ", guess) + s, err := in.ReadString('\n') + if err != nil { + fmt.Println("\nSo, bye.") + return + } + switch s { + case "l\n": + lower = guess + 1 + case "h\n": + upper = guess - 1 + case "c\n": + fmt.Println("I did it. :)") + return + default: + fmt.Println("Please respond by pressing l, h, or c") + } + } +} diff --git a/Task/Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon b/Task/Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon new file mode 100644 index 0000000000..b0c36b9d40 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon @@ -0,0 +1,29 @@ +procedure main () + lower_limit := 1 + higher_limit := 100 + + write ("Think of a number between 1 and 100") + write ("Press 'enter' when ready") + read () + + repeat { + if (higher_limit < lower_limit) + then { # check that player is not cheating! + write ("Something has gone wrong ... I give up") + exit () + } + my_guess := (higher_limit + lower_limit) / 2 + write ("My guess is ", my_guess) + write ("Enter 'H' if your number is higher, 'L' if lower, or 'E' if equal") + reply := map(trim(read ())) + case (reply) of { + "e" : { + write ("I got it correct - thankyou!") + exit () # game over + } + "h" : lower_limit := my_guess + 1 + "l" : higher_limit := my_guess - 1 + default : write ("Pardon? Let's try that again") + } + } +end diff --git a/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j b/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j new file mode 100644 index 0000000000..dfe0576c71 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j @@ -0,0 +1,15 @@ +require 'misc' +guess=:3 :0 + 'lo hi'=.y + while.lo < hi do. + smoutput 'guessing a number between ',(":lo),' and ',":hi + guess=.lo+?hi-lo + select.{.deb tolower prompt 'is it ',(":guess),'? ' + case.'y'do. smoutput 'Win!' return. + case.'l'do. lo=.guess+1 + case.'h'do. hi=.guess-1 + case.'q'do. smoutput 'giving up' return. + case. do. smouput 'options: yes, low, high, quit' + end. + end. +) diff --git a/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j b/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j new file mode 100644 index 0000000000..6090f37b96 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j @@ -0,0 +1,20 @@ + guess 1 100 +guessing a number between 1 and 100 +is it 86? hi +guessing a number between 1 and 85 +is it 56? hi +guessing a number between 1 and 55 +is it 24? lo +guessing a number between 25 and 55 +is it 29? lo +guessing a number between 30 and 55 +is it 43? lo +guessing a number between 44 and 55 +is it 53? hi +guessing a number between 44 and 52 +is it 51? hi +guessing a number between 44 and 50 +is it 48? lo +guessing a number between 49 and 50 +is it 49? lo +50 diff --git a/Task/Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java b/Task/Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java new file mode 100644 index 0000000000..9aedcfbc52 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java @@ -0,0 +1,36 @@ +import java.util.AbstractList; +import java.util.Collections; +import java.util.Scanner; + +public class GuessNumber { + public static final int LOWER = 0, UPPER = 100; + public static void main(String[] args) { + System.out.printf("Instructions:\n" + + "Think of integer number from %d (inclusive) to %d (exclusive) and\n" + + "I will guess it. After each guess, you respond with L, H, or C depending\n" + + "on if my guess was too low, too high, or correct.\n", + LOWER, UPPER); + int result = Collections.binarySearch(new AbstractList() { + private final Scanner in = new Scanner(System.in); + public int size() { return UPPER - LOWER; } + public Integer get(int i) { + System.out.printf("My guess is: %d. Is it too high, too low, or correct? (H/L/C) ", LOWER+i); + String s = in.nextLine(); + assert s.length() > 0; + switch (Character.toLowerCase(s.charAt(0))) { + case 'l': + return -1; + case 'h': + return 1; + case 'c': + return 0; + } + return -1; + } + }, 0); + if (result < 0) + System.out.println("That is impossible."); + else + System.out.printf("Your number is %d.\n", result); + } +} diff --git a/Task/Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js b/Task/Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js new file mode 100644 index 0000000000..5398ceca6e --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js @@ -0,0 +1,53 @@ +#!/usr/bin/env js + +var DONE = RIGHT = 0, HIGH = 1, LOW = -1; + +function main() { + showInstructions(); + while (guess(1, 100) !== DONE); +} + +function guess(low, high) { + if (low > high) { + print("I can't guess it. Perhaps you changed your number."); + return DONE; + } + + var g = Math.floor((low + high) / 2); + var result = getResult(g); + switch (result) { + case RIGHT: + return DONE; + case LOW: + return guess(g + 1, high); + case HIGH: + return guess(low, g - 1); + } +} + +function getResult(g) { + while(true) { + putstr('Is it ' + g + '? '); + var ans = readline().toUpperCase().replace(/^\s+/, '') + ' '; + switch (ans[0]) { + case 'R': + print('I got it! Thanks for the game.'); + return RIGHT; + case 'L': + return LOW; + case 'H': + return HIGH; + default: + print('Please tell me if I am "high", "low" or "right".'); + } + } +} + +function showInstructions() { + print('Think of a number between 1 and 100 and I will try to guess it.'); + print('After I guess, type "low", "high" or "right", and then press enter.'); + putstr("When you've thought of a number press enter."); + readline(); +} + +main(); diff --git a/Task/Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty b/Task/Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty new file mode 100644 index 0000000000..3192dc3eee --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty @@ -0,0 +1,30 @@ +mini=0 +maxi=100 + +print "Think of a number between ";mini;" and ";maxi +print "Each time I guess a number you must state whether my" +print "guess was too high, too low, or equal to your number." +print + +while response$<>"=" + if not(mini<=maxi) then + print "Error" + exit while + end if + guess=int((maxi-mini)/2)+mini + print "My guess is ";guess;". Type L for low, H for high, = for correct." + input response$ + response$=upper$(response$) + select case response$ + case "L" + mini=guess+1 + case "H" + maxi=guess-1 + case "=" + print guess;" is correct." + exit while + case else + print "Your response was not helpful." + end select + wend +print "Thanks for playing." diff --git a/Task/Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.mathematica b/Task/Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.mathematica new file mode 100644 index 0000000000..6fb7891f71 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.mathematica @@ -0,0 +1,9 @@ +guessnumber[min0_, max0_] := + DynamicModule[{min = min0, max = max0, guess, correct = False}, + guess[] := Round@Mean@{min, max}; + Dynamic@If[correct, Row@{"Your number is ", guess[], "."}, + Column@{Row@{"I guess ", guess[], "."}, + Row@{Button["too high", max = guess[]], + Button["too low", min = guess[]], + Button["correct", correct = True]}}]]; +guessnumber[1, 100] diff --git a/Task/Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 b/Task/Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 new file mode 100644 index 0000000000..f44436bea4 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 @@ -0,0 +1,36 @@ +MODULE raden; + +IMPORT InOut; + +VAR done, ok : BOOLEAN; + guess, upp, low : CARDINAL; + res : CHAR; + +BEGIN + InOut.WriteString ("Choose a number between 0 and 1000."); + InOut.WriteLn; + InOut.WriteLn; + upp := 1000; + low := 0; + REPEAT + ok := FALSE; + guess := ( ( upp - low ) DIV 2 ) + low; + InOut.WriteString ("My guess is"); InOut.WriteCard (guess, 4); InOut.Write (11C); + InOut.WriteString ("How did I score? 'L' = too low, 'H' = too high, 'Q' = OK : "); + InOut.WriteBf; + REPEAT + InOut.Read (res); + res := CAP (res) + UNTIL (res = 'Q') OR (res = 'L') OR (res = 'H'); + CASE res OF + 'L' : low := guess | + 'H' : upp := guess + ELSE + ok := TRUE + END; + UNTIL ok; + InOut.WriteString ("So the number is"); InOut.WriteCard (guess, 4); + InOut.WriteLn; + InOut.WriteString ("Thanks for letting me play with you."); + InOut.WriteLn +END raden. diff --git a/Task/Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl b/Task/Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl new file mode 100644 index 0000000000..b9e0a81173 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +my $min = 1; +my $max = 99; + +print "=>> Think of a number between $min and $max and I'll guess it!\n +Press when are you ready... "; + +; + +my $guess = int(rand $max) + $min; +my $tries = 0; + +sub question { + my $guess = shift(); + print "\n=>> My guess is: $guess. Is your number higher, lower or equal? (h/l/e)\n> "; + ++$tries; +} + +question $guess; + +while (1) { + my $score = ; + + if (lc substr($score, 0, 1) eq 'h') { + $min = $guess + 1; + } + elsif (lc substr($score, 0, 1) eq 'l') { + $max = $guess; + } + elsif (lc substr($score, 0, 1) eq 'e') { + print "\nI knew it! It took me only $tries tries.\n"; + last; + } + else { + print "error: invalid score\n"; + } + + print "\nI gave up...\n" and last if $max <= $min; + + $guess = int(($max + $min) / 2); + + question $guess; +} diff --git a/Task/Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l b/Task/Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l new file mode 100644 index 0000000000..966c93012e --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l @@ -0,0 +1,19 @@ +(de guessTheNumber (Min Max) + (prinl "Think of a number between " Min " and " Max ".") + (prinl "On every guess of mine you should state whether my guess was") + (prinl "too high, too low, or equal to your number by typing 'h', 'l', Or '='") + (use Guess + (loop + (NIL (> Max Min) + (prinl "I think somthing is strange here...") ) + (prin + "My guess is " + (setq Guess (+ Min (/ (- Max Min) 2))) + ",is this correct? " ) + (flush) + (NIL + (case (uppc (car (line))) + ("H" (setq Max Guess)) + ("L" (setq Min Guess)) + ("=" (nil (prinl "I did it!"))) + (T (prinl "I do not understand that...")) ) ) ) ) ) diff --git a/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py b/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py new file mode 100644 index 0000000000..98a94e21a5 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py @@ -0,0 +1,29 @@ +inclusive_range = mn, mx = (1, 10) + +print('''\ +Think of a number between %i and %i and wait for me to guess it. +On every guess of mine you should state whether the guess was +too high, too low, or equal to your number by typing h, l, or = +''' % inclusive_range) + +i = 0 +while True: + i += 1 + guess = (mn+mx)//2 + txt = input("Guess %2i is: %2i. The score for which is (h,l,=): " + % (i, guess)).strip().lower()[0] + if txt not in 'hl=': + print(" I don't understand your input of '%s' ?" % txt) + continue + if txt == 'h': + mx = guess-1 + if txt == 'l': + mn = guess+1 + if txt == '=': + print(" Ye-Haw!!") + break + if (mn > mx) or (mn < inclusive_range[0]) or (mx > inclusive_range[1]): + print("Please check your scoring as I cannot find the value") + break + +print("\nThanks for keeping score.") diff --git a/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py b/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py new file mode 100644 index 0000000000..9469964372 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py @@ -0,0 +1,19 @@ +import bisect +try: input = raw_input +except: pass + +class GuessNumberFakeList(object): + def __getitem__(self, i): + s = input("Is your number less than or equal to %d?" % i) + return 0 if s.lower().startswith('y') else -1 + +LOWER, UPPER = 0, 100 + +if __name__ == "__main__": + print("""Instructions: +Think of integer number from %d (inclusive) to %d (exclusive) and +I will guess it. After each guess, I will ask you if it is less than +or equal to some number, and you will respond with "yes" or "no". +""" % (LOWER, UPPER)) + result = bisect.bisect_left(GuessNumberFakeList(), 0, LOWER, UPPER) + print("Your number is %d." % result) diff --git a/Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx b/Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx new file mode 100644 index 0000000000..09772a5dca --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx @@ -0,0 +1,28 @@ +/*REXX pgm to play guess-the-number (with itself) with positive integers*/ +parse arg low high . +if low=='' then low=1 +if high=='' then high=1000 +?=random(low,high) +say +try="Try to guess my integer (it's between" low 'and' high" inclusive)." + + do j=1 + say try; say + call guesser + select + when guess>? then info=right("It's too high.",40) + when guess? then info=right("It's too high.",40) + when guess $number +end + +low = 1 +high = 100 +$number = low + rand(high-low) + +puts "guess a number between #{low} and #{high}" +play(low, high) diff --git a/Task/Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss b/Task/Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss new file mode 100644 index 0000000000..122b1759ad --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss @@ -0,0 +1,18 @@ +(define minimum 1) +(define maximum 100) + +(display "Enter a number from ")(display minimum) +(display " to ")(display maximum)(display ": ") +(define number (read)) + +(define input "") + +(do ((guess (round (/ (+ maximum minimum) 2)) (round (/ (+ maximum minimum) 2)))) + ((string= input "=")) + (display "Is it ")(display guess)(display "?\n(h/l/=) > ") + (set! input (symbol->string (read))) + (if (string= input "h") (begin (display "OK...") + (set! maximum (- guess 1)))) + (if (string= input "l") (begin (display "OK...") + (set! minimum (+ guess 1))))) +(display "I was RIGHT!\n") diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st new file mode 100644 index 0000000000..927c5fb58c --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st @@ -0,0 +1,5 @@ +Object subclass: #NumberGuesser + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'Rosettacode' diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st new file mode 100644 index 0000000000..df5b7eab3d --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st @@ -0,0 +1,25 @@ +playBetween: low and: high + Transcript clear. + number := (low to: high) atRandom. + self playBetween: low and: high atTurn: 1. + +playBetween: low and: high atTurn: turn + | guess | + guess := (low + ((high - low) / 2)) asInteger. + self showGuessing: guess atTurn: turn. + true caseOf: { + [number > guess] -> + [self showNumberBeing: #low. self playBetween: guess and: high atTurn: turn+1 ]. + [number < guess] -> + [self showNumberBeing: #high. self playBetween: low and: guess atTurn: turn+1 ]. + [true] -> + [self showNumberFoundAtTurnNr: turn ] }. + +showGuessing: guess atTurn: turn + Transcript show: ('{1}. guessing: {2}' format: {turn asString. guess asString}). + +showNumberBeing: comparisonToken + Transcript show: ' ==> too ', (comparisonToken asString); cr. + +showNumberFoundAtTurnNr: turn + Transcript show: (' ==> found the number in {1} turn(s).' format: {turn asString}); cr. diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st new file mode 100644 index 0000000000..4f597e80fc --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st @@ -0,0 +1,10 @@ +playBetween: low and: high atTurn: turn + | guess | + guess := (low + ((high - low) / 2)) asInteger. + self showGuessing: guess atTurn: turn. + (guess = number) + ifTrue: [self showNumberFoundAtTurnNr: turn ] + ifFalse: [ + (number > guess) + ifTrue: [self showNumberBeing: #low. self playBetween: guess and: high atTurn: turn+1 ] + ifFalse: [self showNumberBeing: #high. self playBetween: low and: guess atTurn: turn+1]]. diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st new file mode 100644 index 0000000000..3dc16a47cf --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st @@ -0,0 +1,2 @@ +g := NumberGuesser new. +g playBetween: 1 and: 100. diff --git a/Task/Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl b/Task/Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl new file mode 100644 index 0000000000..f1a0fd5306 --- /dev/null +++ b/Task/Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl @@ -0,0 +1,22 @@ +set from 1 +set to 10 +fconfigure stdout -buffering none +while 1 { + set guess [expr {($from+$to) / 2}] + puts -nonewline "Guess: $guess\tWas it lower (<) equal (=) or higher (>)? " + switch -- [gets stdin] { + < { set from [expr {$guess + 1}] } + > { set to [expr {$guess - 1}] } + = { + puts "Found it: $guess" + break + } + default { + puts "What sort of a response was that?!" + } + } + if {$to < $from} { + puts "No answer possible?!" + break + } +} diff --git a/Task/Guess-the-number-With-feedback/0DESCRIPTION b/Task/Guess-the-number-With-feedback/0DESCRIPTION new file mode 100644 index 0000000000..a81f6148f7 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/0DESCRIPTION @@ -0,0 +1,4 @@ +The task is to write a game that follows the following rules: +:The computer will choose a number between given set limits and asks the player for repeated guesses until the player guesses the target number correctly. At each guess, the computer responds with whether the guess was higher than, equal to, or less than the target - or signals that the input was inappropriate. + +C.f: [[Guess the number/With Feedback (Player)]] diff --git a/Task/Guess-the-number-With-feedback/1META.yaml b/Task/Guess-the-number-With-feedback/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Guess-the-number-With-feedback/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/Guess-the-number-With-feedback/Ada/guess-the-number-with-feedback.ada b/Task/Guess-the-number-With-feedback/Ada/guess-the-number-with-feedback.ada new file mode 100644 index 0000000000..1dec349671 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Ada/guess-the-number-with-feedback.ada @@ -0,0 +1,40 @@ +with Ada.Numerics.Discrete_Random; +with Ada.Text_IO; +procedure Guess_Number_Feedback is + procedure Guess_Number (Lower_Limit : Integer; Upper_Limit : Integer) is + subtype Number is Integer range Lower_Limit .. Upper_Limit; + package Number_IO is new Ada.Text_IO.Integer_IO (Number); + package Number_RNG is new Ada.Numerics.Discrete_Random (Number); + Generator : Number_RNG.Generator; + My_Number : Number; + Your_Guess : Number; + begin + Number_RNG.Reset (Generator); + My_Number := Number_RNG.Random (Generator); + Ada.Text_IO.Put_Line ("Guess my number!"); + loop + Ada.Text_IO.Put ("Your guess: "); + Number_IO.Get (Your_Guess); + exit when Your_Guess = My_Number; + if Your_Guess > My_Number then + Ada.Text_IO.Put_Line ("Wrong, too high!"); + else + Ada.Text_IO.Put_Line ("Wrong, too low!"); + end if; + end loop; + Ada.Text_IO.Put_Line ("Well guessed!"); + end Guess_Number; + package Int_IO is new Ada.Text_IO.Integer_IO (Integer); + Lower_Limit : Integer; + Upper_Limit : Integer; +begin + loop + Ada.Text_IO.Put ("Lower Limit: "); + Int_IO.Get (Lower_Limit); + Ada.Text_IO.Put ("Upper Limit: "); + Int_IO.Get (Upper_Limit); + exit when Lower_Limit < Upper_Limit; + Ada.Text_IO.Put_Line ("Lower limit must be lower!"); + end loop; + Guess_Number (Lower_Limit, Upper_Limit); +end Guess_Number_Feedback; diff --git a/Task/Guess-the-number-With-feedback/AutoHotkey/guess-the-number-with-feedback.ahk b/Task/Guess-the-number-With-feedback/AutoHotkey/guess-the-number-with-feedback.ahk new file mode 100644 index 0000000000..0a8f58756d --- /dev/null +++ b/Task/Guess-the-number-With-feedback/AutoHotkey/guess-the-number-with-feedback.ahk @@ -0,0 +1,31 @@ +MinNum = 1 +MaxNum = 99999999999 + +Random, RandNum, %MinNum%, %MaxNum% +Loop +{ + InputBox, Guess, Number Guessing, Please enter a number between %MinNum% and %MaxNum%:,, 350, 130,,,,, %Guess% + If ErrorLevel + ExitApp + If Guess Is Not Integer + { + MsgBox, 16, Error, Invalid guess. + Continue + } + If Guess Not Between %MinNum% And %MaxNum% + { + MsgBox, 16, Error, Guess must be a number between %MinNum% and %MaxNum%. + Continue + } + If A_Index = 1 + TotalTime = %A_TickCount% + Tries = %A_Index% + If Guess = %RandNum% + Break + If Guess < %RandNum% + MsgBox, 64, Incorrect, The number guessed (%Guess%) was too low. + If Guess > %RandNum% + MsgBox, 64, Incorrect, The number guessed (%Guess%) was too high. +} +TotalTime := Round((A_TickCount - TotalTime) / 1000,1) +MsgBox, 64, Correct, The number %RandNum% was guessed in %Tries% tries, which took %TotalTime% seconds. diff --git a/Task/Guess-the-number-With-feedback/BASIC256/guess-the-number-with-feedback.basic256 b/Task/Guess-the-number-With-feedback/BASIC256/guess-the-number-with-feedback.basic256 new file mode 100644 index 0000000000..adfc4ba91b --- /dev/null +++ b/Task/Guess-the-number-With-feedback/BASIC256/guess-the-number-with-feedback.basic256 @@ -0,0 +1,14 @@ +Min = 5: Max = 15 +chosen = int(rand*(Max-Min+1)) + Min +print "Guess a whole number between "+Min+" and "+Max +do + input "Enter your number " ,guess + if guess < Min OR guess > Max then + print "That was an invalid number" + end + else + if guess < chosen then print "Sorry, your number was too low" + if guess > chosen then print "Sorry, your number was too high" + if guess = chosen then print "Well guessed!" + end if +until guess = chosen diff --git a/Task/Guess-the-number-With-feedback/BBC-BASIC/guess-the-number-with-feedback.bbc b/Task/Guess-the-number-With-feedback/BBC-BASIC/guess-the-number-with-feedback.bbc new file mode 100644 index 0000000000..e6015cd8ec --- /dev/null +++ b/Task/Guess-the-number-With-feedback/BBC-BASIC/guess-the-number-with-feedback.bbc @@ -0,0 +1,19 @@ + Min% = 1 + Max% = 10 + chosen% = RND(Max%-Min%+1) + Min% - 1 + REPEAT + PRINT "Guess a number between "; Min% " and " ;Max% ; + INPUT ": " guess% + CASE TRUE OF + WHEN guess% < Min% OR guess% > Max%: + PRINT "That was an invalid number" + WHEN guess% < chosen%: + PRINT "Sorry, your number was too low" + WHEN guess% > chosen%: + PRINT "Sorry, your number was too high" + OTHERWISE: + PRINT "Well guessed!" + EXIT REPEAT + ENDCASE + UNTIL FALSE + END diff --git a/Task/Guess-the-number-With-feedback/Brat/guess-the-number-with-feedback.brat b/Task/Guess-the-number-With-feedback/Brat/guess-the-number-with-feedback.brat new file mode 100644 index 0000000000..2b0bf034e3 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Brat/guess-the-number-with-feedback.brat @@ -0,0 +1,17 @@ +number = random 10 + +p "Guess a number between 1 and 10." + +until { + guess = ask("Guess: ").to_i + + true? (guess.null? || { guess > 10 || guess < 1 }) + { p "Please guess a number between 1 and 10."} + { true? guess == number + { p "Correct!"; true } + { true? guess < number + { p "Too low!" } + { p "Too high!" } + } + } +} diff --git a/Task/Guess-the-number-With-feedback/C++/guess-the-number-with-feedback.cpp b/Task/Guess-the-number-With-feedback/C++/guess-the-number-with-feedback.cpp new file mode 100644 index 0000000000..9d099a3f5c --- /dev/null +++ b/Task/Guess-the-number-With-feedback/C++/guess-the-number-with-feedback.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +int main() +{ + std::srand(std::time(0)); + int lower, upper, guess; + std::cout << "Enter lower limit: "; + std::cin >> lower; + std::cout << "Enter upper limit: "; + std::cin >> upper; + int random_number = lower + std::rand() % ((upper + 1) - lower); + + do + { + std::cout << "Guess what number I have: "; + std::cin >> guess; + if (guess > random_number) + std::cout << "Your guess is too high\n"; + else if (guess < random_number) + std::cout << "Your guess is too low\n"; + else + std::cout << "You got it!\n"; + } while (guess != random_number); + + return 0; +} diff --git a/Task/Guess-the-number-With-feedback/C-sharp/guess-the-number-with-feedback.cs b/Task/Guess-the-number-With-feedback/C-sharp/guess-the-number-with-feedback.cs new file mode 100644 index 0000000000..fa1bb9df41 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/C-sharp/guess-the-number-with-feedback.cs @@ -0,0 +1,39 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + const int from = 1; + const int to = 10; + + int randomNumber = new Random().Next(from, to); + int guessedNumber; + + Console.Write("The number is between {0} and {1}. ", from, to); + while (true) + { + Console.Write("Make a guess: "); + if (int.TryParse(Console.ReadLine(), out guessedNumber)) + { + if (guessedNumber == randomNumber) + { + Console.WriteLine("You guessed the right number!"); + break; + } + else + { + Console.WriteLine("Your guess was too {0}.", (guessedNumber > randomNumber) ? "high" : "low"); + } + } + else + { + Console.WriteLine("Input was not an integer."); + } + } + + Console.WriteLine(); + Console.WriteLine("Press any key to exit."); + Console.ReadKey(); + } +} diff --git a/Task/Guess-the-number-With-feedback/C/guess-the-number-with-feedback.c b/Task/Guess-the-number-With-feedback/C/guess-the-number-with-feedback.c new file mode 100644 index 0000000000..c98b27e337 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/C/guess-the-number-with-feedback.c @@ -0,0 +1,25 @@ +#include +#include +#include + +#define lower_limit 0 +#define upper_limit 100 + +int main(){ + int number, guess; + + srand( time( 0 ) ); + number = lower_limit + rand() % (upper_limit - lower_limit + 1); + + printf( "Guess the number between %d and %d: ", lower_limit, upper_limit ); + + while( scanf( "%d", &guess ) == 1 ){ + if( number == guess ){ + printf( "You guessed correctly!\n" ); + break; + } + printf( "Your guess was too %s.\nTry again: ", number < guess ? "high" : "low" ); + } + + return 0; +} diff --git a/Task/Guess-the-number-With-feedback/Clojure/guess-the-number-with-feedback.clj b/Task/Guess-the-number-With-feedback/Clojure/guess-the-number-with-feedback.clj new file mode 100644 index 0000000000..b76f20eb91 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Clojure/guess-the-number-with-feedback.clj @@ -0,0 +1,16 @@ +(defn guess-run [] + (let [start 1 + end 100 + target (+ start (rand-int (inc (- end start))))] + (printf "Guess a number between %d and %d" start end) + (loop [i 1] + (printf "Your guess %d:\n" i) + (let [ans (read)] + (if (cond + (not (number? ans)) (println "Invalid format") + (or (< ans start) (> ans end)) (println "Out of range") + (< ans target) (println "too low") + (> ans target) (println "too high") + :else true) + (println "Correct") + (recur (inc i))))))) diff --git a/Task/Guess-the-number-With-feedback/Common-Lisp/guess-the-number-with-feedback.lisp b/Task/Guess-the-number-With-feedback/Common-Lisp/guess-the-number-with-feedback.lisp new file mode 100644 index 0000000000..40d6a44384 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Common-Lisp/guess-the-number-with-feedback.lisp @@ -0,0 +1,16 @@ +(defun guess-the-number-feedback (&optional (min 1) (max 100)) + (let ((num-guesses 0) + (num (+ (random (1+ (- max min))) min)) + (guess nil)) + (format t "Try to guess a number from ~:d to ~:d!~%" min max) + (loop do (format t "Guess? ") + (incf num-guesses) + (setf guess (read)) + (format t "Your guess is ~[not a number.~;too small.~;too large.~;correct!~]~%" + (cond ((not (numberp guess)) 0) + ((< guess num) 1) + ((> guess num) 2) + ((= guess num) 3))) + until (and (numberp guess) + (= guess num))) + (format t "You got the number correct on the ~:r guess!~%" num-guesses))) diff --git a/Task/Guess-the-number-With-feedback/D/guess-the-number-with-feedback.d b/Task/Guess-the-number-With-feedback/D/guess-the-number-with-feedback.d new file mode 100644 index 0000000000..9ab323f3bb --- /dev/null +++ b/Task/Guess-the-number-With-feedback/D/guess-the-number-with-feedback.d @@ -0,0 +1,32 @@ +import std.stdio, std.random, std.typecons, std.conv, std.string; + +void main() { + immutable interval = tuple(1, 100); + + writefln("Guess my target number that is between " ~ + "%d and %d (inclusive).\n", interval.tupleof); + immutable target = uniform!"[]"(interval.tupleof); + + int answer = -1; + for (int i = 1; ; i++) { + writef("Your guess(%d): ", i); + immutable string txt = stdin.readln().strip(); + try { + answer = to!int(txt); + } catch (ConvException e) { + writefln(" I don't understand your input '%s'?", txt); + continue; + } + if (answer < interval[0] || answer > interval[1]) { + writeln(" Out of range!"); + continue; + } + if (answer == target) { + writeln(" Ye-Haw!!"); + break; + } + writeln(answer < target ? " Too low." : " Too high."); + } + + writeln("\nThanks for playing."); +} diff --git a/Task/Guess-the-number-With-feedback/Delphi/guess-the-number-with-feedback.delphi b/Task/Guess-the-number-With-feedback/Delphi/guess-the-number-with-feedback.delphi new file mode 100644 index 0000000000..e8025d5235 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Delphi/guess-the-number-with-feedback.delphi @@ -0,0 +1,85 @@ +program GuessTheNumber; + +{$APPTYPE CONSOLE} + +uses + SysUtils, + Math; + + +const + // Set min/max limits + min: Integer = 1; + max: Integer = 10; + +var + last, + val, + inp: Integer; + s: string; + + // Initialise new game + procedure NewGame; + begin + // Make sure this number isn't the same as the last one + repeat + val := RandomRange(min,max); + until + val <> last; + + // Save this number + last := val; + Writeln('Guess a number between ', min, ' and ', max, ' [Answer = ', val, ']'); + end; + +begin + // Initialise the random number generator with a random value + Randomize; + + // Initialise last number + last := 0; + + // Initialise user input + s := ''; + + // Start game + NewGame; + + // Loop + repeat + // User input + Readln(s); + + // Validate - checxk if input is a number + if TryStrToInt(s,inp) then + begin + // Is it the right number? + if (inp = val) then + begin + // Yes - request a new game + Writeln('Correct! Another go? Y/N'); + Readln(s); + if SameText(s,'Y') then + // Start new game + NewGame + else + Exit; + end + else + // Input too low/high + if (inp < val) then + Writeln('Too low! Try again...') + else + if (inp > val) then + Writeln('Too high! Try again...'); + end + else + // Input invalid + if not SameText(s,'bored') then + Writeln('Invalid input! Try again...'); + + until + SameText(s,'bored'); + + +end. diff --git a/Task/Guess-the-number-With-feedback/Ela/guess-the-number-with-feedback.ela b/Task/Guess-the-number-With-feedback/Ela/guess-the-number-with-feedback.ela new file mode 100644 index 0000000000..dbf8419b24 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Ela/guess-the-number-with-feedback.ela @@ -0,0 +1,31 @@ +open random core console string datetime read + +rnd' v = rnd s 1 v where s = milliseconds <| datetime.now() + +start () = + match bound() with + Some v = writen ("Guess a number from 1 to " ++ show v) `seq` (guess <| rnd' v) + None = start() + +bound () = + writen "What's the upper bound?" `seq` (bound' <| readStr <| readn()) + where bound' v | v <= 0 = writen "Bound should be greater than 0." `seq` None + | else = Some v + +success v = + writen "Correct! Do you want to continue? (Y/N)" `seq` ask() + where ask () = read <| upper <| readn() + read "Y" = start() + read "N" = writen "Bye!" + read x = writen "Say what?" `seq` ask() + +failed v n = + writen ("No, this is not " ++ show v ++ ". " ++ hint) `seq` guess n + where hint | v < n = "Try bigger." + | else = "Try smaller." + +guess n = g <| readStr <| readn() + where g v | v == n = success v + | else = failed v n + +start() diff --git a/Task/Guess-the-number-With-feedback/Euphoria/guess-the-number-with-feedback.euphoria b/Task/Guess-the-number-With-feedback/Euphoria/guess-the-number-with-feedback.euphoria new file mode 100644 index 0000000000..6302477cf9 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Euphoria/guess-the-number-with-feedback.euphoria @@ -0,0 +1,19 @@ +include get.e + +constant lower_limit = 0, upper_limit = 100 + +integer number, guess +number = rand(upper_limit-lower_limit+1)+lower_limit + +printf(1,"Guess the number between %d and %d: ", lower_limit & upper_limit) +while 1 do + guess = floor(prompt_number("", lower_limit & upper_limit)) + if number = guess then + puts(1,"You guessed correctly!\n") + exit + elsif number < guess then + puts(1,"You guessed too high.\nTry again: ") + else + puts(1,"You guessed to low.\nTry again: ") + end if +end while diff --git a/Task/Guess-the-number-With-feedback/Fantom/guess-the-number-with-feedback.fantom b/Task/Guess-the-number-With-feedback/Fantom/guess-the-number-with-feedback.fantom new file mode 100644 index 0000000000..1d441d5f06 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Fantom/guess-the-number-with-feedback.fantom @@ -0,0 +1,36 @@ +class Main +{ + public static Void main () + { + Int lowerLimit := 1 + Int higherLimit := 100 + + Int target := (lowerLimit..higherLimit).random + Int guess + while (guess != target) + { + echo ("Enter a guess: ") + try + { + // read in a line of input, and try to interpret as an Int + guess = Env.cur.in.readLine.trim.toInt + if (guess == target) + { + echo ("Well guessed!") + } + else if (guess < target) + { + echo ("Failed - your guess is too small") + } + else // if (guess > target) + { + echo ("Failed - your guess is too large") + } + } + catch (Err e) + { + echo ("Your guess must be an integer") + } + } + } +} diff --git a/Task/Guess-the-number-With-feedback/Fortran/guess-the-number-with-feedback.f b/Task/Guess-the-number-With-feedback/Fortran/guess-the-number-with-feedback.f new file mode 100644 index 0000000000..8654843cad --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Fortran/guess-the-number-with-feedback.f @@ -0,0 +1,27 @@ +program Guess_a_number + implicit none + + integer, parameter :: limit = 100 + integer :: guess, number + real :: rnum + + write(*, "(a, i0, a)") "I have chosen a number between 1 and ", limit, & + " and you have to try to guess it." + write(*, "(a/)") "I will score your guess by indicating whether it is higher, lower or the same as that number" + + call random_seed + call random_number(rnum) + number = rnum * limit + 1 + do + write(*, "(a)", advance="no") "Enter quess: " + read*, guess + if(guess < number) then + write(*, "(a/)") "That is lower" + else if(guess > number) then + write(*, "(a/)") "That is higher" + else + write(*, "(a)") "That is correct" + exit + end if + end do +end program diff --git a/Task/Guess-the-number-With-feedback/Go/guess-the-number-with-feedback.go b/Task/Guess-the-number-With-feedback/Go/guess-the-number-with-feedback.go new file mode 100644 index 0000000000..825c327047 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Go/guess-the-number-with-feedback.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +const lower, upper = 1, 100 + +func main() { + fmt.Printf("Guess integer number from %d to %d: ", lower, upper) + rand.Seed(time.Now().Unix()) + n := rand.Intn(upper-lower+1) + lower + for guess := n; ; { + switch _, err := fmt.Scan(&guess); { + case err != nil: + fmt.Println("\n", err, "So, bye.") + return + case guess < n: + fmt.Print("Too low. Try again: ") + case guess > n: + fmt.Print("Too high. Try again: ") + default: + fmt.Println("Well guessed!") + return + } + } +} diff --git a/Task/Guess-the-number-With-feedback/Haskell/guess-the-number-with-feedback.hs b/Task/Guess-the-number-With-feedback/Haskell/guess-the-number-with-feedback.hs new file mode 100644 index 0000000000..5d925c48ca --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Haskell/guess-the-number-with-feedback.hs @@ -0,0 +1,23 @@ +import Control.Monad +import System.Random + +-- Repeat the action until the predicate is true. +until_ act pred = act >>= pred >>= flip unless (until_ act pred) + +answerIs ans guess = + case compare ans guess of + LT -> putStrLn "Too high. Guess again." >> return False + EQ -> putStrLn "You got it!" >> return True + GT -> putStrLn "Too low. Guess again." >> return False + +-- Repeatedly read until the input *starts* with a number. (Since +-- we use "reads" we allow garbage to follow it, though.) +ask = do line <- getLine + case reads line of + ((num,_):_) -> return num + otherwise -> putStrLn "Please enter a number." >> ask + +main = do + ans <- randomRIO (1,100) :: IO Int + putStrLn "Try to guess my secret number between 1 and 100." + ask `until_` answerIs ans diff --git a/Task/Guess-the-number-With-feedback/Icon/guess-the-number-with-feedback.icon b/Task/Guess-the-number-With-feedback/Icon/guess-the-number-with-feedback.icon new file mode 100644 index 0000000000..81e37b205c --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Icon/guess-the-number-with-feedback.icon @@ -0,0 +1,20 @@ +procedure main() + smallest := 5 + highest := 25 + n := smallest-1 + ?(1+highest-smallest) + repeat { + writes("Pick a number from ", smallest, " through ", highest, ": ") + guess := read () + + if n = numeric(guess) + then { + write ("Well guessed!") + exit () + } + else if n < numeric(guess) + then write ("Your guess is too high") + else if n > numeric(guess) + then write ("Your guess is too low") + else write ("Did you enter a number?") + } +end diff --git a/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-1.j b/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-1.j new file mode 100644 index 0000000000..6de66a4049 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-1.j @@ -0,0 +1,11 @@ +require 'misc' +game=: verb define + assert. y -: 1 >. <.{.y + n=: 1 + ?y + smoutput 'Guess my integer, which is bounded by 1 and ',":y + whilst. -. x -: n do. + x=. {. 0 ". prompt 'Guess: ' + if. 0 -: x do. 'Giving up.' return. end. + smoutput (*x-n){::'You win.';'Too high.';'Too low.' + end. +) diff --git a/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-2.j b/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-2.j new file mode 100644 index 0000000000..38dbe12acf --- /dev/null +++ b/Task/Guess-the-number-With-feedback/J/guess-the-number-with-feedback-2.j @@ -0,0 +1,12 @@ + game 100 +Guess my integer, which is bounded by 1 and 100 +Guess: 64 +Too high. +Guess: 32 +Too low. +Guess: 48 +Too high. +Guess: 40 +Too low. +Guess: 44 +You win. diff --git a/Task/Guess-the-number-With-feedback/Java/guess-the-number-with-feedback.java b/Task/Guess-the-number-With-feedback/Java/guess-the-number-with-feedback.java new file mode 100644 index 0000000000..5b7b3f3520 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Java/guess-the-number-with-feedback.java @@ -0,0 +1,28 @@ +import java.util.Random; +import java.util.Scanner; +public class Main +{ + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + Random random = new Random(); + long from = 1; + long to = 100; + int randomNumber = random.nextInt(to - from + 1) + from; + int guessedNumber = 0; + + System.out.printf("The number is between %d and %d.\n", from, to); + + do + { + System.out.print("Guess what the number is: "); + guessedNumber = scan.nextInt(); + if (guessedNumber > randomNumber) + System.out.println("Your guess is too high!"); + else if (guessedNumber < randomNumber) + System.out.println("Your guess is too low!"); + else + System.out.println("You got it!"); + } while (guessedNumber != randomNumber); + } +} diff --git a/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-1.js b/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-1.js new file mode 100644 index 0000000000..f18ede6414 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-1.js @@ -0,0 +1,7 @@ +

Pick a number between 1 and 100.

+
+ + +
+

+ diff --git a/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-4.js b/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-4.js new file mode 100644 index 0000000000..7aa3cdf6c2 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/JavaScript/guess-the-number-with-feedback-4.js @@ -0,0 +1,44 @@ +#!/usr/bin/env js + +function main() { + guessTheNumber(1, 100); +} + +function guessTheNumber(low, high) { + var num = randOnRange(low, high); + var guessCount = 0; + + function checkGuess(n) { + if (n < low || n > high) { + print('That number is not between ' + low + ' and ' + high + '!'); + return false; + } + + if (n == num) { + print('You got it in ' + String(guessCount) + ' tries.'); + return true; + } + + if (n < num) { + print('Too low.'); + } else { + print('Too high.'); + } + return false; + } + + print('I have picked a number between ' + low + ' and ' + high + '. Try to guess it!'); + while (true) { + guessCount++; + putstr(" Your guess: "); + var n = parseInt(readline()); + if (checkGuess(n)) break; + } +} + +function randOnRange(low, high) { + var r = Math.random(); + return Math.floor(r * (high - low + 1)) + low; +} + +main(); diff --git a/Task/Guess-the-number-With-feedback/Liberty-BASIC/guess-the-number-with-feedback.liberty b/Task/Guess-the-number-With-feedback/Liberty-BASIC/guess-the-number-with-feedback.liberty new file mode 100644 index 0000000000..3fa83de210 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Liberty-BASIC/guess-the-number-with-feedback.liberty @@ -0,0 +1,16 @@ +[start] + target = int( rnd( 1) * 100) +1 + +while 1 + do + input "Guess a whole number between 1 and 100. To finish, type 'exit' "; b$ + if b$ ="exit" then print "Thank you for playing!": end + c = val( b$) + ok =( c =int( c)) and ( c >=1) and ( c <=100) + if ok =0 then notice "Invalid data. Integers 1 to 100 only." + loop until ok <>0 + + if c =target then print " You guessed correctly.": print: goto [start] + if c target then print " Your guess was too high." +wend diff --git a/Task/Guess-the-number-With-feedback/Locomotive-Basic/guess-the-number-with-feedback.bas b/Task/Guess-the-number-With-feedback/Locomotive-Basic/guess-the-number-with-feedback.bas new file mode 100644 index 0000000000..4ded824b27 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Locomotive-Basic/guess-the-number-with-feedback.bas @@ -0,0 +1,12 @@ +10 CLS:RANDOMIZE TIME +20 PRINT "Please specify lower and upper limits":guess=0 +30 INPUT " (must be positive integers) :", first, last +40 IF first<1 OR last<1 THEN 20 +50 num=INT(RND*(last-first+1)+first) +60 WHILE num<>guess +70 INPUT "Your guess? ", guess +80 IF guessnum THEN PRINT "too large!" +100 WEND +110 INPUT "That's correct! Another game (y/n)? ", yn$ +120 IF yn$="y" THEN 20 diff --git a/Task/Guess-the-number-With-feedback/Logo/guess-the-number-with-feedback.logo b/Task/Guess-the-number-With-feedback/Logo/guess-the-number-with-feedback.logo new file mode 100644 index 0000000000..b6499c733f --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Logo/guess-the-number-with-feedback.logo @@ -0,0 +1,25 @@ +to guess [:max 100] + local "number + make "number random :max + local "guesses + make "guesses 0 + + local "guess + forever [ + (type [Guess my number! \(range 1 -\ ] :max "\):\ ) + make "guess first readlist + ifelse (or (not numberp :guess) (lessp :guess 1) (greaterp :guess :max)) [ + print sentence [Guess must be a number between 1 and] (word :max ".) + ] [ + make "guesses (:guesses + 1) + ifelse lessp :guess :number [ + print [Too low!] + ] [ifelse equalp :guess :number [ + (print [You got it in] :guesses "guesses!) + stop + ] [ + print [Too high!] + ]] + ] + ] +end diff --git a/Task/Guess-the-number-With-feedback/Lua/guess-the-number-with-feedback.lua b/Task/Guess-the-number-With-feedback/Lua/guess-the-number-with-feedback.lua new file mode 100644 index 0000000000..8ed67d37ad --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Lua/guess-the-number-with-feedback.lua @@ -0,0 +1,22 @@ +math.randomseed(os.time()) +me_win=false +my_number=math.random(1,10) +while me_win==false do + print "Guess my number from 1 to 10:" + your_number = io.stdin:read'*l' + if type(tonumber(your_number))=="number" then + your_number=tonumber(your_number) + if your_number>10 or your_number<1 then + print "Your number was not between 1 and 10, try again." + elseif your_number>my_number then + print "Your number is greater than mine, try again." + elseif your_number number, "Too high.Guess again.", + "Too low.Guess again.", + "Guess a number between " <> ToString@min <> " and " <> + ToString@max <> "."]]]; + CreateDialog[{"Well guessed!", DefaultButton[]}]]; +guessnumber[1, 10] diff --git a/Task/Guess-the-number-With-feedback/Mirah/guess-the-number-with-feedback.mirah b/Task/Guess-the-number-With-feedback/Mirah/guess-the-number-with-feedback.mirah new file mode 100644 index 0000000000..00bd00e7b5 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Mirah/guess-the-number-with-feedback.mirah @@ -0,0 +1,26 @@ +def getInput:int + s = System.console.readLine() + Integer.parseInt(s) +end + +number = int(Math.random() * 10 + 1) + +puts "Guess the number between 1 and 10" + +guessed = false + +while !guessed do + begin + userNumber = getInput + if userNumber == number + guessed = true + puts "You guessed it." + elsif userNumber > number + puts "Too high." + else + puts "Too low." + end + rescue NumberFormatException => e + puts "Please enter an integer." + end +end diff --git a/Task/Guess-the-number-With-feedback/Modula-2/guess-the-number-with-feedback.mod2 b/Task/Guess-the-number-With-feedback/Modula-2/guess-the-number-with-feedback.mod2 new file mode 100644 index 0000000000..0ecbf35bc1 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Modula-2/guess-the-number-with-feedback.mod2 @@ -0,0 +1,40 @@ +MODULE guessf; + +IMPORT InOut, Random, NumConv, Strings; + +VAR number, guess : CARDINAL; + input : Strings.String; + OK, Done : BOOLEAN; + +BEGIN + number := Random.nr (1000); + InOut.WriteString ("I have chosen a number below 1000; please try to guess it."); + InOut.WriteLn; + REPEAT + REPEAT + InOut.WriteString ("Enter your guess : "); InOut.WriteBf; + InOut.ReadString (input); + NumConv.Str2Num (guess, 10, input, OK); + IF NOT OK THEN + InOut.WriteString (input); + InOut.WriteString (" is not a valid number..."); + InOut.WriteLn + END + UNTIL OK; + InOut.WriteString ("Your guess is "); + IF number = guess THEN + Done := TRUE; + InOut.WriteString ("spot on!") + ELSE + Done := FALSE; + IF guess > number THEN + InOut.WriteString ("too high.") + ELSE + InOut.WriteString ("too low.") + END + END; + InOut.WriteLn + UNTIL Done; + InOut.WriteString ("Thank you for playing; have a nice day!"); + InOut.WriteLn +END guessf. diff --git a/Task/Guess-the-number-With-feedback/PHP/guess-the-number-with-feedback.php b/Task/Guess-the-number-With-feedback/PHP/guess-the-number-with-feedback.php new file mode 100644 index 0000000000..d81421147a --- /dev/null +++ b/Task/Guess-the-number-With-feedback/PHP/guess-the-number-with-feedback.php @@ -0,0 +1,50 @@ +"; + if ($guess < $number) + { + echo "Your guess is too low"; + } + elseif($guess > $number) + { + echo "Your guess is too high"; + } + elseif($guess == $number) + { + echo "You got the correct number!"; + } + +} +?> + + + + + + Guess A Number + + + +
+
+ + + +
+ + diff --git a/Task/Guess-the-number-With-feedback/Perl/guess-the-number-with-feedback.pl b/Task/Guess-the-number-With-feedback/Perl/guess-the-number-with-feedback.pl new file mode 100644 index 0000000000..8835b566f9 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Perl/guess-the-number-with-feedback.pl @@ -0,0 +1,19 @@ +sub prompt { + my $prompt = shift; + while (1) { + print "\n", $prompt, ": "; + # type ^D, q, quit, quagmire, etc to quit + defined($_ = ) and !/^\s*q/ or exit; + + return $_ if /^\s*\d+\s*$/s; + $prompt = "Please give a non-negative integer"; + } +} + +my $tgt = int(rand prompt("Hola! Please tell me the upper bound") + 1); +my $tries = 1; + +$tries++, print "You guessed too ", ($_ == -1 ? "high" : "low"), ".\n" + while ($_ = $tgt <=> prompt "Your guess"); + +print "Correct! You guessed it after $tries tries.\n"; diff --git a/Task/Guess-the-number-With-feedback/PicoLisp/guess-the-number-with-feedback.l b/Task/Guess-the-number-With-feedback/PicoLisp/guess-the-number-with-feedback.l new file mode 100644 index 0000000000..3b5cc3cc3c --- /dev/null +++ b/Task/Guess-the-number-With-feedback/PicoLisp/guess-the-number-with-feedback.l @@ -0,0 +1,19 @@ +(de guessTheNumber () + (use (Low High Guess) + (until + (and + (prin "Enter low limit : ") + (setq Low (read)) + (prin "Enter high limit: ") + (setq High (read)) + (> High Low) ) ) + (seed (time)) + (let Number (rand Low High) + (loop + (prin "Guess what number I have: ") + (T (= Number (setq Guess (read))) + (prinl "You got it!") ) + (prinl + "Your guess is too " + (if (> Number Guess) "low" "high") + "." ) ) ) ) ) diff --git a/Task/Guess-the-number-With-feedback/Python/guess-the-number-with-feedback.py b/Task/Guess-the-number-With-feedback/Python/guess-the-number-with-feedback.py new file mode 100644 index 0000000000..bc96c28d27 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Python/guess-the-number-with-feedback.py @@ -0,0 +1,26 @@ +import random + +inclusive_range = (1, 100) + +print("Guess my target number that is between %i and %i (inclusive).\n" + % inclusive_range) +target = random.randint(*inclusive_range) +answer, i = None, 0 +while answer != target: + i += 1 + txt = input("Your guess(%i): " % i) + try: + answer = int(txt) + except ValueError: + print(" I don't understand your input of '%s' ?" % txt) + continue + if answer < inclusive_range[0] or answer > inclusive_range[1]: + print(" Out of range!") + continue + if answer == target: + print(" Ye-Haw!!") + break + if answer < target: print(" Too low.") + if answer > target: print(" Too high.") + +print("\nThanks for playing.") diff --git a/Task/Guess-the-number-With-feedback/REXX/guess-the-number-with-feedback.rexx b/Task/Guess-the-number-With-feedback/REXX/guess-the-number-with-feedback.rexx new file mode 100644 index 0000000000..2aecd01e6c --- /dev/null +++ b/Task/Guess-the-number-With-feedback/REXX/guess-the-number-with-feedback.rexx @@ -0,0 +1,36 @@ +/*REXX program that plays the guessing (the number) game. */ + low=1 /*lower range for guessing game. */ +high=100 /*upper range for guessing game. */ +try=0 /*number of valid attempts. */ +r=random(1,100) /*get a random # (low ──> high).*/ + lows='too_low too_small too_little below under underneath too_puny' +highs='too_high too_big too_much above over over_the_top too_huge' +er!='*** error! ***' +prompt=centre("guess the number, it's between" low 'and', + high '(inclusive) ───or─── Quit:',79,"─") + + do ask=0; say; say prompt; say; pull g; g=space(g); say + do validate=0 + select + when g=='' then iterate ask + when abbrev('QUIT',g,1) then exit + when words(g)\==1 then say er! 'too many numbers entered:' g + when \datatype(g,'N') then say er! g "isn't numeric" + when \datatype(g,'W') then say er! g "isn't a whole number" + when ghigh then say er! g 'is above the higher limit of' high + otherwise leave validate + end /*select*/ + iterate ask + end /*validate*/ + + try=try+1 + if g=r then leave + if g>r then what=word(highs,random(1,words(highs))) + else what=word( lows,random(1,words( lows))) + say 'your guess of' g "is" translate(what'.',,"_") + end /*ask*/ + +if try==1 then say 'Gadzooks!!! You guessed the number right away!' + else say 'Congratulations!, you guessed the number in' try "tries." + /*stick a fork in it, we're done.*/ diff --git a/Task/Guess-the-number-With-feedback/Ruby/guess-the-number-with-feedback.rb b/Task/Guess-the-number-With-feedback/Ruby/guess-the-number-with-feedback.rb new file mode 100644 index 0000000000..fa8da08d97 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Ruby/guess-the-number-with-feedback.rb @@ -0,0 +1,21 @@ +number = rand(1..10) + +puts "Guess the number between 1 and 10" + +guessed = false + +until guessed do + begin + user_number = Integer(gets) + if user_number == number + guessed = true + puts "You guessed it." + elsif user_number > number + puts "Too high." + else + puts "Too low." + end + rescue ArgumentError => e + puts "Please enter an integer." + end +end diff --git a/Task/Guess-the-number-With-feedback/Scheme/guess-the-number-with-feedback.ss b/Task/Guess-the-number-With-feedback/Scheme/guess-the-number-with-feedback.ss new file mode 100644 index 0000000000..5f789b2d97 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Scheme/guess-the-number-with-feedback.ss @@ -0,0 +1,18 @@ +(define maximum 5) +(define minimum -5) +(define number (+ (random (- (+ maximum 1) minimum)) minimum)) + +(display "Pick a number from ") +(display minimum) +(display " through ") +(display maximum) +(display ".\n> ") +(do ((guess (read) (read))) ((eq? guess number)) + (if (or (>= guess maximum) (< guess minimum)) + (display "Out of range!\n> ") + (begin + (if (> guess number) + (display "Too high!\n> ")) + (if (< guess number) + (display "Too low!\n> "))))) +(display "Correct!\n") diff --git a/Task/Guess-the-number-With-feedback/Tcl/guess-the-number-with-feedback.tcl b/Task/Guess-the-number-With-feedback/Tcl/guess-the-number-with-feedback.tcl new file mode 100644 index 0000000000..cf85c65465 --- /dev/null +++ b/Task/Guess-the-number-With-feedback/Tcl/guess-the-number-with-feedback.tcl @@ -0,0 +1,20 @@ +set from 1 +set to 10 +set target [expr {int(rand()*($to-$from+1) + $from)}] +puts "I have thought of a number from $from to $to." +puts "Try to guess it!" +while 1 { + puts -nonewline "Enter your guess: " + flush stdout + gets stdin guess + if {![string is int -strict $guess] || $guess < $from || $guess > $to} { + puts "Your guess should be an integer from $from to $to (inclusive)." + } elseif {$guess > $target} { + puts "Your guess was too high. Try again!" + } elseif {$guess < $target} { + puts "Your guess was too low. Try again!" + } else { + puts "Well done! You guessed it." + break + } +} diff --git a/Task/Guess-the-number/0DESCRIPTION b/Task/Guess-the-number/0DESCRIPTION new file mode 100644 index 0000000000..f9117028f2 --- /dev/null +++ b/Task/Guess-the-number/0DESCRIPTION @@ -0,0 +1,5 @@ +The task is to write a program where the program chooses a number between 1 and 10. A player is then prompted to enter a guess. If the player guess wrong then the prompt appears again until the guess is correct. When the player has made a successful guess the computer will give a "Well guessed!" message, and the program will exit. + +A [[:Category:Conditional loops|conditional loop]] may be used to repeat the guessing until the user is correct. + +Cf. [[Guess the number/With Feedback]], [[Bulls and cows]] diff --git a/Task/Guess-the-number/1META.yaml b/Task/Guess-the-number/1META.yaml new file mode 100644 index 0000000000..9b33988e1d --- /dev/null +++ b/Task/Guess-the-number/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Conditional loops +- Randomness +note: Games diff --git a/Task/Guess-the-number/ALGOL-68/guess-the-number.alg b/Task/Guess-the-number/ALGOL-68/guess-the-number.alg new file mode 100644 index 0000000000..042053748b --- /dev/null +++ b/Task/Guess-the-number/ALGOL-68/guess-the-number.alg @@ -0,0 +1,19 @@ +main: +( + INT n; + INT g; + n := ENTIER (random*10+1); + PROC puts = (STRING string)VOID: putf(standout, ($gl$,string)); + puts("I'm thinking of a number between 1 and 10."); + puts("Try to guess it! "); + DO + readf(($g$, g)); + IF g = n THEN break + ELSE + puts("That's not my number. "); + puts("Try another guess!") + FI + OD; + break: + puts("You have won! ") +) diff --git a/Task/Guess-the-number/Ada/guess-the-number.ada b/Task/Guess-the-number/Ada/guess-the-number.ada new file mode 100644 index 0000000000..aec4308712 --- /dev/null +++ b/Task/Guess-the-number/Ada/guess-the-number.ada @@ -0,0 +1,21 @@ +with Ada.Numerics.Discrete_Random; +with Ada.Text_IO; +procedure Guess_Number is + subtype Number is Integer range 1 .. 10; + package Number_IO is new Ada.Text_IO.Integer_IO (Number); + package Number_RNG is new Ada.Numerics.Discrete_Random (Number); + Generator : Number_RNG.Generator; + My_Number : Number; + Your_Guess : Number; +begin + Number_RNG.Reset (Generator); + My_Number := Number_RNG.Random (Generator); + Ada.Text_IO.Put_Line ("Guess my number!"); + loop + Ada.Text_IO.Put ("Your guess: "); + Number_IO.Get (Your_Guess); + exit when Your_Guess = My_Number; + Ada.Text_IO.Put_Line ("Wrong, try again!"); + end loop; + Ada.Text_IO.Put_Line ("Well guessed!"); +end Guess_Number; diff --git a/Task/Guess-the-number/Aime/guess-the-number.aime b/Task/Guess-the-number/Aime/guess-the-number.aime new file mode 100644 index 0000000000..019fbe72ce --- /dev/null +++ b/Task/Guess-the-number/Aime/guess-the-number.aime @@ -0,0 +1,21 @@ +file f; +integer n; +text s; + +f_affix(f, "/dev/stdin"); + +n = irand(1, 10); +o_text("I'm thinking of a number between 1 and 10.\n"); +o_text("Try to guess it!\n"); +while (1) { + f_look(f, "0123456789"); + f_near(f, "0123456789", s); + if (atoi(s) != n) { + o_text("That's not my number.\n"); + o_text("Try another guess!\n"); + } else { + break; + } +} + +o_text("You have won!\n"); diff --git a/Task/Guess-the-number/AutoHotkey/guess-the-number.ahk b/Task/Guess-the-number/AutoHotkey/guess-the-number.ahk new file mode 100644 index 0000000000..4b01cf0e02 --- /dev/null +++ b/Task/Guess-the-number/AutoHotkey/guess-the-number.ahk @@ -0,0 +1,14 @@ +Random, rand, 1, 10 ; This stores a number between 1 and 10 in the var rand using the Mersenne Twister +msgbox I am thinking of a number between 1 and 10. + +loop +{ + InputBox, guess, Guess the number, Type in a number from 1 to 10 + If (guess = rand) + { + msgbox Well Guessed! + Break ; exits loop + } + Else + Msgbox Try again. +} diff --git a/Task/Guess-the-number/AutoIt/guess-the-number.autoit b/Task/Guess-the-number/AutoIt/guess-the-number.autoit new file mode 100644 index 0000000000..9b8b2d2bfa --- /dev/null +++ b/Task/Guess-the-number/AutoIt/guess-the-number.autoit @@ -0,0 +1,6 @@ +$irnd = Random(1, 10, 1) +$iinput = -1 +While $input <> $irnd + $iinput = InputBox("Choose a number", "Please chosse a Number between 1 and 10") +WEnd +MsgBox(0, "Success", "Well guessed!") diff --git a/Task/Guess-the-number/BASIC/guess-the-number-1.bas b/Task/Guess-the-number/BASIC/guess-the-number-1.bas new file mode 100644 index 0000000000..49c036043a --- /dev/null +++ b/Task/Guess-the-number/BASIC/guess-the-number-1.bas @@ -0,0 +1,9 @@ +10 LET n=INT (RND*10)+1 +20 PRINT "I have thought of a number." +30 PRINT "Try to guess it!" +40 INPUT "Enter your guess: ";g +50 IF g=n THEN GO TO 100 +60 PRINT "Your guess was wrong. Try again!" +70 GO TO 40 + +100 PRINT "Well done! You guessed it." diff --git a/Task/Guess-the-number/BASIC/guess-the-number-2.bas b/Task/Guess-the-number/BASIC/guess-the-number-2.bas new file mode 100644 index 0000000000..e8be5d44e1 --- /dev/null +++ b/Task/Guess-the-number/BASIC/guess-the-number-2.bas @@ -0,0 +1,37 @@ +supervisor: +GOSUB initialize +GOSUB guessing +GOTO continue + +initialize: +RANDOMIZE TIMER +n = 0: r = INT(RND * 100 + 1): g = 0: c$ = "" +RETURN + +guessing: +WHILE g <> r + INPUT "Pick a number between 1 and 100"; g + IF g = r THEN + PRINT "You got it!" + n = n + 1 + PRINT "It took "; n; "tries to pick the right number." + ELSEIF g < r THEN + PRINT "Try a larger number." + n = n + 1 + ELSE + PRINT "Try a smaller number." + n = n + 1 + END IF +WEND +RETURN + +continue: +WHILE c$ <> "YES" AND c$ <> "NO" + INPUT "Do you want to continue? (YES/NO)"; c$ + c$ = UCASE$(c$) + IF c$ = "YES" THEN + GOTO supervisor + ELSEIF c$ = "NO" THEN + STOP + END IF +WEND diff --git a/Task/Guess-the-number/BASIC256/guess-the-number.basic256 b/Task/Guess-the-number/BASIC256/guess-the-number.basic256 new file mode 100644 index 0000000000..888b2e1c23 --- /dev/null +++ b/Task/Guess-the-number/BASIC256/guess-the-number.basic256 @@ -0,0 +1,9 @@ +n = int(rand * 10) + 1 +print "I am thinking of a number from 1 to 10" +do + input "Guess it > ",g + if g <> n then + print "No luck, Try again." + endif +until g = n +print "Yea! You guessed my number." diff --git a/Task/Guess-the-number/BBC-BASIC/guess-the-number.bbc b/Task/Guess-the-number/BBC-BASIC/guess-the-number.bbc new file mode 100644 index 0000000000..edab18367d --- /dev/null +++ b/Task/Guess-the-number/BBC-BASIC/guess-the-number.bbc @@ -0,0 +1,10 @@ + choose% = RND(10) + REPEAT + INPUT "Guess a number between 1 and 10: " guess% + IF guess% = choose% THEN + PRINT "Well guessed!" + END + ELSE + PRINT "Sorry, try again" + ENDIF + UNTIL FALSE diff --git a/Task/Guess-the-number/Batch-File/guess-the-number.bat b/Task/Guess-the-number/Batch-File/guess-the-number.bat new file mode 100644 index 0000000000..6272d66fc3 --- /dev/null +++ b/Task/Guess-the-number/Batch-File/guess-the-number.bat @@ -0,0 +1,26 @@ +@ECHO OFF +setlocal EnableDelayedExpansion +SET max=10 +SET min=1 + +:begin + SET /A rand=%random% %% (max - min + 1)+ min + SET guess= + SET /P guess=Pick a number between 1 and 10: + +:loop + IF "!guess!" == "" ( + GOTO end + ) + SET /A guess=!guess! + IF !guess! equ !rand! ( + ECHO Well guessed^^! + GOTO end + ) + SET guess= + SET /P guess=Nope, guess again: + GOTO loop + +:end + +ENDLOCAL diff --git a/Task/Guess-the-number/Brat/guess-the-number.brat b/Task/Guess-the-number/Brat/guess-the-number.brat new file mode 100644 index 0000000000..77ea37e9ab --- /dev/null +++ b/Task/Guess-the-number/Brat/guess-the-number.brat @@ -0,0 +1,9 @@ +number = random 10 + +p "Guess a number between 1 and 10." + +until { + true? ask("Guess: ").to_i == number + { p "Well guessed!"; true } + { p "Guess again!" } +} diff --git a/Task/Guess-the-number/C++/guess-the-number.cpp b/Task/Guess-the-number/C++/guess-the-number.cpp new file mode 100644 index 0000000000..59ba568024 --- /dev/null +++ b/Task/Guess-the-number/C++/guess-the-number.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + srand(time(0)); + int n = 1 + (rand() % 10); + int g; + std::cout << "I'm thinking of a number between 1 and 10.\nTry to guess it! "; + while(true) + { + std::cin >> g; + if (g == n) + break; + else + std::cout << "That's not my number.\nTry another guess! "; + } + std::cout << "You've guessed my number!"; + return 0; +} diff --git a/Task/Guess-the-number/C-sharp/guess-the-number.cs b/Task/Guess-the-number/C-sharp/guess-the-number.cs new file mode 100644 index 0000000000..719577b08d --- /dev/null +++ b/Task/Guess-the-number/C-sharp/guess-the-number.cs @@ -0,0 +1,26 @@ +using System; + +class GuessTheNumberGame +{ + static void Main() + { + bool numberCorrect = false; + Random randomNumberGenerator = new Random(); + int randomNumber = randomNumberGenerator.Next(1, 10+1); + + Console.WriteLine("I'm thinking of a number between 1 and 10. Can you guess it?"); + do + { + Console.Write("Guess: "); + int userGuess = int.Parse(Console.ReadLine()); + + if (userGuess == randomNumber) + { + numberCorrect = true; + Console.WriteLine("Congrats!! You guessed right!"); + } + else + Console.WriteLine("That's not it. Guess again."); + } while (!numberCorrect); + } +}; diff --git a/Task/Guess-the-number/C/guess-the-number.c b/Task/Guess-the-number/C/guess-the-number.c new file mode 100644 index 0000000000..4aacd06888 --- /dev/null +++ b/Task/Guess-the-number/C/guess-the-number.c @@ -0,0 +1,30 @@ +#include +#include +#include + +int main(void) +{ + int n; + int g; + char c; + + srand(time(NULL)); + n = 1 + (rand() % 10); + + puts("I'm thinking of a number between 1 and 10."); + puts("Try to guess it:"); + + while (1) { + if (scanf("%d", &g) != 1) { + /* ignore one char, in case user gave a non-number */ + scanf("%c", &c); + continue; + } + + if (g == n) { + puts("Correct!"); + return 0; + } + puts("That's not my number. Try another guess:"); + } +} diff --git a/Task/Guess-the-number/Clojure/guess-the-number.clj b/Task/Guess-the-number/Clojure/guess-the-number.clj new file mode 100644 index 0000000000..f00c0027eb --- /dev/null +++ b/Task/Guess-the-number/Clojure/guess-the-number.clj @@ -0,0 +1,10 @@ +(def target (inc (rand-int 10)) + +(loop [n 0] + (println "Guess a number between 1 and 10 until you get it right:") + (let [guess (read)] + (if (= guess target) + (printf "Correct on the %d guess.\n" n) + (do + (println "Try again") + (recur (inc n)))))) diff --git a/Task/Guess-the-number/CoffeeScript/guess-the-number-1.coffee b/Task/Guess-the-number/CoffeeScript/guess-the-number-1.coffee new file mode 100644 index 0000000000..17c85725ee --- /dev/null +++ b/Task/Guess-the-number/CoffeeScript/guess-the-number-1.coffee @@ -0,0 +1,5 @@ +num = Math.ceil(Math.random() * 10) +guess = prompt "Guess the number. (1-10)" +while parseInt(guess) isnt num + guess = prompt "YOU LOSE! Guess again. (1-10)" +alert "Well guessed!" diff --git a/Task/Guess-the-number/CoffeeScript/guess-the-number-2.coffee b/Task/Guess-the-number/CoffeeScript/guess-the-number-2.coffee new file mode 100644 index 0000000000..38fe1116b6 --- /dev/null +++ b/Task/Guess-the-number/CoffeeScript/guess-the-number-2.coffee @@ -0,0 +1,19 @@ +# This shows how to do simple REPL-like I/O in node.js. +readline = require "readline" + +do -> + number = Math.ceil(10 * Math.random()) + interface = readline.createInterface process.stdin, process.stdout + + guess = -> + interface.question "Guess the number between 1 and 10: ", (answer) -> + if parseInt(answer) == number + # These lines allow the program to terminate. + console.log "GOT IT!" + interface.close() + process.stdin.destroy() + else + console.log "Sorry, guess again" + guess() + + guess() diff --git a/Task/Guess-the-number/Common-Lisp/guess-the-number.lisp b/Task/Guess-the-number/Common-Lisp/guess-the-number.lisp new file mode 100644 index 0000000000..aac07548d0 --- /dev/null +++ b/Task/Guess-the-number/Common-Lisp/guess-the-number.lisp @@ -0,0 +1,15 @@ +(defun guess-the-number () + (let ((num-guesses 0) + (num (1+ (random 9))) + (guess nil)) + (format t "Try to guess a number from 1 to 10!~%") + (loop do (format t "Guess? ") + (incf num-guesses) + (setf guess (read)) + (cond ((not (numberp guess)) + (format t "Your guess is not a number!~%")) + ((not (= guess num)) + (format t "Your guess was wrong. Try again.~%"))) + until (and (numberp guess) + (= guess num))) + (format t "You guessed correctly on the ~:r try!~%" num-guesses))) diff --git a/Task/Guess-the-number/D/guess-the-number.d b/Task/Guess-the-number/D/guess-the-number.d new file mode 100644 index 0000000000..e5106066ef --- /dev/null +++ b/Task/Guess-the-number/D/guess-the-number.d @@ -0,0 +1,10 @@ +import std.stdio, std.random, std.conv, std.string; + +void main() { + auto tnum = text(uniform(1, 10)); + + do write("What's next guess? "); + while (readln().strip() != tnum); + + writeln("Yep, you guessed my ", tnum); +} diff --git a/Task/Guess-the-number/Delphi/guess-the-number.delphi b/Task/Guess-the-number/Delphi/guess-the-number.delphi new file mode 100644 index 0000000000..8a1ba8b39c --- /dev/null +++ b/Task/Guess-the-number/Delphi/guess-the-number.delphi @@ -0,0 +1,19 @@ +program GuessTheNumber; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +var + theDigit : String ; + theAnswer : String ; + +begin + Randomize ; + theDigit := IntToStr(Random(9)+1) ; + while ( theAnswer <> theDigit ) do Begin + Writeln('Please enter a digit between 1 and 10' ) ; + Readln(theAnswer); + End ; + Writeln('Congratulations' ) ; +end. diff --git a/Task/Guess-the-number/Euphoria/guess-the-number.euphoria b/Task/Guess-the-number/Euphoria/guess-the-number.euphoria new file mode 100644 index 0000000000..6d2a58c82b --- /dev/null +++ b/Task/Guess-the-number/Euphoria/guess-the-number.euphoria @@ -0,0 +1,17 @@ +include get.e + +integer n,g +n = rand(10) + +puts(1,"I have thought of a number from 1 to 10.\n") +puts(1,"Try to guess it!\n") + +while 1 do + g = prompt_number("Enter your guess: ",{1,10}) + if n = g then + exit + end if + puts(1,"Your guess was wrong. Try again!\n") +end while + +puts(1,"Well done! You guessed it.") diff --git a/Task/Guess-the-number/Fantom/guess-the-number.fantom b/Task/Guess-the-number/Fantom/guess-the-number.fantom new file mode 100644 index 0000000000..b41e998012 --- /dev/null +++ b/Task/Guess-the-number/Fantom/guess-the-number.fantom @@ -0,0 +1,20 @@ +class Main +{ + public static Void main () + { + Str target := (1..10).random.toStr + Str guess := "" + while (guess != target) + { + echo ("Enter a guess: ") + guess = Env.cur.in.readLine + if (guess.trim == target) // 'trim' to remove any spaces/newline + { + echo ("Well guessed!") + break + } + else + echo ("Failed - try again") + } + } +} diff --git a/Task/Guess-the-number/Fortran/guess-the-number.f b/Task/Guess-the-number/Fortran/guess-the-number.f new file mode 100644 index 0000000000..19a3018ed1 --- /dev/null +++ b/Task/Guess-the-number/Fortran/guess-the-number.f @@ -0,0 +1,34 @@ +program guess_the_number + implicit none + + integer :: guess + real :: r + integer :: i, clock, count, n + integer,dimension(:),allocatable :: seed + + real,parameter :: rmax = 10 + +!initialize random number generator: + call random_seed(size=n) + allocate(seed(n)) + call system_clock(count) + seed = count + call random_seed(put=seed) + deallocate(seed) + +!pick a random number between 1 and rmax: + call random_number(r) !r between 0.0 and 1.0 + i = int((rmax-1.0)*r + 1.0) !i between 1 and rmax + +!get user guess: + write(*,'(A)') 'I''m thinking of a number between 1 and 10.' + do !loop until guess is correct + write(*,'(A)',advance='NO') 'Enter Guess: ' + read(*,'(I5)') guess + if (guess==i) exit + write(*,*) 'Sorry, try again.' + end do + + write(*,*) 'You''ve guessed my number!' + +end program guess_the_number diff --git a/Task/Guess-the-number/GML/guess-the-number.gml b/Task/Guess-the-number/GML/guess-the-number.gml new file mode 100644 index 0000000000..a24bd83d07 --- /dev/null +++ b/Task/Guess-the-number/GML/guess-the-number.gml @@ -0,0 +1,7 @@ +n = string(ceil(random(10))); +show_message("I'm thinking of a number from 1 to 10"); +g = get_string("Please enter guess", ""); +while(g != n){ + g=get_string("I'm sorry "+g+" is not my number, try again. Please enter guess", "");} +show_message("Correct! "+g+" was my number!"); +exit diff --git a/Task/Guess-the-number/GW-BASIC/guess-the-number.bas b/Task/Guess-the-number/GW-BASIC/guess-the-number.bas new file mode 100644 index 0000000000..cc5bb2d3d5 --- /dev/null +++ b/Task/Guess-the-number/GW-BASIC/guess-the-number.bas @@ -0,0 +1,6 @@ +10 RANDOMIZE TIMER:N=INT(RND*10+1):G=0 +20 PRINT "Guess the number between 1 and 10." +30 WHILE N<>G +40 INPUT "Your guess? ",G +50 WEND +60 PRINT "That's correct!" diff --git a/Task/Guess-the-number/Go/guess-the-number.go b/Task/Guess-the-number/Go/guess-the-number.go new file mode 100644 index 0000000000..de43b5f6c0 --- /dev/null +++ b/Task/Guess-the-number/Go/guess-the-number.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +func main() { + fmt.Print("Guess number from 1 to 10: ") + rand.Seed(time.Now().Unix()) + n := rand.Intn(10) + 1 + for guess := n; ; fmt.Print("No. Try again: ") { + switch _, err := fmt.Scan(&guess); { + case err != nil: + fmt.Println("\n", err, "\nSo, bye.") + return + case guess == n: + fmt.Println("Well guessed!") + return + } + } +} diff --git a/Task/Guess-the-number/Groovy/guess-the-number.groovy b/Task/Guess-the-number/Groovy/guess-the-number.groovy new file mode 100644 index 0000000000..ba1a9d2820 --- /dev/null +++ b/Task/Guess-the-number/Groovy/guess-the-number.groovy @@ -0,0 +1,10 @@ +def random = new Random() +def keyboard = new Scanner(System.in) +def number = random.nextInt(10) + 1 +println "Guess the number which is between 1 and 10: " +def guess = keyboard.nextInt() +while (number != guess) { + println "Guess again: " + guess = keyboard.nextInt() +} +println "Hurray! You guessed correctly!" diff --git a/Task/Guess-the-number/Haskell/guess-the-number-1.hs b/Task/Guess-the-number/Haskell/guess-the-number-1.hs new file mode 100644 index 0000000000..09f34b70b9 --- /dev/null +++ b/Task/Guess-the-number/Haskell/guess-the-number-1.hs @@ -0,0 +1,16 @@ +import Control.Monad +import System.Random + +-- Repeat the action until the predicate is true. +until_ act pred = act >>= pred >>= flip unless (until_ act pred) + +answerIs ans guess + | ans == guess = putStrLn "You got it!" >> return True + | otherwise = putStrLn "Nope. Guess again." >> return False + +ask = liftM read getLine + +main = do + ans <- randomRIO (1,10) :: IO Int + putStrLn "Try to guess my secret number between 1 and 10." + ask `until_` answerIs ans diff --git a/Task/Guess-the-number/Haskell/guess-the-number-2.hs b/Task/Guess-the-number/Haskell/guess-the-number-2.hs new file mode 100644 index 0000000000..f1f51e7c2c --- /dev/null +++ b/Task/Guess-the-number/Haskell/guess-the-number-2.hs @@ -0,0 +1,10 @@ +import System.Random + +main = randomRIO (1,10) >>= gameloop + +gameloop :: Int -> IO () +gameloop r = do + i <- fmap read getLine + if i == r + then putStrLn "You got it!" + else putStrLn "Nope. Guess again." >> gameloop r diff --git a/Task/Guess-the-number/Icon/guess-the-number.icon b/Task/Guess-the-number/Icon/guess-the-number.icon new file mode 100644 index 0000000000..549b28ff2d --- /dev/null +++ b/Task/Guess-the-number/Icon/guess-the-number.icon @@ -0,0 +1,8 @@ +procedure main() + n := ?10 + repeat { + writes("Pick a number from 1 through 10: ") + if n = numeric(read()) then break + } + write("Well guessed!") +end diff --git a/Task/Guess-the-number/J/guess-the-number-1.j b/Task/Guess-the-number/J/guess-the-number-1.j new file mode 100644 index 0000000000..6f8fc57b59 --- /dev/null +++ b/Task/Guess-the-number/J/guess-the-number-1.j @@ -0,0 +1,10 @@ +require 'misc' +game=: verb define + n=: 1 + ?10 + smoutput 'Guess my integer, which is bounded by 1 and 10' + whilst. -. guess -: n do. + guess=. {. 0 ". prompt 'Guess: ' + if. 0 -: guess do. 'Giving up.' return. end. + smoutput (guess=n){::'no.';'Well guessed!' + end. +) diff --git a/Task/Guess-the-number/J/guess-the-number-2.j b/Task/Guess-the-number/J/guess-the-number-2.j new file mode 100644 index 0000000000..c5aabc88e7 --- /dev/null +++ b/Task/Guess-the-number/J/guess-the-number-2.j @@ -0,0 +1,6 @@ + game'' +Guess my integer, which is bounded by 1 and 10 +Guess: 1 +no. +Guess: 2 +Well guessed! diff --git a/Task/Guess-the-number/Java/guess-the-number.java b/Task/Guess-the-number/Java/guess-the-number.java new file mode 100644 index 0000000000..fec57600c8 --- /dev/null +++ b/Task/Guess-the-number/Java/guess-the-number.java @@ -0,0 +1,10 @@ +public class Guessing { + public static void main(String[] args) throws NumberFormatException{ + int n = (int)(Math.random() * 10 + 1); + System.out.print("Guess the number between 1 and 10: "); + while(Integer.parseInt(System.console().readLine()) != n){ + System.out.print("Wrong! Guess again: "); + } + System.out.println("Well guessed!"); + } +} diff --git a/Task/Guess-the-number/JavaScript/guess-the-number.js b/Task/Guess-the-number/JavaScript/guess-the-number.js new file mode 100644 index 0000000000..b64d37ca29 --- /dev/null +++ b/Task/Guess-the-number/JavaScript/guess-the-number.js @@ -0,0 +1,12 @@ +function guessNumber() { + // Get a random integer from 1 to 10 inclusive + var num = Math.ceil(Math.random() * 10); + var guess; + + while (guess != num) { + guess = prompt('Guess the number between 1 and 10 inclusive'); + } + alert('Congratulations!\nThe number was ' + num); +} + +guessNumber(); diff --git a/Task/Guess-the-number/LOLCODE/guess-the-number.lol b/Task/Guess-the-number/LOLCODE/guess-the-number.lol new file mode 100644 index 0000000000..6bdf0c8704 --- /dev/null +++ b/Task/Guess-the-number/LOLCODE/guess-the-number.lol @@ -0,0 +1,23 @@ +HAI 1.3 + +VISIBLE "SEED ME, FEMUR! "! +I HAS A seed, GIMMEH seed + +HOW IZ I randomizin + seed R MOD OF SUM OF 1 AN PRODUKT OF 69069 AN seed AN 10 +IF U SAY SO + +I IZ randomizin MKAY +I HAS A answer ITZ SUM OF seed AN 1 +I HAS A guess + +IM IN YR guesser + VISIBLE "WUTS MY NUMBR? "! + GIMMEH guess, guess IS NOW A NUMBR + + BOTH SAEM guess AN answer, O RLY? + YA RLY, VISIBLE "U WIN!", GTFO + OIC +IM OUTTA YR guesser + +KTHXBYE diff --git a/Task/Guess-the-number/Liberty-BASIC/guess-the-number.liberty b/Task/Guess-the-number/Liberty-BASIC/guess-the-number.liberty new file mode 100644 index 0000000000..5f75e4ac96 --- /dev/null +++ b/Task/Guess-the-number/Liberty-BASIC/guess-the-number.liberty @@ -0,0 +1,6 @@ +number = int(rnd(0) * 10) + 1 +input "Guess the number I'm thinking of between 1 and 10. "; guess +while guess <> number + input "Incorrect! Try again! "; guess +wend +print "Congratulations, well guessed! The number was "; number;"." diff --git a/Task/Guess-the-number/Locomotive-Basic/guess-the-number.bas b/Task/Guess-the-number/Locomotive-Basic/guess-the-number.bas new file mode 100644 index 0000000000..38fb986947 --- /dev/null +++ b/Task/Guess-the-number/Locomotive-Basic/guess-the-number.bas @@ -0,0 +1,6 @@ +10 RANDOMIZE TIME:num=INT(RND*10+1):guess=0 +20 PRINT "Guess the number between 1 and 10." +30 WHILE num<>guess +40 INPUT "Your guess? ", guess +50 WEND +60 PRINT "That's correct!" diff --git a/Task/Guess-the-number/Lua/guess-the-number.lua b/Task/Guess-the-number/Lua/guess-the-number.lua new file mode 100644 index 0000000000..f83651b1c1 --- /dev/null +++ b/Task/Guess-the-number/Lua/guess-the-number.lua @@ -0,0 +1,14 @@ +math.randomseed( os.time() ) +n = math.random( 1, 10 ) + +print( "I'm thinking of a number between 1 and 10. Try to guess it: " ) + +repeat + x = tonumber( io.read() ) + + if x == n then + print "Well guessed!" + else + print "Guess again: " + end +until x == n diff --git a/Task/Guess-the-number/MATLAB/guess-the-number.m b/Task/Guess-the-number/MATLAB/guess-the-number.m new file mode 100644 index 0000000000..b4efab7f22 --- /dev/null +++ b/Task/Guess-the-number/MATLAB/guess-the-number.m @@ -0,0 +1,7 @@ +number = ceil(10*rand(1)); +[guess, status] = str2num(input('Guess a number between 1 and 10: ','s')); + +while (~status || guess ~= number) + [guess, status] = str2num(input('Guess again: ','s')); +end +disp('Well guessed!') diff --git a/Task/Guess-the-number/Mathematica/guess-the-number.mathematica b/Task/Guess-the-number/Mathematica/guess-the-number.mathematica new file mode 100644 index 0000000000..3ebbf7c45c --- /dev/null +++ b/Task/Guess-the-number/Mathematica/guess-the-number.mathematica @@ -0,0 +1,3 @@ +number = RandomInteger[{1, 10}]; +While[guess =!= number, guess = Input["Guess my number"]]; +Print["Well guessed!"] diff --git a/Task/Guess-the-number/Mercury/guess-the-number.mercury b/Task/Guess-the-number/Mercury/guess-the-number.mercury new file mode 100644 index 0000000000..fdf018b37e --- /dev/null +++ b/Task/Guess-the-number/Mercury/guess-the-number.mercury @@ -0,0 +1,33 @@ +:- module guess. +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. +:- implementation. +:- import_module random, string. + +main(!IO) :- + time(Time, !IO), + random.init(Time, Rand), + random.random(1, 10, N, Rand, _), + main(from_int(N) ++ "\n", !IO). + +:- pred main(string::in, io::di, io::uo) is det. +main(N, !IO) :- + io.write_string("Guess the number: ", !IO), + io.read_line_as_string(Res, !IO), + ( + Res = ok(S), + ( if S = N then io.write_string("Well guessed!\n", !IO) + else main(N, !IO) ) + ; + Res = error(E) + ; + Res = eof + ). + +:- pred time(int::out, io::di, io::uo) is det. + +:- pragma foreign_decl("C", "#include "). +:- pragma foreign_proc("C", time(Int::out, _IO0::di, _IO1::uo), + [will_not_call_mercury, promise_pure], + "Int = time(NULL);"). diff --git a/Task/Guess-the-number/PHP/guess-the-number.php b/Task/Guess-the-number/PHP/guess-the-number.php new file mode 100644 index 0000000000..bddb536334 --- /dev/null +++ b/Task/Guess-the-number/PHP/guess-the-number.php @@ -0,0 +1,46 @@ +"; + if ($guess != $number) + { + echo "Your guess is not correct"; + } + elseif($guess == $number) + { + echo "You got the correct number!"; + } + +} +?> + + + + + + Guess A Number + + + +
+
+ + + +
+ + diff --git a/Task/Guess-the-number/Perl/guess-the-number.pl b/Task/Guess-the-number/Perl/guess-the-number.pl new file mode 100644 index 0000000000..ddeabd0303 --- /dev/null +++ b/Task/Guess-the-number/Perl/guess-the-number.pl @@ -0,0 +1,3 @@ +my $number = 1 + int rand 10; +do { print "Guess a number between 1 and 10: " } until <> == $number; +print "You got it!\n"; diff --git a/Task/Guess-the-number/PicoLisp/guess-the-number.l b/Task/Guess-the-number/PicoLisp/guess-the-number.l new file mode 100644 index 0000000000..ca4f7a7e64 --- /dev/null +++ b/Task/Guess-the-number/PicoLisp/guess-the-number.l @@ -0,0 +1,7 @@ +(de guessTheNumber () + (let Number (rand 1 9) + (loop + (prin "Guess the number: ") + (T (= Number (read)) + (prinl "Well guessed!") ) + (prinl "Sorry, this was wrong") ) ) ) diff --git a/Task/Guess-the-number/Python/guess-the-number.py b/Task/Guess-the-number/Python/guess-the-number.py new file mode 100644 index 0000000000..d7a13addd2 --- /dev/null +++ b/Task/Guess-the-number/Python/guess-the-number.py @@ -0,0 +1,8 @@ +'Simple number guessing game' + +import random + +target, guess = random.randint(1, 10), 0 +while target != guess: + guess = int(input('Guess my number between 1 and 10 until you get it right: ')) +print('Thats right!') diff --git a/Task/Guess-the-number/R/guess-the-number.r b/Task/Guess-the-number/R/guess-the-number.r new file mode 100644 index 0000000000..92d1196613 --- /dev/null +++ b/Task/Guess-the-number/R/guess-the-number.r @@ -0,0 +1,8 @@ +f <- function() { + print("Guess a number between 1 and 10 until you get it right.") + n <- 1 + floor(10*runif(1)) + while (as.numeric(readline()) != n) { + print("Try again.") + } + print("You got it!") +} diff --git a/Task/Guess-the-number/REXX/guess-the-number-1.rexx b/Task/Guess-the-number/REXX/guess-the-number-1.rexx new file mode 100644 index 0000000000..1db2ffd9ad --- /dev/null +++ b/Task/Guess-the-number/REXX/guess-the-number-1.rexx @@ -0,0 +1,16 @@ +#!/usr/bin/rexx +/*REXX program to play: Guess the number */ + +number = random(1,10) +say "I have thought of a number. Try to guess it!" + +guess=0 /* We don't want a valid guess, before we start */ + +do while guess \= number + pull guess + if guess \= number then + say "Sorry, the guess was wrong. Try again!" + /* endif - There is no endif in rexx. */ +end + +say "Well done! You guessed it!" diff --git a/Task/Guess-the-number/REXX/guess-the-number-2.rexx b/Task/Guess-the-number/REXX/guess-the-number-2.rexx new file mode 100644 index 0000000000..187e305791 --- /dev/null +++ b/Task/Guess-the-number/REXX/guess-the-number-2.rexx @@ -0,0 +1,10 @@ +/*REXX program to (interactively) play "guess my number". */ +?=random(1,10) +say 'Try to guess my number between 1 ──► 10 (inclusive).' + + do j=1 while g\=? + if j\==1 then say 'Try again.' + pull g + end /*j*/ +say 'Well guessed!' + /*stick a fork in it, we're done.*/ diff --git a/Task/Guess-the-number/Ruby/guess-the-number.rb b/Task/Guess-the-number/Ruby/guess-the-number.rb new file mode 100644 index 0000000000..c6eeb6940e --- /dev/null +++ b/Task/Guess-the-number/Ruby/guess-the-number.rb @@ -0,0 +1,4 @@ +n = rand( 10 ) + 1 +puts 'Guess the number: ' +puts 'Wrong! Guess again: ' until gets.to_i == n +puts 'Well guessed!' diff --git a/Task/Guess-the-number/Scala/guess-the-number.scala b/Task/Guess-the-number/Scala/guess-the-number.scala new file mode 100644 index 0000000000..7ce91fc28c --- /dev/null +++ b/Task/Guess-the-number/Scala/guess-the-number.scala @@ -0,0 +1,4 @@ +val n = (math.random * 10 + 1).toInt +print("Guess the number: ") +while(readInt != n) print("Wrong! Guess again: ") +println("Well guessed!") diff --git a/Task/Guess-the-number/Scheme/guess-the-number.ss b/Task/Guess-the-number/Scheme/guess-the-number.ss new file mode 100644 index 0000000000..096c04c82a --- /dev/null +++ b/Task/Guess-the-number/Scheme/guess-the-number.ss @@ -0,0 +1,4 @@ +(define number (random 11)) +(display "Pick a number from 1 through 10.\n> ") +(do ((guess (read) (read))) ((= guess number)) (display "Guess again.\n> ")) +(display "Well guessed!\n") diff --git a/Task/Guess-the-number/Tcl/guess-the-number.tcl b/Task/Guess-the-number/Tcl/guess-the-number.tcl new file mode 100644 index 0000000000..96dac5697e --- /dev/null +++ b/Task/Guess-the-number/Tcl/guess-the-number.tcl @@ -0,0 +1,13 @@ +set target [expr {int(rand()*10 + 1)}] +puts "I have thought of a number." +puts "Try to guess it!" +while 1 { + puts -nonewline "Enter your guess: " + flush stdout + gets stdin guess + if {$guess == $target} { + break + } + puts "Your guess was wrong. Try again!" +} +puts "Well done! You guessed it." diff --git a/Task/HTTP/0DESCRIPTION b/Task/HTTP/0DESCRIPTION new file mode 100644 index 0000000000..8d0c135011 --- /dev/null +++ b/Task/HTTP/0DESCRIPTION @@ -0,0 +1,2 @@ +Access and print a [[wp:Uniform Resource Locator|URL's]] content (the located resource) to the console. +There is a separate task for [[HTTPS Request]]s. diff --git a/Task/HTTP/1META.yaml b/Task/HTTP/1META.yaml new file mode 100644 index 0000000000..7948000013 --- /dev/null +++ b/Task/HTTP/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Networking and Web Interaction +note: Programming environment operations diff --git a/Task/HTTP/ALGOL-68/http.alg b/Task/HTTP/ALGOL-68/http.alg new file mode 100644 index 0000000000..98d0b6094e --- /dev/null +++ b/Task/HTTP/ALGOL-68/http.alg @@ -0,0 +1,29 @@ +STRING domain="rosettacode.org"; +STRING page="wiki/Main_Page"; + +STRING re success="^HTTP/[0-9.]* 200"; +STRING re result description="^HTTP/[0-9.]* [0-9]+ [a-zA-Z ]*"; +STRING re doctype ="\s\s]+"">\s+"; + +PROC html page = (REF STRING page) BOOL: ( + BOOL out=grep in string(re success, page, NIL, NIL) = 0; + IF INT start, end; + grep in string(re result description, page, start, end) = 0 + THEN + page:=page[end+1:]; + IF grep in string(re doctype, page, start, end) = 0 + THEN page:=page[start+2:] + ELSE print ("unknown format retrieving page") + FI + ELSE print ("unknown error retrieving page") + FI; + out +); + +IF STRING reply; + INT rc = + http content (reply, domain, "http://"+domain+"/"+page, 0); + rc = 0 AND html page (reply) +THEN print (reply) +ELSE print (strerror (rc)) +FI diff --git a/Task/HTTP/ActionScript/http.as b/Task/HTTP/ActionScript/http.as new file mode 100644 index 0000000000..8850ae626a --- /dev/null +++ b/Task/HTTP/ActionScript/http.as @@ -0,0 +1,21 @@ +package +{ + import flash.display.Sprite; + import flash.events.Event; + import flash.net.*; + + public class RequestExample extends Sprite + { + public function RequestExample() + { + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, loadComplete); + loader.load(new URLRequest("http://www.rosettacode.org")); + } + + private function loadComplete(evt:Event):void + { + trace(evt.target.data); + } + } +} diff --git a/Task/HTTP/Ada/http.ada b/Task/HTTP/Ada/http.ada new file mode 100644 index 0000000000..b004ac841f --- /dev/null +++ b/Task/HTTP/Ada/http.ada @@ -0,0 +1,9 @@ +with Ada.Text_IO; use Ada.Text_IO; + +with AWS.Client; +with AWS.Response; + +procedure HTTP_Request is +begin + Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org"))); +end HTTP_Request; diff --git a/Task/HTTP/AutoHotkey/http.ahk b/Task/HTTP/AutoHotkey/http.ahk new file mode 100644 index 0000000000..fc1c14d60c --- /dev/null +++ b/Task/HTTP/AutoHotkey/http.ahk @@ -0,0 +1,2 @@ +UrlDownloadToFile, http://rosettacode.org, url.html +Run, cmd /k type url.html diff --git a/Task/HTTP/BBC-BASIC/http.bbc b/Task/HTTP/BBC-BASIC/http.bbc new file mode 100644 index 0000000000..bf821f31f2 --- /dev/null +++ b/Task/HTTP/BBC-BASIC/http.bbc @@ -0,0 +1,9 @@ + SYS "LoadLibrary", "URLMON.DLL" TO urlmon% + SYS "GetProcAddress", urlmon%, "URLDownloadToFileA" TO URLDownloadToFile + + url$ = "http://www.bbcbasic.co.uk/aboutus.html" + file$ = @tmp$ + "rosetta.tmp" + SYS URLDownloadToFile, 0, url$, file$, 0, 0 TO fail% + IF fail% ERROR 100, "File download failed" + + OSCLI "TYPE """ + file$ + """" diff --git a/Task/HTTP/Batch-File/http.bat b/Task/HTTP/Batch-File/http.bat new file mode 100644 index 0000000000..b6418dae6d --- /dev/null +++ b/Task/HTTP/Batch-File/http.bat @@ -0,0 +1 @@ +curl.exe -s -L http://rosettacode.org/ diff --git a/Task/HTTP/Biferno/http.biferno b/Task/HTTP/Biferno/http.biferno new file mode 100644 index 0000000000..6effa562ed --- /dev/null +++ b/Task/HTTP/Biferno/http.biferno @@ -0,0 +1 @@ +$httpExt.ExecRemote("www.tabasoft.it") diff --git a/Task/HTTP/C++/http-1.cpp b/Task/HTTP/C++/http-1.cpp new file mode 100644 index 0000000000..f063e59923 --- /dev/null +++ b/Task/HTTP/C++/http-1.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +int main() { + WSADATA wsaData; + WSAStartup( MAKEWORD( 2, 2 ), &wsaData ); + + addrinfo *result = NULL; + addrinfo hints; + + ZeroMemory( &hints, sizeof( hints ) ); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + getaddrinfo( "74.125.45.100", "80", &hints, &result ); // http://www.google.com + + SOCKET s = socket( result->ai_family, result->ai_socktype, result->ai_protocol ); + + connect( s, result->ai_addr, (int)result->ai_addrlen ); + + freeaddrinfo( result ); + + send( s, "GET / HTTP/1.0\n\n", 16, 0 ); + + char buffer[512]; + int bytes; + + do { + bytes = recv( s, buffer, 512, 0 ); + + if ( bytes > 0 ) + std::cout.write(buffer, bytes); + } while ( bytes > 0 ); + + return 0; +} diff --git a/Task/HTTP/C++/http-2.cpp b/Task/HTTP/C++/http-2.cpp new file mode 100644 index 0000000000..a305d413b3 --- /dev/null +++ b/Task/HTTP/C++/http-2.cpp @@ -0,0 +1,8 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + Cout() << HttpClient("www.rosettacode.org").ExecuteRedirect(); +} diff --git a/Task/HTTP/C-sharp/http.cs b/Task/HTTP/C-sharp/http.cs new file mode 100644 index 0000000000..d34039b65f --- /dev/null +++ b/Task/HTTP/C-sharp/http.cs @@ -0,0 +1,13 @@ +using System; +using System.Text; +using System.Net; + +class Program +{ + static void Main(string[] args) + { + WebClient wc = new WebClient(); + string content = wc.DownloadString("http://www.google.com"); + Console.WriteLine(content); + } +} diff --git a/Task/HTTP/C/http.c b/Task/HTTP/C/http.c new file mode 100644 index 0000000000..85ee8e7d12 --- /dev/null +++ b/Task/HTTP/C/http.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int +main(void) +{ + CURL *curl; + char buffer[CURL_ERROR_SIZE]; + + if ((curl = curl_easy_init()) != NULL) { + curl_easy_setopt(curl, CURLOPT_URL, "http://www.rosettacode.org/"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer); + if (curl_easy_perform(curl) != CURLE_OK) { + fprintf(stderr, "%s\n", buffer); + return EXIT_FAILURE; + } + curl_easy_cleanup(curl); + } + return EXIT_SUCCESS; +} diff --git a/Task/HTTP/Clojure/http-1.clj b/Task/HTTP/Clojure/http-1.clj new file mode 100644 index 0000000000..0f726f01e7 --- /dev/null +++ b/Task/HTTP/Clojure/http-1.clj @@ -0,0 +1,6 @@ +(defn get-http [url] + (let [sc (java.util.Scanner. + (.openStream (java.net.URL. url)))] + (while (.hasNext sc) + (println (.nextLine sc))))) +(get-http "http://www.rosettacode.org") diff --git a/Task/HTTP/Clojure/http-2.clj b/Task/HTTP/Clojure/http-2.clj new file mode 100644 index 0000000000..29a4dfc175 --- /dev/null +++ b/Task/HTTP/Clojure/http-2.clj @@ -0,0 +1,4 @@ +(ns example + (:use [clojure.contrib.http.agent :only (string http-agent)])) + +(println (string (http-agent "http://www.rosettacode.org/"))) diff --git a/Task/HTTP/Clojure/http-3.clj b/Task/HTTP/Clojure/http-3.clj new file mode 100644 index 0000000000..e28394b60f --- /dev/null +++ b/Task/HTTP/Clojure/http-3.clj @@ -0,0 +1 @@ +(print (slurp "http://www.rosettacode.org/")) diff --git a/Task/HTTP/ColdFusion/http.cfm b/Task/HTTP/ColdFusion/http.cfm new file mode 100644 index 0000000000..43cf8c6047 --- /dev/null +++ b/Task/HTTP/ColdFusion/http.cfm @@ -0,0 +1,2 @@ + + #result.FileContent# diff --git a/Task/HTTP/Common-Lisp/http-1.lisp b/Task/HTTP/Common-Lisp/http-1.lisp new file mode 100644 index 0000000000..670b2f19e3 --- /dev/null +++ b/Task/HTTP/Common-Lisp/http-1.lisp @@ -0,0 +1,5 @@ +(defun wget-clisp (url) + (ext:with-http-input (stream url) + (loop for line = (read-line stream nil nil) + while line + do (format t "~a~%" line)))) diff --git a/Task/HTTP/Common-Lisp/http-2.lisp b/Task/HTTP/Common-Lisp/http-2.lisp new file mode 100644 index 0000000000..9c515441ee --- /dev/null +++ b/Task/HTTP/Common-Lisp/http-2.lisp @@ -0,0 +1,10 @@ +(defun wget-drakma-string (url &optional (out *standard-output*)) + "Grab the body as a string, and write it to out." + (write-string (drakma:http-request url) out)) + +(defun wget-drakma-stream (url &optional (out *standard-output*)) + "Grab the body as a stream, and write it to out." + (loop with body = (drakma:http-request url :want-stream t) + for line = (read-line body nil nil) + while line do (write-line line out) + finally (close body))) diff --git a/Task/HTTP/D/http-1.d b/Task/HTTP/D/http-1.d new file mode 100644 index 0000000000..5ec07a31b3 --- /dev/null +++ b/Task/HTTP/D/http-1.d @@ -0,0 +1,4 @@ +void main() { + import std.stdio, std.net.curl; + writeln(get("http://google.com")); +} diff --git a/Task/HTTP/D/http-2.d b/Task/HTTP/D/http-2.d new file mode 100644 index 0000000000..a34349ec8b --- /dev/null +++ b/Task/HTTP/D/http-2.d @@ -0,0 +1,6 @@ +import tango.io.Console; +import tango.net.http.HttpGet; + +void main() { + Cout.stream.copy( (new HttpGet("http://google.com")).open ); +} diff --git a/Task/HTTP/D/http-3.d b/Task/HTTP/D/http-3.d new file mode 100644 index 0000000000..62928c85ca --- /dev/null +++ b/Task/HTTP/D/http-3.d @@ -0,0 +1,10 @@ +import tango.io.Console; +import tango.net.InternetAddress; +import tango.net.device.Socket; + +void main() { + auto site = new Socket; + site.connect (new InternetAddress("google.com",80)).write ("GET / HTTP/1.0\n\n"); + + Cout.stream.copy (site); +} diff --git a/Task/HTTP/Delphi/http-1.delphi b/Task/HTTP/Delphi/http-1.delphi new file mode 100644 index 0000000000..d7e74bc3c3 --- /dev/null +++ b/Task/HTTP/Delphi/http-1.delphi @@ -0,0 +1,43 @@ +program HTTP; + +{$APPTYPE CONSOLE} + +{$DEFINE DEBUG} + +uses + Classes, + httpsend; // Synapse httpsend class + +var + Response: TStrings; + HTTPObj: THTTPSend; + +begin + HTTPObj := THTTPSend.Create; + try + { Stringlist object to capture HTML returned + from URL } + Response := TStringList.Create; + try + if HTTPObj.HTTPMethod('GET','http://www.mgis.uk.com') then + begin + { Load HTTP Document into Stringlist } + Response.LoadFromStream(HTTPObj.Document); + { Write the response to the console window } + Writeln(Response.Text); + end + else + Writeln('Error retrieving data'); + + finally + Response.Free; + end; + + finally + HTTPObj.Free; + end; + + // Keep console window open + Readln; + +end. diff --git a/Task/HTTP/Delphi/http-2.delphi b/Task/HTTP/Delphi/http-2.delphi new file mode 100644 index 0000000000..cf5169dd2c --- /dev/null +++ b/Task/HTTP/Delphi/http-2.delphi @@ -0,0 +1,19 @@ +program ShowHTTP; + +{$APPTYPE CONSOLE} + +uses IdHttp; + +var + s: string; + lHTTP: TIdHTTP; +begin + lHTTP := TIdHTTP.Create(nil); + try + lHTTP.HandleRedirects := True; + s := lHTTP.Get('http://www.rosettacode.org'); + Writeln(s); + finally + lHTTP.Free; + end; +end. diff --git a/Task/HTTP/E/http.e b/Task/HTTP/E/http.e new file mode 100644 index 0000000000..4688040d03 --- /dev/null +++ b/Task/HTTP/E/http.e @@ -0,0 +1,3 @@ +when (def t := <- getText()) -> { + println(t) +} diff --git a/Task/HTTP/Erlang/http-1.erl b/Task/HTTP/Erlang/http-1.erl new file mode 100644 index 0000000000..025743893f --- /dev/null +++ b/Task/HTTP/Erlang/http-1.erl @@ -0,0 +1,9 @@ +-module(main). +-export([main/1]). + +main([Url|[]]) -> + inets:start(), + case http:request(Url) of + {ok, {_V, _H, Body}} -> io:fwrite("~p~n",[Body]); + {error, Res} -> io:fwrite("~p~n", [Res]) + end. diff --git a/Task/HTTP/Erlang/http-2.erl b/Task/HTTP/Erlang/http-2.erl new file mode 100644 index 0000000000..a59d89ce16 --- /dev/null +++ b/Task/HTTP/Erlang/http-2.erl @@ -0,0 +1,11 @@ +-module(main). +-export([main/1]). + +main([Url|[]]) -> + inets:start(), + http:request(get, {Url, [] }, [], [{sync, false}]), + receive + {http, {_ReqId, Res}} -> io:fwrite("~p~n",[Res]); + _Any -> io:fwrite("Error: ~p~n",[_Any]) + after 10000 -> io:fwrite("Timed out.~n",[]) + end. diff --git a/Task/HTTP/Erlang/http-3.erl b/Task/HTTP/Erlang/http-3.erl new file mode 100644 index 0000000000..a064579e9c --- /dev/null +++ b/Task/HTTP/Erlang/http-3.erl @@ -0,0 +1 @@ +|escript ./req.erl http://www.rosettacode.org diff --git a/Task/HTTP/Factor/http.factor b/Task/HTTP/Factor/http.factor new file mode 100644 index 0000000000..d1b1ac69d9 --- /dev/null +++ b/Task/HTTP/Factor/http.factor @@ -0,0 +1,2 @@ +USE: http.client +"http://www.rosettacode.org" http-get nip print diff --git a/Task/HTTP/Forth/http.fth b/Task/HTTP/Forth/http.fth new file mode 100644 index 0000000000..c3d41aa987 --- /dev/null +++ b/Task/HTTP/Forth/http.fth @@ -0,0 +1,6 @@ +include unix/socket.fs + +s" localhost" 80 open-socket +dup s\" GET / HTTP/1.0\n\n" rot write-socket +dup pad 8092 read-socket type +close-socket diff --git a/Task/HTTP/GUISS/http.guiss b/Task/HTTP/GUISS/http.guiss new file mode 100644 index 0000000000..59ce451b0e --- /dev/null +++ b/Task/HTTP/GUISS/http.guiss @@ -0,0 +1,3 @@ +Start,Programs,Applications,Mozilla Firefox,Inputbox:address bar>www.rosettacode.org,Button:Go, +Click:Area:browser window,Type:[Control A],[Control C],Start,Programs,Accessories,Notepad, +Menu:Edit,Paste diff --git a/Task/HTTP/Go/http.go b/Task/HTTP/Go/http.go new file mode 100644 index 0000000000..de03c267aa --- /dev/null +++ b/Task/HTTP/Go/http.go @@ -0,0 +1,16 @@ +package main + +import ( + "io" + "log" + "net/http" + "os" +) + +func main() { + r, err := http.Get("http://rosettacode.org/robots.txt") + if err != nil { + log.Fatalln(err) + } + io.Copy(os.Stdout, r.Body) +} diff --git a/Task/HTTP/Groovy/http.groovy b/Task/HTTP/Groovy/http.groovy new file mode 100644 index 0000000000..e164c1b133 --- /dev/null +++ b/Task/HTTP/Groovy/http.groovy @@ -0,0 +1 @@ +new URL("http://www.rosettacode.org").eachLine { println it } diff --git a/Task/HTTP/Haskell/http-1.hs b/Task/HTTP/Haskell/http-1.hs new file mode 100644 index 0000000000..5feca277fd --- /dev/null +++ b/Task/HTTP/Haskell/http-1.hs @@ -0,0 +1,11 @@ +import Network.Browser +import Network.HTTP +import Network.URI + +httpreq = do + rsp <- Network.Browser.browse $ do + setAllowRedirects True + setOutHandler $ const (return ()) + request $ getRequest "http://www.rosettacode.org/" + + putStrLn $ rspBody $ snd rsp diff --git a/Task/HTTP/Haskell/http-2.hs b/Task/HTTP/Haskell/http-2.hs new file mode 100644 index 0000000000..dd16a7a264 --- /dev/null +++ b/Task/HTTP/Haskell/http-2.hs @@ -0,0 +1,19 @@ +link cfunc +procedure main(arglist) + get(arglist[1]) +end + +procedure get(url) + local f, host, port, path + url ? { + ="http://" | ="HTTP://" + host := tab(upto(':/') | 0) + if not (=":" & (port := integer(tab(upto('/'))))) then port := 80 + if pos(0) then path := "/" else path := tab(0) + } + write(host) + write(path) + f := tconnect(host, port) | stop("Unable to connect") + writes(f, "GET ", path | "/" ," HTTP/1.0\r\n\r\n") + while write(read(f)) +end diff --git a/Task/HTTP/Haskell/http-3.hs b/Task/HTTP/Haskell/http-3.hs new file mode 100644 index 0000000000..5415552ae5 --- /dev/null +++ b/Task/HTTP/Haskell/http-3.hs @@ -0,0 +1 @@ +|icon req.icn http://www.rosettacode.org diff --git a/Task/HTTP/Haskell/http-4.hs b/Task/HTTP/Haskell/http-4.hs new file mode 100644 index 0000000000..f953c013e3 --- /dev/null +++ b/Task/HTTP/Haskell/http-4.hs @@ -0,0 +1,4 @@ +procedure main(arglist) +m := open(arglist[1],"m") +while write(read(m)) +end diff --git a/Task/HTTP/J/http.j b/Task/HTTP/J/http.j new file mode 100644 index 0000000000..8514e1f80e --- /dev/null +++ b/Task/HTTP/J/http.j @@ -0,0 +1 @@ +gethttp 'http://www.rosettacode.org' diff --git a/Task/HTTP/Java/http-1.java b/Task/HTTP/Java/http-1.java new file mode 100644 index 0000000000..483ae63a59 --- /dev/null +++ b/Task/HTTP/Java/http-1.java @@ -0,0 +1,10 @@ +import java.util.Scanner; +import java.net.URL; + +public class Main { + public static void main(String[] args) throws Exception { + Scanner sc = new Scanner(new URL("http://www.rosettacode.org").openStream()); + while (sc.hasNext()) + System.out.println(sc.nextLine()); + } +} diff --git a/Task/HTTP/Java/http-2.java b/Task/HTTP/Java/http-2.java new file mode 100644 index 0000000000..b9d6bd4c28 --- /dev/null +++ b/Task/HTTP/Java/http-2.java @@ -0,0 +1,8 @@ +import org.apache.commons.io.IOUtils; +import java.net.URL; + +public class Main { + public static void main(String[] args) throws Exception { + IOUtils.copy(new URL("http://rosettacode.org").openStream(),System.out); + } +} diff --git a/Task/HTTP/LSL/http.lsl b/Task/HTTP/LSL/http.lsl new file mode 100644 index 0000000000..300c92f5f7 --- /dev/null +++ b/Task/HTTP/LSL/http.lsl @@ -0,0 +1,20 @@ +string sURL = "http://www.RosettaCode.Org"; +key kHttpRequestId; +default { + state_entry() { + kHttpRequestId = llHTTPRequest(sURL, [], ""); + } + http_response(key kRequestId, integer iStatus, list lMetaData, string sBody) { + if(kRequestId==kHttpRequestId) { + llOwnerSay("Status="+(string)iStatus); + integer x = 0; + for(x=0 ; x 0 then print "Error downloading." + +end + +Function DownloadToFile( urlfile$, localfile$) + open "URLmon" for dll as #url + calldll #url, "URLDownloadToFileA",_ + 0 as long,_ 'null + urlfile$ as ptr,_ 'url to download + localfile$ as ptr,_ 'save file name + 0 as long,_ 'reserved, must be 0 + 0 as long,_ 'callback address, can be 0 + DownloadToFile as ulong '0=success + close #url +end function diff --git a/Task/HTTP/Lua/http.lua b/Task/HTTP/Lua/http.lua new file mode 100644 index 0000000000..6aece5b097 --- /dev/null +++ b/Task/HTTP/Lua/http.lua @@ -0,0 +1,20 @@ +local http = require("socket.http") +function url_encode(str) + if (str) then + str = string.gsub (str, "\n", "\r\n") + str = string.gsub (str, "([^%w ])", + function (c) return string.format ("%%%02X", string.byte(c)) end) + str = string.gsub (str, " ", "+") + end + return str +end +function url_decode(str) + str = string.gsub (str, "+", " ") + str = string.gsub (str, "%%(%x%x)", + function(h) return string.char(tonumber(h,16)) end) + str = string.gsub (str, "\r\n", "\n") + return str +end + +local page = http.request( 'http://www.google.com/m/search?q=' .. url_encode("lua") ) +print( page ) diff --git a/Task/HTTP/MATLAB/http.m b/Task/HTTP/MATLAB/http.m new file mode 100644 index 0000000000..0eaa0421fe --- /dev/null +++ b/Task/HTTP/MATLAB/http.m @@ -0,0 +1,5 @@ +>> random = urlread('http://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new') + +random = + +61 diff --git a/Task/HTTP/Maple/http.maple b/Task/HTTP/Maple/http.maple new file mode 100644 index 0000000000..81e46268ad --- /dev/null +++ b/Task/HTTP/Maple/http.maple @@ -0,0 +1 @@ +HTTP:-Get( "http://www.google.com" ); diff --git a/Task/HTTP/Mathematica/http.mathematica b/Task/HTTP/Mathematica/http.mathematica new file mode 100644 index 0000000000..60d51cae32 --- /dev/null +++ b/Task/HTTP/Mathematica/http.mathematica @@ -0,0 +1 @@ +Print[Import["http://www.google.com/webhp?complete=1&hl=en", "Source"]] diff --git a/Task/HTTP/PHP/http.php b/Task/HTTP/PHP/http.php new file mode 100644 index 0000000000..909e2ee047 --- /dev/null +++ b/Task/HTTP/PHP/http.php @@ -0,0 +1 @@ +readfile("http://www.rosettacode.org"); diff --git a/Task/HTTP/Perl/http-1.pl b/Task/HTTP/Perl/http-1.pl new file mode 100644 index 0000000000..36f0956821 --- /dev/null +++ b/Task/HTTP/Perl/http-1.pl @@ -0,0 +1,2 @@ +use LWP::Simple; +print get("http://www.rosettacode.org"); diff --git a/Task/HTTP/Perl/http-2.pl b/Task/HTTP/Perl/http-2.pl new file mode 100644 index 0000000000..10b8260a83 --- /dev/null +++ b/Task/HTTP/Perl/http-2.pl @@ -0,0 +1,9 @@ +use strict; +use LWP::UserAgent; + +my $url = 'http://www.rosettacode.org'; +my $response = LWP::UserAgent->new->get( $url ); + +$response->is_success or die "Failed to GET '$url': ", $response->status_line; + +print $response->as_string; diff --git a/Task/HTTP/PicoLisp/http.l b/Task/HTTP/PicoLisp/http.l new file mode 100644 index 0000000000..ed56b13baf --- /dev/null +++ b/Task/HTTP/PicoLisp/http.l @@ -0,0 +1,4 @@ +(load "@lib/http.l") + +(client "rosettacode.org" 80 NIL # Connect to rosettacode + (out NIL (echo)) ) # Echo to standard output diff --git a/Task/HTTP/Prolog/http.pro b/Task/HTTP/Prolog/http.pro new file mode 100644 index 0000000000..2592635006 --- /dev/null +++ b/Task/HTTP/Prolog/http.pro @@ -0,0 +1,6 @@ +:- use_module(library( http/http_open )). + +http :- + http_open('http://www.rosettacode.org/',In, []), + copy_stream_data(In, user_output), + close(In). diff --git a/Task/HTTP/Python/http-1.py b/Task/HTTP/Python/http-1.py new file mode 100644 index 0000000000..921609af9b --- /dev/null +++ b/Task/HTTP/Python/http-1.py @@ -0,0 +1,2 @@ +import urllib.request +print(urllib.request.urlopen("http://rosettacode.org").read()) diff --git a/Task/HTTP/Python/http-2.py b/Task/HTTP/Python/http-2.py new file mode 100644 index 0000000000..00887667c4 --- /dev/null +++ b/Task/HTTP/Python/http-2.py @@ -0,0 +1,2 @@ +import urllib +print urllib.urlopen("http://rosettacode.org").read() diff --git a/Task/HTTP/Python/http-3.py b/Task/HTTP/Python/http-3.py new file mode 100644 index 0000000000..d0d4a06ab3 --- /dev/null +++ b/Task/HTTP/Python/http-3.py @@ -0,0 +1,2 @@ +import urllib2 +print urllib2.urlopen("http://rosettacode.org").read() diff --git a/Task/HTTP/R/http-1.r b/Task/HTTP/R/http-1.r new file mode 100644 index 0000000000..95dbf1a92e --- /dev/null +++ b/Task/HTTP/R/http-1.r @@ -0,0 +1,10 @@ +library(RCurl) +webpage <- getURL("http://rosettacode.org") + +#If you are linking to a page that no longer exists and need to follow the redirect, use followlocation=TRUE +webpage <- getURL("http://www.rosettacode.org", .opts=list(followlocation=TRUE)) + +#If you are behind a proxy server, you will need to use something like: +webpage <- getURL("http://rosettacode.org", + .opts=list(proxy="123.123.123.123", proxyusername="domain\\username", proxypassword="mypassword", proxyport=8080)) +#Don't forget that backslashes in your username or password need to be escaped! diff --git a/Task/HTTP/R/http-2.r b/Task/HTTP/R/http-2.r new file mode 100644 index 0000000000..f666d17a9a --- /dev/null +++ b/Task/HTTP/R/http-2.r @@ -0,0 +1,3 @@ +library(XML) +pagetree <- htmlTreeParse(webpage ) +pagetree$children$html diff --git a/Task/HTTP/Racket/http.rkt b/Task/HTTP/Racket/http.rkt new file mode 100644 index 0000000000..4d4d46dfca --- /dev/null +++ b/Task/HTTP/Racket/http.rkt @@ -0,0 +1,5 @@ +#lang racket +(require net/url) +(copy-port (get-pure-port (string->url "http://www.rosettacode.org") + #:redirections 100) + (current-output-port)) diff --git a/Task/HTTP/Ruby/http-1.rb b/Task/HTTP/Ruby/http-1.rb new file mode 100644 index 0000000000..aa505ac6da --- /dev/null +++ b/Task/HTTP/Ruby/http-1.rb @@ -0,0 +1,3 @@ +require 'open-uri' + +print open("http://rosettacode.org") {|f| f.read} diff --git a/Task/HTTP/Ruby/http-2.rb b/Task/HTTP/Ruby/http-2.rb new file mode 100644 index 0000000000..a9a8100464 --- /dev/null +++ b/Task/HTTP/Ruby/http-2.rb @@ -0,0 +1,4 @@ +require 'fileutils' +require 'open-uri' + +open("http://rosettacode.org/") {|f| FileUtils.copy_stream(f, $stdout)} diff --git a/Task/HTTP/Scala/http.scala b/Task/HTTP/Scala/http.scala new file mode 100644 index 0000000000..06d825f972 --- /dev/null +++ b/Task/HTTP/Scala/http.scala @@ -0,0 +1,12 @@ +import scala.io._ + +object HttpTest { + def main(args: Array[String]): Unit = { + //if you are behind a firewall you can configure your proxy + System.setProperty("http.proxySet", "true") + System.setProperty("http.proxyHost", "0.0.0.0") + System.setProperty("http.proxyPort", "8080") + + Source.fromURL("http://www.rosettacode.org").getLines.foreach(println) + } +} diff --git a/Task/HTTP/Scheme/http.ss b/Task/HTTP/Scheme/http.ss new file mode 100644 index 0000000000..3a53a12e1f --- /dev/null +++ b/Task/HTTP/Scheme/http.ss @@ -0,0 +1,26 @@ +; Use the regular expression module to parse the url (included with Guile) +(use-modules (ice-9 regex)) + +; Set the url and parse the hostname, port, and path into variables +(define url "http://www.rosettacode.org/wiki/HTTP") +(define r (make-regexp "^(http://)?([^:/]+)(:)?(([0-9])+)?(/.*)?" regexp/icase)) +(define host (match:substring (regexp-exec r url) 2)) +(define port (match:substring (regexp-exec r url) 4)) +(define path (match:substring (regexp-exec r url) 6)) + +; Set port to 80 if it wasn't set above and convert from a string to a number +(if (eq? port #f) (define port "80")) +(define port (string->number port)) + +; Connect to remote host on specified port +(let ((s (socket PF_INET SOCK_STREAM 0))) + (connect s AF_INET (car (hostent:addr-list (gethostbyname host))) port) + +; Send a HTTP request for the specified path + (display "GET " s) + (display path s) + (display " HTTP/1.0\r\n\r\n" s) + +; Display the received HTML + (do ((c (read-char s) (read-char s))) ((eof-object? c)) + (display c))) diff --git a/Task/HTTP/Smalltalk/http.st b/Task/HTTP/Smalltalk/http.st new file mode 100644 index 0000000000..49f8df012f --- /dev/null +++ b/Task/HTTP/Smalltalk/http.st @@ -0,0 +1 @@ +Transcript show: 'http://rosettacode.org' asUrl retrieveContents contentStream. diff --git a/Task/HTTP/Tcl/http.tcl b/Task/HTTP/Tcl/http.tcl new file mode 100644 index 0000000000..3fbf3871c9 --- /dev/null +++ b/Task/HTTP/Tcl/http.tcl @@ -0,0 +1,4 @@ +package require http +set request [http::geturl "http://www.rosettacode.org"] +puts [http::data $request] +http::cleanup $request diff --git a/Task/HTTPS-Authenticated/0DESCRIPTION b/Task/HTTPS-Authenticated/0DESCRIPTION new file mode 100644 index 0000000000..da82d2d0dd --- /dev/null +++ b/Task/HTTPS-Authenticated/0DESCRIPTION @@ -0,0 +1,2 @@ +The goal of this task is to demonstrate [[HTTPS request]]s with authentication. +Implementations of this task should not use client certificates for this: that is the subject of [[Client-Authenticated HTTPS Request|another task]]. diff --git a/Task/HTTPS-Authenticated/1META.yaml b/Task/HTTPS-Authenticated/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/HTTPS-Authenticated/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/HTTPS-Authenticated/AutoHotkey/https-authenticated.ahk b/Task/HTTPS-Authenticated/AutoHotkey/https-authenticated.ahk new file mode 100644 index 0000000000..9ee0ee56fa --- /dev/null +++ b/Task/HTTPS-Authenticated/AutoHotkey/https-authenticated.ahk @@ -0,0 +1,15 @@ +iWeb_Init() +pwb := iWeb_newGui(0, 0, 1000, 800) +iWeb_nav(pwb, "http://www.facebook.com/login.php?ref=pf") +iWeb_Term() +iWeb_complete(pwb) +inputbox, email, email +inputbox, pass, password +iWeb_setDomObj(pwb,"Email",email) +iWeb_setDomObj(pwb,"pass",pass) +iWeb_clickDomObj(pwb, "login") +return + +#Include iweb.ahk +#Include COM.ahk +#Include COMinvokeDeep.ahk diff --git a/Task/HTTPS-Authenticated/C/https-authenticated.c b/Task/HTTPS-Authenticated/C/https-authenticated.c new file mode 100644 index 0000000000..435a2d9a6e --- /dev/null +++ b/Task/HTTPS-Authenticated/C/https-authenticated.c @@ -0,0 +1,22 @@ +#include +#include +#include "curl/curl.h" + +int +main(void) +{ + CURL *curl; + char buffer[CURL_ERROR_SIZE]; + + if ((curl = curl_easy_init()) != NULL) { + curl_easy_setopt(curl, CURLOPT_URL, "https://user:password@secure.example.com/"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer); + if (curl_easy_perform(curl) != CURLE_OK) { + fprintf(stderr, "%s\n", buffer); + return EXIT_FAILURE; + } + curl_easy_cleanup(curl); + } + return EXIT_SUCCESS; +} diff --git a/Task/HTTPS-Authenticated/Delphi/https-authenticated.delphi b/Task/HTTPS-Authenticated/Delphi/https-authenticated.delphi new file mode 100644 index 0000000000..50fea2bd9c --- /dev/null +++ b/Task/HTTPS-Authenticated/Delphi/https-authenticated.delphi @@ -0,0 +1,26 @@ +program ShowHTTPSAuthenticated; + +{$APPTYPE CONSOLE} + +uses IdHttp, IdSSLOpenSSL; + +var + s: string; + lHTTP: TIdHTTP; + lIOHandler: TIdSSLIOHandlerSocketOpenSSL; +begin + ReportMemoryLeaksOnShutdown := True; + lHTTP := TIdHTTP.Create(nil); + lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); + try + lHTTP.Request.Username := 'USERNAME'; + lHTTP.Request.Password := 'PASSWD'; + lHTTP.IOHandler := lIOHandler; + lHTTP.HandleRedirects := True; + s := lHTTP.Get('https://SomeSecureSite.net/'); + Writeln(s); + finally + lHTTP.Free; + lIOHandler.Free; + end; +end. diff --git a/Task/HTTPS-Authenticated/Go/https-authenticated-1.go b/Task/HTTPS-Authenticated/Go/https-authenticated-1.go new file mode 100644 index 0000000000..900c513161 --- /dev/null +++ b/Task/HTTPS-Authenticated/Go/https-authenticated-1.go @@ -0,0 +1,38 @@ +package main + +import ( + "encoding/base64" + "io" + "log" + "net/http" + "strings" +) + +const userPass = "rosetta:code" +const unauth = http.StatusUnauthorized + +func hw(w http.ResponseWriter, req *http.Request) { + auth := req.Header.Get("Authorization") + if !strings.HasPrefix(auth, "Basic ") { + log.Print("Invalid authorization:", auth) + http.Error(w, http.StatusText(unauth), unauth) + return + } + up, err := base64.StdEncoding.DecodeString(auth[6:]) + if err != nil { + log.Print("authorization decode error:", err) + http.Error(w, http.StatusText(unauth), unauth) + return + } + if string(up) != userPass { + log.Print("invalid username:password:", string(up)) + http.Error(w, http.StatusText(unauth), unauth) + return + } + io.WriteString(w, "Goodbye, World!") +} + +func main() { + http.HandleFunc("/", hw) + log.Fatal(http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", nil)) +} diff --git a/Task/HTTPS-Authenticated/Go/https-authenticated-2.go b/Task/HTTPS-Authenticated/Go/https-authenticated-2.go new file mode 100644 index 0000000000..c5c5cae6ad --- /dev/null +++ b/Task/HTTPS-Authenticated/Go/https-authenticated-2.go @@ -0,0 +1,49 @@ +package main + +import ( + "crypto/tls" + "crypto/x509" + "fmt" + "io/ioutil" + "log" + "net/http" +) + +const ( + userid = "rosetta" + password = "code" +) + +func main() { + // Use custom certificate for testing. Not exactly required by task. + b, err := ioutil.ReadFile("cert.pem") + if err != nil { + log.Fatal(err) + } + pool := x509.NewCertPool() + if ok := pool.AppendCertsFromPEM(b); !ok { + log.Fatal("Failed to append cert") + } + tc := &tls.Config{RootCAs: pool} + tr := &http.Transport{TLSClientConfig: tc} + client := &http.Client{Transport: tr} + req, err := http.NewRequest("GET", "https://127.0.0.1:8080", nil) + if err != nil { + log.Fatal(err) + } + + // This one line implements the authentication required for the task. + req.SetBasicAuth(userid, password) + + // Make request and show output. + resp, err := client.Do(req) + if err != nil { + log.Fatal(err) + } + b, err = ioutil.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + log.Fatal(err) + } + fmt.Println(string(b)) +} diff --git a/Task/HTTPS-Authenticated/Mathematica/https-authenticated.mathematica b/Task/HTTPS-Authenticated/Mathematica/https-authenticated.mathematica new file mode 100644 index 0000000000..f58759961d --- /dev/null +++ b/Task/HTTPS-Authenticated/Mathematica/https-authenticated.mathematica @@ -0,0 +1,2 @@ +a = RunThrough["curl -u JohnDoe:Password https://www.example.com", 1] +For[ i=0, i < Length[a] , i++, SomeFunction[a]] diff --git a/Task/HTTPS-Authenticated/Perl/https-authenticated.pl b/Task/HTTPS-Authenticated/Perl/https-authenticated.pl new file mode 100644 index 0000000000..d1fee678d6 --- /dev/null +++ b/Task/HTTPS-Authenticated/Perl/https-authenticated.pl @@ -0,0 +1,19 @@ +use LWP::UserAgent qw(); +my $ua = LWP::UserAgent->new; +my $netloc = 'http://www.buddhism-dict.net/cgi-bin/xpr-dealt.pl:80'; +$ua->credentials( + $netloc, + 'CJK-E and Buddhist Dictionaries', # basic realm + 'guest', # user + '', # empty pw +); +my $response = $ua->get($netloc); + +use WWW::Mechanize qw(); +my $mech = WWW::Mechanize->new; +$mech->get('https://login.yahoo.com/'); +$mech->submit_form(with_fields => { + login => 'XXXXXX', + passwd => 'YYYYYY', + '.persistent' => 'y', # tick checkbox +}); diff --git a/Task/HTTPS-Authenticated/PicoLisp/https-authenticated.l b/Task/HTTPS-Authenticated/PicoLisp/https-authenticated.l new file mode 100644 index 0000000000..0aaa4ac3b3 --- /dev/null +++ b/Task/HTTPS-Authenticated/PicoLisp/https-authenticated.l @@ -0,0 +1,4 @@ +(let (User "Bill" Pass "T0p5ecRet" Url "https://www.example.com") + (in (list 'curl "-u" (pack User ': Pass) Url) + (while (line) + (doSomeProcessingWithLine @) ) ) ) diff --git a/Task/HTTPS-Authenticated/Python/https-authenticated.py b/Task/HTTPS-Authenticated/Python/https-authenticated.py new file mode 100644 index 0000000000..5716181299 --- /dev/null +++ b/Task/HTTPS-Authenticated/Python/https-authenticated.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from mechanize import Browser + +USER_AGENT = "Mozilla/5.0 (X11; U; Linux i686; tr-TR; rv:1.8.1.9) Gecko/20071102 Pardus/2007 Firefox/2.0.0.9" + +br = Browser() +br.addheaders = [("User-agent", USER_AGENT)] + +# remove comment if you get debug output +# br.set_debug_redirects(True) +# br.set_debug_responses(True) +# br.set_debug_http(True) + +br.open("https://www.facebook.com") + +br.select_form("loginform") +br['email'] = "xxxxxxx@xxxxx.com" +br['pass'] = "xxxxxxxxx" +br['persistent'] = ["1"] + +response = br.submit() +print response.read() diff --git a/Task/HTTPS-Authenticated/Racket/https-authenticated.rkt b/Task/HTTPS-Authenticated/Racket/https-authenticated.rkt new file mode 100644 index 0000000000..561c82d773 --- /dev/null +++ b/Task/HTTPS-Authenticated/Racket/https-authenticated.rkt @@ -0,0 +1,22 @@ +#lang racket + +(require net/url + net/url-connect + openssl) + +(module+ main + (parameterize ([current-https-protocol (ssl-make-client-context)]) + (ssl-set-verify! (current-https-protocol) #t) + + ;; When this is #f, we correctly get an exception: + ;; error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed + (when #t + (ssl-load-verify-source! (current-https-protocol) + '(directory + ;; This location works on Debian 6; + ;; adjust as needed for your platform. + "/etc/ssl/certs" + ))) + + (for ([l (in-port read-line (get-pure-port (string->url "https://www.google.com/")))]) + (displayln l)))) diff --git a/Task/HTTPS-Authenticated/Tcl/https-authenticated.tcl b/Task/HTTPS-Authenticated/Tcl/https-authenticated.tcl new file mode 100644 index 0000000000..38221bc6cd --- /dev/null +++ b/Task/HTTPS-Authenticated/Tcl/https-authenticated.tcl @@ -0,0 +1,15 @@ +package require http +package require tls +http::register https 443 ::tls::socket + +# Generate the authentication +set user theUser +set pass thePassword +dict set auth Authenticate "Basic [binary encode base64 ${user}:${pass}]" + +# Make a secure authenticated connection +set token [http::geturl https://secure.example.com/ -headers $auth] + +# Now as for conventional use of the “http” package +set data [http::data $token] +http::cleanup $token diff --git a/Task/HTTPS-Client-authenticated/0DESCRIPTION b/Task/HTTPS-Client-authenticated/0DESCRIPTION new file mode 100644 index 0000000000..317cbf2349 --- /dev/null +++ b/Task/HTTPS-Client-authenticated/0DESCRIPTION @@ -0,0 +1,3 @@ +Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the [[HTTPS request with authentication]] task, it is ''not'' acceptable to perform the authentication by a username/password or a set cookie. + +This task is in general useful for use with [[Creating a SOAP Client|webservice client]]s as it offers a high level of assurance that the client is an acceptable counterparty for the server. For example, [http://aws.amazon.com/ Amazon Web Services] uses this style of authentication. diff --git a/Task/HTTPS-Client-authenticated/1META.yaml b/Task/HTTPS-Client-authenticated/1META.yaml new file mode 100644 index 0000000000..7948000013 --- /dev/null +++ b/Task/HTTPS-Client-authenticated/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Networking and Web Interaction +note: Programming environment operations diff --git a/Task/HTTPS-Client-authenticated/Mathematica/https-client-authenticated.mathematica b/Task/HTTPS-Client-authenticated/Mathematica/https-client-authenticated.mathematica new file mode 100644 index 0000000000..c6eb470fab --- /dev/null +++ b/Task/HTTPS-Client-authenticated/Mathematica/https-client-authenticated.mathematica @@ -0,0 +1,2 @@ +a = RunThrough["curl -E myCert.pem https://www.example.com", 1] +For[ i=0, i < Length[a] , i++, SomeFunction[a]] diff --git a/Task/HTTPS-Client-authenticated/PicoLisp/https-client-authenticated.l b/Task/HTTPS-Client-authenticated/PicoLisp/https-client-authenticated.l new file mode 100644 index 0000000000..b160a99ad8 --- /dev/null +++ b/Task/HTTPS-Client-authenticated/PicoLisp/https-client-authenticated.l @@ -0,0 +1,3 @@ +(in '(curl "-E" "myCert.pem" "https://www.example.com") + (while (line) + (doSomeProcessingWithLine @) ) ) diff --git a/Task/HTTPS-Client-authenticated/Tcl/https-client-authenticated.tcl b/Task/HTTPS-Client-authenticated/Tcl/https-client-authenticated.tcl new file mode 100644 index 0000000000..50af3cd34c --- /dev/null +++ b/Task/HTTPS-Client-authenticated/Tcl/https-client-authenticated.tcl @@ -0,0 +1,16 @@ +package require http +package require tls + +set cert myCert.p12 +http::register https 443 [list \ + ::tls::socket -certfile $cert -password getPass] +proc getPass {} { + return "myPassword"; # Just a noddy example... +} + +# Make a secure authenticated connection +set token [http::geturl https://verysecure.example.com/] + +# Now as for conventional use of the “http” package +set data [http::data $token] +http::cleanup $token diff --git a/Task/HTTPS/0DESCRIPTION b/Task/HTTPS/0DESCRIPTION new file mode 100644 index 0000000000..3ef351d1db --- /dev/null +++ b/Task/HTTPS/0DESCRIPTION @@ -0,0 +1,3 @@ +Print an HTTPS URL's content to the console. Checking the host certificate for validity is recommended. The client should not authenticate itself to the server — the webpage https://sourceforge.net/ supports that access policy — as that is the subject of other [[HTTPS request with authentication|tasks]]. + +Readers may wish to contrast with the [[HTTP Request]] task, and also the task on [[HTTPS request with authentication]]. diff --git a/Task/HTTPS/1META.yaml b/Task/HTTPS/1META.yaml new file mode 100644 index 0000000000..7948000013 --- /dev/null +++ b/Task/HTTPS/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Networking and Web Interaction +note: Programming environment operations diff --git a/Task/HTTPS/Ada/https.ada b/Task/HTTPS/Ada/https.ada new file mode 100644 index 0000000000..b7a5b7e86a --- /dev/null +++ b/Task/HTTPS/Ada/https.ada @@ -0,0 +1,8 @@ +with AWS.Client; +with AWS.Response; +with Ada.Text_IO; use Ada.Text_IO; +procedure GetHttps is +begin + Put_Line (AWS.Response.Message_Body (AWS.Client.Get ( + URL => "https://sourceforge.net/"))); +end GetHttps; diff --git a/Task/HTTPS/AutoHotkey/https.ahk b/Task/HTTPS/AutoHotkey/https.ahk new file mode 100644 index 0000000000..7d219d7d07 --- /dev/null +++ b/Task/HTTPS/AutoHotkey/https.ahk @@ -0,0 +1,7 @@ +URL := "https://sourceforge.net/" +WININET_Init() +msgbox % html := UrlGetContents(URL) +WININET_UnInit() +return +#include urlgetcontents.ahk +#include wininet.ahk diff --git a/Task/HTTPS/Batch-File/https.bat b/Task/HTTPS/Batch-File/https.bat new file mode 100644 index 0000000000..671237f9dd --- /dev/null +++ b/Task/HTTPS/Batch-File/https.bat @@ -0,0 +1 @@ +curl.exe -k -s -L https://sourceforge.net/ diff --git a/Task/HTTPS/C/https.c b/Task/HTTPS/C/https.c new file mode 100644 index 0000000000..e66c4d3e89 --- /dev/null +++ b/Task/HTTPS/C/https.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int +main(void) +{ + CURL *curl; + char buffer[CURL_ERROR_SIZE]; + + if ((curl = curl_easy_init()) != NULL) { + curl_easy_setopt(curl, CURLOPT_URL, "https://sourceforge.net/"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer); + if (curl_easy_perform(curl) != CURLE_OK) { + fprintf(stderr, "%s\n", buffer); + return EXIT_FAILURE; + } + curl_easy_cleanup(curl); + } + return EXIT_SUCCESS; +} diff --git a/Task/HTTPS/Clojure/https-1.clj b/Task/HTTPS/Clojure/https-1.clj new file mode 100644 index 0000000000..79bd7ed951 --- /dev/null +++ b/Task/HTTPS/Clojure/https-1.clj @@ -0,0 +1,2 @@ +(use '[clojure.contrib.duck-streams :only (slurp*)]) +(print (slurp* "https://sourceforge.net")) diff --git a/Task/HTTPS/Clojure/https-2.clj b/Task/HTTPS/Clojure/https-2.clj new file mode 100644 index 0000000000..aba8195cc3 --- /dev/null +++ b/Task/HTTPS/Clojure/https-2.clj @@ -0,0 +1 @@ +(print (slurp "https://sourceforge.net")) diff --git a/Task/HTTPS/Common-Lisp/https.lisp b/Task/HTTPS/Common-Lisp/https.lisp new file mode 100644 index 0000000000..204ddcb7ed --- /dev/null +++ b/Task/HTTPS/Common-Lisp/https.lisp @@ -0,0 +1,13 @@ +(defun wget-drakma-string (url &optional (out *standard-output*)) + "Grab the body as a string, and write it to out." + (write-string (drakma:http-request url) out)) + +(defun wget-drakma-stream (url &optional (out *standard-output*)) + "Grab the body as a stream, and write it to out." + (loop with body = (drakma:http-request url :want-stream t) + for line = (read-line body nil nil) + while line do (write-line line) + finally (close body))) + +;; Use +(wget-drakma-stream "https://sourceforge.net") diff --git a/Task/HTTPS/Delphi/https.delphi b/Task/HTTPS/Delphi/https.delphi new file mode 100644 index 0000000000..bfb69d86fd --- /dev/null +++ b/Task/HTTPS/Delphi/https.delphi @@ -0,0 +1,23 @@ +program ShowHTTPS; + +{$APPTYPE CONSOLE} + +uses IdHttp, IdSSLOpenSSL; + +var + s: string; + lHTTP: TIdHTTP; + lIOHandler: TIdSSLIOHandlerSocketOpenSSL; +begin + lHTTP := TIdHTTP.Create(nil); + lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); + try + lHTTP.IOHandler := lIOHandler; + lHTTP.HandleRedirects := True; + s := lHTTP.Get('https://sourceforge.net/'); + Writeln(s); + finally + lHTTP.Free; + lIOHandler.Free; + end; +end. diff --git a/Task/HTTPS/Erlang/https-1.erl b/Task/HTTPS/Erlang/https-1.erl new file mode 100644 index 0000000000..344402d972 --- /dev/null +++ b/Task/HTTPS/Erlang/https-1.erl @@ -0,0 +1,10 @@ +-module(main). +-export([main/1]). + +main([Url|[]]) -> + inets:start(), + ssl:start(), + case http:request(get, {URL, []}, [{ssl,[{verify,0}]}], []) of + {ok, {_V, _H, Body}} -> io:fwrite("~p~n",[Body]); + {error, Res} -> io:fwrite("~p~n", [Res]) + end. diff --git a/Task/HTTPS/Erlang/https-2.erl b/Task/HTTPS/Erlang/https-2.erl new file mode 100644 index 0000000000..bf79e30997 --- /dev/null +++ b/Task/HTTPS/Erlang/https-2.erl @@ -0,0 +1,12 @@ +-module(main). +-export([main/1]). + +main([Url|[]]) -> + inets:start(), + ssl:start(), + http:request(get, {Url, [] }, [{ssl,[{verify,0}]}], [{sync, false}]), + receive + {http, {_ReqId, Res}} -> io:fwrite("~p~n",[Res]); + _Any -> io:fwrite("Error: ~p~n",[_Any]) + after 10000 -> io:fwrite("Timed out.~n",[]) + end. diff --git a/Task/HTTPS/Erlang/https-3.erl b/Task/HTTPS/Erlang/https-3.erl new file mode 100644 index 0000000000..e21e8da7fd --- /dev/null +++ b/Task/HTTPS/Erlang/https-3.erl @@ -0,0 +1 @@ +|escript ./req.erl https://sourceforge.net/ diff --git a/Task/HTTPS/Go/https.go b/Task/HTTPS/Go/https.go new file mode 100644 index 0000000000..bacc87de32 --- /dev/null +++ b/Task/HTTPS/Go/https.go @@ -0,0 +1,16 @@ +package main + +import ( + "io" + "log" + "net/http" + "os" +) + +func main() { + r, err := http.Get("https://sourceforge.net/") + if err != nil { + log.Fatalln(err) + } + io.Copy(os.Stdout, r.Body) +} diff --git a/Task/HTTPS/Groovy/https.groovy b/Task/HTTPS/Groovy/https.groovy new file mode 100644 index 0000000000..024f9bc24e --- /dev/null +++ b/Task/HTTPS/Groovy/https.groovy @@ -0,0 +1 @@ +new URL("https://sourceforge.net").eachLine { println it } diff --git a/Task/HTTPS/Haskell/https.hs b/Task/HTTPS/Haskell/https.hs new file mode 100644 index 0000000000..1a08bd8ca2 --- /dev/null +++ b/Task/HTTPS/Haskell/https.hs @@ -0,0 +1,8 @@ +#!/usr/bin/runhaskell + +import Network.HTTP.Conduit +import qualified Data.ByteString.Lazy as L +import Network (withSocketsDo) + +main = withSocketsDo + $ simpleHttp "https://sourceforge.net/" >>= L.putStr diff --git a/Task/HTTPS/Ioke/https.ioke b/Task/HTTPS/Ioke/https.ioke new file mode 100644 index 0000000000..1529ff745f --- /dev/null +++ b/Task/HTTPS/Ioke/https.ioke @@ -0,0 +1,6 @@ +connection = URL new("https://sourceforge.net") openConnection +scanner = Scanner new(connection getInputStream) + +while(scanner hasNext, + scanner next println +) diff --git a/Task/HTTPS/J/https.j b/Task/HTTPS/J/https.j new file mode 100644 index 0000000000..cded0f0888 --- /dev/null +++ b/Task/HTTPS/J/https.j @@ -0,0 +1,4 @@ + #page=: gethttp'https://sourceforge.net' +0 + #page=: '--no-check-certificate' gethttp'https://sourceforge.net' +900 diff --git a/Task/HTTPS/Java/https.java b/Task/HTTPS/Java/https.java new file mode 100644 index 0000000000..8319544a35 --- /dev/null +++ b/Task/HTTPS/Java/https.java @@ -0,0 +1,7 @@ +URL url = new URL("https://sourceforge.net"); +HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); +Scanner scanner = new Scanner(connection.getInputStream()); + +while (scanner.hasNext()) { + System.out.println(scanner.next()); +} diff --git a/Task/HTTPS/LSL/https.lsl b/Task/HTTPS/LSL/https.lsl new file mode 100644 index 0000000000..0836458637 --- /dev/null +++ b/Task/HTTPS/LSL/https.lsl @@ -0,0 +1,20 @@ +string sURL = "https://SourceForge.Net/"; +key kHttpRequestId; +default { + state_entry() { + kHttpRequestId = llHTTPRequest(sURL, [], ""); + } + http_response(key kRequestId, integer iStatus, list lMetaData, string sBody) { + if(kRequestId==kHttpRequestId) { + llOwnerSay("Status="+(string)iStatus); + integer x = 0; + for(x=0 ; xnew->get( $url ); + +$response->is_success or die "Failed to GET '$url': ", $response->status_line; + +print $response->as_string; diff --git a/Task/HTTPS/PicoLisp/https.l b/Task/HTTPS/PicoLisp/https.l new file mode 100644 index 0000000000..6d1ac292e3 --- /dev/null +++ b/Task/HTTPS/PicoLisp/https.l @@ -0,0 +1,2 @@ +(in '(curl "https://sourceforge.net") # Open a pipe to 'curl' + (out NIL (echo)) ) # Echo to standard output diff --git a/Task/HTTPS/Python/https-1.py b/Task/HTTPS/Python/https-1.py new file mode 100644 index 0000000000..940fa8f50f --- /dev/null +++ b/Task/HTTPS/Python/https-1.py @@ -0,0 +1,2 @@ +from urllib.request import urlopen +print(urlopen('https://sourceforge.net/').read()) diff --git a/Task/HTTPS/Python/https-2.py b/Task/HTTPS/Python/https-2.py new file mode 100644 index 0000000000..69f0eab80f --- /dev/null +++ b/Task/HTTPS/Python/https-2.py @@ -0,0 +1,2 @@ +from urllib2 import urlopen +print urlopen('https://sourceforge.net/').read() diff --git a/Task/HTTPS/R/https-1.r b/Task/HTTPS/R/https-1.r new file mode 100644 index 0000000000..e0b57c4c86 --- /dev/null +++ b/Task/HTTPS/R/https-1.r @@ -0,0 +1,2 @@ +library(RCurl) +webpage <- getURL("https://sourceforge.net/", .opts=list(followlocation=TRUE, ssl.verifyhost=FALSE, ssl.verifypeer=FALSE)) diff --git a/Task/HTTPS/R/https-2.r b/Task/HTTPS/R/https-2.r new file mode 100644 index 0000000000..9336d5c7ff --- /dev/null +++ b/Task/HTTPS/R/https-2.r @@ -0,0 +1,2 @@ +wp <- readLines(tc <- textConnection(webpage)) +close(tc) diff --git a/Task/HTTPS/R/https-3.r b/Task/HTTPS/R/https-3.r new file mode 100644 index 0000000000..ae7146304d --- /dev/null +++ b/Task/HTTPS/R/https-3.r @@ -0,0 +1,2 @@ +pagetree <- htmlTreeParse(wp) +pagetree$children$html diff --git a/Task/HTTPS/Racket/https.rkt b/Task/HTTPS/Racket/https.rkt new file mode 100644 index 0000000000..b4edbbc87a --- /dev/null +++ b/Task/HTTPS/Racket/https.rkt @@ -0,0 +1,5 @@ +#lang racket +(require net/url) +(copy-port (get-pure-port (string->url "https://www.google.com") + #:redirections 100) + (current-output-port)) diff --git a/Task/HTTPS/Ruby/https.rb b/Task/HTTPS/Ruby/https.rb new file mode 100644 index 0000000000..6a1d5df7bd --- /dev/null +++ b/Task/HTTPS/Ruby/https.rb @@ -0,0 +1,15 @@ +require 'net/https' +require 'uri' +require 'pp' + +uri = URI.parse('https://sourceforge.net') +http = Net::HTTP.new(uri.host,uri.port) +http.use_ssl = true +http.verify_mode = OpenSSL::SSL::VERIFY_NONE + +http.start do + content = http.get("/") + p [content.code, content.message] + pp content.to_hash + puts content.body +end diff --git a/Task/HTTPS/Tcl/https.tcl b/Task/HTTPS/Tcl/https.tcl new file mode 100644 index 0000000000..01d846667c --- /dev/null +++ b/Task/HTTPS/Tcl/https.tcl @@ -0,0 +1,16 @@ +package require http +package require tls + +# Tell the http package what to do with “https:” URLs. +# +# First argument is the protocol name, second the default port, and +# third the connection builder command +http::register "https" 443 ::tls::socket + +# Make a secure connection, which is almost identical to normal +# connections except for the different protocol in the URL. +set token [http::geturl "https://sourceforge.net/"] + +# Now as for conventional use of the “http” package +puts [http::data $token] +http::cleanup $token diff --git a/Task/Hailstone-sequence/0DESCRIPTION b/Task/Hailstone-sequence/0DESCRIPTION new file mode 100644 index 0000000000..1727cdeab1 --- /dev/null +++ b/Task/Hailstone-sequence/0DESCRIPTION @@ -0,0 +1,14 @@ +The Hailstone sequence of numbers can be generated from a starting positive integer, n by: +* If n is 1 then the sequence ends. +* If n is even then the next n of the sequence = n/2 +* If n is odd then the next n of the sequence = (3 * n) + 1 + +The (unproven), [[wp:Collatz conjecture|Collatz conjecture]] is that the hailstone sequence for any starting number always terminates. + +'''Task Description:''' +# Create a routine to generate the hailstone sequence for a number. +# 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 +# Show the number less than 100,000 which has the longest hailstone sequence together with that sequence's length.
(But don't show the actual sequence!) + +'''See Also:'''
+* [http://xkcd.com/710 xkcd] (humourous). diff --git a/Task/Hailstone-sequence/ACL2/hailstone-sequence.acl2 b/Task/Hailstone-sequence/ACL2/hailstone-sequence.acl2 new file mode 100644 index 0000000000..a9cef3d313 --- /dev/null +++ b/Task/Hailstone-sequence/ACL2/hailstone-sequence.acl2 @@ -0,0 +1,16 @@ +(defun hailstone (len) + (loop for x = len + then (if (evenp x) + (/ x 2) + (+ 1 (* 3 x))) + collect x until (= x 1))) + +;; Must be tail recursive +(defun max-hailstone-start (limit mx curr) + (declare (xargs :mode :program)) + (if (zp limit) + (mv mx curr) + (let ((new-mx (len (hailstone limit)))) + (if (> new-mx mx) + (max-hailstone-start (1- limit) new-mx limit) + (max-hailstone-start (1- limit) mx curr))))) diff --git a/Task/Hailstone-sequence/ALGOL-68/hailstone-sequence.alg b/Task/Hailstone-sequence/ALGOL-68/hailstone-sequence.alg new file mode 100644 index 0000000000..4db7ecc248 --- /dev/null +++ b/Task/Hailstone-sequence/ALGOL-68/hailstone-sequence.alg @@ -0,0 +1,47 @@ +MODE LINT = # LONG ... # INT; + +PROC hailstone = (INT in n, REF[]LINT array)INT: +( + INT hs := 1; + INT index := 0; + LINT n := in n; + + WHILE n /= 1 DO + hs +:= 1; + IF array ISNT REF[]LINT(NIL) THEN array[index +:= 1] := n FI; + n := IF ODD n THEN 3*n+1 ELSE n OVER 2 FI + OD; + IF array ISNT REF[]LINT(NIL) THEN array[index +:= 1] := n FI; + hs +); + +main: +( + INT j, hmax := 0; + INT jatmax, n; + INT border = 4; + + FOR j TO 100000-1 DO + n := hailstone(j, NIL); + IF hmax < n THEN + hmax := n; + jatmax := j + FI + OD; + + [2]INT test := (27, jatmax); + FOR key TO UPB test DO + INT val = test[key]; + n := hailstone(val, NIL); + [n]LINT array; + n := hailstone(val, array); + + printf(($"[ "n(border)(g(0)", ")" ..."n(border)(", "g(0))"] len="g(0)l$, + array[:border], array[n-border+1:], n)) + #;free(array) # + OD; + printf(($"Max "g(0)" at j="g(0)l$, hmax, jatmax)) +# ELLA Algol68RS: + print(("Max",hmax," at j=",jatmax, new line)) +# +) diff --git a/Task/Hailstone-sequence/APL/hailstone-sequence-1.apl b/Task/Hailstone-sequence/APL/hailstone-sequence-1.apl new file mode 100644 index 0000000000..fae7c05161 --- /dev/null +++ b/Task/Hailstone-sequence/APL/hailstone-sequence-1.apl @@ -0,0 +1,9 @@ +seq←hailstone n;next +⍝ Returns the hailstone sequence for a given number + +seq←n ⍝ Init the sequence +:While n≠1 + next←(n÷2) (1+3×n) ⍝ Compute both possibilities + n←next[1+2|n] ⍝ Pick the appropriate next step + seq,←n ⍝ Append that to the sequence +:EndWhile diff --git a/Task/Hailstone-sequence/APL/hailstone-sequence-2.apl b/Task/Hailstone-sequence/APL/hailstone-sequence-2.apl new file mode 100644 index 0000000000..12ee97ce03 --- /dev/null +++ b/Task/Hailstone-sequence/APL/hailstone-sequence-2.apl @@ -0,0 +1,8 @@ + 5↑hailstone 27 +27 82 41 124 62 + ¯5↑hailstone 27 +16 8 4 2 1 + ⍴hailstone 27 +112 + 1↑{⍵[⍒↑(⍴∘hailstone)¨⍵]}⍳100000 +77031 diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada b/Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada new file mode 100644 index 0000000000..c35865216b --- /dev/null +++ b/Task/Hailstone-sequence/Ada/hailstone-sequence-1.ada @@ -0,0 +1,39 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure hailstone is + type int_arr is array(Positive range <>) of Integer; + type int_arr_pt is access all int_arr; + + function hailstones(num:Integer; pt:int_arr_pt) return Integer is + stones : Integer := 1; + n : Integer := num; + begin + if pt /= null then pt(1) := num; end if; + while (n/=1) loop + stones := stones + 1; + if n mod 2 = 0 then n := n/2; + else n := (3*n)+1; + end if; + if pt /= null then pt(stones) := n; end if; + end loop; + return stones; + end hailstones; + + nmax,stonemax,stones : Integer := 0; + list : int_arr_pt; +begin + stones := hailstones(27,null); + list := new int_arr(1..stones); + stones := hailstones(27,list); + put(" 27: "&Integer'Image(stones)); new_line; + for n in 1..4 loop put(Integer'Image(list(n))); end loop; + put(" .... "); + for n in stones-3..stones loop put(Integer'Image(list(n))); end loop; + new_line; + for n in 1..100000 loop + stones := hailstones(n,null); + if stones>stonemax then + nmax := n; stonemax := stones; + end if; + end loop; + put_line(Integer'Image(nmax)&" max @ n= "&Integer'Image(stonemax)); +end hailstone; diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-2.ada b/Task/Hailstone-sequence/Ada/hailstone-sequence-2.ada new file mode 100644 index 0000000000..d8f4280e02 --- /dev/null +++ b/Task/Hailstone-sequence/Ada/hailstone-sequence-2.ada @@ -0,0 +1,4 @@ +package Hailstones is + type Integer_Sequence is array(Positive range <>) of Integer; + function Create_Sequence (N : Positive) return Integer_Sequence; +end Hailstones; diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-3.ada b/Task/Hailstone-sequence/Ada/hailstone-sequence-3.ada new file mode 100644 index 0000000000..087766af63 --- /dev/null +++ b/Task/Hailstone-sequence/Ada/hailstone-sequence-3.ada @@ -0,0 +1,15 @@ +package body Hailstones is + function Create_Sequence (N : Positive) return Integer_Sequence is + begin + if N = 1 then + -- terminate + return (1 => N); + elsif N mod 2 = 0 then + -- even + return (1 => N) & Create_Sequence (N / 2); + else + -- odd + return (1 => N) & Create_Sequence (3 * N + 1); + end if; + end Create_Sequence; +end Hailstones; diff --git a/Task/Hailstone-sequence/Ada/hailstone-sequence-4.ada b/Task/Hailstone-sequence/Ada/hailstone-sequence-4.ada new file mode 100644 index 0000000000..3d48d60cbc --- /dev/null +++ b/Task/Hailstone-sequence/Ada/hailstone-sequence-4.ada @@ -0,0 +1,43 @@ +with Ada.Text_IO; +with Hailstones; + +procedure Main is + package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); + + procedure Print_Sequence (X : Hailstones.Integer_Sequence) is + begin + for I in X'Range loop + Integer_IO.Put (Item => X (I), Width => 0); + if I < X'Last then + Ada.Text_IO.Put (", "); + end if; + end loop; + Ada.Text_IO.New_Line; + end Print_Sequence; + + Hailstone_27 : constant Hailstones.Integer_Sequence := + Hailstones.Create_Sequence (N => 27); + +begin + Ada.Text_IO.Put_Line ("Length of 27:" & Integer'Image (Hailstone_27'Length)); + Ada.Text_IO.Put ("First four: "); + Print_Sequence (Hailstone_27 (Hailstone_27'First .. Hailstone_27'First + 3)); + Ada.Text_IO.Put ("Last four: "); + Print_Sequence (Hailstone_27 (Hailstone_27'Last - 3 .. Hailstone_27'Last)); + + declare + Longest_Length : Natural := 0; + Longest_N : Positive; + Length : Natural; + begin + for I in 1 .. 99_999 loop + Length := Hailstones.Create_Sequence (N => I)'Length; + if Length > Longest_Length then + Longest_Length := Length; + Longest_N := I; + end if; + end loop; + Ada.Text_IO.Put_Line ("Longest length is" & Integer'Image (Longest_Length)); + Ada.Text_IO.Put_Line ("with N =" & Integer'Image (Longest_N)); + end; +end Main; diff --git a/Task/Hailstone-sequence/AutoHotkey/hailstone-sequence.ahk b/Task/Hailstone-sequence/AutoHotkey/hailstone-sequence.ahk new file mode 100644 index 0000000000..7836e594bc --- /dev/null +++ b/Task/Hailstone-sequence/AutoHotkey/hailstone-sequence.ahk @@ -0,0 +1,40 @@ +; Submitted by MasterFocus --- http://tiny.cc/iTunis + +; [1] Generate the Hailstone Seq. for a number + +List := varNum := 7 ; starting number is 7, not counting elements +While ( varNum > 1 ) + List .= ", " ( varNum := ( Mod(varNum,2) ? (varNum*3)+1 : varNum//2 ) ) +MsgBox % List + +; [2] Seq. for starting number 27 has 112 elements + +Count := 1, List := varNum := 27 ; starting number is 27, counting elements +While ( varNum > 1 ) + Count++ , List .= ", " ( varNum := ( Mod(varNum,2) ? (varNum*3)+1 : varNum//2 ) ) +MsgBox % "Sequence:`n" List "`n`nCount: " Count + +; [3] Find number<100000 with longest seq. and show both values + +MaxNum := Max := 0 ; reset the Maximum variables +TimesToLoop := 100000 ; limit number here is 100000 +Offset := 70000 ; offset - use 0 to process from 0 to 100000 +Loop, %TimesToLoop% +{ + If ( TimesToLoop < ( varNum := Index := A_Index+Offset ) ) + Break + text := "Processing...`n-------------------`n" + text .= "Current starting number: " Index "`n" + text .= "Current sequence count: " Count + text .= "`n-------------------`n" + text .= "Maximum starting number: " MaxNum "`n" + text .= "Maximum sequence count: " Max " <<" ; text split to avoid long code lines + ToolTip, %text% + Count := 1 ; going to count the elements, but no "List" required + While ( varNum > 1 ) + Count++ , varNum := ( Mod(varNum,2) ? (varNum*3)+1 : varNum//2 ) + If ( Count > Max ) + Max := Count , MaxNum := Index ; set the new maximum values, if necessary +} +ToolTip +MsgBox % "Number: " MaxNum "`nCount: " Max diff --git a/Task/Hailstone-sequence/AutoIt/hailstone-sequence.autoit b/Task/Hailstone-sequence/AutoIt/hailstone-sequence.autoit new file mode 100644 index 0000000000..bf8b834c21 --- /dev/null +++ b/Task/Hailstone-sequence/AutoIt/hailstone-sequence.autoit @@ -0,0 +1,28 @@ +$Hail = Hailstone(27) +ConsoleWrite("Sequence-Lenght: "&$Hail&@CRLF) +$Big = -1 +$Sequenzlenght = -1 +For $I = 1 To 100000 + $Hail = Hailstone($i, False) + If Number($Hail) > $Sequenzlenght Then + $Sequenzlenght = Number($Hail) + $Big = $i + EndIf +Next +ConsoleWrite("Longest Sequence : "&$Sequenzlenght&" from number "&$Big&@CRLF) +Func Hailstone($int, $sequence = True) + $Counter = 0 + While True + $Counter += 1 + If $sequence = True Then ConsoleWrite($int & ",") + If $int = 1 Then ExitLoop + If Not Mod($int, 2) Then + $int = $int / 2 + Else + $int = 3 * $int + 1 + EndIf + If Not Mod($Counter, 25) AND $sequence = True Then ConsoleWrite(@CRLF) + WEnd + If $sequence = True Then ConsoleWrite(@CRLF) + Return $Counter +EndFunc ;==>Hailstone diff --git a/Task/Hailstone-sequence/BBC-BASIC/hailstone-sequence.bbc b/Task/Hailstone-sequence/BBC-BASIC/hailstone-sequence.bbc new file mode 100644 index 0000000000..cb03395d1f --- /dev/null +++ b/Task/Hailstone-sequence/BBC-BASIC/hailstone-sequence.bbc @@ -0,0 +1,23 @@ + seqlen% = FNhailstone(27, TRUE) + PRINT '"Sequence length = "; seqlen% + maxlen% = 0 + FOR number% = 2 TO 100000 + seqlen% = FNhailstone(number%, FALSE) + IF seqlen% > maxlen% THEN + maxlen% = seqlen% + maxnum% = number% + ENDIF + NEXT + PRINT "The number with the longest hailstone sequence is " ; maxnum% + PRINT "Its sequence length is " ; maxlen% + END + + DEF FNhailstone(N%, S%) + LOCAL L% + IF S% THEN PRINT N%; + WHILE N% <> 1 + IF N% AND 1 THEN N% = 3 * N% + 1 ELSE N% DIV= 2 + IF S% THEN PRINT N%; + L% += 1 + ENDWHILE + = L% + 1 diff --git a/Task/Hailstone-sequence/Batch-File/hailstone-sequence-1.bat b/Task/Hailstone-sequence/Batch-File/hailstone-sequence-1.bat new file mode 100644 index 0000000000..07d6ae4cf5 --- /dev/null +++ b/Task/Hailstone-sequence/Batch-File/hailstone-sequence-1.bat @@ -0,0 +1,31 @@ +@echo off +setlocal enabledelayedexpansion +if "%1" equ "" goto :eof +call :hailstone %1 seq cnt +echo %seq% +goto :eof + +:hailstone +set num=%1 +set %2=%1 + +:loop +if %num% equ 1 goto :eof +call :iseven %num% res +if %res% equ T goto divideby2 +set /a num = (3 * num) + 1 +set %2=!%2! %num% +goto loop +:divideby2 +set /a num = num / 2 +set %2=!%2! %num% +goto loop + +:iseven +set /a tmp = %1 %% 2 +if %tmp% equ 1 ( + set %2=F +) else ( + set %2=T +) +goto :eof diff --git a/Task/Hailstone-sequence/Batch-File/hailstone-sequence-2.bat b/Task/Hailstone-sequence/Batch-File/hailstone-sequence-2.bat new file mode 100644 index 0000000000..dcf4e48eb4 --- /dev/null +++ b/Task/Hailstone-sequence/Batch-File/hailstone-sequence-2.bat @@ -0,0 +1,2 @@ +>hailstone.cmd 20 +20 10 5 16 8 4 2 1 diff --git a/Task/Hailstone-sequence/Befunge/hailstone-sequence.bf b/Task/Hailstone-sequence/Befunge/hailstone-sequence.bf new file mode 100644 index 0000000000..cd49289286 --- /dev/null +++ b/Task/Hailstone-sequence/Befunge/hailstone-sequence.bf @@ -0,0 +1,4 @@ +&>:.:1-| + >3*^ @ + |%2: < + v>2/>+ diff --git a/Task/Hailstone-sequence/Bracmat/hailstone-sequence.bracmat b/Task/Hailstone-sequence/Bracmat/hailstone-sequence.bracmat new file mode 100644 index 0000000000..07f8f52f8e --- /dev/null +++ b/Task/Hailstone-sequence/Bracmat/hailstone-sequence.bracmat @@ -0,0 +1,43 @@ +( + ( hailstone + = L len + . !arg:?L + & whl + ' ( !arg:~1 + & (!arg*1/2:~/|3*!arg+1):?arg + & !arg !L:?L + ) + & (!L:? [?len&!len.!L) + ) +& ( reverse + = L e + . :?L + & whl'(!arg:%?e ?arg&!e !L:?L) + & !L + ) +& hailstone$27:(?len.?list) +& reverse$!list:?first4 [4 ? [-5 ?last4 +& put$"Hailstone sequence starting with " +& put$!first4 +& put$(str$(" has " !len " elements and ends with ")) +& put$(!last4 \n) +& 1:?N +& 0:?max:?Nmax +& whl + ' ( !N+1:<100000:?N + & hailstone$!N + : ( >!max:?max&!N:?Nmax + | ? + . ? + ) + ) +& out + $ ( str + $ ( "The number <100000 with the longest hailstone sequence is " + !Nmax + " with " + !max + " elements." + ) + ) +); diff --git a/Task/Hailstone-sequence/Brainf---/hailstone-sequence-1.bf b/Task/Hailstone-sequence/Brainf---/hailstone-sequence-1.bf new file mode 100644 index 0000000000..2f2ffa9feb --- /dev/null +++ b/Task/Hailstone-sequence/Brainf---/hailstone-sequence-1.bf @@ -0,0 +1,12 @@ +>,[ + [ + ----------[ + >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<] + ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],< + ]> + ]>>>++>+>>[ + <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>] + >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]] + >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>> + ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<, +] diff --git a/Task/Hailstone-sequence/Brainf---/hailstone-sequence-2.bf b/Task/Hailstone-sequence/Brainf---/hailstone-sequence-2.bf new file mode 100644 index 0000000000..04b243761b --- /dev/null +++ b/Task/Hailstone-sequence/Brainf---/hailstone-sequence-2.bf @@ -0,0 +1,2 @@ +27 +111 diff --git a/Task/Hailstone-sequence/Brat/hailstone-sequence.brat b/Task/Hailstone-sequence/Brat/hailstone-sequence.brat new file mode 100644 index 0000000000..01e602898b --- /dev/null +++ b/Task/Hailstone-sequence/Brat/hailstone-sequence.brat @@ -0,0 +1,33 @@ +hailstone = { num | + sequence = [num] + while { num != 1 } + { true? num % 2 == 0 + { num = num / 2 } + { num = num * 3 + 1 } + sequence << num + } + + sequence +} + +#Check sequence for 27 +seq = hailstone 27 +true? (seq[0,3] == [27 82 41 124] && seq[-1, -4] == [8 4 2 1]) + { p "Sequence for 27 is correct" } + { p "Sequence for 27 is not correct!" } + +#Find longest sequence for numbers < 100,000 +longest = [number: 0 length: 0] + +1.to 99999 { index | + seq = hailstone index + true? seq.length > longest[:length] + { longest[:length] = seq.length + longest[:number] = index + p "Longest so far: #{index} @ #{longest[:length]} elements" + } + + index = index + 1 + } + +p "Longest was starting from #{longest[:number]} and was of length #{longest[:length]}" diff --git a/Task/Hailstone-sequence/Burlesque/hailstone-sequence.blq b/Task/Hailstone-sequence/Burlesque/hailstone-sequence.blq new file mode 100644 index 0000000000..d4020be2d8 --- /dev/null +++ b/Task/Hailstone-sequence/Burlesque/hailstone-sequence.blq @@ -0,0 +1,2 @@ +blsq ) 27{^^^^2.%{3.*1.+}\/{2./}\/ie}{1!=}w!bx{\/+]}{\/isn!}w!L[ +112 diff --git a/Task/Hailstone-sequence/C++/hailstone-sequence.cpp b/Task/Hailstone-sequence/C++/hailstone-sequence.cpp new file mode 100644 index 0000000000..610b7ed97e --- /dev/null +++ b/Task/Hailstone-sequence/C++/hailstone-sequence.cpp @@ -0,0 +1,50 @@ +#include +#include +#include + +std::vector hailstone(int i) +{ + std::vector v; + while(true){ + v.push_back(i); + if (1 == i) break; + i = (i % 2) ? (3 * i + 1) : (i / 2); + } + return v; +} + +std::pair find_longest_hailstone_seq(int n) +{ + std::pair maxseq(0, 0); + int l; + for(int i = 1; i < n; ++i){ + l = hailstone(i).size(); + if (l > maxseq.second) maxseq = std::make_pair(i, l); + } + return maxseq; +} + +int main () { + +// Use the routine to show that the hailstone sequence for the number 27 + std::vector h27; + h27 = hailstone(27); +// has 112 elements + int l = h27.size(); + std::cout << "length of hailstone(27) is " << l; +// starting with 27, 82, 41, 124 and + std::cout << " first four elements of hailstone(27) are "; + std::cout << h27[0] << " " << h27[1] << " " + << h27[2] << " " << h27[3] << std::endl; +// ending with 8, 4, 2, 1 + std::cout << " last four elements of hailstone(27) are " + << h27[l-4] << " " << h27[l-3] << " " + << h27[l-2] << " " << h27[l-1] << std::endl; + + std::pair m = find_longest_hailstone_seq(100000); + + std::cout << "the longest hailstone sequence under 100,000 is " << m.first + << " with " << m.second << " elements." < +#include + +int hailstone(int n, int *arry) +{ + int hs = 1; + + while (n!=1) { + hs++; + if (arry) *arry++ = n; + n = (n&1) ? (3*n+1) : (n/2); + } + if (arry) *arry++ = n; + return hs; +} + +int main() +{ + int j, hmax = 0; + int jatmax, n; + int *arry; + + for (j=1; j<100000; j++) { + n = hailstone(j, NULL); + if (hmax < n) { + hmax = n; + jatmax = j; + } + } + n = hailstone(27, NULL); + arry = malloc(n*sizeof(int)); + n = hailstone(27, arry); + + printf("[ %d, %d, %d, %d, ...., %d, %d, %d, %d] len=%d\n", + arry[0],arry[1],arry[2],arry[3], + arry[n-4], arry[n-3], arry[n-2], arry[n-1], n); + printf("Max %d at j= %d\n", hmax, jatmax); + free(arry); + + return 0; +} diff --git a/Task/Hailstone-sequence/C/hailstone-sequence-2.c b/Task/Hailstone-sequence/C/hailstone-sequence-2.c new file mode 100644 index 0000000000..63848c2721 --- /dev/null +++ b/Task/Hailstone-sequence/C/hailstone-sequence-2.c @@ -0,0 +1,31 @@ +#include + +#define N 10000000 +#define CS N /* cache size */ + +typedef unsigned long ulong; +ulong cache[CS] = {0}; + +ulong hailstone(ulong n) +{ + int x; + if (n == 1) return 1; + if (n < CS && cache[n]) return cache[n]; + + x = 1 + hailstone((n & 1) ? 3 * n + 1 : n / 2); + if (n < CS) cache[n] = x; + return x; +} + +int main() +{ + int i, l, max = 0, mi; + for (i = 1; i < N; i++) { + if ((l = hailstone(i)) > max) { + max = l; + mi = i; + } + } + printf("max below %d: %d, length %d\n", N, mi, max); + return 0; +} diff --git a/Task/Hailstone-sequence/CLIPS/hailstone-sequence.clips b/Task/Hailstone-sequence/CLIPS/hailstone-sequence.clips new file mode 100644 index 0000000000..d81d7b12a8 --- /dev/null +++ b/Task/Hailstone-sequence/CLIPS/hailstone-sequence.clips @@ -0,0 +1,76 @@ +(deftemplate longest + (slot bound) ; upper bound for the range of values to check + (slot next (default 2)) ; next value that needs to be checked + (slot start (default 1)) ; starting value of longest sequence + (slot len (default 1)) ; length of longest sequence +) + +(deffacts startup + (query 27) + (longest (bound 100000)) +) + +(deffunction hailstone-next + (?n) + (if (evenp ?n) + then (div ?n 2) + else (+ (* 3 ?n) 1) + ) +) + +(defrule extend-sequence + ?hail <- (hailstone $?sequence ?tail&:(> ?tail 1)) + => + (retract ?hail) + (assert (hailstone ?sequence ?tail (hailstone-next ?tail))) +) + +(defrule start-query + (query ?num) + => + (assert (hailstone ?num)) +) + +(defrule result-query + (query ?num) + (hailstone ?num $?sequence 1) + => + (bind ?sequence (create$ ?num ?sequence 1)) + (printout t "Hailstone sequence starting with " ?num ":" crlf) + (bind ?len (length ?sequence)) + (printout t " Length: " ?len crlf) + (printout t " First four: " (implode$ (subseq$ ?sequence 1 4)) crlf) + (printout t " Last four: " (implode$ (subseq$ ?sequence (- ?len 3) ?len)) crlf) + (printout t crlf) +) + +(defrule longest-create-next-hailstone + (longest (bound ?bound) (next ?next)) + (test (<= ?next ?bound)) + (not (hailstone ?next $?)) + => + (assert (hailstone ?next)) +) + +(defrule longest-check-next-hailstone + ?longest <- (longest (bound ?bound) (next ?next) (start ?start) (len ?len)) + (test (<= ?next ?bound)) + ?hailstone <- (hailstone ?next $?sequence 1) + => + (retract ?hailstone) + (bind ?thislen (+ 2 (length ?sequence))) + (if (> ?thislen ?len) then + (modify ?longest (start ?next) (len ?thislen) (next (+ ?next 1))) + else + (modify ?longest (next (+ ?next 1))) + ) +) + +(defrule longest-finished + (longest (bound ?bound) (next ?next) (start ?start) (len ?len)) + (test (> ?next ?bound)) + => + (printout t "The number less than " ?bound " that has the largest hailstone" crlf) + (printout t "sequence is " ?start " with a length of " ?len "." crlf) + (printout t crlf) +) diff --git a/Task/Hailstone-sequence/Clojure/hailstone-sequence.clj b/Task/Hailstone-sequence/Clojure/hailstone-sequence.clj new file mode 100644 index 0000000000..d4e57820e6 --- /dev/null +++ b/Task/Hailstone-sequence/Clojure/hailstone-sequence.clj @@ -0,0 +1,17 @@ +(defn hailstone-seq [n] + (:pre [(pos? n)]) + (lazy-seq + (cond (= n 1) '(1) + (even? n) (cons n (hailstone-seq (/ n 2))) + :else (cons n (hailstone-seq (+ (* n 3) 1)))))) + +(def hseq27 (hailstone-seq 27)) +(assert (= (count hseq27) 112)) +(assert (= (take 4 hseq27) [27 82 41 124])) +(assert (= (drop 108 hseq27) [8 4 2 1])) + +(let [{max-i :num, max-len :len} + (reduce #(max-key :len %1 %2) + (for [i (range 1 100000)] + {:num i, :len (count (hailstone-seq i))}))] + (println "Maximum length" max-len "was found for hailstone(" max-i ").")) diff --git a/Task/Hailstone-sequence/CoffeeScript/hailstone-sequence.coffee b/Task/Hailstone-sequence/CoffeeScript/hailstone-sequence.coffee new file mode 100644 index 0000000000..261496f285 --- /dev/null +++ b/Task/Hailstone-sequence/CoffeeScript/hailstone-sequence.coffee @@ -0,0 +1,26 @@ +hailstone = (n) -> + if n is 1 + [n] + + else if n % 2 is 0 + [n].concat hailstone n/2 + + else + [n].concat hailstone (3*n) + 1 + +h27 = hailstone 27 +console.log "hailstone(27) = #{h27[0..3]} ... #{h27[-4..]} (length: #{h27.length})" + +maxlength = 0 +maxnums = [] + +for i in [1..100000] + seq = hailstone i + + if seq.length is maxlength + maxnums.push i + else if seq.length > maxlength + maxlength = seq.length + maxnums = [i] + +console.log "Max length: #{maxlength}; numbers generating sequences of this length: #{maxnums}" diff --git a/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp b/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp new file mode 100644 index 0000000000..88bd0f3f1f --- /dev/null +++ b/Task/Hailstone-sequence/Common-Lisp/hailstone-sequence.lisp @@ -0,0 +1,11 @@ +(defun hailstone (n) + (cond ((= n 1) '(1)) + ((evenp n) (cons n (hailstone (/ n 2)))) + (t (cons n (hailstone (+ (* 3 n) 1)))))) + +(defun longest (n) + (let ((k 0) (l 0)) + (loop for i from 1 below n do + (let ((len (length (hailstone i)))) + (when (> len l) (setq l len k i))) + finally (format t "Longest hailstone sequence under ~A for ~A, having length ~A." n k l)))) diff --git a/Task/Hailstone-sequence/D/hailstone-sequence-1.d b/Task/Hailstone-sequence/D/hailstone-sequence-1.d new file mode 100644 index 0000000000..16c52648b5 --- /dev/null +++ b/Task/Hailstone-sequence/D/hailstone-sequence-1.d @@ -0,0 +1,22 @@ +import std.stdio, std.algorithm, std.range, std.typecons; + +auto hailstone(int n) pure nothrow { + auto result = [n]; + while (n != 1) { + n = n & 1 ? n*3 + 1 : n/2; + result ~= n; + } + return result; +} + +void main() { + enum M = 27; + auto h = hailstone(M); + writeln("hailstone(", M, ")= ", h[0 .. 4], " ... " , h[$-4 .. $]); + writeln("length hailstone(", M, ")= ", h.length); + + enum N = 100_000; + auto s = iota(1, N).map!(i => tuple(hailstone(i).length, i))(); + auto p = reduce!max(s); + writeln("Longest sequence in [1,", N, "]= ",p[1]," with len ",p[0]); +} diff --git a/Task/Hailstone-sequence/D/hailstone-sequence-2.d b/Task/Hailstone-sequence/D/hailstone-sequence-2.d new file mode 100644 index 0000000000..a2c0c4fca5 --- /dev/null +++ b/Task/Hailstone-sequence/D/hailstone-sequence-2.d @@ -0,0 +1,20 @@ +import std.stdio, std.algorithm, std.range, std.typecons; + +struct Hail { + int n; + bool empty() { return n == 0; } + int front() { return n; } + void popFront() { n = n == 1 ? 0 : (n & 1 ? n*3 + 1 : n/2); } +} + +void main() { + enum M = 27; + auto h = array(Hail(M)); + writeln("hailstone(", M, ")= ", h[0 .. 4], " ... " , h[$-4 .. $]); + writeln("length hailstone(", M, ")= ", h.length); + + enum N = 100_000; + auto s = map!(i => tuple(walkLength(Hail(i)), i))(iota(1, N)); + auto p = reduce!max(s); + writeln("Longest sequence in [1,", N, "]= ",p[1]," with len ",p[0]); +} diff --git a/Task/Hailstone-sequence/Dart/hailstone-sequence.dart b/Task/Hailstone-sequence/Dart/hailstone-sequence.dart new file mode 100644 index 0000000000..6dda425798 --- /dev/null +++ b/Task/Hailstone-sequence/Dart/hailstone-sequence.dart @@ -0,0 +1,52 @@ +List hailstone(int n) { + if(n<=0) { + throw new IllegalArgumentException("start value must be >=1)"); + } + Queue seq=new Queue(); + seq.add(n); + while(n!=1) { + n=n%2==0?(n/2).toInt():3*n+1; + seq.add(n); + } + return new List.from(seq); +} + +// apparently List is missing toString() +String iterableToString(Iterable seq) { + String str="["; + Iterator i=seq.iterator(); + while(i.hasNext()) { + str+=i.next(); + if(i.hasNext()) { + str+=","; + } + } + return str+"]"; +} + +main() { + for(int i=1;i<=10;i++) { + print("h($i)="+iterableToString(hailstone(i))); + } + List h27=hailstone(27); + List first4=h27.getRange(0,4); + print("first 4 elements of h(27): "+iterableToString(first4)); + Expect.listEquals([27,82,41,124],first4); + + List last4=h27.getRange(h27.length-4,4); + print("last 4 elements of h(27): "+iterableToString(last4)); + Expect.listEquals([8,4,2,1],last4); + + print("length of sequence h(27): "+h27.length); + Expect.equals(112,h27.length); + + int seq,max=0; + for(int i=1;i<=100000;i++) { + List h=hailstone(i); + if(h.length>max) { + max=h.length; + seq=i; + } + } + print("up to 100000 the sequence h($seq) has the largest length ($max)"); +} diff --git a/Task/Hailstone-sequence/Dc/hailstone-sequence-1.dc b/Task/Hailstone-sequence/Dc/hailstone-sequence-1.dc new file mode 100644 index 0000000000..1783a390b5 --- /dev/null +++ b/Task/Hailstone-sequence/Dc/hailstone-sequence-1.dc @@ -0,0 +1,5 @@ +27 +[[--: ]nzpq]sq +[d 2/ p]se +[d 3*1+ p]so +[d2% 0=e d1=q d2% 1=o d1=q lxx]dsxx diff --git a/Task/Hailstone-sequence/Dc/hailstone-sequence-2.dc b/Task/Hailstone-sequence/Dc/hailstone-sequence-2.dc new file mode 100644 index 0000000000..e658ede6ae --- /dev/null +++ b/Task/Hailstone-sequence/Dc/hailstone-sequence-2.dc @@ -0,0 +1,8 @@ +0dsLsT1st +[dsLltsT]sM +[[zdlLl]dslx +lTn[:]nlLp diff --git a/Task/Hailstone-sequence/Delphi/hailstone-sequence.delphi b/Task/Hailstone-sequence/Delphi/hailstone-sequence.delphi new file mode 100644 index 0000000000..b564a7ea34 --- /dev/null +++ b/Task/Hailstone-sequence/Delphi/hailstone-sequence.delphi @@ -0,0 +1,57 @@ +program ShowHailstoneSequence; + +{$APPTYPE CONSOLE} + +uses SysUtils, Generics.Collections; + +procedure GetHailstoneSequence(aStartingNumber: Integer; aHailstoneList: TList); +var + n: Integer; +begin + aHailstoneList.Clear; + aHailstoneList.Add(aStartingNumber); + n := aStartingNumber; + + while n <> 1 do + begin + if Odd(n) then + n := (3 * n) + 1 + else + n := n div 2; + aHailstoneList.Add(n); + end; +end; + +var + i: Integer; + lList: TList; + lMaxSequence: Integer; + lMaxLength: Integer; +begin + lList := TList.Create; + try + GetHailstoneSequence(27, lList); + Writeln(Format('27: %d elements', [lList.Count])); + Writeln(Format('[%d,%d,%d,%d ... %d,%d,%d,%d]', + [lList[0], lList[1], lList[2], lList[3], + lList[lList.Count - 4], lList[lList.Count - 3], lList[lList.Count - 2], lList[lList.Count - 1]])); + Writeln; + + lMaxSequence := 0; + lMaxLength := 0; + for i := 1 to 100000 do + begin + GetHailstoneSequence(i, lList); + if lList.Count > lMaxLength then + begin + lMaxSequence := i; + lMaxLength := lList.Count; + end; + end; + Writeln(Format('Longest sequence under 100,000: %d with %d elements', [lMaxSequence, lMaxLength])); + finally + lList.Free; + end; + + Readln; +end. diff --git a/Task/Hailstone-sequence/Erlang/hailstone-sequence.erl b/Task/Hailstone-sequence/Erlang/hailstone-sequence.erl new file mode 100644 index 0000000000..8f4c932716 --- /dev/null +++ b/Task/Hailstone-sequence/Erlang/hailstone-sequence.erl @@ -0,0 +1,24 @@ +-module(hailstone). +-import(io). +-export([main/0]). + +hailstone(1) -> [1]; +hailstone(N) when N band 1 == 1 -> [N|hailstone(N * 3 + 1)]; +hailstone(N) when N band 1 == 0 -> [N|hailstone(N div 2)]. + +max_length(Start, Stop) -> + F = fun (N) -> {length(hailstone(N)), N} end, + Lengths = lists:map(F, lists:seq(Start, Stop)), + lists:max(Lengths). + +main() -> + io:format("hailstone(4): ~w~n", [hailstone(4)]), + Seq27 = hailstone(27), + io:format("hailstone(27) length: ~B~n", [length(Seq27)]), + io:format("hailstone(27) first 4: ~w~n", + [lists:sublist(Seq27, 4)]), + io:format("hailstone(27) last 4: ~w~n", + [lists:nthtail(length(Seq27) - 4, Seq27)]), + io:format("finding maximum hailstone(N) length for 1 <= N <= 100000..."), + {Length, N} = max_length(1, 100000), + io:format(" done.~nhailstone(~B) length: ~B~n", [N, Length]). diff --git a/Task/Hailstone-sequence/Euler-Math-Toolbox/hailstone-sequence.euler b/Task/Hailstone-sequence/Euler-Math-Toolbox/hailstone-sequence.euler new file mode 100644 index 0000000000..538e8b2bf8 --- /dev/null +++ b/Task/Hailstone-sequence/Euler-Math-Toolbox/hailstone-sequence.euler @@ -0,0 +1,44 @@ +>function hailstone (n) ... +$ v=[n]; +$ repeat +$ if mod(n,2) then n=3*n+1; +$ else n=n/2; +$ endif; +$ v=v|n; +$ until n==1; +$ end; +$ return v; +$ endfunction +>hailstone(27), length(%) + [ 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 + 121 364 182 91 274 137 412 206 103 310 155 466 233 700 + 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 + 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 + 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 + 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 + 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 + 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 ] + 112 +>function hailstonelength (n) ... +$ v=zeros(1,n); +$ v[1]=4; v[2]=2; +$ loop 3 to n; +$ count=1; +$ n=#; +$ repeat +$ if mod(n,2) then n=3*n+1; +$ else n=n/2; +$ endif; +$ if n<=cols(v) and v[n] then +$ v[#]=v[n]+count; +$ break; +$ endif; +$ count=count+1; +$ end; +$ end; +$ return v; +$ endfunction +>h=hailstonelength(100000); +>ex=extrema(h); ex[3], ex[4] + 351 + 77031 diff --git a/Task/Hailstone-sequence/Euphoria/hailstone-sequence.euphoria b/Task/Hailstone-sequence/Euphoria/hailstone-sequence.euphoria new file mode 100644 index 0000000000..4fb0b52522 --- /dev/null +++ b/Task/Hailstone-sequence/Euphoria/hailstone-sequence.euphoria @@ -0,0 +1,46 @@ +function hailstone(atom n) + sequence s + s = {n} + while n != 1 do + if remainder(n,2)=0 then + n /= 2 + else + n = 3*n + 1 + end if + s &= n + end while + return s +end function + +function hailstone_count(atom n) + integer count + count = 1 + while n != 1 do + if remainder(n,2)=0 then + n /= 2 + else + n = 3*n + 1 + end if + count += 1 + end while + return count +end function + +sequence s +s = hailstone(27) +puts(1,"hailstone(27) =\n") +? s +printf(1,"len = %d\n\n",length(s)) + +integer max,imax,count +max = 0 +for i = 2 to 1e5-1 do + count = hailstone_count(i) + if count > max then + max = count + imax = i + end if +end for + +printf(1,"The longest hailstone sequence under 100,000 is %d with %d elements.\n", + {imax,max}) diff --git a/Task/Hailstone-sequence/FALSE/hailstone-sequence.false b/Task/Hailstone-sequence/FALSE/hailstone-sequence.false new file mode 100644 index 0000000000..d2349329c0 --- /dev/null +++ b/Task/Hailstone-sequence/FALSE/hailstone-sequence.false @@ -0,0 +1,8 @@ +[$1&$[%3*1+0~]?~[2/]?]n: +[[$." "$1>][n;!]#%]s: +[1\[$1>][\1+\n;!]#%]c: +27s;! 27c;!." +" +0m:0f: +1[$100000\>][$c;!$m;>[m:$f:0]?%1+]#% +f;." has hailstone sequence length "m;. diff --git a/Task/Hailstone-sequence/Factor/hailstone-sequence.factor b/Task/Hailstone-sequence/Factor/hailstone-sequence.factor new file mode 100644 index 0000000000..94ac4bbf28 --- /dev/null +++ b/Task/Hailstone-sequence/Factor/hailstone-sequence.factor @@ -0,0 +1,31 @@ +! rosetta/hailstone/hailstone.factor +USING: arrays io kernel math math.ranges prettyprint sequences vectors ; +IN: rosetta.hailstone + +: hailstone ( n -- seq ) + [ 1vector ] keep + [ dup 1 number= ] + [ + dup even? [ 2 / ] [ 3 * 1 + ] if + 2dup swap push + ] until + drop ; + + { length n }, and reduces to longest Hailstone sequence. + 1 100000 [a,b) + [ [ hailstone length ] keep 2array ] + [ [ [ first ] bi@ > ] most ] map-reduce + first2 + "The hailstone sequence from " write pprint + " has length " write pprint "." print ; +PRIVATE> + +MAIN: main diff --git a/Task/Hailstone-sequence/Forth/hailstone-sequence.fth b/Task/Hailstone-sequence/Forth/hailstone-sequence.fth new file mode 100644 index 0000000000..d44f57abd1 --- /dev/null +++ b/Task/Hailstone-sequence/Forth/hailstone-sequence.fth @@ -0,0 +1,19 @@ +: hail-next ( n -- n ) + dup 1 and if 3 * 1+ else 2/ then ; +: .hail ( n -- ) + begin dup . dup 1 > while hail-next repeat drop ; +: hail-len ( n -- n ) + 1 begin over 1 > while swap hail-next swap 1+ repeat nip ; + +27 hail-len . cr +27 .hail cr + +: longest-hail ( max -- ) + 0 0 rot 1+ 1 do ( n length ) + i hail-len 2dup < if + nip nip i swap + else drop then + loop + swap . ." has hailstone sequence length " . ; + +100000 longest-hail diff --git a/Task/Hailstone-sequence/Fortran/hailstone-sequence.f b/Task/Hailstone-sequence/Fortran/hailstone-sequence.f new file mode 100644 index 0000000000..4112821c45 --- /dev/null +++ b/Task/Hailstone-sequence/Fortran/hailstone-sequence.f @@ -0,0 +1,49 @@ +program Hailstone + implicit none + + integer :: i, maxn + integer :: maxseqlen = 0, seqlen + integer, allocatable :: seq(:) + + call hs(27, seqlen) + allocate(seq(seqlen)) + call hs(27, seqlen, seq) + write(*,"(a,i0,a)") "Hailstone sequence for 27 has ", seqlen, " elements" + write(*,"(a,4(i0,a),3(i0,a),i0)") "Sequence = ", seq(1), ", ", seq(2), ", ", seq(3), ", ", seq(4), " ...., ", & + seq(seqlen-3), ", ", seq(seqlen-2), ", ", seq(seqlen-1), ", ", seq(seqlen) + + do i = 1, 99999 + call hs(i, seqlen) + if (seqlen > maxseqlen) then + maxseqlen = seqlen + maxn = i + end if + end do + write(*,*) + write(*,"(a,i0,a,i0,a)") "Longest sequence under 100000 is for ", maxn, " with ", maxseqlen, " elements" + + deallocate(seq) + +contains + +subroutine hs(number, length, seqArray) + integer, intent(in) :: number + integer, intent(out) :: length + integer, optional, intent(inout) :: seqArray(:) + integer :: n + + n = number + length = 1 + if(present(seqArray)) seqArray(1) = n + do while(n /= 1) + if(mod(n,2) == 0) then + n = n / 2 + else + n = n * 3 + 1 + end if + length = length + 1 + if(present(seqArray)) seqArray(length) = n + end do +end subroutine + +end program diff --git a/Task/Hailstone-sequence/Frege/hailstone-sequence.frege b/Task/Hailstone-sequence/Frege/hailstone-sequence.frege new file mode 100644 index 0000000000..842065eda6 --- /dev/null +++ b/Task/Hailstone-sequence/Frege/hailstone-sequence.frege @@ -0,0 +1,19 @@ +module Hailstone where + +import Data.List (maximumBy) + +hailstone :: Int -> [Int] +hailstone 1 = [1] +hailstone n | even n = n : hailstone (n `div` 2) + | otherwise = n : hailstone (n * 3 + 1) + +withResult :: (t -> t1) -> t -> (t1, t) +withResult f x = (f x, x) + +main _ = do + let h27 = hailstone 27 + printStrLn $ show $ length h27 + let h4 = show $ take 4 h27 + let t4 = show $ drop (length h27 - 4) h27 + printStrLn ("hailstone 27: " ++ h4 ++ " ... " ++ t4) + printStrLn $ show $ maximumBy (comparing fst) $ map (withResult (length . hailstone)) (1..100000) diff --git a/Task/Hailstone-sequence/GAP/hailstone-sequence.gap b/Task/Hailstone-sequence/GAP/hailstone-sequence.gap new file mode 100644 index 0000000000..670ae2b5c4 --- /dev/null +++ b/Task/Hailstone-sequence/GAP/hailstone-sequence.gap @@ -0,0 +1,60 @@ +CollatzSequence := function(n) + local v; + v := [ n ]; + while n > 1 do + if IsEvenInt(n) then + n := QuoInt(n, 2); + else + n := 3*n + 1; + fi; + Add(v, n); + od; + return v; +end; + +CollatzLength := function(n) + local m; + m := 1; + while n > 1 do + if IsEvenInt(n) then + n := QuoInt(n, 2); + else + n := 3*n + 1; + fi; + m := m + 1; + od; + return m; +end; + +CollatzMax := function(a, b) + local n, len, nmax, lmax; + lmax := 0; + for n in [a .. b] do + len := CollatzLength(n); + if len > lmax then + nmax := n; + lmax := len; + fi; + od; + return [ nmax, lmax ]; +end; + +CollatzSequence(27); +# [ 27, 82, 41, 124, 62, 31, 94, 47, 142, 71, 214, 107, 322, 161, 484, 242, 121, 364, 182, 91, 274, 137, 412, 206, +# 103, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336, 668, 334, 167, 502, +# 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158, 1079, 3238, 1619, 4858, 2429, +# 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308, 1154, 577, 1732, 866, 433, 1300, +# 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1 ] +CollatzLength(27); +# 112 + +CollatzMax(1, 100); +# [ 97, 119 ] +CollatzMax(1, 1000); +# [ 871, 179 ] +CollatzMax(1, 10000); +# [ 6171, 262 ] +CollatzMax(1, 100000); +# [ 77031, 351 ] +CollatzMax(1, 1000000); +# [ 837799, 525 ] diff --git a/Task/Hailstone-sequence/Go/hailstone-sequence-1.go b/Task/Hailstone-sequence/Go/hailstone-sequence-1.go new file mode 100644 index 0000000000..93ea3a24b2 --- /dev/null +++ b/Task/Hailstone-sequence/Go/hailstone-sequence-1.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +func hs(n int, seq *[]int) { + s := append((*seq)[:0], n) + for n > 1 { + if n&1 == 0 { + n = n / 2 + } else { + n = 3*n + 1 + } + s = append(s, n) + } + *seq = s +} + +func main() { + var seq []int + + hs(27, &seq) + fmt.Printf("hs(27): %d elements: [%d %d %d %d ... %d %d %d %d]\n", + len(seq), seq[0], seq[1], seq[2], seq[3], + seq[len(seq)-4], seq[len(seq)-3], seq[len(seq)-2], seq[len(seq)-1]) + + var maxN, maxLen int + for n := 1; n < 100000; n++ { + // reusing seq reduces garbage + hs(n, &seq) + if len(seq) > maxLen { + maxN = n + maxLen = len(seq) + } + } + fmt.Printf("hs(%d): %d elements\n", maxN, maxLen) +} diff --git a/Task/Hailstone-sequence/Go/hailstone-sequence-2.go b/Task/Hailstone-sequence/Go/hailstone-sequence-2.go new file mode 100644 index 0000000000..647fdb6aca --- /dev/null +++ b/Task/Hailstone-sequence/Go/hailstone-sequence-2.go @@ -0,0 +1,68 @@ +package main + +import "fmt" + +// Task 1 implemented with a generator. Calling newHg will "create +// a routine to generate the hailstone sequence for a number." +func newHg(n int) func() int { + return func() (n0 int) { + n0 = n + if n&1 == 0 { + n = n / 2 + } else { + n = 3*n + 1 + } + return + } +} + +func main() { + // make generator for sequence starting at 27 + hg := newHg(27) + // save first four elements for printing later + s1, s2, s3, s4 := hg(), hg(), hg(), hg() + // load next four elements in variables to use as shift register. + e4, e3, e2, e1 := hg(), hg(), hg(), hg() + // 4+4= 8 that we've generated so far + ec := 8 + // until we get to 1, generate another value, shift, and increment. + // note that intermediate elements--those shifted off--are not saved. + for e1 > 1 { + e4, e3, e2, e1 = e3, e2, e1, hg() + ec++ + } + // Complete task 2: + fmt.Printf("hs(27): %d elements: [%d %d %d %d ... %d %d %d %d]\n", + ec, s1, s2, s3, s4, e4, e3, e2, e1) + + // Task 3: strategy is to not store sequences, but just the length + // of each sequence. as soon as the sequence we're currently working on + // dips into the range that we've already computed, we short-circuit + // to the end by adding the that known length to whatever length + // we've accumulated so far. + + var nMaxLen int // variable holds n with max length encounted so far + // slice holds sequence length for each n as it is computed + var computedLen [1e5]int + computedLen[1] = 1 + for n := 2; n < 1e5; n++ { + var ele, lSum int + for hg := newHg(n); ; lSum++ { + ele = hg() + // as soon as we get an element in the range we have already + // computed, we're done... + if ele < n { + break + } + } + // just add the sequence length already computed from this point. + lSum += computedLen[ele] + // save the sequence length for this n + computedLen[n] = lSum + // and note if it's the maximum so far + if lSum > computedLen[nMaxLen] { + nMaxLen = n + } + } + fmt.Printf("hs(%d): %d elements\n", nMaxLen, computedLen[nMaxLen]) +} diff --git a/Task/Hailstone-sequence/Groovy/hailstone-sequence-1.groovy b/Task/Hailstone-sequence/Groovy/hailstone-sequence-1.groovy new file mode 100644 index 0000000000..21ed5c2a32 --- /dev/null +++ b/Task/Hailstone-sequence/Groovy/hailstone-sequence-1.groovy @@ -0,0 +1,8 @@ +def hailstone = { long start -> + def sequence = [] + while (start != 1) { + sequence << start + start = (start % 2l == 0l) ? start / 2l : 3l * start + 1l + } + sequence << start +} diff --git a/Task/Hailstone-sequence/Groovy/hailstone-sequence-2.groovy b/Task/Hailstone-sequence/Groovy/hailstone-sequence-2.groovy new file mode 100644 index 0000000000..c37bf4a47d --- /dev/null +++ b/Task/Hailstone-sequence/Groovy/hailstone-sequence-2.groovy @@ -0,0 +1,7 @@ +def sequence = hailstone(27) +assert sequence.size() == 112 +assert sequence[0..3] == [27, 82, 41, 124] +assert sequence[-4..-1] == [8, 4, 2, 1] + +def results = (1..100000).collect { [n:it, size:hailstone(it).size()] }.max { it.size } +println results diff --git a/Task/Hailstone-sequence/Haskell/hailstone-sequence.hs b/Task/Hailstone-sequence/Haskell/hailstone-sequence.hs new file mode 100644 index 0000000000..212faec0a9 --- /dev/null +++ b/Task/Hailstone-sequence/Haskell/hailstone-sequence.hs @@ -0,0 +1,19 @@ +import Data.List (maximumBy) +import Data.Ord (comparing) + +hailstone :: Int -> [Int] +hailstone 1 = [1] +hailstone n | even n = n : hailstone (n `div` 2) + | otherwise = n : hailstone (n * 3 + 1) + +withResult :: (t -> t1) -> t -> (t1, t) +withResult f x = (f x, x) + +main :: IO () +main = do + let h27 = hailstone 27 + print $ length h27 + let h4 = show $ take 4 h27 + let t4 = show $ drop (length h27 - 4) h27 + putStrLn ("hailstone 27: " ++ h4 ++ " ... " ++ t4) + print $ maximumBy (comparing fst) $ map (withResult (length . hailstone)) [1..100000] diff --git a/Task/Hailstone-sequence/HicEst/hailstone-sequence.hicest b/Task/Hailstone-sequence/HicEst/hailstone-sequence.hicest new file mode 100644 index 0000000000..79a9c35fcc --- /dev/null +++ b/Task/Hailstone-sequence/HicEst/hailstone-sequence.hicest @@ -0,0 +1,34 @@ +DIMENSION stones(1000) + +H27 = hailstone(27) +ALIAS(stones,1, first4,4) +ALIAS(stones,H27-3, last4,4) +WRITE(ClipBoard, Name) H27, first4, "...", last4 + +longest_sequence = 0 +DO try = 1, 1E5 + elements = hailstone(try) + IF(elements >= longest_sequence) THEN + number = try + longest_sequence = elements + WRITE(StatusBar, Name) number, longest_sequence + ENDIF +ENDDO +WRITE(ClipBoard, Name) number, longest_sequence +END + +FUNCTION hailstone( n ) + USE : stones + + stones(1) = n + DO i = 1, LEN(stones) + IF(stones(i) == 1) THEN + hailstone = i + RETURN + ELSEIF( MOD(stones(i),2) ) THEN + stones(i+1) = 3*stones(i) + 1 + ELSE + stones(i+1) = stones(i) / 2 + ENDIF + ENDDO +END diff --git a/Task/Hailstone-sequence/Icon/hailstone-sequence-1.icon b/Task/Hailstone-sequence/Icon/hailstone-sequence-1.icon new file mode 100644 index 0000000000..b2a397e473 --- /dev/null +++ b/Task/Hailstone-sequence/Icon/hailstone-sequence-1.icon @@ -0,0 +1,7 @@ +procedure hailstone(n) + while n > 1 do { + suspend n + n := if n%2 = 0 then n/2 else 3*n+1 + } + suspend 1 +end diff --git a/Task/Hailstone-sequence/Icon/hailstone-sequence-2.icon b/Task/Hailstone-sequence/Icon/hailstone-sequence-2.icon new file mode 100644 index 0000000000..816d19e725 --- /dev/null +++ b/Task/Hailstone-sequence/Icon/hailstone-sequence-2.icon @@ -0,0 +1,4 @@ +procedure main(args) + n := integer(!args) | 27 + every writes(" ",hailstone(n)) +end diff --git a/Task/Hailstone-sequence/Icon/hailstone-sequence-3.icon b/Task/Hailstone-sequence/Icon/hailstone-sequence-3.icon new file mode 100644 index 0000000000..e5d3061c2f --- /dev/null +++ b/Task/Hailstone-sequence/Icon/hailstone-sequence-3.icon @@ -0,0 +1,9 @@ +procedure hailstone(n) + static cache + initial { + cache := table() + cache[1] := [1] + } + /cache[n] := [n] ||| hailstone(if n%2 = 0 then n/2 else 3*n+1) + return cache[n] +end diff --git a/Task/Hailstone-sequence/Icon/hailstone-sequence-4.icon b/Task/Hailstone-sequence/Icon/hailstone-sequence-4.icon new file mode 100644 index 0000000000..639358d86f --- /dev/null +++ b/Task/Hailstone-sequence/Icon/hailstone-sequence-4.icon @@ -0,0 +1,23 @@ +procedure main(args) + n := integer(!args) | 27 + task2(n) + write() + task3() +end + +procedure task2(n) + count := 0 + every writes(" ",right(!(sequence := hailstone(n)),5)) do + if (count +:= 1) % 15 = 0 then write() + write() + write(*sequence," value",(*sequence=1,"")|"s"," in the sequence.") +end + +procedure task3() + maxHS := 0 + every n := 1 to 100000 do { + count := *hailstone(n) + if maxHS <:= count then maxN := n + } + write(maxN," has a sequence of ",maxHS," values") +end diff --git a/Task/Hailstone-sequence/Inform-7/hailstone-sequence.inf b/Task/Hailstone-sequence/Inform-7/hailstone-sequence.inf new file mode 100644 index 0000000000..efdf1ae735 --- /dev/null +++ b/Task/Hailstone-sequence/Inform-7/hailstone-sequence.inf @@ -0,0 +1,53 @@ +Home is a room. + +To decide which list of numbers is the hailstone sequence for (N - number): + let result be a list of numbers; + add N to result; + while N is not 1: + if N is even, let N be N / 2; + otherwise let N be (3 * N) + 1; + add N to result; + decide on result. + +Hailstone length cache relates various numbers to one number. + +To decide which number is the hailstone sequence length for (N - number): + let ON be N; + let length so far be 0; + while N is not 1: + if N relates to a number by the hailstone length cache relation: + let result be length so far plus the number to which N relates by the hailstone length cache relation; + now the hailstone length cache relation relates ON to result; + decide on result; + if N is even, let N be N / 2; + otherwise let N be (3 * N) + 1; + increment length so far; + let result be length so far plus 1; + now the hailstone length cache relation relates ON to result; + decide on result. + +To say first and last (N - number) entry/entries in (L - list of values of kind K): + let length be the number of entries in L; + if length <= N * 2: + say L; + else: + repeat with M running from 1 to N: + if M > 1, say ", "; + say entry M in L; + say " ... "; + repeat with M running from length - N + 1 to length: + say entry M in L; + if M < length, say ", ". + +When play begins: + let H27 be the hailstone sequence for 27; + say "Hailstone sequence for 27 has [number of entries in H27] element[s]: [first and last 4 entries in H27]."; + let best length be 0; + let best number be 0; + repeat with N running from 1 to 99999: + let L be the hailstone sequence length for N; + if L > best length: + let best length be L; + let best number be N; + say "The number under 100,000 with the longest hailstone sequence is [best number] with [best length] element[s]."; + end the story. diff --git a/Task/Hailstone-sequence/Ioke/hailstone-sequence.ioke b/Task/Hailstone-sequence/Ioke/hailstone-sequence.ioke new file mode 100644 index 0000000000..4ab2e6944b --- /dev/null +++ b/Task/Hailstone-sequence/Ioke/hailstone-sequence.ioke @@ -0,0 +1,5 @@ +collatz = method(n, + n println + unless(n <= 1, + if(n even?, collatz(n / 2), collatz(n * 3 + 1))) +) diff --git a/Task/Hailstone-sequence/J/hailstone-sequence-1.j b/Task/Hailstone-sequence/J/hailstone-sequence-1.j new file mode 100644 index 0000000000..7c48552af8 --- /dev/null +++ b/Task/Hailstone-sequence/J/hailstone-sequence-1.j @@ -0,0 +1 @@ +hailseq=: -:`(1 3&p.)@.(2&|) ^:(1 ~: ]) ^:a:"0 diff --git a/Task/Hailstone-sequence/J/hailstone-sequence-2.j b/Task/Hailstone-sequence/J/hailstone-sequence-2.j new file mode 100644 index 0000000000..b1ead6e92b --- /dev/null +++ b/Task/Hailstone-sequence/J/hailstone-sequence-2.j @@ -0,0 +1,7 @@ + # hailseq 27 NB. sequence length +112 + 4 _4 {."0 1 hailseq 27 NB. first & last 4 numbers in sequence +27 82 41 124 + 8 4 2 1 + (>:@(i. >./) , >./) #@hailseq }.i. 1e5 NB. number < 100000 with max seq length & its seq length +77031 351 diff --git a/Task/Hailstone-sequence/Java/hailstone-sequence.java b/Task/Hailstone-sequence/Java/hailstone-sequence.java new file mode 100644 index 0000000000..5bf97a45bd --- /dev/null +++ b/Task/Hailstone-sequence/Java/hailstone-sequence.java @@ -0,0 +1,96 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class Hailstone { + + public static List getHailstoneSequence(long n) { + if (n <= 0) + throw new IllegalArgumentException("Invalid starting sequence number"); + List list = new ArrayList(); + list.add(Long.valueOf(n)); + while (n != 1) { + if ((n & 1) == 0) + n = n / 2; + else + n = 3 * n + 1; + list.add(Long.valueOf(n)); + } + return list; + } + + public static void main(String[] args) { + List sequence27 = getHailstoneSequence(27); + System.out.println("Sequence for 27 has " + sequence27.size() + " elements: " + sequence27); + + long MAX = 100000; + // Simple way + { + long highestNumber = 1; + int highestCount = 1; + for (long i = 2; i < MAX; i++) { + int count = getHailstoneSequence(i).size(); + if (count > highestCount) { + highestCount = count; + highestNumber = i; + } + } + System.out.println("Method 1, number " + highestNumber + " has the longest sequence, with a length of " + highestCount); + } + + // More memory efficient way + { + long highestNumber = 1; + int highestCount = 1; + for (long i = 2; i < MAX; i++) { + int count = 1; + long n = i; + while (n != 1) { + if ((n & 1) == 0) + n = n / 2; + else + n = 3 * n + 1; + count++; + } + if (count > highestCount) { + highestCount = count; + highestNumber = i; + } + } + System.out.println("Method 2, number " + highestNumber + " has the longest sequence, with a length of " + highestCount); + } + + // Efficient for analyzing all sequences + { + long highestNumber = 1; + long highestCount = 1; + Map sequenceMap = new HashMap(); + sequenceMap.put(Long.valueOf(1), Integer.valueOf(1)); + + List currentList = new ArrayList(); + for (long i = 2; i < MAX; i++) { + currentList.clear(); + Long n = Long.valueOf(i); + Integer count = null; + while ((count = sequenceMap.get(n)) == null) { + currentList.add(n); + long nValue = n.longValue(); + if ((nValue & 1) == 0) + n = Long.valueOf(nValue / 2); + else + n = Long.valueOf(3 * nValue + 1); + } + int curCount = count.intValue(); + for (int j = currentList.size() - 1; j >= 0; j--) + sequenceMap.put(currentList.get(j), Integer.valueOf(++curCount)); + if (curCount > highestCount) { + highestCount = curCount; + highestNumber = i; + } + } + System.out.println("Method 3, number " + highestNumber + " has the longest sequence, with a length of " + highestCount); + } + return; + } +} diff --git a/Task/Hailstone-sequence/JavaScript/hailstone-sequence.js b/Task/Hailstone-sequence/JavaScript/hailstone-sequence.js new file mode 100644 index 0000000000..34232476da --- /dev/null +++ b/Task/Hailstone-sequence/JavaScript/hailstone-sequence.js @@ -0,0 +1,23 @@ +function hailstone (n) { + var seq = [n]; + while (n > 1) { + n = n % 2 ? 3 * n + 1 : n / 2; + seq.push(n); + } + return seq; +} + +// task 2: verify the sequence for n = 27 +var h = hailstone(27), hLen = h.length; +print("sequence 27 is (" + h.slice(0, 4).join(", ") + " ... " + + h.slice(hLen - 4, hLen).join(", ") + "). length: " + hLen); + +// task 3: find the longest sequence for n < 100000 +for (var n, max = 0, i = 100000; --i;) { + var seq = hailstone(i), sLen = seq.length; + if (sLen > max) { + n = i; + max = sLen; + } +} +print("longest sequence: " + max + " numbers for starting point " + n); diff --git a/Task/Hailstone-sequence/Julia/hailstone-sequence.julia b/Task/Hailstone-sequence/Julia/hailstone-sequence.julia new file mode 100644 index 0000000000..4287ea841a --- /dev/null +++ b/Task/Hailstone-sequence/Julia/hailstone-sequence.julia @@ -0,0 +1,8 @@ +function hailstone(n) + seq = [n] + while n>1 + n = n % 2 == 0 ? n/2 : 3n + 1 + push!(seq,n) + end + return seq +end diff --git a/Task/Hailstone-sequence/K/hailstone-sequence.k b/Task/Hailstone-sequence/K/hailstone-sequence.k new file mode 100644 index 0000000000..e3bf2882d6 --- /dev/null +++ b/Task/Hailstone-sequence/K/hailstone-sequence.k @@ -0,0 +1,12 @@ + hail: (1<){:[x!2;1+3*x;_ x%2]}\ + seqn: hail 27 + + #seqn +112 + 4#seqn +27 82 41 124 + -4#seqn +8 4 2 1 + + {m,x@s?m:|/s:{#hail x}'x}{x@&x!2}!:1e5 +351 77031 diff --git a/Task/Hailstone-sequence/LOLCODE/hailstone-sequence.lol b/Task/Hailstone-sequence/LOLCODE/hailstone-sequence.lol new file mode 100644 index 0000000000..de71dce9f9 --- /dev/null +++ b/Task/Hailstone-sequence/LOLCODE/hailstone-sequence.lol @@ -0,0 +1,49 @@ +HAI 1.3 + +HOW IZ I hailin YR stone + I HAS A sequence ITZ A BUKKIT + sequence HAS A length ITZ 1 + sequence HAS A SRS 0 ITZ stone + + IM IN YR stoner + BOTH SAEM stone AN 1, O RLY? + YA RLY, FOUND YR sequence + OIC + + MOD OF stone AN 2, O RLY? + YA RLY, stone R SUM OF PRODUKT OF stone AN 3 AN 1 + NO WAI, stone R QUOSHUNT OF stone AN 2 + OIC + + sequence HAS A SRS sequence'Z length ITZ stone + sequence'Z length R SUM OF sequence'Z length AN 1 + IM OUTTA YR stoner +IF U SAY SO + +I HAS A hail27 ITZ I IZ hailin YR 27 MKAY +VISIBLE "hail(27) = "! + +IM IN YR first4 UPPIN YR i TIL BOTH SAEM i AN 4 + VISIBLE hail27'Z SRS i " "! +IM OUTTA YR first4 +VISIBLE "..."! + +IM IN YR last4 UPPIN YR i TIL BOTH SAEM i AN 4 + VISIBLE " " hail27'Z SRS SUM OF 108 AN i! +IM OUTTA YR last4 +VISIBLE ", length = " hail27'Z length + +I HAS A max, I HAS A len ITZ 0 + +BTW, DIS IZ RLY NOT FAST SO WE ONLY CHEK N IN [75000, 80000) +IM IN YR maxer UPPIN YR n TIL BOTH SAEM n AN 5000 + I HAS A n ITZ SUM OF n AN 75000 + I HAS A seq ITZ I IZ hailin YR n MKAY + BOTH SAEM len AN SMALLR OF len AN seq'Z length, O RLY? + YA RLY, max R n, len R seq'Z length + OIC +IM OUTTA YR maxer + +VISIBLE "len(hail(" max ")) = " len + +KTHXBYE diff --git a/Task/Hailstone-sequence/Liberty-BASIC/hailstone-sequence.liberty b/Task/Hailstone-sequence/Liberty-BASIC/hailstone-sequence.liberty new file mode 100644 index 0000000000..8f487d6014 --- /dev/null +++ b/Task/Hailstone-sequence/Liberty-BASIC/hailstone-sequence.liberty @@ -0,0 +1,52 @@ +print "Part 1: Create a routine to generate the hailstone sequence for a number." +print "" +while hailstone < 1 or hailstone <> int(hailstone) + input "Please enter a positive integer: "; hailstone +wend +print "" +print "The following is the 'Hailstone Sequence' for your number..." +print "" +print hailstone +while hailstone <> 1 + if hailstone / 2 = int(hailstone / 2) then hailstone = hailstone / 2 else hailstone = (3 * hailstone) + 1 + print hailstone +wend +print "" +input "Hit 'Enter' to continue to part 2...";dummy$ +cls +print "Part 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." +print "" +print "No. in Seq.","Hailstone Sequence Number for 27" +print "" +c = 1: hailstone = 27 +print c, hailstone +while hailstone <> 1 + c = c + 1 + if hailstone / 2 = int(hailstone / 2) then hailstone = hailstone / 2 else hailstone = (3 * hailstone) + 1 + print c, hailstone +wend +print "" +input "Hit 'Enter' to continue to part 3...";dummy$ +cls +print "Part 3: Show the number less than 100,000 which has the longest hailstone sequence together with that sequence's length.(But don't show the actual sequence)!" +print "" +print "Calculating result... Please wait... This could take a little while..." +print "" +print "Percent Done", "Start Number", "Seq. Length", "Maximum Sequence So Far" +print "" +for cc = 1 to 99999 + hailstone = cc: c = 1 + while hailstone <> 1 + c = c + 1 + if hailstone / 2 = int(hailstone / 2) then hailstone = hailstone / 2 else hailstone = (3 * hailstone) + 1 + wend + if c > max then max = c: largesthailstone = cc + locate 1, 7 + print " " + locate 1, 7 + print using("###.###", cc / 99999 * 100);"%", cc, c, max + scan +next cc +print "" +print "The number less than 100,000 with the longest 'Hailstone Sequence' is "; largesthailstone;". It's sequence length is "; max;"." +end diff --git a/Task/Hailstone-sequence/Logo/hailstone-sequence.logo b/Task/Hailstone-sequence/Logo/hailstone-sequence.logo new file mode 100644 index 0000000000..161abf7b6c --- /dev/null +++ b/Task/Hailstone-sequence/Logo/hailstone-sequence.logo @@ -0,0 +1,23 @@ +to hail.next :n + output ifelse equal? 0 modulo :n 2 [:n/2] [3*:n + 1] +end + +to hail.seq :n + if :n = 1 [output [1]] + output fput :n hail.seq hail.next :n +end + +show hail.seq 27 +show count hail.seq 27 + +to max.hail :n + localmake "max.n 0 + localmake "max.length 0 + repeat :n [if greater? count hail.seq repcount :max.length [ + make "max.n repcount + make "max.length count hail.seq repcount + ] ] + (print :max.n [has hailstone sequence length] :max.length) +end + +max.hail 100000 diff --git a/Task/Hailstone-sequence/Logtalk/hailstone-sequence-1.logtalk b/Task/Hailstone-sequence/Logtalk/hailstone-sequence-1.logtalk new file mode 100644 index 0000000000..f94e2b383e --- /dev/null +++ b/Task/Hailstone-sequence/Logtalk/hailstone-sequence-1.logtalk @@ -0,0 +1,94 @@ +:- object(hailstone). + + :- public(generate_sequence/2). + :- mode(generate_sequence(+natural, -list(natural)), zero_or_one). + :- info(generate_sequence/2, [ + comment is 'Generates the Hailstone sequence that starts with its first argument. Fails if the argument is not a natural number.', + argnames is ['Start', 'Sequence'] + ]). + + :- public(write_sequence/1). + :- mode(write_sequence(+natural), zero_or_one). + :- info(write_sequence/1, [ + comment is 'Writes to the standard output the Hailstone sequence that starts with its argument. Fails if the argument is not a natural number.', + argnames is ['Start'] + ]). + + :- public(sequence_length/2). + :- mode(sequence_length(+natural, -natural), zero_or_one). + :- info(sequence_length/2, [ + comment is 'Calculates the length of the Hailstone sequence that starts with its first argument. Fails if the argument is not a natural number.', + argnames is ['Start', 'Length'] + ]). + + :- public(longest_sequence/4). + :- mode(longest_sequence(+natural, +natural, -natural, -natural), zero_or_one). + :- info(longest_sequence/4, [ + comment is 'Calculates the longest Hailstone sequence in the interval [Start, End]. Fails if the interval is not valid.', + argnames is ['Start', 'End', 'N', 'Length'] + ]). + + generate_sequence(Start, Sequence) :- + integer(Start), + Start >= 1, + sequence(Start, Sequence). + + sequence(1, [1]) :- + !. + sequence(N, [N| Sequence]) :- + ( N mod 2 =:= 0 -> + M is N // 2 + ; M is (3 * N) + 1 + ), + sequence(M, Sequence). + + write_sequence(Start) :- + integer(Start), + Start >= 1, + sequence(Start). + + sequence(1) :- + !, + write(1), nl. + sequence(N) :- + write(N), write(' '), + ( N mod 2 =:= 0 -> + M is N // 2 + ; M is (3 * N) + 1 + ), + sequence(M). + + sequence_length(Start, Length) :- + integer(Start), + Start >= 1, + sequence_length(Start, 1, Length). + + sequence_length(1, Length, Length) :- + !. + sequence_length(N, Length0, Length) :- + Length1 is Length0 + 1, + ( N mod 2 =:= 0 -> + M is N // 2 + ; M is (3 * N) + 1 + ), + sequence_length(M, Length1, Length). + + longest_sequence(Start, End, N, Length) :- + integer(Start), + integer(End), + Start >= 1, + Start =< End, + longest_sequence(Start, End, 1, N, 1, Length). + + longest_sequence(Current, End, N, N, Length, Length) :- + Current > End, + !. + longest_sequence(Current, End, N0, N, Length0, Length) :- + sequence_length(Current, 1, CurrentLength), + Next is Current + 1, + ( CurrentLength > Length0 -> + longest_sequence(Next, End, Current, N, CurrentLength, Length) + ; longest_sequence(Next, End, N0, N, Length0, Length) + ). + +:- end_object. diff --git a/Task/Hailstone-sequence/Logtalk/hailstone-sequence-2.logtalk b/Task/Hailstone-sequence/Logtalk/hailstone-sequence-2.logtalk new file mode 100644 index 0000000000..d8b8f64e5a --- /dev/null +++ b/Task/Hailstone-sequence/Logtalk/hailstone-sequence-2.logtalk @@ -0,0 +1,11 @@ +| ?- hailstone::write_sequence(27). +27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 +true + +| ?- hailstone::sequence_length(27, Length). +Length = 112 +true + +| ?- hailstone::longest_sequence(1, 100000, N, Length). +N = 77031, Length = 351 +true diff --git a/Task/Hailstone-sequence/Lua/hailstone-sequence.lua b/Task/Hailstone-sequence/Lua/hailstone-sequence.lua new file mode 100644 index 0000000000..c1c15aa848 --- /dev/null +++ b/Task/Hailstone-sequence/Lua/hailstone-sequence.lua @@ -0,0 +1,30 @@ +function hailstone( n, print_numbers ) + local n_iter = 1 + + while n ~= 1 do + if print_numbers then print( n ) end + if n % 2 == 0 then + n = n / 2 + else + n = 3 * n + 1 + end + + n_iter = n_iter + 1 + end + if print_numbers then print( n ) end + + return n_iter; +end + +hailstone( 27, true ) + +max_i, max_iter = 0, 0 +for i = 1, 100000 do + num = hailstone( i, false ) + if num >= max_iter then + max_i = i + max_iter = num + end +end + +print( string.format( "Needed %d iterations for the number %d.\n", max_iter, max_i ) ) diff --git a/Task/Hailstone-sequence/MATLAB/hailstone-sequence-1.m b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-1.m new file mode 100644 index 0000000000..b818b3ce74 --- /dev/null +++ b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-1.m @@ -0,0 +1,19 @@ + function x = hailstone(n) + % iterative definition + global VERBOSE; + x = 1; + while (1) + if VERBOSE, + printf('%i ',n); % print element + end; + + if n==1, + return; + elseif mod(n,2), + n = 3*n+1; + else + n = n/2; + end; + x = x + 1; + end; + end; diff --git a/Task/Hailstone-sequence/MATLAB/hailstone-sequence-2.m b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-2.m new file mode 100644 index 0000000000..0a9d613d13 --- /dev/null +++ b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-2.m @@ -0,0 +1,4 @@ + global VERBOSE; + VERBOSE = 1; % display of sequence elements turned on + N = hailstone(27); %display sequence + printf('\n\n%i\n',N); % diff --git a/Task/Hailstone-sequence/MATLAB/hailstone-sequence-3.m b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-3.m new file mode 100644 index 0000000000..ecc946b2f7 --- /dev/null +++ b/Task/Hailstone-sequence/MATLAB/hailstone-sequence-3.m @@ -0,0 +1,8 @@ + global VERBOSE; + VERBOSE = 0; % display of sequence elements turned off + N = 100000; + M = zeros(N,1); + for k=1:N, + M(k) = hailstone(k); %display sequence + end; + [maxLength, n] = max(M) diff --git a/Task/Hailstone-sequence/MUMPS/hailstone-sequence.mumps b/Task/Hailstone-sequence/MUMPS/hailstone-sequence.mumps new file mode 100644 index 0000000000..a5ce81cb18 --- /dev/null +++ b/Task/Hailstone-sequence/MUMPS/hailstone-sequence.mumps @@ -0,0 +1,6 @@ +hailstone(n) ; + If n=1 Quit n + If n#2 Quit n_" "_$$hailstone(3*n+1) + Quit n_" "_$$hailstone(n\2) +Set x=$$hailstone(27) Write !,$Length(x," ")," terms in ",x,! +112 terms in 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 diff --git a/Task/Hailstone-sequence/Mathematica/hailstone-sequence-1.mathematica b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-1.mathematica new file mode 100644 index 0000000000..c44375870d --- /dev/null +++ b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-1.mathematica @@ -0,0 +1 @@ +HailstoneFP[n_] := Drop[FixedPointList[If[# != 1, Which[Mod[#, 2] == 0, #/2, True, ( 3*# + 1) ], 1] &, n], -1] diff --git a/Task/Hailstone-sequence/Mathematica/hailstone-sequence-2.mathematica b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-2.mathematica new file mode 100644 index 0000000000..444033c53b --- /dev/null +++ b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-2.mathematica @@ -0,0 +1,3 @@ +HailstoneR[1] := {1} +HailstoneR[n_Integer] := Prepend[HailstoneR[3 n + 1], n] /; OddQ[n] && n > 0 +HailstoneR[n_Integer] := Prepend[HailstoneR[n/2], n] /; EvenQ[n] && n > 0 diff --git a/Task/Hailstone-sequence/Mathematica/hailstone-sequence-3.mathematica b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-3.mathematica new file mode 100644 index 0000000000..008b44e926 --- /dev/null +++ b/Task/Hailstone-sequence/Mathematica/hailstone-sequence-3.mathematica @@ -0,0 +1,12 @@ +Hailstone[n_] := + NestWhileList[Which[Mod[#, 2] == 0, #/2, True, ( 3*# + 1) ] &, n, # != 1 &]; +c27 = Hailstone@27; +Print["Hailstone sequence for n = 27: [", c27[[;; 4]], "...", c27[[-4 ;;]], "]"] +Print["Length Hailstone[27] = ", Length@c27] + +longest = -1; comp = 0; +Do[temp = Length@Hailstone@i; + If[comp < temp, comp = temp; longest = i], + {i, 100000} + ] +Print["Longest Hailstone sequence at n = ", longest, "\nwith length = ", comp]; diff --git a/Task/Hailstone-sequence/Maxima/hailstone-sequence.maxima b/Task/Hailstone-sequence/Maxima/hailstone-sequence.maxima new file mode 100644 index 0000000000..1fa98be411 --- /dev/null +++ b/Task/Hailstone-sequence/Maxima/hailstone-sequence.maxima @@ -0,0 +1,15 @@ +collatz(n) := block([L], L: [n], while n > 1 do +(n: if evenp(n) then n/2 else 3*n + 1, L: endcons(n, L)), L)$ + +collatz_length(n) := block([m], m: 1, while n > 1 do +(n: if evenp(n) then n/2 else 3*n + 1, m: m + 1), m)$ + +collatz_max(n) := block([j, m, p], m: 0, +for i from 1 thru n do + (p: collatz_length(i), if p > m then (m: p, j: i)), +[j, m])$ + +collatz(27); /* [27, 82, 41, ..., 4, 2, 1] */ +length(%); /* 112 */ +collatz_length(27); /* 112 */ +collatz_max(100000); /* [77031, 351] */ diff --git a/Task/Hailstone-sequence/Modula-2/hailstone-sequence.mod2 b/Task/Hailstone-sequence/Modula-2/hailstone-sequence.mod2 new file mode 100644 index 0000000000..f00ad89687 --- /dev/null +++ b/Task/Hailstone-sequence/Modula-2/hailstone-sequence.mod2 @@ -0,0 +1,73 @@ +MODULE hailst; + +IMPORT InOut; + +CONST maxCard = MAX (CARDINAL) DIV 3; +TYPE action = (List, Count, Max); +VAR a : CARDINAL; + +PROCEDURE HailStone (start : CARDINAL; type : action) : CARDINAL; + +VAR n, max, count : CARDINAL; + +BEGIN + count := 1; + n := start; + max := n; + LOOP + IF type = List THEN + InOut.WriteCard (n, 12); + IF count MOD 6 = 0 THEN InOut.WriteLn END + END; + IF n = 1 THEN EXIT END; + IF ODD (n) THEN + IF n < maxCard THEN + n := 3 * n + 1; + IF n > max THEN max := n END + ELSE + InOut.WriteString ("Exceeding max value for type CARDINAL at count = "); + InOut.WriteCard (count, 10); + InOut.WriteString (" for intermediate value "); + InOut.WriteCard (n, 10); + InOut.WriteString (". Aborting."); + HALT + END + ELSE + n := n DIV 2 + END; + INC (count) + END; + IF type = Max THEN RETURN max ELSE RETURN count END +END HailStone; + +PROCEDURE FindMax (num : CARDINAL); + +VAR val, maxCount, maxVal, cnt : CARDINAL; + +BEGIN + maxCount := 0; + maxVal := 0; + FOR val := 2 TO num DO + cnt := HailStone (val, Count); + IF cnt > maxCount THEN + maxVal := val; + maxCount := cnt + END + END; + InOut.WriteString ("Longest sequence below "); InOut.WriteCard (num, 1); + InOut.WriteString (" is "); InOut.WriteCard (HailStone (maxVal, Count), 1); + InOut.WriteString (" for n = "); InOut.WriteCard (maxVal, 1); + InOut.WriteString (" with an intermediate maximum of "); + InOut.WriteCard (HailStone (maxVal, Max), 1); + InOut.WriteLn +END FindMax; + +BEGIN + a := HailStone (27, List); + InOut.WriteLn; + InOut.WriteString ("Iterations total = "); InOut.WriteCard (HailStone (27, Count), 12); + InOut.WriteString (" max value = "); InOut.WriteCard (HailStone (27, Max) , 12); + InOut.WriteLn; + FindMax (100000); + InOut.WriteString ("Done."); InOut.WriteLn +END hailst. diff --git a/Task/Hailstone-sequence/PHP/hailstone-sequence.php b/Task/Hailstone-sequence/PHP/hailstone-sequence.php new file mode 100644 index 0000000000..b30e74eb83 --- /dev/null +++ b/Task/Hailstone-sequence/PHP/hailstone-sequence.php @@ -0,0 +1,26 @@ +function hailstone($n,$seq=array()){ + $sequence = $seq; + $sequence[] = $n; + if($n == 1){ + return $sequence; + }else{ + $n = ($n%2==0) ? $n/2 : (3*$n)+1; + return hailstone($n, $sequence); + } +} + +$result = hailstone(27); +echo count($result) . ' Elements.
'; +echo 'Starting with : ' . implode(",",array_slice($result,0,4)) .' and ending with : ' . implode(",",array_slice($result,count($result)-4)) . '
'; + +$maxResult = array(0); + +for($i=1;$i<=100000;$i++){ + $result = count(hailstone($i)); + if($result > max($maxResult)){ + $maxResult = array($i=>$result); + } +} +foreach($maxResult as $key => $val){ +echo 'Number < 100000 with longest Hailstone seq.: ' . $key . ' with length of ' . $val; +} diff --git a/Task/Hailstone-sequence/Perl/hailstone-sequence-1.pl b/Task/Hailstone-sequence/Perl/hailstone-sequence-1.pl new file mode 100644 index 0000000000..c03e32dcf3 --- /dev/null +++ b/Task/Hailstone-sequence/Perl/hailstone-sequence-1.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +my @h = hailstone(27); +print "Length of hailstone(27) = " . scalar @h . "\n"; +print "[" . join(", ", @h[0 .. 3], "...", @h[-4 .. -1]) . "]\n"; + +my ($max, $n) = (0, 0); +for my $x (1 .. 99_999) { + @h = hailstone($x); + if (scalar @h > $max) { + ($max, $n) = (scalar @h, $x); + } +} + +print "Max length $max was found for hailstone($n) for numbers < 100_000\n"; + + +sub hailstone { + my ($n) = @_; + + my @sequence = ($n); + + while ($n > 1) { + if ($n % 2 == 0) { + $n = int($n / 2); + } else { + $n = $n * 3 + 1; + } + + push @sequence, $n; + } + + return @sequence; +} diff --git a/Task/Hailstone-sequence/Perl/hailstone-sequence-2.pl b/Task/Hailstone-sequence/Perl/hailstone-sequence-2.pl new file mode 100644 index 0000000000..0c54fcf8f3 --- /dev/null +++ b/Task/Hailstone-sequence/Perl/hailstone-sequence-2.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl +use strict; + +sub hailstone { + @_ = local $_ = shift; + push @_, $_ = $_ % 2 ? 3 * $_ + 1 : $_ / 2 while $_ > 1; + @_; +} + +my @h = hailstone($_ = 27); +print "$_: @h[0 .. 3] ... @h[-4 .. -1] (".@h.")\n"; + +@h = (); +for (1 .. 99_999) { @h = ($_, $h[2]) if ($h[2] = hailstone($_)) > $h[1] } +printf "%d: (%d)\n", @h; diff --git a/Task/Hailstone-sequence/Perl/hailstone-sequence-3.pl b/Task/Hailstone-sequence/Perl/hailstone-sequence-3.pl new file mode 100644 index 0000000000..d94b518f99 --- /dev/null +++ b/Task/Hailstone-sequence/Perl/hailstone-sequence-3.pl @@ -0,0 +1,3 @@ +sub _{my$_=$_[''];push@_,$_&1?$_+=$_++<<1:($_>>=1)while$_^1;@_} +@_=_($_=031^2);print "$_: @_[0..3] ... @_[-4..-1] (".@_.")\n"; +$_[1]<($_[2]=_($_))and@_=($_,$_[2])for 1..1e5-1;printf "%d: (%d)\n", @_; diff --git a/Task/Hailstone-sequence/PicoLisp/hailstone-sequence.l b/Task/Hailstone-sequence/PicoLisp/hailstone-sequence.l new file mode 100644 index 0000000000..c6ecb302d9 --- /dev/null +++ b/Task/Hailstone-sequence/PicoLisp/hailstone-sequence.l @@ -0,0 +1,13 @@ +(de hailstone (N) + (make + (until (= 1 (link N)) + (setq N + (if (bit? 1 N) + (inc (* N 3)) + (/ N 2) ) ) ) ) ) + +(let L (hailstone 27) + (println 27 (length L) (head 4 L) '- (tail 4 L)) ) + +(let N (maxi '((N) (length (hailstone N))) (range 1 100000)) + (println N (length (hailstone N))) ) diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-1.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-1.pro new file mode 100644 index 0000000000..efdb582ffb --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-1.pro @@ -0,0 +1,3 @@ +hailstone(1,[1]) :- !. +hailstone(N,[N|S]) :- 0 is N mod 2, N1 is N / 2, hailstone(N1,S). +hailstone(N,[N|S]) :- 1 is N mod 2, N1 is (3 * N) + 1, hailstone(N1, S). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-2.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-2.pro new file mode 100644 index 0000000000..1f10b2a991 --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-2.pro @@ -0,0 +1,4 @@ +hailstone(27,X), +length(X,112), +append([27, 82, 41, 124], _, X), +append(_, [8, 4, 2, 1], X). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-3.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-3.pro new file mode 100644 index 0000000000..07c2b2c14c --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-3.pro @@ -0,0 +1,10 @@ +longestHailstoneSequence(M, Seq, Len) :- longesthailstone(M, 1, 1, Seq, Len). +longesthailstone(1, Cn, Cl, Mn, Ml):- Mn = Cn, + Ml = Cl. +longesthailstone(N, _, Cl, Mn, Ml) :- hailstone(N, X), + length(X, L), + Cl < L, + N1 is N-1, + longesthailstone(N1, N, L, Mn, Ml). +longesthailstone(N, Cn, Cl, Mn, Ml) :- N1 is N-1, + longesthailstone(N1, Cn, Cl, Mn, Ml). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-4.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-4.pro new file mode 100644 index 0000000000..a35c254f85 --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-4.pro @@ -0,0 +1 @@ +longestHailstoneSequence(100000, Seq, Len). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-5.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-5.pro new file mode 100644 index 0000000000..6dff847ec3 --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-5.pro @@ -0,0 +1,17 @@ +:- use_module(library(chr)). +:- chr_option(debug, off). +:- chr_option(optimize, full). + +:- chr_constraint collatz/2, hailstone/1, clean/0. + +% to remove all constraints hailstone/1 after computation +clean @ clean \ hailstone(_) <=> true. +clean @ clean <=> true. + +% compute Collatz number +init @ collatz(1,X) <=> X = 1 | true. +collatz @ collatz(N, C) <=> (N mod 2 =:= 0 -> C is N / 2; C is 3 * N + 1). + +% Hailstone loop +hailstone(1) ==> true. +hailstone(N) ==> N \= 1 | collatz(N, H), hailstone(H). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-6.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-6.pro new file mode 100644 index 0000000000..20520c05a8 --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-6.pro @@ -0,0 +1,6 @@ +task1 :- + hailstone(27), + findall(X, find_chr_constraint(hailstone(X)), L), + clean, + % check the requirements + ( (length(L, 112), append([27, 82, 41, 124 | _], [8,4,2,1], L)) -> writeln(ok); writeln(ko)). diff --git a/Task/Hailstone-sequence/Prolog/hailstone-sequence-7.pro b/Task/Hailstone-sequence/Prolog/hailstone-sequence-7.pro new file mode 100644 index 0000000000..594355ff08 --- /dev/null +++ b/Task/Hailstone-sequence/Prolog/hailstone-sequence-7.pro @@ -0,0 +1,22 @@ +longest_sequence :- + seq(2, 100000, 1-[1], Len-V), + format('For ~w sequence has ~w len ! ~n', [V, Len]). + + +% walk through 2 to 100000 and compute the length of the sequences +% memorize the longest +seq(N, Max, Len-V, Len-V) :- N is Max + 1, !. +seq(N, Max, CLen - CV, FLen - FV) :- + len_seq(N, Len - N), + ( Len > CLen -> Len1 = Len, V1 = [N] + ; Len = CLen -> Len1 = Len, V1 = [N | CV] + ; Len1 = CLen, V1 = CV), + N1 is N+1, + seq(N1, Max, Len1 - V1, FLen - FV). + +% compute the len of the Hailstone sequence for a number +len_seq(N, Len - N) :- + hailstone(N), + findall(hailstone(X), find_chr_constraint(hailstone(X)), L), + length(L, Len), + clean. diff --git a/Task/Hailstone-sequence/Python/hailstone-sequence.py b/Task/Hailstone-sequence/Python/hailstone-sequence.py new file mode 100644 index 0000000000..535e7e23ca --- /dev/null +++ b/Task/Hailstone-sequence/Python/hailstone-sequence.py @@ -0,0 +1,12 @@ +def hailstone(n): + seq = [n] + while n>1: + n = 3*n + 1 if n & 1 else n//2 + seq.append(n) + return seq + +if __name__ == '__main__': + h = hailstone(27) + assert len(h)==112 and h[:4]==[27, 82, 41, 124] and h[-4:]==[8, 4, 2, 1] + print("Maximum length %i was found for hailstone(%i) for numbers <100,000" % + max((len(hailstone(i)), i) for i in range(1,100000))) diff --git a/Task/Hailstone-sequence/R/hailstone-sequence-1.r b/Task/Hailstone-sequence/R/hailstone-sequence-1.r new file mode 100644 index 0000000000..7fce19013e --- /dev/null +++ b/Task/Hailstone-sequence/R/hailstone-sequence-1.r @@ -0,0 +1,34 @@ +### PART 1: +makeHailstone <- function(n){ + hseq <- n + while (hseq[length(hseq)] > 1){ + current.value <- hseq[length(hseq)] + if (current.value %% 2 == 0){ + next.value <- current.value / 2 + } else { + next.value <- (3 * current.value) + 1 + } + hseq <- append(hseq, next.value) + } + return(list(hseq=hseq, seq.length=length(hseq))) +} + +### PART 2: +twenty.seven <- makeHailstone(27) +twenty.seven$hseq +twenty.seven$seq.length + +### PART 3: +max.length <- 0; lower.bound <- 1; upper.bound <- 100000 + +for (index in lower.bound:upper.bound){ + current.hseq <- makeHailstone(index) + if (current.hseq$seq.length > max.length){ + max.length <- current.hseq$seq.length + max.index <- index + } +} + +cat("Between ", lower.bound, " and ", upper.bound, ", the input of ", + max.index, " gives the longest hailstone sequence, which has length ", + max.length, ". \n", sep="") diff --git a/Task/Hailstone-sequence/R/hailstone-sequence-2.r b/Task/Hailstone-sequence/R/hailstone-sequence-2.r new file mode 100644 index 0000000000..e897d84759 --- /dev/null +++ b/Task/Hailstone-sequence/R/hailstone-sequence-2.r @@ -0,0 +1,15 @@ +> twenty.seven$hseq + [1] 27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 + [16] 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 + [31] 350 175 526 263 790 395 1186 593 1780 890 445 1336 668 334 167 + [46] 502 251 754 377 1132 566 283 850 425 1276 638 319 958 479 1438 + [61] 719 2158 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 + [76] 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 + [91] 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 +[106] 10 5 16 8 4 2 1 + +> twenty.seven$seq.length +[1] 112 + +Between 1 and 1e+05, the input of 77031 gives the longest hailstone sequence, +which has length 351. diff --git a/Task/Hailstone-sequence/REXX/hailstone-sequence.rexx b/Task/Hailstone-sequence/REXX/hailstone-sequence.rexx new file mode 100644 index 0000000000..4fc351b0a0 --- /dev/null +++ b/Task/Hailstone-sequence/REXX/hailstone-sequence.rexx @@ -0,0 +1,24 @@ +/*REXX pgm tests a number and a range for hailstone (Collatz) sequences.*/ +parse arg x .; if x=='' then x=27 /*get the optional first argument*/ +numeric digits 20 +$=hailstone(x) /*═════════════task 1════════════*/ +say x 'has a hailstone sequence of' #hs 'and starts with: ' subword($,1,4), + ' and ends with:' subword($,#hs-3) +say +w=0; do j=1 for 99999 /*═════════════task 2════════════*/ + call hailstone j /*compute the hailstone sequence.*/ + if #hs<=w then iterate /*Not big 'nuff? Then keep going.*/ + bigJ=j; w=#hs /*remember what # has biggest HS.*/ + end /*j*/ + +say '(between 1──►99,999) ' bigJ 'has the longest hailstone sequence:' w +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────HAILSTONE subroutine────────────────*/ +hailstone: procedure expose #hs; parse arg n 1 s /*N & S set to 1st arg*/ + + do #hs=1 while n\==1 /*loop while N isn't unity. */ + if n//2 then n=n*3+1 /*if N is odd, calc: 3*n +1 */ + else n=n%2 /* " " " even, perform fast ÷ */ + s=s n /*build a sequence list (append).*/ + end /*#hs*/ +return s diff --git a/Task/Hailstone-sequence/Racket/hailstone-sequence.rkt b/Task/Hailstone-sequence/Racket/hailstone-sequence.rkt new file mode 100644 index 0000000000..5c03852c09 --- /dev/null +++ b/Task/Hailstone-sequence/Racket/hailstone-sequence.rkt @@ -0,0 +1,19 @@ +#lang racket +(define memo (make-hash)) +(hash-set! memo 1 '((1) 1)) + +(define (hailstone n) + (hash-ref memo n + (λ () + (define h (hailstone (if (even? n) (/ n 2) (+ (* 3 n) 1)))) + (hash-set! memo n (list (cons n (first h)) (+ (second h) 1))) + (hash-ref memo n)))) + +(define h27 (first (hailstone 27))) + +(printf "first 4 elements of h(27): ~v\n" (take h27 4)) +(printf "last 4 elements of h(27): ~v\n" (take-right h27 4)) + +(printf "x < 10000 such that h(x) gives the longest sequence: ") +(for/fold ([m 0]) ([n (in-range 1 100000)]) + (max m (second (hailstone n)))) diff --git a/Task/Hailstone-sequence/Ruby/hailstone-sequence-1.rb b/Task/Hailstone-sequence/Ruby/hailstone-sequence-1.rb new file mode 100644 index 0000000000..20d8531d63 --- /dev/null +++ b/Task/Hailstone-sequence/Ruby/hailstone-sequence-1.rb @@ -0,0 +1,18 @@ +def hailstone n + seq = [n] + until n == 1 + n = (n.even?) ? (n / 2) : (3 * n + 1) + seq << n + end + seq +end + +# for n = 27, show sequence length and first and last 4 elements +hs27 = hailstone 27 +p [hs27.length, hs27[0..3], hs27[-4..-1]] + +# find the longest sequence among n less than 100,000 +n, len = (1 ... 100_000) .collect {|n| + [n, hailstone(n).length]} .max_by {|n, len| len} +puts "#{n} has a hailstone sequence length of #{len}" +puts "the largest number in that sequence is #{hailstone(n).max}" diff --git a/Task/Hailstone-sequence/Ruby/hailstone-sequence-2.rb b/Task/Hailstone-sequence/Ruby/hailstone-sequence-2.rb new file mode 100644 index 0000000000..9963dd51f8 --- /dev/null +++ b/Task/Hailstone-sequence/Ruby/hailstone-sequence-2.rb @@ -0,0 +1,47 @@ +module Hailstone + class ListNode + include Enumerable + attr_reader :value, :size, :succ + + def initialize(value, size, succ=nil) + @value, @size, @succ = value, size, succ + end + + def each + node = self + while node + yield node.value + node = node.succ + end + end + end + + @@sequence = {1 => ListNode.new(1, 1)} + + module_function + + def sequence(n) + unless @@sequence[n] + ary = [] + m = n + until succ = @@sequence[m] + ary << m + m = (m.even?) ? (m / 2) : (3 * m + 1) + end + ary.reverse_each do |m| + @@sequence[m] = succ = ListNode.new(m, succ.size + 1, succ) + end + end + @@sequence[n] + end +end + +# for n = 27, show sequence length and first and last 4 elements +hs27 = Hailstone.sequence(27).to_a +p [hs27.length, hs27[0..3], hs27[-4..-1]] + +# find the longest sequence among n less than 100,000 +hs_big = (1 ... 100_000) .collect {|n| + Hailstone.sequence n}.max_by {|hs| hs.size} +puts "#{hs_big.first} has a hailstone sequence length of #{hs_big.size}" +puts "the largest number in that sequence is #{hs_big.max}" diff --git a/Task/Hailstone-sequence/Scala/hailstone-sequence.scala b/Task/Hailstone-sequence/Scala/hailstone-sequence.scala new file mode 100644 index 0000000000..fd3f128a7f --- /dev/null +++ b/Task/Hailstone-sequence/Scala/hailstone-sequence.scala @@ -0,0 +1,11 @@ + def hailstone(n: Int): Stream[Int] = + n #:: { + if (n == 1) Stream.empty + else hailstone(if (n % 2 == 0) n / 2 else n * 3 + 1) + } + + def main(args: Array[String]) { + println(hailstone(27).toList) + val (n, len) = (1 to 100000).map(n => (n, hailstone(n).length)).maxBy(_._2) + println("value=" + n + " len=" + len) + } diff --git a/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss b/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss new file mode 100644 index 0000000000..b0311a38ee --- /dev/null +++ b/Task/Hailstone-sequence/Scheme/hailstone-sequence.ss @@ -0,0 +1,28 @@ +(define (collatz n) +(if (= n 1) '(1) +(cons n (collatz (if (even? n) (/ n 2) (+ 1 (* 3 n))))))) + +(define (collatz-length n) +(let aux ((n n) (r 1)) (if (= n 1) r +(aux (if (even? n) (/ n 2) (+ 1 (* 3 n))) (+ r 1))))) + +(define (collatz-max a b) +(let aux ((i a) (j 0) (k 0)) +(if (> i b) (list j k) +(let ((h (collatz-length i))) +(if (> h k) (aux (+ i 1) i h) (aux (+ i 1) j k)))))) + +(collatz 27) +; (27 82 41 124 62 31 94 47 142 71 214 107 322 161 484 242 121 364 182 +; 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263 790 395 +; 1186 593 1780 890 445 1336 668 334 167 502 251 754 377 1132 566 283 +; 850 425 1276 638 319 958 479 1438 719 2158 1079 3238 1619 4858 2429 +; 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 +; 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 +; 106 53 160 80 40 20 10 5 16 8 4 2 1) + +(collatz-length 27) +; 112 + +(collatz-max 1 100000) +; (77031 351) diff --git a/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-1.st b/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-1.st new file mode 100644 index 0000000000..d17f19edd1 --- /dev/null +++ b/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-1.st @@ -0,0 +1,23 @@ +Object subclass: Sequences [ + Sequences class >> hailstone: n [ + |seq| + seq := OrderedCollection new. + seq add: n. + (n = 1) ifTrue: [ ^seq ]. + (n even) ifTrue: [ seq addAll: (Sequences hailstone: (n / 2)) ] + ifFalse: [ seq addAll: (Sequences hailstone: ( (3*n) + 1 ) ) ]. + ^seq. + ] + + Sequences class >> hailstoneCount: n [ + ^ (Sequences hailstoneCount: n num: 1) + ] + + "this 'version' avoids storing the sequence, it just counts + its length - no memoization anyway" + Sequences class >> hailstoneCount: n num: m [ + (n = 1) ifTrue: [ ^m ]. + (n even) ifTrue: [ ^ Sequences hailstoneCount: (n / 2) num: (m + 1) ] + ifFalse: [ ^ Sequences hailstoneCount: ( (3*n) + 1) num: (m + 1) ]. + ] +]. diff --git a/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-2.st b/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-2.st new file mode 100644 index 0000000000..d32eabfc49 --- /dev/null +++ b/Task/Hailstone-sequence/Smalltalk/hailstone-sequence-2.st @@ -0,0 +1,20 @@ +|r| +r := Sequences hailstone: 27. "hailstone 'from' 27" +(r size) displayNl. "its length" + +"test 'head' ..." +( (r first: 4) = #( 27 82 41 124 ) asOrderedCollection ) displayNl. + +"... and 'tail'" +( ( (r last: 4 ) ) = #( 8 4 2 1 ) asOrderedCollection) displayNl. + +|longest| +longest := OrderedCollection from: #( 1 1 ). +2 to: 100000 do: [ :c | + |l| + l := Sequences hailstoneCount: c. + (l > (longest at: 2) ) ifTrue: [ longest replaceFrom: 1 to: 2 with: { c . l } ]. +]. + +('Sequence generator %1, sequence length %2' % { (longest at: 1) . (longest at: 2) }) + displayNl. diff --git a/Task/Hailstone-sequence/Tcl/hailstone-sequence.tcl b/Task/Hailstone-sequence/Tcl/hailstone-sequence.tcl new file mode 100644 index 0000000000..2c35ace512 --- /dev/null +++ b/Task/Hailstone-sequence/Tcl/hailstone-sequence.tcl @@ -0,0 +1,19 @@ +proc hailstone n { + while 1 { + lappend seq $n + if {$n == 1} {return $seq} + set n [expr {$n & 1 ? $n*3+1 : $n/2}] + } +} + +set h27 [hailstone 27] +puts "h27 len=[llength $h27]" +puts "head4 = [lrange $h27 0 3]" +puts "tail4 = [lrange $h27 end-3 end]" + +set maxlen [set max 0] +for {set i 1} {$i<100000} {incr i} { + set l [llength [hailstone $i]] + if {$l>$maxlen} {set maxlen $l;set max $i} +} +puts "max is $max, with length $maxlen" diff --git a/Task/Hamming-numbers/0DESCRIPTION b/Task/Hamming-numbers/0DESCRIPTION new file mode 100644 index 0000000000..59143ab062 --- /dev/null +++ b/Task/Hamming-numbers/0DESCRIPTION @@ -0,0 +1,12 @@ +[[wp:Hamming_numbers#Algorithms|Hamming numbers]] are numbers of the form +: H = 2^i \cdot 3^j \cdot 5^k, \; \mathrm{where} \; i, j, k \geq 0. +''Hamming numbers'' are also known as ''ugly numbers'' and also ''5-smooth numbers''   (numbers whose prime divisors are less or equal to 5). + +Generate the sequence of Hamming numbers, ''in increasing order''. In particular: +# Show the first twenty Hamming numbers. +# Show the 1691st Hamming number (the last one below 2^{31}). +# Show the one millionth Hamming number (if the language – or a convenient library – supports arbitrary-precision integers). +'''References''' +# [[wp:Hamming_numbers]] +# [[wp:Smooth_number]] +# [http://dobbscodetalk.com/index.php?option=com_content&task=view&id=913&Itemid=85 Hamming problem] from Dr. Dobb's CodeTalk (dead link as of Sep 2011; parts of the thread [http://drdobbs.com/blogs/architecture-and-design/228700538 here] and [http://www.jsoftware.com/jwiki/Essays/Hamming%20Number here]). diff --git a/Task/Hamming-numbers/ALGOL-68/hamming-numbers.alg b/Task/Hamming-numbers/ALGOL-68/hamming-numbers.alg new file mode 100644 index 0000000000..2d03c49372 --- /dev/null +++ b/Task/Hamming-numbers/ALGOL-68/hamming-numbers.alg @@ -0,0 +1,37 @@ +PR precision=100 PR + +MODE SERIES = FLEX [1 : 0] UNT, # Initially, no elements # + UNT = LONG LONG INT; # A 100-digit unsigned integer # + +PROC hamming number = (INT n) UNT: # The n-th Hamming number # + CASE n + IN 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 # First 10 in a table # + OUT # Additional operators # + OP MIN = (INT i, j) INT: (i < j | i | j), MIN = (UNT i, j) UNT: (i < j | i | j); + PRIO MIN = 9; + OP LAST = (SERIES h) UNT: h[UPB h]; # Last element of a series # + OP +:= = (REF SERIES s, UNT elem) VOID: + # Extend a series by one element, only keep the elements you need # + (INT lwb = (i MIN j) MIN k, upb = UPB s; + REF SERIES new s = HEAP FLEX [lwb : upb + 1] UNT; + (new s[lwb : upb] := s[lwb : upb], new s[upb + 1] := elem); + s := new s + ); + # Determine the n-th hamming number iteratively # + SERIES h := 1, # Series, initially one element # + UNT m2 := 2, m3 := 3, m5 := 5, # Multipliers # + INT i := 1, j := 1, k := 1; # Counters # + TO n - 1 + DO h +:= (m2 MIN m3) MIN m5; + (LAST h = m2 | m2 := 2 * h[i +:= 1]); + (LAST h = m3 | m3 := 3 * h[j +:= 1]); + (LAST h = m5 | m5 := 5 * h[k +:= 1]) + OD; + LAST h + ESAC; + +FOR k TO 20 +DO print ((whole (hamming number (k), 0), blank)) +OD; +print ((newline, whole (hamming number (1 691), 0))); +print ((newline, whole (hamming number (1 000 000), 0))) diff --git a/Task/Hamming-numbers/Ada/hamming-numbers-1.ada b/Task/Hamming-numbers/Ada/hamming-numbers-1.ada new file mode 100644 index 0000000000..4f411a0cf4 --- /dev/null +++ b/Task/Hamming-numbers/Ada/hamming-numbers-1.ada @@ -0,0 +1,70 @@ +with Ada.Text_IO; +procedure Hamming is + generic + type Int_Type is private; + Zero : Int_Type; + One : Int_Type; + Two : Int_Type; + Three : Int_Type; + Five : Int_Type; + with function "mod" (Left, Right : Int_Type) return Int_Type is <>; + with function "/" (Left, Right : Int_Type) return Int_Type is <>; + with function "+" (Left, Right : Int_Type) return Int_Type is <>; + function Get_Hamming (Position : Positive) return Int_Type; + + function Get_Hamming (Position : Positive) return Int_Type is + function Is_Hamming (Number : Int_Type) return Boolean is + Temporary : Int_Type := Number; + begin + while Temporary mod Two = Zero loop + Temporary := Temporary / Two; + end loop; + while Temporary mod Three = Zero loop + Temporary := Temporary / Three; + end loop; + while Temporary mod Five = Zero loop + Temporary := Temporary / Five; + end loop; + return Temporary = One; + end Is_Hamming; + Result : Int_Type := One; + Previous : Positive := 1; + begin + while Previous /= Position loop + Result := Result + One; + if Is_Hamming (Result) then + Previous := Previous + 1; + end if; + end loop; + return Result; + end Get_Hamming; + + -- up to 2**32 - 1 + function Integer_Get_Hamming is new Get_Hamming + (Int_Type => Integer, + Zero => 0, + One => 1, + Two => 2, + Three => 3, + Five => 5); + + -- up to 2**64 - 1 + function Long_Long_Integer_Get_Hamming is new Get_Hamming + (Int_Type => Long_Long_Integer, + Zero => 0, + One => 1, + Two => 2, + Three => 3, + Five => 5); +begin + Ada.Text_IO.Put ("1) First 20 Hamming numbers: "); + for I in 1 .. 20 loop + Ada.Text_IO.Put (Integer'Image (Integer_Get_Hamming (I))); + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("2) 1_691st Hamming number: " & + Integer'Image (Integer_Get_Hamming (1_691))); + -- even Long_Long_Integer overflows here + Ada.Text_IO.Put_Line ("3) 1_000_000st Hamming number: " & + Long_Long_Integer'Image (Long_Long_Integer_Get_Hamming (1_000_000))); +end Hamming; diff --git a/Task/Hamming-numbers/Ada/hamming-numbers-2.ada b/Task/Hamming-numbers/Ada/hamming-numbers-2.ada new file mode 100644 index 0000000000..3654388fd0 --- /dev/null +++ b/Task/Hamming-numbers/Ada/hamming-numbers-2.ada @@ -0,0 +1,14 @@ + type My_Index is mod 2**8; + package My_Big_Numbers is new Big_Number (Index_type => My_Index, Nb_Item => 64); + function Int2Big is new My_Big_Numbers.Generic_Conversion.Int_Number2Big_Unsigned (Integer); + + function Big_Get_Hamming is new Get_Hamming + (Int_Type => My_Big_Numbers.Big_Unsigned, + Zero => My_Big_Numbers.Big_Unsigned_Zero, + One => My_Big_Numbers.Big_Unsigned_One, + Two => My_Big_Numbers.Big_Unsigned_Two, + Three => Int2Big(3), + Five => Int2Big(5), + "mod" => My_Big_Numbers.Unsigned_Number."mod", + "+" => My_Big_Numbers.Unsigned_Number."+", + "/" => My_Big_Numbers.Unsigned_Number."/"); diff --git a/Task/Hamming-numbers/Ada/hamming-numbers-3.ada b/Task/Hamming-numbers/Ada/hamming-numbers-3.ada new file mode 100644 index 0000000000..935f240640 --- /dev/null +++ b/Task/Hamming-numbers/Ada/hamming-numbers-3.ada @@ -0,0 +1,2 @@ + Ada.Text_IO.Put_Line ("3) 1_000_000st Hamming number: " & + Ada.Strings.Unbounded.To_String (My_Big_Numbers.String_Conversion.Big_Unsigned2UString (Big_Get_Hamming (1_000_000)))); diff --git a/Task/Hamming-numbers/AutoHotkey/hamming-numbers.ahk b/Task/Hamming-numbers/AutoHotkey/hamming-numbers.ahk new file mode 100644 index 0000000000..b14097b68f --- /dev/null +++ b/Task/Hamming-numbers/AutoHotkey/hamming-numbers.ahk @@ -0,0 +1,51 @@ +SetBatchLines, -1 +Msgbox % hamming(1,20) +Msgbox % hamming(1690) +return + +hamming(first,last=0) +{ + if (first < 1) + ans=ERROR + + if (last = 0) + last := first + + i:=0, j:=0, k:=0 + + num1 := ceil((last * 20)**(1/3)) + num2 := ceil(num1 * ln(2)/ln(3)) + num3 := ceil(num1 * ln(2)/ln(5)) + + loop + { + H := (2**i) * (3**j) * (5**k) + if (H > 0) + ans = %H%`n%ans% + i++ + if (i > num1) + { + i=0 + j++ + if (j > num2) + { + j=0 + k++ + } + } + if (k > num3) + break + } + Sort ans, N + + Loop, parse, ans, `n, `r + { + if (A_index > last) + break + if (A_index < first) + continue + Output = %Output%`n%A_LoopField% + } + + return Output +} diff --git a/Task/Hamming-numbers/BBC-BASIC/hamming-numbers.bbc b/Task/Hamming-numbers/BBC-BASIC/hamming-numbers.bbc new file mode 100644 index 0000000000..65da34d92f --- /dev/null +++ b/Task/Hamming-numbers/BBC-BASIC/hamming-numbers.bbc @@ -0,0 +1,21 @@ + @% = &1010 + FOR h% = 1 TO 20 + PRINT "H("; h% ") = "; FNhamming(h%) + NEXT + PRINT "H(1691) = "; FNhamming(1691) + END + + DEF FNhamming(l%) + LOCAL i%, j%, k%, n%, m, x2, x3, x5, h%() + DIM h%(l%) : h%(0) = 1 + x2 = 2 : x3 = 3 : x5 = 5 + FOR n% = 1 TO l%-1 + m = x2 + IF m > x3 m = x3 + IF m > x5 m = x5 + h%(n%) = m + IF m = x2 i% += 1 : x2 = 2 * h%(i%) + IF m = x3 j% += 1 : x3 = 3 * h%(j%) + IF m = x5 k% += 1 : x5 = 5 * h%(k%) + NEXT + = h%(l%-1) diff --git a/Task/Hamming-numbers/C++/hamming-numbers-1.cpp b/Task/Hamming-numbers/C++/hamming-numbers-1.cpp new file mode 100644 index 0000000000..aea4cf2c6a --- /dev/null +++ b/Task/Hamming-numbers/C++/hamming-numbers-1.cpp @@ -0,0 +1,22 @@ +#include +#include +// Hamming like sequences Generator +// +// Nigel Galloway. August 13th., 2012 +// +class Ham { +private: + std::vector _H, _hp, _hv, _x; +public: + bool operator!=(const Ham& other) const {return true;} + Ham begin() const {return *this;} + Ham end() const {return *this;} + unsigned int operator*() const {return _x.back();} + Ham(const std::vector &pfs):_H(pfs),_hp(pfs.size(),0),_hv({pfs}),_x({1}){} + const Ham& operator++() { + for (int i=0; i<_H.size(); i++) for (;_hv[i]<=_x.back();_hv[i]=_x[++_hp[i]]*_H[i]); + _x.push_back(_hv[0]); + for (int i=1; i<_H.size(); i++) if (_hv[i]<_x.back()) _x.back()=_hv[i]; + return *this; + } +}; diff --git a/Task/Hamming-numbers/C++/hamming-numbers-2.cpp b/Task/Hamming-numbers/C++/hamming-numbers-2.cpp new file mode 100644 index 0000000000..98ca6ae4ef --- /dev/null +++ b/Task/Hamming-numbers/C++/hamming-numbers-2.cpp @@ -0,0 +1,11 @@ +int main() { + int count = 1; + for (unsigned int i : Ham({2,3,5})) { + if (count <= 62) std::cout << i << ' '; + if (count++ == 1691) { + std::cout << "\nThe one thousand six hundred and ninety first Hamming Number is " << i << std::endl; + break; + } + } + return 0; +} diff --git a/Task/Hamming-numbers/C++/hamming-numbers-3.cpp b/Task/Hamming-numbers/C++/hamming-numbers-3.cpp new file mode 100644 index 0000000000..08cd18c1ca --- /dev/null +++ b/Task/Hamming-numbers/C++/hamming-numbers-3.cpp @@ -0,0 +1,9 @@ +int main() { + int count = 1; + for (unsigned int i : Ham({2,3,5,7})) { + std::cout << i << ' '; + if (count++ == 64) break; + } + std::cout << std::endl; + return 0; +} diff --git a/Task/Hamming-numbers/C/hamming-numbers-1.c b/Task/Hamming-numbers/C/hamming-numbers-1.c new file mode 100644 index 0000000000..e2d5bcc3c2 --- /dev/null +++ b/Task/Hamming-numbers/C/hamming-numbers-1.c @@ -0,0 +1,56 @@ +#include +#include + +typedef unsigned long long ham; + +size_t alloc = 0, n = 1; +ham *q = 0; + +void qpush(ham h) +{ + int i, j; + if (alloc <= n) { + alloc = alloc ? alloc * 2 : 16; + q = realloc(q, sizeof(ham) * alloc); + } + + for (i = n++; (j = i/2) && q[j] > h; q[i] = q[j], i = j); + q[i] = h; +} + +ham qpop() +{ + int i, j; + ham r, t; + /* outer loop for skipping duplicates */ + for (r = q[1]; n > 1 && r == q[1]; q[i] = t) { + /* inner loop is the normal down heap routine */ + for (i = 1, t = q[--n]; (j = i * 2) < n;) { + if (j + 1 < n && q[j] > q[j+1]) j++; + if (t <= q[j]) break; + q[i] = q[j], i = j; + } + } + + return r; +} + +int main() +{ + int i; + ham h; + + for (qpush(i = 1); i <= 1691; i++) { + /* takes smallest value, and queue its multiples */ + h = qpop(); + qpush(h * 2); + qpush(h * 3); + qpush(h * 5); + + if (i <= 20 || i == 1691) + printf("%6d: %llu\n", i, h); + } + + /* free(q); */ + return 0; +} diff --git a/Task/Hamming-numbers/C/hamming-numbers-2.c b/Task/Hamming-numbers/C/hamming-numbers-2.c new file mode 100644 index 0000000000..a387ceee57 --- /dev/null +++ b/Task/Hamming-numbers/C/hamming-numbers-2.c @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include + +/* number of factors. best be mutually prime -- duh. */ +#define NK 3 +#define MAX_HAM (1 << 24) +#define MAX_POW 1024 +int n_hams = 0, idx[NK] = {0}, fac[] = { 2, 3, 5, 7, 11}; + +/* k-smooth numbers are stored as their exponents of each factor; + v is the log of the number, for convenience. */ +typedef struct { + int e[NK]; + double v; +} ham_t, *ham; + +ham_t *hams, values[NK] = {{{0}, 0}}; +double inc[NK][MAX_POW]; + +/* most of the time v can be just incremented, but eventually + * floating point precision will bite us, so better recalculate */ +inline +void _setv(ham x) { + int i; + for (x->v = 0, i = 0; i < NK; i++) + x->v += inc[i][x->e[i]]; +} + +inline +int _eq(ham a, ham b) { + int i; + for (i = 0; i < NK && a->e[i] == b->e[i]; i++); + + return i == NK; +} + +ham get_ham(int n) +{ + int i, ni; + ham h; + + n--; + while (n_hams < n) { + for (ni = 0, i = 1; i < NK; i++) + if (values[i].v < values[ni].v) + ni = i; + + *(h = hams + ++n_hams) = values[ni]; + + for (ni = 0; ni < NK; ni++) { + if (! _eq(values + ni, h)) continue; + values[ni] = hams[++idx[ni]]; + values[ni].e[ni]++; + _setv(values + ni); + } + } + + return hams + n; +} + +void show_ham(ham h) +{ + static mpz_t das_ham, tmp; + int i; + + mpz_init_set_ui(das_ham, 1); + mpz_init_set_ui(tmp, 1); + for (i = 0; i < NK; i++) { + mpz_ui_pow_ui(tmp, fac[i], h->e[i]); + mpz_mul(das_ham, das_ham, tmp); + } + gmp_printf("%Zu\n", das_ham); +} + +int main() +{ + int i, j; + hams = malloc(sizeof(ham_t) * MAX_HAM); + + for (i = 0; i < NK; i++) { + values[i].e[i] = 1; + inc[i][1] = log(fac[i]); + _setv(values + i); + + for (j = 2; j < MAX_POW; j++) + inc[i][j] = j * inc[i][1]; + } + + printf(" 1,691: "); show_ham(get_ham(1691)); + printf(" 1,000,000: "); show_ham(get_ham(1e6)); + printf("10,000,000: "); show_ham(get_ham(1e7)); + return 0; +} diff --git a/Task/Hamming-numbers/Clojure/hamming-numbers.clj b/Task/Hamming-numbers/Clojure/hamming-numbers.clj new file mode 100644 index 0000000000..ef1c4b259c --- /dev/null +++ b/Task/Hamming-numbers/Clojure/hamming-numbers.clj @@ -0,0 +1,19 @@ +(defn smerge [xs ys] + (lazy-seq + (let [x (first xs), + y (first ys), + [z xs* ys*] + (cond + (< x y) [x (rest xs) ys] + (> x y) [y xs (rest ys)] + :else [x (rest xs) (rest ys)])] + (cons z (smerge xs* ys*))))) + +(defn smerge3 [xs ys zs] + (smerge xs (smerge ys zs))) + +(defn map*n [n ks] (map #(* n %) ks)) + +(def hamming + (lazy-seq + (cons 1 (smerge3 (map*n 2 hamming) (map*n 3 hamming) (map*n 5 hamming))))) diff --git a/Task/Hamming-numbers/CoffeeScript/hamming-numbers.coffee b/Task/Hamming-numbers/CoffeeScript/hamming-numbers.coffee new file mode 100644 index 0000000000..e66b74e5a0 --- /dev/null +++ b/Task/Hamming-numbers/CoffeeScript/hamming-numbers.coffee @@ -0,0 +1,82 @@ +# Generate hamming numbers in order. Hamming numbers have the +# property that they don't evenly divide any prime numbers outside +# a given set, such as [2, 3, 5]. + +generate_hamming_sequence = (primes, max_n) -> + # We use a lazy algorithm, only ever keeping N candidates + # in play, one for each of our seed primes. Let's say + # primes is [2,3,5]. Our virtual streams are these: + # + # hammings: 1,2,3,4,5,6,8,10,12,15,16,18,20,... + # hammings*2: 2,4,6,9.10,12,16,20,24,30,32,36,40... + # hammings*3: 3,6,9,12,15,18,24,30,36,45,... + # hammings*5: 5,10,15,20,25,30,40,50,... + # + # After encountering 40 for the last time, our candidates + # will be + # 50 = 2 * 25 + # 45 = 3 * 15 + # 50 = 5 * 10 + # Then, after 45 + # 50 = 2 * 25 + # 48 = 3 * 16 <= new + # 50 = 5 * 10 + hamming_numbers = [1] + candidates = ([p, p, 1] for p in primes) + last_number = 1 + while hamming_numbers.length < max_n + # Get the next candidate Hamming Number tuple. + i = min_idx(candidates) + candidate = candidates[i] + [n, p, seq_idx] = candidate + + # Add to sequence unless it's a duplicate. + if n > last_number + hamming_numbers.push n + last_number = n + + # Replace the candidate with its successor (based on + # p = 2, 3, or 5). + # + # This is the heart of the algorithm. Let's say, over the + # primes [2,3,5], we encounter the hamming number 32 based on it being + # 2 * 16, where 16 is the 12th number in the sequence. + # We'll be passed in [32, 2, 12] as candidate, and + # hamming_numbers will be [1,2,3,4,5,6,8,9,10,12,16,18,...] + # by now. The next candidate we need to enqueue is + # [36, 2, 13], where the numbers mean this: + # + # 36 - next multiple of 2 of a Hamming number + # 2 - prime number + # 13 - 1-based index of 18 in the sequence + # + # When we encounter [36, 2, 13], we will then enqueue + # [40, 2, 14], based on 20 being the 14th hamming number. + q = hamming_numbers[seq_idx] + candidates[i] = [p*q, p, seq_idx+1] + + hamming_numbers + +min_idx = (arr) -> + # Don't waste your time reading this--it just returns + # the index of the smallest tuple in an array, respecting that + # the tuples may contain integers. (CS compiles to JS, which is + # kind of stupid about sorting. There are libraries to work around + # the limitation, but I wanted this code to be standalone.) + less_than = (tup1, tup2) -> + i = 0 + while i < tup2.length + return true if tup1[i] <= tup2[i] + return false if tup1[i] > tup2[i] + i += 1 + + min_i = 0 + for i in [1...arr.length] + if less_than arr[i], arr[min_i] + min_i = i + return min_i + +primes = [2, 3, 5] +numbers = generate_hamming_sequence(primes, 10000) +console.log numbers[1690] +console.log numbers[9999] diff --git a/Task/Hamming-numbers/Common-Lisp/hamming-numbers-1.lisp b/Task/Hamming-numbers/Common-Lisp/hamming-numbers-1.lisp new file mode 100644 index 0000000000..428dccf5e5 --- /dev/null +++ b/Task/Hamming-numbers/Common-Lisp/hamming-numbers-1.lisp @@ -0,0 +1,20 @@ +(defun next-hamm (factors seqs) + (let ((x (apply #'min (map 'list #'first seqs)))) + (loop for s in seqs + for f in factors + for i from 0 + with add = t do + (if (= x (first s)) (pop s)) + ;; prevent a value from being added to multiple lists + (when add + (setf (elt seqs i) (nconc s (list (* x f)))) + (if (zerop (mod x f)) (setf add nil))) + finally (return x)))) + +(loop with factors = '(2 3 5) + with seqs = (loop for i in factors collect '(1)) + for n from 1 to 1000001 do + (let ((x (next-hamm factors seqs))) + (if (or (< n 21) + (= n 1691) + (= n 1000000)) (format t "~d: ~d~%" n x)))) diff --git a/Task/Hamming-numbers/Common-Lisp/hamming-numbers-2.lisp b/Task/Hamming-numbers/Common-Lisp/hamming-numbers-2.lisp new file mode 100644 index 0000000000..f5cfd3516e --- /dev/null +++ b/Task/Hamming-numbers/Common-Lisp/hamming-numbers-2.lisp @@ -0,0 +1,20 @@ +(defun hamming (n) + (let ((fac '(2 3 5)) + (idx (make-array 3 :initial-element 0)) + (h (make-array (1+ n) + :initial-element 1 + :element-type 'integer))) + (loop for i from 1 to n + with e with x = '(1 1 1) do + (setf e (setf (aref h i) (apply #'min x)) + x (loop for y in x + for f in fac + for j from 0 + collect (if (= e y) (* f (aref h (incf (aref idx j)))) y)))) + (aref h n))) + +(loop for i from 1 to 20 do + (format t "~2d: ~d~%" i (hamming i))) + +(loop for i in '(1691 1000000) do + (format t "~d: ~d~%" i (hamming i))) diff --git a/Task/Hamming-numbers/D/hamming-numbers-1.d b/Task/Hamming-numbers/D/hamming-numbers-1.d new file mode 100644 index 0000000000..a7797c7317 --- /dev/null +++ b/Task/Hamming-numbers/D/hamming-numbers-1.d @@ -0,0 +1,23 @@ +import std.stdio, std.bigint, std.algorithm, std.range; + +auto hamming(in int n) { + BigInt two = 2, three = 3, five = 5; + auto h = new BigInt[n]; + h[0] = 1; + BigInt x2 = 2, x3 = 3, x5 = 5; + int i, j, k; + + foreach (ref el; h[1 .. $]) { + el = min(x2, x3, x5); + if (el == x2) x2 = two * h[++i]; + if (el == x3) x3 = three * h[++j]; + if (el == x5) x5 = five * h[++k]; + } + return h.back; +} + +void main() { + iota(1, 21).map!hamming.writeln; + 1_691.hamming.writeln; + 1_000_000.hamming.writeln; +} diff --git a/Task/Hamming-numbers/D/hamming-numbers-2.d b/Task/Hamming-numbers/D/hamming-numbers-2.d new file mode 100644 index 0000000000..63605ac641 --- /dev/null +++ b/Task/Hamming-numbers/D/hamming-numbers-2.d @@ -0,0 +1,23 @@ +import std.stdio,std.bigint,std.container,std.algorithm,std.range; + +BigInt hamming(int n) +in { + assert(n > 0); +} body { + auto frontier = redBlackTree(BigInt(2), BigInt(3), BigInt(5)); + auto lowest = BigInt(1); + foreach (_; 1 .. n) { + lowest = frontier.front(); + frontier.removeFront(); + frontier.insert(lowest * 2); + frontier.insert(lowest * 3); + frontier.insert(lowest * 5); + } + return lowest; +} + +void main() { + writeln("First 20 Hamming numbers: ", map!hamming(iota(1, 21))); + writeln("hamming(1691) = ", hamming(1691)); + writeln("hamming(1_000_000) = ", hamming(1_000_000)); +} diff --git a/Task/Hamming-numbers/D/hamming-numbers-3.d b/Task/Hamming-numbers/D/hamming-numbers-3.d new file mode 100644 index 0000000000..854c06e34a --- /dev/null +++ b/Task/Hamming-numbers/D/hamming-numbers-3.d @@ -0,0 +1,107 @@ +import std.stdio: writefln; +import std.bigint: BigInt, toDecimalString; +import std.numeric: gcd; +import std.algorithm: copy, map; +import std.math; // log, ^^ + +// Number of factors. +enum NK = 3; + +enum MAX_HAM = 10_000_000; +static assert(gcd(NK, MAX_HAM) == 1); + +enum int[NK] fac = [2, 3, 5]; + + +/// k-smooth numbers (stored as their exponents of each factor). +struct Hamming { + double v; // log of the number, for convenience. + ushort[NK] e; // exponents of each factor. + + // Compile-time constant, map!log(fac) + // log can't be used in CTFE yet + public static __gshared const double[fac.length] inc; + + nothrow pure static this() { + //map!log(fac[]).copy(inc[]); // Not nothrow, not const. + foreach (i, f; fac) + inc[i] = log(f); + } + + bool opEquals(in ref Hamming y) const pure nothrow { + //return this.e == y.e; // too much slow + foreach (size_t i; 0 .. this.e.length) + if (this.e[i] != y.e[i]) + return false; + return true; + } + + void update() pure nothrow { + //this.v = dotProduct(inc, this.e); // too much slow + this.v = 0.0; + foreach (size_t i; 0 .. this.e.length) + this.v += inc[i] * this.e[i]; + } + + string toString() const { + BigInt result = 1; + foreach (size_t i, f; fac) + result *= BigInt(f) ^^ this.e[i]; + return toDecimalString(result); + } +} + +// Global variables. +__gshared Hamming[] hams; +__gshared Hamming[NK] values; + + +nothrow static this() { + // Slower than malloc if you don't use all the MAX_HAM items. + hams = new Hamming[MAX_HAM]; + + foreach (i, ref v; values) { + v.e[i] = 1; + v.v = Hamming.inc[i]; + } +} + + +ref Hamming getHam(in size_t n) nothrow +in { + assert(n <= MAX_HAM); +} body { + // Most of the time v can be just incremented, but eventually + // floating point precision will bite us, so better recalculate. + __gshared static size_t[NK] idx; + __gshared static int n_hams; + + for (; n_hams < n; n_hams++) { + { + // Find the index of the minimum v. + size_t ni = 0; + foreach (size_t i; 1 .. NK) + if (values[i].v < values[ni].v) + ni = i; + + hams[n_hams] = values[ni]; + hams[n_hams].update(); + } + + foreach (size_t i; 0 .. NK) + if (values[i] == hams[n_hams]) { + values[i] = hams[idx[i]]; + idx[i]++; + values[i].e[i]++; + values[i].update(); + } + } + + return hams[n - 2]; +} + + +void main() { + foreach (n; [1691, 10 ^^ 6, MAX_HAM]) + writefln("%8d: %s", n, getHam(n)); +} diff --git a/Task/Hamming-numbers/Eiffel/hamming-numbers.e b/Task/Hamming-numbers/Eiffel/hamming-numbers.e new file mode 100644 index 0000000000..cf0ce68b9b --- /dev/null +++ b/Task/Hamming-numbers/Eiffel/hamming-numbers.e @@ -0,0 +1,77 @@ +note + description : "Initial part, in order, of the sequence of Hamming numbers" + math : "[ + Hamming numbers, also known as regular numbers and 5-smooth numbers, are natural integers + that have 2, 3 and 5 as their only prime factors. + ]" + computer_arithmetic : + "[ + This version avoids integer overflow and stops at the last representable number in the sequence. + ]" + output : "[ + Per requirements of the RosettaCode example, execution will produce items of indexes 1 to 20 and 1691. + The algorithm (procedure `hamming') is more general and will produce the first `n' Hamming numbers + for any `n'. + ]" + source : "This problem was posed in Edsger W. Dijkstra, A Discipline of Programming, Prentice Hall, 1978" + date : "8 August 2012" + authors : "Bertrand Meyer", "Emmanuel Stapf" + revision : "1.0" + libraries : "Relies on SORTED_TWO_WAY_LIST from EiffelBase" + implementation : "[ + Using SORTED_TWO_WAY_LIST provides an elegant illustration of how to implement + a lazy scheme in Eiffel through the use of object-oriented data structures. + ]" + warning : "[ + The formatting () specifications for Eiffel in RosettaCode are slightly obsolete: + `note' and other newer keywords not supported, red color for manifest strings. + This should be fixed soon. + ]" + +class + APPLICATION + +create + make + +feature {NONE} -- Initialization + + make + -- Print first 20 Hamming numbers, in order, and the 1691-st one. + local + Hammings: like hamming + -- List of Hamming numbers, up to 1691-st one. + do + Hammings := hamming (1691) + across 1 |..| 20 as i loop + io.put_natural (Hammings.i_th (i.item)); io.put_string (" ") + end + io.put_new_line; io.put_natural (Hammings.i_th (1691)); io.put_new_line + end + +feature -- Basic operations + + hamming (n: INTEGER): ARRAYED_LIST [NATURAL] + -- First `n' elements (in order) of the Hamming sequence, + -- or as many of them as will not produce overflow. + local + sl: SORTED_TWO_WAY_LIST [NATURAL] + overflow: BOOLEAN + first, next: NATURAL + do + create Result.make (n); create sl.make + sl.extend (1); sl.start + across 1 |..| n as i invariant + -- "The numbers output so far are the first `i' - 1 Hamming numbers, in order". + -- "Result.first is the `i'-th Hamming number." + until sl.is_empty loop + first := sl.first; sl.start + Result.extend (first); sl.remove + across << 2, 3, 5 >> as multiplier loop + next := multiplier.item * first + overflow := overflow or next <= first + if not overflow and then not sl.has (next) then sl.extend (next) end + end + end + end +end diff --git a/Task/Hamming-numbers/Factor/hamming-numbers-1.factor b/Task/Hamming-numbers/Factor/hamming-numbers-1.factor new file mode 100644 index 0000000000..6133f2edb4 --- /dev/null +++ b/Task/Hamming-numbers/Factor/hamming-numbers-1.factor @@ -0,0 +1,32 @@ +USING: accessors deques dlists fry kernel make math math.order +; +IN: rosetta.hamming + +TUPLE: hamming-iterator 2s 3s 5s ; + +: ( -- hamming-iterator ) + hamming-iterator new + 1 1dlist >>2s + 1 1dlist >>3s + 1 1dlist >>5s ; + +: enqueue ( n hamming-iterator -- ) + [ [ 2 * ] [ 2s>> ] bi* push-back ] + [ [ 3 * ] [ 3s>> ] bi* push-back ] + [ [ 5 * ] [ 5s>> ] bi* push-back ] 2tri ; + +: next ( hamming-iterator -- n ) + dup [ 2s>> ] [ 3s>> ] [ 5s>> ] tri + 3dup [ peek-front ] tri@ min min + [ + '[ + dup peek-front _ = + [ pop-front* ] [ drop ] if + ] tri@ + ] [ swap enqueue ] [ ] tri ; + +: next-n ( hamming-iterator n -- seq ) + swap '[ _ [ _ next , ] times ] { } make ; + +: nth-from-now ( hamming-iterator n -- m ) + 1 - over '[ _ next drop ] times next ; diff --git a/Task/Hamming-numbers/Factor/hamming-numbers-2.factor b/Task/Hamming-numbers/Factor/hamming-numbers-2.factor new file mode 100644 index 0000000000..8992af9d11 --- /dev/null +++ b/Task/Hamming-numbers/Factor/hamming-numbers-2.factor @@ -0,0 +1,18 @@ +USING: combinators fry kernel lists lists.lazy locals math ; +IN: rosetta.hamming-lazy + +:: sort-merge ( xs ys -- result ) + xs car :> x + ys car :> y + { + { [ x y < ] [ [ x ] [ xs cdr ys sort-merge ] lazy-cons ] } + { [ x y > ] [ [ y ] [ ys cdr xs sort-merge ] lazy-cons ] } + [ [ x ] [ xs cdr ys cdr sort-merge ] lazy-cons ] + } cond ; + +:: hamming ( -- hamming ) + f :> h! + [ 1 ] [ + h 2 3 5 [ '[ _ * ] lazy-map ] tri-curry@ tri + sort-merge sort-merge + ] lazy-cons h! h ; diff --git a/Task/Hamming-numbers/Forth/hamming-numbers.fth b/Task/Hamming-numbers/Forth/hamming-numbers.fth new file mode 100644 index 0000000000..f2f8a2fca9 --- /dev/null +++ b/Task/Hamming-numbers/Forth/hamming-numbers.fth @@ -0,0 +1,92 @@ +\ manipulating and computing with Hamming numbers: + +: extract2 ( h -- l ) + 40 rshift ; + +: extract3 ( h -- m ) + 20 rshift $fffff and ; + +: extract5 ( h -- n ) + $fffff and ; + +' + alias h* ( h1 h2 -- h ) + +: h. { h -- } + ." 2^" h extract2 0 .r + ." *3^" h extract3 0 .r + ." *5^" h extract5 . ; + +\ the following numbers have been produced with bc -l as follows +1 62 lshift constant ldscale2 + 7309349404307464679 constant ldscale3 \ 2^62*l(3)/l(2) (rounded up) +10708003330985790206 constant ldscale5 \ 2^62*l(5)/l(2) (rounded down) + +: hld { h -- ud } + \ ud is a scaled fixed-point representation of the logarithm dualis of h + h extract2 ldscale2 um* + h extract3 ldscale3 um* d+ + h extract5 ldscale5 um* d+ ; + +: h<= ( h1 h2 -- f ) + 2dup = if + 2drop true exit + then + hld rot hld assert( 2over 2over d<> ) + du>= ; + +: hmin ( h1 h2 -- h ) + 2dup h<= if + drop + else + nip + then ; + +\ actual algorithm + +0 value seq +variable seqlast 0 seqlast ! + +: lastseq ( -- u ) + \ last stored number in the sequence + seq seqlast @ th @ ; + +: genseq ( h1 "name" -- ) + \ h1 is the factor for the sequence + create , 0 , \ factor and index of element used for last return + does> ( -- u2 ) + \ u2 is the next number resulting from multiplying h1 with numbers + \ in the sequence that is larger than the last number in the + \ sequence + dup @ lastseq { h1 l } cell+ dup @ begin ( index-addr index ) + seq over th @ h1 h* dup l h<= while + drop 1+ repeat + >r swap ! r> ; + +$10000000000 genseq s2 +$00000100000 genseq s3 +$00000000001 genseq s5 + +: nextseq ( -- ) + s2 s3 hmin s5 hmin , 1 seqlast +! ; + +: nthseq ( u1 -- h ) + \ the u1 th element in the sequence + dup seqlast @ u+do + nextseq + loop + 1- 0 max cells seq + @ ; + +: .nseq ( u1 -- ) + dup seqlast @ u+do + nextseq + loop + 0 u+do + seq i th @ h. + loop ; + +here to seq +0 , \ that's 1 + +20 .nseq +cr 1691 nthseq h. +cr 1000000 nthseq h. diff --git a/Task/Hamming-numbers/Fortran/hamming-numbers.f b/Task/Hamming-numbers/Fortran/hamming-numbers.f new file mode 100644 index 0000000000..b96692ad15 --- /dev/null +++ b/Task/Hamming-numbers/Fortran/hamming-numbers.f @@ -0,0 +1,72 @@ +program Hamming_Test + use big_integer_module + implicit none + + call Hamming(1,20) + write(*,*) + call Hamming(1691) + write(*,*) + call Hamming(1000000) + +contains + +subroutine Hamming(first, last) + + integer, intent(in) :: first + integer, intent(in), optional :: last + integer :: i, n, i2, i3, i5, lim + type(big_integer), allocatable :: hnums(:) + + if(present(last)) then + lim = last + else + lim = first + end if + + if(first < 1 .or. lim > 2500000 ) then + write(*,*) "Invalid input" + return + end if + + allocate(hnums(lim)) + + i2 = 1 ; i3 = 1 ; i5 = 1 + hnums(1) = 1 + n = 1 + do while(n < lim) + n = n + 1 + hnums(n) = mini(2*hnums(i2), 3*hnums(i3), 5*hnums(i5)) + if(2*hnums(i2) == hnums(n)) i2 = i2 + 1 + if(3*hnums(i3) == hnums(n)) i3 = i3 + 1 + if(5*hnums(i5) == hnums(n)) i5 = i5 + 1 + end do + + if(present(last)) then + do i = first, last + call print_big(hnums(i)) + write(*, "(a)", advance="no") " " + end do + else + call print_big(hnums(first)) + end if + + deallocate(hnums) +end subroutine + +function mini(a, b, c) + type(big_integer) :: mini + type(big_integer), intent(in) :: a, b, c + + if(a < b ) then + if(a < c) then + mini = a + else + mini = c + end if + else if(b < c) then + mini = b + else + mini = c + end if +end function mini +end program diff --git a/Task/Hamming-numbers/Go/hamming-numbers-1.go b/Task/Hamming-numbers/Go/hamming-numbers-1.go new file mode 100644 index 0000000000..642c1c24ce --- /dev/null +++ b/Task/Hamming-numbers/Go/hamming-numbers-1.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "math/big" +) + +func min(a, b *big.Int) *big.Int { + if a.Cmp(b) < 0 { + return a + } + return b +} + +func hamming(n int) []*big.Int { + h := make([]*big.Int, n) + h[0] = big.NewInt(1) + two, three, five := big.NewInt(2), big.NewInt(3), big.NewInt(5) + next2, next3, next5 := big.NewInt(2), big.NewInt(3), big.NewInt(5) + i, j, k := 0, 0, 0 + for m := 1; m < len(h); m++ { + h[m] = new(big.Int).Set(min(next2, min(next3, next5))) + if h[m].Cmp(next2) == 0 { i++; next2.Mul( two, h[i]) } + if h[m].Cmp(next3) == 0 { j++; next3.Mul(three, h[j]) } + if h[m].Cmp(next5) == 0 { k++; next5.Mul( five, h[k]) } + } + return h +} + +func main() { + h := hamming(1e6) + fmt.Println(h[:20]) + fmt.Println(h[1691-1]) + fmt.Println(h[len(h)-1]) +} diff --git a/Task/Hamming-numbers/Go/hamming-numbers-2.go b/Task/Hamming-numbers/Go/hamming-numbers-2.go new file mode 100644 index 0000000000..f3fb932931 --- /dev/null +++ b/Task/Hamming-numbers/Go/hamming-numbers-2.go @@ -0,0 +1,99 @@ +package main + +import ( + "flag" + "fmt" + "math" + "math/big" + "os" +) + +var ordinal int // ordinal of last sequence element to compute +var sequenceMode bool // print the whole sequence or just one element? + +var lg3, lg5 float64 // precomputed base-2 logarithms for 3 and 5 + +var table [][3]int16 // table for dynamic-programming stored results +var front [3]cursor // state of the three multiplied sequences + +type cursor struct { + f int // index (0, 1, 2) corresponding to factor (2, 3, 5) + i int // index into table for the entry being multiplied + lg float64 // base-2 logarithm of the multiple (for ordering) +} + +func (c *cursor) value() [3]int16 { + x := table[c.i] + x[c.f]++ // multiply by incrementing the exponent + return x +} + +func (c *cursor) advance() { + c.i++ + // skip entries that would produce duplicates + for (c.f < 2 && table[c.i][2] > 0) || (c.f < 1 && table[c.i][1] > 0) { + c.i++ + } + x := c.value() + c.lg = float64(x[0]) + lg3*float64(x[1]) + lg5*float64(x[2]) +} + +func step() { + table = append(table, front[0].value()) + front[0].advance() + // re-establish sorted order + if front[0].lg > front[1].lg { + front[0], front[1] = front[1], front[0] + if front[1].lg > front[2].lg { + front[1], front[2] = front[2], front[1] + } + } +} +func show(elem [3]int16) { + z := big.NewInt(1) + for i, base := range []int64{2, 3, 5} { + b := big.NewInt(base) + x := big.NewInt(int64(elem[i])) + z.Mul(z, b.Exp(b, x, nil)) + } + fmt.Println(z) +} + +func fail(msg string) { + fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], msg) + os.Exit(1) +} + +func parse() { + flag.Parse() + if flag.NArg() != 1 { + fail("need one argument") + } + _, err := fmt.Sscan(flag.Arg(0), &ordinal) + if err != nil || ordinal <= 0 { + fail("argument must be a positive integer") + } +} + +func init() { + flag.BoolVar(&sequenceMode, "s", false, "sequence mode") + lg3 = math.Log2(3) + lg5 = math.Log2(5) + front = [3]cursor{ + {0, 0, 1}, // 2 + {1, 0, lg3}, // 3 + {2, 0, lg5}, // 5 + } +} + +func main() { + parse() + table = make([][3]int16, 1, ordinal) + for i, n := 1, ordinal; i < n; i++ { + if sequenceMode { + show(table[i-1]) + } + step() + } + show(table[ordinal-1]) +} diff --git a/Task/Hamming-numbers/Haskell/hamming-numbers-1.hs b/Task/Hamming-numbers/Haskell/hamming-numbers-1.hs new file mode 100644 index 0000000000..14bad2b763 --- /dev/null +++ b/Task/Hamming-numbers/Haskell/hamming-numbers-1.hs @@ -0,0 +1,16 @@ +hamming = 1 : map (2*) hamming `union` map (3*) hamming `union` map (5*) hamming + +union a@(x:xs) b@(y:ys) = case compare x y of + LT -> x : union xs b + EQ -> x : union xs ys + GT -> y : union a ys + +main = do + print $ take 20 hamming + print (hamming !! (1691-1), hamming !! (1692-1)) + print $ hamming !! (1000000-1) + +-- Output: +-- [1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36] +-- (2125764000,2147483648) +-- 519312780448388736089589843750000000000000000000000000000000000000000000000000000000 diff --git a/Task/Hamming-numbers/Haskell/hamming-numbers-2.hs b/Task/Hamming-numbers/Haskell/hamming-numbers-2.hs new file mode 100644 index 0000000000..a8feb257f2 --- /dev/null +++ b/Task/Hamming-numbers/Haskell/hamming-numbers-2.hs @@ -0,0 +1,12 @@ +hamming = 1:foldl u [] [5,3,2] where + u s n = ar where + ar = merge s (n:map (n*) ar) + merge [] b = b + merge a@(x:xs) b@(y:ys) + | x < y = x:merge xs b + | otherwise = y:merge a ys + +main = do + print $ take 20 hamming + print $ hamming !! 1690 + print $ hamming !! (1000000-1) diff --git a/Task/Hamming-numbers/Haskell/hamming-numbers-3.hs b/Task/Hamming-numbers/Haskell/hamming-numbers-3.hs new file mode 100644 index 0000000000..8fc9632b3b --- /dev/null +++ b/Task/Hamming-numbers/Haskell/hamming-numbers-3.hs @@ -0,0 +1 @@ +hamm n = drop n $ iterate (\(_,(a:t))-> (a,union t [2*a,3*a,5*a])) (0,[1]) diff --git a/Task/Hamming-numbers/Haskell/hamming-numbers-4.hs b/Task/Hamming-numbers/Haskell/hamming-numbers-4.hs new file mode 100644 index 0000000000..72b7da644e --- /dev/null +++ b/Task/Hamming-numbers/Haskell/hamming-numbers-4.hs @@ -0,0 +1,20 @@ +*Main> map fst $ take 20 $ hamm 1 +[1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36] + +*Main> map fst $ take 2 $ hamm 1691 +[2125764000,2147483648] + +*Main> mapM_ print $ take 10 $ hamm 1 +(1,[2,3,5]) +(2,[3,4,5,6,10]) +(3,[4,5,6,9,10,15]) +(4,[5,6,8,9,10,12,15,20]) +(5,[6,8,9,10,12,15,20,25]) +(6,[8,9,10,12,15,18,20,25,30]) +(8,[9,10,12,15,16,18,20,24,25,30,40]) +(9,[10,12,15,16,18,20,24,25,27,30,40,45]) +(10,[12,15,16,18,20,24,25,27,30,40,45,50]) +(12,[15,16,18,20,24,25,27,30,36,40,45,50,60]) + +*Main> map (length.snd.head.hamm) [2000,4000,8000,16000] +[402,638,1007,1596] diff --git a/Task/Hamming-numbers/Haskell/hamming-numbers-5.hs b/Task/Hamming-numbers/Haskell/hamming-numbers-5.hs new file mode 100644 index 0000000000..707f609328 --- /dev/null +++ b/Task/Hamming-numbers/Haskell/hamming-numbers-5.hs @@ -0,0 +1,44 @@ +-- directly find n-th Hamming number, in ~ O(n^{2/3}) time +-- by Will Ness, based on "top band" idea by Louis Klauder, from DDJ discussion +-- http://drdobbs.com/blogs/architecture-and-design/228700538 + +{-# OPTIONS -O2 -XBangPatterns #-} +import Data.List (sortBy) +import Data.Function (on) + +main = do { let (r,t) = nthHam 1000000 + ; sequence_ [print t, print $ trival t] } + +lg3 = logBase 2 3; lg5 = logBase 2 5 +logval (i,j,k) = fromIntegral i + fromIntegral j*lg3 + fromIntegral k*lg5 +trival (i,j,k) = 2^i * 3^j * 5^k +estval n = (6*lg3*lg5* fromIntegral n)**(1/3) -- estimated logval, base 2 +rngval n + | n > 500000 = (2.4496 , 0.0076 ) -- empirical estimation + | n > 50000 = (2.4424 , 0.0146 ) -- correction, base 2 + | n > 500 = (2.3948 , 0.0723 ) -- (dist,width) + | n > 1 = (2.2506 , 0.2887 ) -- around (log $ sqrt 30), + | otherwise = (2.2506 , 0.5771 ) -- says WP + +nthHam n -- n: 1-based: 1,2,3... + | w >= 1 = error $ "Breach of contract: (w < 1): " ++ show w + | m < 0 = error $ "Not enough triples generated: " ++ show (c,n) + | m >= nb = error $ "Generated band is too narrow: " ++ show (m,nb) + | True = res + where + (d,w) = rngval n -- correction dist, width + hi = estval n - d -- hi > logval > hi-w + (m,nb) = ( fromInteger $ c - n, length b ) -- m 0-based from top, |band| + (s,res) = ( sortBy (flip compare `on` fst) b, s!!m ) -- sorted decreasing, result + (c,b) = f 0 -- total count, the band + [ ( i+1, -- total triples w/ this (j,k) + [ (r,(i,j,k)) | frac < w ] ) -- store it, if inside band + | k <- [ 0 .. floor ( hi /lg5) ], let p = fromIntegral k*lg5, + j <- [ 0 .. floor ((hi-p)/lg3) ], let q = fromIntegral j*lg3 + p, + let (i,frac) = pr (hi-q) ; r = hi-frac ] -- r = i + q + -- f 0 z == (sum $ map fst z, concat $ map snd z) + where pr = properFraction + f !c [] = (c,[]) -- code as a loop + f !c ((c1,b1):r) = let (cr,br) = f (c+c1) r -- to prevent space leak + in case b1 of { [v] -> (cr,v:br) + ; _ -> (cr, br) } diff --git a/Task/Hamming-numbers/Icon/hamming-numbers.icon b/Task/Hamming-numbers/Icon/hamming-numbers.icon new file mode 100644 index 0000000000..6b94116872 --- /dev/null +++ b/Task/Hamming-numbers/Icon/hamming-numbers.icon @@ -0,0 +1,53 @@ +# Lazily generate the three Hamming numbers that can be derived directly +# from a known Hamming number h +class Triplet : Class (cv, ce) + + method nextVal() + suspend cv := @ce + end + + initially (baseNum) + cv := 2*baseNum + ce := create (3|5)*baseNum +end + +# Generate Hamming numbers, in order. Default is first 30 +# But an optional argument can be used to generate more (or less) +# e.g. hamming 5000 generates the first 5000. +procedure main(args) + limit := integer(args[1]) | 30 + every write("\t", generateHamming() \ limit) +end + +# Do the work. Start with known Hamming number 1 and maintain +# a set of triplet Hamming numbers as they get derived from that +# one. Most of the code here is to figure out which Hamming +# number is next in sequence (while removing duplicates) +procedure generateHamming() + triplers := set() + insert(triplers, Triplet(1)) + + suspend 1 + repeat { + # Pick a Hamming triplet that *may* have the next smallest number + t1 := !triplers # any will do to start + + every t1 ~=== (t2 := !triplers) do { + if t1.cv > t2.cv then { + # oops we were wrong, switch assumption + t1 := t2 + } + else if t1.cv = t2.cv then { + # t2's value is a duplicate, so + # advance triplet t2, if none left in t2, remove it + t2.nextVal() | delete(triplers, t2) + } + } + + # Ok, t1 has the next Hamming number, grab it + suspend t1.cv + insert(triplers, Triplet(t1.cv)) + # Advance triplet t1, if none left in t1, remove it + t1.nextVal() | delete(triplers, t1) + } +end diff --git a/Task/Hamming-numbers/J/hamming-numbers-1.j b/Task/Hamming-numbers/J/hamming-numbers-1.j new file mode 100644 index 0000000000..d44ef07880 --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-1.j @@ -0,0 +1 @@ +hamming=: {. (/:~@~.@], 2 3 5 * {)/ @ (1x,~i.@-) diff --git a/Task/Hamming-numbers/J/hamming-numbers-2.j b/Task/Hamming-numbers/J/hamming-numbers-2.j new file mode 100644 index 0000000000..45f0b08dcb --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-2.j @@ -0,0 +1,5 @@ + hamming 20 +1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36 + + {: hamming 1691 +2125764000 diff --git a/Task/Hamming-numbers/J/hamming-numbers-3.j b/Task/Hamming-numbers/J/hamming-numbers-3.j new file mode 100644 index 0000000000..184fa06e3e --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-3.j @@ -0,0 +1 @@ + /:~@~.@] diff --git a/Task/Hamming-numbers/J/hamming-numbers-4.j b/Task/Hamming-numbers/J/hamming-numbers-4.j new file mode 100644 index 0000000000..520775ebfb --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-4.j @@ -0,0 +1 @@ + 2 3 5 * { diff --git a/Task/Hamming-numbers/J/hamming-numbers-5.j b/Task/Hamming-numbers/J/hamming-numbers-5.j new file mode 100644 index 0000000000..fe35e2b67f --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-5.j @@ -0,0 +1 @@ + 2 3 5 * LHA { RHA diff --git a/Task/Hamming-numbers/J/hamming-numbers-6.j b/Task/Hamming-numbers/J/hamming-numbers-6.j new file mode 100644 index 0000000000..0be33e15a2 --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-6.j @@ -0,0 +1 @@ + (1x,~i.@-) diff --git a/Task/Hamming-numbers/J/hamming-numbers-7.j b/Task/Hamming-numbers/J/hamming-numbers-7.j new file mode 100644 index 0000000000..ba5d495bdc --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-7.j @@ -0,0 +1,2 @@ + ({. (/:~@~.@], 2 3 5 * {)/ @ (1x,~i.@-)) 7 +1 2 3 4 5 6 8 diff --git a/Task/Hamming-numbers/J/hamming-numbers-8.j b/Task/Hamming-numbers/J/hamming-numbers-8.j new file mode 100644 index 0000000000..7544032d27 --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-8.j @@ -0,0 +1,2 @@ + (1x,~i.@-) 7 +6 5 4 3 2 1 0 1 diff --git a/Task/Hamming-numbers/J/hamming-numbers-9.j b/Task/Hamming-numbers/J/hamming-numbers-9.j new file mode 100644 index 0000000000..b973d50b05 --- /dev/null +++ b/Task/Hamming-numbers/J/hamming-numbers-9.j @@ -0,0 +1,2 @@ + 6(/:~@~.@], 2 3 5 * {) 5(/:~@~.@], 2 3 5 * {) 4(/:~@~.@], 2 3 5 * {) 3(/:~@~.@], 2 3 5 * {) 2(/:~@~.@], 2 3 5 * {) 1(/:~@~.@], 2 3 5 * {) 0(/:~@~.@], 2 3 5 * {) 1 +1 2 3 4 5 6 8 9 10 12 15 18 20 25 30 16 24 40 diff --git a/Task/Hamming-numbers/Java/hamming-numbers.java b/Task/Hamming-numbers/Java/hamming-numbers.java new file mode 100644 index 0000000000..3cc3f55175 --- /dev/null +++ b/Task/Hamming-numbers/Java/hamming-numbers.java @@ -0,0 +1,37 @@ +import java.math.BigInteger; +import java.util.PriorityQueue; + +final class Hamming { + private static BigInteger THREE = BigInteger.valueOf(3); + private static BigInteger FIVE = BigInteger.valueOf(5); + + private static void updateFrontier(BigInteger x, + PriorityQueue pq) { + pq.offer(x.shiftLeft(1)); + pq.offer(x.multiply(THREE)); + pq.offer(x.multiply(FIVE)); + } + + public static BigInteger hamming(int n) { + if (n <= 0) + throw new IllegalArgumentException("Invalid parameter"); + PriorityQueue frontier = new PriorityQueue(); + updateFrontier(BigInteger.ONE, frontier); + BigInteger lowest = BigInteger.ONE; + for (int i = 1; i < n; i++) { + lowest = frontier.poll(); + while (frontier.peek().equals(lowest)) + frontier.poll(); + updateFrontier(lowest, frontier); + } + return lowest; + } + + public static void main(String[] args) { + System.out.print("Hamming(1 .. 20) ="); + for (int i = 1; i < 21; i++) + System.out.print(" " + hamming(i)); + System.out.println("\nHamming(1691) = " + hamming(1691)); + System.out.println("Hamming(1000000) = " + hamming(1000000)); + } +} diff --git a/Task/Hamming-numbers/JavaScript/hamming-numbers-1.js b/Task/Hamming-numbers/JavaScript/hamming-numbers-1.js new file mode 100644 index 0000000000..31d17945c1 --- /dev/null +++ b/Task/Hamming-numbers/JavaScript/hamming-numbers-1.js @@ -0,0 +1,27 @@ +function hamming() { + var queues = {2: [], 3: [], 5: []}; + var base; + var next_ham = 1; + while (true) { + yield next_ham; + + for (base in queues) {queues[base].push(next_ham * base)} + + next_ham = [ queue[0] for each (queue in queues) ].reduce(function(min, val) { + return Math.min(min,val) + }); + + for (base in queues) {if (queues[base][0] == next_ham) queues[base].shift()} + } +} + +var ham = hamming(); +var first20=[], i=1; + +for (; i <= 20; i++) + first20.push(ham.next()); +print(first20.join(', ')); +print('...'); +for (; i <= 1690; i++) + ham.next(); +print(i + " => " + ham.next()); diff --git a/Task/Hamming-numbers/JavaScript/hamming-numbers-2.js b/Task/Hamming-numbers/JavaScript/hamming-numbers-2.js new file mode 100644 index 0000000000..81173bdc64 --- /dev/null +++ b/Task/Hamming-numbers/JavaScript/hamming-numbers-2.js @@ -0,0 +1,98 @@ + + + +
+ + + + + diff --git a/Task/Hamming-numbers/Liberty-BASIC/hamming-numbers.liberty b/Task/Hamming-numbers/Liberty-BASIC/hamming-numbers.liberty new file mode 100644 index 0000000000..c6b7f58ee2 --- /dev/null +++ b/Task/Hamming-numbers/Liberty-BASIC/hamming-numbers.liberty @@ -0,0 +1,24 @@ +dim h( 1000000) + +for i =1 to 20 + print hamming( i); " "; +next i + +print +print "H( 1691)", hamming( 1691) +print "H( 1000000)", hamming( 1000000) + +end + +function hamming( limit) + h( 0) =1 + x2 =2: x3 =3: x5 =5 + i =0: j =0: k =0 + for n =1 to limit + h( n) = min( x2, min( x3, x5)) + if x2 = h( n) then i = i +1: x2 =2 *h( i) + if x3 = h( n) then j = j +1: x3 =3 *h( j) + if x5 = h( n) then k = k +1: x5 =5 *h( k) + next n + hamming =h( limit -1) +end function diff --git a/Task/Hamming-numbers/Logo/hamming-numbers.logo b/Task/Hamming-numbers/Logo/hamming-numbers.logo new file mode 100644 index 0000000000..462f84a15c --- /dev/null +++ b/Task/Hamming-numbers/Logo/hamming-numbers.logo @@ -0,0 +1,26 @@ +to init.ham + ; queues + make "twos [1] + make "threes [1] + make "fives [1] +end +to next.ham + localmake "ham first :twos + if less? first :threes :ham [make "ham first :threes] + if less? first :fives :ham [make "ham first :fives] + + if equal? :ham first :twos [ignore dequeue "twos] + if equal? :ham first :threes [ignore dequeue "threes] + if equal? :ham first :fives [ignore dequeue "fives] + + queue "twos :ham * 2 + queue "threes :ham * 3 + queue "fives :ham * 5 + + output :ham +end + +init.ham +repeat 20 [print next.ham] +repeat 1690-20 [ignore next.ham] +print next.ham diff --git a/Task/Hamming-numbers/Lua/hamming-numbers.lua b/Task/Hamming-numbers/Lua/hamming-numbers.lua new file mode 100644 index 0000000000..5849c4d36c --- /dev/null +++ b/Task/Hamming-numbers/Lua/hamming-numbers.lua @@ -0,0 +1,24 @@ +function hiter() + hammings = {1} + prev, vals = {1, 1, 1} + index = 1 + local function nextv() + local n, v = 1, hammings[prev[1]]*2 + if hammings[prev[2]]*3 < v then n, v = 2, hammings[prev[2]]*3 end + if hammings[prev[3]]*5 < v then n, v = 3, hammings[prev[3]]*5 end + prev[n] = prev[n] + 1 + if hammings[index] == v then return nextv() end + index = index + 1 + hammings[index] = v + return v + end + return nextv +end + +j = hiter() +for i = 1, 20 do + print(j()) +end +n, l = 0, 0 +while n < 2^31 do n, l = j(), n end +print(l) diff --git a/Task/Hamming-numbers/MUMPS/hamming-numbers.mumps b/Task/Hamming-numbers/MUMPS/hamming-numbers.mumps new file mode 100644 index 0000000000..1c9f6f93db --- /dev/null +++ b/Task/Hamming-numbers/MUMPS/hamming-numbers.mumps @@ -0,0 +1,34 @@ +Hamming(n) New count,ok,next,number,which + For which=2,3,5 Set number=1 + For count=1:1:n Do + . Set ok=0 Set:count<21 ok=1 Set:count=1691 ok=1 Set:count=n ok=1 + . Write:ok !,$Justify(count,5),": ",number + . For which=2,3,5 Set next(number*which)=which + . Set number=$Order(next("")) + . Kill next(number) + . Quit + Quit +Do Hamming(2000) + + 1: 1 + 2: 2 + 3: 3 + 4: 4 + 5: 5 + 6: 6 + 7: 8 + 8: 9 + 9: 10 + 10: 12 + 11: 15 + 12: 16 + 13: 18 + 14: 20 + 15: 24 + 16: 25 + 17: 27 + 18: 30 + 19: 32 + 20: 36 + 1691: 2125764000 + 2000: 8062156800 diff --git a/Task/Hamming-numbers/Mathematica/hamming-numbers.mathematica b/Task/Hamming-numbers/Mathematica/hamming-numbers.mathematica new file mode 100644 index 0000000000..607da19a49 --- /dev/null +++ b/Task/Hamming-numbers/Mathematica/hamming-numbers.mathematica @@ -0,0 +1,3 @@ +HammingList[N_] := Module[{A, B, C}, {A, B, C} = (N^(1/3))*{2.8054745679851933, 1.7700573778298891, 1.2082521307023026} - {1, 1, 1}; + Take[ Sort@Flatten@Table[ 2^x * 3^y * 5^z , +{x, 0, A}, {y, 0, (-B/A)*x + B}, {z, 0, C - (C/A)*x - (C/B)*y}], N]]; diff --git a/Task/Hamming-numbers/Perl/hamming-numbers.pl b/Task/Hamming-numbers/Perl/hamming-numbers.pl new file mode 100644 index 0000000000..1748da77a7 --- /dev/null +++ b/Task/Hamming-numbers/Perl/hamming-numbers.pl @@ -0,0 +1,25 @@ +use List::Util 'min'; + +sub ham_gen { + my @s = ([1], [1], [1]); + my @m = (2, 3, 5); + + return sub { + # use bigint; + my $n = min($s[0][0], $s[1][0], $s[2][0]); + for (0 .. 2) { + shift @{$s[$_]} if $s[$_][0] == $n; + push @{$s[$_]}, $n * $m[$_] + } + + return $n + } +} + +my ($h, $i) = ham_gen; + +++$i, print $h->(), " " until $i > 20; +print "...\n"; + +++$i, $h->() until $i == 1690; +print ++$i, "-th: ", $h->(), "\n"; diff --git a/Task/Hamming-numbers/PicoLisp/hamming-numbers.l b/Task/Hamming-numbers/PicoLisp/hamming-numbers.l new file mode 100644 index 0000000000..7c6b4be2b4 --- /dev/null +++ b/Task/Hamming-numbers/PicoLisp/hamming-numbers.l @@ -0,0 +1,13 @@ +(de hamming (N) + (let (L (1) H) + (do N + (for (X L X (cadr X)) # Find smallest result + (setq H (car X)) ) + (idx 'L H NIL) # Remove it + (for I (2 3 5) # Generate next results + (idx 'L (* I H) T) ) ) + H ) ) + +(println (make (for N 20 (link (hamming N))))) +(println (hamming 1691)) +(println (hamming 1000000)) diff --git a/Task/Hamming-numbers/Prolog/hamming-numbers-1.pro b/Task/Hamming-numbers/Prolog/hamming-numbers-1.pro new file mode 100644 index 0000000000..2788f67145 --- /dev/null +++ b/Task/Hamming-numbers/Prolog/hamming-numbers-1.pro @@ -0,0 +1,21 @@ +%% collect N elements produced by a generator in a row + +take( 0, Next, Z-Z, Next). +take( N, Next, [A|B]-Z, NZ):- N>0, !, next(Next,A,Next1), + N1 is N-1, + take(N1,Next1,B-Z,NZ). + +%% a generator provides specific {next} implementation + +next( hamm( A2,B,C3,D,E5,F,[H|G] ), H, hamm(X,U,Y,V,Z,W,G) ):- + H is min(A2, min(C3,E5)), + ( A2 =:= H -> B=[N2|U],X is N2*2 ; (X,U)=(A2,B) ), + ( C3 =:= H -> D=[N3|V],Y is N3*3 ; (Y,V)=(C3,D) ), + ( E5 =:= H -> F=[N5|W],Z is N5*5 ; (Z,W)=(E5,F) ). + +mkHamm( hamm(1,X,1,X,1,X,X) ). % Hamming numbers generator init state + +main(N) :- + mkHamm(G),take(20,G,A-[],_), write(A), nl, + take(1691-1,G,_,G2),take(2,G2,B-[],_), write(B), nl, + take( N -1,G,_,G3),take(2,G3,[C1|_]-_,_), write(C1), nl. diff --git a/Task/Hamming-numbers/Prolog/hamming-numbers-2.pro b/Task/Hamming-numbers/Prolog/hamming-numbers-2.pro new file mode 100644 index 0000000000..d5b3ac93ee --- /dev/null +++ b/Task/Hamming-numbers/Prolog/hamming-numbers-2.pro @@ -0,0 +1,74 @@ +hamming(N) :- + % to stop cleanly + nb_setval(go, 1), + + % display list + ( N = 20 -> watch_20(20, L); watch(1,N,L)), + + % go + L=[1|L235], + multlist(L,2,L2), + multlist(L,3,L3), + multlist(L,5,L5), + merge_(L2,L3,L23), + merge_(L5,L23,L235). + + +%% multlist(L,N,LN) +%% multiply each element of list L with N, resulting in list LN +%% here only do multiplication for 1st element, then use multlist recursively +multlist([X|L],N,XLN) :- + % the trick to stop + nb_getval(go, 1) -> + + % laziness flavor + when(ground(X), + ( XN is X*N, + XLN=[XN|LN], + multlist(L,N,LN))); + + true. + +merge_([X|In1],[Y|In2],XYOut) :- + % the trick to stop + nb_getval(go, 1) -> + + % laziness flavor + ( X < Y -> XYOut = [X|Out], In11 = In1, In12 = [Y|In2] + ; X = Y -> XYOut = [X|Out], In11 = In1, In12 = In2 + ; XYOut = [Y|Out], In11 = [X | In1], In12 = In2), + freeze(In11,freeze(In12, merge_(In11,In12,Out))); + + true. + +%% display nth element +watch(Max, Max, [X|_]) :- + % laziness flavor + when(ground(X), + (format('~w~n', [X]), + + % the trick to stop + nb_linkval(go, 0))). + + +watch(N, Max, [_X|L]):- + N1 is N + 1, + watch(N1, Max, L). + + +%% display nth element +watch_20(1, [X|_]) :- + % laziness flavor + when(ground(X), + (format('~w~n', [X]), + + % the trick to stop + nb_linkval(go, 0))). + + +watch_20(N, [X|L]):- + % laziness flavor + when(ground(X), + (format('~w ', [X]), + N1 is N - 1, + watch_20(N1, L))). diff --git a/Task/Hamming-numbers/Python/hamming-numbers-1.py b/Task/Hamming-numbers/Python/hamming-numbers-1.py new file mode 100644 index 0000000000..fd1eaff0fe --- /dev/null +++ b/Task/Hamming-numbers/Python/hamming-numbers-1.py @@ -0,0 +1,41 @@ +from itertools import islice + +def hamming2(): + '''\ + This version is based on a snippet from: + http://dobbscodetalk.com/index.php?option=com_content&task=view&id=913&Itemid=85 + + When expressed in some imaginary pseudo-C with automatic + unlimited storage allocation and BIGNUM arithmetics, it can be + expressed as: + hamming = h where + array h; + n=0; h[0]=1; i=0; j=0; k=0; + x2=2*h[ i ]; x3=3*h[j]; x5=5*h[k]; + repeat: + h[++n] = min(x2,x3,x5); + if (x2==h[n]) { x2=2*h[++i]; } + if (x3==h[n]) { x3=3*h[++j]; } + if (x5==h[n]) { x5=5*h[++k]; } + ''' + h = 1 + _h=[h] # memoized + multipliers = (2, 3, 5) + multindeces = [0 for i in multipliers] # index into _h for multipliers + multvalues = [x * _h[i] for x,i in zip(multipliers, multindeces)] + yield h + while True: + h = min(multvalues) + _h.append(h) + for (n,(v,x,i)) in enumerate(zip(multvalues, multipliers, multindeces)): + if v == h: + i += 1 + multindeces[n] = i + multvalues[n] = x * _h[i] + # cap the memoization + mini = min(multindeces) + if mini >= 1000: + del _h[:mini] + multindeces = [i - mini for i in multindeces] + # + yield h diff --git a/Task/Hamming-numbers/Python/hamming-numbers-2.py b/Task/Hamming-numbers/Python/hamming-numbers-2.py new file mode 100644 index 0000000000..cb5cfe759f --- /dev/null +++ b/Task/Hamming-numbers/Python/hamming-numbers-2.py @@ -0,0 +1,25 @@ +import psyco + +def hamming(limit): + h = [1] * limit + x2, x3, x5 = 2, 3, 5 + i = j = k = 0 + + for n in xrange(1, limit): + h[n] = min(x2, x3, x5) + if x2 == h[n]: + i += 1 + x2 = 2 * h[i] + if x3 == h[n]: + j += 1 + x3 = 3 * h[j] + if x5 == h[n]: + k += 1 + x5 = 5 * h[k] + + return h[-1] + +psyco.bind(hamming) +print [hamming(i) for i in xrange(1, 21)] +print hamming(1691) +print hamming(1000000) diff --git a/Task/Hamming-numbers/Python/hamming-numbers-3.py b/Task/Hamming-numbers/Python/hamming-numbers-3.py new file mode 100644 index 0000000000..1c572fc067 --- /dev/null +++ b/Task/Hamming-numbers/Python/hamming-numbers-3.py @@ -0,0 +1,25 @@ +from itertools import tee, chain, groupby, islice +from heapq import merge + +def raymonds_hamming(): + # Generate "5-smooth" numbers, also called "Hamming numbers" + # or "Regular numbers". See: http://en.wikipedia.org/wiki/Regular_number + # Finds solutions to 2**i * 3**j * 5**k for some integers i, j, and k. + + def deferred_output(): + for i in output: + yield i + + result, p2, p3, p5 = tee(deferred_output(), 4) + m2 = (2*x for x in p2) # multiples of 2 + m3 = (3*x for x in p3) # multiples of 3 + m5 = (5*x for x in p5) # multiples of 5 + merged = merge(m2, m3, m5) + combined = chain([1], merged) # prepend a starting point + output = (k for k,g in groupby(combined)) # eliminate duplicates + + return result + +print list(islice(raymonds_hamming(), 20)) +print islice(raymonds_hamming(), 1689, 1690).next() +print islice(raymonds_hamming(), 999999, 1000000).next() diff --git a/Task/Hamming-numbers/Python/hamming-numbers-4.py b/Task/Hamming-numbers/Python/hamming-numbers-4.py new file mode 100644 index 0000000000..a8ec26ee3a --- /dev/null +++ b/Task/Hamming-numbers/Python/hamming-numbers-4.py @@ -0,0 +1,13 @@ +from heapq import merge +from itertools import tee + +def hamming_numbers(): + last = 1 + yield last + + a,b,c = tee(hamming_numbers(), 3) + + for n in merge((2*i for i in a), (3*i for i in b), (5*i for i in c)): + if n != last: + yield n + last = n diff --git a/Task/Hamming-numbers/Python/hamming-numbers-5.py b/Task/Hamming-numbers/Python/hamming-numbers-5.py new file mode 100644 index 0000000000..5c8e8f4a87 --- /dev/null +++ b/Task/Hamming-numbers/Python/hamming-numbers-5.py @@ -0,0 +1,38 @@ +from itertools import islice, chain, tee + +def merge(r, s): + # This is faster than heapq.merge. + rr = r.next() + ss = s.next() + while True: + if rr < ss: + yield rr + rr = r.next() + else: + yield ss + ss = s.next() + +def p(n): + def gen(): + x = n + while True: + yield x + x *= n + return gen() + +def pp(n, s): + def gen(): + for x in (merge(s, chain([n], (n * y for y in fb)))): + yield x + r, fb = tee(gen()) + return r + +def hamming(a, b = None): + if not b: + b = a + 1 + seq = (chain([1], pp(5, pp(3, p(2))))) + return list(islice(seq, a - 1, b - 1)) + +print hamming(1, 21) +print hamming(1691)[0] +print hamming(1000000)[0] diff --git a/Task/Hamming-numbers/R/hamming-numbers.r b/Task/Hamming-numbers/R/hamming-numbers.r new file mode 100644 index 0000000000..ae5d0b7785 --- /dev/null +++ b/Task/Hamming-numbers/R/hamming-numbers.r @@ -0,0 +1,12 @@ +hamming=function(hamms,limit) { + tmp=hamms + for(h in c(2,3,5)) { + tmp=c(tmp,h*hamms) + } + tmp=unique(tmp[tmp<=limit]) + if(length(tmp)>length(hamms)) { + hamms=hamming(tmp,limit) + } + hamms +} +sort(hamming(1,limit=2^31)[-1]) diff --git a/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx b/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx new file mode 100644 index 0000000000..49c07af3e1 --- /dev/null +++ b/Task/Hamming-numbers/REXX/hamming-numbers-1.rexx @@ -0,0 +1,23 @@ +/*REXX program computes Hamming numbers: 1──►20, #1691, one millionth.*/ +numeric digits 100 /*ensure we have enough precision*/ +call hamming 1, 20 /*show the first ──► twentieth #s*/ +call hamming 1691 /*show the 1,691st Hamming number*/ +call hamming 1000000 /*show the one millionth number*/ +call hamming 10000000 /*show the 10th millionth number*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────HAMMING subroutine──────────────────*/ +hamming: procedure; parse arg x,y; if y=='' then y=x; w=length(y) + #2=1; #3=1; #5=1; @.=0; @.1=1 + + do n=2 for y-1 + @.n = min(2*@.#2, 3*@.#3, 5*@.#5) /*pick the minimum of three pigs.*/ + if 2*@.#2 == @.n then #2 = #2+1 /*# already defined? Use next #.*/ + if 3*@.#3 == @.n then #3 = #3+1 /*" " " " " " */ + if 5*@.#5 == @.n then #5 = #5+1 /*" " " " " " */ + end /*n*/ + do j=x to y /*W is used to align the index. */ + say 'Hamming('right(j,w)") =" @.j /*list 'em, Dano.*/ + end /*j*/ + +say right( 'length of last Hamming number =' length(@.y), 70); say +return diff --git a/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx b/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx new file mode 100644 index 0000000000..0b9506a7ce --- /dev/null +++ b/Task/Hamming-numbers/REXX/hamming-numbers-2.rexx @@ -0,0 +1,28 @@ +/*REXX program computes Hamming numbers: 1──►20, #1691, one millionth.*/ +numeric digits 100 /*ensure we have enough precision*/ +call hamming 1, 20 /*show the first ──► twentieth #s*/ +call hamming 1691 /*show the 1,691st Hamming number*/ +call hamming 1000000 /*show the one millionth number*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────HAMMING subroutine──────────────────*/ +hamming: procedure; parse arg x,y; if y=='' then y=x; w=length(y) + #2=1; #3=1; #5=1; @.=0; @.1=1 + + do n=2 for y-1 + _2 = @.#2 + @.#2 /*this is faster than 2 * @.#2 */ + _3 = 3 * @.#3 + _5 = 5 * @.#5 + m =_2 /*assume a minimum (of the three)*/ + if _3 < m then m =_3 /*is this less than the minimum? */ + if _5 < m then m =_5 /* " " " " " " */ + @.n = m /*now, assign the next Hamming #.*/ + if _2 == m then #2 =#2 + 1 /*# already defined? Use next #.*/ + if _3 == m then #3 =#3 + 1 /*" " " " " " */ + if _5 == m then #5 =#5 + 1 /*" " " " " " */ + end /*n*/ + do j=x to y /*W is used to align the index. */ + say 'Hamming('right(j,w)") =" @.j /*list 'em, Dano.*/ + end /*j*/ + +say right( 'length of last Hamming number =' length(@.y), 70); say +return diff --git a/Task/Hamming-numbers/Racket/hamming-numbers.rkt b/Task/Hamming-numbers/Racket/hamming-numbers.rkt new file mode 100644 index 0000000000..4748e4b77a --- /dev/null +++ b/Task/Hamming-numbers/Racket/hamming-numbers.rkt @@ -0,0 +1,23 @@ +#lang racket +(require racket/stream) +(define first stream-first) +(define rest stream-rest) + +(define (merge s1 s2) + (define x1 (first s1)) + (define x2 (first s2)) + (cond [(= x1 x2) (merge s1 (rest s2))] + [(< x1 x2) (stream-cons x1 (merge (rest s1) s2))] + [else (stream-cons x2 (merge s1 (rest s2)))])) + +(define (mult k) (λ(x) (* x k))) + +(define hamming + (stream-cons + 1 (merge (stream-map (mult 2) hamming) + (merge (stream-map (mult 3) hamming) + (stream-map (mult 5) hamming))))) + +(for/list ([i 20] [x hamming]) x) +(stream-ref hamming 1690) +(stream-ref hamming 999999) diff --git a/Task/Hamming-numbers/Ruby/hamming-numbers-1.rb b/Task/Hamming-numbers/Ruby/hamming-numbers-1.rb new file mode 100644 index 0000000000..4331e55049 --- /dev/null +++ b/Task/Hamming-numbers/Ruby/hamming-numbers-1.rb @@ -0,0 +1,14 @@ +require 'generator' + +# the Hamming number generator +hamming = Generator.new do |generator| + next_ham = 1 + queues = { 2 => [], 3 => [], 5 => [] } + loop do + generator.yield next_ham + + [2,3,5].each {|m| queues[m] << (next_ham * m)} + next_ham = [2,3,5].collect {|m| queues[m][0]}.min + [2,3,5].each {|m| queues[m].shift if queues[m][0] == next_ham} + end +end diff --git a/Task/Hamming-numbers/Ruby/hamming-numbers-2.rb b/Task/Hamming-numbers/Ruby/hamming-numbers-2.rb new file mode 100644 index 0000000000..70751dd8ff --- /dev/null +++ b/Task/Hamming-numbers/Ruby/hamming-numbers-2.rb @@ -0,0 +1,12 @@ +hamming = Enumerator.new do |yielder| + next_ham = 1 + queues = { 2 => [], 3 => [], 5 => [] } + + loop do + yielder << next_ham # or: yielder.yield(next_ham) + + [2,3,5].each {|m| queues[m]<< (next_ham * m)} + next_ham = [2,3,5].collect {|m| queues[m][0]}.min + [2,3,5].each {|m| queues[m].shift if queues[m][0]== next_ham} + end +end diff --git a/Task/Hamming-numbers/Ruby/hamming-numbers-3.rb b/Task/Hamming-numbers/Ruby/hamming-numbers-3.rb new file mode 100644 index 0000000000..c889dcf885 --- /dev/null +++ b/Task/Hamming-numbers/Ruby/hamming-numbers-3.rb @@ -0,0 +1,15 @@ +start = Time.now + +idx = 1 +hamming.each do |ham| + case idx + when (1..20), 1691 + p [idx, ham] + when 1_000_000 + p [idx, ham] + break + end + idx += 1 +end + +puts "elapsed: #{Time.now - start} seconds" diff --git a/Task/Hamming-numbers/Scala/hamming-numbers-1.scala b/Task/Hamming-numbers/Scala/hamming-numbers-1.scala new file mode 100644 index 0000000000..8cd5b61f61 --- /dev/null +++ b/Task/Hamming-numbers/Scala/hamming-numbers-1.scala @@ -0,0 +1,13 @@ +class Hamming extends Iterator[BigInt] { + import scala.collection.mutable.Queue + val qs = Seq.fill(3)(new Queue[BigInt]) + def enqueue(n: BigInt) = qs zip Seq(2, 3, 5) foreach { case (q, m) => q enqueue n * m } + def next = { + val n = qs map (_.head) min; + qs foreach { q => if (q.head == n) q.dequeue } + enqueue(n) + n + } + def hasNext = true + qs foreach (_ enqueue 1) +} diff --git a/Task/Hamming-numbers/Scala/hamming-numbers-2.scala b/Task/Hamming-numbers/Scala/hamming-numbers-2.scala new file mode 100644 index 0000000000..a5f070de14 --- /dev/null +++ b/Task/Hamming-numbers/Scala/hamming-numbers-2.scala @@ -0,0 +1,21 @@ +class Hamming extends Iterator[BigInt] { + import scala.collection.mutable.Queue + val q2 = new Queue[BigInt] + val q3 = new Queue[BigInt] + val q5 = new Queue[BigInt] + def enqueue(n: BigInt) = { + q2 enqueue n * 2 + q3 enqueue n * 3 + q5 enqueue n * 5 + } + def next = { + val n = q2.head min q3.head min q5.head + if (q2.head == n) q2.dequeue + if (q3.head == n) q3.dequeue + if (q5.head == n) q5.dequeue + enqueue(n) + n + } + def hasNext = true + List(q2, q3, q5) foreach (_ enqueue 1) +} diff --git a/Task/Hamming-numbers/Scala/hamming-numbers-3.scala b/Task/Hamming-numbers/Scala/hamming-numbers-3.scala new file mode 100644 index 0000000000..2a4f976c4a --- /dev/null +++ b/Task/Hamming-numbers/Scala/hamming-numbers-3.scala @@ -0,0 +1,9 @@ +val hamming : Stream[BigInt] = { + def merge(inx : Stream[BigInt], iny : Stream[BigInt]) : Stream[BigInt] = { + if (inx.head < iny.head) inx.head #:: merge(inx.tail, iny) else + if (iny.head < inx.head) iny.head #:: merge(inx, iny.tail) else + merge(inx, iny.tail) + } + + 1 #:: merge(hamming map (_ * 2), merge(hamming map (_ * 3), hamming map (_ * 5))) +} diff --git a/Task/Hamming-numbers/Scheme/hamming-numbers.ss b/Task/Hamming-numbers/Scheme/hamming-numbers.ss new file mode 100644 index 0000000000..a0b3767b44 --- /dev/null +++ b/Task/Hamming-numbers/Scheme/hamming-numbers.ss @@ -0,0 +1,48 @@ +(define-syntax lons + (syntax-rules () + ((_ lar ldr) (delay (cons lar (delay ldr)))))) + +(define (lar lons) + (car (force lons))) + +(define (ldr lons) + (force (cdr (force lons)))) + +(define (lap proc . llists) + (lons (apply proc (map lar llists)) (apply lap proc (map ldr llists)))) + +(define (take n llist) + (if (zero? n) + (list) + (cons (lar llist) (take (- n 1) (ldr llist))))) + +(define (llist-ref n llist) + (if (= n 1) + (lar llist) + (llist-ref (- n 1) (ldr llist)))) + +(define (merge llist-1 . llists) + (define (merge-2 llist-1 llist-2) + (cond ((null? llist-1) llist-2) + ((null? llist-2) llist-1) + ((< (lar llist-1) (lar llist-2)) + (lons (lar llist-1) (merge-2 (ldr llist-1) llist-2))) + ((> (lar llist-1) (lar llist-2)) + (lons (lar llist-2) (merge-2 llist-1 (ldr llist-2)))) + (else (lons (lar llist-1) (merge-2 (ldr llist-1) (ldr llist-2)))))) + (if (null? llists) + llist-1 + (apply merge (cons (merge-2 llist-1 (car llists)) (cdr llists))))) + +(define hamming + (lons 1 + (merge (lap (lambda (x) (* x 2)) hamming) + (lap (lambda (x) (* x 3)) hamming) + (lap (lambda (x) (* x 5)) hamming)))) + +(display (take 20 hamming)) +(newline) +(display (llist-ref 1691 hamming)) +(newline) +(display (llist-ref 1000000 hamming)) +(newline) diff --git a/Task/Hamming-numbers/Smalltalk/hamming-numbers.st b/Task/Hamming-numbers/Smalltalk/hamming-numbers.st new file mode 100644 index 0000000000..296a6821cc --- /dev/null +++ b/Task/Hamming-numbers/Smalltalk/hamming-numbers.st @@ -0,0 +1,21 @@ +Object subclass: Hammer [ + Hammer class >> hammingNumbers: howMany [ + |h i j k x2 x3 x5| + h := OrderedCollection new. + i := 0. j := 0. k := 0. + h add: 1. + x2 := 2. x3 := 2. x5 := 5. + [ ( h size) < howMany ] whileTrue: [ + |m| + m := { x2. x3. x5 } sort first. + (( h indexOf: m ) = 0) ifTrue: [ h add: m ]. + ( x2 = (h last) ) ifTrue: [ i := i + 1. x2 := 2 * (h at: i) ]. + ( x3 = (h last) ) ifTrue: [ j := j + 1. x3 := 3 * (h at: j) ]. + ( x5 = (h last) ) ifTrue: [ k := k + 1. x5 := 5 * (h at: k) ]. + ]. + ^ h sort + ] +]. + +(Hammer hammingNumbers: 20) displayNl. +(Hammer hammingNumbers: 1690) last displayNl. diff --git a/Task/Hamming-numbers/Tcl/hamming-numbers-1.tcl b/Task/Hamming-numbers/Tcl/hamming-numbers-1.tcl new file mode 100644 index 0000000000..482663d9ef --- /dev/null +++ b/Task/Hamming-numbers/Tcl/hamming-numbers-1.tcl @@ -0,0 +1,58 @@ +package require Tcl 8.6 + +# Simple helper: Tcl-style list "map" +proc map {varName list script} { + set l {} + upvar 1 $varName v + foreach v $list {lappend l [uplevel 1 $script]} + return $l +} + +# The core of a coroutine to compute the product of a hamming sequence. +# +# Tricky bit: we don't automatically advance to the next value, and instead +# wait to be told that the value has been consumed (i.e., is the result of +# the [yield] operation). +proc ham {key multiplier} { + global hammingCache + set i 0 + yield [info coroutine] + # Cannot use [foreach]; that would take a snapshot of the list in + # the hammingCache variable, so missing updates. + while 1 { + set n [expr {[lindex $hammingCache($key) $i] * $multiplier}] + # If the number selected was ours, we advance to compute the next + if {[yield $n] == $n} { + incr i + } + } +} + +# This coroutine computes the hamming sequence given a list of multipliers. +# It uses the [ham] helper from above to generate indivdual multiplied +# sequences. The key into the cache is the list of multipliers. +# +# Note that it is advisable for the values to be all co-prime wrt each other. +proc hammingCore args { + global hammingCache + set hammingCache($args) 1 + set hammers [map x $args {coroutine ham$x,$args ham $args $x}] + yield + while 1 { + set n [lindex $hammingCache($args) [incr i]-1] + lappend hammingCache($args) \ + [tcl::mathfunc::min {*}[map h $hammers {$h $n}]] + yield $n + } +} + +# Assemble the pieces so as to compute the classic hamming sequence. +coroutine hamming hammingCore 2 3 5 +# Print the first 20 values of the sequence +for {set i 1} {$i <= 20} {incr i} { + puts [format "hamming\[%d\] = %d" $i [hamming]] +} +for {} {$i <= 1690} {incr i} {set h [hamming]} +puts "hamming{1690} = $h" +for {} {$i <= 1000000} {incr i} {set h [hamming]} +puts "hamming{1000000} = $h" diff --git a/Task/Hamming-numbers/Tcl/hamming-numbers-2.tcl b/Task/Hamming-numbers/Tcl/hamming-numbers-2.tcl new file mode 100644 index 0000000000..3d8f231da0 --- /dev/null +++ b/Task/Hamming-numbers/Tcl/hamming-numbers-2.tcl @@ -0,0 +1,34 @@ +variable hamming 1 hi2 0 hi3 0 hi5 0 +proc hamming {n} { + global hamming hi2 hi3 hi5 + set h2 [expr {[lindex $hamming $hi2]*2}] + set h3 [expr {[lindex $hamming $hi3]*3}] + set h5 [expr {[lindex $hamming $hi5]*5}] + while {[llength $hamming] < $n} { + lappend hamming [set h [expr { + $h2<$h3 + ? $h2<$h5 ? $h2 : $h5 + : $h3<$h5 ? $h3 : $h5 + }]] + if {$h==$h2} { + set h2 [expr {[lindex $hamming [incr hi2]]*2}] + } + if {$h==$h3} { + set h3 [expr {[lindex $hamming [incr hi3]]*3}] + } + if {$h==$h5} { + set h5 [expr {[lindex $hamming [incr hi5]]*5}] + } + } + return [lindex $hamming [expr {$n - 1}]] +} + +# Print the first 20 values of the sequence +for {set i 1} {$i <= 20} {incr i} { + puts [format "hamming\[%d\] = %d" $i [hamming $i]] +} +puts "hamming{1690} = [hamming 1690]" +puts "hamming{1691} = [hamming 1691]" +puts "hamming{1692} = [hamming 1692]" +puts "hamming{1693} = [hamming 1693]" +puts "hamming{1000000} = [hamming 1000000]" diff --git a/Task/Handle-a-signal/0DESCRIPTION b/Task/Handle-a-signal/0DESCRIPTION new file mode 100644 index 0000000000..1d9bdf8911 --- /dev/null +++ b/Task/Handle-a-signal/0DESCRIPTION @@ -0,0 +1,3 @@ +Most general purpose operating systems provide interrupt facilities, sometimes called signals. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defined manner upon receipt of a signal. + +For this task you will provide a program that displays a single integer on each line of output at the rate of one integer in each half second. Upon receipt of the SigInt signal (often created by the user typing ctrl-C) the program will cease printing integers to its output, print the number of seconds the program has run, and then the program will terminate. diff --git a/Task/Handle-a-signal/1META.yaml b/Task/Handle-a-signal/1META.yaml new file mode 100644 index 0000000000..8e554e7730 --- /dev/null +++ b/Task/Handle-a-signal/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Signal handling +note: Concurrency +requires: +- Signal handling diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-1.ada b/Task/Handle-a-signal/Ada/handle-a-signal-1.ada new file mode 100644 index 0000000000..8df88b5965 --- /dev/null +++ b/Task/Handle-a-signal/Ada/handle-a-signal-1.ada @@ -0,0 +1,14 @@ +with Ada.Interrupts; use Ada.Interrupts; +with Ada.Interrupts.Names; use Ada.Interrupts.Names; + +package Sigint_Handler is + protected Handler is + entry Wait; + procedure Handle; + pragma Interrupt_Handler(Handle); + pragma Attach_Handler(Handle, Sigint); + private + Call_Count : Natural := 0; + end Handler; + +end Sigint_Handler; diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-2.ada b/Task/Handle-a-signal/Ada/handle-a-signal-2.ada new file mode 100644 index 0000000000..eb402a92ce --- /dev/null +++ b/Task/Handle-a-signal/Ada/handle-a-signal-2.ada @@ -0,0 +1,29 @@ +package body Sigint_Handler is + + ------------- + -- Handler -- + ------------- + + protected body Handler is + + ---------- + -- Wait -- + ---------- + + entry Wait when Call_Count > 0 is + begin + Call_Count := Call_Count - 1; + end Wait; + + ------------ + -- Handle -- + ------------ + + procedure Handle is + begin + Call_Count := Call_Count + 1; + end Handle; + + end Handler; + +end Sigint_Handler; diff --git a/Task/Handle-a-signal/Ada/handle-a-signal-3.ada b/Task/Handle-a-signal/Ada/handle-a-signal-3.ada new file mode 100644 index 0000000000..34b7a3a028 --- /dev/null +++ b/Task/Handle-a-signal/Ada/handle-a-signal-3.ada @@ -0,0 +1,37 @@ +with Ada.Calendar; use Ada.Calendar; +with Ada.Text_Io; use Ada.Text_Io; +with Sigint_Handler; use Sigint_Handler; + +procedure Signals is + task Counter is + entry Stop; + end Counter; + task body Counter is + Current_Count : Natural := 0; + begin + loop + select + accept Stop; + exit; + or delay 0.5; + end select; + Current_Count := Current_Count + 1; + Put_Line(Natural'Image(Current_Count)); + end loop; + end Counter; + task Sig_Handler; + + task body Sig_Handler is + Start_Time : Time := Clock; + Sig_Time : Time; + begin + Handler.Wait; + Sig_Time := Clock; + Counter.Stop; + Put_Line("Program execution took" & Duration'Image(Sig_Time - Start_Time) & " seconds"); + end Sig_Handler; + +begin + null; + +end Signals; diff --git a/Task/Handle-a-signal/BBC-BASIC/handle-a-signal.bbc b/Task/Handle-a-signal/BBC-BASIC/handle-a-signal.bbc new file mode 100644 index 0000000000..82e4644bbc --- /dev/null +++ b/Task/Handle-a-signal/BBC-BASIC/handle-a-signal.bbc @@ -0,0 +1,33 @@ + REM!Exefile C:\bbcsigint.exe,encrypt,console + INSTALL @lib$+"CALLBACK" + CTRL_C_EVENT = 0 + + SYS "GetStdHandle", -10 TO @hfile%(1) + SYS "GetStdHandle", -11 TO @hfile%(2) + *INPUT 13 + *OUTPUT 14 + ON ERROR PRINT REPORT$ : QUIT ERR + + CtrlC% = FALSE + handler% = FN_callback(FNsigint(), 1) + SYS FN_syscalls("SetConsoleCtrlHandler"), handler%, 1 TO !FN_systo(res%) + IF res%=0 PRINT "Could not set SIGINT handler" : QUIT 1 + + PRINT "Press Ctrl+C to test...." + TIME = 0 + Time% = 50 + REPEAT + WAIT 1 + IF TIME > Time% THEN + PRINT Time% + Time% += 50 + ENDIF + UNTIL CtrlC% + PRINT "Ctrl+C was pressed after "; TIME/100 " seconds." + QUIT + + DEF FNsigint(T%) + CASE T% OF + WHEN CTRL_C_EVENT: CtrlC% = TRUE : = 1 + ENDCASE + = 0 diff --git a/Task/Handle-a-signal/C-sharp/handle-a-signal.cs b/Task/Handle-a-signal/C-sharp/handle-a-signal.cs new file mode 100644 index 0000000000..02740da79b --- /dev/null +++ b/Task/Handle-a-signal/C-sharp/handle-a-signal.cs @@ -0,0 +1,23 @@ +using System; //DateTime, Console, Environment classes +class Program +{ + static DateTime start; + static void Main(string[] args) + { + start = DateTime.Now; + //Add event handler for Ctrl+C command + Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); + int counter = 0; + while (true) + { + Console.WriteLine(++counter); + System.Threading.Thread.Sleep(500); + } + } + static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) + { + var end = DateTime.Now; + Console.WriteLine("This program ran for {0:000.000} seconds.", (end - start).TotalMilliseconds / 1000); + Environment.Exit(0); + } +} diff --git a/Task/Handle-a-signal/C/handle-a-signal.c b/Task/Handle-a-signal/C/handle-a-signal.c new file mode 100644 index 0000000000..f3691dbdb7 --- /dev/null +++ b/Task/Handle-a-signal/C/handle-a-signal.c @@ -0,0 +1,33 @@ +#include +#include // for exit() +#include +#include // for clock() +#include // for POSIX usleep() + +volatile sig_atomic_t gotint = 0; + +void handleSigint() { + /* + * Signal safety: It is not safe to call clock(), printf(), + * or exit() inside a signal handler. Instead, we set a flag. + */ + gotint = 1; +} + +int main() { + clock_t startTime = clock(); + signal(SIGINT, handleSigint); + int i=0; + for (;;) { + if (gotint) + break; + usleep(500000); + if (gotint) + break; + printf("%d\n", ++i); + } + clock_t endTime = clock(); + double td = (endTime - startTime) / (double)CLOCKS_PER_SEC; + printf("Program has run for %5.3f seconds\n", td); + return 0; +} diff --git a/Task/Handle-a-signal/Clojure/handle-a-signal.clj b/Task/Handle-a-signal/Clojure/handle-a-signal.clj new file mode 100644 index 0000000000..de54d8adbd --- /dev/null +++ b/Task/Handle-a-signal/Clojure/handle-a-signal.clj @@ -0,0 +1,15 @@ +(require 'clojure.repl) + +(def start (System/nanoTime)) + +(defn shutdown [_] + (println "Received INT after" + (/ (- (System/nanoTime) start) 1e9) + "seconds.") + (System/exit 0)) + +(clojure.repl/set-break-handler! shutdown) + +(doseq [i (range)] + (prn i) + (Thread/sleep 500)) diff --git a/Task/Handle-a-signal/Forth/handle-a-signal.fth b/Task/Handle-a-signal/Forth/handle-a-signal.fth new file mode 100644 index 0000000000..2a209b19aa --- /dev/null +++ b/Task/Handle-a-signal/Forth/handle-a-signal.fth @@ -0,0 +1,15 @@ +-28 constant SIGINT + +: numbers ( n -- n' ) + begin dup . cr 1+ 500 ms again ; + +: main + utime + 0 begin + ['] numbers catch + SIGINT = + until drop + utime d- dnegate + <# # # # # # # [char] . hold #s #> type ." seconds" ; + +main bye diff --git a/Task/Handle-a-signal/Go/handle-a-signal.go b/Task/Handle-a-signal/Go/handle-a-signal.go new file mode 100644 index 0000000000..fb594faa70 --- /dev/null +++ b/Task/Handle-a-signal/Go/handle-a-signal.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "os" + "os/signal" + "time" +) + +func main() { + start := time.Now() + k := time.NewTicker(time.Second / 2) + sc := make(chan os.Signal, 1) + signal.Notify(sc, os.Interrupt) + for n := 1; ; { + // not busy waiting, this blocks until one of the two + // channel operations is possible + select { + case <-k.C: + fmt.Println(n) + n++ + case <-sc: + fmt.Printf("Ran for %f seconds.\n", + time.Now().Sub(start).Seconds()) + return + } + } +} diff --git a/Task/Handle-a-signal/Haskell/handle-a-signal.hs b/Task/Handle-a-signal/Haskell/handle-a-signal.hs new file mode 100644 index 0000000000..4c19a1d95e --- /dev/null +++ b/Task/Handle-a-signal/Haskell/handle-a-signal.hs @@ -0,0 +1,15 @@ +import Prelude hiding (catch) +import Control.Exception (catch, throwIO, AsyncException(UserInterrupt)) +import Data.Time.Clock (getCurrentTime, diffUTCTime) +import Control.Concurrent (threadDelay) + +main = do t0 <- getCurrentTime + catch (loop 0) + (\e -> if e == UserInterrupt + then do t1 <- getCurrentTime + putStrLn ("\nTime: " ++ show (diffUTCTime t1 t0)) + else throwIO e) + +loop i = do print i + threadDelay 500000 {- µs -} + loop (i + 1) diff --git a/Task/Handle-a-signal/HicEst/handle-a-signal.hicest b/Task/Handle-a-signal/HicEst/handle-a-signal.hicest new file mode 100644 index 0000000000..5aa223e9fd --- /dev/null +++ b/Task/Handle-a-signal/HicEst/handle-a-signal.hicest @@ -0,0 +1,12 @@ +seconds = TIME() + +DO i = 1, 1E100 ! "forever" + SYSTEM(WAIT = 500) ! milli seconds + WRITE(Name) i +ENDDO + +SUBROUTINE F2 ! call by either the F2 key, or by a toolbar-F2 click + seconds = TIME() - seconds + WRITE(Messagebox, Name) seconds + ALARM(999) ! quit immediately +END diff --git a/Task/Handle-a-signal/Java/handle-a-signal-1.java b/Task/Handle-a-signal/Java/handle-a-signal-1.java new file mode 100644 index 0000000000..db7c805625 --- /dev/null +++ b/Task/Handle-a-signal/Java/handle-a-signal-1.java @@ -0,0 +1,19 @@ +import sun.misc.Signal; +import sun.misc.SignalHandler; + +public class ExampleSignalHandler { + public static void main(String... args) throws InterruptedException { + final long start = System.nanoTime(); + Signal.handle(new Signal("INT"), new SignalHandler() { + public void handle(Signal sig) { + System.out.format("\nProgram execution took %f seconds\n", (System.nanoTime() - start) / 1e9f); + System.exit(0); + } + }); + int counter = 0; + while(true) { + System.out.println(counter++); + Thread.sleep(500); + } + } +} diff --git a/Task/Handle-a-signal/Java/handle-a-signal-2.java b/Task/Handle-a-signal/Java/handle-a-signal-2.java new file mode 100644 index 0000000000..31c592d1ea --- /dev/null +++ b/Task/Handle-a-signal/Java/handle-a-signal-2.java @@ -0,0 +1,15 @@ +public class ExampleSignalHandler { + public static void main(String... args) throws InterruptedException { + final long start = System.nanoTime(); + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + public void run() { + System.out.format("\nProgram execution took %f seconds\n", (System.nanoTime() - start) / 1e9f); + } + })); + int counter = 0; + while(true) { + System.out.println(counter++); + Thread.sleep(500); + } + } +} diff --git a/Task/Handle-a-signal/Liberty-BASIC/handle-a-signal.liberty b/Task/Handle-a-signal/Liberty-BASIC/handle-a-signal.liberty new file mode 100644 index 0000000000..03b9686728 --- /dev/null +++ b/Task/Handle-a-signal/Liberty-BASIC/handle-a-signal.liberty @@ -0,0 +1,29 @@ +nomainwin +WindowHeight=DisplayHeight +open "Handle a signal" for graphics as #1 +#1 "trapclose [quit]" +#1 "down;setfocus;place 10 20" +#1 "\Press CTRL + C to stop." +#1 "when characterInput [keyPressed]" +start=time$("ms") +timer 500, [doPrint] +wait +[quit] close #1:end + +[doPrint] + if sigInt then + timer 0 + #1 "\Seconds elapsed: ";(time$("ms")-start)/1000 + else + i=i+1 + if i mod 20 = 0 then #1 "cls;place 10 20" + #1 "\";i + end if + wait + +[keyPressed] + if len(Inkey$)>1 then + if left$(Inkey$,1)=chr$(8) then sigCtrl=1 else sigCtrl=0 + end if + if sigCtrl=1 and Inkey$=chr$(3) then sigInt=1 + wait diff --git a/Task/Handle-a-signal/PHP/handle-a-signal.php b/Task/Handle-a-signal/PHP/handle-a-signal.php new file mode 100644 index 0000000000..84192f6845 --- /dev/null +++ b/Task/Handle-a-signal/PHP/handle-a-signal.php @@ -0,0 +1,17 @@ + diff --git a/Task/Handle-a-signal/Perl/handle-a-signal-1.pl b/Task/Handle-a-signal/Perl/handle-a-signal-1.pl new file mode 100644 index 0000000000..033cb6521d --- /dev/null +++ b/Task/Handle-a-signal/Perl/handle-a-signal-1.pl @@ -0,0 +1,8 @@ +my $start = time; + +$SIG{INT} = sub + {print 'Ran for ', time - $start, " seconds.\n"; + exit;}; + +for (my $n = 0 ;; select(undef, undef, undef, .5)) + {print ++$n, "\n";} diff --git a/Task/Handle-a-signal/Perl/handle-a-signal-2.pl b/Task/Handle-a-signal/Perl/handle-a-signal-2.pl new file mode 100644 index 0000000000..c7c10c267b --- /dev/null +++ b/Task/Handle-a-signal/Perl/handle-a-signal-2.pl @@ -0,0 +1,9 @@ +use 5.010; +use AnyEvent; +my $start = AE::time; +my $exit = AE::cv; +my $int = AE::signal 'INT', $exit; +my $n; +my $num = AE::timer 0, 0.5, sub { say $n++ }; +$exit->recv; +say " interrupted after ", AE::time - $start, " seconds"; diff --git a/Task/Handle-a-signal/PicoLisp/handle-a-signal.l b/Task/Handle-a-signal/PicoLisp/handle-a-signal.l new file mode 100644 index 0000000000..9e25fa14d7 --- /dev/null +++ b/Task/Handle-a-signal/PicoLisp/handle-a-signal.l @@ -0,0 +1,8 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(push '*Bye '(println (*/ (usec) 1000000)) '(prinl)) + +(let Cnt 0 + (loop + (println (inc 'Cnt)) + (wait 500) ) ) diff --git a/Task/Handle-a-signal/Python/handle-a-signal-1.py b/Task/Handle-a-signal/Python/handle-a-signal-1.py new file mode 100644 index 0000000000..d893249411 --- /dev/null +++ b/Task/Handle-a-signal/Python/handle-a-signal-1.py @@ -0,0 +1,18 @@ +import time + +def intrptWIN(): + procDone = False + n = 0 + + while not procDone: + try: + time.sleep(0.5) + n += 1 + print n + except KeyboardInterrupt, e: + procDone = True + +t1 = time.time() +intrptWIN() +tdelt = time.time() - t1 +print 'Program has run for %5.3f seconds.' % tdelt diff --git a/Task/Handle-a-signal/Python/handle-a-signal-2.py b/Task/Handle-a-signal/Python/handle-a-signal-2.py new file mode 100644 index 0000000000..171ae28a5f --- /dev/null +++ b/Task/Handle-a-signal/Python/handle-a-signal-2.py @@ -0,0 +1,29 @@ +import signal, time, threading +done = False +n = 0 + +def counter(): + global n, timer + n += 1 + print n + timer = threading.Timer(0.5, counter) + timer.start() + +def sigIntHandler(signum, frame): + global done + timer.cancel() + done = True + +def intrptUNIX(): + global timer + signal.signal(signal.SIGINT, sigIntHandler) + + timer = threading.Timer(0.5, counter) + timer.start() + while not done: + signal.pause() + +t1 = time.time() +intrptUNIX() +tdelt = time.time() - t1 +print 'Program has run for %5.3f seconds.' % tdelt diff --git a/Task/Handle-a-signal/Python/handle-a-signal-3.py b/Task/Handle-a-signal/Python/handle-a-signal-3.py new file mode 100644 index 0000000000..708305e655 --- /dev/null +++ b/Task/Handle-a-signal/Python/handle-a-signal-3.py @@ -0,0 +1,23 @@ +import time, signal + +class WeAreDoneException(Exception): + pass + +def sigIntHandler(signum, frame): + signal.signal(signal.SIGINT, signal.SIG_DFL) # resets to default handler + raise WeAreDoneException + +t1 = time.time() + +try: + signal.signal(signal.SIGINT, sigIntHandler) + n = 0 + while True: + time.sleep(0.5) + n += 1 + print n +except WeAreDoneException: + pass + +tdelt = time.time() - t1 +print 'Program has run for %5.3f seconds.' % tdelt diff --git a/Task/Handle-a-signal/REXX/handle-a-signal.rexx b/Task/Handle-a-signal/REXX/handle-a-signal.rexx new file mode 100644 index 0000000000..05fbbb6f2d --- /dev/null +++ b/Task/Handle-a-signal/REXX/handle-a-signal.rexx @@ -0,0 +1,20 @@ +/*REXX program displays integers until a Ctrl─C is pressed, then show*/ +/* the number of seconds that have elapsed since start of pgm execution.*/ + +call time 'E' /*reset the REXX elapsed timer. */ +signal on halt /*HALT is signaled via a Ctrl─C.*/ + + do j=1 /*start with 1 and go ye forth. */ + say right(j,20) /*display integer right-justified*/ + t=time('E') /*get the elapsed time in seconds*/ + do forever; u=time('E') /*get the elapsed time in seconds./ + if u◄t |, /* ◄═══ means we passed midnight.*/ + u>t+.5 then iterate j /* ◄═══ means we passed ½ second.*/ + end /*forever*/ + end /*j*/ + +say 'Program control should never ever get here, said Captain Dunsel.' + +/*──────────────────────────────────HALT subroutine─────────────────────*/ +halt: say 'program HALTed, it ran for' format(time("E"),,2) 'seconds.' + /*stick a fork in it, we're done.*/ diff --git a/Task/Handle-a-signal/Ruby/handle-a-signal.rb b/Task/Handle-a-signal/Ruby/handle-a-signal.rb new file mode 100644 index 0000000000..594c730144 --- /dev/null +++ b/Task/Handle-a-signal/Ruby/handle-a-signal.rb @@ -0,0 +1,17 @@ +t1 = Time.now + +catch :done do + Signal.trap('INT') do + Signal.trap('INT', 'DEFAULT') # reset to default + throw :done + end + n = 0 + loop do + sleep(0.5) + n += 1 + puts n + end +end + +tdelt = Time.now - t1 +puts 'Program has run for %5.3f seconds.' % tdelt diff --git a/Task/Handle-a-signal/Smalltalk/handle-a-signal-1.st b/Task/Handle-a-signal/Smalltalk/handle-a-signal-1.st new file mode 100644 index 0000000000..8821083e63 --- /dev/null +++ b/Task/Handle-a-signal/Smalltalk/handle-a-signal-1.st @@ -0,0 +1,11 @@ +|n| + +n := 0. +UserInterrupt + catch:[ + [true] whileTrue:[ + n := n + 1. + n printCR. + Delay waitForSeconds: 0.5. + ] + ] diff --git a/Task/Handle-a-signal/Smalltalk/handle-a-signal-2.st b/Task/Handle-a-signal/Smalltalk/handle-a-signal-2.st new file mode 100644 index 0000000000..70501596d5 --- /dev/null +++ b/Task/Handle-a-signal/Smalltalk/handle-a-signal-2.st @@ -0,0 +1 @@ +[ ... do something... ] on: UserInterrupt do: [:exInfo | ...handler... ] diff --git a/Task/Handle-a-signal/Smalltalk/handle-a-signal-3.st b/Task/Handle-a-signal/Smalltalk/handle-a-signal-3.st new file mode 100644 index 0000000000..501a6f1556 --- /dev/null +++ b/Task/Handle-a-signal/Smalltalk/handle-a-signal-3.st @@ -0,0 +1,8 @@ +|mySignal| +mySignal := Signal new mayProceed: false. +OperatingSytem operatingSystemSignal: (OperatingSystem signalNamed:'SIGHUP') install: mySignal. +[ + .. do something... +] on: mySignal do:[ + ... handle SIGHUP gracefully... +] diff --git a/Task/Handle-a-signal/Tcl/handle-a-signal-1.tcl b/Task/Handle-a-signal/Tcl/handle-a-signal-1.tcl new file mode 100644 index 0000000000..5f73026ccf --- /dev/null +++ b/Task/Handle-a-signal/Tcl/handle-a-signal-1.tcl @@ -0,0 +1,16 @@ +package require Expect + +proc sigint_handler {} { + puts "elapsed time: [expr {[clock seconds] - $::start_time}] seconds" + set ::looping false +} + +trap sigint_handler SIGINT + +set start_time [clock seconds] +set n 0 +set looping true +while {$looping} { + puts [incr n] + after 500 +} diff --git a/Task/Handle-a-signal/Tcl/handle-a-signal-2.tcl b/Task/Handle-a-signal/Tcl/handle-a-signal-2.tcl new file mode 100644 index 0000000000..51af9feada --- /dev/null +++ b/Task/Handle-a-signal/Tcl/handle-a-signal-2.tcl @@ -0,0 +1,16 @@ +package require Tclx + +proc sigint_handler {} { + puts "elapsed time: [expr {[clock seconds] - $::start_time}] seconds" + set ::looping false +} + +signal trap sigint sigint_handler + +set start_time [clock seconds] +set n 0 +set looping true +while {$looping} { + puts [incr n] + after 500 +} diff --git a/Task/Handle-a-signal/Tcl/handle-a-signal-3.tcl b/Task/Handle-a-signal/Tcl/handle-a-signal-3.tcl new file mode 100644 index 0000000000..6cced3e0c4 --- /dev/null +++ b/Task/Handle-a-signal/Tcl/handle-a-signal-3.tcl @@ -0,0 +1,20 @@ +package require Tclx + +signal error sigint + +set start_time [clock seconds] +set n 0 +proc infinite_loop {} { + while 1 { + puts [incr n] + after 500 + } +} +if {[catch infinite_loop out] != 0} { + lassign $::errorCode class name msg + if {$class eq "POSIX" && $name eq "SIG" && $msg eq "SIGINT"} { + puts "elapsed time: [expr {[clock seconds] - $start_time}] seconds" + } else { + puts "infinite loop interrupted, but not on SIGINT: $::errorInfo" + } +} diff --git a/Task/Handle-a-signal/Tcl/handle-a-signal-4.tcl b/Task/Handle-a-signal/Tcl/handle-a-signal-4.tcl new file mode 100644 index 0000000000..7899dbd634 --- /dev/null +++ b/Task/Handle-a-signal/Tcl/handle-a-signal-4.tcl @@ -0,0 +1,16 @@ +package require Tclx + +signal error sigint + +set start_time [clock seconds] +proc infinite_loop {} { + while 1 { + puts [incr n] + after 500 + } +} +try { + infinite_loop +} trap {POSIX SIG SIGINT} {} { + puts "elapsed time: [expr {[clock seconds] - $start_time}] seconds" +} diff --git a/Task/Happy-numbers/0DESCRIPTION b/Task/Happy-numbers/0DESCRIPTION new file mode 100644 index 0000000000..da58ac2ec1 --- /dev/null +++ b/Task/Happy-numbers/0DESCRIPTION @@ -0,0 +1,8 @@ +From Wikipedia, the free encyclopedia: +:A [[wp:Happy number|happy number]] is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. Display an example of your output here. + +'''Task:''' Find and print the first 8 happy numbers. + +See also: +* [[oeis:A007770|The     happy numbers on OEIS:   A007770]] +* [[oeis:A031177|The unhappy numbers on OEIS;   A031177]] diff --git a/Task/Happy-numbers/1META.yaml b/Task/Happy-numbers/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Happy-numbers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Happy-numbers/ACL2/happy-numbers.acl2 b/Task/Happy-numbers/ACL2/happy-numbers.acl2 new file mode 100644 index 0000000000..90d936cc89 --- /dev/null +++ b/Task/Happy-numbers/ACL2/happy-numbers.acl2 @@ -0,0 +1,25 @@ +(include-book "arithmetic-3/top" :dir :system) + +(defun sum-of-digit-squares (n) + (if (zp n) + 0 + (+ (expt (mod n 10) 2) + (sum-of-digit-squares (floor n 10))))) + +(defun is-happy-r (n seen) + (let ((next (sum-of-digit-squares n))) + (cond ((= next 1) t) + ((member next seen) nil) + (t (is-happy-r next (cons next seen)))))) + +(defun is-happy (n) + (is-happy-r n nil)) + +(defun first-happy-nums-r (n i) + (cond ((zp n) nil) + ((is-happy i) + (cons i (first-happy-nums-r (1- n) (1+ i)))) + (t (first-happy-nums-r n (1+ i))))) + +(defun first-happy-nums (n) + (first-happy-nums-r n 1)) diff --git a/Task/Happy-numbers/ALGOL-68/happy-numbers.alg b/Task/Happy-numbers/ALGOL-68/happy-numbers.alg new file mode 100644 index 0000000000..8f77953dd3 --- /dev/null +++ b/Task/Happy-numbers/ALGOL-68/happy-numbers.alg @@ -0,0 +1,25 @@ +INT base10 = 10, num happy = 8; + +PROC next = (INT in n)INT: ( + INT n := in n; + INT out := 0; + WHILE n NE 0 DO + out +:= ( n MOD base10 ) ** 2; + n := n OVER base10 + OD; + out +); + +PROC is happy = (INT in n)BOOL: ( + INT n := in n; + FOR i WHILE n NE 1 AND n NE 4 DO n := next(n) OD; + n=1 +); + +INT count := 0; +FOR i WHILE count NE num happy DO + IF is happy(i) THEN + count +:= 1; + print((i, new line)) + FI +OD diff --git a/Task/Happy-numbers/APL/happy-numbers.apl b/Task/Happy-numbers/APL/happy-numbers.apl new file mode 100644 index 0000000000..82b679d248 --- /dev/null +++ b/Task/Happy-numbers/APL/happy-numbers.apl @@ -0,0 +1,20 @@ + ∇ HappyNumbers arg;⎕IO;∆roof;∆first;bin;iroof +[1] ⍝0: Happy number +[2] ⍝1: http://rosettacode.org/wiki/Happy_numbers +[3] ⎕IO←1 ⍝ Index origin +[4] ∆roof ∆first←2↑arg,10 ⍝ +[5] +[6] bin←{ +[7] ⍺←⍬ ⍝ Default left arg +[8] ⍵=1:1 ⍝ Always happy! +[9] +[10] numbers←⍎¨1⊂⍕⍵ ⍝ Split numbers into parts +[11] next←+/{⍵*2}¨numbers ⍝ Sum and square of numbers +[12] +[13] next∊⍺:0 ⍝ Return 0, if already exists +[14] (⍺,next)∇ next ⍝ Check next number (recursive) +[15] +[16] }¨iroof←⍳∆roof ⍝ Does all numbers upto ∆root smiles? +[17] +[18] ⎕←~∘0¨∆first↑bin/iroof ⍝ Show ∆first numbers, but not 0 + ∇ diff --git a/Task/Happy-numbers/AWK/happy-numbers-1.awk b/Task/Happy-numbers/AWK/happy-numbers-1.awk new file mode 100644 index 0000000000..4e4b001abe --- /dev/null +++ b/Task/Happy-numbers/AWK/happy-numbers-1.awk @@ -0,0 +1,41 @@ +function is_happy(n) +{ + if ( n in happy ) return 1; + if ( n in unhappy ) return 0; + cycle[""] = 0 + while( (n!=1) && !(n in cycle) ) { + cycle[n] = n + new_n = 0 + while(n>0) { + d = n % 10 + new_n += d*d + n = int(n/10) + } + n = new_n + } + if ( n == 1 ) { + for (i_ in cycle) { + happy[cycle[i_]] = 1 + delete cycle[i_] + } + return 1 + } else { + for (i_ in cycle) { + unhappy[cycle[i_]] = 1 + delete cycle[i_] + } + return 0 + } +} + +BEGIN { + cnt = 0 + happy[""] = 0 + unhappy[""] = 0 + for(j=1; (cnt < 8); j++) { + if ( is_happy(j) == 1 ) { + cnt++ + print j + } + } +} diff --git a/Task/Happy-numbers/AWK/happy-numbers-2.awk b/Task/Happy-numbers/AWK/happy-numbers-2.awk new file mode 100644 index 0000000000..c2475df728 --- /dev/null +++ b/Task/Happy-numbers/AWK/happy-numbers-2.awk @@ -0,0 +1,28 @@ +BEGIN { + for (i = 1; i < 50; ++i){ + if (isHappy(i)) { + print i; + } + } + exit +} + +function isHappy(n, seen) { + delete seen; + while (1) { + n = sumSqrDig(n) + if (seen[n]) { + return n == 1 + } + seen[n] = 1 + } +} + +function sumSqrDig(n, d, tot) { + while (n) { + d = n % 10 + tot += d * d + n = int(n/10) + } + return tot +} diff --git a/Task/Happy-numbers/ActionScript/happy-numbers.as b/Task/Happy-numbers/ActionScript/happy-numbers.as new file mode 100644 index 0000000000..fa10a049a4 --- /dev/null +++ b/Task/Happy-numbers/ActionScript/happy-numbers.as @@ -0,0 +1,42 @@ +function sumOfSquares(n:uint) +{ + var sum:uint = 0; + while(n != 0) + { + sum += (n%10)*(n%10); + n /= 10; + } + return sum; +} +function isInArray(n:uint, array:Array) +{ + for(var k = 0; k < array.length; k++) + if(n == array[k]) return true; + return false; +} +function isHappy(n) +{ + var sequence:Array = new Array(); + while(n != 1) + { + sequence.push(n); + n = sumOfSquares(n); + if(isInArray(n,sequence))return false; + } + return true; +} +function printHappy() +{ + var numbersLeft:uint = 8; + var numberToTest:uint = 1; + while(numbersLeft != 0) + { + if(isHappy(numberToTest)) + { + trace(numberToTest); + numbersLeft--; + } + numberToTest++; + } +} +printHappy(); diff --git a/Task/Happy-numbers/Ada/happy-numbers.ada b/Task/Happy-numbers/Ada/happy-numbers.ada new file mode 100644 index 0000000000..be5e22c994 --- /dev/null +++ b/Task/Happy-numbers/Ada/happy-numbers.ada @@ -0,0 +1,41 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Containers.Ordered_Sets; + +procedure Test_Happy_Digits is + function Is_Happy (N : Positive) return Boolean is + package Sets_Of_Positive is new Ada.Containers.Ordered_Sets (Positive); + use Sets_Of_Positive; + function Next (N : Positive) return Natural is + Sum : Natural := 0; + Accum : Natural := N; + begin + while Accum > 0 loop + Sum := Sum + (Accum mod 10) ** 2; + Accum := Accum / 10; + end loop; + return Sum; + end Next; + Current : Positive := N; + Visited : Set; + begin + loop + if Current = 1 then + return True; + elsif Visited.Contains (Current) then + return False; + else + Visited.Insert (Current); + Current := Next (Current); + end if; + end loop; + end Is_Happy; + Found : Natural := 0; +begin + for N in Positive'Range loop + if Is_Happy (N) then + Put (Integer'Image (N)); + Found := Found + 1; + exit when Found = 8; + end if; + end loop; +end Test_Happy_Digits; diff --git a/Task/Happy-numbers/AutoHotkey/happy-numbers.ahk b/Task/Happy-numbers/AutoHotkey/happy-numbers.ahk new file mode 100644 index 0000000000..2e248df451 --- /dev/null +++ b/Task/Happy-numbers/AutoHotkey/happy-numbers.ahk @@ -0,0 +1,21 @@ +Loop { + If isHappy(A_Index) { + out .= (out="" ? "" : ",") . A_Index + i ++ + If (i = 8) { + MsgBox, The first 8 happy numbers are: %out% + ExitApp + } + } +} + +isHappy(num, list="") { + list .= (list="" ? "" : ",") . num + Loop, Parse, num + sum += A_LoopField ** 2 + If (sum = 1) + Return true + Else If sum in %list% + Return false + Else Return isHappy(sum, list) +} diff --git a/Task/Happy-numbers/AutoIt/happy-numbers-1.autoit b/Task/Happy-numbers/AutoIt/happy-numbers-1.autoit new file mode 100644 index 0000000000..202ed9858e --- /dev/null +++ b/Task/Happy-numbers/AutoIt/happy-numbers-1.autoit @@ -0,0 +1,22 @@ +$c = 0 +$k = 0 +While $c < 8 + $k += 1 + $n = $k + While $n <> 1 + $s = StringSplit($n, "") + $t = 0 + For $i = 1 To $s[0] + $t += $s[$i] ^ 2 + Next + $n = $t + Switch $n + Case 4,16,37,58,89,145,42,20 + ExitLoop + EndSwitch + WEnd + If $n = 1 Then + ConsoleWrite($k & " is Happy" & @CRLF) + $c += 1 + EndIf +WEnd diff --git a/Task/Happy-numbers/AutoIt/happy-numbers-2.autoit b/Task/Happy-numbers/AutoIt/happy-numbers-2.autoit new file mode 100644 index 0000000000..f0348eb3c3 --- /dev/null +++ b/Task/Happy-numbers/AutoIt/happy-numbers-2.autoit @@ -0,0 +1,24 @@ +$c = 0 +$k = 0 +While $c < 8 + $a = ObjCreate("System.Collections.ArrayList") + $k += 1 + $n = $k + While $n <> 1 + If $a.Contains($n) Then + ExitLoop + EndIf + $a.add($n) + $s = StringSplit($n, "") + $t = 0 + For $i = 1 To $s[0] + $t += $s[$i] ^ 2 + Next + $n = $t + WEnd + If $n = 1 Then + ConsoleWrite($k & " is Happy" & @CRLF) + $c += 1 + EndIf + $a.Clear +WEnd diff --git a/Task/Happy-numbers/BBC-BASIC/happy-numbers.bbc b/Task/Happy-numbers/BBC-BASIC/happy-numbers.bbc new file mode 100644 index 0000000000..867e01a520 --- /dev/null +++ b/Task/Happy-numbers/BBC-BASIC/happy-numbers.bbc @@ -0,0 +1,21 @@ + number% = 0 + total% = 0 + REPEAT + number% += 1 + IF FNhappy(number%) THEN + PRINT number% " is a happy number" + total% += 1 + ENDIF + UNTIL total% = 8 + END + + DEF FNhappy(num%) + LOCAL digit&() + DIM digit&(10) + REPEAT + digit&() = 0 + $$^digit&(0) = STR$(num%) + digit&() AND= 15 + num% = MOD(digit&())^2 + 0.5 + UNTIL num% = 1 OR num% = 4 + = (num% = 1) diff --git a/Task/Happy-numbers/Batch-File/happy-numbers.bat b/Task/Happy-numbers/Batch-File/happy-numbers.bat new file mode 100644 index 0000000000..ad0ccd6d2d --- /dev/null +++ b/Task/Happy-numbers/Batch-File/happy-numbers.bat @@ -0,0 +1,81 @@ +@echo off +setlocal enableDelayedExpansion +::Define a list with 10 terms as a convenience for defining a loop +set "L10=0 1 2 3 4 5 6 7 8 9" +shift /1 & goto %1 +exit /b + + +:list min count +:: This routine prints all happy numbers > min (arg1) +:: until it finds count (arg2) happy numbers. +set /a "n=%~1, cnt=%~2" +call :listInternal +exit /b + + +:test min [max] +:: This routine sequentially tests numbers between min (arg1) and max (arg2) +:: to see if they are happy. If max is not specified then it defaults to min. +set /a "min=%~1" +if "%~2" neq "" (set /a "max=%~2") else set max=%min% +::The FOR /L loop does not detect integer overflow, so must protect against +::an infinite loop when max=0x7FFFFFFFF +set end=%max% +if %end% equ 2147483647 set /a end-=1 +for /l %%N in (%min% 1 %end%) do ( + call :testInternal %%N && (echo %%N is happy :^)) || echo %%N is sad :( +) +if %end% neq %max% call :testInternal %max% && (echo %max% is happy :^)) || echo %max% is sad :( +exit /b + + + :listInternal + :: This loop sequentially tests each number >= n. The loop conditionally + :: breaks within the body once cnt happy numbers have been found, or if + :: the max integer value is reached. Performance is improved by using a + :: FOR loop to perform most of the looping, with a GOTO only needed once + :: per 100 iterations. + for %%. in ( + %L10% %L10% %L10% %L10% %L10% %L10% %L10% %L10% %L10% %L10% + ) do ( + call :testInternal !n! && ( + echo !n! + set /a cnt-=1 + if !cnt! leq 0 exit /b 0 + ) + if !n! equ 2147483647 ( + >&2 echo ERROR: Maximum integer value reached + exit /b 1 + ) + set /a n+=1 + ) + goto :listInternal + + + :testInternal n + :: This routine loops until the sum of squared digits converges on 1 (happy) + :: or it detects a cycle (sad). It exits with errorlevel 0 for happy and 1 for sad. + :: Performance is improved by using a FOR loop for the looping instead of a GOTO. + :: Numbers less than 1000 never neeed more than 20 iterations, and any number + :: with 4 or more digits shrinks by at least one digit each iteration. + :: Since Windows batch can't handle more than 10 digits, allowance for 27 + :: iterations is enough, and 30 is more than adequate. + setlocal + set n=%1 + for %%. in (%L10% %L10% %L10%) do ( + if !n!==1 exit /b 0 + %= Only numbers < 1000 can cycle =% + if !n! lss 1000 ( + if defined t.!n! exit /b 1 + set t.!n!=1 + ) + %= Sum the squared digits =% + %= Batch can't handle numbers greater than 10 digits so we can use =% + %= a constrained FOR loop and avoid a slow goto =% + set sum=0 + for /l %%N in (1 1 10) do ( + if !n! gtr 0 set /a "sum+=(n%%10)*(n%%10), n/=10" + ) + set /a n=sum + ) diff --git a/Task/Happy-numbers/Bori/happy-numbers.bori b/Task/Happy-numbers/Bori/happy-numbers.bori new file mode 100644 index 0000000000..263681dd2c --- /dev/null +++ b/Task/Happy-numbers/Bori/happy-numbers.bori @@ -0,0 +1,36 @@ +bool isHappy (int n) +{ + ints cache; + + while (n != 1) + { + int sum = 0; + + if (cache.contains(n)) + return false; + + cache.add(n); + while (n != 0) + { + int digit = n % 10; + sum += (digit * digit); + n = (int)(n / 10); + } + n = sum; + } + return true; +} + +void test () +{ + int num = 1; + ints happynums; + + while (happynums.count() < 8) + { + if (isHappy(num)) + happynums.add(num); + num++; + } + puts("First 8 happy numbers : " + str.newline + happynums); +} diff --git a/Task/Happy-numbers/Brat/happy-numbers.brat b/Task/Happy-numbers/Brat/happy-numbers.brat new file mode 100644 index 0000000000..9770020853 --- /dev/null +++ b/Task/Happy-numbers/Brat/happy-numbers.brat @@ -0,0 +1,29 @@ +include :set + +happiness = set.new 1 +sadness = set.new + +sum_of_squares_of_digits = { num | + num.to_s.dice.reduce 0 { sum, n | sum = sum + n.to_i ^ 2 } +} + +happy? = { n, seen = set.new | + when {true? happiness.include? n } { happiness.merge seen << n; true } + { true? sadness.include? n } { sadness.merge seen; false } + { true? seen.include? n } { sadness.merge seen; false } + { true } { seen << n; happy? sum_of_squares_of_digits(n), seen } +} + +num = 1 +happies = [] + +while { happies.length < 8 } { + true? happy?(num) + { happies << num } + + num = num + 1 +} + +p "First eight happy numbers: #{happies}" +p "Happy numbers found: #{happiness.to_array.sort}" +p "Sad numbers found: #{sadness.to_array.sort}" diff --git a/Task/Happy-numbers/C++/happy-numbers-1.cpp b/Task/Happy-numbers/C++/happy-numbers-1.cpp new file mode 100644 index 0000000000..8a57cdc6d0 --- /dev/null +++ b/Task/Happy-numbers/C++/happy-numbers-1.cpp @@ -0,0 +1,36 @@ +#include +#include + +bool happy(int number) { + static std::map cache; + + std::set cycle; + while (number != 1 && !cycle.count(number)) { + if (cache.count(number)) { + number = cache[number] ? 1 : 0; + break; + } + cycle.insert(number); + int newnumber = 0; + while (number > 0) { + int digit = number % 10; + newnumber += digit * digit; + number /= 10; + } + number = newnumber; + } + bool happiness = number == 1; + for (std::set::const_iterator it = cycle.begin(); + it != cycle.end(); it++) + cache[*it] = happiness; + return happiness; +} + +#include + +int main() { + for (int i = 1; i < 50; i++) + if (happy(i)) + std::cout << i << std::endl; + return 0; +} diff --git a/Task/Happy-numbers/C++/happy-numbers-2.cpp b/Task/Happy-numbers/C++/happy-numbers-2.cpp new file mode 100644 index 0000000000..ad063efd61 --- /dev/null +++ b/Task/Happy-numbers/C++/happy-numbers-2.cpp @@ -0,0 +1,41 @@ +unsigned int happy_iteration(unsigned int n) +{ + unsigned int result = 0; + while (n > 0) + { + unsigned int lastdig = n % 10; + result += lastdig*lastdig; + n /= 10; + } + return result; +} + +bool is_happy(unsigned int n) +{ + unsigned int n2 = happy_iteration(n); + while (n != n2) + { + n = happy_iteration(n); + n2 = happy_iteration(happy_iteration(n2)); + } + return n == 1; +} + +#include + +int main() +{ + unsigned int current_number = 1; + + unsigned int happy_count = 0; + while (happy_count != 8) + { + if (is_happy(current_number)) + { + std::cout << current_number << " "; + ++happy_count; + } + ++current_number; + } + std::cout << std::endl; +} diff --git a/Task/Happy-numbers/C/happy-numbers-1.c b/Task/Happy-numbers/C/happy-numbers-1.c new file mode 100644 index 0000000000..00c5ffa3eb --- /dev/null +++ b/Task/Happy-numbers/C/happy-numbers-1.c @@ -0,0 +1,33 @@ +#include + +#define CACHE 256 +enum { h_unknown = 0, h_yes, h_no }; +unsigned char buf[CACHE] = {0, h_yes, 0}; + +int happy(int n) +{ + int sum = 0, x, nn; + if (n < CACHE) { + if (buf[n]) return 2 - buf[n]; + buf[n] = h_no; + } + + for (nn = n; nn; nn /= 10) x = nn % 10, sum += x * x; + + x = happy(sum); + if (n < CACHE) buf[n] = 2 - x; + return x; +} + +int main() +{ + int i, cnt = 8; + for (i = 1; cnt || !printf("\n"); i++) + if (happy(i)) --cnt, printf("%d ", i); + + printf("The %dth happy number: ", cnt = 1000000); + for (i = 1; cnt; i++) + if (happy(i)) --cnt || printf("%d\n", i); + + return 0; +} diff --git a/Task/Happy-numbers/C/happy-numbers-2.c b/Task/Happy-numbers/C/happy-numbers-2.c new file mode 100644 index 0000000000..eaac55ce67 --- /dev/null +++ b/Task/Happy-numbers/C/happy-numbers-2.c @@ -0,0 +1,31 @@ +#include + +int dsum(int n) +{ + int sum, x; + for (sum = 0; n; n /= 10) x = n % 10, sum += x * x; + return sum; +} + +int happy(int n) +{ + int nn; + while (n > 999) n = dsum(n); /* 4 digit numbers can't cycle */ + nn = dsum(n); + while (nn != n && nn != 1) + n = dsum(n), nn = dsum(dsum(nn)); + return n == 1; +} + +int main() +{ + int i, cnt = 8; + for (i = 1; cnt || !printf("\n"); i++) + if (happy(i)) --cnt, printf("%d ", i); + + printf("The %dth happy number: ", cnt = 1000000); + for (i = 1; cnt; i++) + if (happy(i)) --cnt || printf("%d\n", i); + + return 0; +} diff --git a/Task/Happy-numbers/Clojure/happy-numbers.clj b/Task/Happy-numbers/Clojure/happy-numbers.clj new file mode 100644 index 0000000000..22a51896ff --- /dev/null +++ b/Task/Happy-numbers/Clojure/happy-numbers.clj @@ -0,0 +1,14 @@ +(defn- digit-to-num [d] (Character/digit d 10)) +(defn- square [n] (* n n)) + +(defn happy? [n] + (loop [n n, seen #{}] + (cond (= n 1) true + (seen n) false + :else + (recur (reduce + (map (comp square digit-to-num) (str n))) + (conj seen n))))) + +(def happy-numbers (filter happy? (iterate inc 1))) + +(println (take 8 happy-numbers)) diff --git a/Task/Happy-numbers/CoffeeScript/happy-numbers.coffee b/Task/Happy-numbers/CoffeeScript/happy-numbers.coffee new file mode 100644 index 0000000000..1e58b0e277 --- /dev/null +++ b/Task/Happy-numbers/CoffeeScript/happy-numbers.coffee @@ -0,0 +1,22 @@ +happy = (n) -> + seen = {} + while true + n = sum_digit_squares(n) + return true if n == 1 + return false if seen[n] + seen[n] = true + +sum_digit_squares = (n) -> + sum = 0 + for c in n.toString() + d = parseInt(c) + sum += d*d + sum + +i = 1 +cnt = 0 +while cnt < 8 + if happy(i) + console.log i + cnt += 1 + i += 1 diff --git a/Task/Happy-numbers/Common-Lisp/happy-numbers.lisp b/Task/Happy-numbers/Common-Lisp/happy-numbers.lisp new file mode 100644 index 0000000000..0d880b94cd --- /dev/null +++ b/Task/Happy-numbers/Common-Lisp/happy-numbers.lisp @@ -0,0 +1,21 @@ +(defun sqr (n) + (* n n)) + +(defun sum-of-sqr-dgts (n) + (loop for i = n then (floor i 10) + while (plusp i) + sum (sqr (mod i 10)))) + +(defun happy-p (n &optional cache) + (or (= n 1) + (unless (find n cache) + (happy-p (sum-of-sqr-dgts n) + (cons n cache))))) + +(defun happys (&aux (happys 0)) + (loop for i from 1 + while (< happys 8) + when (happy-p i) + collect i and do (incf happys))) + +(print (happys)) diff --git a/Task/Happy-numbers/D/happy-numbers-1.d b/Task/Happy-numbers/D/happy-numbers-1.d new file mode 100644 index 0000000000..0475b0f7fe --- /dev/null +++ b/Task/Happy-numbers/D/happy-numbers-1.d @@ -0,0 +1,23 @@ +import std.stdio, std.algorithm, std.range; + +bool isHappy(int n) pure nothrow { + int[int] past; + + while (true) { + int total = 0; + while (n > 0) { + total += (n % 10) ^^ 2; + n /= 10; + } + if (total == 1) + return true; + if (total in past) + return false; + n = total; + past[total] = 0; + } +} + +void main() { + int.max.iota().filter!isHappy().take(8).writeln(); +} diff --git a/Task/Happy-numbers/D/happy-numbers-2.d b/Task/Happy-numbers/D/happy-numbers-2.d new file mode 100644 index 0000000000..c8085075ec --- /dev/null +++ b/Task/Happy-numbers/D/happy-numbers-2.d @@ -0,0 +1,19 @@ +import std.stdio, std.algorithm, std.range, std.conv; + +bool isHappy(int n) /*pure nothrow*/ { + int[int] seen; + + while (true) { + const t = n.text().map!q{(a - '0') ^^ 2}().reduce!q{a + b}(); + if (t == 1) + return true; + if (t in seen) + return false; + n = t; + seen[t] = 0; + } +} + +void main() { + int.max.iota().filter!isHappy().take(8).writeln(); +} diff --git a/Task/Happy-numbers/DWScript/happy-numbers.dwscript b/Task/Happy-numbers/DWScript/happy-numbers.dwscript new file mode 100644 index 0000000000..f810437e02 --- /dev/null +++ b/Task/Happy-numbers/DWScript/happy-numbers.dwscript @@ -0,0 +1,30 @@ +function IsHappy(n : Integer) : Boolean; +var + cache : array of Integer; + sum : Integer; +begin + while True do begin + sum := 0; + while n>0 do begin + sum += Sqr(n mod 10); + n := n div 10; + end; + if sum = 1 then + Exit(True); + if sum in cache then + Exit(False); + n := sum; + cache.Add(sum); + end; +end; + +var n := 8; +var i : Integer; + +while n>0 do begin + Inc(i); + if IsHappy(i) then begin + PrintLn(i); + Dec(n); + end; +end; diff --git a/Task/Happy-numbers/Dart/happy-numbers.dart b/Task/Happy-numbers/Dart/happy-numbers.dart new file mode 100644 index 0000000000..626a622ff6 --- /dev/null +++ b/Task/Happy-numbers/Dart/happy-numbers.dart @@ -0,0 +1,35 @@ +main() { + HashMap happy=new HashMap(); + happy[1]=true; + + int count=0; + int i=0; + + while(count<8) { + if(happy[i]==null) { + int j=i; + Set sequence=new Set(); + while(happy[j]==null && !sequence.contains(j)) { + sequence.add(j); + int sum=0; + int val=j; + while(val>0) { + int digit=val%10; + sum+=digit*digit; + val=(val/10).toInt(); + } + j=sum; + } + bool sequenceHappy=happy[j]; + Iterator it=sequence.iterator(); + while(it.hasNext()) { + happy[it.next()]=sequenceHappy; + } + } + if(happy[i]) { + print(i); + count++; + } + i++; + } +} diff --git a/Task/Happy-numbers/E/happy-numbers.e b/Task/Happy-numbers/E/happy-numbers.e new file mode 100644 index 0000000000..bf1a633927 --- /dev/null +++ b/Task/Happy-numbers/E/happy-numbers.e @@ -0,0 +1,20 @@ +def isHappyNumber(var x :int) { + var seen := [].asSet() + while (!seen.contains(x)) { + seen with= x + var sum := 0 + while (x > 0) { + sum += (x % 10) ** 2 + x //= 10 + } + x := sum + if (x == 1) { return true } + } + return false +} + +var count := 0 +for x ? (isHappyNumber(x)) in (int >= 1) { + println(x) + if ((count += 1) >= 8) { break } +} diff --git a/Task/Happy-numbers/Erlang/happy-numbers-1.erl b/Task/Happy-numbers/Erlang/happy-numbers-1.erl new file mode 100644 index 0000000000..8098b08c9b --- /dev/null +++ b/Task/Happy-numbers/Erlang/happy-numbers-1.erl @@ -0,0 +1,32 @@ +-module(tasks). +-export([main/0]). +-import(lists, [map/2, member/2, sort/1, sum/1]). + +is_happy(X, XS) -> + if + X == 1 -> + true; + X < 1 -> + false; + true -> + case member(X, XS) of + true -> false; + false -> + is_happy(sum(map(fun(Z) -> Z*Z end, + [Y - 48 || Y <- integer_to_list(X)])), + [X|XS]) + end + end. + +main(X, XS) -> + if + length(XS) == 8 -> + io:format("8 Happy Numbers: ~w~n", [sort(XS)]); + true -> + case is_happy(X, []) of + true -> main(X + 1, [X|XS]); + false -> main(X + 1, XS) + end + end. +main() -> + main(0, []). diff --git a/Task/Happy-numbers/Erlang/happy-numbers-2.erl b/Task/Happy-numbers/Erlang/happy-numbers-2.erl new file mode 100644 index 0000000000..5c53e1fbf4 --- /dev/null +++ b/Task/Happy-numbers/Erlang/happy-numbers-2.erl @@ -0,0 +1 @@ +erl -run tasks main -run init stop -noshell diff --git a/Task/Happy-numbers/Erlang/happy-numbers-3.erl b/Task/Happy-numbers/Erlang/happy-numbers-3.erl new file mode 100644 index 0000000000..4fbcc5c121 --- /dev/null +++ b/Task/Happy-numbers/Erlang/happy-numbers-3.erl @@ -0,0 +1 @@ +8 Happy Numbers: [1,7,10,13,19,23,28,31] diff --git a/Task/Happy-numbers/Erlang/happy-numbers-4.erl b/Task/Happy-numbers/Erlang/happy-numbers-4.erl new file mode 100644 index 0000000000..a87f72141b --- /dev/null +++ b/Task/Happy-numbers/Erlang/happy-numbers-4.erl @@ -0,0 +1,18 @@ +-module(tasks). + +-export([main/0]). + +main() -> io:format("~w ~n", [happy_list(1, 8, [])]). + +happy_list(_, N, L) when length(L) =:= N -> lists:reverse(L); +happy_list(X, N, L) -> + Happy = is_happy(X), + if Happy -> happy_list(X + 1, N, [X|L]); + true -> happy_list(X + 1, N, L) end. + +is_happy(1) -> true; +is_happy(4) -> false; +is_happy(N) when N > 0 -> + N_As_Digits = [Y - 48 || Y <- integer_to_list(N)], + is_happy(lists:foldl(fun(X, Sum) -> (X * X) + Sum end, 0, N_As_Digits)); +is_happy(_) -> false. diff --git a/Task/Happy-numbers/Euphoria/happy-numbers.euphoria b/Task/Happy-numbers/Euphoria/happy-numbers.euphoria new file mode 100644 index 0000000000..ad3a9dcdfd --- /dev/null +++ b/Task/Happy-numbers/Euphoria/happy-numbers.euphoria @@ -0,0 +1,29 @@ +function is_happy(integer n) + sequence seen + integer k + seen = {} + while n > 1 do + seen &= n + k = 0 + while n > 0 do + k += power(remainder(n,10),2) + n = floor(n/10) + end while + n = k + if find(n,seen) then + return 0 + end if + end while + return 1 +end function + +integer n,count +n = 1 +count = 0 +while count < 8 do + if is_happy(n) then + ? n + count += 1 + end if + n += 1 +end while diff --git a/Task/Happy-numbers/Factor/happy-numbers-1.factor b/Task/Happy-numbers/Factor/happy-numbers-1.factor new file mode 100644 index 0000000000..66368e0cbe --- /dev/null +++ b/Task/Happy-numbers/Factor/happy-numbers-1.factor @@ -0,0 +1,21 @@ +USING: combinators kernel make math sequences ; + +: squares ( n -- s ) + 0 [ over 0 > ] [ [ 10 /mod sq ] dip + ] while nip ; + +: (happy?) ( n1 n2 -- ? ) + [ squares ] [ squares squares ] bi* { + { [ dup 1 = ] [ 2drop t ] } + { [ 2dup = ] [ 2drop f ] } + [ (happy?) ] + } cond ; + +: happy? ( n -- ? ) + dup (happy?) ; + +: happy-numbers ( n -- seq ) + [ + 0 [ over 0 > ] [ + dup happy? [ dup , [ 1 - ] dip ] when 1 + + ] while 2drop + ] { } make ; diff --git a/Task/Happy-numbers/Factor/happy-numbers-2.factor b/Task/Happy-numbers/Factor/happy-numbers-2.factor new file mode 100644 index 0000000000..16e8bc76f8 --- /dev/null +++ b/Task/Happy-numbers/Factor/happy-numbers-2.factor @@ -0,0 +1 @@ +8 happy-numbers ! { 1 7 10 13 19 23 28 31 } diff --git a/Task/Happy-numbers/Fantom/happy-numbers.fantom b/Task/Happy-numbers/Fantom/happy-numbers.fantom new file mode 100644 index 0000000000..ff685e3820 --- /dev/null +++ b/Task/Happy-numbers/Fantom/happy-numbers.fantom @@ -0,0 +1,35 @@ +class Main +{ + static Bool isHappy (Int n) + { + Int[] record := [,] + while (n != 1 && !record.contains(n)) + { + record.add (n) + // find sum of squares of digits + newn := 0 + while (n > 0) + { + newn += (n.mod(10) * n.mod(10)) + n = n.div(10) + } + n = newn + } + return (n == 1) + } + + public static Void main () + { + i := 1 + count := 0 + while (count < 8) + { + if (isHappy (i)) + { + echo (i) + count += 1 + } + i += 1 + } + } +} diff --git a/Task/Happy-numbers/Forth/happy-numbers.fth b/Task/Happy-numbers/Forth/happy-numbers.fth new file mode 100644 index 0000000000..83d03318e8 --- /dev/null +++ b/Task/Happy-numbers/Forth/happy-numbers.fth @@ -0,0 +1,20 @@ +: next ( n -- n ) + 0 swap begin 10 /mod >r dup * + r> ?dup 0= until ; + +: cycle? ( n -- ? ) + here dup @ cells + + begin dup here > + while 2dup @ = if 2drop true exit then + 1 cells - + repeat + 1 over +! dup @ cells + ! false ; + +: happy? ( n -- ? ) + 0 here ! begin next dup cycle? until 1 = ; + +: happy-numbers ( n -- ) + 0 swap 0 do + begin 1+ dup happy? until dup . + loop drop ; + +8 happy-numbers \ 1 7 10 13 19 23 28 31 diff --git a/Task/Happy-numbers/Fortran/happy-numbers.f b/Task/Happy-numbers/Fortran/happy-numbers.f new file mode 100644 index 0000000000..5079f8810a --- /dev/null +++ b/Task/Happy-numbers/Fortran/happy-numbers.f @@ -0,0 +1,67 @@ +program happy + + implicit none + integer, parameter :: find = 8 + integer :: found + integer :: number + + found = 0 + number = 1 + do + if (found == find) then + exit + end if + if (is_happy (number)) then + found = found + 1 + write (*, '(i0)') number + end if + number = number + 1 + end do + +contains + + function sum_digits_squared (number) result (result) + + implicit none + integer, intent (in) :: number + integer :: result + integer :: digit + integer :: rest + integer :: work + + result = 0 + work = number + do + if (work == 0) then + exit + end if + rest = work / 10 + digit = work - 10 * rest + result = result + digit * digit + work = rest + end do + + end function sum_digits_squared + + function is_happy (number) result (result) + + implicit none + integer, intent (in) :: number + logical :: result + integer :: turtoise + integer :: hare + + turtoise = number + hare = number + do + turtoise = sum_digits_squared (turtoise) + hare = sum_digits_squared (sum_digits_squared (hare)) + if (turtoise == hare) then + exit + end if + end do + result = turtoise == 1 + + end function is_happy + +end program happy diff --git a/Task/Happy-numbers/Frege/happy-numbers.frege b/Task/Happy-numbers/Frege/happy-numbers.frege new file mode 100644 index 0000000000..09e66890a5 --- /dev/null +++ b/Task/Happy-numbers/Frege/happy-numbers.frege @@ -0,0 +1,17 @@ +module Happy where + +import Prelude.Math +-- ugh, since Frege doesn't have Set, use Map instead +import Data.Map (member, insertMin, empty) + +digitToInteger :: Char -> Integer +digitToInteger c = fromInt $ (ord c) - (ord '0') + +isHappy :: Integer -> Bool +isHappy = p empty + where p _ 1n = true + p s n | n `member` s = false + | otherwise = p (insertMin n () s) (f n) + f = sum . map (sqr . digitToInteger) . unpacked . show + +main _ = printStrLn $ unwords $ map show $ take 8 $ filter isHappy $ iterate (+ 1n) 1n diff --git a/Task/Happy-numbers/Go/happy-numbers.go b/Task/Happy-numbers/Go/happy-numbers.go new file mode 100644 index 0000000000..063dbafe9c --- /dev/null +++ b/Task/Happy-numbers/Go/happy-numbers.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "strconv" +) + +func happy(n int) bool { + m := make(map[int]int) + for n > 1 { + m[n] = 0 + s := strconv.Itoa(n) + n = 0 + for _, d := range s { + x := int(d) - '0' + n += x * x + } + if _, ok := m[n]; ok { + return false + } + } + return true +} + +func main() { + for found, n := 0, 1; found < 8; n++ { + if happy(n) { + fmt.Print(n, " ") + found++ + } + } + fmt.Println("") +} diff --git a/Task/Happy-numbers/Haskell/happy-numbers-1.hs b/Task/Happy-numbers/Haskell/happy-numbers-1.hs new file mode 100644 index 0000000000..d8fab6956a --- /dev/null +++ b/Task/Happy-numbers/Haskell/happy-numbers-1.hs @@ -0,0 +1,11 @@ +import Data.Char (digitToInt) +import Data.Set (member, insert, empty) + +isHappy :: Integer -> Bool +isHappy = p empty + where p _ 1 = True + p s n | n `member` s = False + | otherwise = p (insert n s) (f n) + f = sum . map ((^2) . toInteger . digitToInt) . show + +main = mapM_ print $ take 8 $ filter isHappy [1..] diff --git a/Task/Happy-numbers/Haskell/happy-numbers-2.hs b/Task/Happy-numbers/Haskell/happy-numbers-2.hs new file mode 100644 index 0000000000..a3ae3c605e --- /dev/null +++ b/Task/Happy-numbers/Haskell/happy-numbers-2.hs @@ -0,0 +1,10 @@ +import Data.Array + +happy x = if xx <= 150 then seen!xx else happy xx where + xx = dsum x + seen :: Array Int Bool + seen = listArray (1,150) $ True:False:False:False:(map happy [5..150]) + dsum n | n < 10 = n * n + | otherwise = let (q,r) = n `divMod` 10 in r*r + dsum q + +main = print $ sum $ take 10000 $ filter happy [1..] diff --git a/Task/Happy-numbers/Icon/happy-numbers.icon b/Task/Happy-numbers/Icon/happy-numbers.icon new file mode 100644 index 0000000000..f2c6955246 --- /dev/null +++ b/Task/Happy-numbers/Icon/happy-numbers.icon @@ -0,0 +1,17 @@ +procedure main(arglist) +local n +n := arglist[1] | 8 # limiting number of happy numbers to generate, default=8 +writes("The first ",n," happy numbers are:") +every writes(" ", happy(seq()) \ n ) +write() +end + +procedure happy(i) #: returns i if i is happy +local n + + if 4 ~= (0 <= i) then { # unhappy if negative, 0, or 4 + if i = 1 then return i + every (n := 0) +:= !i ^ 2 + if happy(n) then return i + } +end diff --git a/Task/Happy-numbers/J/happy-numbers-1.j b/Task/Happy-numbers/J/happy-numbers-1.j new file mode 100644 index 0000000000..167abcc3d9 --- /dev/null +++ b/Task/Happy-numbers/J/happy-numbers-1.j @@ -0,0 +1,2 @@ + 8{. (#~1=+/@(*:@(,.&.":))^:(1&~:*.4&~:)^:_ "0) 1+i.100 +1 7 10 13 19 23 28 31 diff --git a/Task/Happy-numbers/J/happy-numbers-2.j b/Task/Happy-numbers/J/happy-numbers-2.j new file mode 100644 index 0000000000..1222d05163 --- /dev/null +++ b/Task/Happy-numbers/J/happy-numbers-2.j @@ -0,0 +1 @@ + f ^: cond ^: _ input diff --git a/Task/Happy-numbers/J/happy-numbers-3.j b/Task/Happy-numbers/J/happy-numbers-3.j new file mode 100644 index 0000000000..88e74b1e26 --- /dev/null +++ b/Task/Happy-numbers/J/happy-numbers-3.j @@ -0,0 +1 @@ + (binary array) # 1..100 diff --git a/Task/Happy-numbers/J/happy-numbers-4.j b/Task/Happy-numbers/J/happy-numbers-4.j new file mode 100644 index 0000000000..3b13fdbf25 --- /dev/null +++ b/Task/Happy-numbers/J/happy-numbers-4.j @@ -0,0 +1,7 @@ + cond=: 1&~: *. 4&~: NB. not equal to 1 and not equal to 4 + sumSqrDigits=: +/@(*:@(,.&.":)) + + sumSqrDigits 123 NB. test sum of squared digits +14 + 8{. (#~ 1 = sumSqrDigits ^: cond ^:_ "0) 1 + i.100 +1 7 10 13 19 23 28 31 diff --git a/Task/Happy-numbers/Java/happy-numbers.java b/Task/Happy-numbers/Java/happy-numbers.java new file mode 100644 index 0000000000..aab8217a4e --- /dev/null +++ b/Task/Happy-numbers/Java/happy-numbers.java @@ -0,0 +1,27 @@ +import java.util.HashSet; +public class Happy{ + public static boolean happy(long number){ + long m = 0; + int digit = 0; + HashSet cycle = new HashSet(); + while(number != 1 && cycle.add(number)){ + m = 0; + while(number > 0){ + digit = (int)(number % 10); + m += digit*digit; + number /= 10; + } + number = m; + } + return number == 1; + } + + public static void main(String[] args){ + for(long num = 1,count = 0;count<8;num++){ + if(happy(num)){ + System.out.println(num); + count++; + } + } + } +} diff --git a/Task/Happy-numbers/JavaScript/happy-numbers.js b/Task/Happy-numbers/JavaScript/happy-numbers.js new file mode 100644 index 0000000000..8f77410f40 --- /dev/null +++ b/Task/Happy-numbers/JavaScript/happy-numbers.js @@ -0,0 +1,26 @@ +function happy(number) { + var m, digit ; + var cycle = [] ; + + while(number != 1 && cycle[number] !== true) { + cycle[number] = true ; + m = 0 ; + while (number > 0) { + digit = number % 10 ; + m += digit * digit ; + number = (number - digit) / 10 ; + } + number = m ; + } + return (number == 1) ; +} + +var cnt = 8 ; +var number = 1 ; + +while(cnt-- > 0) { + while(!happy(number)) + number++ ; + document.write(number + " ") ; + number++ ; +} diff --git a/Task/Happy-numbers/Julia/happy-numbers.julia b/Task/Happy-numbers/Julia/happy-numbers.julia new file mode 100644 index 0000000000..11a7b8d456 --- /dev/null +++ b/Task/Happy-numbers/Julia/happy-numbers.julia @@ -0,0 +1,15 @@ +function happy(x) + happy_ints = ref(Int) + int_try = 1 + while length(happy_ints) < x + n = int_try + past = ref(Int) + while n != 1 + n = sum([int(string(y))^2 for y in string(n)]) + contains(past,n) ? break : push!(past,n) + end + if n == 1 push!(happy_ints,int_try) end + int_try += 1 + end + return happy_ints +end diff --git a/Task/Happy-numbers/K/happy-numbers.k b/Task/Happy-numbers/K/happy-numbers.k new file mode 100644 index 0000000000..7e9df1f782 --- /dev/null +++ b/Task/Happy-numbers/K/happy-numbers.k @@ -0,0 +1,7 @@ + hpy: {x@&1={~|/x=1 4}{_+/_sqr 0$'$x}//:x} + + hpy 1+!100 +1 7 10 13 19 23 28 31 32 44 49 68 70 79 82 86 91 94 97 100 + + 8#hpy 1+!100 +1 7 10 13 19 23 28 31 diff --git a/Task/Happy-numbers/Liberty-BASIC/happy-numbers.liberty b/Task/Happy-numbers/Liberty-BASIC/happy-numbers.liberty new file mode 100644 index 0000000000..a5b7e2f9ad --- /dev/null +++ b/Task/Happy-numbers/Liberty-BASIC/happy-numbers.liberty @@ -0,0 +1,28 @@ + ct = 0 + n = 0 + DO + n = n + 1 + IF HappyN(n, sqrInt$) = 1 THEN + ct = ct + 1 + PRINT ct, n + END IF + LOOP UNTIL ct = 8 +END + +FUNCTION HappyN(n, sqrInts$) + n$ = Str$(n) + sqrInts = 0 + FOR i = 1 TO Len(n$) + sqrInts = sqrInts + Val(Mid$(n$, i, 1)) ^ 2 + NEXT i + IF sqrInts = 1 THEN + HappyN = 1 + EXIT FUNCTION + END IF + IF Instr(sqrInts$, ":";Str$(sqrInts);":") > 0 THEN + HappyN = 0 + EXIT FUNCTION + END IF + sqrInts$ = sqrInts$ + Str$(sqrInts) + ":" + HappyN = HappyN(sqrInts, sqrInts$) +END FUNCTION diff --git a/Task/Happy-numbers/Locomotive-Basic/happy-numbers.bas b/Task/Happy-numbers/Locomotive-Basic/happy-numbers.bas new file mode 100644 index 0000000000..8f8b5e4b94 --- /dev/null +++ b/Task/Happy-numbers/Locomotive-Basic/happy-numbers.bas @@ -0,0 +1,16 @@ +10 mode 1:defint a-z +20 for i=1 to 100 +30 i2=i +40 for l=1 to 20 +50 a$=str$(i2) +60 i2=0 +70 for j=1 to len(a$) +80 d=val(mid$(a$,j,1)) +90 i2=i2+d*d +100 next j +110 if i2=1 then print i;"is a happy number":n=n+1:goto 150 +120 if i2=4 then 150 ' cycle found +130 next l +140 ' check if we have reached 8 numbers yet +150 if n=8 then end +160 next i diff --git a/Task/Happy-numbers/Logo/happy-numbers.logo b/Task/Happy-numbers/Logo/happy-numbers.logo new file mode 100644 index 0000000000..0fac5e2eb5 --- /dev/null +++ b/Task/Happy-numbers/Logo/happy-numbers.logo @@ -0,0 +1,24 @@ +to sum_of_square_digits :number + output (apply "sum (map [[d] d*d] ` :number)) +end + +to is_happy? :number [:seen []] + output cond [ + [ [:number = 1] "true ] + [ [member? :number :seen] "false ] + [ else (is_happy? (sum_of_square_digits :number) (lput :number :seen))] + ] +end + +to n_happy :count [:start 1] [:result []] + output cond [ + [ [:count <= 0] :result ] + [ [is_happy? :start] + (n_happy (:count-1) (:start+1) (lput :start :result)) ] + [ else + (n_happy :count (:start+1) :result) ] + ] +end + +print n_happy 8 +bye diff --git a/Task/Happy-numbers/Lua/happy-numbers.lua b/Task/Happy-numbers/Lua/happy-numbers.lua new file mode 100644 index 0000000000..77c963d955 --- /dev/null +++ b/Task/Happy-numbers/Lua/happy-numbers.lua @@ -0,0 +1,15 @@ +function digits(n) + if n > 0 then return n % 10, digits(math.floor(n/10)) end +end +function sumsq(a, ...) + return a and a ^ 2 + sumsq(...) or 0 +end +local happy = setmetatable({true, false, false, false}, { + __index = function(self, n) + self[n] = self[sumsq(digits(n))] + return self[n] + end } ) +i, j = 0, 1 +repeat + i, j = happy[j] and (print(j) or i+1) or i, j + 1 +until i == 8 diff --git a/Task/Happy-numbers/MUMPS/happy-numbers.mumps b/Task/Happy-numbers/MUMPS/happy-numbers.mumps new file mode 100644 index 0000000000..d778649b2f --- /dev/null +++ b/Task/Happy-numbers/MUMPS/happy-numbers.mumps @@ -0,0 +1,24 @@ +ISHAPPY(N) + ;Determines if a number N is a happy number + ;Note that the returned strings do not have a leading digit unless it is a happy number + IF (N'=N\1)!(N<0) QUIT "Not a positive integer" + NEW SUM,I + ;SUM is the sum of the square of each digit + ;I is a loop variable + ;SEQ is the sequence of previously checked SUMs from the original N + ;If it isn't set already, initialize it to an empty string + IF $DATA(SEQ)=0 NEW SEQ SET SEQ="" + SET SUM=0 + FOR I=1:1:$LENGTH(N) DO + .SET SUM=SUM+($EXTRACT(N,I)*$EXTRACT(N,I)) + QUIT:(SUM=1) SUM + QUIT:$FIND(SEQ,SUM)>1 "Part of a sequence not containing 1" + SET SEQ=SEQ_","_SUM + QUIT $$ISHAPPY(SUM) +HAPPY(C) ;Finds the first C happy numbers + NEW I + ;I is a counter for what integer we're looking at + WRITE !,"The first "_C_" happy numbers are:" + FOR I=1:1 QUIT:C<1 SET Q=+$$ISHAPPY(I) WRITE:Q !,I SET:Q C=C-1 + KILL I + QUIT diff --git a/Task/Happy-numbers/Maple/happy-numbers-1.maple b/Task/Happy-numbers/Maple/happy-numbers-1.maple new file mode 100644 index 0000000000..b64c9f30fd --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-1.maple @@ -0,0 +1,8 @@ +SumSqDigits := proc( n :: posint ) + local s := 0; + local m := n; + while m <> 0 do + s := s + irem( m, 10, 'm' )^2 + end do; + s +end proc: diff --git a/Task/Happy-numbers/Maple/happy-numbers-2.maple b/Task/Happy-numbers/Maple/happy-numbers-2.maple new file mode 100644 index 0000000000..440072aa5a --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-2.maple @@ -0,0 +1,2 @@ +> SumSqDigits( 1234567890987654321 ); + 570 diff --git a/Task/Happy-numbers/Maple/happy-numbers-3.maple b/Task/Happy-numbers/Maple/happy-numbers-3.maple new file mode 100644 index 0000000000..35f92488f5 --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-3.maple @@ -0,0 +1,3 @@ +> n := 1234567890987654321: +> `+`( op( map( parse, StringTools:-Explode( convert( n, 'string' ) ) )^~2) ); + 570 diff --git a/Task/Happy-numbers/Maple/happy-numbers-4.maple b/Task/Happy-numbers/Maple/happy-numbers-4.maple new file mode 100644 index 0000000000..f7dd80c7f9 --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-4.maple @@ -0,0 +1,13 @@ +Happy? := proc( n ) + if n = 1 then + true + elif n = 4 then + false + else + local s := SumSqDigits( n ); + while not ( s in { 1, 4 } ) do + s := SumSqDigits( s ) + end do; + evalb( s = 1 ) + end if +end proc: diff --git a/Task/Happy-numbers/Maple/happy-numbers-5.maple b/Task/Happy-numbers/Maple/happy-numbers-5.maple new file mode 100644 index 0000000000..da3e191df0 --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-5.maple @@ -0,0 +1,3 @@ +> H, S := selectremove( Happy?, [seq]( 1 .. N ) ): +> nops( H ), nops( S ); + 143071, 856929 diff --git a/Task/Happy-numbers/Maple/happy-numbers-6.maple b/Task/Happy-numbers/Maple/happy-numbers-6.maple new file mode 100644 index 0000000000..bff486eb76 --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-6.maple @@ -0,0 +1,11 @@ +FindHappiness := proc( N ) + local count := 0; + local T := table(); + for local i while count < N do + if Happy?( i ) then + count := 1 + count; + T[ count ] := i + end if + end do; + {seq}( T[ i ], i = 1 .. count ) +end proc: diff --git a/Task/Happy-numbers/Maple/happy-numbers-7.maple b/Task/Happy-numbers/Maple/happy-numbers-7.maple new file mode 100644 index 0000000000..54ef3164b5 --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-7.maple @@ -0,0 +1,2 @@ +> FindHappiness( 8 ); + {1, 7, 10, 13, 19, 23, 28, 31} diff --git a/Task/Happy-numbers/Maple/happy-numbers-8.maple b/Task/Happy-numbers/Maple/happy-numbers-8.maple new file mode 100644 index 0000000000..6aa3511fdb --- /dev/null +++ b/Task/Happy-numbers/Maple/happy-numbers-8.maple @@ -0,0 +1,9 @@ +Happy? := proc( n :: posint ) + local a, b; + a, b := n, SumSqDigits( n ); + while a <> b do + a := SumSqDigits( a ); + b := (SumSqDigits@@2)( b ) + end do; + evalb( a = 1 ) +end proc: diff --git a/Task/Happy-numbers/Mathematica/happy-numbers-1.mathematica b/Task/Happy-numbers/Mathematica/happy-numbers-1.mathematica new file mode 100644 index 0000000000..3761d94a33 --- /dev/null +++ b/Task/Happy-numbers/Mathematica/happy-numbers-1.mathematica @@ -0,0 +1,3 @@ +AddSumSquare[input_]:=Append[input,Total[IntegerDigits[Last[input]]^2]] +NestUntilRepeat[a_,f_]:=NestWhile[f,{a},!MemberQ[Most[Last[{##}]],Last[Last[{##}]]]&,All] +HappyQ[a_]:=Last[NestUntilRepeat[a,AddSumSquare]]==1 diff --git a/Task/Happy-numbers/Mathematica/happy-numbers-2.mathematica b/Task/Happy-numbers/Mathematica/happy-numbers-2.mathematica new file mode 100644 index 0000000000..c267337d5e --- /dev/null +++ b/Task/Happy-numbers/Mathematica/happy-numbers-2.mathematica @@ -0,0 +1,2 @@ +HappyQ[1337] +HappyQ[137] diff --git a/Task/Happy-numbers/Mathematica/happy-numbers-3.mathematica b/Task/Happy-numbers/Mathematica/happy-numbers-3.mathematica new file mode 100644 index 0000000000..1cc8b5e10d --- /dev/null +++ b/Task/Happy-numbers/Mathematica/happy-numbers-3.mathematica @@ -0,0 +1,2 @@ +True +False diff --git a/Task/Happy-numbers/Mathematica/happy-numbers-4.mathematica b/Task/Happy-numbers/Mathematica/happy-numbers-4.mathematica new file mode 100644 index 0000000000..287ffc85ae --- /dev/null +++ b/Task/Happy-numbers/Mathematica/happy-numbers-4.mathematica @@ -0,0 +1,12 @@ +m = 8; +n = 1; +i = 0; +happynumbers = {}; +While[n <= m, + i++; + If[HappyQ[i], + n++; + AppendTo[happynumbers, i] + ] + ] +happynumbers diff --git a/Task/Happy-numbers/Mathematica/happy-numbers-5.mathematica b/Task/Happy-numbers/Mathematica/happy-numbers-5.mathematica new file mode 100644 index 0000000000..9fce257307 --- /dev/null +++ b/Task/Happy-numbers/Mathematica/happy-numbers-5.mathematica @@ -0,0 +1 @@ +{1, 7, 10, 13, 19, 23, 28, 31} diff --git a/Task/Happy-numbers/PHP/happy-numbers.php b/Task/Happy-numbers/PHP/happy-numbers.php new file mode 100644 index 0000000000..6f35c338d3 --- /dev/null +++ b/Task/Happy-numbers/PHP/happy-numbers.php @@ -0,0 +1,24 @@ +function isHappy($n) { + while (1) { + $total = 0; + while ($n > 0) { + $total += pow(($n % 10), 2); + $n /= 10; + } + if ($total == 1) + return true; + if (array_key_exists($total, $past)) + return false; + $n = $total; + $past[$total] = 0; + } +} + +$i = $cnt = 0; +while ($cnt < 8) { + if (isHappy($i)) { + echo "$i "; + $cnt++; + } + $i++; +} diff --git a/Task/Happy-numbers/Perl/happy-numbers.pl b/Task/Happy-numbers/Perl/happy-numbers.pl new file mode 100644 index 0000000000..00663c1605 --- /dev/null +++ b/Task/Happy-numbers/Perl/happy-numbers.pl @@ -0,0 +1,11 @@ +use List::Util qw(sum); + +sub is_happy ($) + {for (my ($n, %seen) = shift ;; $n = sum map {$_**2} split //, $n) + {$n == 1 and return 1; + $seen{$n}++ and return 0;}} + +for (my ($n, $happy) = (1, 0) ; $happy < 8 ; ++$n) + {is_happy $n or next; + print "$n\n"; + ++$happy;} diff --git a/Task/Happy-numbers/PicoLisp/happy-numbers.l b/Task/Happy-numbers/PicoLisp/happy-numbers.l new file mode 100644 index 0000000000..87a0a205c2 --- /dev/null +++ b/Task/Happy-numbers/PicoLisp/happy-numbers.l @@ -0,0 +1,13 @@ +(de happy? (N) + (let Seen NIL + (loop + (T (= N 1) T) + (T (member N Seen)) + (setq N + (sum '((C) (** (format C) 2)) + (chop (push 'Seen N)) ) ) ) ) ) + +(let H 0 + (do 8 + (until (happy? (inc 'H))) + (printsp H) ) ) diff --git a/Task/Happy-numbers/Prolog/happy-numbers-1.pro b/Task/Happy-numbers/Prolog/happy-numbers-1.pro new file mode 100644 index 0000000000..40b9ee7db5 --- /dev/null +++ b/Task/Happy-numbers/Prolog/happy-numbers-1.pro @@ -0,0 +1,47 @@ +happy_numbers(L, Nb) :- + % creation of the list + length(L, Nb), + % Process of this list + get_happy_number(L, 1). + + +% the game is over +get_happy_number([], _). + +% querying the newt happy_number +get_happy_number([H | T], N) :- + N1 is N+1, + (is_happy_number(N) -> + H = N, + get_happy_number(T, N1); + get_happy_number([H | T], N1)). + +% we must memorized the numbers reached +is_happy_number(N) :- + is_happy_number(N, [N]). + +% a number is happy when we get 1 +is_happy_number(N, _L) :- + get_next_number(N, 1), !. + +% or when this number is not already reached ! +is_happy_number(N, L) :- + get_next_number(N, NN), + \+member(NN, L), + is_happy_number(NN, [NN | L]). + +% Process of the next number from N +get_next_number(N, NewN) :- + get_list_digits(N, LD), + maplist(square, LD, L), + sumlist(L, NewN). + +get_list_digits(N, LD) :- + number_chars(N, LCD), + maplist(number_chars_, LD, LCD). + +number_chars_(D, CD) :- + number_chars(D, [CD]). + +square(N, SN) :- + SN is N * N. diff --git a/Task/Happy-numbers/Prolog/happy-numbers-2.pro b/Task/Happy-numbers/Prolog/happy-numbers-2.pro new file mode 100644 index 0000000000..4f9943da6f --- /dev/null +++ b/Task/Happy-numbers/Prolog/happy-numbers-2.pro @@ -0,0 +1,2 @@ + ?- happy_numbers(L, 8). +L = [1,7,10,13,19,23,28,31]. diff --git a/Task/Happy-numbers/Python/happy-numbers.py b/Task/Happy-numbers/Python/happy-numbers.py new file mode 100644 index 0000000000..75f7e26f5e --- /dev/null +++ b/Task/Happy-numbers/Python/happy-numbers.py @@ -0,0 +1,11 @@ +>>> def happy(n): + past = set() + while n <> 1: + n = sum(int(i)**2 for i in str(n)) + if n in past: + return False + past.add(n) + return True + +>>> [x for x in xrange(500) if happy(x)][:8] +[1, 7, 10, 13, 19, 23, 28, 31] diff --git a/Task/Happy-numbers/R/happy-numbers-1.r b/Task/Happy-numbers/R/happy-numbers-1.r new file mode 100644 index 0000000000..d1160e385e --- /dev/null +++ b/Task/Happy-numbers/R/happy-numbers-1.r @@ -0,0 +1,29 @@ +is.happy <- function(n) +{ + stopifnot(is.numeric(n) && length(n)==1) + getdigits <- function(n) + { + as.integer(unlist(strsplit(as.character(n), ""))) + } + digits <- getdigits(n) + previous <- c() + repeat + { + sumsq <- sum(digits^2, na.rm=TRUE) + if(sumsq==1L) + { + happy <- TRUE + break + } else if(sumsq %in% previous) + { + happy <- FALSE + attr(happy, "cycle") <- previous + break + } else + { + previous <- c(previous, sumsq) + digits <- getdigits(sumsq) + } + } + happy +} diff --git a/Task/Happy-numbers/R/happy-numbers-2.r b/Task/Happy-numbers/R/happy-numbers-2.r new file mode 100644 index 0000000000..72e56bea56 --- /dev/null +++ b/Task/Happy-numbers/R/happy-numbers-2.r @@ -0,0 +1 @@ +is.happy(2) diff --git a/Task/Happy-numbers/R/happy-numbers-3.r b/Task/Happy-numbers/R/happy-numbers-3.r new file mode 100644 index 0000000000..ff5df6f727 --- /dev/null +++ b/Task/Happy-numbers/R/happy-numbers-3.r @@ -0,0 +1,2 @@ +#Find happy numbers between 1 and 50 +which(apply(rbind(1:50), 2, is.happy)) diff --git a/Task/Happy-numbers/R/happy-numbers-4.r b/Task/Happy-numbers/R/happy-numbers-4.r new file mode 100644 index 0000000000..f9138665bf --- /dev/null +++ b/Task/Happy-numbers/R/happy-numbers-4.r @@ -0,0 +1,9 @@ +#Find the first 8 happy numbers +happies <- c() +i <- 1L +while(length(happies) < 8L) +{ + if(is.happy(i)) happies <- c(happies, i) + i <- i + 1L +} +happies diff --git a/Task/Happy-numbers/REXX/happy-numbers-1.rexx b/Task/Happy-numbers/REXX/happy-numbers-1.rexx new file mode 100644 index 0000000000..5eaa968e55 --- /dev/null +++ b/Task/Happy-numbers/REXX/happy-numbers-1.rexx @@ -0,0 +1,19 @@ +/*REXX program displays eight (or a specified limit) happy numbers. */ +parse arg limit . /*get optional argument LIMIT. */ +if limit=='' | limit==',' then limit=8 /*Not specified? Set LIMIT to 8.*/ +haps=0 /*count of happy numbers so far. */ + + do n=1 while hapssw then do /*maybe display the happy number.*/ + say strip(out) /*line is too long, tell it*/ + out= /*nullify the OUT (line).*/ + end + out=out n /*append the happy number to OUT.*/ + end /*n*/ + +if out\=='' then say strip(out) /*handle any residuals for OUT. */ + /*stick a fork in it, we're done.*/ diff --git a/Task/Happy-numbers/Ruby/happy-numbers-1.rb b/Task/Happy-numbers/Ruby/happy-numbers-1.rb new file mode 100644 index 0000000000..f20cbd1a28 --- /dev/null +++ b/Task/Happy-numbers/Ruby/happy-numbers-1.rb @@ -0,0 +1,19 @@ +require 'set' # Set: Fast array lookup / Simple existence hash + +@seen_numbers = Set.new +@happy_numbers = Set.new + +def happy?(n) + return true if n == 1 # Base case + return @happy_numbers.include?(n) if @seen_numbers.include?(n) # Use performance cache, and stop unhappy cycles + + @seen_numbers << n + digit_squared_sum = n.to_s.each_char.inject(0) { |sum, c| sum + c.to_i**2 } # In Rails: n.to_s.each_char.sum { c.to_i**2 } + + if happy?(digit_squared_sum) + @happy_numbers << n + true # Return true + else + false # Return false + end +end diff --git a/Task/Happy-numbers/Ruby/happy-numbers-2.rb b/Task/Happy-numbers/Ruby/happy-numbers-2.rb new file mode 100644 index 0000000000..80bdddf1df --- /dev/null +++ b/Task/Happy-numbers/Ruby/happy-numbers-2.rb @@ -0,0 +1,10 @@ +def print_happy + happy_numbers = [] + + (1..Float::INFINITY).each do |i| + break if happy_numbers.length >= 8 + happy_numbers << i if happy?(i) + end + + p happy_numbers +end diff --git a/Task/Happy-numbers/Ruby/happy-numbers-3.rb b/Task/Happy-numbers/Ruby/happy-numbers-3.rb new file mode 100644 index 0000000000..5800fcce68 --- /dev/null +++ b/Task/Happy-numbers/Ruby/happy-numbers-3.rb @@ -0,0 +1 @@ +[1, 7, 10, 13, 19, 23, 28, 31] diff --git a/Task/Happy-numbers/Scala/happy-numbers.scala b/Task/Happy-numbers/Scala/happy-numbers.scala new file mode 100644 index 0000000000..e3f87dbace --- /dev/null +++ b/Task/Happy-numbers/Scala/happy-numbers.scala @@ -0,0 +1,24 @@ +scala> def isHappy(n: Int) = { + | new Iterator[Int] { + | val seen = scala.collection.mutable.Set[Int]() + | var curr = n + | def next = { + | val res = curr + | curr = res.toString.map(_.asDigit).map(n => n * n).sum + | seen += res + | res + | } + | def hasNext = !seen.contains(curr) + | }.toList.last == 1 + | } +isHappy: (n: Int)Boolean + +scala> Iterator from 1 filter isHappy take 8 foreach println +1 +7 +10 +13 +19 +23 +28 +31 diff --git a/Task/Happy-numbers/Scheme/happy-numbers.ss b/Task/Happy-numbers/Scheme/happy-numbers.ss new file mode 100644 index 0000000000..0a6f3e7306 --- /dev/null +++ b/Task/Happy-numbers/Scheme/happy-numbers.ss @@ -0,0 +1,17 @@ +(define (number->list num) + (do ((num num (quotient num 10)) + (lst '() (cons (remainder num 10) lst))) + ((zero? num) lst))) + +(define (happy? num) + (let loop ((num num) (seen '())) + (cond ((= num 1) #t) + ((memv num seen) #f) + (else (loop (apply + (map (lambda (x) (* x x)) (number->list num))) + (cons num seen)))))) + +(display "happy numbers:") +(let loop ((n 1) (more 8)) + (cond ((= more 0) (newline)) + ((happy? n) (display " ") (display n) (loop (+ n 1) (- more 1))) + (else (loop (+ n 1) more)))) diff --git a/Task/Happy-numbers/Smalltalk/happy-numbers-1.st b/Task/Happy-numbers/Smalltalk/happy-numbers-1.st new file mode 100644 index 0000000000..76d73510c3 --- /dev/null +++ b/Task/Happy-numbers/Smalltalk/happy-numbers-1.st @@ -0,0 +1,63 @@ +Object subclass: HappyNumber [ + |cache negativeCache| + HappyNumber class >> new [ |me| + me := super new. + ^ me init + ] + init [ cache := Set new. negativeCache := Set new. ] + + hasSad: aNum [ + ^ (negativeCache includes: (self recycle: aNum)) + ] + hasHappy: aNum [ + ^ (cache includes: (self recycle: aNum)) + ] + addHappy: aNum [ + cache add: (self recycle: aNum) + ] + addSad: aNum [ + negativeCache add: (self recycle: aNum) + ] + + recycle: aNum [ |r n| r := Bag new. + n := aNum. + [ n > 0 ] + whileTrue: [ |d| + d := n rem: 10. + r add: d. + n := n // 10. + ]. + ^r + ] + + isHappy: aNumber [ |cycle number newnumber| + number := aNumber. + cycle := Set new. + [ (number ~= 1) & ( (cycle includes: number) not ) ] + whileTrue: [ + (self hasHappy: number) + ifTrue: [ ^true ] + ifFalse: [ + (self hasSad: number) ifTrue: [ ^false ]. + cycle add: number. + newnumber := 0. + [ number > 0 ] + whileTrue: [ |digit| + digit := number rem: 10. + newnumber := newnumber + (digit * digit). + number := (number - digit) // 10. + ]. + number := newnumber. + ] + ]. + (number = 1) + ifTrue: [ + cycle do: [ :e | self addHappy: e ]. + ^true + ] + ifFalse: [ + cycle do: [ :e | self addSad: e ]. + ^false + ] + ] +]. diff --git a/Task/Happy-numbers/Smalltalk/happy-numbers-2.st b/Task/Happy-numbers/Smalltalk/happy-numbers-2.st new file mode 100644 index 0000000000..30e232c4c5 --- /dev/null +++ b/Task/Happy-numbers/Smalltalk/happy-numbers-2.st @@ -0,0 +1,7 @@ +|happy| +happy := HappyNumber new. + +1 to: 31 do: [ :i | + (happy isHappy: i) + ifTrue: [ i displayNl ] +]. diff --git a/Task/Happy-numbers/Smalltalk/happy-numbers-3.st b/Task/Happy-numbers/Smalltalk/happy-numbers-3.st new file mode 100644 index 0000000000..bafa0d6256 --- /dev/null +++ b/Task/Happy-numbers/Smalltalk/happy-numbers-3.st @@ -0,0 +1,25 @@ +|next isHappy happyNumbers| + +next := + [:n | + (n printString collect:[:ch | ch digitValue squared] as:Array) sum + ]. + +isHappy := + [:n | | t already | + already := Set new. + t := n. + [ t == 1 or:[ (already includes:t)]] whileFalse:[ + already add:t. + t := next value:t. + ]. + t == 1 + ]. + +happyNumbers := OrderedCollection new. +try := 1. +[happyNumbers size < 8] whileTrue:[ + (isHappy value:try) ifTrue:[ happyNumbers add:try]. + try := try + 1 +]. +happyNumbers printCR diff --git a/Task/Happy-numbers/Tcl/happy-numbers.tcl b/Task/Happy-numbers/Tcl/happy-numbers.tcl new file mode 100644 index 0000000000..a87a391074 --- /dev/null +++ b/Task/Happy-numbers/Tcl/happy-numbers.tcl @@ -0,0 +1,16 @@ +proc is_happy n { + set seen [list] + while {$n > 1 && [lsearch -exact $seen $n] == -1} { + lappend seen $n + set n [sum_of_squares [split $n ""]] + } + return [expr {$n == 1}] +} + +set happy [list] +set n -1 +while {[llength $happy] < 8} { + if {[is_happy $n]} {lappend happy $n} + incr n +} +puts "the first 8 happy numbers are: [list $happy]" diff --git a/Task/Harshad-or-Niven-series/0DESCRIPTION b/Task/Harshad-or-Niven-series/0DESCRIPTION new file mode 100644 index 0000000000..eed905856d --- /dev/null +++ b/Task/Harshad-or-Niven-series/0DESCRIPTION @@ -0,0 +1,5 @@ +The [http://mathworld.wolfram.com/HarshadNumber.html Harshad] or Niven numbers are positive integers >= 1 that are divisible by the sum of their digits. For example, 42 is a [[oeis:A005349|Harshad number]] as 42 is divisible by (4+2) without remainder. +Assume that the series is defined as the numbers in increasing order. + +The task is to create a function/method/procedure to generate successive members of the Harshad sequence. Use it to list the first twenty members of the sequence and list the first Harshad number greater than 1000. +Show your output here. diff --git a/Task/Harshad-or-Niven-series/C/harshad-or-niven-series.c b/Task/Harshad-or-Niven-series/C/harshad-or-niven-series.c new file mode 100644 index 0000000000..39aedc1173 --- /dev/null +++ b/Task/Harshad-or-Niven-series/C/harshad-or-niven-series.c @@ -0,0 +1,22 @@ +#include + +static int digsum(int n) +{ + int sum = 0; + do { sum += n % 10; } while (n /= 10); + return sum; +} + +int main(void) +{ + int n, done, found; + + for (n = 1, done = found = 0; !done; ++n) { + if (n % digsum(n) == 0) { + if (found++ < 20) printf("%d ", n); + if (n > 1000) done = printf("\n%d\n", n); + } + } + + return 0; +} diff --git a/Task/Harshad-or-Niven-series/Clojure/harshad-or-niven-series.clj b/Task/Harshad-or-Niven-series/Clojure/harshad-or-niven-series.clj new file mode 100644 index 0000000000..7b41325e6d --- /dev/null +++ b/Task/Harshad-or-Niven-series/Clojure/harshad-or-niven-series.clj @@ -0,0 +1,9 @@ +(defn digsum [n acc] + (if (zero? n) acc + (digsum (quot n 10) (+ acc (mod n 10))))) + +(let [harshads (filter + #(zero? (mod % (digsum % 0))) + (iterate inc 1))] + (prn (take 20 harshads)) + (prn (first (filter #(> % 1000) harshads)))) diff --git a/Task/Harshad-or-Niven-series/D/harshad-or-niven-series.d b/Task/Harshad-or-Niven-series/D/harshad-or-niven-series.d new file mode 100644 index 0000000000..642b3c9a9b --- /dev/null +++ b/Task/Harshad-or-Niven-series/D/harshad-or-niven-series.d @@ -0,0 +1,9 @@ +import std.stdio, std.algorithm, std.range, std.conv; + +void main() { + auto digsum = (int n) => n.text.map!q{a - '0'}.reduce!q{a + b}; + auto harshads = iota(1, int.max).filter!(n => n % digsum(n) == 0); + + harshads.take(20).writeln; + harshads.filter!q{ a > 1000 }.front.writeln; +} diff --git a/Task/Harshad-or-Niven-series/Haskell/harshad-or-niven-series.hs b/Task/Harshad-or-Niven-series/Haskell/harshad-or-niven-series.hs new file mode 100644 index 0000000000..e9c1aaee1c --- /dev/null +++ b/Task/Harshad-or-Niven-series/Haskell/harshad-or-niven-series.hs @@ -0,0 +1,6 @@ +import Data.Char (ord) + +main = do print $ take 20 harshads + print $ head $ filter (> 1000) harshads + where digsum = sum . map ((48 -) . ord) . show + harshads = filter (\n -> mod n (digsum n) == 0) [1..] diff --git a/Task/Harshad-or-Niven-series/Java/harshad-or-niven-series.java b/Task/Harshad-or-Niven-series/Java/harshad-or-niven-series.java new file mode 100644 index 0000000000..caee3cf47c --- /dev/null +++ b/Task/Harshad-or-Niven-series/Java/harshad-or-niven-series.java @@ -0,0 +1,24 @@ +public class Harshad{ + private static long sumDigits(long n){ + long sum = 0; + for(char digit:Long.toString(n).toCharArray()){ + sum += Character.digit(digit, 10); + } + return sum; + } + public static void main(String[] args){ + for(int count = 0, i = 1; count < 20;i++){ + if(i % sumDigits(i) == 0){ + System.out.println(i); + count++; + } + } + System.out.println(); + for(int i = 1001; ; i++){ + if(i % sumDigits(i) == 0){ + System.out.println(i); + break; + } + } + } +} diff --git a/Task/Harshad-or-Niven-series/Julia/harshad-or-niven-series.julia b/Task/Harshad-or-Niven-series/Julia/harshad-or-niven-series.julia new file mode 100644 index 0000000000..a5f314f01b --- /dev/null +++ b/Task/Harshad-or-Niven-series/Julia/harshad-or-niven-series.julia @@ -0,0 +1,10 @@ +isharshad(x) = x % sum([int(string(i)) for i in string(x)]) == 0 +function harshads(n) + h = ref(Int) + i = 1 + while length(h) < n + isharshad(i) && push!(h,i) + i+=1 + end + return h +end diff --git a/Task/Harshad-or-Niven-series/LOLCODE/harshad-or-niven-series.lol b/Task/Harshad-or-Niven-series/LOLCODE/harshad-or-niven-series.lol new file mode 100644 index 0000000000..499a6ce4a4 --- /dev/null +++ b/Task/Harshad-or-Niven-series/LOLCODE/harshad-or-niven-series.lol @@ -0,0 +1,35 @@ +HAI 1.3 + +HOW IZ I digsummin YR num + I HAS A digsum ITZ 0 + IM IN YR loop + num, O RLY? + YA RLY + digsum R SUM OF digsum AN MOD OF num AN 10 + num R QUOSHUNT OF num AN 10 + NO WAI, FOUND YR digsum + OIC + IM OUTTA YR loop +IF U SAY SO + +I HAS A found ITZ 0 + +IM IN YR finder UPPIN YR n + I HAS A n ITZ SUM OF n AN 1 + I HAS A digsum ITZ I IZ digsummin YR n MKAY + + NOT MOD OF n AN digsum, O RLY? + YA RLY + DIFFRINT found AN BIGGR OF found AN 20, O RLY? + YA RLY + VISIBLE n " "! + found R SUM OF found AN 1 + OIC + + DIFFRINT n AN SMALLR OF n AN 1000, O RLY? + YA RLY, VISIBLE ":)" n, GTFO + OIC + OIC +IM OUTTA YR finder + +KTHXBYE diff --git a/Task/Harshad-or-Niven-series/Perl/harshad-or-niven-series.pl b/Task/Harshad-or-Niven-series/Perl/harshad-or-niven-series.pl new file mode 100644 index 0000000000..bc663dbfd5 --- /dev/null +++ b/Task/Harshad-or-Niven-series/Perl/harshad-or-niven-series.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +use strict ; +use warnings ; +use List::Util qw ( sum ) ; + +sub createHarshads { + my @harshads ; + my $number = 1 ; + do { + if ( $number % sum ( split ( // , $number ) ) == 0 ) { + push @harshads , $number ; + } + $number++ ; + } until ( $harshads[ -1 ] > 1000 ) ; + return @harshads ; +} +my @harshadnumbers = createHarshads ; +for my $i ( 0..19 ) { + print "$harshadnumbers[ $i ]\n" ; +} +print "The first Harshad number greater than 1000 is $harshadnumbers[ -1 ]!\n" ; diff --git a/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-1.py b/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-1.py new file mode 100644 index 0000000000..57ad89c576 --- /dev/null +++ b/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-1.py @@ -0,0 +1,17 @@ +>>> import itertools +>>> def harshad(): + for n in itertools.count(1): + if n % sum(int(ch) for ch in str(n)) == 0: + yield n + + +>>> list(itertools.islice(harshad(), 0, 20)) +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42] +>>> for n in harshad(): + if n > 1000: + print(n) + break + + +1002 +>>> diff --git a/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-2.py b/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-2.py new file mode 100644 index 0000000000..20d64ccf2d --- /dev/null +++ b/Task/Harshad-or-Niven-series/Python/harshad-or-niven-series-2.py @@ -0,0 +1,7 @@ +>>> from itertools import count, islice +>>> harshad = (n for n in count(1) if n % sum(int(ch) for ch in str(n)) == 0) +>>> list(islice(harshad, 0, 20)) +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42] +>>> next(x for x in harshad if x > 1000) +1002 +>>> diff --git a/Task/Harshad-or-Niven-series/REXX/harshad-or-niven-series.rexx b/Task/Harshad-or-Niven-series/REXX/harshad-or-niven-series.rexx new file mode 100644 index 0000000000..3b653f9ae4 --- /dev/null +++ b/Task/Harshad-or-Niven-series/REXX/harshad-or-niven-series.rexx @@ -0,0 +1,24 @@ +/*REXX program finds first X Niven numbers; also first Niven number > Y.*/ +parse arg X Y . /*get optional argyuments: X Y */ +if X=='' then X=20 /*Not specified? Then use default*/ +if Y=='' then Y=1000 /*Not specified? Then use default*/ +#=0; $= /*Niven# count, Niven# list. */ + + do j=1 until #==X /*let's go Niven number hunting. */ + if j//sumDigs(j)\==0 then iterate /*Not a Niven number? Then skip.*/ + #=#+1; $=$ j /*bump Niven# count, add to list.*/ + end /*j*/ + +say 'first' X 'Niven numbers:' $ + + do t=1 /*let's go Niven number searching*/ + if t//sumDigs(t)\==0 then iterate /*Not a Niven number? Then skip.*/ + if t>Y then leave /*if too low, then keep searching*/ + end /*t*/ + +say 'first Niven number >' Y " is: " t +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SUMDIGS subroutine──────────────────*/ +sumDigs: procedure; parse arg ?; sum = left(?,1) + do k=2 to length(?); sum = sum+substr(?,k,1); end /*k*/ +return sum diff --git a/Task/Harshad-or-Niven-series/Racket/harshad-or-niven-series.rkt b/Task/Harshad-or-Niven-series/Racket/harshad-or-niven-series.rkt new file mode 100644 index 0000000000..1ca387eb89 --- /dev/null +++ b/Task/Harshad-or-Niven-series/Racket/harshad-or-niven-series.rkt @@ -0,0 +1,20 @@ +#lang racket +(require math/number-theory) +(define (digital-sum n) + (let inner + ((n n) (s 0)) + (if (zero? n) s + (let-values ([(q r) (quotient/remainder n 10)]) + (inner q (+ s r)))))) + +(define (harshad-number? n) + (and (>= n 1) + (divides? (digital-sum n) n))) + +;; find 1st 20 Harshad numbers +(for ((i (in-range 1 (add1 20))) + (h (sequence-filter harshad-number? (in-naturals 1)))) + (printf "#~a ~a~%" i h)) + +;; find 1st Harshad number > 1000 +(displayln (for/first ((h (sequence-filter harshad-number? (in-naturals 1001)))) h)) diff --git a/Task/Harshad-or-Niven-series/Ruby/harshad-or-niven-series.rb b/Task/Harshad-or-Niven-series/Ruby/harshad-or-niven-series.rb new file mode 100644 index 0000000000..1e783f49b3 --- /dev/null +++ b/Task/Harshad-or-Niven-series/Ruby/harshad-or-niven-series.rb @@ -0,0 +1,8 @@ +def digsum n + n.to_s.chars.map(&:to_i).reduce(:+) +end + +harshad = (1..Float::INFINITY).lazy.select { |n| n % digsum(n) == 0 } + +p harshad.take(20).to_a +p harshad.find { |n| n > 1000 } diff --git a/Task/Harshad-or-Niven-series/Scheme/harshad-or-niven-series.ss b/Task/Harshad-or-Niven-series/Scheme/harshad-or-niven-series.ss new file mode 100644 index 0000000000..7b6d2d48be --- /dev/null +++ b/Task/Harshad-or-Niven-series/Scheme/harshad-or-niven-series.ss @@ -0,0 +1,24 @@ +#!/usr/local/bin/gosh + +;; Show the first 20 niven numbers and the +;; first one greater than 1000. +(define (main args) + (display (iota-filtered 20 1 niven?))(newline) + (display (iota-filtered 1 1001 niven?))(newline)) + +;; Return a list of length n +;; for numbers starting at start +;; that satisfy the predicate fn. +(define (iota-filtered n start fn) + (let loop ((num start)(lst (list))) + (if (= (length lst) n) + lst + (loop (+ 1 num) (if (fn num) (append lst (list num)) lst))))) + +;; Is a number a niven number? +(define (niven? n) + (and (> n 0) (= 0 (remainder n (sum-of-digits n))))) + +;; Get the sum of the digits of a number. +(define (sum-of-digits n) + (apply + (map string->number (map string (string->list (number->string n)))))) diff --git a/Task/Harshad-or-Niven-series/Tcl/harshad-or-niven-series.tcl b/Task/Harshad-or-Niven-series/Tcl/harshad-or-niven-series.tcl new file mode 100644 index 0000000000..8fabd0765f --- /dev/null +++ b/Task/Harshad-or-Niven-series/Tcl/harshad-or-niven-series.tcl @@ -0,0 +1,18 @@ +# Determine if the given number is a member of the class of Harshad numbers +proc isHarshad {n} { + if {$n < 1} {return false} + set sum [tcl::mathop::+ {*}[split $n ""]] + return [expr {$n%$sum == 0}] +} + +# Get the first 20 numbers that satisfy the condition +for {set n 1; set harshads {}} {[llength $harshads] < 20} {incr n} { + if {[isHarshad $n]} { + lappend harshads $n + } +} +puts [format "First twenty Harshads: %s" [join $harshads ", "]] + +# Get the first value greater than 1000 that satisfies the condition +for {set n 1000} {![isHarshad [incr n]]} {} {} +puts "First Harshad > 1000 = $n" diff --git a/Task/Hash-from-two-arrays/0DESCRIPTION b/Task/Hash-from-two-arrays/0DESCRIPTION new file mode 100644 index 0000000000..06b6894591 --- /dev/null +++ b/Task/Hash-from-two-arrays/0DESCRIPTION @@ -0,0 +1,3 @@ +Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) + +Related task: [[Associative arrays/Creation]] diff --git a/Task/Hash-from-two-arrays/1META.yaml b/Task/Hash-from-two-arrays/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Hash-from-two-arrays/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Hash-from-two-arrays/AWK/hash-from-two-arrays.awk b/Task/Hash-from-two-arrays/AWK/hash-from-two-arrays.awk new file mode 100644 index 0000000000..95d0b8b809 --- /dev/null +++ b/Task/Hash-from-two-arrays/AWK/hash-from-two-arrays.awk @@ -0,0 +1,8 @@ +$ awk 'BEGIN{split("one two three",a); + split("1 2 3",b); + for(i=1;i in a;i++){c[a[i]]=b[i]}; + for(i in c)print i,c[i] + }' +three 3 +two 2 +one 1 diff --git a/Task/Hash-from-two-arrays/ActionScript/hash-from-two-arrays.as b/Task/Hash-from-two-arrays/ActionScript/hash-from-two-arrays.as new file mode 100644 index 0000000000..9e9ad725e2 --- /dev/null +++ b/Task/Hash-from-two-arrays/ActionScript/hash-from-two-arrays.as @@ -0,0 +1,15 @@ +package +{ + public class MyClass + { + public static function main():Void + { + var hash:Object = new Object(); + var keys:Array = new Array("a", "b", "c"); + var values:Array = new Array(1, 2, 3); + + for (var i:int = 0; i < keys.length(); i++) + hash[keys[i]] = values[i]; + } + } +} diff --git a/Task/Hash-from-two-arrays/Ada/hash-from-two-arrays.ada b/Task/Hash-from-two-arrays/Ada/hash-from-two-arrays.ada new file mode 100644 index 0000000000..49eef2409e --- /dev/null +++ b/Task/Hash-from-two-arrays/Ada/hash-from-two-arrays.ada @@ -0,0 +1,43 @@ +with Ada.Strings.Hash; +with Ada.Containers.Hashed_Maps; +with Ada.Text_Io; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; + +procedure Hash_Map_Test is + function Equivalent_Key (Left, Right : Unbounded_String) return Boolean is + begin + return Left = Right; + end Equivalent_Key; + + function Hash_Func(Key : Unbounded_String) return Ada.Containers.Hash_Type is + begin + return Ada.Strings.Hash(To_String(Key)); + end Hash_Func; + + package My_Hash is new Ada.Containers.Hashed_Maps(Key_Type => Unbounded_String, + Element_Type => Unbounded_String, + Hash => Hash_Func, + Equivalent_Keys => Equivalent_Key); + + type String_Array is array(Positive range <>) of Unbounded_String; + + Hash : My_Hash.Map; + Key_List : String_Array := (To_Unbounded_String("foo"), + To_Unbounded_String("bar"), + To_Unbounded_String("val")); + + Element_List : String_Array := (To_Unbounded_String("little"), + To_Unbounded_String("miss"), + To_Unbounded_String("muffet")); + +begin + for I in Key_List'range loop + Hash.Insert(Key => (Key_List(I)), + New_Item => (Element_List(I))); + end loop; + for I in Key_List'range loop + Ada.Text_Io.Put_Line(To_String(Key_List(I)) & " => " & + To_String(Hash.Element(Key_List(I)))); + end loop; + +end Hash_Map_Test; diff --git a/Task/Hash-from-two-arrays/Argile/hash-from-two-arrays.argile b/Task/Hash-from-two-arrays/Argile/hash-from-two-arrays.argile new file mode 100644 index 0000000000..69352fb277 --- /dev/null +++ b/Task/Hash-from-two-arrays/Argile/hash-from-two-arrays.argile @@ -0,0 +1,8 @@ +use std, array, hash + +let keys = @["hexadecimal" "decimal" "octal" "binary"] +let values = @[0xa 11 014 0b1101] (: 10 11 12 13 :) +let hash = new hash of int +for each val int i from 0 to 3 + hash[keys[i]] = values[i] +del hash hash diff --git a/Task/Hash-from-two-arrays/AutoHotkey/hash-from-two-arrays.ahk b/Task/Hash-from-two-arrays/AutoHotkey/hash-from-two-arrays.ahk new file mode 100644 index 0000000000..73599a6560 --- /dev/null +++ b/Task/Hash-from-two-arrays/AutoHotkey/hash-from-two-arrays.ahk @@ -0,0 +1,6 @@ +array1 := ["two", "three", "apple"] +array2 := [2, 3, "fruit"] +hash := {} +Loop % array1.maxIndex() + hash[array1[A_Index]] := array2[A_Index] +MsgBox % hash["apple"] "`n" hash["two"] diff --git a/Task/Hash-from-two-arrays/BBC-BASIC/hash-from-two-arrays.bbc b/Task/Hash-from-two-arrays/BBC-BASIC/hash-from-two-arrays.bbc new file mode 100644 index 0000000000..727fddcf95 --- /dev/null +++ b/Task/Hash-from-two-arrays/BBC-BASIC/hash-from-two-arrays.bbc @@ -0,0 +1,20 @@ + DIM array1$(4) : array1$() = "0", "1", "2", "3", "4" + DIM array2$(4) : array2$() = "zero", "one", "two", "three", "four" + + FOR index% = 0 TO DIM(array1$(),1) + PROCputdict(mydict$, array2$(index%), array1$(index%)) + NEXT + PRINT FNgetdict(mydict$, "3") + END + + DEF PROCputdict(RETURN dict$, value$, key$) + IF dict$ = "" dict$ = CHR$(0) + dict$ += key$ + CHR$(1) + value$ + CHR$(0) + ENDPROC + + DEF FNgetdict(dict$, key$) + LOCAL I%, J% + I% = INSTR(dict$, CHR$(0) + key$ + CHR$(1)) + IF I% = 0 THEN = "" ELSE I% += LEN(key$) + 2 + J% = INSTR(dict$, CHR$(0), I%) + = MID$(dict$, I%, J% - I%) diff --git a/Task/Hash-from-two-arrays/Bracmat/hash-from-two-arrays.bracmat b/Task/Hash-from-two-arrays/Bracmat/hash-from-two-arrays.bracmat new file mode 100644 index 0000000000..a98a4482e1 --- /dev/null +++ b/Task/Hash-from-two-arrays/Bracmat/hash-from-two-arrays.bracmat @@ -0,0 +1,10 @@ + two three apple:?arr1 +& 2 3 fruit:?arr2 +& new$hash:?H +& whl + ' ( !arr1:%?k ?arr1 + & !arr2:%?v ?arr2 + & (H..insert)$(!k.!v) + ) +& (H..forall)$out +& ; diff --git a/Task/Hash-from-two-arrays/Brat/hash-from-two-arrays.brat b/Task/Hash-from-two-arrays/Brat/hash-from-two-arrays.brat new file mode 100644 index 0000000000..c2b44325ed --- /dev/null +++ b/Task/Hash-from-two-arrays/Brat/hash-from-two-arrays.brat @@ -0,0 +1,10 @@ +zip = { keys, values | + h = [:] + keys.each_with_index { key, index | + h[key] = values[index] + } + + h +} + +p zip [1 2 3] [:a :b :c] #Prints [1: a, 2: b, 3: c] diff --git a/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-1.cpp b/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-1.cpp new file mode 100644 index 0000000000..407cfdaa8b --- /dev/null +++ b/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-1.cpp @@ -0,0 +1,16 @@ +#include +#include + +int +main( int argc, char* argv[] ) +{ + std::string keys[] = { "1", "2", "3" } ; + std::string vals[] = { "a", "b", "c" } ; + + std::map< std::string, std::string > hash ; + + for( int i = 0 ; i < 3 ; i++ ) + { + hash[ keys[i] ] = vals[i] ; + } +} diff --git a/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-2.cpp b/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-2.cpp new file mode 100644 index 0000000000..2a0f0d0d04 --- /dev/null +++ b/Task/Hash-from-two-arrays/C++/hash-from-two-arrays-2.cpp @@ -0,0 +1,17 @@ +#include // for std::map +#include // for std::transform +#include // for std::string +#include // for std::make_pair + +int main() +{ + std::string keys[] = { "one", "two", "three" }; + std::string vals[] = { "foo", "bar", "baz" }; + + std::map hash; + + std::transform(keys, keys+3, + vals, + std::inserter(hash, hash.end()), + std::make_pair); +} diff --git a/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-1.cs b/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-1.cs new file mode 100644 index 0000000000..6d49c3db16 --- /dev/null +++ b/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-1.cs @@ -0,0 +1,14 @@ +System.Collections.HashTable h = new System.Collections.HashTable(); + +string[] arg_keys = {"foo","bar","val"}; +string[] arg_values = {"little", "miss", "muffet"}; + +//Some basic error checking +int arg_length = 0; +if ( arg_keys.Length == arg_values.Length ) { + arg_length = arg_keys.Length; +} + +for( int i = 0; i < arg_length; i++ ){ + h.add( arg_keys[i], arg_values[i] ); +} diff --git a/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-2.cs b/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-2.cs new file mode 100644 index 0000000000..6e9e7eab61 --- /dev/null +++ b/Task/Hash-from-two-arrays/C-sharp/hash-from-two-arrays-2.cs @@ -0,0 +1,3 @@ +for( int i = 0; i < arg_length; i++ ){ + h[ arg_keys[i] ] = arg_values[i]; +} diff --git a/Task/Hash-from-two-arrays/C/hash-from-two-arrays.c b/Task/Hash-from-two-arrays/C/hash-from-two-arrays.c new file mode 100644 index 0000000000..a58beb4544 --- /dev/null +++ b/Task/Hash-from-two-arrays/C/hash-from-two-arrays.c @@ -0,0 +1,115 @@ +#include +#include +#include + +#define KeyType const char * +#define ValType int + +#define HASH_SIZE 4096 + +// hash function useful when KeyType is char * (string) +unsigned strhashkey( const char * key, int max) +{ + unsigned h=0; + unsigned hl, hr; + + while(*key) { + h += *key; + hl= 0x5C5 ^ (h&0xfff00000 )>>18; + hr =(h&0x000fffff ); + h = hl ^ hr ^ *key++; + } + return h % max; +} + +typedef struct sHme { + KeyType key; + ValType value; + struct sHme *link; +} *MapEntry; + +typedef struct he { + MapEntry first, last; +} HashElement; + +HashElement hash[HASH_SIZE]; + +typedef void (*KeyCopyF)(KeyType *kdest, KeyType ksrc); +typedef void (*ValCopyF)(ValType *vdest, ValType vsrc); +typedef unsigned (*KeyHashF)( KeyType key, int upperBound ); +typedef int (*KeyCmprF)(KeyType key1, KeyType key2); + +void HashAddH( KeyType key, ValType value, + KeyCopyF copyKey, ValCopyF copyVal, KeyHashF hashKey, KeyCmprF keySame ) +{ + unsigned hix = (*hashKey)(key, HASH_SIZE); + MapEntry m_ent; + + for (m_ent= hash[hix].first; + m_ent && !(*keySame)(m_ent->key,key); m_ent=m_ent->link); + if (m_ent) { + (*copyVal)(&m_ent->value, value); + } + else { + MapEntry last; + MapEntry hme = malloc(sizeof(struct sHme)); + (*copyKey)(&hme->key, key); + (*copyVal)(&hme->value, value); + hme->link = NULL; + last = hash[hix].last; + if (last) { +// printf("Dup. hash key\n"); + last->link = hme; + } + else + hash[hix].first = hme; + hash[hix].last = hme; + } +} + +int HashGetH(ValType *val, KeyType key, KeyHashF hashKey, KeyCmprF keySame ) +{ + unsigned hix = (*hashKey)(key, HASH_SIZE); + MapEntry m_ent; + for (m_ent= hash[hix].first; + m_ent && !(*keySame)(m_ent->key,key); m_ent=m_ent->link); + if (m_ent) { + *val = m_ent->value; + } + return (m_ent != NULL); +} + +void copyStr(const char**dest, const char *src) +{ + *dest = strdup(src); +} +void copyInt( int *dest, int src) +{ + *dest = src; +} +int strCompare( const char *key1, const char *key2) +{ + return strcmp(key1, key2) == 0; +} + +void HashAdd( KeyType key, ValType value ) +{ + HashAddH( key, value, ©Str, ©Int, &strhashkey, &strCompare); +} + +int HashGet(ValType *val, KeyType key) +{ + return HashGetH( val, key, &strhashkey, &strCompare); +} + +int main() +{ + static const char * keyList[] = {"red","orange","yellow","green", "blue", "violet" }; + static int valuList[] = {1,43,640, 747, 42, 42}; + int ix; + + for (ix=0; ix<6; ix++) { + HashAdd(keyList[ix], valuList[ix]); + } + return 0; +} diff --git a/Task/Hash-from-two-arrays/Clojure/hash-from-two-arrays.clj b/Task/Hash-from-two-arrays/Clojure/hash-from-two-arrays.clj new file mode 100644 index 0000000000..dce306b019 --- /dev/null +++ b/Task/Hash-from-two-arrays/Clojure/hash-from-two-arrays.clj @@ -0,0 +1 @@ +(zipmap [\a \b \c] [1 2 3]) diff --git a/Task/Hash-from-two-arrays/CoffeeScript/hash-from-two-arrays.coffee b/Task/Hash-from-two-arrays/CoffeeScript/hash-from-two-arrays.coffee new file mode 100644 index 0000000000..cf3b3bbd9f --- /dev/null +++ b/Task/Hash-from-two-arrays/CoffeeScript/hash-from-two-arrays.coffee @@ -0,0 +1,4 @@ + keys = ['a','b','c'] + values = [1,2,3] + map = {} + map[key] = values[i] for key, i in keys diff --git a/Task/Hash-from-two-arrays/ColdFusion/hash-from-two-arrays.cfm b/Task/Hash-from-two-arrays/ColdFusion/hash-from-two-arrays.cfm new file mode 100644 index 0000000000..6426b73bbe --- /dev/null +++ b/Task/Hash-from-two-arrays/ColdFusion/hash-from-two-arrays.cfm @@ -0,0 +1,14 @@ + +function makeHash(keyArray, valueArray) { + var x = 1; + var result = {}; + for( ; x <= ArrayLen(keyArray); x ++ ) { + result[keyArray[x]] = valueArray[x]; + } + return result; +} + +keyArray = ['a', 'b', 'c']; +valueArray = [1, 2, 3]; +map = makeHash(keyArray, valueArray); + diff --git a/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-1.lisp b/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-1.lisp new file mode 100644 index 0000000000..a01593e1ba --- /dev/null +++ b/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-1.lisp @@ -0,0 +1,6 @@ +(defun rosetta-code-hash-from-two-arrays (vector-1 vector-2 &key (test 'eql)) + (assert (= (length vector-1) (length vector-2))) + (let ((table (make-hash-table :test test :size (length vector-1)))) + (map nil (lambda (k v) (setf (gethash k table) v)) + vector-1 vector-2) + table)) diff --git a/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-2.lisp b/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-2.lisp new file mode 100644 index 0000000000..fe0f891e65 --- /dev/null +++ b/Task/Hash-from-two-arrays/Common-Lisp/hash-from-two-arrays-2.lisp @@ -0,0 +1,7 @@ +(defun rosetta-code-hash-from-two-arrays (vector-1 vector-2 &key (test 'eql)) + (loop initially (assert (= (length vector-1) (length vector-2))) + with table = (make-hash-table :test test :size (length vector-1)) + for k across vector-1 + for v across vector-2 + do (setf (gethash k table) v) + finally (return table))) diff --git a/Task/Hash-from-two-arrays/D/hash-from-two-arrays.d b/Task/Hash-from-two-arrays/D/hash-from-two-arrays.d new file mode 100644 index 0000000000..1a3c3f6165 --- /dev/null +++ b/Task/Hash-from-two-arrays/D/hash-from-two-arrays.d @@ -0,0 +1,5 @@ +import std.array, std.range; + +void main() { + auto hash = ["a", "b", "c"].zip([1, 2, 3]).assocArray; +} diff --git a/Task/Hash-from-two-arrays/E/hash-from-two-arrays.e b/Task/Hash-from-two-arrays/E/hash-from-two-arrays.e new file mode 100644 index 0000000000..0ea9795032 --- /dev/null +++ b/Task/Hash-from-two-arrays/E/hash-from-two-arrays.e @@ -0,0 +1,3 @@ +def keys := ["one", "two", "three"] +def values := [1, 2, 3] +__makeMap.fromColumns(keys, values) diff --git a/Task/Hash-from-two-arrays/Factor/hash-from-two-arrays.factor b/Task/Hash-from-two-arrays/Factor/hash-from-two-arrays.factor new file mode 100644 index 0000000000..56287b15e0 --- /dev/null +++ b/Task/Hash-from-two-arrays/Factor/hash-from-two-arrays.factor @@ -0,0 +1,2 @@ +USING: hashtables ; +{ "one" "two" "three" } { 1 2 3 } zip >hashtable diff --git a/Task/Hash-from-two-arrays/Falcon/hash-from-two-arrays.falcon b/Task/Hash-from-two-arrays/Falcon/hash-from-two-arrays.falcon new file mode 100644 index 0000000000..c69ee20abf --- /dev/null +++ b/Task/Hash-from-two-arrays/Falcon/hash-from-two-arrays.falcon @@ -0,0 +1,4 @@ +keys = [ 'a', 'b', 'c', 'd' ] +values = [ 1, 2, 3, 4 ] +hash = [ => ] +for i in [ 0 : keys.len() ]: hash[ keys[ i ] ] = values[ i ] diff --git a/Task/Hash-from-two-arrays/Fantom/hash-from-two-arrays.fantom b/Task/Hash-from-two-arrays/Fantom/hash-from-two-arrays.fantom new file mode 100644 index 0000000000..323b03ab9e --- /dev/null +++ b/Task/Hash-from-two-arrays/Fantom/hash-from-two-arrays.fantom @@ -0,0 +1,16 @@ +class Main +{ + public static Void main () + { + keys := [1,2,3,4,5] + values := ["one", "two", "three", "four", "five"] + + // create an empty map + map := [:] + // add the key-value pairs to it + keys.size.times |Int index| + { + map.add(keys[index], values[index]) + } + } +} diff --git a/Task/Hash-from-two-arrays/Go/hash-from-two-arrays.go b/Task/Hash-from-two-arrays/Go/hash-from-two-arrays.go new file mode 100644 index 0000000000..c08b40455f --- /dev/null +++ b/Task/Hash-from-two-arrays/Go/hash-from-two-arrays.go @@ -0,0 +1,13 @@ +package main + +import "fmt" + +func main() { + keys := []string{"a", "b", "c"} + vals := []int{1, 2, 3} + hash := map[string]int{} + for i, key := range keys { + hash[key] = vals[i] + } + fmt.Println(hash) +} diff --git a/Task/Hash-from-two-arrays/Groovy/hash-from-two-arrays.groovy b/Task/Hash-from-two-arrays/Groovy/hash-from-two-arrays.groovy new file mode 100644 index 0000000000..953dd5688e --- /dev/null +++ b/Task/Hash-from-two-arrays/Groovy/hash-from-two-arrays.groovy @@ -0,0 +1,6 @@ +keys = ['a','b','c'] +vals = ['aaa', 'bbb', 'ccc'] +hash = [:] +keys.eachWithIndex { key, i -> + hash[key] = vals[i] +} diff --git a/Task/Hash-from-two-arrays/Haskell/hash-from-two-arrays.hs b/Task/Hash-from-two-arrays/Haskell/hash-from-two-arrays.hs new file mode 100644 index 0000000000..5608a0f051 --- /dev/null +++ b/Task/Hash-from-two-arrays/Haskell/hash-from-two-arrays.hs @@ -0,0 +1,4 @@ +import Data.Map + +makeMap ks vs = fromList $ zip ks vs +mymap = makeMap ['a','b','c'] [1,2,3] diff --git a/Task/Hash-from-two-arrays/Icon/hash-from-two-arrays.icon b/Task/Hash-from-two-arrays/Icon/hash-from-two-arrays.icon new file mode 100644 index 0000000000..8c848fe736 --- /dev/null +++ b/Task/Hash-from-two-arrays/Icon/hash-from-two-arrays.icon @@ -0,0 +1,12 @@ +link ximage # to format the structure + +procedure main(arglist) #: demonstrate hash from 2 lists +local keylist + +if *arglist = 0 then arglist := [1,2,3,4] # ensure there's a list +every put(keylist := [], "key-" || !arglist) # make keys for each entry + +every (T := table())[keylist[ i := 1 to *keylist ]] := arglist[i] # create the hash table + +write(ximage(T)) # show result +end diff --git a/Task/Hash-from-two-arrays/Ioke/hash-from-two-arrays.ioke b/Task/Hash-from-two-arrays/Ioke/hash-from-two-arrays.ioke new file mode 100644 index 0000000000..8ef721915d --- /dev/null +++ b/Task/Hash-from-two-arrays/Ioke/hash-from-two-arrays.ioke @@ -0,0 +1 @@ +{} addKeysAndValues([:a, :b, :c], [1, 2, 3]) diff --git a/Task/Hash-from-two-arrays/J/hash-from-two-arrays-1.j b/Task/Hash-from-two-arrays/J/hash-from-two-arrays-1.j new file mode 100644 index 0000000000..d11423ea89 --- /dev/null +++ b/Task/Hash-from-two-arrays/J/hash-from-two-arrays-1.j @@ -0,0 +1 @@ +hash=: vals {~ keys&i. diff --git a/Task/Hash-from-two-arrays/J/hash-from-two-arrays-2.j b/Task/Hash-from-two-arrays/J/hash-from-two-arrays-2.j new file mode 100644 index 0000000000..55adee8def --- /dev/null +++ b/Task/Hash-from-two-arrays/J/hash-from-two-arrays-2.j @@ -0,0 +1,19 @@ + keys=: 10?.100 + vals=: > ;:'zero one two three four five six seven eight nine' + hash=: vals {~ keys&i. + + keys +46 99 23 62 42 44 12 5 68 63 + $vals +10 5 + + hash 46 +zero + hash 99 +one + hash 63 5 12 5 23 +nine +seven +six +seven +two diff --git a/Task/Hash-from-two-arrays/Java/hash-from-two-arrays.java b/Task/Hash-from-two-arrays/Java/hash-from-two-arrays.java new file mode 100644 index 0000000000..de2d9ea411 --- /dev/null +++ b/Task/Hash-from-two-arrays/Java/hash-from-two-arrays.java @@ -0,0 +1,10 @@ +import java.util.HashMap; +public static void main(String[] args){ + String[] keys= {"a", "b", "c"}; + int[] vals= {1, 2, 3}; + HashMap hash= new HashMap(); + + for(int i= 0; i < keys.length; i++){ + hash.put(keys[i], vals[i]); + } +} diff --git a/Task/Hash-from-two-arrays/JavaScript/hash-from-two-arrays.js b/Task/Hash-from-two-arrays/JavaScript/hash-from-two-arrays.js new file mode 100644 index 0000000000..fad9b18300 --- /dev/null +++ b/Task/Hash-from-two-arrays/JavaScript/hash-from-two-arrays.js @@ -0,0 +1,6 @@ +var keys = ['a', 'b', 'c']; +var values = [1, 2, 3]; +var map = {}; +for(var i in keys) { + map[ keys[i] ] = values[i]; +} diff --git a/Task/Hash-from-two-arrays/K/hash-from-two-arrays-1.k b/Task/Hash-from-two-arrays/K/hash-from-two-arrays-1.k new file mode 100644 index 0000000000..72a0529a40 --- /dev/null +++ b/Task/Hash-from-two-arrays/K/hash-from-two-arrays-1.k @@ -0,0 +1,10 @@ + a: `zero `one `two / symbols + b: 0 1 2 + + d:. a,'b / create the dictionary +.((`zero;0;) + (`one;1;) + (`two;2;)) + + d[`one] +1 diff --git a/Task/Hash-from-two-arrays/K/hash-from-two-arrays-2.k b/Task/Hash-from-two-arrays/K/hash-from-two-arrays-2.k new file mode 100644 index 0000000000..9c4adc38c8 --- /dev/null +++ b/Task/Hash-from-two-arrays/K/hash-from-two-arrays-2.k @@ -0,0 +1,19 @@ + keys: !10 / 0..9 + split:{1_'(&x=y)_ x:y,x} + vals:split["zero one two three four five six seven eight nine";" "] + + s:{`$$x} / convert to symbol + d:. (s'keys),'s'vals +.((`"0";`zero;) + (`"1";`one;) + (`"2";`two;) + (`"3";`three;) + (`"4";`four;) + (`"5";`five;) + (`"6";`six;) + (`"7";`seven;) + (`"8";`eight;) + (`"9";`nine;)) + + $d[s 1] / leading "$" converts back to string +"one" diff --git a/Task/Hash-from-two-arrays/Lang5/hash-from-two-arrays.lang5 b/Task/Hash-from-two-arrays/Lang5/hash-from-two-arrays.lang5 new file mode 100644 index 0000000000..5fd255a0e7 --- /dev/null +++ b/Task/Hash-from-two-arrays/Lang5/hash-from-two-arrays.lang5 @@ -0,0 +1,2 @@ +: >table 2 compress -1 transpose ; +['one 'two 'three 'four] [1 2 3 4] >table diff --git a/Task/Hash-from-two-arrays/Lua/hash-from-two-arrays.lua b/Task/Hash-from-two-arrays/Lua/hash-from-two-arrays.lua new file mode 100644 index 0000000000..c581af53f2 --- /dev/null +++ b/Task/Hash-from-two-arrays/Lua/hash-from-two-arrays.lua @@ -0,0 +1,6 @@ +function(keys,values) + local t = {} + for i=1, #keys do + t[keys[i]] = values[i] + end +end diff --git a/Task/Hash-from-two-arrays/Mathematica/hash-from-two-arrays.mathematica b/Task/Hash-from-two-arrays/Mathematica/hash-from-two-arrays.mathematica new file mode 100644 index 0000000000..e5a26d467d --- /dev/null +++ b/Task/Hash-from-two-arrays/Mathematica/hash-from-two-arrays.mathematica @@ -0,0 +1,7 @@ +Map[(Hash[Part[#, 1]] = Part[#, 2]) &, + Transpose[{{1, 2, 3}, {"one", "two", "three"}}]] + +?? Hash +->Hash[1]=one +->Hash[2]=two +->Hash[3]=three diff --git a/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-1.php b/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-1.php new file mode 100644 index 0000000000..515d2f1e08 --- /dev/null +++ b/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-1.php @@ -0,0 +1,3 @@ +$keys = array('a', 'b', 'c'); +$values = array(1, 2, 3); +$hash = array_combine($keys, $values); diff --git a/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-2.php b/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-2.php new file mode 100644 index 0000000000..63a4036fca --- /dev/null +++ b/Task/Hash-from-two-arrays/PHP/hash-from-two-arrays-2.php @@ -0,0 +1,6 @@ +$keys = array('a', 'b', 'c'); +$values = array(1, 2, 3); +$hash = array(); +for ($idx = 0; $idx < count($keys); $idx++) { + $hash[$keys[$idx]] = $values[$idx]; +} diff --git a/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-1.pl b/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-1.pl new file mode 100644 index 0000000000..707a9860f0 --- /dev/null +++ b/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-1.pl @@ -0,0 +1,4 @@ +my @keys = qw(a b c); +my @vals = (1, 2, 3); +my %hash; +@hash{@keys} = @vals; diff --git a/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-2.pl b/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-2.pl new file mode 100644 index 0000000000..98816bf40d --- /dev/null +++ b/Task/Hash-from-two-arrays/Perl/hash-from-two-arrays-2.pl @@ -0,0 +1,2 @@ +use List::MoreUtils qw(zip); +my %hash = zip @keys, @vals; diff --git a/Task/Hash-from-two-arrays/PicoLisp/hash-from-two-arrays.l b/Task/Hash-from-two-arrays/PicoLisp/hash-from-two-arrays.l new file mode 100644 index 0000000000..84119cbcf6 --- /dev/null +++ b/Task/Hash-from-two-arrays/PicoLisp/hash-from-two-arrays.l @@ -0,0 +1,3 @@ +(let (Keys '(one two three) Values (1 2 3)) + (mapc println + (mapcar cons Keys Values) ) ) diff --git a/Task/Hash-from-two-arrays/Prolog/hash-from-two-arrays.pro b/Task/Hash-from-two-arrays/Prolog/hash-from-two-arrays.pro new file mode 100644 index 0000000000..8938e2b415 --- /dev/null +++ b/Task/Hash-from-two-arrays/Prolog/hash-from-two-arrays.pro @@ -0,0 +1,19 @@ +% this one with side effect hash table creation + +:-dynamic hash/2. + +make_hash([],[]). +make_hash([H|Q],[H1|Q1]):- + assert(hash(H,H1)), + make_hash(Q,Q1). + +:-make_hash([un,deux,trois],[[a,b,c],[d,e,f],[g,h,i]]) + + +% this one without side effects + +make_hash_pure([],[],[]). +make_hash_pure([H|Q],[H1|Q1],[hash(H,H1)|R]):- + make_hash_pure(Q,Q1,R). + +:-make_hash_pure([un,deux,trois],[[a,b,c],[d,e,f],[g,h,i]],L),findall(M,(member(M,L),assert(M)),L). diff --git a/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-1.py b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-1.py new file mode 100644 index 0000000000..c59da0effb --- /dev/null +++ b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-1.py @@ -0,0 +1,7 @@ +keys = ['a', 'b', 'c'] +values = [1, 2, 3] +hash = dict(zip(keys, values)) + +# Lazily, Python 2.3+, not 3.x: +from itertools import izip +hash = dict(izip(keys, values)) diff --git a/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-2.py b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-2.py new file mode 100644 index 0000000000..6b9e7cca37 --- /dev/null +++ b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-2.py @@ -0,0 +1,3 @@ +keys = ['a', 'b', 'c'] +values = [1, 2, 3] +hash = {key: value for key, value in zip(keys, values)} diff --git a/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-3.py b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-3.py new file mode 100644 index 0000000000..d1f389dc2e --- /dev/null +++ b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-3.py @@ -0,0 +1,5 @@ +keys = ['a', 'b', 'c'] +values = [1, 2, 3] +hash = {} +for k,v in zip(keys, values): + hash[k] = v diff --git a/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-4.py b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-4.py new file mode 100644 index 0000000000..3416960ee9 --- /dev/null +++ b/Task/Hash-from-two-arrays/Python/hash-from-two-arrays-4.py @@ -0,0 +1,41 @@ +>>> class Hashable(object): + def __hash__(self): + return id(self) ^ 0xBEEF + + +>>> my_inst = Hashable() +>>> my_int = 1 +>>> my_complex = 0 + 1j +>>> my_float = 1.2 +>>> my_string = "Spam" +>>> my_bool = True +>>> my_unicode = u'Ham' +>>> my_list = ['a', 7] +>>> my_tuple = ( 0.0, 1.4 ) +>>> my_set = set(my_list) +>>> def my_func(): + pass + +>>> class my_class(object): + pass + +>>> keys = [my_inst, my_tuple, my_int, my_complex, my_float, my_string, + my_bool, my_unicode, frozenset(my_set), tuple(my_list), + my_func, my_class] +>>> values = range(12) +>>> d = dict(zip(keys, values)) +>>> for key, value in d.items(): print key, ":", value + +1 : 6 +1j : 3 +Ham : 7 +Spam : 5 +(0.0, 1.3999999999999999) : 1 +frozenset(['a', 7]) : 8 +1.2 : 4 +('a', 7) : 9 + : 10 + : 11 +<__main__.Hashable object at 0x012AFC50> : 0 +>>> # Notice that the key "True" disappeared, and its value got associated with the key "1" +>>> # This is because 1 == True in Python, and dictionaries cannot have two equal keys diff --git a/Task/Hash-from-two-arrays/R/hash-from-two-arrays.r b/Task/Hash-from-two-arrays/R/hash-from-two-arrays.r new file mode 100644 index 0000000000..e38b5e1831 --- /dev/null +++ b/Task/Hash-from-two-arrays/R/hash-from-two-arrays.r @@ -0,0 +1,8 @@ +# Set up hash table +keys <- c("John Smith", "Lisa Smith", "Sam Doe", "Sandra Dee", "Ted Baker") +values <- c(152, 1, 254, 152, 153) +names(values) <- keys +# Get value corresponding to a key +values["Sam Doe"] # vals["Sam Doe"] +# Get all keys corresponding to a value +names(values)[values==152] # "John Smith" "Sandra Dee" diff --git a/Task/Hash-from-two-arrays/REXX/hash-from-two-arrays.rexx b/Task/Hash-from-two-arrays/REXX/hash-from-two-arrays.rexx new file mode 100644 index 0000000000..83542ddd14 --- /dev/null +++ b/Task/Hash-from-two-arrays/REXX/hash-from-two-arrays.rexx @@ -0,0 +1,18 @@ +/*REXX program demonstrate hashing of a stemmed array (from a key). */ + /*names of the 9 regular polygons*/ +values='triangle quadrilateral pentagon hexagon heptagon octagon nonagon decagon dodecagon' +keys ='thuhree vour phive sicks zeaven ate nein den duzun' + +/*superflous blanks added to humorous keys just 'cause it looks prettier*/ +call hash values,keys /*hash the keys to the values. */ +parse arg query . /*what was specified on cmd line.*/ +if query=='' then exit /*nothing, then let's leave Dodge*/ +pad=left('',30) /*used for padding the display. */ +say 'key:' query pad "value:" hash.query /*show & tell some stuff.*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────HASH subroutine─────────────────────*/ +hash: procedure expose hash.; parse arg v,k,hash. + do j=1 until map=''; map=word(k,j) + hash.map=word(v,j) + end /*j*/ +return diff --git a/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-1.rkt b/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-1.rkt new file mode 100644 index 0000000000..7cdb310494 --- /dev/null +++ b/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-1.rkt @@ -0,0 +1,4 @@ +(make-hash + (map cons + '("a" "b" "c" "d") + '(1 2 3 4))) diff --git a/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-2.rkt b/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-2.rkt new file mode 100644 index 0000000000..e5ea6eee04 --- /dev/null +++ b/Task/Hash-from-two-arrays/Racket/hash-from-two-arrays-2.rkt @@ -0,0 +1,4 @@ +(define (connect keys vals) + (for/hash ([k keys] [v vals]) (values k v))) +;; Example: +(connect #("a" "b" "c" "d") #(1 2 3 4)) diff --git a/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-1.rb b/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-1.rb new file mode 100644 index 0000000000..6d1d5d9f30 --- /dev/null +++ b/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-1.rb @@ -0,0 +1,14 @@ +keys=['hal',666,[1,2,3]] +vals=['ibm','devil',123] + +if RUBY_VERSION >= '1.8.7' + # Easy way, but needs Ruby 1.8.7 or later. + hash = Hash[keys.zip(vals)] +else + hash = keys.zip(vals).inject({}) {|h, kv| h.store(*kv); h } +end + +p hash # => {"hal"=>"ibm", 666=>"devil", [1, 2, 3]=>123} + +#retrieve the value linked to the key [1,2,3] +puts hash[ [1,2,3] ] # => 123 diff --git a/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-2.rb b/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-2.rb new file mode 100644 index 0000000000..c07682095b --- /dev/null +++ b/Task/Hash-from-two-arrays/Ruby/hash-from-two-arrays-2.rb @@ -0,0 +1,9 @@ +class Array + def zip_hash(other) + Hash[*(0...self.size).inject([]) { |arr, ix| + arr.push(self[ix], other[ix]) } ] + end +end + +hash = %W{ a b c }.zip_hash( %W{ 1 2 3 } ) +p hash # => {"a"=>"1", "b"=>"2", "c"=>"3"} diff --git a/Task/Hash-from-two-arrays/Sather/hash-from-two-arrays.sa b/Task/Hash-from-two-arrays/Sather/hash-from-two-arrays.sa new file mode 100644 index 0000000000..e99ec6f05e --- /dev/null +++ b/Task/Hash-from-two-arrays/Sather/hash-from-two-arrays.sa @@ -0,0 +1,23 @@ +class ZIPPER{K,E} is + zip(k:ARRAY{K}, e:ARRAY{E}) :MAP{K, E} + pre k.size = e.size + is + m :MAP{K, E} := #; + loop m[k.elt!] := e.elt!; end; + return m; + end; +end; + +class MAIN is + + main is + keys:ARRAY{STR} := |"one", "three", "four"|; + values:ARRAY{INT} := |1, 3, 4|; + m ::= ZIPPER{STR,INT}::zip(keys, values); + loop + #OUT + m.pair! + " "; + end; + #OUT + "\n"; + end; + +end; diff --git a/Task/Hash-from-two-arrays/Scala/hash-from-two-arrays.scala b/Task/Hash-from-two-arrays/Scala/hash-from-two-arrays.scala new file mode 100644 index 0000000000..0f0b1a85c2 --- /dev/null +++ b/Task/Hash-from-two-arrays/Scala/hash-from-two-arrays.scala @@ -0,0 +1,3 @@ +val keys = Array(1, 2, 3) +val values = Array("A", "B", "C") +val map = keys.zip(values).toMap diff --git a/Task/Hash-from-two-arrays/Scheme/hash-from-two-arrays.ss b/Task/Hash-from-two-arrays/Scheme/hash-from-two-arrays.ss new file mode 100644 index 0000000000..dd767ebc8b --- /dev/null +++ b/Task/Hash-from-two-arrays/Scheme/hash-from-two-arrays.ss @@ -0,0 +1,2 @@ +(define (lists->hash-table keys values . rest) + (apply alist->hash-table (map cons keys values) rest)) diff --git a/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-1.st b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-1.st new file mode 100644 index 0000000000..2e4263add7 --- /dev/null +++ b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-1.st @@ -0,0 +1,13 @@ +Array extend [ + dictionaryWithValues: array [ |d| + d := Dictionary new. + 1 to: ((self size) min: (array size)) do: [:i| + d at: (self at: i) put: (array at: i). + ]. + ^ d + ] +]. + + +({ 'red' . 'one' . 'two' } + dictionaryWithValues: { '#ff0000'. 1. 2 }) displayNl. diff --git a/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-2.st b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-2.st new file mode 100644 index 0000000000..df22233157 --- /dev/null +++ b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-2.st @@ -0,0 +1,3 @@ +Dictionary + withKeys:#('one' 'two' 'three') + andValues:#('eins' 'zwei' 'drei') diff --git a/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-3.st b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-3.st new file mode 100644 index 0000000000..70c189023e --- /dev/null +++ b/Task/Hash-from-two-arrays/Smalltalk/hash-from-two-arrays-3.st @@ -0,0 +1 @@ +Dictionary withAssociations:{ 'one'->1 . 'two'->2 . 'three'->3 } diff --git a/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-1.tcl b/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-1.tcl new file mode 100644 index 0000000000..9b87add18c --- /dev/null +++ b/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-1.tcl @@ -0,0 +1,4 @@ +set keys [list fred bob joe] +set values [list barber plumber tailor] +array set arr {} +foreach a $keys b $values { set arr($a) $b } diff --git a/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-2.tcl b/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-2.tcl new file mode 100644 index 0000000000..62d3a08d8f --- /dev/null +++ b/Task/Hash-from-two-arrays/Tcl/hash-from-two-arrays-2.tcl @@ -0,0 +1,3 @@ +foreach a $keys b $values { + dict set jobs $a $b +} diff --git a/Task/Haversine-formula/0DESCRIPTION b/Task/Haversine-formula/0DESCRIPTION new file mode 100644 index 0000000000..5b793aeb98 --- /dev/null +++ b/Task/Haversine-formula/0DESCRIPTION @@ -0,0 +1,25 @@ +{{Wikipedia}}The '''haversine formula''' is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes. It is a special case of a more general formula in spherical trigonometry, the '''law of haversines''', relating the sides and angles of spherical "triangles". + +'''Task:''' Implement a great-circle distance function, or use a library function, to show the great-circle distance between Nashville International Airport (BNA) in Nashville, TN, USA: N 36°7.2', W 86°40.2' (36.12, -86.67) and Los Angeles International Airport (LAX) in Los Angeles, CA, USA: N 33°56.4', W 118°24.0' (33.94, -118.40). + +
+User Kaimbridge clarified on the Talk page:
+
+ -- 6371.0 km is the authalic radius based on/extracted from surface area;
+ -- 6372.8 km is an approximation of the radius of the average circumference
+    (i.e., the average great-elliptic or great-circle radius), where the
+     boundaries are the meridian (6367.45 km) and the equator (6378.14 km).
+
+Using either of these values results, of course, in differing distances:
+
+ 6371.0 km -> 2886.44444283798329974715782394574671655 km;
+ 6372.8 km -> 2887.25995060711033944886005029688505340 km;
+ (results extended for accuracy check:  Given that the radii are only
+  approximations anyways, .01' ≈ 1.0621333 km and .001" ≈ .00177 km,
+  practical precision required is certainly no greater than about
+  .0000001——i.e., .1 mm!)
+
+As distances are segments of great circles/circumferences, it is
+recommended that the latter value (r = 6372.8 km) be used (which
+most of the given solutions have already adopted, anyways).
+
diff --git a/Task/Haversine-formula/ALGOL-68/haversine-formula.alg b/Task/Haversine-formula/ALGOL-68/haversine-formula.alg new file mode 100644 index 0000000000..317f166784 --- /dev/null +++ b/Task/Haversine-formula/ALGOL-68/haversine-formula.alg @@ -0,0 +1,22 @@ +#!/usr/local/bin/a68g --script # + +REAL r = 20 000/pi + 6.6 # km #, + to rad = pi/180; + +PROC dist = (REAL th1 deg, ph1 deg, th2 deg, ph2 deg)REAL: +( + REAL ph1 = (ph1 deg - ph2 deg) * to rad, + th1 = th1 deg * to rad, th2 = th2 deg * to rad, + + dz = sin(th1) - sin(th2), + dx = cos(ph1) * cos(th1) - cos(th2), + dy = sin(ph1) * cos(th1); + arc sin(sqrt(dx * dx + dy * dy + dz * dz) / 2) * 2 * r +); + +main: +( + REAL d = dist(36.12, -86.67, 33.94, -118.4); + # Americans don't know kilometers # + printf(($"dist: "g(0,1)" km ("g(0,1)" mi.)"l$, d, d / 1.609344)) +) diff --git a/Task/Haversine-formula/AWK/haversine-formula.awk b/Task/Haversine-formula/AWK/haversine-formula.awk new file mode 100644 index 0000000000..14aeb4699d --- /dev/null +++ b/Task/Haversine-formula/AWK/haversine-formula.awk @@ -0,0 +1,18 @@ +# syntax: GAWK -f HAVERSINE_FORMULA.AWK +# converted from Python +BEGIN { + distance(36.12,-86.67,33.94,-118.40) # BNA to LAX + exit(0) +} +function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) { + dlat = radians(lat2-lat1) + dlon = radians(lon2-lon1) + lat1 = radians(lat1) + lat2 = radians(lat2) + a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2 + c = 2 * atan2(sqrt(a),sqrt(1-a)) + printf("distance: %.4f km\n",6372.8 * c) +} +function radians(degree) { # degrees to radians + return degree * (3.1415926 / 180.) +} diff --git a/Task/Haversine-formula/Ada/haversine-formula.ada b/Task/Haversine-formula/Ada/haversine-formula.ada new file mode 100644 index 0000000000..06529752b9 --- /dev/null +++ b/Task/Haversine-formula/Ada/haversine-formula.ada @@ -0,0 +1,31 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO; +with Ada.Numerics.Generic_Elementary_Functions; + +procedure Haversine_Formula is + + package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math; + + -- Compute great circle distance, given latitude and longitude of two points, in radians + function Great_Circle_Distance (lat1, long1, lat2, long2 : Long_Float) return Long_Float is + Earth_Radius : constant := 6371.0; -- in kilometers + a : Long_Float := Sin (0.5 * (lat2 - lat1)); + b : Long_Float := Sin (0.5 * (long2 - long1)); + begin + return 2.0 * Earth_Radius * ArcSin (Sqrt (a * a + Cos (lat1) * Cos (lat2) * b * b)); + end Great_Circle_Distance; + + -- convert degrees, minutes and seconds to radians + function DMS_To_Radians (Deg, Min, Sec : Long_Float := 0.0) return Long_Float is + Pi_Over_180 : constant := 0.017453_292519_943295_769236_907684_886127; + begin + return (Deg + Min/60.0 + Sec/3600.0) * Pi_Over_180; + end DMS_To_Radians; + +begin + Put_Line("Distance in kilometers between BNA and LAX"); + Put (Great_Circle_Distance ( + DMS_To_Radians (36.0, 7.2), DMS_To_Radians (86.0, 40.2), -- Nashville International Airport (BNA) + DMS_To_Radians (33.0, 56.4), DMS_To_Radians (118.0, 24.0)), -- Los Angeles International Airport (LAX) + Aft=>3, Exp=>0); +end Haversine_Formula; diff --git a/Task/Haversine-formula/BBC-BASIC/haversine-formula.bbc b/Task/Haversine-formula/BBC-BASIC/haversine-formula.bbc new file mode 100644 index 0000000000..97299ff5f4 --- /dev/null +++ b/Task/Haversine-formula/BBC-BASIC/haversine-formula.bbc @@ -0,0 +1,9 @@ + PRINT "Distance = " ; FNhaversine(36.12, -86.67, 33.94, -118.4) " km" + END + + DEF FNhaversine(n1, e1, n2, e2) + LOCAL d() : DIM d(2) + d() = COSRAD(e1-e2) * COSRAD(n1) - COSRAD(n2), \ + \ SINRAD(e1-e2) * COSRAD(n1), \ + \ SINRAD(n1) - SINRAD(n2) + = ASN(MOD(d()) / 2) * 6372.8 * 2 diff --git a/Task/Haversine-formula/C/haversine-formula.c b/Task/Haversine-formula/C/haversine-formula.c new file mode 100644 index 0000000000..f11129757e --- /dev/null +++ b/Task/Haversine-formula/C/haversine-formula.c @@ -0,0 +1,26 @@ +#include +#include +#include + +#define R 6371 +#define TO_RAD (3.1415926536 / 180) +double dist(double th1, double ph1, double th2, double ph2) +{ + double dx, dy, dz; + ph1 -= ph2; + ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD; + + dz = sin(th1) - sin(th2); + dx = cos(ph1) * cos(th1) - cos(th2); + dy = sin(ph1) * cos(th1); + return asin(sqrt(dx * dx + dy * dy + dz * dz) / 2) * 2 * R; +} + +int main() +{ + double d = dist(36.12, -86.67, 33.94, -118.4); + /* Americans don't know kilometers */ + printf("dist: %.1f km (%.1f mi.)\n", d, d / 1.609344); + + return 0; +} diff --git a/Task/Haversine-formula/Common-Lisp/haversine-formula.lisp b/Task/Haversine-formula/Common-Lisp/haversine-formula.lisp new file mode 100644 index 0000000000..c32ef582c1 --- /dev/null +++ b/Task/Haversine-formula/Common-Lisp/haversine-formula.lisp @@ -0,0 +1,21 @@ +(defparameter *earth-radius* 6372.8) + +(defparameter *rad-conv* (/ pi 180)) + +(defun deg->rad (x) + (* x *rad-conv*)) + +(defun haversine (x) + (expt (sin (/ x 2)) 2)) + +(defun dist-rad (lat1 lng1 lat2 lng2) + (let* ((hlat (haversine (- lat2 lat1))) + (hlng (haversine (- lng2 lng1))) + (root (sqrt (+ hlat (* (cos lat1) (cos lat2) hlng))))) + (* 2 *earth-radius* (asin root)))) + +(defun dist-deg (lat1 lng1 lat2 lng2) + (dist-rad (deg->rad lat1) + (deg->rad lng1) + (deg->rad lat2) + (deg->rad lng2))) diff --git a/Task/Haversine-formula/D/haversine-formula.d b/Task/Haversine-formula/D/haversine-formula.d new file mode 100644 index 0000000000..35eb5849ee --- /dev/null +++ b/Task/Haversine-formula/D/haversine-formula.d @@ -0,0 +1,24 @@ +import std.stdio, std.math; + +real haversineDistance(in real dth1, in real dph1, + in real dth2, in real dph2) pure nothrow { + + enum real R = 6371; + enum real TO_RAD = PI / 180; + + alias imr = immutable(real); + imr ph1d = dph1 - dph2; + imr ph1 = ph1d * TO_RAD; + imr th1 = dth1 * TO_RAD; + imr th2 = dth2 * TO_RAD; + + imr dz = sin(th1) - sin(th2); + imr dx = cos(ph1) * cos(th1) - cos(th2); + imr dy = sin(ph1) * cos(th1); + return asin(sqrt(dx ^^ 2 + dy ^^ 2 + dz ^^ 2) / 2) * 2 * R; +} + +void main() { + writefln("Haversine distance: %.1f km", + haversineDistance(36.12, -86.67, 33.94, -118.4)); +} diff --git a/Task/Haversine-formula/Factor/haversine-formula-1.factor b/Task/Haversine-formula/Factor/haversine-formula-1.factor new file mode 100644 index 0000000000..d04afad9a0 --- /dev/null +++ b/Task/Haversine-formula/Factor/haversine-formula-1.factor @@ -0,0 +1,11 @@ +USING: arrays kernel math math.constants math.functions math.vectors sequences ; + +: haversin ( x -- y ) cos 1 swap - 2 / ; +: haversininv ( y -- x ) 2 * 1 swap - acos ; +: haversineDist ( as bs -- d ) +[ [ 180 / pi * ] map ] bi@ + [ [ swap - haversin ] 2map ] + [ [ first cos ] bi@ * 1 swap 2array ] + 2bi +v. +haversininv R_earth * ; diff --git a/Task/Haversine-formula/Factor/haversine-formula-2.factor b/Task/Haversine-formula/Factor/haversine-formula-2.factor new file mode 100644 index 0000000000..b3b5cf6c6a --- /dev/null +++ b/Task/Haversine-formula/Factor/haversine-formula-2.factor @@ -0,0 +1,2 @@ +( scratchpad ) { 36.12 -86.67 } { 33.94 -118.4 } haversineDist . +2887.259950607113 diff --git a/Task/Haversine-formula/Forth/haversine-formula.fth b/Task/Haversine-formula/Forth/haversine-formula.fth new file mode 100644 index 0000000000..86847c2c1f --- /dev/null +++ b/Task/Haversine-formula/Forth/haversine-formula.fth @@ -0,0 +1,15 @@ +: s>f s>d d>f ; +: deg>rad 174532925199433e-16 f* ; +: difference f- deg>rad 2 s>f f/ fsin fdup f* ; + +: haversine ( lat1 lon1 lat2 lon2 -- haversine) + frot difference ( lat1 lat2 dLon^2) + frot frot fover fover ( dLon^2 lat1 lat2 lat1 lat2) + fswap difference ( dLon^2 lat1 lat2 dLat^2) + fswap deg>rad fcos ( dLon^2 lat1 dLat^2 lat2) + frot deg>rad fcos f* ( dLon^2 dLat2 lat1*lat2) + frot f* f+ ( lat1*lat2*dLon^2+dLat^2) + fsqrt fasin 127456 s>f f* 10 s>f f/ ( haversine) +; + +36.12e -86.67e 33.94e -118.40e haversine cr f. diff --git a/Task/Haversine-formula/Fortran/haversine-formula.f b/Task/Haversine-formula/Fortran/haversine-formula.f new file mode 100644 index 0000000000..1cfa5bc33b --- /dev/null +++ b/Task/Haversine-formula/Fortran/haversine-formula.f @@ -0,0 +1,34 @@ +program example +implicit none +real :: d + +d = haversine(36.12,-86.67,33.94,-118.40) ! BNA to LAX +print '(A,F9.4,A)', 'distance: ',d,' km' ! distance: 2887.2600 km + +contains + + function to_radian(degree) result(rad) + ! degrees to radians + real,intent(in) :: degree + real :: rad,pi + + pi = 4*atan(1.0) ! exploit intrinsic atan to generate pi + rad = degree*pi/180 + end function to_radian + + function haversine(deglat1,deglon1,deglat2,deglon2) result (dist) + ! great circle distance -- adapted from Matlab + real,intent(in) :: deglat1,deglon1,deglat2,deglon2 + real :: a,c,dist,dlat,dlon,lat1,lat2 + real,parameter :: radius = 6372.8 + + dlat = to_radian(deglat2-deglat1) + dlon = to_radian(deglon2-deglon1) + lat1 = to_radian(deglat1) + lat2 = to_radian(deglat2) + a = (sin(dlat/2))**2 + cos(lat1)*cos(lat2)*(sin(dlon/2))**2 + c = 2*atan2(sqrt(a),sqrt(1-a)) + dist = radius*c + end function haversine + +end program example diff --git a/Task/Haversine-formula/Frink/haversine-formula-1.frink b/Task/Haversine-formula/Frink/haversine-formula-1.frink new file mode 100644 index 0000000000..2ea5ef9c32 --- /dev/null +++ b/Task/Haversine-formula/Frink/haversine-formula-1.frink @@ -0,0 +1,6 @@ +haversine[theta] := (1-cos[theta])/2 + +dist[lat1, long1, lat2, long2] := 2 earthradius arcsin[sqrt[haversine[lat2-lat1] + cos[lat1] cos[lat2] haversine[long2-long1]]] + +d = dist[36.12 deg, -86.67 deg, 33.94 deg, -118.40 deg] +println[d-> "km"] diff --git a/Task/Haversine-formula/Frink/haversine-formula-2.frink b/Task/Haversine-formula/Frink/haversine-formula-2.frink new file mode 100644 index 0000000000..c4504a66ef --- /dev/null +++ b/Task/Haversine-formula/Frink/haversine-formula-2.frink @@ -0,0 +1,4 @@ +use navigation.frink + +d = earthDistance[36.12 deg North, 86.67 deg West, 33.94 deg North, 118.40 deg West] +println[d-> "km"] diff --git a/Task/Haversine-formula/Go/haversine-formula.go b/Task/Haversine-formula/Go/haversine-formula.go new file mode 100644 index 0000000000..c1a477d757 --- /dev/null +++ b/Task/Haversine-formula/Go/haversine-formula.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "math" +) + +func haversine(θ float64) float64 { + return .5 * (1 - math.Cos(θ)) +} + +type pos struct { + φ float64 // latitude, radians + ψ float64 // longitude, radians +} + +func degPos(lat, lon float64) pos { + return pos{lat * math.Pi / 180, lon * math.Pi / 180} +} + +const rEarth = 6372.8 // km + +func hsDist(p1, p2 pos) float64 { + return 2 * rEarth * math.Asin(math.Sqrt(haversine(p2.φ-p1.φ)+ + math.Cos(p1.φ)*math.Cos(p2.φ)*haversine(p2.ψ-p1.ψ))) +} + +func main() { + fmt.Println(hsDist(degPos(36.12, -86.67), degPos(33.94, -118.40))) +} diff --git a/Task/Haversine-formula/Groovy/haversine-formula.groovy b/Task/Haversine-formula/Groovy/haversine-formula.groovy new file mode 100644 index 0000000000..4cb568ee8b --- /dev/null +++ b/Task/Haversine-formula/Groovy/haversine-formula.groovy @@ -0,0 +1,16 @@ +def haversine(lat1, lon1, lat2, lon2) { + def R = 6372.8 + // In kilometers + def dLat = Math.toRadians(lat2 - lat1) + def dLon = Math.toRadians(lon2 - lon1) + lat1 = Math.toRadians(lat1) + lat2 = Math.toRadians(lat2) + + def a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2) + def c = 2 * Math.asin(Math.sqrt(a)) + R * c +} + +haversine(36.12, -86.67, 33.94, -118.40) + +> 2887.25995060711 diff --git a/Task/Haversine-formula/Haskell/haversine-formula.hs b/Task/Haversine-formula/Haskell/haversine-formula.hs new file mode 100644 index 0000000000..40cd59148b --- /dev/null +++ b/Task/Haversine-formula/Haskell/haversine-formula.hs @@ -0,0 +1,28 @@ +import Text.Printf + +-- The haversine of an angle. +hsin t = let u = sin (t/2) in u*u + +-- The distance between two points, given by latitude and longtitude, on a +-- circle. The points are specified in radians. +distRad radius (lat1, lng1) (lat2, lng2) = + let hlat = hsin (lat2 - lat1) + hlng = hsin (lng2 - lng1) + root = sqrt (hlat + cos lat1 * cos lat2 * hlng) + in 2 * radius * asin (min 1.0 root) + +-- The distance between two points, given by latitude and longtitude, on a +-- circle. The points are specified in degrees. +distDeg radius p1 p2 = distRad radius (deg2rad p1) (deg2rad p2) + where deg2rad (t, u) = (d2r t, d2r u) + d2r t = t * pi / 180 + +-- The approximate distance, in kilometers, between two points on Earth. The +-- latitude and longtitude are assumed to be in degrees. +earthDist = distDeg 6372.8 + +main = do + let bna = (36.12, -86.67) + lax = (33.94, -118.40) + dst = earthDist bna lax :: Double + printf "The distance between BNA and LAX is about %0.f km.\n" dst diff --git a/Task/Haversine-formula/Icon/haversine-formula.icon b/Task/Haversine-formula/Icon/haversine-formula.icon new file mode 100644 index 0000000000..93c5e2f067 --- /dev/null +++ b/Task/Haversine-formula/Icon/haversine-formula.icon @@ -0,0 +1,15 @@ +link printf + +procedure main() #: Haversine formula + printf("BNA to LAX is %d km (%d miles)\n", + d := gcdistance([36.12, -86.67],[33.94, -118.40]),d*3280/5280) # with cute km2mi conversion +end + +procedure gcdistance(a,b) + a[2] -:= b[2] + every (x := a|b)[i := 1 to 2] := dtor(x[i]) + dz := sin(a[1]) - sin(b[1]) + dx := cos(a[2]) * cos(a[1]) - cos(b[1]) + dy := sin(a[2]) * cos(a[1]) + return asin(sqrt(dx * dx + dy * dy + dz * dz) / 2) * 2 * 6371 +end diff --git a/Task/Haversine-formula/J/haversine-formula-1.j b/Task/Haversine-formula/J/haversine-formula-1.j new file mode 100644 index 0000000000..6a61994a5e --- /dev/null +++ b/Task/Haversine-formula/J/haversine-formula-1.j @@ -0,0 +1,4 @@ +require 'trig' +haversin=: 0.5 * 1 - cos +Rearth=: 6372.8 +haversineDist=: Rearth * haversin^:_1@((1 , *&(cos@{.)) +/ .* [: haversin -)&rfd diff --git a/Task/Haversine-formula/J/haversine-formula-2.j b/Task/Haversine-formula/J/haversine-formula-2.j new file mode 100644 index 0000000000..158285d58f --- /dev/null +++ b/Task/Haversine-formula/J/haversine-formula-2.j @@ -0,0 +1,2 @@ + 36.12 _86.67 haversineDist 33.94 _118.4 +2887.26 diff --git a/Task/Haversine-formula/Java/haversine-formula.java b/Task/Haversine-formula/Java/haversine-formula.java new file mode 100644 index 0000000000..d6f0ba8370 --- /dev/null +++ b/Task/Haversine-formula/Java/haversine-formula.java @@ -0,0 +1,16 @@ +public class Haversine { + public static final double R = 6372.8; // In kilometers + public static double haversine(double lat1, double lon1, double lat2, double lon2) { + double dLat = Math.toRadians(lat2 - lat1); + double dLon = Math.toRadians(lon2 - lon1); + lat1 = Math.toRadians(lat1); + lat2 = Math.toRadians(lat2); + + double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2); + double c = 2 * Math.asin(Math.sqrt(a)); + return R * c; + } + public static void main(String[] args) { + System.out.println(haversine(36.12, -86.67, 33.94, -118.40)); + } +} diff --git a/Task/Haversine-formula/Julia/haversine-formula.julia b/Task/Haversine-formula/Julia/haversine-formula.julia new file mode 100644 index 0000000000..8f1c78fbed --- /dev/null +++ b/Task/Haversine-formula/Julia/haversine-formula.julia @@ -0,0 +1,5 @@ +julia> haversine(lat1,lon1,lat2,lon2) = 2 * 6372.8 * asin(sqrt(sind((lat2-lat1)/2)^2 + cosd(lat1) * cosd(lat2) * sind((lon2 - lon1)/2)^2)) +# method added to generic function haversine + +julia> haversine(36.12,-86.67,33.94,-118.4) +2887.2599506071106 diff --git a/Task/Haversine-formula/Liberty-BASIC/haversine-formula.liberty b/Task/Haversine-formula/Liberty-BASIC/haversine-formula.liberty new file mode 100644 index 0000000000..1ae4a62303 --- /dev/null +++ b/Task/Haversine-formula/Liberty-BASIC/haversine-formula.liberty @@ -0,0 +1,13 @@ +print "Haversine distance: "; using( "####.###########", havDist( 36.12, -86.67, 33.94, -118.4)); " km." +end +function havDist( th1, ph1, th2, ph2) + degtorad = acs(-1)/180 + diameter = 2 * 6372.8 + LgD = degtorad * (ph1 - ph2) + th1 = degtorad * th1 + th2 = degtorad * th2 + dz = sin( th1) - sin( th2) + dx = cos( LgD) * cos( th1) - cos( th2) + dy = sin( LgD) * cos( th1) + havDist = asn( ( dx^2 +dy^2 +dz^2)^0.5 /2) *diameter +end function diff --git a/Task/Haversine-formula/MATLAB/haversine-formula.m b/Task/Haversine-formula/MATLAB/haversine-formula.m new file mode 100644 index 0000000000..9222ded026 --- /dev/null +++ b/Task/Haversine-formula/MATLAB/haversine-formula.m @@ -0,0 +1,17 @@ +function rad = radians(degree) +% degrees to radians + rad = degree * pi / 180; +end; + +function [a,c,dlat,dlon]=haversine(lat1,lon1,lat2,lon2) +% HAVERSINE_FORMULA.AWK - converted from AWK + dlat = radians(lat2-lat1); + dlon = radians(lon2-lon1); + lat1 = radians(lat1); + lat2 = radians(lat2); + a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2; + c = 2 * atan2(sqrt(a),sqrt(1-a)); + printf("distance: %.4f km\n",6372.8 * c); +end + +[a,c,dlat,dlon] = haversine(36.12,-86.67,33.94,-118.40); % BNA to LAX diff --git a/Task/Haversine-formula/Mathematica/haversine-formula.mathematica b/Task/Haversine-formula/Mathematica/haversine-formula.mathematica new file mode 100644 index 0000000000..cd1e21c059 --- /dev/null +++ b/Task/Haversine-formula/Mathematica/haversine-formula.mathematica @@ -0,0 +1,4 @@ +distance[{theta1_, phi1_}, {theta2_, phi2_}] := + 2*6378.14 ArcSin@ + Sqrt[Haversine[(theta2 - theta1) Degree] + + Cos[theta1*Degree] Cos[theta2*Degree] Haversine[(phi2 - phi1) Degree]] diff --git a/Task/Haversine-formula/Maxima/haversine-formula.maxima b/Task/Haversine-formula/Maxima/haversine-formula.maxima new file mode 100644 index 0000000000..b8c42b637d --- /dev/null +++ b/Task/Haversine-formula/Maxima/haversine-formula.maxima @@ -0,0 +1,12 @@ +dms(d, m, s) := (d + m/60 + s/3600)*%pi/180$ + +great_circle_distance(lat1, long1, lat2, long2) := + 12742*asin(sqrt(sin((lat2 - lat1)/2)^2 + cos(lat1)*cos(lat2)*sin((long2 - long1)/2)^2))$ + +/* Coordinates are found here: + http://www.airport-data.com/airport/BNA/ + http://www.airport-data.com/airport/LAX/ */ + +great_circle_distance(dms( 36, 7, 28.10), -dms( 86, 40, 41.50), + dms( 33, 56, 32.98), -dms(118, 24, 29.05)), numer; +/* 2886.326609413624 */ diff --git a/Task/Haversine-formula/PHP/haversine-formula-1.php b/Task/Haversine-formula/PHP/haversine-formula-1.php new file mode 100644 index 0000000000..4a527d4bcf --- /dev/null +++ b/Task/Haversine-formula/PHP/haversine-formula-1.php @@ -0,0 +1,21 @@ +class POI { + private $latitude; + private $longitude; + public function __construct($latitude, $longitude) { + $this->latitude = deg2rad($latitude); + $this->longitude = deg2rad($longitude); + } + public function getLatitude() return $this->latitude; + public function getLongitude() return $this->longitude; + public function getDistanceInMetersTo(POI $other) { + $radiusOfEarth = 6371000;// Earth's radius in meters. + $diffLatitude = $other->getLatitude() - $this->latitude; + $diffLongitude = $other->getLongitude() - $this->longitude; + $a = sin($diffLatitude / 2) * sin($diffLatitude / 2) + + cos($this->latitude) * cos($other->getLatitude()) * + sin($diffLongitude / 2) * sin($diffLongitude / 2); + $c = 2 * asin(sqrt($a)); + $distance = $radiusOfEarth * $c; + return $distance; + } +} diff --git a/Task/Haversine-formula/PHP/haversine-formula-2.php b/Task/Haversine-formula/PHP/haversine-formula-2.php new file mode 100644 index 0000000000..aff83fdbc7 --- /dev/null +++ b/Task/Haversine-formula/PHP/haversine-formula-2.php @@ -0,0 +1,3 @@ +$user = new POI($_GET["latitude"], $_GET["longitude"]); +$poi = new POI(19,69276, -98,84350); // Piramide del Sol, Mexico +echo $user->getDistanceInMetersTo($poi); diff --git a/Task/Haversine-formula/PicoLisp/haversine-formula-1.l b/Task/Haversine-formula/PicoLisp/haversine-formula-1.l new file mode 100644 index 0000000000..02b1ab0dcd --- /dev/null +++ b/Task/Haversine-formula/PicoLisp/haversine-formula-1.l @@ -0,0 +1,17 @@ +(scl 12) +(load "@lib/math.l") + +(de haversine (Th1 Ph1 Th2 Ph2) + (setq + Ph1 (*/ (- Ph1 Ph2) pi 180.0) + Th1 (*/ Th1 pi 180.0) + Th2 (*/ Th2 pi 180.0) ) + (let + (DX (- (*/ (cos Ph1) (cos Th1) 1.0) (cos Th2)) + DY (*/ (sin Ph1) (cos Th1) 1.0) + DZ (- (sin Th1) (sin Th2)) ) + (* `(* 2 6371) + (asin + (/ + (sqrt (+ (* DX DX) (* DY DY) (* DZ DZ))) + 2 ) ) ) ) ) diff --git a/Task/Haversine-formula/PicoLisp/haversine-formula-2.l b/Task/Haversine-formula/PicoLisp/haversine-formula-2.l new file mode 100644 index 0000000000..dd31bc6a77 --- /dev/null +++ b/Task/Haversine-formula/PicoLisp/haversine-formula-2.l @@ -0,0 +1,4 @@ +(prinl + "Haversine distance: " + (round (haversine 36.12 -86.67 33.94 -118.4)) + " km" ) diff --git a/Task/Haversine-formula/Python/haversine-formula.py b/Task/Haversine-formula/Python/haversine-formula.py new file mode 100644 index 0000000000..d2931713e5 --- /dev/null +++ b/Task/Haversine-formula/Python/haversine-formula.py @@ -0,0 +1,16 @@ +>>> import math +>>> def haversine(lat1, lon1, lat2, lon2): + R = 6372.8 + # In kilometers + dLat = math.radians(lat2 - lat1) + dLon = math.radians(lon2 - lon1) + lat1 = math.radians(lat1) + lat2 = math.radians(lat2) + + a = math.sin(dLat / 2) * math.sin(dLat / 2) + math.sin(dLon / 2) * math.sin(dLon / 2) * math.cos(lat1) * math.cos(lat2) + c = 2 * math.asin(math.sqrt(a)) + return R * c + +>>> haversine(36.12, -86.67, 33.94, -118.40) +2887.2599506071106 +>>> diff --git a/Task/Haversine-formula/R/haversine-formula.r b/Task/Haversine-formula/R/haversine-formula.r new file mode 100644 index 0000000000..87bc482ae7 --- /dev/null +++ b/Task/Haversine-formula/R/haversine-formula.r @@ -0,0 +1,20 @@ +dms_to_rad <- function(d, m, s) (d + m / 60 + s / 3600) * pi / 180 + +# Volumetric mean radius is 6371 km, see http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html +# The diameter is thus 12742 km + +great_circle_distance <- function(lat1, long1, lat2, long2) { + a <- sin(0.5 * (lat2 - lat1)) + b <- sin(0.5 * (long2 - long1)) + 12742 * asin(sqrt(a * a + cos(lat1) * cos(lat2) * b * b)) +} + +# Coordinates are found here: +# http://www.airport-data.com/airport/BNA/ +# http://www.airport-data.com/airport/LAX/ + +great_circle_distance( + dms_to_rad(36, 7, 28.10), dms_to_rad( 86, 40, 41.50), # Nashville International Airport (BNA) + dms_to_rad(33, 56, 32.98), dms_to_rad(118, 24, 29.05)) # Los Angeles International Airport (LAX) + +# Output: 2886.327 diff --git a/Task/Haversine-formula/REXX/haversine-formula.rexx b/Task/Haversine-formula/REXX/haversine-formula.rexx new file mode 100644 index 0000000000..5f3c432de7 --- /dev/null +++ b/Task/Haversine-formula/REXX/haversine-formula.rexx @@ -0,0 +1,89 @@ +/*REXX pgm calculates distance between Nashville & Los Angles airports. */ +say " Nashville: north 36º 7.2', west 86º 40.2' = 36.12º, -86.67º" +say "Los Angles: north 33º 56.4', west 118º 24.0' = 33.94º, -118.40º" +say +$.= /*set defaults for subroutines. */ +dist=surfaceDistance(36.12, -86.67, 33.94, -118.4) +kdist=format(dist/1 ,,2) /*show 2 digs past decimal point.*/ +mdist=format(dist/1.609344,,2) /* " " " " " " */ +ndist=format(mdist*5280/6076.1,,2) /* " " " " " " */ +say ' distance between= ' kdist " kilometers," +say ' or ' mdist " statute miles," +say ' or ' ndist " nautical or air miles." +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SURFACEDISTANCE subroutine──────────*/ +surfaceDistance: arg th1,ph1,th2,ph2 /*use haversine formula for dist.*/ +numeric digits digits()*2 /*double the number of digits. */ +radius = 6372.8 /*earth's mean radius in km */ + ph1 = d2r(ph1-ph2) /*convert degs──►radians & reduce*/ + ph2 = d2r(ph2) /* " " " " " */ + th1 = d2r(th1) /* " " " " " */ + th2 = d2r(th2) + x = cos(ph1) * cos(th1) - cos(th2) + y = sin(ph1) * cos(th1) + z = sin(th1) - sin(th2) +return radius * 2 * aSin(sqrt(x**2+y**2+z**2)/2 ) +/*═════════════════════════════general 1-line subs══════════════════════*/ +d2d: return arg(1) // 360 /*normalize degrees. */ +d2r: return r2r(arg(1)*pi() / 180) /*normalize and convert deg──►rad*/ +r2d: return d2d((arg(1)*180 / pi())) /*normalize and convert rad──►deg*/ +r2r: return arg(1) // (2*pi()) /*normalize radians. */ +p: return word(arg(1),1) /*pick the first of two words. */ +pi: if $.pipi=='' then $.pipi=$pi(); return $.pipi /*return π.*/ + +aCos: procedure expose $.; arg x; if x<-1|x>1 then call $81r -1,1,x,"ACOS" + return .5*pi()-aSin(x) /*$81R says arg is out of range,*/ + /* and it isn't included here.*/ +aSin: procedure expose $.; parse arg x + if x<-1 | x>1 then call $81r -1,1,x,"ASIN"; s=x*x + if abs(x)>=.7 then return sign(x)*aCos(sqrt(1-s),'-ASIN') + z=x; o=x; p=z; do j=2 by 2; o=o*s*(j-1)/j; z=z+o/(j+1) + if z=p then leave; p=z; end; return z + +cos: procedure expose $.; parse arg x; x=r2r(x); a=abs(x) + numeric fuzz min(9,digits()-9); if a=pi() then return -1 + if a=pi()/2 | a=2*pi() then return 0; if a=pi()/3 then return .5 + if a=2*pi()/3 then return -.5; return .sinCos(1,1,-1) + +sin: procedure expose $.; parse arg x; x=r2r(x); + numeric fuzz min(5,digits()-3) + if abs(x)=pi() then return 0; return .sinCos(x,x,1) + +.sinCos: parse arg z,_,i; x=x*x; p=z; do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_ + if z=p then leave; p=z; end; return z /*used by SIN & COS.*/ + +sqrt: procedure; parse arg x; if x=0 then return 0; d=digits() + numeric digits 11; g=.sqrtGuess(); do j=0 while p>9; m.j=p; p=p%2+1; end + do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k; g=.5*(g+x/g);end + numeric digits d; return g/1 +.sqrtGuess: numeric form; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 + +$pi: return , +'3.1415926535897932384626433832795028841971693993751058209749445923078'||, +'164062862089986280348253421170679821480865132823066470938446095505822'||, +'3172535940812848111745028410270193852110555964462294895493038196' +/*┌───────────────────────────────────────────────────────────────────────┐ + │ A note on built-in functions. REXX doesn't have a lot of mathmatical │ + │ or (particularly) trigomentric functions, so REXX programmers have │ + │ to write their own. Usually, this is done once, or most likely, one │ + │ is borrowed from another program. Knowing this, the one that is used │ + │ has a lot of boilerplate in it. Once coded and throughly debugged, I │ + │ put those commonly-used subroutines into the "1-line sub" section. │ + │ │ + │ Programming note: the "general 1-line" subroutines are taken from │ + │ other programs that I wrote, but I broke up their one line of source │ + │ so it can be viewed without shifting the viewing window. │ + │ │ + │ The "er 81" [which won't happen here] just shows an error telling │ + │ the legal range for ARCxxx functions (in this case: -1 ──► +1). │ + │ │ + │ Similarly, the SQRT function checks for a negative argument │ + │ [which again, won't happen here]. │ + │ │ + │ The pi constant (as used here) is actually a much more robust function│ + │ and will return up to one million digits in the real version. │ + │ │ + │ One bad side effect is that, like a automobile without a hood, you see│ + │ all the dirty stuff going on. Also, don't visit a sausage factory. │ + └───────────────────────────────────────────────────────────────────────┘ */ diff --git a/Task/Haversine-formula/Racket/haversine-formula.rkt b/Task/Haversine-formula/Racket/haversine-formula.rkt new file mode 100644 index 0000000000..63bdfe7059 --- /dev/null +++ b/Task/Haversine-formula/Racket/haversine-formula.rkt @@ -0,0 +1,15 @@ +#lang racket +(require math) +(define earth-radius 6371) + +(define (distance lat1 long1 lat2 long2) + (define (h a b) (sqr (sin (/ (- b a) 2)))) + (* 2 earth-radius + (asin (sqrt (+ (h lat1 lat2) + (* (cos lat1) (cos lat2) (h long1 long2))))))) + +(define (deg-to-rad d m s) + (* (/ pi 180) (+ d (/ m 60) (/ s 3600)))) + +(distance (deg-to-rad 36 7.2 0) (deg-to-rad 86 40.2 0) + (deg-to-rad 33 56.4 0) (deg-to-rad 118 24.0 0)) diff --git a/Task/Haversine-formula/Ruby/haversine-formula.rb b/Task/Haversine-formula/Ruby/haversine-formula.rb new file mode 100644 index 0000000000..a2441cb0d5 --- /dev/null +++ b/Task/Haversine-formula/Ruby/haversine-formula.rb @@ -0,0 +1,18 @@ +include Math + +Radius = 6371 # rough radius of the Earth, in kilometers + +def spherical_distance(start_coords, end_coords) + lat1, long1 = deg2rad *start_coords + lat2, long2 = deg2rad *end_coords + 2 * Radius * asin(sqrt(sin((lat2-lat1)/2)**2 + cos(lat1) * cos(lat2) * sin((long2 - long1)/2)**2)) +end + +def deg2rad(lat, long) + [lat * PI / 180, long * PI / 180] +end + +bna = [36.12, -86.67] +lax = [33.94, -118.4] + +puts "%.1f" % spherical_distance(bna, lax) diff --git a/Task/Haversine-formula/Scala/haversine-formula.scala b/Task/Haversine-formula/Scala/haversine-formula.scala new file mode 100644 index 0000000000..844793f485 --- /dev/null +++ b/Task/Haversine-formula/Scala/haversine-formula.scala @@ -0,0 +1,18 @@ +import math._ + +object Haversine { + val R = 6372.8 //radius in km + + def haversine(lat1:Double, lon1:Double, lat2:Double, lon2:Double)={ + val dLat=(lat2 - lat1).toRadians + val dLon=(lon2 - lon1).toRadians + + val a = pow(sin(dLat/2),2) + pow(sin(dLon/2),2) * cos(lat1.toRadians) * cos(lat2.toRadians) + val c = 2 * asin(sqrt(a)) + R * c + } + + def main(args: Array[String]): Unit = { + println(haversine(36.12, -86.67, 33.94, -118.40)) + } +} diff --git a/Task/Haversine-formula/Scheme/haversine-formula.ss b/Task/Haversine-formula/Scheme/haversine-formula.ss new file mode 100644 index 0000000000..a61ead5c70 --- /dev/null +++ b/Task/Haversine-formula/Scheme/haversine-formula.ss @@ -0,0 +1,12 @@ +(define earth-radius 6371) +(define pi (acos -1)) + +(define (distance lat1 long1 lat2 long2) +(define (h a b) (expt (sin (/ (- b a) 2)) 2)) +(* 2 earth-radius (asin (sqrt (+ (h lat1 lat2) (* (cos lat1) (cos lat2) (h long1 long2))))))) + +(define (deg-to-rad d m s) (* (/ pi 180) (+ d (/ m 60) (/ s 3600)))) + +(distance (deg-to-rad 36 7.2 0) (deg-to-rad 86 40.2 0) + (deg-to-rad 33 56.4 0) (deg-to-rad 118 24.0 0)) +; 2886.444442837984 diff --git a/Task/Haversine-formula/Tcl/haversine-formula.tcl b/Task/Haversine-formula/Tcl/haversine-formula.tcl new file mode 100644 index 0000000000..4a2183d63b --- /dev/null +++ b/Task/Haversine-formula/Tcl/haversine-formula.tcl @@ -0,0 +1,17 @@ +package require Tcl 8.5 +proc haversineFormula {lat1 lon1 lat2 lon2} { + set rads [expr atan2(0,-1)/180] + set R 6372.8 ;# In kilometers + + set dLat [expr {($lat2-$lat1) * $rads}] + set dLon [expr {($lon2-$lon1) * $rads}] + set lat1 [expr {$lat1 * $rads}] + set lat2 [expr {$lat2 * $rads}] + + set a [expr {sin($dLat/2)**2 + sin($dLon/2)**2*cos($lat1)*cos($lat2)}] + set c [expr {2*asin(sqrt($a))}] + return [expr {$R * $c}] +} + +# Don't bother with too much inappropriate accuracy! +puts [format "distance=%.1f km" [haversineFormula 36.12 -86.67 33.94 -118.40]] diff --git a/Task/Hello-world-Graphical/0DESCRIPTION b/Task/Hello-world-Graphical/0DESCRIPTION new file mode 100644 index 0000000000..b7bd88b526 --- /dev/null +++ b/Task/Hello-world-Graphical/0DESCRIPTION @@ -0,0 +1,3 @@ +In this User Output task, the goal is to display the string "Goodbye, World!" on a [[GUI]] object (alert box, plain window, text area, etc.). + +See also: [[Hello world/Text]] diff --git a/Task/Hello-world-Graphical/1META.yaml b/Task/Hello-world-Graphical/1META.yaml new file mode 100644 index 0000000000..04942ee47c --- /dev/null +++ b/Task/Hello-world-Graphical/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Basic language learning +note: GUI +requires: +- Graphics diff --git a/Task/Hello-world-Graphical/ATS/hello-world-graphical.ats b/Task/Hello-world-Graphical/ATS/hello-world-graphical.ats new file mode 100644 index 0000000000..6632bb1ebe --- /dev/null +++ b/Task/Hello-world-Graphical/ATS/hello-world-graphical.ats @@ -0,0 +1,35 @@ +%{^ +extern +ats_void_type +mainats (ats_int_type argc, ats_ptr_type argv); +%} + +staload "contrib/glib/SATS/glib.sats" +staload "contrib/glib/SATS/glib-object.sats" +staload "contrib/GTK/SATS/gtk.sats" + +extern fun main1 (): void = "main1" + +implement main1 () = () where { + val window = gtk_window_new (GTK_WINDOW_TOPLEVEL) + val (pf | title) = gstring_of_string ("Goodbye, World!") + val () = gtk_window_set_title (window, title) + prval () = pf (title) + val _sid = g_signal_connect + (window, (gsignal)"delete-event", (G_CALLBACK)gtk_main_quit, (gpointer)null) + val () = gtk_widget_show (window) + val () = gtk_main () + val () = gtk_widget_destroy0 (window) +} + +implement main_dummy () = () + +%{$ +ats_void_type +mainats (ats_int_type argc, ats_ptr_type argv) +{ + gtk_init ((int*)&argc, (char***)&argv); + main1 (); + return; +} +%} diff --git a/Task/Hello-world-Graphical/ActionScript/hello-world-graphical.as b/Task/Hello-world-Graphical/ActionScript/hello-world-graphical.as new file mode 100644 index 0000000000..6461879f1b --- /dev/null +++ b/Task/Hello-world-Graphical/ActionScript/hello-world-graphical.as @@ -0,0 +1,3 @@ +var textField:TextField = new TextField(); +stage.addChild(textField); +textField.text = "Goodbye, World!" diff --git a/Task/Hello-world-Graphical/Ada/hello-world-graphical.ada b/Task/Hello-world-Graphical/Ada/hello-world-graphical.ada new file mode 100644 index 0000000000..ac980b1b31 --- /dev/null +++ b/Task/Hello-world-Graphical/Ada/hello-world-graphical.ada @@ -0,0 +1,47 @@ +with Gdk.Event; use Gdk.Event; +with Gtk.Label; use Gtk.Label; +with Gtk.Window; use Gtk.Window; +with Gtk.Widget; use Gtk.Widget; + +with Gtk.Handlers; +with Gtk.Main; + +procedure Windowed_Goodbye_World is + Window : Gtk_Window; + Label : Gtk_Label; + + package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record); + package Return_Handlers is + new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean); + + function Delete_Event (Widget : access Gtk_Widget_Record'Class) + return Boolean is + begin + return False; + end Delete_Event; + + procedure Destroy (Widget : access Gtk_Widget_Record'Class) is + begin + Gtk.Main.Main_Quit; + end Destroy; + +begin + Gtk.Main.Init; + Gtk.Window.Gtk_New (Window); + Gtk_New (Label, "Goodbye, World!"); + Add (Window, Label); + Return_Handlers.Connect + ( Window, + "delete_event", + Return_Handlers.To_Marshaller (Delete_Event'Access) + ); + Handlers.Connect + ( Window, + "destroy", + Handlers.To_Marshaller (Destroy'Access) + ); + Show_All (Label); + Show (Window); + + Gtk.Main.Main; +end Windowed_Goodbye_World; diff --git a/Task/Hello-world-Graphical/AppleScript/hello-world-graphical.applescript b/Task/Hello-world-Graphical/AppleScript/hello-world-graphical.applescript new file mode 100644 index 0000000000..09e6b71c5b --- /dev/null +++ b/Task/Hello-world-Graphical/AppleScript/hello-world-graphical.applescript @@ -0,0 +1 @@ +display dialog "Goodbye, World!" buttons {"Bye"} diff --git a/Task/Hello-world-Graphical/Applesoft-BASIC/hello-world-graphical.bas b/Task/Hello-world-Graphical/Applesoft-BASIC/hello-world-graphical.bas new file mode 100644 index 0000000000..83fefd5d9d --- /dev/null +++ b/Task/Hello-world-Graphical/Applesoft-BASIC/hello-world-graphical.bas @@ -0,0 +1,36 @@ + 1 LET T$ = "GOODBYE, WORLD!" + 2 LET R = 5:GX = 3:GY = 2:O = 3:XC = R + GX:YC = R * 2 + GY + 3 TEXT : HOME : TEXT : HGR : HCOLOR= 7: HPLOT 0,0: CALL 62454: HCOLOR= 6 + 4 LET L = LEN (T$): FOR I = 1 TO L:K = ASC ( MID$ (T$,I,1)):XO = XC:YO = YC: GOSUB 5:XC = XO + 1:YC = YO: GOSUB 7: NEXT : END + 5 IF K > 64 THEN K = K + LC: GOSUB 20:LC = 32: RETURN + 6 LET LC = 0: ON K > = 32 GOTO 20: RETURN + 7 GOSUB 20:XC = XC + R * 2 + GX: IF XC > 279 - R THEN XC = R + GX:YC = YC + GY + R * 5 + 8 RETURN + 9 LET XC = XC - R * 2: RETURN + 10 LET Y = R:D = 1 - R:X = 0 + 11 IF D > = 0 THEN Y = Y - 1:D = D - Y * 2 + 12 LET D = D + X * 2 + 3 + 13 IF O = 1 OR O = 3 THEN GOSUB 17 + 14 IF O = 2 OR O = 3 THEN GOSUB 19 + 15 LET X = X + 1: IF X < Y THEN 11 + 16 LET O = 3:E = 0: RETURN + 17 HPLOT XC - X,YC + Y: HPLOT XC + X,YC + Y: HPLOT XC - Y,YC + X: IF NOT E THEN HPLOT XC + Y,YC + X + 18 RETURN + 19 HPLOT XC - X,YC - Y: HPLOT XC + X,YC - Y: HPLOT XC - Y,YC - X: HPLOT XC + Y,YC - X: RETURN + 20 LET M = K - 31 + 21 ON M GOTO 32,33,34,35,36,37,38,39,40,41,42,43,44 + 22 LET M = M - 32 + 23 ON M GOTO 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87 + 24 LET M = M - 32 + 25 ON M GOTO 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,10,112,113,114,115,116,117,118,119,120,121 + 32 RETURN + 33 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R - GY: HPLOT XC - R,YC + R: GOTO 9: REM ! + 44 HPLOT XC - R,YC + R + R / 2 TO XC - R,YC + R: GOTO 9: REM , + 71 LET O = 2:YC = YC - R: GOSUB 10:YC = YC + R: HPLOT XC - R,YC TO XC - R,YC - R: HPLOT XC + R / 2,YC TO XC + R,YC TO XC + R,YC + R:O = 1: GOTO 10: REM G + 87 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R TO XC,YC TO XC + R,YC + R TO XC + R,YC - R * 2: RETURN : REM W + 98 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 10: RETURN : REM B +100 HPLOT XC + R,YC - R * 2 TO XC + R,YC + R: GOTO 10: REM D +101 HPLOT XC - R,YC TO XC + R,YC:E = 1: GOTO 10: REM E +108 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 9: REM L +114 HPLOT XC - R,YC - R TO XC - R,YC + R:O = 2: GOTO 10: REM R +121 HPLOT XC - R,YC - R TO XC,YC + R: HPLOT XC + R,YC - R TO XC - R,YC + R * 3: RETURN : REM Y diff --git a/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-1.ahk b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-1.ahk new file mode 100644 index 0000000000..b833e0a6a2 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-1.ahk @@ -0,0 +1 @@ +MsgBox, Goodbye`, World! diff --git a/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-2.ahk b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-2.ahk new file mode 100644 index 0000000000..fc3b650175 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-2.ahk @@ -0,0 +1 @@ +ToolTip, Goodbye`, World! diff --git a/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-3.ahk b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-3.ahk new file mode 100644 index 0000000000..abe5734342 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-3.ahk @@ -0,0 +1,5 @@ +Gui, Add, Text, x4 y4, To be announced: +Gui, Add, Edit, xp+90 yp-3, Goodbye, World! +Gui, Add, Button, xp+98 yp-1, OK +Gui, Show, w226 h22 , Rosetta Code +Return diff --git a/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-4.ahk b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-4.ahk new file mode 100644 index 0000000000..6a704ab3ba --- /dev/null +++ b/Task/Hello-world-Graphical/AutoHotkey/hello-world-graphical-4.ahk @@ -0,0 +1 @@ +SplashTextOn, 100, 100, Rosetta Code, Goodbye, World! diff --git a/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-1.autoit b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-1.autoit new file mode 100644 index 0000000000..58187a6fb6 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-1.autoit @@ -0,0 +1,9 @@ +; display a window +$hMain = GUICreate("Hello World", 178, 125) +GUICtrlCreateLabel("Goodbye, world", 48, 48, 78, 17) +GUISetState() +While GUIGetMsg() <> -3 +WEnd +GUIDelete($hMain) +;a message box +MsgBox(0, "", "Goodbye, world") diff --git a/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-2.autoit b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-2.autoit new file mode 100644 index 0000000000..98444a7b1a --- /dev/null +++ b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-2.autoit @@ -0,0 +1 @@ +MsgBox(0,"Goodbye","Goodbye, World!") diff --git a/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-3.autoit b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-3.autoit new file mode 100644 index 0000000000..7cd33957b3 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoIt/hello-world-graphical-3.autoit @@ -0,0 +1 @@ +ToolTip("Goodbye, World!") diff --git a/Task/Hello-world-Graphical/BASIC/hello-world-graphical-1.bas b/Task/Hello-world-Graphical/BASIC/hello-world-graphical-1.bas new file mode 100644 index 0000000000..0bf875b33c --- /dev/null +++ b/Task/Hello-world-Graphical/BASIC/hello-world-graphical-1.bas @@ -0,0 +1,17 @@ +' Demonstrate a simple Windows application using FreeBasic + +#include once "windows.bi" + +Declare Function WinMain(ByVal hInst As HINSTANCE, _ + ByVal hPrev As HINSTANCE, _ + ByVal szCmdLine as String, _ + ByVal iCmdShow As Integer) As Integer +End WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL ) + +Function WinMain (ByVal hInst As HINSTANCE, _ + ByVal hPrev As HINSTANCE, _ + ByVal szCmdLine As String, _ + ByVal iCmdShow As Integer) As Integer + MessageBox(NULL, "Goodbye World", "Goodbye World", MB_ICONINFORMATION) + function = 0 +End Function diff --git a/Task/Hello-world-Graphical/BASIC/hello-world-graphical-2.bas b/Task/Hello-world-Graphical/BASIC/hello-world-graphical-2.bas new file mode 100644 index 0000000000..2142044d54 --- /dev/null +++ b/Task/Hello-world-Graphical/BASIC/hello-world-graphical-2.bas @@ -0,0 +1,14 @@ +' Demonstrate a simple Windows/Linux application using GTK/FreeBasic + +#INCLUDE "gtk/gtk.bi" + +gtk_init(@__FB_ARGC__, @__FB_ARGV__) + +VAR win = gtk_window_new (GTK_WINDOW_TOPLEVEL) +gtk_window_set_title (gtk_window (win), "Goodbye, World") +g_signal_connect(G_OBJECT (win), "delete-event", @gtk_main_quit, 0) +gtk_widget_show_all (win) + +gtk_main() + +END 0 diff --git a/Task/Hello-world-Graphical/BASIC256/hello-world-graphical.basic256 b/Task/Hello-world-Graphical/BASIC256/hello-world-graphical.basic256 new file mode 100644 index 0000000000..6cec5e7fcf --- /dev/null +++ b/Task/Hello-world-Graphical/BASIC256/hello-world-graphical.basic256 @@ -0,0 +1,6 @@ +clg +font "times new roman", 20,100 +color orange +rect 10,10, 140,30 +color red +text 10,10, "Hello World" diff --git a/Task/Hello-world-Graphical/BBC-BASIC/hello-world-graphical.bbc b/Task/Hello-world-Graphical/BBC-BASIC/hello-world-graphical.bbc new file mode 100644 index 0000000000..055b55ee97 --- /dev/null +++ b/Task/Hello-world-Graphical/BBC-BASIC/hello-world-graphical.bbc @@ -0,0 +1 @@ + SYS "MessageBox", @hwnd%, "Goodbye, World!", "", 0 diff --git a/Task/Hello-world-Graphical/C++-CLI/hello-world-graphical.cpp b/Task/Hello-world-Graphical/C++-CLI/hello-world-graphical.cpp new file mode 100644 index 0000000000..7c26287cfb --- /dev/null +++ b/Task/Hello-world-Graphical/C++-CLI/hello-world-graphical.cpp @@ -0,0 +1,6 @@ +using namespace System::Windows::Forms; + +int main(array ^args) +{ + MessageBox::Show("Goodbye, World!", "Rosetta Code"); +} diff --git a/Task/Hello-world-Graphical/C++/hello-world-graphical-1.cpp b/Task/Hello-world-Graphical/C++/hello-world-graphical-1.cpp new file mode 100644 index 0000000000..9fc5a8cc77 --- /dev/null +++ b/Task/Hello-world-Graphical/C++/hello-world-graphical-1.cpp @@ -0,0 +1,7 @@ +#include +int main(int argc, char *argv[]) +{ + Gtk::Main app(argc, argv); + Gtk::MessageDialog msg("Goodbye, World!"); + msg.run(); +} diff --git a/Task/Hello-world-Graphical/C++/hello-world-graphical-2.cpp b/Task/Hello-world-Graphical/C++/hello-world-graphical-2.cpp new file mode 100644 index 0000000000..529a5fabbf --- /dev/null +++ b/Task/Hello-world-Graphical/C++/hello-world-graphical-2.cpp @@ -0,0 +1,5 @@ +#include "afx.h" +void ShowGoodbyeWorld(CWnd* pWnd) +{ + pWnd->SetWindowText(_T("Goodbye, World!")); +} diff --git a/Task/Hello-world-Graphical/C++/hello-world-graphical-3.cpp b/Task/Hello-world-Graphical/C++/hello-world-graphical-3.cpp new file mode 100644 index 0000000000..98a6970bf7 --- /dev/null +++ b/Task/Hello-world-Graphical/C++/hello-world-graphical-3.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char **argv) { + Fl_Window *window = new Fl_Window(300,180); + Fl_Box *box = new Fl_Box(20,40,260,100,"Goodby, World!"); + box->box(FL_UP_BOX); + box->labelsize(36); + box->labelfont(FL_BOLD+FL_ITALIC); + box->labeltype(FL_SHADOW_LABEL); + window->end(); + window->show(argc, argv); + return Fl::run(); +} diff --git a/Task/Hello-world-Graphical/C/hello-world-graphical-1.c b/Task/Hello-world-Graphical/C/hello-world-graphical-1.c new file mode 100644 index 0000000000..04c1c3d073 --- /dev/null +++ b/Task/Hello-world-Graphical/C/hello-world-graphical-1.c @@ -0,0 +1,14 @@ +#include + +int main (int argc, char **argv) { + GtkWidget *window; + gtk_init(&argc, &argv); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World"); + g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL); + gtk_widget_show_all (window); + + gtk_main(); + return 0; +} diff --git a/Task/Hello-world-Graphical/C/hello-world-graphical-2.c b/Task/Hello-world-Graphical/C/hello-world-graphical-2.c new file mode 100644 index 0000000000..1a4145bb97 --- /dev/null +++ b/Task/Hello-world-Graphical/C/hello-world-graphical-2.c @@ -0,0 +1,5 @@ +#include "windows.h" +void SayGoodbyeWorld(HWND hWnd) +{ + SetWindowText(hWnd, _T("Goodbye, World!")); +} diff --git a/Task/Hello-world-Graphical/COBOL/hello-world-graphical.cobol b/Task/Hello-world-Graphical/COBOL/hello-world-graphical.cobol new file mode 100644 index 0000000000..2f46c51e30 --- /dev/null +++ b/Task/Hello-world-Graphical/COBOL/hello-world-graphical.cobol @@ -0,0 +1,19 @@ + program-id. ghello. + data division. + working-storage section. + 01 var pic x(1). + 01 lynz pic 9(3). + 01 colz pic 9(3). + 01 msg pic x(15) value "Goodbye, world!". + procedure division. + accept lynz from lines end-accept + divide lynz by 2 giving lynz. + accept colz from columns end-accept + divide colz by 2 giving colz. + subtract 7 from colz giving colz. + display msg + at line number lynz + column number colz + end-display + accept var end-accept + stop run. diff --git a/Task/Hello-world-Graphical/Clean/hello-world-graphical.clean b/Task/Hello-world-Graphical/Clean/hello-world-graphical.clean new file mode 100644 index 0000000000..c5214b90d5 --- /dev/null +++ b/Task/Hello-world-Graphical/Clean/hello-world-graphical.clean @@ -0,0 +1,7 @@ +import StdEnv, StdIO + +Start :: *World -> *World +Start world = startIO NDI Void (snd o openDialog undef hello) [] world +where + hello = Dialog "" (TextControl "Goodbye, World!" []) + [WindowClose (noLS closeProcess)] diff --git a/Task/Hello-world-Graphical/Clojure/hello-world-graphical.clj b/Task/Hello-world-Graphical/Clojure/hello-world-graphical.clj new file mode 100644 index 0000000000..5d92975f65 --- /dev/null +++ b/Task/Hello-world-Graphical/Clojure/hello-world-graphical.clj @@ -0,0 +1,15 @@ +(ns experimentation.core + (:import (javax.swing JOptionPane JFrame JTextArea JButton) + (java.awt FlowLayout))) + +(JOptionPane/showMessageDialog nil "Goodbye, World!") +(let [button (JButton. "Goodbye, World!") + window (JFrame. "Goodbye, World!") + text (JTextArea. "Goodbye, World!")] + (doto window + (.setLayout (FlowLayout.)) + (.add button) + (.add text) + (.pack) + (.setDefaultCloseOperation (JFrame/EXIT_ON_CLOSE)) + (.setVisible true))) diff --git a/Task/Hello-world-Graphical/Cobra/hello-world-graphical.cobra b/Task/Hello-world-Graphical/Cobra/hello-world-graphical.cobra new file mode 100644 index 0000000000..910dbd29e4 --- /dev/null +++ b/Task/Hello-world-Graphical/Cobra/hello-world-graphical.cobra @@ -0,0 +1,14 @@ +@args -pkg:gtk-sharp-2.0 + +use Gtk + +class MainProgram + def main + Application.init + dialog = MessageDialog(nil, + DialogFlags.DestroyWithParent, + MessageType.Info, + ButtonsType.Ok, + "Goodbye, World!") + dialog.run + dialog.destroy diff --git a/Task/Hello-world-Graphical/CoffeeScript/hello-world-graphical.coffee b/Task/Hello-world-Graphical/CoffeeScript/hello-world-graphical.coffee new file mode 100644 index 0000000000..3c97f8cdc7 --- /dev/null +++ b/Task/Hello-world-Graphical/CoffeeScript/hello-world-graphical.coffee @@ -0,0 +1 @@ +alert "Goodbye, World!" diff --git a/Task/Hello-world-Graphical/Common-Lisp/hello-world-graphical.lisp b/Task/Hello-world-Graphical/Common-Lisp/hello-world-graphical.lisp new file mode 100644 index 0000000000..3f3c7c4130 --- /dev/null +++ b/Task/Hello-world-Graphical/Common-Lisp/hello-world-graphical.lisp @@ -0,0 +1,15 @@ +(use-package :ltk) + +(defun show-message (text) + "Show message in a label on a Tk window" + (with-ltk () + (let* ((label (make-instance 'label :text text)) + (button (make-instance 'button :text "Done" + :command (lambda () + (ltk::break-mainloop) + (ltk::update))))) + (pack label :side :top :expand t :fill :both) + (pack button :side :right) + (mainloop)))) + +(show-message "Goodbye World") diff --git a/Task/Hello-world-Graphical/D/hello-world-graphical.d b/Task/Hello-world-Graphical/D/hello-world-graphical.d new file mode 100644 index 0000000000..cec1b32f3b --- /dev/null +++ b/Task/Hello-world-Graphical/D/hello-world-graphical.d @@ -0,0 +1,15 @@ +import gtk.MainWindow, gtk.Label, gtk.Main; + +class GoodbyeWorld : MainWindow { + this() { + super("GtkD"); + add(new Label("Goodbye World")); + showAll(); + } +} + +void main(string[] args) { + Main.init(args); + new GoodbyeWorld(); + Main.run(); +} diff --git a/Task/Hello-world-Graphical/Delphi/hello-world-graphical.delphi b/Task/Hello-world-Graphical/Delphi/hello-world-graphical.delphi new file mode 100644 index 0000000000..feb1128ec9 --- /dev/null +++ b/Task/Hello-world-Graphical/Delphi/hello-world-graphical.delphi @@ -0,0 +1,8 @@ +program HelloWorldGraphical; + +uses + Dialogs; + +begin + ShowMessage('Goodbye, World!'); +end. diff --git a/Task/Hello-world-Graphical/Dylan/hello-world-graphical.dylan b/Task/Hello-world-Graphical/Dylan/hello-world-graphical.dylan new file mode 100644 index 0000000000..85b9da7031 --- /dev/null +++ b/Task/Hello-world-Graphical/Dylan/hello-world-graphical.dylan @@ -0,0 +1 @@ +notify-user("hello world!", frame: make()); diff --git a/Task/Hello-world-Graphical/E/hello-world-graphical.e b/Task/Hello-world-Graphical/E/hello-world-graphical.e new file mode 100644 index 0000000000..48ebd21724 --- /dev/null +++ b/Task/Hello-world-Graphical/E/hello-world-graphical.e @@ -0,0 +1,17 @@ +def := +def SWT := + +def frame := (currentDisplay) + frame.setText("Rosetta Code") + frame.setBounds(30, 30, 230, 60) + frame.addDisposeListener(def _ { to widgetDisposed(event) { + interp.continueAtTop() + }}) + +def label := (frame, SWT.getLEFT()) + label.setText("Goodbye, World!") + swtGrid`$frame: $label` + +frame.open() + +interp.blockAtTop() diff --git a/Task/Hello-world-Graphical/EGL/hello-world-graphical.egl b/Task/Hello-world-Graphical/EGL/hello-world-graphical.egl new file mode 100644 index 0000000000..dff2d4398a --- /dev/null +++ b/Task/Hello-world-Graphical/EGL/hello-world-graphical.egl @@ -0,0 +1,16 @@ +import org.eclipse.edt.rui.widgets.*; +import dojo.widgets.*; + +handler HelloWorld type RUIhandler{initialUI =[ui]} + + ui Box {columns=1, children=[nameField, helloLabel, goButton]}; + + nameField DojoTextField {placeHolder = "What's your name?", text = "World"}; + helloLabel TextLabel {}; + goButton DojoButton {text = "Say Goodbye", onClick ::= onClick_goButton}; + + function onClick_goButton(e Event in) + helloLabel.text = "Goodbye, " + nameField.text + "!"; + end + +end diff --git a/Task/Hello-world-Graphical/Euphoria/hello-world-graphical.euphoria b/Task/Hello-world-Graphical/Euphoria/hello-world-graphical.euphoria new file mode 100644 index 0000000000..4fcc59f0ec --- /dev/null +++ b/Task/Hello-world-Graphical/Euphoria/hello-world-graphical.euphoria @@ -0,0 +1,4 @@ +include msgbox.e + +integer response +response = message_box("Goodbye, World!","Bye",MB_OK) diff --git a/Task/Hello-world-Graphical/Fantom/hello-world-graphical.fantom b/Task/Hello-world-Graphical/Fantom/hello-world-graphical.fantom new file mode 100644 index 0000000000..d33ba0c8de --- /dev/null +++ b/Task/Hello-world-Graphical/Fantom/hello-world-graphical.fantom @@ -0,0 +1,9 @@ +using fwt + +class Hello +{ + public static Void main () + { + Dialog.openInfo (null, "Goodbye world") + } +} diff --git a/Task/Hello-world-Graphical/Forth/hello-world-graphical.fth b/Task/Hello-world-Graphical/Forth/hello-world-graphical.fth new file mode 100644 index 0000000000..df684fa799 --- /dev/null +++ b/Task/Hello-world-Graphical/Forth/hello-world-graphical.fth @@ -0,0 +1 @@ +HWND z" Goodbye, World!" z" (title)" MB_OK MessageBox diff --git a/Task/Hello-world-Graphical/Frink/hello-world-graphical.frink b/Task/Hello-world-Graphical/Frink/hello-world-graphical.frink new file mode 100644 index 0000000000..ff673a1464 --- /dev/null +++ b/Task/Hello-world-Graphical/Frink/hello-world-graphical.frink @@ -0,0 +1,7 @@ +g = new graphics +g.font["SansSerif", 10] +g.text["Hello World!", 0, 0] +g.show[] + +g.print[] // Optional: render to printer +g.write["HelloWorld.png", 400, 300] // Optional: write to graphics file diff --git a/Task/Hello-world-Graphical/GUISS/hello-world-graphical.guiss b/Task/Hello-world-Graphical/GUISS/hello-world-graphical.guiss new file mode 100644 index 0000000000..9d2877fae8 --- /dev/null +++ b/Task/Hello-world-Graphical/GUISS/hello-world-graphical.guiss @@ -0,0 +1 @@ +Start,Programs,Accessories,Notepad,Type:Goodbye[comma][space]World[pling] diff --git a/Task/Hello-world-Graphical/Gambas/hello-world-graphical.gambas b/Task/Hello-world-Graphical/Gambas/hello-world-graphical.gambas new file mode 100644 index 0000000000..db16b3b652 --- /dev/null +++ b/Task/Hello-world-Graphical/Gambas/hello-world-graphical.gambas @@ -0,0 +1 @@ +Message.Info("Goodbye, World!") ' Display a simple message box diff --git a/Task/Hello-world-Graphical/Go/hello-world-graphical.go b/Task/Hello-world-Graphical/Go/hello-world-graphical.go new file mode 100644 index 0000000000..476ff68737 --- /dev/null +++ b/Task/Hello-world-Graphical/Go/hello-world-graphical.go @@ -0,0 +1,16 @@ +package main + +import "github.com/mattn/go-gtk/gtk" + +func main() { + gtk.Init(nil) + win := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL) + win.SetTitle("Goodbye, World!") + win.SetSizeRequest(300, 200) + win.Connect("destroy", gtk.MainQuit) + button := gtk.ButtonWithLabel("Goodbye, World!") + win.Add(button) + button.Connect("clicked", gtk.MainQuit) + win.ShowAll() + gtk.Main() +} diff --git a/Task/Hello-world-Graphical/Groovy/hello-world-graphical.groovy b/Task/Hello-world-Graphical/Groovy/hello-world-graphical.groovy new file mode 100644 index 0000000000..9ab30ebe24 --- /dev/null +++ b/Task/Hello-world-Graphical/Groovy/hello-world-graphical.groovy @@ -0,0 +1,11 @@ +import groovy.swing.SwingBuilder +import javax.swing.JFrame + +new SwingBuilder().edt { + optionPane().showMessageDialog(null, "Goodbye, World!") + frame(title:'Goodbye, World!', defaultCloseOperation:JFrame.EXIT_ON_CLOSE, pack:true, show: true) { + flowLayout() + button(text:'Goodbye, World!') + textArea(text:'Goodbye, World!') + } +} diff --git a/Task/Hello-world-Graphical/Haskell/hello-world-graphical-1.hs b/Task/Hello-world-Graphical/Haskell/hello-world-graphical-1.hs new file mode 100644 index 0000000000..fb612e343d --- /dev/null +++ b/Task/Hello-world-Graphical/Haskell/hello-world-graphical-1.hs @@ -0,0 +1,13 @@ +import Graphics.UI.Gtk +import Control.Monad + +messDialog = do + initGUI + dialog <- messageDialogNew Nothing [] MessageInfo ButtonsOk "Goodbye, World!" + + rs <- dialogRun dialog + when (rs == ResponseOk || rs == ResponseDeleteEvent) $ widgetDestroy dialog + + dialog `onDestroy` mainQuit + + mainGUI diff --git a/Task/Hello-world-Graphical/Haskell/hello-world-graphical-2.hs b/Task/Hello-world-Graphical/Haskell/hello-world-graphical-2.hs new file mode 100644 index 0000000000..029eeef113 --- /dev/null +++ b/Task/Hello-world-Graphical/Haskell/hello-world-graphical-2.hs @@ -0,0 +1 @@ +*Main> messDialog diff --git a/Task/Hello-world-Graphical/HicEst/hello-world-graphical-1.hicest b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-1.hicest new file mode 100644 index 0000000000..3888b21856 --- /dev/null +++ b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-1.hicest @@ -0,0 +1 @@ +WRITE(Messagebox='!') 'Goodbye, World!' diff --git a/Task/Hello-world-Graphical/HicEst/hello-world-graphical-2.hicest b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-2.hicest new file mode 100644 index 0000000000..6343cb20aa --- /dev/null +++ b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-2.hicest @@ -0,0 +1,6 @@ +link graphics +procedure main() + WOpen("size=100,20") | stop("No window") + WWrites("Goodbye, World!") + WDone() +end diff --git a/Task/Hello-world-Graphical/HicEst/hello-world-graphical-3.hicest b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-3.hicest new file mode 100644 index 0000000000..fce8c59d05 --- /dev/null +++ b/Task/Hello-world-Graphical/HicEst/hello-world-graphical-3.hicest @@ -0,0 +1,21 @@ +import gui +$include "guih.icn" + +class WindowApp : Dialog () + + # -- automatically called when the dialog is created + method component_setup () + # add 'hello world' label + label := Label("label=Hello world","pos=0,0") + add (label) + + # make sure we respond to close event + connect(self, "dispose", CLOSE_BUTTON_EVENT) + end +end + +# create and show the window +procedure main () + w := WindowApp () + w.show_modal () +end diff --git a/Task/Hello-world-Graphical/Integer-BASIC/hello-world-graphical.bas b/Task/Hello-world-Graphical/Integer-BASIC/hello-world-graphical.bas new file mode 100644 index 0000000000..1adaa6f73c --- /dev/null +++ b/Task/Hello-world-Graphical/Integer-BASIC/hello-world-graphical.bas @@ -0,0 +1,67 @@ +10 REM FONT DERIVED FROM 04B-09 BY YUJI OSHIMOTO +20 GR +30 COLOR = 12 +40 REM G +50 HLIN 0,5 AT 0 : HLIN 0,5 AT 1 +60 VLIN 2,9 AT 0 : VLIN 2,9 AT 1 +70 HLIN 2,5 AT 9 : HLIN 2,5 AT 8 +80 VLIN 4,7 AT 5 : VLIN 4,7 AT 4 +90 VLIN 4,5 AT 3 +100 REM O +110 HLIN 7,12 AT 2 : HLIN 7,12 AT 3 +120 HLIN 7,12 AT 8 : HLIN 7,12 AT 9 +130 VLIN 4,7 AT 7 : VLIN 4,7 AT 8 +140 VLIN 4,7 AT 11 : VLIN 4,7 AT 12 +150 REM O +160 HLIN 14,19 AT 2 : HLIN 14,19 AT 3 +170 HLIN 14,19 AT 8 : HLIN 14,19 AT 9 +180 VLIN 4,7 AT 14 : VLIN 4,7 AT 15 +190 VLIN 4,7 AT 18 : VLIN 4,7 AT 19 +200 REM D +210 HLIN 21,24 AT 2 : HLIN 21,24 AT 3 +220 HLIN 21,26 AT 8 : HLIN 21,26 AT 9 +230 VLIN 4,7 AT 21 : VLIN 4,7 AT 22 +240 VLIN 0,7 AT 25 : VLIN 0,7 AT 26 +250 REM - +260 HLIN 28,33 AT 4 : HLIN 28,33 AT 5 +270 REM B +280 VLIN 11,20 AT 0 : VLIN 11,20 AT 1 +290 HLIN 2,5 AT 20 : HLIN 2,5 AT 19 +300 VLIN 15,18 AT 5 : VLIN 15,18 AT 4 +310 HLIN 2,5 AT 14 : HLIN 2,5 AT 13 +320 REM Y +330 VLIN 13,20 AT 7 : VLIN 13,20 AT 8 +340 VLIN 19,20 AT 9 : VLIN 19,20 AT 10 +350 VLIN 13,24 AT 11 : VLIN 13,24 AT 12 +360 VLIN 23,24 AT 10 : VLIN 23,24 AT 9 +370 REM E +380 VLIN 13,20 AT 14 : VLIN 13,20 AT 15 +390 HLIN 16,19 AT 13 : HLIN 16,19 AT 14 +400 HLIN 18,19 AT 15 : HLIN 18,19 AT 16 +410 HLIN 16,17 AT 17 : HLIN 16,17 AT 18 +420 HLIN 16,19 AT 19 : HLIN 16,19 AT 20 +430 REM , +440 VLIN 17,22 AT 21 : VLIN 17,22 AT 22 +450 REM W +460 VLIN 24,33 AT 0 : VLIN 24,33 AT 1 : VLIN 24,33 AT 3 +470 VLIN 24,33 AT 4 : VLIN 24,33 AT 6 : VLIN 24,33 AT 7 +480 HLIN 0,7 AT 33 : HLIN 0,7 AT 32 +490 REM O +500 HLIN 9,14 AT 26 : HLIN 9,14 AT 27 +510 HLIN 9,14 AT 32 : HLIN 9,14 AT 33 +520 VLIN 28,31 AT 9 : VLIN 28,31 AT 10 +530 VLIN 28,31 AT 13 : VLIN 28,31 AT 14 +540 REM R +550 HLIN 16,21 AT 26 : HLIN 16,21 AT 27 +560 VLIN 28,33 AT 16 : VLIN 28,33 AT 17 +570 REM L +580 VLIN 24,33 AT 23 : VLIN 24,33 AT 24 +590 REM D +600 HLIN 26,29 AT 26 : HLIN 26,29 AT 27 +610 HLIN 26,29 AT 32 : HLIN 26,29 AT 33 +620 VLIN 28,33 AT 26 : VLIN 28,33 AT 27 +630 VLIN 24,33 AT 30 : VLIN 24,33 AT 31 +640 REM ! +650 VLIN 24,29 AT 33 : VLIN 24,29 AT 34 +660 VLIN 32,33 AT 33 : VLIN 32,33 AT 34 +670 END diff --git a/Task/Hello-world-Graphical/Ioke/hello-world-graphical.ioke b/Task/Hello-world-Graphical/Ioke/hello-world-graphical.ioke new file mode 100644 index 0000000000..8aa30d0511 --- /dev/null +++ b/Task/Hello-world-Graphical/Ioke/hello-world-graphical.ioke @@ -0,0 +1,16 @@ +import( + :javax:swing, :JOptionPane, :JFrame, :JTextArea, :JButton +) +import java:awt:FlowLayout + +JOptionPane showMessageDialog(nil, "Goodbye, World!") +button = JButton new("Goodbye, World!") +text = JTextArea new("Goodbye, World!") +window = JFrame new("Goodbye, World!") do( + layout = FlowLayout new + add(button) + add(text) + pack + setDefaultCloseOperation(JFrame field:EXIT_ON_CLOSE) + visible = true +) diff --git a/Task/Hello-world-Graphical/J/hello-world-graphical.j b/Task/Hello-world-Graphical/J/hello-world-graphical.j new file mode 100644 index 0000000000..62a575d93b --- /dev/null +++ b/Task/Hello-world-Graphical/J/hello-world-graphical.j @@ -0,0 +1 @@ +wdinfo'Goodbye, World!' diff --git a/Task/Hello-world-Graphical/Java/hello-world-graphical.java b/Task/Hello-world-Graphical/Java/hello-world-graphical.java new file mode 100644 index 0000000000..e49a5fb5f6 --- /dev/null +++ b/Task/Hello-world-Graphical/Java/hello-world-graphical.java @@ -0,0 +1,24 @@ +import javax.swing.*; +import java.awt.*; + +public class OutputSwing { + + public static void main(String[] args) { + + SwingUtilities.invokeLater(new Runnable(){ + public void run() { + JOptionPane.showMessageDialog (null, "Goodbye, World!"); // in alert box + JFrame frame = new JFrame("Goodbye, World!"); // on title bar + JTextArea text = new JTextArea("Goodbye, World!"); // in editable area + JButton button = new JButton("Goodbye, World!"); // on button + + frame.setLayout(new FlowLayout()); + frame.add(button); + frame.add(text); + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + }); + } +} diff --git a/Task/Hello-world-Graphical/JavaScript/hello-world-graphical.js b/Task/Hello-world-Graphical/JavaScript/hello-world-graphical.js new file mode 100644 index 0000000000..12c5604c6a --- /dev/null +++ b/Task/Hello-world-Graphical/JavaScript/hello-world-graphical.js @@ -0,0 +1 @@ + alert("Goodbye, World!"); diff --git a/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-1.konso b/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-1.konso new file mode 100644 index 0000000000..82b92bc0e4 --- /dev/null +++ b/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-1.konso @@ -0,0 +1,3 @@ +function main() { + Konsol:Message("Goodbye, World!", "") +} diff --git a/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-2.konso b/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-2.konso new file mode 100644 index 0000000000..334640f3d0 --- /dev/null +++ b/Task/Hello-world-Graphical/KonsolScript/hello-world-graphical-2.konso @@ -0,0 +1,6 @@ +function main() { + Screen:PrintString("Goodbye, World!") + while (B1 == false) { + Screen:Render() + } +} diff --git a/Task/Hello-world-Graphical/Liberty-BASIC/hello-world-graphical.liberty b/Task/Hello-world-Graphical/Liberty-BASIC/hello-world-graphical.liberty new file mode 100644 index 0000000000..5ec92e9848 --- /dev/null +++ b/Task/Hello-world-Graphical/Liberty-BASIC/hello-world-graphical.liberty @@ -0,0 +1 @@ +NOTICE "Goodbye, world!" diff --git a/Task/Hello-world-Graphical/Logo/hello-world-graphical.logo b/Task/Hello-world-Graphical/Logo/hello-world-graphical.logo new file mode 100644 index 0000000000..e8ae9c45da --- /dev/null +++ b/Task/Hello-world-Graphical/Logo/hello-world-graphical.logo @@ -0,0 +1,3 @@ +LABEL [Hello, World!] +SETLABELHEIGHT 2 * last LABELSIZE +LABEL [Goodbye, World!] diff --git a/Task/Hello-world-Graphical/Lua/hello-world-graphical.lua b/Task/Hello-world-Graphical/Lua/hello-world-graphical.lua new file mode 100644 index 0000000000..e289770ec8 --- /dev/null +++ b/Task/Hello-world-Graphical/Lua/hello-world-graphical.lua @@ -0,0 +1,8 @@ +require "iuplua" + +dlg = iup.dialog{iup.label{title="Goodbye, World!"}; title="test"} +dlg:show() + +if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then + iup.MainLoop() +end diff --git a/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-1.m b/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-1.m new file mode 100644 index 0000000000..cfa12ad375 --- /dev/null +++ b/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-1.m @@ -0,0 +1 @@ +msgbox('Goodbye, World!') diff --git a/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-2.m b/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-2.m new file mode 100644 index 0000000000..8de9d188b4 --- /dev/null +++ b/Task/Hello-world-Graphical/MATLAB/hello-world-graphical-2.m @@ -0,0 +1 @@ + text(0.2,0.2,'Hello World!') diff --git a/Task/Hello-world-Graphical/MAXScript/hello-world-graphical.max b/Task/Hello-world-Graphical/MAXScript/hello-world-graphical.max new file mode 100644 index 0000000000..6bbfeafc3c --- /dev/null +++ b/Task/Hello-world-Graphical/MAXScript/hello-world-graphical.max @@ -0,0 +1 @@ +messageBox "Goodbye world" diff --git a/Task/Hello-world-Graphical/Maple/hello-world-graphical.maple b/Task/Hello-world-Graphical/Maple/hello-world-graphical.maple new file mode 100644 index 0000000000..3cfeb113f3 --- /dev/null +++ b/Task/Hello-world-Graphical/Maple/hello-world-graphical.maple @@ -0,0 +1 @@ +Maplets:-Display( Maplets:-Elements:-Maplet( [ "Goodbye, World!" ] ) ); diff --git a/Task/Hello-world-Graphical/Mathematica/hello-world-graphical.mathematica b/Task/Hello-world-Graphical/Mathematica/hello-world-graphical.mathematica new file mode 100644 index 0000000000..9911bda81f --- /dev/null +++ b/Task/Hello-world-Graphical/Mathematica/hello-world-graphical.mathematica @@ -0,0 +1 @@ +CreateDialog["Hello world"] diff --git a/Task/Hello-world-Graphical/Modula-3/hello-world-graphical.mod3 b/Task/Hello-world-Graphical/Modula-3/hello-world-graphical.mod3 new file mode 100644 index 0000000000..7c6c63ae12 --- /dev/null +++ b/Task/Hello-world-Graphical/Modula-3/hello-world-graphical.mod3 @@ -0,0 +1,12 @@ +MODULE GUIHello EXPORTS Main; + +IMPORT TextVBT, Trestle; + +<*FATAL ANY*> + +VAR v := TextVBT.New("Goodbye, World!"); + +BEGIN + Trestle.Install(v); + Trestle.AwaitDelete(v); +END GUIHello. diff --git a/Task/Hello-world-Graphical/PHP/hello-world-graphical.php b/Task/Hello-world-Graphical/PHP/hello-world-graphical.php new file mode 100644 index 0000000000..cf7b9d840b --- /dev/null +++ b/Task/Hello-world-Graphical/PHP/hello-world-graphical.php @@ -0,0 +1,14 @@ +if (!class_exists('gtk')) +{ + die("Please load the php-gtk2 module in your php.ini\r\n"); +} + +$wnd = new GtkWindow(); +$wnd->set_title('Goodbye world'); +$wnd->connect_simple('destroy', array('gtk', 'main_quit')); + +$lblHello = new GtkLabel("Goodbye, World!"); +$wnd->add($lblHello); + +$wnd->show_all(); +Gtk::main(); diff --git a/Task/Hello-world-Graphical/Perl/hello-world-graphical-1.pl b/Task/Hello-world-Graphical/Perl/hello-world-graphical-1.pl new file mode 100644 index 0000000000..0310780745 --- /dev/null +++ b/Task/Hello-world-Graphical/Perl/hello-world-graphical-1.pl @@ -0,0 +1,7 @@ +use strict; +use warnings; +use Tk; + +my $main = MainWindow->new; +$main->Label(-text => 'Goodbye, World')->pack; +MainLoop(); diff --git a/Task/Hello-world-Graphical/Perl/hello-world-graphical-2.pl b/Task/Hello-world-Graphical/Perl/hello-world-graphical-2.pl new file mode 100644 index 0000000000..f69ab9fca5 --- /dev/null +++ b/Task/Hello-world-Graphical/Perl/hello-world-graphical-2.pl @@ -0,0 +1,10 @@ +use strict; +use warnings; +use Tk; + +my $main = MainWindow->new; +$main->Button( + -text => 'Goodbye, World', + -command => \&exit, +)->pack; +MainLoop(); diff --git a/Task/Hello-world-Graphical/Perl/hello-world-graphical-3.pl b/Task/Hello-world-Graphical/Perl/hello-world-graphical-3.pl new file mode 100644 index 0000000000..b635a7baac --- /dev/null +++ b/Task/Hello-world-Graphical/Perl/hello-world-graphical-3.pl @@ -0,0 +1,15 @@ +use strict; +use warnings; +use Gtk2 '-init'; + +my $window = Gtk2::Window->new; +$window->set_title('Goodbye world'); +$window->signal_connect( + destroy => sub { Gtk2->main_quit; } +); + +my $label = Gtk2::Label->new('Goodbye, world'); +$window->add($label); + +$window->show_all; +Gtk2->main; diff --git a/Task/Hello-world-Graphical/Perl/hello-world-graphical-4.pl b/Task/Hello-world-Graphical/Perl/hello-world-graphical-4.pl new file mode 100644 index 0000000000..d20da06afb --- /dev/null +++ b/Task/Hello-world-Graphical/Perl/hello-world-graphical-4.pl @@ -0,0 +1,5 @@ +use strict; +use warnings; +use XUL::Gui; + +display Label 'Goodbye, World!'; diff --git a/Task/Hello-world-Graphical/Perl/hello-world-graphical-5.pl b/Task/Hello-world-Graphical/Perl/hello-world-graphical-5.pl new file mode 100644 index 0000000000..260ed3d35e --- /dev/null +++ b/Task/Hello-world-Graphical/Perl/hello-world-graphical-5.pl @@ -0,0 +1,7 @@ +use strict; +use warnings; +use XUL::Gui; + +display Button + label => 'Goodbye, World!', + oncommand => sub {quit}; diff --git a/Task/Hello-world-Graphical/PicoLisp/hello-world-graphical.l b/Task/Hello-world-Graphical/PicoLisp/hello-world-graphical.l new file mode 100644 index 0000000000..f64304a721 --- /dev/null +++ b/Task/Hello-world-Graphical/PicoLisp/hello-world-graphical.l @@ -0,0 +1 @@ +(call 'dialog "--msgbox" "Goodbye, World!" 5 20) diff --git a/Task/Hello-world-Graphical/Prolog/hello-world-graphical-1.pro b/Task/Hello-world-Graphical/Prolog/hello-world-graphical-1.pro new file mode 100644 index 0000000000..d727df3268 --- /dev/null +++ b/Task/Hello-world-Graphical/Prolog/hello-world-graphical-1.pro @@ -0,0 +1 @@ +send(@display, inform, 'Goodbye, World !'). diff --git a/Task/Hello-world-Graphical/Prolog/hello-world-graphical-2.pro b/Task/Hello-world-Graphical/Prolog/hello-world-graphical-2.pro new file mode 100644 index 0000000000..fa8b5b380c --- /dev/null +++ b/Task/Hello-world-Graphical/Prolog/hello-world-graphical-2.pro @@ -0,0 +1,12 @@ +goodbye :- + new(D, window('Goodbye')), + send(D, size, size(250, 100)), + new(S, string("Goodbye, World !")), + new(T, text(S)), + get(@display, label_font, F), + get(F, width(S), M), + XT is (250 - M)/2, + get(F, height, H), + YT = (100-H)/2, + send(D, display, T, point(XT, YT)), + send(D, open). diff --git a/Task/Hello-world-Graphical/Python/hello-world-graphical-1.py b/Task/Hello-world-Graphical/Python/hello-world-graphical-1.py new file mode 100644 index 0000000000..7a1da0a648 --- /dev/null +++ b/Task/Hello-world-Graphical/Python/hello-world-graphical-1.py @@ -0,0 +1,3 @@ +import tkMessageBox + +result = tkMessageBox.showinfo("Some Window Label", "Goodbye, World!") diff --git a/Task/Hello-world-Graphical/Python/hello-world-graphical-2.py b/Task/Hello-world-Graphical/Python/hello-world-graphical-2.py new file mode 100644 index 0000000000..43310f360b --- /dev/null +++ b/Task/Hello-world-Graphical/Python/hello-world-graphical-2.py @@ -0,0 +1,3 @@ +from tkinter import messagebox + +result = messagebox.showinfo("Some Window Label", "Goodbye, World!") diff --git a/Task/Hello-world-Graphical/Python/hello-world-graphical-3.py b/Task/Hello-world-Graphical/Python/hello-world-graphical-3.py new file mode 100644 index 0000000000..0468ab3b65 --- /dev/null +++ b/Task/Hello-world-Graphical/Python/hello-world-graphical-3.py @@ -0,0 +1,6 @@ +import PyQt4.QtGui +app = PyQt4.QtGui.QApplication([]) +pb = PyQt4.QtGui.QPushButton('Hello World') +pb.connect(pb,PyQt4.QtCore.SIGNAL("clicked()"),pb.close) +pb.show() +exit(app.exec_()) diff --git a/Task/Hello-world-Graphical/Python/hello-world-graphical-4.py b/Task/Hello-world-Graphical/Python/hello-world-graphical-4.py new file mode 100644 index 0000000000..91035f951f --- /dev/null +++ b/Task/Hello-world-Graphical/Python/hello-world-graphical-4.py @@ -0,0 +1,9 @@ +import pygtk +pygtk.require('2.0') +import gtk + +window = gtk.Window() +window.set_title('Goodbye, World') +window.connect('delete-event', gtk.main_quit) +window.show_all() +gtk.main() diff --git a/Task/Hello-world-Graphical/Python/hello-world-graphical-5.py b/Task/Hello-world-Graphical/Python/hello-world-graphical-5.py new file mode 100644 index 0000000000..de1eb03618 --- /dev/null +++ b/Task/Hello-world-Graphical/Python/hello-world-graphical-5.py @@ -0,0 +1,6 @@ +import wx + +app = wx.App(False) +frame = wx.Frame(None, wx.ID_ANY, "Hello, World") +frame.Show(True) +app.MainLoop() diff --git a/Task/Hello-world-Graphical/R/hello-world-graphical.r b/Task/Hello-world-Graphical/R/hello-world-graphical.r new file mode 100644 index 0000000000..6195f71d8c --- /dev/null +++ b/Task/Hello-world-Graphical/R/hello-world-graphical.r @@ -0,0 +1,4 @@ +library(RGtk2) # bindings to Gtk +w <- gtkWindowNew() +l <- gtkLabelNew("Goodbye, World!") +w$add(l) diff --git a/Task/Hello-world-Graphical/REXX/hello-world-graphical-1.rexx b/Task/Hello-world-Graphical/REXX/hello-world-graphical-1.rexx new file mode 100644 index 0000000000..5582540abd --- /dev/null +++ b/Task/Hello-world-Graphical/REXX/hello-world-graphical-1.rexx @@ -0,0 +1,16 @@ +/*REXX (PC/REXX) to display a message in a window (which is bordered). */ + +/*REXX (PC/REXX) to display a message in a window (which is bordered). */ +if fcnpkg('rxwindow')¬==1 then do + say 'RXWINDOW function package not loaded.' + exit 13 + end + +if pcvideo()==3 then normal= 7 + else normal=13 + +window#=w_open(1, 1, 3, 80, normal) +call w_border window# +call w_put window#, 2, 2, center("Goodbye, World!", 80-2) + + /*stick a fork in it, we're done.*/ diff --git a/Task/Hello-world-Graphical/REXX/hello-world-graphical-2.rexx b/Task/Hello-world-Graphical/REXX/hello-world-graphical-2.rexx new file mode 100644 index 0000000000..6787d59752 --- /dev/null +++ b/Task/Hello-world-Graphical/REXX/hello-world-graphical-2.rexx @@ -0,0 +1,26 @@ +/*REXX pgm shows a "hello world" window (& another to show how to close)*/ +parse upper version !ver .; !pcrexx='REXX/PERSONAL'==!ver |'REXX/PC'==!ver +if \!pcrexx then call ser "This isn't PC/REXX" /* is ¬ PC/REXX ? */ +rxWin=fcnpkg('rxwindow') /*function around?*/ +if rxWin\==1 then do 1; 'RXWINDOW /q' + if fcnpkg('rxwindow')==1 then leave /*function is OK. */ + say 'error loading RXWINDOW !'; exit 13 + end +top=1; normal=31; border=30; curpos=cursor() +width=40; height=11; line.=; line.1='Goodbye, World!' +w=w_open(2,3,height+2,width,normal); call w_border w,,,,,border +helpLine="press the esc key to quit" +helpw=w_open(2,50,3,length(helpLine)+4,normal) +call w_border helpw,,,,,border; call w_put helpw,2,3,helpLine +call w_hide w, 'n' + do k=0 to height-1 + _=top+k; call w_put w,k+2,3,line._,width-4 + end /*k*/ +call w_unhide w; esc='1b'x + do forever; if inkey()=esc then leave; end +call w_close w +call w_close helpw +if rxWin\==1 then 'RXUNLOAD rxwindow' +parse var curpos row col +call cursor row, col + /*stick a fork in it, we're done.*/ diff --git a/Task/Hello-world-Graphical/Racket/hello-world-graphical.rkt b/Task/Hello-world-Graphical/Racket/hello-world-graphical.rkt new file mode 100644 index 0000000000..79ab9dbcea --- /dev/null +++ b/Task/Hello-world-Graphical/Racket/hello-world-graphical.rkt @@ -0,0 +1,19 @@ + #lang racket/gui +(require racket/gui/base) + +; Make a frame by instantiating the frame% class +(define frame (new frame% [label "Goodbye, World!"])) + +; Make a static text message in the frame +(define msg (new message% [parent frame] + [label "No events so far..."])) + +; Make a button in the frame +(new button% [parent frame] + [label "Click Me"] + ; Callback procedure for a button click: + (callback (lambda (button event) + (send msg set-label "Button click")))) + +; Show the frame by calling its show method +(send frame show #t) diff --git a/Task/Hello-world-Graphical/Ruby/hello-world-graphical-1.rb b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-1.rb new file mode 100644 index 0000000000..c290b888a6 --- /dev/null +++ b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-1.rb @@ -0,0 +1,8 @@ +require 'gtk2' + +window = Gtk::Window.new +window.title = 'Goodbye, World' +window.signal_connect(:delete-event) { Gtk.main_quit } +window.show_all + +Gtk.main diff --git a/Task/Hello-world-Graphical/Ruby/hello-world-graphical-2.rb b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-2.rb new file mode 100644 index 0000000000..f67c69a07b --- /dev/null +++ b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-2.rb @@ -0,0 +1,4 @@ +require 'tk' +root = TkRoot.new("title" => "User Output") +TkLabel.new(root, "text"=>"CHUNKY BACON!").pack("side"=>'top') +Tk.mainloop diff --git a/Task/Hello-world-Graphical/Ruby/hello-world-graphical-3.rb b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-3.rb new file mode 100644 index 0000000000..06e596f871 --- /dev/null +++ b/Task/Hello-world-Graphical/Ruby/hello-world-graphical-3.rb @@ -0,0 +1,5 @@ +#_Note: this code MUST be executed through the Shoes GUI!! + +Shoes.app do + para "CHUNKY BACON!", :size => 72 +end diff --git a/Task/Hello-world-Graphical/Scala/hello-world-graphical-1.scala b/Task/Hello-world-Graphical/Scala/hello-world-graphical-1.scala new file mode 100644 index 0000000000..fd1c0b3bd8 --- /dev/null +++ b/Task/Hello-world-Graphical/Scala/hello-world-graphical-1.scala @@ -0,0 +1 @@ +swing.Dialog.showMessage(message = "Goodbye, World!") diff --git a/Task/Hello-world-Graphical/Scala/hello-world-graphical-2.scala b/Task/Hello-world-Graphical/Scala/hello-world-graphical-2.scala new file mode 100644 index 0000000000..663934117b --- /dev/null +++ b/Task/Hello-world-Graphical/Scala/hello-world-graphical-2.scala @@ -0,0 +1,14 @@ +import swing._ + +object GoodbyeWorld extends SimpleSwingApplication { + + Dialog.showMessage(message = "Goodbye, World!") + + def top = new MainFrame { + title = "Goodbye, World!" + contents = new FlowPanel { + contents += new Button ("Goodbye, World!") + contents += new TextArea("Goodbye, World!") + } + } +} diff --git a/Task/Hello-world-Graphical/Scheme/hello-world-graphical.ss b/Task/Hello-world-Graphical/Scheme/hello-world-graphical.ss new file mode 100644 index 0000000000..259119f3ea --- /dev/null +++ b/Task/Hello-world-Graphical/Scheme/hello-world-graphical.ss @@ -0,0 +1,15 @@ +#!r6rs + +;; PS-TK example: display frame + label + +(import (rnrs) + (lib pstk main) ; change this to refer to your PS/Tk installation + ) + +(define tk (tk-start)) +(tk/wm 'title tk "PS-Tk Example: Label") + +(let ((label (tk 'create-widget 'label 'text: "Goodbye, world"))) + (tk/place label 'height: 20 'width: 50 'x: 10 'y: 20)) + +(tk-event-loop tk) diff --git a/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-1.st b/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-1.st new file mode 100644 index 0000000000..c5b49aae51 --- /dev/null +++ b/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-1.st @@ -0,0 +1 @@ +MessageBox show: 'Goodbye, world.' diff --git a/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-2.st b/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-2.st new file mode 100644 index 0000000000..a09f4e8f77 --- /dev/null +++ b/Task/Hello-world-Graphical/Smalltalk/hello-world-graphical-2.st @@ -0,0 +1 @@ +Dialog information: 'Goodbye, world.' diff --git a/Task/Hello-world-Graphical/Tcl/hello-world-graphical-1.tcl b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-1.tcl new file mode 100644 index 0000000000..dafaa51e63 --- /dev/null +++ b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-1.tcl @@ -0,0 +1 @@ +pack [label .l -text "Goodbye, World"] diff --git a/Task/Hello-world-Graphical/Tcl/hello-world-graphical-2.tcl b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-2.tcl new file mode 100644 index 0000000000..a2b8c65501 --- /dev/null +++ b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-2.tcl @@ -0,0 +1 @@ +pack [button .b -text "Goodbye, World" -command exit] diff --git a/Task/Hello-world-Graphical/Tcl/hello-world-graphical-3.tcl b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-3.tcl new file mode 100644 index 0000000000..6885e77944 --- /dev/null +++ b/Task/Hello-world-Graphical/Tcl/hello-world-graphical-3.tcl @@ -0,0 +1 @@ +tk_messageBox -message "Goodbye, World" diff --git a/Task/Hello-world-Line-printer/0DESCRIPTION b/Task/Hello-world-Line-printer/0DESCRIPTION new file mode 100644 index 0000000000..22f4289b73 --- /dev/null +++ b/Task/Hello-world-Line-printer/0DESCRIPTION @@ -0,0 +1,3 @@ +Cause a line printer attached to the computer to print a line containing the message Hello World! + +'''Note:''' A line printer is not the same as standard output. A [[wp:line printer|line printer]] was an older-style printer which prints one line at a time to a continuous ream of paper. With some systems, a line printer can be any device attached to an appropriate port (such as a parallel port). diff --git a/Task/Hello-world-Line-printer/AWK/hello-world-line-printer.awk b/Task/Hello-world-Line-printer/AWK/hello-world-line-printer.awk new file mode 100644 index 0000000000..b4b546035a --- /dev/null +++ b/Task/Hello-world-Line-printer/AWK/hello-world-line-printer.awk @@ -0,0 +1 @@ +BEGIN { print("Hello World!") >"/dev/lp0" } diff --git a/Task/Hello-world-Line-printer/Ada/hello-world-line-printer.ada b/Task/Hello-world-Line-printer/Ada/hello-world-line-printer.ada new file mode 100644 index 0000000000..6a8c9fc4ba --- /dev/null +++ b/Task/Hello-world-Line-printer/Ada/hello-world-line-printer.ada @@ -0,0 +1,17 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Print_Line is + Printer : File_Type; +begin + begin + Open (Printer, Mode => Out_File, Name => "/dev/lp0"); + exception + when others => + Put_Line ("Unable to open printer."); + return; + end; + + Set_Output (Printer); + Put_Line ("Hello World!"); + Close (Printer); +end Print_Line; diff --git a/Task/Hello-world-Line-printer/Applesoft-BASIC/hello-world-line-printer.bas b/Task/Hello-world-Line-printer/Applesoft-BASIC/hello-world-line-printer.bas new file mode 100644 index 0000000000..28d5f1b82d --- /dev/null +++ b/Task/Hello-world-Line-printer/Applesoft-BASIC/hello-world-line-printer.bas @@ -0,0 +1,2 @@ +PR#1 +PRINT "HELLO WORLD!" diff --git a/Task/Hello-world-Line-printer/AutoHotkey/hello-world-line-printer.ahk b/Task/Hello-world-Line-printer/AutoHotkey/hello-world-line-printer.ahk new file mode 100644 index 0000000000..11ed51a385 --- /dev/null +++ b/Task/Hello-world-Line-printer/AutoHotkey/hello-world-line-printer.ahk @@ -0,0 +1,2 @@ +Fileappend, Hallo World!, print.txt +Run, print "print.txt" diff --git a/Task/Hello-world-Line-printer/BASIC/hello-world-line-printer.bas b/Task/Hello-world-Line-printer/BASIC/hello-world-line-printer.bas new file mode 100644 index 0000000000..54472a9963 --- /dev/null +++ b/Task/Hello-world-Line-printer/BASIC/hello-world-line-printer.bas @@ -0,0 +1 @@ +LPRINT "Hello World!" diff --git a/Task/Hello-world-Line-printer/BBC-BASIC/hello-world-line-printer.bbc b/Task/Hello-world-Line-printer/BBC-BASIC/hello-world-line-printer.bbc new file mode 100644 index 0000000000..b9fe3e6d92 --- /dev/null +++ b/Task/Hello-world-Line-printer/BBC-BASIC/hello-world-line-printer.bbc @@ -0,0 +1,3 @@ + prn% = OPENOUT("PRN:") + PRINT #prn%, "Hello World!" + CLOSE #prn% diff --git a/Task/Hello-world-Line-printer/Batch-File/hello-world-line-printer.bat b/Task/Hello-world-Line-printer/Batch-File/hello-world-line-printer.bat new file mode 100644 index 0000000000..58684fb248 --- /dev/null +++ b/Task/Hello-world-Line-printer/Batch-File/hello-world-line-printer.bat @@ -0,0 +1 @@ +ECHO Hello world!>PRN diff --git a/Task/Hello-world-Line-printer/C++/hello-world-line-printer.cpp b/Task/Hello-world-Line-printer/C++/hello-world-line-printer.cpp new file mode 100644 index 0000000000..3ca245afeb --- /dev/null +++ b/Task/Hello-world-Line-printer/C++/hello-world-line-printer.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main(){ + std::ofstream lprFile; + lprFile.open( "/dev/lp0" ); + lprFile << "Hello World\n"; + lprFile.close(); + return 0; +} diff --git a/Task/Hello-world-Line-printer/C/hello-world-line-printer.c b/Task/Hello-world-Line-printer/C/hello-world-line-printer.c new file mode 100644 index 0000000000..417e7c2582 --- /dev/null +++ b/Task/Hello-world-Line-printer/C/hello-world-line-printer.c @@ -0,0 +1,10 @@ +#include + +int main() +{ + FILE *lp; + lp = fopen("/dev/lp0","w"); + fprintf(lp,"Hello world!\n"); + fclose(lp); + return 0; +} diff --git a/Task/Hello-world-Line-printer/COBOL/hello-world-line-printer.cobol b/Task/Hello-world-Line-printer/COBOL/hello-world-line-printer.cobol new file mode 100644 index 0000000000..641157d155 --- /dev/null +++ b/Task/Hello-world-Line-printer/COBOL/hello-world-line-printer.cobol @@ -0,0 +1,8 @@ +IDENTIFICATION DIVISION. +PROGRAM-ID. GOODBYE-WORLD-PRINTER. + +PROCEDURE DIVISION. +DISPLAY 'Hello World!' + UPON PRINTER +END-DISPLAY. +STOP RUN. diff --git a/Task/Hello-world-Line-printer/D/hello-world-line-printer.d b/Task/Hello-world-Line-printer/D/hello-world-line-printer.d new file mode 100644 index 0000000000..c65f3359b9 --- /dev/null +++ b/Task/Hello-world-Line-printer/D/hello-world-line-printer.d @@ -0,0 +1,7 @@ +import std.stdio; + +void main() +{ + auto lp = File("/dev/lp0", "w"); + lp.writeln("Hello World!"); +} diff --git a/Task/Hello-world-Line-printer/Delphi/hello-world-line-printer.delphi b/Task/Hello-world-Line-printer/Delphi/hello-world-line-printer.delphi new file mode 100644 index 0000000000..4f88d93469 --- /dev/null +++ b/Task/Hello-world-Line-printer/Delphi/hello-world-line-printer.delphi @@ -0,0 +1,14 @@ +program Project1; + +{$APPTYPE CONSOLE} + +uses Printers; + +var + lPrinterAsTextFile: TextFile; +begin + AssignPrn(lPrinterAsTextFile); + Rewrite(lPrinterAsTextFile); + Writeln(lPrinterAsTextFile, 'Hello World!'); + CloseFile(lPrinterAsTextFile); +end. diff --git a/Task/Hello-world-Line-printer/Factor/hello-world-line-printer.factor b/Task/Hello-world-Line-printer/Factor/hello-world-line-printer.factor new file mode 100644 index 0000000000..bdb84da287 --- /dev/null +++ b/Task/Hello-world-Line-printer/Factor/hello-world-line-printer.factor @@ -0,0 +1,3 @@ +( scratchpad ) USE: io.encodings.utf8 +( scratchpad ) USE: io.launcher +( scratchpad ) "lpr" utf8 [ "Hello World!" print ] with-process-writer diff --git a/Task/Hello-world-Line-printer/GUISS/hello-world-line-printer.guiss b/Task/Hello-world-Line-printer/GUISS/hello-world-line-printer.guiss new file mode 100644 index 0000000000..53e91676e0 --- /dev/null +++ b/Task/Hello-world-Line-printer/GUISS/hello-world-line-printer.guiss @@ -0,0 +1,2 @@ +Start,Programs,Accessories,Notepad,Type:Goodbye World[pling], +Menu:File,Print,Button:OK diff --git a/Task/Hello-world-Line-printer/Go/hello-world-line-printer.go b/Task/Hello-world-Line-printer/Go/hello-world-line-printer.go new file mode 100644 index 0000000000..8b43bdf6a9 --- /dev/null +++ b/Task/Hello-world-Line-printer/Go/hello-world-line-printer.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + lp0, err := os.Create("/dev/lp0") + + if err != nil { + panic(err) + } + + defer lp0.Close() + + fmt.Fprintln(lp0, "Hello world!") +} diff --git a/Task/Hello-world-Line-printer/Groovy/hello-world-line-printer.groovy b/Task/Hello-world-Line-printer/Groovy/hello-world-line-printer.groovy new file mode 100644 index 0000000000..165778d9bd --- /dev/null +++ b/Task/Hello-world-Line-printer/Groovy/hello-world-line-printer.groovy @@ -0,0 +1 @@ +new File('/dev/lp0').write('Hello World\n') diff --git a/Task/Hello-world-Line-printer/Haskell/hello-world-line-printer.hs b/Task/Hello-world-Line-printer/Haskell/hello-world-line-printer.hs new file mode 100644 index 0000000000..9dc4edeb17 --- /dev/null +++ b/Task/Hello-world-Line-printer/Haskell/hello-world-line-printer.hs @@ -0,0 +1,5 @@ +import System.Cmd + +cmd = "echo \"Hello World!\" | lpr" + +main = system cmd diff --git a/Task/Hello-world-Line-printer/J/hello-world-line-printer.j b/Task/Hello-world-Line-printer/J/hello-world-line-printer.j new file mode 100644 index 0000000000..90d0d18010 --- /dev/null +++ b/Task/Hello-world-Line-printer/J/hello-world-line-printer.j @@ -0,0 +1,2 @@ +require'print' +print'Hello world!' diff --git a/Task/Hello-world-Line-printer/Java/hello-world-line-printer.java b/Task/Hello-world-Line-printer/Java/hello-world-line-printer.java new file mode 100644 index 0000000000..875f00fc17 --- /dev/null +++ b/Task/Hello-world-Line-printer/Java/hello-world-line-printer.java @@ -0,0 +1,14 @@ +import java.io.FileWriter; +import java.io.IOException; + +public class LinePrinter { + public static void main(String[] args) { + try { + FileWriter lp0 = new FileWriter("/dev/lp0"); + lp0.write("Hello World!"); + lp0.close(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } +} diff --git a/Task/Hello-world-Line-printer/JavaScript/hello-world-line-printer.js b/Task/Hello-world-Line-printer/JavaScript/hello-world-line-printer.js new file mode 100644 index 0000000000..6a057e5a7c --- /dev/null +++ b/Task/Hello-world-Line-printer/JavaScript/hello-world-line-printer.js @@ -0,0 +1,6 @@ +// This example runs on Node.js +var fs = require('fs'); +// Assuming lp is at /dev/lp0 +var lp = fs.openSync('/dev/lp0', 'w'); +fs.writeSync(lp, 'Hello, world!\n'); +fs.close(lp); diff --git a/Task/Hello-world-Line-printer/Locomotive-Basic/hello-world-line-printer.bas b/Task/Hello-world-Line-printer/Locomotive-Basic/hello-world-line-printer.bas new file mode 100644 index 0000000000..ea4376272a --- /dev/null +++ b/Task/Hello-world-Line-printer/Locomotive-Basic/hello-world-line-printer.bas @@ -0,0 +1 @@ +10 PRINT #8, "Hello World!" diff --git a/Task/Hello-world-Line-printer/MATLAB/hello-world-line-printer.m b/Task/Hello-world-Line-printer/MATLAB/hello-world-line-printer.m new file mode 100644 index 0000000000..35b5096426 --- /dev/null +++ b/Task/Hello-world-Line-printer/MATLAB/hello-world-line-printer.m @@ -0,0 +1,3 @@ + fid = fopen('/dev/lp0'); + fprintf(fid,'Hello World!\n'); + fclose(fid); diff --git a/Task/Hello-world-Line-printer/Mathematica/hello-world-line-printer.mathematica b/Task/Hello-world-Line-printer/Mathematica/hello-world-line-printer.mathematica new file mode 100644 index 0000000000..e5f1244c43 --- /dev/null +++ b/Task/Hello-world-Line-printer/Mathematica/hello-world-line-printer.mathematica @@ -0,0 +1,2 @@ +commandstring = "echo Hello World! | lpr -P Printer01" +Run[commandstring] diff --git a/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-1.php b/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-1.php new file mode 100644 index 0000000000..a5f3a51f03 --- /dev/null +++ b/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-1.php @@ -0,0 +1,3 @@ + diff --git a/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-2.php b/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-2.php new file mode 100644 index 0000000000..5913e3c57a --- /dev/null +++ b/Task/Hello-world-Line-printer/PHP/hello-world-line-printer-2.php @@ -0,0 +1,5 @@ + diff --git a/Task/Hello-world-Line-printer/Perl/hello-world-line-printer.pl b/Task/Hello-world-Line-printer/Perl/hello-world-line-printer.pl new file mode 100644 index 0000000000..eed3a04ac3 --- /dev/null +++ b/Task/Hello-world-Line-printer/Perl/hello-world-line-printer.pl @@ -0,0 +1,3 @@ +open O, ">", "/dev/lp0"; +print O "Hello World!\n"; +close O; diff --git a/Task/Hello-world-Line-printer/PicoLisp/hello-world-line-printer.l b/Task/Hello-world-Line-printer/PicoLisp/hello-world-line-printer.l new file mode 100644 index 0000000000..b1961c24d5 --- /dev/null +++ b/Task/Hello-world-Line-printer/PicoLisp/hello-world-line-printer.l @@ -0,0 +1,2 @@ +(out '(lpr "-P" "Printer01") + (prinl "Hello world") ) diff --git a/Task/Hello-world-Line-printer/Python/hello-world-line-printer.py b/Task/Hello-world-Line-printer/Python/hello-world-line-printer.py new file mode 100644 index 0000000000..9a79134c9f --- /dev/null +++ b/Task/Hello-world-Line-printer/Python/hello-world-line-printer.py @@ -0,0 +1,3 @@ +lp = open("/dev/lp0") +lp.write("Hello World!/n") +lp.close() diff --git a/Task/Hello-world-Line-printer/REXX/hello-world-line-printer.rexx b/Task/Hello-world-Line-printer/REXX/hello-world-line-printer.rexx new file mode 100644 index 0000000000..8067d2d97b --- /dev/null +++ b/Task/Hello-world-Line-printer/REXX/hello-world-line-printer.rexx @@ -0,0 +1,2 @@ +str='Hello World' +'@ECHO' str ">PRN" diff --git a/Task/Hello-world-Line-printer/Ruby/hello-world-line-printer.rb b/Task/Hello-world-Line-printer/Ruby/hello-world-line-printer.rb new file mode 100644 index 0000000000..cc3d80d2ba --- /dev/null +++ b/Task/Hello-world-Line-printer/Ruby/hello-world-line-printer.rb @@ -0,0 +1 @@ +open("| lpr", "w") { |f| f.puts "Hello World!" } diff --git a/Task/Hello-world-Line-printer/Scheme/hello-world-line-printer.ss b/Task/Hello-world-Line-printer/Scheme/hello-world-line-printer.ss new file mode 100644 index 0000000000..7c86770b5b --- /dev/null +++ b/Task/Hello-world-Line-printer/Scheme/hello-world-line-printer.ss @@ -0,0 +1,3 @@ +(call-with-output-file "/dev/lp0" +  (lambda (printer) +    (write "Hello World!" printer))) diff --git a/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-1.tcl b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-1.tcl new file mode 100644 index 0000000000..e792c4c948 --- /dev/null +++ b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-1.tcl @@ -0,0 +1 @@ +exec lp << "Hello World!" diff --git a/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-2.tcl b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-2.tcl new file mode 100644 index 0000000000..d28ac209f6 --- /dev/null +++ b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-2.tcl @@ -0,0 +1,3 @@ +set f [open |lp w] +puts $f "Hello World!" +close $f diff --git a/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-3.tcl b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-3.tcl new file mode 100644 index 0000000000..6d9dc25b03 --- /dev/null +++ b/Task/Hello-world-Line-printer/Tcl/hello-world-line-printer-3.tcl @@ -0,0 +1,3 @@ +set f [open prn w] +puts $f "Hello World!" +close $f diff --git a/Task/Hello-world-Newline-omission/0DESCRIPTION b/Task/Hello-world-Newline-omission/0DESCRIPTION new file mode 100644 index 0000000000..7e91882923 --- /dev/null +++ b/Task/Hello-world-Newline-omission/0DESCRIPTION @@ -0,0 +1,7 @@ +Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. The purpose of this task is to output the string "Goodbye, World!" without a trailing newline. + +'''See also''' +* [[Hello world/Graphical]] +* [[Hello world/Line Printer]] +* [[Hello world/Standard error]] +* [[Hello world/Text]] diff --git a/Task/Hello-world-Newline-omission/1META.yaml b/Task/Hello-world-Newline-omission/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Hello-world-Newline-omission/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Hello-world-Newline-omission/ACL2/hello-world-newline-omission.acl2 b/Task/Hello-world-Newline-omission/ACL2/hello-world-newline-omission.acl2 new file mode 100644 index 0000000000..ddc14b87ef --- /dev/null +++ b/Task/Hello-world-Newline-omission/ACL2/hello-world-newline-omission.acl2 @@ -0,0 +1 @@ +(cw "Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/ATS/hello-world-newline-omission.ats b/Task/Hello-world-Newline-omission/ATS/hello-world-newline-omission.ats new file mode 100644 index 0000000000..78de4a035e --- /dev/null +++ b/Task/Hello-world-Newline-omission/ATS/hello-world-newline-omission.ats @@ -0,0 +1 @@ +implement main () = print "Goodbye, World!" diff --git a/Task/Hello-world-Newline-omission/AWK/hello-world-newline-omission.awk b/Task/Hello-world-Newline-omission/AWK/hello-world-newline-omission.awk new file mode 100644 index 0000000000..d27009ae49 --- /dev/null +++ b/Task/Hello-world-Newline-omission/AWK/hello-world-newline-omission.awk @@ -0,0 +1 @@ +BEGIN { printf("Goodbye, World!") } diff --git a/Task/Hello-world-Newline-omission/Ada/hello-world-newline-omission.ada b/Task/Hello-world-Newline-omission/Ada/hello-world-newline-omission.ada new file mode 100644 index 0000000000..f9221fb6de --- /dev/null +++ b/Task/Hello-world-Newline-omission/Ada/hello-world-newline-omission.ada @@ -0,0 +1,6 @@ +with Ada.Text_IO; + +procedure Goodbye_World is +begin + Ada.Text_IO.Put("Goodbye, World!"); +end Goodbye_World; diff --git a/Task/Hello-world-Newline-omission/AutoHotkey/hello-world-newline-omission.ahk b/Task/Hello-world-Newline-omission/AutoHotkey/hello-world-newline-omission.ahk new file mode 100644 index 0000000000..a375820f3d --- /dev/null +++ b/Task/Hello-world-Newline-omission/AutoHotkey/hello-world-newline-omission.ahk @@ -0,0 +1,3 @@ +DllCall("AllocConsole") +FileAppend, Goodbye`, World!, CONOUT$ ; No newline outputted +MsgBox diff --git a/Task/Hello-world-Newline-omission/BASIC/hello-world-newline-omission.bas b/Task/Hello-world-Newline-omission/BASIC/hello-world-newline-omission.bas new file mode 100644 index 0000000000..29c4c9d207 --- /dev/null +++ b/Task/Hello-world-Newline-omission/BASIC/hello-world-newline-omission.bas @@ -0,0 +1,2 @@ +10 REM The trailing semicolon prevents a newline +20 PRINT "Goodbye, World!"; diff --git a/Task/Hello-world-Newline-omission/BASIC256/hello-world-newline-omission.basic256 b/Task/Hello-world-Newline-omission/BASIC256/hello-world-newline-omission.basic256 new file mode 100644 index 0000000000..85d7ed1117 --- /dev/null +++ b/Task/Hello-world-Newline-omission/BASIC256/hello-world-newline-omission.basic256 @@ -0,0 +1,3 @@ +print "Goodbye,"; +print " "; +print "World!"; diff --git a/Task/Hello-world-Newline-omission/BBC-BASIC/hello-world-newline-omission.bbc b/Task/Hello-world-Newline-omission/BBC-BASIC/hello-world-newline-omission.bbc new file mode 100644 index 0000000000..91b6d52c4c --- /dev/null +++ b/Task/Hello-world-Newline-omission/BBC-BASIC/hello-world-newline-omission.bbc @@ -0,0 +1,8 @@ + REM BBC BASIC accepts the standard trailing semicolon: + PRINT "Goodbye World!"; + + REM One could also output the characters individually: + GW$ = "Goodbye World!" + FOR i% = 1 TO LEN(GW$) + VDU ASCMID$(GW$, i%) + NEXT diff --git a/Task/Hello-world-Newline-omission/Batch-File/hello-world-newline-omission-1.bat b/Task/Hello-world-Newline-omission/Batch-File/hello-world-newline-omission-1.bat new file mode 100644 index 0000000000..62ea22e6af --- /dev/null +++ b/Task/Hello-world-Newline-omission/Batch-File/hello-world-newline-omission-1.bat @@ -0,0 +1,2 @@ + + +int main(int argc, char *argv[]) { + std::cout << "Goodbye, World!"; +} diff --git a/Task/Hello-world-Newline-omission/C/hello-world-newline-omission.c b/Task/Hello-world-Newline-omission/C/hello-world-newline-omission.c new file mode 100644 index 0000000000..f20a3152e5 --- /dev/null +++ b/Task/Hello-world-Newline-omission/C/hello-world-newline-omission.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char *argv[]) { + (void) printf("Goodbye, World!"); /* No automatic newline */ + return EXIT_SUCCESS; +} diff --git a/Task/Hello-world-Newline-omission/COBOL/hello-world-newline-omission.cobol b/Task/Hello-world-Newline-omission/COBOL/hello-world-newline-omission.cobol new file mode 100644 index 0000000000..bdd232ef8e --- /dev/null +++ b/Task/Hello-world-Newline-omission/COBOL/hello-world-newline-omission.cobol @@ -0,0 +1,9 @@ +IDENTIFICATION DIVISION. +PROGRAM-ID. GOODBYE-WORLD. + +PROCEDURE DIVISION. +DISPLAY 'Goodbye, World!' + WITH NO ADVANCING +END-DISPLAY +. +STOP RUN. diff --git a/Task/Hello-world-Newline-omission/Clojure/hello-world-newline-omission.clj b/Task/Hello-world-Newline-omission/Clojure/hello-world-newline-omission.clj new file mode 100644 index 0000000000..6e7296b324 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Clojure/hello-world-newline-omission.clj @@ -0,0 +1 @@ +(print "Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/Common-Lisp/hello-world-newline-omission.lisp b/Task/Hello-world-Newline-omission/Common-Lisp/hello-world-newline-omission.lisp new file mode 100644 index 0000000000..e8c634f681 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Common-Lisp/hello-world-newline-omission.lisp @@ -0,0 +1 @@ +(princ "Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/D/hello-world-newline-omission.d b/Task/Hello-world-Newline-omission/D/hello-world-newline-omission.d new file mode 100644 index 0000000000..310654a287 --- /dev/null +++ b/Task/Hello-world-Newline-omission/D/hello-world-newline-omission.d @@ -0,0 +1,5 @@ +import std.stdio; + +void main() { + write("Goodbye, World!"); +} diff --git a/Task/Hello-world-Newline-omission/DWScript/hello-world-newline-omission.dwscript b/Task/Hello-world-Newline-omission/DWScript/hello-world-newline-omission.dwscript new file mode 100644 index 0000000000..7a075f0873 --- /dev/null +++ b/Task/Hello-world-Newline-omission/DWScript/hello-world-newline-omission.dwscript @@ -0,0 +1 @@ +Print('Goodbye, World!'); diff --git a/Task/Hello-world-Newline-omission/Deja-Vu/hello-world-newline-omission.djv b/Task/Hello-world-Newline-omission/Deja-Vu/hello-world-newline-omission.djv new file mode 100644 index 0000000000..886afd8d92 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Deja-Vu/hello-world-newline-omission.djv @@ -0,0 +1 @@ +print\ "Goodbye, World!" diff --git a/Task/Hello-world-Newline-omission/Delphi/hello-world-newline-omission.delphi b/Task/Hello-world-Newline-omission/Delphi/hello-world-newline-omission.delphi new file mode 100644 index 0000000000..188d0c7b27 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Delphi/hello-world-newline-omission.delphi @@ -0,0 +1,7 @@ +program Project1; + +{$APPTYPE CONSOLE} + +begin + Write('Goodbye, World!'); +end. diff --git a/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-1.net b/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-1.net new file mode 100644 index 0000000000..05f17cc220 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-1.net @@ -0,0 +1 @@ +Console::Write("Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-2.net b/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-2.net new file mode 100644 index 0000000000..10814d63fc --- /dev/null +++ b/Task/Hello-world-Newline-omission/Dylan.NET/hello-world-newline-omission-2.net @@ -0,0 +1,16 @@ +//compile using the new dylan.NET v, 11.3.1.3 or later +//use mono to run the compiler +#refstdasm mscorlib.dll + +import System + +assembly gdbyeex exe +ver 1.1.0.0 + +class public auto ansi Module1 + + method public static void main() + Console::Write("Goodbye, World!") + end method + +end class diff --git a/Task/Hello-world-Newline-omission/Erlang/hello-world-newline-omission.erl b/Task/Hello-world-Newline-omission/Erlang/hello-world-newline-omission.erl new file mode 100644 index 0000000000..01a415d3bf --- /dev/null +++ b/Task/Hello-world-Newline-omission/Erlang/hello-world-newline-omission.erl @@ -0,0 +1 @@ +io:format("Goodbye, world!"). diff --git a/Task/Hello-world-Newline-omission/Euphoria/hello-world-newline-omission.euphoria b/Task/Hello-world-Newline-omission/Euphoria/hello-world-newline-omission.euphoria new file mode 100644 index 0000000000..a4ff548da0 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Euphoria/hello-world-newline-omission.euphoria @@ -0,0 +1,2 @@ +-- In Euphoria puts() does not insert a newline character after outputting a string +puts(1,"Goodbye, world!") diff --git a/Task/Hello-world-Newline-omission/Factor/hello-world-newline-omission.factor b/Task/Hello-world-Newline-omission/Factor/hello-world-newline-omission.factor new file mode 100644 index 0000000000..104f9a3094 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Factor/hello-world-newline-omission.factor @@ -0,0 +1,2 @@ +USE: io +"Goodbye, World!" write diff --git a/Task/Hello-world-Newline-omission/Fantom/hello-world-newline-omission.fantom b/Task/Hello-world-Newline-omission/Fantom/hello-world-newline-omission.fantom new file mode 100644 index 0000000000..f3e5dcfe41 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Fantom/hello-world-newline-omission.fantom @@ -0,0 +1,7 @@ +class Main +{ + Void main () + { + Env.cur.out.writeChars ("Hello world") + } +} diff --git a/Task/Hello-world-Newline-omission/Forth/hello-world-newline-omission.fth b/Task/Hello-world-Newline-omission/Forth/hello-world-newline-omission.fth new file mode 100644 index 0000000000..1fa395e74a --- /dev/null +++ b/Task/Hello-world-Newline-omission/Forth/hello-world-newline-omission.fth @@ -0,0 +1,2 @@ +\ The Forth word ." does not insert a newline character after outputting a string +." Goodbye, World!" diff --git a/Task/Hello-world-Newline-omission/Fortran/hello-world-newline-omission.f b/Task/Hello-world-Newline-omission/Fortran/hello-world-newline-omission.f new file mode 100644 index 0000000000..2f7204eb41 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Fortran/hello-world-newline-omission.f @@ -0,0 +1,3 @@ +program bye + write (*,'(a)',advance='no') 'Goodbye, World!' +end program bye diff --git a/Task/Hello-world-Newline-omission/Frink/hello-world-newline-omission.frink b/Task/Hello-world-Newline-omission/Frink/hello-world-newline-omission.frink new file mode 100644 index 0000000000..355d6d4711 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Frink/hello-world-newline-omission.frink @@ -0,0 +1 @@ +print["Goodbye, World!"] diff --git a/Task/Hello-world-Newline-omission/GUISS/hello-world-newline-omission.guiss b/Task/Hello-world-Newline-omission/GUISS/hello-world-newline-omission.guiss new file mode 100644 index 0000000000..f0ceda619f --- /dev/null +++ b/Task/Hello-world-Newline-omission/GUISS/hello-world-newline-omission.guiss @@ -0,0 +1 @@ +Start,Programs,Accessories,Notepad,Type:Goodbye World[pling] diff --git a/Task/Hello-world-Newline-omission/Go/hello-world-newline-omission.go b/Task/Hello-world-Newline-omission/Go/hello-world-newline-omission.go new file mode 100644 index 0000000000..dd9cf4c32f --- /dev/null +++ b/Task/Hello-world-Newline-omission/Go/hello-world-newline-omission.go @@ -0,0 +1,5 @@ +package main + +import "fmt" + +func main() { fmt.Print("Goodbye, World!") } diff --git a/Task/Hello-world-Newline-omission/Groovy/hello-world-newline-omission.groovy b/Task/Hello-world-Newline-omission/Groovy/hello-world-newline-omission.groovy new file mode 100644 index 0000000000..a4691e8aba --- /dev/null +++ b/Task/Hello-world-Newline-omission/Groovy/hello-world-newline-omission.groovy @@ -0,0 +1 @@ +print "Goodbye, world" diff --git a/Task/Hello-world-Newline-omission/Haskell/hello-world-newline-omission.hs b/Task/Hello-world-Newline-omission/Haskell/hello-world-newline-omission.hs new file mode 100644 index 0000000000..1d0a60c874 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Haskell/hello-world-newline-omission.hs @@ -0,0 +1 @@ +main = putStr "Goodbye, world" diff --git a/Task/Hello-world-Newline-omission/Icon/hello-world-newline-omission.icon b/Task/Hello-world-Newline-omission/Icon/hello-world-newline-omission.icon new file mode 100644 index 0000000000..550278b160 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Icon/hello-world-newline-omission.icon @@ -0,0 +1,3 @@ +procedure main() + writes("Goodbye, World!") +end diff --git a/Task/Hello-world-Newline-omission/Java/hello-world-newline-omission.java b/Task/Hello-world-Newline-omission/Java/hello-world-newline-omission.java new file mode 100644 index 0000000000..f008cc7b58 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Java/hello-world-newline-omission.java @@ -0,0 +1,7 @@ +public class HelloWorld +{ + public static void main(String[] args) + { + System.out.print("Goodbye, World!"); + } +} diff --git a/Task/Hello-world-Newline-omission/Liberty-BASIC/hello-world-newline-omission.liberty b/Task/Hello-world-Newline-omission/Liberty-BASIC/hello-world-newline-omission.liberty new file mode 100644 index 0000000000..06eb32599c --- /dev/null +++ b/Task/Hello-world-Newline-omission/Liberty-BASIC/hello-world-newline-omission.liberty @@ -0,0 +1 @@ +print "Goodbye, World!"; diff --git a/Task/Hello-world-Newline-omission/Lua/hello-world-newline-omission.lua b/Task/Hello-world-Newline-omission/Lua/hello-world-newline-omission.lua new file mode 100644 index 0000000000..57ea7bb146 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Lua/hello-world-newline-omission.lua @@ -0,0 +1 @@ +io.write("Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-1.ml b/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-1.ml new file mode 100644 index 0000000000..f06c489626 --- /dev/null +++ b/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-1.ml @@ -0,0 +1 @@ +Goodbye, World! diff --git a/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-2.ml b/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-2.ml new file mode 100644 index 0000000000..eacee72e90 --- /dev/null +++ b/Task/Hello-world-Newline-omission/ML-I/hello-world-newline-omission-2.ml @@ -0,0 +1,2 @@ +MCSKIP " WITH " NL +Goodbye, World!"" diff --git a/Task/Hello-world-Newline-omission/Maple/hello-world-newline-omission.maple b/Task/Hello-world-Newline-omission/Maple/hello-world-newline-omission.maple new file mode 100644 index 0000000000..c5b850cbb3 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Maple/hello-world-newline-omission.maple @@ -0,0 +1 @@ +printf( "Goodbye, World!" ); diff --git a/Task/Hello-world-Newline-omission/Mathematica/hello-world-newline-omission.mathematica b/Task/Hello-world-Newline-omission/Mathematica/hello-world-newline-omission.mathematica new file mode 100644 index 0000000000..75eb8418e7 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Mathematica/hello-world-newline-omission.mathematica @@ -0,0 +1 @@ +NotebookWrite[EvaluationNotebook[], "Goodbye, World!"] diff --git a/Task/Hello-world-Newline-omission/Perl/hello-world-newline-omission.pl b/Task/Hello-world-Newline-omission/Perl/hello-world-newline-omission.pl new file mode 100644 index 0000000000..7602646713 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Perl/hello-world-newline-omission.pl @@ -0,0 +1 @@ +print "Goodbye, World!"; # A newline does not occur automatically diff --git a/Task/Hello-world-Newline-omission/PicoLisp/hello-world-newline-omission.l b/Task/Hello-world-Newline-omission/PicoLisp/hello-world-newline-omission.l new file mode 100644 index 0000000000..f809cd9841 --- /dev/null +++ b/Task/Hello-world-Newline-omission/PicoLisp/hello-world-newline-omission.l @@ -0,0 +1 @@ +(prin "Goodbye, world") diff --git a/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-1.py b/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-1.py new file mode 100644 index 0000000000..1755a5aed6 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-1.py @@ -0,0 +1,2 @@ +import sys +sys.stdout.write("Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-2.py b/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-2.py new file mode 100644 index 0000000000..c6cfc4eac8 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Python/hello-world-newline-omission-2.py @@ -0,0 +1 @@ +print("Goodbye, World!", end="") diff --git a/Task/Hello-world-Newline-omission/REXX/hello-world-newline-omission.rexx b/Task/Hello-world-Newline-omission/REXX/hello-world-newline-omission.rexx new file mode 100644 index 0000000000..a8fb10461f --- /dev/null +++ b/Task/Hello-world-Newline-omission/REXX/hello-world-newline-omission.rexx @@ -0,0 +1,3 @@ +/*REXX pgm displays a "Goodbye, World!" without a trailing newline. */ + +call charout ,'Goodbye, World!' diff --git a/Task/Hello-world-Newline-omission/Ruby/hello-world-newline-omission.rb b/Task/Hello-world-Newline-omission/Ruby/hello-world-newline-omission.rb new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Ruby/hello-world-newline-omission.rb @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Newline-omission/Scheme/hello-world-newline-omission.ss b/Task/Hello-world-Newline-omission/Scheme/hello-world-newline-omission.ss new file mode 100644 index 0000000000..45077c3429 --- /dev/null +++ b/Task/Hello-world-Newline-omission/Scheme/hello-world-newline-omission.ss @@ -0,0 +1 @@ +(display "Goodbye, World!") diff --git a/Task/Hello-world-Newline-omission/Tcl/hello-world-newline-omission.tcl b/Task/Hello-world-Newline-omission/Tcl/hello-world-newline-omission.tcl new file mode 100644 index 0000000000..bebbeb03cc --- /dev/null +++ b/Task/Hello-world-Newline-omission/Tcl/hello-world-newline-omission.tcl @@ -0,0 +1 @@ +puts -nonewline "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/0DESCRIPTION b/Task/Hello-world-Standard-error/0DESCRIPTION new file mode 100644 index 0000000000..d595c6ffbe --- /dev/null +++ b/Task/Hello-world-Standard-error/0DESCRIPTION @@ -0,0 +1,3 @@ +{{selection|Short Circuit|Console Program Basics}}A common practice in computing is to send error messages to a different output stream than [[User Output - text|normal text console messages]]. The normal messages print to what is called "standard output" or "standard out". The error messages print to "standard error". This separation can be used to redirect error messages to a different place than normal messages. + +Show how to print a message to standard error by printing "Goodbye, World!" on that stream. diff --git a/Task/Hello-world-Standard-error/1META.yaml b/Task/Hello-world-Standard-error/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Hello-world-Standard-error/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Hello-world-Standard-error/4DOS-Batch/hello-world-standard-error.4dos b/Task/Hello-world-Standard-error/4DOS-Batch/hello-world-standard-error.4dos new file mode 100644 index 0000000000..7e930d90a2 --- /dev/null +++ b/Task/Hello-world-Standard-error/4DOS-Batch/hello-world-standard-error.4dos @@ -0,0 +1 @@ +echoerr Goodbye, World! diff --git a/Task/Hello-world-Standard-error/ALGOL-68/hello-world-standard-error.alg b/Task/Hello-world-Standard-error/ALGOL-68/hello-world-standard-error.alg new file mode 100644 index 0000000000..34394f41dd --- /dev/null +++ b/Task/Hello-world-Standard-error/ALGOL-68/hello-world-standard-error.alg @@ -0,0 +1,3 @@ +main:( + put(stand error, ("Goodbye, World!", new line)) +) diff --git a/Task/Hello-world-Standard-error/ATS/hello-world-standard-error.ats b/Task/Hello-world-Standard-error/ATS/hello-world-standard-error.ats new file mode 100644 index 0000000000..8a8a439936 --- /dev/null +++ b/Task/Hello-world-Standard-error/ATS/hello-world-standard-error.ats @@ -0,0 +1 @@ +implement main () = fprint (stderr_ref, "Goodbye, World!\n") diff --git a/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-1.awk b/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-1.awk new file mode 100644 index 0000000000..b22f8b5356 --- /dev/null +++ b/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-1.awk @@ -0,0 +1,3 @@ +BEGIN { + print "Goodbye, World!"| "cat 1>&2" +} diff --git a/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-2.awk b/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-2.awk new file mode 100644 index 0000000000..05ceebf8d9 --- /dev/null +++ b/Task/Hello-world-Standard-error/AWK/hello-world-standard-error-2.awk @@ -0,0 +1,3 @@ +BEGIN { + print "Goodbye, World!" > "/dev/stderr" +} diff --git a/Task/Hello-world-Standard-error/Ada/hello-world-standard-error.ada b/Task/Hello-world-Standard-error/Ada/hello-world-standard-error.ada new file mode 100644 index 0000000000..bc0ef2c3b3 --- /dev/null +++ b/Task/Hello-world-Standard-error/Ada/hello-world-standard-error.ada @@ -0,0 +1,6 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Goodbye_World is +begin + Put_Line (Standard_Error, "Goodbye, World!"); +end Goodbye_World; diff --git a/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-1.argile b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-1.argile new file mode 100644 index 0000000000..63d6f52e43 --- /dev/null +++ b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-1.argile @@ -0,0 +1,2 @@ +use std +eprint "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-2.argile b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-2.argile new file mode 100644 index 0000000000..e11b3a18b0 --- /dev/null +++ b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-2.argile @@ -0,0 +1,2 @@ +use std +eprintf "Goodbye, World!\n" diff --git a/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-3.argile b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-3.argile new file mode 100644 index 0000000000..db6d1771e5 --- /dev/null +++ b/Task/Hello-world-Standard-error/Argile/hello-world-standard-error-3.argile @@ -0,0 +1,2 @@ +use std +fprintf stderr "Goodbye, World!\n" diff --git a/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-1.ahk b/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-1.ahk new file mode 100644 index 0000000000..e0cf3e6c27 --- /dev/null +++ b/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-1.ahk @@ -0,0 +1,2 @@ +; c:\> autohotkey.exe stderr.ahk 2> error.txt +FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N diff --git a/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-2.ahk b/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-2.ahk new file mode 100644 index 0000000000..81a7099c59 --- /dev/null +++ b/Task/Hello-world-Standard-error/AutoHotkey/hello-world-standard-error-2.ahk @@ -0,0 +1 @@ +FileAppend, Goodbye`, World!, * diff --git a/Task/Hello-world-Standard-error/AutoIt/hello-world-standard-error.autoit b/Task/Hello-world-Standard-error/AutoIt/hello-world-standard-error.autoit new file mode 100644 index 0000000000..03965394cb --- /dev/null +++ b/Task/Hello-world-Standard-error/AutoIt/hello-world-standard-error.autoit @@ -0,0 +1 @@ +ConsoleWriteError("Goodbye, World!" & @CRLF) diff --git a/Task/Hello-world-Standard-error/BASIC/hello-world-standard-error.bas b/Task/Hello-world-Standard-error/BASIC/hello-world-standard-error.bas new file mode 100644 index 0000000000..9df0bc8f18 --- /dev/null +++ b/Task/Hello-world-Standard-error/BASIC/hello-world-standard-error.bas @@ -0,0 +1,2 @@ +10 PRINT #1;"Goodbye, World!" +20 PAUSE 5: REM allow time for the user to see the error message diff --git a/Task/Hello-world-Standard-error/BBC-BASIC/hello-world-standard-error.bbc b/Task/Hello-world-Standard-error/BBC-BASIC/hello-world-standard-error.bbc new file mode 100644 index 0000000000..fa0eadb88c --- /dev/null +++ b/Task/Hello-world-Standard-error/BBC-BASIC/hello-world-standard-error.bbc @@ -0,0 +1,4 @@ + STD_ERROR_HANDLE = -12 + SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1) + PRINT #13, "Goodbye, World!" + QUIT diff --git a/Task/Hello-world-Standard-error/Batch-File/hello-world-standard-error.bat b/Task/Hello-world-Standard-error/Batch-File/hello-world-standard-error.bat new file mode 100644 index 0000000000..05a98a70f2 --- /dev/null +++ b/Task/Hello-world-Standard-error/Batch-File/hello-world-standard-error.bat @@ -0,0 +1 @@ +1>&2 echo Goodbye, World! diff --git a/Task/Hello-world-Standard-error/C++/hello-world-standard-error.cpp b/Task/Hello-world-Standard-error/C++/hello-world-standard-error.cpp new file mode 100644 index 0000000000..b4b871c450 --- /dev/null +++ b/Task/Hello-world-Standard-error/C++/hello-world-standard-error.cpp @@ -0,0 +1,10 @@ +#include + +using std::cerr; +using std::endl; + +int main () { + cerr << "Goodbye, World!" << endl; + + return cerr.bad(); +} diff --git a/Task/Hello-world-Standard-error/C/hello-world-standard-error.c b/Task/Hello-world-Standard-error/C/hello-world-standard-error.c new file mode 100644 index 0000000000..d004930155 --- /dev/null +++ b/Task/Hello-world-Standard-error/C/hello-world-standard-error.c @@ -0,0 +1,9 @@ +#include + +int main() +{ + fprintf(stderr, "Goodbye, "); + fputs("World!\n", stderr); + + return 0; +} diff --git a/Task/Hello-world-Standard-error/CMake/hello-world-standard-error.cmake b/Task/Hello-world-Standard-error/CMake/hello-world-standard-error.cmake new file mode 100644 index 0000000000..eed78d549b --- /dev/null +++ b/Task/Hello-world-Standard-error/CMake/hello-world-standard-error.cmake @@ -0,0 +1 @@ +message("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/COBOL/hello-world-standard-error.cobol b/Task/Hello-world-Standard-error/COBOL/hello-world-standard-error.cobol new file mode 100644 index 0000000000..3d24cd14fb --- /dev/null +++ b/Task/Hello-world-Standard-error/COBOL/hello-world-standard-error.cobol @@ -0,0 +1,4 @@ + program-id. ehello. + procedure division. + display "Goodbye, world!" upon syserr. + stop run. diff --git a/Task/Hello-world-Standard-error/Clojure/hello-world-standard-error.clj b/Task/Hello-world-Standard-error/Clojure/hello-world-standard-error.clj new file mode 100644 index 0000000000..01e08abf8d --- /dev/null +++ b/Task/Hello-world-Standard-error/Clojure/hello-world-standard-error.clj @@ -0,0 +1,2 @@ +(binding [*out* *err*] + (println "Goodbye, world!")) diff --git a/Task/Hello-world-Standard-error/CoffeeScript/hello-world-standard-error.coffee b/Task/Hello-world-Standard-error/CoffeeScript/hello-world-standard-error.coffee new file mode 100644 index 0000000000..2097f1cb34 --- /dev/null +++ b/Task/Hello-world-Standard-error/CoffeeScript/hello-world-standard-error.coffee @@ -0,0 +1 @@ +console.warn "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Common-Lisp/hello-world-standard-error.lisp b/Task/Hello-world-Standard-error/Common-Lisp/hello-world-standard-error.lisp new file mode 100644 index 0000000000..fdefc1e10e --- /dev/null +++ b/Task/Hello-world-Standard-error/Common-Lisp/hello-world-standard-error.lisp @@ -0,0 +1 @@ +(format *error-output* "Goodbye, world!~%") diff --git a/Task/Hello-world-Standard-error/D/hello-world-standard-error-1.d b/Task/Hello-world-Standard-error/D/hello-world-standard-error-1.d new file mode 100644 index 0000000000..86ee63bb3d --- /dev/null +++ b/Task/Hello-world-Standard-error/D/hello-world-standard-error-1.d @@ -0,0 +1,5 @@ +import std.stdio; + +void main () { + stderr.writeln("Goodbye, World!"); +} diff --git a/Task/Hello-world-Standard-error/D/hello-world-standard-error-2.d b/Task/Hello-world-Standard-error/D/hello-world-standard-error-2.d new file mode 100644 index 0000000000..3f3ec89f4d --- /dev/null +++ b/Task/Hello-world-Standard-error/D/hello-world-standard-error-2.d @@ -0,0 +1,5 @@ +import tango.io.Stdout; + +void main () { + Stderr("Goodbye, World!").newline; +} diff --git a/Task/Hello-world-Standard-error/Delphi/hello-world-standard-error.delphi b/Task/Hello-world-Standard-error/Delphi/hello-world-standard-error.delphi new file mode 100644 index 0000000000..35a6bc59d6 --- /dev/null +++ b/Task/Hello-world-Standard-error/Delphi/hello-world-standard-error.delphi @@ -0,0 +1,7 @@ +program Project1; + +{$APPTYPE CONSOLE} + +begin + WriteLn(ErrOutput, 'Goodbye, World!'); +end. diff --git a/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-1.net b/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-1.net new file mode 100644 index 0000000000..c7b59d89ae --- /dev/null +++ b/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-1.net @@ -0,0 +1 @@ +Console::get_Error()::WriteLine("Goodbye World!") diff --git a/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-2.net b/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-2.net new file mode 100644 index 0000000000..7c9f2baa63 --- /dev/null +++ b/Task/Hello-world-Standard-error/Dylan.NET/hello-world-standard-error-2.net @@ -0,0 +1,16 @@ +//compile using the new dylan.NET v, 11.2.8.2 or later +//use mono to run the compiler +#refstdasm mscorlib.dll + +import System + +assembly stderrex exe +ver 1.1.0.0 + +class public auto ansi Module1 + + method public static void main() + Console::get_Error()::WriteLine("Goodbye World!") + end method + +end class diff --git a/Task/Hello-world-Standard-error/E/hello-world-standard-error.e b/Task/Hello-world-Standard-error/E/hello-world-standard-error.e new file mode 100644 index 0000000000..af7f41286a --- /dev/null +++ b/Task/Hello-world-Standard-error/E/hello-world-standard-error.e @@ -0,0 +1 @@ +stderr.println("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Erlang/hello-world-standard-error.erl b/Task/Hello-world-Standard-error/Erlang/hello-world-standard-error.erl new file mode 100644 index 0000000000..e30f9f2fe0 --- /dev/null +++ b/Task/Hello-world-Standard-error/Erlang/hello-world-standard-error.erl @@ -0,0 +1 @@ +io:put_chars(standard_error, "Goodbye, World!\n"). diff --git a/Task/Hello-world-Standard-error/Euphoria/hello-world-standard-error.euphoria b/Task/Hello-world-Standard-error/Euphoria/hello-world-standard-error.euphoria new file mode 100644 index 0000000000..62fd9f05b7 --- /dev/null +++ b/Task/Hello-world-Standard-error/Euphoria/hello-world-standard-error.euphoria @@ -0,0 +1 @@ +puts(2,"Goodbye, world!\n") -- 2 means output to 'standard error' diff --git a/Task/Hello-world-Standard-error/Factor/hello-world-standard-error.factor b/Task/Hello-world-Standard-error/Factor/hello-world-standard-error.factor new file mode 100644 index 0000000000..354b8ee555 --- /dev/null +++ b/Task/Hello-world-Standard-error/Factor/hello-world-standard-error.factor @@ -0,0 +1 @@ +error-stream get [ "Goodbye, World! bbl, crashing" print flush ] with-output-stream* diff --git a/Task/Hello-world-Standard-error/Fantom/hello-world-standard-error.fantom b/Task/Hello-world-Standard-error/Fantom/hello-world-standard-error.fantom new file mode 100644 index 0000000000..26f3f87733 --- /dev/null +++ b/Task/Hello-world-Standard-error/Fantom/hello-world-standard-error.fantom @@ -0,0 +1,7 @@ +class Main +{ + public static Void main () + { + Env.cur.err.printLine ("Goodbye, World!") + } +} diff --git a/Task/Hello-world-Standard-error/Forth/hello-world-standard-error.fth b/Task/Hello-world-Standard-error/Forth/hello-world-standard-error.fth new file mode 100644 index 0000000000..b97d958bb9 --- /dev/null +++ b/Task/Hello-world-Standard-error/Forth/hello-world-standard-error.fth @@ -0,0 +1,4 @@ +outfile-id + stderr to outfile-id + ." Goodbye, World!" cr +to outfile-id diff --git a/Task/Hello-world-Standard-error/Fortran/hello-world-standard-error.f b/Task/Hello-world-Standard-error/Fortran/hello-world-standard-error.f new file mode 100644 index 0000000000..3165aec677 --- /dev/null +++ b/Task/Hello-world-Standard-error/Fortran/hello-world-standard-error.f @@ -0,0 +1,9 @@ +program StdErr + ! Fortran 2003 + use iso_fortran_env + + ! in case there's no module iso_fortran_env ... + !integer, parameter :: ERROR_UNIT = 0 + + write (ERROR_UNIT, *) "Goodbye, World!" +end program StdErr diff --git a/Task/Hello-world-Standard-error/Go/hello-world-standard-error-1.go b/Task/Hello-world-Standard-error/Go/hello-world-standard-error-1.go new file mode 100644 index 0000000000..ff4d4f256c --- /dev/null +++ b/Task/Hello-world-Standard-error/Go/hello-world-standard-error-1.go @@ -0,0 +1,2 @@ +package main +func main() { println("Goodbye, World!") } diff --git a/Task/Hello-world-Standard-error/Go/hello-world-standard-error-2.go b/Task/Hello-world-Standard-error/Go/hello-world-standard-error-2.go new file mode 100644 index 0000000000..47475fd52c --- /dev/null +++ b/Task/Hello-world-Standard-error/Go/hello-world-standard-error-2.go @@ -0,0 +1,3 @@ +package main +import ("fmt"; "os") +func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") } diff --git a/Task/Hello-world-Standard-error/Groovy/hello-world-standard-error.groovy b/Task/Hello-world-Standard-error/Groovy/hello-world-standard-error.groovy new file mode 100644 index 0000000000..06d66a6512 --- /dev/null +++ b/Task/Hello-world-Standard-error/Groovy/hello-world-standard-error.groovy @@ -0,0 +1 @@ +System.err.println("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Haskell/hello-world-standard-error.hs b/Task/Hello-world-Standard-error/Haskell/hello-world-standard-error.hs new file mode 100644 index 0000000000..784af81fd8 --- /dev/null +++ b/Task/Hello-world-Standard-error/Haskell/hello-world-standard-error.hs @@ -0,0 +1,2 @@ +import System.IO +main = hPutStrLn stderr "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Icon/hello-world-standard-error.icon b/Task/Hello-world-Standard-error/Icon/hello-world-standard-error.icon new file mode 100644 index 0000000000..005bd5bf94 --- /dev/null +++ b/Task/Hello-world-Standard-error/Icon/hello-world-standard-error.icon @@ -0,0 +1,3 @@ +procedure main() + write(&errout, "Goodbye World" ) +end diff --git a/Task/Hello-world-Standard-error/J/hello-world-standard-error.j b/Task/Hello-world-Standard-error/J/hello-world-standard-error.j new file mode 100644 index 0000000000..740f485e6b --- /dev/null +++ b/Task/Hello-world-Standard-error/J/hello-world-standard-error.j @@ -0,0 +1,2 @@ +stderr =: 1!:2&4 +stderr 'Goodbye, World!' diff --git a/Task/Hello-world-Standard-error/Java/hello-world-standard-error.java b/Task/Hello-world-Standard-error/Java/hello-world-standard-error.java new file mode 100644 index 0000000000..76b2628742 --- /dev/null +++ b/Task/Hello-world-Standard-error/Java/hello-world-standard-error.java @@ -0,0 +1,5 @@ +public class Err{ + public static void main(String[] args){ + System.err.println("Goodbye, World!"); + } +} diff --git a/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-1.js b/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-1.js new file mode 100644 index 0000000000..bfffabf052 --- /dev/null +++ b/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-1.js @@ -0,0 +1 @@ +WScript.StdErr.WriteLine("Goodbye, World!"); diff --git a/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-2.js b/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-2.js new file mode 100644 index 0000000000..d2a6adc20c --- /dev/null +++ b/Task/Hello-world-Standard-error/JavaScript/hello-world-standard-error-2.js @@ -0,0 +1 @@ +console.warn("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Lua/hello-world-standard-error.lua b/Task/Hello-world-Standard-error/Lua/hello-world-standard-error.lua new file mode 100644 index 0000000000..414d6717ff --- /dev/null +++ b/Task/Hello-world-Standard-error/Lua/hello-world-standard-error.lua @@ -0,0 +1 @@ +io.stderr:write("Goodbye, World!\n") diff --git a/Task/Hello-world-Standard-error/MATLAB/hello-world-standard-error.m b/Task/Hello-world-Standard-error/MATLAB/hello-world-standard-error.m new file mode 100644 index 0000000000..8153dc5b12 --- /dev/null +++ b/Task/Hello-world-Standard-error/MATLAB/hello-world-standard-error.m @@ -0,0 +1 @@ +error 'Goodbye, World!' diff --git a/Task/Hello-world-Standard-error/ML-I/hello-world-standard-error.ml b/Task/Hello-world-Standard-error/ML-I/hello-world-standard-error.ml new file mode 100644 index 0000000000..6c34599ce9 --- /dev/null +++ b/Task/Hello-world-Standard-error/ML-I/hello-world-standard-error.ml @@ -0,0 +1,2 @@ +MCSET S4=1 +MCNOTE Goodbye, World! diff --git a/Task/Hello-world-Standard-error/Mathematica/hello-world-standard-error.mathematica b/Task/Hello-world-Standard-error/Mathematica/hello-world-standard-error.mathematica new file mode 100644 index 0000000000..ad293adb93 --- /dev/null +++ b/Task/Hello-world-Standard-error/Mathematica/hello-world-standard-error.mathematica @@ -0,0 +1 @@ +Write[Streams["stderr"], "Goodbye, World!"] diff --git a/Task/Hello-world-Standard-error/Mercury/hello-world-standard-error.mercury b/Task/Hello-world-Standard-error/Mercury/hello-world-standard-error.mercury new file mode 100644 index 0000000000..7c94e8e947 --- /dev/null +++ b/Task/Hello-world-Standard-error/Mercury/hello-world-standard-error.mercury @@ -0,0 +1,11 @@ +:- module hello_error. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. + +main(!IO) :- + io.stderr_stream(Stderr, !IO), + io.write_string(Stderr, "Goodbye, World!\n", !IO). diff --git a/Task/Hello-world-Standard-error/Metafont/hello-world-standard-error.metafont b/Task/Hello-world-Standard-error/Metafont/hello-world-standard-error.metafont new file mode 100644 index 0000000000..3fa04464b0 --- /dev/null +++ b/Task/Hello-world-Standard-error/Metafont/hello-world-standard-error.metafont @@ -0,0 +1,3 @@ +errmessage "Error"; +message "...going on..."; % if the user decides to go on and not to stop + % the program because of the error. diff --git a/Task/Hello-world-Standard-error/Modula-2/hello-world-standard-error.mod2 b/Task/Hello-world-Standard-error/Modula-2/hello-world-standard-error.mod2 new file mode 100644 index 0000000000..c267749907 --- /dev/null +++ b/Task/Hello-world-Standard-error/Modula-2/hello-world-standard-error.mod2 @@ -0,0 +1,7 @@ +MODULE HelloErr; +IMPORT StdError; + +BEGIN + StdError.WriteString('Goodbye, World!'); + StdError.WriteLn +END HelloErr. diff --git a/Task/Hello-world-Standard-error/Modula-3/hello-world-standard-error.mod3 b/Task/Hello-world-Standard-error/Modula-3/hello-world-standard-error.mod3 new file mode 100644 index 0000000000..ebe23cf983 --- /dev/null +++ b/Task/Hello-world-Standard-error/Modula-3/hello-world-standard-error.mod3 @@ -0,0 +1,7 @@ +MODULE Stderr EXPORTS Main; + +IMPORT Wr, Stdio; + +BEGIN + Wr.PutText(Stdio.stderr, "Goodbye, World!\n"); +END Stderr. diff --git a/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-1.php b/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-1.php new file mode 100644 index 0000000000..a7b3c30264 --- /dev/null +++ b/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-1.php @@ -0,0 +1 @@ +fprintf(STDERR, "Goodbye, World!\n"); diff --git a/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-2.php b/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-2.php new file mode 100644 index 0000000000..349002e75e --- /dev/null +++ b/Task/Hello-world-Standard-error/PHP/hello-world-standard-error-2.php @@ -0,0 +1 @@ +file_put_contents("php://stderr","Hello World!\n"); diff --git a/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-1.pl b/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-1.pl new file mode 100644 index 0000000000..3970b9b78e --- /dev/null +++ b/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-1.pl @@ -0,0 +1 @@ +warn "Goodbye, World!\n"; diff --git a/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-2.pl b/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-2.pl new file mode 100644 index 0000000000..752fc1684d --- /dev/null +++ b/Task/Hello-world-Standard-error/Perl/hello-world-standard-error-2.pl @@ -0,0 +1 @@ +print STDERR "Goodbye, World!\n"; diff --git a/Task/Hello-world-Standard-error/PicoLisp/hello-world-standard-error.l b/Task/Hello-world-Standard-error/PicoLisp/hello-world-standard-error.l new file mode 100644 index 0000000000..c5760a2d02 --- /dev/null +++ b/Task/Hello-world-Standard-error/PicoLisp/hello-world-standard-error.l @@ -0,0 +1 @@ +(out 2 (prinl "Goodbye, World!")) diff --git a/Task/Hello-world-Standard-error/Python/hello-world-standard-error-1.py b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-1.py new file mode 100644 index 0000000000..95d9ca6338 --- /dev/null +++ b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-1.py @@ -0,0 +1,3 @@ +import sys + +print >> sys.stderr, "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Python/hello-world-standard-error-2.py b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-2.py new file mode 100644 index 0000000000..a810b8faa3 --- /dev/null +++ b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-2.py @@ -0,0 +1,3 @@ +import sys + +print("Goodbye, World!", file=sys.stderr) diff --git a/Task/Hello-world-Standard-error/Python/hello-world-standard-error-3.py b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-3.py new file mode 100644 index 0000000000..fc18f94dfe --- /dev/null +++ b/Task/Hello-world-Standard-error/Python/hello-world-standard-error-3.py @@ -0,0 +1,3 @@ +import sys + +sys.stderr.write("Goodbye, World!\n") diff --git a/Task/Hello-world-Standard-error/R/hello-world-standard-error.r b/Task/Hello-world-Standard-error/R/hello-world-standard-error.r new file mode 100644 index 0000000000..e8725b6fb4 --- /dev/null +++ b/Task/Hello-world-Standard-error/R/hello-world-standard-error.r @@ -0,0 +1 @@ +cat("Goodbye, World!", file=stderr()) diff --git a/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-1.rexx b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-1.rexx new file mode 100644 index 0000000000..a1ec6ead2c --- /dev/null +++ b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-1.rexx @@ -0,0 +1 @@ +say 'Goodbye, World!' diff --git a/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-2.rexx b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-2.rexx new file mode 100644 index 0000000000..2d546acdaa --- /dev/null +++ b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-2.rexx @@ -0,0 +1 @@ +say "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-3.rexx b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-3.rexx new file mode 100644 index 0000000000..989e73ff9e --- /dev/null +++ b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-3.rexx @@ -0,0 +1 @@ +call lineout ,"Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-4.rexx b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-4.rexx new file mode 100644 index 0000000000..442de3fc47 --- /dev/null +++ b/Task/Hello-world-Standard-error/REXX/hello-world-standard-error-4.rexx @@ -0,0 +1 @@ +call charout ,"Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Racket/hello-world-standard-error.rkt b/Task/Hello-world-Standard-error/Racket/hello-world-standard-error.rkt new file mode 100644 index 0000000000..43580516e2 --- /dev/null +++ b/Task/Hello-world-Standard-error/Racket/hello-world-standard-error.rkt @@ -0,0 +1 @@ +(eprintf "Goodbye, World!\n") diff --git a/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-1.rb b/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-1.rb new file mode 100644 index 0000000000..97c35b3262 --- /dev/null +++ b/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-1.rb @@ -0,0 +1 @@ +$stderr.puts "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-2.rb b/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-2.rb new file mode 100644 index 0000000000..d7b6c8beed --- /dev/null +++ b/Task/Hello-world-Standard-error/Ruby/hello-world-standard-error-2.rb @@ -0,0 +1 @@ +warn "Goodbye, World!" diff --git a/Task/Hello-world-Standard-error/Sather/hello-world-standard-error.sa b/Task/Hello-world-Standard-error/Sather/hello-world-standard-error.sa new file mode 100644 index 0000000000..5f162f07f5 --- /dev/null +++ b/Task/Hello-world-Standard-error/Sather/hello-world-standard-error.sa @@ -0,0 +1,5 @@ +class MAIN is + main is + #ERR + "Hello World!\n"; + end; +end; diff --git a/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-1.scala b/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-1.scala new file mode 100644 index 0000000000..06d66a6512 --- /dev/null +++ b/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-1.scala @@ -0,0 +1 @@ +System.err.println("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-2.scala b/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-2.scala new file mode 100644 index 0000000000..a9aec1c99a --- /dev/null +++ b/Task/Hello-world-Standard-error/Scala/hello-world-standard-error-2.scala @@ -0,0 +1 @@ +Console.err.println("Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Scheme/hello-world-standard-error.ss b/Task/Hello-world-Standard-error/Scheme/hello-world-standard-error.ss new file mode 100644 index 0000000000..035594d38a --- /dev/null +++ b/Task/Hello-world-Standard-error/Scheme/hello-world-standard-error.ss @@ -0,0 +1 @@ +(error "Goodbye, World!") diff --git a/Task/Hello-world-Standard-error/Tcl/hello-world-standard-error.tcl b/Task/Hello-world-Standard-error/Tcl/hello-world-standard-error.tcl new file mode 100644 index 0000000000..42fdeffb29 --- /dev/null +++ b/Task/Hello-world-Standard-error/Tcl/hello-world-standard-error.tcl @@ -0,0 +1 @@ +puts stderr "Goodbye, World!" diff --git a/Task/Hello-world-Text/0815/hello-world-text.0815 b/Task/Hello-world-Text/0815/hello-world-text.0815 new file mode 100644 index 0000000000..b26fc123c9 --- /dev/null +++ b/Task/Hello-world-Text/0815/hello-world-text.0815 @@ -0,0 +1,5 @@ +<:47:x<:6F:=<:64:$=$$=$ +<:62:x<:79:=<:65:$=$=$ +<:2C:x<:20:=<:57:$=$=$ +<:6F:x<:72:=<:6C:$=$=$ +<:64:x<:21:=<:0D:$=$=$ diff --git a/Task/Hello-world-Text/0DESCRIPTION b/Task/Hello-world-Text/0DESCRIPTION new file mode 100644 index 0000000000..ce80791888 --- /dev/null +++ b/Task/Hello-world-Text/0DESCRIPTION @@ -0,0 +1,8 @@ +{{selection|Short Circuit|Console Program Basics}}In this User Output task, the goal is to display the string "Goodbye, World!" [sic] on a text console. + +'''See also''' +* [[Hello world/Graphical]] +* [[Hello world/Line Printer]] +* [[Hello world/Newline omission]] +* [[Hello world/Standard error]] +* [[Hello world/Web server]] diff --git a/Task/Hello-world-Text/1META.yaml b/Task/Hello-world-Text/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Hello-world-Text/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Hello-world-Text/360-Assembly/hello-world-text.360 b/Task/Hello-world-Text/360-Assembly/hello-world-text.360 new file mode 100644 index 0000000000..a46d728e82 --- /dev/null +++ b/Task/Hello-world-Text/360-Assembly/hello-world-text.360 @@ -0,0 +1,16 @@ +{using native SVC (Supervisor Call) to write to system console} + + LA 1,MSGAREA Point Register 1 to message area + SVC 35 Invoke SVC 35 (Write to Operator) + BR 14 Return +MSGAREA EQU * Message Area + DC AL2(19) Total area length = 19 (Prefix length:4 + Data Length:15) + DC XL2'00' 2 bytes binary of zeros + DC C'Goodbye, World!' Text to be written to system console + END + +{using WTO Macro to generate SVC 35 and message area} + + WTO 'Goodbye, World!' + BR 14 Return + END diff --git a/Task/Hello-world-Text/4DOS-Batch/hello-world-text.4dos b/Task/Hello-world-Text/4DOS-Batch/hello-world-text.4dos new file mode 100644 index 0000000000..fd705ab250 --- /dev/null +++ b/Task/Hello-world-Text/4DOS-Batch/hello-world-text.4dos @@ -0,0 +1 @@ +echo Goodbye, World! diff --git a/Task/Hello-world-Text/6502-Assembly/hello-world-text.6502 b/Task/Hello-world-Text/6502-Assembly/hello-world-text.6502 new file mode 100644 index 0000000000..05ce162a15 --- /dev/null +++ b/Task/Hello-world-Text/6502-Assembly/hello-world-text.6502 @@ -0,0 +1,22 @@ +; goodbyeworld.s for C= 8-bit machines, ca65 assembler format. +; String printing limited to strings of 256 characters or less. + +a_cr = $0d ; Carriage return. +bsout = $ffd2 ; KERNAL ROM, output a character to current device. + + .code + + ldx #0 ; Starting index 0 in X register. +printnext: + lda text,x ; Get character from string. + beq done ; If we read a 0 we're done. + jsr bsout ; Output character. + inx ; Increment index to next character. + bne printnext ; Repeat if index doesn't overflow to 0. +done: + rts ; Return from subroutine. + + .rodata + +text: + .byte "Goodbye, World!", a_cr, 0 diff --git a/Task/Hello-world-Text/6800-Assembly/hello-world-text.6800 b/Task/Hello-world-Text/6800-Assembly/hello-world-text.6800 new file mode 100644 index 0000000000..8908ba7a58 --- /dev/null +++ b/Task/Hello-world-Text/6800-Assembly/hello-world-text.6800 @@ -0,0 +1,31 @@ + .cr 6800 + .tf gbye6800.obj,AP1 + .lf gbye6800 +;=====================================================; +; Goodbye, World! for the Motorola 6800 ; +; by barrym 2013-03-17 ; +;-----------------------------------------------------; +; Prints the message "Goodbye, World!" to an ascii ; +; terminal (console) connected to a 1970s vintage ; +; SWTPC 6800 system, which is the target device for ; +; this assembly. ; +; Many thanks to: ; +; swtpc.com for hosting Michael Holley's documents! ; +; sbprojects.com for a very nice assembler! ; +; swtpcemu.com for a very capable emulator! ; +; reg x is the string pointer ; +; reg a holds the ascii char to be output ; +;-----------------------------------------------------; +outeee = $e1d1 ROM: console putchar routine + .or $0f00 +;-----------------------------------------------------; +main ldx #string Point to the string + bra puts and print it +outs jsr outeee Emit a as ascii + inx Advance the string pointer +puts ldaa ,x Load a string character + bne outs Print it if non-null + swi else return to the monitor +;=====================================================; +string .as "Goodbye, World!",#13,#10,#0 + .en diff --git a/Task/Hello-world-Text/8086-Assembly/hello-world-text.8086 b/Task/Hello-world-Text/8086-Assembly/hello-world-text.8086 new file mode 100644 index 0000000000..7164843ed7 --- /dev/null +++ b/Task/Hello-world-Text/8086-Assembly/hello-world-text.8086 @@ -0,0 +1,16 @@ +DOSSEG +.MODEL TINY +.DATA +TXT DB "Goodbye, World!$" +.CODE +START: + MOV ax, @DATA + MOV ds, ax + + MOV ah, 09h ; prepare output function + MOV dx, OFFSET TXT ; set offset + INT 21h ; output string TXT + + MOV AX, 4C00h ; go back to DOS + INT 21h +END START diff --git a/Task/Hello-world-Text/ABAP/hello-world-text.abap b/Task/Hello-world-Text/ABAP/hello-world-text.abap new file mode 100644 index 0000000000..d00a545f70 --- /dev/null +++ b/Task/Hello-world-Text/ABAP/hello-world-text.abap @@ -0,0 +1,2 @@ +REPORT zgoodbyeworld. + WRITE 'Goodbye, World!'. diff --git a/Task/Hello-world-Text/ACL2/hello-world-text.acl2 b/Task/Hello-world-Text/ACL2/hello-world-text.acl2 new file mode 100644 index 0000000000..afd55197c9 --- /dev/null +++ b/Task/Hello-world-Text/ACL2/hello-world-text.acl2 @@ -0,0 +1 @@ +(cw "Goodbye, World!~%") diff --git a/Task/Hello-world-Text/ALGOL-68/hello-world-text.alg b/Task/Hello-world-Text/ALGOL-68/hello-world-text.alg new file mode 100644 index 0000000000..bb912a9c4e --- /dev/null +++ b/Task/Hello-world-Text/ALGOL-68/hello-world-text.alg @@ -0,0 +1,3 @@ +main: ( + printf($"Goodbye, World!"l$) +) diff --git a/Task/Hello-world-Text/ATS/hello-world-text.ats b/Task/Hello-world-Text/ATS/hello-world-text.ats new file mode 100644 index 0000000000..88d840645a --- /dev/null +++ b/Task/Hello-world-Text/ATS/hello-world-text.ats @@ -0,0 +1 @@ +implement main () = print "Goodbye, World!\n" diff --git a/Task/Hello-world-Text/AWK/hello-world-text-1.awk b/Task/Hello-world-Text/AWK/hello-world-text-1.awk new file mode 100644 index 0000000000..1bc6c6ef55 --- /dev/null +++ b/Task/Hello-world-Text/AWK/hello-world-text-1.awk @@ -0,0 +1 @@ +BEGIN{print "Goodbye, World!"} diff --git a/Task/Hello-world-Text/AWK/hello-world-text-2.awk b/Task/Hello-world-Text/AWK/hello-world-text-2.awk new file mode 100644 index 0000000000..d02edc3e26 --- /dev/null +++ b/Task/Hello-world-Text/AWK/hello-world-text-2.awk @@ -0,0 +1,3 @@ +END { + print "Goodbye, World!" + } diff --git a/Task/Hello-world-Text/AWK/hello-world-text-3.awk b/Task/Hello-world-Text/AWK/hello-world-text-3.awk new file mode 100644 index 0000000000..0226fd5081 --- /dev/null +++ b/Task/Hello-world-Text/AWK/hello-world-text-3.awk @@ -0,0 +1,4 @@ +// { + print "Goodbye, World!" + exit + } diff --git a/Task/Hello-world-Text/AWK/hello-world-text-4.awk b/Task/Hello-world-Text/AWK/hello-world-text-4.awk new file mode 100644 index 0000000000..524b476182 --- /dev/null +++ b/Task/Hello-world-Text/AWK/hello-world-text-4.awk @@ -0,0 +1,3 @@ +// { + print "Goodbye, World!" + } diff --git a/Task/Hello-world-Text/AWK/hello-world-text-5.awk b/Task/Hello-world-Text/AWK/hello-world-text-5.awk new file mode 100644 index 0000000000..8337712ea5 --- /dev/null +++ b/Task/Hello-world-Text/AWK/hello-world-text-5.awk @@ -0,0 +1 @@ +// diff --git a/Task/Hello-world-Text/ActionScript/hello-world-text.as b/Task/Hello-world-Text/ActionScript/hello-world-text.as new file mode 100644 index 0000000000..f2c4a774ba --- /dev/null +++ b/Task/Hello-world-Text/ActionScript/hello-world-text.as @@ -0,0 +1 @@ +trace("Goodbye, World!"); diff --git a/Task/Hello-world-Text/Ada/hello-world-text.ada b/Task/Hello-world-Text/Ada/hello-world-text.ada new file mode 100644 index 0000000000..738d3b2a47 --- /dev/null +++ b/Task/Hello-world-Text/Ada/hello-world-text.ada @@ -0,0 +1,5 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Main is +begin + Put_Line ("Goodbye, World!"); +end Main; diff --git a/Task/Hello-world-Text/Aime/hello-world-text-1.aime b/Task/Hello-world-Text/Aime/hello-world-text-1.aime new file mode 100644 index 0000000000..a1bbc80dd8 --- /dev/null +++ b/Task/Hello-world-Text/Aime/hello-world-text-1.aime @@ -0,0 +1 @@ +o_text("GOODBYE, WORLD!\n"); diff --git a/Task/Hello-world-Text/Aime/hello-world-text-2.aime b/Task/Hello-world-Text/Aime/hello-world-text-2.aime new file mode 100644 index 0000000000..d508bdf296 --- /dev/null +++ b/Task/Hello-world-Text/Aime/hello-world-text-2.aime @@ -0,0 +1,7 @@ +integer +main(void) +{ + o_text("GOODBYE, WORLD!\n"); + + return 0; +} diff --git a/Task/Hello-world-Text/Algae/hello-world-text.algae b/Task/Hello-world-Text/Algae/hello-world-text.algae new file mode 100644 index 0000000000..981a55417b --- /dev/null +++ b/Task/Hello-world-Text/Algae/hello-world-text.algae @@ -0,0 +1 @@ +printf("Goodbye, World\n"); diff --git a/Task/Hello-world-Text/Alore/hello-world-text.alore b/Task/Hello-world-Text/Alore/hello-world-text.alore new file mode 100644 index 0000000000..d8dba31817 --- /dev/null +++ b/Task/Hello-world-Text/Alore/hello-world-text.alore @@ -0,0 +1 @@ +Print('Goodbye, World!') diff --git a/Task/Hello-world-Text/AmbientTalk/hello-world-text.ambient b/Task/Hello-world-Text/AmbientTalk/hello-world-text.ambient new file mode 100644 index 0000000000..a945b1d028 --- /dev/null +++ b/Task/Hello-world-Text/AmbientTalk/hello-world-text.ambient @@ -0,0 +1 @@ +system.println("Goodbye, World!") diff --git a/Task/Hello-world-Text/AmigaE/hello-world-text.amiga b/Task/Hello-world-Text/AmigaE/hello-world-text.amiga new file mode 100644 index 0000000000..c6ac128669 --- /dev/null +++ b/Task/Hello-world-Text/AmigaE/hello-world-text.amiga @@ -0,0 +1,3 @@ +PROC main() + WriteF('Goodbye, World!\n') +ENDPROC diff --git a/Task/Hello-world-Text/AppleScript/hello-world-text-1.applescript b/Task/Hello-world-Text/AppleScript/hello-world-text-1.applescript new file mode 100644 index 0000000000..1e9d709f27 --- /dev/null +++ b/Task/Hello-world-Text/AppleScript/hello-world-text-1.applescript @@ -0,0 +1 @@ +"Goodbye, World!" diff --git a/Task/Hello-world-Text/AppleScript/hello-world-text-2.applescript b/Task/Hello-world-Text/AppleScript/hello-world-text-2.applescript new file mode 100644 index 0000000000..a70b284f81 --- /dev/null +++ b/Task/Hello-world-Text/AppleScript/hello-world-text-2.applescript @@ -0,0 +1 @@ +log "Goodbye, World!" diff --git a/Task/Hello-world-Text/Applesoft-BASIC/hello-world-text.bas b/Task/Hello-world-Text/Applesoft-BASIC/hello-world-text.bas new file mode 100644 index 0000000000..094ab76917 --- /dev/null +++ b/Task/Hello-world-Text/Applesoft-BASIC/hello-world-text.bas @@ -0,0 +1 @@ + PRINT "GOODBYE, WORLD!" diff --git a/Task/Hello-world-Text/Argile/hello-world-text.argile b/Task/Hello-world-Text/Argile/hello-world-text.argile new file mode 100644 index 0000000000..7c3c5a8862 --- /dev/null +++ b/Task/Hello-world-Text/Argile/hello-world-text.argile @@ -0,0 +1,2 @@ +use std +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/Asymptote/hello-world-text.asymptote b/Task/Hello-world-Text/Asymptote/hello-world-text.asymptote new file mode 100644 index 0000000000..b2ae9ccd8a --- /dev/null +++ b/Task/Hello-world-Text/Asymptote/hello-world-text.asymptote @@ -0,0 +1 @@ +write('Goodbye, World!'); diff --git a/Task/Hello-world-Text/AutoHotkey/hello-world-text-1.ahk b/Task/Hello-world-Text/AutoHotkey/hello-world-text-1.ahk new file mode 100644 index 0000000000..59e1e21440 --- /dev/null +++ b/Task/Hello-world-Text/AutoHotkey/hello-world-text-1.ahk @@ -0,0 +1,3 @@ +DllCall("AllocConsole") +FileAppend, Goodbye`, World!, CONOUT$ +FileReadLine, _, CONIN$, 1 diff --git a/Task/Hello-world-Text/AutoHotkey/hello-world-text-2.ahk b/Task/Hello-world-Text/AutoHotkey/hello-world-text-2.ahk new file mode 100644 index 0000000000..24df851f16 --- /dev/null +++ b/Task/Hello-world-Text/AutoHotkey/hello-world-text-2.ahk @@ -0,0 +1,2 @@ +DllCall("AttachConsole", "int", -1) +FileAppend, Goodbye`, World!, CONOUT$ diff --git a/Task/Hello-world-Text/AutoHotkey/hello-world-text-3.ahk b/Task/Hello-world-Text/AutoHotkey/hello-world-text-3.ahk new file mode 100644 index 0000000000..88c6afa82a --- /dev/null +++ b/Task/Hello-world-Text/AutoHotkey/hello-world-text-3.ahk @@ -0,0 +1 @@ +SendInput Goodbye, World{!} diff --git a/Task/Hello-world-Text/AutoIt/hello-world-text.autoit b/Task/Hello-world-Text/AutoIt/hello-world-text.autoit new file mode 100644 index 0000000000..91a674d4bc --- /dev/null +++ b/Task/Hello-world-Text/AutoIt/hello-world-text.autoit @@ -0,0 +1 @@ +ConsoleWrite("Goodbye, World!" & @CRLF) diff --git a/Task/Hello-world-Text/BASIC/hello-world-text-1.bas b/Task/Hello-world-Text/BASIC/hello-world-text-1.bas new file mode 100644 index 0000000000..298c3c904d --- /dev/null +++ b/Task/Hello-world-Text/BASIC/hello-world-text-1.bas @@ -0,0 +1 @@ +10 print "Goodbye, World!" diff --git a/Task/Hello-world-Text/BASIC/hello-world-text-2.bas b/Task/Hello-world-Text/BASIC/hello-world-text-2.bas new file mode 100644 index 0000000000..2dffd5dbb8 --- /dev/null +++ b/Task/Hello-world-Text/BASIC/hello-world-text-2.bas @@ -0,0 +1 @@ +PRINT "Goodbye, World!" diff --git a/Task/Hello-world-Text/BASIC256/hello-world-text.basic256 b/Task/Hello-world-Text/BASIC256/hello-world-text.basic256 new file mode 100644 index 0000000000..2dffd5dbb8 --- /dev/null +++ b/Task/Hello-world-Text/BASIC256/hello-world-text.basic256 @@ -0,0 +1 @@ +PRINT "Goodbye, World!" diff --git a/Task/Hello-world-Text/BBC-BASIC/hello-world-text.bbc b/Task/Hello-world-Text/BBC-BASIC/hello-world-text.bbc new file mode 100644 index 0000000000..4b77be9e32 --- /dev/null +++ b/Task/Hello-world-Text/BBC-BASIC/hello-world-text.bbc @@ -0,0 +1 @@ + PRINT "Goodbye, World!" diff --git a/Task/Hello-world-Text/BCPL/hello-world-text.bcpl b/Task/Hello-world-Text/BCPL/hello-world-text.bcpl new file mode 100644 index 0000000000..f3e65eee38 --- /dev/null +++ b/Task/Hello-world-Text/BCPL/hello-world-text.bcpl @@ -0,0 +1,6 @@ +GET "libhdr" + +LET start() = VALOF +{ writef("Goodbye, World!") + RESULTIS 0 +} diff --git a/Task/Hello-world-Text/Babel/hello-world-text.pb b/Task/Hello-world-Text/Babel/hello-world-text.pb new file mode 100644 index 0000000000..9a0d73ace9 --- /dev/null +++ b/Task/Hello-world-Text/Babel/hello-world-text.pb @@ -0,0 +1 @@ +main: { "Goodbye, World!" << } diff --git a/Task/Hello-world-Text/Batch-File/hello-world-text-1.bat b/Task/Hello-world-Text/Batch-File/hello-world-text-1.bat new file mode 100644 index 0000000000..fd705ab250 --- /dev/null +++ b/Task/Hello-world-Text/Batch-File/hello-world-text-1.bat @@ -0,0 +1 @@ +echo Goodbye, World! diff --git a/Task/Hello-world-Text/Batch-File/hello-world-text-2.bat b/Task/Hello-world-Text/Batch-File/hello-world-text-2.bat new file mode 100644 index 0000000000..bbd99d564b --- /dev/null +++ b/Task/Hello-world-Text/Batch-File/hello-world-text-2.bat @@ -0,0 +1,2 @@ +setlocal enableDelayedExpansion +echo Goodbye, World^^^! diff --git a/Task/Hello-world-Text/Befunge/hello-world-text.bf b/Task/Hello-world-Text/Befunge/hello-world-text.bf new file mode 100644 index 0000000000..389a88090a --- /dev/null +++ b/Task/Hello-world-Text/Befunge/hello-world-text.bf @@ -0,0 +1 @@ +0"!dlroW ,eybdooG">:#,_@ diff --git a/Task/Hello-world-Text/Blast/hello-world-text.blast b/Task/Hello-world-Text/Blast/hello-world-text.blast new file mode 100644 index 0000000000..37586d20e5 --- /dev/null +++ b/Task/Hello-world-Text/Blast/hello-world-text.blast @@ -0,0 +1,5 @@ +# This will display a goodbye message on the terminal screen +.begin +display "Goodbye, World!" +return +# This is the end of the script. diff --git a/Task/Hello-world-Text/Boo/hello-world-text.boo b/Task/Hello-world-Text/Boo/hello-world-text.boo new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/Boo/hello-world-text.boo @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/Brace/hello-world-text.brace b/Task/Hello-world-Text/Brace/hello-world-text.brace new file mode 100644 index 0000000000..a9c9dcace8 --- /dev/null +++ b/Task/Hello-world-Text/Brace/hello-world-text.brace @@ -0,0 +1,4 @@ +#!/usr/bin/env bx +use b +Main: + say("Goodbye, World!") diff --git a/Task/Hello-world-Text/Bracmat/hello-world-text.bracmat b/Task/Hello-world-Text/Bracmat/hello-world-text.bracmat new file mode 100644 index 0000000000..f80f47d891 --- /dev/null +++ b/Task/Hello-world-Text/Bracmat/hello-world-text.bracmat @@ -0,0 +1 @@ +put$"Goodbye, World!" diff --git a/Task/Hello-world-Text/Brainf---/hello-world-text-1.bf b/Task/Hello-world-Text/Brainf---/hello-world-text-1.bf new file mode 100644 index 0000000000..14246aeae6 --- /dev/null +++ b/Task/Hello-world-Text/Brainf---/hello-world-text-1.bf @@ -0,0 +1,59 @@ ++++++ +++++ First cell 10 (its a counter and we will be "multiplying") + +[ +>+ 10 times 1 is 10 +>+++ 10 times 3 is 30 +>++++ etc etc +>+++++ ++ +>+++++ +++ +>+++++ ++++ +>+++++ +++++ +>+++++ ++++++ +>+++++ +++++++ +<<<<<<<<< - go back to counter and subtract 1 +] + +printing G +>>>> + . + +o twice +>>>> + .. + +d +< . + +b +< +++++ +++ . + +y +>>> + . + +e +<< + . + +COMMA +<<<< ++++ . + +SPACE +< ++ . + +W +>>> +++++ ++ . + +o +>>> . + +r ++++ . + +l +< +++++ ++ . + +d +----- --- . + +! +<<<<< + . + +CRLF +< +++ . --- . diff --git a/Task/Hello-world-Text/Brainf---/hello-world-text-2.bf b/Task/Hello-world-Text/Brainf---/hello-world-text-2.bf new file mode 100644 index 0000000000..d195e7b5bd --- /dev/null +++ b/Task/Hello-world-Text/Brainf---/hello-world-text-2.bf @@ -0,0 +1,4 @@ +++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++ +++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>> +>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++. +<+++++++.--------.<<<<<+.<+++.---. diff --git a/Task/Hello-world-Text/Brat/hello-world-text.brat b/Task/Hello-world-Text/Brat/hello-world-text.brat new file mode 100644 index 0000000000..8b8559124c --- /dev/null +++ b/Task/Hello-world-Text/Brat/hello-world-text.brat @@ -0,0 +1 @@ +p "Goodbye, World!" diff --git a/Task/Hello-world-Text/Brlcad/hello-world-text.brlcad b/Task/Hello-world-Text/Brlcad/hello-world-text.brlcad new file mode 100644 index 0000000000..fd705ab250 --- /dev/null +++ b/Task/Hello-world-Text/Brlcad/hello-world-text.brlcad @@ -0,0 +1 @@ +echo Goodbye, World! diff --git a/Task/Hello-world-Text/Burlesque/hello-world-text.blq b/Task/Hello-world-Text/Burlesque/hello-world-text.blq new file mode 100644 index 0000000000..7a5b504380 --- /dev/null +++ b/Task/Hello-world-Text/Burlesque/hello-world-text.blq @@ -0,0 +1 @@ +"Goodbye, World!"sh diff --git a/Task/Hello-world-Text/C++-CLI/hello-world-text.cpp b/Task/Hello-world-Text/C++-CLI/hello-world-text.cpp new file mode 100644 index 0000000000..75239c29f6 --- /dev/null +++ b/Task/Hello-world-Text/C++-CLI/hello-world-text.cpp @@ -0,0 +1,5 @@ +using namespace System; +int main() +{ + Console::WriteLine("Goodbye, World!"); +} diff --git a/Task/Hello-world-Text/C++/hello-world-text.cpp b/Task/Hello-world-Text/C++/hello-world-text.cpp new file mode 100644 index 0000000000..11018fdb05 --- /dev/null +++ b/Task/Hello-world-Text/C++/hello-world-text.cpp @@ -0,0 +1,6 @@ +#include + +int main () { + std::cout << "Goodbye, World!" << std::endl; + return std::cout.bad(); +} diff --git a/Task/Hello-world-Text/C/hello-world-text-1.c b/Task/Hello-world-Text/C/hello-world-text-1.c new file mode 100644 index 0000000000..a41f806c57 --- /dev/null +++ b/Task/Hello-world-Text/C/hello-world-text-1.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) +{ + printf("Goodbye, World!\n"); + return EXIT_SUCCESS; +} diff --git a/Task/Hello-world-Text/C/hello-world-text-2.c b/Task/Hello-world-Text/C/hello-world-text-2.c new file mode 100644 index 0000000000..de46ea5230 --- /dev/null +++ b/Task/Hello-world-Text/C/hello-world-text-2.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) +{ + puts("Goodbye, World!"); + return EXIT_SUCCESS; +} diff --git a/Task/Hello-world-Text/C1R/hello-world-text.c1r b/Task/Hello-world-Text/C1R/hello-world-text.c1r new file mode 100644 index 0000000000..17245ce4a4 --- /dev/null +++ b/Task/Hello-world-Text/C1R/hello-world-text.c1r @@ -0,0 +1 @@ +Hello_world/Text diff --git a/Task/Hello-world-Text/CLIPS/hello-world-text.clips b/Task/Hello-world-Text/CLIPS/hello-world-text.clips new file mode 100644 index 0000000000..70fa59a2af --- /dev/null +++ b/Task/Hello-world-Text/CLIPS/hello-world-text.clips @@ -0,0 +1 @@ +(printout t "Goodbye, World!" crlf) diff --git a/Task/Hello-world-Text/CMake/hello-world-text.cmake b/Task/Hello-world-Text/CMake/hello-world-text.cmake new file mode 100644 index 0000000000..bd0ddb4c42 --- /dev/null +++ b/Task/Hello-world-Text/CMake/hello-world-text.cmake @@ -0,0 +1 @@ +message(STATUS "Goodbye, World!") diff --git a/Task/Hello-world-Text/COBOL/hello-world-text.cobol b/Task/Hello-world-Text/COBOL/hello-world-text.cobol new file mode 100644 index 0000000000..6457871e9d --- /dev/null +++ b/Task/Hello-world-Text/COBOL/hello-world-text.cobol @@ -0,0 +1,4 @@ + program-id. hello. + procedure division. + display "Goodbye, World!". + stop run. diff --git a/Task/Hello-world-Text/Cat/hello-world-text.cat b/Task/Hello-world-Text/Cat/hello-world-text.cat new file mode 100644 index 0000000000..8f9f0307f6 --- /dev/null +++ b/Task/Hello-world-Text/Cat/hello-world-text.cat @@ -0,0 +1 @@ +"Goodbye, World!" writeln diff --git a/Task/Hello-world-Text/Cduce/hello-world-text.cduce b/Task/Hello-world-Text/Cduce/hello-world-text.cduce new file mode 100644 index 0000000000..8d7839e5df --- /dev/null +++ b/Task/Hello-world-Text/Cduce/hello-world-text.cduce @@ -0,0 +1 @@ +print "Goodbye, World!";; diff --git a/Task/Hello-world-Text/Chef/hello-world-text.chef b/Task/Hello-world-Text/Chef/hello-world-text.chef new file mode 100644 index 0000000000..2ca70bf058 --- /dev/null +++ b/Task/Hello-world-Text/Chef/hello-world-text.chef @@ -0,0 +1,36 @@ +Goodbye World Souffle. + +Ingredients. +71 g green beans +111 cups oil +98 g butter +121 ml yogurt +101 eggs +44 g wheat flour +32 zucchinis +119 ml water +114 g red salmon +108 g lard +100 g dijon mustard +33 potatoes + +Method. +Put potatoes into the mixing bowl. +Put dijon mustard into the mixing bowl. +Put lard into the mixing bowl. +Put red salmon into the mixing bowl. +Put oil into the mixing bowl. +Put water into the mixing bowl. +Put zucchinis into the mixing bowl. +Put wheat flour into the mixing bowl. +Put eggs into the mixing bowl. +Put yogurt into the mixing bowl. +Put butter into the mixing bowl. +Put dijon mustard into the mixing bowl. +Put oil into the mixing bowl. +Put oil into the mixing bowl. +Put green beans into the mixing bowl. +Liquefy contents of the mixing bowl. +Pour contents of the mixing bowl into the baking dish. + +Serves 1. diff --git a/Task/Hello-world-Text/Clay/hello-world-text.clay b/Task/Hello-world-Text/Clay/hello-world-text.clay new file mode 100644 index 0000000000..f04344c563 --- /dev/null +++ b/Task/Hello-world-Text/Clay/hello-world-text.clay @@ -0,0 +1,3 @@ +main() { + println("Goodbye, World!"); +} diff --git a/Task/Hello-world-Text/Clean/hello-world-text.clean b/Task/Hello-world-Text/Clean/hello-world-text.clean new file mode 100644 index 0000000000..7fec74bc18 --- /dev/null +++ b/Task/Hello-world-Text/Clean/hello-world-text.clean @@ -0,0 +1 @@ +Start = "Goodbye, World!" diff --git a/Task/Hello-world-Text/Clojure/hello-world-text.clj b/Task/Hello-world-Text/Clojure/hello-world-text.clj new file mode 100644 index 0000000000..2b23b653e6 --- /dev/null +++ b/Task/Hello-world-Text/Clojure/hello-world-text.clj @@ -0,0 +1 @@ +(println "Goodbye, World!") diff --git a/Task/Hello-world-Text/Cobra/hello-world-text.cobra b/Task/Hello-world-Text/Cobra/hello-world-text.cobra new file mode 100644 index 0000000000..684e41e0df --- /dev/null +++ b/Task/Hello-world-Text/Cobra/hello-world-text.cobra @@ -0,0 +1,3 @@ +class Hello + def main + print 'Goodbye, World!' diff --git a/Task/Hello-world-Text/CoffeeScript/hello-world-text.coffee b/Task/Hello-world-Text/CoffeeScript/hello-world-text.coffee new file mode 100644 index 0000000000..4cc9152eb3 --- /dev/null +++ b/Task/Hello-world-Text/CoffeeScript/hello-world-text.coffee @@ -0,0 +1 @@ +console.log "Goodbye, World!" diff --git a/Task/Hello-world-Text/ColdFusion/hello-world-text.cfm b/Task/Hello-world-Text/ColdFusion/hello-world-text.cfm new file mode 100644 index 0000000000..fc87663cef --- /dev/null +++ b/Task/Hello-world-Text/ColdFusion/hello-world-text.cfm @@ -0,0 +1 @@ +Goodbye, World! diff --git a/Task/Hello-world-Text/Common-Lisp/hello-world-text.lisp b/Task/Hello-world-Text/Common-Lisp/hello-world-text.lisp new file mode 100644 index 0000000000..2618e2e53b --- /dev/null +++ b/Task/Hello-world-Text/Common-Lisp/hello-world-text.lisp @@ -0,0 +1 @@ +(format t "Goodbye, World!~%") diff --git a/Task/Hello-world-Text/Component-Pascal/hello-world-text.pascal b/Task/Hello-world-Text/Component-Pascal/hello-world-text.pascal new file mode 100644 index 0000000000..52ae0c5b90 --- /dev/null +++ b/Task/Hello-world-Text/Component-Pascal/hello-world-text.pascal @@ -0,0 +1,8 @@ +MODULE Hello; + IMPORT Out; + + PROCEDURE Do*; + BEGIN + Out.String("Goodbye, World!"); Out.Ln + END Do; +END Hello. diff --git a/Task/Hello-world-Text/Crack/hello-world-text.crack b/Task/Hello-world-Text/Crack/hello-world-text.crack new file mode 100644 index 0000000000..b239168ba2 --- /dev/null +++ b/Task/Hello-world-Text/Crack/hello-world-text.crack @@ -0,0 +1,2 @@ +import crack.io cout; +cout `Goodbye, World!\n`; diff --git a/Task/Hello-world-Text/D/hello-world-text.d b/Task/Hello-world-Text/D/hello-world-text.d new file mode 100644 index 0000000000..934b3adabc --- /dev/null +++ b/Task/Hello-world-Text/D/hello-world-text.d @@ -0,0 +1,5 @@ +import std.stdio; + +void main() { + writeln("Goodbye, World!"); +} diff --git a/Task/Hello-world-Text/DWScript/hello-world-text.dwscript b/Task/Hello-world-Text/DWScript/hello-world-text.dwscript new file mode 100644 index 0000000000..130e69df6c --- /dev/null +++ b/Task/Hello-world-Text/DWScript/hello-world-text.dwscript @@ -0,0 +1 @@ +PrintLn('Goodbye, World!'); diff --git a/Task/Hello-world-Text/Dao/hello-world-text.dao b/Task/Hello-world-Text/Dao/hello-world-text.dao new file mode 100644 index 0000000000..cd3630f39a --- /dev/null +++ b/Task/Hello-world-Text/Dao/hello-world-text.dao @@ -0,0 +1 @@ +io.writeln( 'Goodbye, World!' ) diff --git a/Task/Hello-world-Text/Dart/hello-world-text.dart b/Task/Hello-world-Text/Dart/hello-world-text.dart new file mode 100644 index 0000000000..b7edaeb7d7 --- /dev/null +++ b/Task/Hello-world-Text/Dart/hello-world-text.dart @@ -0,0 +1,4 @@ +main() { + var bye = 'Goodbye, World!'; + print("$bye"); +} diff --git a/Task/Hello-world-Text/Deja-Vu/hello-world-text.djv b/Task/Hello-world-Text/Deja-Vu/hello-world-text.djv new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/Deja-Vu/hello-world-text.djv @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/Delphi/hello-world-text.delphi b/Task/Hello-world-Text/Delphi/hello-world-text.delphi new file mode 100644 index 0000000000..c4f89335d4 --- /dev/null +++ b/Task/Hello-world-Text/Delphi/hello-world-text.delphi @@ -0,0 +1,5 @@ +program ProjectGoodbye; +{$APPTYPE CONSOLE} +begin + WriteLn('Goodbye, World!'); +end. diff --git a/Task/Hello-world-Text/Dylan.NET/hello-world-text-1.net b/Task/Hello-world-Text/Dylan.NET/hello-world-text-1.net new file mode 100644 index 0000000000..991ed56716 --- /dev/null +++ b/Task/Hello-world-Text/Dylan.NET/hello-world-text-1.net @@ -0,0 +1 @@ +Console::WriteLine("Goodbye, World!") diff --git a/Task/Hello-world-Text/Dylan.NET/hello-world-text-2.net b/Task/Hello-world-Text/Dylan.NET/hello-world-text-2.net new file mode 100644 index 0000000000..a85b9bb090 --- /dev/null +++ b/Task/Hello-world-Text/Dylan.NET/hello-world-text-2.net @@ -0,0 +1,16 @@ +//compile using the new dylan.NET v, 11.2.8.2 or later +//use mono to run the compiler +#refstdasm mscorlib.dll + +import System + +assembly helloworld exe +ver 1.2.0.0 + +class public auto ansi Module1 + + method public static void main() + Console::WriteLine("Goodbye, World!") + end method + +end class diff --git a/Task/Hello-world-Text/Dylan/hello-world-text.dylan b/Task/Hello-world-Text/Dylan/hello-world-text.dylan new file mode 100644 index 0000000000..a254efc1b1 --- /dev/null +++ b/Task/Hello-world-Text/Dylan/hello-world-text.dylan @@ -0,0 +1,3 @@ +module: hello-world + +format-out("%s\n", "Goodbye, World!"); diff --git a/Task/Hello-world-Text/E/hello-world-text.e b/Task/Hello-world-Text/E/hello-world-text.e new file mode 100644 index 0000000000..316775bb31 --- /dev/null +++ b/Task/Hello-world-Text/E/hello-world-text.e @@ -0,0 +1,3 @@ +println("Goodbye, World!") + +stdout.println("Goodbye, World!") diff --git a/Task/Hello-world-Text/EGL/hello-world-text.egl b/Task/Hello-world-Text/EGL/hello-world-text.egl new file mode 100644 index 0000000000..2d2feb5383 --- /dev/null +++ b/Task/Hello-world-Text/EGL/hello-world-text.egl @@ -0,0 +1,5 @@ +program HelloWorld + function main() + SysLib.writeStdout("Goodbye, World!"); + end +end diff --git a/Task/Hello-world-Text/Efene/hello-world-text-1.efene b/Task/Hello-world-Text/Efene/hello-world-text-1.efene new file mode 100644 index 0000000000..bdc2fb652e --- /dev/null +++ b/Task/Hello-world-Text/Efene/hello-world-text-1.efene @@ -0,0 +1 @@ +io.format("Goodbye, World!~n") diff --git a/Task/Hello-world-Text/Efene/hello-world-text-2.efene b/Task/Hello-world-Text/Efene/hello-world-text-2.efene new file mode 100644 index 0000000000..0b7b258efa --- /dev/null +++ b/Task/Hello-world-Text/Efene/hello-world-text-2.efene @@ -0,0 +1,4 @@ +@public +run = fn () { + io.format("Goodbye, World!~n") +} diff --git a/Task/Hello-world-Text/Eiffel/hello-world-text.e b/Task/Hello-world-Text/Eiffel/hello-world-text.e new file mode 100644 index 0000000000..a895106d01 --- /dev/null +++ b/Task/Hello-world-Text/Eiffel/hello-world-text.e @@ -0,0 +1,10 @@ +class + HELLO_WORLD +create + make +feature + make + do + print ("Goodbye, World!%N") + end +end diff --git a/Task/Hello-world-Text/Ela/hello-world-text.ela b/Task/Hello-world-Text/Ela/hello-world-text.ela new file mode 100644 index 0000000000..ab9ebfd156 --- /dev/null +++ b/Task/Hello-world-Text/Ela/hello-world-text.ela @@ -0,0 +1,2 @@ +open console +writen "Goodbye, World!" diff --git a/Task/Hello-world-Text/Elena/hello-world-text-1.elena b/Task/Hello-world-Text/Elena/hello-world-text-1.elena new file mode 100644 index 0000000000..0c5a017121 --- /dev/null +++ b/Task/Hello-world-Text/Elena/hello-world-text-1.elena @@ -0,0 +1,4 @@ +#symbol Program = +[ + 'program'output << "Goodbye, World!%n". +]. diff --git a/Task/Hello-world-Text/Elena/hello-world-text-2.elena b/Task/Hello-world-Text/Elena/hello-world-text-2.elena new file mode 100644 index 0000000000..e687500bb8 --- /dev/null +++ b/Task/Hello-world-Text/Elena/hello-world-text-2.elena @@ -0,0 +1,5 @@ +sys'vm'routines'dummy "Goodbye, World!" %write &nil 'program'output &wrapbatch[4] +%get &nil 'program'input &wrapbatch[2] +&cast[2] +&nil +^eval diff --git a/Task/Hello-world-Text/Elisa/hello-world-text.elisa b/Task/Hello-world-Text/Elisa/hello-world-text.elisa new file mode 100644 index 0000000000..62164fa889 --- /dev/null +++ b/Task/Hello-world-Text/Elisa/hello-world-text.elisa @@ -0,0 +1 @@ + "Goodbye, World!"? diff --git a/Task/Hello-world-Text/Emacs-Lisp/hello-world-text.l b/Task/Hello-world-Text/Emacs-Lisp/hello-world-text.l new file mode 100644 index 0000000000..977843a519 --- /dev/null +++ b/Task/Hello-world-Text/Emacs-Lisp/hello-world-text.l @@ -0,0 +1 @@ +(insert "Goodbye, World!") diff --git a/Task/Hello-world-Text/Erlang/hello-world-text.erl b/Task/Hello-world-Text/Erlang/hello-world-text.erl new file mode 100644 index 0000000000..07e4771bb5 --- /dev/null +++ b/Task/Hello-world-Text/Erlang/hello-world-text.erl @@ -0,0 +1 @@ +io:format("Goodbye, World!~n"). diff --git a/Task/Hello-world-Text/Euphoria/hello-world-text.euphoria b/Task/Hello-world-Text/Euphoria/hello-world-text.euphoria new file mode 100644 index 0000000000..1b865d44c7 --- /dev/null +++ b/Task/Hello-world-Text/Euphoria/hello-world-text.euphoria @@ -0,0 +1 @@ +puts(1,"Goodbye, World!\n") diff --git a/Task/Hello-world-Text/FALSE/hello-world-text.false b/Task/Hello-world-Text/FALSE/hello-world-text.false new file mode 100644 index 0000000000..bfc340df1b --- /dev/null +++ b/Task/Hello-world-Text/FALSE/hello-world-text.false @@ -0,0 +1,2 @@ +"Goodbye, World! +" diff --git a/Task/Hello-world-Text/Factor/hello-world-text.factor b/Task/Hello-world-Text/Factor/hello-world-text.factor new file mode 100644 index 0000000000..26e70906de --- /dev/null +++ b/Task/Hello-world-Text/Factor/hello-world-text.factor @@ -0,0 +1 @@ +"Goodbye, World!" print diff --git a/Task/Hello-world-Text/Falcon/hello-world-text.falcon b/Task/Hello-world-Text/Falcon/hello-world-text.falcon new file mode 100644 index 0000000000..7d0512316b --- /dev/null +++ b/Task/Hello-world-Text/Falcon/hello-world-text.falcon @@ -0,0 +1 @@ +> "Goodbye, World!" diff --git a/Task/Hello-world-Text/Fantom/hello-world-text.fantom b/Task/Hello-world-Text/Fantom/hello-world-text.fantom new file mode 100644 index 0000000000..960455f495 --- /dev/null +++ b/Task/Hello-world-Text/Fantom/hello-world-text.fantom @@ -0,0 +1,7 @@ +class HelloText +{ + public static Void main () + { + echo ("Goodbye, World!") + } +} diff --git a/Task/Hello-world-Text/Fexl/hello-world-text.fexl b/Task/Hello-world-Text/Fexl/hello-world-text.fexl new file mode 100644 index 0000000000..3d0d857ec7 --- /dev/null +++ b/Task/Hello-world-Text/Fexl/hello-world-text.fexl @@ -0,0 +1 @@ +print "Goodbye, World!";nl; diff --git a/Task/Hello-world-Text/Fish/hello-world-text.fish b/Task/Hello-world-Text/Fish/hello-world-text.fish new file mode 100644 index 0000000000..523d858890 --- /dev/null +++ b/Task/Hello-world-Text/Fish/hello-world-text.fish @@ -0,0 +1,2 @@ +!v"Goodbye, World!"r! + >l?!;o diff --git a/Task/Hello-world-Text/Forth/hello-world-text-1.fth b/Task/Hello-world-Text/Forth/hello-world-text-1.fth new file mode 100644 index 0000000000..1489b37634 --- /dev/null +++ b/Task/Hello-world-Text/Forth/hello-world-text-1.fth @@ -0,0 +1 @@ +." Goodbye, World!" diff --git a/Task/Hello-world-Text/Forth/hello-world-text-2.fth b/Task/Hello-world-Text/Forth/hello-world-text-2.fth new file mode 100644 index 0000000000..945a905263 --- /dev/null +++ b/Task/Hello-world-Text/Forth/hello-world-text-2.fth @@ -0,0 +1 @@ +: goodbye ( -- ) ." Goodbye, World!" CR ; diff --git a/Task/Hello-world-Text/Fortran/hello-world-text-1.f b/Task/Hello-world-Text/Fortran/hello-world-text-1.f new file mode 100644 index 0000000000..100df01b18 --- /dev/null +++ b/Task/Hello-world-Text/Fortran/hello-world-text-1.f @@ -0,0 +1 @@ +print *,"Goodbye, World!" diff --git a/Task/Hello-world-Text/Fortran/hello-world-text-2.f b/Task/Hello-world-Text/Fortran/hello-world-text-2.f new file mode 100644 index 0000000000..f1686a5452 --- /dev/null +++ b/Task/Hello-world-Text/Fortran/hello-world-text-2.f @@ -0,0 +1,2 @@ +100 format (5X,A,"!") + print 100,"Goodbye, World!" diff --git a/Task/Hello-world-Text/Fortran/hello-world-text-3.f b/Task/Hello-world-Text/Fortran/hello-world-text-3.f new file mode 100644 index 0000000000..48988ab0ed --- /dev/null +++ b/Task/Hello-world-Text/Fortran/hello-world-text-3.f @@ -0,0 +1 @@ +write (89,100) "Goodbye, World!" diff --git a/Task/Hello-world-Text/Fortress/hello-world-text.fortress b/Task/Hello-world-Text/Fortress/hello-world-text.fortress new file mode 100644 index 0000000000..51008f7285 --- /dev/null +++ b/Task/Hello-world-Text/Fortress/hello-world-text.fortress @@ -0,0 +1,3 @@ +export Executable + +run() = println("Goodbye, World!") diff --git a/Task/Hello-world-Text/Frege/hello-world-text.frege b/Task/Hello-world-Text/Frege/hello-world-text.frege new file mode 100644 index 0000000000..c768b1d3a1 --- /dev/null +++ b/Task/Hello-world-Text/Frege/hello-world-text.frege @@ -0,0 +1,2 @@ +module HelloWorld where +main _ = println "Goodbye, World!" diff --git a/Task/Hello-world-Text/Frink/hello-world-text.frink b/Task/Hello-world-Text/Frink/hello-world-text.frink new file mode 100644 index 0000000000..54290b41d9 --- /dev/null +++ b/Task/Hello-world-Text/Frink/hello-world-text.frink @@ -0,0 +1 @@ +println["Goodbye, World!"] diff --git a/Task/Hello-world-Text/GAP/hello-world-text.gap b/Task/Hello-world-Text/GAP/hello-world-text.gap new file mode 100644 index 0000000000..be47f9bad2 --- /dev/null +++ b/Task/Hello-world-Text/GAP/hello-world-text.gap @@ -0,0 +1,10 @@ +# Several ways to do it +"Goodbye, World!"; + +Print("Goodbye, World!\n"); # No EOL appended + +Display("Goodbye, World!"); + +f := OutputTextUser(); +WriteLine(f, "Goodbye, World!\n"); +CloseStream(f); diff --git a/Task/Hello-world-Text/GLBasic/hello-world-text.glbasic b/Task/Hello-world-Text/GLBasic/hello-world-text.glbasic new file mode 100644 index 0000000000..4370b68927 --- /dev/null +++ b/Task/Hello-world-Text/GLBasic/hello-world-text.glbasic @@ -0,0 +1 @@ +STDOUT "GOODBYE, WORLD!" diff --git a/Task/Hello-world-Text/GW-BASIC/hello-world-text.bas b/Task/Hello-world-Text/GW-BASIC/hello-world-text.bas new file mode 100644 index 0000000000..bb029a7873 --- /dev/null +++ b/Task/Hello-world-Text/GW-BASIC/hello-world-text.bas @@ -0,0 +1 @@ +10 PRINT "Goodbye, World!" diff --git a/Task/Hello-world-Text/Gambas/hello-world-text.gambas b/Task/Hello-world-Text/Gambas/hello-world-text.gambas new file mode 100644 index 0000000000..2dffd5dbb8 --- /dev/null +++ b/Task/Hello-world-Text/Gambas/hello-world-text.gambas @@ -0,0 +1 @@ +PRINT "Goodbye, World!" diff --git a/Task/Hello-world-Text/Gema/hello-world-text.gema b/Task/Hello-world-Text/Gema/hello-world-text.gema new file mode 100644 index 0000000000..926fc7025e --- /dev/null +++ b/Task/Hello-world-Text/Gema/hello-world-text.gema @@ -0,0 +1,2 @@ +*= ! ignore off content of input +\B=Goodbye, World\! ! Start output with this text. diff --git a/Task/Hello-world-Text/Glee/hello-world-text.glee b/Task/Hello-world-Text/Glee/hello-world-text.glee new file mode 100644 index 0000000000..1e9d709f27 --- /dev/null +++ b/Task/Hello-world-Text/Glee/hello-world-text.glee @@ -0,0 +1 @@ +"Goodbye, World!" diff --git a/Task/Hello-world-Text/Go/hello-world-text.go b/Task/Hello-world-Text/Go/hello-world-text.go new file mode 100644 index 0000000000..4bd996ffba --- /dev/null +++ b/Task/Hello-world-Text/Go/hello-world-text.go @@ -0,0 +1,3 @@ +package main + +func main() { println("Goodbye, World!") } diff --git a/Task/Hello-world-Text/Golfscript/hello-world-text.golf b/Task/Hello-world-Text/Golfscript/hello-world-text.golf new file mode 100644 index 0000000000..1e9d709f27 --- /dev/null +++ b/Task/Hello-world-Text/Golfscript/hello-world-text.golf @@ -0,0 +1 @@ +"Goodbye, World!" diff --git a/Task/Hello-world-Text/Gosu/hello-world-text.gosu b/Task/Hello-world-Text/Gosu/hello-world-text.gosu new file mode 100644 index 0000000000..b4f3181031 --- /dev/null +++ b/Task/Hello-world-Text/Gosu/hello-world-text.gosu @@ -0,0 +1 @@ +print("Goodbye, World!") diff --git a/Task/Hello-world-Text/Groovy/hello-world-text.groovy b/Task/Hello-world-Text/Groovy/hello-world-text.groovy new file mode 100644 index 0000000000..8fa3591166 --- /dev/null +++ b/Task/Hello-world-Text/Groovy/hello-world-text.groovy @@ -0,0 +1 @@ +println "Goodbye, World!" diff --git a/Task/Hello-world-Text/HLA/hello-world-text.hla b/Task/Hello-world-Text/HLA/hello-world-text.hla new file mode 100644 index 0000000000..d7f52e4992 --- /dev/null +++ b/Task/Hello-world-Text/HLA/hello-world-text.hla @@ -0,0 +1,7 @@ +program goodbyeWorld; +#include("stdlib.hhf") +begin goodbyeWorld; + + stdout.put( "Goodbye, World!" nl ); + +end goodbyeWorld; diff --git a/Task/Hello-world-Text/HQ9+/hello-world-text.hq9p b/Task/Hello-world-Text/HQ9+/hello-world-text.hq9p new file mode 100644 index 0000000000..a9edc74f38 --- /dev/null +++ b/Task/Hello-world-Text/HQ9+/hello-world-text.hq9p @@ -0,0 +1 @@ +H diff --git a/Task/Hello-world-Text/Haskell/hello-world-text.hs b/Task/Hello-world-Text/Haskell/hello-world-text.hs new file mode 100644 index 0000000000..bd50e65f95 --- /dev/null +++ b/Task/Hello-world-Text/Haskell/hello-world-text.hs @@ -0,0 +1 @@ +main = putStrLn "Goodbye, World!" diff --git a/Task/Hello-world-Text/HicEst/hello-world-text.hicest b/Task/Hello-world-Text/HicEst/hello-world-text.hicest new file mode 100644 index 0000000000..09fa11b14f --- /dev/null +++ b/Task/Hello-world-Text/HicEst/hello-world-text.hicest @@ -0,0 +1 @@ +WRITE() 'Goodbye, World!' diff --git a/Task/Hello-world-Text/IDL/hello-world-text.idl b/Task/Hello-world-Text/IDL/hello-world-text.idl new file mode 100644 index 0000000000..57c420036f --- /dev/null +++ b/Task/Hello-world-Text/IDL/hello-world-text.idl @@ -0,0 +1 @@ +print,'Goodbye, World!' diff --git a/Task/Hello-world-Text/Icon/hello-world-text.icon b/Task/Hello-world-Text/Icon/hello-world-text.icon new file mode 100644 index 0000000000..58efa3eb4a --- /dev/null +++ b/Task/Hello-world-Text/Icon/hello-world-text.icon @@ -0,0 +1,3 @@ +procedure main() + write( "Goodbye, World!" ) +end diff --git a/Task/Hello-world-Text/Inform-6/hello-world-text.inf b/Task/Hello-world-Text/Inform-6/hello-world-text.inf new file mode 100644 index 0000000000..0d163a54b3 --- /dev/null +++ b/Task/Hello-world-Text/Inform-6/hello-world-text.inf @@ -0,0 +1,3 @@ +[Main; + print "Goodbye, World!^"; +]; diff --git a/Task/Hello-world-Text/Integer-BASIC/hello-world-text.bas b/Task/Hello-world-Text/Integer-BASIC/hello-world-text.bas new file mode 100644 index 0000000000..efdcc2b172 --- /dev/null +++ b/Task/Hello-world-Text/Integer-BASIC/hello-world-text.bas @@ -0,0 +1,2 @@ + 10 PRINT "GOODBYE, WORLD!" + 20 END diff --git a/Task/Hello-world-Text/Io/hello-world-text.io b/Task/Hello-world-Text/Io/hello-world-text.io new file mode 100644 index 0000000000..08ea2f6744 --- /dev/null +++ b/Task/Hello-world-Text/Io/hello-world-text.io @@ -0,0 +1 @@ +"Goodbye, World!" println diff --git a/Task/Hello-world-Text/Ioke/hello-world-text.ioke b/Task/Hello-world-Text/Ioke/hello-world-text.ioke new file mode 100644 index 0000000000..08ea2f6744 --- /dev/null +++ b/Task/Hello-world-Text/Ioke/hello-world-text.ioke @@ -0,0 +1 @@ +"Goodbye, World!" println diff --git a/Task/Hello-world-Text/J/hello-world-text-1.j b/Task/Hello-world-Text/J/hello-world-text-1.j new file mode 100644 index 0000000000..39c972e7ca --- /dev/null +++ b/Task/Hello-world-Text/J/hello-world-text-1.j @@ -0,0 +1,2 @@ + 'Goodbye, World!' +Goodbye, World! diff --git a/Task/Hello-world-Text/J/hello-world-text-2.j b/Task/Hello-world-Text/J/hello-world-text-2.j new file mode 100644 index 0000000000..f4b2c424e3 --- /dev/null +++ b/Task/Hello-world-Text/J/hello-world-text-2.j @@ -0,0 +1,6 @@ + [data=. 'Goodbye, World!' +Goodbye, World! + data +Goodbye, World! + smoutput data +Goodbye, World! diff --git a/Task/Hello-world-Text/JCL/hello-world-text.jcl b/Task/Hello-world-Text/JCL/hello-world-text.jcl new file mode 100644 index 0000000000..7383f874d9 --- /dev/null +++ b/Task/Hello-world-Text/JCL/hello-world-text.jcl @@ -0,0 +1 @@ +/*MESSAGE Goodbye, World! diff --git a/Task/Hello-world-Text/Jacquard-Loom/hello-world-text.jacquard b/Task/Hello-world-Text/Jacquard-Loom/hello-world-text.jacquard new file mode 100644 index 0000000000..45b599bc49 --- /dev/null +++ b/Task/Hello-world-Text/Jacquard-Loom/hello-world-text.jacquard @@ -0,0 +1,87 @@ ++---------------+ +| | +| * * | +|* * * * | +|* * *| +|* * *| +|* * * | +| * * * | +| * | ++---------------+ + ++---------------+ +| | +|* * * | +|* * * | +| * *| +| * *| +|* * * | +|* * * * | +| * | ++---------------+ + ++---------------+ +| | +|* ** * * | +|******* *** * | +| **** * * ***| +| **** * ******| +| ****** ** * | +| * * * * | +| * | ++---------------+ + ++---------------+ +| | +|******* *** * | +|******* *** * | +| ** *| +|* * * *| +|******* ** * | +|******* *** * | +| * | ++---------------+ + ++---------------+ +| | +|******* *** * | +|******* *** * | +| * * * *| +| * * * *| +|******* ** * | +|******* ** * | +| * | ++---------------+ + ++---------------+ +| | +|***** * *** * | +|******* *** * | +| * * * * | +| * * * | +|****** ** * | +|****** ** * | +| * | ++---------------+ + ++---------------+ +| | +| * * * | +|***** * ***** | +|***** ** * ***| +|***** ** * ***| +|******* * ** | +| * * * * | +| * | ++---------------+ + ++---------------+ +| | +| | +| * * | +| * * | +| * | +| * | +| | +| | ++---------------+ diff --git a/Task/Hello-world-Text/Java/hello-world-text.java b/Task/Hello-world-Text/Java/hello-world-text.java new file mode 100644 index 0000000000..1e51bb296c --- /dev/null +++ b/Task/Hello-world-Text/Java/hello-world-text.java @@ -0,0 +1,7 @@ +public class HelloWorld +{ + public static void main(String[] args) + { + System.out.println("Goodbye, World!"); + } +} diff --git a/Task/Hello-world-Text/JavaScript/hello-world-text-1.js b/Task/Hello-world-Text/JavaScript/hello-world-text-1.js new file mode 100644 index 0000000000..44f0887c57 --- /dev/null +++ b/Task/Hello-world-Text/JavaScript/hello-world-text-1.js @@ -0,0 +1 @@ +document.write("Goodbye, World!"); diff --git a/Task/Hello-world-Text/JavaScript/hello-world-text-2.js b/Task/Hello-world-Text/JavaScript/hello-world-text-2.js new file mode 100644 index 0000000000..ebe9fadde8 --- /dev/null +++ b/Task/Hello-world-Text/JavaScript/hello-world-text-2.js @@ -0,0 +1 @@ +print('Goodbye, World!'); diff --git a/Task/Hello-world-Text/JavaScript/hello-world-text-3.js b/Task/Hello-world-Text/JavaScript/hello-world-text-3.js new file mode 100644 index 0000000000..488ccbf140 --- /dev/null +++ b/Task/Hello-world-Text/JavaScript/hello-world-text-3.js @@ -0,0 +1 @@ +WScript.Echo("Goodbye, World!"); diff --git a/Task/Hello-world-Text/JavaScript/hello-world-text-4.js b/Task/Hello-world-Text/JavaScript/hello-world-text-4.js new file mode 100644 index 0000000000..9848c0d61c --- /dev/null +++ b/Task/Hello-world-Text/JavaScript/hello-world-text-4.js @@ -0,0 +1 @@ +console.log("Goodbye, World!") diff --git a/Task/Hello-world-Text/Joy/hello-world-text.joy b/Task/Hello-world-Text/Joy/hello-world-text.joy new file mode 100644 index 0000000000..6b50dbca5a --- /dev/null +++ b/Task/Hello-world-Text/Joy/hello-world-text.joy @@ -0,0 +1 @@ +"Goodbye, World!" putchars. diff --git a/Task/Hello-world-Text/Julia/hello-world-text.julia b/Task/Hello-world-Text/Julia/hello-world-text.julia new file mode 100644 index 0000000000..b4f3181031 --- /dev/null +++ b/Task/Hello-world-Text/Julia/hello-world-text.julia @@ -0,0 +1 @@ +print("Goodbye, World!") diff --git a/Task/Hello-world-Text/Kaya/hello-world-text.kaya b/Task/Hello-world-Text/Kaya/hello-world-text.kaya new file mode 100644 index 0000000000..44abad835a --- /dev/null +++ b/Task/Hello-world-Text/Kaya/hello-world-text.kaya @@ -0,0 +1,6 @@ +program hello; + +Void main() { + // My first program! + putStrLn("Goodbye, World!"); +} diff --git a/Task/Hello-world-Text/Kite/hello-world-text.kite b/Task/Hello-world-Text/Kite/hello-world-text.kite new file mode 100644 index 0000000000..b47e8d6fcf --- /dev/null +++ b/Task/Hello-world-Text/Kite/hello-world-text.kite @@ -0,0 +1,3 @@ +"#!/usr/local/bin/kite + +"Goodbye, World!"|print; diff --git a/Task/Hello-world-Text/KonsolScript/hello-world-text.konso b/Task/Hello-world-Text/KonsolScript/hello-world-text.konso new file mode 100644 index 0000000000..b53be6fde7 --- /dev/null +++ b/Task/Hello-world-Text/KonsolScript/hello-world-text.konso @@ -0,0 +1,3 @@ +function main() { + Konsol:Log("Goodbye, World!") +} diff --git a/Task/Hello-world-Text/LSE64/hello-world-text.lse64 b/Task/Hello-world-Text/LSE64/hello-world-text.lse64 new file mode 100644 index 0000000000..3906efcea8 --- /dev/null +++ b/Task/Hello-world-Text/LSE64/hello-world-text.lse64 @@ -0,0 +1 @@ +"Goodbye, World!" ,t nl diff --git a/Task/Hello-world-Text/Lang5/hello-world-text.lang5 b/Task/Hello-world-Text/Lang5/hello-world-text.lang5 new file mode 100644 index 0000000000..004ce7a41f --- /dev/null +++ b/Task/Hello-world-Text/Lang5/hello-world-text.lang5 @@ -0,0 +1 @@ +"Goodbye, World!\n" . diff --git a/Task/Hello-world-Text/Liberty-BASIC/hello-world-text.liberty b/Task/Hello-world-Text/Liberty-BASIC/hello-world-text.liberty new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/Liberty-BASIC/hello-world-text.liberty @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/Limbo/hello-world-text.limbo b/Task/Hello-world-Text/Limbo/hello-world-text.limbo new file mode 100644 index 0000000000..ab62b15e6f --- /dev/null +++ b/Task/Hello-world-Text/Limbo/hello-world-text.limbo @@ -0,0 +1,14 @@ +implement Command; + + include "sys.m"; + sys: Sys; + + include "draw.m"; + + include "sh.m"; + + init(nil: ref Draw->Context, nil: list of string) + { + sys = load Sys Sys->PATH; + sys->print("Goodby, World!\n"); + } diff --git a/Task/Hello-world-Text/Lisaac/hello-world-text-1.lisaac b/Task/Hello-world-Text/Lisaac/hello-world-text-1.lisaac new file mode 100644 index 0000000000..c3f41a6792 --- /dev/null +++ b/Task/Hello-world-Text/Lisaac/hello-world-text-1.lisaac @@ -0,0 +1,5 @@ +Section Header // The Header section is required. + + name := GOODBYE; // Define the name of this object. + +Section Public + - main <- ("Goodbye, World!\n".print;); diff --git a/Task/Hello-world-Text/Lisaac/hello-world-text-2.lisaac b/Task/Hello-world-Text/Lisaac/hello-world-text-2.lisaac new file mode 100644 index 0000000000..dd29f31d1d --- /dev/null +++ b/Task/Hello-world-Text/Lisaac/hello-world-text-2.lisaac @@ -0,0 +1,5 @@ +Section Header // The Header section is required. + + name := GOODBYE2; // Define the name of this object. + +Section Public + - main <- (IO.put_string "Goodbye, World!\n";); diff --git a/Task/Hello-world-Text/Logo/hello-world-text-1.logo b/Task/Hello-world-Text/Logo/hello-world-text-1.logo new file mode 100644 index 0000000000..25e0a6d51a --- /dev/null +++ b/Task/Hello-world-Text/Logo/hello-world-text-1.logo @@ -0,0 +1 @@ +print [Goodbye, World!] diff --git a/Task/Hello-world-Text/Logo/hello-world-text-2.logo b/Task/Hello-world-Text/Logo/hello-world-text-2.logo new file mode 100644 index 0000000000..d115fd0908 --- /dev/null +++ b/Task/Hello-world-Text/Logo/hello-world-text-2.logo @@ -0,0 +1 @@ +type [Goodbye, World!] diff --git a/Task/Hello-world-Text/Logtalk/hello-world-text.logtalk b/Task/Hello-world-Text/Logtalk/hello-world-text.logtalk new file mode 100644 index 0000000000..2a2f6f80d3 --- /dev/null +++ b/Task/Hello-world-Text/Logtalk/hello-world-text.logtalk @@ -0,0 +1,7 @@ +:- object(hello_world). + + % the initialization/1 directive argument is automatically executed + % when the object is loaded into memory: + :- initialization((nl, write('Goodbye, World!'), nl)). + +:- end_object. diff --git a/Task/Hello-world-Text/LotusScript/hello-world-text.lotus b/Task/Hello-world-Text/LotusScript/hello-world-text.lotus new file mode 100644 index 0000000000..89d8bbdcc3 --- /dev/null +++ b/Task/Hello-world-Text/LotusScript/hello-world-text.lotus @@ -0,0 +1,5 @@ +:- object(hello_world). + 'This will send the output to the status bar at the bottom of the Notes client screen + print "Goodbye, World!" + +:- end_object. diff --git a/Task/Hello-world-Text/Lua/hello-world-text.lua b/Task/Hello-world-Text/Lua/hello-world-text.lua new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/Lua/hello-world-text.lua @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/M4/hello-world-text.m4 b/Task/Hello-world-Text/M4/hello-world-text.m4 new file mode 100644 index 0000000000..76aa175531 --- /dev/null +++ b/Task/Hello-world-Text/M4/hello-world-text.m4 @@ -0,0 +1 @@ +`Goodbye, World!' diff --git a/Task/Hello-world-Text/MATLAB/hello-world-text.m b/Task/Hello-world-Text/MATLAB/hello-world-text.m new file mode 100644 index 0000000000..6882cf79f0 --- /dev/null +++ b/Task/Hello-world-Text/MATLAB/hello-world-text.m @@ -0,0 +1,5 @@ +>> 'Goodbye, World!' + +ans = + +Goodbye, World! diff --git a/Task/Hello-world-Text/MAXScript/hello-world-text-1.max b/Task/Hello-world-Text/MAXScript/hello-world-text-1.max new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/MAXScript/hello-world-text-1.max @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/MAXScript/hello-world-text-2.max b/Task/Hello-world-Text/MAXScript/hello-world-text-2.max new file mode 100644 index 0000000000..7d1ac51fed --- /dev/null +++ b/Task/Hello-world-Text/MAXScript/hello-world-text-2.max @@ -0,0 +1 @@ +format "%" "Goodbye, World!" diff --git a/Task/Hello-world-Text/MIPS-Assembly/hello-world-text.mips b/Task/Hello-world-Text/MIPS-Assembly/hello-world-text.mips new file mode 100644 index 0000000000..5c15dfe390 --- /dev/null +++ b/Task/Hello-world-Text/MIPS-Assembly/hello-world-text.mips @@ -0,0 +1,10 @@ + .data +hello: .asciiz "Goodbye, World!" + + .text +main: + la $a0, hello + li $v0, 4 + syscall + li $v0, 10 + syscall diff --git a/Task/Hello-world-Text/ML-I/hello-world-text.ml b/Task/Hello-world-Text/ML-I/hello-world-text.ml new file mode 100644 index 0000000000..f06c489626 --- /dev/null +++ b/Task/Hello-world-Text/ML-I/hello-world-text.ml @@ -0,0 +1 @@ +Goodbye, World! diff --git a/Task/Hello-world-Text/MUF/hello-world-text.muf b/Task/Hello-world-Text/MUF/hello-world-text.muf new file mode 100644 index 0000000000..efeb2cb78c --- /dev/null +++ b/Task/Hello-world-Text/MUF/hello-world-text.muf @@ -0,0 +1,4 @@ +: main[ -- ] +me @ "Goodbye, World!" notify +exit +; diff --git a/Task/Hello-world-Text/MUMPS/hello-world-text.mumps b/Task/Hello-world-Text/MUMPS/hello-world-text.mumps new file mode 100644 index 0000000000..89c0d829d0 --- /dev/null +++ b/Task/Hello-world-Text/MUMPS/hello-world-text.mumps @@ -0,0 +1 @@ +Write "Goodbye, World!",! diff --git a/Task/Hello-world-Text/Maple/hello-world-text.maple b/Task/Hello-world-Text/Maple/hello-world-text.maple new file mode 100644 index 0000000000..b7346c3c1b --- /dev/null +++ b/Task/Hello-world-Text/Maple/hello-world-text.maple @@ -0,0 +1,2 @@ +> printf( "Goodbye, World!\n" ): # print without quotes +Goodbye, World! diff --git a/Task/Hello-world-Text/Mathematica/hello-world-text.mathematica b/Task/Hello-world-Text/Mathematica/hello-world-text.mathematica new file mode 100644 index 0000000000..fc3ee4c8a9 --- /dev/null +++ b/Task/Hello-world-Text/Mathematica/hello-world-text.mathematica @@ -0,0 +1 @@ +Print["Goodbye, World!"] diff --git a/Task/Hello-world-Text/Maxima/hello-world-text.maxima b/Task/Hello-world-Text/Maxima/hello-world-text.maxima new file mode 100644 index 0000000000..eac215fa44 --- /dev/null +++ b/Task/Hello-world-Text/Maxima/hello-world-text.maxima @@ -0,0 +1 @@ +print("Goodbye, World!"); diff --git a/Task/Hello-world-Text/Mercury/hello-world-text.mercury b/Task/Hello-world-Text/Mercury/hello-world-text.mercury new file mode 100644 index 0000000000..161d4dc494 --- /dev/null +++ b/Task/Hello-world-Text/Mercury/hello-world-text.mercury @@ -0,0 +1,8 @@ +:- module hello. +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +main(!IO) :- + io.write_string("Goodbye, World!\n", !IO). diff --git a/Task/Hello-world-Text/Metafont/hello-world-text.metafont b/Task/Hello-world-Text/Metafont/hello-world-text.metafont new file mode 100644 index 0000000000..dc716d0de1 --- /dev/null +++ b/Task/Hello-world-Text/Metafont/hello-world-text.metafont @@ -0,0 +1 @@ +message "Goodbye, World!"; end diff --git a/Task/Hello-world-Text/Modula-2/hello-world-text.mod2 b/Task/Hello-world-Text/Modula-2/hello-world-text.mod2 new file mode 100644 index 0000000000..b8300cc918 --- /dev/null +++ b/Task/Hello-world-Text/Modula-2/hello-world-text.mod2 @@ -0,0 +1,7 @@ +MODULE Hello; +IMPORT InOut; + +BEGIN + InOut.WriteString('Goodbye, World!'); + InOut.WriteLn +END Hello. diff --git a/Task/Hello-world-Text/Modula-3/hello-world-text.mod3 b/Task/Hello-world-Text/Modula-3/hello-world-text.mod3 new file mode 100644 index 0000000000..133d8da65d --- /dev/null +++ b/Task/Hello-world-Text/Modula-3/hello-world-text.mod3 @@ -0,0 +1,7 @@ +MODULE Goodbye EXPORTS Main; + +IMPORT IO; + +BEGIN + IO.Put("Goodbye, World!\n"); +END Goodbye. diff --git a/Task/Hello-world-Text/Mythryl/hello-world-text.mythryl b/Task/Hello-world-Text/Mythryl/hello-world-text.mythryl new file mode 100644 index 0000000000..06eb32599c --- /dev/null +++ b/Task/Hello-world-Text/Mythryl/hello-world-text.mythryl @@ -0,0 +1 @@ +print "Goodbye, World!"; diff --git a/Task/Hello-world-Text/PHP/hello-world-text-1.php b/Task/Hello-world-Text/PHP/hello-world-text-1.php new file mode 100644 index 0000000000..cbbf2eac24 --- /dev/null +++ b/Task/Hello-world-Text/PHP/hello-world-text-1.php @@ -0,0 +1,3 @@ + diff --git a/Task/Hello-world-Text/PHP/hello-world-text-2.php b/Task/Hello-world-Text/PHP/hello-world-text-2.php new file mode 100644 index 0000000000..f06c489626 --- /dev/null +++ b/Task/Hello-world-Text/PHP/hello-world-text-2.php @@ -0,0 +1 @@ +Goodbye, World! diff --git a/Task/Hello-world-Text/PIR/hello-world-text.pir b/Task/Hello-world-Text/PIR/hello-world-text.pir new file mode 100644 index 0000000000..9a8b6b6b52 --- /dev/null +++ b/Task/Hello-world-Text/PIR/hello-world-text.pir @@ -0,0 +1,3 @@ +.sub hello_world_text :main + print "Goodbye, World!\n" +.end diff --git a/Task/Hello-world-Text/Perl/hello-world-text-1.pl b/Task/Hello-world-Text/Perl/hello-world-text-1.pl new file mode 100644 index 0000000000..6663ed5a14 --- /dev/null +++ b/Task/Hello-world-Text/Perl/hello-world-text-1.pl @@ -0,0 +1 @@ +print "Goodbye, World!\n"; diff --git a/Task/Hello-world-Text/Perl/hello-world-text-2.pl b/Task/Hello-world-Text/Perl/hello-world-text-2.pl new file mode 100644 index 0000000000..fc8aced088 --- /dev/null +++ b/Task/Hello-world-Text/Perl/hello-world-text-2.pl @@ -0,0 +1,2 @@ +use feature 'say'; +say 'Goodbye, World!'; diff --git a/Task/Hello-world-Text/Perl/hello-world-text-3.pl b/Task/Hello-world-Text/Perl/hello-world-text-3.pl new file mode 100644 index 0000000000..c3abccc964 --- /dev/null +++ b/Task/Hello-world-Text/Perl/hello-world-text-3.pl @@ -0,0 +1,2 @@ +use 5.010; +say 'Goodbye, World!'; diff --git a/Task/Hello-world-Text/PicoLisp/hello-world-text.l b/Task/Hello-world-Text/PicoLisp/hello-world-text.l new file mode 100644 index 0000000000..76b3193378 --- /dev/null +++ b/Task/Hello-world-Text/PicoLisp/hello-world-text.l @@ -0,0 +1 @@ +(prinl "Goodbye, World!") diff --git a/Task/Hello-world-Text/Prolog/hello-world-text.pro b/Task/Hello-world-Text/Prolog/hello-world-text.pro new file mode 100644 index 0000000000..6135c08f95 --- /dev/null +++ b/Task/Hello-world-Text/Prolog/hello-world-text.pro @@ -0,0 +1 @@ +:- write('Goodbye, World!'), nl. diff --git a/Task/Hello-world-Text/Python/hello-world-text-1.py b/Task/Hello-world-Text/Python/hello-world-text-1.py new file mode 100644 index 0000000000..a9f594ad30 --- /dev/null +++ b/Task/Hello-world-Text/Python/hello-world-text-1.py @@ -0,0 +1 @@ +print "Goodbye, World!" diff --git a/Task/Hello-world-Text/Python/hello-world-text-2.py b/Task/Hello-world-Text/Python/hello-world-text-2.py new file mode 100644 index 0000000000..9b94478bef --- /dev/null +++ b/Task/Hello-world-Text/Python/hello-world-text-2.py @@ -0,0 +1,2 @@ +import sys +sys.stdout.write("Goodbye, World!\n") diff --git a/Task/Hello-world-Text/Python/hello-world-text-3.py b/Task/Hello-world-Text/Python/hello-world-text-3.py new file mode 100644 index 0000000000..b4f3181031 --- /dev/null +++ b/Task/Hello-world-Text/Python/hello-world-text-3.py @@ -0,0 +1 @@ +print("Goodbye, World!") diff --git a/Task/Hello-world-Text/R/hello-world-text.r b/Task/Hello-world-Text/R/hello-world-text.r new file mode 100644 index 0000000000..3ac1a07fbe --- /dev/null +++ b/Task/Hello-world-Text/R/hello-world-text.r @@ -0,0 +1 @@ + cat("Goodbye, World!\n") diff --git a/Task/Hello-world-Text/REXX/hello-world-text-1.rexx b/Task/Hello-world-Text/REXX/hello-world-text-1.rexx new file mode 100644 index 0000000000..783400cbd1 --- /dev/null +++ b/Task/Hello-world-Text/REXX/hello-world-text-1.rexx @@ -0,0 +1,2 @@ +/*REXX program to show a line of text. */ +say 'Goodbye, World!' diff --git a/Task/Hello-world-Text/REXX/hello-world-text-2.rexx b/Task/Hello-world-Text/REXX/hello-world-text-2.rexx new file mode 100644 index 0000000000..6fc68cc3e9 --- /dev/null +++ b/Task/Hello-world-Text/REXX/hello-world-text-2.rexx @@ -0,0 +1,3 @@ +/*REXX program to show a line of text. */ +yyy = 'Goodbye, World!' +say yyy diff --git a/Task/Hello-world-Text/REXX/hello-world-text-3.rexx b/Task/Hello-world-Text/REXX/hello-world-text-3.rexx new file mode 100644 index 0000000000..94acfd0405 --- /dev/null +++ b/Task/Hello-world-Text/REXX/hello-world-text-3.rexx @@ -0,0 +1,3 @@ +/*REXX program to show a line of text. */ + +call lineout ,"Goodbye, World!" diff --git a/Task/Hello-world-Text/Racket/hello-world-text.rkt b/Task/Hello-world-Text/Racket/hello-world-text.rkt new file mode 100644 index 0000000000..e3f9786f3c --- /dev/null +++ b/Task/Hello-world-Text/Racket/hello-world-text.rkt @@ -0,0 +1 @@ +(printf "Goodbye, World!\n") diff --git a/Task/Hello-world-Text/Ruby/hello-world-text-1.rb b/Task/Hello-world-Text/Ruby/hello-world-text-1.rb new file mode 100644 index 0000000000..7aed8b2172 --- /dev/null +++ b/Task/Hello-world-Text/Ruby/hello-world-text-1.rb @@ -0,0 +1 @@ +puts "Goodbye, World!" diff --git a/Task/Hello-world-Text/Ruby/hello-world-text-2.rb b/Task/Hello-world-Text/Ruby/hello-world-text-2.rb new file mode 100644 index 0000000000..2af954a040 --- /dev/null +++ b/Task/Hello-world-Text/Ruby/hello-world-text-2.rb @@ -0,0 +1 @@ +$stdout.puts "Goodbye, World!" diff --git a/Task/Hello-world-Text/SNUSP/hello-world-text.snusp b/Task/Hello-world-Text/SNUSP/hello-world-text.snusp new file mode 100644 index 0000000000..50a3619b42 --- /dev/null +++ b/Task/Hello-world-Text/SNUSP/hello-world-text.snusp @@ -0,0 +1,4 @@ +@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! # + | | \@------|# | \@@+@@++|+++#- \\ - + | \@@@@=+++++# | \===--------!\===!\-----|-------#-------/ + \@@+@@@+++++# \!#+++++++++++++++++++++++#!/ diff --git a/Task/Hello-world-Text/Sather/hello-world-text.sa b/Task/Hello-world-Text/Sather/hello-world-text.sa new file mode 100644 index 0000000000..01ca7e1136 --- /dev/null +++ b/Task/Hello-world-Text/Sather/hello-world-text.sa @@ -0,0 +1,5 @@ +class GOODBYE_WORLD is + main is + #OUT+"Goodbye, World!\n"; + end; +end; diff --git a/Task/Hello-world-Text/Scala/hello-world-text.scala b/Task/Hello-world-Text/Scala/hello-world-text.scala new file mode 100644 index 0000000000..d0337b0351 --- /dev/null +++ b/Task/Hello-world-Text/Scala/hello-world-text.scala @@ -0,0 +1 @@ +println("Goodbye, World!") diff --git a/Task/Hello-world-Text/Scheme/hello-world-text-1.ss b/Task/Hello-world-Text/Scheme/hello-world-text-1.ss new file mode 100644 index 0000000000..69701a0394 --- /dev/null +++ b/Task/Hello-world-Text/Scheme/hello-world-text-1.ss @@ -0,0 +1,2 @@ +(display "Goodbye, World!") +(newline) diff --git a/Task/Hello-world-Text/Scheme/hello-world-text-2.ss b/Task/Hello-world-Text/Scheme/hello-world-text-2.ss new file mode 100644 index 0000000000..6e7296b324 --- /dev/null +++ b/Task/Hello-world-Text/Scheme/hello-world-text-2.ss @@ -0,0 +1 @@ +(print "Goodbye, World!") diff --git a/Task/Hello-world-Text/Scheme/hello-world-text-3.ss b/Task/Hello-world-Text/Scheme/hello-world-text-3.ss new file mode 100644 index 0000000000..1e9d709f27 --- /dev/null +++ b/Task/Hello-world-Text/Scheme/hello-world-text-3.ss @@ -0,0 +1 @@ +"Goodbye, World!" diff --git a/Task/Hello-world-Text/Smalltalk/hello-world-text-1.st b/Task/Hello-world-Text/Smalltalk/hello-world-text-1.st new file mode 100644 index 0000000000..31ab449d30 --- /dev/null +++ b/Task/Hello-world-Text/Smalltalk/hello-world-text-1.st @@ -0,0 +1 @@ +Transcript show: 'Goodbye, World!'; cr. diff --git a/Task/Hello-world-Text/Smalltalk/hello-world-text-2.st b/Task/Hello-world-Text/Smalltalk/hello-world-text-2.st new file mode 100644 index 0000000000..ec793eba5a --- /dev/null +++ b/Task/Hello-world-Text/Smalltalk/hello-world-text-2.st @@ -0,0 +1 @@ +'Goodbye, World!' printNl. diff --git a/Task/Hello-world-Text/Tcl/hello-world-text-1.tcl b/Task/Hello-world-Text/Tcl/hello-world-text-1.tcl new file mode 100644 index 0000000000..7aed8b2172 --- /dev/null +++ b/Task/Hello-world-Text/Tcl/hello-world-text-1.tcl @@ -0,0 +1 @@ +puts "Goodbye, World!" diff --git a/Task/Hello-world-Text/Tcl/hello-world-text-2.tcl b/Task/Hello-world-Text/Tcl/hello-world-text-2.tcl new file mode 100644 index 0000000000..4231289e8f --- /dev/null +++ b/Task/Hello-world-Text/Tcl/hello-world-text-2.tcl @@ -0,0 +1 @@ +puts $fileID "Goodbye, World!" diff --git a/Task/Hello-world-Web-server/0DESCRIPTION b/Task/Hello-world-Web-server/0DESCRIPTION new file mode 100644 index 0000000000..667642b316 --- /dev/null +++ b/Task/Hello-world-Web-server/0DESCRIPTION @@ -0,0 +1,5 @@ +The browser is the new [[GUI]]! + +The task is to serve our standard text "Goodbye, World!" to http://localhost:8080/ so that it can be viewed with a web browser. The provided solution must start or implement a server that accepts multiple client connections and serves text as requested. + +Note that starting a web browser or opening a new window with this URL is not part of the task. Additionally, it is permissible to serve the provided page as a plain text file (there is no requirement to serve properly formatted [[HTML]] here). The browser will generally do the right thing with simple text like this. diff --git a/Task/Hello-world-Web-server/1META.yaml b/Task/Hello-world-Web-server/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/Hello-world-Web-server/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/Hello-world-Web-server/AWK/hello-world-web-server.awk b/Task/Hello-world-Web-server/AWK/hello-world-web-server.awk new file mode 100644 index 0000000000..9c1db765fe --- /dev/null +++ b/Task/Hello-world-Web-server/AWK/hello-world-web-server.awk @@ -0,0 +1,15 @@ +#!/usr/bin/gawk -f + BEGIN { + RS = ORS = "\r\n" + HttpService = "/inet/tcp/8080/0/0" + Hello = "" \ + "A Famous Greeting" \ + "

Hello, world

" + Len = length(Hello) + length(ORS) + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) + } diff --git a/Task/Hello-world-Web-server/Ada/hello-world-web-server.ada b/Task/Hello-world-Web-server/Ada/hello-world-web-server.ada new file mode 100644 index 0000000000..0df685cbf6 --- /dev/null +++ b/Task/Hello-world-Web-server/Ada/hello-world-web-server.ada @@ -0,0 +1,19 @@ +with AWS; use AWS; +with AWS.Response; +with AWS.Server; +with AWS.Status; +with Ada.Text_IO; use Ada.Text_IO; +procedure HelloHTTP is + function CB (Request : Status.Data) return Response.Data is + pragma Unreferenced (Request); + begin + return Response.Build ("text/html", "Hello world!"); + end CB; + TheServer : Server.HTTP; + ch : Character; +begin + Server.Start (TheServer, "Rosettacode", + Callback => CB'Unrestricted_Access, Port => 8080); + Put_Line ("Press any key to quit."); Get_Immediate (ch); + Server.Shutdown (TheServer); +end HelloHTTP; diff --git a/Task/Hello-world-Web-server/BBC-BASIC/hello-world-web-server.bbc b/Task/Hello-world-Web-server/BBC-BASIC/hello-world-web-server.bbc new file mode 100644 index 0000000000..c93867cec7 --- /dev/null +++ b/Task/Hello-world-Web-server/BBC-BASIC/hello-world-web-server.bbc @@ -0,0 +1,62 @@ + INSTALL @lib$+"SOCKLIB" + PROC_initsockets + + maxSess% = 8 + DIM sock%(maxSess%-1), rcvd$(maxSess%-1), Buffer% 255 + + ON ERROR PRINT REPORT$ : PROC_exitsockets : END + ON CLOSE PROC_exitsockets : QUIT + + port$ = "8080" + host$ = FN_gethostname + PRINT "Host name is " host$ + + listen% = FN_tcplisten(host$, port$) + PRINT "Listening on port ";port$ + + REPEAT + socket% = FN_check_connection(listen%) + IF socket% THEN + FOR i% = 0 TO maxSess%-1 + IF sock%(i%) = 0 THEN + sock%(i%) = socket% + rcvd$(i%) = "" + PRINT "Connection on socket "; sock%(i%) " opened" + EXIT FOR + ENDIF + NEXT i% + listen% = FN_tcplisten(host$, port$) + ENDIF + + FOR i% = 0 TO maxSess%-1 + IF sock%(i%) THEN + res% = FN_readsocket(sock%(i%), Buffer%, 256) + IF res% >= 0 THEN + Buffer%?res% = 0 + rcvd$(i%) += $$Buffer% + IF LEFT$(rcvd$(i%),4) = "GET " AND ( \ + \ RIGHT$(rcvd$(i%),4) = CHR$13+CHR$10+CHR$13+CHR$10 OR \ + \ RIGHT$(rcvd$(i%),4) = CHR$10+CHR$13+CHR$10+CHR$13 OR \ + \ RIGHT$(rcvd$(i%),2) = CHR$10+CHR$10 ) THEN + rcvd$(i%) = "" + IF FN_writelinesocket(sock%(i%), "HTTP/1.0 200 OK") + IF FN_writelinesocket(sock%(i%), "Content-type: text/html") + IF FN_writelinesocket(sock%(i%), "") + IF FN_writelinesocket(sock%(i%), "Hello World!") + IF FN_writelinesocket(sock%(i%), "

Hello World!

") + IF FN_writelinesocket(sock%(i%), "") + PROC_closesocket(sock%(i%)) + PRINT "Connection on socket " ; sock%(i%) " closed (local)" + sock%(i%) = 0 + ENDIF + ELSE + PROC_closesocket(sock%(i%)) + PRINT "Connection on socket " ; sock%(i%) " closed (remote)" + sock%(i%) = 0 + ENDIF + ENDIF + NEXT i% + + WAIT 0 + UNTIL FALSE + END diff --git a/Task/Hello-world-Web-server/C/hello-world-web-server.c b/Task/Hello-world-Web-server/C/hello-world-web-server.c new file mode 100644 index 0000000000..124a86c512 --- /dev/null +++ b/Task/Hello-world-Web-server/C/hello-world-web-server.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char response[] = "HTTP/1.1 200 OK\r\n" +"Content-Type: text/html; charset=UTF-8\r\n\r\n" +"Bye-bye baby bye-bye" +"" +"

Goodbye, world!

\r\n"; + +int main() +{ + int one = 1, client_fd; + struct sockaddr_in svr_addr, cli_addr; + socklen_t sin_len = sizeof(cli_addr); + + int sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) + err(1, "can't open socket"); + + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(int)); + + int port = 8080; + svr_addr.sin_family = AF_INET; + svr_addr.sin_addr.s_addr = INADDR_ANY; + svr_addr.sin_port = htons(port); + + if (bind(sock, (struct sockaddr *) &svr_addr, sizeof(svr_addr)) == -1) { + close(sock); + err(1, "Can't bind"); + } + + listen(sock, 5); + while (1) { + client_fd = accept(sock, (struct sockaddr *) &cli_addr, &sin_len); + printf("got connection\n"); + + if (client_fd == -1) { + perror("Can't accept"); + continue; + } + + write(client_fd, response, sizeof(response) - 1); /*-1:'\0'*/ + close(client_fd); + } +} diff --git a/Task/Hello-world-Web-server/D/hello-world-web-server.d b/Task/Hello-world-Web-server/D/hello-world-web-server.d new file mode 100644 index 0000000000..ae74051007 --- /dev/null +++ b/Task/Hello-world-Web-server/D/hello-world-web-server.d @@ -0,0 +1,24 @@ +import std.socket, std.array; + +ushort port = 8080; + +void main() { + Socket listener = new TcpSocket; + listener.bind(new InternetAddress(port)); + listener.listen(10); + + Socket currSock; + + while(cast(bool)(currSock = listener.accept())) { + currSock.sendTo(replace(q"EOF +HTTP/1.1 200 OK +Content-Type: text/html; charset=UTF-8 + + + Hello, world! + Hello, world! + +EOF", "\n", "\r\n")); + currSock.close(); + } +} diff --git a/Task/Hello-world-Web-server/Delphi/hello-world-web-server.delphi b/Task/Hello-world-Web-server/Delphi/hello-world-web-server.delphi new file mode 100644 index 0000000000..689afee470 --- /dev/null +++ b/Task/Hello-world-Web-server/Delphi/hello-world-web-server.delphi @@ -0,0 +1,50 @@ +program HelloWorldWebServer; + +{$APPTYPE CONSOLE} + +uses SysUtils, IdContext, IdCustomHTTPServer, IdHTTPServer; + +type + TWebServer = class + private + FHTTPServer: TIdHTTPServer; + public + constructor Create; + destructor Destroy; override; + procedure HTTPServerCommandGet(AContext: TIdContext; + ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); + end; + +constructor TWebServer.Create; +begin + FHTTPServer := TIdHTTPServer.Create(nil); + FHTTPServer.DefaultPort := 8080; + FHTTPServer.OnCommandGet := HTTPServerCommandGet; + FHTTPServer.Active := True; +end; + +destructor TWebServer.Destroy; +begin + FHTTPServer.Active := False; + FHTTPServer.Free; + inherited Destroy; +end; + +procedure TWebServer.HTTPServerCommandGet(AContext: TIdContext; + ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); +begin + AResponseInfo.ContentText := 'Goodbye, World!'; +end; + +var + lWebServer: TWebServer; +begin + lWebServer := TWebServer.Create; + try + Writeln('Delphi Hello world/Web server '); + Writeln('Press Enter to quit'); + Readln; + finally + lWebServer.Free; + end; +end. diff --git a/Task/Hello-world-Web-server/Erlang/hello-world-web-server.erl b/Task/Hello-world-Web-server/Erlang/hello-world-web-server.erl new file mode 100644 index 0000000000..ff0b6bfbb8 --- /dev/null +++ b/Task/Hello-world-Web-server/Erlang/hello-world-web-server.erl @@ -0,0 +1,28 @@ +-module(hello_world_server). + +-export([start/0, loop0/1]). + +-define(PORTNO, 8080). + +start() -> + start(?PORTNO). +start(Pno) -> + spawn(?MODULE, loop0, [Pno]). + +loop0(Port) -> + case gen_tcp:listen(Port, [binary, {packet, 0}, {active, false}]) of + {ok, LSock} -> + loop(LSock); + _ -> + stop + end. + +loop(Listen) -> + case gen_tcp:accept(Listen) of + {ok, S} -> + gen_tcp:send(S, io_lib:format("Goodbye, World!~n", [])), + gen_tcp:close(S), + loop(Listen); + _ -> + loop(Listen) + end. diff --git a/Task/Hello-world-Web-server/Fantom/hello-world-web-server.fantom b/Task/Hello-world-Web-server/Fantom/hello-world-web-server.fantom new file mode 100644 index 0000000000..d170d98024 --- /dev/null +++ b/Task/Hello-world-Web-server/Fantom/hello-world-web-server.fantom @@ -0,0 +1,25 @@ +using web +using wisp + +const class HelloMod : WebMod // provides the content +{ + override Void onGet () + { + res.headers["Content-Type"] = "text/plain; charset=utf-8" + res.out.print ("Goodbye, World!") + } +} + +class HelloWeb +{ + Void main () + { + WispService // creates the web service + { + port = 8080 + root = HelloMod() + }.start + + while (true) {} // stay running + } +} diff --git a/Task/Hello-world-Web-server/Go/hello-world-web-server.go b/Task/Hello-world-Web-server/Go/hello-world-web-server.go new file mode 100644 index 0000000000..0f93278481 --- /dev/null +++ b/Task/Hello-world-Web-server/Go/hello-world-web-server.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + http.HandleFunc("/", + func(w http.ResponseWriter, req *http.Request) { + fmt.Fprintln(w, "Goodbye, World!") + }) + if err := http.ListenAndServe(":8080", nil); err != nil { + fmt.Println(err) + } +} diff --git a/Task/Hello-world-Web-server/Haskell/hello-world-web-server-1.hs b/Task/Hello-world-Web-server/Haskell/hello-world-web-server-1.hs new file mode 100644 index 0000000000..c638de68d5 --- /dev/null +++ b/Task/Hello-world-Web-server/Haskell/hello-world-web-server-1.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Data.ByteString.Char8 () +import Data.Conduit ( ($$), yield ) +import Data.Conduit.Network ( ServerSettings(..), runTCPServer ) + +main :: IO () +main = runTCPServer (ServerSettings 8080 "127.0.0.1") $ const (yield response $$) + where response = "HTTP/1.0 200 OK\nContent-Length: 16\n\nGoodbye, World!\n" diff --git a/Task/Hello-world-Web-server/Haskell/hello-world-web-server-2.hs b/Task/Hello-world-Web-server/Haskell/hello-world-web-server-2.hs new file mode 100644 index 0000000000..391ded9d3a --- /dev/null +++ b/Task/Hello-world-Web-server/Haskell/hello-world-web-server-2.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Data.ByteString.Char8 () +import Network hiding ( accept ) +import Network.Socket ( accept ) +import Network.Socket.ByteString ( sendAll ) +import Control.Monad ( forever ) +import Control.Exception ( bracket, finally ) +import Control.Concurrent ( forkIO ) + +main :: IO () +main = bracket (listenOn $ PortNumber 8080) sClose loop where + loop s = forever $ forkIO . request . fst =<< accept s + request c = sendAll c response `finally` sClose c + response = "HTTP/1.0 200 OK\nContent-Length: 16\n\nGoodbye, World!\n" diff --git a/Task/Hello-world-Web-server/J/hello-world-web-server-1.j b/Task/Hello-world-Web-server/J/hello-world-web-server-1.j new file mode 100644 index 0000000000..ff76edc774 --- /dev/null +++ b/Task/Hello-world-Web-server/J/hello-world-web-server-1.j @@ -0,0 +1 @@ +'Goodbye, World!' diff --git a/Task/Hello-world-Web-server/J/hello-world-web-server-2.j b/Task/Hello-world-Web-server/J/hello-world-web-server-2.j new file mode 100644 index 0000000000..50ac6498b6 --- /dev/null +++ b/Task/Hello-world-Web-server/J/hello-world-web-server-2.j @@ -0,0 +1,27 @@ +hello=: verb define + 8080 hello y NB. try to use port 8080 by default +: + port=: x + require 'socket' + coinsert 'jsocket' + sdclose ; sdcheck sdgetsockets '' + server=: {. ; sdcheck sdsocket '' + sdcheck sdbind server; AF_INET; ''; port + sdcheck sdlisten server, 1 + while. 1 do. + while. + server e. ready=: >{. sdcheck sdselect (sdcheck sdgetsockets ''),'';'';<1e3 + do. + sdcheck sdaccept server + end. + for_socket. ready do. + request=: ; sdcheck sdrecv socket, 65536 0 + sdcheck (socket responseFor request) sdsend socket, 0 + sdcheck sdclose socket + end. + end. +) + +responseFor=: dyad define + 'HTTP/1.0 200 OK',CRLF,'Content-Type: text/plain',CRLF,CRLF,'Goodbye, World!',CRLF +) diff --git a/Task/Hello-world-Web-server/J/hello-world-web-server-3.j b/Task/Hello-world-Web-server/J/hello-world-web-server-3.j new file mode 100644 index 0000000000..4ae8442931 --- /dev/null +++ b/Task/Hello-world-Web-server/J/hello-world-web-server-3.j @@ -0,0 +1 @@ +hello'' diff --git a/Task/Hello-world-Web-server/Java/hello-world-web-server.java b/Task/Hello-world-Web-server/Java/hello-world-web-server.java new file mode 100644 index 0000000000..f45b202e6d --- /dev/null +++ b/Task/Hello-world-Web-server/Java/hello-world-web-server.java @@ -0,0 +1,16 @@ +import java.io.IOException; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; + +public class HelloWorld{ + public static void main(String[] args) throws IOException{ + ServerSocket listener = new ServerSocket(8080); + while(true){ + Socket sock = listener.accept(); + new PrintWriter(sock.getOutputStream(), true). + println("Goodbye, World!"); + sock.close(); + } + } +} diff --git a/Task/Hello-world-Web-server/JavaScript/hello-world-web-server.js b/Task/Hello-world-Web-server/JavaScript/hello-world-web-server.js new file mode 100644 index 0000000000..1958e24dd3 --- /dev/null +++ b/Task/Hello-world-Web-server/JavaScript/hello-world-web-server.js @@ -0,0 +1,6 @@ +var http = require('http'); + +http.createServer(function (req, res) { + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end('Goodbye, World!\n'); +}).listen(8080, '127.0.0.1'); diff --git a/Task/Hello-world-Web-server/Liberty-BASIC/hello-world-web-server.liberty b/Task/Hello-world-Web-server/Liberty-BASIC/hello-world-web-server.liberty new file mode 100644 index 0000000000..2a1dc18bb8 --- /dev/null +++ b/Task/Hello-world-Web-server/Liberty-BASIC/hello-world-web-server.liberty @@ -0,0 +1 @@ +print "hello world!" diff --git a/Task/Hello-world-Web-server/PHP/hello-world-web-server.php b/Task/Hello-world-Web-server/PHP/hello-world-web-server.php new file mode 100644 index 0000000000..217e38b0af --- /dev/null +++ b/Task/Hello-world-Web-server/PHP/hello-world-web-server.php @@ -0,0 +1,19 @@ +Goodbye, world!Goodbye, world!'; + +for (;;) { + // @ is used to stop PHP from spamming with error messages if there is no connection + if ($client = @socket_accept($socket)) { + socket_write($client, "HTTP/1.1 200 OK\r\n" . + "Content-length: " . strlen($msg) . "\r\n" . + "Content-Type: text/html; charset=UTF-8\r\n\r\n" . + $msg); + } + else usleep(100000); // limits CPU usage by sleeping after doing every request +} diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-1.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-1.pl new file mode 100644 index 0000000000..417bdcbc07 --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-1.pl @@ -0,0 +1,25 @@ +use Socket; + +my $port = 8080; +my $protocol = getprotobyname( "tcp" ); + +socket( SOCK, PF_INET, SOCK_STREAM, $protocol ) or die "couldn't open a socket: $!"; + # PF_INET to indicate that this socket will connect to the internet domain + # SOCK_STREAM indicates a TCP stream, SOCK_DGRAM would indicate UDP communication + +setsockopt( SOCK, SOL_SOCKET, SO_REUSEADDR, 1 ) or die "couldn't set socket options: $!"; + # SOL_SOCKET to indicate that we are setting an option on the socket instead of the protocol + # mark the socket reusable + +bind( SOCK, sockaddr_in($port, INADDR_ANY) ) or die "couldn't bind socket to port $port: $!"; + # bind our socket to $port, allowing any IP to connect + +listen( SOCK, SOMAXCONN ) or die "couldn't listen to port $port: $!"; + # start listening for incoming connections + +while( accept(CLIENT, SOCK) ){ + print CLIENT "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/html; charset=UTF-8\r\n\r\n" . + "Goodbye, world!Goodbye, world!\r\n"; + close CLIENT; +} diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-2.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-2.pl new file mode 100644 index 0000000000..5093513418 --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-2.pl @@ -0,0 +1,12 @@ +use IO::Socket::INET; + +my $sock = new IO::Socket::INET ( LocalAddr => "127.0.0.1:8080", + Listen => 1, + Reuse => 1, ) or die "Could not create socket: $!"; + +while( my $client = $sock->accept() ){ + print $client "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/html; charset=UTF-8\r\n\r\n" . + "Goodbye, world!Goodbye, world!\r\n"; + close $client; +} diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-3.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-3.pl new file mode 100644 index 0000000000..63b7847c3b --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-3.pl @@ -0,0 +1,6 @@ +while (++(our $vn)) { + open NC, "|-", qw(nc -l -p 8080 -q 1); + print NC "HTTP/1.0 200 OK\xd\xa", + "Content-type: text/plain; charset=utf-8\xd\xa\xd\xa", + "Goodbye, World! (hello, visitor No. $vn!)\xd\xa"; +} diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-4.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-4.pl new file mode 100644 index 0000000000..c29fe8fbdc --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-4.pl @@ -0,0 +1,10 @@ +use Plack::Runner; +my $app = sub { + return [ 200, + [ 'Content-Type' => 'text/html; charset=UTF-8' ], + [ 'Goodbye, world!Goodbye, world!' ] + ] +}; +my $runner = Plack::Runner->new; +$runner->parse_options('--host' => 'localhost', '--port' => 8080); +$runner->run($app); diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-5.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-5.pl new file mode 100644 index 0000000000..5673293569 --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-5.pl @@ -0,0 +1 @@ +my $app = sub { return [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], [ 'Goodbye, world!Goodbye, world!' ] ] }; diff --git a/Task/Hello-world-Web-server/Perl/hello-world-web-server-6.pl b/Task/Hello-world-Web-server/Perl/hello-world-web-server-6.pl new file mode 100644 index 0000000000..6ccc8867fa --- /dev/null +++ b/Task/Hello-world-Web-server/Perl/hello-world-web-server-6.pl @@ -0,0 +1 @@ +plackup --host localhost --port 8080 script.psgi diff --git a/Task/Hello-world-Web-server/PicoLisp/hello-world-web-server.l b/Task/Hello-world-Web-server/PicoLisp/hello-world-web-server.l new file mode 100644 index 0000000000..9d920e1842 --- /dev/null +++ b/Task/Hello-world-Web-server/PicoLisp/hello-world-web-server.l @@ -0,0 +1,2 @@ +(html 0 "Bye" NIL NIL + "Goodbye, World!" ) diff --git a/Task/Hello-world-Web-server/Python/hello-world-web-server.py b/Task/Hello-world-Web-server/Python/hello-world-web-server.py new file mode 100644 index 0000000000..5290634d93 --- /dev/null +++ b/Task/Hello-world-Web-server/Python/hello-world-web-server.py @@ -0,0 +1,8 @@ +def app(environ, start_response): + start_response('200 OK', []) + yield "Goodbye, World!" + +if __name__ == '__main__': + from wsgiref.simple_server import make_server + server = make_server('127.0.0.1', 8080, app) + server.serve_forever() diff --git a/Task/Hello-world-Web-server/Racket/hello-world-web-server.rkt b/Task/Hello-world-Web-server/Racket/hello-world-web-server.rkt new file mode 100644 index 0000000000..705925f10c --- /dev/null +++ b/Task/Hello-world-Web-server/Racket/hello-world-web-server.rkt @@ -0,0 +1,8 @@ +#lang racket +(require web-server/servlet + web-server/servlet-env) + +(define (start req) + (response/xexpr "Goodbye, World!")) + +(serve/servlet start #:port 8080 #:servlet-path "/") diff --git a/Task/Hello-world-Web-server/Ruby/hello-world-web-server-1.rb b/Task/Hello-world-Web-server/Ruby/hello-world-web-server-1.rb new file mode 100644 index 0000000000..894425b6d7 --- /dev/null +++ b/Task/Hello-world-Web-server/Ruby/hello-world-web-server-1.rb @@ -0,0 +1,5 @@ +require 'webrick' +server = WEBrick::HTTPServer.new(:Port => 8080) +server.mount_proc('/') {|request, response| response.body = "Goodbye, World!"} +trap("INT") {server.shutdown} +server.start diff --git a/Task/Hello-world-Web-server/Ruby/hello-world-web-server-2.rb b/Task/Hello-world-Web-server/Ruby/hello-world-web-server-2.rb new file mode 100644 index 0000000000..7569c667f5 --- /dev/null +++ b/Task/Hello-world-Web-server/Ruby/hello-world-web-server-2.rb @@ -0,0 +1,2 @@ +require 'sinatra' +get("/") { "Goodbye, World!" } diff --git a/Task/Hello-world-Web-server/Smalltalk/hello-world-web-server.st b/Task/Hello-world-Web-server/Smalltalk/hello-world-web-server.st new file mode 100644 index 0000000000..803e14f599 --- /dev/null +++ b/Task/Hello-world-Web-server/Smalltalk/hello-world-web-server.st @@ -0,0 +1,14 @@ +Smalltalk loadPackage:'stx:goodies/webServer'. "usually already loaded" +|myServer service| + +myServer := HTTPServer startServerOnPort:8082. +service := HTTPPluggableActionService new. +service + register:[:request | + self halt: 'debugging'. + request reply:'

Hello World

' + ] + as:'hello'. +service linkNames:#('/' ). +service registerServiceOn: myServer. +myServer start. diff --git a/Task/Hello-world-Web-server/Tcl/hello-world-web-server.tcl b/Task/Hello-world-Web-server/Tcl/hello-world-web-server.tcl new file mode 100644 index 0000000000..320d736838 --- /dev/null +++ b/Task/Hello-world-Web-server/Tcl/hello-world-web-server.tcl @@ -0,0 +1,8 @@ +proc accept {chan addr port} { + while {[gets $chan] ne ""} {} + puts $chan "HTTP/1.1 200 OK\nConnection: close\nContent-Type: text/plain\n" + puts $chan "Goodbye, World!" + close $chan +} +socket -server accept 8080 +vwait forever diff --git a/Task/Here-document/0DESCRIPTION b/Task/Here-document/0DESCRIPTION new file mode 100644 index 0000000000..f5ff9ffd7c --- /dev/null +++ b/Task/Here-document/0DESCRIPTION @@ -0,0 +1,4 @@ +{{omit from|BBC BASIC}} +A here document (or "heredoc") is a way of specifying a text block, preserving the line breaks, indentation and other whitespace within the text. Depending on the language being used a here document is constructed using a command followed by "<<" (or some other symbol) followed by a token string. The text block will then start on the next line, and will be followed by the chosen token at the beginning of the following line, which is used to mark the end of the textblock. + +The task is to demonstrate the use of here documents within the language. diff --git a/Task/Here-document/ALGOL-68/here-document.alg b/Task/Here-document/ALGOL-68/here-document.alg new file mode 100644 index 0000000000..498d34b372 --- /dev/null +++ b/Task/Here-document/ALGOL-68/here-document.alg @@ -0,0 +1,17 @@ +#!/usr/local/bin/a68g --script # + +[]STRING help = ( +"Usage: thingy [OPTIONS]", +" -h Display this usage message", +" -H hostname Hostname to connect to" +); + +printf(($gl$,help,$l$)); + +printf(($gl$, +"The river was deep but I swam it, Janet.", +"The future is ours so let's plan it, Janet.", +"So please don't tell me to can it, Janet.", +"I've one thing to say and that's ...", +"Dammit. Janet, I love you." +)) diff --git a/Task/Here-document/Ada/here-document.ada b/Task/Here-document/Ada/here-document.ada new file mode 100644 index 0000000000..28537f94e2 --- /dev/null +++ b/Task/Here-document/Ada/here-document.ada @@ -0,0 +1,20 @@ +with Ada.Containers.Indefinite_Vectors, Ada.Text_IO; + +procedure Here_Doc is + + package String_Vec is new Ada.Containers.Indefinite_Vectors + (Index_Type => Positive, + Element_Type => String); + + use type String_Vec.Vector; + + Document: String_Vec.Vector := String_Vec.Empty_Vector + & "This is a vector of strings with the following properties:" + & " - indention is preserved, and" + & " - a quotation mark '""' must be ""escaped"" by a double-quote '""""'."; +begin + Document := Document & "Have fun!"; + for I in Document.First_Index .. Document.Last_Index loop + Ada.Text_IO.Put_Line(Document.Element(I)); + end loop; +end Here_Doc; diff --git a/Task/Here-document/AutoHotkey/here-document.ahk b/Task/Here-document/AutoHotkey/here-document.ahk new file mode 100644 index 0000000000..9b8e611e19 --- /dev/null +++ b/Task/Here-document/AutoHotkey/here-document.ahk @@ -0,0 +1,9 @@ +MyVar = "This is the text inside MyVar" +MyVariable = +( + Note that whitespace is preserved + As well as newlines. + The LTrim option can be present to remove left whitespace. + Variable references such as %MyVar% are expanded. +) +MsgBox % MyVariable diff --git a/Task/Here-document/C-sharp/here-document.cs b/Task/Here-document/C-sharp/here-document.cs new file mode 100644 index 0000000000..15217e1620 --- /dev/null +++ b/Task/Here-document/C-sharp/here-document.cs @@ -0,0 +1,13 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + Console.Write(@" +multiline +strings are easy +to put together +in C#"); + } +} diff --git a/Task/Here-document/CoffeeScript/here-document.coffee b/Task/Here-document/CoffeeScript/here-document.coffee new file mode 100644 index 0000000000..f0698273ff --- /dev/null +++ b/Task/Here-document/CoffeeScript/here-document.coffee @@ -0,0 +1,11 @@ +myDoc = ''' + Single-quoted heredocs allows no '#{foo}' interpolation. + This behavior is similar to single-quoted strings. + ''' +doc2 = """ + However, double-quoted heredocs *do* allow these. + See it in action: + Content: "#{myDoc}" + """ + +console.log doc2 diff --git a/Task/Here-document/D/here-document-1.d b/Task/Here-document/D/here-document-1.d new file mode 100644 index 0000000000..4336aadcfa --- /dev/null +++ b/Task/Here-document/D/here-document-1.d @@ -0,0 +1 @@ +auto s = q"[a string that you "don't" have to escape]"; diff --git a/Task/Here-document/D/here-document-2.d b/Task/Here-document/D/here-document-2.d new file mode 100644 index 0000000000..cf080f7f0a --- /dev/null +++ b/Task/Here-document/D/here-document-2.d @@ -0,0 +1,6 @@ +writefln(q"EOS +This +is a multi-line +heredoc string +EOS" +); diff --git a/Task/Here-document/DWScript/here-document.dwscript b/Task/Here-document/DWScript/here-document.dwscript new file mode 100644 index 0000000000..6d495a0f4c --- /dev/null +++ b/Task/Here-document/DWScript/here-document.dwscript @@ -0,0 +1,4 @@ +PrintLn("This is +a multiline +""string"" +sample"); diff --git a/Task/Here-document/Forth/here-document.fth b/Task/Here-document/Forth/here-document.fth new file mode 100644 index 0000000000..06c108ead7 --- /dev/null +++ b/Task/Here-document/Forth/here-document.fth @@ -0,0 +1,49 @@ +\ GForth specific words: +\ under+ ( a b c -- a+c b) , latest ( -- nt ) , name>string ( nt -- ca u ) +\ Should not be a problem to modify it to work with other Forth implementation: + +: $! ( ca u -- a ) + dup >R dup , here swap move R> allot ; +: $@ ( a -- ca u ) + dup @ 1 cells under+ ; +: c!+ ( c ca - ca+1 ) + tuck c! 1+ ; +: $!+ ( a u a' -- a'+u ; string-store-plus ) + 2dup + >R swap move R> ; + +\ --- UNIX end-of-line adapted words +10 constant EOL +: input-fix ( -- ; for interactive use ! ) + source-id 0= IF cr THEN ; +: get_line ( -- ca u ) EOL parse input-fix ; +: EOL!+ ( a -- a' ; eol-store-plus ) EOL swap c!+ ; + +: EOD ( -- ca u ; end-of-doc ) + latest name>string ; + +: >> ( "doc-name" "doc-body" -- ) input-fix + CREATE 0 , \ post body length + here dup >R + BEGIN refill >R + get_line 2dup EOD compare + R> AND \ notEOD && input-stream -> + WHILE rot $!+ EOL!+ + REPEAT 2drop + R> tuck - dup allot + swap -1 cells + ! \ fixup body length + DOES> ( -- ca u ) $@ ; + +\ TEST ; excerpt from Project Gutenberg 'Alice in Wonderland' + +>> ALICE +CHAPTER I. Down the Rabbit-Hole + +Alice was beginning to get very tired of sitting by her sister on the +bank, and of having nothing to do: once or twice she had peeped into the +book her sister was reading, but it had no pictures or conversations in +it, 'and what is the use of a book,' thought Alice 'without pictures or +conversation?' +ALICE +>> RABBIT +RABBIT +ALICE type ." --" cr RABBIT type diff --git a/Task/Here-document/Frink/here-document.frink b/Task/Here-document/Frink/here-document.frink new file mode 100644 index 0000000000..3f9edd9482 --- /dev/null +++ b/Task/Here-document/Frink/here-document.frink @@ -0,0 +1,3 @@ +lyrics = """Oh, Danny Boy, +The pipes, the pipes are calling +From glen to glen and down the mountainside""" diff --git a/Task/Here-document/Go/here-document.go b/Task/Here-document/Go/here-document.go new file mode 100644 index 0000000000..1bc4f0b285 --- /dev/null +++ b/Task/Here-document/Go/here-document.go @@ -0,0 +1,3 @@ +var m = ` leading spaces + +and blank lines` diff --git a/Task/Here-document/Groovy/here-document-1.groovy b/Task/Here-document/Groovy/here-document-1.groovy new file mode 100644 index 0000000000..71c06f15e5 --- /dev/null +++ b/Task/Here-document/Groovy/here-document-1.groovy @@ -0,0 +1,8 @@ +println ''' +Time's a strange fellow; + more he gives than takes +(and he takes all) nor any marvel finds +quite disappearance but some keener makes +losing, gaining + --love! if a world ends +''' diff --git a/Task/Here-document/Groovy/here-document-2.groovy b/Task/Here-document/Groovy/here-document-2.groovy new file mode 100644 index 0000000000..dc85e016ea --- /dev/null +++ b/Task/Here-document/Groovy/here-document-2.groovy @@ -0,0 +1,18 @@ +def expired='defunct' +def horse='stallion' +def christ='Jesus' + +println """ +Buffalo Bill's + ${expired} + who used to + ride a watersmooth-silver + ${horse} + and break onetwothreefourfive pigeonsjustlikethat + ${christ} + + he was a handsome man + and what i want to know is + how do you like your blueeyed boy + Mister Death +""" diff --git a/Task/Here-document/J/here-document.j b/Task/Here-document/J/here-document.j new file mode 100644 index 0000000000..22e29b24b2 --- /dev/null +++ b/Task/Here-document/J/here-document.j @@ -0,0 +1,40 @@ +here=:0 :0 + 0 :0 will be replaced by the text on the following lines. + This is three tokens: two instances of the number 0 and + one instance of the explicit definition token ':'. + Any indentation in the here document will be retained in the result. + There must be a space to the left of : or it will combine with the + 0 on its left to form the token 0: which is something completely + different. + + The here document is terminated by a line which contains only a + single right parenthesis ')' and optional white space. In J's + documentation the family of entities which include here documents + (and verb definitions and so on) are called 'scripts'. + + When several scripts are referenced on the same line, they are used + sequentially in an order determined by their appearance on the line. + The leftmost 'script' reference gets the last script and the rightmost + reference gets the first script. But this is a rare usage. + + Typically, such values are assigned a name so that they can be + used later. However, they may also be discarded and/or ignored, in + which case they are logically equivalent to multi-line comments. +) + +and_here=:noun define + 'noun define' is an alternative and perhaps more "user friendly" + way of declaring a here document. It achieves the same thing as + 0 :0 and in fact 'noun' has the value 0 and 'define' has the value :0 + And, of course, there must be a space between the word 'noun' and + the word 'define'. + + Other useful alternatives include verb (which has the value 3) + and dyad (which has the value 4), and adverb (which has the value 1). + In other words 'verb define' (if unquoted) would be replaced by a + verb whose definition is provided in the following 'script'. + However, all of these names are normal variables which can + be declared to have different values by the developer. And, of course, + note that this mechanism is significantly more verbose than using + the underlying 0 :0 mechanism directly. +) diff --git a/Task/Here-document/Lua/here-document.lua b/Task/Here-document/Lua/here-document.lua new file mode 100644 index 0000000000..c3e461b99b --- /dev/null +++ b/Task/Here-document/Lua/here-document.lua @@ -0,0 +1,14 @@ +print([[ +This is a long paragraph of text +it is the simplest while using it +with lua, however it will have the +same line breaks and spacing as + you set in this block. +]]) + +local msg = [[this is a message that spans +multiple lines and will have the next lines +preserved as they were entered, so be careful +when using this]] + +print(msg) diff --git a/Task/Here-document/PHP/here-document-1.php b/Task/Here-document/PHP/here-document-1.php new file mode 100644 index 0000000000..9944a1ba07 --- /dev/null +++ b/Task/Here-document/PHP/here-document-1.php @@ -0,0 +1,6 @@ +$address = <<>> @text <<<}) + +(output + @list{Blah blah blah + with indentation intact + but respecting the indentation of + the whole code + and "free" \punctuations\ + and even string interpolation-like @excited + but really @shout{any code} + + }) diff --git a/Task/Here-document/Ruby/here-document-1.rb b/Task/Here-document/Ruby/here-document-1.rb new file mode 100644 index 0000000000..850fbd60b2 --- /dev/null +++ b/Task/Here-document/Ruby/here-document-1.rb @@ -0,0 +1,6 @@ +address = < +#include + +template +typename Func::result_type first(Func func, typename Func::argument_type arg) +{ + return func(arg); +} + +class second : public std::unary_function +{ +public: + result_type operator()(argument_type arg) const + { + return arg * arg; + } +}; + +int main() +{ + std::cout << first(second(), 2) << std::endl; + return 0; +} diff --git a/Task/Higher-order-functions/C-sharp/higher-order-functions-1.cs b/Task/Higher-order-functions/C-sharp/higher-order-functions-1.cs new file mode 100644 index 0000000000..f83d8fd85c --- /dev/null +++ b/Task/Higher-order-functions/C-sharp/higher-order-functions-1.cs @@ -0,0 +1,38 @@ +using System; +delegate int Func2(int a, int b); +class Program +{ + static int Add(int a, int b) + { + return a + b; + } + + static int Mul(int a, int b) + { + return a * b; + } + + static int Div(int a, int b) + { + return a / b; + } + + static int Call(Func2 f, int a, int b) + { + return f(a, b); + } + + static void Main() + { + int a = 6; + int b = 2; + + Func2 add = new Func2(Add); + Func2 mul = new Func2(Mul); + Func2 div = new Func2(Div); + + Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b)); + Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b)); + Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b)); + } +} diff --git a/Task/Higher-order-functions/C-sharp/higher-order-functions-2.cs b/Task/Higher-order-functions/C-sharp/higher-order-functions-2.cs new file mode 100644 index 0000000000..f37b96377f --- /dev/null +++ b/Task/Higher-order-functions/C-sharp/higher-order-functions-2.cs @@ -0,0 +1,19 @@ +using System; +delegate int Func2(int a, int b); +class Program +{ + static int Call(Func2 f, int a, int b) + { + return f(a, b); + } + + static void Main() + { + int a = 6; + int b = 2; + + Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(delegate(int x, int y) { return x + y; }, a, b)); + Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(delegate(int x, int y) { return x * y; }, a, b)); + Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(delegate(int x, int y) { return x / y; }, a, b)); + } +} diff --git a/Task/Higher-order-functions/C-sharp/higher-order-functions-3.cs b/Task/Higher-order-functions/C-sharp/higher-order-functions-3.cs new file mode 100644 index 0000000000..a60fcf6e05 --- /dev/null +++ b/Task/Higher-order-functions/C-sharp/higher-order-functions-3.cs @@ -0,0 +1,18 @@ +using System; +class Program +{ + static int Call(Func f, int a, int b) + { + return f(a, b); + } + + static void Main() + { + int a = 6; + int b = 2; + + Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call((x, y) => x + y, a, b)); + Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call((x, y) => x * y, a, b)); + Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call((x, y) => x / y, a, b)); + } +} diff --git a/Task/Higher-order-functions/C/higher-order-functions-1.c b/Task/Higher-order-functions/C/higher-order-functions-1.c new file mode 100644 index 0000000000..d534b954d9 --- /dev/null +++ b/Task/Higher-order-functions/C/higher-order-functions-1.c @@ -0,0 +1,9 @@ +void myFuncSimple( void (*funcParameter)(void) ) +{ + /* ... */ + + (*funcParameter)(); /* Call the passed function. */ + funcParameter(); /* Same as above with slight different syntax. */ + + /* ... */ +} diff --git a/Task/Higher-order-functions/C/higher-order-functions-2.c b/Task/Higher-order-functions/C/higher-order-functions-2.c new file mode 100644 index 0000000000..8738cb12b8 --- /dev/null +++ b/Task/Higher-order-functions/C/higher-order-functions-2.c @@ -0,0 +1,5 @@ +void funcToBePassed(void); + +/* ... */ + +myFuncSimple(&funcToBePassed); diff --git a/Task/Higher-order-functions/C/higher-order-functions-3.c b/Task/Higher-order-functions/C/higher-order-functions-3.c new file mode 100644 index 0000000000..5c60c7a025 --- /dev/null +++ b/Task/Higher-order-functions/C/higher-order-functions-3.c @@ -0,0 +1,13 @@ +int* myFuncComplex( double* (*funcParameter)(long* parameter) ) +{ + long inLong; + double* outDouble; + long *inLong2 = &inLong; + + /* ... */ + + outDouble = (*funcParameter)(&inLong); /* Call the passed function and store returned pointer. */ + outDouble = funcParameter(inLong2); /* Same as above with slight different syntax. */ + + /* ... */ +} diff --git a/Task/Higher-order-functions/C/higher-order-functions-4.c b/Task/Higher-order-functions/C/higher-order-functions-4.c new file mode 100644 index 0000000000..3bddc2899f --- /dev/null +++ b/Task/Higher-order-functions/C/higher-order-functions-4.c @@ -0,0 +1,7 @@ +double* funcToBePassed(long* parameter); + +/* ... */ + +int* outInt; + +outInt = myFuncComplex(&funcToBePassed); diff --git a/Task/Higher-order-functions/C/higher-order-functions-5.c b/Task/Higher-order-functions/C/higher-order-functions-5.c new file mode 100644 index 0000000000..873d302b62 --- /dev/null +++ b/Task/Higher-order-functions/C/higher-order-functions-5.c @@ -0,0 +1,5 @@ +int* (*funcPointer)( double* (*funcParameter)(long* parameter) ); + +/* ... */ + +funcPointer = &myFuncComplex; diff --git a/Task/Higher-order-functions/Clean/higher-order-functions-1.clean b/Task/Higher-order-functions/Clean/higher-order-functions-1.clean new file mode 100644 index 0000000000..877550b776 --- /dev/null +++ b/Task/Higher-order-functions/Clean/higher-order-functions-1.clean @@ -0,0 +1,2 @@ +map f [x:xs] = [f x:map f xs] +map f [] = [] diff --git a/Task/Higher-order-functions/Clean/higher-order-functions-2.clean b/Task/Higher-order-functions/Clean/higher-order-functions-2.clean new file mode 100644 index 0000000000..8f8af5ffff --- /dev/null +++ b/Task/Higher-order-functions/Clean/higher-order-functions-2.clean @@ -0,0 +1,3 @@ +incr x = x + 1 + +Start = map incr [1..10] diff --git a/Task/Higher-order-functions/Clean/higher-order-functions-3.clean b/Task/Higher-order-functions/Clean/higher-order-functions-3.clean new file mode 100644 index 0000000000..0dda4b9e1a --- /dev/null +++ b/Task/Higher-order-functions/Clean/higher-order-functions-3.clean @@ -0,0 +1 @@ +Start = map (\x -> x + 1) [1..10] diff --git a/Task/Higher-order-functions/Clean/higher-order-functions-4.clean b/Task/Higher-order-functions/Clean/higher-order-functions-4.clean new file mode 100644 index 0000000000..3022d57e8a --- /dev/null +++ b/Task/Higher-order-functions/Clean/higher-order-functions-4.clean @@ -0,0 +1 @@ +Start = map ((+) 1) [1..10] diff --git a/Task/Higher-order-functions/Clojure/higher-order-functions.clj b/Task/Higher-order-functions/Clojure/higher-order-functions.clj new file mode 100644 index 0000000000..01a257f958 --- /dev/null +++ b/Task/Higher-order-functions/Clojure/higher-order-functions.clj @@ -0,0 +1,7 @@ +(defn append-hello [s] + (str "Hello " s)) + +(defn modify-string [f s] + (f s)) + +(println (modify-string append-hello "World!")) diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-1.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-1.coffee new file mode 100644 index 0000000000..4c22a34d5d --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-1.coffee @@ -0,0 +1 @@ +double = [1,2,3].map (x) -> x*2 diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-2.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-2.coffee new file mode 100644 index 0000000000..31b5194904 --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-2.coffee @@ -0,0 +1,3 @@ +fn = -> return 8 +sum = (a, b) -> a() + b() +sum(fn, fn) # => 16 diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-3.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-3.coffee new file mode 100644 index 0000000000..0cd508d9af --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-3.coffee @@ -0,0 +1,7 @@ +bowl = ["Cheese", "Tomato"] + +smash = (ingredient) -> + return "Smashed #{ingredient}" + +contents = smash ingredient for ingredient in bowl +# => ["Smashed Cheese", "Smashed Tomato"] diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-4.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-4.coffee new file mode 100644 index 0000000000..6d914e6ad1 --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-4.coffee @@ -0,0 +1,5 @@ +double = (x) -> x*2 +triple = (x) -> x*3 +addOne = (x) -> x+1 + +addOne triple double 2 # same as addOne(triple(double(2))) diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-5.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-5.coffee new file mode 100644 index 0000000000..09dc0462b9 --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-5.coffee @@ -0,0 +1 @@ +(-> -> -> -> 2 )()()()() # => 2 diff --git a/Task/Higher-order-functions/CoffeeScript/higher-order-functions-6.coffee b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-6.coffee new file mode 100644 index 0000000000..a909d73515 --- /dev/null +++ b/Task/Higher-order-functions/CoffeeScript/higher-order-functions-6.coffee @@ -0,0 +1,4 @@ +((x)-> + 2 + x(-> 5) +)((y) -> y()+3) +# result: 10 diff --git a/Task/Higher-order-functions/Common-Lisp/higher-order-functions.lisp b/Task/Higher-order-functions/Common-Lisp/higher-order-functions.lisp new file mode 100644 index 0000000000..60fa37ab65 --- /dev/null +++ b/Task/Higher-order-functions/Common-Lisp/higher-order-functions.lisp @@ -0,0 +1,9 @@ +CL-USER> (defun add (a b) (+ a b)) +ADD +CL-USER> (add 1 2) +3 +CL-USER> (defun call-it (fn x y) + (funcall fn x y)) +CALL-IT +CL-USER> (call-it #'add 1 2) +3 diff --git a/Task/Higher-order-functions/D/higher-order-functions-1.d b/Task/Higher-order-functions/D/higher-order-functions-1.d new file mode 100644 index 0000000000..d44c545a5c --- /dev/null +++ b/Task/Higher-order-functions/D/higher-order-functions-1.d @@ -0,0 +1,9 @@ +int hof(int a, int b, int delegate(int, int) f) { + return f(a, b); +} + +void main() { + import std.stdio; + writeln("Add: ", hof(2, 3, (a, b) => a + b)); + writeln("Multiply: ", hof(2, 3, (a, b) => a * b)); +} diff --git a/Task/Higher-order-functions/D/higher-order-functions-2.d b/Task/Higher-order-functions/D/higher-order-functions-2.d new file mode 100644 index 0000000000..6c1106f0a2 --- /dev/null +++ b/Task/Higher-order-functions/D/higher-order-functions-2.d @@ -0,0 +1,61 @@ +import std.stdio; + +// Test the function argument. +string test(U)(string scopes, U func) { + string typeStr = typeid(typeof(func)).toString(); + + string isFunc = (typeStr[$ - 1] == '*') ? "function" : "delegate"; + writefln("Hi, %-13s : scope: %-8s (%s) : %s", + func(), scopes, isFunc, typeStr ); + return scopes; +} + +// Normal module level function. +string aFunction() { return "Function"; } + +// Implicit-Function-Template-Instantiation (IFTI) Function. +T tmpFunc(T)() { return "IFTI.function"; } + +// Member in a template. +template tmpGroup(T) { + T t0(){ return "Tmp.member.0"; } + T t1(){ return "Tmp.member.1"; } + T t2(){ return "Tmp.member.2"; } +} + +// Used for implementing member function at class & struct. +template Impl() { + static string aStatic() { return "Static Method"; } + string aMethod() { return "Method"; } +} + +class C { mixin Impl!(); } +struct S { mixin Impl!(); } + +void main() { + // Nested function. + string aNested() { + return "Nested"; + } + + // Bind to a variable. + auto variableF = function string() { return "variable.F"; }; + auto variableD = delegate string() { return "variable.D"; }; + + C c = new C; + S s; + + "Global".test(&aFunction); + "Nested".test(&aNested); + "Class".test(&C.aStatic) + .test(&c.aMethod); + "Struct".test(&S.aStatic) + .test(&s.aMethod); + "Template".test(&tmpFunc!(string)) + .test(&tmpGroup!(string).t2); + "Binding".test(variableF) + .test(variableD); + // Literal function/delegate. + "Literal".test(function string() { return "literal.F"; }) + .test(delegate string() { return "literal.D"; }); +} diff --git a/Task/Higher-order-functions/DWScript/higher-order-functions.dwscript b/Task/Higher-order-functions/DWScript/higher-order-functions.dwscript new file mode 100644 index 0000000000..4220ebed2d --- /dev/null +++ b/Task/Higher-order-functions/DWScript/higher-order-functions.dwscript @@ -0,0 +1,13 @@ +type TFnType = function(x : Float) : Float; + +function First(f : TFnType) : Float; +begin + Result := f(1) + 2; +end; + +function Second(f : Float) : Float; +begin + Result := f/2; +end; + +PrintLn(First(Second)); diff --git a/Task/Higher-order-functions/E/higher-order-functions.e b/Task/Higher-order-functions/E/higher-order-functions.e new file mode 100644 index 0000000000..0f655f4684 --- /dev/null +++ b/Task/Higher-order-functions/E/higher-order-functions.e @@ -0,0 +1,17 @@ +def map(f, list) { + var out := [] + for x in list { + out with= f(x) + } + return out +} + +? map(fn x { x + x }, [1, "two"]) +# value: [2, "twotwo"] + +? map(1.add, [5, 10, 20]) +# value: [6, 11, 21] + +? def foo(x) { return -(x.size()) } +> map(foo, ["", "a", "bc"]) +# value: [0, -1, -2] diff --git a/Task/Higher-order-functions/Efene/higher-order-functions.efene b/Task/Higher-order-functions/Efene/higher-order-functions.efene new file mode 100644 index 0000000000..ba9fa48bd2 --- /dev/null +++ b/Task/Higher-order-functions/Efene/higher-order-functions.efene @@ -0,0 +1,23 @@ +first = fn (F) { + F() +} + +second = fn () { + io.format("hello~n") +} + +@public +run = fn () { + # passing the function specifying the name and arity + # arity: the number of arguments it accepts + first(fn second:0) + + first(fn () { io.format("hello~n") }) + + # holding a reference to the function in a variable + F1 = fn second:0 + F2 = fn () { io.format("hello~n") } + + first(F1) + first(F2) +} diff --git a/Task/Higher-order-functions/Erlang/higher-order-functions-1.erl b/Task/Higher-order-functions/Erlang/higher-order-functions-1.erl new file mode 100644 index 0000000000..69feaf3fcc --- /dev/null +++ b/Task/Higher-order-functions/Erlang/higher-order-functions-1.erl @@ -0,0 +1,5 @@ +-module(test). +-export([first/1, second/0]). + +first(F) -> F(). +second() -> hello. diff --git a/Task/Higher-order-functions/Erlang/higher-order-functions-2.erl b/Task/Higher-order-functions/Erlang/higher-order-functions-2.erl new file mode 100644 index 0000000000..6df217b657 --- /dev/null +++ b/Task/Higher-order-functions/Erlang/higher-order-functions-2.erl @@ -0,0 +1,6 @@ +1> c(tests). +{ok, tests} +2> tests:first(fun tests:second/0). +hello +3> tests:first(fun() -> anonymous_function end). +anonymous_function diff --git a/Task/Higher-order-functions/Euler-Math-Toolbox/higher-order-functions.euler b/Task/Higher-order-functions/Euler-Math-Toolbox/higher-order-functions.euler new file mode 100644 index 0000000000..929f169290 --- /dev/null +++ b/Task/Higher-order-functions/Euler-Math-Toolbox/higher-order-functions.euler @@ -0,0 +1,5 @@ +>function f(x,a) := x^a-a^x +>function dof (f$:string,x) := f$(x,args()); +>dof("f",1:5;2) + [ -1 0 1 0 -7 ] +>plot2d("f",1,5;2): diff --git a/Task/Higher-order-functions/Euphoria/higher-order-functions.euphoria b/Task/Higher-order-functions/Euphoria/higher-order-functions.euphoria new file mode 100644 index 0000000000..f88b3fb30b --- /dev/null +++ b/Task/Higher-order-functions/Euphoria/higher-order-functions.euphoria @@ -0,0 +1,9 @@ +procedure use(integer fi, integer a, integer b) + print(1,call_func(fi,{a,b})) +end procedure + +function add(integer a, integer b) + return a + b +end function + +use(routine_id("add"),23,45) diff --git a/Task/Higher-order-functions/FALSE/higher-order-functions.false b/Task/Higher-order-functions/FALSE/higher-order-functions.false new file mode 100644 index 0000000000..78792e1da8 --- /dev/null +++ b/Task/Higher-order-functions/FALSE/higher-order-functions.false @@ -0,0 +1,5 @@ +[f:[$0>][@@\f;!\1-]#%]r: { reduce n stack items using the given basis and binary function } + +1 2 3 4 0 4[+]r;!." " { 10 } +1 2 3 4 1 4[*]r;!." " { 24 } +1 2 3 4 0 4[$*+]r;!. { 30 } diff --git a/Task/Higher-order-functions/Factor/higher-order-functions.factor b/Task/Higher-order-functions/Factor/higher-order-functions.factor new file mode 100644 index 0000000000..39503f1c14 --- /dev/null +++ b/Task/Higher-order-functions/Factor/higher-order-functions.factor @@ -0,0 +1,13 @@ +USING: io ; +IN: rosetacode +: argument-function1 ( -- ) "Hello World!" print ; +: argument-function2 ( -- ) "Goodbye World!" print ; + +! normal words have to know the stack effect of the input parameters they execute +: calling-function1 ( another-function -- ) execute( -- ) ; + +! unlike normal words, inline words do not have to know the stack effect. +: calling-function2 ( another-function -- ) execute ; inline + +! Stack effect has to be written for runtime computed values : +: calling-function3 ( bool -- ) \ argument-function1 \ argument-function2 ? execute( -- ) ; diff --git a/Task/Higher-order-functions/Fantom/higher-order-functions.fantom b/Task/Higher-order-functions/Fantom/higher-order-functions.fantom new file mode 100644 index 0000000000..864b853024 --- /dev/null +++ b/Task/Higher-order-functions/Fantom/higher-order-functions.fantom @@ -0,0 +1,14 @@ +class Main +{ + // apply given function to two arguments + static Int performOp (Int arg1, Int arg2, |Int, Int -> Int| fn) + { + fn (arg1, arg2) + } + + public static Void main () + { + echo (performOp (2, 5, |Int a, Int b -> Int| { a + b })) + echo (performOp (2, 5, |Int a, Int b -> Int| { a * b })) + } +} diff --git a/Task/Higher-order-functions/Forth/higher-order-functions.fth b/Task/Higher-order-functions/Forth/higher-order-functions.fth new file mode 100644 index 0000000000..7e4cf1f0a9 --- /dev/null +++ b/Task/Higher-order-functions/Forth/higher-order-functions.fth @@ -0,0 +1,9 @@ +: square dup * ; +: cube dup dup * * ; +: map. ( xt addr len -- ) + 0 do 2dup i cells + @ swap execute . loop 2drop ; + +create array 1 , 2 , 3 , 4 , 5 , +' square array 5 map. cr \ 1 4 9 16 25 +' cube array 5 map. cr \ 1 8 27 64 125 +:noname 2* 1+ ; array 5 map. cr \ 3 5 7 9 11 diff --git a/Task/Higher-order-functions/Fortran/higher-order-functions-1.f b/Task/Higher-order-functions/Fortran/higher-order-functions-1.f new file mode 100644 index 0000000000..e9b77afa4f --- /dev/null +++ b/Task/Higher-order-functions/Fortran/higher-order-functions-1.f @@ -0,0 +1,7 @@ +FUNCTION FUNC3(FUNC1, FUNC2, x, y) + REAL, EXTERNAL :: FUNC1, FUNC2 + REAL :: FUNC3 + REAL :: x, y + + FUNC3 = FUNC1(x) * FUNC2(y) +END FUNCTION FUNC3 diff --git a/Task/Higher-order-functions/Fortran/higher-order-functions-2.f b/Task/Higher-order-functions/Fortran/higher-order-functions-2.f new file mode 100644 index 0000000000..3239742dc6 --- /dev/null +++ b/Task/Higher-order-functions/Fortran/higher-order-functions-2.f @@ -0,0 +1,50 @@ +module FuncContainer + implicit none +contains + + function func1(x) + real :: func1 + real, intent(in) :: x + + func1 = x**2.0 + end function func1 + + function func2(x) + real :: func2 + real, intent(in) :: x + + func2 = x**2.05 + end function func2 + +end module FuncContainer + +program FuncArg + use FuncContainer + implicit none + + print *, "Func1" + call asubroutine(func1) + + print *, "Func2" + call asubroutine(func2) + +contains + + subroutine asubroutine(f) + ! the following interface is redundant: can be omitted + interface + function f(x) + real, intent(in) :: x + real :: f + end function f + end interface + real :: px + + px = 0.0 + do while( px < 10.0 ) + print *, px, f(px) + px = px + 1.0 + end do + end subroutine asubroutine + +end program FuncArg diff --git a/Task/Higher-order-functions/GAP/higher-order-functions.gap b/Task/Higher-order-functions/GAP/higher-order-functions.gap new file mode 100644 index 0000000000..d4b77ee658 --- /dev/null +++ b/Task/Higher-order-functions/GAP/higher-order-functions.gap @@ -0,0 +1,6 @@ +Eval := function(f, x) + return f(x); +end; + +Eval(x -> x^3, 7); +# 343 diff --git a/Task/Higher-order-functions/Go/higher-order-functions.go b/Task/Higher-order-functions/Go/higher-order-functions.go new file mode 100644 index 0000000000..5512ff9159 --- /dev/null +++ b/Task/Higher-order-functions/Go/higher-order-functions.go @@ -0,0 +1,6 @@ +package main +import "fmt" + +func func1(f func(string) string) string { return f("a string") } +func func2(s string) string { return "func2 called with " + s } +func main() { fmt.Println(func1(func2)) } diff --git a/Task/Higher-order-functions/Groovy/higher-order-functions-1.groovy b/Task/Higher-order-functions/Groovy/higher-order-functions-1.groovy new file mode 100644 index 0000000000..60bccf654e --- /dev/null +++ b/Task/Higher-order-functions/Groovy/higher-order-functions-1.groovy @@ -0,0 +1,4 @@ +first = { func -> func() } +second = { println "second" } + +first(second) diff --git a/Task/Higher-order-functions/Groovy/higher-order-functions-2.groovy b/Task/Higher-order-functions/Groovy/higher-order-functions-2.groovy new file mode 100644 index 0000000000..59d4a3820d --- /dev/null +++ b/Task/Higher-order-functions/Groovy/higher-order-functions-2.groovy @@ -0,0 +1,4 @@ +def first(func) { func() } +def second() { println "second" } + +first(this.&second) diff --git a/Task/Higher-order-functions/Haskell/higher-order-functions-1.hs b/Task/Higher-order-functions/Haskell/higher-order-functions-1.hs new file mode 100644 index 0000000000..769d93265d --- /dev/null +++ b/Task/Higher-order-functions/Haskell/higher-order-functions-1.hs @@ -0,0 +1,4 @@ +func1 f = f "a string" +func2 s = "func2 called with " ++ s + +main = putStrLn $ func1 func2 diff --git a/Task/Higher-order-functions/Haskell/higher-order-functions-2.hs b/Task/Higher-order-functions/Haskell/higher-order-functions-2.hs new file mode 100644 index 0000000000..a5e507752b --- /dev/null +++ b/Task/Higher-order-functions/Haskell/higher-order-functions-2.hs @@ -0,0 +1,4 @@ +func f = f 1 2 + +main = print $ func (\x y -> x+y) +-- output: 3 diff --git a/Task/Higher-order-functions/Icon/higher-order-functions.icon b/Task/Higher-order-functions/Icon/higher-order-functions.icon new file mode 100644 index 0000000000..1e30975da4 --- /dev/null +++ b/Task/Higher-order-functions/Icon/higher-order-functions.icon @@ -0,0 +1,13 @@ + procedure main() + local lst + lst := [10, 20, 30, 40] + myfun(callback, lst) +end + +procedure myfun(fun, lst) + every fun(!lst) +end + +procedure callback(arg) + write("->", arg) +end diff --git a/Task/Higher-order-functions/Inform-6/higher-order-functions.inf b/Task/Higher-order-functions/Inform-6/higher-order-functions.inf new file mode 100644 index 0000000000..6eae3ad476 --- /dev/null +++ b/Task/Higher-order-functions/Inform-6/higher-order-functions.inf @@ -0,0 +1,11 @@ +[ func; + print "Hello^"; +]; + +[ call_func x; + x(); +]; + +[ Main; + call_func(func); +]; diff --git a/Task/Higher-order-functions/Inform-7/higher-order-functions.inf b/Task/Higher-order-functions/Inform-7/higher-order-functions.inf new file mode 100644 index 0000000000..6a88492b7a --- /dev/null +++ b/Task/Higher-order-functions/Inform-7/higher-order-functions.inf @@ -0,0 +1,15 @@ +Higher Order Functions is a room. + +To decide which number is (N - number) added to (M - number) (this is addition): + decide on N + M. + +To decide which number is (N - number) multiplied by (M - number) (this is multiplication): + decide on N * M. + +To demonstrate (P - phrase (number, number) -> number) as (title - text): + say "[title]: [P applied to 12 and 34]." + +When play begins: + demonstrate addition as "Add"; + demonstrate multiplication as "Mul"; + end the story. diff --git a/Task/Higher-order-functions/J/higher-order-functions-1.j b/Task/Higher-order-functions/J/higher-order-functions-1.j new file mode 100644 index 0000000000..0795980450 --- /dev/null +++ b/Task/Higher-order-functions/J/higher-order-functions-1.j @@ -0,0 +1,23 @@ + + / 3 1 4 1 5 9 NB. sum +23 + >./ 3 1 4 1 5 9 NB. max +9 + *./ 3 1 4 1 5 9 NB. lcm +180 + + +/\ 3 1 4 1 5 9 NB. sum prefix (partial sums) +3 4 8 9 14 23 + + +/\. 3 1 4 1 5 9 NB. sum suffix +23 20 19 15 14 9 + + f=: -:@(+ 2&%) NB. one Newton iteration + f 1 +1.5 + f f 1 +1.41667 + + f^:(i.5) 1 NB. first 5 Newton iterations +1 1.5 1.41667 1.41422 1.41421 + f^:(i.5) 1x NB. rational approximations to sqrt 2 +1 3r2 17r12 577r408 665857r470832 diff --git a/Task/Higher-order-functions/J/higher-order-functions-2.j b/Task/Higher-order-functions/J/higher-order-functions-2.j new file mode 100644 index 0000000000..7bf3aa239c --- /dev/null +++ b/Task/Higher-order-functions/J/higher-order-functions-2.j @@ -0,0 +1,8 @@ + + conjunction def 'u' - ++ + + conjunction def 'v' - +- + * adverb def '10 u y' 11 +110 + ^ conjunction def '10 v 2 u y' * 11 +20480 diff --git a/Task/Higher-order-functions/Java/higher-order-functions.java b/Task/Higher-order-functions/Java/higher-order-functions.java new file mode 100644 index 0000000000..8008bef035 --- /dev/null +++ b/Task/Higher-order-functions/Java/higher-order-functions.java @@ -0,0 +1,26 @@ +public class NewClass { + + public NewClass() { + first(new AnEventOrCallback() { + public void call() { + second(); + } + }); + } + + public void first(AnEventOrCallback obj) { + obj.call(); + } + + public void second() { + System.out.println("Second"); + } + + public static void main(String[] args) { + new NewClass(); + } +} + +interface AnEventOrCallback { + public void call(); +} diff --git a/Task/Higher-order-functions/JavaScript/higher-order-functions-1.js b/Task/Higher-order-functions/JavaScript/higher-order-functions-1.js new file mode 100644 index 0000000000..41d50fd0e1 --- /dev/null +++ b/Task/Higher-order-functions/JavaScript/higher-order-functions-1.js @@ -0,0 +1,10 @@ +function first (func) { + return func(); +} + +function second () { + return "second"; +} + +var result = first(second); +result = first(function () { return "third"; }); diff --git a/Task/Higher-order-functions/JavaScript/higher-order-functions-2.js b/Task/Higher-order-functions/JavaScript/higher-order-functions-2.js new file mode 100644 index 0000000000..ca53b50242 --- /dev/null +++ b/Task/Higher-order-functions/JavaScript/higher-order-functions-2.js @@ -0,0 +1,27 @@ +>>> var array = [2, 4, 5, 13, 18, 24, 34, 97]; +>>> array +[2, 4, 5, 13, 18, 24, 34, 97] + +// return all elements less than 10 +>>> array.filter(function (x) { return x < 10 }); +[2, 4, 5] + +// return all elements less than 30 +>>> array.filter(function (x) { return x < 30 }); +[2, 4, 5, 13, 18, 24] + +// return all elements less than 100 +>>> array.filter(function (x) { return x < 100 }); +[2, 4, 5, 13, 18, 24, 34, 97] + +// multiply each element by 2 and return the new array +>>> array.map(function (x) { return x * 2 }); +[4, 8, 10, 26, 36, 48, 68, 194] + +// sort the array from smallest to largest +>>> array.sort(function (a, b) { return a > b }); +[2, 4, 5, 13, 18, 24, 34, 97] + +// sort the array from largest to smallest +>>> array.sort(function (a, b) { return a < b }); +[97, 34, 24, 18, 13, 5, 4, 2] diff --git a/Task/Higher-order-functions/Joy/higher-order-functions-1.joy b/Task/Higher-order-functions/Joy/higher-order-functions-1.joy new file mode 100644 index 0000000000..d2c06951af --- /dev/null +++ b/Task/Higher-order-functions/Joy/higher-order-functions-1.joy @@ -0,0 +1 @@ +DEFINE first == *. diff --git a/Task/Higher-order-functions/Joy/higher-order-functions-2.joy b/Task/Higher-order-functions/Joy/higher-order-functions-2.joy new file mode 100644 index 0000000000..74be87d8e0 --- /dev/null +++ b/Task/Higher-order-functions/Joy/higher-order-functions-2.joy @@ -0,0 +1 @@ +DEFINE second == i. diff --git a/Task/Higher-order-functions/Joy/higher-order-functions-3.joy b/Task/Higher-order-functions/Joy/higher-order-functions-3.joy new file mode 100644 index 0000000000..d81a141095 --- /dev/null +++ b/Task/Higher-order-functions/Joy/higher-order-functions-3.joy @@ -0,0 +1 @@ +2 3 [first] second. diff --git a/Task/Higher-order-functions/Logo/higher-order-functions.logo b/Task/Higher-order-functions/Logo/higher-order-functions.logo new file mode 100644 index 0000000000..7dca3df5eb --- /dev/null +++ b/Task/Higher-order-functions/Logo/higher-order-functions.logo @@ -0,0 +1,8 @@ +to printstuff + print "stuff +end +to runstuff :proc + run :proc +end +runstuff "printstuff ; stuff +runstuff [print [also stuff]] ; also stuff diff --git a/Task/Higher-order-functions/Lua/higher-order-functions.lua b/Task/Higher-order-functions/Lua/higher-order-functions.lua new file mode 100644 index 0000000000..6aaea3bd0a --- /dev/null +++ b/Task/Higher-order-functions/Lua/higher-order-functions.lua @@ -0,0 +1,3 @@ +a = function() return 1 end +b = function(r) print( r() ) end +b(a) diff --git a/Task/Higher-order-functions/MAXScript/higher-order-functions.max b/Task/Higher-order-functions/MAXScript/higher-order-functions.max new file mode 100644 index 0000000000..0163724b4e --- /dev/null +++ b/Task/Higher-order-functions/MAXScript/higher-order-functions.max @@ -0,0 +1,11 @@ +fn second = +( + print "Second" +) + +fn first func = +( + func() +) + +first second diff --git a/Task/Higher-order-functions/Mathematica/higher-order-functions-1.mathematica b/Task/Higher-order-functions/Mathematica/higher-order-functions-1.mathematica new file mode 100644 index 0000000000..516b96c50f --- /dev/null +++ b/Task/Higher-order-functions/Mathematica/higher-order-functions-1.mathematica @@ -0,0 +1,4 @@ +PassFunc[f_, g_, h_, x_] := f[g[x]*h[x]] +PassFunc[Tan, Cos, Sin, x] +% /. x -> 0.12 +PassFunc[Tan, Cos, Sin, 0.12] diff --git a/Task/Higher-order-functions/Mathematica/higher-order-functions-2.mathematica b/Task/Higher-order-functions/Mathematica/higher-order-functions-2.mathematica new file mode 100644 index 0000000000..47c9a26147 --- /dev/null +++ b/Task/Higher-order-functions/Mathematica/higher-order-functions-2.mathematica @@ -0,0 +1,3 @@ +Tan[Cos[x] Sin[x]] +0.119414 +0.119414 diff --git a/Task/Higher-order-functions/Maxima/higher-order-functions.maxima b/Task/Higher-order-functions/Maxima/higher-order-functions.maxima new file mode 100644 index 0000000000..db17bd606f --- /dev/null +++ b/Task/Higher-order-functions/Maxima/higher-order-functions.maxima @@ -0,0 +1,6 @@ +callee(n) := (print(sconcat("called with ", n)), n + 1)$ +caller(f, n) := sum(f(i), i, 1, n)$ +caller(callee, 3); +"called with 1" +"called with 2" +"called with 3" diff --git a/Task/Higher-order-functions/Metafont/higher-order-functions.metafont b/Task/Higher-order-functions/Metafont/higher-order-functions.metafont new file mode 100644 index 0000000000..53b793a17a --- /dev/null +++ b/Task/Higher-order-functions/Metafont/higher-order-functions.metafont @@ -0,0 +1,5 @@ +def calcit(expr v, s) = scantokens(s & decimal v) enddef; + +t := calcit(100.4, "sind"); +show t; +end diff --git a/Task/Higher-order-functions/Modula-3/higher-order-functions.mod3 b/Task/Higher-order-functions/Modula-3/higher-order-functions.mod3 new file mode 100644 index 0000000000..f9b7d9d924 --- /dev/null +++ b/Task/Higher-order-functions/Modula-3/higher-order-functions.mod3 @@ -0,0 +1,19 @@ +MODULE Proc EXPORTS Main; + +IMPORT IO; + +TYPE Proc = PROCEDURE(); + +PROCEDURE Second() = + BEGIN + IO.Put("Second procedure.\n"); + END Second; + +PROCEDURE First(proc: Proc) = + BEGIN + proc(); + END First; + +BEGIN + First(Second); +END Proc. diff --git a/Task/Higher-order-functions/PHP/higher-order-functions-1.php b/Task/Higher-order-functions/PHP/higher-order-functions-1.php new file mode 100644 index 0000000000..21a7d94308 --- /dev/null +++ b/Task/Higher-order-functions/PHP/higher-order-functions-1.php @@ -0,0 +1,9 @@ +function first($func) { + return $func(); +} + +function second() { + return 'second'; +} + +$result = first('second'); diff --git a/Task/Higher-order-functions/PHP/higher-order-functions-2.php b/Task/Higher-order-functions/PHP/higher-order-functions-2.php new file mode 100644 index 0000000000..eb6393a4e4 --- /dev/null +++ b/Task/Higher-order-functions/PHP/higher-order-functions-2.php @@ -0,0 +1,5 @@ +function first($func) { + return $func(); +} + +$result = first(function() { return 'second'; }); diff --git a/Task/Higher-order-functions/Perl/higher-order-functions-1.pl b/Task/Higher-order-functions/Perl/higher-order-functions-1.pl new file mode 100644 index 0000000000..8b90909d69 --- /dev/null +++ b/Task/Higher-order-functions/Perl/higher-order-functions-1.pl @@ -0,0 +1,27 @@ +sub another { + # take a function and a value + my $func = shift; + my $val = shift; + + # call the function with the value as argument + return $func->($val); +}; + +sub reverser { + return scalar reverse shift; +}; + +# pass named coderef +print another \&reverser, 'data'; +# pass anonymous coderef +print another sub {return scalar reverse shift}, 'data'; + +# if all you have is a string and you want to act on that, +# set up a dispatch table +my %dispatch = ( + square => sub {return shift() ** 2}, + cube => sub {return shift() ** 3}, + rev => \&reverser, +); + +print another $dispatch{$_}, 123 for qw(square cube rev); diff --git a/Task/Higher-order-functions/Perl/higher-order-functions-2.pl b/Task/Higher-order-functions/Perl/higher-order-functions-2.pl new file mode 100644 index 0000000000..f13f84f728 --- /dev/null +++ b/Task/Higher-order-functions/Perl/higher-order-functions-2.pl @@ -0,0 +1,8 @@ +sub apply (&@) { # use & as the first item in a prototype to take bare blocks like map and grep + my ($sub, @ret) = @_; # this function applies a function that is expected to modify $_ to a list + $sub->() for @ret; # it allows for simple inline application of the s/// and tr/// constructs + @ret +} + +print join ", " => apply {tr/aeiou/AEIOU/} qw/one two three four/; +# OnE, twO, thrEE, fOUr diff --git a/Task/Higher-order-functions/Perl/higher-order-functions-3.pl b/Task/Higher-order-functions/Perl/higher-order-functions-3.pl new file mode 100644 index 0000000000..b570c19627 --- /dev/null +++ b/Task/Higher-order-functions/Perl/higher-order-functions-3.pl @@ -0,0 +1,7 @@ +sub first {shift->()} + +sub second {'second'} + +print first \&second; + +print first sub{'sub'}; diff --git a/Task/Higher-order-functions/PicoLisp/higher-order-functions.l b/Task/Higher-order-functions/PicoLisp/higher-order-functions.l new file mode 100644 index 0000000000..bc424ca17c --- /dev/null +++ b/Task/Higher-order-functions/PicoLisp/higher-order-functions.l @@ -0,0 +1,33 @@ +: (de first (Fun) + (Fun) ) +-> first + +: (de second () + "second" ) +-> second + +: (first second) +-> "second" + +: (de add (A B) + (+ A B) ) +-> add + +: (add 1 2) +-> 3 + +: (de call-it (Fun X Y) + (Fun X Y) ) +-> call-it + +: (call-it add 1 2) +-> 3 + +: (mapcar inc (1 2 3 4 5)) +-> (2 3 4 5 6) + +: (mapcar + (1 2 3) (4 5 6)) +-> (5 7 9) + +: (mapcar add (1 2 3) (4 5 6)) +-> (5 7 9) diff --git a/Task/Higher-order-functions/Prolog/higher-order-functions.pro b/Task/Higher-order-functions/Prolog/higher-order-functions.pro new file mode 100644 index 0000000000..9fc00c925c --- /dev/null +++ b/Task/Higher-order-functions/Prolog/higher-order-functions.pro @@ -0,0 +1,4 @@ +first(Predicate):-Predicate. +second(Argument):-print(Argument). + +:-first(second('Hello World!')). diff --git a/Task/Higher-order-functions/Python/higher-order-functions-1.py b/Task/Higher-order-functions/Python/higher-order-functions-1.py new file mode 100644 index 0000000000..dfbf0c2a74 --- /dev/null +++ b/Task/Higher-order-functions/Python/higher-order-functions-1.py @@ -0,0 +1,7 @@ +def first(function): + return function() + +def second(): + return "second" + +result = first(second) diff --git a/Task/Higher-order-functions/Python/higher-order-functions-2.py b/Task/Higher-order-functions/Python/higher-order-functions-2.py new file mode 100644 index 0000000000..7ca2924773 --- /dev/null +++ b/Task/Higher-order-functions/Python/higher-order-functions-2.py @@ -0,0 +1 @@ + result = first(lambda: "second") diff --git a/Task/Higher-order-functions/R/higher-order-functions.r b/Task/Higher-order-functions/R/higher-order-functions.r new file mode 100644 index 0000000000..7b10b25d38 --- /dev/null +++ b/Task/Higher-order-functions/R/higher-order-functions.r @@ -0,0 +1,6 @@ +f <- function(f0) f0(pi) # calc. the function in pi +tf <- function(x) x^pi # a func. just to test + +print(f(sin)) +print(f(cos)) +print(f(tf)) diff --git a/Task/Higher-order-functions/REXX/higher-order-functions.rexx b/Task/Higher-order-functions/REXX/higher-order-functions.rexx new file mode 100644 index 0000000000..8778be49bf --- /dev/null +++ b/Task/Higher-order-functions/REXX/higher-order-functions.rexx @@ -0,0 +1,21 @@ +/*REXX program demonstrates passing a function as a name to a function.*/ +n=3735928559 +funcName='fib' ; q= 10; call someFunk funcName, q; call tell +funcName='fact' ; q= 6; call someFunk funcName, q; call tell +funcName='square' ; q= 13; call someFunk funcName, q; call tell +funcName='cube' ; q= 3; call someFunk funcName, q; call tell + q=721; call someFunk 'reverse',q; call tell +say copies('─',30) /*display a nice separator fence.*/ +say 'done as' d2x(n)"." /*prove that var N still intact. */ +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────subroutines─────────────────────────*/ +cube: return n**3 +fact: !=1; do j=2 to n; !=!*j; end; return ! +reverse: return 'REVERSE'(n) +someFunk: procedure; arg ?,n; signal value (?); say result 'result'; return +square: return n**2 +tell: say right(funcName'('q") = ",20) result; return + +fib: if n==0 | n==1 then return n; _=0; a=0; b=1 + do j=2 to n; _=a+b; a=b; b=_; end; return _ diff --git a/Task/Higher-order-functions/Racket/higher-order-functions.rkt b/Task/Higher-order-functions/Racket/higher-order-functions.rkt new file mode 100644 index 0000000000..1bd6755bcb --- /dev/null +++ b/Task/Higher-order-functions/Racket/higher-order-functions.rkt @@ -0,0 +1,4 @@ + #lang racket/base + (define (add f g x) + (+ (f x) (g x))) + (add sin cos 10) diff --git a/Task/Higher-order-functions/Ruby/higher-order-functions-1.rb b/Task/Higher-order-functions/Ruby/higher-order-functions-1.rb new file mode 100644 index 0000000000..5da499ab25 --- /dev/null +++ b/Task/Higher-order-functions/Ruby/higher-order-functions-1.rb @@ -0,0 +1,7 @@ +succ = proc{|x| x+1} +def to2(&f) + f[2] +end + +to2(&succ) #=> 3 +to2{|x| x+1} #=> 3 diff --git a/Task/Higher-order-functions/Ruby/higher-order-functions-2.rb b/Task/Higher-order-functions/Ruby/higher-order-functions-2.rb new file mode 100644 index 0000000000..2bc571209b --- /dev/null +++ b/Task/Higher-order-functions/Ruby/higher-order-functions-2.rb @@ -0,0 +1,9 @@ +def succ(n) + n+1 +end +def to2(m) + m[2] +end + +meth = method(:succ) +to2(meth) #=> 3 diff --git a/Task/Higher-order-functions/Scala/higher-order-functions-1.scala b/Task/Higher-order-functions/Scala/higher-order-functions-1.scala new file mode 100644 index 0000000000..92bcec5737 --- /dev/null +++ b/Task/Higher-order-functions/Scala/higher-order-functions-1.scala @@ -0,0 +1 @@ +def functionWithAFunctionArgument(x : int, y : int, f : (int, int) => int) = f(x,y) diff --git a/Task/Higher-order-functions/Scala/higher-order-functions-2.scala b/Task/Higher-order-functions/Scala/higher-order-functions-2.scala new file mode 100644 index 0000000000..28a456a1f9 --- /dev/null +++ b/Task/Higher-order-functions/Scala/higher-order-functions-2.scala @@ -0,0 +1 @@ +functionWithAFunctionArgument(3, 5, {(x, y) => x + y}) // returns 8 diff --git a/Task/Higher-order-functions/Scheme/higher-order-functions-1.ss b/Task/Higher-order-functions/Scheme/higher-order-functions-1.ss new file mode 100644 index 0000000000..a1eef5f207 --- /dev/null +++ b/Task/Higher-order-functions/Scheme/higher-order-functions-1.ss @@ -0,0 +1,4 @@ +> (define (func1 f) (f "a string")) +> (define (func2 s) (string-append "func2 called with " s)) +> (begin (display (func1 func2)) (newline)) +func2 called with a string diff --git a/Task/Higher-order-functions/Scheme/higher-order-functions-2.ss b/Task/Higher-order-functions/Scheme/higher-order-functions-2.ss new file mode 100644 index 0000000000..6f235e26a3 --- /dev/null +++ b/Task/Higher-order-functions/Scheme/higher-order-functions-2.ss @@ -0,0 +1,3 @@ +> (define (func f) (f 1 2)) +> (begin (display (func (lambda (x y) (+ x y)))) (newline)) +3 diff --git a/Task/Higher-order-functions/Smalltalk/higher-order-functions-1.st b/Task/Higher-order-functions/Smalltalk/higher-order-functions-1.st new file mode 100644 index 0000000000..174c29f915 --- /dev/null +++ b/Task/Higher-order-functions/Smalltalk/higher-order-functions-1.st @@ -0,0 +1,3 @@ +first := [ :f | f value ]. +second := [ 'second' ]. +Transcript show: (first value: second). diff --git a/Task/Higher-order-functions/Smalltalk/higher-order-functions-2.st b/Task/Higher-order-functions/Smalltalk/higher-order-functions-2.st new file mode 100644 index 0000000000..65cae03479 --- /dev/null +++ b/Task/Higher-order-functions/Smalltalk/higher-order-functions-2.st @@ -0,0 +1,2 @@ +function := [:x | x * 3 - 1]. +#(1 1 2 3 5 8) collect: function. diff --git a/Task/Higher-order-functions/Tcl/higher-order-functions-1.tcl b/Task/Higher-order-functions/Tcl/higher-order-functions-1.tcl new file mode 100644 index 0000000000..f3986598c3 --- /dev/null +++ b/Task/Higher-order-functions/Tcl/higher-order-functions-1.tcl @@ -0,0 +1,6 @@ +# this procedure executes its argument: +proc demo {function} { + $function +} +# for example: +demo bell diff --git a/Task/Higher-order-functions/Tcl/higher-order-functions-2.tcl b/Task/Higher-order-functions/Tcl/higher-order-functions-2.tcl new file mode 100644 index 0000000000..270252a8af --- /dev/null +++ b/Task/Higher-order-functions/Tcl/higher-order-functions-2.tcl @@ -0,0 +1,19 @@ +# This procedure executes its argument with an extra argument of "2" +proc demoFrag {fragment} { + {*}$fragment 2 +} +# This procedure executes its argument in the context of its caller, which is +# useful for scripts so they get the right variable resolution context +proc demoScript {script} { + uplevel 1 $script +} + +# Examples... +set chan stderr +demoFrag [list puts $chan] +demoFrag { + apply {x {puts [string repeat ? $x]}} +} +demoScript { + parray tcl_platform +} diff --git a/Task/History-variables/0DESCRIPTION b/Task/History-variables/0DESCRIPTION new file mode 100644 index 0000000000..8b3ff2f31d --- /dev/null +++ b/Task/History-variables/0DESCRIPTION @@ -0,0 +1,18 @@ +''Storing the history of objects in a program is a common task. Maintaining the history of an object in a program has traditionally required programmers either to write specific code for handling the historical data, or to use a library which supports history logging.'' + +''History variables are variables in a programming language which store not only their current value, but also the values they have contained in the past. Some existing languages do provide support for history variables. However these languages typically have many limits and restrictions on use of history variables. +'' + +[http://www.bod.com/index.php?id=3435&objk_id=148050 "History Variables: The Semantics, Formal Correctness, and Implementation of History Variables in an Imperative Programming Language" by Mallon and Takaoka] + +Concept also discussed on [http://lambda-the-ultimate.org/node/3111 LtU] and [http://www.patents.com/us-7111283.html Patents.com]. + +;Task: +Demonstrate History variable support: +* enable history variable support (if needed) +* define a history variable +* assign three values +* non-destructively display the history +* recall the three values. + +For extra points, if the language of choice does not support history variables, demonstrate how this might be implemented. diff --git a/Task/History-variables/Ada/history-variables-1.ada b/Task/History-variables/Ada/history-variables-1.ada new file mode 100644 index 0000000000..a0b26a73a9 --- /dev/null +++ b/Task/History-variables/Ada/history-variables-1.ada @@ -0,0 +1,34 @@ +private with Ada.Containers.Indefinite_Vectors; +generic + type Item_Type (<>) is private; +package History_Variables is + + type Variable is tagged limited private; + + -- set and get current value + procedure Set(V: in out Variable; Item: Item_Type); + function Get(V: Variable) return Item_Type; + + -- number of items in history (including the current one) + function Defined(V: Variable) return Natural; + + -- non-destructively search for old values + function Peek(V: Variable; Generation: Natural := 1) return Item_Type; + -- V.Peek(0) returns current value; V.Peek(1) the previous value, ect. + -- when calling V.Peek(i), i must be in 0 .. V.Defined-1, else Constraint_Error is raised + + -- destructively restore previous value + procedure Undo(V: in out Variable); + -- old V.Peek(0) is forgotten, old V.Peek(i) is new V.Peek(i-1), ect. + -- accordingly, V.Defined decrements by 1 + -- special case: if V.Defined=0 then V.Undo does not change V + +private + package Vectors is new Ada.Containers.Indefinite_Vectors + (Index_Type => Positive, + Element_Type => Item_Type); + + type Variable is tagged limited record + History: Vectors.Vector; + end record; +end History_Variables; diff --git a/Task/History-variables/Ada/history-variables-2.ada b/Task/History-variables/Ada/history-variables-2.ada new file mode 100644 index 0000000000..9fe008eebd --- /dev/null +++ b/Task/History-variables/Ada/history-variables-2.ada @@ -0,0 +1,35 @@ +package body History_Variables is + + -- set and get + procedure Set(V: in out Variable; Item: Item_Type) is + begin + V.History.Prepend(Item); + end Set; + + function Get(V: Variable) return Item_Type is + begin + return V.History.First_Element; + end Get; + + -- number of items in history (including the current one) + function Defined(V: Variable) return Natural is + begin + return (1 + V.History.Last_Index) - V.History.First_Index; + end Defined; + + -- non-destructively search + function Peek(V: Variable; Generation: Natural := 1) return Item_Type is + Index: Positive := V.History.First_Index + Generation; + begin + if Index > V.History.Last_Index then + raise Constraint_Error; + end if; + return V.History.Element(Index); + end Peek; + + procedure Undo(V: in out Variable) is + begin + V.History.Delete_First; + end Undo; + +end History_Variables; diff --git a/Task/History-variables/Ada/history-variables-3.ada b/Task/History-variables/Ada/history-variables-3.ada new file mode 100644 index 0000000000..c60691ae4c --- /dev/null +++ b/Task/History-variables/Ada/history-variables-3.ada @@ -0,0 +1,32 @@ +with Ada.Text_IO, History_Variables; + +procedure Test_History is + + package Int_With_Hist is new History_Variables(Integer); + + -- define a history variable + I: Int_With_Hist.Variable; + + Sum: Integer := 0; + +begin + + -- assign three values + I.Set(3); + I.Set(I.Get + 4); + I.Set(9); + + -- non-destructively display the history + for N in reverse 0 .. I.Defined-1 loop + Ada.Text_IO.Put(Integer'Image(I.Peek(N))); + end loop; + Ada.Text_IO.New_Line; + + -- recall the three values + while I.Defined > 0 loop + Sum := Sum + I.Get; + I.Undo; + end loop; + Ada.Text_IO.Put_Line(Integer'Image(Sum)); + +end Test_History; diff --git a/Task/History-variables/Ada/history-variables-4.ada b/Task/History-variables/Ada/history-variables-4.ada new file mode 100644 index 0000000000..d7bc8632ed --- /dev/null +++ b/Task/History-variables/Ada/history-variables-4.ada @@ -0,0 +1,32 @@ +with Ada.Text_IO, History_Variables; + +procedure Test_History is + + package Str_With_Hist is new History_Variables(String); + + -- define a history variable + S: Str_With_Hist.Variable; + + Sum: Integer := 0; + +begin + + -- assign three values + S.Set("one"); + S.Set(S.Get & S.Get); --"oneone" + S.Set("three"); + + -- non-destructively display the history + for N in reverse 0 .. S.Defined-1 loop + Ada.Text_IO.Put(S.Peek(Generation => N) &" "); + end loop; + Ada.Text_IO.New_Line; + + -- recall the three values + while S.Defined > 0 loop + Sum := Sum + S.Get'Length; + S.Undo; + end loop; + Ada.Text_IO.Put_Line(Integer'Image(Sum)); + +end Test_History; diff --git a/Task/History-variables/C-sharp/history-variables.cs b/Task/History-variables/C-sharp/history-variables.cs new file mode 100644 index 0000000000..6e63dc9107 --- /dev/null +++ b/Task/History-variables/C-sharp/history-variables.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace History +{ + class Program + { + static void Main(string[] args) + { + var h = new HistoryObject(); + h.Value = 5; + h.Value = "foo"; + h.Value += "bar"; + + var history = h.ToArray(); + + for (int i = 0; i < history.Length; i++) + { + Console.Write("{0}{1}", history[i], ((i >= history.Length - 1) ? "\n" : " <- ")); + } + + h.Undo(); + h.Undo(); + h.Undo(); + + Console.WriteLine(h.Value); + } + + private class HistoryObject : IEnumerable + { + public HistoryObject() + { + _history = new Stack(); // Initiates the history stack. + } + + public object Value + { + get // Returns the top value from the history if there is one. Otherwise null. + { + if (_history.Count > 0) + return _history.Peek(); + return null; + } + set { _history.Push(value); } // Adds the specified value to the history. + } + + public void Undo() + { + if (_history.Count > 0) + _history.Pop(); // Removes the current value from the history. + } + + // History stack that will hold all previous values of the object. + private readonly Stack _history; + + public IEnumerator GetEnumerator() + { + return _history.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } + } +} diff --git a/Task/History-variables/D/history-variables.d b/Task/History-variables/D/history-variables.d new file mode 100644 index 0000000000..9457e7424b --- /dev/null +++ b/Task/History-variables/D/history-variables.d @@ -0,0 +1,63 @@ +import std.stdio, std.array, std.string, std.datetime, std.traits; + +/// A history variable. +struct HistoryVariable(T) { + /// A value in a point in time. + static struct HistoryValue { + SysTime time; + T value; + + // Alternative to the more common toString. + //void toString(scope void delegate(string) output) const { + void toString(scope void delegate(const(char)[]) output)const { + output(format("%s; %s", time, value)); + } + } + + const(HistoryValue)[] values; + + private void addValue(T value) { + values ~= HistoryValue(Clock.currTime(), value); + } + + void opAssign(T value) { + addValue(value); + } + + @property T currentValue() const pure nothrow { + return values.back.value; + } + + alias currentValue this; + + @property auto history() const pure nothrow { + return values; + } + + /** + Demonstrating D's compile-time reflection features. The member + functions that are in this 'static if' block would be added for + types T that are arrays (including strings). */ + static if (isArray!T) { + // Append-with-assign operator. + void opOpAssign(string op : "~")(T element) { + addValue(currentValue ~ element); + } + + // Similar implementation for other array operators... + } +} + +void main() { + HistoryVariable!int x; + x = 1; + x = 2; + x = 3; + writefln("%(%s\n%)\n", x.history); + + HistoryVariable!string s; + s = "hello"; + s ~= " world"; + s = "goodby"; + writefln("%(%s\n%)", s.history); +} diff --git a/Task/History-variables/Go/history-variables.go b/Task/History-variables/Go/history-variables.go new file mode 100644 index 0000000000..e288e7e36d --- /dev/null +++ b/Task/History-variables/Go/history-variables.go @@ -0,0 +1,113 @@ +package main + +import ( + "fmt" + "sort" + "sync" + "time" +) + +// data type for history variable (its an int) +type history struct { + timestamp tsFunc + hs []hset +} + +// data type for timestamp generator +type tsFunc func() time.Time + +// data type for a "set" event +type hset struct { + int // new value + t time.Time // timestamp +} + +// newHistory creates a history variable +func newHistory(ts tsFunc) history { + return history{ts, []hset{{t: ts()}}} +} + +// int returns the current value +func (h history) int() int { + return h.hs[len(h.hs)-1].int +} + +// set does what you expect and returns the timestamp recorded for the event +func (h *history) set(x int) time.Time { + t := h.timestamp() + h.hs = append(h.hs, hset{x, t}) + return t +} + +// dump displays a complete history +func (h history) dump() { + for _, hs := range h.hs { + fmt.Println(hs.t.Format(time.StampNano), hs.int) + } +} + +// recall recalls the value stored in the history variable at time t. +// if the variable had not been created yet, ok is false. +func (h history) recall(t time.Time) (int, /*ok*/ bool) { + i := sort.Search(len(h.hs), func(i int) bool { + return h.hs[i].t.After(t) + }) + if i > 0 { + return h.hs[i-1].int, true + } + return 0, false +} + +// newTimestamper returns a function that generates unique timestamps. +// Use a single timestamper for multiple history variables to preserve +// an unambiguous sequence of assignments across the multiple history +// variables within a single goroutine. +func newTimestamper() tsFunc { + var last time.Time + return func() time.Time { + if t := time.Now(); t.After(last) { + last = t + } else { + last.Add(1) + } + return last + } +} + +// newProtectedTimestamper generates unique timestamps for concurrent +// goroutines. +func newProtectedTimestamper() tsFunc { + var last time.Time + var m sync.Mutex + return func() (t time.Time) { + t = time.Now() + m.Lock() // m protects last + if t.After(last) { + last = t + } else { + last.Add(1) + t = last + } + m.Unlock() + return + } +} + +func main() { + // enable history variable support appropriate for single goroutine. + ts := newTimestamper() + // define a history variable + h := newHistory(ts) + // assign three values. (timestamps kept for future reference.) + ref := []time.Time{h.set(3), h.set(1), h.set(4)} + // non-destructively display history + fmt.Println("History of variable h:") + h.dump() + // recall the three values. (this is non-destructive as well, but + // different than the dump in that values are recalled by time.) + fmt.Println("Recalling values:") + for _, t := range ref { + rv, _ := h.recall(t) + fmt.Println(rv) + } +} diff --git a/Task/History-variables/Haskell/history-variables.hs b/Task/History-variables/Haskell/history-variables.hs new file mode 100644 index 0000000000..9d789143d4 --- /dev/null +++ b/Task/History-variables/Haskell/history-variables.hs @@ -0,0 +1,32 @@ +import Data.IORef + +newtype HVar a = HVar (IORef [a]) + +newHVar :: a -> IO (HVar a) +newHVar value = fmap HVar (newIORef [value]) + +readHVar :: HVar a -> IO a +readHVar (HVar ref) = fmap head (readIORef ref) + +writeHVar :: a -> HVar a -> IO () +writeHVar value (HVar ref) = modifyIORef ref (value:) + +undoHVar :: HVar a -> IO () +undoHVar (HVar ref) = do + (_ : history) <- readIORef ref + writeIORef ref history + +getHistory :: HVar a -> IO [a] +getHistory (HVar ref) = readIORef ref + +-- Testing +main :: IO () +main = do + var <- newHVar 0 + writeHVar 1 var + writeHVar 2 var + writeHVar 3 var + getHistory var >>= print + undoHVar var + undoHVar var + undoHVar var diff --git a/Task/History-variables/J/history-variables-1.j b/Task/History-variables/J/history-variables-1.j new file mode 100644 index 0000000000..87b61102ec --- /dev/null +++ b/Task/History-variables/J/history-variables-1.j @@ -0,0 +1,12 @@ +varref_hist_=:'VAR','_hist_',~] +set_hist_=:4 :0 + V=.varref x + if.0>nc[-1] +} + +sub STORE { + my ($var, $val) = @_; + push @$var, $val; + return $val; +} + +sub get(\$) { @{tied ${+shift}} } +sub on(\$) { tie ${+shift}, __PACKAGE__ } +sub off(\$) { untie ${+shift} } +sub undo(\$) { pop @{tied ${+shift}} } + +package main; + +my $x = 0; +History::on($x); + +for ("a" .. "d") { $x = $_ } + +print "History: @{[History::get($x)]}\n"; + +for (1 .. 3) { + print "undo $_, "; + History::undo($x); + print "current value: $x\n"; +} + +History::off($x); +print "\$x is: $x\n"; diff --git a/Task/History-variables/Perl/history-variables-2.pl b/Task/History-variables/Perl/history-variables-2.pl new file mode 100644 index 0000000000..9166dead92 --- /dev/null +++ b/Task/History-variables/Perl/history-variables-2.pl @@ -0,0 +1,5 @@ +History: a b c d +undo 1, current value: c +undo 2, current value: b +undo 3, current value: a +$x is: a diff --git a/Task/History-variables/PicoLisp/history-variables.l b/Task/History-variables/PicoLisp/history-variables.l new file mode 100644 index 0000000000..e7a3100333 --- /dev/null +++ b/Task/History-variables/PicoLisp/history-variables.l @@ -0,0 +1,8 @@ +(de setH ("Var" Val) + (when (val "Var") + (with "Var" + (=: history (cons @ (: history))) ) ) + (set "Var" Val) ) + +(de restoreH ("Var") + (set "Var" (pop (prop "Var" 'history))) ) diff --git a/Task/History-variables/Python/history-variables-1.py b/Task/History-variables/Python/history-variables-1.py new file mode 100644 index 0000000000..1174f60e9c --- /dev/null +++ b/Task/History-variables/Python/history-variables-1.py @@ -0,0 +1,34 @@ +import sys + +HIST = {} + +def trace(frame, event, arg): + for name,val in frame.f_locals.items(): + if name not in HIST: + HIST[name] = [] + else: + if HIST[name][-1] is val: + continue + HIST[name].append(val) + return trace + +def undo(name): + HIST[name].pop(-1) + return HIST[name][-1] + +def main(): + a = 10 + a = 20 + + for i in range(5): + c = i + + print "c:", c, "-> undo x3 ->", + c = undo('c') + c = undo('c') + c = undo('c') + print c + print 'HIST:', HIST + +sys.settrace(trace) +main() diff --git a/Task/History-variables/Python/history-variables-2.py b/Task/History-variables/Python/history-variables-2.py new file mode 100644 index 0000000000..e048ffbfa0 --- /dev/null +++ b/Task/History-variables/Python/history-variables-2.py @@ -0,0 +1,2 @@ +c: 4 -> undo x3 -> 1 +HIST: {'a': [10, 20], 'i': [0, 1, 2, 3, 4], 'c': [0, 1], 'name': ['c']} diff --git a/Task/History-variables/REXX/history-variables-1.rexx b/Task/History-variables/REXX/history-variables-1.rexx new file mode 100644 index 0000000000..4dc32bb869 --- /dev/null +++ b/Task/History-variables/REXX/history-variables-1.rexx @@ -0,0 +1,22 @@ +/*REXX pgm shows a method to track history of assignments to a REXX var.*/ +varset!.=0 /*initialize the whole shebang. */ +call varset 'fluid',min(0,-5/2,-1) ; say 'fluid=' fluid +call varset 'fluid',3.14159 ; say 'fluid=' fluid +call varset 'fluid',' Santa Claus' ; say 'fluid=' fluid +call varset 'fluid',,999 +say 'There were' result "assignments (sets) for the FLUID variable." +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────VARSET subroutine────────────────*/ +varset: arg ?x; parse arg ?z, ?v, ?L /*varName, value, optional-List. */ +if ?L=='' then do /*not list, so set the X variable*/ + ?_=varset!.0.?x+1 /*bump the history count (SETs). */ + varset!.0.?x=?_ /* ... and store it in "database"*/ + varset!.?_.?x=?v /* ... and store the SET value.*/ + call value(?x),?v /*now, set the real X variable.*/ + return ?v /*also, return the value for FUNC*/ + end +say /*show blank line for readability*/ + do ?j=1 to ?L while ?j<=varset!.0.?x /*list "set" history.*/ + say 'history entry' ?j "for var" ?z":" varset!.?J.?x + end /*?j*/ +return ?j-1 /*return the num of assignments. */ diff --git a/Task/History-variables/REXX/history-variables-2.rexx b/Task/History-variables/REXX/history-variables-2.rexx new file mode 100644 index 0000000000..54f8d785f0 --- /dev/null +++ b/Task/History-variables/REXX/history-variables-2.rexx @@ -0,0 +1,40 @@ +/* REXX *************************************************************** +* Demonstrate how the history of assignments can be kept and shown +* 13.07.2012 Walter Pachl Rewrite of Version 1 for (my) readability +* varset.i.varu contains the ith value assigned to var +* varset.0.varu contains the number of assignments so far +**********************************************************************/ +varset.=0 /*initialize the assignment count */ + +call varset 'fluid',min(0,-5/2,-1) ; say 'fluid=' fluid +call varset 'fluid',3.14159 ; say 'fluid=' fluid +call varset 'fluid',3.14159 ; say 'fluid=' fluid +call varset 'fluid',' Santa Claus' ; say 'fluid=' fluid +call varset 'FLUID',' Easter Rabbit' ; say 'fluid=' fluid + +say 'There were' varset('fluid',,'L'), + 'assignments (sets) for the FLUID variable.' +exit + +varset: Procedure Expose varset. +/********************************************************************** +* record values assigned to var (=varu as Rexx is case insensitive) +* Invoke with list<>'' to list the sequence of assigned values +* and return the number of assignments made (using this routine) +**********************************************************************/ + Parse Upper Arg varu /* name of variable in uppercase */ + Parse arg var,value,list /*varName, value, optional-List. */ + + if list='' then do /*not list, so set the X variable*/ + z=varset.0.varu+1 /*bump the history count (SETs). */ + varset.z.varu=value /* ... and store it in "database"*/ + varset.0.varu=z /*the new history count */ + call value var,value /*now assign the value to var */ + end + else Do + Say '' /*show blank line for readability*/ + do i=1 to varset.0.varu /*list the assignment history */ + say 'history entry' i "for var" var":" varset.i.varu + end + end + Return varset.0.varu /*return the number of assignments. */ diff --git a/Task/History-variables/Racket/history-variables.rkt b/Task/History-variables/Racket/history-variables.rkt new file mode 100644 index 0000000000..0382b08b8a --- /dev/null +++ b/Task/History-variables/Racket/history-variables.rkt @@ -0,0 +1,29 @@ +#lang racket + +(require rackunit) + +(struct hvar (current history) #:mutable) + +(define (make-hvar v) (hvar v empty)) + +(define (hvar-set! hv new) + (match-define (hvar cur hist) hv) + (set-hvar-history! hv (cons cur hist)) + (set-hvar-current! hv new)) + +(define (hvar-undo! hv) + (match-define (hvar cur (cons old hist)) hv) + (set-hvar-current! hv old) + (set-hvar-history! hv hist)) + +;; unit tests +(define hv (make-hvar 0)) +(hvar-set! hv 1) +(check-equal? (hvar-current hv) 1) +(hvar-set! hv 2) +(hvar-set! hv 3) +(check-equal? (hvar-history hv) '(2 1 0)) +(hvar-undo! hv) +(hvar-undo! hv) +(hvar-undo! hv) +(check-equal? (hvar-current hv) 0) diff --git a/Task/History-variables/Scala/history-variables-1.scala b/Task/History-variables/Scala/history-variables-1.scala new file mode 100644 index 0000000000..4cdfb76b38 --- /dev/null +++ b/Task/History-variables/Scala/history-variables-1.scala @@ -0,0 +1,20 @@ +class HVar[A](initialValue: A) extends Proxy { + override def self = !this + override def toString = "HVar(" + !this + ")" + + def history = _history + + private var _history = List(initialValue) + def unary_! = _history.head + def :=(newValue: A): Unit = { + _history = newValue :: _history + } + def modify(f: A => A): Unit = { + _history = f(!this) :: _history + } + def undo: A = { + val v = !this + _history = _history.tail + v + } +} diff --git a/Task/History-variables/Scala/history-variables-2.scala b/Task/History-variables/Scala/history-variables-2.scala new file mode 100644 index 0000000000..2ace85a53e --- /dev/null +++ b/Task/History-variables/Scala/history-variables-2.scala @@ -0,0 +1,21 @@ +scala> val h = new HVar(3) +h: HVar[Int] = HVar(3) + +scala> h := 11 + +scala> h := 90 + +scala> !h +res32: Int = 90 + +scala> h.history +res33: List[Int] = List(90, 11, 3) + +scala> h.undo +res34: Int = 90 + +scala> h.undo +res35: Int = 11 + +scala> h.undo +res36: Int = 3 diff --git a/Task/History-variables/Smalltalk/history-variables.st b/Task/History-variables/Smalltalk/history-variables.st new file mode 100644 index 0000000000..845d0f4cff --- /dev/null +++ b/Task/History-variables/Smalltalk/history-variables.st @@ -0,0 +1,35 @@ +Object subclass:'HVar' + instanceVariableNames:'values' + classVariableNames:'' + poolDictionaries:'' + category:'example'. +! + +!HVar methodsFor:'accessing'! + +<-- value + (values ifNil:[values := OrderedCollection new]) add:value. + ^ value +! + +value + ^ values last +! + +undo + values removeLast. +! + +history + ^ history +! ! + +|x| + +x := HVar new. +x <-- 1. +x value. +x <-- 2. +x <-- (x value + 1). +x value. +x history. diff --git a/Task/History-variables/Tcl/history-variables-1.tcl b/Task/History-variables/Tcl/history-variables-1.tcl new file mode 100644 index 0000000000..220eb95342 --- /dev/null +++ b/Task/History-variables/Tcl/history-variables-1.tcl @@ -0,0 +1,33 @@ +# Define the history machinery +proc histvar {varName operation} { + upvar 1 $varName v ___history($varName) history + switch -- $operation { + start { + set history {} + if {[info exist v]} { + lappend history $v + } + trace add variable v write [list histvar.write $varName] + trace add variable v read [list histvar.read $varName] + } + list { + return $history + } + undo { + set history [lrange $history 0 end-1] + } + stop { + unset history + trace remove variable v write [list histvar.write $varName] + trace remove variable v read [list histvar.read $varName] + } + } +} +proc histvar.write {key varName args} { + upvar 1 $varName v ___history($key) history + lappend history $v +} +proc histvar.read {key varName args} { + upvar 1 $varName v ___history($key) history + set v [lindex $history end] +} diff --git a/Task/History-variables/Tcl/history-variables-2.tcl b/Task/History-variables/Tcl/history-variables-2.tcl new file mode 100644 index 0000000000..04dcf1ab27 --- /dev/null +++ b/Task/History-variables/Tcl/history-variables-2.tcl @@ -0,0 +1,13 @@ +# Enable history for foo +histvar foo start +set foo {a b c d} +set foo 123 +set foo "quick brown fox" +puts $foo +puts foo-history=[join [histvar foo list] ", "] +puts $foo +histvar foo undo +puts $foo +histvar foo undo +puts $foo +histvar foo stop diff --git a/Task/Hofstadter-Conway-$10,000-sequence/0DESCRIPTION b/Task/Hofstadter-Conway-$10,000-sequence/0DESCRIPTION new file mode 100644 index 0000000000..66aa36c8d4 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/0DESCRIPTION @@ -0,0 +1,38 @@ +The definition of the sequence is colloquially described as: +* Starting with the list [1,1], +* Take the last number in the list so far: 1, I'll call it x. +* Count forward x places from the beginning of the list to find the first number to add (1) +* Count backward x places from the end of the list to find the second number to add (1) +* Add the two indexed numbers from the list and the result becomes the next number in the list (1+1) +* This would then produce [1,1,2] where 2 is the third element of the sequence. +Note that indexing for the description above starts from alternately the left and right ends of the list and starts from an index of ''one''. + +A less wordy description of the sequence is: + a(1)=a(2)=1 + a(n)=a(a(n-1))+a(n-a(n-1)) + +The sequence begins: + 1, 1, 2, 2, 3, 4, 4, 4, 5, ... + +Interesting features of the sequence are that: +* a(n)/n tends to 0.5 as n grows towards infinity. +* a(n)/n where n is a power of 2 is 0.5 +* For n>4 the maximal value of a(n)/n between successive powers of 2 decreases. + +[[File:Hofstadter conway 10K.gif|center|a(n) / n for n in 1..256]]
+ +The sequence is so named because [[wp:John Horton Conway|John Conway]] [http://www.nytimes.com/1988/08/30/science/intellectual-duel-brash-challenge-swift-response.html offered a prize] of $10,000 to the first person who could +find the first position, p in the sequence where + |a(n)/n| < 0.55 for all n > p. +It was later found that [[wp:Douglas Hofstadter|Hofstadter]] had also done prior work on the sequence. + +The 'prize' was won quite quickly by [http://www.research.avayalabs.com/gcm/usa/en-us/people/all/mallows.htm Dr. Colin L. Mallows] who proved the properties of the sequence and allowed him to find the value of n. (Which is much smaller than the 3,173,375,556. quoted in the NYT article) + +
'''The task is to:''' +# Create a routine to generate members of the Hofstadter-Conway $10,000 sequence. +# Use it to show the maxima of a(n)/n between successive powers of two up to 2**20 +# As a stretch goal: Compute the value of n that would have won the prize and confirm it is true for n up to 2**20 + +References: +* [http://www.jstor.org/stable/2324028 Conways Challenge Sequence], Mallows' own account. +* [http://mathworld.wolfram.com/Hofstadter-Conway10000-DollarSequence.html Mathworld Article]. diff --git a/Task/Hofstadter-Conway-$10,000-sequence/1META.yaml b/Task/Hofstadter-Conway-$10,000-sequence/1META.yaml new file mode 100644 index 0000000000..fae269ae79 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Memoization diff --git a/Task/Hofstadter-Conway-$10,000-sequence/ALGOL-68/hofstadter-conway-$10,000-sequence.alg b/Task/Hofstadter-Conway-$10,000-sequence/ALGOL-68/hofstadter-conway-$10,000-sequence.alg new file mode 100644 index 0000000000..f73c6d20c7 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/ALGOL-68/hofstadter-conway-$10,000-sequence.alg @@ -0,0 +1,36 @@ +PROC do sqnc = (INT max)INT: +BEGIN + [max]INT a list; + INT k1 := 2, + lg2 := 1, + v := a list[1] := a list[2] := 1; # Concurrent declaration and assignment in declarations are allowed # + + INT nmax; + LONG REAL amax := 0.0; + + INT mallows number; + + FOR n FROM 3 TO max DO + v := a list[n] := a list[v] + a list[n-v]; + + ( amax < v/n | amax := v/n; nmax := n ); # When given a Boolean as the 1st expression, ( | ) is the short form of IF...THEN...FI # + + IF v/n >= 0.55 THEN # This is the equivalent full form of the above construct # + mallows number := n + FI; + + IF ABS(BIN k1 AND BIN n) = 0 THEN + # 'BIN' converts an INT type to a BITS type; In this context, 'ABS' reverses that operation # + printf(($"Maximum between 2^"g(0)" and 2^"g(0)" is about "g(-10,8)" at "g(0)l$, lg2,lg2+1, amax, nmax)); + amax := 0; + lg2 PLUSAB 1 # 'PLUSAB' (plus-and-becomes) has the short form +:= # + FI; + k1 := n + OD; + mallows number # the result of the last expression evaluated is returned as the result of the PROC # +END; + +INT mallows number = do sqnc(2**20); # This definition of 'mallows number' does not clash with the variable + of the same name inside PROC do sqnc - they are in different scopes# + +printf(($"You too might have won $1000 with an answer of n = "g(0)$, mallows number)) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/AWK/hofstadter-conway-$10,000-sequence-1.awk b/Task/Hofstadter-Conway-$10,000-sequence/AWK/hofstadter-conway-$10,000-sequence-1.awk new file mode 100644 index 0000000000..51c70edb13 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/AWK/hofstadter-conway-$10,000-sequence-1.awk @@ -0,0 +1,22 @@ +#!/usr/bin/awk -f +BEGIN { + NN = 20; + iterativeHCsequence(2^NN+1,Q); + for (K=1; K 1, Aft => 8, Exp => 0); + Put_Line (" at" & Integer'Image (Where)); + end; + end loop; + -- Calculate Mallows number + for I in reverse 2 ** M .. 2 ** (M + 1) loop + if (Ratio (I) > 0.55) then + Mallows := I; + exit; + end if; + end loop; + Put_Line ("Mallows number" & Integer'Image (Mallows)); + Free (S); + Free (Ratio); +end Conway; diff --git a/Task/Hofstadter-Conway-$10,000-sequence/AutoHotkey/hofstadter-conway-$10,000-sequence.ahk b/Task/Hofstadter-Conway-$10,000-sequence/AutoHotkey/hofstadter-conway-$10,000-sequence.ahk new file mode 100644 index 0000000000..1024858e4a --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/AutoHotkey/hofstadter-conway-$10,000-sequence.ahk @@ -0,0 +1,47 @@ +Progress, b2 w150 zh0 fs9, CreateLists ... +CreateLists(2 ** (Max:=20)) + +Progress,, Find Maxima ... +Loop, % Max - 1 + msg .= "Maximum between 2^" A_Index " and 2^" A_Index + 1 + . " is " GetMax(2 ** A_Index, 2 ** (A_Index + 1), n) + . " for n = " n "`n" + +Progress,, Find Mallows Number ... +Loop, % 2 ** Max + If (n_%A_Index% > 0.55) + MallowsNumber := A_Index +msg .= "Mallows Number = " MallowsNumber + +Progress, Off +MsgBox, %msg% + +;--------------------------------------------------------------------------- +GetMax(a, b, ByRef Item) { ; return max value of a(n)/n between a and b +;--------------------------------------------------------------------------- + Loop { + IfGreater, a, %b%, Break + If (Maximum < n_%a%) + Maximum := n_%a%, Item := a + a++ + } + Return, Maximum +} + +;--------------------------------------------------------------------------- +CreateLists(Lenght) { ; Hofstadter-Conway sequences (using lookups) +;--------------------------------------------------------------------------- + ; create the sequence a_%A_Index% [ a(n) ] + ; and the sequence n_%A_Index% [ a(n)/n ] + ;----------------------------------------------------------------------- + global + a_1 := a_2 := n_1 := 1, n_2 := 1 / 2 + Loop, %Lenght% { + IfLess, A_Index, 3, Continue + n1 := A_Index - 1 + an1 := a_%n1% + nan1 := A_Index - an1 + a_%A_Index% := a_%an1% + a_%nan1% + n_%A_Index% := a_%A_Index% / A_Index + } +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/BBC-BASIC/hofstadter-conway-$10,000-sequence.bbc b/Task/Hofstadter-Conway-$10,000-sequence/BBC-BASIC/hofstadter-conway-$10,000-sequence.bbc new file mode 100644 index 0000000000..259ddca9eb --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/BBC-BASIC/hofstadter-conway-$10,000-sequence.bbc @@ -0,0 +1,21 @@ +HIMEM=LOMEM+1E7 : REM Reserve enough memory for a 4 MB array, plus other code +DIM a%(2^20) +a%(1)=1 +a%(2)=1 +pow2%=2 +p2%=2^pow2% +peak=0.5 +peakpos%=0 +FOR n%=3 TO 2^20 + a%(n%)=a%(a%(n%-1))+a%(n%-a%(n%-1)) + r=a%(n%)/n% + IF r>=0.55 THEN Mallows%=n% + IF r>peak THEN peak=r:peakpos%=n% + IF n%=p2% THEN + PRINT "Maximum between 2^";pow2%-1;" and 2^";pow2%;" is ";peak;" at n=";peakpos% + pow2%+=1 + p2%=2^pow2% + peak=0.5 + ENDIF +NEXT n% +PRINT "Mallows number is ";Mallows% diff --git a/Task/Hofstadter-Conway-$10,000-sequence/C++/hofstadter-conway-$10,000-sequence.cpp b/Task/Hofstadter-Conway-$10,000-sequence/C++/hofstadter-conway-$10,000-sequence.cpp new file mode 100644 index 0000000000..ac09bfec71 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/C++/hofstadter-conway-$10,000-sequence.cpp @@ -0,0 +1,33 @@ +#include +#include + +int hcseq(int n) +{ + static std::deque seq(2, 1); + while (seq.size() < n) + { + int x = seq.back(); + seq.push_back(seq[x-1] + seq[seq.size()-x]); + } + return seq[n-1]; +} + +int main() +{ + int pow2 = 1; + for (int i = 0; i < 20; ++i) + { + int pow2next = 2*pow2; + double max = 0; + for (int n = pow2; n < pow2next; ++n) + { + double anon = hcseq(n)/double(n); + if (anon > max) + max = anon; + } + std::cout << "maximum of a(n)/n between 2^" << i + << " (" << pow2 << ") and 2^" << i+1 + << " (" << pow2next << ") is " << max << "\n"; + pow2 = pow2next; + } +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/C/hofstadter-conway-$10,000-sequence.c b/Task/Hofstadter-Conway-$10,000-sequence/C/hofstadter-conway-$10,000-sequence.c new file mode 100644 index 0000000000..04ea662a1e --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/C/hofstadter-conway-$10,000-sequence.c @@ -0,0 +1,29 @@ +#include +#include + +int a_list[1<<20 + 1]; + +int doSqnc( int m) +{ + int max_df = 0; + int p2_max = 2; + int v, n; + int k1 = 2; + int lg2 = 1; + double amax = 0; + a_list[0] = -50000; + a_list[1] = a_list[2] = 1; + v = a_list[2]; + + for (n=3; n <= m; n++) { + v = a_list[n] = a_list[v] + a_list[n-v]; + if ( amax < v*1.0/n) amax = v*1.0/n; + if ( 0 == (k1&n)) { + printf("Maximum between 2^%d and 2^%d was %f\n", lg2,lg2+1, amax); + amax = 0; + lg2++; + } + k1 = n; + } + return 1; +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Clojure/hofstadter-conway-$10,000-sequence.clj b/Task/Hofstadter-Conway-$10,000-sequence/Clojure/hofstadter-conway-$10,000-sequence.clj new file mode 100644 index 0000000000..fe66f8def6 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Clojure/hofstadter-conway-$10,000-sequence.clj @@ -0,0 +1,41 @@ +(use 'clojure.contrib.math) ; for expt + +;; A literal transcription of the definition, with memoize doing the heavy lifting +(def conway + (memoize + (fn [x] + (if (< x 3) + 1 + (+ (conway (conway (dec x))) + (conway (- x (conway (dec x))))))))) + +(def N (drop 1 (range))) ; natural numbers + +;; This is enough to compute them all. The rest is grouping and max-finding +(def all-conways (map conway N)) + +;; All the powers of two +(def pow2 (map #(expt 2 %) N)) + +;; Find the lowest power of two > n +(defn lowest-pow-higher [n] + (some #(and (> % n) %) pow2)) + +;; Split the natural numbers into groups at each power of two +(def groups (partition-by lowest-pow-higher N)) + +;; The conway numbers of each number in the group +(def C (map #(map conway %) groups)) + +;; Each conway number divided by its index +(def ratios (map #(map / %1 %2) C groups)) + +;; The largest value in each group of ratios +(def maxima (map #(apply max %) ratios)) + +(take 4 maxima) ; no rounding errors: still using ratios +;; yields (1 2/3 2/3 7/11) + +(def first-20 (take 20 maxima)) +(apply >= first-20) ; yields true - the sequence is decreasing +(map double first-20) ; to get them in decimal form diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Common-Lisp/hofstadter-conway-$10,000-sequence.lisp b/Task/Hofstadter-Conway-$10,000-sequence/Common-Lisp/hofstadter-conway-$10,000-sequence.lisp new file mode 100644 index 0000000000..322c515a44 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Common-Lisp/hofstadter-conway-$10,000-sequence.lisp @@ -0,0 +1,42 @@ +(defparameter *hof-con* + (make-array '(2) :initial-contents '(1 1) :adjustable t + :element-type 'integer :fill-pointer 2)) + +(defparameter *hof-con-ratios* + (make-array '(2) :initial-contents '(1.0 0.5) :adjustable t + :element-type 'single-float :fill-pointer 2)) + +(defun hof-con (n) + (let ((l (length *hof-con*))) + (if (<= n l) (aref *hof-con* (1- n)) + (extend-hof-con-sequence l n)))) + +(defun extend-hof-con-sequence (l n) + (loop for i from l below n do + (let* ((x (aref *hof-con* (1- i))) + (hc (+ (aref *hof-con* (1- x)) + (aref *hof-con* (- i x))))) + (vector-push-extend hc *hof-con*) + (vector-push-extend (/ hc (+ i 1.0)) *hof-con-ratios*))) + (aref *hof-con* (1- n))) + +(defun max-in-array-range (arr id1 id2) + (let ((m 0) (id 0)) + (loop for i from (1- id1) to (1- id2) do + (let ((n (aref arr i))) + (if (> n m) (setq m n id i)))) + (values m (1+ id)))) + +(defun maxima (po2) + (hof-con (expt 2 po2)) + (loop for i from 1 below po2 do + (let ((id1 (expt 2 i)) (id2 (expt 2 (1+ i)))) + (multiple-value-bind (m id) + (max-in-array-range *hof-con-ratios* id1 id2) + (format t "Local maximum in [~A .. ~A]: ~A at n = ~A~%" id1 id2 m id))))) + +(defun mallows (po2) + (let ((n (expt 2 po2))) + (hof-con n) + (do ((i (1- n) (1- i))) + ((> (aref *hof-con-ratios* i) 0.55) (+ i 1))))) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/D/hofstadter-conway-$10,000-sequence.d b/Task/Hofstadter-Conway-$10,000-sequence/D/hofstadter-conway-$10,000-sequence.d new file mode 100644 index 0000000000..29df1b9feb --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/D/hofstadter-conway-$10,000-sequence.d @@ -0,0 +1,24 @@ +import std.stdio, std.algorithm; + +void hofstadterConwaySequence(in int m) { + auto alist = new int[m + 1]; + alist[0 .. 2] = 1; + auto v = alist[2]; + int k1 = 2, lg2 = 1; + double amax = 0.0; + + foreach (n; 2 .. m + 1) { + v = alist[n] = alist[v] + alist[n - v]; + amax = max(amax, v * 1.0 / n); + if ((k1 & n) == 0) { + writefln("Max in [2^%d, 2^%d]: %f", lg2, lg2 + 1, amax); + amax = 0; + lg2++; + } + k1 = n; + } +} + +void main() { + hofstadterConwaySequence(2 ^^ 20); +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Euler-Math-Toolbox/hofstadter-conway-$10,000-sequence.euler b/Task/Hofstadter-Conway-$10,000-sequence/Euler-Math-Toolbox/hofstadter-conway-$10,000-sequence.euler new file mode 100644 index 0000000000..40c49a12e4 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Euler-Math-Toolbox/hofstadter-conway-$10,000-sequence.euler @@ -0,0 +1,27 @@ +>function hofstadter (n) ... +$v=ones(1,n); +$ loop 2 to n-1 +$ k=v{#}; +$ v{#+1}=v{k}+v{#-k+1}; +$ end +$ return v +$endfunction +>v=hofstadter(2^20); +>k=1:256; plot2d(v[k]/k): +>function hsmaxima (v,k) ... +$ w=zeros(1,k); +$ for j=1 to k +$ i=2^(j-1):2^j; +$ w[j]=max(v[i]/i); +$ end; +$ return w; +$endfunction +>w=hsmaxima(v,20) + [ 1 0.666666666667 0.666666666667 0.636363636364 0.608695652174 + 0.590909090909 0.576086956522 0.567415730337 0.559459459459 + 0.554937413074 0.550100874243 0.547462892648 0.544144747864 + 0.54244270878 0.540071097512 0.538784020584 0.537043657 + 0.536020067812 0.534645431078 0.533779229963 ] +>v1=flipx(cummax(flipx(v/(1:cols(v))))); +>max(nonzeros(v1>0.55)) + 1489 diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Fortran/hofstadter-conway-$10,000-sequence.f b/Task/Hofstadter-Conway-$10,000-sequence/Fortran/hofstadter-conway-$10,000-sequence.f new file mode 100644 index 0000000000..e4d83f69e1 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Fortran/hofstadter-conway-$10,000-sequence.f @@ -0,0 +1,45 @@ +program conway + implicit none + integer :: a(2**20) ! The sequence a(n) + real :: b(2**20) ! The sequence a(n)/n + real :: v ! Max value in the range [2*i, 2**(i+1)] + integer :: nl(1) ! The location of v in the array b(n) + integer :: i, N, first, second, last, m + + ! Populate a(n) and b(n) + a(1:2) = [1, 1] + b(1:2) = [1.0e0, 0.5e0] + N = 2 + do i=1,2**20 + last = a(N) + first = a(last) + second = a(N-last+1) + N = N+1 + a(N:N) = first + second + b(N:N) = a(N:N)/real(N) + end do + + ! Calculate the max values in the logarithmic ranges + m = 0 + do i=1,19 + v = maxval(b(2**i:2**(i+1))) + nl = maxloc(b(2**i:2**(i+1))) + write(*,'(2(a,i0),a,f8.6,a,i0)') & + 'Max. between 2**', i, & + ' and 2**', (i+1), & + ' is ', v, & + ' at n = ', 2**i+nl(1)-1 + if (m == 0 .and. v < 0.55e0) then + m = i-1 + end if + end do + + ! Calculate Mallows number + do i=2**(m+1), 2**m,-1 + if (b(i) > 0.55e0) then + exit + end if + end do + write(*,'(a,i0)') 'Mallows number = ',i + +end program conway diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Go/hofstadter-conway-$10,000-sequence.go b/Task/Hofstadter-Conway-$10,000-sequence/Go/hofstadter-conway-$10,000-sequence.go new file mode 100644 index 0000000000..b072f2a9f5 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Go/hofstadter-conway-$10,000-sequence.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" +) + +func main() { + a := []int{0, 1, 1} // ignore 0 element. work 1 based. + x := 1 // last number in list + n := 2 // index of last number in list = len(a)-1 + mallow := 0 + for p := 1; p < 20; p++ { + max := 0. + for nextPot := n*2; n < nextPot; { + n = len(a) // advance n + x = a[x]+a[n-x] + a = append(a, x) + f := float64(x)/float64(n) + if f > max { + max = f + } + if f >= .55 { + mallow = n + } + } + fmt.Printf("max between 2^%d and 2^%d was %f\n", p, p+1, max) + } + fmt.Println("winning number", mallow) +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Haskell/hofstadter-conway-$10,000-sequence.hs b/Task/Hofstadter-Conway-$10,000-sequence/Haskell/hofstadter-conway-$10,000-sequence.hs new file mode 100644 index 0000000000..5f688d10ec --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Haskell/hofstadter-conway-$10,000-sequence.hs @@ -0,0 +1,25 @@ +import Data.List +import Data.Ord +import Data.Array +import Text.Printf + +hc :: Int -> Array Int Int +hc n = arr + where arr = listArray (1, n) $ 1 : 1 : map (f (arr!)) [3 .. n] + f a i = a (a $ i - 1) + a (i - a (i - 1)) + +printMaxima :: (Int, (Int, Double)) -> IO () +printMaxima (n, (pos, m)) = + printf "Max between 2^%-2d and 2^%-2d is %1.5f at n = %6d\n" + n (n + 1) m pos + +main = do + mapM_ printMaxima maxima + printf "Mallows's number is %d\n" mallows + where + hca = hc $ 2^20 + hc' n = fromIntegral (hca!n) / fromIntegral n + maxima = zip [0..] $ map max powers + max seq = maximumBy (comparing snd) $ zip seq (map hc' seq) + powers = map (\n -> [2^n .. 2^(n + 1) - 1]) [0 .. 19] + mallows = last.takeWhile ((< 0.55) . hc') $ [2^20, 2^20 - 1 .. 1] diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Icon/hofstadter-conway-$10,000-sequence.icon b/Task/Hofstadter-Conway-$10,000-sequence/Icon/hofstadter-conway-$10,000-sequence.icon new file mode 100644 index 0000000000..b04908095e --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Icon/hofstadter-conway-$10,000-sequence.icon @@ -0,0 +1,16 @@ +procedure main(args) + m := integer(!args) | 20 + nextNum := create put(A := [], 1 | 1 | |A[A[*A]]+A[-A[*A]])[*A] + p2 := 2 ^ (p := 1) + maxv := 0 + every n := 1 to (2^m) do { + if maxv <:= (x := @nextNum / real(n)) then maxm := n + if x >= 0.55 then mallows := n # Want *this* n, not next one! + if n = p2 then { + write("Max between 2^",p-1," and 2^",p," is ",maxv," at n = ",maxm) + p2 := 2 ^ (p +:= 1) + maxv := 0 + } + } + write("Mallows's number is ",\mallows | "NOT found!") +end diff --git a/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-1.j b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-1.j new file mode 100644 index 0000000000..b1a8f29fb4 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-1.j @@ -0,0 +1,3 @@ + hc10k =: , ] +/@:{~ (,&<: -.)@{: NB. Actual sequence a(n) + AnN =: % 1+i.@:# NB. a(n)/n + MxAnN =: >./;.1~ 2 (=<.)@:^. 1+i.@# NB. Maxima of a(n)/n between successive powers of 2 diff --git a/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-2.j b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-2.j new file mode 100644 index 0000000000..6a0608a3d5 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-2.j @@ -0,0 +1,4 @@ + hc10kE =: 1 1 , expand@tail + expand =: 2+I.@; + tail =: copies&.>^:(<@>:`(<@,@2:)) + copies =: >: |.@(#!.1 |.)~ 1 j. #;.1 #^:_1 ::1:~ ]~:{. diff --git a/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-3.j b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-3.j new file mode 100644 index 0000000000..2b58ddd07a --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/J/hofstadter-conway-$10,000-sequence-3.j @@ -0,0 +1,8 @@ + ] A=:1 1 hc10k @]^:[~ 2^20x +1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 ... + AnN A +1 0.5 0.666667 0.5 0.6 0.666667 ... + MxAnN@AnN A +1 0.666667 0.666667 0.636364 ... + MxAnN@AnN@hc10kE 20 +1 0.666667 0.666667 0.636364 ... diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Java/hofstadter-conway-$10,000-sequence.java b/Task/Hofstadter-Conway-$10,000-sequence/Java/hofstadter-conway-$10,000-sequence.java new file mode 100644 index 0000000000..9f292bcb54 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Java/hofstadter-conway-$10,000-sequence.java @@ -0,0 +1,31 @@ +public class HofCon +{ + public static void main(final String[] args) + { + doSqnc(1<<20); + } + public static void doSqnc(int m) + { + int[] a_list = new int[m + 1]; + int max_df = 0; + int p2_max = 2; + int k1 = 2; + int lg2 = 1; + double amax = 0; + a_list[0] = a_list[1] = 1; + int v = a_list[2]; + for (int n = 2; n <= m; n++) + { + v = a_list[n] = a_list[v] + a_list[n - v]; + if (amax < v * 1.0 / n) + amax = v * 1.0 / n; + if (0 == (k1 & n)) + { + System.out.printf("Maximum between 2^%d and 2^%d was %f\n", lg2, lg2 + 1, amax); + amax = 0; + lg2++; + } + k1 = n; + } + } +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/JavaScript/hofstadter-conway-$10,000-sequence.js b/Task/Hofstadter-Conway-$10,000-sequence/JavaScript/hofstadter-conway-$10,000-sequence.js new file mode 100644 index 0000000000..1e34ecd447 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/JavaScript/hofstadter-conway-$10,000-sequence.js @@ -0,0 +1,25 @@ +var hofst_10k = function(n) { + var memo = [1, 1]; + + var a = function(n) { + var result = memo[n-1]; + if (typeof result !== 'number') { + result = a(a(n-1))+a(n-a(n-1)); + memo[n-1] = result; + } + return result; + } + return a; +}(); + +var maxima_between_twos = function(exp) { + var current_max = 0; + for(var i = Math.pow(2,exp)+1; i < Math.pow(2,exp+1); i += 1) { + current_max = Math.max(current_max, hofst_10k(i)/i); + } + return current_max; +} + +for(var i = 1; i <= 20; i += 1) { + console.log("Maxima between 2^"+i+"-2^"+(i+1)+" is: "+maxima_between_twos(i)+"\n"); +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-1.m b/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-1.m new file mode 100644 index 0000000000..b583223a4f --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-1.m @@ -0,0 +1,7 @@ + function Q = HCsequence(N) + Q = zeros(1,N); + Q(1:2) = 1; + for n = 3:N, + Q(n) = Q(Q(n-1))+Q(n-Q(n-1)); + end; +end; diff --git a/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-2.m b/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-2.m new file mode 100644 index 0000000000..87b4b9f5fe --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/MATLAB/hofstadter-conway-$10,000-sequence-2.m @@ -0,0 +1,8 @@ +NN = 20; +Q = HCsequence(2^NN+1); +V = Q./(1:2^NN); +for k=1:NN, + [m,i] = max(V(2^k:2^(k+1))); + i = i + 2^k - 1; + printf('Maximum between 2^%i and 2^%i is %f at n=%i\n',k,k+1,m,i); +end; diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Mathematica/hofstadter-conway-$10,000-sequence.mathematica b/Task/Hofstadter-Conway-$10,000-sequence/Mathematica/hofstadter-conway-$10,000-sequence.mathematica new file mode 100644 index 0000000000..e7e0ea405b --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Mathematica/hofstadter-conway-$10,000-sequence.mathematica @@ -0,0 +1,5 @@ +a[1] := 1; a[2] := 1; +a[n_] := a[n] = a[a[n-1]] + a[n-a[n-1]] + +Map[Print["Max value: ",Max[Table[a[n]/n//N,{n,2^#,2^(#+1)}]]," for n between 2^",#," and 2^",(#+1)]& , Range[19]] +n=2^20; While[(a[n]/n//N)<0.55,n--]; Print["Mallows number: ",n] diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Perl/hofstadter-conway-$10,000-sequence.pl b/Task/Hofstadter-Conway-$10,000-sequence/Perl/hofstadter-conway-$10,000-sequence.pl new file mode 100644 index 0000000000..98f3507330 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Perl/hofstadter-conway-$10,000-sequence.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +use warnings ; +use strict ; + +my $limit = 2 ** 20 ; +my @numbers = ( 0 , 1 , 1 ) ; +my $mallows ; +my $max_i ; +foreach my $i ( 3..$limit ) { + push ( @numbers , $numbers[ $numbers[ $i - 1 ]] + $numbers[ $i - $numbers[ $i - 1 ] ] ) ; +} +for ( my $rangelimit = 1 ; $rangelimit < 20 ; $rangelimit++ ) { + my $max = 0 ; + for ( my $i = 2 ** $rangelimit ; $i < ( 2 ** ( $rangelimit + 1 ) ) ; $i++ ) { + my $rat = $numbers[ $i ] / $i ; + $mallows = $i if $rat >= 0.55 ; + if ( $rat > $max ) { + $max = $rat ; + $max_i = $i ; + } + } + my $upperlimit = $rangelimit + 1 ; + print "Between 2 ^ $rangelimit and 2 ^ $upperlimit the maximum value is $max at $max_i !\n" ; +} +print "The prize would have been won at $mallows !\n" diff --git a/Task/Hofstadter-Conway-$10,000-sequence/PicoLisp/hofstadter-conway-$10,000-sequence.l b/Task/Hofstadter-Conway-$10,000-sequence/PicoLisp/hofstadter-conway-$10,000-sequence.l new file mode 100644 index 0000000000..ba70ba4f3b --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/PicoLisp/hofstadter-conway-$10,000-sequence.l @@ -0,0 +1,29 @@ +(de hofcon (N) + (cache '(NIL) (pack (char (hash N)) N) + (if (>= 2 N) + 1 + (+ + (hofcon (hofcon (dec N))) + (hofcon (- N (hofcon (dec N)))) ) ) ) ) + +(scl 20) + +(de sequence (M) + (let (Lim 4 Max 0 4k$ 0) + (for (N 3 (>= M N) (inc N)) + (let V (*/ (hofcon N) 1.0 N) + (setq Max (max Max V)) + (when (>= V 0.55) + (setq 4k$ N) ) + (when (= N Lim) + (prinl + "Maximum between " (/ Lim 2) + " and " Lim + " was " (format Max `*Scl) ) + (inc 'Lim Lim) + (zero Max) ) ) ) + (prinl + "Win with " 4k$ + " (the task requests 'n > p' now)" ) ) ) + +(sequence (** 2 20)) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Python/hofstadter-conway-$10,000-sequence.py b/Task/Hofstadter-Conway-$10,000-sequence/Python/hofstadter-conway-$10,000-sequence.py new file mode 100644 index 0000000000..78712d30d9 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Python/hofstadter-conway-$10,000-sequence.py @@ -0,0 +1,23 @@ +from __future__ import division + +def maxandmallows(nmaxpower2=20): + # Note: The first hc number is returned in hc[1]; + # hc[0] is not part of the series. + nmax = 2**nmaxpower2 + hc, mallows, mx, mxpow2 = [None, 1, 1], None, (0.5, 2), [] + for n in range(2, nmax + 1): + ratio = hc[n] / n + if ratio > mx[0]: mx = (ratio, n) + if ratio >= 0.55: mallows = n + if ratio == 0.5: + print("In the region %7i < n <= %7i: max a(n)/n = %s" % + ((n)//2, n, "%6.4f at n = %i" % mx)) + mxpow2.append(mx[0]) + mx = (ratio, n) + hc.append(hc[hc[n]] + hc[-hc[n]]) + return hc, mallows if mxpow2 and mxpow2[-1] < 0.55 and n > 4 else None + +if __name__ == '__main__': + hc, mallows = maxandmallows(20) + if mallows: + print("\nYou too might have won $1000 with the mallows number of %i" % mallows) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-1.r b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-1.r new file mode 100644 index 0000000000..bbad7056ef --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-1.r @@ -0,0 +1,6 @@ +f = local( + {a = c(1, 1) + function(n) + {if (is.na(a[n])) + a[n] <<- f(f(n - 1)) + f(n - f(n - 1)) + a[n]}}) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-2.r b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-2.r new file mode 100644 index 0000000000..d612704157 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-2.r @@ -0,0 +1,5 @@ +hofcon = c(1, 1, rep(NA, 2^20 - 2)) +for (n in 3 : (2^20)) + {hofcon[n] = + hofcon[hofcon[n - 1]] + + hofcon[n - hofcon[n - 1]]} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-3.r b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-3.r new file mode 100644 index 0000000000..7bfd89d9f8 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/R/hofstadter-conway-$10,000-sequence-3.r @@ -0,0 +1,8 @@ +ratios = hofcon / seq_along(hofcon) + +message("Maxima:") +print(sapply(1 : 20, function(pwr) + max(ratios[2^(pwr - 1) : 2^pwr]))) + +message("Prize-winning point:") +print(max(which(ratios >= .55))) diff --git a/Task/Hofstadter-Conway-$10,000-sequence/REXX/hofstadter-conway-$10,000-sequence.rexx b/Task/Hofstadter-Conway-$10,000-sequence/REXX/hofstadter-conway-$10,000-sequence.rexx new file mode 100644 index 0000000000..0832b4412d --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/REXX/hofstadter-conway-$10,000-sequence.rexx @@ -0,0 +1,33 @@ +/*REXX program solves the Hofstadter-Conway $10,000 prize. */ +hC.=; i.=0; m.=0; n.=0; w=0; wi=0; few=70; L= + + do i=1 for few; L=L hc(i) /*build first 70 numbers in seq. */ + end /*i*/ + /*I wear a belt and suspenders. */ +say 'The first' few "numbers in the Hofstadter-Conway sequence:" +say strip(L) /*show&tell, no trees have to die*/ +say /*show a blank line for the eyes.*/ + do k=0 to 20 /*build an array, powers of two.*/ + p.k=2**k /*Bang-bang!. Er, I mean pow-pow*/ + maxp=p.k /*and remember who's da big 'un. */ + end /*k*/ +r=1 /*R: the range of the power of 2.*/ + do n=1 for maxp /*heck, let's get cracking then.*/ + if n>p.r then r=r+1 /*for golf players: r=r+(n>p.r) */ + _=hc(n)/n; if _>=.55 then w=n /*get next seq #; if ≥.55, a win?*/ + if _<=m.r then iterate /*less than? Then keep truckin'.*/ + m.r=_; i.r=n /*m.r & i.r is for ginkgo biloba*/ + end /*n*/ + +pref='Maximum of a(n) ÷ n between ' /*prefix text of message.*/ + + do j=1 for 20; range='2**'right(j-1,2) "───► 2**"right(j,2) + say pref range '(inclusive) is ' left(m.j,8) ' at n='right(i.j,7) + end /*j*/ +say +say 'The winning number is: ' w /*and the money shot is ... */ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────hC [Hofstadter-Conway] subroutine*/ +hC: procedure expose hC.; parse arg n; if n<3 then return 1 +if hC.n=='' then hC.n = hC(hC(n-1)) + hC(n-hC(n-1)) +return hC.n /*return with the goodie stuff. */ diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-1.rb b/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-1.rb new file mode 100644 index 0000000000..e5096b7a17 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-1.rb @@ -0,0 +1,15 @@ +class HofstadterConway10000 + def initialize + @sequence = [nil, 1, 1] + end + attr_reader :sequence + + def [](n) + raise ArgumentError, "n must be >= 1" if n < 1 + a = @sequence + a.length.upto(n) {|i| a[i] = a[a[i-1]] + a[i-a[i-1]] } + a[n] + end +end + +hc = HofstadterConway10000.new diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-2.rb b/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-2.rb new file mode 100644 index 0000000000..1e9125fb06 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Ruby/hofstadter-conway-$10,000-sequence-2.rb @@ -0,0 +1,13 @@ +p = -1 +20.downto(1).each_cons(2) do |j, i| + max_n, max_v = -1, -1 + (2**j).downto(2**i).each do |n| + v = hc[n].to_f / n + max_n, max_v = n, v if v > max_v + # Mallows number + p = n if p == -1 and v >= 0.55 + end + puts "maximum between 2^#{i} and 2^#{j} occurs at #{max_n}: #{max_v}" +end + +puts "the mallows number is #{p}" diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Scala/hofstadter-conway-$10,000-sequence.scala b/Task/Hofstadter-Conway-$10,000-sequence/Scala/hofstadter-conway-$10,000-sequence.scala new file mode 100644 index 0000000000..ed655ac608 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Scala/hofstadter-conway-$10,000-sequence.scala @@ -0,0 +1,29 @@ +object HofstadterConway { + def pow2(n: Int): Int = (Iterator.fill(n)(2)).product + + def makeHCSequence(max: Int): Seq[Int] = + (0 to max - 1).foldLeft (Vector[Int]()) { (v, idx) => + if (idx <= 1) v :+ 1 else v :+ (v(v(idx - 1) - 1) + v(idx - v(idx - 1))) + } + + val max = pow2(20) + + val maxSeq = makeHCSequence(max) + + def hcRatio(n: Int, seq: Seq[Int]): Double = seq(n - 1).toDouble / n + + def maximumHCRatioBetween(a: Int, b: Int): (Int, Double) = + Iterator.range(a, b + 1) map (n => (n, hcRatio(n, maxSeq))) maxBy (_._2) + + lazy val mallowsNumber: Int = + ((max to 1 by -1) takeWhile (hcRatio(_, maxSeq) < 0.55) last) - 1 + + def main(args: Array[String]): Unit = { + for (n <- 1 to 19) { + val (value, ratio) = maximumHCRatioBetween(pow2(n), pow2(n+1)) + val message = "Maximum of a(n)/n between 2^%s and 2^%s was %s at %s" + println(message.format(n, n+1, ratio, value)) + } + println("Mallow's number = %s".format(mallowsNumber)) + } +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-1.tcl b/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-1.tcl new file mode 100644 index 0000000000..5cf44b1be5 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-1.tcl @@ -0,0 +1,18 @@ +package require Tcl 8.5 + +set hofcon10k {1 1} +proc hofcon10k n { + global hofcon10k + if {$n < 1} {error "n must be at least 1"} + if {$n <= [llength $hofcon10k]} { + return [lindex $hofcon10k [expr {$n-1}]] + } + while {$n > [llength $hofcon10k]} { + set i [lindex $hofcon10k end] + set a [lindex $hofcon10k [expr {$i-1}]] + # Don't use end-based indexing here; faster to compute manually + set b [lindex $hofcon10k [expr {[llength $hofcon10k]-$i}]] + lappend hofcon10k [set c [expr {$a + $b}]] + } + return $c +} diff --git a/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-2.tcl b/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-2.tcl new file mode 100644 index 0000000000..561e3a75e6 --- /dev/null +++ b/Task/Hofstadter-Conway-$10,000-sequence/Tcl/hofstadter-conway-$10,000-sequence-2.tcl @@ -0,0 +1,9 @@ +for {set p 1} {$p<20} {incr p} { + set end [expr {2**($p+1)}] + set maxI 0; set maxV 0 + for {set i [expr {2**$p}]} {$i<=$end} {incr i} { + set v [expr {[hofcon10k $i] / double($i)}] + if {$v > $maxV} {set maxV $v; set maxI $i} + } + puts "max in 2**$p..2**[expr {$p+1}] at $maxI : $maxV" +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/0DESCRIPTION b/Task/Hofstadter-Figure-Figure-sequences/0DESCRIPTION new file mode 100644 index 0000000000..367064692c --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/0DESCRIPTION @@ -0,0 +1,19 @@ +These two sequences of positive integers are defined as: +:\begin{align} +R(1)&=1\ ;\ S(1)=2 \\ +R(n)&=R(n-1)+S(n-1), \quad n>1. +\end{align} +:The sequence S(n) is further defined as the sequence of positive integers ''not'' present in R(n). +Sequence R starts: 1, 3, 7, 12, 18, ...
+Sequence S starts: 2, 4, 5, 6, 8, ... + +Task: +# Create two functions named ffr and ffs that when given n return R(n) or S(n) respectively.
(Note that R(1) = 1 and S(1) = 2 to avoid off-by-one errors). +# No maximum value for n should be assumed. +# Calculate and show that the first ten values of R are: 1, 3, 7, 12, 18, 26, 35, 45, 56, and 69 +# Calculate and show that the first 40 values of ffr plus the first 960 values of ffs include all the integers from 1 to 1000 exactly once. + +;References: +* Sloane's [http://oeis.org/A005228 A005228] and [http://oeis.org/A030124 A030124]. +* [http://mathworld.wolfram.com/HofstadterFigure-FigureSequence.html Wolfram Mathworld] +* Wikipedia: [[wp:Hofstadter_sequence#Hofstadter_Figure-Figure_sequences|Hofstadter Figure-Figure sequences]]. diff --git a/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-1.ada b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-1.ada new file mode 100644 index 0000000000..bc2fcd9f79 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-1.ada @@ -0,0 +1,7 @@ +package Hofstadter_Figure_Figure is + + function FFR(P: Positive) return Positive; + + function FFS(P: Positive) return Positive; + +end Hofstadter_Figure_Figure; diff --git a/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-2.ada b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-2.ada new file mode 100644 index 0000000000..2d73e9b1a7 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-2.ada @@ -0,0 +1,51 @@ +package body Hofstadter_Figure_Figure is + + type Positive_Array is array (Positive range <>) of Positive; + + function FFR(P: Positive) return Positive_Array is + Figures: Positive_Array(1 .. P+1); + Space: Positive := 2; + Space_Index: Positive := 2; + begin + Figures(1) := 1; + for I in 2 .. P loop + Figures(I) := Figures(I-1) + Space; + Space := Space+1; + while Space = Figures(Space_Index) loop + Space := Space + 1; + Space_Index := Space_Index + 1; + end loop; + end loop; + return Figures(1 .. P); + end FFR; + + function FFR(P: Positive) return Positive is + Figures: Positive_Array(1 .. P) := FFR(P); + begin + return Figures(P); + end FFR; + + function FFS(P: Positive) return Positive_Array is + Spaces: Positive_Array(1 .. P); + Figures: Positive_Array := FFR(P+1); + J: Positive := 1; + K: Positive := 1; + begin + for I in Spaces'Range loop + while J = Figures(K) loop + J := J + 1; + K := K + 1; + end loop; + Spaces(I) := J; + J := J + 1; + end loop; + return Spaces; + end FFS; + + function FFS(P: Positive) return Positive is + Spaces: Positive_Array := FFS(P); + begin + return Spaces(P); + end FFS; + +end Hofstadter_Figure_Figure; diff --git a/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-3.ada b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-3.ada new file mode 100644 index 0000000000..66933aab42 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-3.ada @@ -0,0 +1,40 @@ +with Ada.Text_IO, Hofstadter_Figure_Figure; + +procedure Test_HSS is + + use Hofstadter_Figure_Figure; + + A: array(1 .. 1000) of Boolean := (others => False); + J: Positive; + +begin + for I in 1 .. 10 loop + Ada.Text_IO.Put(Integer'Image(FFR(I))); + end loop; + Ada.Text_IO.New_Line; + + for I in 1 .. 40 loop + J := FFR(I); + if A(J) then + raise Program_Error with Positive'Image(J) & " used twice"; + end if; + A(J) := True; + end loop; + + for I in 1 .. 960 loop + J := FFS(I); + if A(J) then + raise Program_Error with Positive'Image(J) & " used twice"; + end if; + A(J) := True; + end loop; + + for I in A'Range loop + if not A(I) then raise Program_Error with Positive'Image(I) & " unused"; + end if; + end loop; + Ada.Text_IO.Put_Line("Test Passed: No overlap between FFR(I) and FFS(J)"); + +exception + when Program_Error => Ada.Text_IO.Put_Line("Test Failed"); raise; +end Test_HSS; diff --git a/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-4.ada b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-4.ada new file mode 100644 index 0000000000..8f828d92ee --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Ada/hofstadter-figure-figure-sequences-4.ada @@ -0,0 +1,2 @@ + 1 3 7 12 18 26 35 45 56 69 +Test Passed: No overlap between FFR(I) and FFS(J) diff --git a/Task/Hofstadter-Figure-Figure-sequences/BBC-BASIC/hofstadter-figure-figure-sequences.bbc b/Task/Hofstadter-Figure-Figure-sequences/BBC-BASIC/hofstadter-figure-figure-sequences.bbc new file mode 100644 index 0000000000..e73322dec6 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/BBC-BASIC/hofstadter-figure-figure-sequences.bbc @@ -0,0 +1,53 @@ + PRINT "First 10 values of R:" + FOR i% = 1 TO 10 : PRINT ;FNffr(i%) " "; : NEXT : PRINT + PRINT "First 10 values of S:" + FOR i% = 1 TO 10 : PRINT ;FNffs(i%) " "; : NEXT : PRINT + PRINT "Checking for first 1000 integers:" + r% = 1 : s% = 1 + ffr% = FNffr(r%) + ffs% = FNffs(s%) + FOR wanted% = 1 TO 1000 + CASE TRUE OF + WHEN wanted% = ffr% : r% += 1 : ffr% = FNffr(r%) + WHEN wanted% = ffs% : s% += 1 : ffs% = FNffs(s%) + OTHERWISE: EXIT FOR + ENDCASE + NEXT + IF r% = 41 AND s% = 961 PRINT "Test passed" ELSE PRINT "Test failed" + END + + DEF FNffr(N%) + LOCAL I%, J%, R%, S%, V% + DIM V% LOCAL 2*N%+1 + V%?1 = 1 + IF N% = 1 THEN = 1 + R% = 1 + S% = 2 + FOR I% = 2 TO N% + FOR J% = S% TO 2*N% + IF V%?J% = 0 EXIT FOR + NEXT + V%?J% = 1 + S% = J% + R% += S% + IF R% <= 2*N% V%?R% = 1 + NEXT I% + = R% + + DEF FNffs(N%) + LOCAL I%, J%, R%, S%, V% + DIM V% LOCAL 2*N%+1 + V%?1 = 1 + IF N% = 1 THEN = 2 + R% = 1 + S% = 2 + FOR I% = 1 TO N% + FOR J% = S% TO 2*N% + IF V%?J% = 0 EXIT FOR + NEXT + V%?J% = 1 + S% = J% + R% += S% + IF R% <= 2*N% V%?R% = 1 + NEXT I% + = S% diff --git a/Task/Hofstadter-Figure-Figure-sequences/C/hofstadter-figure-figure-sequences.c b/Task/Hofstadter-Figure-Figure-sequences/C/hofstadter-figure-figure-sequences.c new file mode 100644 index 0000000000..67befd587c --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/C/hofstadter-figure-figure-sequences.c @@ -0,0 +1,84 @@ +#include +#include + +// simple extensible array stuff +typedef unsigned long long xint; + +typedef struct { + size_t len, alloc; + xint *buf; +} xarray; + +xarray rs, ss; + +void setsize(xarray *a, size_t size) +{ + size_t n = a->alloc; + if (!n) n = 1; + + while (n < size) n <<= 1; + if (a->alloc < n) { + a->buf = realloc(a->buf, sizeof(xint) * n); + if (!a->buf) abort(); + a->alloc = n; + } +} + +void push(xarray *a, xint v) +{ + while (a->alloc <= a->len) + setsize(a, a->alloc * 2); + + a->buf[a->len++] = v; +} + + +// sequence stuff +void RS_append(void); + +xint R(int n) +{ + while (n > rs.len) RS_append(); + return rs.buf[n - 1]; +} + +xint S(int n) +{ + while (n > ss.len) RS_append(); + return ss.buf[n - 1]; +} + +void RS_append() +{ + int n = rs.len; + xint r = R(n) + S(n); + xint s = S(ss.len); + + push(&rs, r); + while (++s < r) push(&ss, s); + push(&ss, r + 1); // pesky 3 +} + +int main(void) +{ + push(&rs, 1); + push(&ss, 2); + + int i; + printf("R(1 .. 10):"); + for (i = 1; i <= 10; i++) + printf(" %llu", R(i)); + + char seen[1001] = { 0 }; + for (i = 1; i <= 40; i++) seen[ R(i) ] = 1; + for (i = 1; i <= 960; i++) seen[ S(i) ] = 1; + for (i = 1; i <= 1000 && seen[i]; i++); + + if (i <= 1000) { + fprintf(stderr, "%d not seen\n", i); + abort(); + } + + puts("\nfirst 1000 ok"); + return 0; +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-1.lisp b/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-1.lisp new file mode 100644 index 0000000000..bb071d4c53 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-1.lisp @@ -0,0 +1,34 @@ +;;; equally doable with a list +(flet ((seq (i) (make-array 1 :element-type 'integer + :initial-element i + :fill-pointer 1 + :adjustable t))) + (let ((rr (seq 1)) (ss (seq 2))) + (labels ((extend-r () + (let* ((l (1- (length rr))) + (r (+ (aref rr l) (aref ss l))) + (s (elt ss (1- (length ss))))) + (vector-push-extend r rr) + (loop while (<= s r) do + (if (/= (incf s) r) + (vector-push-extend s ss)))))) + (defun seq-r (n) + (loop while (> n (length rr)) do (extend-r)) + (elt rr (1- n))) + + (defun seq-s (n) + (loop while (> n (length ss)) do (extend-r)) + (elt ss (1- n)))))) + +(defun take (f n) + (loop for x from 1 to n collect (funcall f x))) + +(format t "First of R: ~a~%" (take #'seq-r 10)) + +(mapl (lambda (l) (if (and (cdr l) + (/= (1+ (car l)) (cadr l))) + (error "not in sequence"))) + (sort (append (take #'seq-r 40) + (take #'seq-s 960)) + #'<)) +(princ "Ok") diff --git a/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-2.lisp b/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-2.lisp new file mode 100644 index 0000000000..e405bc5764 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Common-Lisp/hofstadter-figure-figure-sequences-2.lisp @@ -0,0 +1,2 @@ +First of R: (1 3 7 12 18 26 35 45 56 69) +Ok diff --git a/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-1.d b/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-1.d new file mode 100644 index 0000000000..3907b6f7ec --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-1.d @@ -0,0 +1,31 @@ +import std.stdio, std.array, std.range, std.algorithm; + +int delegate(in int) nothrow ffr, ffs; + +static this() { + auto r = [0, 1], s = [0, 2]; + + ffr = (in int n) { + while (r.length <= n) { + int nrk = r.length - 1; + int rNext = r[nrk] + s[nrk]; + r ~= rNext; + foreach (sn; r[nrk] + 2 .. rNext) + s ~= sn; + s ~= rNext + 1; + } + return r[n]; + }; + + ffs = (in int n) { + while (s.length <= n) + ffr(r.length); + return s[n]; + }; +} + +void main() { + writeln(iota(1, 11).map!ffr()); + auto t = iota(1, 41).map!ffr().chain(iota(1, 961).map!ffs()); + writeln(t.array().sort().equal(iota(1, 1001))); +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-2.d b/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-2.d new file mode 100644 index 0000000000..610586d8ba --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/D/hofstadter-figure-figure-sequences-2.d @@ -0,0 +1,50 @@ +import std.stdio, std.array, std.range, std.algorithm; + +struct ffr { + static int[] r = [int.min, 1]; + + static int opCall(in int n) { + assert(n > 0); + if (n < r.length) { + return r[n]; + } else { + int ffr_n_1 = ffr(n - 1); + int lastr = r[$ - 1]; + // extend s up to, and one past, last r + ffs.s ~= array(iota(ffs.s[$ - 1] + 1, lastr)); + if (ffs.s[$ - 1] < lastr) + ffs.s ~= lastr + 1; + // access s[n-1] temporarily extending s if necessary + size_t len_s = ffs.s.length; + int ffs_n_1 = len_s > n ? ffs.s[n - 1] : + (n - len_s) + ffs.s[$-1]; + int ans = ffr_n_1 + ffs_n_1; + r ~= ans; + return ans; + } + } +} + +struct ffs { + static int[] s = [int.min, 2]; + + static int opCall(in int n) { + assert(n > 0); + if (n < s.length) { + return s[n]; + } else { + foreach (i; ffr.r.length .. n+2) { + ffr(i); + if (s.length > n) + return s[n]; + } + assert(0, "Whoops!"); + } + } +} + +void main() { + writeln(map!ffr(iota(1, 11))); + auto t = chain(map!ffr(iota(1, 41)), map!ffs(iota(1, 961))); + writeln(equal(sort(array(t)), iota(1, 1001))); +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Euler-Math-Toolbox/hofstadter-figure-figure-sequences.euler b/Task/Hofstadter-Figure-Figure-sequences/Euler-Math-Toolbox/hofstadter-figure-figure-sequences.euler new file mode 100644 index 0000000000..9654cdf5c2 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Euler-Math-Toolbox/hofstadter-figure-figure-sequences.euler @@ -0,0 +1,19 @@ +>function RSstep (r,s) ... +$ n=cols(r); +$ r=r|(r[n]+s[n]); +$ s=s|(max(s[n]+1,r[n]+1):r[n+1]-1); +$ return {r,s}; +$ endfunction +>function RS (n) ... +$ if n==1 then return {[1],[2]}; endif; +$ if n==2 then return {[1,3],[2]}; endif; +$ r=[1,3]; s=[2,4]; +$ loop 3 to n; {r,s}=RSstep(r,s); end; +$ return {r,s}; +$ endfunction +>{r,s}=RS(10); +>r + [ 1 3 7 12 18 26 35 45 56 69 ] +>{r,s}=RS(50); +>all(sort(r[1:40]|s[1:960])==(1:1000)) + 1 diff --git a/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-1.factor b/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-1.factor new file mode 100644 index 0000000000..28392abf20 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-1.factor @@ -0,0 +1,21 @@ +SYMBOL: S V{ 2 } S set +SYMBOL: R V{ 1 } R set + +: next ( s r -- news newr ) +2dup [ last ] bi@ + suffix +dup [ + [ dup last 1 + dup ] dip member? [ 1 + ] when suffix +] dip ; + +: inc-SR ( n -- ) +dup 0 <= +[ drop ] +[ [ S get R get ] dip [ next ] times R set S set ] +if ; + +: ffs ( n -- S(n) ) +dup S get length - inc-SR +1 - S get nth ; +: ffr ( n -- R(n) ) +dup R get length - inc-SR +1 - R get nth ; diff --git a/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-2.factor b/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-2.factor new file mode 100644 index 0000000000..52a1be58d2 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Factor/hofstadter-figure-figure-sequences-2.factor @@ -0,0 +1,4 @@ +( scratchpad ) 10 iota [ 1 + ffr ] map . +{ 1 3 7 12 18 26 35 45 56 69 } +( scratchpad ) 40 iota [ 1 + ffr ] map 960 iota [ 1 + ffs ] map append 1000 iota 1 v+n set= . +t diff --git a/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-1.go b/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-1.go new file mode 100644 index 0000000000..2f3401e742 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-1.go @@ -0,0 +1,56 @@ +package main + +import "fmt" + +var ffr, ffs func(int) int + +// The point of the init function is to encapsulate r and s. If you are +// not concerned about that or do not want that, r and s can be variables at +// package level and ffr and ffs can be ordinary functions at package level. +func init() { + // task 1, 2 + r := []int{0, 1} + s := []int{0, 2} + + ffr = func(n int) int { + for len(r) <= n { + nrk := len(r) - 1 // last n for which r(n) is known + rNxt := r[nrk] + s[nrk] // next value of r: r(nrk+1) + r = append(r, rNxt) // extend sequence r by one element + for sn := r[nrk] + 2; sn < rNxt; sn++ { + s = append(s, sn) // extend sequence s up to rNext + } + s = append(s, rNxt+1) // extend sequence s one past rNext + } + return r[n] + } + + ffs = func(n int) int { + for len(s) <= n { + ffr(len(r)) + } + return s[n] + } +} + +func main() { + // task 3 + for n := 1; n <= 10; n++ { + fmt.Printf("r(%d): %d\n", n, ffr(n)) + } + // task 4 + var found [1001]int + for n := 1; n <= 40; n++ { + found[ffr(n)]++ + } + for n := 1; n <= 960; n++ { + found[ffs(n)]++ + } + for i := 1; i <= 1000; i++ { + if found[i] != 1 { + fmt.Println("task 4: FAIL") + return + } + } + fmt.Println("task 4: PASS") +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-2.go b/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-2.go new file mode 100644 index 0000000000..ca74b411ac --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Go/hofstadter-figure-figure-sequences-2.go @@ -0,0 +1,49 @@ +package main +import "fmt" + +type xint int64 +func R() (func() (xint)) { + r, s := xint(0), func() (xint) (nil) + return func() (xint) { + switch { + case r < 1: r = 1 + case r < 3: r = 3 + default: + if s == nil { + s = S() + s() + } + r += s() + } + if r < 0 { panic("r overflow") } + return r + } +} + +func S() (func() (xint)) { + s, r1, r := xint(0), xint(0), func() (xint) (nil) + return func() (xint) { + if s < 2 { + s = 2 + } else { + if r == nil { + r = R() + r() + r1 = r() + } + s++ + if s > r1 { r1 = r() } + if s == r1 { s++ } + } + if s < 0 { panic("s overflow") } + return s + } +} + +func main() { + r, sum := R(), xint(0) + for i := 0; i < 10000000; i++ { + sum += r() + } + fmt.Println(sum) +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-1.hs b/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-1.hs new file mode 100644 index 0000000000..1d38006862 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-1.hs @@ -0,0 +1,15 @@ +import Data.List (delete, sort) + +-- Functions by Reinhard Zumkeller +ffr n = rl !! (n - 1) where + rl = 1 : fig 1 [2 ..] + fig n (x : xs) = n' : fig n' (delete n' xs) where n' = n + x + +ffs n = rl !! n where + rl = 2 : figDiff 1 [2 ..] + figDiff n (x : xs) = x : figDiff n' (delete n' xs) where n' = n + x + +main = do + print $ map ffr [1 .. 10] + let i1000 = sort (map ffr [1 .. 40] ++ map ffs [1 .. 960]) + print (i1000 == [1 .. 1000]) diff --git a/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-2.hs b/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-2.hs new file mode 100644 index 0000000000..3b51bc7420 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Haskell/hofstadter-figure-figure-sequences-2.hs @@ -0,0 +1,12 @@ +import Data.List (sort) + +r = scanl (+) 1 s +s = 2:4:tail (compliment (tail r)) where + compliment = concat.interval + interval x = zipWith (\x y -> [x+1..y-1]) x (tail x) + +main = do + putStr "R: "; print (take 10 r) + putStr "S: "; print (take 10 s) + putStr "test 1000: "; + print ([1..1000] == sort ((take 40 r) ++ (take 960 s))) diff --git a/Task/Hofstadter-Figure-Figure-sequences/Icon/hofstadter-figure-figure-sequences.icon b/Task/Hofstadter-Figure-Figure-sequences/Icon/hofstadter-figure-figure-sequences.icon new file mode 100644 index 0000000000..bff894a0e9 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Icon/hofstadter-figure-figure-sequences.icon @@ -0,0 +1,59 @@ +link printf,ximage + +procedure main() + printf("Hofstader ff sequences R(n:= 1 to %d)\n",N := 10) + every printf("R(%d)=%d\n",n := 1 to N,ffr(n)) + + L := list(N := 1000,0) + zero := dup := oob := 0 + every n := 1 to (RN := 40) do + if not L[ffr(n)] +:= 1 then # count R occurrence + oob +:= 1 # count out of bounds + + every n := 1 to (N-RN) do + if not L[ffs(n)] +:= 1 then # count S occurrence + oob +:= 1 # count out of bounds + + every zero +:= (!L = 0) # count zeros / misses + every dup +:= (!L > 1) # count > 1's / duplicates + + printf("Results of R(1 to %d) and S(1 to %d) coverage is ",RN,(N-RN)) + if oob+zero+dup=0 then + printf("complete.\n") + else + printf("flawed\noob=%i,zero=%i,dup=%i\nL:\n%s\nR:\n%s\nS:\n%s\n", + oob,zero,dup,ximage(L),ximage(ffr(ffr)),ximage(ffs(ffs))) +end + +procedure ffr(n) +static R,S +initial { + R := [1] + S := ffs(ffs) # get access to S in ffs + } + + if n === ffr then return R # secret handshake to avoid globals :) + + if integer(n) > 0 then + return R[n] | put(R,ffr(n-1) + ffs(n-1))[n] +end + +procedure ffs(n) +static R,S +initial { + S := [2] + R := ffr(ffr) # get access to R in ffr + } + + if n === ffs then return S # secret handshake to avoid globals :) + + if integer(n) > 0 then { + if S[n] then return S[n] + else { + t := S[*S] + until *S = n do + if (t +:= 1) = !R then next # could be optimized with more code + else return put(S,t)[*S] # extend S + } + } +end diff --git a/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-1.j b/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-1.j new file mode 100644 index 0000000000..43258a30fe --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-1.j @@ -0,0 +1,11 @@ +R=: 1 1 3 +S=: 0 2 4 +FF=: 3 :0 + while. +./y>:R,&#S do. + R=: R,({:R)+(<:#R){S + S=: (i.<:+/_2{.R)-.R + end. + R;S +) +ffr=: { 0 {:: FF@(>./@,) +ffs=: { 1 {:: FF@(0,>./@,) diff --git a/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-2.j b/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-2.j new file mode 100644 index 0000000000..f773441346 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/J/hofstadter-figure-figure-sequences-2.j @@ -0,0 +1,4 @@ + ffr 1+i.10 +1 3 7 12 18 26 35 45 56 69 + (1+i.1000) -: /:~ (ffr 1+i.40), ffs 1+i.960 +1 diff --git a/Task/Hofstadter-Figure-Figure-sequences/Java/hofstadter-figure-figure-sequences.java b/Task/Hofstadter-Figure-Figure-sequences/Java/hofstadter-figure-figure-sequences.java new file mode 100644 index 0000000000..f6980a6c1a --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Java/hofstadter-figure-figure-sequences.java @@ -0,0 +1,56 @@ +import java.util.*; + +class Hofstadter +{ + private static List getSequence(int rlistSize, int slistSize) + { + List rlist = new ArrayList(); + List slist = new ArrayList(); + Collections.addAll(rlist, 1, 3, 7); + Collections.addAll(slist, 2, 4, 5, 6); + List list = (rlistSize > 0) ? rlist : slist; + int targetSize = (rlistSize > 0) ? rlistSize : slistSize; + while (list.size() > targetSize) + list.remove(list.size() - 1); + while (list.size() < targetSize) + { + int lastIndex = rlist.size() - 1; + int lastr = rlist.get(lastIndex).intValue(); + int r = lastr + slist.get(lastIndex).intValue(); + rlist.add(Integer.valueOf(r)); + for (int s = lastr + 1; (s < r) && (list.size() < targetSize); s++) + slist.add(Integer.valueOf(s)); + } + return list; + } + + public static int ffr(int n) + { return getSequence(n, 0).get(n - 1).intValue(); } + + public static int ffs(int n) + { return getSequence(0, n).get(n - 1).intValue(); } + + public static void main(String[] args) + { + System.out.print("R():"); + for (int n = 1; n <= 10; n++) + System.out.print(" " + ffr(n)); + System.out.println(); + + Set first40R = new HashSet(); + for (int n = 1; n <= 40; n++) + first40R.add(Integer.valueOf(ffr(n))); + + Set first960S = new HashSet(); + for (int n = 1; n <= 960; n++) + first960S.add(Integer.valueOf(ffs(n))); + + for (int i = 1; i <= 1000; i++) + { + Integer n = Integer.valueOf(i); + if (first40R.contains(n) == first960S.contains(n)) + System.out.println("Integer " + i + " either in both or neither set"); + } + System.out.println("Done"); + } +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/JavaScript/hofstadter-figure-figure-sequences.js b/Task/Hofstadter-Figure-Figure-sequences/JavaScript/hofstadter-figure-figure-sequences.js new file mode 100644 index 0000000000..7bb635805b --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/JavaScript/hofstadter-figure-figure-sequences.js @@ -0,0 +1,47 @@ +var R = [null, 1]; +var S = [null, 2]; + +var extend_sequences = function (n) { + var current = Math.max(R[R.length-1],S[S.length-1]); + var i; + while (R.length <= n || S.length <= n) { + i = Math.min(R.length, S.length) - 1; + current += 1; + if (current === R[i] + S[i]) { + R.push(current); + } else { + S.push(current); + } + } +} + +var ffr = function(n) { + extend_sequences(n); + return R[n]; +}; + +var ffs = function(n) { + extend_sequences(n); + return S[n]; +}; + +for (var i = 1; i <=10; i += 1) { + console.log('R('+ i +') = ' + ffr(i)); +} + +var int_array = []; + +for (var i = 1; i <= 40; i += 1) { + int_array.push(ffr(i)); +} +for (var i = 1; i <= 960; i += 1) { + int_array.push(ffs(i)); +} + +int_array.sort(function(a,b){return a-b;}); + +for (var i = 1; i <= 1000; i += 1) { + if (int_array[i-1] !== i) { + throw "Something's wrong!" + } else { console.log("1000 integer check ok."); } +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/MATLAB/hofstadter-figure-figure-sequences.m b/Task/Hofstadter-Figure-Figure-sequences/MATLAB/hofstadter-figure-figure-sequences.m new file mode 100644 index 0000000000..9d55b4fd8a --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/MATLAB/hofstadter-figure-figure-sequences.m @@ -0,0 +1,24 @@ + function [R,S] = ffr_ffs(N) + t = [1,0]; + T = 1; + n = 1; + %while T<=1000, + while n<=N, + R = find(t,n); + S = find(~t,n); + T = R(n)+S(n); + + % pre-allocate memory, this improves performance + if T > length(t), t = [t,zeros(size(t))]; end; + + t(T) = 1; + n = n + 1; + end; + if nargout>0, + r = max(R); + s = max(S); + else + printf('Sequence R:\n'); disp(R); + printf('Sequence S:\n'); disp(S); + end; + end; diff --git a/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-1.mathematica b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-1.mathematica new file mode 100644 index 0000000000..824e234a66 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-1.mathematica @@ -0,0 +1,5 @@ + ffr[j_] := Module[{R = {1}, S = 2, k = 1}, + Do[While[Position[R, S] != {}, S++]; k = k + S; S++; + R = Append[R, k], {n, 1, j - 1}]; R] + + ffs[j_] := Differences[ffr[j + 1]] diff --git a/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-2.mathematica b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-2.mathematica new file mode 100644 index 0000000000..c64cbe9963 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-2.mathematica @@ -0,0 +1,4 @@ + ffr[10] + + (* out *) + {1, 3, 7, 12, 18, 26, 35, 45, 56, 69} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-3.mathematica b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-3.mathematica new file mode 100644 index 0000000000..9c8b210d21 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Mathematica/hofstadter-figure-figure-sequences-3.mathematica @@ -0,0 +1,6 @@ + t = Sort[Join[ffr[40], ffs[960]]]; + + t == Range[1000] + + (* out *) + True diff --git a/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-1.l b/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-1.l new file mode 100644 index 0000000000..8945e337f7 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-1.l @@ -0,0 +1,17 @@ +(setq *RNext 2) + +(de ffr (N) + (cache '(NIL) (pack (char (hash N)) N) + (if (= 1 N) + 1 + (+ (ffr (dec N)) (ffs (dec N))) ) ) ) + +(de ffs (N) + (cache '(NIL) (pack (char (hash N)) N) + (if (= 1 N) + 2 + (let S (inc (ffs (dec N))) + (when (= S (ffr *RNext)) + (inc 'S) + (inc '*RNext) ) + S ) ) ) ) diff --git a/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-2.l b/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-2.l new file mode 100644 index 0000000000..ab65c1b0e0 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/PicoLisp/hofstadter-figure-figure-sequences-2.l @@ -0,0 +1,7 @@ +: (mapcar ffr (range 1 10)) +-> (1 3 7 12 18 26 35 45 56 69) + +: (= + (range 1 1000) + (sort (conc (mapcar ffr (range 1 40)) (mapcar ffs (range 1 960)))) ) +-> T diff --git a/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-1.pro b/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-1.pro new file mode 100644 index 0000000000..7552c8d4d7 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-1.pro @@ -0,0 +1,25 @@ +:- use_module(library(chr)). + +:- chr_constraint ffr/2, ffs/2, hofstadter/1,hofstadter/2. +:- chr_option(debug, off). +:- chr_option(optimize, full). + +% to remove duplicates +ffr(N, R1) \ ffr(N, R2) <=> R1 = R2 | true. +ffs(N, R1) \ ffs(N, R2) <=> R1 = R2 | true. + +% compute ffr +ffr(N, R), ffr(N1, R1), ffs(N1,S1) ==> + N > 1, N1 is N - 1 | + R is R1 + S1. + +% compute ffs +ffs(N, S), ffs(N1,S1) ==> + N > 1, N1 is N - 1 | + V is S1 + 1, + ( find_chr_constraint(ffr(_, V)) -> S is V+1; S = V). + +% init +hofstadter(N) ==> ffr(1,1), ffs(1,2). +% loop +hofstadter(N), ffr(N1, _R), ffs(N1, _S) ==> N1 < N, N2 is N1 +1 | ffr(N2,_), ffs(N2,_). diff --git a/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-2.pro b/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-2.pro new file mode 100644 index 0000000000..c22b6b30c2 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Prolog/hofstadter-figure-figure-sequences-2.pro @@ -0,0 +1,14 @@ +hofstadter :- + hofstadter(960), + % fetch the values of ffr + bagof(Y, X^find_chr_constraint(ffs(X,Y)), L1), + % fetch the values of ffs + bagof(Y, X^(find_chr_constraint(ffr(X,Y)), X < 41), L2), + % concatenate then + append(L1, L2, L3), + % sort removing duplicates + sort(L3, L4), + % check the correctness of the list + ( (L4 = [1|_], last(L4, 1000), length(L4, 1000)) -> writeln(ok); writeln(ko)), + % to remove all pending constraints + fail. diff --git a/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-1.py b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-1.py new file mode 100644 index 0000000000..c29d165a81 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-1.py @@ -0,0 +1,46 @@ +def ffr(n): + if n < 1 or type(n) != int: raise ValueError("n must be an int >= 1") + try: + return ffr.r[n] + except IndexError: + r, s = ffr.r, ffs.s + ffr_n_1 = ffr(n-1) + lastr = r[-1] + # extend s up to, and one past, last r + s += list(range(s[-1] + 1, lastr)) + if s[-1] < lastr: s += [lastr + 1] + # access s[n-1] temporarily extending s if necessary + len_s = len(s) + ffs_n_1 = s[n-1] if len_s > n else (n - len_s) + s[-1] + ans = ffr_n_1 + ffs_n_1 + r.append(ans) + return ans +ffr.r = [None, 1] + +def ffs(n): + if n < 1 or type(n) != int: raise ValueError("n must be an int >= 1") + try: + return ffs.s[n] + except IndexError: + r, s = ffr.r, ffs.s + for i in range(len(r), n+2): + ffr(i) + if len(s) > n: + return s[n] + raise Exception("Whoops!") +ffs.s = [None, 2] + +if __name__ == '__main__': + first10 = [ffr(i) for i in range(1,11)] + assert first10 == [1, 3, 7, 12, 18, 26, 35, 45, 56, 69], "ffr() value error(s)" + print("ffr(n) for n = [1..10] is", first10) + # + bin = [None] + [0]*1000 + for i in range(40, 0, -1): + bin[ffr(i)] += 1 + for i in range(960, 0, -1): + bin[ffs(i)] += 1 + if all(b == 1 for b in bin[1:1000]): + print("All Integers 1..1000 found OK") + else: + print("All Integers 1..1000 NOT found only once: ERROR") diff --git a/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-2.py b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-2.py new file mode 100644 index 0000000000..63ad6b581c --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-2.py @@ -0,0 +1,29 @@ +cR = [1] +cS = [2] + +def extend_RS(): + x = cR[len(cR) - 1] + cS[len(cR) - 1] + cR.append(x) + cS += range(cS[-1] + 1, x) + cS.append(x + 1) + +def ff_R(n): + assert(n > 0) + while n > len(cR): extend_RS() + return cR[n - 1] + +def ff_S(n): + assert(n > 0) + while n > len(cS): extend_RS() + return cS[n - 1] + +# tests +print([ ff_R(i) for i in range(1, 11) ]) + +s = {} +for i in range(1, 1001): s[i] = 0 +for i in range(1, 41): del s[ff_R(i)] +for i in range(1, 961): del s[ff_S(i)] + +# the fact that we got here without a key error +print("Ok") diff --git a/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-3.py b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-3.py new file mode 100644 index 0000000000..7af4f3512a --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-3.py @@ -0,0 +1,2 @@ +[1, 3, 7, 12, 18, 26, 35, 45, 56, 69] +Ok diff --git a/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-4.py b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-4.py new file mode 100644 index 0000000000..f63a81fdd7 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Python/hofstadter-figure-figure-sequences-4.py @@ -0,0 +1,26 @@ +from itertools import islice + +def R(): + n = 1 + yield n + for s in S(): + n += s + yield n; + +def S(): + yield 2 + yield 4 + u = 5 + for r in R(): + if r <= u: continue; + for x in range(u, r): yield x + u = r + 1 + +def lst(s, n): return list(islice(s(), n)) + +print "R:", lst(R, 10) +print "S:", lst(S, 10) +print sorted(lst(R, 40) + lst(S, 960)) == list(range(1,1001)) + +# perf test case +# print sum(lst(R, 10000000)) diff --git a/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-1.rexx b/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-1.rexx new file mode 100644 index 0000000000..f30b698cef --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-1.rexx @@ -0,0 +1,51 @@ +/*REXX pgm to calculate & verify the Hofstadter Figure-Figure sequences.*/ +parse arg x highV . /*obtain any C.L. specifications.*/ +if x=='' then x=10; if highV=='' then highV=1000 /*use the defaults?*/ +low=1 /*use unity as the starting point*/ +if x<0 then low=abs(x) /*only show a single │X│ value.*/ +r.=0; r.1=1; rr.=r.; rr.1=1 /*initialize the R and RR arrays.*/ +s.=0; s.1=2; ss.=s.; ss.2=1 /* " " S " SS " .*/ +errs=0 + do i=low to abs(x) /*show first X values of R & S */ + say right('R('i") =",20) right(ffr(i),7), /*show nice*/ + right('S('i") =",20) right(ffs(i),7) /* R & S */ + end /*i*/ +if x<1 then exit /*stick a fork in it, we're done.*/ +/*═══════════════════════════════════════verify 1st 1k: unique & present*/ +both.=0 /*initialize the BOTH array. */ + /*build list of 1st 40 R values.*/ + do m=1 for 40; r=ffr(m) /*calculate 1st 40 R values.*/ + both.r=1 /*build the BOTH array. */ + end /*m*/ + + do n=1 for 960; s=ffs(n) /*calculate 1st 960 S values.*/ + if both.s then call sayErr 'duplicate number in R and S lists:' s + both.s=1 /*add to the BOTH array. */ + end /*n*/ + /*verify presence and uniqueness.*/ + do v=1 for highV /*verify all 1 ≤ # ≤ 1k present.*/ + if \both.v then call sayErr 'missing R │ S:' v + end /*v*/ +say +@v='verification'; @i=" [inclusive]." /*shortcuts to shorten prog width*/ +if errs==0 then say @v 'completed for all numbers from 1 ──►' highV @i + else say @v 'failed with' errs "errors." +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────FFR subroutine──────────────────────*/ +ffr: procedure expose r. s. rr. ss.; parse arg n +if r.n\==0 then return r.n /*Defined? Then return the value.*/ +_=ffr(n-1)+ffs(n-1) /*calculate the FFR value. */ +r.n=_; rr._=1 /*assign the value to R and RR.*/ +return _ /*return the value to the invoker*/ +/*──────────────────────────────────FFS subroutine──────────────────────*/ +ffs: procedure expose r. s. rr. ss.; parse arg n +if s.n\==0 then return s.n /*Defined? Then return the value.*/ + do k=1 for n while s.n==0 /*search for not null R │ S num.*/ + if s.k\==0 & ffr(k)\==0 then iterate + km=k-1; _=s.km+1 /*the next SS number, possibly.*/ + _=_+rr._ /*maybe adjust for the FRR num.*/ + s.k=_; ss._=1 /*define couple of FFS numbers.*/ + end /*k*/ +return s.n /*return the value to the invoker*/ +/*──────────────────────────────────SAYERR subroutine───────────────────*/ +sayErr: errs=errs+1; say; say '***error***!'; say; say arg(1); say; return diff --git a/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-2.rexx b/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-2.rexx new file mode 100644 index 0000000000..ed77be02a2 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/REXX/hofstadter-figure-figure-sequences-2.rexx @@ -0,0 +1,72 @@ +/* REXX ************************************************************** +* 21.11.2012 Walter Pachl transcribed from PL/I +**********************************************************************/ + Call time 'R' + Say 'Verification that the first 40 FFR numbers and the first' + Say '960 FFS numbers result in the integers 1 to 1000 only.' + t.=0 + num.='' + do i = 1 to 40 + j = ffr(i) + if t.j then Say 'error, duplicate value at ' || i + else t.j = 1 + num.i=j + end + nn=0 + Say time('E') 'seconds elapsed' + Do i=1 To 3 + ol='' + Do j=1 To 15 + nn=nn+1 + ol=ol right(num.nn,3) + End + Say ol + End + do i = 1 to 960 + j = ffs(i) + if t.j then + Say 'error, duplicate value at ' || i + else t.j = 1 + end + Do i=1 To 1000 + if t.i=0 Then + Say i 'was not set' + End + If i>1000 Then + Say 'passed test' + Say time('E') 'seconds elapsed' + Exit + + ffr: procedure Expose v. + Parse Arg n + v.= 0 + v.1 = 1 + if n = 1 then return 1 + r = 1 + do i = 2 to n + do j = 2 to 2*n + if v.j = 0 then leave + end + v.j = 1 + s = j + r = r + s + if r <= 2*n then v.r = 1 + end + return r + + ffs: procedure Expose v. + Parse Arg n + v.= 0 + v.1 = 1 + if n = 1 then return 2 + r = 1 + do i = 1 to n + do j = 2 to 2*n + if v.j = 0 then leave + end + v.j = 1 + s = j + r = r + s + if r <= 2*n then v.r = 1 + end + return s diff --git a/Task/Hofstadter-Figure-Figure-sequences/Ruby/hofstadter-figure-figure-sequences.rb b/Task/Hofstadter-Figure-Figure-sequences/Ruby/hofstadter-figure-figure-sequences.rb new file mode 100644 index 0000000000..ae900c11b7 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Ruby/hofstadter-figure-figure-sequences.rb @@ -0,0 +1,42 @@ +$r = [nil, 1] +$s = [nil, 2] + +def buildSeq(n) + current = [ $r[-1], $s[-1] ].max + while $r.length <= n || $s.length <= n + idx = [ $r.length, $s.length ].min - 1 + current += 1 + if current == $r[idx] + $s[idx] + $r << current + else + $s << current + end + end +end + +def ffr(n) + buildSeq(n) + $r[n] +end + +def ffs(n) + buildSeq(n) + $s[n] +end + +require 'set' +require 'test/unit' + +class TestHofstadterFigureFigure < Test::Unit::TestCase + def test_first_ten_R_values + r10 = 1.upto(10).map {|n| ffr(n)} + assert_equal(r10, [1, 3, 7, 12, 18, 26, 35, 45, 56, 69]) + end + + def test_40_R_and_960_S_are_1_to_1000 + rs_values = Set.new + rs_values.merge( 1.upto(40).collect {|n| ffr(n)} ) + rs_values.merge( 1.upto(960).collect {|n| ffs(n)} ) + assert_equal(rs_values, Set.new( 1..1000 )) + end +end diff --git a/Task/Hofstadter-Figure-Figure-sequences/Scala/hofstadter-figure-figure-sequences.scala b/Task/Hofstadter-Figure-Figure-sequences/Scala/hofstadter-figure-figure-sequences.scala new file mode 100644 index 0000000000..7f1be3d48f --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Scala/hofstadter-figure-figure-sequences.scala @@ -0,0 +1,27 @@ +object HofstadterFigFigSeq extends App { + import scala.collection.mutable.ListBuffer + + val r = ListBuffer(0, 1) + val s = ListBuffer(0, 2) + + def ffr(n: Int): Int = { + val ffri: Int => Unit = i => { + val nrk = r.size - 1 + val rNext = r(nrk)+s(nrk) + r += rNext + (r(nrk)+2 to rNext-1).foreach{s += _} + s += rNext+1 + } + + (r.size to n).foreach(ffri(_)) + r(n) + } + + def ffs(n:Int): Int = { + while (s.size <= n) ffr(r.size) + s(n) + } + + (1 to 10).map(i=>(i,ffr(i))).foreach(t=>println("r("+t._1+"): "+t._2)) + println((1 to 1000).toList.filterNot(((1 to 40).map(ffr(_))++(1 to 960).map(ffs(_))).contains)==List()) +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/Tcl/hofstadter-figure-figure-sequences.tcl b/Task/Hofstadter-Figure-Figure-sequences/Tcl/hofstadter-figure-figure-sequences.tcl new file mode 100644 index 0000000000..108c211caa --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/Tcl/hofstadter-figure-figure-sequences.tcl @@ -0,0 +1,43 @@ +package require Tcl 8.5 +package require struct::set + +# Core sequence generator engine; stores in $R and $S globals +set R {R:-> 1} +set S {S:-> 2} +proc buildSeq {n} { + global R S + set ctr [expr {max([lindex $R end],[lindex $S end])}] + while {[llength $R] <= $n || [llength $S] <= $n} { + set idx [expr {min([llength $R],[llength $S]) - 1}] + if {[incr ctr] == [lindex $R $idx]+[lindex $S $idx]} { + lappend R $ctr + } else { + lappend S $ctr + } + } +} + +# Accessor procedures +proc ffr {n} { + buildSeq $n + lindex $::R $n +} +proc ffs {n} { + buildSeq $n + lindex $::S $n +} + +# Show some things about the sequence +for {set i 1} {$i <= 10} {incr i} { + puts "R($i) = [ffr $i]" +} +puts "Considering {1..1000} vs {R(i)|i\u2208\[1,40\]}\u222a{S(i)|i\u2208\[1,960\]}" +for {set i 1} {$i <= 1000} {incr i} {lappend numsInSeq $i} +for {set i 1} {$i <= 40} {incr i} { + lappend numsRS [ffr $i] +} +for {set i 1} {$i <= 960} {incr i} { + lappend numsRS [ffs $i] +} +puts "set sizes: [struct::set size $numsInSeq] vs [struct::set size $numsRS]" +puts "set equality: [expr {[struct::set equal $numsInSeq $numsRS]?{yes}:{no}}]" diff --git a/Task/Hofstadter-Q-sequence/0DESCRIPTION b/Task/Hofstadter-Q-sequence/0DESCRIPTION new file mode 100644 index 0000000000..ed250259b0 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/0DESCRIPTION @@ -0,0 +1,14 @@ +The [[wp:Hofstadter_sequence#Hofstadter_Q_sequence|Hofstadter Q sequence]] is defined as: +:\begin{align} +Q(1)&=Q(2)=1, \\ +Q(n)&=Q\big(n-Q(n-1)\big)+Q\big(n-Q(n-2)\big), \quad n>2. +\end{align} +It is defined like the [[Fibonacci sequence]], but whereas the next term in the Fibonacci sequence is the sum of the previous two terms, in the Q sequence the previous two terms tell you how far to go back in the Q sequence to find the two numbers to sum to make the next term of the sequence. + +;Task: +* Confirm and display that the first ten terms of the sequence are: 1, 1, 2, 3, 3, 4, 5, 5, 6, and 6 +* Confirm and display that the 1000th term is: 502 + +;Optional extra credit +* Count and display how many times a member of the sequence is less than its preceding term for terms up to and including the 100,000'th term. +* Ensure that the extra credit solution 'safely' handles being initially asked for an n'th term where n is large.
(This point is to ensure that caching and/or recursion limits, if it is a concern, is correctly handled). diff --git a/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg b/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg new file mode 100644 index 0000000000..071be33dcf --- /dev/null +++ b/Task/Hofstadter-Q-sequence/ALGOL-68/hofstadter-q-sequence.alg @@ -0,0 +1,24 @@ +#!/usr/local/bin/a68g --script # + +INT n = 100000; +main: +( + INT flip; + [n]INT q; + + q[1] := q[2] := 1; + + FOR i FROM 3 TO n DO + q[i] := q[i - q[i - 1]] + q[i - q[i - 2]] OD; + + FOR i TO 10 DO + printf(($g(0)$, q[i], $b(l,x)$, i = 10)) OD; + + printf(($g(0)l$, q[1000])); + + flip := 0; + FOR i TO n-1 DO + flip +:= ABS (q[i] > q[i + 1]) OD; + + printf(($"flips: "g(0)l$, flip)) +) diff --git a/Task/Hofstadter-Q-sequence/AWK/hofstadter-q-sequence.awk b/Task/Hofstadter-Q-sequence/AWK/hofstadter-q-sequence.awk new file mode 100644 index 0000000000..8c10fbfabe --- /dev/null +++ b/Task/Hofstadter-Q-sequence/AWK/hofstadter-q-sequence.awk @@ -0,0 +1,22 @@ +#!/usr/bin/awk -f +BEGIN { + N = 100000; + print "Q-sequence(1..10) : " Qsequence(10); + Qsequence(N,Q); + print "1000th number of Q sequence : " Q[1000]; + for (n=2; n<=N; n++) { + if (Q[n] 2 + + Q_Store: array(1 .. Last) of Natural := (1 => 1, 2 => 1, others => 0); + -- "global" array to store the Q(I) + -- if Q_Store(I)=0, we compute Q(I) and update Q_Store(I) + -- else we already know Q(I) = Q_Store(I) + + function Q(N: Positive) return Positive is + begin + if Q_Store(N) = 0 then + Q_Store(N) := Q(N - Q(N-1)) + Q(N-Q(N-2)); + end if; + return Q_Store(N); + end Q; + + begin + for I in First .. Last loop + Q_Proc(Q(I)); + end loop; + end Q; + + procedure Print(P: Positive) is + begin + Ada.Text_IO.Put(Positive'Image(P)); + end Print; + + Decrease_Counter: Natural := 0; + Previous_Value: Positive := 1; + + procedure Decrease_Count(P: Positive) is + begin + if P < Previous_Value then + Decrease_Counter := Decrease_Counter + 1; + end if; + Previous_Value := P; + end Decrease_Count; + +begin + Q(1, 10, Print'Access); + -- the first ten terms of the sequence are: 1, 1, 2, 3, 3, 4, 5, 5, 6, and 6 + Ada.Text_IO.New_Line; + + Q(1000, 1000, Print'Access); + -- the 1000'th term is: 502 + Ada.Text_IO.New_Line; + + Q(2, 100_000, Decrease_Count'Access); + Ada.Text_IO.Put_Line(Integer'Image(Decrease_Counter)); + -- how many times a member of the sequence is less than its preceding term + -- for terms up to and including the 100,000'th term +end Hofstadter_Q_Sequence; diff --git a/Task/Hofstadter-Q-sequence/BBC-BASIC/hofstadter-q-sequence.bbc b/Task/Hofstadter-Q-sequence/BBC-BASIC/hofstadter-q-sequence.bbc new file mode 100644 index 0000000000..95de5f81db --- /dev/null +++ b/Task/Hofstadter-Q-sequence/BBC-BASIC/hofstadter-q-sequence.bbc @@ -0,0 +1,18 @@ + PRINT "First 10 terms of Q = " ; + FOR i% = 1 TO 10 : PRINT ;FNq(i%, c%) " "; : NEXT : PRINT + PRINT "1000th term = " ; FNq(1000, c%) + PRINT "100000th term = " ; FNq(100000, c%) + PRINT "Term is less than preceding term " ; c% " times" + END + + DEF FNq(n%, RETURN c%) + LOCAL i%,q%() + IF n% < 3 THEN = 1 ELSE IF n% = 3 THEN = 2 + DIM q%(n%) + q%(1) = 1 : q%(2) = 1 : q%(3) = 2 + c% = 0 + FOR i% = 3 TO n% + q%(i%) = q%(i% - q%(i%-1)) + q%(i% - q%(i%-2)) + IF q%(i%) < q%(i%-1) THEN c% += 1 + NEXT + = q%(n%) diff --git a/Task/Hofstadter-Q-sequence/C++/hofstadter-q-sequence.cpp b/Task/Hofstadter-Q-sequence/C++/hofstadter-q-sequence.cpp new file mode 100644 index 0000000000..57d70bc677 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/C++/hofstadter-q-sequence.cpp @@ -0,0 +1,21 @@ +#include + +int main( ) { + int hofstadters[100000] ; + hofstadters[ 0 ] = 1 ; + hofstadters[ 1 ] = 1 ; + for ( int i = 3 ; i < 100000 ; i++ ) + hofstadters[ i - 1 ] = hofstadters[ i - 1 - hofstadters[ i - 1 - 1 ]] + + hofstadters[ i - 1 - hofstadters[ i - 2 - 1 ]] ; + std::cout << "The first 10 numbers are:\n" ; + for ( int i = 0 ; i < 10 ; i++ ) + std::cout << hofstadters[ i ] << std::endl ; + std::cout << "The 1000'th term is " << hofstadters[ 999 ] << " !" << std::endl ; + int less_than_preceding = 0 ; + for ( int i = 0 ; i < 99999 ; i++ ) { + if ( hofstadters[ i + 1 ] < hofstadters[ i ] ) + less_than_preceding++ ; + } + std::cout << less_than_preceding << " times a number was preceded by a greater number!\n" ; + return 0 ; +} diff --git a/Task/Hofstadter-Q-sequence/C-sharp/hofstadter-q-sequence.cs b/Task/Hofstadter-Q-sequence/C-sharp/hofstadter-q-sequence.cs new file mode 100644 index 0000000000..3d1e6c244f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/C-sharp/hofstadter-q-sequence.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; + +namespace HofstadterQSequence +{ + class Program + { + // Initialize the dictionary with the first two indices filled. + private static readonly Dictionary QList = new Dictionary + { + {1, 1}, + {2, 1} + }; + + private static void Main() + { + int lessThanLast = 0; + /* Initialize our variable that holds the number of times + * a member of the sequence was less than its preceding term. */ + + for (int n = 1; n <= 100000; n++) + { + int q = Q(n); // Get Q(n). + + if (n > 1 && QList[n - 1] > q) // If Q(n) is less than Q(n - 1), + lessThanLast++; // then add to the counter. + + if (n > 10 && n != 1000) continue; /* If n is greater than 10 and not 1000, + * the rest of the code in the loop does not apply, + * and it will be skipped. */ + + if (!Confirm(n, q)) // Confirm Q(n) is correct. + throw new Exception(string.Format("Invalid result: Q({0}) != {1}", n, q)); + + Console.WriteLine("Q({0}) = {1}", n, q); // Write Q(n) to the console. + } + + Console.WriteLine("Number of times a member of the sequence was less than its preceding term: {0}.", + lessThanLast); + } + + private static bool Confirm(int n, int value) + { + if (n <= 10) + return new[] {1, 1, 2, 3, 3, 4, 5, 5, 6, 6}[n - 1] == value; + if (n == 1000) + return 502 == value; + throw new ArgumentException("Invalid index.", "n"); + } + + private static int Q(int n) + { + int q; + + if (!QList.TryGetValue(n, out q)) // Try to get Q(n) from the dictionary. + { + q = Q(n - Q(n - 1)) + Q(n - Q(n - 2)); // If it's not available, then calculate it. + QList.Add(n, q); // Add it to the dictionary. + } + + return q; + } + } +} diff --git a/Task/Hofstadter-Q-sequence/C/hofstadter-q-sequence.c b/Task/Hofstadter-Q-sequence/C/hofstadter-q-sequence.c new file mode 100644 index 0000000000..df7f8f5c6f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/C/hofstadter-q-sequence.c @@ -0,0 +1,24 @@ +#include +#include + +#define N 100000 +int main() +{ + int i, flip, *q = (int*)malloc(sizeof(int) * N) - 1; + + q[1] = q[2] = 1; + + for (i = 3; i <= N; i++) + q[i] = q[i - q[i - 1]] + q[i - q[i - 2]]; + + for (i = 1; i <= 10; i++) + printf("%d%c", q[i], i == 10 ? '\n' : ' '); + + printf("%d\n", q[1000]); + + for (flip = 0, i = 1; i < N; i++) + flip += q[i] > q[i + 1]; + + printf("flips: %d\n", flip); + return 0; +} diff --git a/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-1.lisp b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-1.lisp new file mode 100644 index 0000000000..c37c17cc7b --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-1.lisp @@ -0,0 +1,27 @@ +(defparameter *mm* (make-hash-table :test #'equal)) + +;;; generic memoization macro +(defmacro defun-memoize (f (&rest args) &body body) + (defmacro hash () `(gethash (cons ',f (list ,@args)) *mm*)) + (let ((h (gensym))) + `(defun ,f (,@args) + (let ((,h (hash))) + (if ,h ,h + (setf (hash) (progn ,@body))))))) + +;;; def q +(defun-memoize q (n) + (if (<= n 2) 1 + (+ (q (- n (q (- n 1)))) + (q (- n (q (- n 2))))))) + +;;; test +(format t "First of Q: ~a~%Q(1000): ~a~%Bumps up to 100000: ~a~%" + (loop for i from 1 to 10 collect (q i)) + (q 1000) + (loop with c = 0 with last-q = (q 1) + for i from 2 to 100000 + do (let ((next-q (q i))) + (if (< next-q last-q) (incf c)) + (setf last-q next-q)) + finally (return c))) diff --git a/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-2.lisp b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-2.lisp new file mode 100644 index 0000000000..a601e9757d --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-2.lisp @@ -0,0 +1,3 @@ +First of Q: (1 1 2 3 3 4 5 5 6 6) +Q(1000): 502 +Bumps up to 100000: 49798 diff --git a/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-3.lisp b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-3.lisp new file mode 100644 index 0000000000..363deb7e14 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Common-Lisp/hofstadter-q-sequence-3.lisp @@ -0,0 +1,12 @@ +(let ((cc (make-array 3 :element-type 'integer + :initial-element 1 + :adjustable t + :fill-pointer 3))) + (defun q (n) + (when (>= n (length cc)) + (loop for i from (length cc) below n do (q i)) + (vector-push-extend + (+ (aref cc (- n (aref cc (- n 1)))) + (aref cc (- n (aref cc (- n 2))))) + cc)) + (aref cc n))) diff --git a/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-1.d b/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-1.d new file mode 100644 index 0000000000..d1e66c43d2 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-1.d @@ -0,0 +1,17 @@ +import std.stdio, std.algorithm, std.functional, std.range; + +int Q(int n) { + assert(n > 0); + alias memoize!Q mQ; + if (n == 1 || n == 2) + return 1; + else + return mQ(n - mQ(n - 1)) + mQ(n - mQ(n - 2)); +} + +void main() { + writeln("Q(n) for n = [1..10] is: ", map!Q(iota(1, 11))); + writeln("Q(1000) = ", Q(1000)); + writefln("Q(i) is less than Q(i-1) for i [2..100_000] %d times.", + count!(i => Q(i) < Q(i-1))(iota(2, 100_001))); +} diff --git a/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-2.d b/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-2.d new file mode 100644 index 0000000000..17fd7da1b4 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/D/hofstadter-q-sequence-2.d @@ -0,0 +1,23 @@ +import std.stdio, std.algorithm, std.range, std.array; + +struct Q { + static Appender!(uint[]) s; + + /*nothrow*/ static this() { + s ~= [0, 1, 1]; + } + + static uint opCall(in int n) /*nothrow*/ { + assert(n > 0); + foreach (immutable i; s.data.length .. n + 1) + s ~= s.data[i - s.data[i - 1]] + s.data[i - s.data[i - 2]]; + return s.data[n]; + } +} + +void main() { + writeln("Q(n) for n = [1..10] is: ", map!Q(iota(1, 11))); + writeln("Q(1000) = ", Q(1000)); + writefln("Q(i) is less than Q(i-1) for i [2..100_000] %d times.", + count!(i => Q(i) < Q(i-1))(iota(2, 100_001))); +} diff --git a/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-1.dart b/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-1.dart new file mode 100644 index 0000000000..8a695b1441 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-1.dart @@ -0,0 +1,8 @@ +int Q(int n) => n>2 ? Q(n-Q(n-1))+Q(n-Q(n-2)) : 1; + +main() { + for(int i=1;i<=10;i++) { + print("Q($i)=${Q(i)}"); + } + print("Q(1000)=${Q(1000)}"); +} diff --git a/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-2.dart b/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-2.dart new file mode 100644 index 0000000000..bc23e0e5be --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Dart/hofstadter-q-sequence-2.dart @@ -0,0 +1,42 @@ +class Q { + Map _table; + + Q() { + _table=new Map(); + _table[1]=1; + _table[2]=1; + } + + int q(int n) { + // if the cache is not filled until n-1, fill it starting with the lowest entries first + // this avoids doing a recursion from n to 2 (e.g. if you call q(1000000) first) + // this doesn't happen in the tasks calls since the cache is filled ascending + if(_table[n-1]==null) { + for(int i=_table.length;i q=new List(100001); + q[1]=q[2]=1; + + int count=0; + for(int i=3;i +%% Hofstadter Q Sequence for Rosetta Code + +-module(hofstadter). +-export([main/0]). +-define(MAX, 100000). + +flip(V2, V1) when V1 > V2 -> 1; +flip(_V2, _V1) -> 0. + +list_terms(N, N, Acc) -> + io:format("~w~n", [array:get(N, Acc)]); +list_terms(Max, N, Acc) -> + io:format("~w, ", [array:get(N, Acc)]), + list_terms(Max, N+1, Acc). + +hofstadter(N, N, Acc, Flips) -> + io:format("The first ten terms are: "), + list_terms(9, 0, Acc), + io:format("The 1000'th term is ~w~n", [array:get(999, Acc)]), + io:format("Number of flips: ~w~n", [Flips]); +hofstadter(Max, N, Acc, Flips) -> + Qn1 = array:get(N-1, Acc), + Qn = array:get(N - Qn1, Acc) + array:get(N - array:get(N-2, Acc), Acc), + hofstadter(Max, N+1, array:set(N, Qn, Acc), Flips + flip(Qn, Qn1)). + +main() -> + Tmp = array:set(0, 1, array:new(?MAX)), + Acc = array:set(1, 1, Tmp), + hofstadter(?MAX, 2, Acc, 0). diff --git a/Task/Hofstadter-Q-sequence/Factor/hofstadter-q-sequence.factor b/Task/Hofstadter-Q-sequence/Factor/hofstadter-q-sequence.factor new file mode 100644 index 0000000000..f72f18367d --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Factor/hofstadter-q-sequence.factor @@ -0,0 +1,7 @@ +( scratchpad ) : next ( seq -- newseq ) +dup 2 tail* over length [ swap - ] curry map +[ dupd swap nth ] map 0 [ + ] reduce suffix ; + +( scratchpad ) { 1 1 } 1000 [ next ] times dup 10 head . 999 swap nth . +{ 1 1 2 3 3 4 5 5 6 6 } +502 diff --git a/Task/Hofstadter-Q-sequence/Go/hofstadter-q-sequence.go b/Task/Hofstadter-Q-sequence/Go/hofstadter-q-sequence.go new file mode 100644 index 0000000000..b57ce60700 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Go/hofstadter-q-sequence.go @@ -0,0 +1,46 @@ +package main + +import "fmt" + +var m map[int]int + +func initMap() { + m = make(map[int]int) + m[1] = 1 + m[2] = 1 +} + +func q(n int) (r int) { + if r = m[n]; r == 0 { + r = q(n-q(n-1)) + q(n-q(n-2)) + m[n] = r + } + return +} + +func main() { + initMap() + // task + for n := 1; n <= 10; n++ { + showQ(n) + } + // task + showQ(1000) + // extra credit + count, p := 0, 1 + for n := 2; n <= 1e5; n++ { + qn := q(n) + if qn < p { + count++ + } + p = qn + } + fmt.Println("count:", count) + // extra credit + initMap() + showQ(1e6) +} + +func showQ(n int) { + fmt.Printf("Q(%d) = %d\n", n, q(n)) +} diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-1.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-1.hs new file mode 100644 index 0000000000..c08d3df619 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-1.hs @@ -0,0 +1,8 @@ +qSequence = tail qq where + qq = 0 : 1 : 1 : map g [3..] + g n = qq !! (n - qq !! (n-1)) + qq !! (n - qq !! (n-2)) + +-- Output: +*Main> (take 10 qSequence, qSequence !! (1000-1)) +([1,1,2,3,3,4,5,5,6,6],502) +(0.00 secs, 525044 bytes) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs new file mode 100644 index 0000000000..37c7f28e2d --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-2.hs @@ -0,0 +1,21 @@ +import Data.Array + +qSequence n = arr + where + arr = listArray (1,n) $ 1:1: map g [3..n] + g i = arr!(i - arr!(i-1)) + + arr!(i - arr!(i-2)) + +gradualth m k arr -- gradually precalculate m-th item + | m <= v = pre `seq` arr!m -- in steps of k + where -- to prevent STACK OVERFLOW + pre = foldl1 (\a b-> a `seq` arr!b) [u,u+k..m] + (u,v) = bounds arr + +qSeqTest m n = let arr = qSequence $ max m n in + ( take 10 . elems $ arr -- 10 first items + , gradualth m 10000 $ arr -- m-th item + , length . filter (> 0) -- reversals in n items + . _S (zipWith (-)) tail . take n . elems $ arr ) + +_S f g x = f x (g x) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs new file mode 100644 index 0000000000..162d5cee47 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-3.hs @@ -0,0 +1,7 @@ +Prelude Main> qSeqTest 1000 100000 -- reversals in 100,000 +([1,1,2,3,3,4,5,5,6,6],502,49798) +(0.09 secs, 18879708 bytes) + +Prelude Main> qSeqTest 1000000 100000 -- 1,000,000-th item +([1,1,2,3,3,4,5,5,6,6],512066,49798) +(2.80 secs, 87559640 bytes) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs new file mode 100644 index 0000000000..d7ed082956 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-4.hs @@ -0,0 +1,18 @@ +import Data.Array + +q = qq (listArray (1,2) [1,1]) 1 where + qq ar n = (arr!n) : qq arr (n+1) where + l = snd (bounds ar) + step n =arr!(n - (fromIntegral (arr!(n - 1)))) + + arr!(n - (fromIntegral (arr!(n - 2)))) + arr :: Array Int Integer + arr | n <= l = ar + | otherwise = listArray (1, l*2)$ + ([ar!i | i <- [1..l]] ++ + [step i | i <- [l+1..l*2]]) + +main = do + putStr("first 10: "); print (take 10 q) + putStr("1000-th: "); print (q !! 999) + putStr("flips: ") + print $ length $ filter id $ take 100000 (zipWith (>) q (tail q)) diff --git a/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs new file mode 100644 index 0000000000..cbce25054e --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Haskell/hofstadter-q-sequence-5.hs @@ -0,0 +1,20 @@ +import Data.Array +import Data.Int (Int64) + +q = qq [listArray (1,2) [1,1]] 1 where + qq a n = seek aa n : qq aa (1 + n) where + aa | n <= l = a + | otherwise = listArray (l+1,l*2) (take l $ drop 2 lst):a + where + l = snd (bounds $ head a) + lst = seek a (l-1):seek a l:(ext lst (l+1)) + ext (q1:q2:qs) i = (g (i-q2) + g (i-q1)):ext (q2:qs) (1+i) + g = seek aa + seek (ar:ars) n + | n >= fst (bounds ar) = ar ! n + | otherwise = seek ars n + +-- Only a perf test. Task can be done exactly the same as above +main = print $ sum qqq + where qqq :: [Int64] + qqq = map fromIntegral $ take 3000000 q diff --git a/Task/Hofstadter-Q-sequence/Icon/hofstadter-q-sequence.icon b/Task/Hofstadter-Q-sequence/Icon/hofstadter-q-sequence.icon new file mode 100644 index 0000000000..7d744bea28 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Icon/hofstadter-q-sequence.icon @@ -0,0 +1,39 @@ +link printf + +procedure main() + +V := [1, 1, 2, 3, 3, 4, 5, 5, 6, 6] +every i := 1 to *V do + if Q(i) ~= V[i] then stop("Assertion failure for position ",i) +printf("Q(1 to %d) - verified.\n",*V) + +q := Q(n := 1000) +v := 502 +printf("Q[%d]=%d - %s.\n",n,v,if q = v then "verified" else "failed") + +invcount := 0 +every i := 2 to (n := 100000) do + if Q(i) < Q(i-1) then { + printf("Q(%d)=%d < Q(%d)=%d\n",i,Q(i),i-1,Q(i-1)) + invcount +:= 1 + } +printf("There were %d inversions in Q up to %d\n",invcount,n) +end + + + +procedure Q(n) #: Hofstader Q sequence +static S +initial S := [1,1] + +if q := S[n] then return q +else { + q := Q(n - Q(n - 1)) + Q(n - Q(n - 2)) + if *S = n - 1 then { + put(S,q) + return q + } + else + runerr(500,n) + } +end diff --git a/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-1.j b/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-1.j new file mode 100644 index 0000000000..4cc1f0de77 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-1.j @@ -0,0 +1,8 @@ +Qs=:0 1 1 +Q=: verb define + n=. >./,y + while. n>:#Qs do. + Qs=: Qs,+/(-_2{.Qs){Qs + end. + y{Qs +) diff --git a/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-2.j b/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-2.j new file mode 100644 index 0000000000..f139aeae0f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/J/hofstadter-q-sequence-2.j @@ -0,0 +1,6 @@ + Q 1+i.10 +1 1 2 3 3 4 5 5 6 6 + Q 1000 +502 + +/2>/\ Q 1+i.100000 +49798 diff --git a/Task/Hofstadter-Q-sequence/Java/hofstadter-q-sequence.java b/Task/Hofstadter-Q-sequence/Java/hofstadter-q-sequence.java new file mode 100644 index 0000000000..be32510b0d --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Java/hofstadter-q-sequence.java @@ -0,0 +1,46 @@ +import java.util.HashMap; +import java.util.Map; + +public class HofQ { + private static Map q = new HashMap(){{ + put(1, 1); + put(2, 1); + }}; + + private static int[] nUses = new int[100001];//not part of the task + + public static int Q(int n){ + nUses[n]++;//not part of the task + if(q.containsKey(n)){ + return q.get(n); + } + int ans = Q(n - Q(n - 1)) + Q(n - Q(n - 2)); + q.put(n, ans); + return ans; + } + + public static void main(String[] args){ + for(int i = 1; i <= 10; i++){ + System.out.println("Q(" + i + ") = " + Q(i)); + } + int last = 6;//value for Q(10) + int count = 0; + for(int i = 11; i <= 100000; i++){ + int curr = Q(i); + if(curr < last) count++; + last = curr; + if(i == 1000) System.out.println("Q(1000) = " + curr); + } + System.out.println("Q(i) is less than Q(i-1) for i <= 100000 " + count + " times"); + + //Optional stuff below here + int maxUses = 0, maxN = 0; + for(int i = 1; i maxUses){ + maxUses = nUses[i]; + maxN = i; + } + } + System.out.println("Q(" + maxN + ") was called the most with " + maxUses + " calls"); + } +} diff --git a/Task/Hofstadter-Q-sequence/JavaScript/hofstadter-q-sequence.js b/Task/Hofstadter-Q-sequence/JavaScript/hofstadter-q-sequence.js new file mode 100644 index 0000000000..01dfdfd415 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/JavaScript/hofstadter-q-sequence.js @@ -0,0 +1,18 @@ +var hofstadterQ = function() { + var memo = [1,1,1]; + var Q = function (n) { + var result = memo[n]; + if (typeof result !== 'number') { + result = Q(n - Q(n-1)) + Q(n - Q(n-2)); + memo[n] = result; + } + return result; + }; + return Q; +}(); + +for (var i = 1; i <=10; i += 1) { + console.log('Q('+ i +') = ' + hofstadterQ(i)); +} + +console.log('Q(1000) = ' + hofstadterQ(1000)); diff --git a/Task/Hofstadter-Q-sequence/MATLAB/hofstadter-q-sequence.m b/Task/Hofstadter-Q-sequence/MATLAB/hofstadter-q-sequence.m new file mode 100644 index 0000000000..e011ee9810 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/MATLAB/hofstadter-q-sequence.m @@ -0,0 +1,7 @@ +function Q = Qsequence(N) + %% zeros are used to pre-allocate memory, this is not strictly necessary but can significantly improve performance for large N + Q = [1,1,zeros(1,N-2)]; + for n=3:N + Q(n) = Q(n-Q(n-1))+Q(n-Q(n-2)); + end; +end; diff --git a/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-1.maple b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-1.maple new file mode 100644 index 0000000000..4d0a3193b7 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-1.maple @@ -0,0 +1,8 @@ +Q := proc( n ) + option remember, system; + if n = 1 or n = 2 then + 1 + else + thisproc( n - thisproc( n - 1 ) ) + thisproc( n - thisproc( n - 2 ) ) + end if +end proc: diff --git a/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-2.maple b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-2.maple new file mode 100644 index 0000000000..951fdfea8f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-2.maple @@ -0,0 +1,5 @@ +> seq( Q( i ), i = 1 .. 10 ); + 1, 1, 2, 3, 3, 4, 5, 5, 6, 6 + +> Q( 1000 ); + 502 diff --git a/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-3.maple b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-3.maple new file mode 100644 index 0000000000..d04b028752 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-3.maple @@ -0,0 +1,8 @@ +> flips := 0: +> for i from 2 to 100000 do +> if L[ i ] < L[ i - 1 ] then +> flips := 1 + flips +> end if +> end do: +> flips; + 49798 diff --git a/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-4.maple b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-4.maple new file mode 100644 index 0000000000..b5c6cf0c68 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-4.maple @@ -0,0 +1,15 @@ +Qflips := proc( n ) + local a := Array( 1 .. n ); + a[ 1 ] := 1; + a[ 2 ] := 1; + for local i from 3 to n do + a[ i ] := a[ i - a[ i - 1 ] ] + a[ i - a[ i - 2 ] ] + end do; + local flips := 0; + for i from 2 to n do + if a[ i ] < a[ i - 1 ] then + flips := 1 + flips + end if + end do; + flips +end proc: diff --git a/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-5.maple b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-5.maple new file mode 100644 index 0000000000..e22a6eab89 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Maple/hofstadter-q-sequence-5.maple @@ -0,0 +1,2 @@ +> Qflips( 10^5 ); + 49798 diff --git a/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-1.mathematica b/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-1.mathematica new file mode 100644 index 0000000000..4504597a28 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-1.mathematica @@ -0,0 +1,4 @@ +Hofstadter[1] = Hofstadter[2] = 1; +Hofstadter[n_Integer?Positive] := Hofstadter[n] = Block[{$RecursionLimit = Infinity}, + Hofstadter[n - Hofstadter[n - 1]] + Hofstadter[n - Hofstadter[n - 2]] +] diff --git a/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-2.mathematica b/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-2.mathematica new file mode 100644 index 0000000000..7405642f02 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Mathematica/hofstadter-q-sequence-2.mathematica @@ -0,0 +1,6 @@ +Hofstadter /@ Range[10] +{1,1,2,3,3,4,5,5,6,6} +Hofstadter[1000] +502 +Count[Differences[Hofstadter /@ Range[100000]], _?Negative] +49798 diff --git a/Task/Hofstadter-Q-sequence/Perl/hofstadter-q-sequence.pl b/Task/Hofstadter-Q-sequence/Perl/hofstadter-q-sequence.pl new file mode 100644 index 0000000000..2b16e62a90 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Perl/hofstadter-q-sequence.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +use warnings; +use strict; + +my @hofstadters = ( 1 , 1 ); +while ( @hofstadters < 100000 ) { + my $nextn = @hofstadters + 1; +# array index counting starts at 0 , so we have to subtract 1 from the numbers! + push @hofstadters , $hofstadters [ $nextn - 1 - $hofstadters[ $nextn - 1 - 1 ] ] + + $hofstadters[ $nextn - 1 - $hofstadters[ $nextn - 2 - 1 ]]; +} +for my $i ( 0..9 ) { + print "$hofstadters[ $i ]\n"; +} +print "The 1000'th term is $hofstadters[ 999 ]!\n"; +my $less_than_preceding = 0; +for my $i ( 0..99998 ) { + $less_than_preceding++ if $hofstadters[ $i + 1 ] < $hofstadters[ $i ]; +} +print "Up to and including the 100000'th term, $less_than_preceding terms are less " . + "than their preceding terms!\n"; diff --git a/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-1.l b/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-1.l new file mode 100644 index 0000000000..b37d0a3385 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-1.l @@ -0,0 +1,7 @@ +(de q (N) + (cache '(NIL) (pack (char (hash N)) N) + (if (>= 2 N) + 1 + (+ + (q (- N (q (dec N)))) + (q (- N (q (- N 2)))) ) ) ) ) diff --git a/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-2.l b/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-2.l new file mode 100644 index 0000000000..43b1083675 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/PicoLisp/hofstadter-q-sequence-2.l @@ -0,0 +1,9 @@ +: (mapcar q (range 1 10)) +-> (1 1 2 3 3 4 5 5 6 6) + +: (q 1000) +-> 502 + +: (let L (mapcar q (range 1 100000)) + (cnt < (cdr L) L) ) +-> 49798 diff --git a/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-1.py b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-1.py new file mode 100644 index 0000000000..bfdc95d73f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-1.py @@ -0,0 +1,16 @@ +def q(n): + if n < 1 or type(n) != int: raise ValueError("n must be an int >= 1") + try: + return q.seq[n] + except IndexError: + ans = q(n - q(n - 1)) + q(n - q(n - 2)) + q.seq.append(ans) + return ans +q.seq = [None, 1, 1] + +if __name__ == '__main__': + first10 = [q(i) for i in range(1,11)] + assert first10 == [1, 1, 2, 3, 3, 4, 5, 5, 6, 6], "Q() value error(s)" + print("Q(n) for n = [1..10] is:", ', '.join(str(i) for i in first10)) + assert q(1000) == 502, "Q(1000) value error" + print("Q(1000) =", q(1000)) diff --git a/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-2.py b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-2.py new file mode 100644 index 0000000000..b99cf99248 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-2.py @@ -0,0 +1,19 @@ +from sys import getrecursionlimit + +def q1(n): + if n < 1 or type(n) != int: raise ValueError("n must be an int >= 1") + try: + return q.seq[n] + except IndexError: + len_q, rlimit = len(q.seq), getrecursionlimit() + if (n - len_q) > (rlimit // 5): + for i in range(len_q, n, rlimit // 5): + q(i) + ans = q(n - q(n - 1)) + q(n - q(n - 2)) + q.seq.append(ans) + return ans + +if __name__ == '__main__': + tmp = q1(100000) + print("Q(i+1) < Q(i) for i [1..100000] is true %i times." % + sum(k1 < k0 for k0, k1 in zip(q.seq[1:], q.seq[2:]))) diff --git a/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-3.py b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-3.py new file mode 100644 index 0000000000..514384ba20 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Python/hofstadter-q-sequence-3.py @@ -0,0 +1,13 @@ +def q(n): + l = len(q.seq) + while l <= n: + q.seq.append(q.seq[l - q.seq[l - 1]] + q.seq[l - q.seq[l - 2]]) + l += 1 + return q.seq[n] +q.seq = [None, 1, 1] + +print("Q(n) for n = [1..10] is:", [q(i) for i in range(1, 11)]) +print("Q(1000) =", q(1000)) +q(100000) +print("Q(i+1) < Q(i) for i [1..100000] is true %i times." % + sum([q.seq[i] > q.seq[i + 1] for i in range(1, 100000)])) diff --git a/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-1.rexx b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-1.rexx new file mode 100644 index 0000000000..4309cdd13f --- /dev/null +++ b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-1.rexx @@ -0,0 +1,24 @@ +/*REXX program to generate Hofstadter Q sequence for any N. */ +q.=1 /*negative #s won't have values displayed.*/ +call HofstadterQ 10 +call HofstadterQ -1000; say; say '1000th value='result; say +call HofstadterQ -100000 +downs=0; do j=2 to 100000; jm=j-1 + downs=downs + (q.j2 then if q.j==1 then do; jm1=j-1; jm2=j-2 + _1=j-q.jm1; _2=j-q.jm2 + q.j=q._1+q._2 + end + if ox>0 then say right(j,L) right(q.j,L) /*if X>0, tell*/ + end /*j*/ +return q.x /*return the Xth term to caller.*/ diff --git a/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-2.rexx b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-2.rexx new file mode 100644 index 0000000000..248e804a37 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-2.rexx @@ -0,0 +1,23 @@ +/*REXX program to generate Hofstadter Q sequence for any N. */ +q.=1 /*negative #s won't have values displayed.*/ +call HofstadterQ 10 +call HofstadterQ -1000; say; say '1000th value='result; say +call HofstadterQ -100000 +downs=0; do j=2 to 100000; jm=j-1 + downs=downs + (q.j2 then if q.j==1 then q.j=q(j-q(j-1)) + q(j-q(j-2)) + if ox>0 then say right(j,L) right(q.j,L) /*if X>0, tell*/ + end /*j*/ +return q.x /*return the Xth term to caller.*/ +/*──────────────────────────────────Q subroutine────────────────────────*/ +q: parse arg ?; return q.? /*return value of Q.? to invoker.*/ diff --git a/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-3.rexx b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-3.rexx new file mode 100644 index 0000000000..f10bf21def --- /dev/null +++ b/Task/Hofstadter-Q-sequence/REXX/hofstadter-q-sequence-3.rexx @@ -0,0 +1,25 @@ +/*REXX program to generate Hofstadter Q sequence for any N. */ +q.=0; q.1=1; q.2=1 /*negative #s won't have values displayed.*/ +call HofstadterQ 10 +call HofstadterQ -1000; say; say '1000th value='result; say +call HofstadterQ -100000 +downs=0; do j=2 to 100000; jm=j-1 + downs=downs + (q.j0 then say right(j,L) right(q.j,L) /*if X>0, tell*/ + end /*j*/ +return q.x /*return the Xth term to caller.*/ +/*──────────────────────────────────QR subroutine───────────────────────*/ +QR: procedure expose q.; parse arg n /*function is recursive. */ +if q.n==0 then q.n=QR(n-QR(n-1)) + QR(n-QR(n-2)) /*¬defined? Define it*/ +return q.n /*return with the value. */ diff --git a/Task/Hofstadter-Q-sequence/Racket/hofstadter-q-sequence.rkt b/Task/Hofstadter-Q-sequence/Racket/hofstadter-q-sequence.rkt new file mode 100644 index 0000000000..43e90b782c --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Racket/hofstadter-q-sequence.rkt @@ -0,0 +1,16 @@ +#lang racket + +(define t (make-hash)) +(hash-set! t 0 0) +(hash-set! t 1 1) +(hash-set! t 2 1) + +(define (Q n) + (hash-ref! t n ( () (+ (Q (- n (Q (- n 1)))) + (Q (- n (Q (- n 2)))))))) + +(for/list ([i (in-range 1 11)]) (Q i)) +(Q 1000) + +;; extra credit +(for/sum ([i 100000]) (if (< (Q (add1 i)) (Q i)) 1 0)) diff --git a/Task/Hofstadter-Q-sequence/Ruby/hofstadter-q-sequence.rb b/Task/Hofstadter-Q-sequence/Ruby/hofstadter-q-sequence.rb new file mode 100644 index 0000000000..df017d9d28 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Ruby/hofstadter-q-sequence.rb @@ -0,0 +1,22 @@ +@cache = [] +def Q(n) + if @cache[n].nil? + case n + when 1, 2 then @cache[n] = 1 + else @cache[n] = Q(n - Q(n-1)) + Q(n - Q(n-2)) + end + end + @cache[n] +end + +puts "first 10 numbers in the sequence: #{(1..10).map {|n| Q(n)}}" +puts "1000'th term: #{Q(1000)}" + +prev = Q(1) +count = 0 +2.upto(100_000) do |n| + q = Q(n) + count += 1 if q < prev + prev = q +end +puts "number of times in the first 100,000 terms where Q(i) Int = n => { + if (n <= 2) 1 + else Q(n-Q(n-1))+Q(n-Q(n-2)) + } + (1 to 10).map(i=>(i,Q(i))).foreach(t=>println("Q("+t._1+") = "+t._2)) + println("Q("+1000+") = "+Q(1000)) +} diff --git a/Task/Hofstadter-Q-sequence/Scala/hofstadter-q-sequence-2.scala b/Task/Hofstadter-Q-sequence/Scala/hofstadter-q-sequence-2.scala new file mode 100644 index 0000000000..639de5e1f8 --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Scala/hofstadter-q-sequence-2.scala @@ -0,0 +1,19 @@ +object HofstadterQseq extends App { + + val HofQ = scala.collection.mutable.Map((1->1),(2->1)) + + val Q: Int => Int = n => { + if (n < 1) 0 + else { + val res = HofQ.keys.filter(_==n).toList match { + case Nil => {val v = Q(n-Q(n-1))+Q(n-Q(n-2)); HofQ += (n->v); v} + case xs => HofQ(n) + } + res + } + } + + (1 to 10).map(i=>(i,Q(i))).foreach(t=>println("Q("+t._1+") = "+t._2)) + println("Q("+1000+") = "+Q(1000)) + println((3 to 100000).filter(i=>Q(i)= filled len) (extend-qc)) + (if (>= n filled) + (begin + (vector-set! qc filled (+ (q (- filled (q (- filled 1)))) + (q (- filled (q (- filled 2)))))) + (set! filled (+ 1 filled)) + (loop)) + (vector-ref qc n)))) + +(display "Q(1 .. 10): ") +(let loop ((i 1)) + ;; (print) behave differently regarding newline across compilers + (display (q i)) + (display " ") + (if (< i 10) + (loop (+ 1 i)) + (newline))) + +(display "Q(1000): ") +(display (q 1000)) +(newline) + +(display "bumps up to 100000: ") +(display + (let loop ((s 0) (i 1)) + (if (>= i 100000) s + (loop (+ s (if (> (q i) (q (+ 1 i))) 1 0)) (+ 1 i))))) +(newline) diff --git a/Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence-2.ss b/Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence-2.ss new file mode 100644 index 0000000000..35644fa2ca --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Scheme/hofstadter-q-sequence-2.ss @@ -0,0 +1,3 @@ +Q(1 .. 10): 1 1 2 3 3 4 5 5 6 6 +Q(1000): 502 +bumps up to 100000: 49798 diff --git a/Task/Hofstadter-Q-sequence/Tcl/hofstadter-q-sequence.tcl b/Task/Hofstadter-Q-sequence/Tcl/hofstadter-q-sequence.tcl new file mode 100644 index 0000000000..48502246dd --- /dev/null +++ b/Task/Hofstadter-Q-sequence/Tcl/hofstadter-q-sequence.tcl @@ -0,0 +1,24 @@ +package require Tcl 8.5 + +# Index 0 is not used, but putting it in makes the code a bit shorter +set tcl::mathfunc::Qcache {Q:-> 1 1} +proc tcl::mathfunc::Q {n} { + variable Qcache + if {$n >= [llength $Qcache]} { + lappend Qcache [expr {Q($n - Q($n-1)) + Q($n - Q($n-2))}] + } + return [lindex $Qcache $n] +} + +# Demonstration code +for {set i 1} {$i <= 10} {incr i} { + puts "Q($i) == [expr {Q($i)}]" +} +# This runs very close to recursion limit... +puts "Q(1000) == [expr Q(1000)]" +# This code is OK, because the calculations are done step by step +set q [expr Q(1)] +for {set i 2} {$i <= 100000} {incr i} { + incr count [expr {$q > [set q [expr {Q($i)}]]}] +} +puts "Q(i) year days(year OF date) DO + days -:= year days(year OF date); + year OF date +:= 1 + OD; + month day OF date +:= days; + # Normalize the days to be the same month # + WHILE month day OF date > month days(year OF date, month OF date) DO + month day OF date -:= month days(year OF date, month OF date); + month OF date +:= 1; + IF month OF date > year months THEN + month OF date -:= year months; + year OF date +:= 1 + FI + OD; + week day OF date := week day(date); + date + END; + +OP +:= = (REF DATE date, DAY in days)DATE: + date := date + in days; + +PROC easter = (YEAR year)DATE: + BEGIN + COMMENT + Easter date algorithm from J.M. Oudin (1940), reprinted in: + P.K. Seidelmann ed., "Explanatory Supplement to the Astronomical + Almanac" [1992] (Chapter 12, "Calendars", by L.E. Doggett) + COMMENT + DATE date; year OF date := year; + INT c = year OVER 100, n = year MOD 19; # 19 years: Metonic cycle # + INT i := (c - c OVER 4 - (c - (c - 17) OVER 25) OVER 3 + 19 * n + 15) MOD 30; + i -:= (i OVER 28) * (1 - (i OVER 28) * (29 OVER (i + 1)) * ((21 - n) OVER 11)); + INT l = i - (year + year OVER 4 + i + 2 - c + c OVER 4) MOD 7; + month OF date := 3 + (l + 40) OVER 44; + month day OF date := l + 28 - 31 * (month OF date OVER 4); + week day OF date := week day(date); + date + END; + +PROC week day = (DATE date)DAY: + # Zeller’s Congruence algorithm from 1887. # + BEGIN + INT year := year OF date, month := month OF date, month day := month day OF date, c; + (month <= 2 | (month +:= 12, year -:= 1)); + c := year OVER 100; + year MODAB 100; + 1 + (month day + ((month + 1) * 26) OVER 10 + + year + year OVER 4 + c OVER 4 - 2 * c) MOD 7 + END; + +FORMAT wdmdm fmt = $f(week day fmt)z-dxf(mon fmt)$, + +MODE EASTERRELATED = STRUCT(DATE easter, ascension, pentecost, trinity, corpus christi); + +PROC easter related init = (YEAR year)EASTERRELATED: +BEGIN + DATE date; + EASTERRELATED holidays; +# Easter date, always a Sunday. # + easter OF holidays := date := easter(year); +# Ascension day is 39 days after Easter.# + ascension OF holidays := ( date +:= 39); +# Pentecost is 10 days after Ascension day.# + pentecost OF holidays := date +:= 10; +# Trinity is 7 days after Pentecost.# + trinity OF holidays := date +:= 7; +# Corpus Christi is 4 days after Trinity.# + corpus christi OF holidays := date +:= 4; + holidays +END; + +# Note: Y10K bug here... :-) # +FORMAT easter related fmt = $g(-4)" Easter: "f(wdmdm fmt) ", Ascension: "f(wdmdm fmt) + ", Pentecost: "f(wdmdm fmt) ", Trinity: "f(wdmdm fmt)", Corpus: "f(wdmdm fmt)$; + +PROC easter related print = (YEAR year)VOID: +BEGIN + EASTERRELATED holidays = easter related init(year); + PROC wdmdm = (DATE date)STRUCT(DAY week day, DAY month day, MONTH month): + (week day OF date, month day OF date, month OF date); + printf((easter related fmt, year, + wdmdm(easter OF holidays), wdmdm(ascension OF holidays), wdmdm(pentecost OF holidays), + wdmdm(trinity OF holidays), wdmdm(corpus christi OF holidays), + $l$)) +END; + +printf (($"Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:"l$)); +FOR year FROM 400 BY 100 TO 2100 DO easter related print(year) OD; + +printf (($l"Christian holidays, related to Easter, for years from 2010 to 2020 CE:"l$)); +FOR year FROM 2010 TO 2020 DO easter related print(year) OD diff --git a/Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.ada b/Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.ada new file mode 100644 index 0000000000..ecbffb0207 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Ada/holidays-related-to-easter.ada @@ -0,0 +1,52 @@ +with Ada.Calendar.Arithmetic; +with Ada.Calendar.Formatting; +with Ada.Text_IO; + +procedure Main is + use Ada.Calendar; + use Arithmetic; + + function Get_Easter (Year : Year_Number) return Time is + A : Integer := Year mod 19; + B : Integer := Year / 100; + C : Integer := Year mod 100; + D : Integer := B / 4; + E : Integer := B mod 4; + F : Integer := (B + 8) / 25; + G : Integer := (B - F + 1) / 3; + H : Integer := (19 * A + B - D - G + 15) mod 30; + I : Integer := C / 4; + K : Integer := C mod 4; + L : Integer := (32 + 2 * E + 2 * I - H - K) mod 7; + M : Integer := (A + 11 * H + 22 * L) / 451; + N : Integer := H + L - 7 * M + 114; + begin + return Time_Of (Year, N / 31, N mod 31 + 1, 43200.0); + end Get_Easter; + + procedure Print_Easter (Year : Year_Number) is + Days_To_Ascension : constant Day_Count := 39; + Days_To_Pentecost : constant Day_Count := 49; + Days_To_Trinity : constant Day_Count := 56; + Days_To_Corpus : constant Day_Count := 60; + Easter : Time := Get_Easter (Year); + begin + Ada.Text_IO.Put (Integer'Image (Year)); + Ada.Text_IO.Put (": Easter: " & + Formatting.Image (Easter) (6 .. 10)); + Ada.Text_IO.Put (", Ascension: " & + Formatting.Image (Easter + Days_To_Ascension) (6 .. 10)); + Ada.Text_IO.Put (", Pentecost: " & + Formatting.Image (Easter + Days_To_Pentecost) (6 .. 10)); + Ada.Text_IO.Put (", Trinity: " & + Formatting.Image (Easter + Days_To_Trinity) (6 .. 10)); + Ada.Text_IO.Put_Line (", Corpus: " & + Formatting.Image (Easter + Days_To_Corpus) (6 .. 10)); + end Print_Easter; +begin + Ada.Text_IO.Put_Line + ("Christian holidays, related to Easter, for years from 2010 to 2020 CE:"); + for I in 2010 .. 2020 loop + Print_Easter (I); + end loop; +end Main; diff --git a/Task/Holidays-related-to-Easter/BBC-BASIC/holidays-related-to-easter.bbc b/Task/Holidays-related-to-Easter/BBC-BASIC/holidays-related-to-easter.bbc new file mode 100644 index 0000000000..40b503ad5b --- /dev/null +++ b/Task/Holidays-related-to-Easter/BBC-BASIC/holidays-related-to-easter.bbc @@ -0,0 +1,27 @@ + INSTALL @lib$+"DATELIB" + + PRINT "Year Easter Ascension Pentecost Trinity Corpus" + FOR year% = 1800 TO 2100 STEP 100 + e% = FNeaster(year%) : f$ = "dd MMM" + PRINT ;year%, FN_date$(e%,f$), FN_date$(e%+39,f$), \ + \ FN_date$(e%+49,f$), FN_date$(e%+56,f$), FN_date$(e%+60,f$) + NEXT + PRINT + FOR year% = 2010 TO 2020 + e% = FNeaster(year%) : f$ = "dd MMM" + PRINT ;year%, FN_date$(e%,f$), FN_date$(e%+39,f$), \ + \ FN_date$(e%+49,f$), FN_date$(e%+56,f$), FN_date$(e%+60,f$) + NEXT + END + + DEF FNeaster(year%) + LOCAL a%, b%, c%, d%, e% + a% = year% MOD 19 + b% = year% >>> 2 + c% = b% DIV 25 + 1 + d% = (c% * 3) >>> 2 + e% = ((a% * 19) - ((c% * 8 + 5) DIV 25) + d% + 15) MOD 30 + e% += (29578 - a% - e% * 32) >>> 10 + e% -= ((year% MOD 7) + b% - d% + e% + 2) MOD 7 + d% = e% >>> 5 + = FN_mjd(e% - d% * 31, d% + 3, year%) diff --git a/Task/Holidays-related-to-Easter/C-sharp/holidays-related-to-easter.cs b/Task/Holidays-related-to-Easter/C-sharp/holidays-related-to-easter.cs new file mode 100644 index 0000000000..91e7e506c4 --- /dev/null +++ b/Task/Holidays-related-to-Easter/C-sharp/holidays-related-to-easter.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Linq; + +internal class Program +{ + private static readonly OrderedDictionary _holidayOffsets = new OrderedDictionary + { + {"Easter", 0}, + {"Ascension", 39}, + {"Pentecost", 49}, + {"Trinity", 56}, + {"Corpus", 60}, + }; + + static void Main(string[] args) + { + Console.WriteLine("Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:"); + for (int year = 400; year <= 2100; year += 100) + OutputHolidays(year); + + Console.WriteLine(); + Console.WriteLine("Christian holidays, related to Easter, for years from 2010 to 2020 CE:"); + for (int year = 2010; year <= 2020; year += 1) + OutputHolidays(year); + } + + static void OutputHolidays(int year) + { + var easter = CalculateEaster(year); + var holidays = from kp in _holidayOffsets.OfType() + let holiday = easter.AddDays(Convert.ToInt32(kp.Value)) + select kp.Key + ": " + string.Format("{0,2:ddd} {0,2:%d} {0:MMM}", holiday); + Console.WriteLine("{0,4} {1}", year, string.Join(", ", holidays.ToArray())); + } + + static DateTime CalculateEaster(int year) + { + var a = year % 19; + var b = year / 100; + var c = year %100; + var d = b / 4; + var e = b % 4; + var f = (b + 8) / 25; + var g = (b - f + 1) / 3; + var h = (19 * a + b - d - g + 15) % 30; + var i = c / 4; + var k = c % 4; + var l = (32 + 2 * e + 2 * i - h - k) % 7; + var m = (a + 11 * h + 22 * l) / 451; + var numerator = h + l - 7 * m + 114; + var month = numerator / 31; + var day = (numerator % 31) + 1; + return new DateTime(year, month, day); + } +} diff --git a/Task/Holidays-related-to-Easter/C/holidays-related-to-easter.c b/Task/Holidays-related-to-Easter/C/holidays-related-to-easter.c new file mode 100644 index 0000000000..c957bc6d4e --- /dev/null +++ b/Task/Holidays-related-to-Easter/C/holidays-related-to-easter.c @@ -0,0 +1,122 @@ +#include + +typedef int year_t, month_t, week_t, day_t; + +typedef struct{ + year_t year; /* day_t year_day, */ + month_t month; day_t month_day;/* + week_t week, */ day_t week_day; } date_t; + +const char *mon_fmt[] = {0, "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; +const char *week_day_fmt[] = {0, "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"}; + +day_t month_days(year_t year, month_t month) + { day_t days[]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + return (month==2) ? 28 + (( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0) : days[month]; + } + +day_t year_days(year_t year) /* Ignore 1752 CE for the moment */ + { return (month_days(year, 2) == 28) ? 365 : 366; } + +month_t year_months = 12; +week_t week_days = 7; /* France 1793 to 1805 had 10 day weeks! */ + +date_t plusab(date_t *date, day_t days) + { /* todo: eliminate loops, handle year <== 1752 */ + /* Normalize the days to be less then 1 year */ + while(days < 0){ + date->year -= 1; + days += year_days(date->year); + }; + while(days > year_days(date->year)){ + days -= year_days(date->year); + date->year += 1; + }; + date->month_day += days; + /* Normalize the days to be the same month */ + while(date->month_day > month_days(date->year, date->month)){ + date->month_day -= month_days(date->year, date->month); + date->month += 1; + if(date->month > year_months){ + date->month -= year_months; + date->year += 1; + } + } + date->week_day = week_day(*date); + return *date; + } + +date_t easter (year_t year) + { + /* + Easter date algorithm from J.M. Oudin (1940), reprinted in: + P.K. Seidelmann ed., "Explanatory Supplement to the Astronomical + Almanac" [1992] (Chapter 12, "Calendars", by L.E. Doggett) + */ + date_t date; date.year = year; + int c = year / 100, n = year % 19; /* 19 years: Metonic cycle */ + int i = (c - c / 4 - (c - (c - 17) / 25) / 3 + 19 * n + 15) % 30; + i -= (i / 28) * (1 - (i / 28) * (29 / (i + 1)) * ((21 - n) / 11)); + int l = i - (year + year / 4 + i + 2 - c + c / 4) % 7; + date.month = 3 + (l + 40) / 44; + date.month_day = l + 28 - 31 * (date.month / 4); + date.week_day = week_day(date); + return date; + } + +day_t week_day (date_t date) + /* Zeller’s Congruence algorithm from 1887. */ + { + int year = date.year, month = date.month, month_day = date.month_day, c; + if(month <= 2){month += 12; year -= 1;} + c = year / 100; + year %= 100; + return 1 + ((month_day + ((month + 1) * 26) / 10 + + year + year / 4 + c / 4 - 2 * c) % 7 + 7) % 7; + } + +#define wdmdm_fmt "%s %2d %s" + +typedef struct{date_t easter, ascension, pentecost, trinity, corpus_christi;}easter_related_t; + +easter_related_t easter_related_init (year_t year) +{ + date_t date; + easter_related_t holidays; +/* Easter date, always a Sunday. */ + holidays.easter = date = easter(year); +/* Ascension day is 39 days after Easter.*/ + holidays.ascension = plusab(&date, 39); +/* Pentecost is 10 days after Ascension day.*/ + holidays.pentecost = plusab(&date, 10); +/* Trinity is 7 days after Pentecost.*/ + holidays.trinity = plusab(&date, 7); +/* Corpus Christi is 4 days after Trinity.*/ + holidays.corpus_christi = plusab(&date, 4); + return holidays; +} + +/* note: y10k bug here... :-) */ +#define easter_related_fmt "%4d Easter: "wdmdm_fmt", Ascension: "wdmdm_fmt\ + ", Pentecost: "wdmdm_fmt", Trinity: "wdmdm_fmt", Corpus: "wdmdm_fmt"\n" + +void easter_related_print(year_t year) +{ + easter_related_t holidays = easter_related_init(year); +#define wdmdm(date) week_day_fmt[date.week_day], date.month_day, mon_fmt[date.month] + printf(easter_related_fmt, year, + wdmdm(holidays.easter), wdmdm(holidays.ascension), wdmdm(holidays.pentecost), + wdmdm(holidays.trinity), wdmdm(holidays.corpus_christi)); +} + +int main(){ + year_t year; + + printf ("Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:\n"); + for(year=400; year<=2100; year+=100){ easter_related_print(year); } + + printf ("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:\n"); + for(year=2010; year<=2020; year++){ easter_related_print(year); } + return 0; +} diff --git a/Task/Holidays-related-to-Easter/Common-Lisp/holidays-related-to-easter.lisp b/Task/Holidays-related-to-Easter/Common-Lisp/holidays-related-to-easter.lisp new file mode 100644 index 0000000000..d27bca7b81 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Common-Lisp/holidays-related-to-easter.lisp @@ -0,0 +1,19 @@ +; Easter sunday. Result is a list '(month day) +; +; See: +; Jean Meeus, "Astronomical Formulae for Calculators", +; 4th edition, Willmann-Bell, 1988, p.31 + +(defun easter (year) + (let (a b c d e f g h i k l m n p) + (setq a (rem year 19)) + (multiple-value-setq (b c) (floor year 100)) + (multiple-value-setq (d e) (floor b 4)) + (setq f (floor (+ b 8) 25)) + (setq g (floor (- b f -1) 3)) + (setq h (rem (+ (* 19 a) (- b d g) 15) 30)) + (multiple-value-setq (i k) (floor c 4)) + (setq l (rem (+ 32 e e i (- i h k)) 7)) + (setq m (floor (+ a (* 11 h) (* 22 l)) 451)) + (multiple-value-setq (n p) (floor (+ h l (- 114 (* 7 m))) 31)) + (list n (1+ p)))) diff --git a/Task/Holidays-related-to-Easter/D/holidays-related-to-easter.d b/Task/Holidays-related-to-Easter/D/holidays-related-to-easter.d new file mode 100644 index 0000000000..2ebb3eff93 --- /dev/null +++ b/Task/Holidays-related-to-Easter/D/holidays-related-to-easter.d @@ -0,0 +1,53 @@ +import std.stdio, std.datetime; + +void printEasterRelatedHolidays(in int year) { + static struct Holyday { + string name; + int offs; + } + static immutable Holyday[] holidayOffsets = [{"Easter", 0}, + {"Ascension", 39}, + {"Pentecost", 10}, + {"Trinity", 7}, + {"Corpus", 4}]; + + // Calculate Easter. + Date date; + { + immutable a = year % 19; + immutable b = year / 100; + immutable c = year %100; + immutable d = b / 4; + immutable e = b % 4; + immutable f = (b + 8) / 25; + immutable g = (b - f + 1) / 3; + immutable h = (19 * a + b - d - g + 15) % 30; + immutable i = c / 4; + immutable k = c % 4; + immutable l = (32 + 2 * e + 2 * i - h - k) % 7; + immutable m = (a + 11 * h + 22 * l) / 451; + immutable n = h + l - 7 * m + 114; + immutable month = n / 31; + immutable day = (n % 31) + 1; + date = Date(year, month, day); + } + + writef("%4d ", year); + foreach (immutable hd; holidayOffsets) { + date += days(hd.offs); + writef("%s: %2d %s ", hd.name, date.day, date.month); + } + writeln(); +} + +void main() { + writeln("Christian holidays, related to Easter," ~ + " for each centennial from 400 to 2100 CE:"); + for (int y = 400; y <= 2100; y += 100) + printEasterRelatedHolidays(y); + + writeln("\nChristian holidays, related to Easter," ~ + " for years from 2010 to 2020 CE:"); + foreach (immutable y; 2010 .. 2021) + printEasterRelatedHolidays(y); +} diff --git a/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter.f b/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter.f new file mode 100644 index 0000000000..32a9a699af --- /dev/null +++ b/Task/Holidays-related-to-Easter/Fortran/holidays-related-to-easter.f @@ -0,0 +1,29 @@ + subroutine easter(year,month,day) +c Easter sunday +c +c Input +c year +c Output +c month +c day +c +c See: +c Jean Meeus, "Astronomical Formulae for Calculators", +c 4th edition, Willmann-Bell, 1988, p.31 + implicit integer(a-z) + a=mod(year,19) + b=year/100 + c=mod(year,100) + d=b/4 + e=mod(b,4) + f=(b+8)/25 + g=(b-f+1)/3 + h=mod(19*a+b-d-g+15,30) + i=c/4 + k=mod(c,4) + l=mod(32+2*e+2*i-h-k,7) + m=(a+11*h+22*l)/451 + n=h+l-7*m+114 + month=n/31 + day=mod(n,31)+1 + end diff --git a/Task/Holidays-related-to-Easter/Go/holidays-related-to-easter.go b/Task/Holidays-related-to-Easter/Go/holidays-related-to-easter.go new file mode 100644 index 0000000000..9d4a8aa378 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Go/holidays-related-to-easter.go @@ -0,0 +1,70 @@ +package main + +import ( + "fmt" + "time" +) + +type holiday struct { + time.Time +} + +func easter(y int) holiday { + c := y / 100 + n := mod(y, 19) + i := mod(c-c/4-(c-(c-17)/25)/3+19*n+15, 30) + i -= (i / 28) * (1 - (i/28)*(29/(i+1))*((21-n)/11)) + l := i - mod(y+y/4+i+2-c+c/4, 7) + m := 3 + (l+40)/44 + d := l + 28 - 31*(m/4) + return holiday{time.Date(y, time.Month(m), d, 0, 0, 0, 0, time.UTC)} +} + +func mod(a, n int) int { + r := a % n + if r < 0 { + return r + n + } + return r +} + +func (h holiday) addDays(d int) holiday { + return holiday{h.Add(time.Duration(d) * 24 * time.Hour)} +} + +type easterRelated struct { + easter, ascension, pentecost, trinity, corpusChristi holiday +} + +func newEasterRelated(y int) (er easterRelated) { + er.easter = easter(y) + er.ascension = er.easter.addDays(39) + er.pentecost = er.ascension.addDays(10) + er.trinity = er.pentecost.addDays(7) + er.corpusChristi = er.trinity.addDays(4) + return +} + +func (er easterRelated) print() { + const wdmdm = ": Mon _2 Jan" + fmt.Printf("%4d %s, %s, %s, %s, %s\n", + er.easter.Year(), + er.easter.Format("Easter"+wdmdm), + er.ascension.Format("Ascension"+wdmdm), + er.pentecost.Format("Pentecost"+wdmdm), + er.trinity.Format("Trinity"+wdmdm), + er.corpusChristi.Format("Corpus"+wdmdm)) +} + +func main() { + fmt.Println("Christian holidays, related to Easter, " + + "for each centennial from 400 to 2100 CE:") + for y := 400; y <= 2100; y += 100 { + newEasterRelated(y).print() + } + fmt.Println("\nChristian holidays, related to Easter, " + + "for years from 2010 to 2020 CE:") + for y := 2010; y <= 2020; y++ { + newEasterRelated(y).print() + } +} diff --git a/Task/Holidays-related-to-Easter/Icon/holidays-related-to-easter.icon b/Task/Holidays-related-to-Easter/Icon/holidays-related-to-easter.icon new file mode 100644 index 0000000000..a1e00ddb55 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Icon/holidays-related-to-easter.icon @@ -0,0 +1,65 @@ +link printf + +procedure main() + printf("Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:\n") + every year := 400 to 2100 by 100 do + OutputHolidays(year) + + printf("\nChristian holidays, related to Easter, for years from 2010 to 2020 CE:\n") + every year := 2010 to 2020 do + OutputHolidays(year) +end + +procedure OutputHolidays(year) +static ho,hoo,monL,dayL +initial { + ho := table() + ho["Easter"] := 0 + ho["Ascension"] := 39 + ho["Pentecost"] := 49 + ho["Trinity"] := 56 + ho["Corpus"] := 60 + hoo := ["Easter","Ascension","Pentecost","Trinity","Corpus"] # order + monL := ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + dayL := ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri","Sat"] + } + + easter := CalculateEaster(year) + printf("%d ",year) + every d := Add2Easter(easter,ho[k := !hoo]) do + printf("%d: %s %d %s ", k, dayL[d.wday], d.day, monL[d.month]) + printf("\n") +end + +record daterec(year,month,day,wday) + +procedure CalculateEaster(year) #: Calculates Gregorian Easter + a := year % 19 + b := year / 100 + c := year % 100 + d := b / 4 + e := b % 4 + f := (b + 8) / 25 + g := (b - f + 1) / 3 + h := (19 * a + b - d - g + 15) % 30 + i := c / 4 + k := c % 4 + l := (32 + 2 * e + 2 * i - h - k) % 7 + m := (a + 11 * h + 22 * l) / 451 + n := h + l - 7 * m + 114 + return daterec(year, n / 31, (n % 31) + 1,1) # year,month, day, "Sun"=1 +end + +procedure Add2Easter(dr,days) #: very limited date addition +static dom +initial dom := [,,31,30,31,30,] # limited days per month + dr := copy(dr) + dr.day +:= days + dr.wday := (dr.wday + days - 1 ) % 7 + 1 # rely upon Easter=Sunday + while dr.day > dom[dr.month] do { + dr.day -:= dom[dr.month] + dr.month +:= 1 + } + return dr +end diff --git a/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-1.j b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-1.j new file mode 100644 index 0000000000..be04e33da8 --- /dev/null +++ b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-1.j @@ -0,0 +1,6 @@ +jed=:3 :0 + pfm=. 21 + 30 | _4 + 19 * 1 + 19|y + sn=. 6 - 7 | 4 + <.@*&1.25 y + dys=. 1 40 50 50 +/~sn (] + 7 | 4 + -) pfm + y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys +) diff --git a/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-2.j b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-2.j new file mode 100644 index 0000000000..6c7a9e8522 --- /dev/null +++ b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-2.j @@ -0,0 +1 @@ + jed (400 + 100* i.17),(2010 + i.11),2100 diff --git a/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-3.j b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-3.j new file mode 100644 index 0000000000..c57d2fdd97 --- /dev/null +++ b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-3.j @@ -0,0 +1,11 @@ +ged=:3 :0 + ce =. <. y%100 + GN =. 1 + 19 | y + CY =. 30 | 23 + (<.4 %~ 3 * ce+1) - <. 25 %~ 13 + ce*8 + YR =. 400 | y + SN =. 6 - 7 | 6 + YR + (<. YR%4) - <. YR%100 + dm =. 21 + 30 | 3 + CY + 19*GN + DM =. dm - 49 < dm+11 < GN + dys=. 0 39 49 56 60 +/~ DM + 1 + 7 | 60+SN-DM + y,"0 1(+/\0 0 0 31 30 31 30) (I.,"0]-<:@I.{[) dys +) diff --git a/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-4.j b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-4.j new file mode 100644 index 0000000000..89bb4fcdde --- /dev/null +++ b/Task/Holidays-related-to-Easter/J/holidays-related-to-easter-4.j @@ -0,0 +1 @@ + ged (400 + 100* i.17),(2010 + i.11),2100 diff --git a/Task/Holidays-related-to-Easter/Mathematica/holidays-related-to-easter.mathematica b/Task/Holidays-related-to-Easter/Mathematica/holidays-related-to-easter.mathematica new file mode 100644 index 0000000000..dd6b797389 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Mathematica/holidays-related-to-easter.mathematica @@ -0,0 +1,38 @@ +Needs["Calendar`"];DateFormat[x_]:=DateString[x,{"DayNameShort"," ","DayShort"," ","MonthName"}] +Map[StringJoin[ToString[#]," Easter: ",DateFormat[EasterSunday[#]], +", Ascension: ",DateFormat[DaysPlus[EasterSunday[#],39]], +", Pentecost: ",DateFormat[DaysPlus[EasterSunday[#],49]], +", Trinity: ",DateFormat[DaysPlus[EasterSunday[#],56]], +", Corpus: ",DateFormat[DaysPlus[EasterSunday[#],60]]]& +,Range[400,2100,100]~Join~Range[2010,2020]] + +Output +{400 Easter: Sun 2 April, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus: Thu 1 June, + 500 Easter: Sun 4 April, Ascension: Thu 13 May, Pentecost: Sun 23 May, Trinity: Sun 30 May, Corpus: Thu 3 June, + 600 Easter: Sun 13 April, Ascension: Thu 22 May, Pentecost: Sun 1 June, Trinity: Sun 8 June, Corpus: Thu 12 June, + 700 Easter: Sun 15 April, Ascension: Thu 24 May, Pentecost: Sun 3 June, Trinity: Sun 10 June, Corpus: Thu 14 June, + 800 Easter: Sun 23 April, Ascension: Thu 1 June, Pentecost: Sun 11 June, Trinity: Sun 18 June, Corpus: Thu 22 June, + 900 Easter: Sun 28 March, Ascension: Thu 6 May, Pentecost: Sun 16 May, Trinity: Sun 23 May, Corpus: Thu 27 May, +1000 Easter: Sun 30 March, Ascension: Thu 8 May, Pentecost: Sun 18 May, Trinity: Sun 25 May, Corpus: Thu 29 May, +1100 Easter: Sun 8 April, Ascension: Thu 17 May, Pentecost: Sun 27 May, Trinity: Sun 3 June, Corpus: Thu 7 June, +1200 Easter: Sun 9 April, Ascension: Thu 18 May, Pentecost: Sun 28 May, Trinity: Sun 4 June, Corpus: Thu 8 June, +1300 Easter: Sun 18 April, Ascension: Thu 27 May, Pentecost: Sun 6 June, Trinity: Sun 13 June, Corpus: Thu 17 June, +1400 Easter: Sun 20 April, Ascension: Thu 29 May, Pentecost: Sun 8 June, Trinity: Sun 15 June, Corpus: Thu 19 June, +1500 Easter: Sun 1 April, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus: Thu 31 May, +1600 Easter: Sun 2 April, Ascension: Thu 11 May, Pentecost: Sun 21 May, Trinity: Sun 28 May, Corpus: Thu 1 June, +1700 Easter: Sun 11 April, Ascension: Thu 20 May, Pentecost: Sun 30 May, Trinity: Sun 6 June, Corpus: Thu 10 June, +1800 Easter: Sun 13 April, Ascension: Thu 22 May, Pentecost: Sun 1 June, Trinity: Sun 8 June, Corpus: Thu 12 June, +1900 Easter: Sun 15 April, Ascension: Thu 24 May, Pentecost: Sun 3 June, Trinity: Sun 10 June, Corpus: Thu 14 June, +2000 Easter: Sun 23 April, Ascension: Thu 1 June, Pentecost: Sun 11 June, Trinity: Sun 18 June, Corpus: Thu 22 June, +2100 Easter: Sun 28 March, Ascension: Thu 6 May, Pentecost: Sun 16 May, Trinity: Sun 23 May, Corpus: Thu 27 May, +2010 Easter: Sun 4 April, Ascension: Thu 13 May, Pentecost: Sun 23 May, Trinity: Sun 30 May, Corpus: Thu 3 June, +2011 Easter: Sun 24 April, Ascension: Thu 2 June, Pentecost: Sun 12 June, Trinity: Sun 19 June, Corpus: Thu 23 June, +2012 Easter: Sun 8 April, Ascension: Thu 17 May, Pentecost: Sun 27 May, Trinity: Sun 3 June, Corpus: Thu 7 June, +2013 Easter: Sun 31 March, Ascension: Thu 9 May, Pentecost: Sun 19 May, Trinity: Sun 26 May, Corpus: Thu 30 May, +2014 Easter: Sun 20 April, Ascension: Thu 29 May, Pentecost: Sun 8 June, Trinity: Sun 15 June, Corpus: Thu 19 June, +2015 Easter: Sun 5 April, Ascension: Thu 14 May, Pentecost: Sun 24 May, Trinity: Sun 31 May, Corpus: Thu 4 June, +2016 Easter: Sun 27 March, Ascension: Thu 5 May, Pentecost: Sun 15 May, Trinity: Sun 22 May, Corpus: Thu 26 May, +2017 Easter: Sun 16 April, Ascension: Thu 25 May, Pentecost: Sun 4 June, Trinity: Sun 11 June, Corpus: Thu 15 June, +2018 Easter: Sun 1 April, Ascension: Thu 10 May, Pentecost: Sun 20 May, Trinity: Sun 27 May, Corpus: Thu 31 May, +2019 Easter: Sun 21 April, Ascension: Thu 30 May, Pentecost: Sun 9 June, Trinity: Sun 16 June, Corpus: Thu 20 June, +2020 Easter: Sun 12 April, Ascension: Thu 21 May, Pentecost: Sun 31 May, Trinity: Sun 7 June, Corpus: Thu 11 June} diff --git a/Task/Holidays-related-to-Easter/Maxima/holidays-related-to-easter.maxima b/Task/Holidays-related-to-Easter/Maxima/holidays-related-to-easter.maxima new file mode 100644 index 0000000000..95820c3cb0 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Maxima/holidays-related-to-easter.maxima @@ -0,0 +1,11 @@ +/* Easter sunday. Result is a list [month, day] + +See: +Jean Meeus, "Astronomical Formulae for Calculators", +4th edition, Willmann-Bell, 1988, p.31 */ + +easter_sunday(year):=block([a,b,c,d,e,f,g,h,i,k,l,m,n,p], +a:remainder(year,19),[b,c]:divide(year,100),[d,e]:divide(b,4), +f:quotient(b+8,25),g:quotient(b-f+1,3),h:remainder(19*a+b-d-g+15,30), +[i,k]:divide(c,4),l:remainder(32+2*e+2*i-h-k,7),m:quotient(a+11*h+22*l,451), +[n,p]:divide(h+l-7*m+114,31),[n,p+1])$ diff --git a/Task/Holidays-related-to-Easter/Perl/holidays-related-to-easter.pl b/Task/Holidays-related-to-Easter/Perl/holidays-related-to-easter.pl new file mode 100644 index 0000000000..8b3ea5661c --- /dev/null +++ b/Task/Holidays-related-to-Easter/Perl/holidays-related-to-easter.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +use strict; use warnings; +use Date::Calc qw(:all); + +my @abbr = qw( Not Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); + +my %c_hols = ( + Easter=> 0, + Ascension=> 39, + Pentecost=> 49, + Trinity=> 56, + Corpus=> 60 +); + +sub easter { + my $year=shift; + + my $ay=$year % 19; + my $by=int($year / 100); + my $cy=$year % 100; + my $dy=int($by/4); + my $ey=$by % 4; + my $fy=int(($by+8)/25); + my $gy=int(($by-$fy+1)/3); + my $hy=($ay*19+$by-$dy-$gy+15) % 30; + my $iy=int($cy/4); + my $ky=$cy % 4; + my $ly=(32+2*$ey+2*$iy-$hy-$ky) % 7; + my $m_y=int(($ay+11*$hy+22*$ly)/451); + + my $month=int(($hy+$ly-7*$m_y+114)/31); + my $day=(($hy+$ly-7*$m_y+114) % 31)+1; + + return ($month, $day, $year); +} + +sub cholidays { + my $year=shift; + my ($emon, $eday)=easter($year); + my @fields; + printf("%4s: ", $year); + + foreach my $hol (sort { $c_hols{$a}<=>$c_hols{$b} } keys %c_hols) { + my ($ye,$mo,$da)=Add_Delta_Days($year,$emon,$eday,$c_hols{$hol}); + my $month=$abbr[$mo]; + push @fields, sprintf("%s: %02s %s",$hol,$da,$month); + } + print join (", ",@fields); + print "\n"; +} + + +print "Christian holidays, related to Easter, for each centennial from ", + "400 to 2100 CE:\n"; +for (my $year=400; $year<=2100; $year+=100) { + cholidays($year); +} + +print "Christian holidays, related to Easter, ", + "for years from 2010 to 2020 CE:\n"; + + +cholidays($_) for(2010..2020); diff --git a/Task/Holidays-related-to-Easter/PicoLisp/holidays-related-to-easter.l b/Task/Holidays-related-to-Easter/PicoLisp/holidays-related-to-easter.l new file mode 100644 index 0000000000..2d9b0ba89b --- /dev/null +++ b/Task/Holidays-related-to-Easter/PicoLisp/holidays-related-to-easter.l @@ -0,0 +1,15 @@ +(load "@lib/cal.l") # For 'easter' function + +(de dayMon (Dat) + (let D (date Dat) + (list (day Dat *Day) " " (align 2 (caddr D)) " " (get *Mon (cadr D))) ) ) + +(for Y (append (range 400 2100 100) (range 2010 2020)) + (let E (easter Y) + (prinl + (align 4 Y) + " Easter: " (dayMon E) + ", Ascension: " (dayMon (+ E 39)) + ", Pentecost: " (dayMon (+ E 49)) + ", Trinity: " (dayMon (+ E 56)) + ", Corpus: " (dayMon (+ E 60)) ) ) ) diff --git a/Task/Holidays-related-to-Easter/Python/holidays-related-to-easter.py b/Task/Holidays-related-to-Easter/Python/holidays-related-to-easter.py new file mode 100644 index 0000000000..84d6576473 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Python/holidays-related-to-easter.py @@ -0,0 +1,34 @@ +from dateutil.easter import * +import datetime, calendar + +class Holiday(object): + def __init__(self, date, offset=0): + self.holiday = date + datetime.timedelta(days=offset) + + def __str__(self): + dayofweek = calendar.day_name[self.holiday.weekday()][0:3] + month = calendar.month_name[self.holiday.month][0:3] + return '{0} {1:2d} {2}'.format(dayofweek, self.holiday.day, month) + +def get_holiday_values(year): + holidays = {'year': year} + easterDate = easter(year) + holidays['easter'] = Holiday(easterDate) + holidays['ascension'] = Holiday(easterDate, 39) + holidays['pentecost'] = Holiday(easterDate, 49) + holidays['trinity'] = Holiday(easterDate, 56) + holidays['corpus'] = Holiday(easterDate, 60) + return holidays + +def print_holidays(holidays): + print '{year:4d} Easter: {easter}, Ascension: {ascension}, Pentecost: {pentecost}, Trinity: {trinity}, Corpus: {corpus}'.format(**holidays) + +if __name__ == "__main__": + print "Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:" + for year in range(400, 2200, 100): + print_holidays(get_holiday_values(year)) + + print '' + print "Christian holidays, related to Easter, for years from 2010 to 2020 CE:" + for year in range(2010, 2021): + print_holidays(get_holiday_values(year)) diff --git a/Task/Holidays-related-to-Easter/Ruby/holidays-related-to-easter.rb b/Task/Holidays-related-to-Easter/Ruby/holidays-related-to-easter.rb new file mode 100644 index 0000000000..777bb3e660 --- /dev/null +++ b/Task/Holidays-related-to-Easter/Ruby/holidays-related-to-easter.rb @@ -0,0 +1,42 @@ +require 'date' + +def easter_date(year) + # Anonymous Gregorian algorithm + # http://en.wikipedia.org/wiki/Computus#Algorithms + + a = year % 19 + b = year / 100 + c = year % 100 + d = b / 4 + e = b % 4 + f = (b + 8) / 25 + g = (b - f + 1) / 3 + h = (19*a +b - d - g + 15) % 30 + i = c / 4 + k = c % 4 + l = (32 + 2*e + 2*i - h - k) % 7 + m = (a + 11*h + 22*l) / 451 + numerator = h + l - 7*m + 114 + month = numerator / 31 + day = (numerator % 31) + 1 + Date.new(year, month, day) +end + +OFFSETS = { + :easter => 0, + :ascension => 39, + :pentecost => 49, + :trinity => 56, + :corpus => 60, +} + +def emit_dates(year) + e = easter_date year + dates = OFFSETS.collect {|(item, offset)| (e + offset).strftime("%e %b")} + puts "%4s: %s" % [year, dates.join(', ')] +end + +puts "year: " + OFFSETS.keys.join(', ') +400.step(2100, 100).each {|year| emit_dates year} +puts "" +(2010 .. 2020).each {|year| emit_dates year} diff --git a/Task/Holidays-related-to-Easter/Scala/holidays-related-to-easter.scala b/Task/Holidays-related-to-Easter/Scala/holidays-related-to-easter.scala new file mode 100644 index 0000000000..1d13edd92e --- /dev/null +++ b/Task/Holidays-related-to-Easter/Scala/holidays-related-to-easter.scala @@ -0,0 +1,61 @@ +import java.util._ +import scala.swing._ + +def easter(year: Int) = { + // Start at March 21. + val cal = new GregorianCalendar(year, 2, 21); + + /* + * Calculate e = day of Easter, following the 1886 paper, + * Kalender-Formeln (Calendar Formulae) by Chr. Zeller. + * http://www.merlyn.demon.co.uk/zel-1886.htm + * + * With Scala, p % 7 gives the wrong result when p < 0. To give the + * correct result, this code uses "+ 6 * j" where one might have used + * "- j". This works because because 6 == -1 (mod 7). + */ + var b = 0 + var d = 0 + if (cal.getTime().before(cal.getGregorianChange())) { + // Julian calendar + b = (19 * (year % 19) + 15) % 30 + d = (b + year + year / 4) % 7 + } else { + // Gregorian calendar + val j = year / 100 + val a = year % 19 + b = (19 * a + 15 + j - (8 * j + 13) / 25 - j / 4) % 30 + d = (b + year + year / 4 + 6 * j + j / 4 + 2) % 7 + if (d == 0 && (b == 29 || (b == 28 && a > 10))) d = 7 + } + val e = b + 7 - d // This counts days after 21 March. + + val df = new java.text.SimpleDateFormat("EEE dd MMM"); + def advance(days: Int) = { + cal.add(Calendar.DAY_OF_MONTH, days) + df.format(cal.getTime()) + } + + val ary = new Array[Any](6) + ary(0) = year + ary(1) = advance(e) // Easter + ary(2) = advance(39) // Ascension Thursday + ary(3) = advance(10) // Pentecost + ary(4) = advance(7) // Trinity Sunday + ary(5) = advance(4) // Corpus Christi + ary +} + +val columns = Array("AD", "Easter", "Ascension Thursday", "Pentecost", + "Trinity Sunday", "Corpus Christi") +val rows = (400.to(2000, 100) ++ 2010.to(2020) ++ Array(2100)) + .map(easter(_)).toArray + +new MainFrame { + title = "Holidays related to Easter" + contents = new ScrollPane { + contents = new Table(rows, columns) + } + size = new java.awt.Dimension(600, 400) + visible = true +} diff --git a/Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.ss b/Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.ss new file mode 100644 index 0000000000..48cb2f1efd --- /dev/null +++ b/Task/Holidays-related-to-Easter/Scheme/holidays-related-to-easter.ss @@ -0,0 +1,21 @@ +; Easter sunday. Result is a list '(month day) +; +; See: +; Jean Meeus, "Astronomical Formulae for Calculators", +; 4th edition, Willmann-Bell, 1988, p.31 + +(define (easter year) + (let* ((a (remainder year 19)) + (b (quotient year 100)) + (c (remainder year 100)) + (d (quotient b 4)) + (e (remainder b 4)) + (f (quotient (+ b 8) 25)) + (g (quotient (+ 1 (- b f)) 3)) + (h (remainder (+ (* 19 a) (- b d g) 15) 30)) + (i (quotient c 4)) + (k (remainder c 4)) + (l (remainder (+ e e i i (- 32 h k)) 7)) + (m (quotient (+ a (* 11 h) (* 22 l)) 451)) + (n (+ h l (- 114 (* 7 m))))) + (list (quotient n 31) (+ 1 (remainder n 31))))) diff --git a/Task/Holidays-related-to-Easter/Tcl/holidays-related-to-easter.tcl b/Task/Holidays-related-to-Easter/Tcl/holidays-related-to-easter.tcl new file mode 100644 index 0000000000..b5cf1dd7ca --- /dev/null +++ b/Task/Holidays-related-to-Easter/Tcl/holidays-related-to-easter.tcl @@ -0,0 +1,68 @@ +package require Tcl 8.5; # Advanced date handling engine + +# Easter computation code from http://www.assa.org.au/edm.html +proc EasterDate year { + set FirstDig [expr {$year / 100}] + set Remain19 [expr {$year % 19}] + + # calculate Paschal Full Moon date + set temp [expr {($FirstDig - 15)/2 + 202 - 11*$Remain19}] + if {$FirstDig in {21 24 25 27 28 29 30 31 32 34 35 38}} { + incr temp -1 + } elseif {$FirstDig in {33 36 37 39 40}} { + incr temp -2 + } + set temp [expr {$temp % 30}] + + set tA [expr {$temp + 21}] + if {$temp == 29} {incr tA -1} + if {$temp == 28 && $Remain19 > 10} {incr tA -1} + + # find the next Sunday + set tB [expr {($tA - 19) % 7}] + + set tC [expr {(40 - $FirstDig) % 4}] + if {$tC == 3} {incr tC} + if {$tC > 1} {incr tC} + + set temp [expr {$year % 100}] + set tD [expr {($temp + $temp/4) % 7}] + + set tE [expr {((20 - $tB - $tC - $tD) % 7) + 1}] + set d [expr {$tA + $tE}] + + # return the date + if {$d > 31} { + return [format "%02d April %04d" [expr {$d - 31}] $year] + } else { + return [format "%02d March %04d" $d $year] + } +} + +# Use the Easter calculator to work out the data for the feasts +proc DateInfo year { + set fields [format %4d: $year]\t + set easter [clock scan [EasterDate $year] -format "%d %B %Y"] + foreach {name delta} { + Easter 0 + Ascension 39 + Pentecost 49 + Trinity 56 + Corpus 60 + } { + set when [clock add $easter $delta days] + append fields [clock format $when -format "${name}: %d %b, "] + } + return [string trimright $fields " ,"] +} + +# Print the required info +puts "Christian holidays, related to Easter, for each centennial from 400 to 2100 CE:" +for {set year 400} {$year <= 2100} {incr year 100} { + puts [DateInfo $year] +} +puts "" +puts "Christian holidays, related to Easter, for years from 2010 to 2020 CE:" +for {set year 2010} {$year <= 2020} {incr year} { + puts [DateInfo $year] +} diff --git a/Task/Honeycombs/0DESCRIPTION b/Task/Honeycombs/0DESCRIPTION new file mode 100644 index 0000000000..fbb2e17a34 --- /dev/null +++ b/Task/Honeycombs/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to produce a matrix of 20 hexagon shaped widgets in a honeycomb arrangement. The matrix should be arranged in such a manner that there are five +columns of four hexagons. The hexagons in columns one, three and five are aligned horizontally, whereas the hexagons in columns two and four occupy a lower position within the arrangement. Each hexagon should be the same colour, and should +display a unique randomly selected single capital letter on the front. The application should now wait for the user to select a hexagon, either by using a pointing device, or by pressing a key that carries a corresponding letter on a hexagon. For platforms that support pointing devices and keyboards, the application should support both methods of selection. A record of the chosen letters should be maintained and the code should be suitably commented, at the point where the the selected letter has been determined. The selected hexagon should now change colour on the display. The cycle repeats until the user has chosen all of the letters. Note that each letter can only be selected once and previously selected hexagons retain their colour after selection. The program terminates when all letters have been chosen. + +Optionally: output the list of selected letters and show the last selected letter, cater for a different number of columns or a different number of hexagons in each column, cater for two players, (turns alternate and the hexagons change a different colour depending on whether they were selected by player one or player two and records of both players selections are maintained.) + +[[image:honeycomb.gif]] diff --git a/Task/Honeycombs/1META.yaml b/Task/Honeycombs/1META.yaml new file mode 100644 index 0000000000..64a3e6dd93 --- /dev/null +++ b/Task/Honeycombs/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- GUI diff --git a/Task/Honeycombs/BBC-BASIC/honeycombs.bbc b/Task/Honeycombs/BBC-BASIC/honeycombs.bbc new file mode 100644 index 0000000000..97deecf3b3 --- /dev/null +++ b/Task/Honeycombs/BBC-BASIC/honeycombs.bbc @@ -0,0 +1,84 @@ + ALTERNATE = 1 + VDU 23,22,252;252;8,16,16,128 + *FONT Arial,24,B + + Letters$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + Letters% = !^Letters$ + FOR i% = 0 TO 24 + SWAP Letters%?i%, Letters%?(i%+RND(26-i%)-1) + NEXT + + DIM xpos%(20), ypos%(20), hrgn%(20) + C% = 1 + FOR Y% = 36 TO 192 STEP 52 + FOR X% = 35 TO 215 STEP 90 + xpos%(C%) = X% + ypos%(C%) = Y% + C% += 1 + NEXT + FOR X% = 80 TO 170 STEP 90 + xpos%(C%) = X% + ypos%(C%) = Y%+26 + C% += 1 + NEXT + NEXT + + REM Plot the hexagons: + FOR C% = 1 TO 20 + hrgn%(C%) = FNplothexagon(xpos%(C%), ypos%(C%), &00FFFF, \ + \ MID$(Letters$,C%,1), &0000FF) + NEXT + SYS "InvalidateRect", @hwnd%, 0, 0 + + REM Initialise word selected: + Word$ = "" + + REM Monitor mouse clicks: + ON MOUSE PROCmouse(@wparam%,@lparam%) : RETURN + + REM Monitor keypresses: + REPEAT + key$ = INKEY$(1) + IF key$ >= "a" key$ = CHR$(ASCkey$-32) + C% = INSTR(Letters$, key$) + IF C% IF C%<21 IF hrgn%(C%) PROCselect(C%) + UNTIL FALSE + END + + REM Select a hexagon with the keyboard or mouse: + DEF PROCselect(C%) + hrgn%(C%) = 0 * FNplothexagon(xpos%(C%), ypos%(C%), &FF00FF, \ + \ MID$(Letters$,C%,1), &000000) + SYS "InvalidateRect", @hwnd%, 0, 0 + Word$ += MID$(Letters$, C%, 1) + SYS "SetWindowText", @hwnd%, Word$ + ENDPROC + + DEF PROCmouse(W%, L%) + LOCAL C%, R% + IF W%<>1 ENDPROC + FOR C% = 1 TO 20 + SYS "PtInRegion", hrgn%(C%), L% AND &FFFF, L% >>> 16 TO R% + IF R% PROCselect(C%) + NEXT + ENDPROC + + DEF FNplothexagon(x%, y%, hcol%, text$, tcol%) + LOCAL brush%, pen%, hrgn%, pt%(), size{} + DIM pt%(5,1), size{dx%,dy%} + pt%() = x%-30,y%,x%-15,y%+26,x%+15,y%+26,x%+30,y%,x%+15,y%-26,x%-15,y%-26 + SYS "CreatePen", 0, 3, 0 TO pen% + SYS "CreateSolidBrush", hcol% TO brush% + SYS "SelectObject", @memhdc%, pen% TO pen% + SYS "SelectObject", @memhdc%, brush% TO brush% + SYS "Polygon", @memhdc%, ^pt%(0,0), 6 + SYS "SelectObject", @memhdc%, pen% TO pen% + SYS "SelectObject", @memhdc%, brush% TO brush% + SYS "DeleteObject", pen% + SYS "DeleteObject", brush% + SYS "GetTextExtentPoint32", @memhdc%, text$, LEN(text$), size{} + SYS "SetTextColor", @memhdc%, tcol% + SYS "SetBkColor", @memhdc%, hcol% + SYS "TextOut", @memhdc%, x%-size.dx%/2, y%-size.dy%/2, text$, LEN(text$) + SYS "CreatePolygonRgn", ^pt%(0,0), 6, ALTERNATE TO hrgn% + = hrgn% diff --git a/Task/Honeycombs/C-sharp/honeycombs-1.cs b/Task/Honeycombs/C-sharp/honeycombs-1.cs new file mode 100644 index 0000000000..bccbcb9562 --- /dev/null +++ b/Task/Honeycombs/C-sharp/honeycombs-1.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Shapes; + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// namespace: Honeycombs +// +// summary: WPF implementation of Rosetta Code Honeycombs task. Uses Polygon shapes as hexes. +//////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace Honeycombs +{ + public partial class MainWindow + { + private const int RowCount = 4; + private const int ColCount = 5; + private const int LabelSize = 20; + private readonly char[] _permutedChars; + + public MainWindow() + { + if (RowCount * ColCount > 26) +#pragma warning disable 162 + { + throw new ArgumentException("Too many cells"); + } +#pragma warning restore 162 + _permutedChars = GetPermutedChars(RowCount * ColCount); + + // VS Generated code not included + InitializeComponent(); + } + + private static char[] GetPermutedChars(int characterCount) + { + const string allChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + var rnd = new Random(); + var chars = new char[allChars.Length]; + + for (int i = 0; i < allChars.Length; i++) + { + chars[i] = allChars[i]; + } + + for (int i = 0; i < characterCount; i++) + { + int swapIndex = rnd.Next() % (allChars.Length - i); + char tmp = chars[swapIndex + i]; + chars[swapIndex + i] = chars[i]; + chars[i] = tmp; + } + return chars; + } + + private void SetHexProperties(UIElementCollection hexes, double cellSize) + { + int charIndex = 0; + List hexList = hexes.Cast().ToList(); + + foreach (Polygon element in hexList) + { + SetHexProperties(element, _permutedChars[charIndex++], cellSize); + } + } + + private void SetHexProperties(Polygon hex, char charToSet, double cellSize) + { + var tag = (Tuple) hex.Tag; + double cellX = tag.Item3; + double cellY = tag.Item4; + + // We place the text in a grid centered on the hex. + // The grid will then center the text within itself. + + var centeringGrid = new Grid(); + centeringGrid.Width = centeringGrid.Height = 2 * cellSize; + centeringGrid.SetValue(Canvas.LeftProperty, cellX - cellSize); + centeringGrid.SetValue(Canvas.TopProperty, cellY - cellSize); + centeringGrid.IsHitTestVisible = false; + HoneycombCanvas.Children.Add(centeringGrid); + + var label = new TextBlock + { + Text = new string(charToSet, 1), + FontFamily = new FontFamily("Segoe"), + FontSize = LabelSize + }; + label.HorizontalAlignment = HorizontalAlignment.Center; + label.VerticalAlignment = VerticalAlignment.Center; + label.IsHitTestVisible = false; + centeringGrid.Children.Add(label); + + // Reset the tag to keep track of the character in the hex + hex.Tag = charToSet; + hex.Fill = new SolidColorBrush(Colors.Yellow); + hex.Stroke = new SolidColorBrush(Colors.Black); + hex.StrokeThickness = cellSize / 10; + + // Mouse down event handler for the hex + hex.MouseDown += hex_MouseDown; + } + + private void hex_MouseDown(object sender, MouseButtonEventArgs e) + { + var hex = sender as Shape; + if (hex == null) + { + throw new InvalidCastException("Non-shape in Honeycomb"); + } + + // Get the letter for this hex + var ch = (char) hex.Tag; + + // Add it to our Letters TextBlock + Letters.Text = Letters.Text + ch; + + // Color the hex magenta + hex.Fill = new SolidColorBrush(Colors.Magenta); + + // Remove the mouse down event handler so we won't hit on this hex again + hex.MouseDown -= hex_MouseDown; + } + + private static void GetCombSize(double actualHeight, double actualWidth, int columns, int rows, + out double cellSize, out double combHeight, out double combWidth) + { + double columnFactor = (3 * columns + 1) / 2.0; + double rowFactor = (Math.Sqrt(3) * (2 * rows + 1)) / 2.0; + double cellFromWidth = actualWidth / columnFactor; + double cellFromHeight = actualHeight / rowFactor; + cellSize = Math.Min(cellFromWidth, cellFromHeight); + combWidth = cellSize * columnFactor; + combHeight = cellSize * rowFactor; + } + + private static void AddCells(Canvas canvas, double cellSize, int columns, int rows) + { + double rowHeight = cellSize * Math.Sqrt(3) / 2; + + for (int row = 0; row < rows; row++) + { + AddRow(rowHeight, canvas, cellSize, columns, row); + rowHeight += cellSize * Math.Sqrt(3); + } + } + + private static void AddRow(double rowHeight, Canvas canvas, double cellSize, int columnCount, int row) + { + double cellX = cellSize; + double cellHeight = cellSize * Math.Sqrt(3); + + for (int col = 0; col < columnCount; col++) + { + double cellY = rowHeight + ((col & 1) == 1 ? cellHeight / 2 : 0); + Polygon hex = GetCenteredHex(cellSize, cellX, cellY, cellHeight); + hex.Tag = Tuple.Create(col, row, cellX, cellY); + canvas.Children.Add(hex); + cellX += 3 * cellSize / 2; + } + } + + private static Polygon GetCenteredHex(double cellSize, double cellX, double cellY, double cellHeight) + { + var hex = new Polygon(); + hex.Points.Add(new Point(cellX - cellSize, cellY)); + hex.Points.Add(new Point(cellX - cellSize / 2, cellY + cellHeight / 2)); + hex.Points.Add(new Point(cellX + cellSize / 2, cellY + cellHeight / 2)); + hex.Points.Add(new Point(cellX + cellSize, cellY)); + hex.Points.Add(new Point(cellX + cellSize / 2, cellY - cellHeight / 2)); + hex.Points.Add(new Point(cellX - cellSize / 2, cellY - cellHeight / 2)); + return hex; + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + double combHeight, combWidth, cellSize; + + // Get sizes that will fit within our window + GetCombSize(Main.ActualHeight, Main.ActualWidth, ColCount, RowCount, out cellSize, out combHeight, + out combWidth); + + // Set the canvas size appropriately + HoneycombCanvas.Width = combWidth; + HoneycombCanvas.Height = combHeight; + + // Add the cells to the canvas + AddCells(HoneycombCanvas, cellSize, ColCount, RowCount); + + // Set the cells to look like we want them + SetHexProperties(HoneycombCanvas.Children, cellSize); + } + } +} diff --git a/Task/Honeycombs/C-sharp/honeycombs-2.cs b/Task/Honeycombs/C-sharp/honeycombs-2.cs new file mode 100644 index 0000000000..ecb9d12634 --- /dev/null +++ b/Task/Honeycombs/C-sharp/honeycombs-2.cs @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/Task/Honeycombs/C/honeycombs.c b/Task/Honeycombs/C/honeycombs.c new file mode 100644 index 0000000000..08c1e2d77b --- /dev/null +++ b/Task/Honeycombs/C/honeycombs.c @@ -0,0 +1,268 @@ +/* Program for gtk3 */ +/* discovery: essential to use consistent documentation */ +/* compilation on linux: */ +/* $ a=./hexagon && make -k "CFLAGS=$( pkg-config --cflags gtk+-3.0 )" "LOADLIBES=$( pkg-config --libs gtk+-3.0 )" $a && $a --gtk-debug=all */ +/* search for to do */ +/* The keyboard and mouse callbacks increment the "selected" status, */ +/* of the matching hexagon, */ +/* then invalidate the drawing window which triggers a draw event. */ +/* The draw callback redraws the screen and tests for completion, */ +/* upon which the program spits back the characters selected and exits */ + +#include +#include +#include +#include + +static GdkPixbuf*create_pixbuf(const gchar*filename) { + GdkPixbuf*pixbuf; + GError*error = NULL; + pixbuf = gdk_pixbuf_new_from_file(filename, &error); + if(!pixbuf) { + fprintf(stderr,"\n%s\n", error->message); + g_error_free(error); + } + return pixbuf; +} + +#define NGON struct ngon +NGON { + double Cx,Cy, r; + int sides, selected; + char c; +}; + +GRand*random_numbers = NULL; + +#define R 20 +#define TAU (2*M_PI) /* http://laughingsquid.com/pi-is-wrong/ */ +#define OFFSET_X (1+sin(TAU/12)) +#define OFFSET_Y (cos(TAU/12)) +#define ODD(A) ((A)&1) + +static void initialize_hexagons(NGON*hs,size_t n) { + NGON*h; + gint i,broken; + GQueue*shuffler = g_queue_new(); + if (NULL == shuffler) { + fputs("\ncannot allocate shuffling queue. quitting!\n",stderr); + exit(EXIT_FAILURE); + } + /* randomize characters by stuffing them onto a double end queue + and popping them off from random positions */ + if ((broken = (NULL == random_numbers))) + random_numbers = g_rand_new(); + for (i = 'A'; i <= 'Z'; ++i) + g_queue_push_head(shuffler,GINT_TO_POINTER(i)); + memset(hs,0,n*(sizeof(NGON))); + hs[n-1].sides = -1; /* assign the sentinel */ + for (h = hs; !h->sides; ++h) { + int div = (h-hs)/4, mod = (h-hs)%4; + h->sides = 6; + h->c = GPOINTER_TO_INT( + g_queue_pop_nth( + shuffler, + g_rand_int_range( + random_numbers, + (gint32)0, + (gint32)g_queue_get_length(shuffler)))); + fputc(h->c,stderr); + h->r = R; + h->Cx = R*(2+div*OFFSET_X), h->Cy = R*(2*(1+mod*OFFSET_Y)+ODD(div)*OFFSET_Y); + fprintf(stderr,"(%g,%g)\n",h->Cx,h->Cy); + } + fputc('\n',stderr); + g_queue_free(shuffler); + if (broken) + g_rand_free(random_numbers); +} + +static void add_loop(cairo_t*cr,NGON*hs,int select) { + NGON*h; + double r,Cx,Cy,x,y; + int i, sides; + for (h = hs; 0 < (sides = h->sides); ++h) + if ((select && h->selected) || (select == h->selected)) { + r = h->r, Cx = h->Cx, Cy = h->Cy; + i = 0; + x = Cx+r*cos(TAU*i/sides), y = Cy+r*sin(TAU*i/sides), cairo_move_to(cr,x,y); + for (i = 1; i < sides; ++i) + x = Cx+r*cos(TAU*i/sides), y = Cy+r*sin(TAU*i/sides), cairo_line_to(cr,x,y); + cairo_close_path(cr); + } +} + +static int make_labels(cairo_t*cr,NGON*hs,int select) { + NGON*h; + int i = 0; + char text[2]; + text[1] = 0; + for (h = hs; 0 < h->sides; ++h) + if ((select && h->selected) || (select == h->selected)) + /* yuck, need to measure the font. Better to use pango_cairo */ + *text = h->c, cairo_move_to(cr,h->Cx,h->Cy), cairo_show_text(cr,text), ++i; + return i; +} + +static int archive(int a) { + static GQueue*q = NULL; + if ((NULL == q) && (NULL == (q = g_queue_new()))) { + fputs("\ncannot allocate archival queue. quitting!\n",stderr); + exit(EXIT_FAILURE); + } + if (a < -1) /* reset */ + return g_queue_free(q), q = NULL, 0; + if (-1 == a) /* pop off tail */ + return g_queue_is_empty(q) ? 0 : GPOINTER_TO_INT(g_queue_pop_tail(q)); + if (!a) /* peek most recent entry */ + return g_queue_is_empty(q) ? 0 : GPOINTER_TO_INT(g_queue_peek_head(q)); + g_queue_push_head(q,GINT_TO_POINTER(a)); /* store */ + return a; +} + +/* to do: use appropriate sizing, use the cairo transformation matrix */ +static gboolean draw(GtkWidget*widget,cairo_t*cr,gpointer data) { + + /* unselected fill in yellow */ + cairo_set_source_rgba(cr,0.8,0.8,0,1), + add_loop(cr,(NGON*)data,0); + cairo_fill(cr); + + /* selected fill, purple */ + cairo_set_source_rgba(cr,0.8,0,0.8,1); + add_loop(cr,(NGON*)data,1); + cairo_fill_preserve(cr); + + /* all outlines gray, background shows through, fun fun! */ + cairo_set_line_width (cr, 3.0); + cairo_set_source_rgba(cr,0.7,0.7,0.7,0.7); + add_loop(cr,(NGON*)data,0); + cairo_stroke(cr); + + /* select labels */ + cairo_set_source_rgba(cr,0,1,0,1); + make_labels(cr,(NGON*)data,1); + cairo_stroke(cr); + + /* unselected labels */ + cairo_set_source_rgba(cr,1,0,0,1); + /* to do: clean up this exit code */ + if (!make_labels(cr,(NGON*)data,0)) { + int c; + putchar('\n'); + while ((c = archive(-1))) + putchar(c); + puts("\nfinished"); + archive(-2); + exit(EXIT_SUCCESS); + } + cairo_stroke(cr); + + return TRUE; +} + +/*the widget is a GtkDrawingArea*/ +static gboolean button_press_event(GtkWidget*widget,const GdkEvent*event,gpointer data) { + NGON*h,*hs = (NGON*)data; + gdouble x_win, y_win; + if (!gdk_event_get_coords(event,&x_win,&y_win)) + fputs("\nBUTTON, gdk_event_get_coords(event,&x_win,&y_win)) failed\n",stderr); + else { + fprintf(stderr,"x_win=%g y_win=%g\n",(double)x_win,(double)y_win); + for (h = hs; 0 < h->sides; ++h) /* detection algorithm: */ + /* if mouse click within inner radius of hexagon */ + /* Much easier than all in-order cross products have same sign test! */ + if ((pow((x_win-h->Cx),2)+pow((y_win-h->Cy),2)) < pow((h->r*cos(TAU/(180/h->sides))),2)) { + ++h->selected; + archive(h->c); + /* discovery: gdk_window_invalidate_region with NULL second argument does not work */ + gdk_window_invalidate_rect(gtk_widget_get_window(widget),(const GdkRectangle*)NULL,TRUE); + break; + } + } + return TRUE; +} + +static gboolean key_press_event(GtkWidget*widget,const GdkEvent*event,gpointer data) { + NGON*h,*hs = (NGON*)data; + guint keyval; + int unicode; + if (!gdk_event_get_keyval(event,&keyval)) + fputs("\nKEY! gdk_event_get_keyval(event,&keyval)) failed.\n",stderr); + else { + unicode = (int)gdk_keyval_to_unicode(gdk_keyval_to_upper(keyval)); + fprintf(stderr,"key with unicode value: %d\n",unicode); + for (h = hs; 0 < h->sides; ++h) /* look for a matching character associated with a hexagon */ + if (h->c == unicode) { + ++(h->selected); + archive(h->c); + /* discovery: gdk_window_invalidate_region with NULL second argument does not work */ + gdk_window_invalidate_rect(gtk_widget_get_window(widget),(const GdkRectangle*)NULL,TRUE); + break; + } + } + return TRUE; +} + +int main(int argc,char*argv[]) { + GtkWidget *window, *vbox, /* *label, */ *drawing_area; + NGON ngons[21]; /* sentinal has negative number of sides */ + + /* discovery: gtk_init removes gtk debug flags, such as --gtk-debug=all */ + /* also calls gdk_init which handles --display and --screen or other X11 communication issues */ + gtk_init(&argc, &argv); + + /* GTK VERSION 3.2.0 */ + fprintf(stderr,"GTK VERSION %d.%d.%d\n",GTK_MAJOR_VERSION,GTK_MINOR_VERSION,GTK_MICRO_VERSION); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + /* discovery: to make window transparent I have to use the alpha channel correctly */ + + /* discovery: GTK_WINDOW(GtkWidget*) casts the widget to window */ + /* discovery: window in the function name? use GTK_WINDOW. g_ in function name? use G_OBJECT */ + gtk_window_set_title(GTK_WINDOW(window), "Rosetta Code Honeycomb, C with GTK"); + gtk_window_set_default_size(GTK_WINDOW(window), 308, 308+12+8); /* XxY */ + /* discovery: making the window vanish does not stop the program */ + /* discovery: NULL is placeholder for extra data sent to the callback */ + g_signal_connect_swapped(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL); + + /* I created /tmp/favicon.ico from http://rosettacode.org/favicon.ico */ + /* Your window manager could use the icon, if it exists, and you fix the file name */ + gtk_window_set_icon(GTK_WINDOW(window),create_pixbuf("/tmp/favicon.ico")); + + vbox = gtk_vbox_new(TRUE,1); + gtk_container_add(GTK_CONTAINER(window),vbox); + + /* to do: fix the label widget */ + /* I did not learn to control multiple box packing, and I was */ + /* too lazy to make the label widget accessible. Plan was to */ + /* insert the most recent character using "peek" option of the archive */ +#if 0 + label = gtk_label_new("None Selected"); + gtk_widget_set_size_request(label,308,20); + gtk_box_pack_end(GTK_BOX(vbox),label,FALSE,TRUE,4); +#endif + + drawing_area = gtk_drawing_area_new(); + gtk_widget_set_events(drawing_area,GDK_BUTTON_PRESS_MASK|GDK_KEY_PRESS_MASK|GDK_EXPOSURE_MASK); + + random_numbers = g_rand_new(); + initialize_hexagons(ngons,G_N_ELEMENTS(ngons)); + /* Discovery: expose_event changed to draw signal. We no longer need configure-event */ + g_signal_connect(G_OBJECT(drawing_area),"draw",G_CALLBACK(draw),(gpointer)ngons); + + g_signal_connect(G_OBJECT(drawing_area),"button-press-event",G_CALLBACK(button_press_event),(gpointer)ngons); + g_signal_connect(G_OBJECT(drawing_area),"key-press-event",G_CALLBACK(key_press_event),(gpointer)ngons); + gtk_widget_set_size_request(drawing_area, 308, 308); /* XxY */ + gtk_box_pack_start(GTK_BOX(vbox),drawing_area,TRUE,TRUE,4); + + /* Discovery: must allow focus to receive keyboard events */ + gtk_widget_set_can_focus(drawing_area,TRUE); + + /* Discovery: can set show for individual widgets or use show_all */ + gtk_widget_show_all(window); + gtk_main(); + g_rand_free(random_numbers); + return EXIT_SUCCESS; +} diff --git a/Task/Honeycombs/Icon/honeycombs.icon b/Task/Honeycombs/Icon/honeycombs.icon new file mode 100644 index 0000000000..b39496e2e0 --- /dev/null +++ b/Task/Honeycombs/Icon/honeycombs.icon @@ -0,0 +1,108 @@ +link printf + +procedure main(A) + h := (0 < integer(\A[1])) | 4 # cells high + w := (0 < integer(\A[2])) | 5 # cells wide + u := (10 < integer(\A[3])) | 30 # length of cell side + HoneyComb(h,w,u) +end + +$define INACTIVE "light yellow" +$define ACTIVE "light purple" + +procedure HoneyComb(h,w,u) #: run HoneyComb demo + + wb := u/2 # window border + wmsg := 10 # . message space + ww := 2*wb + u*(3*w+1)/2 # . width + wh := 2*wb+wmsg+integer((h+1)*u*sqrt(3.)) # . height + + chosen := sprintf("black,%d",wb) + fine := sprintf("black,%d",wmsg) + + wparms := [ title := sprintf("HoneyComb-%dx%d",h,w), + "g","bg=white","fg=black", + sprintf("size=%d,%d",ww,wh) ] + &window := open!wparms | stop("Unable to open window") + + alpha := &ucase # per original spec + if h*w > *alpha then alpha ++:= &lcase # more + if h*w > *alpha then alpha ++:= &digits # more again + if h*w > *alpha then + stop("More than ",*alpha," cells.") # choke + + every put(letters := [],!string(alpha)) + every !letters :=: ?letters # randomize + + Widgets := [] # prepare widgets + every c := 1 to w do { # layout grid of cells + if /top then # start at top left + x := y := wb + else { # continue right from top + x := top.rx + y := if c % 2 = 0 then top.ry0 else top.ry1 + } + put(Widgets,W := top := HexWidget(x,y,u,get(letters))) + every 2 to h do # fill in rest of column + put(Widgets,W := HexWidget(x := W.dx,y := W.dy,u,get(letters))) + } + + activated := "" + until *activated = *Widgets do { # process widgets + e := Event() + every W := !Widgets do # select widget by + if ((e == &lpress) & W.inside(W,&x,&y)) | # mouse (left press) or + (e == W.s) then # label character + if not find(W.s,activated) then # activate if new + break activated ||:= ( DrawCell(W,ACTIVE), W.s) + Font(chosen) + DrawString(wb,wh-wb-wmsg,"Chosen: "||activated) # update selected list + } + WriteImage(sprintf("%s-%d.gif",title,&now)) # save file + Font(fine) # tell how to quit + DrawString(wb,wh-wmsg,"Right click to exit") + until Event() == &rpress + close(&window) +end + +record HexWidgetData(s,u,w,h,ax,ay,cx,cy,poly,xx,xy,dx,dy,rx,ry0,ry1,inside) + +procedure HexWidget(ax,ay,u,s) #: create widget s @ x,y & side u +/u := 20. # side +x := integer(0 <= ax) | runerr(205,ax) # ensure whole numbers +y := integer(0 <= ay) | runerr(205,ay) +u := integer(1 <= u) | runerr(205,u) # 1 is minimal if ridiculous +h := integer(sqrt(3./4) * (w := 2 * u)) # h,w +W := HexWidgetData(s,u,w,h, # string, side, width and height + ax,ay, # absolute x,y + ax+w/2,ay+h/2, # center x,y + [ax+u/2,ay, ax+(3*u)/2,ay, ax+2*u,ay+h/2, + ax+(3*u)/2,ay+h, ax+u/2,ay+h, ax,ay+h/2], # to draw polygon + -u/2,h/2, # const for z of cross product + x,ay+h, # next cell down + ax+(3*u)/2,ay+h/2,ay-h/2, # next cells right up/down + InHexWidget) # is it activated proc +return DrawCell(W,INACTIVE) +end + +procedure DrawCell(W,colour) #: Draw the (general) Widget + Fg(colour) + FillPolygon!W.poly # can draw any polygon + Fg("black") + DrawPolygon!W.poly + Font(sprintf("Helvetica,%d",integer(W.h/2.))) + DrawString(W.cx - TextWidth(W.s)/2, + W.cy + (WAttrib("ascent") - WAttrib("descent"))/2 + 1,W.s) + return W +end + +procedure InHexWidget(W,x,y) #: return W if x,y are inside W + if W.w < 0 then W.ax -:= (W.w := -W.w) # fix if -w + if W.h < 0 then W.ay -:= (W.h := -W.h) # fix if -h + if (0 < x - W.ax < W.w) & (0 < y - W.ay < W.h) then { # disallow edge + if x > W.cx then x := W.cx - (x - W.cx) # reflect x->NW + if y > W.cy then y := W.cy - (y - W.cy) # reflect y->NW + if 0 > real(W.xx)*(y-W.poly[2]) - W.xy*(x-W.poly[1]) then # z from cross + return W + } +end diff --git a/Task/Honeycombs/Prolog/honeycombs.pro b/Task/Honeycombs/Prolog/honeycombs.pro new file mode 100644 index 0000000000..67f14533e2 --- /dev/null +++ b/Task/Honeycombs/Prolog/honeycombs.pro @@ -0,0 +1,214 @@ +honeycomb :- + new(W, window('Honeycomb')), + new(Counter, counter(20)), + new(Ph, phrase(W, point(50,500))), + send(W, recogniser, new(KB, key_binding(@nil, argument))), + numlist(0, 19, NL), + create_letters(20, [], LL), + maplist(build_list(150,100), NL, LP), + new(ChCell, chain), + maplist(create_cell(W, Counter, Ph, KB, ChCell), LP, LL), + send(W, size, size(600, 600)), + % we must free the resources + send(W, done_message, and(message(ChCell, for_all, message(@arg1, free)), + message(ChCell, free), + message(Counter, free), + message(Ph, free), + message(W, destroy))), + send(W, open). + + +% create the link between the keyboard and the cell +init_key_binding(KB, Cell-UpperCase) :- + downcase_atom(UpperCase, LowerCase), + send(KB, function, UpperCase, message(Cell, click)), + send(KB, function, LowerCase, message(Cell, click)). + +create_letters(0, LL, LL) :- !. + +create_letters(N, L1, LL) :- + C is random(26) + 65, + ( \+member(C, L1) -> + N1 is N-1, create_letters(N1, [C|L1], LL) + ; create_letters(N, L1, LL)). + +% creation of the cells +create_cell(W, Counter,Phrase, KB, ChCell, Point, Code) :- + char_code(Letter, Code), + new(H, cell(W, Counter, Phrase, Letter, Point)), + send(H, my_draw), + send(ChCell, append, H), + % create the link between the keyboard and the cell + init_key_binding(KB, H-Letter). + + +% build the list of the centers of the cells +build_list(X0,Y0, N, point(X,Y)) :- + C is N mod 5, + L is N // 5, + C0 is C mod 2, + X is C * 75 + X0, + Y is L * round(50 * sqrt(3)) + C0 * round(25 * sqrt(3)) + Y0. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +:- pce_begin_class(phrase, string, "spelled string"). +variable(str, string, both, "displayed string"). +variable(window, object, both, "the display" ). +variable(pt, point, both, "where to display strings"). +variable(lbl1, label, both, "label to display the letters"). +variable(lbl2, label, both, "label to display the last letter"). + +initialise(P, Window : object, Point : point) :-> + send(P, slot, window, Window), + send(P, slot, str, new(_, string(''))), + send(P, slot, pt, Point), + new(Lbl1, label), + send(Lbl1, font, @times_bold_24), + send(P, slot, lbl1, Lbl1), + new(Lbl2, label), + send(Lbl2, font, @times_bold_24), + send(P, slot, lbl2, Lbl2). + +unlink(P) :-> + get(P, slot, lbl1, Lbl1), + send(Lbl1, free), + get(P, slot, lbl2, Lbl2), + send(Lbl2, free), + send(P, send_super, unlink). + +% display the list of the letters +% and the last letter on the screen +new_letter(P, Letter) :-> + get(P, slot, str, Str), + send(Str, append, Letter), + send(P, slot, str, Str), + new(S1, string('Chosen : %s', Str)), + get(P, slot, lbl1, Lbl1), + send(Lbl1, selection, S1), + get(P, slot, window, W), + get(P, slot, pt, Pt), + send(W, display, Lbl1, Pt), + new(S2, string('The user choose letter %c.', Letter)), + get(P, slot, lbl2, Lbl2), + send(Lbl2, selection, S2), + get(Pt, x, X), + get(Pt, y, Y), + Y1 is Y + 30, + send(W, display, Lbl2, point(X, Y1)). + +:- pce_end_class(phrase). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +:- pce_begin_class(counter, object, "count the unclicked cells"). +variable(nb, number, both, "number of unclicked cells"). + +initialise(P, N : number) :-> + send(P, slot, nb, N). + +decrement(P) :-> + get(P, slot, nb, N), + send(N, minus, 1), + send(P, slot, nb, N), + ( send(N, equal, 0) -> + send(@display, inform, 'The game is over !') + ; true). +:- pce_end_class(counter). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +:- pce_begin_class(cell, path, "The honneycomb cell"). +variable(p, path, both, "the cell itself" ). +variable(window, object, both, "the display" ). +variable(letter, name, both, "Upcase letter displayed in the cell" ). +variable(center, point, both, "coordinates of the center of the cell"). +variable(color, colour, both, "colour of the cell"). +variable(count, counter, both, "counter of unclicked cells"). +variable(status, object, both, "clicked/unclicked"). +variable(phr, phrase, both, "to display the new letter"). + +initialise(P, Window : object, Counter : counter, + Phrase: phrase, Letter:name, Center:point) :-> + send_super(P, initialise), + send(P, slot, letter, Letter), + send(P, slot, center, Center), + send(P, slot, window, Window), + send(P, slot, count, Counter), + send(P, slot, status, unclicked), + send(P, slot, phr, Phrase), + new(Pa, path), + ( + get(Center, x, X0), + get(Center, y, Y0), + X is X0 - 25, Y is Y0 - round(25 * sqrt(3)), + send(Pa, append, point(X, Y)), + X1 is X + 50, + send(Pa, append, point(X1, Y)), + X2 is X1 + 25, + send(Pa, append, point(X2, Y0)), + Y3 is Y0 + round(25 * sqrt(3)), + send(Pa, append, point(X1, Y3)), + send(Pa, append, point(X, Y3)), + X4 is X - 25, + send(Pa, append, point(X4, Y0)), + send(Pa, closed, @on) + ), + send(P, p, Pa), + send(P, slot, color, colour(@default, 65535, 65535, 0)), + % create the link between the mouse and the cell + send(Pa, recogniser, + click_gesture(left, '', single, message(P, click))). + + +unlink(P) :-> + get(P, slot, p, Pa), + send(Pa, free), + send(P, send_super, unlink). + + +% message processed when the cell is clicked +% or when the letter is pressed on the keyboard +click(P) :-> + % test if the cell has already been clicked + % succeed when the the status is 'unclicked' + get(P, slot, status, unclicked), + % change the status + send(P, slot, status, clicked), + % change the color + send(P, slot, color, colour(@default, 65535, 0, 65535)), + send(P, my_draw), + get(P, slot, letter, Letter), + % inform the object "phrase" that a new letter is clicked + get(P, slot, phr, Phrase), + send(Phrase, new_letter, Letter), + % inform the object "counter" that a new letter is clicked + get(P, count, Counter), + send(Counter, decrement). + +my_draw(P) :-> + % display the path and fill it with the current colour + get(P, slot, window, W), + get(P, slot, p, Pa), + send(W, display, Pa), + get(P, slot, color, Col), + send(Pa, fill_pattern, Col), + + % display the letter centered + get(P, slot, letter, C), + new(Str, string(C)), + new(Tx, text(Str?value)), + send(Tx, font, font(times, bold, 24)), + + % compute the size of the message to center it + get(P, slot, center, point(X0,Y0)), + get(font(times, bold, 24), width(Str), M), + XT is X0 - M/2, + get(font(times, bold, 24), height, H), + YT is Y0 - H/2, + send(W, display, Tx, point(XT, YT)). + + +:- pce_end_class(cell). diff --git a/Task/Honeycombs/Ruby/honeycombs.rb b/Task/Honeycombs/Ruby/honeycombs.rb new file mode 100644 index 0000000000..23efc8e3c5 --- /dev/null +++ b/Task/Honeycombs/Ruby/honeycombs.rb @@ -0,0 +1,137 @@ +Shoes.app(:height => 700, :width => 800) do + C = Math::cos(Math::PI/3) + S = Math::sin(Math::PI/3) + Radius = 60 + letters = [ + %w[L A R N D 1 2], + %w[G U I Y T 3 4], + %w[P C F E B 5 6], + %w[V S O M K 7 8], + %w[Q X J Z H 9 0], + ] + + def highlight(hexagon) + hexagon.style(:fill => magenta) + end + + def unhighlight(hexagon) + hexagon.style(:fill => yellow) + end + + def choose(hexagon) + hexagon.choose + highlight hexagon + chosen = @hexagons.find_all {|h| h.chosen?}.map {|h| h.letter} + if chosen.size == @hexagons.size + @chosen.text = 'Every hexagon has been chosen.' + else + @chosen.text = "Chosen: #{chosen.sort.join(',')}" + + "\nLast Chosen: #{hexagon.letter}" + end + end + + width = 20 + (Radius*(7*letters[0].size - 3)/4.0).ceil + height = 60 + (Radius*(1 + 2*S*letters.size)).ceil + @hexagons = [] + letter_to_hex = {} + + # create the GUI + stack(:height => height, :width => width) do + @chosen = para("Chosen:\nLast chosen:") + + # draw the hexagrams + letters.size.times do |row| + letters[0].size.times do |column| + x = 60 + column * Radius * 0.75 + (1-S)*Radius + y = 80 + row * Radius * S + (column.odd? ? S * Radius * 0.5 : 0) + h = shape(x-Radius, y-S*Radius) do + stroke red + strokewidth 3 + move_to(x-C*Radius, y-S*Radius) + line_to(x+C*Radius, y-S*Radius) + line_to(x+Radius, y) + line_to(x+C*Radius, y+S*Radius) + line_to(x-C*Radius, y+S*Radius) + line_to(x-Radius, y) + line_to(x-C*Radius, y-S*Radius) + end + + # add some attributes and methods to the shape + class << h + attr_accessor :x, :y, :state, :letter + def chosen? + not @state.nil? + end + def choose + @state = :chosen + end + def contains?(px,py) + if @x-Radius < px and px <= @x-C*Radius + ratio = (px - @x + Radius).to_f/(Radius*(1-C)) + return (@y - ratio*S*Radius < py and py <= @y + ratio*S*Radius) + elsif @x-C*Radius < px and px <= @x+C*Radius + return (@y - S*Radius < py and py < @y + S*Radius) + elsif @x+C*Radius < px and px <= @x+Radius + ratio = (@x + Radius - px).to_f/(Radius*(1-C)) + return (@y - ratio*S*Radius < py and py <= @y + ratio*S*Radius) + else + return false + end + end + def inspect + '<%s,"%s",%s,%d@%d>' % [self.class, letter, chosen?, x, y] + end + end + + h.x = x + x-Radius + h.y = y + y-S*Radius + h.letter = letters[row][column] + unhighlight h + + @hexagons << h + letter_to_hex[h.letter.downcase] = h + letter_to_hex[h.letter.upcase] = h + + # add the letter to the hexagon + para(h.letter) \ + .style(:size => 56, :stroke => red) \ + .move(h.x - C*Radius, h.y - S*Radius) + end + end + + # highlight the hexagon under the mouse + @hex_over = nil + motion do |x, y| + hex = @hexagons.find {|h| h.contains?(x,y)} + unless hex.nil? or hex.chosen? + highlight hex + end + unless @hex_over == hex or @hex_over.nil? or @hex_over.chosen? + unhighlight @hex_over + end + @hex_over = hex + end + + # handle mouse clicks + click do |button, x, y| + info("button #{button} clicked at (#{x}, #{y})") + hexagon = @hexagons.find {|h| h.contains?(x,y)} + unless hexagon.nil? + info("clicked hexagon #{hexagon}") + choose hexagon + end + end + + # handle keystrokes + keypress do |key| + if key == "\x11" # control-Q + exit + elsif key == "?" + info @hexagons.collect {|h| h.inspect}.join("\n") + elsif letter_to_hex.has_key?(key) + info("pressed key #{key} -> #{letter_to_hex[key]}") + choose letter_to_hex[key] + end + end + end +end diff --git a/Task/Honeycombs/Tcl/honeycombs.tcl b/Task/Honeycombs/Tcl/honeycombs.tcl new file mode 100644 index 0000000000..6212961f15 --- /dev/null +++ b/Task/Honeycombs/Tcl/honeycombs.tcl @@ -0,0 +1,87 @@ +package require Tcl 8.5 +package require Tk + +# How to make a honeycomb +proc honeycomb {w letterpattern} { + canvas $w -width 500 -height 470 + set basey 10 + foreach row $letterpattern { + set basex 10 + set majoroffsety 0 + foreach letter $row { + set x [expr {$basex + 60}] + set y [expr {$basey + 50 + $majoroffsety}] + drawhex $w $x $y $letter 30 50 + set majoroffsety [expr {50 - $majoroffsety}] + incr basex 90 + } + incr basey 100 + } + return $w +} + +namespace import tcl::mathop::? ;# For convenience +# How to draw a single hexagon, centered at a particular point. +proc drawhex {w x y ch dx dy} { + if {$ch eq ""} return ;# Allow elision of cells (not used here) + $w create polygon \ + [- $x $dx] [- $y $dy] [+ $x $dx] [- $y $dy] [+ $x $dx $dx] $y \ + [+ $x $dx] [+ $y $dy] [- $x $dx] [+ $y $dy] [- $x $dx $dx] $y \ + -fill yellow -outline black -tags [list hex$ch hull$ch] -width 3 + $w create text $x $y -text $ch -fill red -tags [list hex$ch txt$ch] \ + -font {Arial 72 bold} + # Install bindings on items + $w bind hex$ch [list enterhex $w $ch] + $w bind hex$ch [list leavehex $w $ch] + $w bind hex$ch [list dohex $w $ch] + # Handle keyboard activity through canvas-level bindings + bind $w [string toupper $ch] [list dokey $w $ch] + bind $w [string tolower $ch] [list dokey $w $ch] +} + +# Callbacks for various bindings +proc enterhex {w ch} { + global chosen + if {$ch ni $chosen} { + $w itemconfigure hull$ch -fill magenta + $w itemconfigure txt$ch -fill black + } +} +proc leavehex {w ch} { + global chosen + if {$ch ni $chosen} { + $w itemconfigure hull$ch -fill yellow + $w itemconfigure txt$ch -fill red + } +} +proc dohex {w ch} { + global chosen + if {$ch ni $chosen} { + lappend chosen $ch + puts "chosen $ch" + } + if {[llength $chosen] >= 5} { + destroy $w + } +} +proc dokey {w ch} { + enterhex $w $ch + dohex $w $ch +} + +# Initial declarations of state variables +set chosen {} +set letterpattern { + {L A R N D} + {G U I Y T} + {P C F E B} + {V S O M K} +} + +# Build the GUI +pack [honeycomb .c $letterpattern] +focus .c +# Usually don't use this, but it's ideal for this interaction pattern +tkwait window .c +puts "overall list of characters: $chosen" +exit diff --git a/Task/Horizontal-sundial-calculations/0DESCRIPTION b/Task/Horizontal-sundial-calculations/0DESCRIPTION new file mode 100644 index 0000000000..f367e3c4b1 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/0DESCRIPTION @@ -0,0 +1,5 @@ +A program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an ''operator'' entered location. + +As the example the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W) of [[wp:Jules Verne|Jules Verne]]'s ''[[wp:The Mysterious Island|Lincoln Island]]'', aka ''[[wp:Ernest Legouve Reef|Ernest Legouve Reef]])''. With a legal meridian of 150°W. + +Wikipedia: A [[wp:sundial|sundial]] is a device that measures time by the position of the [[wp:Sun|Sun]]. In common designs such as the horizontal sundial, the sun casts a [[wp:shadow|shadow]] from its ''style'' (also called its [[wp:Gnomon|Gnomon]], a thin rod or a sharp, straight edge) onto a flat surface marked with lines indicating the hours of the day. As the sun moves across the sky, the shadow-edge progressively aligns with different hour-lines on the plate. Such designs rely on the style being aligned with the axis of the Earth's rotation. Hence, if such a sundial is to tell the correct time, the style must point towards [[wp:true north|true north]] (not the [[wp:North Magnetic Pole|north]] or [[wp:Magnetic South Pole|south magnetic pole]]) and the style's angle with horizontal must equal the sundial's geographical [[wp:latitude|latitude]]. diff --git a/Task/Horizontal-sundial-calculations/1META.yaml b/Task/Horizontal-sundial-calculations/1META.yaml new file mode 100644 index 0000000000..d77143425a --- /dev/null +++ b/Task/Horizontal-sundial-calculations/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Mathematics +note: sciences diff --git a/Task/Horizontal-sundial-calculations/ALGOL-68/horizontal-sundial-calculations.alg b/Task/Horizontal-sundial-calculations/ALGOL-68/horizontal-sundial-calculations.alg new file mode 100644 index 0000000000..b93d4652bb --- /dev/null +++ b/Task/Horizontal-sundial-calculations/ALGOL-68/horizontal-sundial-calculations.alg @@ -0,0 +1,24 @@ +BEGIN + REAL lat, slat, lng, ref; + print ( "Enter latitude => " ); read (lat); + print ( "Enter longitude => " ); read (lng); + print ( "Enter legal meridian => " ); read (ref); + new line(stand out); + + slat := sin(lat*2*pi/360) ; + print ( (" sine of latitude: ", float(slat,8,2,1), new line ) ); + print ( (" diff longitude: ", fixed((lng - ref),0,3), new line, new line ) ); + + print ( ("Hour, sun hour angle, dial hour line angle from 6am to 6pm", new line )); + + FOR h FROM -6 TO 6 + DO + REAL hra , hla ; # define hour angle and hour line angle # + hra := 15 * h ; # hour angle is 15 times the hour # + hra := hra - (lng - ref); # but correct for longitude difference # + hla := arc tan ( slat * tan(hra*2*pi/360) ) * 360 / ( 2*pi) ; + # page 132 of a68gdoc.pdf documentationfile # + print ("HR="+whole(h,3)+"; HRA="+fixed(hra,8,3)+"; HLA="+fixed(hla,8,3)); + new line(stand out) + OD +END diff --git a/Task/Horizontal-sundial-calculations/Ada/horizontal-sundial-calculations.ada b/Task/Horizontal-sundial-calculations/Ada/horizontal-sundial-calculations.ada new file mode 100644 index 0000000000..201d2daac4 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Ada/horizontal-sundial-calculations.ada @@ -0,0 +1,45 @@ +with Ada.Text_IO; +with Ada.Numerics.Elementary_Functions; +procedure Sundial is + use Ada.Numerics.Elementary_Functions; + use Ada.Numerics; + package Float_IO is new Ada.Text_IO.Float_IO (Float); + + Latitude, Longitude, Meridian : Float; + Latitude_Sine : Float; +begin + Ada.Text_IO.Put ("Enter latitude: "); + Float_IO.Get (Latitude); + Ada.Text_IO.Put ("Enter longitude: "); + Float_IO.Get (Longitude); + Ada.Text_IO.Put ("Enter legal meridian: "); + Float_IO.Get (Meridian); + Ada.Text_IO.New_Line; + + Latitude_Sine := Sin (Latitude * Pi / 180.0); + Ada.Text_IO.Put_Line + (" sine of latitude:" & Float'Image (Latitude_Sine)); + Ada.Text_IO.Put_Line + (" diff longitude:" & Float'Image (Longitude - Meridian)); + Ada.Text_IO.New_Line; + + Ada.Text_IO.Put_Line + ("hour, sun hour angle, dial hour line angle from 6am to 6pm"); + for H in -6 .. 6 loop + declare + Hour_Angle : constant Float := + 15.0 * Float (H) - (Longitude - Meridian); + Line_Angle : constant Float := + Arctan (Latitude_Sine * Tan (Hour_Angle * Pi / 180.0)) * 180.0 / + Pi; + begin + Ada.Text_IO.Put_Line + ("HR=" & + Integer'Image (H) & + "; HRA=" & + Float'Image (Hour_Angle) & + "; HLA=" & + Float'Image (Line_Angle)); + end; + end loop; +end Sundial; diff --git a/Task/Horizontal-sundial-calculations/AutoHotkey/horizontal-sundial-calculations.ahk b/Task/Horizontal-sundial-calculations/AutoHotkey/horizontal-sundial-calculations.ahk new file mode 100644 index 0000000000..801abd9ee6 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/AutoHotkey/horizontal-sundial-calculations.ahk @@ -0,0 +1,32 @@ +DllCall("AllocConsole") ; Open a console window for this application +Pi := 4*ATan(1) +,Degrees := Pi/180 + +FileAppend, Enter Latitude: , CONOUT$ ; write to stdout +FileReadLine, latitude, CONIN$, 1 ; read from stdin + +FileAppend, Enter Longitude: , CONOUT$ +FileReadLine, longitude, CONIN$, 1 + +FileAppend, Enter Legal meridian: , CONOUT$ +FileReadLine, meridian, CONIN$, 1 + +sineLatitude := Sin(latitude*Degrees) +FileAppend, `n, CONOUT$ +FileAppend, Sine of latitude: %sineLatitude%`n, CONOUT$ +FileAppend, % "Difference of Longitudes (given longitude - meridian): " . longitude-meridian . "`n", CONOUT$ +FileAppend, `n, CONOUT$ + +FileAppend, Numbers from 6 AM to 6 PM:`n, CONOUT$ +FileAppend, Hour`t`tSun Hour Angle`t Dial hour line angle`n, CONOUT$ + + +hour := -7 +While (++hour < 7) +{ + clockHour := hour < 0 ? abs(hour) . "AM" : hour . "PM" + shr := RTrim("" . (15.0*hour - (longitude-meridian)), "0") ; RTrim() removes trailing zeroes + dhla := Atan(sineLatitude*Tan(shr*degrees))/Degrees + FileAppend, %clockhour%`t`t%shr%`t`t%dhla%`n, CONOUT$ +} +MsgBox close me when done. diff --git a/Task/Horizontal-sundial-calculations/BBC-BASIC/horizontal-sundial-calculations.bbc b/Task/Horizontal-sundial-calculations/BBC-BASIC/horizontal-sundial-calculations.bbc new file mode 100644 index 0000000000..dd50b617d2 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/BBC-BASIC/horizontal-sundial-calculations.bbc @@ -0,0 +1,14 @@ + INSTALL @lib$+"FNUSING" + + INPUT "Enter latitude (degrees) : " latitude + INPUT "Enter longitude (degrees) : " longitude + INPUT "Enter legal meridian (degrees): " meridian + + PRINT '" Time", "Sun hour angle", "Dial hour line angle" + + FOR hour = 6 TO 18 + hra = 15*hour - longitude + meridian - 180 + hla = DEG(ATN(SIN(RAD(latitude)) * TAN(RAD(hra)))) + IF ABS(hra) > 90 hla += 180 * SGN(hra * latitude) + PRINT FNusing("##.##", hour), FNusing(" ####.### ", hra), FNusing(" ####.###", hla) + NEXT hour diff --git a/Task/Horizontal-sundial-calculations/C/horizontal-sundial-calculations.c b/Task/Horizontal-sundial-calculations/C/horizontal-sundial-calculations.c new file mode 100644 index 0000000000..542a49cc57 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/C/horizontal-sundial-calculations.c @@ -0,0 +1,43 @@ +#include +#include + +#define PICKVALUE(TXT, VM) do { \ + printf("%s: ", TXT); \ + scanf("%lf", &VM); \ + } while(0); + +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif + +#define DR(X) ((X)*M_PI/180.0) +#define RD(X) ((X)*180.0/M_PI) + +int main() +{ + double lat, slat, lng, ref; + int h; + + PICKVALUE("Enter latitude", lat); + PICKVALUE("Enter longitude", lng); + PICKVALUE("Enter legal meridian", ref); + printf("\n"); + + slat = sin(DR(lat)); + printf("sine of latitude: %.3f\n", slat); + printf("diff longitude: %.3f\n\n", lng - ref); + + printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n"); + + for(h = -6; h <= 6; h++) + { + double hla, hra; + hra = 15.0*h; + hra = hra - lng + ref; + hla = RD(atan(slat * tan(DR(hra)))); + printf("HR= %3d; \t HRA=%7.3f; \t HLA= %7.3f\n", + h, hra, hla); + } + + return 0; +} diff --git a/Task/Horizontal-sundial-calculations/D/horizontal-sundial-calculations.d b/Task/Horizontal-sundial-calculations/D/horizontal-sundial-calculations.d new file mode 100644 index 0000000000..04eb53cffe --- /dev/null +++ b/Task/Horizontal-sundial-calculations/D/horizontal-sundial-calculations.d @@ -0,0 +1,29 @@ +import std.stdio, std.math, std.conv, std.string; + +double radians(double x) { return x * (PI/180); } +double degrees(double x) { return x / (PI/180); } + +T input(T)(string msg) { + write(msg); + return to!T(readln().strip()); +} + +void main() { + double lat = input!double("Enter latitude => "); + double lng = input!double("Enter longitude => "); + double lme = input!double("Enter legal meridian => "); + writeln(); + + double slat = sin(radians(lat)); + writefln(" sine of latitude: %.3f", slat); + writefln(" diff longitude: %.3f", lng-lme); + writeln(); + writeln("Hour, sun hour angle, dial hour line angle from 6am to 6pm"); + + foreach (h; -6 .. 7) { + double hra = 15 * h; + hra -= (lng - lme); + double hla = degrees(atan(slat * tan(radians(hra)))); + writefln("HR=%3d; HRA=%7.3f; HLA=%7.3f", h, hra, hla); + } +} diff --git a/Task/Horizontal-sundial-calculations/DWScript/horizontal-sundial-calculations.dwscript b/Task/Horizontal-sundial-calculations/DWScript/horizontal-sundial-calculations.dwscript new file mode 100644 index 0000000000..4505e0a3bc --- /dev/null +++ b/Task/Horizontal-sundial-calculations/DWScript/horizontal-sundial-calculations.dwscript @@ -0,0 +1,23 @@ +procedure PrintSundial(lat, lng, lme : Float); +begin + PrintLn(Format('latitude: %7.2f', [lat])); + PrintLn(Format('longitude: %7.2f', [lng])); + PrintLn(Format('legal meridian: %7.2f', [lme])); + + var slat := Sin(DegToRad(lat)); + + PrintLn(Format('sine of latitude: %.3f', [slat])); + PrintLn(Format('diff longitude: %.3f', [lng-lme])); + PrintLn(''); + PrintLn('Hour, sun hour angle, dial hour line angle from 6am to 6pm'); + + var h : Integer; + for h:=-6 to 6 do begin + var hra := 15 * h - (lng - lme); + var hraRad := DegToRad(hra); + var hla :=RadToDeg(ArcTan2(Sin(hraRad)*slat, Cos(hraRad))); + PrintLn(Format('HR=%3d; HRA=%7.3f; HLA=%7.3f', [h, hra, hla])); + end +end; + +PrintSundial(-4.95, -150.5, -150); diff --git a/Task/Horizontal-sundial-calculations/Forth/horizontal-sundial-calculations.fth b/Task/Horizontal-sundial-calculations/Forth/horizontal-sundial-calculations.fth new file mode 100644 index 0000000000..d9c47914ad --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Forth/horizontal-sundial-calculations.fth @@ -0,0 +1,19 @@ +: faccept ( -- f ) + pad 32 accept pad swap >float 0= throw ; +: >radians ( deg -- rad ) 180e f/ pi f* ; +: >degrees ( rad -- deg ) pi f/ 180e f* ; +: sundial + cr ." Enter latitude: " + faccept >radians fsin + cr ." Enter longitude: " + faccept + cr ." Enter legal meridian: " + faccept f- ( sin[latitude] longitude ) + + cr ." Hour : HourAngle , DialAngle" + 7 -6 do + cr i . ." : " + fover fover fnegate i 15 * s>d d>f f+ + fdup f. ." , " + >radians ftan f* fatan >degrees f. + loop fdrop fdrop ; diff --git a/Task/Horizontal-sundial-calculations/Fortran/horizontal-sundial-calculations.f b/Task/Horizontal-sundial-calculations/Fortran/horizontal-sundial-calculations.f new file mode 100644 index 0000000000..afe33d0921 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Fortran/horizontal-sundial-calculations.f @@ -0,0 +1,45 @@ +program SunDial + + real :: lat, slat, lng, ref + real :: hra, hla + integer :: h + + real, parameter :: pi = 3.14159265358979323846 + + print *, "Enter latitude" + read *, lat + print *, "Enter longitude" + read *, lng + print *, "Enter legal meridian" + read *, ref + + print * + + slat = sin(dr(lat)) + write(*, '(A,1F6.3)') "sine of latitude: ", slat + write(*, '(A,1F6.3)') "diff longitude: ", lng - ref + + print *, "Hour, sun hour angle, dial hour line angle from 6am to 6pm" + + do h = -6, 6 + hra = 15.0*h + hra = hra - lng + ref + hla = rd( atan( slat * tan( dr(hra) ) ) ) + write(*, '(" HR= ",I3,"; \t HRA=",F7.3,"; \t HLA= ", F7.3)'), h, hra, hla + end do + +contains + + function dr(angle) + real :: dr + real, intent(in) :: angle + dr = angle*pi/180.0 + end function dr + + function rd(angle) + real :: rd + real, intent(in) :: angle + rd = angle*180.0/pi + end function rd + +end program SunDial diff --git a/Task/Horizontal-sundial-calculations/Go/horizontal-sundial-calculations.go b/Task/Horizontal-sundial-calculations/Go/horizontal-sundial-calculations.go new file mode 100644 index 0000000000..b172de86c8 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Go/horizontal-sundial-calculations.go @@ -0,0 +1,44 @@ +package main + +import ( + "bufio" + "fmt" + "math" + "os" + "strconv" + "strings" +) + +func getnum(prompt string) (r float64) { + in := bufio.NewReader(os.Stdin) + for { + fmt.Print(prompt) + s, err := in.ReadString('\n') + if err != nil { + fmt.Println(err) + os.Exit(-1) + } + r, err = strconv.ParseFloat(strings.TrimSpace(s), 64) + if err == nil { + break + } + fmt.Println(err) + } + return +} + +func main() { + lat := getnum("Enter latitude => ") + lng := getnum("Enter longitude => ") + ref := getnum("Enter legal meridian => ") + slat := math.Sin(lat * math.Pi / 180) + diff := lng - ref + fmt.Println("\n sine of latitude: ", slat) + fmt.Println(" diff longitude: ", diff) + fmt.Println("\nHour, sun hour angle, dial hour line angle from 6am to 6pm") + for h := -6.; h <= 6; h++ { + hra := 15*h - diff + hla := math.Atan(slat*math.Tan(hra*math.Pi/180)) * 180 / math.Pi + fmt.Printf("%2.0f %8.3f %8.3f\n", h, hra, hla) + } +} diff --git a/Task/Horizontal-sundial-calculations/Haskell/horizontal-sundial-calculations.hs b/Task/Horizontal-sundial-calculations/Haskell/horizontal-sundial-calculations.hs new file mode 100644 index 0000000000..a611727850 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Haskell/horizontal-sundial-calculations.hs @@ -0,0 +1,28 @@ +module Rosetta.HorSunDial where + +roundDec :: Int -> Double -> Double +roundDec d = (/10.0^d). fromIntegral. round. (*10.0^d) + +radToDegr = ((180/pi)*) +degrToRad = ((pi/180)*) + +main = do + let lat = -4.95 + long = -150.5 + legalMerid = -150 + sinOfLat = sin $ degrToRad lat + diff = legalMerid - long + + putStrLn $ "Latitude " ++ show lat + putStrLn $ "Longitude " ++ show long + putStrLn $ "Legal meridian " ++ show legalMerid + putStrLn $ "Sine of latitude " ++ show (roundDec 6 sinOfLat) + putStrLn $ "Diff longitude " ++ show (-diff) + putStrLn "hour sun hour angle dial hour line angle" + mapM_ (\h -> + let sha = diff + 15*h + dhla = radToDegr . atan. (sinOfLat *). tan $ degrToRad sha + in putStrLn $ take 7 (show h ++ repeat ' ') + ++ take 16 (show (roundDec 3 sha) ++ repeat ' ' ) + ++ " " ++ show (roundDec 3 dhla) + ) [-6,-5..6] diff --git a/Task/Horizontal-sundial-calculations/Icon/horizontal-sundial-calculations.icon b/Task/Horizontal-sundial-calculations/Icon/horizontal-sundial-calculations.icon new file mode 100644 index 0000000000..85917555b2 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Icon/horizontal-sundial-calculations.icon @@ -0,0 +1,24 @@ +procedure main() + PrintSundial(-4.95, -150.5, -150); +end + +procedure PrintSundial(lat, lng, mer ) + write("latitude: ", lat, + "\nlongitude: ", lng, + "\nlegal meridian: ", mer) + + slat := sin(dtor(lat)) + + write("sine of latitude: ",slat, + "\ndiff longitude: ", lng-mer) + write("\nHour, sun hour angle, dial hour line angle from 6am to 6pm") + + every h := -6 to 6 do { + hraRad := dtor(hra := 15 * h - (lng - mer)) + hla :=rtod(atan(sin(hraRad)*slat, cos(hraRad))) + write("HR=", + right(if h <= 0 then 12+h else h,2), + if h < 0 then "am" else "pm", + " HRA=",hra,", HLA=",hla) + } +end diff --git a/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-1.j b/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-1.j new file mode 100644 index 0000000000..2b09e58b5a --- /dev/null +++ b/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-1.j @@ -0,0 +1,15 @@ +require 'trig' +atan2=: {:@*.@j. NB. arc tangent of y divided by x + +horiz=: verb define + 'lat lng ref'=. y + out=. smoutput@,&": + 'Latitude ' out lat + 'Longitude ' out lng + 'Legal meridian ' out ref + 'Sine of latitude ' out slat=. sin rfd lat + 'Diff longitude ' out -diff=. ref - lng + lbl=.'hour ';'sun hour angle ';'dial hour line angle' + r=.((,. (,. (atan2 *&slat)/@+.@r.&.rfd)) diff + 15&*) i:6 + smoutput lbl ,: ('3.0';'7.3';'7.3') 8!:1 r +) diff --git a/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-2.j b/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-2.j new file mode 100644 index 0000000000..47c97df5e1 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/J/horizontal-sundial-calculations-2.j @@ -0,0 +1,23 @@ + horiz _4.95 _150.5 _150 +Latitude _4.95 +Longitude _150.5 +Legal meridian _150 +Sine of latitude _0.0862864 +Diff longitude _0.5 +┌──────┬────────────────┬────────────────────┐ +│hour │sun hour angle │dial hour line angle│ +├──────┼────────────────┼────────────────────┤ +│ -6 │-89.500 │ 84.225 │ +│ -5 │-74.500 │ 17.283 │ +│ -4 │-59.500 │ 8.334 │ +│ -3 │-44.500 │ 4.847 │ +│ -2 │-29.500 │ 2.795 │ +│ -1 │-14.500 │ 1.278 │ +│ 0 │ 0.500 │ -0.043 │ +│ 1 │ 15.500 │ -1.371 │ +│ 2 │ 30.500 │ -2.910 │ +│ 3 │ 45.500 │ -5.018 │ +│ 4 │ 60.500 │ -8.671 │ +│ 5 │ 75.500 │-18.451 │ +│ 6 │ 90.500 │-95.775 │ +└──────┴────────────────┴────────────────────┘ diff --git a/Task/Horizontal-sundial-calculations/Java/horizontal-sundial-calculations.java b/Task/Horizontal-sundial-calculations/Java/horizontal-sundial-calculations.java new file mode 100644 index 0000000000..b7e7aefe83 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Java/horizontal-sundial-calculations.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +public class Sundial { + public static void main(String[] args) { + double lat, slat, lng, ref; + Scanner sc = new Scanner(System.in); + + System.out.print("Enter latitude: "); + lat = sc.nextDouble(); + System.out.print("Enter longitude: "); + lng = sc.nextDouble(); + System.out.print("Enter legal meridian: "); + ref = sc.nextDouble(); + System.out.println(); + + slat = Math.sin(Math.toRadians(lat)); + System.out.printf("sine of latitude: %.3f\n", slat); + System.out.printf("diff longitude: %.3f\n\n", lng - ref); + + System.out.printf("Hour, sun hour angle, dial hour line angle from 6am to 6pm\n"); + + for (int h = -6; h <= 6; h++) { + double hla, hra; + hra = 15.0 * h; + hra = hra - lng + ref; + hraRad = Math.toRadians(hra); + hla = Math.toDegrees(Math.atan2(Math.sin(hraRad)*Math.sin(Math.toRadians(lat)), Math.cos(hraRad))); + System.out.printf("HR= %3d; \t HRA=%7.3f; \t HLA= %7.3f\n", + h, hra, hla); + } + } +} diff --git a/Task/Horizontal-sundial-calculations/Liberty-BASIC/horizontal-sundial-calculations.liberty b/Task/Horizontal-sundial-calculations/Liberty-BASIC/horizontal-sundial-calculations.liberty new file mode 100644 index 0000000000..1f026b744f --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Liberty-BASIC/horizontal-sundial-calculations.liberty @@ -0,0 +1,30 @@ +global pi +pi =3.14159265 + +input "Enter latitude (degrees) : "; latitude ' -4.95 +input "Enter longitude (degrees) : "; longitude ' -150.5 +input "Enter legal meridian (degrees): "; meridian ' -150.0 + +print +print "Time Sun hour angle Dial hour line angle" + +for hour = 6 TO 18 + hra =15 *hour - longitude +meridian -180 + hla =rad2deg( atn( sin( deg2rad( latitude)) *tan( deg2rad( hra)))) + if abs( hra) >90 then hla =hla +180 *sgn( hra *latitude) + print using( "##.##", hour), using("####.### ", hra), using("####.###", hla) +next hour + +function rad2deg( theta) + rad2deg =theta *180 /pi +end function + +function deg2rad( theta) + deg2rad =theta *pi /180 +end function + +function sgn( x) + if x >0 then sgn =1 else sgn =-1 +end function + +end diff --git a/Task/Horizontal-sundial-calculations/Logo/horizontal-sundial-calculations.logo b/Task/Horizontal-sundial-calculations/Logo/horizontal-sundial-calculations.logo new file mode 100644 index 0000000000..23410f244f --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Logo/horizontal-sundial-calculations.logo @@ -0,0 +1,13 @@ +type "|Enter latitude: | +make "lat readword +type "|Enter longitude: | +make "long readword +type "|Enter legal meridian: | +make "long :long - readword + +print [Hour : HourAngle , DialAngle] +for [hour -6 6] [ + make "hra 15 * :hour - :long + make "hla arctan product sin :lat quotient sin :hra cos :hra + print (sentence "hour :hour ": :hra ", :hla) +] diff --git a/Task/Horizontal-sundial-calculations/PicoLisp/horizontal-sundial-calculations.l b/Task/Horizontal-sundial-calculations/PicoLisp/horizontal-sundial-calculations.l new file mode 100644 index 0000000000..4fbe76f6a3 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/PicoLisp/horizontal-sundial-calculations.l @@ -0,0 +1,26 @@ +(load "@lib/math.l") + +(de prompt (Str . Arg) + (prin Str " => ") + (set (car Arg) (in NIL (read))) ) + +(use (Lat Lng Ref) + (prompt "Enter latitude " Lat) + (prompt "Enter longitude " Lng) + (prompt "Enter legal meridian" Ref) + (prinl) + (let Slat (sin (*/ Lat pi 180.0)) + (prinl " sine of latitude: " (round Slat)) + (prinl " diff longitude: " (round (- Lng Ref))) + (prinl) + (prinl "Hour, sun hour angle, dial hour line angle from 6am to 6pm") + (for H (range -6 6) + (let Hra (- (* 15.0 H) (- Lng Ref)) + (let Hla (*/ (atan (*/ Slat (tan (*/ Hra pi 180.0)) 1.0)) 180.0 pi) + (prinl + "HR=" + (align 3 H) + "; HRA=" + (align 8 (round Hra)) + "; HLA=" + (align 8 (round Hla)) ) ) ) ) ) ) diff --git a/Task/Horizontal-sundial-calculations/Python/horizontal-sundial-calculations.py b/Task/Horizontal-sundial-calculations/Python/horizontal-sundial-calculations.py new file mode 100644 index 0000000000..d4c150c2d4 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Python/horizontal-sundial-calculations.py @@ -0,0 +1,21 @@ +from __future__ import print_function +import math +try: raw_input +except: raw_input = input + +lat = float(raw_input("Enter latitude => ")) +lng = float(raw_input("Enter longitude => ")) +ref = float(raw_input("Enter legal meridian => ")) +print() + +slat = math.sin(math.radians(lat)) +print(" sine of latitude: %.3f" % slat) +print(" diff longitude: %.3f" % (lng-ref)) +print() +print("Hour, sun hour angle, dial hour line angle from 6am to 6pm") + +for h in range(-6, 7): + hra = 15 * h + hra -= lng - ref + hla = math.degrees(math.atan(slat * math.tan(math.radians(hra)))) + print("HR=%3d; HRA=%7.3f; HLA=%7.3f" % (h, hra, hla)) diff --git a/Task/Horizontal-sundial-calculations/REXX/horizontal-sundial-calculations.rexx b/Task/Horizontal-sundial-calculations/REXX/horizontal-sundial-calculations.rexx new file mode 100644 index 0000000000..a66bb39a51 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/REXX/horizontal-sundial-calculations.rexx @@ -0,0 +1,84 @@ +/*REXX program shows hour/sun hour angle/dial hour line angle, 6am─►6pm.*/ +numeric digits 60 /*better overkill then underkill. */ + +parse arg lat lng mer . /*get the arguments (if any). */ + /*If none specified, then use the */ + /*default of Jules Verne's Lincoln*/ + /*Island, aka Ernest Legouve Reef.*/ + +if lat=='' | lat==',' then lat=-4.95 /*No argument? Then use default.*/ +if lng=='' | lng==',' then lng=-150.5 /*No argument? Then use default.*/ +if mer=='' | mer==',' then mer=-150 /*No argument? Then use default.*/ +L=max(length(lat),length(lng),length(mer)) + say ' latitude:' right(lat,L) + say ' longitude:' right(lng,L) + say ' legal meridian:' right(mer,L) +sineLat=sin(d2r(lat)) +w1=max(length('hour'),length('midnight'))+2 +w2=max(length('sun hour') ,length('angle'))+2 +w3=max(length('dial hour'),length('line angle'))+2 +indent=left('',30) /*make presentation prettier. */ +say indent center(' ',w1) center('sun hour',w2) center('dial hour' ,w3) +say indent center('hour',w1) center('angle' ,w2) center('line angle',w3) +call sep /*add separator line for eyeballs*/ + + do h=-6 to 6 /*Okey dokey then, let's get busy*/ + select + when abs(h)==12 then hc='midnight' /*above artic circle ? */ + when h<0 then hc=-h 'am' /*convert hour for human beans. */ + when h==0 then hc='noon' /* ... easy to understand now. */ + when h>0 then hc=h 'pm' /* ... even meaningfull. */ + end /*select*/ + hra=15*h-lng+mer + hla=r2d(Atan(sineLat*tan(d2r(hra)))) + say indent center(hc,w1) right(format(hra,,1),w2) right(format(hla,,1),w3) + end /*h*/ + +call sep +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────subroutines─────────────────────────*/ +/*looking at subroutines is like looking at saugages being made. Don't.*/ +sep: say indent copies('═',w1) copies('═',w2) copies('═',w3); return +pi: return, /*a bit of overkill, but hey !! */ +3.1415926535897932384626433832795028841971693993751058209749445923078164062862 + /*Note: the real PI subroutine returns PI's accuracy that */ + /*matches the current NUMERIC DIGITS, up to 1 million digits.*/ + /*John Machin's formula is used for calculating more digits. */ + +d2d: return arg(1)//360 /*normalize degrees►1 unit circle*/ +d2r: return r2r(arg(1)*pi()/180) /*convert degrees ──► radians. */ +r2d: return d2d((arg(1)*180/pi())) /*convert radians ──► degrees. */ +r2r: return arg(1)//(2*pi()) /*normalize radians►1 unit circle*/ +tan: procedure; arg x; _=cos(x); if _=0 then call tanErr; return sin(x)/_ +tanErr: call tellErr 'tan('||x") causes division by zero, X="||x +tellErr: say; say '*** error! ***'; say; say arg(1); say; exit 13 +AsinErr: call tellErr 'Asin(x), X must be in the range of -1 ──► +1, X='||x +sqrtErr: call tellErr "sqrt(x), X can't be negative, X="||x +AcosErr: call tellErr 'Acos(x), X must be in the range of -1 ──► +1, X='||x +Acos: procedure; arg x; if x<-1|x>1 then call AcosErr; return .5*pi()-Asin(x) + +Atan: procedure; arg x; if abs(x)=1 then return pi()/4*sign(x) + return Asin(x/sqrt(1+x**2)) + +sin: procedure; arg x; x=r2r(x); numeric fuzz min(5,digits()-3) + if abs(x)=pi() then return 0; return .sinCos(x,x,1) + +cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz min(9,digits()-9) + if a=pi() then return -1; if a=pi()/2 | a=2*pi() then return 0 + if a=pi()/3 then return .5; if a=2*pi()/3 then return -.5 + return .sincos(1,1,-1) +.sinCos: parse arg z,_,i; x=x*x; p=z + do k=2 by 2; _=-_*x/(k*(k+i));z=z+_; if z=p then leave;p=z;end; return z + +Asin: procedure; parse arg x; if x<-1 | x>1 then call AsinErr; s=x*x + if abs(x)>=.7 then return sign(x)*Acos(sqrt(1-s)); z=x; o=x; p=z + do j=2 by 2; o=o*s*(j-1)/j; z=z+o/(j+1); if z=p then leave; p=z; end + return z + +sqrt: procedure; parse arg x; if x=0 then return 0;d=digits();numeric digits 11 + g=.sqrtGuess(); do j=0 while p>9; m.j=p; p=p%2+1; end + do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k; g=.5*(g+x/g); end + numeric digits d; return g/1 +.sqrtGuess: if x<0 then call sqrtErr; numeric form scientific; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 diff --git a/Task/Horizontal-sundial-calculations/Racket/horizontal-sundial-calculations.rkt b/Task/Horizontal-sundial-calculations/Racket/horizontal-sundial-calculations.rkt new file mode 100644 index 0000000000..d8c263a7b8 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Racket/horizontal-sundial-calculations.rkt @@ -0,0 +1,77 @@ +#lang racket + +;; print the table for a given latitude and longitude-offset, +;; given in degrees +(define (print-table lat long-offset) + ;; print the table header + (display + (~a " sine of latitude: " + (~r (sin (deg->rad lat)) #:precision '(= 3)) + "\n" + " diff longitude: " + (~r long-offset #:precision '(= 3)) + "\n\nHour, sun hour angle, dial hour line angle " + "from 6am to 6pm\n")) + ;; print the table + (for ([h (in-range -6 7)]) + (define hra (- (* 15 h) long-offset)) + (define hla (to-hla lat hra)) + (display (~a "HR="(pad-to 3 (~a h))"; " + "HRA="(pad-to 7 (~r hra #:precision '(= 3)))"; " + "HLA="(pad-to 7 (~r hla #:precision '(= 3)))"\n")))) + + +;; compute the angle on the gnomon corresponding to a +;; given angle of the sun (angles given and returned in degrees) +(define (to-hla lat ang) + (define lat-sign (cond [(< lat 0) -1] [else 1])) + ;; move to the right quadrant for + ;; angles outside [-90,90] + (define correction (* (cond [(< ang -90) -180] + [(> ang 90) 180] + [else 0]) + lat-sign)) + (+ (rad->deg (atan (* (sin (deg->rad lat)) + (tan (deg->rad ang))))) + correction)) + +;; write the prompt, return the entered number +(define (prompt->num p) + (printf "~a" p) + (string->number (read-line))) + +;; translate degrees to radians +(define (deg->rad d) (* 2 pi (/ d 360))) + +;; translate radians to degrees +(define (rad->deg r) (* 360 (/ r (* 2 pi)))) + +;; add spaces to reach given length +(define (pad-to cols str) + (define spaces-needed (max 0 (- cols (string-length str)))) + (string-append + (list->string (for/list ([i spaces-needed]) #\space)) + str)) + + +;; INPUT PARAMETERS, PRINT TABLE: +(define lat (prompt->num "Enter latitude => ")) +(define lng (prompt->num "Enter longitude => ")) +(define ref (prompt->num "Enter legal meridian => ")) + +(print-table lat (- lng ref)) + +;; test cases for angle conversion +(require rackunit) +(check < (to-hla 30 89) 90) +(check-= (to-hla 30 90) 90 1e-5) +(check > (to-hla 30 91) 90) +(check > (to-hla 30 -89) -90) +(check-= (to-hla 30 90) 90 1e-5) +(check < (to-hla 30 -91) -90) +(check < (to-hla -30 -89) 90) +(check-= (to-hla -30 -90) 90 1e-5) +(check > (to-hla -30 -91) 90) +(check > (to-hla -30 89) -90) +(check-= (to-hla -30 90) -90 1e-5) +(check < (to-hla -30 91) -90) diff --git a/Task/Horizontal-sundial-calculations/Ruby/horizontal-sundial-calculations.rb b/Task/Horizontal-sundial-calculations/Ruby/horizontal-sundial-calculations.rb new file mode 100644 index 0000000000..4e51d5a8e4 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Ruby/horizontal-sundial-calculations.rb @@ -0,0 +1,23 @@ +include Math +DtoR = PI/180 + +print 'Enter latitude: ' +lat = Float( gets ) +print 'Enter longitude: ' +lng = Float( gets ) +print 'Enter legal meridian: ' +ref = Float( gets ) +puts + +slat = sin( lat * DtoR ) + +puts " sine of latitude: %.3f"% slat +puts " diff longitude: %.3f"% (lng-ref) +puts +puts 'Hour, sun hour angle, dial hour line angle from 6am to 6pm' +-6.upto(6) do |h| + hra = 15 * h + hra -= lng - ref + hla = atan( slat * tan( hra * DtoR ))/ DtoR + puts "HR =%3d; HRA =%7.3f; HLA =%7.3f" % [h, hra, hla] +end diff --git a/Task/Horizontal-sundial-calculations/Sather/horizontal-sundial-calculations.sa b/Task/Horizontal-sundial-calculations/Sather/horizontal-sundial-calculations.sa new file mode 100644 index 0000000000..99e4364e97 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Sather/horizontal-sundial-calculations.sa @@ -0,0 +1,32 @@ +class MAIN is + + getvalue(s:STR):FLT is + #OUT + s + ": "; + return #FLT(#IN.get_line.str); + end; + + dr(a:FLT):FLT is + return a * FLT::pi / 180.0; + end; + + rd(a:FLT):FLT is + return a * 180.0 / FLT::pi; + end; + + main is + lat ::= getvalue("Enter latitude"); + lng ::= getvalue("Enter longitude"); + ref ::= getvalue("Enter legal meridian"); + #OUT + "\n"; + slat ::= dr(lat).sin; + #OUT + "sine of latitude: " + #FMT("%.3f\n", slat); + #OUT + "diff longitude: " + #FMT("%.3f\n\n", lng - ref); + #OUT + "Hour, sun hour angle, dial hour line angle from 6am to 6pm\n"; + loop h ::= (-6).upto!(6); + hra ::= 15.0 * h.flt; + hra := hra - lng + ref; + hla ::= rd((dr(hra).tan * slat).atan); + #OUT + #FMT("HR = %3d; \t HRA=%7.3f; \t HLA= %7.3f\n", h, hra, hla); + end; + end; +end; diff --git a/Task/Horizontal-sundial-calculations/Smalltalk/horizontal-sundial-calculations.st b/Task/Horizontal-sundial-calculations/Smalltalk/horizontal-sundial-calculations.st new file mode 100644 index 0000000000..95da0a75f8 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Smalltalk/horizontal-sundial-calculations.st @@ -0,0 +1,17 @@ +|lat slat lng ref hra hla pi| +pi := 1 arcTan * 4. +'Enter latitude: ' display. lat := stdin nextLine asNumber. +'Enter longitude: ' display. lng := stdin nextLine asNumber. +'Enter legal meridian: ' display. ref := stdin nextLine asNumber. +slat := lat degreesToRadians sin. +('sine of latitude: %1' % { slat }) displayNl. +('diff longitude: %1' % { lng - ref }) displayNl. + +'Hour, sun hour angle, dial hour line angle from 6am to 6pm' displayNl. + +-6 to: 6 do: [ :h | + hra := 15.0 * h. + hra := hra - lng + ref. + hla := (hra degreesToRadians tan * slat) arcTan radiansToDegrees. + ('HR= %1; %4 HRA=%2; %4 HLA= %3' % { h. hra. hla. $<9> }) displayNl. +] diff --git a/Task/Horizontal-sundial-calculations/Tcl/horizontal-sundial-calculations.tcl b/Task/Horizontal-sundial-calculations/Tcl/horizontal-sundial-calculations.tcl new file mode 100644 index 0000000000..80dd7e12f8 --- /dev/null +++ b/Task/Horizontal-sundial-calculations/Tcl/horizontal-sundial-calculations.tcl @@ -0,0 +1,19 @@ +set PI 3.1415927 +fconfigure stdout -buffering none +puts -nonewline "Enter latitude => "; gets stdin lat +puts -nonewline "Enter longitude => "; gets stdin lng +puts -nonewline "Enter legal meridian => "; gets stdin ref +puts "" + +set slat [expr {sin($lat*$PI/180)}] +puts [format " sine of latitude: %8g" $slat] +puts [format " diff longitude: %3.3f" [expr {$lng - $ref}]] +puts "" +puts "Hour, sun hour angle, dial hour line angle from 6am to 6pm" + +for {set h -6} {$h<=6} {incr h} { + set hra [expr {15.0 * $h}]; # hour angle is 15 times the hour # + set hra [expr {$hra-$lng+$ref}]; # but correct for longitude difference # + set hla [expr {atan($slat * tan($hra*$PI/180)) * 180/$PI}] + puts [format "HR=%+3d; HRA=%+8.3f; HLA=%+8.3f" $h $hra $hla] +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/0DESCRIPTION b/Task/Horners-rule-for-polynomial-evaluation/0DESCRIPTION new file mode 100644 index 0000000000..844f6e9d2d --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/0DESCRIPTION @@ -0,0 +1,20 @@ +A fast scheme for evaluating a polynomial such as: +: -19+7x-4x^2+6x^3\, +when +: x=3\;. +is to arrange the computation as follows: +: ((((0) x + 6) x + (-4)) x + 7) x + (-19)\; +And compute the result from the innermost brackets outwards as in this pseudocode: + coefficients ''':=''' [-19, 7, -4, 6] ''# list coefficients of all x^0..x^n in order'' + x ''':=''' 3 + accumulator ''':=''' 0 + '''for''' i '''in''' ''length''(coefficients) '''downto''' 1 '''do''' + ''# Assumes 1-based indexing for arrays'' + accumulator ''':=''' ( accumulator * x ) + coefficients[i] + '''done''' + ''# accumulator now has the answer'' + +'''Task Description''' +:Create a routine that takes a list of coefficients of a polynomial in order of increasing powers of x; together with a value of x to compute its value at, and return the value of the polynomial at that value using [http://www.physics.utah.edu/~detar/lessons/c++/array/node1.html Horner's rule]. + +Cf. [[Formal power series]] diff --git a/Task/Horners-rule-for-polynomial-evaluation/ACL2/horners-rule-for-polynomial-evaluation.acl2 b/Task/Horners-rule-for-polynomial-evaluation/ACL2/horners-rule-for-polynomial-evaluation.acl2 new file mode 100644 index 0000000000..56857230e1 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/ACL2/horners-rule-for-polynomial-evaluation.acl2 @@ -0,0 +1,5 @@ +(defun horner (ps x) + (if (endp ps) + 0 + (+ (first ps) + (* x (horner (rest ps) x))))) diff --git a/Task/Horners-rule-for-polynomial-evaluation/ALGOL-68/horners-rule-for-polynomial-evaluation.alg b/Task/Horners-rule-for-polynomial-evaluation/ALGOL-68/horners-rule-for-polynomial-evaluation.alg new file mode 100644 index 0000000000..ebf6722433 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/ALGOL-68/horners-rule-for-polynomial-evaluation.alg @@ -0,0 +1,13 @@ +PROC horner = ([]REAL c, REAL x)REAL : +( + REAL res := 0.0; + FOR i FROM UPB c BY -1 TO LWB c DO + res := res * x + c[i] + OD; + res +); + +main:( + [4]REAL coeffs := (-19.0, 7.0, -4.0, 6.0); + print( horner(coeffs, 3.0) ) +) diff --git a/Task/Horners-rule-for-polynomial-evaluation/ATS/horners-rule-for-polynomial-evaluation.ats b/Task/Horners-rule-for-polynomial-evaluation/ATS/horners-rule-for-polynomial-evaluation.ats new file mode 100644 index 0000000000..e5b5c26692 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/ATS/horners-rule-for-polynomial-evaluation.ats @@ -0,0 +1,16 @@ +staload "prelude/SATS/list.sats" +staload "prelude/DATS/list.dats" + +fun horner (x: int, coeff: List int): int = let + val f = lam (a: int, b: int) = a + b*x +in + list_fold_right_cloref (f, coeff, 0) +end + +implement main () = let + val x = 3 + val coeff = '[~19,7,~4,6] + val res = horner (x, coeff) +in + print! (res, "\n") +end diff --git a/Task/Horners-rule-for-polynomial-evaluation/Ada/horners-rule-for-polynomial-evaluation.ada b/Task/Horners-rule-for-polynomial-evaluation/Ada/horners-rule-for-polynomial-evaluation.ada new file mode 100644 index 0000000000..f6716d5853 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Ada/horners-rule-for-polynomial-evaluation.ada @@ -0,0 +1,17 @@ +with Ada.Float_Text_IO; use Ada.Float_Text_IO; + +procedure Horners_Rule is + type Coef is array(Positive range <>) of Float; + + function Horner(Coeffs: Coef; Val: Float) return Float is + Res : Float := 0.0; + begin + for P in reverse Coeffs'Range loop + Res := Res*Val + Coeffs(P); + end loop; + return Res; + end Horner; + +begin + Put(Horner(Coeffs => (-19.0, 7.0, -4.0, 6.0), Val => 3.0), Aft=>1, Exp=>0); +end Horners_Rule; diff --git a/Task/Horners-rule-for-polynomial-evaluation/Aime/horners-rule-for-polynomial-evaluation.aime b/Task/Horners-rule-for-polynomial-evaluation/Aime/horners-rule-for-polynomial-evaluation.aime new file mode 100644 index 0000000000..16c04f5852 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Aime/horners-rule-for-polynomial-evaluation.aime @@ -0,0 +1,34 @@ +real +horner(list coeffs, real x) +{ + integer i; + real z; + + z = 0; + + i = l_length(coeffs); + while (i) { + i -= 1; + z *= x; + z += l_q_real(coeffs, i); + } + + return z; +} + + +integer +main(void) +{ + list l; + + l_append(l, -19r); + l_append(l, 7.0); + l_append(l, -real(4)); + l_append(l, 6r); + + o_real(1, horner(l, 3)); + o_byte('\n'); + + return 0; +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/AutoHotkey/horners-rule-for-polynomial-evaluation.ahk b/Task/Horners-rule-for-polynomial-evaluation/AutoHotkey/horners-rule-for-polynomial-evaluation.ahk new file mode 100644 index 0000000000..f34d84b52e --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/AutoHotkey/horners-rule-for-polynomial-evaluation.ahk @@ -0,0 +1,16 @@ +Coefficients = -19, 7, -4, 6 +x := 3 + +MsgBox, % EvalPolynom(Coefficients, x) + + + +;--------------------------------------------------------------------------- +EvalPolynom(Coefficients, x) { ; using Horner's rule +;--------------------------------------------------------------------------- + StringSplit, Co, coefficients, `,, %A_Space% + Result := 0 + Loop, % Co0 + i := Co0 - A_Index + 1, Result := Result * x + Co%i% + Return, Result +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/BBC-BASIC/horners-rule-for-polynomial-evaluation.bbc b/Task/Horners-rule-for-polynomial-evaluation/BBC-BASIC/horners-rule-for-polynomial-evaluation.bbc new file mode 100644 index 0000000000..bd610e54fc --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/BBC-BASIC/horners-rule-for-polynomial-evaluation.bbc @@ -0,0 +1,11 @@ + DIM coefficients(3) + coefficients() = -19, 7, -4, 6 + PRINT FNhorner(coefficients(), 3) + END + + DEF FNhorner(coeffs(), x) + LOCAL i%, v + FOR i% = DIM(coeffs(), 1) TO 0 STEP -1 + v = v * x + coeffs(i%) + NEXT + = v diff --git a/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-1.cpp b/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-1.cpp new file mode 100644 index 0000000000..d013f77570 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-1.cpp @@ -0,0 +1,21 @@ +#include +#include + +using namespace std; + +double horner(vector v, double x) +{ + double s = 0; + + for( vector::const_reverse_iterator i = v.rbegin(); i != v.rend(); i++ ) + s = s*x + *i; + return s; +} + +int main() +{ + double c[] = { -19, 7, -4, 6 }; + vector v(c, c + sizeof(c)/sizeof(double)); + cout << horner(v, 3.0) << endl; + return 0; +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-2.cpp b/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-2.cpp new file mode 100644 index 0000000000..c924d6b6b7 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/C++/horners-rule-for-polynomial-evaluation-2.cpp @@ -0,0 +1,16 @@ +#include + +template + double horner(BidirIter begin, BidirIter end, double x) +{ + double result = 0; + while (end != begin) + result = result*x + *--end; + return result; +} + +int main() +{ + double c[] = { -19, 7, -4, 6 }; + std::cout << horner(c, c + 4, 3) << std::endl; +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/C/horners-rule-for-polynomial-evaluation.c b/Task/Horners-rule-for-polynomial-evaluation/C/horners-rule-for-polynomial-evaluation.c new file mode 100644 index 0000000000..a742548e0b --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/C/horners-rule-for-polynomial-evaluation.c @@ -0,0 +1,22 @@ +#include + +double horner(double *coeffs, int s, double x) +{ + int i; + double res = 0.0; + + for(i=s-1; i >= 0; i--) + { + res = res * x + coeffs[i]; + } + return res; +} + + +int main() +{ + double coeffs[] = { -19.0, 7.0, -4.0, 6.0 }; + + printf("%5.1f\n", horner(coeffs, sizeof(coeffs)/sizeof(double), 3.0)); + return 0; +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/Clojure/horners-rule-for-polynomial-evaluation.clj b/Task/Horners-rule-for-polynomial-evaluation/Clojure/horners-rule-for-polynomial-evaluation.clj new file mode 100644 index 0000000000..a932f6fbb7 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Clojure/horners-rule-for-polynomial-evaluation.clj @@ -0,0 +1,4 @@ +(defn horner [coeffs x] + (reduce (fn [acc coeff] (+ (* acc x) coeff)) (reverse coeffs))) + +(println (horner [-19 7 -4 6] 3)) diff --git a/Task/Horners-rule-for-polynomial-evaluation/CoffeeScript/horners-rule-for-polynomial-evaluation.coffee b/Task/Horners-rule-for-polynomial-evaluation/CoffeeScript/horners-rule-for-polynomial-evaluation.coffee new file mode 100644 index 0000000000..34e5fdacbd --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/CoffeeScript/horners-rule-for-polynomial-evaluation.coffee @@ -0,0 +1,9 @@ +eval_poly = (x, coefficients) -> + # coefficients are for ascending powers + return 0 if coefficients.length == 0 + ones_place = coefficients.shift() + x * eval_poly(x, coefficients) + ones_place + +console.log eval_poly 3, [-19, 7, -4, 6] # 128 +console.log eval_poly 10, [4, 3, 2, 1] # 1234 +console.log eval_poly 2, [1, 1, 0, 0, 1] # 19 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Common-Lisp/horners-rule-for-polynomial-evaluation.lisp b/Task/Horners-rule-for-polynomial-evaluation/Common-Lisp/horners-rule-for-polynomial-evaluation.lisp new file mode 100644 index 0000000000..53053b56fd --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Common-Lisp/horners-rule-for-polynomial-evaluation.lisp @@ -0,0 +1,3 @@ +(defun horner (coeffs x) + (reduce #'(lambda (coef acc) (+ (* acc x) coef)) + coeffs :from-end t :initial-value 0)) diff --git a/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-1.d b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-1.d new file mode 100644 index 0000000000..2fc7d60ef4 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-1.d @@ -0,0 +1,5 @@ +import std.stdio, std.math; + +void main() { + writeln(poly(3.0, [-19, 7, -4, 6])); +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-2.d b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-2.d new file mode 100644 index 0000000000..dd9f53eaf3 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-2.d @@ -0,0 +1,12 @@ +import std.stdio, std.traits; + +CommonType!(U, V) horner(U, V)(U[] p, V x) { + typeof(return) accumulator = 0; + foreach_reverse (c; p) + accumulator = accumulator * x + c; + return accumulator; +} + +void main() { + writeln([-19, 7, -4, 6].horner(3.0)); +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-3.d b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-3.d new file mode 100644 index 0000000000..ee1b36a536 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/D/horners-rule-for-polynomial-evaluation-3.d @@ -0,0 +1,9 @@ +import std.stdio, std.algorithm, std.range; + +auto horner(U, V)(U[] p, V x) { + return reduce!((a, b) => a * x + b)(cast(V)0, retro(p)); +} + +void main() { + writeln([-19, 7, -4, 6].horner(3.0)); +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-1.e b/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-1.e new file mode 100644 index 0000000000..1081ddb761 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-1.e @@ -0,0 +1,10 @@ +def makeHornerPolynomial(coefficients :List) { + def indexing := (0..!coefficients.size()).descending() + return def hornerPolynomial(x) { + var acc := 0 + for i in indexing { + acc := acc * x + coefficients[i] + } + return acc + } +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-2.e b/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-2.e new file mode 100644 index 0000000000..f568a589ef --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/E/horners-rule-for-polynomial-evaluation-2.e @@ -0,0 +1,2 @@ +? makeHornerPolynomial([-19, 7, -4, 6])(3) +# value: 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Erlang/horners-rule-for-polynomial-evaluation.erl b/Task/Horners-rule-for-polynomial-evaluation/Erlang/horners-rule-for-polynomial-evaluation.erl new file mode 100644 index 0000000000..159112b37c --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Erlang/horners-rule-for-polynomial-evaluation.erl @@ -0,0 +1,4 @@ +horner(L,X) -> + lists:foldl(fun(C, Acc) -> X*Acc+C end,0, lists:reverse(L)). +t() -> + horner([-19,7,-4,6], 3). diff --git a/Task/Horners-rule-for-polynomial-evaluation/Euler-Math-Toolbox/horners-rule-for-polynomial-evaluation.euler b/Task/Horners-rule-for-polynomial-evaluation/Euler-Math-Toolbox/horners-rule-for-polynomial-evaluation.euler new file mode 100644 index 0000000000..309023404a --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Euler-Math-Toolbox/horners-rule-for-polynomial-evaluation.euler @@ -0,0 +1,18 @@ +>function horner (x,v) ... +$ n=cols(v); res=v{n}; +$ loop 1 to n-1; res=res*x+v{n-#}; end; +$ return res +$endfunction +>v=[-19,7,-4,6] + [ -19 7 -4 6 ] +>horner(2,v) // test Horner + 27 +>evalpoly(2,v) // built-in Horner + 27 +>horner(I,v) // complex values + -15+1i +>horner(1±0.05,v) // interval values + ~-10.9,-9.11~ +>function p(x) &= sum(@v[k]*x^(k-1),k,1,4) // Symbolic Polynomial + 3 2 + 6 x - 4 x + 7 x - 19 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Factor/horners-rule-for-polynomial-evaluation.factor b/Task/Horners-rule-for-polynomial-evaluation/Factor/horners-rule-for-polynomial-evaluation.factor new file mode 100644 index 0000000000..1833a2e05a --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Factor/horners-rule-for-polynomial-evaluation.factor @@ -0,0 +1,2 @@ +: horner ( coeff x -- res ) + [ 0 ] dip '[ [ _ * ] dip + ] reduce ; diff --git a/Task/Horners-rule-for-polynomial-evaluation/Forth/horners-rule-for-polynomial-evaluation.fth b/Task/Horners-rule-for-polynomial-evaluation/Forth/horners-rule-for-polynomial-evaluation.fth new file mode 100644 index 0000000000..a47dfb7533 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Forth/horners-rule-for-polynomial-evaluation.fth @@ -0,0 +1,10 @@ +: fhorner ( coeffs len F: x -- F: val ) + 0e + floats bounds ?do + fover f* i f@ f+ + 1 floats +loop + fswap fdrop ; + +create coeffs 6e f, -4e f, 7e f, -19e f, + +coeffs 4 3e fhorner f. \ 128. diff --git a/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-1.f b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-1.f new file mode 100644 index 0000000000..281b4354e4 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-1.f @@ -0,0 +1,24 @@ +program test_horner + + implicit none + + write (*, '(f5.1)') horner ((/-19.0, 7.0, -4.0, 6.0/), 3.0) + +contains + + function horner (coeffs, x) result (res) + + implicit none + real, dimension (:), intent (in) :: coeffs + real, intent (in) :: x + real :: res + integer :: i + + res = 0.0 + do i = size (coeffs), 1, -1 + res = res * x + coeffs (i) + end do + + end function horner + +end program test_horner diff --git a/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-2.f b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-2.f new file mode 100644 index 0000000000..9a8bdab124 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-2.f @@ -0,0 +1,10 @@ + FUNCTION HORNER(N,A,X) + IMPLICIT NONE + INTEGER I,N + DOUBLE PRECISION A(N),X,Y,HORNER + Y=A(N) + DO I=N-1,1,-1 + Y=Y*X+A(I) + END DO + HORNER=Y + END diff --git a/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-3.f b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-3.f new file mode 100644 index 0000000000..e931074893 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Fortran/horners-rule-for-polynomial-evaluation-3.f @@ -0,0 +1,14 @@ + SUBROUTINE HORNER2(N,A,X,Y,Z) +C COMPUTE POLYNOMIAL VALUE AND DERIVATIVE +C SEE "ROUNDOFF IN POLYNOMIAL EVALUATION", W. KAHAN, 1986 +C POLY: A(1)+A(2)*X+...+A(N)*X**(N-1) +C Y: VALUE, Z: DERIVATIVE + IMPLICIT NONE + INTEGER I,N + DOUBLE PRECISION A(N),X,Y,Z + Z=0.0D0 + Y=A(N) + DO 10 I=N-1,1,-1 + Z=Z*X+Y + 10 Y=Y*X+A(I) + END diff --git a/Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap b/Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap new file mode 100644 index 0000000000..338800cae0 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/GAP/horners-rule-for-polynomial-evaluation.gap @@ -0,0 +1,32 @@ +# The idiomatic way to compute with polynomials + +x := Indeterminate(Rationals, "x"); + +# This is a value in a polynomial ring, not a function +p := 6*x^3 - 4*x^2 + 7*x - 19; + +Value(p, 3); +# 128 + +u := CoefficientsOfUnivariatePolynomial(p); +# [ -19, 7, -4, 6 ] + +# One may also create the polynomial from coefficients +q := UnivariatePolynomial(Rationals, [-19, 7, -4, 6], x); +# 6*x^3-4*x^2+7*x-19 + +p = q; +# true + +# Now a Horner implementation +Horner := function(coef, x) + local v, c; + v := 0; + for c in Reversed(coef) do + v := x*v + c; + od; + return v; +end; + +Horner(u, 3); +# 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Go/horners-rule-for-polynomial-evaluation.go b/Task/Horners-rule-for-polynomial-evaluation/Go/horners-rule-for-polynomial-evaluation.go new file mode 100644 index 0000000000..332ea7d000 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Go/horners-rule-for-polynomial-evaluation.go @@ -0,0 +1,14 @@ +package main + +import "fmt" + +func horner(x int64, c []int64) (acc int64) { + for i := len(c) - 1; i >= 0; i-- { + acc = acc*x + c[i] + } + return +} + +func main() { + fmt.Println(horner(3, []int64{-19, 7, -4, 6})) +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-1.groovy b/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-1.groovy new file mode 100644 index 0000000000..f08d56e6d8 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-1.groovy @@ -0,0 +1 @@ +def hornersRule = { coeff, x -> coeff.reverse().inject(0) { accum, c -> (accum * x) + c } } diff --git a/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-2.groovy b/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-2.groovy new file mode 100644 index 0000000000..0150629bbd --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Groovy/horners-rule-for-polynomial-evaluation-2.groovy @@ -0,0 +1,23 @@ +def coefficients = [-19g, 7g, -4g, 6g] +println (["p coefficients":coefficients]) + +def testPoly = hornersRule.curry(coefficients) +println (["p(3)":testPoly(3g)]) +println (["p(0)":testPoly(0g)]) + +def derivativeCoefficients = { coeff -> (1..<(coeff.size())).collect { coeff[it] * it } } +println (["p' coefficients":derivativeCoefficients(coefficients)]) + +def testDeriv = hornersRule.curry(derivativeCoefficients(coefficients)) +println (["p'(3)":testDeriv(3g)]) +println (["p'(0)":testDeriv(0g)]) + +def newtonRaphson = { x, f, fPrime -> + while (f(x).abs() > 0.0001) { + x -= f(x)/fPrime(x) + } + x +} + +def root = newtonRaphson(3g, testPoly, testDeriv) +println ([root:root.toString()[0..5], "p(root)":testPoly(root).toString()[0..5], "p'(root)":testDeriv(root).toString()[0..5]]) diff --git a/Task/Horners-rule-for-polynomial-evaluation/Haskell/horners-rule-for-polynomial-evaluation.hs b/Task/Horners-rule-for-polynomial-evaluation/Haskell/horners-rule-for-polynomial-evaluation.hs new file mode 100644 index 0000000000..72fbf0e9ea --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Haskell/horners-rule-for-polynomial-evaluation.hs @@ -0,0 +1,4 @@ +horner :: (Num a) => a -> [a] -> a +horner x = foldr (\a b -> a + b*x) 0 + +main = print $ horner 3 [-19, 7, -4, 6] diff --git a/Task/Horners-rule-for-polynomial-evaluation/HicEst/horners-rule-for-polynomial-evaluation.hicest b/Task/Horners-rule-for-polynomial-evaluation/HicEst/horners-rule-for-polynomial-evaluation.hicest new file mode 100644 index 0000000000..a983f59aab --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/HicEst/horners-rule-for-polynomial-evaluation.hicest @@ -0,0 +1,12 @@ +REAL :: x=3, coeffs(4) +DATA coeffs/-19.0, 7.0, -4.0, 6.0/ + +WRITE(Messagebox) Horner(coeffs, x) ! shows 128 + +FUNCTION Horner(c, x) + DIMENSION c(1) + Horner = 0 + DO i = LEN(c), 1, -1 + Horner = x*Horner + c(i) + ENDDO +END diff --git a/Task/Horners-rule-for-polynomial-evaluation/Icon/horners-rule-for-polynomial-evaluation.icon b/Task/Horners-rule-for-polynomial-evaluation/Icon/horners-rule-for-polynomial-evaluation.icon new file mode 100644 index 0000000000..8d9a8554bc --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Icon/horners-rule-for-polynomial-evaluation.icon @@ -0,0 +1,10 @@ +procedure poly_eval (x, coeffs) + accumulator := 0 + every index := *coeffs to 1 by -1 do + accumulator := accumulator * x + coeffs[index] + return accumulator +end + +procedure main () + write (poly_eval (3, [-19, 7, -4, 6])) +end diff --git a/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-1.j b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-1.j new file mode 100644 index 0000000000..1c8f31816e --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-1.j @@ -0,0 +1,3 @@ + horner =: (#."0 _ |.)~ + + horner2=: [: +`*/ [: }: ,@,. NB. Alternate diff --git a/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-2.j b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-2.j new file mode 100644 index 0000000000..1c697cef05 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-2.j @@ -0,0 +1,2 @@ + _19 7 _4 6 horner 3 +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-3.j b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-3.j new file mode 100644 index 0000000000..f7c61e7ffc --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/J/horners-rule-for-polynomial-evaluation-3.j @@ -0,0 +1,2 @@ + _19 7 _4 6 p. 3 +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Java/horners-rule-for-polynomial-evaluation.java b/Task/Horners-rule-for-polynomial-evaluation/Java/horners-rule-for-polynomial-evaluation.java new file mode 100644 index 0000000000..c8f00693f7 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Java/horners-rule-for-polynomial-evaluation.java @@ -0,0 +1,23 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Horner { + public static void main(String[] args){ + List coeffs = new ArrayList(); + coeffs.add(-19.0); + coeffs.add(7.0); + coeffs.add(-4.0); + coeffs.add(6.0); + System.out.println(polyEval(coeffs, 3)); + } + + public static double polyEval(List coefficients, double x) { + Collections.reverse(coefficients); + Double accumulator = coefficients.get(0); + for (int i = 1; i < coefficients.size(); i++) { + accumulator = (accumulator * x) + (Double) coefficients.get(i); + } + return accumulator; + } +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/JavaScript/horners-rule-for-polynomial-evaluation.js b/Task/Horners-rule-for-polynomial-evaluation/JavaScript/horners-rule-for-polynomial-evaluation.js new file mode 100644 index 0000000000..1ee7474e61 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/JavaScript/horners-rule-for-polynomial-evaluation.js @@ -0,0 +1,4 @@ +function horner(coeffs, x) { + return coeffs.reduceRight(function(acc, coeff) {return(acc * x + coeff)}, 0); +} +print(horner([-19,7,-4,6],3)); // ==> 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/K/horners-rule-for-polynomial-evaluation.k b/Task/Horners-rule-for-polynomial-evaluation/K/horners-rule-for-polynomial-evaluation.k new file mode 100644 index 0000000000..20d0092ced --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/K/horners-rule-for-polynomial-evaluation.k @@ -0,0 +1,3 @@ + horner:{y _sv|x} + horner[-19 7 -4 6;3] +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Liberty-BASIC/horners-rule-for-polynomial-evaluation.liberty b/Task/Horners-rule-for-polynomial-evaluation/Liberty-BASIC/horners-rule-for-polynomial-evaluation.liberty new file mode 100644 index 0000000000..491f1908ec --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Liberty-BASIC/horners-rule-for-polynomial-evaluation.liberty @@ -0,0 +1,19 @@ +src$ = "Hello" +coefficients$ = "-19 7 -4 6" ' list coefficients of all x^0..x^n in order +x = 3 +print horner(coefficients$, x) '128 + +print horner("4 3 2 1", 10) '1234 +print horner("1 1 0 0 1", 2) '19 +end + +function horner(coefficients$, x) + accumulator = 0 + 'getting length of a list requires extra pass with WORD$. + 'So we just started from high above + for index = 100 to 1 step -1 + cft$ = word$(coefficients$, index) + if cft$<>"" then accumulator = ( accumulator * x ) + val(cft$) + next + horner = accumulator +end function diff --git a/Task/Horners-rule-for-polynomial-evaluation/Logo/horners-rule-for-polynomial-evaluation.logo b/Task/Horners-rule-for-polynomial-evaluation/Logo/horners-rule-for-polynomial-evaluation.logo new file mode 100644 index 0000000000..3208f868f4 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Logo/horners-rule-for-polynomial-evaluation.logo @@ -0,0 +1,6 @@ +to horner :x :coeffs + if empty? :coeffs [output 0] + output (first :coeffs) + (:x * horner :x bf :coeffs) +end + +show horner 3 [-19 7 -4 6] ; 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Lua/horners-rule-for-polynomial-evaluation.lua b/Task/Horners-rule-for-polynomial-evaluation/Lua/horners-rule-for-polynomial-evaluation.lua new file mode 100644 index 0000000000..1560a9903b --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Lua/horners-rule-for-polynomial-evaluation.lua @@ -0,0 +1,11 @@ +function horners_rule( coeff, x ) + local res = 0 + for i = #coeff, 1, -1 do + res = res * x + coeff[i] + end + return res +end + +x = 3 +coefficients = { -19, 7, -4, 6 } +print( horners_rule( coefficients, x ) ) diff --git a/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-1.m b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-1.m new file mode 100644 index 0000000000..f6d7f5f51e --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-1.m @@ -0,0 +1,9 @@ +function accumulator = hornersRule(x,coefficients) + + accumulator = 0; + + for i = (numel(coefficients):-1:1) + accumulator = (accumulator * x) + coefficients(i); + end + +end diff --git a/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-2.m b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-2.m new file mode 100644 index 0000000000..35053886ac --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-2.m @@ -0,0 +1,5 @@ +>> hornersRule(3,[-19, 7, -4, 6]) + +ans = + + 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-3.m b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-3.m new file mode 100644 index 0000000000..5fa5f20e11 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/MATLAB/horners-rule-for-polynomial-evaluation-3.m @@ -0,0 +1,5 @@ +>> polyval(fliplr([-19, 7, -4, 6]),3) + +ans = + + 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Mathematica/horners-rule-for-polynomial-evaluation.mathematica b/Task/Horners-rule-for-polynomial-evaluation/Mathematica/horners-rule-for-polynomial-evaluation.mathematica new file mode 100644 index 0000000000..3dbb1471bf --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Mathematica/horners-rule-for-polynomial-evaluation.mathematica @@ -0,0 +1,6 @@ +Horner[l_List, x_] := Fold[x #1 + #2 &, 0, l] +Horner[{6, -4, 7, -19}, x] +-> -19 + x (7 + x (-4 + 6 x)) + +-19 + x (7 + x (-4 + 6 x)) /. x -> 3 +-> 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Maxima/horners-rule-for-polynomial-evaluation.maxima b/Task/Horners-rule-for-polynomial-evaluation/Maxima/horners-rule-for-polynomial-evaluation.maxima new file mode 100644 index 0000000000..52d3d0f5b1 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Maxima/horners-rule-for-polynomial-evaluation.maxima @@ -0,0 +1,45 @@ +/* Function horner already exists in Maxima, though it operates on expressions, not lists of coefficients */ +horner(5*x^3+2*x+1); +x*(5*x^2+2)+1 + +/* Here is an implementation */ +horner2(p, x) := block([n, y, i], + n: length(p), + y: p[n], + for i: n - 1 step -1 thru 1 do y: y*x + p[i], + y +)$ + +horner2([-19, 7, -4, 6], 3); +128 + +/* Another with rreduce */ +horner3(p,x):=rreduce(lambda([a,y],x*y+a),p); +horner3([a,b,c,d,e,f],x); +x*(x*(x*(x*(f*x+e)+d)+c)+b)+a + +/* Extension to compute also derivatives up to a specified order. + See William Kahan, Roundoff in Polynomial Evaluation, 1986 + http://www.cs.berkeley.edu/~wkahan/Math128/Poly.pdf */ + +poleval(a, x, [m]) := block( + [n: length(a), v, k: 1], + if emptyp(m) then m: 1 else m: 1 + first(m), + v: makelist(0, m), + v[1]: a[n], + for i from n - 1 thru 1 step -1 do ( + for j from m thru 2 step -1 do v[j]: v[j] * x + v[j - 1], + v[1]: v[1] * x + a[i] + ), + for i from 2 thru m do ( + v[i]: v[i] * k, + k: k * i + ), + if m = 1 then first(v) else v +)$ + +poleval([0, 0, 0, 0, 1], x, 4); +[x^4, 4 * x^3, 12 * x^2, 24 * x, 24] + +poleval([0, 0, 0, 0, 1], x); +x^4 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Mercury/horners-rule-for-polynomial-evaluation.mercury b/Task/Horners-rule-for-polynomial-evaluation/Mercury/horners-rule-for-polynomial-evaluation.mercury new file mode 100644 index 0000000000..2d53f74ca8 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Mercury/horners-rule-for-polynomial-evaluation.mercury @@ -0,0 +1,13 @@ +:- module horner. +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + io.format("%i\n", [i(horner(3, [-19, 7, -4, 6]))], !IO). + +:- func horner(int, list(int)) = int. + +horner(X, Cs) = list.foldr((func(C, Acc) = Acc * X + C), Cs, 0). diff --git a/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-1.php b/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-1.php new file mode 100644 index 0000000000..7cd1687c4b --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-1.php @@ -0,0 +1,12 @@ + diff --git a/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-2.php b/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-2.php new file mode 100644 index 0000000000..0d8c13f7f5 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/PHP/horners-rule-for-polynomial-evaluation-2.php @@ -0,0 +1,9 @@ + diff --git a/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-1.pl b/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-1.pl new file mode 100644 index 0000000000..c43345c033 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-1.pl @@ -0,0 +1,14 @@ +use 5.10.0; +use strict; +use warnings; + +sub horner(\@$){ + my ($coef, $x) = @_; + my $result = 0; + $result = $result * $x + $_ for reverse @$coef; + return $result; +} + +my @coeff = (-19.0, 7, -4, 6); +my $x = 3; +say horner @coeff, $x; diff --git a/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-2.pl b/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-2.pl new file mode 100644 index 0000000000..bcd79ca86c --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Perl/horners-rule-for-polynomial-evaluation-2.pl @@ -0,0 +1,11 @@ +use strict; +use List::Util qw(reduce); + +sub horner($$){ + my ($coeff_ref, $x) = @_; + reduce { $a * $x + $b } reverse @$coeff_ref; +} + +my @coeff = (-19.0, 7, -4, 6); +my $x = 3; +print horner(\@coeff, $x), "\n"; diff --git a/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-1.l b/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-1.l new file mode 100644 index 0000000000..906142c39b --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-1.l @@ -0,0 +1,4 @@ +(de horner (Coeffs X) + (let Res 0 + (for C (reverse Coeffs) + (setq Res (+ C (* X Res))) ) ) ) diff --git a/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-2.l b/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-2.l new file mode 100644 index 0000000000..ffb39e02d4 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/PicoLisp/horners-rule-for-polynomial-evaluation-2.l @@ -0,0 +1,2 @@ +: (horner (-19.0 7.0 -4.0 6.0) 3.0) +-> 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-1.pro b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-1.pro new file mode 100644 index 0000000000..c3fa50fac4 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-1.pro @@ -0,0 +1,5 @@ +horner([], _X, 0). + +horner([H|T], X, V) :- + horner(T, X, V1), + V is V1 * X + H. diff --git a/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-2.pro b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-2.pro new file mode 100644 index 0000000000..41f20d1e81 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-2.pro @@ -0,0 +1,2 @@ + ?- horner([-19, 7, -4, 6], 3, V). +V = 128. diff --git a/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-3.pro b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-3.pro new file mode 100644 index 0000000000..22cee97b90 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Prolog/horners-rule-for-polynomial-evaluation-3.pro @@ -0,0 +1,12 @@ +:- use_module(library(lambda)). + + +% foldr(Pred, Init, List, R). +% +foldr(_Pred, Val, [], Val). +foldr(Pred, Val, [H | T], Res) :- + foldr(Pred, Val, T, Res1), + call(Pred, Res1, H, Res). + +f_horner(L, V, R) :- + foldr(\X^Y^Z^(Z is X * V + Y), 0, L, R). diff --git a/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-1.py b/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-1.py new file mode 100644 index 0000000000..55c7f89d0c --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-1.py @@ -0,0 +1,8 @@ +>>> def horner(coeffs, x): + acc = 0 + for c in reversed(coeffs): + acc = acc * x + c + return acc + +>>> horner( (-19, 7, -4, 6), 3) +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-2.py b/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-2.py new file mode 100644 index 0000000000..43a3fa011c --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Python/horners-rule-for-polynomial-evaluation-2.py @@ -0,0 +1,8 @@ +>>> try: from functools import reduce +except: pass + +>>> def horner(coeffs, x): + return reduce(lambda acc, c: acc * x + c, reversed(coeffs), 0) + +>>> horner( (-19, 7, -4, 6), 3) +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/R/horners-rule-for-polynomial-evaluation.r b/Task/Horners-rule-for-polynomial-evaluation/R/horners-rule-for-polynomial-evaluation.r new file mode 100644 index 0000000000..f5ff5b6abc --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/R/horners-rule-for-polynomial-evaluation.r @@ -0,0 +1,9 @@ +horner <- function(a, x) { + iv <- 0 + for(i in length(a):1) { + iv <- iv * x + a[i] + } + iv +} + +cat(horner(c(-19, 7, -4, 6), 3), "\n") diff --git a/Task/Horners-rule-for-polynomial-evaluation/REXX/horners-rule-for-polynomial-evaluation.rexx b/Task/Horners-rule-for-polynomial-evaluation/REXX/horners-rule-for-polynomial-evaluation.rexx new file mode 100644 index 0000000000..0098590e53 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/REXX/horners-rule-for-polynomial-evaluation.rexx @@ -0,0 +1,26 @@ +/*REXX program shows using Horner's rule for polynomial evaluation.*/ +numeric digits 30 /*use extra numeric precision. */ +parse arg x poly /*get value of X and coefficients*/ +equ= /*start with equation clean slate*/ + /*works for any degree equation. */ + do deg=0 until poly=='' /*get the equation's coefficients*/ + parse var poly c.deg poly /*get a equation coefficient.*/ + c.deg = (c.deg+0) / 1 /*normalize it (add 0, div by 1)*/ + if c.deg>=0 then c.deg = '+'c.deg /*if ¬ neg, then prefix a + sign.*/ + equ=equ c.deg /*concatenate it to the equation.*/ + if deg\==0 & c.deg\=0 then /*if not the first coefficient & */ + equ = equ'∙x^'deg /* not 0, append power (^) of X.*/ + equ = equ ' ' /*insert some blanks, look pretty*/ + end /*deg*/ + +say ' x = ' x +say ' degree = ' deg +say ' equation = ' equ +a=c.deg + do j=deg by -1 for deg /*apply Horner's rule.*/ + _ = j-1 + a = a*x + c._ + end /*j*/ +say +say ' answer = ' a + /*stick a fork in it, we're done.*/ diff --git a/Task/Horners-rule-for-polynomial-evaluation/Racket/horners-rule-for-polynomial-evaluation.rkt b/Task/Horners-rule-for-polynomial-evaluation/Racket/horners-rule-for-polynomial-evaluation.rkt new file mode 100644 index 0000000000..4fa6db319e --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Racket/horners-rule-for-polynomial-evaluation.rkt @@ -0,0 +1,5 @@ +#lang racket +(define (horner x l) + (foldr (lambda (a b) (+ a (* b x))) 0 l)) + +(horner 3 '(-19 7 -4 6)) diff --git a/Task/Horners-rule-for-polynomial-evaluation/Ruby/horners-rule-for-polynomial-evaluation.rb b/Task/Horners-rule-for-polynomial-evaluation/Ruby/horners-rule-for-polynomial-evaluation.rb new file mode 100644 index 0000000000..338e938ee9 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Ruby/horners-rule-for-polynomial-evaluation.rb @@ -0,0 +1,4 @@ +def horner(coeffs, x) + coeffs.reverse.inject(0) {|acc, coeff| acc * x + coeff} +end +p horner([-19, 7, -4, 6], 3) # ==> 128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Sather/horners-rule-for-polynomial-evaluation.sa b/Task/Horners-rule-for-polynomial-evaluation/Sather/horners-rule-for-polynomial-evaluation.sa new file mode 100644 index 0000000000..1e2e881dcd --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Sather/horners-rule-for-polynomial-evaluation.sa @@ -0,0 +1,15 @@ +class MAIN is + + action(s, e, x:FLT):FLT is + return s*x + e; + end; + + horner(v:ARRAY{FLT}, x:FLT):FLT is + rv ::= v.reverse; + return rv.reduce(bind(action(_, _, x))); + end; + + main is + #OUT + horner(|-19.0, 7.0, -4.0, 6.0|, 3.0) + "\n"; + end; +end; diff --git a/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-1.scala b/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-1.scala new file mode 100644 index 0000000000..3b3e652ef3 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-1.scala @@ -0,0 +1,2 @@ +def horner(coeffs:List[Double], x:Double)= + coeffs.reverse.foldLeft(0.0){(a,c)=> a*x+c} diff --git a/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-2.scala b/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-2.scala new file mode 100644 index 0000000000..159219ec81 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Scala/horners-rule-for-polynomial-evaluation-2.scala @@ -0,0 +1,3 @@ +val coeffs=List(-19.0, 7.0, -4.0, 6.0) +println(horner(coeffs, 3)) + -> 128.0 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-1.ss b/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-1.ss new file mode 100644 index 0000000000..6dd66add92 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-1.ss @@ -0,0 +1,9 @@ +(define (horner lst x) + (define (*horner lst x acc) + (if (null? lst) + acc + (*horner (cdr lst) x (+ (* acc x) (car lst))))) + (*horner (reverse lst) x 0)) + +(display (horner (list -19 7 -4 6) 3)) +(newline) diff --git a/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-2.ss b/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-2.ss new file mode 100644 index 0000000000..a949a93dfc --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Scheme/horners-rule-for-polynomial-evaluation-2.ss @@ -0,0 +1 @@ +128 diff --git a/Task/Horners-rule-for-polynomial-evaluation/Smalltalk/horners-rule-for-polynomial-evaluation.st b/Task/Horners-rule-for-polynomial-evaluation/Smalltalk/horners-rule-for-polynomial-evaluation.st new file mode 100644 index 0000000000..9f6a74f8db --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Smalltalk/horners-rule-for-polynomial-evaluation.st @@ -0,0 +1,7 @@ +OrderedCollection extend [ + horner: aValue [ + ^ self reverse inject: 0 into: [:acc :c | acc * aValue + c]. + ] +]. + +(#(-19 7 -4 6) asOrderedCollection horner: 3) displayNl. diff --git a/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-1.tcl b/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-1.tcl new file mode 100644 index 0000000000..c0b423fa5f --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-1.tcl @@ -0,0 +1,8 @@ +package require Tcl 8.5 +proc horner {coeffs x} { + set y 0 + foreach c [lreverse $coeffs] { + set y [expr { $y*$x+$c }] + } + return $y +} diff --git a/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-2.tcl b/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-2.tcl new file mode 100644 index 0000000000..e5fcee7709 --- /dev/null +++ b/Task/Horners-rule-for-polynomial-evaluation/Tcl/horners-rule-for-polynomial-evaluation-2.tcl @@ -0,0 +1 @@ +puts [horner {-19 7 -4 6} 3] diff --git a/Task/Host-introspection/0DESCRIPTION b/Task/Host-introspection/0DESCRIPTION new file mode 100644 index 0000000000..cbc30149a3 --- /dev/null +++ b/Task/Host-introspection/0DESCRIPTION @@ -0,0 +1,3 @@ +Print the [[wp:Word_size#Word_size_choice|word size]] and [[wp:Endianness|endianness]] of the host machine. + +See also: [[Variable size/Get]] diff --git a/Task/Host-introspection/1META.yaml b/Task/Host-introspection/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Host-introspection/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Host-introspection/ALGOL-68/host-introspection.alg b/Task/Host-introspection/ALGOL-68/host-introspection.alg new file mode 100644 index 0000000000..ddd7319c9f --- /dev/null +++ b/Task/Host-introspection/ALGOL-68/host-introspection.alg @@ -0,0 +1,24 @@ +INT max abs bit = ABS(BIN 1 SHL 1)-1; +INT bits per char = ENTIER (ln(max abs char+1)/ln(max abs bit+1)); +INT bits per int = ENTIER (1+ln(max int+1.0)/ln(max abs bit+1)); + +printf(($"states per bit: "dl$,max abs bit+1)); +printf(($"bits per char: "z-dl$,bits per char)); +printf(($"bits per int: "z-dl$,bits per int)); +printf(($"chars per int: "z-dl$,bits per int OVER bits per char)); + +printf(($"bits width: "z-dl$, bits width)); + +STRING abcds = "ABCD"; +FILE abcdf; +INT abcdi; + +INT errno := open(abcdf, "abcd.dat",stand back channel); +put(abcdf,abcds); # output alphabetically # +reset(abcdf); +get bin(abcdf,abcdi); # input in word byte order # +STRING int byte order := ""; +FOR shift FROM 0 BY bits per char TO bits per int - bits per char DO + int byte order +:= REPR(abcdi OVER (max abs bit+1) ** shift MOD (max abs char+1)) +OD; +printf(($"int byte order: "g,", Hex:",16r8dl$,int byte order, BIN abcdi)) diff --git a/Task/Host-introspection/Ada/host-introspection.ada b/Task/Host-introspection/Ada/host-introspection.ada new file mode 100644 index 0000000000..8bb81b1d55 --- /dev/null +++ b/Task/Host-introspection/Ada/host-introspection.ada @@ -0,0 +1,8 @@ +with Ada.Text_IO; use Ada.Text_IO; +with System; use System; + +procedure Host_Introspection is +begin + Put_Line ("Word size" & Integer'Image (Word_Size)); + Put_Line ("Endianness " & Bit_Order'Image (Default_Bit_Order)); +end Host_Introspection; diff --git a/Task/Host-introspection/BBC-BASIC/host-introspection.bbc b/Task/Host-introspection/BBC-BASIC/host-introspection.bbc new file mode 100644 index 0000000000..32e993a332 --- /dev/null +++ b/Task/Host-introspection/BBC-BASIC/host-introspection.bbc @@ -0,0 +1,7 @@ + DIM P% 8 + !P% = -1 + I% = 0 : REPEAT I% += 1 : UNTIL P%?I%=0 + PRINT "Word size = " ; I% " bytes" + !P% = 1 + IF P%?0 = 1 THEN PRINT "Little-endian" + IF P%?(I%-1) = 1 THEN PRINT "Big-endian" diff --git a/Task/Host-introspection/Babel/host-introspection.pb b/Task/Host-introspection/Babel/host-introspection.pb new file mode 100644 index 0000000000..e9ae534ba0 --- /dev/null +++ b/Task/Host-introspection/Babel/host-introspection.pb @@ -0,0 +1,3 @@ +main : + { "Word size: " << msize 3 shl %d << " bits" cr << + "Endianness: " << { endian } { "little" } { "big" } ifte cr << } diff --git a/Task/Host-introspection/C-sharp/host-introspection.cs b/Task/Host-introspection/C-sharp/host-introspection.cs new file mode 100644 index 0000000000..fb2d0f9112 --- /dev/null +++ b/Task/Host-introspection/C-sharp/host-introspection.cs @@ -0,0 +1,9 @@ +static void Main() +{ + Console.WriteLine("Word size = {0} bytes,",sizeof(int)); + + if (BitConverter.IsLittleEndian) + Console.WriteLine("Little-endian."); + else + Console.WriteLine("Big-endian."); +} diff --git a/Task/Host-introspection/C/host-introspection-1.c b/Task/Host-introspection/C/host-introspection-1.c new file mode 100644 index 0000000000..270257347d --- /dev/null +++ b/Task/Host-introspection/C/host-introspection-1.c @@ -0,0 +1,22 @@ +#include +#include /* for size_t */ +#include /* for CHAR_BIT */ + +int main() { + int one = 1; + + /* + * Best bet: size_t typically is exactly one word. + */ + printf("word size = %d bits\n", (int)(CHAR_BIT * sizeof(size_t))); + + /* + * Check if the least significant bit is located + * in the lowest-address byte. + */ + if (*(char *)&one) + printf("little endian\n"); + else + printf("big endian\n"); + return 0; +} diff --git a/Task/Host-introspection/C/host-introspection-2.c b/Task/Host-introspection/C/host-introspection-2.c new file mode 100644 index 0000000000..7362fc691c --- /dev/null +++ b/Task/Host-introspection/C/host-introspection-2.c @@ -0,0 +1,10 @@ +#include +#include + +int main() +{ + if (htonl(1) == 1) + printf("big endian\n"); + else + printf("little endian\n"); +} diff --git a/Task/Host-introspection/Clojure/host-introspection.clj b/Task/Host-introspection/Clojure/host-introspection.clj new file mode 100644 index 0000000000..cc02432a81 --- /dev/null +++ b/Task/Host-introspection/Clojure/host-introspection.clj @@ -0,0 +1,2 @@ +(println "word size: " (System/getProperty "sun.arch.data.model")) +(println "endianness: " (System/getProperty "sun.cpu.endian")) diff --git a/Task/Host-introspection/Common-Lisp/host-introspection.lisp b/Task/Host-introspection/Common-Lisp/host-introspection.lisp new file mode 100644 index 0000000000..68e1cbe9b2 --- /dev/null +++ b/Task/Host-introspection/Common-Lisp/host-introspection.lisp @@ -0,0 +1 @@ +(machine-type) ;; => "X86-64" on SBCL here diff --git a/Task/Host-introspection/D/host-introspection.d b/Task/Host-introspection/D/host-introspection.d new file mode 100644 index 0000000000..aebd82de11 --- /dev/null +++ b/Task/Host-introspection/D/host-introspection.d @@ -0,0 +1,6 @@ +import std.stdio, std.system; + +void main() { + writefln("word size = ", size_t.sizeof * 8); + writefln(endian == Endian.LittleEndian ? "little" : "big", " endian"); +} diff --git a/Task/Host-introspection/Delphi/host-introspection.delphi b/Task/Host-introspection/Delphi/host-introspection.delphi new file mode 100644 index 0000000000..935509c26f --- /dev/null +++ b/Task/Host-introspection/Delphi/host-introspection.delphi @@ -0,0 +1,10 @@ +program HostIntrospection ; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +begin + Writeln('word size: ', SizeOf(Integer)); + Writeln('endianness: little endian'); // Windows is always little endian +end. diff --git a/Task/Host-introspection/Erlang/host-introspection-1.erl b/Task/Host-introspection/Erlang/host-introspection-1.erl new file mode 100644 index 0000000000..10daa71444 --- /dev/null +++ b/Task/Host-introspection/Erlang/host-introspection-1.erl @@ -0,0 +1,2 @@ +1> erlang:system_info(wordsize). +4 diff --git a/Task/Host-introspection/Erlang/host-introspection-2.erl b/Task/Host-introspection/Erlang/host-introspection-2.erl new file mode 100644 index 0000000000..ec5ce0ee79 --- /dev/null +++ b/Task/Host-introspection/Erlang/host-introspection-2.erl @@ -0,0 +1,6 @@ +1> <<1:4/native-unit:8>>. +<<1,0,0,0>> +2> <<1:4/big-unit:8>> +<<0,0,0,1>> +3> <<1:4/little-unit:8>>. +<<1,0,0,0>> diff --git a/Task/Host-introspection/Erlang/host-introspection-3.erl b/Task/Host-introspection/Erlang/host-introspection-3.erl new file mode 100644 index 0000000000..55e2b4f6b9 --- /dev/null +++ b/Task/Host-introspection/Erlang/host-introspection-3.erl @@ -0,0 +1,2 @@ +endianness() when <<1:4/native-unit:8>> =:= <<1:4/big-unit:8>> -> big; +endianness() -> little. diff --git a/Task/Host-introspection/Factor/host-introspection.factor b/Task/Host-introspection/Factor/host-introspection.factor new file mode 100644 index 0000000000..28d09375c6 --- /dev/null +++ b/Task/Host-introspection/Factor/host-introspection.factor @@ -0,0 +1,3 @@ +USING: alien.c-types alien.data io layouts ; +"Word size: " write cell 8 * . +"Endianness: " write little-endian? "little" "big" ? print diff --git a/Task/Host-introspection/Forth/host-introspection.fth b/Task/Host-introspection/Forth/host-introspection.fth new file mode 100644 index 0000000000..27f9a4eabf --- /dev/null +++ b/Task/Host-introspection/Forth/host-introspection.fth @@ -0,0 +1,4 @@ +: endian + cr 1 cells . ." address units per cell" + s" ADDRESS-UNIT-BITS" environment? if cr . ." bits per address unit" then + cr 1 here ! here c@ if ." little" else ." big" then ." endian" ; diff --git a/Task/Host-introspection/Fortran/host-introspection.f b/Task/Host-introspection/Fortran/host-introspection.f new file mode 100644 index 0000000000..b02f3fe28f --- /dev/null +++ b/Task/Host-introspection/Fortran/host-introspection.f @@ -0,0 +1,13 @@ + integer :: i + character(len=1) :: c(20) + equivalence (c, i) + + WRITE(*,*) bit_size(1) ! number of bits in the default integer type + ! which may (or may not!) equal the word size + i = 1 + + IF (ichar(c(1)) == 0) THEN + WRITE(*,*) "Big Endian" + ELSE + WRITE(*,*) "Little Endian" + END IF diff --git a/Task/Host-introspection/Go/host-introspection-1.go b/Task/Host-introspection/Go/host-introspection-1.go new file mode 100644 index 0000000000..c924b1e8ea --- /dev/null +++ b/Task/Host-introspection/Go/host-introspection-1.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "io/ioutil" + "strings" + "unsafe" +) + +func main() { + // inspect an int variable to determine endianness + x := 1 + if *(*byte)(unsafe.Pointer(&x)) == 1 { + fmt.Println("little endian") + } else { + fmt.Println("big endian") + } + // inspect cpuinfo to determine word size (unix-like os only) + c, err := ioutil.ReadFile("/proc/cpuinfo") + if err != nil { + fmt.Println(err) + return + } + ls := strings.Split(string(c), "\n") + for _, l := range ls { + if strings.HasPrefix(l, "flags") { + for _, f := range strings.Fields(l) { + if f == "lm" { // "long mode" + fmt.Println("64 bit word size") + return + } + } + fmt.Println("32 bit word size") + return + } + } + fmt.Println("cpuinfo flags not found") +} diff --git a/Task/Host-introspection/Go/host-introspection-2.go b/Task/Host-introspection/Go/host-introspection-2.go new file mode 100644 index 0000000000..71070bd8aa --- /dev/null +++ b/Task/Host-introspection/Go/host-introspection-2.go @@ -0,0 +1,17 @@ +package main + +import ( + "debug/elf" + "fmt" + "os" +) + +func main() { + f, err := elf.Open(os.Args[0]) + if err != nil { + fmt.Println(" ", err) + return + } + fmt.Println(f.FileHeader.ByteOrder) + f.Close() +} diff --git a/Task/Host-introspection/Groovy/host-introspection.groovy b/Task/Host-introspection/Groovy/host-introspection.groovy new file mode 100644 index 0000000000..5bbb9096ba --- /dev/null +++ b/Task/Host-introspection/Groovy/host-introspection.groovy @@ -0,0 +1,2 @@ +println "word size: ${System.getProperty('sun.arch.data.model')}" +println "endianness: ${System.getProperty('sun.cpu.endian')}" diff --git a/Task/Host-introspection/Haskell/host-introspection.hs b/Task/Host-introspection/Haskell/host-introspection.hs new file mode 100644 index 0000000000..9949302ec7 --- /dev/null +++ b/Task/Host-introspection/Haskell/host-introspection.hs @@ -0,0 +1,8 @@ +import Data.Bits +import ADNS.Endian -- http://hackage.haskell.org/package/hsdns + +main = do + putStrLn $ "Word size: " ++ bitsize + putStrLn $ "Endianness: " ++ show endian + where + bitsize = show $ bitSize (undefined :: Int) diff --git a/Task/Host-introspection/J/host-introspection-1.j b/Task/Host-introspection/J/host-introspection-1.j new file mode 100644 index 0000000000..c4c73e8405 --- /dev/null +++ b/Task/Host-introspection/J/host-introspection-1.j @@ -0,0 +1,2 @@ + IF64 {32 64 +64 diff --git a/Task/Host-introspection/J/host-introspection-2.j b/Task/Host-introspection/J/host-introspection-2.j new file mode 100644 index 0000000000..c231c72bfc --- /dev/null +++ b/Task/Host-introspection/J/host-introspection-2.j @@ -0,0 +1,3 @@ + ":&> (|: 32 64 ;"0 big`little) {"_1~ 2 2 #: 16b_e0 + a. i. 0 { 3!:1 '' +64 +little diff --git a/Task/Host-introspection/Java/host-introspection-1.java b/Task/Host-introspection/Java/host-introspection-1.java new file mode 100644 index 0000000000..dbcc3a84e8 --- /dev/null +++ b/Task/Host-introspection/Java/host-introspection-1.java @@ -0,0 +1,8 @@ +import java.nio.ByteOrder; + +public class ShowByteOrder { + public static void main(String[] args) { + // Print "BIG_ENDIAN" or "LITTLE_ENDIAN". + System.out.println(ByteOrder.nativeOrder()); + } +} diff --git a/Task/Host-introspection/Java/host-introspection-2.java b/Task/Host-introspection/Java/host-introspection-2.java new file mode 100644 index 0000000000..e4f0cb60e7 --- /dev/null +++ b/Task/Host-introspection/Java/host-introspection-2.java @@ -0,0 +1,2 @@ +System.out.println("word size: "+System.getProperty("sun.arch.data.model")); +System.out.println("endianness: "+System.getProperty("sun.cpu.endian")); diff --git a/Task/Host-introspection/MATLAB/host-introspection.m b/Task/Host-introspection/MATLAB/host-introspection.m new file mode 100644 index 0000000000..32e3033486 --- /dev/null +++ b/Task/Host-introspection/MATLAB/host-introspection.m @@ -0,0 +1,17 @@ + function [endian]=endian() + fid=tmpfile(); + fwrite(fid,1:8,'uint8'); + + fseek(fid,0,'bof'); + t=fread(fid,8,'int8'); + i8=sprintf('%02X',t); + + fseek(fid,0,'bof'); + t=fread(fid,4,'int16'); + i16=sprintf('%04X',t); + + fclose(fid); + + if strcmp(i8,i16) endian='big'; + else endian='little'; + end; diff --git a/Task/Host-introspection/Mathematica/host-introspection.mathematica b/Task/Host-introspection/Mathematica/host-introspection.mathematica new file mode 100644 index 0000000000..c68c58a11b --- /dev/null +++ b/Task/Host-introspection/Mathematica/host-introspection.mathematica @@ -0,0 +1,2 @@ +If[$ByteOrdering > 0, Print["Big endian"], Print["Little endian" ]] +$SystemWordLength "bits" diff --git a/Task/Host-introspection/Modula-3/host-introspection.mod3 b/Task/Host-introspection/Modula-3/host-introspection.mod3 new file mode 100644 index 0000000000..e3b8cb74dc --- /dev/null +++ b/Task/Host-introspection/Modula-3/host-introspection.mod3 @@ -0,0 +1,12 @@ +MODULE Host EXPORTS Main; + +IMPORT IO, Fmt, Word, Swap; + +BEGIN + IO.Put("Word Size: " & Fmt.Int(Word.Size) & "\n"); + IF Swap.endian = Swap.Endian.Big THEN + IO.Put("Endianness: Big\n"); + ELSE + IO.Put("Endianness: Little\n"); + END; +END Host. diff --git a/Task/Host-introspection/Perl/host-introspection-1.pl b/Task/Host-introspection/Perl/host-introspection-1.pl new file mode 100644 index 0000000000..a056208c84 --- /dev/null +++ b/Task/Host-introspection/Perl/host-introspection-1.pl @@ -0,0 +1,2 @@ +use Config; +print "UV size: $Config{uvsize}, byte order: $Config{byteorder}\n"; diff --git a/Task/Host-introspection/Perl/host-introspection-2.pl b/Task/Host-introspection/Perl/host-introspection-2.pl new file mode 100644 index 0000000000..5c0086a672 --- /dev/null +++ b/Task/Host-introspection/Perl/host-introspection-2.pl @@ -0,0 +1,9 @@ +use 5.010; +use Config; +my ($size, $order, $end) = @Config{qw(uvsize byteorder)}; +given ($order) { + when (join '', sort split '') { $end = 'little' } + when (join '', reverse sort split '') { $end = 'big' } + default { $end = 'mixed' } +} +say "UV size: $size, byte order: $order ($end-endian)"; diff --git a/Task/Host-introspection/PicoLisp/host-introspection.l b/Task/Host-introspection/PicoLisp/host-introspection.l new file mode 100644 index 0000000000..da670b5036 --- /dev/null +++ b/Task/Host-introspection/PicoLisp/host-introspection.l @@ -0,0 +1,12 @@ +(in (cmd) # Inspect ELF header + (rd 4) # Skip "7F" and 'E', 'L' and 'F' + (prinl + (case (rd 1) # Get EI_CLASS byte + (1 "32 bits") + (2 "64 bits") + (T "Bad EI_CLASS") ) ) + (prinl + (case (rd 1) # Get EI_DATA byte + (1 "Little endian") + (2 "Big endian") + (T "Bad EI_DATA") ) ) ) diff --git a/Task/Host-introspection/Python/host-introspection.py b/Task/Host-introspection/Python/host-introspection.py new file mode 100644 index 0000000000..25a83697cc --- /dev/null +++ b/Task/Host-introspection/Python/host-introspection.py @@ -0,0 +1,12 @@ +>>> import sys, math +>>> int(round(math.log(sys.maxint,2)+1)) # this only works in Python 2.x +32 +>>> import struct +>>> struct.calcsize('i') * 8 +32 +>>> sys.byteorder +little +>>> import socket +>>> socket.gethostname() +'PADDY3118-RESTING' +>>> diff --git a/Task/Host-introspection/R/host-introspection-1.r b/Task/Host-introspection/R/host-introspection-1.r new file mode 100644 index 0000000000..e9493a3428 --- /dev/null +++ b/Task/Host-introspection/R/host-introspection-1.r @@ -0,0 +1,3 @@ +8 * .Machine$sizeof.long # e.g. 32 +# or +object.size(0L) # e.g. 32 bytes diff --git a/Task/Host-introspection/R/host-introspection-2.r b/Task/Host-introspection/R/host-introspection-2.r new file mode 100644 index 0000000000..1847947008 --- /dev/null +++ b/Task/Host-introspection/R/host-introspection-2.r @@ -0,0 +1 @@ +.Platform$endian # e.g. "little" diff --git a/Task/Host-introspection/REXX/host-introspection.rexx b/Task/Host-introspection/REXX/host-introspection.rexx new file mode 100644 index 0000000000..f69dbaff42 --- /dev/null +++ b/Task/Host-introspection/REXX/host-introspection.rexx @@ -0,0 +1,6 @@ +/*REXX program to examine which operating system that REXX is running under. */ + +parse source opSys howInvoked pathName + +/*where opSys will indicate which operating system REXX is running under, and */ +/*from that, one could make assumptions what the wordsize is, etc. */ diff --git a/Task/Host-introspection/Racket/host-introspection.rkt b/Task/Host-introspection/Racket/host-introspection.rkt new file mode 100644 index 0000000000..212e76c1ae --- /dev/null +++ b/Task/Host-introspection/Racket/host-introspection.rkt @@ -0,0 +1,4 @@ +#lang racket/base + +(printf "Word size: ~a\n" (system-type 'word)) +(printf "Endianness: ~a\n" (if (system-big-endian?) 'big 'little)) diff --git a/Task/Host-introspection/Ruby/host-introspection.rb b/Task/Host-introspection/Ruby/host-introspection.rb new file mode 100644 index 0000000000..9231092462 --- /dev/null +++ b/Task/Host-introspection/Ruby/host-introspection.rb @@ -0,0 +1,10 @@ +# We assume that a Fixnum occupies one machine word. +# Fixnum#size returns bytes (1 byte = 8 bits). +word_size = 42.size * 8 +puts "Word size: #{word_size} bits" + +# Array#pack knows the native byte order. We pack 1 as a 16-bit integer, +# then unpack bytes: [0, 1] is big endian, [1, 0] is little endian. +bytes = [1].pack('S').unpack('C*') +byte_order = (bytes[0] == 0 ? 'big' : 'little') + ' endian' +puts "Byte order: #{byte_order}" diff --git a/Task/Host-introspection/Scheme/host-introspection.ss b/Task/Host-introspection/Scheme/host-introspection.ss new file mode 100644 index 0000000000..ca939d1d30 --- /dev/null +++ b/Task/Host-introspection/Scheme/host-introspection.ss @@ -0,0 +1,8 @@ +(define host-info + (begin + (display "Endianness: ") + (display (machine-byte-order)) + (newline) + (display "Word Size: ") + (display (if (fixnum? (expt 2 33)) 64 32)) + (newline))) diff --git a/Task/Host-introspection/Tcl/host-introspection.tcl b/Task/Host-introspection/Tcl/host-introspection.tcl new file mode 100644 index 0000000000..0a94dec306 --- /dev/null +++ b/Task/Host-introspection/Tcl/host-introspection.tcl @@ -0,0 +1,10 @@ +% parray tcl_platform +tcl_platform(byteOrder) = littleEndian +tcl_platform(machine) = intel +tcl_platform(os) = Windows NT +tcl_platform(osVersion) = 5.1 +tcl_platform(platform) = windows +tcl_platform(pointerSize) = 4 +tcl_platform(threaded) = 1 +tcl_platform(user) = glennj +tcl_platform(wordSize) = 4 diff --git a/Task/Hostname/0DESCRIPTION b/Task/Hostname/0DESCRIPTION new file mode 100644 index 0000000000..d6241dbee7 --- /dev/null +++ b/Task/Hostname/0DESCRIPTION @@ -0,0 +1 @@ +Find the name of the host on which the routine is running. diff --git a/Task/Hostname/1META.yaml b/Task/Hostname/1META.yaml new file mode 100644 index 0000000000..7948000013 --- /dev/null +++ b/Task/Hostname/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Networking and Web Interaction +note: Programming environment operations diff --git a/Task/Hostname/ALGOL-68/hostname.alg b/Task/Hostname/ALGOL-68/hostname.alg new file mode 100644 index 0000000000..e544dce50c --- /dev/null +++ b/Task/Hostname/ALGOL-68/hostname.alg @@ -0,0 +1,3 @@ +STRING hostname; +get(read OF execve child pipe("/bin/hostname","hostname",""), hostname); +print(("hostname: ", hostname, new line)) diff --git a/Task/Hostname/AWK/hostname.awk b/Task/Hostname/AWK/hostname.awk new file mode 100644 index 0000000000..ddb709ec1c --- /dev/null +++ b/Task/Hostname/AWK/hostname.awk @@ -0,0 +1,2 @@ +$ awk 'BEGIN{print ENVIRON["HOST"]}' +E51A08ZD diff --git a/Task/Hostname/Ada/hostname.ada b/Task/Hostname/Ada/hostname.ada new file mode 100644 index 0000000000..420edde6e1 --- /dev/null +++ b/Task/Hostname/Ada/hostname.ada @@ -0,0 +1,7 @@ +with Ada.Text_IO; use Ada.Text_IO; +with GNAT.Sockets; + +procedure Demo is +begin + Put_Line (GNAT.Sockets.Host_Name); +end Demo; diff --git a/Task/Hostname/Aikido/hostname.aikido b/Task/Hostname/Aikido/hostname.aikido new file mode 100644 index 0000000000..d74f5ff71d --- /dev/null +++ b/Task/Hostname/Aikido/hostname.aikido @@ -0,0 +1 @@ +println (System.hostname) diff --git a/Task/Hostname/AutoHotkey/hostname.ahk b/Task/Hostname/AutoHotkey/hostname.ahk new file mode 100644 index 0000000000..38fbda799f --- /dev/null +++ b/Task/Hostname/AutoHotkey/hostname.ahk @@ -0,0 +1 @@ +MsgBox % A_ComputerName diff --git a/Task/Hostname/BBC-BASIC/hostname.bbc b/Task/Hostname/BBC-BASIC/hostname.bbc new file mode 100644 index 0000000000..5fed28d4ea --- /dev/null +++ b/Task/Hostname/BBC-BASIC/hostname.bbc @@ -0,0 +1,4 @@ + INSTALL @lib$+"SOCKLIB" + PROC_initsockets + PRINT "hostname: " FN_gethostname + PROC_exitsockets diff --git a/Task/Hostname/C/hostname.c b/Task/Hostname/C/hostname.c new file mode 100644 index 0000000000..2c1bd387e4 --- /dev/null +++ b/Task/Hostname/C/hostname.c @@ -0,0 +1,10 @@ +#include +#include +#include +#include + +int main(void) +{ + char name[_POSIX_HOST_NAME_MAX + 1]; + return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/Task/Hostname/Clojure/hostname-1.clj b/Task/Hostname/Clojure/hostname-1.clj new file mode 100644 index 0000000000..30df592a17 --- /dev/null +++ b/Task/Hostname/Clojure/hostname-1.clj @@ -0,0 +1 @@ +(.. java.net.InetAddress getLocalHost getHostName) diff --git a/Task/Hostname/Clojure/hostname-2.clj b/Task/Hostname/Clojure/hostname-2.clj new file mode 100644 index 0000000000..faa6963ffb --- /dev/null +++ b/Task/Hostname/Clojure/hostname-2.clj @@ -0,0 +1 @@ +java -cp clojure.jar clojure.main -e "(.. java.net.InetAddress getLocalHost getHostName)" diff --git a/Task/Hostname/CoffeeScript/hostname.coffee b/Task/Hostname/CoffeeScript/hostname.coffee new file mode 100644 index 0000000000..0d9b70b3ac --- /dev/null +++ b/Task/Hostname/CoffeeScript/hostname.coffee @@ -0,0 +1,2 @@ +os = require 'os' +console.log os.hostname() diff --git a/Task/Hostname/Common-Lisp/hostname-1.lisp b/Task/Hostname/Common-Lisp/hostname-1.lisp new file mode 100644 index 0000000000..56b9360588 --- /dev/null +++ b/Task/Hostname/Common-Lisp/hostname-1.lisp @@ -0,0 +1,4 @@ +(defun get-host-name () + #+sbcl (machine-instance) + #+clisp (let ((s (machine-instance))) (subseq s 0 (position #\Space s))) + #-(or sbcl clisp) (error "get-host-name not implemented")) diff --git a/Task/Hostname/Common-Lisp/hostname-2.lisp b/Task/Hostname/Common-Lisp/hostname-2.lisp new file mode 100644 index 0000000000..00cc3d45d5 --- /dev/null +++ b/Task/Hostname/Common-Lisp/hostname-2.lisp @@ -0,0 +1,8 @@ +(cffi:defcfun ("gethostname" c-gethostname) :int + (buf :pointer) (len :unsigned-long)) + +(defun get-hostname () + (cffi:with-foreign-object (buf :char 256) + (unless (zerop (c-gethostname buf 256)) + (error "Can't get hostname")) + (values (cffi:foreign-string-to-lisp buf)))) diff --git a/Task/Hostname/Common-Lisp/hostname-3.lisp b/Task/Hostname/Common-Lisp/hostname-3.lisp new file mode 100644 index 0000000000..602bd8eb25 --- /dev/null +++ b/Task/Hostname/Common-Lisp/hostname-3.lisp @@ -0,0 +1,2 @@ +BOA> (get-hostname) +"aurora" diff --git a/Task/Hostname/D/hostname.d b/Task/Hostname/D/hostname.d new file mode 100644 index 0000000000..fe3ffd68a2 --- /dev/null +++ b/Task/Hostname/D/hostname.d @@ -0,0 +1,5 @@ +import std.stdio, std.socket; + +void main() { + writeln(Socket.hostName()); +} diff --git a/Task/Hostname/Delphi/hostname.delphi b/Task/Hostname/Delphi/hostname.delphi new file mode 100644 index 0000000000..63a515345d --- /dev/null +++ b/Task/Hostname/Delphi/hostname.delphi @@ -0,0 +1,16 @@ +program ShowHostName; + +{$APPTYPE CONSOLE} + +uses Windows; + +var + lHostName: array[0..255] of char; + lBufferSize: DWORD; +begin + lBufferSize := 256; + if GetComputerName(lHostName, lBufferSize) then + Writeln(lHostName) + else + Writeln('error getting host name'); +end. diff --git a/Task/Hostname/E/hostname.e b/Task/Hostname/E/hostname.e new file mode 100644 index 0000000000..115fccb30d --- /dev/null +++ b/Task/Hostname/E/hostname.e @@ -0,0 +1 @@ +makeCommand("hostname")()[0].trim() diff --git a/Task/Hostname/Erlang/hostname.erl b/Task/Hostname/Erlang/hostname.erl new file mode 100644 index 0000000000..4f5b3ee870 --- /dev/null +++ b/Task/Hostname/Erlang/hostname.erl @@ -0,0 +1 @@ +Host = net_adm:localhost(). diff --git a/Task/Hostname/Factor/hostname.factor b/Task/Hostname/Factor/hostname.factor new file mode 100644 index 0000000000..93baf2ba01 --- /dev/null +++ b/Task/Hostname/Factor/hostname.factor @@ -0,0 +1 @@ +host-name diff --git a/Task/Hostname/Forth/hostname.fth b/Task/Hostname/Forth/hostname.fth new file mode 100644 index 0000000000..1982ff75bd --- /dev/null +++ b/Task/Hostname/Forth/hostname.fth @@ -0,0 +1,3 @@ +include unix/socket.fs + +hostname type diff --git a/Task/Hostname/Fortran/hostname.f b/Task/Hostname/Fortran/hostname.f new file mode 100644 index 0000000000..5c15637ece --- /dev/null +++ b/Task/Hostname/Fortran/hostname.f @@ -0,0 +1,5 @@ +program HostTest + character(len=128) :: name + call hostnm(name) + print *, name +end program HostTest diff --git a/Task/Hostname/Go/hostname.go b/Task/Hostname/Go/hostname.go new file mode 100644 index 0000000000..f1873c75e0 --- /dev/null +++ b/Task/Hostname/Go/hostname.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + host, _ := os.Hostname() + fmt.Printf("hostname: %s\n", host) +} diff --git a/Task/Hostname/Groovy/hostname.groovy b/Task/Hostname/Groovy/hostname.groovy new file mode 100644 index 0000000000..bf434f8b6a --- /dev/null +++ b/Task/Hostname/Groovy/hostname.groovy @@ -0,0 +1 @@ +println InetAddress.localHost.hostName diff --git a/Task/Hostname/Haskell/hostname.hs b/Task/Hostname/Haskell/hostname.hs new file mode 100644 index 0000000000..2363e07b21 --- /dev/null +++ b/Task/Hostname/Haskell/hostname.hs @@ -0,0 +1,3 @@ +import Network.BSD +main = do hostName <- getHostName + putStrLn hostName diff --git a/Task/Hostname/IDL/hostname.idl b/Task/Hostname/IDL/hostname.idl new file mode 100644 index 0000000000..951c84d25b --- /dev/null +++ b/Task/Hostname/IDL/hostname.idl @@ -0,0 +1 @@ +hostname = GETENV('computername') diff --git a/Task/Hostname/Icon/hostname.icon b/Task/Hostname/Icon/hostname.icon new file mode 100644 index 0000000000..e3b5064f5c --- /dev/null +++ b/Task/Hostname/Icon/hostname.icon @@ -0,0 +1,3 @@ +procedure main() + write(&host) +end diff --git a/Task/Hostname/J/hostname.j b/Task/Hostname/J/hostname.j new file mode 100644 index 0000000000..2fa939adcc --- /dev/null +++ b/Task/Hostname/J/hostname.j @@ -0,0 +1,13 @@ +NB. Load the socket libraries + + load 'socket' + coinsert 'jsocket' + +NB. fetch and implicitly display the hostname + + > {: sdgethostname '' + +NB. If fetching the hostname is the only reason for loading the socket libraries, +NB. and the hostname is fetched only once, then use a 'one-liner' to accomplish it: + + > {: sdgethostname coinsert 'jsocket' [ load 'socket' diff --git a/Task/Hostname/Java/hostname.java b/Task/Hostname/Java/hostname.java new file mode 100644 index 0000000000..25ba17d0d9 --- /dev/null +++ b/Task/Hostname/Java/hostname.java @@ -0,0 +1,9 @@ +import java.net.*; +class DiscoverHostName { + public static void main(final String[] args) { + try { + System.out.println(InetAddress.getLocalHost().getHostName()); + } catch (UnknownHostException e) { // Doesn't actually happen, but Java requires it be handled. + } + } +} diff --git a/Task/Hostname/JavaScript/hostname.js b/Task/Hostname/JavaScript/hostname.js new file mode 100644 index 0000000000..4bf7023ea7 --- /dev/null +++ b/Task/Hostname/JavaScript/hostname.js @@ -0,0 +1,3 @@ +var network = new ActiveXObject('WScript.Network'); +var hostname = network.computerName; +WScript.echo(hostname); diff --git a/Task/Hostname/Liberty-BASIC/hostname.liberty b/Task/Hostname/Liberty-BASIC/hostname.liberty new file mode 100644 index 0000000000..2a11683d15 --- /dev/null +++ b/Task/Hostname/Liberty-BASIC/hostname.liberty @@ -0,0 +1,8 @@ +lpBuffer$=Space$(128) + Chr$(0) +struct SIZE,sz As Long +SIZE.sz.struct=Len(lpBuffer$) + +calldll #kernel32, "GetComputerNameA",lpBuffer$ as ptr, SIZE as struct, result as Long +CurrentComputerName$=Trim$(Left$(lpBuffer$, SIZE.sz.struct)) + +print CurrentComputerName$ diff --git a/Task/Hostname/Lua/hostname.lua b/Task/Hostname/Lua/hostname.lua new file mode 100644 index 0000000000..e29adf78a5 --- /dev/null +++ b/Task/Hostname/Lua/hostname.lua @@ -0,0 +1,2 @@ +socket = require "socket" +print( socket.dns.gethostname() ) diff --git a/Task/Hostname/MATLAB/hostname.m b/Task/Hostname/MATLAB/hostname.m new file mode 100644 index 0000000000..8d74bb4c7a --- /dev/null +++ b/Task/Hostname/MATLAB/hostname.m @@ -0,0 +1 @@ +[failed,hostname] = system('hostname') diff --git a/Task/Hostname/MUMPS/hostname.mumps b/Task/Hostname/MUMPS/hostname.mumps new file mode 100644 index 0000000000..090a02459b --- /dev/null +++ b/Task/Hostname/MUMPS/hostname.mumps @@ -0,0 +1 @@ +Write $Piece($System,":") diff --git a/Task/Hostname/Maple/hostname.maple b/Task/Hostname/Maple/hostname.maple new file mode 100644 index 0000000000..d01ecb9ee1 --- /dev/null +++ b/Task/Hostname/Maple/hostname.maple @@ -0,0 +1 @@ +Sockets:-GetHostName() diff --git a/Task/Hostname/Mathematica/hostname.mathematica b/Task/Hostname/Mathematica/hostname.mathematica new file mode 100644 index 0000000000..90ffa26980 --- /dev/null +++ b/Task/Hostname/Mathematica/hostname.mathematica @@ -0,0 +1 @@ +$MachineName diff --git a/Task/Hostname/Modula-3/hostname.mod3 b/Task/Hostname/Modula-3/hostname.mod3 new file mode 100644 index 0000000000..a1b1035a46 --- /dev/null +++ b/Task/Hostname/Modula-3/hostname.mod3 @@ -0,0 +1,7 @@ +MODULE Hostname EXPORTS Main; + +IMPORT IO, OSConfig; + +BEGIN + IO.Put(OSConfig.HostName() & "\n"); +END Hostname. diff --git a/Task/Hostname/PHP/hostname-1.php b/Task/Hostname/PHP/hostname-1.php new file mode 100644 index 0000000000..3a1e0addda --- /dev/null +++ b/Task/Hostname/PHP/hostname-1.php @@ -0,0 +1 @@ +echo $_SERVER['HTTP_HOST']; diff --git a/Task/Hostname/PHP/hostname-2.php b/Task/Hostname/PHP/hostname-2.php new file mode 100644 index 0000000000..207d2f125f --- /dev/null +++ b/Task/Hostname/PHP/hostname-2.php @@ -0,0 +1 @@ +echo php_uname('n'); diff --git a/Task/Hostname/PHP/hostname-3.php b/Task/Hostname/PHP/hostname-3.php new file mode 100644 index 0000000000..7cb45b6805 --- /dev/null +++ b/Task/Hostname/PHP/hostname-3.php @@ -0,0 +1 @@ +echo gethostname(); diff --git a/Task/Hostname/Perl/hostname.pl b/Task/Hostname/Perl/hostname.pl new file mode 100644 index 0000000000..291827f954 --- /dev/null +++ b/Task/Hostname/Perl/hostname.pl @@ -0,0 +1,3 @@ +use Sys::Hostname; + +$name = hostname; diff --git a/Task/Hostname/PicoLisp/hostname-1.l b/Task/Hostname/PicoLisp/hostname-1.l new file mode 100644 index 0000000000..72774e21ad --- /dev/null +++ b/Task/Hostname/PicoLisp/hostname-1.l @@ -0,0 +1 @@ +(call 'hostname) diff --git a/Task/Hostname/PicoLisp/hostname-2.l b/Task/Hostname/PicoLisp/hostname-2.l new file mode 100644 index 0000000000..b6e05f9eef --- /dev/null +++ b/Task/Hostname/PicoLisp/hostname-2.l @@ -0,0 +1 @@ +(in '(hostname) (line T)) diff --git a/Task/Hostname/Python/hostname.py b/Task/Hostname/Python/hostname.py new file mode 100644 index 0000000000..23f77fc0e3 --- /dev/null +++ b/Task/Hostname/Python/hostname.py @@ -0,0 +1,2 @@ +import socket +host = socket.gethostname() diff --git a/Task/Hostname/R/hostname-1.r b/Task/Hostname/R/hostname-1.r new file mode 100644 index 0000000000..b113e8e429 --- /dev/null +++ b/Task/Hostname/R/hostname-1.r @@ -0,0 +1 @@ +Sys.info()[["nodename"]] diff --git a/Task/Hostname/R/hostname-2.r b/Task/Hostname/R/hostname-2.r new file mode 100644 index 0000000000..7c1cdb915d --- /dev/null +++ b/Task/Hostname/R/hostname-2.r @@ -0,0 +1 @@ +system("hostname", intern = TRUE) diff --git a/Task/Hostname/R/hostname-3.r b/Task/Hostname/R/hostname-3.r new file mode 100644 index 0000000000..2a452a9424 --- /dev/null +++ b/Task/Hostname/R/hostname-3.r @@ -0,0 +1,2 @@ +env_var <- ifelse(.Platform$OS.type == "windows", "COMPUTERNAME", "HOSTNAME") +Sys.getenv(env_var) diff --git a/Task/Hostname/REXX/hostname-1.rexx b/Task/Hostname/REXX/hostname-1.rexx new file mode 100644 index 0000000000..4a4937b2d5 --- /dev/null +++ b/Task/Hostname/REXX/hostname-1.rexx @@ -0,0 +1,2 @@ +say value('COMPUTERNAME',,"ENVIRONMENT") +say value('OS',,"ENVIRONMENT") diff --git a/Task/Hostname/REXX/hostname-2.rexx b/Task/Hostname/REXX/hostname-2.rexx new file mode 100644 index 0000000000..0afd8c8449 --- /dev/null +++ b/Task/Hostname/REXX/hostname-2.rexx @@ -0,0 +1,2 @@ +say value('COMPUTERNAME',,"SYSTEM") +say value('OS',,"SYSTEM") diff --git a/Task/Hostname/REXX/hostname-3.rexx b/Task/Hostname/REXX/hostname-3.rexx new file mode 100644 index 0000000000..7c24fe0fae --- /dev/null +++ b/Task/Hostname/REXX/hostname-3.rexx @@ -0,0 +1 @@ +say userid() diff --git a/Task/Hostname/REXX/hostname-4.rexx b/Task/Hostname/REXX/hostname-4.rexx new file mode 100644 index 0000000000..a8f7c9b45f --- /dev/null +++ b/Task/Hostname/REXX/hostname-4.rexx @@ -0,0 +1 @@ +'VER' /*this passes the VER command to the MS DOS system. */ diff --git a/Task/Hostname/REXX/hostname-5.rexx b/Task/Hostname/REXX/hostname-5.rexx new file mode 100644 index 0000000000..8aa1fe59f5 --- /dev/null +++ b/Task/Hostname/REXX/hostname-5.rexx @@ -0,0 +1,6 @@ +/* Rexx */ +address command "hostname -f" with output stem hn. +do q_ = 1 to hn.0 + say hn.q_ + end q_ +exit diff --git a/Task/Hostname/Racket/hostname.rkt b/Task/Hostname/Racket/hostname.rkt new file mode 100644 index 0000000000..92389f379f --- /dev/null +++ b/Task/Hostname/Racket/hostname.rkt @@ -0,0 +1,3 @@ +#lang racket/base +(require mzlib/os) +(gethostname) diff --git a/Task/Hostname/Ruby/hostname.rb b/Task/Hostname/Ruby/hostname.rb new file mode 100644 index 0000000000..fe390bc8f4 --- /dev/null +++ b/Task/Hostname/Ruby/hostname.rb @@ -0,0 +1,2 @@ +require 'socket' +host = Socket.gethostname diff --git a/Task/Hostname/Scala/hostname.scala b/Task/Hostname/Scala/hostname.scala new file mode 100644 index 0000000000..f2e20dcb11 --- /dev/null +++ b/Task/Hostname/Scala/hostname.scala @@ -0,0 +1 @@ +println(java.net.InetAddress.getLocalHost.getHostName) diff --git a/Task/Hostname/Scheme/hostname-1.ss b/Task/Hostname/Scheme/hostname-1.ss new file mode 100644 index 0000000000..8da80d3f67 --- /dev/null +++ b/Task/Hostname/Scheme/hostname-1.ss @@ -0,0 +1,2 @@ +(use posix) +(get-host-name) diff --git a/Task/Hostname/Scheme/hostname-2.ss b/Task/Hostname/Scheme/hostname-2.ss new file mode 100644 index 0000000000..016cb5a711 --- /dev/null +++ b/Task/Hostname/Scheme/hostname-2.ss @@ -0,0 +1 @@ +(gethostname) diff --git a/Task/Hostname/Smalltalk/hostname.st b/Task/Hostname/Smalltalk/hostname.st new file mode 100644 index 0000000000..bc222aedfb --- /dev/null +++ b/Task/Hostname/Smalltalk/hostname.st @@ -0,0 +1 @@ +OperatingSystem getHostName diff --git a/Task/Hostname/Tcl/hostname.tcl b/Task/Hostname/Tcl/hostname.tcl new file mode 100644 index 0000000000..b4302f0b83 --- /dev/null +++ b/Task/Hostname/Tcl/hostname.tcl @@ -0,0 +1 @@ +set hname [info hostname] diff --git a/Task/Hough-transform/0DESCRIPTION b/Task/Hough-transform/0DESCRIPTION new file mode 100644 index 0000000000..870a252c10 --- /dev/null +++ b/Task/Hough-transform/0DESCRIPTION @@ -0,0 +1,8 @@ +Implement the [[wp:Hough transform|Hough transform]], which is used as part of feature extraction with digital images. It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation. + +The transform maps each point in the target image, (\rho,\theta), to the average color of the pixels on the corresponding line of the source image (in (x,y)-space, where the line corresponds to points of the form x\cos\theta + y\sin\theta = \rho). The idea is that where there is a straight line in the original image, it corresponds to a bright (or dark, depending on the color of the background field) spot; by applying a suitable filter to the results of the transform, it is possible to extract the locations of the lines in the original image. + +[[Image:Pentagon.png|thumb|Sample PNG image to use for the Hough transform.]] +The target space actually uses polar coordinates, but is conventionally plotted on rectangular coordinates for display. There's no specification of exactly how to map polar coordinates to a flat surface for display, but a convenient method is to use one axis for \theta and the other for \rho, with the center of the source image being the origin. + +There is also a spherical Hough transform, which is more suited to identifying planes in 3D data. diff --git a/Task/Hough-transform/1META.yaml b/Task/Hough-transform/1META.yaml new file mode 100644 index 0000000000..f250e44c7a --- /dev/null +++ b/Task/Hough-transform/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Graphics algorithms +note: Image processing diff --git a/Task/Hough-transform/BBC-BASIC/hough-transform.bbc b/Task/Hough-transform/BBC-BASIC/hough-transform.bbc new file mode 100644 index 0000000000..579e1db45e --- /dev/null +++ b/Task/Hough-transform/BBC-BASIC/hough-transform.bbc @@ -0,0 +1,47 @@ + Width% = 320 + Height% = 240 + + VDU 23,22,Width%;Height%;8,16,16,128 + *DISPLAY Pentagon.bmp + OFF + + DIM hist%(Width%-1, Height%-1) + + rs = 2 * SQR(Width%^2 + Height%^2) / Height% : REM Radial step + ts = PI / Width% : REM Angular step + h% = Height% / 2 + + REM Hough transform: + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + IF TINT(x%*2, y%*2) = 0 THEN + FOR t% = 0 TO Width%-1 + th = t% * ts + r% = (x%*COS(th) + y%*SIN(th)) / rs + h% + 0.5 + hist%(t%,r%) += 1 + NEXT + ENDIF + NEXT + NEXT y% + + REM Find max: + max% = 0 + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + IF hist%(x%,y%) > max% max% = hist%(x%,y%) + NEXT + NEXT y% + + REM Plot: + GCOL 1 + FOR y% = 0 TO Height%-1 + FOR x% = 0 TO Width%-1 + c% = 255 * hist%(x%,y%) / max% + COLOUR 1, c%, c%, c% + LINE x%*2,y%*2,x%*2,y%*2 + NEXT + NEXT y% + + REPEAT + WAIT 1 + UNTIL FALSE diff --git a/Task/Hough-transform/D/hough-transform.d b/Task/Hough-transform/D/hough-transform.d new file mode 100644 index 0000000000..208d966c65 --- /dev/null +++ b/Task/Hough-transform/D/hough-transform.d @@ -0,0 +1,40 @@ +import std.math, grayscale_image; + +Image!Gray houghTransform(in Image!Gray im, + in size_t hx=460, in size_t hy=360) +/*pure nothrow*/ in { + assert(im !is null); + assert(hx > 0 && hy > 0); + assert((hy & 1) == 0, "hy argument must be even."); +} body { + auto result = new Image!Gray(hx, hy); + result.clear(Gray.white); + + immutable double rMax = hypot(im.nx, im.ny); + immutable double dr = rMax / (hy / 2.0); + immutable double dTh = PI / hx; + + foreach (immutable y; 0 .. im.ny) { + foreach (immutable x; 0 .. im.nx) { + // if (im[x, y] == Gray.max) // Not pure. + if (im[x, y] == Gray(255)) + continue; + foreach (immutable iTh; 0 .. hx) { + immutable double th = dTh * iTh; + immutable double r = x * cos(th) + y * sin(th); + immutable iry = hy / 2 - cast(int)floor(r / dr + 0.5); + if (result[iTh, iry] > Gray(0)) + result[iTh, iry]--; + } + } + } + return result; +} + +void main() { + auto im = new Image!RGB; + loadPPM6(im, "Pentagon.ppm") + .rgb2grayImage() + .houghTransform() + .savePGM("Pentagon_hough.pgm"); +} diff --git a/Task/Hough-transform/Go/hough-transform.go b/Task/Hough-transform/Go/hough-transform.go new file mode 100644 index 0000000000..40e233b874 --- /dev/null +++ b/Task/Hough-transform/Go/hough-transform.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + "image" + "image/color" + "image/draw" + "image/png" + "math" + "os" +) + +func hough(im image.Image, ntx, mry int) draw.Image { + nimx := im.Bounds().Max.X + mimy := im.Bounds().Max.Y + mry = int(mry/2) * 2 + him := image.NewGray(image.Rect(0, 0, ntx, mry)) + draw.Draw(him, him.Bounds(), image.NewUniform(color.White), + image.ZP, draw.Src) + + rmax := math.Hypot(float64(nimx), float64(mimy)) + dr := rmax / float64(mry/2) + dth := math.Pi / float64(ntx) + + for jx := 0; jx < nimx; jx++ { + for iy := 0; iy < mimy; iy++ { + col := color.GrayModel.Convert(im.At(jx, iy)).(color.Gray) + if col.Y == 255 { + continue + } + for jtx := 0; jtx < ntx; jtx++ { + th := dth * float64(jtx) + r := float64(jx)*math.Cos(th) + float64(iy)*math.Sin(th) + iry := mry/2 - int(math.Floor(r/dr+.5)) + col = him.At(jtx, iry).(color.Gray) + if col.Y > 0 { + col.Y-- + him.SetGray(jtx, iry, col) + } + } + } + } + return him +} + +func main() { + f, err := os.Open("Pentagon.png") + if err != nil { + fmt.Println(err) + return + } + pent, err := png.Decode(f) + if err != nil { + fmt.Println(err) + return + } + if err = f.Close(); err != nil { + fmt.Println(err) + } + h := hough(pent, 460, 360) + if f, err = os.Create("hough.png"); err != nil { + fmt.Println(err) + return + } + if err = png.Encode(f, h); err != nil { + fmt.Println(err) + } + if cErr := f.Close(); cErr != nil && err == nil { + fmt.Println(err) + } +} diff --git a/Task/Hough-transform/J/hough-transform-1.j b/Task/Hough-transform/J/hough-transform-1.j new file mode 100644 index 0000000000..375625a8b1 --- /dev/null +++ b/Task/Hough-transform/J/hough-transform-1.j @@ -0,0 +1,11 @@ +NB.*houghTransform v Produces a density plot of image y in hough space +NB. y is picture as an array with 1 at non-white points, +NB. x is resolution (width,height) of resulting image +houghTransform=: dyad define + 'w h'=. x NB. width and height of target image + theta=. o. (%~ 0.5+i.) w NB. theta in radians from 0 to π + rho=. (4$.$. |.y) +/ .* 2 1 o./theta NB. rho for each pixel at each theta + 'min max'=. (,~-) +/&.:*: $y NB. min/max possible rho + rho=. <. 0.5+ h * (rho-min) % max-min NB. Rescale rho from 0 to h and round to int + |.([: <:@(#/.~) (i.h)&,)"1&.|: rho NB. consolidate into picture +) diff --git a/Task/Hough-transform/J/hough-transform-2.j b/Task/Hough-transform/J/hough-transform-2.j new file mode 100644 index 0000000000..34c9eb8c09 --- /dev/null +++ b/Task/Hough-transform/J/hough-transform-2.j @@ -0,0 +1,3 @@ + require 'viewmat media/platimg' + Img=: readimg jpath '~temp/pentagon.png' + viewmat 460 360 houghTransform _1 > Img diff --git a/Task/Hough-transform/Java/hough-transform.java b/Task/Hough-transform/Java/hough-transform.java new file mode 100644 index 0000000000..01b94738a7 --- /dev/null +++ b/Task/Hough-transform/Java/hough-transform.java @@ -0,0 +1,142 @@ +import java.awt.image.*; +import java.io.File; +import java.io.IOException; +import javax.imageio.*; + +public class HoughTransform +{ + public static ArrayData houghTransform(ArrayData inputData, int thetaAxisSize, int rAxisSize, int minContrast) + { + int width = inputData.width; + int height = inputData.height; + int maxRadius = (int)Math.ceil(Math.hypot(width, height)); + int halfRAxisSize = rAxisSize >>> 1; + ArrayData outputData = new ArrayData(thetaAxisSize, rAxisSize); + // x output ranges from 0 to pi + // y output ranges from -maxRadius to maxRadius + double[] sinTable = new double[thetaAxisSize]; + double[] cosTable = new double[thetaAxisSize]; + for (int theta = thetaAxisSize - 1; theta >= 0; theta--) + { + double thetaRadians = theta * Math.PI / thetaAxisSize; + sinTable[theta] = Math.sin(thetaRadians); + cosTable[theta] = Math.cos(thetaRadians); + } + + for (int y = height - 1; y >= 0; y--) + { + for (int x = width - 1; x >= 0; x--) + { + if (inputData.contrast(x, y, minContrast)) + { + for (int theta = thetaAxisSize - 1; theta >= 0; theta--) + { + double r = cosTable[theta] * x + sinTable[theta] * y; + int rScaled = (int)Math.round(r * halfRAxisSize / maxRadius) + halfRAxisSize; + outputData.accumulate(theta, rScaled, 1); + } + } + } + } + return outputData; + } + + public static class ArrayData + { + public final int[] dataArray; + public final int width; + public final int height; + + public ArrayData(int width, int height) + { + this(new int[width * height], width, height); + } + + public ArrayData(int[] dataArray, int width, int height) + { + this.dataArray = dataArray; + this.width = width; + this.height = height; + } + + public int get(int x, int y) + { return dataArray[y * width + x]; } + + public void set(int x, int y, int value) + { dataArray[y * width + x] = value; } + + public void accumulate(int x, int y, int delta) + { set(x, y, get(x, y) + delta); } + + public boolean contrast(int x, int y, int minContrast) + { + int centerValue = get(x, y); + for (int i = 8; i >= 0; i--) + { + if (i == 4) + continue; + int newx = x + (i % 3) - 1; + int newy = y + (i / 3) - 1; + if ((newx < 0) || (newx >= width) || (newy < 0) || (newy >= height)) + continue; + if (Math.abs(get(newx, newy) - centerValue) >= minContrast) + return true; + } + return false; + } + + public int getMax() + { + int max = dataArray[0]; + for (int i = width * height - 1; i > 0; i--) + if (dataArray[i] > max) + max = dataArray[i]; + return max; + } + } + + public static ArrayData getArrayDataFromImage(String filename) throws IOException + { + BufferedImage inputImage = ImageIO.read(new File(filename)); + int width = inputImage.getWidth(); + int height = inputImage.getHeight(); + int[] rgbData = inputImage.getRGB(0, 0, width, height, null, 0, width); + ArrayData arrayData = new ArrayData(width, height); + // Flip y axis when reading image + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + int rgbValue = rgbData[y * width + x]; + rgbValue = (int)(((rgbValue & 0xFF0000) >>> 16) * 0.30 + ((rgbValue & 0xFF00) >>> 8) * 0.59 + (rgbValue & 0xFF) * 0.11); + arrayData.set(x, height - 1 - y, rgbValue); + } + } + return arrayData; + } + + public static void writeOutputImage(String filename, ArrayData arrayData) throws IOException + { + int max = arrayData.getMax(); + BufferedImage outputImage = new BufferedImage(arrayData.width, arrayData.height, BufferedImage.TYPE_INT_ARGB); + for (int y = 0; y < arrayData.height; y++) + { + for (int x = 0; x < arrayData.width; x++) + { + int n = Math.min((int)Math.round(arrayData.get(x, y) * 255.0 / max), 255); + outputImage.setRGB(x, arrayData.height - 1 - y, (n << 16) | (n << 8) | 0x90 | -0x01000000); + } + } + ImageIO.write(outputImage, "PNG", new File(filename)); + return; + } + + public static void main(String[] args) throws IOException + { + ArrayData inputData = getArrayDataFromImage(args[0]); + int minContrast = (args.length >= 4) ? 64 : Integer.parseInt(args[4]); + ArrayData outputData = houghTransform(inputData, Integer.parseInt(args[2]), Integer.parseInt(args[3]), minContrast); + writeOutputImage(args[1], outputData); + return; + } +} diff --git a/Task/Hough-transform/Mathematica/hough-transform.mathematica b/Task/Hough-transform/Mathematica/hough-transform.mathematica new file mode 100644 index 0000000000..3760742ccf --- /dev/null +++ b/Task/Hough-transform/Mathematica/hough-transform.mathematica @@ -0,0 +1 @@ +Radon[image, Method -> "Hough"] diff --git a/Task/Hough-transform/Python/hough-transform.py b/Task/Hough-transform/Python/hough-transform.py new file mode 100644 index 0000000000..4694375f45 --- /dev/null +++ b/Task/Hough-transform/Python/hough-transform.py @@ -0,0 +1,36 @@ +from math import hypot, pi, cos, sin +import Image + + +def hough(im, ntx=460, mry=360): + "Calculate Hough transform." + pim = im.load() + nimx, mimy = im.size + mry = int(mry/2)*2 #Make sure that this is even + him = Image.new("L", (ntx, mry), 255) + phim = him.load() + + rmax = hypot(nimx, mimy) + dr = rmax / (mry/2) + dth = pi / ntx + + for jx in xrange(nimx): + for iy in xrange(mimy): + col = pim[jx, iy] + if col == 255: continue + for jtx in xrange(ntx): + th = dth * jtx + r = jx*cos(th) + iy*sin(th) + iry = mry/2 + int(r/dr+0.5) + phim[jtx, iry] -= 1 + return him + + +def test(): + "Test Hough transform with pentagon." + im = Image.open("pentagon.png").convert("L") + him = hough(im) + him.save("ho5.bmp") + + +if __name__ == "__main__": test() diff --git a/Task/Hough-transform/Ruby/hough-transform.rb b/Task/Hough-transform/Ruby/hough-transform.rb new file mode 100644 index 0000000000..c29da7b54d --- /dev/null +++ b/Task/Hough-transform/Ruby/hough-transform.rb @@ -0,0 +1,34 @@ +require 'mathn' +require 'rubygems' +require 'gd2' +include GD2 + +def hough_transform(img) + mx, my = img.w*0.5, img.h*0.5 + max_d = Math.sqrt(mx**2 + my**2) + min_d = max_d * -1 + hough = Hash.new(0) + (0..img.w).each do |x| + puts "#{x} of #{img.w}" + (0..img.h).each do |y| + if img.pixel2color(img.get_pixel(x,y)).g > 32 + (0...180).each do |a| + rad = a * (Math::PI / 180.0) + d = (x-mx) * Math.cos(rad) + (y-my) * Math.sin(rad) + hough["#{a.to_i}_#{d.to_i}"] = hough["#{a.to_i}_#{d.to_i}"] + 1 + end + end + end + end + heat = GD2::Image.import 'heatmap.png' + out = GD2::Image::TrueColor.new(180,max_d*2) + max = hough.values.max + p max + hough.each_pair do |k,v| + a,d = k.split('_').map(&:to_i) + c = (v / max) * 255 + c = heat.get_pixel(c,0) + out.set_pixel(a, max_d + d, c) + end + out +end diff --git a/Task/Huffman-coding/0DESCRIPTION b/Task/Huffman-coding/0DESCRIPTION new file mode 100644 index 0000000000..000609ea64 --- /dev/null +++ b/Task/Huffman-coding/0DESCRIPTION @@ -0,0 +1,22 @@ +Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols. + +For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter with a fixed number of bits, such as in ASCII codes. You can do better than this by encoding more frequently occurring letters such as e and a, with smaller bit strings; and less frequently occurring letters such as q and x with longer bit strings. + +Any string of letters will be encoded as a string of bits that are no-longer of the same length per letter. To successfully decode such as string, the smaller codes assigned to letters such as 'e' cannot occur as a prefix in the larger codes such as that for 'x'. +:If you were to assign a code 01 for 'e' and code 011 for 'x', then if the bits to decode started as 011... then you would not know if you should decode an 'e' or an 'x'. + +The Huffman coding scheme takes each symbol and its weight (or frequency of occurrence), and generates proper encodings for each symbol taking account of the weights of each symbol, so that higher weighted symbols have fewer bits in their encoding. (See the [[wp:Huffman_coding|WP article]] for more information). + +A Huffman encoding can be computed by first creating a tree of nodes: + +[[Image:Huffman_coding_example.jpg|right|250px]] +# Create a leaf node for each symbol and add it to the [[priority queue]]. +# While there is more than one node in the queue: +## Remove the node of highest priority (lowest probability) twice to get two nodes. +## Create a new internal node with these two nodes as children and with probability equal to the sum of the two nodes' probabilities. +## Add the new node to the queue. +# The remaining node is the root node and the tree is complete. + +Traverse the constructed binary tree from root to leaves assigning and accumulating a '0' for one branch and a '1' for the other at each node. The accumulated zeros and ones at each leaf constitute a Huffman encoding for those symbols and weights: + +'''Using the characters and their frequency from the string ''"this is an example for huffman encoding"'', create a program to generate a Huffman encoding for each character as a table.''' diff --git a/Task/Huffman-coding/1META.yaml b/Task/Huffman-coding/1META.yaml new file mode 100644 index 0000000000..093819d0be --- /dev/null +++ b/Task/Huffman-coding/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Compression diff --git a/Task/Huffman-coding/Ada/huffman-coding-1.ada b/Task/Huffman-coding/Ada/huffman-coding-1.ada new file mode 100644 index 0000000000..73c99519aa --- /dev/null +++ b/Task/Huffman-coding/Ada/huffman-coding-1.ada @@ -0,0 +1,83 @@ +with Ada.Containers.Indefinite_Ordered_Maps; +with Ada.Containers.Ordered_Maps; +with Ada.Finalization; +generic + type Symbol_Type is private; + with function "<" (Left, Right : Symbol_Type) return Boolean is <>; + with procedure Put (Item : Symbol_Type); + type Symbol_Sequence is array (Positive range <>) of Symbol_Type; + type Frequency_Type is private; + with function "+" (Left, Right : Frequency_Type) return Frequency_Type + is <>; + with function "<" (Left, Right : Frequency_Type) return Boolean is <>; +package Huffman is + -- bits = booleans (true/false = 1/0) + type Bit_Sequence is array (Positive range <>) of Boolean; + Zero_Sequence : constant Bit_Sequence (1 .. 0) := (others => False); + -- output the sequence + procedure Put (Code : Bit_Sequence); + + -- type for freqency map + package Frequency_Maps is new Ada.Containers.Ordered_Maps + (Element_Type => Frequency_Type, + Key_Type => Symbol_Type); + + type Huffman_Tree is private; + -- create a huffman tree from frequency map + procedure Create_Tree + (Tree : out Huffman_Tree; + Frequencies : Frequency_Maps.Map); + -- encode a single symbol + function Encode + (Tree : Huffman_Tree; + Symbol : Symbol_Type) + return Bit_Sequence; + -- encode a symbol sequence + function Encode + (Tree : Huffman_Tree; + Symbols : Symbol_Sequence) + return Bit_Sequence; + -- decode a bit sequence + function Decode + (Tree : Huffman_Tree; + Code : Bit_Sequence) + return Symbol_Sequence; + -- dump the encoding table + procedure Dump_Encoding (Tree : Huffman_Tree); +private + -- type for encoding map + package Encoding_Maps is new Ada.Containers.Indefinite_Ordered_Maps + (Element_Type => Bit_Sequence, + Key_Type => Symbol_Type); + + type Huffman_Node; + type Node_Access is access Huffman_Node; + -- a node is either internal (left_child/right_child used) + -- or a leaf (left_child/right_child are null) + type Huffman_Node is record + Frequency : Frequency_Type; + Left_Child : Node_Access := null; + Right_Child : Node_Access := null; + Symbol : Symbol_Type; + end record; + -- create a leaf node + function Create_Node + (Symbol : Symbol_Type; + Frequency : Frequency_Type) + return Node_Access; + -- create an internal node + function Create_Node (Left, Right : Node_Access) return Node_Access; + -- fill the encoding map + procedure Fill + (The_Node : Node_Access; + Map : in out Encoding_Maps.Map; + Prefix : Bit_Sequence); + + -- huffman tree has a tree and an encoding map + type Huffman_Tree is new Ada.Finalization.Controlled with record + Tree : Node_Access := null; + Map : Encoding_Maps.Map := Encoding_Maps.Empty_Map; + end record; + -- free memory after finalization + overriding procedure Finalize (Object : in out Huffman_Tree); +end Huffman; diff --git a/Task/Huffman-coding/Ada/huffman-coding-2.ada b/Task/Huffman-coding/Ada/huffman-coding-2.ada new file mode 100644 index 0000000000..2d37898e41 --- /dev/null +++ b/Task/Huffman-coding/Ada/huffman-coding-2.ada @@ -0,0 +1,244 @@ +with Ada.Text_IO; +with Ada.Unchecked_Deallocation; +with Ada.Containers.Vectors; +package body Huffman is + package Node_Vectors is new Ada.Containers.Vectors + (Element_Type => Node_Access, + Index_Type => Positive); + + function "<" (Left, Right : Node_Access) return Boolean is + begin + -- compare frequency + if Left.Frequency < Right.Frequency then + return True; + elsif Right.Frequency < Left.Frequency then + return False; + end if; + -- same frequency, choose leaf node + if Left.Left_Child = null and then Right.Left_Child /= null then + return True; + elsif Left.Left_Child /= null and then Right.Left_Child = null then + return False; + end if; + -- same frequency, same node type (internal/leaf) + if Left.Left_Child /= null then + -- for internal nodes, compare left children, then right children + if Left.Left_Child < Right.Left_Child then + return True; + elsif Right.Left_Child < Left.Left_Child then + return False; + else + return Left.Right_Child < Right.Right_Child; + end if; + else + -- for leaf nodes, compare symbol + return Left.Symbol < Right.Symbol; + end if; + end "<"; + package Node_Vector_Sort is new Node_Vectors.Generic_Sorting; + + procedure Create_Tree + (Tree : out Huffman_Tree; + Frequencies : Frequency_Maps.Map) is + Node_Queue : Node_Vectors.Vector := Node_Vectors.Empty_Vector; + begin + -- insert all leafs into the queue + declare + use Frequency_Maps; + Position : Cursor := Frequencies.First; + The_Node : Node_Access := null; + begin + while Position /= No_Element loop + The_Node := + Create_Node + (Symbol => Key (Position), + Frequency => Element (Position)); + Node_Queue.Append (The_Node); + Next (Position); + end loop; + end; + -- sort by frequency (see "<") + Node_Vector_Sort.Sort (Node_Queue); + -- iterate over all elements + while not Node_Queue.Is_Empty loop + declare + First : constant Node_Access := Node_Queue.First_Element; + begin + Node_Queue.Delete_First; + -- if we only have one node left, it is the root node of the tree + if Node_Queue.Is_Empty then + Tree.Tree := First; + else + -- create new internal node with two smallest frequencies + declare + Second : constant Node_Access := Node_Queue.First_Element; + begin + Node_Queue.Delete_First; + Node_Queue.Append (Create_Node (First, Second)); + end; + Node_Vector_Sort.Sort (Node_Queue); + end if; + end; + end loop; + -- fill encoding map + Fill (The_Node => Tree.Tree, Map => Tree.Map, Prefix => Zero_Sequence); + end Create_Tree; + + -- create leaf node + function Create_Node + (Symbol : Symbol_Type; + Frequency : Frequency_Type) + return Node_Access + is + Result : Node_Access := new Huffman_Node; + begin + Result.Frequency := Frequency; + Result.Symbol := Symbol; + return Result; + end Create_Node; + + -- create internal node + function Create_Node (Left, Right : Node_Access) return Node_Access is + Result : Node_Access := new Huffman_Node; + begin + Result.Frequency := Left.Frequency + Right.Frequency; + Result.Left_Child := Left; + Result.Right_Child := Right; + return Result; + end Create_Node; + + -- fill encoding map + procedure Fill + (The_Node : Node_Access; + Map : in out Encoding_Maps.Map; + Prefix : Bit_Sequence) is + begin + if The_Node.Left_Child /= null then + -- append false (0) for left child + Fill (The_Node.Left_Child, Map, Prefix & False); + -- append true (1) for right child + Fill (The_Node.Right_Child, Map, Prefix & True); + else + -- leaf node reached, prefix = code for symbol + Map.Insert (The_Node.Symbol, Prefix); + end if; + end Fill; + + -- free memory after finalization + overriding procedure Finalize (Object : in out Huffman_Tree) is + procedure Free is new Ada.Unchecked_Deallocation + (Name => Node_Access, + Object => Huffman_Node); + -- recursively free all nodes + procedure Recursive_Free (The_Node : in out Node_Access) is + begin + -- free node if it is a leaf + if The_Node.Left_Child = null then + Free (The_Node); + else + -- free left and right child if node is internal + Recursive_Free (The_Node.Left_Child); + Recursive_Free (The_Node.Right_Child); + -- free node afterwards + Free (The_Node); + end if; + end Recursive_Free; + begin + -- recursively free root node + Recursive_Free (Object.Tree); + end Finalize; + + -- encode single symbol + function Encode + (Tree : Huffman_Tree; + Symbol : Symbol_Type) + return Bit_Sequence + is + begin + -- simply lookup in map + return Tree.Map.Element (Symbol); + end Encode; + + -- encode symbol sequence + function Encode + (Tree : Huffman_Tree; + Symbols : Symbol_Sequence) + return Bit_Sequence + is + begin + -- only one element + if Symbols'Length = 1 then + -- see above + return Encode (Tree, Symbols (Symbols'First)); + else + -- encode first element, append result of recursive call + return Encode (Tree, Symbols (Symbols'First)) & + Encode (Tree, Symbols (Symbols'First + 1 .. Symbols'Last)); + end if; + end Encode; + + -- decode a bit sequence + function Decode + (Tree : Huffman_Tree; + Code : Bit_Sequence) + return Symbol_Sequence + is + -- maximum length = code length + Result : Symbol_Sequence (1 .. Code'Length); + -- last used index of result + Last : Natural := 0; + The_Node : Node_Access := Tree.Tree; + begin + -- iterate over the code + for I in Code'Range loop + -- if current element is true, descent the right branch + if Code (I) then + The_Node := The_Node.Right_Child; + else + -- false: descend left branch + The_Node := The_Node.Left_Child; + end if; + if The_Node.Left_Child = null then + -- reached leaf node: append symbol to result + Last := Last + 1; + Result (Last) := The_Node.Symbol; + -- reset current node to root + The_Node := Tree.Tree; + end if; + end loop; + -- return subset of result array + return Result (1 .. Last); + end Decode; + + -- output a bit sequence + procedure Put (Code : Bit_Sequence) is + package Int_IO is new Ada.Text_IO.Integer_IO (Integer); + begin + for I in Code'Range loop + if Code (I) then + -- true = 1 + Int_IO.Put (1, 0); + else + -- false = 0 + Int_IO.Put (0, 0); + end if; + end loop; + Ada.Text_IO.New_Line; + end Put; + + -- dump encoding map + procedure Dump_Encoding (Tree : Huffman_Tree) is + use type Encoding_Maps.Cursor; + Position : Encoding_Maps.Cursor := Tree.Map.First; + begin + -- iterate map + while Position /= Encoding_Maps.No_Element loop + -- key + Put (Encoding_Maps.Key (Position)); + Ada.Text_IO.Put (" = "); + -- code + Put (Encoding_Maps.Element (Position)); + Encoding_Maps.Next (Position); + end loop; + end Dump_Encoding; +end Huffman; diff --git a/Task/Huffman-coding/Ada/huffman-coding-3.ada b/Task/Huffman-coding/Ada/huffman-coding-3.ada new file mode 100644 index 0000000000..417297bffa --- /dev/null +++ b/Task/Huffman-coding/Ada/huffman-coding-3.ada @@ -0,0 +1,49 @@ +with Ada.Text_IO; +with Huffman; +procedure Main is + package Char_Natural_Huffman_Tree is new Huffman + (Symbol_Type => Character, + Put => Ada.Text_IO.Put, + Symbol_Sequence => String, + Frequency_Type => Natural); + Tree : Char_Natural_Huffman_Tree.Huffman_Tree; + Frequencies : Char_Natural_Huffman_Tree.Frequency_Maps.Map; + Input_String : constant String := + "this is an example for huffman encoding"; +begin + -- build frequency map + for I in Input_String'Range loop + declare + use Char_Natural_Huffman_Tree.Frequency_Maps; + Position : constant Cursor := Frequencies.Find (Input_String (I)); + begin + if Position = No_Element then + Frequencies.Insert (Key => Input_String (I), New_Item => 1); + else + Frequencies.Replace_Element + (Position => Position, + New_Item => Element (Position) + 1); + end if; + end; + end loop; + + -- create huffman tree + Char_Natural_Huffman_Tree.Create_Tree + (Tree => Tree, + Frequencies => Frequencies); + + -- dump encodings + Char_Natural_Huffman_Tree.Dump_Encoding (Tree => Tree); + + -- encode example string + declare + Code : constant Char_Natural_Huffman_Tree.Bit_Sequence := + Char_Natural_Huffman_Tree.Encode + (Tree => Tree, + Symbols => Input_String); + begin + Char_Natural_Huffman_Tree.Put (Code); + Ada.Text_IO.Put_Line + (Char_Natural_Huffman_Tree.Decode (Tree => Tree, Code => Code)); + end; +end Main; diff --git a/Task/Huffman-coding/BBC-BASIC/huffman-coding.bbc b/Task/Huffman-coding/BBC-BASIC/huffman-coding.bbc new file mode 100644 index 0000000000..66b3753cbd --- /dev/null +++ b/Task/Huffman-coding/BBC-BASIC/huffman-coding.bbc @@ -0,0 +1,53 @@ + INSTALL @lib$+"SORTSALIB" + SortUp% = FN_sortSAinit(0,0) : REM Ascending + SortDn% = FN_sortSAinit(1,0) : REM Descending + + Text$ = "this is an example for huffman encoding" + + DIM tree{(127) ch&, num%, lkl%, lkr%} + FOR i% = 1 TO LEN(Text$) + c% = ASCMID$(Text$,i%) + tree{(c%)}.ch& = c% + tree{(c%)}.num% += 1 + NEXT + + C% = DIM(tree{()},1) + 1 + CALL SortDn%, tree{()}, tree{(0)}.num% + FOR i% = 0 TO DIM(tree{()},1) + IF tree{(i%)}.num% = 0 EXIT FOR + NEXT + size% = i% + + linked% = 0 + REPEAT + C% = size% + CALL SortUp%, tree{()}, tree{(0)}.num% + i% = 0 : WHILE tree{(i%)}.lkl% OR tree{(i%)}.lkr% i% += 1 : ENDWHILE + tree{(i%)}.lkl% = size% + j% = 0 : WHILE tree{(j%)}.lkl% OR tree{(j%)}.lkr% j% += 1 : ENDWHILE + tree{(j%)}.lkr% = size% + linked% += 2 + tree{(size%)}.num% = tree{(i%)}.num% + tree{(j%)}.num% + size% += 1 + UNTIL linked% = (size% - 1) + + FOR i% = size% - 1 TO 0 STEP -1 + IF tree{(i%)}.ch& THEN + h$ = "" + j% = i% + REPEAT + CASE TRUE OF + WHEN tree{(j%)}.lkl% <> 0: + h$ = "0" + h$ + j% = tree{(j%)}.lkl% + WHEN tree{(j%)}.lkr% <> 0: + h$ = "1" + h$ + j% = tree{(j%)}.lkr% + OTHERWISE: + EXIT REPEAT + ENDCASE + UNTIL FALSE + VDU tree{(i%)}.ch& : PRINT " " h$ + ENDIF + NEXT + END diff --git a/Task/Huffman-coding/C++/huffman-coding.cpp b/Task/Huffman-coding/C++/huffman-coding.cpp new file mode 100644 index 0000000000..9b5db3e65a --- /dev/null +++ b/Task/Huffman-coding/C++/huffman-coding.cpp @@ -0,0 +1,115 @@ +#include +#include +#include +#include // for CHAR_BIT +#include +#include + +const int UniqueSymbols = 1 << CHAR_BIT; +const char* SampleString = "this is an example for huffman encoding"; + +typedef std::vector HuffCode; +typedef std::map HuffCodeMap; + +class INode +{ +public: + const int f; + + virtual ~INode() {} + +protected: + INode(int f) : f(f) {} +}; + +class InternalNode : public INode +{ +public: + INode *const left; + INode *const right; + + InternalNode(INode* c0, INode* c1) : INode(c0->f + c1->f), left(c0), right(c1) {} + ~InternalNode() + { + delete left; + delete right; + } +}; + +class LeafNode : public INode +{ +public: + const char c; + + LeafNode(int f, char c) : INode(f), c(c) {} +}; + +struct NodeCmp +{ + bool operator()(const INode* lhs, const INode* rhs) const { return lhs->f > rhs->f; } +}; + +INode* BuildTree(const int (&frequencies)[UniqueSymbols]) +{ + std::priority_queue, NodeCmp> trees; + + for (int i = 0; i < UniqueSymbols; ++i) + { + if(frequencies[i] != 0) + trees.push(new LeafNode(frequencies[i], (char)i)); + } + while (trees.size() > 1) + { + INode* childR = trees.top(); + trees.pop(); + + INode* childL = trees.top(); + trees.pop(); + + INode* parent = new InternalNode(childR, childL); + trees.push(parent); + } + return trees.top(); +} + +void GenerateCodes(const INode* node, const HuffCode& prefix, HuffCodeMap& outCodes) +{ + if (const LeafNode* lf = dynamic_cast(node)) + { + outCodes[lf->c] = prefix; + } + else if (const InternalNode* in = dynamic_cast(node)) + { + HuffCode leftPrefix = prefix; + leftPrefix.push_back(false); + GenerateCodes(in->left, leftPrefix, outCodes); + + HuffCode rightPrefix = prefix; + rightPrefix.push_back(true); + GenerateCodes(in->right, rightPrefix, outCodes); + } +} + +int main() +{ + // Build frequency table + int frequencies[UniqueSymbols] = {0}; + const char* ptr = SampleString; + while (*ptr != '\0') + ++frequencies[*ptr++]; + + INode* root = BuildTree(frequencies); + + HuffCodeMap codes; + GenerateCodes(root, HuffCode(), codes); + delete root; + + for (HuffCodeMap::const_iterator it = codes.begin(); it != codes.end(); ++it) + { + std::cout << it->first << " "; + std::copy(it->second.begin(), it->second.end(), + std::ostream_iterator(std::cout)); + std::cout << std::endl; + } + return 0; +} diff --git a/Task/Huffman-coding/C-sharp/huffman-coding.cs b/Task/Huffman-coding/C-sharp/huffman-coding.cs new file mode 100644 index 0000000000..fe1b5aa6c5 --- /dev/null +++ b/Task/Huffman-coding/C-sharp/huffman-coding.cs @@ -0,0 +1,314 @@ +using System; +using System.Collections.Generic; + +namespace Huffman_Encoding +{ + public class PriorityQueue where T : IComparable + { + protected List LstHeap = new List(); + + public virtual int Count + { + get { return LstHeap.Count; } + } + + public virtual void Add(T val) + { + LstHeap.Add(val); + SetAt(LstHeap.Count - 1, val); + UpHeap(LstHeap.Count - 1); + } + + public virtual T Peek() + { + if (LstHeap.Count == 0) + { + throw new IndexOutOfRangeException("Peeking at an empty priority queue"); + } + + return LstHeap[0]; + } + + public virtual T Pop() + { + if (LstHeap.Count == 0) + { + throw new IndexOutOfRangeException("Popping an empty priority queue"); + } + + T valRet = LstHeap[0]; + + SetAt(0, LstHeap[LstHeap.Count - 1]); + LstHeap.RemoveAt(LstHeap.Count - 1); + DownHeap(0); + return valRet; + } + + protected virtual void SetAt(int i, T val) + { + LstHeap[i] = val; + } + + protected bool RightSonExists(int i) + { + return RightChildIndex(i) < LstHeap.Count; + } + + protected bool LeftSonExists(int i) + { + return LeftChildIndex(i) < LstHeap.Count; + } + + protected int ParentIndex(int i) + { + return (i - 1) / 2; + } + + protected int LeftChildIndex(int i) + { + return 2 * i + 1; + } + + protected int RightChildIndex(int i) + { + return 2 * (i + 1); + } + + protected T ArrayVal(int i) + { + return LstHeap[i]; + } + + protected T Parent(int i) + { + return LstHeap[ParentIndex(i)]; + } + + protected T Left(int i) + { + return LstHeap[LeftChildIndex(i)]; + } + + protected T Right(int i) + { + return LstHeap[RightChildIndex(i)]; + } + + protected void Swap(int i, int j) + { + T valHold = ArrayVal(i); + SetAt(i, LstHeap[j]); + SetAt(j, valHold); + } + + protected void UpHeap(int i) + { + while (i > 0 && ArrayVal(i).CompareTo(Parent(i)) > 0) + { + Swap(i, ParentIndex(i)); + i = ParentIndex(i); + } + } + + protected void DownHeap(int i) + { + while (i >= 0) + { + int iContinue = -1; + + if (RightSonExists(i) && Right(i).CompareTo(ArrayVal(i)) > 0) + { + iContinue = Left(i).CompareTo(Right(i)) < 0 ? RightChildIndex(i) : LeftChildIndex(i); + } + else if (LeftSonExists(i) && Left(i).CompareTo(ArrayVal(i)) > 0) + { + iContinue = LeftChildIndex(i); + } + + if (iContinue >= 0 && iContinue < LstHeap.Count) + { + Swap(i, iContinue); + } + + i = iContinue; + } + } + } + + internal class HuffmanNode : IComparable + { + internal HuffmanNode(double probability, T value) + { + Probability = probability; + LeftSon = RightSon = Parent = null; + Value = value; + IsLeaf = true; + } + + internal HuffmanNode(HuffmanNode leftSon, HuffmanNode rightSon) + { + LeftSon = leftSon; + RightSon = rightSon; + Probability = leftSon.Probability + rightSon.Probability; + leftSon.IsZero = true; + rightSon.IsZero = false; + leftSon.Parent = rightSon.Parent = this; + IsLeaf = false; + } + + internal HuffmanNode LeftSon { get; set; } + internal HuffmanNode RightSon { get; set; } + internal HuffmanNode Parent { get; set; } + internal T Value { get; set; } + internal bool IsLeaf { get; set; } + + internal bool IsZero { get; set; } + + internal int Bit + { + get { return IsZero ? 0 : 1; } + } + + internal bool IsRoot + { + get { return Parent == null; } + } + + internal double Probability { get; set; } + + public int CompareTo(object obj) + { + return -Probability.CompareTo(((HuffmanNode) obj).Probability); + } + } + + public class Huffman where T : IComparable + { + private readonly Dictionary> _leafDictionary = new Dictionary>(); + private readonly HuffmanNode _root; + + public Huffman(IEnumerable values) + { + var counts = new Dictionary(); + var priorityQueue = new PriorityQueue>(); + int valueCount = 0; + + foreach (T value in values) + { + if (!counts.ContainsKey(value)) + { + counts[value] = 0; + } + counts[value]++; + valueCount++; + } + + foreach (T value in counts.Keys) + { + var node = new HuffmanNode((double) counts[value] / valueCount, value); + priorityQueue.Add(node); + _leafDictionary[value] = node; + } + + while (priorityQueue.Count > 1) + { + HuffmanNode leftSon = priorityQueue.Pop(); + HuffmanNode rightSon = priorityQueue.Pop(); + var parent = new HuffmanNode(leftSon, rightSon); + priorityQueue.Add(parent); + } + + _root = priorityQueue.Pop(); + _root.IsZero = false; + } + + public List Encode(T value) + { + var returnValue = new List(); + Encode(value, returnValue); + return returnValue; + } + + public void Encode(T value, List encoding) + { + if (!_leafDictionary.ContainsKey(value)) + { + throw new ArgumentException("Invalid value in Encode"); + } + HuffmanNode nodeCur = _leafDictionary[value]; + var reverseEncoding = new List(); + while (!nodeCur.IsRoot) + { + reverseEncoding.Add(nodeCur.Bit); + nodeCur = nodeCur.Parent; + } + + reverseEncoding.Reverse(); + encoding.AddRange(reverseEncoding); + } + + public List Encode(IEnumerable values) + { + var returnValue = new List(); + + foreach (T value in values) + { + Encode(value, returnValue); + } + return returnValue; + } + + public T Decode(List bitString, ref int position) + { + HuffmanNode nodeCur = _root; + while (!nodeCur.IsLeaf) + { + if (position > bitString.Count) + { + throw new ArgumentException("Invalid bitstring in Decode"); + } + nodeCur = bitString[position++] == 0 ? nodeCur.LeftSon : nodeCur.RightSon; + } + return nodeCur.Value; + } + + public List Decode(List bitString) + { + int position = 0; + var returnValue = new List(); + + while (position != bitString.Count) + { + returnValue.Add(Decode(bitString, ref position)); + } + return returnValue; + } + } + + internal class Program + { + private const string Example = "this is an example for huffman encoding"; + + private static void Main() + { + var huffman = new Huffman(Example); + List encoding = huffman.Encode(Example); + List decoding = huffman.Decode(encoding); + var outString = new string(decoding.ToArray()); + Console.WriteLine(outString == Example ? "Encoding/decoding worked" : "Encoding/Decoding failed"); + + var chars = new HashSet(Example); + foreach (char c in chars) + { + encoding = huffman.Encode(c); + Console.Write("{0}: ", c); + foreach (int bit in encoding) + { + Console.Write("{0}", bit); + } + Console.WriteLine(); + } + Console.ReadKey(); + } + } +} diff --git a/Task/Huffman-coding/C/huffman-coding-1.c b/Task/Huffman-coding/C/huffman-coding-1.c new file mode 100644 index 0000000000..593edc522d --- /dev/null +++ b/Task/Huffman-coding/C/huffman-coding-1.c @@ -0,0 +1,174 @@ +#include +#include +#include + +#define BYTES 256 + +struct huffcode { + int nbits; + int code; +}; +typedef struct huffcode huffcode_t; + +struct huffheap { + int *h; + int n, s, cs; + long *f; +}; +typedef struct huffheap heap_t; + +/* heap handling funcs */ +static heap_t *_heap_create(int s, long *f) +{ + heap_t *h; + h = malloc(sizeof(heap_t)); + h->h = malloc(sizeof(int)*s); + h->s = h->cs = s; + h->n = 0; + h->f = f; + return h; +} + +static void _heap_destroy(heap_t *heap) +{ + free(heap->h); + free(heap); +} + +#define swap_(I,J) do { int t_; t_ = a[(I)]; \ + a[(I)] = a[(J)]; a[(J)] = t_; } while(0) +static void _heap_sort(heap_t *heap) +{ + int i=1, j=2; /* gnome sort */ + int *a = heap->h; + + while(i < heap->n) { /* smaller values are kept at the end */ + if ( heap->f[a[i-1]] >= heap->f[a[i]] ) { + i = j; j++; + } else { + swap_(i-1, i); + i--; + i = (i==0) ? j++ : i; + } + } +} +#undef swap_ + +static void _heap_add(heap_t *heap, int c) +{ + if ( (heap->n + 1) > heap->s ) { + heap->h = realloc(heap->h, heap->s + heap->cs); + heap->s += heap->cs; + } + heap->h[heap->n] = c; + heap->n++; + _heap_sort(heap); +} + +static int _heap_remove(heap_t *heap) +{ + if ( heap->n > 0 ) { + heap->n--; + return heap->h[heap->n]; + } + return -1; +} + +/* huffmann code generator */ +huffcode_t **create_huffman_codes(long *freqs) +{ + huffcode_t **codes; + heap_t *heap; + long efreqs[BYTES*2]; + int preds[BYTES*2]; + int i, extf=BYTES; + int r1, r2; + + memcpy(efreqs, freqs, sizeof(long)*BYTES); + memset(&efreqs[BYTES], 0, sizeof(long)*BYTES); + + heap = _heap_create(BYTES*2, efreqs); + if ( heap == NULL ) return NULL; + + for(i=0; i < BYTES; i++) if ( efreqs[i] > 0 ) _heap_add(heap, i); + + while( heap->n > 1 ) + { + r1 = _heap_remove(heap); + r2 = _heap_remove(heap); + efreqs[extf] = efreqs[r1] + efreqs[r2]; + _heap_add(heap, extf); + preds[r1] = extf; + preds[r2] = -extf; + extf++; + } + r1 = _heap_remove(heap); + preds[r1] = r1; + _heap_destroy(heap); + + codes = malloc(sizeof(huffcode_t *)*BYTES); + + int bc, bn, ix; + for(i=0; i < BYTES; i++) { + bc=0; bn=0; + if ( efreqs[i] == 0 ) { codes[i] = NULL; continue; } + ix = i; + while( abs(preds[ix]) != ix ) { + bc |= ((preds[ix] >= 0) ? 1 : 0 ) << bn; + ix = abs(preds[ix]); + bn++; + } + codes[i] = malloc(sizeof(huffcode_t)); + codes[i]->nbits = bn; + codes[i]->code = bc; + } + return codes; +} + +void free_huffman_codes(huffcode_t **c) +{ + int i; + + for(i=0; i < BYTES; i++) free(c[i]); + free(c); +} + +#define MAXBITSPERCODE 100 + +void inttobits(int c, int n, char *s) +{ + s[n] = 0; + while(n > 0) { + s[n-1] = (c%2) + '0'; + c >>= 1; n--; + } +} + +const char *test = "this is an example for huffman encoding"; + +int main() +{ + huffcode_t **r; + int i; + char strbit[MAXBITSPERCODE]; + const char *p; + long freqs[BYTES]; + + memset(freqs, 0, sizeof freqs); + + p = test; + while(*p != '\0') freqs[*p++]++; + + r = create_huffman_codes(freqs); + + for(i=0; i < BYTES; i++) { + if ( r[i] != NULL ) { + inttobits(r[i]->code, r[i]->nbits, strbit); + printf("%c (%d) %s\n", i, r[i]->code, strbit); + } + } + + free_huffman_codes(r); + + return 0; +} diff --git a/Task/Huffman-coding/C/huffman-coding-2.c b/Task/Huffman-coding/C/huffman-coding-2.c new file mode 100644 index 0000000000..9c33cacbdc --- /dev/null +++ b/Task/Huffman-coding/C/huffman-coding-2.c @@ -0,0 +1,122 @@ +#include +#include + +typedef struct node_t { + struct node_t *left, *right; + int freq; + char c; +} *node; + +struct node_t pool[256] = {{0}}; +node qqq[255], *q = qqq - 1; +int n_nodes = 0, qend = 1; +char *code[128] = {0}, buf[1024]; + +node new_node(int freq, char c, node a, node b) +{ + node n = pool + n_nodes++; + if (freq) n->c = c, n->freq = freq; + else { + n->left = a, n->right = b; + n->freq = a->freq + b->freq; + } + return n; +} + +/* priority queue */ +void qinsert(node n) +{ + int j, i = qend++; + while ((j = i / 2)) { + if (q[j]->freq <= n->freq) break; + q[i] = q[j], i = j; + } + q[i] = n; +} + +node qremove() +{ + int i, l; + node n = q[i = 1]; + + if (qend < 2) return 0; + qend--; + while ((l = i * 2) < qend) { + if (l + 1 < qend && q[l + 1]->freq < q[l]->freq) l++; + q[i] = q[l], i = l; + } + q[i] = q[qend]; + return n; +} + +/* walk the tree and put 0s and 1s */ +void build_code(node n, char *s, int len) +{ + static char *out = buf; + if (n->c) { + s[len] = 0; + strcpy(out, s); + code[n->c] = out; + out += len + 1; + return; + } + + s[len] = '0'; build_code(n->left, s, len + 1); + s[len] = '1'; build_code(n->right, s, len + 1); +} + +void init(const char *s) +{ + int i, freq[128] = {0}; + char c[16]; + + while (*s) freq[(int)*s++]++; + + for (i = 0; i < 128; i++) + if (freq[i]) qinsert(new_node(freq[i], i, 0, 0)); + + while (qend > 2) + qinsert(new_node(0, 0, qremove(), qremove())); + + build_code(q[1], c, 0); +} + +void encode(const char *s, char *out) +{ + while (*s) { + strcpy(out, code[*s]); + out += strlen(code[*s++]); + } +} + +void decode(const char *s, node t) +{ + node n = t; + while (*s) { + if (*s++ == '0') n = n->left; + else n = n->right; + + if (n->c) putchar(n->c), n = t; + } + + putchar('\n'); + if (t != n) printf("garbage input\n"); +} + +int main(void) +{ + int i; + const char *str = "this is an example for huffman encoding", buf[1024]; + + init(str); + for (i = 0; i < 128; i++) + if (code[i]) printf("'%c': %s\n", i, code[i]); + + encode(str, buf); + printf("encoded: %s\n", buf); + + printf("decoded: "); + decode(buf, q[1]); + + return 0; +} diff --git a/Task/Huffman-coding/C/huffman-coding-3.c b/Task/Huffman-coding/C/huffman-coding-3.c new file mode 100644 index 0000000000..1e18cd3110 --- /dev/null +++ b/Task/Huffman-coding/C/huffman-coding-3.c @@ -0,0 +1,21 @@ +' ': 000 +'a': 1000 +'c': 01101 +'d': 01100 +'e': 0101 +'f': 0010 +'g': 010000 +'h': 1101 +'i': 0011 +'l': 010001 +'m': 1111 +'n': 101 +'o': 1110 +'p': 10011 +'r': 10010 +'s': 1100 +'t': 01111 +'u': 01110 +'x': 01001 +encoded: 0111111010011110000000111100000100010100001010100110001111100110100010101000001011101001000011010111000100010111110001010000101101011011110011000011101010000 +decoded: this is an example for huffman encoding diff --git a/Task/Huffman-coding/Clojure/huffman-coding.clj b/Task/Huffman-coding/Clojure/huffman-coding.clj new file mode 100644 index 0000000000..eb31106fb9 --- /dev/null +++ b/Task/Huffman-coding/Clojure/huffman-coding.clj @@ -0,0 +1,36 @@ +(use 'clojure.contrib.seq-utils) + +(defn probs [items] + (let [freqs (frequencies items) sum (reduce + (vals freqs))] + (into {} (map (fn [[k v]] [k (/ v sum)]) freqs)))) + +(defn init-pq [weighted-items] + (let [comp (proxy [java.util.Comparator] [] + (compare [a b] (compare (:priority a) (:priority b)))) + pq (java.util.PriorityQueue. (count weighted-items) comp)] + (doseq [[item prob] weighted-items] (.add pq { :symbol item, :priority prob })) + pq)) + +(defn huffman-tree [pq] + (while (> (.size pq) 1) + (let [a (.poll pq) b (.poll pq) new-node { :priority (+ (:priority a) (:priority b)), :left a, :right b }] + (.add pq new-node))) + (.poll pq)) + +(defn symbol-map + ([t] (into {} (symbol-map t []))) + ([{:keys [symbol,left,right] :as t} code] + (if symbol [[symbol code]] + (concat (symbol-map left (conj code 0)) + (symbol-map right (conj code 1)))))) + +(defn huffman-encode [items] + (-> items probs init-pq huffman-tree symbol-map)) + +(defn display-huffman-encode [s] + (println "SYMBOL\tWEIGHT\tHUFFMAN CODE") + (let [probs (probs (seq s))] + (doseq [[char code] (huffman-encode (seq s))] + (printf "%s:\t\t%s\t\t%s\n" char (probs char) (apply str code))))) + +(display-huffman-encode "this is an example for huffman encoding") diff --git a/Task/Huffman-coding/CoffeeScript/huffman-coding-1.coffee b/Task/Huffman-coding/CoffeeScript/huffman-coding-1.coffee new file mode 100644 index 0000000000..d8ebaa3963 --- /dev/null +++ b/Task/Huffman-coding/CoffeeScript/huffman-coding-1.coffee @@ -0,0 +1,85 @@ +huffman_encoding_table = (counts) -> + # counts is a hash where keys are characters and + # values are frequencies; + # return a hash where keys are codes and values + # are characters + + build_huffman_tree = -> + # returns a Huffman tree. Each node has + # cnt: total frequency of all chars in subtree + # c: character to be encoded (leafs only) + # children: children nodes (branches only) + q = min_queue() + for c, cnt of counts + q.enqueue cnt, + cnt: cnt + c: c + while q.size() >= 2 + a = q.dequeue() + b = q.dequeue() + cnt = a.cnt + b.cnt + node = + cnt: cnt + children: [a, b] + q.enqueue cnt, node + root = q.dequeue() + + root = build_huffman_tree() + + codes = {} + encode = (node, code) -> + if node.c? + codes[code] = node.c + else + encode node.children[0], code + "0" + encode node.children[1], code + "1" + + encode(root, "") + codes + +min_queue = -> + # This is very non-optimized; you could use a binary heap for better + # performance. Items with smaller priority get dequeued first. + arr = [] + enqueue: (priority, data) -> + i = 0 + while i < arr.length + if priority < arr[i].priority + break + i += 1 + arr.splice i, 0, + priority: priority + data: data + dequeue: -> + arr.shift().data + size: -> arr.length + _internal: -> + arr + +freq_count = (s) -> + cnts = {} + for c in s + cnts[c] ?= 0 + cnts[c] += 1 + cnts + +rpad = (s, n) -> + while s.length < n + s += ' ' + s + +examples = [ + "this is an example for huffman encoding" + "abcd" + "abbccccddddddddeeeeeeeee" +] + +for s in examples + console.log "---- #{s}" + counts = freq_count(s) + huffman_table = huffman_encoding_table(counts) + codes = (code for code of huffman_table).sort() + for code in codes + c = huffman_table[code] + console.log "#{rpad(code, 5)}: #{c} (#{counts[c]})" + console.log() diff --git a/Task/Huffman-coding/CoffeeScript/huffman-coding-2.coffee b/Task/Huffman-coding/CoffeeScript/huffman-coding-2.coffee new file mode 100644 index 0000000000..ba94c69a9e --- /dev/null +++ b/Task/Huffman-coding/CoffeeScript/huffman-coding-2.coffee @@ -0,0 +1,34 @@ +> coffee huffman.coffee +---- this is an example for huffman encoding +000 : n (4) +0010 : s (2) +0011 : m (2) +0100 : o (2) +01010: t (1) +01011: x (1) +01100: p (1) +01101: l (1) +01110: r (1) +01111: u (1) +10000: c (1) +10001: d (1) +1001 : i (3) +101 : (6) +1100 : a (3) +1101 : e (3) +1110 : f (3) +11110: g (1) +11111: h (2) + +---- abcd +00 : a (1) +01 : b (1) +10 : c (1) +11 : d (1) + +---- abbccccddddddddeeeeeeeee +0 : e (9) +1000 : a (1) +1001 : b (2) +101 : c (4) +11 : d (8) diff --git a/Task/Huffman-coding/Common-Lisp/huffman-coding.lisp b/Task/Huffman-coding/Common-Lisp/huffman-coding.lisp new file mode 100644 index 0000000000..05f577bbaf --- /dev/null +++ b/Task/Huffman-coding/Common-Lisp/huffman-coding.lisp @@ -0,0 +1,59 @@ +(defstruct huffman-node + (weight 0 :type number) + (element nil :type t) + (encoding nil :type (or null bit-vector)) + (left nil :type (or null huffman-node)) + (right nil :type (or null huffman-node))) + +(defun initial-huffman-nodes (sequence &key (test 'eql)) + (let* ((length (length sequence)) + (increment (/ 1 length)) + (nodes (make-hash-table :size length :test test)) + (queue '())) + (map nil #'(lambda (element) + (multiple-value-bind (node presentp) (gethash element nodes) + (if presentp + (incf (huffman-node-weight node) increment) + (let ((node (make-huffman-node :weight increment + :element element))) + (setf (gethash element nodes) node + queue (list* node queue)))))) + sequence) + (values nodes (sort queue '< :key 'huffman-node-weight)))) + +(defun huffman-tree (sequence &key (test 'eql)) + (multiple-value-bind (nodes queue) + (initial-huffman-nodes sequence :test test) + (do () ((endp (rest queue)) (values nodes (first queue))) + (destructuring-bind (n1 n2 &rest queue-rest) queue + (let ((n3 (make-huffman-node + :left n1 + :right n2 + :weight (+ (huffman-node-weight n1) + (huffman-node-weight n2))))) + (setf queue (merge 'list (list n3) queue-rest '< + :key 'huffman-node-weight)))))))1 + +(defun huffman-codes (sequence &key (test 'eql)) + (multiple-value-bind (nodes tree) + (huffman-tree sequence :test test) + (labels ((hc (node length bits) + (let ((left (huffman-node-left node)) + (right (huffman-node-right node))) + (cond + ((and (null left) (null right)) + (setf (huffman-node-encoding node) + (make-array length :element-type 'bit + :initial-contents (reverse bits)))) + (t (hc left (1+ length) (list* 0 bits)) + (hc right (1+ length) (list* 1 bits))))))) + (hc tree 0 '()) + nodes))) + +(defun print-huffman-code-table (nodes &optional (out *standard-output*)) + (format out "~&Element~10tWeight~20tCode") + (loop for node being each hash-value of nodes + do (format out "~&~s~10t~s~20t~s" + (huffman-node-element node) + (huffman-node-weight node) + (huffman-node-encoding node)))) diff --git a/Task/Huffman-coding/D/huffman-coding.d b/Task/Huffman-coding/D/huffman-coding.d new file mode 100644 index 0000000000..c9067702f5 --- /dev/null +++ b/Task/Huffman-coding/D/huffman-coding.d @@ -0,0 +1,21 @@ +import std.stdio, std.algorithm, std.typecons, std.container,std.array; + +auto encode(T)(Group!("a == b", T[]) sf) { + auto heap = sf.map!(s => tuple(s[1], [tuple(s[0], "")])) + .array.heapify!q{b < a}; + + while (heap.length > 1) { + auto lo = heap.front; heap.removeFront; + auto hi = heap.front; heap.removeFront; + foreach (ref pair; lo[1]) pair[1] = '0' ~ pair[1]; + foreach (ref pair; hi[1]) pair[1] = '1' ~ pair[1]; + heap.insert(tuple(lo[0] + hi[0], lo[1] ~ hi[1])); + } + return heap.front[1].schwartzSort!q{tuple(a[1].length, a[0])}; +} + +void main() { + auto s = "this is an example for huffman encoding"d; + foreach (p; s.dup.sort().release.group.encode) + writefln("'%s' %s", p[]); +} diff --git a/Task/Huffman-coding/Fantom/huffman-coding.fantom b/Task/Huffman-coding/Fantom/huffman-coding.fantom new file mode 100644 index 0000000000..6dafb80572 --- /dev/null +++ b/Task/Huffman-coding/Fantom/huffman-coding.fantom @@ -0,0 +1,97 @@ +class Node +{ + Float probability := 0.0f +} + +class Leaf : Node +{ + Int character + + new make (Int character, Float probability) + { + this.character = character + this.probability = probability + } +} + +class Branch : Node +{ + Node left + Node right + + new make (Node left, Node right) + { + this.left = left + this.right = right + probability = this.left.probability + this.right.probability + } +} + +class Huffman +{ + Node[] queue := [,] + Str:Str table := [:] + + new make (Int[] items) + { + uniqueItems := items.dup.unique + uniqueItems.each |Int item| + { + num := items.findAll { it == item }.size + queue.add (Leaf(item, num.toFloat / items.size)) + } + createTree + createTable + } + + Void createTree () + { + while (queue.size > 1) + { + queue.sort |a,b| {a.probability <=> b.probability} + node1 := queue.removeAt (0) + node2 := queue.removeAt (0) + queue.add (Branch (node1, node2)) + } + } + + Void traverse (Node node, Str encoding) + { + if (node is Leaf) + { + table[(node as Leaf).character.toChar] = encoding + } + else // (node is Branch) + { + traverse ((node as Branch).left, encoding + "0") + traverse ((node as Branch).right, encoding + "1") + } + } + + Void createTable () + { + if (queue.size != 1) return // error! + traverse (queue.first, "") + } + + override Str toStr () + { + result := "Huffman Encoding Table:\n" + table.keys.sort.each |Str key| + { + result += "$key -> ${table[key]}\n" + } + return result + } +} + +class Main +{ + public static Void main () + { + example := "this is an example for huffman encoding" + huffman := Huffman (example.chars) + echo ("From \"$example\"") + echo (huffman) + } +} diff --git a/Task/Huffman-coding/Go/huffman-coding-1.go b/Task/Huffman-coding/Go/huffman-coding-1.go new file mode 100644 index 0000000000..5d69d81fbe --- /dev/null +++ b/Task/Huffman-coding/Go/huffman-coding-1.go @@ -0,0 +1,97 @@ +package main + +import ( + "container/heap" + "fmt" +) + +type HuffmanTree interface { + Freq() int +} + +type HuffmanLeaf struct { + freq int + value rune +} + +type HuffmanNode struct { + freq int + left, right HuffmanTree +} + +func (self HuffmanLeaf) Freq() int { + return self.freq +} + +func (self HuffmanNode) Freq() int { + return self.freq +} + +type treeHeap []HuffmanTree + +func (th treeHeap) Len() int { return len(th) } +func (th treeHeap) Less(i, j int) bool { + return th[i].Freq() < th[j].Freq() +} +func (th *treeHeap) Push(ele interface{}) { + *th = append(*th, ele.(HuffmanTree)) +} +func (th *treeHeap) Pop() (popped interface{}) { + popped = (*th)[len(*th)-1] + *th = (*th)[:len(*th)-1] + return +} +func (th treeHeap) Swap(i, j int) { th[i], th[j] = th[j], th[i] } + +func buildTree(symFreqs map[rune]int) HuffmanTree { + var trees treeHeap + for c, f := range symFreqs { + trees = append(trees, HuffmanLeaf{f, c}) + } + heap.Init(&trees) + for trees.Len() > 1 { + // two trees with least frequency + a := heap.Pop(&trees).(HuffmanTree) + b := heap.Pop(&trees).(HuffmanTree) + + // put into new node and re-insert into queue + heap.Push(&trees, HuffmanNode{a.Freq() + b.Freq(), a, b}) + } + return heap.Pop(&trees).(HuffmanTree) +} + +func printCodes(tree HuffmanTree, prefix []byte) { + switch i := tree.(type) { + case HuffmanLeaf: + // print out symbol, frequency, and code for this + // leaf (which is just the prefix) + fmt.Printf("%c\t%d\t%s\n", i.value, i.freq, string(prefix)) + case HuffmanNode: + // traverse left + prefix = append(prefix, '0') + printCodes(i.left, prefix) + prefix = prefix[:len(prefix)-1] + + // traverse right + prefix = append(prefix, '1') + printCodes(i.right, prefix) + prefix = prefix[:len(prefix)-1] + } +} + +func main() { + test := "this is an example for huffman encoding" + + symFreqs := make(map[rune]int) + // read each symbol and record the frequencies + for _, c := range test { + symFreqs[c]++ + } + + // build tree + tree := buildTree(symFreqs) + + // print out results + fmt.Println("SYMBOL\tWEIGHT\tHUFFMAN CODE") + printCodes(tree, []byte{}) +} diff --git a/Task/Huffman-coding/Go/huffman-coding-2.go b/Task/Huffman-coding/Go/huffman-coding-2.go new file mode 100644 index 0000000000..74a00a80e7 --- /dev/null +++ b/Task/Huffman-coding/Go/huffman-coding-2.go @@ -0,0 +1,65 @@ +package main + +import ( + "container/heap" + "fmt" +) + +type coded struct { + sym rune + code string +} + +type counted struct { + total int + syms []coded +} + +type cHeap []counted + +// satisfy heap.Interface +func (c cHeap) Len() int { return len(c) } +func (c cHeap) Less(i, j int) bool { return c[i].total < c[j].total } +func (c cHeap) Swap(i, j int) { c[i], c[j] = c[j], c[i] } +func (c *cHeap) Push(ele interface{}) { + *c = append(*c, ele.(counted)) +} +func (c *cHeap) Pop() (popped interface{}) { + popped = (*c)[len(*c)-1] + *c = (*c)[:len(*c)-1] + return +} + +func encode(sym2freq map[rune]int) []coded { + var ch cHeap + for sym, freq := range sym2freq { + ch = append(ch, counted{freq, []coded{{sym: sym}}}) + } + heap.Init(&ch) + for len(ch) > 1 { + a := heap.Pop(&ch).(counted) + b := heap.Pop(&ch).(counted) + for i, c := range a.syms { + a.syms[i].code = "0" + c.code + } + for i, c := range b.syms { + b.syms[i].code = "1" + c.code + } + heap.Push(&ch, counted{a.total + b.total, append(a.syms, b.syms...)}) + } + return heap.Pop(&ch).(counted).syms +} + +const txt = "this is an example for huffman encoding" + +func main() { + sym2freq := make(map[rune]int) + for _, c := range txt { + sym2freq[c]++ + } + table := encode(sym2freq) + fmt.Println("Symbol Weight Huffman Code") + for _, c := range table { + fmt.Printf(" %c %d %s\n", c.sym, sym2freq[c.sym], c.code) + } +} diff --git a/Task/Huffman-coding/Haskell/huffman-coding-1.hs b/Task/Huffman-coding/Haskell/huffman-coding-1.hs new file mode 100644 index 0000000000..95cedb08dd --- /dev/null +++ b/Task/Huffman-coding/Haskell/huffman-coding-1.hs @@ -0,0 +1,24 @@ +import Data.List +import Control.Arrow +import Data.Ord + +data HTree a = Leaf a | Branch (HTree a) (HTree a) + deriving (Show, Eq, Ord) + +test :: String -> IO () +test s = mapM_ (\(a,b)-> putStrLn ('\'' : a : "\' : " ++ b)) + . serialize . huffmanTree . freq $ s + +serialize :: HTree a -> [(a, String)] +serialize (Branch l r) = map (second('0':)) (serialize l) ++ map (second('1':)) (serialize r) +serialize (Leaf x) = [(x, "")] + +huffmanTree :: (Ord w, Num w) => [(w, a)] -> HTree a +huffmanTree = snd . head . until (null.tail) hstep + . sortBy (comparing fst) . map (second Leaf) + +hstep :: (Ord a, Num a) => [(a, HTree b)] -> [(a, HTree b)] +hstep ((w1,t1):(w2,t2):wts) = insertBy (comparing fst) (w1 + w2, Branch t1 t2) wts + +freq :: Ord a => [a] -> [(Int, a)] +freq = map (length &&& head) . group . sort diff --git a/Task/Huffman-coding/Haskell/huffman-coding-2.hs b/Task/Huffman-coding/Haskell/huffman-coding-2.hs new file mode 100644 index 0000000000..8bfa01be65 --- /dev/null +++ b/Task/Huffman-coding/Haskell/huffman-coding-2.hs @@ -0,0 +1,20 @@ +*Main> test "this is an example for huffman encoding" +'p' : 00000 +'r' : 00001 +'g' : 00010 +'l' : 00011 +'n' : 001 +'m' : 0100 +'o' : 0101 +'c' : 01100 +'d' : 01101 +'h' : 0111 +'s' : 1000 +'x' : 10010 +'t' : 100110 +'u' : 100111 +'f' : 1010 +'i' : 1011 +'a' : 1100 +'e' : 1101 +' ' : 111 diff --git a/Task/Huffman-coding/Haskell/huffman-coding-3.hs b/Task/Huffman-coding/Haskell/huffman-coding-3.hs new file mode 100644 index 0000000000..6f79891807 --- /dev/null +++ b/Task/Huffman-coding/Haskell/huffman-coding-3.hs @@ -0,0 +1,12 @@ +import qualified Data.Set as S + +htree :: (Ord t, Num t, Ord a) => S.Set (t, HTree a) -> HTree a +htree ts | S.null ts_1 = t1 + | otherwise = htree ts_3 + where + ((w1,t1), ts_1) = S.deleteFindMin ts + ((w2,t2), ts_2) = S.deleteFindMin ts_1 + ts_3 = S.insert (w1 + w2, Branch t1 t2) ts_2 + +huffmanTree :: (Ord w, Num w, Ord a) => [(w, a)] -> HTree a +huffmanTree = htree . S.fromList . map (second Leaf) diff --git a/Task/Huffman-coding/Haskell/huffman-coding-4.hs b/Task/Huffman-coding/Haskell/huffman-coding-4.hs new file mode 100644 index 0000000000..58dab333c4 --- /dev/null +++ b/Task/Huffman-coding/Haskell/huffman-coding-4.hs @@ -0,0 +1,17 @@ +import Data.List (sortBy, insertBy, sort, group) +import Control.Arrow (second, (&&&)) +import Data.Ord (comparing) + +freq :: Ord a => [a] -> [(Int, a)] +freq = map (length &&& head) . group . sort + +huffman :: [(Int, Char)] -> [(Char, String)] +huffman = reduce . map (\(p, c) -> (p, [(c ,"")])) . sortBy (comparing fst) + where add (p1, xs1) (p2, xs2) = (p1 + p2, map (second ('0':)) xs1 ++ map (second ('1':)) xs2) + reduce [(_, ys)] = sortBy (comparing fst) ys + reduce (x1:x2:xs) = reduce $ insertBy (comparing fst) (add x1 x2) xs + +test s = mapM_ (\(a, b) -> putStrLn ('\'' : a : "\' : " ++ b)) . huffman . freq $ s + +main = do + test "this is an example for huffman encoding" diff --git a/Task/Huffman-coding/Icon/huffman-coding-1.icon b/Task/Huffman-coding/Icon/huffman-coding-1.icon new file mode 100644 index 0000000000..36efd05c44 --- /dev/null +++ b/Task/Huffman-coding/Icon/huffman-coding-1.icon @@ -0,0 +1,60 @@ +record huffnode(l,r,n,c) # internal and leaf nodes +record huffcode(c,n,b,i) # encoding table char, freq, bitstring, bits (int) + +procedure main() + +s := "this is an example for huffman encoding" + +Count := huffcount(s) # frequency count +Tree := huffTree(Count) # heap and tree + +Code := [] # extract encodings +CodeT := table() +every x := huffBits(Tree) do + put( Code, CodeT[c] := huffcode( c := x[-1], Count[c].n, b := x[1:-1], integer("2r"||b) ) ) + + +Code := sortf( Code, 1 ) # show table in char order +write("Input String : ",image(s)) +write(right("char",5), right("freq",5), " encoding" ) +every write(right(image((x := !Code).c),5), right(x.n,5), " ", x.b ) + +end + +procedure huffBits(N) # generates huffman bitcodes with trailing character +if \N.c then return N.c # . append leaf char code +suspend "0" || huffBits(N.l) # . left +suspend "1" || huffBits(N.r) # . right +end + + +procedure huffTree(T) # two queue huffman tree method +local Q1,Q2,x,n1,n2 + +Q1 := [] # queue of characters and weights +every x := !T do # ensure all are huffnodes + if type(x) == "huffnode" then put(Q1,x) else runerr(205,x) +Q1 := sortf(Q1,3) # sort by weight ( 3 means by .n ) + +if *Q1 > 1 then Q2 := [] +while *Q1+*\Q2 > 1 do { # While there is more than one node ... + + n1 := if Q1[1] & ( ( Q1[1].n <= Q2[1].n ) | not Q2[1] ) then get(Q1) else get(Q2) # lowest weight from Q1 or Q2 + n2 := if Q1[1] & ( ( Q1[1].n <= Q2[1].n ) | not Q2[1] ) then get(Q1) else get(Q2) # lowest weight from Q1 or Q2 + + put( Q2, huffnode( n1, n2, n1.n + n2.n ) ) # new weighted node to end of Q2 +} + +return (\Q2 | Q1)[1] # return the root node +end + +procedure huffcount(s) # return characters and frequencies in a table of huffnodes by char +local c,T + +T := table() +every c := !s do { + /T[c] := huffnode(,,0,c) + T[c].n +:= 1 + } +return T +end diff --git a/Task/Huffman-coding/Icon/huffman-coding-2.icon b/Task/Huffman-coding/Icon/huffman-coding-2.icon new file mode 100644 index 0000000000..4898308378 --- /dev/null +++ b/Task/Huffman-coding/Icon/huffman-coding-2.icon @@ -0,0 +1,30 @@ +import Collections + +procedure main(A) + every line := !&input do { + every (t := table(0))[!line] +:= 1 # Frequency table + heap := Heap(sort(t), field, "<") # Initial priority queue + while heap.size() > 1 do { # Tree construction + every (p1|p2) := heap.get() + heap.add([&null, p1[2]+p2[2], p1, p2]) + } + codes := treeWalk(heap.get(),"") # Get codes from tree + write("Huffman encoding:") # Display codes + every pair := !sort(codes) do + write("\t'",\pair[1],"'-> ",pair[2]) + } +end + +procedure field(node) # selector function for Heap + return node[2] # field to use for priority ordering +end + +procedure treeWalk(node, prefix, codeMap) + /codeMap := table("") + if /node[1] then { # interior node + treeWalk(node[3], prefix||"0", codeMap) + treeWalk(node[4], prefix||"1", codeMap) + } + else codeMap[node[1]] := prefix + return codeMap +end diff --git a/Task/Huffman-coding/J/huffman-coding-1.j b/Task/Huffman-coding/J/huffman-coding-1.j new file mode 100644 index 0000000000..eda2916c9e --- /dev/null +++ b/Task/Huffman-coding/J/huffman-coding-1.j @@ -0,0 +1,14 @@ +hc=: 4 : 0 + if. 1=#x do. y + else. ((i{x),+/j{x) hc (i{y),: L.y NB. words are boxed not more than once + w=. ,&.> y NB. standardized words + assert. w -: ~.w NB. words are unique + t=. 0 {:: x hc w NB. minimal weight binary tree + ((< S: 0 t) i. w) { <@(1&=)@; S: 1 {:: t +) diff --git a/Task/Huffman-coding/J/huffman-coding-2.j b/Task/Huffman-coding/J/huffman-coding-2.j new file mode 100644 index 0000000000..62ebb4c98a --- /dev/null +++ b/Task/Huffman-coding/J/huffman-coding-2.j @@ -0,0 +1,20 @@ + ;"1":L:0(#/.~ (],.(<' '),.hcodes) ,&.>@~.)'this is an example for huffman encoding' + t 0 1 0 1 0 + h 1 1 1 1 1 + i 1 0 0 1 + s 0 0 1 0 + 1 0 1 + a 1 1 0 0 + n 0 0 0 + e 1 1 0 1 + x 0 1 0 1 1 + m 0 0 1 1 + p 0 1 1 0 0 + l 0 1 1 0 1 + f 1 1 1 0 + o 0 1 0 0 + r 0 1 1 1 0 + u 0 1 1 1 1 + c 1 0 0 0 0 + d 1 0 0 0 1 + g 1 1 1 1 0 diff --git a/Task/Huffman-coding/Java/huffman-coding.java b/Task/Huffman-coding/Java/huffman-coding.java new file mode 100644 index 0000000000..92b9d837e3 --- /dev/null +++ b/Task/Huffman-coding/Java/huffman-coding.java @@ -0,0 +1,95 @@ +import java.util.*; + +abstract class HuffmanTree implements Comparable { + public final int frequency; // the frequency of this tree + public HuffmanTree(int freq) { frequency = freq; } + + // compares on the frequency + public int compareTo(HuffmanTree tree) { + return frequency - tree.frequency; + } +} + +class HuffmanLeaf extends HuffmanTree { + public final char value; // the character this leaf represents + + public HuffmanLeaf(int freq, char val) { + super(freq); + value = val; + } +} + +class HuffmanNode extends HuffmanTree { + public final HuffmanTree left, right; // subtrees + + public HuffmanNode(HuffmanTree l, HuffmanTree r) { + super(l.frequency + r.frequency); + left = l; + right = r; + } +} + +public class HuffmanCode { + // input is an array of frequencies, indexed by character code + public static HuffmanTree buildTree(int[] charFreqs) { + PriorityQueue trees = new PriorityQueue(); + // initially, we have a forest of leaves + // one for each non-empty character + for (int i = 0; i < charFreqs.length; i++) + if (charFreqs[i] > 0) + trees.offer(new HuffmanLeaf(charFreqs[i], (char)i)); + + assert trees.size() > 0; + // loop until there is only one tree left + while (trees.size() > 1) { + // two trees with least frequency + HuffmanTree a = trees.poll(); + HuffmanTree b = trees.poll(); + + // put into new node and re-insert into queue + trees.offer(new HuffmanNode(a, b)); + } + return trees.poll(); + } + + public static void printCodes(HuffmanTree tree, StringBuffer prefix) { + assert tree != null; + if (tree instanceof HuffmanLeaf) { + HuffmanLeaf leaf = (HuffmanLeaf)tree; + + // print out character, frequency, and code for this leaf (which is just the prefix) + System.out.println(leaf.value + "\t" + leaf.frequency + "\t" + prefix); + + } else if (tree instanceof HuffmanNode) { + HuffmanNode node = (HuffmanNode)tree; + + // traverse left + prefix.append('0'); + printCodes(node.left, prefix); + prefix.deleteCharAt(prefix.length()-1); + + // traverse right + prefix.append('1'); + printCodes(node.right, prefix); + prefix.deleteCharAt(prefix.length()-1); + } + } + + public static void main(String[] args) { + String test = "this is an example for huffman encoding"; + + // we will assume that all our characters will have + // code less than 256, for simplicity + int[] charFreqs = new int[256]; + // read each character and record the frequencies + for (char c : test.toCharArray()) + charFreqs[c]++; + + // build tree + HuffmanTree tree = buildTree(charFreqs); + + // print out results + System.out.println("SYMBOL\tWEIGHT\tHUFFMAN CODE"); + printCodes(tree, new StringBuffer()); + } +} diff --git a/Task/Huffman-coding/JavaScript/huffman-coding-1.js b/Task/Huffman-coding/JavaScript/huffman-coding-1.js new file mode 100644 index 0000000000..7239418794 --- /dev/null +++ b/Task/Huffman-coding/JavaScript/huffman-coding-1.js @@ -0,0 +1,63 @@ +function HuffmanEncoding(str) { + this.str = str; + + var count_chars = {}; + for (var i = 0; i < str.length; i++) + if (str[i] in count_chars) + count_chars[str[i]] ++; + else + count_chars[str[i]] = 1; + + var pq = new BinaryHeap(function(x){return x[0];}); + for (var ch in count_chars) + pq.push([count_chars[ch], ch]); + + while (pq.size() > 1) { + var pair1 = pq.pop(); + var pair2 = pq.pop(); + pq.push([pair1[0]+pair2[0], [pair1[1], pair2[1]]]); + } + + var tree = pq.pop(); + this.encoding = {}; + this._generate_encoding(tree[1], ""); + + this.encoded_string = "" + for (var i = 0; i < this.str.length; i++) { + this.encoded_string += this.encoding[str[i]]; + } +} + +HuffmanEncoding.prototype._generate_encoding = function(ary, prefix) { + if (ary instanceof Array) { + this._generate_encoding(ary[0], prefix + "0"); + this._generate_encoding(ary[1], prefix + "1"); + } + else { + this.encoding[ary] = prefix; + } +} + +HuffmanEncoding.prototype.inspect_encoding = function() { + for (var ch in this.encoding) { + print("'" + ch + "': " + this.encoding[ch]) + } +} + +HuffmanEncoding.prototype.decode = function(encoded) { + var rev_enc = {}; + for (var ch in this.encoding) + rev_enc[this.encoding[ch]] = ch; + + var decoded = ""; + var pos = 0; + while (pos < encoded.length) { + var key = "" + while (!(key in rev_enc)) { + key += encoded[pos]; + pos++; + } + decoded += rev_enc[key]; + } + return decoded; +} diff --git a/Task/Huffman-coding/JavaScript/huffman-coding-2.js b/Task/Huffman-coding/JavaScript/huffman-coding-2.js new file mode 100644 index 0000000000..69f7d44a5a --- /dev/null +++ b/Task/Huffman-coding/JavaScript/huffman-coding-2.js @@ -0,0 +1,13 @@ +var s = "this is an example for huffman encoding"; +print(s); + +var huff = new HuffmanEncoding(s); +huff.inspect_encoding(); + +var e = huff.encoded_string; +print(e); + +var t = huff.decode(e); +print(t); + +print("is decoded string same as original? " + (s==t)); diff --git a/Task/Huffman-coding/PHP/huffman-coding.php b/Task/Huffman-coding/PHP/huffman-coding.php new file mode 100644 index 0000000000..b5acaaba7e --- /dev/null +++ b/Task/Huffman-coding/PHP/huffman-coding.php @@ -0,0 +1,28 @@ +setExtractFlags(SplPriorityQueue::EXTR_BOTH); + foreach ($symb2freq as $sym => $wt) + $heap->insert(array($sym => ''), -$wt); + + while ($heap->count() > 1) { + $lo = $heap->extract(); + $hi = $heap->extract(); + foreach ($lo['data'] as &$x) + $x = '0'.$x; + foreach ($hi['data'] as &$x) + $x = '1'.$x; + $heap->insert($lo['data'] + $hi['data'], + $lo['priority'] + $hi['priority']); + } + $result = $heap->extract(); + return $result['data']; +} + +$txt = 'this is an example for huffman encoding'; +$symb2freq = array_count_values(str_split($txt)); +$huff = encode($symb2freq); +echo "Symbol\tWeight\tHuffman Code\n"; +foreach ($huff as $sym => $code) + echo "$sym\t$symb2freq[$sym]\t$code\n"; +?> diff --git a/Task/Huffman-coding/Perl/huffman-coding-1.pl b/Task/Huffman-coding/Perl/huffman-coding-1.pl new file mode 100644 index 0000000000..e842c7adf0 --- /dev/null +++ b/Task/Huffman-coding/Perl/huffman-coding-1.pl @@ -0,0 +1,52 @@ +sub make_tree { + my %letters; + $letters{$_}++ for (split "", shift); + my (@nodes, $n) = map({ a=>$_, freq=>$letters{$_} }, keys %letters); + while ((@nodes = sort { $a->{freq} <=> $b->{freq} + or $a->{a} cmp $b->{a} } @nodes) > 1) + { + $n = { "0"=>shift(@nodes), "1"=>shift(@nodes) }; + $n->{freq} = $n->{0}{freq} + $n->{1}{freq}; + push @nodes, $n; + } + + walk($n, "", $n->{tree} = {}); + $n; +} + +sub walk { + my ($n, $s, $h) = @_; + exists $n->{a} and do { + print "'$n->{a}': $s\n"; + $h->{$n->{a}} = $s if $h; + return; + }; + walk($n->{0}, $s.0, $h); + walk($n->{1}, $s.1, $h); +} + +sub encode { + my ($s, $t) = @_; + $t = $t->{tree}; + join("", map($t->{$_}, split("", $s))); +} + +sub decode { + my @b = split("", shift); + my ($n, $out) = $_[0]; + + while (@b) { + $n = $n->{shift @b}; + if ($n->{a}) { + $out .= $n->{a}; + $n = $_[0]; + } + } + $out; +} + +my $text = "this is an example for huffman encoding"; +my $tree = make_tree($text); +my $e = encode($text, $tree); +print "$e\n"; +print decode($e, $tree), "\n"; diff --git a/Task/Huffman-coding/Perl/huffman-coding-2.pl b/Task/Huffman-coding/Perl/huffman-coding-2.pl new file mode 100644 index 0000000000..fb8f765ad2 --- /dev/null +++ b/Task/Huffman-coding/Perl/huffman-coding-2.pl @@ -0,0 +1,21 @@ +'g': 00000 +'l': 00001 +'p': 00010 +'r': 00011 +'t': 00100 +'u': 00101 +'h': 0011 +'m': 0100 +'o': 0101 +'n': 011 +'s': 1000 +'x': 10010 +'c': 100110 +'d': 100111 +'a': 1010 +'e': 1011 +'f': 1100 +'i': 1101 +' ': 111 +0010000111101100011111...111110101100000 +this is an example for huffman encoding diff --git a/Task/Huffman-coding/PicoLisp/huffman-coding.l b/Task/Huffman-coding/PicoLisp/huffman-coding.l new file mode 100644 index 0000000000..f6f96aaef4 --- /dev/null +++ b/Task/Huffman-coding/PicoLisp/huffman-coding.l @@ -0,0 +1,18 @@ +(de prio (Idx) + (while (cadr Idx) (setq Idx @)) + (car Idx) ) + +(let (A NIL P NIL L NIL) + (for C (chop "this is an example for huffman encoding") + (accu 'A C 1) ) # Count characters + (for X A # Build index tree as priority queue + (idx 'P (cons (cdr X) (car X)) T) ) + (while (or (cadr P) (cddr P)) # Remove entries, insert as nodes + (let (A (car (idx 'P (prio P) NIL)) B (car (idx 'P (prio P) NIL))) + (idx 'P (cons (+ (car A) (car B)) A B) T) ) ) + (setq P (car P)) + (recur (P L) # Traverse and print + (if (atom (cdr P)) + (prinl (cdr P) " " L) + (recurse (cadr P) (cons 0 L)) + (recurse (cddr P) (cons 1 L)) ) ) ) diff --git a/Task/Huffman-coding/Prolog/huffman-coding.pro b/Task/Huffman-coding/Prolog/huffman-coding.pro new file mode 100644 index 0000000000..78aa28e163 --- /dev/null +++ b/Task/Huffman-coding/Prolog/huffman-coding.pro @@ -0,0 +1,47 @@ +huffman :- + L = 'this is an example for huffman encoding', + atom_chars(L, LA), + msort(LA, LS), + packList(LS, PL), + sort(PL, PLS), + build_tree(PLS, A), + coding(A, [], C), + sort(C, SC), + format('Symbol~t Weight~t~30|Code~n'), + maplist(print_code, SC). + +build_tree([[V1|R1], [V2|R2]|T], AF) :- + V is V1 + V2, + A = [V, [V1|R1], [V2|R2]], + ( T=[] -> AF=A ; sort([A|T], NT), build_tree(NT, AF) ). + +coding([_A,FG,FD], Code, CF) :- + ( is_node(FG) -> coding(FG, [0 | Code], C1) + ; leaf_coding(FG, [0 | Code], C1) ), + ( is_node(FD) -> coding(FD, [1 | Code], C2) + ; leaf_coding(FD, [1 | Code], C2) ), + append(C1, C2, CF). + +leaf_coding([FG,FD], Code, CF) :- + reverse(Code, CodeR), + CF = [[FG, FD, CodeR]] . + +is_node([_V, _FG, _FD]). + +print_code([N, Car, Code]):- + format('~w :~t~w~t~30|', [Car, N]), + forall(member(V, Code), write(V)), + nl. + +packList([], []). +packList([X], [[1,X]]) :- !. +packList([X|Rest], [XRun|Packed]):- + run(X, Rest, XRun, RRest), + packList(RRest, Packed). + +run(V, [], [1,V], []). +run(V, [V|LRest], [N1,V], RRest):- + run(V, LRest, [N, V], RRest), + N1 is N + 1. +run(V, [Other|RRest], [1,V], [Other|RRest]):- + dif(V, Other). diff --git a/Task/Huffman-coding/Python/huffman-coding.py b/Task/Huffman-coding/Python/huffman-coding.py new file mode 100644 index 0000000000..5222452a13 --- /dev/null +++ b/Task/Huffman-coding/Python/huffman-coding.py @@ -0,0 +1,27 @@ +from heapq import heappush, heappop, heapify +from collections import defaultdict + +def encode(symb2freq): + """Huffman encode the given dict mapping symbols to weights""" + heap = [[wt, [sym, ""]] for sym, wt in symb2freq.items()] + heapify(heap) + while len(heap) > 1: + lo = heappop(heap) + hi = heappop(heap) + for pair in lo[1:]: + pair[1] = '0' + pair[1] + for pair in hi[1:]: + pair[1] = '1' + pair[1] + heappush(heap, [lo[0] + hi[0]] + lo[1:] + hi[1:]) + return sorted(heappop(heap)[1:], key=lambda p: (len(p[-1]), p)) + +txt = "this is an example for huffman encoding" +symb2freq = defaultdict(int) +for ch in txt: + symb2freq[ch] += 1 +# in Python 3.1+: +# symb2freq = collections.Counter(txt) +huff = encode(symb2freq) +print "Symbol\tWeight\tHuffman Code" +for p in huff: + print "%s\t%s\t%s" % (p[0], symb2freq[p[0]], p[1]) diff --git a/Task/Huffman-coding/Racket/huffman-coding.rkt b/Task/Huffman-coding/Racket/huffman-coding.rkt new file mode 100644 index 0000000000..86a6c8b5e1 --- /dev/null +++ b/Task/Huffman-coding/Racket/huffman-coding.rkt @@ -0,0 +1,113 @@ +#lang racket + +(require data/heap + data/bit-vector) + +;; A node is either an interior, or a leaf. +;; In either case, they record an item with an associated frequency. +(struct node (freq) #:transparent) +(struct interior node (left right) #:transparent) +(struct leaf node (val) #:transparent) + +;; node<=?: node node -> boolean +;; Compares two nodes by frequency. +(define (node<=? x y) + (<= (node-freq x) (node-freq y))) + +;; We keep a private sentinel-val under our own control. +(define sentinel-val (cons 'sentinel 'sentinel)) + +;; make-huffman-tree: (listof leaf) -> interior-node +;; Makes the huffman tree with basic priority-queue operations. +;; Note: we ensure that make-huffman-tree always returns an interior node. +(define (make-huffman-tree leaves) + (define a-heap (make-heap node<=?)) + (heap-add-all! a-heap leaves) + ;; To ensure that we always get tree with at least one interior node, + ;; we also inject a sentinel leaf node with zero frequency. + (heap-add! a-heap (leaf 0 sentinel-val)) + (for ([i (in-range (length leaves))]) + (define min-1 (heap-min a-heap)) + (heap-remove-min! a-heap) + (define min-2 (heap-min a-heap)) + (heap-remove-min! a-heap) + (heap-add! a-heap (interior (+ (node-freq min-1) (node-freq min-2)) + min-1 min-2))) + (heap-min a-heap)) + +;; string->huffman-tree: string -> node +;; Given a string, produces its huffman tree. The leaves hold the characters +;; and their relative frequencies. +(define (string->huffman-tree str) + (define ht (make-hash)) + (define n (sequence-length str)) + (for ([ch str]) + (hash-set! ht ch (add1 (hash-ref ht ch 0)))) + (make-huffman-tree + (for/list ([(k v) (in-hash ht)]) + (leaf (/ v n) k)))) + +;; make-encoder: node -> (string -> bit-vector) +;; Given a huffman tree, generates the encoder function. +(define (make-encoder a-tree) + (define dict (huffman-tree->dictionary a-tree)) + (lambda (a-str) + (list->bit-vector (apply append (for/list ([ch a-str]) (hash-ref dict ch)))))) + +;; huffman-tree->dictionary: node -> (hashof val (listof boolean)) +;; A helper for the encoder: maps characters to their code sequences. +(define (huffman-tree->dictionary a-node) + (define ht (make-hash)) + (let loop ([a-node a-node] + [path/rev '()]) + (cond + [(interior? a-node) + (loop (interior-left a-node) (cons #f path/rev)) + (loop (interior-right a-node) (cons #t path/rev))] + [(leaf? a-node) + (unless (eq? (leaf-val a-node) sentinel-val) + (hash-set! ht (reverse path/rev) (leaf-val a-node)))])) + (for/hash ([(k v) ht]) + (values v k))) + +;; make-decoder: interior-node -> (bit-vector -> string) +;; Generates the decoder function from the tree. +(define (make-decoder a-tree) + (lambda (a-bitvector) + (define-values (decoded/rev _) + (for/fold ([decoded/rev '()] + [a-node a-tree]) + ([bit a-bitvector]) + (define next-node + (cond + [(not bit) + (interior-left a-node)] + [else + (interior-right a-node)])) + (cond [(leaf? next-node) + (values (cons (leaf-val next-node) decoded/rev) + a-tree)] + [else + (values decoded/rev next-node)]))) + (apply string (reverse decoded/rev)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Example application: +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define msg "this is an example for huffman encoding") + +(define tree (string->huffman-tree msg)) + +;; We can print out the mapping for inspection: +(huffman-tree->dictionary tree) + +(define encode (make-encoder tree)) +(define encoded (encode msg)) + +;; Here's what the encoded message looks like: +(bit-vector->string encoded) + +(define decode (make-decoder tree)) +;; Here's what the decoded message looks like: +(decode encoded) diff --git a/Task/Huffman-coding/Ruby/huffman-coding.rb b/Task/Huffman-coding/Ruby/huffman-coding.rb new file mode 100644 index 0000000000..60c1053b18 --- /dev/null +++ b/Task/Huffman-coding/Ruby/huffman-coding.rb @@ -0,0 +1,54 @@ +require 'priority_queue' + +def huffman_encoding(str) + char_count = Hash.new(0) + str.each_char {|c| char_count[c] += 1} + + pq = CPriorityQueue.new + # chars with fewest count have highest priority + char_count.each {|char, count| pq.push(char, count)} + + while pq.length > 1 + key1, prio1 = pq.delete_min + key2, prio2 = pq.delete_min + pq.push([key1, key2], prio1 + prio2) + end + + Hash[*generate_encoding(pq.min_key)] +end + +def generate_encoding(ary, prefix="") + case ary + when Array + generate_encoding(ary[0], "#{prefix}0") + generate_encoding(ary[1], "#{prefix}1") + else + [ary, prefix] + end +end + +def encode(str, encoding) + str.each_char.collect {|char| encoding[char]}.join +end + +def decode(encoded, encoding) + rev_enc = encoding.invert + decoded = "" + pos = 0 + while pos < encoded.length + key = "" + while rev_enc[key].nil? + key << encoded[pos] + pos += 1 + end + decoded << rev_enc[key] + end + decoded +end + +str = "this is an example for huffman encoding" +encoding = huffman_encoding(str) +encoding.to_a.sort.each {|x| p x} + +enc = encode(str, encoding) +dec = decode(enc, encoding) +puts "success!" if str == dec diff --git a/Task/Huffman-coding/Scala/huffman-coding.scala b/Task/Huffman-coding/Scala/huffman-coding.scala new file mode 100644 index 0000000000..9d0c94dcd7 --- /dev/null +++ b/Task/Huffman-coding/Scala/huffman-coding.scala @@ -0,0 +1,49 @@ +object Huffman { + import scala.collection.mutable.{Map, PriorityQueue} + + sealed abstract class Tree + case class Node(left: Tree, right: Tree) extends Tree + case class Leaf(c: Char) extends Tree + + def treeOrdering(m: Map[Tree, Int]) = new Ordering[Tree] { + def compare(x: Tree, y: Tree) = m(y).compare(m(x)) + } + + def stringMap(text: String) = text groupBy (x => Leaf(x) : Tree) mapValues (_.length) + + def buildNode(queue: PriorityQueue[Tree], map: Map[Tree,Int]) { + val right = queue.dequeue + val left = queue.dequeue + val node = Node(left, right) + map(node) = map(left) + map(right) + queue.enqueue(node) + } + + def codify(tree: Tree, map: Map[Tree, Int]) = { + def recurse(tree: Tree, prefix: String): List[(Char, (Int, String))] = tree match { + case Node(left, right) => recurse(left, prefix+"0") ::: recurse(right, prefix+"1") + case leaf @ Leaf(c) => c -> ((map(leaf), prefix)) :: Nil + } + recurse(tree, "") + } + + def encode(text: String) = { + val map = Map.empty[Tree,Int] ++= stringMap(text) + val queue = new PriorityQueue[Tree]()(treeOrdering(map)) ++= map.keysIterator + + while(queue.size > 1) { + buildNode(queue, map) + } + codify(queue.dequeue, map) + } + + + def main(args: Array[String]) { + val text = "this is an example for huffman encoding" + val code = encode(text) + println("Char\tWeight\t\tEncoding") + code sortBy (_._2._1) foreach { + case (c, (weight, encoding)) => println("%c:\t%3d/%-3d\t\t%s" format (c, weight, text.length, encoding)) + } + } +} diff --git a/Task/Huffman-coding/Tcl/huffman-coding.tcl b/Task/Huffman-coding/Tcl/huffman-coding.tcl new file mode 100644 index 0000000000..3f6c8b8e9f --- /dev/null +++ b/Task/Huffman-coding/Tcl/huffman-coding.tcl @@ -0,0 +1,54 @@ +package require Tcl 8.5 +package require struct::prioqueue + +proc huffmanEncode {str args} { + array set opts [concat -dump false $args] + + set charcount [dict create] + foreach char [split $str ""] { + dict incr charcount $char + } + + set pq [struct::prioqueue -dictionary] ;# want lower values to have higher priority + dict for {char count} $charcount { + $pq put $char $count + } + + while {[$pq size] > 1} { + lassign [$pq peekpriority 2] p1 p2 + $pq put [$pq get 2] [expr {$p1 + $p2}] + } + + set encoding [walkTree [$pq get]] + set map [dict create {*}[lreverse $encoding]] + + if {$opts(-dump)} { + foreach key [lsort -command compare [dict keys $map]] { + set char [dict get $map $key] + puts "$char\t[dict get $charcount $char]\t$key" + } + } + + return $encoding +} + +proc walkTree {tree {prefix ""}} { + if {[llength $tree] < 2} { + return [list $tree $prefix] + } + lassign $tree left right + return [concat [walkTree $left "${prefix}0"] [walkTree $right "${prefix}1"]] +} + +proc compare {a b} { + if {[string length $a] < [string length $b]} {return -1} + if {[string length $a] > [string length $b]} {return 1} + return [string compare $a $b] +} + +set str "this is an example for huffman encoding" + +set encoding [huffmanEncode $str -dump true] + +puts $str +puts [string map $encoding $str] diff --git a/Task/I-before-E-except-after-C/0DESCRIPTION b/Task/I-before-E-except-after-C/0DESCRIPTION new file mode 100644 index 0000000000..88a4c70e88 --- /dev/null +++ b/Task/I-before-E-except-after-C/0DESCRIPTION @@ -0,0 +1,15 @@ +The phrase [[wp:I before E except after C|"I before E, except after C"]] is a widely known mnemonic which is supposed to help when spelling English words. + +;Task Description: +Using the word list from [http://www.puzzlers.org/pub/wordlists/unixdict.txt http://www.puzzlers.org/pub/wordlists/unixdict.txt], check if the two sub-clauses of the phrase are plausible individually: +# ''"I before E when not preceded by C"'' +# ''"E before I when preceded by C"'' + +If both sub-phrases are plausible then the original phrase can be said to be plausible.
+Something is plausible if the number of words having the feature is more than two times the number of words having the opposite feature (where feature is 'ie' or 'ei' preceded or not by 'c' as appropriate). + +Show your output here as well as your program. + +;cf.: +* [http://news.bbc.co.uk/1/hi/education/8110573.stm Schools to rethink 'i before e'] - BBC news, 20 June 2009 +* [http://www.youtube.com/watch?v=duqlZXiIZqA I Before E Except After C] - [[wp:QI|QI]] Series 8 Ep 14, (humorous) diff --git a/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-1.j b/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-1.j new file mode 100644 index 0000000000..f5da82bf4f --- /dev/null +++ b/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-1.j @@ -0,0 +1 @@ + dict=:tolower fread '/tmp/unixdict.txt' diff --git a/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-2.j b/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-2.j new file mode 100644 index 0000000000..41b510b7e1 --- /dev/null +++ b/Task/I-before-E-except-after-C/J/i-before-e-except-after-c-2.j @@ -0,0 +1,8 @@ + +/'cie' E. dict +24 + +/'cei' E. dict +13 + +/'ie' E. dict +490 + +/'ei' E. dict +230 diff --git a/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c.py b/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c.py new file mode 100644 index 0000000000..6b4da8bd49 --- /dev/null +++ b/Task/I-before-E-except-after-C/Python/i-before-e-except-after-c.py @@ -0,0 +1,34 @@ +import urllib.request +import re + +PLAUSIBILITY_RATIO = 2 + +def plausibility_check(comment, x, y): + print('\n Checking plausibility of: %s' % comment) + if x > PLAUSIBILITY_RATIO * y: + print(' PLAUSIBLE. As we have counts of %i vs %i words, a ratio of %4.1f times' + % (x, y, x / y)) + else: + if x > y: + print(' IMPLAUSIBLE. As although we have counts of %i vs %i words, a ratio of %4.1f times does not make it plausible' + % (x, y, x / y)) + else: + print(' IMPLAUSIBLE, probably contra-indicated. As we have counts of %i vs %i words, a ratio of %4.1f times' + % (x, y, x / y)) + return x > PLAUSIBILITY_RATIO * y + +words = set(urllib.request.urlopen( + 'http://www.puzzlers.org/pub/wordlists/unixdict.txt' + ).read().decode().lower().split()) +cie = sum('cie' in word for word in words) +cei = sum('cei' in word for word in words) +not_c_ie = sum(bool(re.search(r'(^ie|[^c]ie)', word)) for word in words) +not_c_ei = sum(bool(re.search(r'(^ei|[^c]ei)', word)) for word in words) + +print('Checking plausibility of "I before E except after C":') +if ( plausibility_check('I before E when not preceded by C', not_c_ie, not_c_ei) + and plausibility_check('E before I when preceded by C', cei, cie) ): + print('\nOVERALL IT IS PLAUSIBLE!') +else: + print('\nOVERALL IT IS IMPLAUSIBLE!') +print('\n(To be plausible, one word count must exceed another by %i times)' % PLAUSIBILITY_RATIO) diff --git a/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx b/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx new file mode 100644 index 0000000000..ae56a0f3da --- /dev/null +++ b/Task/I-before-E-except-after-C/REXX/i-before-e-except-after-c.rexx @@ -0,0 +1,35 @@ +/*REXX pgm shows plausibility of I before E when not preceded by C, and*/ +/*────────────────────────────── E before I when preceded by C. */ +#.=0 /*zero out various word counters.*/ +parse arg iFID .; if iFID=='' then iFID='UNIXDICT.TXT' /*use default?*/ + + do r=1 while lines(ifid)\==0; _=linein(iFID) /*get a single line.*/ + u=translate(space(_,0)) /*elide superfluous blanks & tabs*/ + if u=='' then iterate /*if a blank line, then ignore it*/ + #.words=#.words+1 /*keep a running count of #words.*/ + if pos('EI',u)\==0 & pos('IE',u)\==0 then #.both=#.both+1 /*has both.*/ + call find 'ie' + call find 'ei' + end /*r*/ + +L=length(#.words) /*use this to align the output #s*/ +say 'words in the ' ifid ' dictionary: ' #.words +say 'words with "IE" and "EI" (in same word): ' right(#.both,L) +say 'words with "IE" and preceded by "C": ' right(#.ie.c ,L) +say 'words with "IE" and not preceded by "C": ' right(#.ie.z ,L) +say 'words with "EI" and preceded by "C": ' right(#.ei.c ,L) +say 'words with "EI" and not preceded by "C": ' right(#.ei.z ,L) +say; mantra='The spelling mantra ' +p1=#.ie.z/max(1,#.ei.z); phrase='"I before E when not preceded by C"' +say mantra phrase ' is ' word("im", 1+(p1>2))'plausible.' +p2=#.ie.c/max(1,#.ei.c); phrase='"E before I when preceded by C"' +say mantra phrase ' is ' word("im", 1+(p2>2))'plausible.' +po=p1>2 & p2>2; say 'Overall, it is' word("im",1+po)'plausible.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────FIND subroutine─────────────────────*/ +find: arg x; s=1; do forever; _=pos(x,u,s); if _==0 then leave + if substr(u,_-1+(_==1)*999,1)=='C' then #.x.c=#.x.c+1 + else #.x.z=#.x.z+1 + s=_+1 /*handle case of multiple finds. */ + end /*forever*/ +return diff --git a/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl b/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl new file mode 100644 index 0000000000..5e6b48f34b --- /dev/null +++ b/Task/I-before-E-except-after-C/Tcl/i-before-e-except-after-c.tcl @@ -0,0 +1,42 @@ +package require http + +variable PLAUSIBILITY_RATIO 2.0 +proc plausible {description x y} { + variable PLAUSIBILITY_RATIO + puts " Checking plausibility of: $description" + if {$x > $PLAUSIBILITY_RATIO * $y} { + set conclusion "PLAUSIBLE" + set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" + set result true + } elseif {$x > $y} { + set conclusion "IMPLAUSIBLE" + set fmt "As although we have counts of %i vs %i words," + append fmt " a ratio of %.1f times does not make it plausible" + set result false + } else { + set conclusion "IMPLAUSIBLE, probably contra-indicated" + set fmt "As we have counts of %i vs %i words, a ratio of %.1f times" + set result false + } + puts [format " %s.\n $fmt" $conclusion $x $y [expr {double($x)/$y}]] + return $result +} + +set t [http::geturl http://www.puzzlers.org/pub/wordlists/unixdict.txt] +set words [split [http::data $t] "\n"] +http::cleanup $t +foreach {name pattern} {ie (?:^|[^c])ie ei (?:^|[^c])ei cie cie cei cei} { + set count($name) [llength [lsearch -nocase -all -regexp $words $pattern]] +} + +puts "Checking plausibility of \"I before E except after C\":" +if { + [plausible "I before E when not preceded by C" $count(ie) $count(ei)] && + [plausible "E before I when preceded by C" $count(cei) $count(cie)] +} then { + puts "\nOVERALL IT IS PLAUSIBLE!" +} else { + puts "\nOVERALL IT IS IMPLAUSIBLE!" +} +puts "\n(To be plausible, one word count must exceed another by\ + $PLAUSIBILITY_RATIO times)" diff --git a/Task/Identity-matrix/0DESCRIPTION b/Task/Identity-matrix/0DESCRIPTION new file mode 100644 index 0000000000..160237f501 --- /dev/null +++ b/Task/Identity-matrix/0DESCRIPTION @@ -0,0 +1,9 @@ +Build an [[wp:identity matrix|identity matrix]] of a size known at runtime. An identity matrix is a square matrix, of size ''n'' × ''n'', where the diagonal elements are all 1s, and the other elements are all 0s. + +I_n = \begin{bmatrix} + 1 & 0 & 0 & \cdots & 0 \\ + 0 & 1 & 0 & \cdots & 0 \\ + 0 & 0 & 1 & \cdots & 0 \\ + \vdots & \vdots & \vdots & \ddots & \vdots \\ + 0 & 0 & 0 & \cdots & 1 \\ +\end{bmatrix} diff --git a/Task/Identity-matrix/1META.yaml b/Task/Identity-matrix/1META.yaml new file mode 100644 index 0000000000..106b0ac419 --- /dev/null +++ b/Task/Identity-matrix/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Matrices diff --git a/Task/Identity-matrix/APL/identity-matrix-1.apl b/Task/Identity-matrix/APL/identity-matrix-1.apl new file mode 100644 index 0000000000..f692a5c359 --- /dev/null +++ b/Task/Identity-matrix/APL/identity-matrix-1.apl @@ -0,0 +1,4 @@ + ∘.=/⍳¨3 3 +1 0 0 +0 1 0 +0 0 1 diff --git a/Task/Identity-matrix/APL/identity-matrix-2.apl b/Task/Identity-matrix/APL/identity-matrix-2.apl new file mode 100644 index 0000000000..ed7d871e5f --- /dev/null +++ b/Task/Identity-matrix/APL/identity-matrix-2.apl @@ -0,0 +1,7 @@ + ID←{∘.=/⍳¨ ⍵ ⍵} + ID 5 +1 0 0 0 0 +0 1 0 0 0 +0 0 1 0 0 +0 0 0 1 0 +0 0 0 0 1 diff --git a/Task/Identity-matrix/APL/identity-matrix-3.apl b/Task/Identity-matrix/APL/identity-matrix-3.apl new file mode 100644 index 0000000000..f880266da1 --- /dev/null +++ b/Task/Identity-matrix/APL/identity-matrix-3.apl @@ -0,0 +1 @@ + ID←{⍵ ⍵ ρ 1, ⍵ρ0} diff --git a/Task/Identity-matrix/AWK/identity-matrix.awk b/Task/Identity-matrix/AWK/identity-matrix.awk new file mode 100644 index 0000000000..7a139cb4c4 --- /dev/null +++ b/Task/Identity-matrix/AWK/identity-matrix.awk @@ -0,0 +1,17 @@ +# syntax: GAWK -f IDENTITY_MATRIX.AWK size +BEGIN { + size = ARGV[1] + if (size !~ /^[0-9]+$/) { + print("size invalid or missing from command line") + exit(1) + } + for (i=1; i<=size; i++) { + for (j=1; j<=size; j++) { + x = (i == j) ? 1 : 0 + printf("%2d",x) # print + arr[i,j] = x # build + } + printf("\n") + } + exit(0) +} diff --git a/Task/Identity-matrix/Ada/identity-matrix-1.ada b/Task/Identity-matrix/Ada/identity-matrix-1.ada new file mode 100644 index 0000000000..c348a78aec --- /dev/null +++ b/Task/Identity-matrix/Ada/identity-matrix-1.ada @@ -0,0 +1,4 @@ +-- As prototyped in the Generic_Real_Arrays specification: +-- function Unit_Matrix (Order : Positive; First_1, First_2 : Integer := 1) return Real_Matrix; +-- For the task: +mat : Real_Matrix := Unit_Matrix(5); diff --git a/Task/Identity-matrix/Ada/identity-matrix-2.ada b/Task/Identity-matrix/Ada/identity-matrix-2.ada new file mode 100644 index 0000000000..12f1e25dc8 --- /dev/null +++ b/Task/Identity-matrix/Ada/identity-matrix-2.ada @@ -0,0 +1,4 @@ +type Matrix is array(Positive Range <>, Positive Range <>) of Integer; +mat : Matrix(1..5,1..5) := (others => (others => 0)); +-- then after the declarative section: +for i in mat'Range(1) loop mat(i,i) := 1; end loop; diff --git a/Task/Identity-matrix/BBC-BASIC/identity-matrix.bbc b/Task/Identity-matrix/BBC-BASIC/identity-matrix.bbc new file mode 100644 index 0000000000..1e8fb1fdf2 --- /dev/null +++ b/Task/Identity-matrix/BBC-BASIC/identity-matrix.bbc @@ -0,0 +1,17 @@ + INPUT "Enter size of matrix: " size% + PROCidentitymatrix(size%, im()) + FOR r% = 0 TO size%-1 + FOR c% = 0 TO size%-1 + PRINT im(r%, c%),; + NEXT + PRINT + NEXT r% + END + + DEF PROCidentitymatrix(s%, RETURN m()) + LOCAL i% + DIM m(s%-1, s%-1) + FOR i% = 0 TO s%-1 + m(i%,i%) = 1 + NEXT + ENDPROC diff --git a/Task/Identity-matrix/Burlesque/identity-matrix-1.blq b/Task/Identity-matrix/Burlesque/identity-matrix-1.blq new file mode 100644 index 0000000000..8631c4717b --- /dev/null +++ b/Task/Identity-matrix/Burlesque/identity-matrix-1.blq @@ -0,0 +1,7 @@ +blsq ) 6 -.^^0\/r@\/'0\/.*'1+]\/{\/{rt}\/E!XX}x/+]m[sp +1 0 0 0 0 0 +0 1 0 0 0 0 +0 0 1 0 0 0 +0 0 0 1 0 0 +0 0 0 0 1 0 +0 0 0 0 0 1 diff --git a/Task/Identity-matrix/Burlesque/identity-matrix-2.blq b/Task/Identity-matrix/Burlesque/identity-matrix-2.blq new file mode 100644 index 0000000000..5e47008d8b --- /dev/null +++ b/Task/Identity-matrix/Burlesque/identity-matrix-2.blq @@ -0,0 +1 @@ +6hd0bx#a.*\[#a.*0#a?dr@{(D!)\/1\/^^bx\/[+}m[e! diff --git a/Task/Identity-matrix/C-sharp/identity-matrix.cs b/Task/Identity-matrix/C-sharp/identity-matrix.cs new file mode 100644 index 0000000000..ad024c7df7 --- /dev/null +++ b/Task/Identity-matrix/C-sharp/identity-matrix.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; + +namespace IdentityMatrix +{ + class Program + { + static void Main(string[] args) + { + if (args.Length != 1) + { + Console.WriteLine("Requires exactly one argument"); + return; + } + int n; + if (!int.TryParse(args[0], out n)) + { + Console.WriteLine("Requires integer parameter"); + return; + } + + var identity = + Enumerable.Range(0, n).Select(i => Enumerable.Repeat(0, n).Select((z,j) => j == i ? 1 : 0).ToList()).ToList(); + foreach (var row in identity) + { + foreach (var elem in row) + { + Console.Write(" " + elem); + } + Console.WriteLine(); + } + Console.ReadKey(); + } + } +} diff --git a/Task/Identity-matrix/C/identity-matrix.c b/Task/Identity-matrix/C/identity-matrix.c new file mode 100644 index 0000000000..68d2fc470e --- /dev/null +++ b/Task/Identity-matrix/C/identity-matrix.c @@ -0,0 +1,38 @@ +#include +#include +int main(int argc, char** argv) { + if (argc < 2) { + printf("usage: identitymatrix \n"); + exit(EXIT_FAILURE); + } + signed int rowsize = atoi(argv[1]); + if (rowsize < 0) { + printf("Dimensions of matrix cannot be negative\n"); + exit(EXIT_FAILURE); + } + volatile int numElements = rowsize * rowsize; + if (numElements < rowsize) { + printf("Squaring %d caused result to overflow to %d.\n", rowsize, numElements); + abort(); + } + int** matrix = calloc(numElements, sizeof(int*)); + if (!matrix) { + printf("Failed to allocate %d elements of %d bytes each\n", numElements, sizeof(int*)); + abort(); + } + for (unsigned int row = 0;row < rowsize;row++) { + matrix[row] = calloc(numElements, sizeof(int)); + if (!matrix[row]) { + printf("Failed to allocate %d elements of %d bytes each\n", numElements, sizeof(int)); + abort(); + } + matrix[row][row] = 1; + } + printf("Matrix is: \n"); + for (unsigned int row = 0;row < rowsize;row++) { + for (unsigned int column = 0;column < rowsize;column++) { + printf("%d ", matrix[row][column]); + } + printf("\n"); + } +} diff --git a/Task/Identity-matrix/Clojure/identity-matrix-1.clj b/Task/Identity-matrix/Clojure/identity-matrix-1.clj new file mode 100644 index 0000000000..c8f665e0d0 --- /dev/null +++ b/Task/Identity-matrix/Clojure/identity-matrix-1.clj @@ -0,0 +1 @@ + '( (0 1) (2 3) ) diff --git a/Task/Identity-matrix/Clojure/identity-matrix-2.clj b/Task/Identity-matrix/Clojure/identity-matrix-2.clj new file mode 100644 index 0000000000..33719cd62e --- /dev/null +++ b/Task/Identity-matrix/Clojure/identity-matrix-2.clj @@ -0,0 +1,6 @@ +(defn identity-matrix [n] + (let [row (conj (repeat (dec n) 0) 1)] + (vec + (for [i (range 1 (inc n))] + (vec + (reduce conj (drop i row ) (take i row))))))) diff --git a/Task/Identity-matrix/Clojure/identity-matrix-3.clj b/Task/Identity-matrix/Clojure/identity-matrix-3.clj new file mode 100644 index 0000000000..24a823c07e --- /dev/null +++ b/Task/Identity-matrix/Clojure/identity-matrix-3.clj @@ -0,0 +1,2 @@ +=> (identity-matrix 5) +[[1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1]] diff --git a/Task/Identity-matrix/Clojure/identity-matrix-4.clj b/Task/Identity-matrix/Clojure/identity-matrix-4.clj new file mode 100644 index 0000000000..0ef3e8ad10 --- /dev/null +++ b/Task/Identity-matrix/Clojure/identity-matrix-4.clj @@ -0,0 +1,4 @@ +(defn identity-matrix [n] + (take n + (partition n (dec n) + (cycle (conj (repeat (dec n) 0) 1))))) diff --git a/Task/Identity-matrix/Common-Lisp/identity-matrix.lisp b/Task/Identity-matrix/Common-Lisp/identity-matrix.lisp new file mode 100644 index 0000000000..259423a9bf --- /dev/null +++ b/Task/Identity-matrix/Common-Lisp/identity-matrix.lisp @@ -0,0 +1,4 @@ +(defun make-identity-matrix (n) + (let ((array (make-array (list n n) :initial-element 0))) + (loop for i below n do (setf (aref array i i) 1)) + array)) diff --git a/Task/Identity-matrix/D/identity-matrix.d b/Task/Identity-matrix/D/identity-matrix.d new file mode 100644 index 0000000000..3493b44294 --- /dev/null +++ b/Task/Identity-matrix/D/identity-matrix.d @@ -0,0 +1,30 @@ +import std.traits; + +T[][] matId(T)(in size_t n) pure nothrow if (isAssignable!(T, T)) { + auto Id = new T[][](n, n); + + foreach (r, row; Id) { + static if (__traits(compiles, {row[] = 0;})) { + row[] = 0; // vector op doesn't work with T = BigInt + row[r] = 1; + } else { + foreach (c; 0 .. n) + row[c] = (c == r) ? 1 : 0; + } + } + + return Id; +} + +void main() { + import std.stdio, std.bigint; + enum form = "[%([%(%s, %)],\n %)]]"; + + immutable id1 = matId!real(5); + writefln(form ~ "\n", id1); + + immutable id2 = matId!BigInt(3); + writefln(form ~ "\n", id2); + + // auto id3 = matId!(const int)(2); // cant't compile +} diff --git a/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-1.euler b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-1.euler new file mode 100644 index 0000000000..d6bfb27e9e --- /dev/null +++ b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-1.euler @@ -0,0 +1,7 @@ +function IdentityMatrix(n) + $ X:=zeros(n,n); + $ for i=1 to n + $ X[i,i]:=1; + $ end; + $ return X; + $endfunction diff --git a/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-2.euler b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-2.euler new file mode 100644 index 0000000000..47416c4291 --- /dev/null +++ b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-2.euler @@ -0,0 +1,3 @@ +>function IdentityMatrix (n:index) +$ return setdiag(zeros(n,n),0,1); +$endfunction diff --git a/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-3.euler b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-3.euler new file mode 100644 index 0000000000..35b802b991 --- /dev/null +++ b/Task/Identity-matrix/Euler-Math-Toolbox/identity-matrix-3.euler @@ -0,0 +1 @@ +>id(5) diff --git a/Task/Identity-matrix/Fortran/identity-matrix.f b/Task/Identity-matrix/Fortran/identity-matrix.f new file mode 100644 index 0000000000..a28f8a2212 --- /dev/null +++ b/Task/Identity-matrix/Fortran/identity-matrix.f @@ -0,0 +1,23 @@ +program identitymatrix + + real, dimension(:, :), allocatable :: I + character(len=8) :: fmt + integer :: ms, j + + ms = 10 ! the desired size + + allocate(I(ms,ms)) + I = 0 ! Initialize the array. + forall(j = 1:ms) I(j,j) = 1 ! Set the diagonal. + + ! I is the identity matrix, let's show it: + + write (fmt, '(A,I2,A)') '(', ms, 'F6.2)' + ! if you consider to have used the (row, col) convention, + ! the following will print the transposed matrix (col, row) + ! but I' = I, so it's not important here + write (*, fmt) I(:,:) + + deallocate(I) + +end program identitymatrix diff --git a/Task/Identity-matrix/Go/identity-matrix-1.go b/Task/Identity-matrix/Go/identity-matrix-1.go new file mode 100644 index 0000000000..60dcbdcf4d --- /dev/null +++ b/Task/Identity-matrix/Go/identity-matrix-1.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +func main() { + fmt.Println(I(3)) +} + +func I(n int) [][]float64 { + m := make([][]float64, n) + a := make([]float64, n*n) + for i := 0; i < n; i++ { + a[i] = 1 + m[i] = a[:n] + a = a[n:] + } + return m +} diff --git a/Task/Identity-matrix/Go/identity-matrix-2.go b/Task/Identity-matrix/Go/identity-matrix-2.go new file mode 100644 index 0000000000..713b60d5f9 --- /dev/null +++ b/Task/Identity-matrix/Go/identity-matrix-2.go @@ -0,0 +1,18 @@ +package main + +import "fmt" + +type matrix []float64 + +func main() { + fmt.Println(I(3)) +} + +func I(n int) matrix { + m := make(matrix, n*n) + n++ + for i := 0; i < len(m); i += n { + m[i] = 1 + } + return m +} diff --git a/Task/Identity-matrix/Go/identity-matrix-3.go b/Task/Identity-matrix/Go/identity-matrix-3.go new file mode 100644 index 0000000000..a941c4e97d --- /dev/null +++ b/Task/Identity-matrix/Go/identity-matrix-3.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + + mat "github.com/skelterjohn/go.matrix" +) + +func main() { + fmt.Println(mat.Eye(3)) +} diff --git a/Task/Identity-matrix/Groovy/identity-matrix-1.groovy b/Task/Identity-matrix/Groovy/identity-matrix-1.groovy new file mode 100644 index 0000000000..58c3cf45a6 --- /dev/null +++ b/Task/Identity-matrix/Groovy/identity-matrix-1.groovy @@ -0,0 +1,3 @@ +def makeIdentityMatrix = { n -> + (0.. (0.. (i == j) ? 1 : 0 } } +} diff --git a/Task/Identity-matrix/Groovy/identity-matrix-2.groovy b/Task/Identity-matrix/Groovy/identity-matrix-2.groovy new file mode 100644 index 0000000000..70e7b41f56 --- /dev/null +++ b/Task/Identity-matrix/Groovy/identity-matrix-2.groovy @@ -0,0 +1,5 @@ +(2..6).each { order -> + def iMatrix = makeIdentityMatrix(order) + iMatrix.each { println it } + println() +} diff --git a/Task/Identity-matrix/Haskell/identity-matrix-1.hs b/Task/Identity-matrix/Haskell/identity-matrix-1.hs new file mode 100644 index 0000000000..beeca364ab --- /dev/null +++ b/Task/Identity-matrix/Haskell/identity-matrix-1.hs @@ -0,0 +1 @@ +matI n = [ [fromEnum $ i == j | i <- [1..n]] | j <- [1..n]] diff --git a/Task/Identity-matrix/Haskell/identity-matrix-2.hs b/Task/Identity-matrix/Haskell/identity-matrix-2.hs new file mode 100644 index 0000000000..b54c62bcd1 --- /dev/null +++ b/Task/Identity-matrix/Haskell/identity-matrix-2.hs @@ -0,0 +1,2 @@ +showMat :: [[Int]] -> String +showMat = unlines . map (unwords . map show) diff --git a/Task/Identity-matrix/Haskell/identity-matrix-3.hs b/Task/Identity-matrix/Haskell/identity-matrix-3.hs new file mode 100644 index 0000000000..bc532ded2a --- /dev/null +++ b/Task/Identity-matrix/Haskell/identity-matrix-3.hs @@ -0,0 +1,10 @@ +*Main> putStr $ showMat $ matId 9 +1 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 +0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 1 0 0 +0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 1 diff --git a/Task/Identity-matrix/J/identity-matrix.j b/Task/Identity-matrix/J/identity-matrix.j new file mode 100644 index 0000000000..a209ace2c5 --- /dev/null +++ b/Task/Identity-matrix/J/identity-matrix.j @@ -0,0 +1,12 @@ + = i. 4 NB. create an Identity matrix of size 4 +1 0 0 0 +0 1 0 0 +0 0 1 0 +0 0 0 1 + makeI=: =@i. NB. define as a verb with a user-defined name + makeI 5 NB. create an Identity matrix of size 5 +1 0 0 0 0 +0 1 0 0 0 +0 0 1 0 0 +0 0 0 1 0 +0 0 0 0 1 diff --git a/Task/Identity-matrix/Java/identity-matrix.java b/Task/Identity-matrix/Java/identity-matrix.java new file mode 100644 index 0000000000..ab23e0a972 --- /dev/null +++ b/Task/Identity-matrix/Java/identity-matrix.java @@ -0,0 +1,30 @@ +public class IdentityMatrix { + + public static int[][] matrix(int n){ + int[][] array = new int[n][n]; + + for(int row=0; row LinearAlgebra:-IdentityMatrix( 4 ); + [1 0 0 0] + [ ] + [0 1 0 0] + [ ] + [0 0 1 0] + [ ] + [0 0 0 1] diff --git a/Task/Identity-matrix/Maple/identity-matrix-2.maple b/Task/Identity-matrix/Maple/identity-matrix-2.maple new file mode 100644 index 0000000000..46b45f5d3b --- /dev/null +++ b/Task/Identity-matrix/Maple/identity-matrix-2.maple @@ -0,0 +1,8 @@ +> Matrix( 4, shape = scalar[1], datatype = float[4] ); + [1. 0. 0. 0.] + [ ] + [0. 1. 0. 0.] + [ ] + [0. 0. 1. 0.] + [ ] + [0. 0. 0. 1.] diff --git a/Task/Identity-matrix/Maple/identity-matrix-3.maple b/Task/Identity-matrix/Maple/identity-matrix-3.maple new file mode 100644 index 0000000000..5b9d859671 --- /dev/null +++ b/Task/Identity-matrix/Maple/identity-matrix-3.maple @@ -0,0 +1,8 @@ +> Matrix( 4, shape = identity, datatype = integer[ 2 ] ); + [1 0 0 0] + [ ] + [0 1 0 0] + [ ] + [0 0 1 0] + [ ] + [0 0 0 1] diff --git a/Task/Identity-matrix/Mathematica/identity-matrix.mathematica b/Task/Identity-matrix/Mathematica/identity-matrix.mathematica new file mode 100644 index 0000000000..d199c446bd --- /dev/null +++ b/Task/Identity-matrix/Mathematica/identity-matrix.mathematica @@ -0,0 +1 @@ +IdentityMatrix[4] diff --git a/Task/Identity-matrix/Maxima/identity-matrix.maxima b/Task/Identity-matrix/Maxima/identity-matrix.maxima new file mode 100644 index 0000000000..45e6e408c7 --- /dev/null +++ b/Task/Identity-matrix/Maxima/identity-matrix.maxima @@ -0,0 +1,5 @@ +ident(4); +/* matrix([1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1]) */ diff --git a/Task/Identity-matrix/PHP/identity-matrix.php b/Task/Identity-matrix/PHP/identity-matrix.php new file mode 100644 index 0000000000..c1aba080d1 --- /dev/null +++ b/Task/Identity-matrix/PHP/identity-matrix.php @@ -0,0 +1,25 @@ +function createMatrix($size) +{ + $result = array(); + + for ($i = 0; $i < $size; $i++) { + $row = array_fill(0, $size, 0); + $row[$i] = 1; + $result[] = $row; + } + + return $result; +} + +function printMatrix(array $matrix) +{ + foreach ($matrix as $row) { + foreach ($row as $column) { + echo $column . " "; + } + echo PHP_EOL; + } + echo PHP_EOL; +} + +printMatrix(createMatrix(5)); diff --git a/Task/Identity-matrix/Perl/identity-matrix.pl b/Task/Identity-matrix/Perl/identity-matrix.pl new file mode 100644 index 0000000000..d5efaef8eb --- /dev/null +++ b/Task/Identity-matrix/Perl/identity-matrix.pl @@ -0,0 +1,18 @@ +sub identity_matrix { + my $n = shift; + map { + my $i = $_; + [ map { ($_ == $i) - 0 } 1 .. $n ] + } 1 .. $n; +} + +@ARGV = (4, 5, 6) unless @ARGV; + +for (@ARGV) { + my @id = identity_matrix $_; + print "$_:\n"; + for (my $i=0; $i<@id; ++$i) { + print join ' ', @{$id[$i]}, "\n"; + } + print "\n"; +} diff --git a/Task/Identity-matrix/PicoLisp/identity-matrix-1.l b/Task/Identity-matrix/PicoLisp/identity-matrix-1.l new file mode 100644 index 0000000000..5d525fccfc --- /dev/null +++ b/Task/Identity-matrix/PicoLisp/identity-matrix-1.l @@ -0,0 +1,5 @@ +(de identity (Size) + (let L (need Size (1) 0) + (make + (do Size + (link (copy (rot L))) ) ) ) ) diff --git a/Task/Identity-matrix/PicoLisp/identity-matrix-2.l b/Task/Identity-matrix/PicoLisp/identity-matrix-2.l new file mode 100644 index 0000000000..1f9a578041 --- /dev/null +++ b/Task/Identity-matrix/PicoLisp/identity-matrix-2.l @@ -0,0 +1,9 @@ +: (identity 3) +-> ((1 0 0) (0 1 0) (0 0 1)) + +: (mapc println (identity 5)) +(1 0 0 0 0) +(0 1 0 0 0) +(0 0 1 0 0) +(0 0 0 1 0) +(0 0 0 0 1) diff --git a/Task/Identity-matrix/Python/identity-matrix-1.py b/Task/Identity-matrix/Python/identity-matrix-1.py new file mode 100644 index 0000000000..ac826cff6a --- /dev/null +++ b/Task/Identity-matrix/Python/identity-matrix-1.py @@ -0,0 +1,10 @@ +def identity(size): + matrix = [[0] * size] * size + + for i in range(size): + matrix[i][i] = 1 + + for rows in matrix: + for elements in rows: + print elements, + print "" diff --git a/Task/Identity-matrix/Python/identity-matrix-2.py b/Task/Identity-matrix/Python/identity-matrix-2.py new file mode 100644 index 0000000000..50ac677340 --- /dev/null +++ b/Task/Identity-matrix/Python/identity-matrix-2.py @@ -0,0 +1 @@ +np.mat(np.eye(size)) diff --git a/Task/Identity-matrix/R/identity-matrix-1.r b/Task/Identity-matrix/R/identity-matrix-1.r new file mode 100644 index 0000000000..8c8d5178f9 --- /dev/null +++ b/Task/Identity-matrix/R/identity-matrix-1.r @@ -0,0 +1 @@ +diag(3) diff --git a/Task/Identity-matrix/R/identity-matrix-2.r b/Task/Identity-matrix/R/identity-matrix-2.r new file mode 100644 index 0000000000..6171cb3b61 --- /dev/null +++ b/Task/Identity-matrix/R/identity-matrix-2.r @@ -0,0 +1,4 @@ + [,1] [,2] [,3] +[1,] 1 0 0 +[2,] 0 1 0 +[3,] 0 0 1 diff --git a/Task/Identity-matrix/REXX/identity-matrix-1.rexx b/Task/Identity-matrix/REXX/identity-matrix-1.rexx new file mode 100644 index 0000000000..aef3b23ed6 --- /dev/null +++ b/Task/Identity-matrix/REXX/identity-matrix-1.rexx @@ -0,0 +1,28 @@ +/*REXX program to create and display an identity matrix. */ +call identity_matrix 4 /*build and display a 4x4 matrix.*/ +call identity_matrix 5 /*build and display a 5x5 matrix.*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────IDENTITY_MATRIX subroutine───────*/ +identity_matrix: procedure; parse arg n; $= + + do r=1 for n /*build indentity matrix, by row,*/ + do c=1 for n /* and by cow.*/ + $=$ (r==c) /*append zero or one (if on diag)*/ + end /*c*/ + end /*r*/ + +call showMatrix 'identity matrix of size' n,$,n +return +/*─────────────────────────────────────TELL subroutine───&find the order*/ +showMatrix: procedure; parse arg hdr,x,order,sep; if sep=='' then sep='═' + width=2 /*width of field to be used to display the elements*/ +decPlaces=1 /*# decimal places to the right of decimal point. */ +say; say center(hdr,max(length(hdr)+6,(width+1)*words(x)%order),sep); say +#=0 + do row=1 for order; aLine= + do col=1 for order; #=#+1 + aLine=aLine right(format(word(x,#),,decPlaces)/1, width) + end /*col*/ /*dividing by 1 normalizes the #.*/ + say aLine + end /*row*/ +return diff --git a/Task/Identity-matrix/REXX/identity-matrix-2.rexx b/Task/Identity-matrix/REXX/identity-matrix-2.rexx new file mode 100644 index 0000000000..42c49c8081 --- /dev/null +++ b/Task/Identity-matrix/REXX/identity-matrix-2.rexx @@ -0,0 +1,16 @@ +/* REXX *************************************************************** +* show identity matrix of size n +* I consider m.i.j to represent the matrix (not needed for showing) +* 06.07.2012 Walter Pachl +**********************************************************************/ +Parse Arg n +Say 'Identity Matrix of size' n '(m.i.j IS the Matrix)' +m.=0 +Do i=1 To n + ol='' + Do j=1 To n + m.i.j=(i=j) + ol=ol''format(m.i.j,2) /* or ol=ol (i=j) */ + End + Say ol + End diff --git a/Task/Identity-matrix/REXX/identity-matrix-3.rexx b/Task/Identity-matrix/REXX/identity-matrix-3.rexx new file mode 100644 index 0000000000..0353bef9dc --- /dev/null +++ b/Task/Identity-matrix/REXX/identity-matrix-3.rexx @@ -0,0 +1,3 @@ +m.=0 +m.0=1000 /* the matrix' size */ +m.4.17.333='Walter' diff --git a/Task/Identity-matrix/Racket/identity-matrix.rkt b/Task/Identity-matrix/Racket/identity-matrix.rkt new file mode 100644 index 0000000000..f94fd6e275 --- /dev/null +++ b/Task/Identity-matrix/Racket/identity-matrix.rkt @@ -0,0 +1,3 @@ +#lang racket +(require math) +(identity-matrix 5) diff --git a/Task/Identity-matrix/Ruby/identity-matrix.rb b/Task/Identity-matrix/Ruby/identity-matrix.rb new file mode 100644 index 0000000000..b2535b2fad --- /dev/null +++ b/Task/Identity-matrix/Ruby/identity-matrix.rb @@ -0,0 +1,7 @@ +def identity(size) + size.times.map { |i| size.times.map { |j| i == j ? 1 : 0 } } +end + +[4,5,6].each do |size| + puts size, identity(size.to_i).map {|r| r.to_s}, "" +end diff --git a/Task/Identity-matrix/Scala/identity-matrix.scala b/Task/Identity-matrix/Scala/identity-matrix.scala new file mode 100644 index 0000000000..8f5c90e229 --- /dev/null +++ b/Task/Identity-matrix/Scala/identity-matrix.scala @@ -0,0 +1,4 @@ +def identityMatrix(n:Int)=Array.tabulate(n,n)((x,y) => if(x==y) 1 else 0) +def printMatrix[T](m:Array[Array[T]])=m map (_.mkString("[", ", ", "]")) mkString "\n" + +printMatrix(identityMatrix(5)) diff --git a/Task/Identity-matrix/Scheme/identity-matrix-1.ss b/Task/Identity-matrix/Scheme/identity-matrix-1.ss new file mode 100644 index 0000000000..fcd8fd0dcc --- /dev/null +++ b/Task/Identity-matrix/Scheme/identity-matrix-1.ss @@ -0,0 +1,15 @@ +(define (identity n) + (letrec + ((uvec + (lambda (m i acc) + (if (= i n) + acc + (uvec m (+ i 1) + (cons (if (= i m) 1 0) acc))))) + (idgen + (lambda (i acc) + (if (= i n) + acc + (idgen (+ i 1) + (cons (uvec i 0 '()) acc)))))) + (idgen 0 '()))) diff --git a/Task/Identity-matrix/Scheme/identity-matrix-2.ss b/Task/Identity-matrix/Scheme/identity-matrix-2.ss new file mode 100644 index 0000000000..2137cff9ff --- /dev/null +++ b/Task/Identity-matrix/Scheme/identity-matrix-2.ss @@ -0,0 +1 @@ +(display (identity 4)) diff --git a/Task/Identity-matrix/Tcl/identity-matrix-1.tcl b/Task/Identity-matrix/Tcl/identity-matrix-1.tcl new file mode 100644 index 0000000000..17692fce2d --- /dev/null +++ b/Task/Identity-matrix/Tcl/identity-matrix-1.tcl @@ -0,0 +1,7 @@ +proc I {rank {zero 0.0} {one 1.0}} { + set m [lrepeat $rank [lrepeat $rank $zero]] + for {set i 0} {$i < $rank} {incr i} { + lset m $i $i $one + } + return $m +} diff --git a/Task/Identity-matrix/Tcl/identity-matrix-2.tcl b/Task/Identity-matrix/Tcl/identity-matrix-2.tcl new file mode 100644 index 0000000000..2342fdd286 --- /dev/null +++ b/Task/Identity-matrix/Tcl/identity-matrix-2.tcl @@ -0,0 +1,13 @@ +package require struct::matrix + +proc I {rank {zero 0.0} {one 1.0}} { + set m [struct::matrix] + $m add columns $rank + $m add rows $rank + for {set i 0} {$i < $rank} {incr i} { + for {set j 0} {$j < $rank} {incr j} { + $m set cell $i $j [expr {$i==$j ? $one : $zero}] + } + } + return $m +} diff --git a/Task/Identity-matrix/Tcl/identity-matrix-3.tcl b/Task/Identity-matrix/Tcl/identity-matrix-3.tcl new file mode 100644 index 0000000000..fca3ad8694 --- /dev/null +++ b/Task/Identity-matrix/Tcl/identity-matrix-3.tcl @@ -0,0 +1,2 @@ +set m [I 5 0 1] ;# Integer 0/1 for clarity of presentation +puts [$m format 2string] diff --git a/Task/Image-convolution/0DESCRIPTION b/Task/Image-convolution/0DESCRIPTION new file mode 100644 index 0000000000..9fd4998177 --- /dev/null +++ b/Task/Image-convolution/0DESCRIPTION @@ -0,0 +1,11 @@ +One class of image digital filters is described by a rectangular matrix of real coefficients called '''kernel''' convoluted in a sliding window of image pixels. Usually the kernel is square K_{kl}, where k, l are in the range -R,-R+1,..,R-1,R. W=2R+1 is the kernel width. The filter determines the new value of a monochromatic image pixel Pij as a convolution of the image pixels in the window centered in i, j and the kernel values: + +
+P_{ij}=\displaystyle\sum_{k=-R}^R \sum_{l=-R}^R P_{i+k\ j+l} K_{k l} +
+ +Color images are usually split into the channels which are filtered independently. A color model can be changed as well, i.e. filtration is performed not necessarily in RGB. Common kernels sizes are 3x3 and 5x5. The complexity of filtrating grows quadratically ([[O]](n2)) with the kernel width. + +'''Task''': Write a generic convolution 3x3 kernel filter. Optionally show some end user filters that use this generic one. + +''(You can use, to test the functions below, these [[Read_ppm_file|input]] and [[Write_ppm_file|output]] solutions.)'' diff --git a/Task/Image-convolution/1META.yaml b/Task/Image-convolution/1META.yaml new file mode 100644 index 0000000000..58807afa1b --- /dev/null +++ b/Task/Image-convolution/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Image processing diff --git a/Task/Image-convolution/Ada/image-convolution-1.ada b/Task/Image-convolution/Ada/image-convolution-1.ada new file mode 100644 index 0000000000..79eedade0d --- /dev/null +++ b/Task/Image-convolution/Ada/image-convolution-1.ada @@ -0,0 +1,35 @@ +type Float_Luminance is new Float; + +type Float_Pixel is record + R, G, B : Float_Luminance := 0.0; +end record; + +function "*" (Left : Float_Pixel; Right : Float_Luminance) return Float_Pixel is + pragma Inline ("*"); +begin + return (Left.R * Right, Left.G * Right, Left.B * Right); +end "*"; + +function "+" (Left, Right : Float_Pixel) return Float_Pixel is + pragma Inline ("+"); +begin + return (Left.R + Right.R, Left.G + Right.G, Left.B + Right.B); +end "+"; + +function To_Luminance (X : Float_Luminance) return Luminance is + pragma Inline (To_Luminance); +begin + if X <= 0.0 then + return 0; + elsif X >= 255.0 then + return 255; + else + return Luminance (X); + end if; +end To_Luminance; + +function To_Pixel (X : Float_Pixel) return Pixel is + pragma Inline (To_Pixel); +begin + return (To_Luminance (X.R), To_Luminance (X.G), To_Luminance (X.B)); +end To_Pixel; diff --git a/Task/Image-convolution/Ada/image-convolution-2.ada b/Task/Image-convolution/Ada/image-convolution-2.ada new file mode 100644 index 0000000000..fc931e3fb9 --- /dev/null +++ b/Task/Image-convolution/Ada/image-convolution-2.ada @@ -0,0 +1,46 @@ +type Kernel_3x3 is array (-1..1, -1..1) of Float_Luminance; + +procedure Filter (Picture : in out Image; K : Kernel_3x3) is + function Get (I, J : Integer) return Float_Pixel is + pragma Inline (Get); + begin + if I in Picture'Range (1) and then J in Picture'Range (2) then + declare + Color : Pixel := Picture (I, J); + begin + return (Float_Luminance (Color.R), Float_Luminance (Color.G), Float_Luminance (Color.B)); + end; + else + return (others => 0.0); + end if; + end Get; + W11, W12, W13 : Float_Pixel; -- The image window + W21, W22, W23 : Float_Pixel; + W31, W32, W33 : Float_Pixel; + Above : array (Picture'First (2) - 1..Picture'Last (2) + 1) of Float_Pixel; + This : Float_Pixel; +begin + for I in Picture'Range (1) loop + W11 := Above (Picture'First (2) - 1); -- The upper row is taken from the cache + W12 := Above (Picture'First (2) ); + W13 := Above (Picture'First (2) + 1); + W21 := (others => 0.0); -- The middle row + W22 := Get (I, Picture'First (2) ); + W23 := Get (I, Picture'First (2) + 1); + W31 := (others => 0.0); -- The bottom row + W32 := Get (I+1, Picture'First (2) ); + W33 := Get (I+1, Picture'First (2) + 1); + for J in Picture'Range (2) loop + This := + W11 * K (-1, -1) + W12 * K (-1, 0) + W13 * K (-1, 1) + + W21 * K ( 0, -1) + W22 * K ( 0, 0) + W23 * K ( 0, 1) + + W31 * K ( 1, -1) + W32 * K ( 1, 0) + W33 * K ( 1, 1); + Above (J-1) := W21; + W11 := W12; W12 := W13; W13 := Above (J+1); -- Shift the window + W21 := W22; W22 := W23; W23 := Get (I, J+1); + W31 := W32; W32 := W23; W33 := Get (I+1, J+1); + Picture (I, J) := To_Pixel (This); + end loop; + Above (Picture'Last (2)) := W21; + end loop; +end Filter; diff --git a/Task/Image-convolution/Ada/image-convolution-3.ada b/Task/Image-convolution/Ada/image-convolution-3.ada new file mode 100644 index 0000000000..bb0f56ba44 --- /dev/null +++ b/Task/Image-convolution/Ada/image-convolution-3.ada @@ -0,0 +1,12 @@ + F1, F2 : File_Type; +begin + Open (F1, In_File, "city.ppm"); + declare + X : Image := Get_PPM (F1); + begin + Close (F1); + Create (F2, Out_File, "city_sharpen.ppm"); + Filter (X, ((-1.0, -1.0, -1.0), (-1.0, 9.0, -1.0), (-1.0, -1.0, -1.0))); + Put_PPM (F2, X); + end; + Close (F2); diff --git a/Task/Image-convolution/BBC-BASIC/image-convolution.bbc b/Task/Image-convolution/BBC-BASIC/image-convolution.bbc new file mode 100644 index 0000000000..0f4babd908 --- /dev/null +++ b/Task/Image-convolution/BBC-BASIC/image-convolution.bbc @@ -0,0 +1,46 @@ + Width% = 200 + Height% = 200 + + DIM out&(Width%-1, Height%-1, 2) + + VDU 23,22,Width%;Height%;8,16,16,128 + *DISPLAY Lena + OFF + + DIM filter%(2, 2) + filter%() = -1, -1, -1, -1, 12, -1, -1, -1, -1 + + REM Do the convolution: + FOR Y% = 1 TO Height%-2 + FOR X% = 1 TO Width%-2 + R% = 0 : G% = 0 : B% = 0 + FOR I% = -1 TO 1 + FOR J% = -1 TO 1 + C% = TINT((X%+I%)*2, (Y%+J%)*2) + F% = filter%(I%+1,J%+1) + R% += F% * (C% AND &FF) + G% += F% * (C% >> 8 AND &FF) + B% += F% * (C% >> 16) + NEXT + NEXT + IF R% < 0 R% = 0 ELSE IF R% > 1020 R% = 1020 + IF G% < 0 G% = 0 ELSE IF G% > 1020 G% = 1020 + IF B% < 0 B% = 0 ELSE IF B% > 1020 B% = 1020 + out&(X%, Y%, 0) = R% / 4 + 0.5 + out&(X%, Y%, 1) = G% / 4 + 0.5 + out&(X%, Y%, 2) = B% / 4 + 0.5 + NEXT + NEXT Y% + + REM Display: + GCOL 1 + FOR Y% = 0 TO Height%-1 + FOR X% = 0 TO Width%-1 + COLOUR 1, out&(X%,Y%,0), out&(X%,Y%,1), out&(X%,Y%,2) + LINE X%*2,Y%*2,X%*2,Y%*2 + NEXT + NEXT Y% + + REPEAT + WAIT 1 + UNTIL FALSE diff --git a/Task/Image-convolution/C/image-convolution-1.c b/Task/Image-convolution/C/image-convolution-1.c new file mode 100644 index 0000000000..938954ee94 --- /dev/null +++ b/Task/Image-convolution/C/image-convolution-1.c @@ -0,0 +1 @@ +image filter(image img, double *K, int Ks, double, double); diff --git a/Task/Image-convolution/C/image-convolution-2.c b/Task/Image-convolution/C/image-convolution-2.c new file mode 100644 index 0000000000..9ca2caafa1 --- /dev/null +++ b/Task/Image-convolution/C/image-convolution-2.c @@ -0,0 +1,39 @@ +#include "imglib.h" + +inline static color_component GET_PIXEL_CHECK(image img, int x, int y, int l) { + if ( (x<0) || (x >= img->width) || (y<0) || (y >= img->height) ) return 0; + return GET_PIXEL(img, x, y)[l]; +} + +image filter(image im, double *K, int Ks, double divisor, double offset) +{ + image oi; + unsigned int ix, iy, l; + int kx, ky; + double cp[3]; + + oi = alloc_img(im->width, im->height); + if ( oi != NULL ) { + for(ix=0; ix < im->width; ix++) { + for(iy=0; iy < im->height; iy++) { + cp[0] = cp[1] = cp[2] = 0.0; + for(kx=-Ks; kx <= Ks; kx++) { + for(ky=-Ks; ky <= Ks; ky++) { + for(l=0; l<3; l++) + cp[l] += (K[(kx+Ks) + + (ky+Ks)*(2*Ks+1)]/divisor) * + ((double)GET_PIXEL_CHECK(im, ix+kx, iy+ky, l)) + offset; + } + } + for(l=0; l<3; l++) + cp[l] = (cp[l]>255.0) ? 255.0 : ((cp[l]<0.0) ? 0.0 : cp[l]) ; + put_pixel_unsafe(oi, ix, iy, + (color_component)cp[0], + (color_component)cp[1], + (color_component)cp[2]); + } + } + return oi; + } + return NULL; +} diff --git a/Task/Image-convolution/C/image-convolution-3.c b/Task/Image-convolution/C/image-convolution-3.c new file mode 100644 index 0000000000..1ff83162e2 --- /dev/null +++ b/Task/Image-convolution/C/image-convolution-3.c @@ -0,0 +1,61 @@ +#include +#include "imglib.h" + +const char *input = "Lenna100.jpg"; +const char *output = "filtered_lenna%d.ppm"; + +double emboss_kernel[3*3] = { + -2., -1., 0., + -1., 1., 1., + 0., 1., 2., +}; + +double sharpen_kernel[3*3] = { + -1.0, -1.0, -1.0, + -1.0, 9.0, -1.0, + -1.0, -1.0, -1.0 +}; +double sobel_emboss_kernel[3*3] = { + -1., -2., -1., + 0., 0., 0., + 1., 2., 1., +}; +double box_blur_kernel[3*3] = { + 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, +}; + +double *filters[4] = { + emboss_kernel, sharpen_kernel, sobel_emboss_kernel, box_blur_kernel +}; +const double filter_params[2*4] = { + 1.0, 0.0, + 1.0, 0.0, + 1.0, 0.5, + 9.0, 0.0 +}; + +int main() +{ + image ii, oi; + int i; + char lennanames[30]; + + ii = read_image(input); + if ( ii != NULL ) { + for(i=0; i<4; i++) { + sprintf(lennanames, output, i); + oi = filter(ii, filters[i], 1, filter_params[2*i], filter_params[2*i+1]); + if ( oi != NULL ) { + FILE *outfh = fopen(lennanames, "w"); + if ( outfh != NULL ) { + output_ppm(outfh, oi); + fclose(outfh); + } else { fprintf(stderr, "out err %s\n", output); } + free_img(oi); + } else { fprintf(stderr, "err creating img filters %d\n", i); } + } + free_img(ii); + } else { fprintf(stderr, "err reading %s\n", input); } +} diff --git a/Task/Image-convolution/D/image-convolution.d b/Task/Image-convolution/D/image-convolution.d new file mode 100644 index 0000000000..6385b01cca --- /dev/null +++ b/Task/Image-convolution/D/image-convolution.d @@ -0,0 +1,116 @@ +import std.string, std.math, std.algorithm, grayscale_image; + +struct ConvolutionFilter { + double[][] kernel; + double divisor, offset_; + string name; +} + + +Image!Color convolve(Color)(in Image!Color im, + in ConvolutionFilter filter) +pure nothrow in { + assert(im !is null); + assert(!isnan(filter.divisor) && !isnan(filter.offset_)); + assert(filter.divisor != 0); + assert(filter.kernel.length > 0 && filter.kernel[0].length > 0); + foreach (const row; filter.kernel) // Is rectangular. + assert(row.length == filter.kernel[0].length); + assert(filter.kernel.length % 2 == 1); // Odd sized kernel. + assert(filter.kernel[0].length % 2 == 1); + assert(im.ny >= filter.kernel.length); + assert(im.nx >= filter.kernel[0].length); +} out(result) { + assert(result !is null); + assert(result.nx == im.nx && result.ny == im.ny); +} body { + immutable knx2 = filter.kernel[0].length / 2; + immutable kny2 = filter.kernel.length / 2; + auto io = new Image!Color(im.nx, im.ny); + + static if (is(Color == RGB)) + alias CT = typeof(Color.r); // Component type. + else static if (is(typeof(Color.c))) + alias CT = typeof(Color.c); + else + alias CT = Color; + + foreach (immutable y; kny2 .. im.ny - kny2) { + foreach (immutable x; knx2 .. im.nx - knx2) { + static if (is(Color == RGB)) + double[3] total = 0.0; + else + double total = 0.0; + + foreach (immutable sy, const kRow; filter.kernel) { + foreach (immutable sx, immutable k; kRow) { + immutable p = im[x + sx - knx2, y + sy - kny2]; + static if (is(Color == RGB)) { + total[0] += p.r * k; + total[1] += p.g * k; + total[2] += p.b * k; + } else { + total += p * k; + } + } + } + + immutable D = filter.divisor; + immutable O = filter.offset_ * CT.max; + static if (is(Color == RGB)) { + io[x, y] = Color( + cast(CT)min(max(total[0]/ D + O, CT.min), CT.max), + cast(CT)min(max(total[1]/ D + O, CT.min), CT.max), + cast(CT)min(max(total[2]/ D + O, CT.min), CT.max)); + } else static if (is(typeof(Color.c))) { + io[x, y] = Color( + cast(CT)min(max(total / D + O, CT.min), CT.max)); + } else { + // If Color doesn't have a 'c' field, then Color is + // assumed to be a built-in type. + io[x, y] = + cast(CT)min(max(total / D + O, CT.min), CT.max); + } + } + } + + return io; +} + + +void main() { + immutable ConvolutionFilter[] filters = [ + {[[-2.0, -1.0, 0.0], + [-1.0, 1.0, 1.0], + [ 0.0, 1.0, 2.0]], divisor:1.0, offset_:0.0, name:"Emboss"}, + + {[[-1.0, -1.0, -1.0], + [-1.0, 9.0, -1.0], + [-1.0, -1.0, -1.0]], divisor:1.0, 0.0, "Sharpen"}, + + {[[-1.0, -2.0, -1.0], + [ 0.0, 0.0, 0.0], + [ 1.0, 2.0, 1.0]], divisor:1.0, 0.5, "Sobel_emboss"}, + + {[[1.0, 1.0, 1.0], + [1.0, 1.0, 1.0], + [1.0, 1.0, 1.0]], divisor:9.0, 0.0, "Box_blur"}, + + {[[1, 4, 7, 4, 1], + [4, 16, 26, 16, 4], + [7, 26, 41, 26, 7], + [4, 16, 26, 16, 4], + [1, 4, 7, 4, 1]], divisor:273, 0.0, "Gaussian_blur"}]; + + Image!RGB im; + im.loadPPM6("Lenna100.ppm"); + + foreach (immutable filter; filters) + im.convolve(filter) + .savePPM6(format("lenna_%s.ppm", filter.name)); + + const img = im.rgb2grayImage(); + foreach (immutable filter; filters) + img.convolve(filter) + .savePGM(format("lenna_gray_%s.ppm", filter.name)); +} diff --git a/Task/Image-convolution/Go/image-convolution-1.go b/Task/Image-convolution/Go/image-convolution-1.go new file mode 100644 index 0000000000..e0f10d6c2f --- /dev/null +++ b/Task/Image-convolution/Go/image-convolution-1.go @@ -0,0 +1,91 @@ +package main + +import ( + "fmt" + "image" + "image/color" + "image/jpeg" + "math" + "os" +) + +// kf3 is a generic convolution 3x3 kernel filter that operatates on +// images of type image.Gray from the Go standard image library. +func kf3(k *[9]float64, src, dst *image.Gray) { + for y := src.Rect.Min.Y; y < src.Rect.Max.Y; y++ { + for x := src.Rect.Min.X; x < src.Rect.Max.X; x++ { + var sum float64 + var i int + for yo := y - 1; yo <= y+1; yo++ { + for xo := x - 1; xo <= x+1; xo++ { + if (image.Point{xo, yo}).In(src.Rect) { + sum += k[i] * float64(src.At(xo, yo).(color.Gray).Y) + } else { + sum += k[i] * float64(src.At(x, y).(color.Gray).Y) + } + i++ + } + } + dst.SetGray(x, y, + color.Gray{uint8(math.Min(255, math.Max(0, sum)))}) + } + } +} + +var blur = [9]float64{ + 1. / 9, 1. / 9, 1. / 9, + 1. / 9, 1. / 9, 1. / 9, + 1. / 9, 1. / 9, 1. / 9} + +// blurY example function applies blur kernel to Y channel +// of YCbCr image using generic kernel filter function kf3 +func blurY(src *image.YCbCr) *image.YCbCr { + dst := *src + + // catch zero-size image here + if src.Rect.Max.X == src.Rect.Min.X || src.Rect.Max.Y == src.Rect.Min.Y { + return &dst + } + + // pass Y channels as gray images + srcGray := image.Gray{src.Y, src.YStride, src.Rect} + dstGray := srcGray + dstGray.Pix = make([]uint8, len(src.Y)) + kf3(&blur, &srcGray, &dstGray) // call generic convolution function + + // complete result + dst.Y = dstGray.Pix // convolution result + dst.Cb = append([]uint8{}, src.Cb...) // Cb, Cr are just copied + dst.Cr = append([]uint8{}, src.Cr...) + return &dst +} + +func main() { + // Example file used here is Lenna100.jpg from the task "Percentage + // difference between images" + f, err := os.Open("Lenna100.jpg") + if err != nil { + fmt.Println(err) + return + } + img, err := jpeg.Decode(f) + if err != nil { + fmt.Println(err) + return + } + f.Close() + y, ok := img.(*image.YCbCr) + if !ok { + fmt.Println("expected color jpeg") + return + } + f, err = os.Create("blur.jpg") + if err != nil { + fmt.Println(err) + return + } + err = jpeg.Encode(f, blurY(y), &jpeg.Options{90}) + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Image-convolution/Go/image-convolution-2.go b/Task/Image-convolution/Go/image-convolution-2.go new file mode 100644 index 0000000000..bd6fa6dd00 --- /dev/null +++ b/Task/Image-convolution/Go/image-convolution-2.go @@ -0,0 +1,72 @@ +package raster + +import "math" + +func (g *Grmap) KernelFilter3(k []float64) *Grmap { + if len(k) != 9 { + return nil + } + r := NewGrmap(g.cols, g.rows) + r.Comments = append([]string{}, g.Comments...) + // Filter edge pixels with minimal code. + // Execution time per pixel is high but there are few edge pixels + // relative to the interior. + o3 := [][]int{ + {-1, -1}, {0, -1}, {1, -1}, + {-1, 0}, {0, 0}, {1, 0}, + {-1, 1}, {0, 1}, {1, 1}} + edge := func(x, y int) uint16 { + var sum float64 + for i, o := range o3 { + c, ok := g.GetPx(x+o[0], y+o[1]) + if !ok { + c = g.pxRow[y][x] + } + sum += float64(c) * k[i] + } + return uint16(math.Min(math.MaxUint16, math.Max(0,sum))) + } + for x := 0; x < r.cols; x++ { + r.pxRow[0][x] = edge(x, 0) + r.pxRow[r.rows-1][x] = edge(x, r.rows-1) + } + for y := 1; y < r.rows-1; y++ { + r.pxRow[y][0] = edge(0, y) + r.pxRow[y][r.cols-1] = edge(r.cols-1, y) + } + if r.rows < 3 || r.cols < 3 { + return r + } + + // Interior pixels can be filtered much more efficiently. + otr := -g.cols + 1 + obr := g.cols + 1 + z := g.cols + 1 + c2 := g.cols - 2 + for y := 1; y < r.rows-1; y++ { + tl := float64(g.pxRow[y-1][0]) + tc := float64(g.pxRow[y-1][1]) + tr := float64(g.pxRow[y-1][2]) + ml := float64(g.pxRow[y][0]) + mc := float64(g.pxRow[y][1]) + mr := float64(g.pxRow[y][2]) + bl := float64(g.pxRow[y+1][0]) + bc := float64(g.pxRow[y+1][1]) + br := float64(g.pxRow[y+1][2]) + for x := 1; ; x++ { + r.px[z] = uint16(math.Min(math.MaxUint16, math.Max(0, + tl*k[0] + tc*k[1] + tr*k[2] + + ml*k[3] + mc*k[4] + mr*k[5] + + bl*k[6] + bc*k[7] + br*k[8]))) + if x == c2 { + break + } + z++ + tl, tc, tr = tc, tr, float64(g.px[z+otr]) + ml, mc, mr = mc, mr, float64(g.px[z+1]) + bl, bc, br = bc, br, float64(g.px[z+obr]) + } + z += 3 + } + return r +} diff --git a/Task/Image-convolution/Go/image-convolution-3.go b/Task/Image-convolution/Go/image-convolution-3.go new file mode 100644 index 0000000000..600c269560 --- /dev/null +++ b/Task/Image-convolution/Go/image-convolution-3.go @@ -0,0 +1,40 @@ +package main + +// Files required to build supporting package raster are found in: +// * This task (immediately above) +// * Bitmap +// * Grayscale image +// * Read a PPM file +// * Write a PPM file + +import ( + "fmt" + "raster" +) + +var blur = []float64{ + 1./9, 1./9, 1./9, + 1./9, 1./9, 1./9, + 1./9, 1./9, 1./9} + +var sharpen = []float64{ + -1, -1, -1, + -1, 9, -1, + -1, -1, -1} + +func main() { + // Example file used here is Lenna100.jpg from the task "Percentage + // difference between images" converted with with the command + // convert Lenna100.jpg -colorspace gray Lenna100.ppm + b, err := raster.ReadPpmFile("Lenna100.ppm") + if err != nil { + fmt.Println(err) + return + } + g0 := b.Grmap() + g1 := g0.KernelFilter3(blur) + err = g1.Bitmap().WritePpmFile("blur.ppm") + if err != nil { + fmt.Println(err) + } +} diff --git a/Task/Image-convolution/J/image-convolution.j b/Task/Image-convolution/J/image-convolution.j new file mode 100644 index 0000000000..8c7ea93a61 --- /dev/null +++ b/Task/Image-convolution/J/image-convolution.j @@ -0,0 +1,11 @@ +NB. pad the first n dimensions of an array with zeros +NB. (increasing all dimensions by 1 less than the kernel size) +pad=: adverb define + adj1=: <.m%2 + adj2=: m-1 + (-@(adj2 + ]) {. (adj1 + ]) {. [) (#m) {. $ +) + +kernel_filter=: adverb define + [: ,/"(-#$m) ($m) +/@(,/^:(_1+#$m))@:*&m;._3 ($m)pad +) diff --git a/Task/Image-convolution/Java/image-convolution.java b/Task/Image-convolution/Java/image-convolution.java new file mode 100644 index 0000000000..8b8ab38577 --- /dev/null +++ b/Task/Image-convolution/Java/image-convolution.java @@ -0,0 +1,141 @@ +import java.awt.image.*; +import java.io.File; +import java.io.IOException; +import javax.imageio.*; + +public class ImageConvolution +{ + public static class ArrayData + { + public final int[] dataArray; + public final int width; + public final int height; + + public ArrayData(int width, int height) + { + this(new int[width * height], width, height); + } + + public ArrayData(int[] dataArray, int width, int height) + { + this.dataArray = dataArray; + this.width = width; + this.height = height; + } + + public int get(int x, int y) + { return dataArray[y * width + x]; } + + public void set(int x, int y, int value) + { dataArray[y * width + x] = value; } + } + + private static int bound(int value, int endIndex) + { + if (value < 0) + return 0; + if (value < endIndex) + return value; + return endIndex - 1; + } + + public static ArrayData convolute(ArrayData inputData, ArrayData kernel, int kernelDivisor) + { + int inputWidth = inputData.width; + int inputHeight = inputData.height; + int kernelWidth = kernel.width; + int kernelHeight = kernel.height; + if ((kernelWidth <= 0) || ((kernelWidth & 1) != 1)) + throw new IllegalArgumentException("Kernel must have odd width"); + if ((kernelHeight <= 0) || ((kernelHeight & 1) != 1)) + throw new IllegalArgumentException("Kernel must have odd height"); + int kernelWidthRadius = kernelWidth >>> 1; + int kernelHeightRadius = kernelHeight >>> 1; + + ArrayData outputData = new ArrayData(inputWidth, inputHeight); + for (int i = inputWidth - 1; i >= 0; i--) + { + for (int j = inputHeight - 1; j >= 0; j--) + { + double newValue = 0.0; + for (int kw = kernelWidth - 1; kw >= 0; kw--) + for (int kh = kernelHeight - 1; kh >= 0; kh--) + newValue += kernel.get(kw, kh) * inputData.get( + bound(i + kw - kernelWidthRadius, inputWidth), + bound(j + kh - kernelHeightRadius, inputHeight)); + outputData.set(i, j, (int)Math.round(newValue / kernelDivisor)); + } + } + return outputData; + } + + public static ArrayData[] getArrayDatasFromImage(String filename) throws IOException + { + BufferedImage inputImage = ImageIO.read(new File(filename)); + int width = inputImage.getWidth(); + int height = inputImage.getHeight(); + int[] rgbData = inputImage.getRGB(0, 0, width, height, null, 0, width); + ArrayData reds = new ArrayData(width, height); + ArrayData greens = new ArrayData(width, height); + ArrayData blues = new ArrayData(width, height); + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + int rgbValue = rgbData[y * width + x]; + reds.set(x, y, (rgbValue >>> 16) & 0xFF); + greens.set(x, y, (rgbValue >>> 8) & 0xFF); + blues.set(x, y, rgbValue & 0xFF); + } + } + return new ArrayData[] { reds, greens, blues }; + } + + public static void writeOutputImage(String filename, ArrayData[] redGreenBlue) throws IOException + { + ArrayData reds = redGreenBlue[0]; + ArrayData greens = redGreenBlue[1]; + ArrayData blues = redGreenBlue[2]; + BufferedImage outputImage = new BufferedImage(reds.width, reds.height, + BufferedImage.TYPE_INT_ARGB); + for (int y = 0; y < reds.height; y++) + { + for (int x = 0; x < reds.width; x++) + { + int red = bound(reds.get(x, y), 256); + int green = bound(greens.get(x, y), 256); + int blue = bound(blues.get(x, y), 256); + outputImage.setRGB(x, y, (red << 16) | (green << 8) | blue | -0x01000000); + } + } + ImageIO.write(outputImage, "PNG", new File(filename)); + return; + } + + public static void main(String[] args) throws IOException + { + int kernelWidth = Integer.parseInt(args[2]); + int kernelHeight = Integer.parseInt(args[3]); + int kernelDivisor = Integer.parseInt(args[4]); + System.out.println("Kernel size: " + kernelWidth + "x" + kernelHeight + + ", divisor=" + kernelDivisor); + int y = 5; + ArrayData kernel = new ArrayData(kernelWidth, kernelHeight); + for (int i = 0; i < kernelHeight; i++) + { + System.out.print("["); + for (int j = 0; j < kernelWidth; j++) + { + kernel.set(j, i, Integer.parseInt(args[y++])); + System.out.print(" " + kernel.get(j, i) + " "); + } + System.out.println("]"); + } + + ArrayData[] dataArrays = getArrayDatasFromImage(args[0]); + for (int i = 0; i < dataArrays.length; i++) + dataArrays[i] = convolute(dataArrays[i], kernel, kernelDivisor); + writeOutputImage(args[1], dataArrays); + return; + } +} diff --git a/Task/Image-convolution/Liberty-BASIC/image-convolution.liberty b/Task/Image-convolution/Liberty-BASIC/image-convolution.liberty new file mode 100644 index 0000000000..f7dc7967b6 --- /dev/null +++ b/Task/Image-convolution/Liberty-BASIC/image-convolution.liberty @@ -0,0 +1,95 @@ + dim result( 300, 300), image( 300, 300), mask( 100, 100) + w =128 + h =128 + + nomainwin + + WindowWidth = 460 + WindowHeight = 210 + + open "Convolution" for graphics_nsb_nf as #w + + #w "trapclose [quit]" + + #w "down ; fill darkblue" + + hw = hwnd( #w) + calldll #user32,"GetDC", hw as ulong, hdc as ulong + + loadbmp "img", "alpha25.bmp"' 128x128 pixels + #w "drawbmp img 20, 20" + + #w "up ; color white ; goto 292 20 ; down ; box 420 148" + #w "up ; goto 180 60 ; down ; backcolor darkblue ; color cyan" + #w "\"; "Convolved with" + + for y =0 to 127 ' fill in the input matrix + for x =0 to 127 + xx =x + 20 + yy =y + 20 + CallDLL #gdi32, "GetPixel", hdc as uLong, xx as long, yy as long, pixcol as ulong + call getRGB pixcol, b, g, r + image( x, y) =b + '#w "color "; image( x, y); " 0 "; 255 -image( x, y) + '#w "set "; x + 20; " "; y +20 +140 + next x + next y + + #w "flush" + print " Input matrix filled." + + #w "size 8" + for y =0 to 2 ' fill in the mask matrix + for x =0 to 2 + read mask + mask( x, y) =mask + if mask = ( 0 -1) then #w "color yellow" else #w "color red" + #w "set "; 8 *x +200; " "; 8 *y +80 + next x + next y + data -1,-1,-1,-1,9,-1,-1,-1,-1 + + #w "flush" + print " Mask matrix filled." + + #w "size 1" + mxx =0: mnn =0 + + for x =0 to 127 -2 ' since any further overlaps image edge + for y =0 to 127 -2 + result( x, y) =0 + for kx =0 to 2 + for ky =0 to 2 + result( x, y) =result( x, y) +image( x +kx, y +ky) *mask( kx, ky) + next ky + if mxx result( x, y) then mnn =result( x, y) + next kx + scan + next y + next x + + range =mxx -mnn + for x =0 to 127 -2 + for y =0 to 127 -2 + c =int( 255 *( result( x, y) -mnn) /range) + '#w "color "; c; " "; c; " "; c + if c >128 then #w "color white" else #w "color black" + #w "set "; x +292 +1; " "; y +20 +1 + scan + next y + next x + #w "flush" + + wait + + sub getRGB pixcol, byref r, byref g, byref b + b = int( pixcol / (256 *256)) + g = int( ( pixcol - b *256 *256) / 256) + r = int( pixcol - b *256 *256 - g *256) + end sub + + [quit] + close #w + CallDLL #user32, "ReleaseDC", hw as ulong, hdc as ulong + end diff --git a/Task/Image-convolution/Mathematica/image-convolution.mathematica b/Task/Image-convolution/Mathematica/image-convolution.mathematica new file mode 100644 index 0000000000..08abf2cff7 --- /dev/null +++ b/Task/Image-convolution/Mathematica/image-convolution.mathematica @@ -0,0 +1,5 @@ +img = Import[NotebookDirectory[] <> "Lenna50.jpg"]; +kernel = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}}; +ImageConvolve[img, kernel] +ImageConvolve[img, GaussianMatrix[35] ] +ImageConvolve[img, BoxMatrix[1] ] diff --git a/Task/Image-convolution/PicoLisp/image-convolution.l b/Task/Image-convolution/PicoLisp/image-convolution.l new file mode 100644 index 0000000000..bad1a69850 --- /dev/null +++ b/Task/Image-convolution/PicoLisp/image-convolution.l @@ -0,0 +1,25 @@ +(scl 3) + +(de ppmConvolution (Ppm Kernel) + (let (Len (length (car Kernel)) Radius (/ Len 2)) + (make + (chain (head Radius Ppm)) + (for (Y Ppm T (cdr Y)) + (NIL (nth Y Len) + (chain (tail Radius Y)) ) + (link + (make + (chain (head Radius (get Y (inc Radius)))) + (for (X (head Len Y) T) + (NIL (nth X 1 Len) + (chain (tail Radius (get X (inc Radius)))) ) + (link + (make + (for C 3 + (let Val 0 + (for K Len + (for L Len + (inc 'Val + (* (get X K L C) (get Kernel K L)) ) ) ) + (link (min 255 (max 0 (*/ Val 1.0)))) ) ) ) ) + (map pop X) ) ) ) ) ) ) ) diff --git a/Task/Image-convolution/Ruby/image-convolution.rb b/Task/Image-convolution/Ruby/image-convolution.rb new file mode 100644 index 0000000000..d05897eca1 --- /dev/null +++ b/Task/Image-convolution/Ruby/image-convolution.rb @@ -0,0 +1,57 @@ +class Pixmap + # Apply a convolution kernel to a whole image + def convolute(kernel) + newimg = Pixmap.new(@width, @height) + pb = ProgressBar.new(@width) if $DEBUG + @width.times do |x| + @height.times do |y| + apply_kernel(x, y, kernel, newimg) + end + pb.update(x) if $DEBUG + end + pb.close if $DEBUG + newimg + end + + # Applies a convolution kernel to produce a single pixel in the destination + def apply_kernel(x, y, kernel, newimg) + x0 = x==0 ? 0 : x-1 + y0 = y==0 ? 0 : y-1 + x1 = x + y1 = y + x2 = x+1==@width ? x : x+1 + y2 = y+1==@height ? y : y+1 + + r = g = b = 0.0 + [x0, x1, x2].zip(kernel).each do |xx, kcol| + [y0, y1, y2].zip(kcol).each do |yy, k| + r += k * self[xx,yy].r + g += k * self[xx,yy].g + b += k * self[xx,yy].b + end + end + newimg[x,y] = RGBColour.new(luma(r), luma(g), luma(b)) + end + + # Function for clamping values to those that we can use with colors + def luma(value) + if value < 0 + 0 + elsif value > 255 + 255 + else + value + end + end +end + + +# Demonstration code using the teapot image from Tk's widget demo +teapot = Pixmap.open('teapot.ppm') +[ ['Emboss', [[-2.0, -1.0, 0.0], [-1.0, 1.0, 1.0], [0.0, 1.0, 2.0]]], + ['Sharpen', [[-1.0, -1.0, -1.0], [-1.0, 9.0, -1.0], [-1.0, -1.0, -1.0]]], + ['Blur', [[0.1111,0.1111,0.1111],[0.1111,0.1111,0.1111],[0.1111,0.1111,0.1111]]], +].each do |label, kernel| + savefile = 'teapot_' + label.downcase + '.ppm' + teapot.convolute(kernel).save(savefile) +end diff --git a/Task/Image-convolution/Tcl/image-convolution.tcl b/Task/Image-convolution/Tcl/image-convolution.tcl new file mode 100644 index 0000000000..09c1dde8b4 --- /dev/null +++ b/Task/Image-convolution/Tcl/image-convolution.tcl @@ -0,0 +1,77 @@ +package require Tk + +# Function for clamping values to those that we can use with colors +proc tcl::mathfunc::luma channel { + set channel [expr {round($channel)}] + if {$channel < 0} { + return 0 + } elseif {$channel > 255} { + return 255 + } else { + return $channel + } +} +# Applies a convolution kernel to produce a single pixel in the destination +proc applyKernel {srcImage x y -- kernel -> dstImage} { + set x0 [expr {$x==0 ? 0 : $x-1}] + set y0 [expr {$y==0 ? 0 : $y-1}] + set x1 $x + set y1 $y + set x2 [expr {$x+1==[image width $srcImage] ? $x : $x+1}] + set y2 [expr {$y+1==[image height $srcImage] ? $y : $y+1}] + + set r [set g [set b 0.0]] + foreach X [list $x0 $x1 $x2] kcol $kernel { + foreach Y [list $y0 $y1 $y2] k $kcol { + lassign [$srcImage get $X $Y] rPix gPix bPix + set r [expr {$r + $k * $rPix}] + set g [expr {$g + $k * $gPix}] + set b [expr {$b + $k * $bPix}] + } + } + + $dstImage put [format "#%02x%02x%02x" \ + [expr {luma($r)}] [expr {luma($g)}] [expr {luma($b)}]]\ + -to $x $y +} +# Apply a convolution kernel to a whole image +proc convolve {srcImage kernel {dstImage ""}} { + if {$dstImage eq ""} { + set dstImage [image create photo] + } + set w [image width $srcImage] + set h [image height $srcImage] + for {set x 0} {$x < $w} {incr x} { + for {set y 0} {$y < $h} {incr y} { + applyKernel $srcImage $x $y -- $kernel -> $dstImage + } + } + return $dstImage +} + +# Demonstration code using the teapot image from Tk's widget demo +image create photo teapot -file $tk_library/demos/images/teapot.ppm +pack [labelframe .src -text Source] -side left +pack [label .src.l -image teapot] +foreach {label kernel} { + Emboss { + {-2. -1. 0.} + {-1. 1. 1.} + { 0. 1. 2.} + } + Sharpen { + {-1. -1. -1} + {-1. 9. -1} + {-1. -1. -1} + } + Blur { + {.1111 .1111 .1111} + {.1111 .1111 .1111} + {.1111 .1111 .1111} + } +} { + set name [string tolower $label] + update + pack [labelframe .$name -text $label] -side left + pack [label .$name.l -image [convolve teapot $kernel]] +} diff --git a/Task/Image-noise/0DESCRIPTION b/Task/Image-noise/0DESCRIPTION new file mode 100644 index 0000000000..7ac81df3b7 --- /dev/null +++ b/Task/Image-noise/0DESCRIPTION @@ -0,0 +1,5 @@ +Generate a random black and white 320x240 image continuously, showing FPS (frames per second). + +Sample image: + +[[Image:NoiseOutput.png]] diff --git a/Task/Image-noise/Ada/image-noise-1.ada b/Task/Image-noise/Ada/image-noise-1.ada new file mode 100644 index 0000000000..0c500bc561 --- /dev/null +++ b/Task/Image-noise/Ada/image-noise-1.ada @@ -0,0 +1,7 @@ +with Lumen.Image; + +package Noise is + + function Create_Image (Width, Height : Natural) return Lumen.Image.Descriptor; + +end Noise; diff --git a/Task/Image-noise/Ada/image-noise-2.ada b/Task/Image-noise/Ada/image-noise-2.ada new file mode 100644 index 0000000000..183df43b77 --- /dev/null +++ b/Task/Image-noise/Ada/image-noise-2.ada @@ -0,0 +1,28 @@ +with Ada.Numerics.Discrete_Random; + +package body Noise is + type Color is (Black, White); + package Color_Random is new Ada.Numerics.Discrete_Random (Color); + Color_Gen : Color_Random.Generator; + + function Create_Image (Width, Height : Natural) return Lumen.Image.Descriptor is + Result : Lumen.Image.Descriptor; + begin + Color_Random.Reset (Color_Gen); + Result.Width := Width; + Result.Height := Height; + Result.Complete := True; + Result.Values := new Lumen.Image.Pixel_Matrix (1 .. Width, 1 .. Height); + for X in 1 .. Width loop + for Y in 1 .. Height loop + if Color_Random.Random (Color_Gen) = Black then + Result.Values (X, Y) := (R => 0, G => 0, B => 0, A => 0); + else + Result.Values (X, Y) := (R => 255, G => 255, B => 255, A => 0); + end if; + end loop; + end loop; + return Result; + end Create_Image; + +end Noise; diff --git a/Task/Image-noise/Ada/image-noise-3.ada b/Task/Image-noise/Ada/image-noise-3.ada new file mode 100644 index 0000000000..6473438ecc --- /dev/null +++ b/Task/Image-noise/Ada/image-noise-3.ada @@ -0,0 +1,179 @@ +with Ada.Calendar; +with Ada.Text_IO; +with System.Address_To_Access_Conversions; +with Lumen.Window; +with Lumen.Image; +with Lumen.Events.Animate; +with GL; +with Noise; + +procedure Test_Noise is + package Float_IO is new Ada.Text_IO.Float_IO (Float); + + Program_End : exception; + + Win : Lumen.Window.Handle; + Image : Lumen.Image.Descriptor; + Tx_Name : aliased GL.GLuint; + Wide : Natural := 320; + High : Natural := 240; + First_Frame : Ada.Calendar.Time; + Frame_Count : Natural := 0; + + -- Create a texture and bind a 2D image to it + procedure Create_Texture is + use GL; + + package GLB is new System.Address_To_Access_Conversions (GLubyte); + + IP : GLpointer; + begin -- Create_Texture + -- Allocate a texture name + glGenTextures (1, Tx_Name'Unchecked_Access); + + -- Bind texture operations to the newly-created texture name + glBindTexture (GL_TEXTURE_2D, Tx_Name); + + -- Select modulate to mix texture with color for shading + glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + -- Wrap textures at both edges + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + -- How the texture behaves when minified and magnified + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + -- Create a pointer to the image. This sort of horror show is going to + -- be disappearing once Lumen includes its own OpenGL bindings. + IP := GLB.To_Pointer (Image.Values.all'Address).all'Unchecked_Access; + + -- Build our texture from the image we loaded earlier + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, GLsizei (Image.Width), GLsizei (Image.Height), 0, + GL_RGBA, GL_UNSIGNED_BYTE, IP); + end Create_Texture; + + -- Set or reset the window view parameters + procedure Set_View (W, H : in Natural) is + use GL; + begin -- Set_View + GL.glEnable (GL.GL_TEXTURE_2D); + glClearColor (0.8, 0.8, 0.8, 1.0); + + glMatrixMode (GL_PROJECTION); + glLoadIdentity; + glViewport (0, 0, GLsizei (W), GLsizei (H)); + glOrtho (0.0, GLdouble (W), GLdouble (H), 0.0, -1.0, 1.0); + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity; + end Set_View; + + -- Draw our scene + procedure Draw is + use GL; + begin -- Draw + -- clear the screen + glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + GL.glBindTexture (GL.GL_TEXTURE_2D, Tx_Name); + + -- fill with a single textured quad + glBegin (GL_QUADS); + begin + glTexCoord2f (1.0, 0.0); + glVertex2i (GLint (Wide), 0); + + glTexCoord2f (0.0, 0.0); + glVertex2i (0, 0); + + glTexCoord2f (0.0, 1.0); + glVertex2i (0, GLint (High)); + + glTexCoord2f (1.0, 1.0); + glVertex2i (GLint (Wide), GLint (High)); + end; + glEnd; + + -- flush rendering pipeline + glFlush; + + -- Now show it + Lumen.Window.Swap (Win); + end Draw; + + -- Simple event handler routine for keypresses and close-window events + procedure Quit_Handler (Event : in Lumen.Events.Event_Data) is + begin -- Quit_Handler + raise Program_End; + end Quit_Handler; + + -- Simple event handler routine for Exposed events + procedure Expose_Handler (Event : in Lumen.Events.Event_Data) is + pragma Unreferenced (Event); + begin -- Expose_Handler + Draw; + end Expose_Handler; + + -- Simple event handler routine for Resized events + procedure Resize_Handler (Event : in Lumen.Events.Event_Data) is + begin -- Resize_Handler + Wide := Event.Resize_Data.Width; + High := Event.Resize_Data.Height; + Set_View (Wide, High); + Draw; + end Resize_Handler; + + procedure Next_Frame (Frame_Delta : in Duration) is + pragma Unreferenced (Frame_Delta); + use type Ada.Calendar.Time; + begin + Frame_Count := Frame_Count + 1; + if Ada.Calendar.Clock >= First_Frame + 1.0 then + Ada.Text_IO.Put ("FPS: "); + Float_IO.Put (Float (Frame_Count), 5, 1, 0); + Ada.Text_IO.New_Line; + First_Frame := Ada.Calendar.Clock; + Frame_Count := 0; + end if; + Image := Noise.Create_Image (Width => Wide, Height => High); + Create_Texture; + Draw; + end Next_Frame; +begin + -- Create Lumen window, accepting most defaults; turn double buffering off + -- for simplicity + Lumen.Window.Create (Win => Win, + Name => "Noise fractal", + Width => Wide, + Height => High, + Events => (Lumen.Window.Want_Exposure => True, + Lumen.Window.Want_Key_Press => True, + others => False)); + + -- Set up the viewport and scene parameters + Set_View (Wide, High); + + -- Now create the texture and set up to use it + Image := Noise.Create_Image (Width => Wide, Height => High); + Create_Texture; + + First_Frame := Ada.Calendar.Clock; + + -- Enter the event loop + declare + use Lumen.Events; + begin + Animate.Select_Events (Win => Win, + Calls => (Key_Press => Quit_Handler'Unrestricted_Access, + Exposed => Expose_Handler'Unrestricted_Access, + Resized => Resize_Handler'Unrestricted_Access, + Close_Window => Quit_Handler'Unrestricted_Access, + others => No_Callback), + FPS => Animate.Flat_Out, + Frame => Next_Frame'Unrestricted_Access); + end; +exception + when Program_End => + null; +end Test_Noise; diff --git a/Task/Image-noise/BBC-BASIC/image-noise.bbc b/Task/Image-noise/BBC-BASIC/image-noise.bbc new file mode 100644 index 0000000000..434bf40386 --- /dev/null +++ b/Task/Image-noise/BBC-BASIC/image-noise.bbc @@ -0,0 +1,36 @@ + dx% = 320 + dy% = 240 + images% = 100000 + VDU 23,22,dx%;dy%;8,8,16,0 + + REM Create a block of random data in memory: + DIM random% dx%*dy%+images% + FOR R% = random% TO random%+dx%*dy%+images% + ?R% = RND(256)-1 + NEXT + + REM Create a BMP file structure: + DIM bmpfile{bfType{l&,h&}, bfSize%, bfReserved%, bfOffBits%, \ + \ biSize%, biWidth%, biHeight%, biPlanes{l&,h&}, biBitCount{l&,h&}, \ + \ biCompression%, biSizeImage%, biXPelsPerMeter%, biYPelsPerMeter%, \ + \ biClrUsed%, biClrImportant%, biPalette%(255)} + bmpfile.biSize% = 40 + bmpfile.biWidth% = dx% + bmpfile.biHeight% = dy% + bmpfile.biPlanes.l& = 1 + bmpfile.biBitCount.l& = 8 + FOR C% = 0 TO 255 + bmpfile.biPalette%(C%) = C% OR C%<<8 OR C%<<16 + NEXT + + REM Display image at a random offset into the data: + frame% = 0 + TIME = 0 + REPEAT + bmpfile.bfOffBits% = random% - bmpfile{} + RND(images%) + OSCLI "MDISPLAY " + STR$~bmpfile{} + frame% += 1 + IF TIME>10 THEN + SYS "SetWindowText", @hwnd%, "BBC BASIC: " + STR$(frame%*100 DIV TIME) + " fps" + ENDIF + UNTIL FALSE diff --git a/Task/Image-noise/C/image-noise-1.c b/Task/Image-noise/C/image-noise-1.c new file mode 100644 index 0000000000..ac800d1b8a --- /dev/null +++ b/Task/Image-noise/C/image-noise-1.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include + +unsigned int frames = 0; +unsigned int t_acc = 0; + +void print_fps () +{ + static Uint32 last_t = 0; + Uint32 t = SDL_GetTicks(); + Uint32 dt = t - last_t; + t_acc += dt; + if (t_acc > 1000) + { + unsigned int el_time = t_acc / 1000; + printf("- fps: %g\n", + (float) frames / (float) el_time); + t_acc = 0; + frames = 0; + } + last_t = t; +} + +void blit_noise(SDL_Surface *surf) +{ + unsigned int i; + long dim = surf->w * surf->h; + while (1) + { + SDL_LockSurface(surf); + for (i=0; i < dim; ++i) { + ((unsigned char *)surf->pixels)[i] = ((rand() & 1) ? 255 : 0); + } + SDL_UnlockSurface(surf); + SDL_Flip(surf); + ++frames; + print_fps(); + } +} + +int main(void) +{ + SDL_Surface *surf = NULL; + srand((unsigned int)time(NULL)); + SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); + surf = SDL_SetVideoMode(320, 240, 8, SDL_DOUBLEBUF | SDL_HWSURFACE); + blit_noise(surf); +} diff --git a/Task/Image-noise/C/image-noise-2.c b/Task/Image-noise/C/image-noise-2.c new file mode 100644 index 0000000000..4591c42c51 --- /dev/null +++ b/Task/Image-noise/C/image-noise-2.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#define W 320 +#define H 240 +#define slen W * H / sizeof(int) + +time_t start, last; + +void render() +{ + static int frame = 0, bits[slen]; + register int i = slen, r; + time_t t; + + r = bits[0] + 1; + while (i--) r *= 1103515245, bits[i] = r ^ (bits[i] >> 16); + + glClear(GL_COLOR_BUFFER_BIT); + glBitmap(W, H, 0, 0, 0, 0, (void*)bits); + glFlush(); + + if (!(++frame & 15)) { + if ((t = time(0)) > last) { + last = t; + printf("\rfps: %ld ", frame / (t - start)); + fflush(stdout); + } + } +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_INDEX); + glutInitWindowSize(W, H); + glutCreateWindow("noise"); + glutDisplayFunc(render); + glutIdleFunc(render); + + last = start = time(0); + + glutMainLoop(); + return 0; +} diff --git a/Task/Image-noise/D/image-noise.d b/Task/Image-noise/D/image-noise.d new file mode 100644 index 0000000000..f21efc13bc --- /dev/null +++ b/Task/Image-noise/D/image-noise.d @@ -0,0 +1,24 @@ +import std.stdio, std.random, sdl.SDL; + +void main() { + SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); + auto surface = SDL_SetVideoMode(320,240,8, SDL_DOUBLEBUF|SDL_HWSURFACE); + + uint frameNumber, totalTime, lastTime; + while (true) { + SDL_LockSurface(surface); + foreach (i; 0 .. surface.w * surface.h) + (cast(ubyte*)surface.pixels)[i] = (uniform(0, 2) ? 255 : 0); + SDL_UnlockSurface(surface); + SDL_Flip(surface); + frameNumber++; + + uint time = SDL_GetTicks(); + totalTime += time - lastTime; + if (totalTime > 1000) { + writeln("FPS: ", frameNumber / (totalTime / 1000.0)); + totalTime = frameNumber = 0; + } + lastTime = time; + } +} diff --git a/Task/Image-noise/Euler-Math-Toolbox/image-noise.euler b/Task/Image-noise/Euler-Math-Toolbox/image-noise.euler new file mode 100644 index 0000000000..221fedf1f8 --- /dev/null +++ b/Task/Image-noise/Euler-Math-Toolbox/image-noise.euler @@ -0,0 +1,13 @@ +>function noiseimg () ... +$aspect(320,240); clg; +$count=0; now=time; +$repeat +$ plotrgb(intrandom(240,420,2)-1,[0,0,1024,1024]); +$ wait(0); +$ count=count+1; +$ until testkey(); +$end; +$return count/(time-now); +$endfunction +>noiseimg + 2.73544353263 diff --git a/Task/Image-noise/Factor/image-noise.factor b/Task/Image-noise/Factor/image-noise.factor new file mode 100644 index 0000000000..5345f2bf43 --- /dev/null +++ b/Task/Image-noise/Factor/image-noise.factor @@ -0,0 +1,54 @@ +USING: accessors calendar images images.viewer kernel math +math.parser models models.arrow random sequences threads timers +ui.gadgets ui.gadgets.labels ui.gadgets.packs ; +IN: bw-noise + +CONSTANT: pixels { B{ 0 0 0 } B{ 255 255 255 } } + +: ( dim -- bytes ) + product [ pixels random ] { } replicate-as concat ; + +: ( -- image ) + + { 320 240 } [ >>dim ] [ >>bitmap ] bi + RGB >>component-order + ubyte-components >>component-type ; + +TUPLE: bw-noise-gadget < image-control timers cnt old-cnt fps-model ; + +: animate-image ( control -- ) + [ 1 + ] change-cnt + model>> swap set-model ; + +: update-cnt ( gadget -- ) + [ cnt>> ] [ old-cnt<< ] bi ; +: fps ( gadget -- fps ) + [ cnt>> ] [ old-cnt>> ] bi - ; +: fps-monitor ( gadget -- ) + [ fps ] [ update-cnt ] [ fps-model>> set-model ] tri ; + +: start-animation ( gadget -- ) + [ [ animate-image ] curry 1 nanoseconds every ] [ timers>> push ] bi ; +: start-fps ( gadget -- ) + [ [ fps-monitor ] curry 1 seconds every ] [ timers>> push ] bi ; +: setup-timers ( gadget -- ) + [ start-animation ] [ start-fps ] bi ; +: stop-animation ( gadget -- ) + timers>> [ [ stop-timer ] each ] [ 0 swap set-length ] bi ; + +M: bw-noise-gadget graft* [ call-next-method ] [ setup-timers ] bi ; +M: bw-noise-gadget ungraft* [ stop-animation ] [ call-next-method ] bi ; + +: ( -- gadget ) + bw-noise-gadget new-image-gadget* + 0 >>cnt 0 >>old-cnt 0 >>fps-model V{ } clone >>timers ; +: fps-gadget ( model -- gadget ) + [ number>string ] + "FPS: "