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/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#Ada
Ada
with Ada.Text_IO, Generic_Divisors;   procedure Odd_Abundant is function Same(P: Positive) return Positive is (P);   package Divisor_Sum is new Generic_Divisors (Result_Type => Natural, None => 0, One => Same, Add => "+");   function Abundant(N: Positive) return Boolean is (Divisor_Sum.Process(N) >...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Nim
Nim
  import sequtils import strutils   type SandPile = array[3, array[3, int]]   #---------------------------------------------------------------------------------------------------   iterator neighbors(i, j: int): tuple[a, b: int] = ## Yield the indexes of the neighbours of cell at indexes (i, j). if i > 0: yield...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#E
E
interface Foo { to bar(a :int, b :int) }
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Eiffel
Eiffel
  deferred class AN_ABSTRACT_CLASS   feature   a_deferred_feature -- a feature whose implementation is left to a descendent deferred end   an_effective_feature: STRING -- deferred (abstract) classes may still include effective features do Result := "I am ...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Perl
Perl
{ my @memo; sub A { my( $m, $n ) = @_; $memo[ $m ][ $n ] and return $memo[ $m ][ $n ]; $m or return $n + 1; return $memo[ $m ][ $n ] = ( $n ? A( $m - 1, A( $m, $n - 1 ) ) : A( $m - 1, 1 ) ); } }
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#Ada
Ada
with Ada.Containers.Indefinite_Vectors; with Ada.Strings.Fixed; with Ada.Strings.Maps; with Ada.Text_IO;   procedure Abbreviations is   package String_Vectors is new Ada.Containers.Indefinite_Vectors (Index_Type => Positive, Element_Type => String); use Ada.Text_...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#Raku
Raku
sub cleanup { print "\e[0m\e[?25h\n"; exit(0) }   signal(SIGINT).tap: { cleanup(); exit(0) }   unit sub MAIN ($stack = 1000, :$hide-progress = False );   my @color = "\e[38;2;0;0;0m█", "\e[38;2;255;0;0m█", "\e[38;2;255;255;0m█", "\e[38;2;0;0;255m█", "\e[38;2;255;255;255m█...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Lua
Lua
abbr = { define = function(self, cmdstr) local cmd self.hash = {} for word in cmdstr:upper():gmatch("%S+") do if cmd then local n = tonumber(word) for len = n or #cmd, #cmd do self.hash[cmd:sub(1,len)] = cmd end cmd = n==nil and word or nil else ...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Nanoquery
Nanoquery
import map   COMMAND_TABLE = " Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy\n" +\ " COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find\n" +\ " NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput\n" +\ ...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Nim
Nim
  import sequtils import strutils   const Commands = "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy " & "COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find " & "NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#ALGOL_68
ALGOL 68
BEGIN # find some abundant odd numbers - numbers where the sum of the proper # # divisors is bigger than the number # # itself #   # returns the sum of the proper divisors of n ...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#OCaml
OCaml
    (* https://en.wikipedia.org/wiki/Abelian_sandpile_model *)   module Make = functor (M : sig val m : int val n : int end) -> struct   type t = { grid : int array array ; unstable : ((int*int),unit) Hashtbl.t }   let make () = { grid = Array.init M.m (fun _ -> Array.make M.n 0); unstable = Hashtbl.create ...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Elena
Elena
abstract class Bike { abstract run(); }  
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#F.23
F#
type Shape = abstract Perimeter: unit -> float abstract Area: unit -> float   type Rectangle(width, height) = interface Shape with member x.Perimeter() = 2.0 * width + 2.0 * height member x.Area() = width * height
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Phix
Phix
function ack(integer m, integer n) if m=0 then return n+1 elsif m=1 then return n+2 elsif m=2 then return 2*n+3 elsif m=3 then return power(2,n+3)-3 elsif m>0 and n=0 then return ack(m-1,1) else return ack(m-1,ack(m,n-1)) end if end function ...
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#Amazing_Hopper
Amazing Hopper
  #include <jambo.h>   #define MAX_LINE 150 Main Break on days of week = 0, fd=0, length=0, days=0, temp=0   Open in("dias_de_la_semana.txt")( fd ) If ( Not( File error ) ) Loop if (Not (Eof(fd)) ) Using( MAX_LINE ), Split( Readlin(fd) » (days), days of week, " ")   Continue if( Z...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#Rust
Rust
// This is the main algorithm. // // It loops over the current state of the sandpile and updates it on-the-fly. fn advance(field: &mut Vec<Vec<usize>>, boundary: &mut [usize; 4]) -> bool { // This variable is used to check whether we changed anything in the array. If no, the loop terminates. let mut done = fal...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#Scheme
Scheme
; A two-dimensional grid of values...   ; Create an empty (all cells 0) grid of the specified size. ; Optionally, fill all cells with given value. (define make-grid (lambda (size-x size-y . opt-value) (cons size-x (make-vector (* size-x size-y) (if (null? opt-value) 0 (car opt-value))))))   ; Return the vector of...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#M2000_Interpreter
M2000 Interpreter
  Module Abbreviations_Simple { Function Lex { a$={add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 ...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#OCaml
OCaml
let cmds = "\ Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase ...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#ALGOL_W
ALGOL W
begin  % find some abundant odd numbers - numbers where the sum of the proper  %  % divisors is bigger than the number  %  % itself  %    % computes the sum of the divisors of v using the prime ...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Phix
Phix
constant s1 = {"1 2 0", "2 1 1", "0 1 3"}, s2 = {"2 1 3", "1 0 1", "0 1 0"}, s3 = {"3 3 3", "3 3 3", "3 3 3"}, s3_id = {"2 1 2", "1 0 1", "2 1 2"}, s4 = {"4 3 ...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Fantom
Fantom
  abstract class X { Void method1 () { echo ("Method 1 in X") }   abstract Void method2 () }   class Y : X { // Y must override the abstract method in X override Void method2 () { echo ("Method 2 in Y") } }   class Main { public static Void main () { y := Y() y.method1 y.method2...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Forth
Forth
include 4pp/lib/foos.4pp   :: X() class method: method1 method: method2 end-class {  :method { ." Method 1 in X" cr } ; defines method1 } ;   :: Y() extends X() end-extends {  :method { ." Method 2 in Y" cr } ; defines method2 } ;   : Main static Y() y y => method1 y => method2...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Phixmonti
Phixmonti
def ack var n var m   m 0 == if n 1 + else n 0 == if m 1 - 1 ack else m 1 - m n 1 - ack ack endif endif enddef   3 6 ack print nl
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#ARM_Assembly
ARM Assembly
  /* ARM assembly Raspberry PI */ /* program abbrAuto.s */ /* store list of day in a file listDays.txt*/ /* and run the program abbrAuto listDays.txt */   /* REMARK 1 : this program use routines in a include file see task Include a file language arm assembly for the routine affichageMess conversion10 s...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#VBA
VBA
Sub SetupPile(a As Integer, b As Integer) Application.ScreenUpdating = False For i = 1 To a For j = 1 To b Cells(i, j).value = "" Cells(i, j).Select   With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlMedium End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Wei...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#Vlang
Vlang
import os import strings   const dim = 16   // Outputs the result to the terminal using UTF-8 block characters. fn draw_pile(pile [][]int) { chars:= [` `,`░`,`▓`,`█`] for row in pile { mut line := []rune{len: row.len} for i, e in row { mut elem := e if elem > 3 { // only ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
ClearAll[ct, FunctionMatchQ, ValidFunctionQ, ProcessString] ct = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Pascal
Pascal
  program Abbreviations_Easy; {$IFDEF WINDOWS} {$APPTYPE CONSOLE} {$ENDIF} {$IFDEF FPC} {$MODE DELPHI} uses SysUtils; {$ELSE} uses System.SysUtils; {$ENDIF}   const _TABLE_ = 'Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy ' + 'COUnt COVerlay CURsor DELete CDelete...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#AppleScript
AppleScript
on aliquotSum(n) if (n < 2) then return 0 set sum to 1 set sqrt to n ^ 0.5 set limit to sqrt div 1 if (limit = sqrt) then set sum to sum + limit set limit to limit - 1 end if repeat with i from 2 to limit if (n mod i is 0) then set sum to sum + i + n div i end rep...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Python
Python
from itertools import product from collections import defaultdict     class Sandpile(): def __init__(self, gridtext): array = [int(x) for x in gridtext.strip().split()] self.grid = defaultdict(int, {(i //3, i % 3): x for i, x in enume...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Fortran
Fortran
  ! abstract derived type type, abstract :: TFigure real(rdp) :: area contains ! deferred method i.e. abstract method = must be overridden in extended type procedure(calculate_area), deferred, pass :: calculate_area end type TFigure ! only declaration of the abstract method/procedure f...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#PHP
PHP
function ackermann( $m , $n ) { if ( $m==0 ) { return $n + 1; } elseif ( $n==0 ) { return ackermann( $m-1 , 1 ); } return ackermann( $m-1, ackermann( $m , $n-1 ) ); }   echo ackermann( 3, 4 ); // prints 125
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#AWK
AWK
  # syntax: GAWK -f ABBREVIATIONS_AUTOMATIC.AWK ABBREVIATIONS_AUTOMATIC.TXT { dow_arr[NR] = $0 } END { for (i=1; i<=NR; i++) { if (split(dow_arr[i],arr1,FS) != 7) { printf("NG %s\n",dow_arr[i]) continue } col_width = 0 for (j=1; j<=7; j++) { col_width = max(col_width,...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#Wren
Wren
import "/fmt" for Fmt   class Sandpile { // 'a' is a list of integers in row order construct new(a) { var count = a.count _rows = count.sqrt.floor if (_rows * _rows != count) Fiber.abort("The matrix of values must be square.") _a = a _neighbors = List.filled(count, 0) ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#MiniScript
MiniScript
c = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3" + " compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate" + " 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2" + " forward 2 get help 1 hexType 4 input 1 p...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Perl
Perl
@c = (join ' ', qw< Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LP...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#ARM_Assembly
ARM Assembly
  /* ARM assembly Raspberry PI */ /* program abundant.s */   /* REMARK 1 : this program use routines in a include file see task Include a file language arm assembly for the routine affichageMess conversion10 see at end of this program the instruction include */ /* for constantes see task include a file ...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Raku
Raku
class ASP { has $.h = 3; has $.w = 3; has @.pile = 0 xx $!w * $!h;   method topple { my $buf = $!w * $!h; my $done; repeat { $done = True; loop (my int $row; $row < $!h; $row = $row + 1) { my int $rs = $row * $!w; # row start ...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#FreeBASIC
FreeBASIC
' FB 1.05.0 Win64   Type Animal Extends Object Declare Abstract Sub MakeNoise() End Type   Type Bear Extends Animal name As String Declare Constructor(name As String) Declare Sub MakeNoise() End Type   Constructor Bear(name As String) This.name = name End Constructor   Sub Bear.MakeNoise() Print name; " is...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Picat
Picat
go => foreach(M in 0..3) println([m=M,[a(M,N) : N in 0..16]]) end, nl, printf("a2(4,1): %d\n", a2(4,1)), nl, time(check_larger(3,10000)), nl, time(check_larger(4,2)), nl.   % Using a2/2 and chop off large output check_larger(M,N) => printf("a2(%d,%d): ", M,N), A = a2...
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#BQN
BQN
Split ← (⊢-˜+`׬)∘=⊔⊢ Abbrnum ← 1⊸{ 𝕊⟨⟩:@; ((⊢≡⍷)𝕨↑¨𝕩)◶⟨(𝕨+1)⊸𝕊,𝕨⟩𝕩} words ← ' ' Split¨ •FLines "abbrs.txt" (•Show Abbrnum ≍○< ⊢)¨words
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#C
C
#include <stdio.h> #include <stdlib.h> #include <string.h>   void process(int lineNum, char buffer[]) { char days[7][64]; int i = 0, d = 0, j = 0;   while (buffer[i] != 0) { if (buffer[i] == ' ') { days[d][j] = '\0'; ++d; j = 0; } else if (buffer[i] == '\n...
http://rosettacode.org/wiki/Abelian_sandpile_model
Abelian sandpile model
This page uses content from Wikipedia. The original article was at Abelian sandpile model. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Implement the Abelian sandpile model also known as Bak–Tan...
#XPL0
XPL0
def Size = 200; char Pile1(Size*Size), Pile2(Size*Size); int Spigot, I, X, Y; [SetVid($13); \VGA 320x200x8 FillMem(Pile1, 0, Size*Size); FillMem(Pile2, 0, Size*Size); Spigot:= 400_000; repeat I:= 0; for Y:= 0 to Size-1 do for X:= 0 to Size-1 do [if X=Size/2 & Y=Size/2 then ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Nim
Nim
  import parseutils import strutils import tables   const Commands = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 " & "compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate " & "3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cf...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Phix
Phix
constant abbrtxt = """ Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercas...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#Arturo
Arturo
abundant?: function [n]-> (2*n) < sum factors n   print "the first 25 abundant odd numbers:" [i, found]: @[new 1, new 0] while [found<25][ if abundant? i [ inc 'found print [i "=> sum:" sum factors i] ] 'i + 2 ]   [i, found]: @[new 1, new 0] while [found<1000][ if abundant? i [ i...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Red
Red
  Red [Purpose: "implement Abelian sandpile model"]   sadd: make object! [ comb: function [pile1 [series!] pile2 [series!]] [ repeat r 3 [ repeat c 3 [ pile2/:r/:c: pile2/:r/:c + pile1/:r/:c ] ] check pile2 ] check: func [pile [series!]] [ stable: true row: col: none repeat r 3[ repeat c 3[ ...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Genyris
Genyris
class AbstractStack() def .valid?(object) nil   tag AbstractStack some-object # always fails
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Go
Go
package main   import "fmt"   type Beast interface { Kind() string Name() string Cry() string }   type Dog struct { kind string name string }   func (d Dog) Kind() string { return d.kind }   func (d Dog) Name() string { return d.name }   func (d Dog) Cry() string { return "Woof" }   type Cat struct ...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#PicoLisp
PicoLisp
(de ack (X Y) (cond ((=0 X) (inc Y)) ((=0 Y) (ack (dec X) 1)) (T (ack (dec X) (ack X (dec Y)))) ) )
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#C.23
C#
using System; using System.Collections.Generic;   namespace Abbreviations { class Program { static void Main(string[] args) { string[] lines = System.IO.File.ReadAllLines("days_of_week.txt"); int i = 0;   foreach (string line in lines) { i++; ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#OCaml
OCaml
open String   let table_as_string = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 \ Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 \ Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 \ xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 \ Cfind 2 findUP 3 fUP 2 forward ...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#PHP
PHP
  // note this is php 7.x $commands = 'Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLoc...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#AutoHotkey
AutoHotkey
Abundant(num){ sum := 0, str := "" for n, bool in proper_divisors(num) sum += n, str .= (str?"+":"") n return sum > num ? str " = " sum : 0 } proper_divisors(n) { Array := [] if n = 1 return Array Array[1] := true x := Floor(Sqrt(n)) loop, % x+1 if !Mod(n, i:=A_Index+1) && (floor(n/i) < n) Array[floor...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#REXX
REXX
/*REXX program demonstrates a 3x3 sandpile model by addition with toppling & avalanches.*/ @.= 0; size= 3 /*assign 0 to all grid cells; grid size*/ call init 1, 1 2 0 2 1 1 0 1 3 /* " grains of sand──► sandpile 1. */ call init 2, 2 1 3 1 0 1 0 1 0 ...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Groovy
Groovy
public interface Interface { int method1(double value) int method2(String name) int add(int a, int b) }
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Haskell
Haskell
class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Piet
Piet
 ? 3  ? 5 253
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#C.2B.2B
C++
#include <iomanip> #include <iostream> #include <fstream> #include <map> #include <sstream> #include <string> #include <vector>   std::vector<std::string> split(const std::string& str, char delimiter) { std::vector<std::string> tokens; std::string token; std::istringstream tokenStream(str); while (std::...
http://rosettacode.org/wiki/ABC_problem
ABC problem
ABC problem You are encouraged to solve this task according to the task description, using any language you may know. You are given a collection of ABC blocks   (maybe like the ones you had when you were a kid). There are twenty blocks with two letters on each block. A complete alphabet is guaranteed amongst all sid...
#11l
11l
F can_make_word(word) I word == ‘’ R 0B   V blocks_remaining = ‘BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM’.split(‘ ’)   L(ch) word.uppercase() L(block) blocks_remaining I ch C block blocks_remaining.remove(block) L.break L.was_no_break ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Perl
Perl
@c = (uc join ' ', qw< add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get help 1 hexType 4 input 1 ...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Picat
Picat
  import util.   command_table("Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase U...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#PowerShell
PowerShell
<# Start with a string of the commands #> $cmdTableStr = "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOA...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#AWK
AWK
  # syntax: GAWK -f ABUNDANT_ODD_NUMBERS.AWK # converted from C BEGIN { print(" index number sum") fmt = "%8s %10d %10d\n" n = 1 for (c=0; c<25; n+=2) { if (n < sum_proper_divisors(n)) { printf(fmt,++c,n,sum) } } for (; c<1000; n+=2) { if (n < sum_proper_di...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Ruby
Ruby
class Sandpile   def initialize(ar) = @grid = ar   def to_a = @grid.dup   def + (other) res = self.to_a.zip(other.to_a).map{|row1, row2| row1.zip(row2).map(&:sum) } Sandpile.new(res) end   def stable? = @grid.flatten.none?{|v| v > 3}   def avalanche topple until stable? self end   def =...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Icon_and_Unicon
Icon and Unicon
class abstraction() abstract method compare(l,r) # generates runerr(700, "method compare()") end
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#J
J
public abstract class Abs { public abstract int method1(double value); protected abstract int method2(String name); int add(int a, int b) { return a + b; } }
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#Pike
Pike
int main(){ write(ackermann(3,4) + "\n"); }   int ackermann(int m, int n){ if(m == 0){ return n + 1; } else if(n == 0){ return ackermann(m-1, 1); } else { return ackermann(m-1, ackermann(m, n-1)); } }
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#COBOL
COBOL
IDENTIFICATION DIVISION. PROGRAM-ID. AUTO-ABBREVIATIONS.   ENVIRONMENT DIVISION.   INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT DOW ASSIGN TO "days-of-week.txt" ORGANIZATION IS LINE SEQUENTIAL.   DATA DIVISION. ...
http://rosettacode.org/wiki/ABC_problem
ABC problem
ABC problem You are encouraged to solve this task according to the task description, using any language you may know. You are given a collection of ABC blocks   (maybe like the ones you had when you were a kid). There are twenty blocks with two letters on each block. A complete alphabet is guaranteed amongst all sid...
#360_Assembly
360 Assembly
* ABC Problem 21/07/2016 ABC CSECT USING ABC,R13 base register B 72(R15) skip savearea DC 17F'0' savearea STM R14,R12,12(R13) prolog ST R13,4(R15) " <- ST R15,8(R13) ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Phix
Phix
constant abbrtxt = """ add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get help 1 hexType...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Prolog
Prolog
  :- initialization(main).   command_table("Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate ...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#BASIC256
BASIC256
  numimpar = 1 contar = 0 sumaDiv = 0   function SumaDivisores(n) # Devuelve la suma de los divisores propios de n suma = 1 i = int(sqr(n))   for d = 2 to i if n % d = 0 then suma += d otroD = n \ d if otroD <> d Then suma += otroD end if Next d Return suma End Function   # Encontrar los números requ...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Vlang
Vlang
import strings   struct Sandpile { mut: a [9]int }   const ( neighbors = [ [1, 3], [0, 2, 4], [1, 5], [0, 4, 6], [1, 3, 5, 7], [2, 4, 8], [3, 7], [4, 6, 8], [5, 7] ] )   // 'a' is in row order fn new_sandpile(a [9]int) Sandpile { return Sandpile{a} }   fn (s &Sandpile) plus(other &Sandpile) Sandpile { mut b...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Java
Java
public abstract class Abs { public abstract int method1(double value); protected abstract int method2(String name); int add(int a, int b) { return a + b; } }
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Julia
Julia
abstract type «name» end abstract type «name» <: «supertype» end
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#PL.2FI
PL/I
Ackerman: procedure (m, n) returns (fixed (30)) recursive; declare (m, n) fixed (30); if m = 0 then return (n+1); else if m > 0 & n = 0 then return (Ackerman(m-1, 1)); else if m > 0 & n > 0 then return (Ackerman(m-1, Ackerman(m, n-1))); return (0); end Ackerman;
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#Common_Lisp
Common Lisp
  (defun max-mismatch (list) (if (cdr list) (max (apply #'max (mapcar #'(lambda (w2) (mismatch (car list) w2)) (cdr list))) (max-mismatch (cdr list))) 0 ))   (with-open-file (f "days-of-the-week.txt" :direction :input) (do* ((row (read-line f nil nil) (read-line f nil nil))) ((null row) t) (forma...
http://rosettacode.org/wiki/ABC_problem
ABC problem
ABC problem You are encouraged to solve this task according to the task description, using any language you may know. You are given a collection of ABC blocks   (maybe like the ones you had when you were a kid). There are twenty blocks with two letters on each block. A complete alphabet is guaranteed amongst all sid...
#8080_Assembly
8080 Assembly
org 100h jmp test ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Subroutine 'blocks': takes a $-terminated string in ;;; DE containing a word, and checks whether it can be ;;; written with the blocks. ;;; Returns: carry flag set if word is accepted. ;;; Uses registers: A, B, D, E, H, L ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Python
Python
    command_table_text = """add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get help 1 hexTy...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Python
Python
command_table_text = \ """Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPerca...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#C
C
#include <stdio.h> #include <math.h>   // The following function is for odd numbers ONLY // Please use "for (unsigned i = 2, j; i*i <= n; i ++)" for even and odd numbers unsigned sum_proper_divisors(const unsigned n) { unsigned sum = 1; for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i ==...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Wren
Wren
import "/fmt" for Fmt   class Sandpile { static init() { __neighbors = [ [1, 3], [0, 2, 4], [1, 5], [0, 4, 6], [1, 3, 5, 7], [2, 4, 8], [3, 7], [4, 6, 8], [5, 7] ] }   // 'a' is a list of 9 integers in row order construct new(a) { _a = a }   a { _a }   +(o...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Kotlin
Kotlin
// version 1.1   interface Announcer { fun announceType()   // interface can contain non-abstract members but cannot store state fun announceName() { println("I don't have a name") } }   abstract class Animal: Announcer { abstract fun makeNoise()   // abstract class can contain non-abstr...
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#PL.2FSQL
PL/SQL
DECLARE   FUNCTION ackermann(pi_m IN NUMBER, pi_n IN NUMBER) RETURN NUMBER IS BEGIN IF pi_m = 0 THEN RETURN pi_n + 1; ELSIF pi_n = 0 THEN RETURN ackermann(pi_m - 1, 1); ELSE RETURN ackermann(pi_m - 1, ackermann(pi_m, pi_n - 1)); END IF; END ackermann;   BEGIN...
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#D
D
import std.conv; import std.exception; import std.range; import std.stdio; import std.string;   void main() { foreach (size_t i, dstring line; File("days_of_week.txt").lines) { line = chomp(line); if (!line.empty) { auto days = line.split; enforce(days.length==7, text("There ...
http://rosettacode.org/wiki/ABC_problem
ABC problem
ABC problem You are encouraged to solve this task according to the task description, using any language you may know. You are given a collection of ABC blocks   (maybe like the ones you had when you were a kid). There are twenty blocks with two letters on each block. A complete alphabet is guaranteed amongst all sid...
#8086_Assembly
8086 Assembly
cpu 8086 bits 16 org 100h section .text jmp demo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Subroutine "blocks": see if the $-terminated string in DS:BX ;;; can be written with the blocks. ;;; Returns: carry flag set if word is accepted. ;;; Uses registers: AL, BX, CX, SI, DI ...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Racket
Racket
#lang racket (require srfi/13)   (define command-table #<<EOS add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 for...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Racket
Racket
#lang racket   (define command-string "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CL...
http://rosettacode.org/wiki/Abbreviations,_easy
Abbreviations, easy
This task is an easier (to code) variant of the Rosetta Code task:   Abbreviations, simple. For this task, the following   command table   will be used: Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find ...
#Raku
Raku
< Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO MErge ...
http://rosettacode.org/wiki/Abundant_odd_numbers
Abundant odd numbers
An Abundant number is a number n for which the   sum of divisors   σ(n) > 2n, or,   equivalently,   the   sum of proper divisors   (or aliquot sum)       s(n) > n. E.G. 12   is abundant, it has the proper divisors     1,2,3,4 & 6     which sum to   16   ( > 12 or n);        or alternately,   has the sigma sum of ...
#C.23
C#
using static System.Console; using System.Collections.Generic; using System.Linq;   public static class AbundantOddNumbers { public static void Main() { WriteLine("First 25 abundant odd numbers:"); foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format()); WriteLine(); Writ...
http://rosettacode.org/wiki/Abelian_sandpile_model/Identity
Abelian sandpile model/Identity
Our sandpiles are based on a 3 by 3 rectangular grid giving nine areas that contain a number from 0 to 3 inclusive. (The numbers are said to represent grains of sand in each area of the sandpile). E.g. s1 = 1 2 0 2 1 1 0 1 3 and s2 = 2 1 3 1 0 1 0 1 0 Addition on sandpiles is done by a...
#Rust
Rust
#[derive(Clone)] struct Box { piles: [[u8; 3]; 3], }   impl Box { fn init(piles: [[u8; 3]; 3]) -> Box { let a = Box { piles };   if a.piles.iter().any(|&row| row.iter().any(|&pile| pile >= 4)) { return a.avalanche(); } else { return a; } }   fn ava...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Lasso
Lasso
define abstract_trait => trait { require get(index::integer)   provide first() => .get(1) provide second() => .get(2) provide third() => .get(3) provide fourth() => .get(4) }   define my_type => type { parent array trait { import abstract_trait }   public onCreate(...) => ..onCreate(:#...
http://rosettacode.org/wiki/Abstract_type
Abstract type
Abstract type is a type without instances or without definition. For example in object-oriented programming using some languages, abstract types can be partial implementations of other types, which are to be derived there-from. An abstract type may provide implementation of some operations and/or components. Abstract ...
#Lingo
Lingo
on extendAbstractClass (instance, abstractClass) -- 'raw' instance of abstract class is made parent ("ancestor") of the -- passed instance, i.e. the passed instance extends the abstract class instance.setProp(#ancestor, abstractClass.rawNew()) end
http://rosettacode.org/wiki/Ackermann_function
Ackermann function
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree. The Ackermann function is usually defined as follows: A ( m , n ) = { n + 1 if  m = 0 A ( m ...
#PostScript
PostScript
/ackermann{ /n exch def /m exch def %PostScript takes arguments in the reverse order as specified in the function definition m 0 eq{ n 1 add }if m 0 gt n 0 eq and { m 1 sub 1 ackermann }if m 0 gt n 0 gt and{ m 1 sub m n 1 sub ackermann ackermann }if }def
http://rosettacode.org/wiki/Abbreviations,_automatic
Abbreviations, automatic
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. It would make a list of words easier to maintain   (as words are added, changed, and/or deleted)   if the minimum abbrevia...
#Delphi
Delphi
  program Abbreviations_Automatic;   {$APPTYPE CONSOLE}   uses System.SysUtils, System.Generics.Collections, System.IOUtils;   function DistinctStrings(strs: TArray<string>): TArray<string>; begin var l := length(strs); var _set := TDictionary<string, Boolean>.Create; SetLength(result, 0); for var str in ...
http://rosettacode.org/wiki/ABC_problem
ABC problem
ABC problem You are encouraged to solve this task according to the task description, using any language you may know. You are given a collection of ABC blocks   (maybe like the ones you had when you were a kid). There are twenty blocks with two letters on each block. A complete alphabet is guaranteed amongst all sid...
#8th
8th
  \ ======================================================================================== \ You are given a collection of ABC blocks \ There are twenty blocks with two letters on each block. \ A complete alphabet is guaranteed amongst all sides of the blocks. \ \ Write a function that takes a string (word) and dete...
http://rosettacode.org/wiki/Abbreviations,_simple
Abbreviations, simple
The use of   abbreviations   (also sometimes called synonyms, nicknames, AKAs, or aliases)   can be an easy way to add flexibility when specifying or using commands, sub─commands, options, etc. For this task, the following   command table   will be used: add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 ...
#Raku
Raku
< add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 ...