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/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#PowerShell
PowerShell
  $asString = 97..122 | ForEach-Object -Begin {$asArray = @()} -Process {$asArray += [char]$_} -End {$asArray -join('')} $asString  
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Prolog
Prolog
a_to_z(From, To, L) :- maplist(atom_codes, [From, To], [[C_From], [C_To]]), bagof([C], between(C_From, C_To, C), L1), maplist(atom_codes,L, L1).  
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Pop11
Pop11
printf('Hello world!\n');
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#M2000_Interpreter
M2000 Interpreter
  Module CheckIt { Compose = lambda (f, g)->{ =lambda f, g (x)->f(g(x)) } Add5=lambda (x)->x+5 Division2=lambda (x)->x/2 Add5Div2=compose(Division2, Add5) Print Add5Div2(15)=10 ' True } CheckIt  
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Mathcad
Mathcad
Composition[f, g][x] Composition[f, g, h, i][x]
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#PureBasic
PureBasic
#Spread_Ang = 35 #Scaling_Factor = 0.75 #Deg_to_Rad = #PI / 180 #SizeH = 500 #SizeV = 375 #Init_Size = 100   Procedure drawTree(x1, y1, Size, theta, depth) Protected x2 = x1 + Cos(theta * #Deg_to_Rad) * Size, y2 = y1 + Sin(theta * #Deg_to_Rad) * Size LineXY(x1, y1, x2, y2, RGB(255, 255, 255)) If depth <= 0 ...
http://rosettacode.org/wiki/Fraction_reduction
Fraction reduction
There is a fine line between numerator and denominator.       ─── anonymous A method to   "reduce"   some reducible fractions is to   cross out   a digit from the numerator and the denominator.   An example is: 16 16 ──── and then (simp...
#Wren
Wren
import "/dynamic" for Struct import "/fmt" for Fmt   var Result = Struct.create("Result", ["n", "nine"])   var toNumber = Fn.new { |digits, removeDigit| var digits2 = digits.toList if (removeDigit != 0) { var d = digits2.indexOf(removeDigit) digits2.removeAt(d) } var res = digits2[0] ...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#OCaml
OCaml
open Num   let get_input () = num_of_int ( try int_of_string Sys.argv.(1) with _ -> 10)   let get_max_steps () = try int_of_string Sys.argv.(2) with _ -> 50   let read_program () = let line = read_line () in let words = Str.split (Str.regexp " +") line in List.map num_of_string words   let i...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#BQN
BQN
Multiply ← ×
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#uBasic.2F4tH
uBasic/4tH
Print "Index-------Value"   For i = 0 To 60 Print Using "____#"; i; Using "___________#"; FUNC(_fusc(i)) Next   Proc _printLargeFuscs (35500) End   _fusc Param (1)   If (a@ = 0) + (a@ = 1) Then Return (a@) If (a@ % 2) = 0 Then Return (FUNC(_fusc(a@/2))) Return (FUNC(_fusc((a@ - 1)/2)) + FUNC(_fusc((a@ + 1)/2)))...
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#Vala
Vala
int fusc(int n) { if (n == 0 || n == 1) return n; else if (n % 2 == 0) return fusc(n / 2); else return fusc((n - 1) / 2) + fusc((n + 1) / 2); }   void main() { print("The first 61 fusc numbers:\n"); for (int i = 0; i < 61; i++) print(@"$(fusc(i)) "); print("\n\nThe fusc numbers whose lengths...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#OCaml
OCaml
let e = exp 1. let pi = 4. *. atan 1. let sqrttwopi = sqrt (2. *. pi)   module Lanczos = struct (* Lanczos method *) (* Coefficients used by the GNU Scientific Library *) let g = 7. let c = [|0.99999999999980993; 676.5203681218851; -1259.1392167224028; 771.32342877765313; -176.61502916214059; 12.5073432786...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#Tcl
Tcl
package require math::linearalgebra   set A { {1.00 0.00 0.00 0.00 0.00 0.00} {1.00 0.63 0.39 0.25 0.16 0.10} {1.00 1.26 1.58 1.98 2.49 3.13} {1.00 1.88 3.55 6.70 12.62 23.80} {1.00 2.51 6.32 15.88 39.90 100.28} {1.00 3.14 9.87 31.01 97.41 306.02} } set b {-0.01 0.61 0....
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Python
Python
# From the standard library: from string import ascii_lowercase   # Generation: lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Quackery
Quackery
[ [] 26 times [ i^ char a + join ] ] constant is alpha$ ( --> $ )   alpha$ echo$
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Portugol
Portugol
  programa { // funcao defines a new function // inicio is the entry point of the program, like main in C funcao inicio() { // escreva is used to print stuff to the screen escreva("Hello, world!\n") // no ';' needed } }  
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
Composition[f, g][x] Composition[f, g, h, i][x]
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Maxima
Maxima
/* 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))));
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Processing
Processing
void setup() { size(600, 600); background(0); stroke(255); drawTree(300, 550, 9); }   void drawTree(float x, float y, int depth) { float forkAngle = radians(20); float baseLen = 10.0; if (depth > 0) { pushMatrix(); translate(x, y - baseLen * depth); line(0, baseLen * depth, 0, 0); rotate...
http://rosettacode.org/wiki/Fraction_reduction
Fraction reduction
There is a fine line between numerator and denominator.       ─── anonymous A method to   "reduce"   some reducible fractions is to   cross out   a digit from the numerator and the denominator.   An example is: 16 16 ──── and then (simp...
#zkl
zkl
fcn toInt(digits,remove_digit=0){ if(remove_digit!=0) digits=digits.copy().del(digits.index(remove_digit)); digits.reduce(fcn(s,d){ s*10 + d }); } fcn nDigits(n){ //-- generate numbers with unique digits efficiently //-- and store them in an array for multiple re-use, //-- along with an array of the ...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#PARI.2FGP
PARI/GP
  \\ FRACTRAN \\ 4/27/16 aev fractran(val,ft,lim)={ my(ftn=#ft,fti,di,L=List(),j=0); while(val&&j<lim, listput(L,val); for(i=1,ftn, fti=ft[i]; di=denominator(fti); if(val%di==0, break));\\fend i val= numerator(fti)*val/di; j++);\\wend j return(Vec(L)); }   {\\ Executing: my(v=[17/91,78/85,19/51,23/38,29/33,7...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#Bracmat
Bracmat
multiply=a b.!arg:(?a.?b)&!a*!b; out$multiply$(123456789.987654321); { writes 121932631112635269 to standard output }
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#Visual_Basic_.NET
Visual Basic .NET
Module Module1   Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList   Function fusc(n As Integer) As Integer If n < l.Count Then Return l(n) fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1)) l.Add(fusc) End Function   Sub Main(args As String()) ...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Octave
Octave
function g = lacz_gamma(a, cg=7) p = [ 0.99999999999980993, 676.5203681218851, -1259.1392167224028, \ 771.32342877765313, -176.61502916214059, 12.507343278686905, \ -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7 ]; x=a; if ( x < 0.5 ) g = pi / ( sin(pi*x) * lacz_gamma(1.0-x...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#TI-83_BASIC
TI-83 BASIC
[[ 1.00 0.00 0.00 0.00 0.00 0.00 -0.01] [ 1.00 0.63 0.39 0.25 0.16 0.10 0.61] [ 1.00 1.26 1.58 1.98 2.49 3.13 0.91] [ 1.00 1.88 3.55 6.70 12.62 23.80 0.99] [ 1.00 2.51 6.32 15.88 39.90 100.28 0.60] [ 1.00 3.14 9.87 31.01 97.41 306.02 0.02]]→[...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#R
R
# From constants built into R: letters   # Or generate the same with: sapply(97:122, intToUtf8)
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Racket
Racket
(define lowercase-letters (build-list 26 (lambda (x) (integer->char (+ x (char->integer #\a))))))
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#PostScript
PostScript
%!PS /Helvetica 20 selectfont 70 700 moveto (Hello world!) show showpage
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#min
min
(1 +) (2 *) concat print
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#MiniScript
MiniScript
funcA = function(x) return x * 10 end function   funcB = function(x) return x + 5 end function   compose = function(f, g) return function(x) return f(g(x)) end function end function   f = compose(@funcA, @funcB) print f(3) // should be equal to (3+5)*10
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Python
Python
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): fork_angle = 20 base_len = 10.0 if depth > 0: x2 = x1 + int(math.cos(math.radians(angle)) * depth * ...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Perl
Perl
use strict; use warnings; use Math::BigRat;   my ($n, @P) = map Math::BigRat->new($_), qw{ 2 17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1 };   $|=1; MAIN: for( 1 .. 5000 ) { print " " if $_ > 1; my ($pow, $rest) = (0, $n->copy); until( $rest->is_odd ) { ++$pow; $rest->bdiv(2);...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#Brat
Brat
multiply = { x, y | x * y }   p multiply 3 14 #Prints 42
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#Wren
Wren
import "/fmt" for Fmt   System.print("The first 61 numbers in the fusc sequence are:") var fusc = [0, 1] var fusc2 = [[0, 0]] var maxLen = 1 var n = 2 while (n < 20e6) { // limit to indices under 20 million say var f = (n % 2 == 0) ? fusc[n/2] : fusc[(n-1)/2] + fusc[(n+1)/2] fusc.add(f) var len = "%(f)".c...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Oforth
Oforth
import: math   [ 676.5203681218851, -1259.1392167224028, 771.32342877765313, -176.61502916214059, 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7 ] const: Gamma.Lanczos   : gamma(z) | i t | z 0.5 < ifTrue: [ Pi dup z * sin 1.0 z - gamma * / return ] z 1.0 - ->z ...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#VBA
VBA
'Option Base 1 Private Function gauss_eliminate(a As Variant, b As Variant) As Variant Dim n As Integer: n = UBound(b) Dim tmp As Variant, m As Integer, mx As Variant For col = 1 To n m = col mx = a(m, m) For i = col + 1 To n tmp = Abs(a(i, col)) If tmp > mx T...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Raku
Raku
say my @letters = 'a'..'z';
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Potion
Potion
"Hello world!\n" print
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Nemerle
Nemerle
using System; using System.Console; using System.Math;   module Composition { Compose[T](f : T -> T, g : T -> T, x : T) : T { f(g(x)) }   Main() : void { def SinAsin = Compose(Sin, Asin, _); WriteLine(SinAsin(0.5)); } }
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Never
Never
  func compose(f(i : int) -> int, g(i : int) -> int) -> (int) -> int { let func (i : int) -> int { f(g(i)) } }   func dec(i : int) -> int { 10 * i }   func succ(i : int) -> int { i + 1 }   func main() -> int { let h = compose(dec, succ);   print(h(1));   0 }  
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#QB64
QB64
_Title "Fractal Tree" Const sw% = 640 Const sh% = 480   Screen _NewImage(sw, sh, 8) Cls , 15: Color 2   Call tree(sw \ 2, sh - 10, _Pi * 1.5, _Pi / 180 * 29, 112, 15)   Sleep System   Sub tree (x As Integer, y As Integer, initAngle As Double, theta As Double, length As Double, depth As Integer) Dim As Integer iL, n...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Quackery
Quackery
[ $ "turtleduck.qky" loadfile ] now!   [ [ 1 1 30 times [ tuck + ] swap join ] constant do ] is phi ( --> n/d )   [ 2dup 5 1 v< iff 2drop done 2dup 5 1 v/ proper 2drop wide 2dup walk 1 5 turn 2dup phi v/ 2dup recurse -2 5 turn recurse 1 5 turn -v fl...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Phix
Phix
without js -- 8s --with javascript_semantics -- 52s!! (see note) constant steps = 20, primes = 45 sequence known_factors = {} -- nb: no specific order function combine_factors(sequence n) -- (inverse of as_primes) atom res = 1 for i=1 to length(n) do if n[i]!=0 then res *= power...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#C
C
double multiply(double a, double b) { return a * b; }
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#XPL0
XPL0
func IntLen(N); \Return number of digits in N int N, L; [L:= 0; repeat N:= N/10; L:= L+1; until N = 0; return L; ];   def Size = 1000000; int Fusc(Size), N, Len, Max; [Fusc(0):= 0; Fusc(1):= 1; for N:= 2 to Size-1 do Fusc(N):= if N&1 then Fusc((N-1)/2) + Fusc((N+1)/2) else Fusc(N/2); for N:= 0 to 60 do...
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#Yabasic
Yabasic
maximo = 20000000 dim f(maximo)   fusc()   for i = 0 to 60 print f(i), " "; next i   print "\n\n Index Value" d = 0 for i = 0 to maximo-1 if f(i) >= d then print i using "###,###,###", f(i) using "###,###,###" if d = 0 d = 1 d = d * 10 end if next i end   sub fusc() f(...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#PARI.2FGP
PARI/GP
gamma(x)
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Pascal
Pascal
  program GammaTest; {$mode objfpc}{$H+} uses SysUtils;   function Gamma( x : extended) : extended; const COF : array [0..14] of extended = ( 0.999999999999997092, // may as well include this in the array 57.1562356658629235, -59.5979603554754912, 14.1360979747417471, -0.491913816097620199, 0.33994649984811888...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#VBScript
VBScript
' Gaussian elimination - VBScript const n=6 dim a(6,6),b(6),x(6),ab ab=array( 1 , 0 , 0 , 0 , 0 , 0 , -0.01, _ 1 , 0.63, 0.39, 0.25, 0.16, 0.10, 0.61, _ 1 , 1.26, 1.58, 1.98, 2.49, 3.13, 0.91, _ 1 , 1.88...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#REXX
REXX
/* REXX --------------------------------------------------------------- * 08.02.2014 Walter Pachl *--------------------------------------------------------------------*/ say xrange('a','z')
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Ring
Ring
for i in 'a':'z' put i next
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#PowerBASIC
PowerBASIC
#COMPILE EXE #COMPILER PBCC 6   FUNCTION PBMAIN () AS LONG CON.PRINT "Hello world!" CON.WAITKEY$ END FUNCTION
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#NewLISP
NewLISP
> (define (compose f g) (expand (lambda (x) (f (g x))) 'f 'g)) (lambda (f g) (expand (lambda (x) (f (g x))) 'f 'g)) > ((compose sin asin) 0.5) 0.5  
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Nim
Nim
import sugar   proc compose[A,B,C](f: A -> B, g: B -> C): A -> C = (x: A) => f(g(x))   proc plustwo(x: int): int = x + 2 proc minustwo(x: int): int = x - 2   var plusminustwo = compose(plustwo, minustwo) echo plusminustwo(10)
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#R
R
  ## Recursive FT plotting plotftree <- function(x, y, a, d, c) { x2=y2=0; d2r=pi/180.0; a1 <- a*d2r; d1=0; if(d<=0) {return()} if(d>0) { d1=d*10.0; x2=x+cos(a1)*d1; y2=y+sin(a1)*d1; segments(x*c, y*c, x2*c, y2*c, col='darkgreen'); plotftree(x2,y2,a-20,d-1,c); plotftree(x2,y2,a+20,d-1,c); #ret...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Racket
Racket
  #lang racket (require graphics/turtles)   (define (tree n) (when (> n 1) (draw (/ n 2)) (tprompt (split* (turn 60) (turn -60)) (tree (/ n 2))) (draw (/ n 2)) (turn 5) (tree (- n 1))))   (turtles #t) (move 100) (turn 90) (move -200) (tree 35) (save-turtle-bitmap "tree.png" 'png) ...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Prolog
Prolog
  load(Program, Fractions) :- re_split("[ ]+", Program, Split), odd_items(Split, TextualFractions), maplist(convert_frac, TextualFractions, Fractions).   odd_items(L, L) :- L = [_], !. % remove the even elements from a list. odd_items([X,_|L], [X|R]) :- odd_items(L, R).   convert_frac(Text, Frac) :- re_mat...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#C.23
C#
static double multiply(double a, double b) { return a * b; }
http://rosettacode.org/wiki/Fusc_sequence
Fusc sequence
Definitions The   fusc   integer sequence is defined as:   fusc(0) = 0   fusc(1) = 1   for n>1,   the   nth   term is defined as:   if   n   is even;     fusc(n) = fusc(n/2)   if   n   is   odd;     fusc(n) = fusc((n-1)/2)   +   fusc((n+1)/2) Note that MathWorld's definition starts with unity, not zero.   Th...
#zkl
zkl
fuscs:=List.createLong(1_000_000, 0); fuscs[1]=1; // we'll just use a big count foreach n in ([2..fuscs.len()-1]){ // and generate fuscs[n]=( if(n.isEven()) fuscs[n/2] else fuscs[(n-1)/2] + fuscs[(n+1)/2] ) }   println("First 61 terms of the Stern-Brocot sequence:"); fuscs[0,61].concat(" ").println();   println("\...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Perl
Perl
use strict; use warnings; use constant pi => 4*atan2(1, 1); use constant e => exp(1);   # Normally would be: use Math::MPFR # but this will use it if it's installed and ignore otherwise my $have_MPFR = eval { require Math::MPFR; Math::MPFR->import(); 1; };   sub Gamma { my $z = shift; my $method = shift // 'l...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#Wren
Wren
import "/trait" for Stepped   var ta = [ [1.00, 0.00, 0.00, 0.00, 0.00, 0.00], [1.00, 0.63, 0.39, 0.25, 0.16, 0.10], [1.00, 1.26, 1.58, 1.98, 2.49, 3.13], [1.00, 1.88, 3.55, 6.70, 12.62, 23.80], [1.00, 2.51, 6.32, 15.88, 39.90, 100.28], [1.00, 3.14, 9.87, 31.01, 97.41, 306.02] ]   ...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Ruby
Ruby
p ('a' .. 'z').to_a p [*'a' .. 'z']
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Rust
Rust
fn main() { // An iterator over the lowercase alpha's let ascii_iter = (0..26) .map(|x| (x + b'a') as char);   println!("{:?}", ascii_iter.collect::<Vec<char>>()); }
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#PowerShell
PowerShell
'Hello world!'
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Objeck
Objeck
  bundle Default { class Test { @f : static : (Int) ~ Int; @g : static : (Int) ~ Int;   function : Main(args : String[]) ~ Nil { compose := Composer(F(Int) ~ Int, G(Int) ~ Int); compose(13)->PrintLine(); }   function : F(a : Int) ~ Int { return a + 14; }   function : G(a ...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Raku
Raku
my ($width, $height) = (1000,1000); # image dimension my $scale = 6/10; # branch scale relative to trunk my $length = 400; # trunk size   say "<?xml version='1.0' encoding='utf-8' standalone='no'?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg width='100%' heig...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Python
Python
from fractions import Fraction   def fractran(n, fstring='17 / 91, 78 / 85, 19 / 51, 23 / 38, 29 / 33,' '77 / 29, 95 / 23, 77 / 19, 1 / 17, 11 / 13,' '13 / 11, 15 / 14, 15 / 2, 55 / 1'): flist = [Fraction(f) for f in fstring.replace(' ', '').split(',')]   n = Frac...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#C.2B.2B
C++
inline double multiply(double a, double b) { return a*b; }
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Phix
Phix
with javascript_semantics sequence c = repeat(0,12) function gamma(atom z) atom accm = c[1] if accm=0 then accm = sqrt(2*PI) c[1] = accm atom k1_factrl = 1 -- (k - 1)!*(-1)^k with 0!==1 for k=2 to 12 do c[k] = exp(13-k)*power(13-k,k-1.5)/k1_factrl k1_fa...
http://rosettacode.org/wiki/Gaussian_elimination
Gaussian elimination
Task Solve   Ax=b   using Gaussian elimination then backwards substitution. A   being an   n by n   matrix. Also,   x and b   are   n by 1   vectors. To improve accuracy, please use partial pivoting and scaling. See also   the Wikipedia entry:   Gaussian elimination
#zkl
zkl
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library) a:=GSL.Matrix(6,6).set( 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.63, 0.39, 0.25, 0.16, 0.10, 1.00, 1.26, 1.58, 1.98, 2.49, 3.13, 1.00, 1.88, 3.55, 6.70, 12.62, 23.80, 1.00, 2.51, 6.32, 15.88, 39.90, 100.28, 1.00, 3.1...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#S-lang
S-lang
variable alpha_ch = ['a':'z'], a;
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Scala
Scala
object Abc extends App { val lowAlpha = 'a' to 'z' //That's all // Now several tests assert(lowAlpha.toSeq == Seq('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'), "No complete lowercase alphabet.") assert(lowAlpha.size == ...
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Processing
Processing
println("Hello world!");
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#ObjectIcon
ObjectIcon
# -*- ObjectIcon -*- # # The Rosetta Code function composition task, in Object Icon. # Composition will result in a co-expression. # # Object Icon co-expressions are closures: they share the local # variables of the context in which they are created. In Arizona Icon, # co-expressions obtain only the *values* of those v...
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Objective-C
Objective-C
#include <Foundation/Foundation.h>   typedef id (^Function)(id);   // a commodity for "encapsulating" double f(double) typedef double (*func_t)(double); Function encapsulate(func_t f) { return ^(id x) { return @(f([x doubleValue])); }; }   Function compose(Function a, Function b) { return ^(id x) { return a(b(x)); ...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Red
Red
Red [Needs: 'View]   color: brown width: 9 view/tight/options/flags/no-wait [ ; click image to grow tree img: image 1097x617 draw [ pen brown line-width 9 line 500x600 500x500] [grow] ] [offset: 0x0] [no-border]   ends: reduce [500x500 pi * 3 / 2] ; list of terminal nodes da: pi * 30 / 180 ; angle of branches in rad...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Ring
Ring
  load "guilib.ring"   new qapp { win1 = new qwidget() { setwindowtitle("drawing using qpainter") setgeometry(100,100,500,500) label1 = new qlabel(win1) { setgeometry(10,10,400,400) settext("") }...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Quackery
Quackery
[ $ "bigrat.qky" loadfile ] now!   [ 1 & not ] is even ( n --> b )   [ nip 1 = ] is vint ( n/d --> b )   [ [ dup even while 1 >> again ] 1 = ] is powerof2 ( n --> b )   [ 0 swap [ dup even while dip 1+ ...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#ChucK
ChucK
  fun float multiply (float a, float b) { return a * b; } // uncomment next line and change values to test //<<< multiply(16,4) >>>;  
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#Phixmonti
Phixmonti
0.577215664901 var gamma -0.65587807152056 var coeff -0.042002635033944 var quad 0.16653861138228 var qui -0.042197734555571 var theSet   def recigamma var z /# n -- n #/ z 6 power theSet * z 5 power qui * z 4 power quad * z 3 power coeff * z 2 power gamma * z + + + + + enddef   /# without var d...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#PicoLisp
PicoLisp
(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.0...
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Scheme
Scheme
(map integer->char (iota 26 (char->integer #\a)))
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Seed7
Seed7
$ include "seed7_05.s7i";   const proc: main is func local var string: lower is ""; var char: ch is ' '; begin for ch range 'a' to 'z' do lower &:= ch; end for; writeln(lower); end func;
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#ProDOS
ProDOS
printline Hello world!
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#OCaml
OCaml
let compose f g x = f (g x)
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Octave
Octave
function r = compose(f, g) r = @(x) f(g(x)); endfunction   r = compose(@exp, @sin); r(pi/3)
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Ruby
Ruby
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 *...
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Rust
Rust
//Cargo deps : // piston = "0.35.0" // piston2d-graphics = "0.23.0" // piston2d-opengl_graphics = "0.49.0" // pistoncore-glutin_window = "0.42.0"   extern crate piston; extern crate graphics; extern crate opengl_graphics; extern crate glutin_window;   use piston::window::WindowSettings; use piston::event_loop::{Eve...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Racket
Racket
#lang racket   (define (displaysp x) (display x) (display " "))   (define (read-string-list str) (map string->number (string-split (string-replace str " " "") ",")))   (define (eval-fractran n list) (for/or ([e (in-list list)]) (let ([en (* e n)]) (and (integer? en) en))))   (define (show-fract...
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#Clay
Clay
multiply(x,y) = x * y;
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#PL.2FI
PL/I
/* From Rosetta Fortran */ test: procedure options (main);   declare i fixed binary;   on underflow ;   put skip list ('Lanczos', 'Builtin' ); do i = 1 to 10; put skip list (lanczos_gamma(i/3.0q0), gamma(i/3.0q0) ); end;     lanczos_gamma: procedure (a) returns (float (18)) recursive; declare a float...
http://rosettacode.org/wiki/Gamma_function
Gamma function
Task Implement one algorithm (or more) to compute the Gamma ( Γ {\displaystyle \Gamma } ) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma funct...
#PowerShell
PowerShell
  Add-Type -Path "C:\Program Files (x86)\Math\MathNet.Numerics.3.12.0\lib\net40\MathNet.Numerics.dll"   1..20 | ForEach-Object {[MathNet.Numerics.SpecialFunctions]::Gamma($_ / 10)}  
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Sidef
Sidef
var arr = 'a'..'z'; say arr.join(' ');
http://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet
Generate lower case ASCII alphabet
Task Generate an array, list, lazy sequence, or even an indexable string of all the lower case ASCII characters, from a to z. If the standard library contains such a sequence, show how to access it, but don't fail to show how to generate a similar sequence. For this basic task use a reliable style of coding, a sty...
#Smalltalk
Smalltalk
| asciiLower | asciiLower := String new. 97 to: 122 do: [:asciiCode | asciiLower := asciiLower , asciiCode asCharacter ]. ^asciiLower
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Programming_Language
Programming Language
print(Hello world!)
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Oforth
Oforth
g f
http://rosettacode.org/wiki/Function_composition
Function composition
Task 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. Example compose...
#Ol
Ol
  (define (compose f g) (lambda (x) (f (g x))))   ;; or:   (define ((compose f g) x) (f (g x)))  
http://rosettacode.org/wiki/Fractal_tree
Fractal tree
Generate and draw a fractal tree. 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 Related tasks Pythagoras Tree
#Scala
Scala
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...
http://rosettacode.org/wiki/Fractran
Fractran
FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Horton Conway. A FRACTRAN program is an ordered list of positive fractions P = ( f 1 , f 2 , … , f m ) {\displaystyle P=(f_{1},f_{2},\ldots ,f_{m})} , together with an initial positive integer input n ...
#Raku
Raku
sub fractran(@program) { 2, { first Int, map (* * $_).narrow, @program } ... 0 } say fractran(<17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1>)[^100];
http://rosettacode.org/wiki/Function_definition
Function definition
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function. Task 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 ...
#Clojure
Clojure
(defn multiply [x y] (* x y))   (multiply 4 5)