task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#PureBasic
PureBasic
EnableExplicit DisableDebugger   Procedure.d maxXY(a.d,b.d,c.d,d.d) If a<b : Swap a,b : EndIf If a<c : Swap a,c : EndIf If a<d : Swap a,d : EndIf ProcedureReturn a EndProcedure   Procedure.d minXY(a.d,b.d,c.d,d.d) If a>b : Swap a,b : EndIf If a>c : Swap a,c : EndIf If a>d : Swap a,d : EndIf Procedur...
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#C.23
C#
using System; using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra.Double;     class Program {   static void Main(string[] args) { Matrix<double> A = DenseMatrix.OfArray(new double[,] { { 12, -51, 4 }, { 6, 167, -68 }, ...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#68000_Assembly
68000 Assembly
LEA $000200,A3 JSR PrintString ;(my print routine is 255-terminated and there just so happens to be an FF after the name of the game.)
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#AArch64_Assembly
AArch64 Assembly
sp+0 = argc sp+8 = argv[0] sp+16 = argv[1] ...
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Common_Lisp
Common Lisp
(defun mmul (a b) (loop for x in a collect (loop for y in x for z in b sum (* y z))))   (defun count-tri (lim &aux (prim 0) (cnt 0)) (labels ((count1 (tr &aux (peri (reduce #'+ tr))) (when (<= peri lim) (incf prim) (incf cnt (truncate lim peri)) ...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Scheme
Scheme
((lambda (s) (display (list s (list (quote quote) s)))) (quote (lambda (s) (display (list s (list (quote quote) s))))))
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a
Pseudo-random numbers/Combined recursive generator MRG32k3a
MRG32k3a Combined recursive generator (pseudo-code) /* Constants */ /* First generator */ a1 = [0, 1403580, -810728] m1 = 2**32 - 209 /* Second Generator */ a2 = [527612, 0, -1370589] m2 = 2**32 - 22853 d = m1 + 1 class MRG32k3a x1 = [0, 0, 0] /* list of three last values of...
#Sidef
Sidef
class MRG32k3a(seed) {   define( m1 = (2**32 - 209) m2 = (2**32 - 22853) )   define( a1 = %n< 0 1403580 -810728> a2 = %n<527612 0 -1370589> )   has x1 = [seed, 0, 0] has x2 = x1.clone   method next_int { x1.unshift(a1.map_kv {|k,v| v * x1[k]...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Ring
Ring
# Project : Pythagorean quadruples   limit = 2200 pq = list(limit) for n = 1 to limit for m = 1 to limit for p = 1 to limit for x = 1 to limit if pow(x,2) = pow(n,2) + pow(m,2) + pow(p,2) pq[x] = 1 ok ...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Ruby
Ruby
n = 2200 l_add, l = {}, {} 1.step(n) do |x| x2 = x*x x.step(n) {|y| l_add[x2 + y*y] = true} end   s = 3 1.step(n) do |x| s1 = s s += 2 s2 = s (x+1).step(n) do |y| l[y] = true if l_add[s1] s1 += s2 s2 += 2 end end   puts (1..n).reject{|x| l[x]}.join(" ")  
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Python
Python
from turtle import goto, pu, pd, color, done   def level(ax, ay, bx, by, depth=0): if depth > 0: dx,dy = bx-ax, ay-by x3,y3 = bx-dy, by-dx x4,y4 = ax-dy, ay-dx x5,y5 = x4 + (dx - dy)/2, y4 - (dx + dy)/2 goto(ax, ay), pd() for x, y in ((bx, by), (x3, y3), (x4, y4), (ax...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#11l
11l
I problem exit(1)
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#C.2B.2B
C++
/* * g++ -O3 -Wall --std=c++11 qr_standalone.cpp -o qr_standalone */ #include <cstdio> #include <cstdlib> #include <cstring> // for memset #include <limits> #include <iostream> #include <vector>   #include <math.h>   class Vector;   class Matrix {   public: // default constructor (don't allocate) Matrix() : m(0),...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Ada
Ada
with Ada.Command_Line, Ada.Text_IO;   procedure Command_Name is begin Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name); end Command_Name;
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Aime
Aime
o_text(argv(0)); o_byte('\n');
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Crystal
Crystal
class PythagoranTriplesCounter def initialize(limit = 0) @limit = limit @total = 0 @primitives = 0 generate_triples(3, 4, 5) end   def total; @total end def primitives; @primitives end   private def generate_triples(a, b, c) perim = a + b + c return if perim > @limit   @primitives ...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Seed7
Seed7
$ include "seed7_05.s7i"; const array string: prog is []( "$ include \"seed7_05.s7i\";", "const array string: prog is [](", "const proc: main is func", " local var integer: number is 0;", " begin", " for number range 1 to 2 do writeln(prog[number]); end for;", " for number range 1 to 11 do", " writeln(lite...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Shale
Shale
i var i "i var i %c%s%c = 34 i 34 i printf" = 34 i 34 i printf
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a
Pseudo-random numbers/Combined recursive generator MRG32k3a
MRG32k3a Combined recursive generator (pseudo-code) /* Constants */ /* First generator */ a1 = [0, 1403580, -810728] m1 = 2**32 - 209 /* Second Generator */ a2 = [527612, 0, -1370589] m2 = 2**32 - 22853 d = m1 + 1 class MRG32k3a x1 = [0, 0, 0] /* list of three last values of...
#uBasic.2F4tH
uBasic/4tH
@(0) = 0 ' First generator @(1) = 1403580 @(2) = -810728 m = SHL(1, 32) - 209   @(3) = 527612 ' Second generator @(4) = 0 @(5) = -1370589 n = SHL(1, 32) - 22853   d = SHL(1, 32) - 209 + 1 ' m + 1   Proc _Seed(1234567) Print FUNC(_NextInt) Print FUNC(...
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a
Pseudo-random numbers/Combined recursive generator MRG32k3a
MRG32k3a Combined recursive generator (pseudo-code) /* Constants */ /* First generator */ a1 = [0, 1403580, -810728] m1 = 2**32 - 209 /* Second Generator */ a2 = [527612, 0, -1370589] m2 = 2**32 - 22853 d = m1 + 1 class MRG32k3a x1 = [0, 0, 0] /* list of three last values of...
#Wren
Wren
// constants var A1 = [0, 1403580, -810728] var M1 = 2.pow(32) - 209 var A2 = [527612, 0, -1370589] var M2 = 2.pow(32) - 22853 var D = M1 + 1   // Python style modulus var Mod = Fn.new { |x, y| var m = x % y return (m < 0) ? m + y.abs : m }   class MRG32k3a { construct new() { _x1 = [0, 0, 0] ...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Rust
Rust
  use std::collections::BinaryHeap;   fn a094958_iter() -> Vec<u16> { (0..12) .map(|n| vec![1 << n, 5 * (1 << n)]) .flatten() .filter(|x| x < &2200) .collect::<BinaryHeap<u16>>() .into_sorted_vec() }   fn a094958_filter() -> Vec<u16> { (1..2200) // ported from Sidef ...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Scala
Scala
object PythagoreanQuadruple extends App { val MAX = 2200 val MAX2: Int = MAX * MAX * 2 val found = Array.ofDim[Boolean](MAX + 1) val a2b2 = Array.ofDim[Boolean](MAX2 + 1) var s = 3 for (a <- 1 to MAX) { val a2 = a * a   for (b <- a to MAX) a2b2(a2 + b * b) = true }   for (c <- 1 to MAX) { va...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#R
R
## Recursive PT plotting pythtree <- function(ax,ay,bx,by,d) { if(d<0) {return()}; clr="darkgreen"; dx=bx-ax; dy=ay-by; x3=bx-dy; y3=by-dx; x4=ax-dy; y4=ay-dx; x5=x4+(dx-dy)/2; y5=y4-(dx+dy)/2; segments(ax,-ay,bx,-by, col=clr); segments(bx,-by,x3,-y3, col=clr); segments(x3,-y3,x4,-y4, col=clr); segmen...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#QB64
QB64
_Title "Pythagoras Tree"   Dim As Integer sw, sh sw = 640 sh = 480   Screen _NewImage(sw, sh, 32)   Call pythTree(sw / 2 - sw / 12, sh - 30, sw / 2 + sw / 12, sh - 30, 0)   Sleep System   Sub pythTree (ax As Integer, ay As Integer, bx As Integer, by As Integer, depth As Integer) Dim As Single cx, cy, dx, dy, ex, ey...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#6502_Assembly
6502 Assembly
;assuming this is not a subroutine and runs inline. cmp TestValue ;a label for a memory address that contains some value we want to test the accumulator against beq continue rts  ;unlike the Z80 there is no conditional return so we have to branch around the return instruction. continue:
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B */ /* program ending64.s */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "../includeConstantesARM64...
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#Common_Lisp
Common Lisp
(defun sign (x) (if (zerop x) x (/ x (abs x))))   (defun norm (x) (let ((len (car (array-dimensions x)))) (sqrt (loop for i from 0 to (1- len) sum (expt (aref x i 0) 2)))))   (defun make-unit-vector (dim) (let ((vec (make-array `(,dim ,1) :initial-element 0.0d0))) (setf (aref vec 0 0) 1.0d0) ...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#ALGOL_68
ALGOL 68
  BEGIN print ((program idf, newline)) END  
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Amazing_Hopper
Amazing Hopper
  #include <hbasic.h> Begin GetParam(name File) Print("My Program name: ", name File,Newl) End  
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#D
D
void main() @safe { import std.stdio, std.range, std.algorithm, std.typecons, std.numeric;   enum triples = (in uint n) pure nothrow @safe /*@nogc*/ => iota(1, n + 1) .map!(z => iota(1, z + 1) .map!(x => iota(x, z + 1).map!(y => tuple(x, y, z)))) .joiner.joiner ...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Sidef
Sidef
s = %(s = %%(%s); printf(s, s); ); printf(s, s);
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Smalltalk
Smalltalk
[:s| Transcript show: s, s printString; cr ] value: '[:s| Transcript show: s, s printString; cr ] value: '  
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Sidef
Sidef
# Finds all solutions (a,b) such that: a^2 + b^2 = n^2 func sum_of_two_squares(n) is cached {   n == 0 && return [[0, 0]]   var prod1 = 1 var prod2 = 1   var prime_powers = []   for p,e in (n.factor_exp) { if (p % 4 == 3) { # p = 3 (mod 4) e.is_even || return [] ...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Racket
Racket
#lang racket (require racket/draw pict)   (define (draw-pythagoras-tree order x0 y0 x1 y1) (λ (the-dc dx dy) (define (inr order x0 y0 x1 y1) (when (positive? order) (let* ((y0-1 (- y0 y1)) (x1-0 (- x1 x0)) (x2 (+ x1 y0-1)) (y2 (+ y1 x1-0)) ...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#Action.21
Action!
PROC Main() DO IF Rand(0)=10 THEN PrintE("Terminate program by Break() procedure") Break() FI OD PrintE("This is a dead code") RETURN
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#Ada
Ada
with Ada.Task_Identification; use Ada.Task_Identification;   procedure Main is -- Create as many task objects as your program needs begin -- whatever logic is required in your Main procedure if some_condition then Abort_Task (Current_Task); end if; end Main;
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#D
D
import std.stdio, std.math, std.algorithm, std.traits, std.typecons, std.numeric, std.range, std.conv;   template elementwiseMat(string op) { T[][] elementwiseMat(T)(in T[][] A, in T B) pure nothrow { if (A.empty) return null; auto R = new typeof(return)(A.length, A[0].length); ...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Applesoft_BASIC
Applesoft BASIC
  10 GOSUB 40"GET PROGRAM NAME 20 PRINT N$ 30 END   40 REMGET PROGRAM NAME 50 GOSUB 100"GET INPUT BUFFER 60 GOSUB 200"REMOVE RUN PREFIX 70 GOSUB 300"REMOVE , SUFFIXES 80 GOSUB 400"TRIM SPACES 90 RETURN   100 REMGET INPUT BUFFER 110 N$ = "" 120 FOR I = 512 TO 767 130 B = PEEK (I) - 128 140 IF B < 32 THEN RETUR...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#ARM_Assembly
ARM Assembly
    /* ARM assembly Raspberry PI */ /* program namepgm.s */ /* Constantes */ .equ STDOUT, 1 .equ WRITE, 4 .equ EXIT, 1 /* Initialized data */ .data szMessage: .asciz "Program : " @ szRetourLigne: .asciz "\n"     .text .global main main: push {fp,lr} /* save des 2 registres */ add fp,sp,#8...
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Delphi
Delphi
  [Pythagorean triples for Rosetta code. Counts (1) all Pythagorean triples (2) primitive Pythagorean triples, with perimeter not greater than a given value.   Library subroutine M3, Prints header and is then overwritten. Here, the last character sets the teleprinter to figures.] ..PZ [simulate blank tape] ...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#SmileBASIC
SmileBASIC
Q$="Q$=%SPRINT FORMAT$(Q$,CHR$(34)+Q$+CHR$(34)+CHR$(10))" PRINT FORMAT$(Q$,CHR$(34)+Q$+CHR$(34)+CHR$(10))
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Swift
Swift
func missingD(upTo n: Int) -> [Int] { var a2 = 0, s = 3, s1 = 0, s2 = 0 var res = [Int](repeating: 0, count: n + 1) var ab = [Int](repeating: 0, count: n * n * 2 + 1)   for a in 1...n { a2 = a * a   for b in a...n { ab[a2 + b * b] = 1 } }   for c in 1..<n { s1 = s s += 2 s2 = s...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#VBA
VBA
Const n = 2200 Public Sub pq() Dim s As Long, s1 As Long, s2 As Long, x As Long, x2 As Long, y As Long: s = 3 Dim l(n) As Boolean, l_add(9680000) As Boolean '9680000=n * n * 2 For x = 1 To n x2 = x * x For y = x To n l_add(x2 + y * y) = True Next y Next x For x = ...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Raku
Raku
class Square { has Complex ($.position, $.edge); method size { $!edge.abs } method svg-polygon { qq[<polygon points="{join ' ', map { ($!position + $_ * $!edge).reals.join(',') }, 0, 1, 1+1i, 1i}" style="fill:lime;stroke=black" />] } method left-child { self.new: position => $!position + i*$!ed...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#Aime
Aime
void f1(integer a) { if (a) { exit(1); } }   integer main(void) { f1(3);   return 0; }
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#ALGOL_68
ALGOL 68
IF problem = 1 THEN stop FI
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#F.23
F#
  // QR decomposition. Nigel Galloway: January 11th., 2022 let n=[[12.0;-51.0;4.0];[6.0;167.0;-68.0];[-4.0;24.0;-41.0]]|>MathNet.Numerics.LinearAlgebra.MatrixExtensions.matrix let g=n|>MathNet.Numerics.LinearAlgebra.Matrix.qr printfn $"Matrix\n------\n%A{n}\nQ\n-\n%A{g.Q}\nR\n-\n%A{g.R}"  
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#AutoHotkey
AutoHotkey
  MsgBox, % A_ScriptName  
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#EDSAC_order_code
EDSAC order code
  [Pythagorean triples for Rosetta code. Counts (1) all Pythagorean triples (2) primitive Pythagorean triples, with perimeter not greater than a given value.   Library subroutine M3, Prints header and is then overwritten. Here, the last character sets the teleprinter to figures.] ..PZ [simulate blank tape] ...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#SNOBOL4
SNOBOL4
S = ' OUTPUT = " S = 0" S "0"; OUTPUT = REPLACE(S,+"","0");END' OUTPUT = " S = '" S ""; OUTPUT = REPLACE(S,+"","'");END
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Wren
Wren
var N = 2200 var N2 = N * N * 2 var s = 3 var s1 = 0 var s2 = 0 var r = List.filled(N + 1, false) var ab = List.filled(N2 + 1, false)   for (a in 1..N) { var a2 = a * a for (b in a..N) ab[a2 + b*b] = true }   for (c in 1..N) { s1 = s s = s + 2 s2 = s var d = c + 1 while (d <= N) { if...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Ring
Ring
# Project : Pythagoras tree   load "guilib.ring"   paint = null   new qapp { win1 = new qwidget() { setwindowtitle("Pythagoras tree") setgeometry(100,100,800,600) label1 = new qlabel(win1) { setgeometry(10,10,800,600) ...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#ALGOL_W
ALGOL W
if anErrorOccured then assert( false );
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#AppleScript
AppleScript
if (someCondition) then error number -128
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#Fortran
Fortran
program qrtask implicit none integer, parameter :: n = 4 real(8) :: durer(n, n) = reshape(dble([ & 16, 5, 9, 4, & 3, 10, 6, 15, & 2, 11, 7, 14, & 13, 8, 12, 1 & ]), [n, n]) real(8) :: q(n, n), r(n, n), qr(n, n), id(n, n), tau(n) integer, parameter :: lwo...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#AWK
AWK
  # syntax: TAWK -f PROGRAM_NAME.AWK # # GAWK can provide the invoking program name from ARGV[0] but is unable to # provide the AWK script name that follows -f. Thompson Automation's TAWK # version 5.0c, last released in 1998 and no longer commercially available, can # provide the AWK script name that follows -f from ...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#BASIC
BASIC
appname = COMMAND$(0)
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Eiffel
Eiffel
  class APPLICATION   create make   feature   make local perimeter: INTEGER do perimeter := 100 from until perimeter > 1000000 loop total := 0 primitive_triples := 0 count_pythagorean_triples (3, 4, 5, perimeter) io.put_string ("There are " + total.out + " triples, below " + pe...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#SPL
SPL
d='JC5wcmludCgiZD0nIitkKyInOyIrJC5iNjRkZWNvZGUoZCkp';$.print("d='"+d+"';"+$.b64decode(d))  
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#SPWN
SPWN
d='JC5wcmludCgiZD0nIitkKyInOyIrJC5iNjRkZWNvZGUoZCkp';$.print("d='"+d+"';"+$.b64decode(d))  
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#Yabasic
Yabasic
limite = 2200 s = 3 dim l(limite) dim ladd(limite * limite * 2)   for x = 1 to limite x2 = x * x for y = x to limite ladd(x2 + y * y) = 1 next y next x   for x = 1 to limite s1 = s s = s + 2 s2 = s for y = x +1 to limite if ladd(s1) = 1 l(y) = 1 s1 = s1 + s2 ...
http://rosettacode.org/wiki/Pythagorean_quadruples
Pythagorean quadruples
One form of   Pythagorean quadruples   is   (for positive integers   a,   b,   c,   and   d):   a2   +   b2   +   c2     =     d2 An example:   22   +   32   +   62     =     72 which is:   4    +   9    +   36     =     49 Task For positive integers up   2,200   (inclusive),   for all values of   ...
#zkl
zkl
# find values of d where d^2 =/= a^2 + b^2 + c^2 for any integers a, b, c # # where d in [1..2200], a, b, c =/= 0 # # max number to check # const max_number = 2200; const max_square = max_number * max_number; # table of numbers that can be the sum of two squares # sum_of_two_squares:...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Ruby
Ruby
  # frozen_string_literal: true   def setup sketch_title 'Pythagoras Tree' background(255) stroke(0, 255, 0) tree(width / 2.3, height, width / 1.8, height, 10) end   def tree(x1, y1, x2, y2, depth) return if depth <= 0   dx = (x2 - x1) dy = (y1 - y2)   x3 = (x2 - dy) y3 = (y2 - dx) x4 = (x1 - dy) ...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#APL
APL
  #!/usr/local/bin/apl --script --   ⍝⍝ GNU APL script ⍝⍝ Usage: errout.apl <code> ⍝⍝ ⍝⍝ $ echo $? ## to see exit code ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ args ← 2↓⎕ARG~'--script' '--' ⍝⍝ strip off script args we don't need   err ← ⍎⊃args[1]   ∇main →(0=err)/ok error: 'Error! exiting.' ⍎')off 1' ⍝⍝ NOTE...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#ARM_Assembly
ARM Assembly
  /* ARM assembly Raspberry PI */ /* program ending.s */   /* Constantes */ .equ EXIT, 1 @ Linux syscall   /* Initialized data */ .data   /* code section */ .text .global main main: @ entry of program push {fp,lr} ...
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#Futhark
Futhark
  import "lib/github.com/diku-dk/linalg/linalg"   module linalg_f64 = mk_linalg f64   let eye (n: i32): [n][n]f64 = let arr = map (\ind -> let (i,j) = (ind/n,ind%n) in if (i==j) then 1.0 else 0.0) (iota (n*n)) in unflatten n n arr   let norm v = linalg_f64.dotprod v v |> f64.sqrt   let qr [n] [m] (a: [m][n]f64): ([...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Blue
Blue
global _start   : syscall ( num:eax -- result:eax ) syscall ;   : exit ( status:edi -- noret ) 60 syscall ; : bye ( -- noret ) 0 exit ;   : write ( buf:esi len:edx fd:edi -- ) 1 syscall drop ;   1 const stdout   : print ( buf len -- ) stdout write ;   : newline ( -- ) s" \n" print ; : println ( buf len -- ) print newli...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#C
C
#include <stdio.h>   int main(int argc, char **argv) { printf("Executable: %s\n", argv[0]);   return 0; }
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Elixir
Elixir
defmodule RC do def count_triples(limit), do: count_triples(limit,3,4,5)   defp count_triples(limit, a, b, c) when limit<(a+b+c), do: {0,0} defp count_triples(limit, a, b, c) do {p1, t1} = count_triples(limit, a-2*b+2*c, 2*a-b+2*c, 2*a-2*b+3*c) {p2, t2} = count_triples(limit, a+2*b+2*c, 2*a+b+2*c, 2*a+2*b...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Standard_ML
Standard ML
(fn s => print (s ^ "\"" ^ String.toString s ^ "\";\n")) "(fn s => print (s ^ \"\\\"\" ^ String.toString s ^ \"\\\";\\n\")) ";
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Swift
Swift
({print($0+$0.debugDescription+")")})("({print($0+$0.debugDescription+\")\")})(")
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Rust
Rust
/* add to file Cargo.toml: [dependencies] svg = "0.10.0" */   use svg::node::element::{Group, Polygon};   fn main() { let mut doc = svg::Document::new().set("stroke", "white"); let mut base: Vec<[(f64, f64); 2]> = vec![[(-200.0, 0.0), (200.0, 0.0)]]; for lvl in 0..12u8 { let rg = |step| lvl.wrapping...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#Arturo
Arturo
problem: true   if problem -> exit
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#AutoHotkey
AutoHotkey
If (problem) ExitApp
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#Go
Go
package main   import ( "fmt" "math"   "github.com/skelterjohn/go.matrix" )   func sign(s float64) float64 { if s > 0 { return 1 } else if s < 0 { return -1 } return 0 }   func unitVector(n int) *matrix.DenseMatrix { vec := matrix.Zeros(n, 1) vec.Set(0, 0, 1) retu...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#C.23
C#
using System; namespace ProgramName { class Program { static void Main(string[] args) { Console.Write(Environment.CommandLine); } } }
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#C.2B.2B
C++
#include <iostream>   using namespace std;   int main(int argc, char **argv) { char *program = argv[0]; cout << "Program: " << program << endl; }
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Erlang
Erlang
%% %% Pythagorian triples in Erlang, J.W. Luiten %% -module(triples). -export([main/1]).   %% Transformations t1, t2 and t3 to generate new triples t1(A, B, C) -> {A-2*B+2*C, 2*A-B+2*C, 2*A-2*B+3*C}. t2(A, B, C) -> {A+2*B+2*C, 2*A+B+2*C, 2*A+2*B+3*C}. t3(A, B, C) -> {2*B+2*C-A, B+2*C-2*A, 2*B+3*C-2*A}.   %% G...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Tcl
Tcl
join { {} A B } any_string => any_stringAany_stringB
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Turbo_Pascal
Turbo Pascal
program quine;   const apos: Char = Chr(39); comma: Char = Chr(44); lines: Array[1..17] of String[80] = ( 'program quine;', '', 'const', ' apos: Char = Chr(39);', ' comma: Char = Chr(44);', ' lines: Array[1..17] of String[80] = (', ' );', '', 'var', ' num: Integer;', '', 'begin', ' ...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Scala
Scala
import java.awt._ import java.awt.geom.Path2D   import javax.swing.{JFrame, JPanel, SwingUtilities, WindowConstants}   object PythagorasTree extends App {   SwingUtilities.invokeLater(() => { new JFrame {   class PythagorasTree extends JPanel { setPreferredSize(new Dimension(640, 640)) setBa...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#AutoIt
AutoIt
If problem Then Exit Endif
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#AWK
AWK
if(problem)exit 1
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#Haskell
Haskell
  import Data.List import Text.Printf (printf)   eps = 1e-6 :: Double   -- a matrix is represented as a list of columns mmult :: Num a => [[a]] -> [[a]] -> [[a]] nth :: Num a => [[a]] -> Int -> Int -> a mmult_num :: Num a => [[a]] -> a -> [[a]] madd :: Num a => [[a]] -> [[a]] -> [[a]] idMatrix :: Num a => Int -> Int -...
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Clojure
Clojure
":";exec lein exec $0 ${1+"$@"} ":";exit   (ns scriptname (:gen-class))   (defn -main [& args] (let [program (first *command-line-args*)] (println "Program:" program)))   (when (.contains (first *command-line-args*) *source-path*) (apply -main (rest *command-line-args*)))
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#COBOL
COBOL
identification division. program-id. sample.   data division. working-storage section. 01 progname pic x(16).   procedure division. sample-main.   display 0 upon argument-number accept progname from argument-value display "argument-value zero :" prog...
http://rosettacode.org/wiki/Primorial_numbers
Primorial numbers
Primorial numbers are those formed by multiplying successive prime numbers. The primorial number series is:   primorial(0) =         1       (by definition)   primorial(1) =         2       (2)   primorial(2) =         6       (2×3)   primorial(3) =       30       (2×3×5)   primorial(4) =     210       (2×3×5×...
#11l
11l
F get_primes(primes_count) V limit = 17 * primes_count V is_prime = [0B] * 2 [+] [1B] * (limit - 1) L(n) 0 .< Int(limit ^ 0.5 + 1.5) I is_prime[n] L(i) (n * n .< limit + 1).step(n) is_prime[i] = 0B   [Int] primes L(prime) is_prime I prime primes.append(L.index) ...
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#ERRE
ERRE
PROGRAM PIT   BEGIN   PRINT(CHR$(12);) !CLS PRINT(TIME$)   FOR POWER=1 TO 7 DO PLIMIT=10#^POWER UPPERBOUND=INT(1+PLIMIT^0.5) PRIMITIVES=0 TRIPLES=0 EXTRAS=0  ! will count the in-range multiples of any primitive   FOR M=2 TO UPPERBOUND DO FOR N=1+(M MOD 2=1) TO M-1 STEP 2 DO...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#TXR
TXR
@(deffilter me ("ME" "@(bind me &quot;ME&quot;)&#10;@(output)&#10;@@(deffilter me (&quot;ME&quot; &quot;@{me :filter me}&quot;))&#10;@{me :filter (me :from_html)}&#10;@(end)")) @(bind me "ME") @(output) @@(deffilter me ("ME" "@{me :filter me}")) @{me :filter (me :from_html)} @(end)
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#UNIX_Shell
UNIX Shell
#!/bin/sh cat < "$0"
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Scilab
Scilab
side = 1; //side length of the square depth = 8; //final number of branch levels   //L-system definition: //Alphabet: UTDB+-[] //U: go upwards T: top of the square //D: go downwards B: bottom of the square //[: start new branch ]: end current branch //+: branch to ...
http://rosettacode.org/wiki/Pythagoras_tree
Pythagoras tree
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem. Task Construct a Pythagoras tree of order 7 using only vectors (no rotation or ...
#Sidef
Sidef
require('Imager')   func tree(img, x1, y1, x2, y2, depth) {   depth <= 0 && return()   var dx = (x2 - x1) var dy = (y1 - y2)   var x3 = (x2 - dy) var y3 = (y2 - dx) var x4 = (x1 - dy) var y4 = (y1 - dx) var x5 = (x4 + 0.5*(dx - dy)) var y5 = (y4 - 0.5*(dx + dy))   # square im...
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#Axe
Axe
Returnʳ
http://rosettacode.org/wiki/Program_termination
Program termination
Task Show the syntax for a complete stoppage of a program inside a   conditional. This includes all threads/processes which are part of your program. Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks...
#BASIC
BASIC
IF problem = 1 THEN END END IF
http://rosettacode.org/wiki/QR_decomposition
QR decomposition
Any rectangular m × n {\displaystyle m\times n} matrix A {\displaystyle {\mathit {A}}} can be decomposed to a product of an orthogonal matrix Q {\displaystyle {\mathit {Q}}} and an upper (right) triangular matrix R {\displaystyle {\mathit {R}}} , as described in QR decompositi...
#J
J
QR =: 128!:0
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#CoffeeScript
CoffeeScript
#!/usr/bin/env coffee   main = () -> program = __filename console.log "Program: " + program   if not module.parent then main()
http://rosettacode.org/wiki/Program_name
Program name
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal A...
#Common_Lisp
Common Lisp
;;; Play nice with shebangs (set-dispatch-macro-character #\# #\! (lambda (stream character n) (declare (ignore character n)) (read-line stream nil nil t) nil))
http://rosettacode.org/wiki/Primorial_numbers
Primorial numbers
Primorial numbers are those formed by multiplying successive prime numbers. The primorial number series is:   primorial(0) =         1       (by definition)   primorial(1) =         2       (2)   primorial(2) =         6       (2×3)   primorial(3) =       30       (2×3×5)   primorial(4) =     210       (2×3×5×...
#C
C
  #include <inttypes.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <string.h> #include <gmp.h>   /* Eratosthenes bit-sieve */ int es_check(uint32_t *sieve, uint64_t n) { if ((n != 2 && !(n & 1)) || (n < 2)) return 0; else return !(sieve[n >> 6] & (1 << ...
http://rosettacode.org/wiki/Pythagorean_triples
Pythagorean triples
A Pythagorean triple is defined as three positive integers ( a , b , c ) {\displaystyle (a,b,c)} where a < b < c {\displaystyle a<b<c} , and a 2 + b 2 = c 2 . {\displaystyle a^{2}+b^{2}=c^{2}.} They are called primitive triples if a , b , c {\displaystyle a,b,c} are co-prime,...
#Euphoria
Euphoria
function tri(atom lim, sequence in) sequence r atom p p = in[1] + in[2] + in[3] if p > lim then return {0, 0} end if r = {1, floor(lim / p)} r += tri(lim, { in[1]-2*in[2]+2*in[3], 2*in[1]-in[2]+2*in[3], 2*in[1]-2*in[2]+3*in[3]}) r += tri(lim, { in[1]+2*in[2]+2*in[3], 2*in[1]+i...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#Unlambda
Unlambda
``d`.v`.vv```s``si`k`ki``si`k`d`..`.``.d`.``.c`.s`.``.``.s`.``.``.vv``s``sc`d`.`v``s``sc`d`.`v``s``sc`d`.dv``s``sc`d`.`v``s``sc`d`..v``s``sc`d`.vv``s``sc`d`.`v``s``sc`d`..v``s``sc`d`.vv``s``sc`d`.vv``s``sc`d`.`v``s``sc`d`.`v``s``sc`d`.`v``s``sc`d`.sv``s``sc`d`.`v``s``sc`d`.`v``s``sc`d`.sv``s``sc`d`.iv``s``sc`d`.`v``s``...
http://rosettacode.org/wiki/Quine
Quine
A quine is a self-referential program that can, without any external access, output its own source. A   quine   (named after Willard Van Orman Quine)   is also known as:   self-reproducing automata   (1972)   self-replicating program         or   self-replicating computer program   self-reproducing program      ...
#V
V
[p [put ' 'put] map ' ' puts].