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/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 ...
#Nim
Nim
from strutils import parseInt   proc ackermann(m, n: int64): int64 = if m == 0: result = n + 1 elif n == 0: result = ackermann(m - 1, 1) else: result = ackermann(m - 1, ackermann(m, n - 1))   proc getNumber(): int = try: result = stdin.readLine.parseInt except ValueError: echo "An integer,...
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...
#Forth
Forth
#! /usr/bin/gforth -d 20M \ Abelian Sandpile Model   0 assert-level !   \ command-line   : parse-number s>number? invert throw drop ; : parse-size ." size  : " next-arg parse-number dup . cr ; : parse-height ." height: " next-arg parse-number dup . cr ; : parse-args cr parse-size parse-height ;   parse-args con...
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...
#Fortran
Fortran
module abelian_sandpile_m   implicit none   private public :: pile   type :: pile !! usage: !! 1) init !! 2) run   integer, allocatable :: grid(:,:) integer :: n(2)   contains procedure :: init procedure :: run   procedure, private :: process_node procedu...
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 ...
#Clojure
Clojure
  (defn words "Split string into words" [^String str] (.split (.stripLeading str) "\\s+"))   (defn join-words "Join words into a single string" ^String [strings] (String/join " " strings))   ;; SOURCE: https://www.stackoverflow.com/a/38947571/12947681 (defn starts-with-ignore-case "Does string start with ...
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 ...
#C
C
#include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h>   const char* 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 CFi...
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...
#ARM_Assembly
ARM Assembly
  /* ARM assembly Raspberry PI or android 32 bits */ /* program abelianSum.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 se...
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 ...
#ABAP
ABAP
class abs definition abstract. public section. methods method1 abstract importing iv_value type f exporting ev_ret type i. protected section. methods method2 abstract importing iv_name type string exporting ev_ret type i. methods add importing iv_a type i iv_b type i exporting ev_ret type i. endclass.  ...
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 ...
#Nit
Nit
# Task: Ackermann function # # A simple straightforward recursive implementation. module ackermann_function   fun ack(m, n: Int): Int do if m == 0 then return n + 1 if n == 0 then return ack(m-1,1) return ack(m-1, ack(m, n-1)) end   for m in [0..3] do for n in [0..6] do print ack(m,n) end print "" end
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...
#F.C5.8Drmul.C3.A6
Fōrmulæ
  // Abelian sandpile model. Nigel Galloway: July 20th., 2020 type Sandpile(x,y,N:int[])= member private this.x=x member private this.y=y member private this.i=let rec topple n=match Array.tryFindIndex(fun n->n>3)n with None->n |So...
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 ...
#Crystal
Crystal
COMMAND_TABLE = "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 in...
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 ...
#C.2B.2B
C++
#include <algorithm> #include <cctype> #include <iostream> #include <sstream> #include <string> #include <vector>   const char* 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 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...
#Ada
Ada
-- Works with Ada 2012   package Abelian_Sandpile is Limit : constant Integer := 4;   type Sandpile is array (0 .. 2, 0 .. 2) of Natural with Default_Component_Value => 0;   procedure Stabalize (Pile : in out Sandpile); function Is_Stable (Pile : in Sandpile) return Boolean; procedure Topple (Pile ...
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 ...
#ActionScript
ActionScript
package { public interface IInterface { function method1():void; function method2(arg1:Array, arg2:Boolean):uint; } }
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 ...
#Ada
Ada
type Queue is limited interface; procedure Enqueue (Lounge : in out Queue; Item : in out Element) is abstract; procedure Dequeue (Lounge : in out Queue; Item : in out Element) is abstract;
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 ...
#Oberon-2
Oberon-2
MODULE ackerman;   IMPORT Out;   VAR m, n : INTEGER;   PROCEDURE Ackerman (x, y : INTEGER) : INTEGER;   BEGIN IF x = 0 THEN RETURN y + 1 ELSIF y = 0 THEN RETURN Ackerman (x - 1 , 1) ELSE RETURN Ackerman (x - 1 , Ackerman (x , y - 1)) END END Ackerman;   BEGIN FOR m := 0 TO 3 DO ...
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...
#F.23
F#
  // Abelian sandpile model. Nigel Galloway: July 20th., 2020 type Sandpile(x,y,N:int[])= member private this.x=x member private this.y=y member private this.i=let rec topple n=match Array.tryFindIndex(fun n->n>3)n with None->n |So...
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 ...
#D
D
class Abbreviations { import std.array: split, join; import std.uni:toUpper;   string[string] replaces;   this(string table) { import std.ascii; import std.conv:parse;   string saved; auto add = (string word){ if(word.length) replaces[word] = word; };   foreach(word; table.toUpper.split) if(isDigit(wo...
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 ...
#Clojure
Clojure
  (defn words [str] "Split string into words" (.split str "\\s+"))   (defn join-words [strings] "Join words into a single string" (clojure.string/join " " strings))   (def cmd-table "Command Table - List of words to match against" (words "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst CO...
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...
#ALGOL_68
ALGOL 68
BEGIN # model Abelian sandpiles # # represents a sandpile # INT elements = 3; MODE SANDPILE = [ 1 : elements, 1 : elements ]INT; # returns TRUE if the sandpiles a and b have the same values, FALSE otherwise # OP = = ( SANDPILE a, b )BOOL: BEGIN BOOL result := TRUE; FOR i TO eleme...
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 ...
#Agda
Agda
module AbstractInterfaceExample where   open import Function open import Data.Bool open import Data.String   -- * One-parameter interface for the type `a' with only one method.   record VoiceInterface (a : Set) : Set where constructor voice-interface field say-method-of : a → String   open VoiceInterface   -- * An ...
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 ...
#Aikido
Aikido
class Abs { public function method1... public function 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 ...
#Objeck
Objeck
class Ackermann { function : Main(args : String[]) ~ Nil { for(m := 0; m <= 3; ++m;) { for(n := 0; n <= 4; ++n;) { a := Ackermann(m, n); if(a > 0) { "Ackermann({$m}, {$n}) = {$a}"->PrintLine(); }; }; }; }   function : Ackermann(m : Int, n : Int) ~ Int { if...
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...
#FreeBASIC
FreeBASIC
ScreenRes 320, 200, 8 WindowTitle "Abelian sandpile model"   Dim As Long dimen = 220 Dim As Long pila1(dimen*dimen), pila2(dimen*dimen) Dim As Long i, x, y Dim As Long partic = 400000 Dim As Double t0 = Timer Do i = 0 For y = 0 To dimen-1 For x = 0 To dimen-1 If x = dimen/2 And y = dimen/2 ...
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 ...
#Delphi
Delphi
  program Abraviation_simple;   {$APPTYPE CONSOLE}   uses System.SysUtils;   type TCommand = record value: string; len: integer; end;   function ReadTable(table: string): TArray<TCommand>; begin var fields := table.Split([' '], TStringSplitOptions.ExcludeEmpty); var i := 0; var max := Length(fields)...
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 ...
#Delphi
Delphi
  program Abbreviations_Easy;   {$APPTYPE CONSOLE}   uses System.SysUtils;   const _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 ...
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...
#C.2B.2B
C++
#include <algorithm> #include <array> #include <cassert> #include <initializer_list> #include <iostream>   constexpr size_t sp_rows = 3; constexpr size_t sp_columns = 3; constexpr size_t sp_cells = sp_rows * sp_columns; constexpr int sp_limit = 4;   class abelian_sandpile { friend std::ostream& operator<<(std::ostr...
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 ...
#AmigaE
AmigaE
  OBJECT fruit ENDOBJECT   PROC color OF fruit IS EMPTY   OBJECT apple OF fruit ENDOBJECT   PROC color OF apple IS WriteF('red ')   OBJECT orange OF fruit ENDOBJECT   PROC color OF orange IS WriteF('orange ')   PROC main() DEF a:PTR TO apple,o:PTR TO orange,x:PTR TO fruit FORALL({x},[NEW a, NEW o],`x.color()) ENDPR...
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 ...
#Apex
Apex
  // Interface public interface PurchaseOrder { // All other functionality excluded Double discount(); }   // One implementation of the interface for customers public class CustomerPurchaseOrder implements PurchaseOrder { public Double discount() { return .05; // Flat 5% discount } }     // Abs...
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 ...
#OCaml
OCaml
let rec a m n = if m=0 then (n+1) else if n=0 then (a (m-1) 1) else (a (m-1) (a m (n-1)))
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...
#Go
Go
package main   import ( "fmt" "log" "os" "strings" )   const dim = 16 // image size   func check(err error) { if err != nil { log.Fatal(err) } }   // Outputs the result to the terminal using UTF-8 block characters. func drawPile(pile [][]uint) { chars:= []rune(" ░▓█") for _, row ...
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 ...
#Factor
Factor
USING: arrays assocs combinators formatting fry grouping.extras kernel literals math math.parser multiline sequences splitting.extras unicode ; IN: rosetta-code.abbr-simple   CONSTANT: input $[ "riG rePEAT copies put mo rest types fup. 6 " "poweRin" append ]   <<  ! Make the following two words av...
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 ...
#Euphoria
Euphoria
  include std/text.e -- for upper conversion include std/console.e -- for display include std/sequence.e   sequence ct = """ 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 F...
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...
#F.23
F#
  let s1=Sandpile(3,3,[|1;2;0;2;1;1;0;1;3|]) let s2=Sandpile(3,3,[|2;1;3;1;0;1;0;1;0|]) printfn "%s\n" ((s1+s2).toS) printfn "%s\n" ((s2+s1).toS);; printfn "%s\n" ((s1+s1).toS) printfn "%s\n" ((s2+s2).toS);; printfn "%s\n" (Sandpile(3,3,[|4;3;3;3;1;2;0;2;3|])).toS;; let s3=Sandpile(3,3,(Array.create 9 3)) let s3_id=San...
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 ...
#Argile
Argile
use std   (: abstract class :)   class Abs text name AbsIface iface   class AbsIface function(Abs)(int)->int method   let Abs_Iface = Cdata AbsIface@ {.method = nil}   .: new Abs :. -> Abs {let a = new(Abs); a.iface = Abs_Iface; a}   =: <Abs self>.method <int i> := -> int (self.iface.method is nil) ? 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 ...
#AutoHotkey
AutoHotkey
color(r, g, b){ static color If !color color := Object("base", Object("R", r, "G", g, "B", b ,"GetRGB", "Color_GetRGB")) return Object("base", Color) } Color_GetRGB(clr) { return "not implemented" }   waterColor(r, g, b){ static waterColor If !waterCol...
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 ...
#Octave
Octave
function r = ackerman(m, n) if ( m == 0 ) r = n + 1; elseif ( n == 0 ) r = ackerman(m-1, 1); else r = ackerman(m-1, ackerman(m, n-1)); endif endfunction   for i = 0:3 disp(ackerman(i, 4)); endfor
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...
#Haskell
Haskell
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-}   module Rosetta.AbelianSandpileModel.ST ( simulate , test , toPGM ) where   import Control.Monad.Reader (asks, MonadReader (..), ReaderT, runReaderT) import Control.Monad...
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 ...
#Forth
Forth
include FMS-SI.f include FMS-SILib.f   ${ 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...
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 ...
#Factor
Factor
USING: arrays ascii assocs combinators.short-circuit io kernel literals math qw sequences sequences.extras splitting.extras ; IN: rosetta-code.abbreviations-easy   CONSTANT: commands qw{ Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xed...
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 ...
#Go
Go
package main   import ( "fmt" "strings" )   var 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...
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...
#Factor
Factor
USING: arrays grouping io kernel math math.vectors prettyprint qw sequences ;   CONSTANT: 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 } }   ! Sandpile words : find-tall ( seq -- n ) [ 3 > ] find drop ; : tall? ( seq -- ? ) find-tall >boolean ; : distribute ( ind...
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 ...
#BASIC
BASIC
INSTALL @lib$+"CLASSLIB"   REM Declare a class with no implementation: DIM abstract{method} PROC_class(abstract{})   REM Inherit from the abstract class: DIM derived{member%} PROC_inherit(derived{}, abstract{}) PROC_class(derived{})   REM Provide an implementation f...
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 ...
#C
C
#ifndef INTERFACE_ABS #define INTERFACE_ABS   typedef struct sAbstractCls *AbsCls;   typedef struct sAbstractMethods { int (*method1)(AbsCls c, int a); const char *(*method2)(AbsCls c, int b); void (*method3)(AbsCls c, double d); } *AbstractMethods, sAbsMethods;   struct sAbstractCls { Ab...
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 ...
#Oforth
Oforth
: A( m n -- p ) m ifZero: [ n 1+ return ] m 1- n ifZero: [ 1 ] else: [ A( m, n 1- ) ] A ;
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...
#J
J
grid=: 4 : 'x (<<.-:2$y)} (2$y)$0' NB. y by y grid with x grains in middle ab=: - [: +/@(-"2 ((,-)=/~i.2)|.!.0]) 3&< NB. abelian sand pile for grid graph require 'viewmat' NB. viewmat utility viewmat ab ^: _ (1024 grid 25) NB. visual
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...
#Java
Java
import java.awt.*; import java.awt.event.*; import javax.swing.*;   public class AbelianSandpile { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Frame frame = new Frame(); frame.setVisible(true); ...
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 ...
#Go
Go
package main   import ( "io" "os" "strconv" "strings" "text/tabwriter" )   func readTable(table string) ([]string, []int) { fields := strings.Fields(table) var commands []string var minLens []int   for i, max := 0, len(fields); i < max; { cmd := fields[i] cmdLen := len(cmd) i++   if i < max { num, e...
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 ...
#Haskell
Haskell
  import Data.Maybe (fromMaybe) import Data.List (find, isPrefixOf) import Data.Char (toUpper, isUpper)   isAbbreviationOf :: String -> String -> Bool isAbbreviationOf abbreviation command = minimumPrefix `isPrefixOf` normalizedAbbreviation && normalizedAbbreviation `isPrefixOf` normalizedCommand where normal...
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...
#Go
Go
package main   import ( "fmt" "strconv" "strings" )   type sandpile struct{ a [9]int }   var neighbors = [][]int{ {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 func newSandpile(a [9]int) *sandpile { return &sandpile{a} }   func (s *s...
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 ...
#C.23
C#
abstract class Class1 { public abstract void method1();   public int method2() { return 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 ...
#C.2B.2B
C++
class Abs { public: virtual int method1(double value) = 0; virtual 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 ...
#OOC
OOC
  ack: func (m: Int, n: Int) -> Int { if (m == 0) { n + 1 } else if (n == 0) { ack(m - 1, 1) } else { ack(m - 1, ack(m, n - 1)) } }   main: func { for (m in 0..4) { for (n in 0..10) { "ack(#{m}, #{n}) = #{ack(m, n)}" println() } } }  
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...
#Julia
Julia
module AbelSand   # supports output functionality for the results of the sandpile simulations # outputs the final grid in CSV format, as well as an image file   using CSV, DataFrames, Images   function TrimZeros(A) # given an array A trims any zero rows/columns from its borders # returns a 4 tuple of integers, ...
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...
#Lua
Lua
local sandpile = { init = function(self, dim, val) self.cell, self.dim = {}, dim for r = 1, dim do self.cell[r] = {} for c = 1, dim do self.cell[r][c] = 0 end end self.cell[math.floor(dim/2)+1][math.floor(dim/2)+1] = val end, iter = function(self) local dim, cel, more...
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 ...
#Haskell
Haskell
import Data.List (find, isPrefixOf) import Data.Char (isDigit, toUpper) import Data.Maybe (maybe)   withExpansions :: [(String, Int)] -> String -> String withExpansions tbl s = unwords $ expanded tbl <$> words s   expanded :: [(String, Int)] -> String -> String expanded tbl k = maybe "*error" fst (expand k) where ...
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 ...
#J
J
  COMMAND_TABLE=: noun define 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 L...
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 ...
#Java
Java
import java.util.HashMap; import java.util.Map; import java.util.Scanner;   public class AbbreviationsEasy { private static final Scanner input = new Scanner(System.in); private static final String COMMAND_TABLE = " Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COp...
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...
#Haskell
Haskell
{-# LANGUAGE TupleSections #-}   import Data.List (findIndex, transpose) import Data.List.Split (chunksOf)   --------------------------- TEST --------------------------- main :: IO () main = do let s0 = [[4, 3, 3], [3, 1, 2], [0, 2, 3]] s1 = [[1, 2, 0], [2, 1, 1], [0, 1, 3]] s2 = [[2, 1, 3], [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 ...
#Cach.C3.A9_ObjectScript
Caché ObjectScript
Class Abstract.Class.Shape [ Abstract ] { Parameter SHAPE = 1; Property Name As %String; Method Description() {} }   Class Abstract.Class.Square Extends (%RegisteredObject, Shape) { Method Description() { Write "SHAPE=", ..#SHAPE, ! Write ..%ClassName()_$Case(..%Extends(..%PackageName()_".Shape"), 1: " is a ", : " is...
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 ...
#Clojure
Clojure
(defprotocol Foo (foo [this]))
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 ...
#ooRexx
ooRexx
  loop m = 0 to 3 loop n = 0 to 6 say "Ackermann("m", "n") =" ackermann(m, n) end end   ::routine ackermann use strict arg m, n -- give us some precision room numeric digits 10000 if m = 0 then return n + 1 else if n = 0 then return ackermann(m - 1, 1) else return ackermann(m - 1, ackermann(...
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...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
ClearAll[sp] sp[s_List] + sp[n_Integer] ^:= sp[s] + sp[ConstantArray[n, Dimensions[s]]] sp[s_List] + sp[t_List] ^:= Module[{dim, r, tmp, neighbours}, dim = Dimensions[s]; r = s + t; While[Max[r] > 3, r = ArrayPad[r, 1, 0]; tmp = Quotient[r, 4]; r -= 4 tmp; r += RotateLeft[tmp, {0, 1}] + RotateLeft[tmp, {1,...
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...
#Nim
Nim
  # Abelian sandpile.   from math import sqrt from nimPNG import savePNG24 from sequtils import repeat from strformat import fmt from strutils import strip, addSep, parseInt   # The grid represented as a sequence of sequences of int32. type Grid = seq[seq[int32]]   # Colors to use for PPM and PNG files. const Colors = ...
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 ...
#J
J
  range=:<.+[:i.>.-<. assert 2 3 4 -: 2 range 5 assert (i.0) -: 3 range 3   abbreviate =: 3 :0 NB. input is the abbreviation table NB. output are the valid abbreviations y =. toupper CRLF -.~ y y =. ;: y y =. (([: (,3":#)L:_1 {)`[`]}~ ([: I. [: -. {.@e.&Num_j_&>)) y y =. [&.:(;:inv) y y =. _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 ...
#JavaScript
JavaScript
  var abr=`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/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...
#J
J
  While=:2 :'u^:(0-.@:-:v)^:_' index_of_maximum=: $ #: (i. >./)@:,   frame=: ({.~ -@:>:@:$)@:({.~ >:@:$) :. ([;.0~ (1,:_2+$)) NEIGHBORS=: _2]\_1 0 0 _1 0 0 0 1 1 0 AVALANCHE =: 1 1 _4 1 1   avalanche=: (AVALANCHE + {)`[`]}~ ([: <"1 NEIGHBORS +"1 index_of_maximum) erode=: avalanche&.:frame While(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 ...
#COBOL
COBOL
INTERFACE-ID. Shape.   PROCEDURE DIVISION.   METHOD-ID. perimeter. DATA DIVISION. LINKAGE SECTION. 01 ret USAGE FLOAT-LONG. PROCEDURE DIVISION RETURNING ret. END METHOD perimeter.   METHOD-ID. shape-area. DATA DIVISION. LINKAGE SECTION. ...
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 ...
#Order
Order
#include <order/interpreter.h>   #define ORDER_PP_DEF_8ack ORDER_PP_FN( \ 8fn(8X, 8Y, \ 8cond((8is_0(8X), 8inc(8Y)) \ (8is_0(8Y), 8ack(8dec(8X), 1)) \ (8else, 8ack(8dec(8X), 8ack(8X, 8dec(8Y)))))))   ORDER_PP(8to_lit(8ack(3, 4))) // 125
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...
#Pascal
Pascal
mul := val DIV 4;//not only := val -4
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...
#OCaml
OCaml
  module Make = functor (M : sig val m : int val n : int end) -> struct   let grid = Array.init M.m (fun _ -> Array.make M.n 0)   let print () = for i = 0 to M.m - 1 do for j = 0 to M.n - 1 do Printf.printf "%d " grid.(i).(j) done ; print_newline () done   let...
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 ...
#Java
Java
import java.util.*;   public class Abbreviations { public static void main(String[] args) { CommandList commands = new CommandList(commandTable); String input = "riG rePEAT copies put mo rest types fup. 6 poweRin"; System.out.println(" input: " + input); System.out...
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 ...
#jq
jq
  def 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 CLocate LOWe...
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 ...
#Julia
Julia
const 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 CLocat...
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 ...
#11l
11l
V oddNumber = 1 V aCount = 0 V dSum = 0   F divisorSum(n) V sum = 1 V i = Int(sqrt(n) + 1)   L(d) 2 .< i I n % d == 0 sum += d V otherD = n I/ d I otherD != d sum += otherD R sum   print(‘The first 25 abundant odd numbers:’) L aCount < 25 dSum = divisorSum(odd...
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...
#Julia
Julia
import Base.+, Base.print   struct Sandpile pile::Matrix{UInt8} end   function Sandpile(s::String) arr = [parse(UInt8, x.match) for x in eachmatch(r"\d+", s)] siz = isqrt(length(arr)) return Sandpile(reshape(UInt8.(arr), siz, siz)') end   const HMAX = 3   function avalanche!(s::Sandpile, lim=HMAX) n...
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 ...
#Common_Lisp
Common Lisp
(defgeneric kar (kons) (:documentation "Return the kar of a kons."))   (defgeneric kdr (kons) (:documentation "Return the kdr of a kons."))   (defun konsp (object &aux (args (list object))) "True if there are applicable methods for kar and kdr on object." (not (or (endp (compute-applicable-methods #'kar args)) ...
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 ...
#Component_Pascal
Component Pascal
  (* Abstract type *) Object = POINTER TO ABSTRACT RECORD END;   (* Integer inherits Object *) Integer = POINTER TO RECORD (Object) i: INTEGER END; (* Point inherits Object *) Point = POINTER TO RECORD (Object) x,y: REAL 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 ...
#Oz
Oz
declare   fun {Ack M N} if M == 0 then N+1 elseif N == 0 then {Ack M-1 1} else {Ack M-1 {Ack M N-1}} end end   in   {Show {Ack 3 7}}
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...
#Perl
Perl
#!/usr/bin/perl   use strict; # http://www.rosettacode.org/wiki/Abelian_sandpile_model use warnings;   my ($high, $wide) = split ' ', qx(stty size); my $mask = "\0" x $wide . ("\0" . "\177" x ($wide - 2) . "\0") x ($high - 5) . "\0" x $wide; my $pile = $mask =~ s/\177/ rand() < 0.02 ? chr 64 + rand 20 : "\0" /ger;   ...
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 ...
#JavaScript
JavaScript
(() => { 'use strict';   // withExpansions :: [(String, Int)] -> String -> String const withExpansions = tbl => s => unwords(map(expanded(tbl), words(s)));   // expanded :: [(String, Int)] -> String -> String const expanded = tbl => s => { const lng = s.length, ...
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 ...
#Kotlin
Kotlin
// version 1.1.4-3   val r = Regex("[ ]+")   val 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 " + ...
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 ...
#360_Assembly
360 Assembly
* Abundant odd numbers 18/09/2019 ABUNODDS CSECT USING ABUNODDS,R13 base register B 72(R15) skip savearea DC 17F'0' savearea SAVE (14,12) save previous context ST R13,4(R15) link backward ST...
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...
#Lua
Lua
sandpile.__index = sandpile sandpile.new = function(self, vals) local inst = setmetatable({},sandpile) inst.cell, inst.dim = {}, #vals for r = 1, inst.dim do inst.cell[r] = {} for c = 1, inst.dim do inst.cell[r][c] = vals[r][c] end end return inst end sandpile.add = function(self, other) l...
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 ...
#Crystal
Crystal
abstract class Animal # only abstract class can have abstract methods abstract def move abstract def think   # abstract class can have normal fields and methods def initialize(@name : String) end   def process think move end end   # WalkingAnimal still have to be declared abstract because `think` ...
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 ...
#D
D
import std.stdio;   class Foo { // abstract methods can have an implementation for // use in super calls. abstract void foo() { writeln("Test"); } }   interface Bar { void bar();   // Final interface methods are allowed. final int spam() { return 1; } }   class Baz : Foo, Bar { // Su...
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 ...
#PARI.2FGP
PARI/GP
A(m,n)={ if(m, if(n, A(m-1, A(m,n-1)) , A(m-1,1) ) , 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...
#11l
11l
F shortest_abbreviation_length(line, list_size) V words = line.split(‘ ’) V word_count = words.len I word_count != list_size X ValueError(‘Not enough entries, expected #. found #.’.format(list_size, word_count))   V abbreviation_length = 1 L V abbreviations = Set(words.map(word -> word[0 .< @...
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...
#Phix
Phix
-- demo\rosetta\Abelian_sandpile_model.exw include pGUI.e Ihandle dlg, canvas cdCanvas cddbuffer sequence board = {{0,0,0}, {0,0,0}, {0,0,0}} procedure drop(integer y, x) sequence moves = {} while true do board[y,x] += 1 if board[y,x]>=4 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 ...
#Julia
Julia
  const commandtable = """ 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 inpu...
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 ...
#Lua
Lua
#!/usr/bin/lua   local list1 = [[ 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 LOW...
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 ...
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B or android 64 bits */ /* program abundant64.s */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "../in...
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...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
ClearAll[sp] sp[s_List] + sp[n_Integer] ^:= sp[s] + sp[ConstantArray[n, Dimensions[s]]] sp[s_List] + sp[t_List] ^:= Module[{dim, r, tmp, neighbours}, dim = Dimensions[s]; r = s + t; While[Max[r] > 3, r = ArrayPad[r, 1, 0]; tmp = Quotient[r, 4]; r -= 4 tmp; r += RotateLeft[tmp, {0, 1}] + RotateLeft[tmp, ...
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 ...
#Delphi
Delphi
TSomeClass = class abstract (TObject) ... 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 ...
#DWScript
DWScript
interface Foo { to bar(a :int, b :int) }
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 ...
#Pascal
Pascal
Program Ackerman;   function ackermann(m, n: Integer) : Integer; begin if m = 0 then ackermann := n+1 else if n = 0 then ackermann := ackermann(m-1, 1) else ackermann := ackermann(m-1, ackermann(m, n-1)); end;   var m, n : Integer;   begin for n := 0 to 6 do for m := 0 to 3 do W...
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...
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B */ /* program abbrAuto64.s */ /* store list of day in a file listDays.txt*/ /* and run the program abbrAuto64 listDays.txt */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for t...
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...
#Python
Python
import numpy as np import matplotlib.pyplot as plt     def iterate(grid): changed = False for ii, arr in enumerate(grid): for jj, val in enumerate(arr): if val > 3: grid[ii, jj] -= 4 if ii > 0: grid[ii - 1, jj] += 1 if ii < ...
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 ...
#Kotlin
Kotlin
import java.util.Locale   private const val table = "" + "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 NfU...
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 ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
ClearAll[ct, FunctionMatchQ, ValidFunctionQ, ProcessString] ct = "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 ...
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 ...
#MATLAB_.2F_Octave
MATLAB / Octave
  function R = abbreviations_easy(input)   CMD=strsplit(['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' ... ' ...