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/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#CoffeeScript
CoffeeScript
  combinations = (n, p) -> return [ [] ] if p == 0 i = 0 combos = [] combo = [] while combo.length < p if i < n combo.push i i += 1 else break if combo.length == 0 i = combo.pop() + 1   if combo.length == p combos.push clone combo i = combo.pop() + 1 combos   ...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Modula-2
Modula-2
IF i = 1 THEN InOut.WriteString('One') ELSIF i = 2 THEN InOut.WriteString('Two') ELSIF i = 3 THEN InOut.WriteString('Three') ELSE InOut.WriteString('Other') END;
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#PowerShell
PowerShell
# single-line comment
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Processing
Processing
// a single-line comment   /* a multi-line comment */   /* * a multi-line comment * with some decorative stars */   // comment out a code line // println("foo");   // comment at the end of a line println("foo bar"); // "baz"
http://rosettacode.org/wiki/Color_quantization
Color quantization
full color Example: Gimp 16 color Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace. There...
#Wren
Wren
import "dome" for Window import "graphics" for Canvas, Color, ImageData import "./dynamic" for Struct import "./sort" for Sort   var QItem = Struct.create("QItem", ["color", "index"])   var ColorsUsed = []   class ColorQuantization { construct new(filename, filename2) { Window.title = "Color quantization" ...
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#AutoHotkey
AutoHotkey
#SingleInstance, Force #NoEnv SetBatchLines, -1   ; Uncomment if Gdip.ahk is not in your standard library ;#Include, Gdip.ahk   ; Start gdi+ If !pToken := Gdip_Startup() { message = ( LTrim gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system. ) MsgBox, 48, %mes...
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#Sidef
Sidef
require('GD')   func pinstripes(width = 1280, height = 720) {   var im = %O<GD::Image>.new(width, height) var colors = [0, 255].variations_with_repetition(3)   var paintcolors = colors.shuffle.map {|rgb| im.colorAllocate(rgb...) }   var starty = 0 var barheight = height//4   for...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Common_Lisp
Common Lisp
(defun map-combinations (m n fn) "Call fn with each m combination of the integers from 0 to n-1 as a list. The list may be destroyed after fn returns." (let ((combination (make-list m))) (labels ((up-from (low) (let ((start (1- low))) (lambda () (incf start)))) (mc (...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Modula-3
Modula-3
IF Foo = TRUE THEN Bar(); ELSE Baz(); END;
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#ProDOS
ProDOS
IGNORELINE your text here
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Prolog
Prolog
% this is a single-line comment that extends to the end of the line
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#AWK
AWK
  BEGIN { nrcolors = 8   for (height=0; height<20; height++) { for (width=0; width<nrcolors; width++) { # print (ANSI) basic color and amount of spaces printf("\033[%dm%*s", width + 40, 64 / nrcolors, " ") }   # reset color and print newline printf("\033[0m\n") } }  
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#BASIC
BASIC
SCREEN 1,320,200,5,1 WINDOW 2,"Color bars",(0,10)-(297,186),15,1 FOR a=0 TO 300 LINE (a,0)-(a,186),(a+10)/10 NEXT loop: GOTO loop
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#SmileBASIC
SmileBASIC
FOR I=1 TO 4 COLIDX=0 YTOP=(I-1)*60 FOR X=0 TO 399 STEP I IF COLIDX MOD 8==0 THEN RESTORE @COLOURS ENDIF READ R,G,B GFILL X,YTOP,X+I,YTOP+59,RGB(R,G,B) INC COLIDX NEXT NEXT   @COLOURS DATA 0,0,0 DATA 255,0,0 DATA 0,255,0 DATA 0,0,255 DATA 255,0,255 DATA 0,255,255 DATA 255,255,0 DATA 255,255,255
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#Tcl
Tcl
package require Tcl 8.5 package require Tk 8.5   wm attributes . -fullscreen 1 pack [canvas .c -highlightthick 0] -fill both -expand 1 set colors {black red green blue magenta cyan yellow white}   set dy [expr {[winfo screenheight .c]/4}] set y 0 foreach dx {1 2 3 4} { for {set x 0} {$x < [winfo screenwidth .c]} {i...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Crystal
Crystal
  def comb(m, n) (0...n).to_a.each_combination(m) { |p| puts(p) } end  
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Monicelli
Monicelli
  che cosè var? # switch var minore di 0: # case var < 0 ... maggiore di 0: # case var > 0 ... o tarapia tapioco: # else (none of the previous cases) ... e velocità di esecuzione  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#PureBasic
PureBasic
;comments come after an unquoted semicolon and last until the end of the line foo = 5 ;This is a comment c$ = ";This is not a comment" ;This is also a comment
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Python
Python
# This is a comment foo = 5 # You can also append comments to statements
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Befunge
Befunge
<v%"P": <<*"(2" v_:"P"/"["39*,, :55+/68v v,,,";1H" ,+*86%+55 ,+*< 73654210v,,\,,,*93"[4m"< >$:55+%#v_:1-"P"%55+/3g^ 39*,,,~@>48*,1-:#v_$"m["
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#C
C
  #include<conio.h>   #define COLOURS 8   int main() { int colour=0,i,j,MAXROW,MAXCOL; struct text_info tInfo; gettextinfo(&tInfo); MAXROW = tInfo.screenheight; MAXCOL = tInfo.screenwidth; textbackground(BLACK); //8 colour constants are defined clrscr();   for(colour=0;colour<COLOURS;colour++) { getch();...
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#True_BASIC
True BASIC
LET w = 640 LET h = 480 SET WINDOW 0, w, 0, h   LET h = h/4 LET y2 = h-1   FOR i = 1 TO 4 LET col = 0 LET y = (i-1)*h FOR x = 1 TO w STEP i IF remainder(col,15) = 0 THEN LET col = 0 SET COLOR col BOX AREA x, x+i, y, y+h LET col = col+1 NEXT x NEXT i END
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#Visual_Basic_.NET
Visual Basic .NET
Public Class Main Inherits System.Windows.Forms.Form Public Sub New() Me.FormBorderStyle = FormBorderStyle.None Me.WindowState = FormWindowState.Maximized End Sub Private Sub Main_Load(sender As Object, e As EventArgs) Handles Me.Load Dim Index As Integer Dim Colors() As ...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#D
D
T[][] comb(T)(in T[] arr, in int k) pure nothrow { if (k == 0) return [[]]; typeof(return) result; foreach (immutable i, immutable x; arr) foreach (suffix; arr[i + 1 .. $].comb(k - 1)) result ~= x ~ suffix; return result; }   void main() { import std.stdio; [0, 1, 2, 3].comb(...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Morfa
Morfa
  if(s == "Hello World") { foo(); } else if(s == "Bye World") bar(); else { baz(); }  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Quackery
Quackery
  ( The word "(" is a compiler directive (a builder, in Quackery jargon) that causes the compiler to disregard everything until it encounters a ")" preceded by whitespace.   If you require more than that, it is trivial to define new comment builders... )   [ behead carriage = until ...
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#QB64
QB64
REM This is a remark... ' This is also a remark...   IF a = 0 THEN REM (REM follows syntax rules) IF a = 0 THEN '(apostrophe doesn't follow syntax rules, so use END IF after this) END IF   'Metacommands such as $DYNAMIC and $INCLUDE use the REM (or apostrophe). REM $STATIC 'arrays cannot be resized once dimensioned. RE...
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#R
R
# end of line comment
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#C.2B.2B
C++
#ifndef MYWIDGET_H #define MYWIDGET_H #include <QWidget>   class QPaintEvent ;   class MyWidget : public QWidget { public : MyWidget( ) ;   protected : void paintEvent( QPaintEvent * ) ; private : int width ; int height ; const int colornumber ; } ; #endif
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#COBOL
COBOL
IDENTIFICATION DIVISION. PROGRAM-ID. terminal-colour-bars.   DATA DIVISION. WORKING-STORAGE SECTION. 01 width PIC 9(3). 01 height PIC 9(3).   01 interval PIC 9(3).   01 colours-area. 03 colour-values. 05 FI...
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#Wren
Wren
import "graphics" for Canvas, Color import "dome" for Window   class Game { static init() { Window.title = "Color pinstripe" __width = 900 __height = 600 Canvas.resize(__width, __height) Window.resize(__width, __height) var colors = [ Color.hex("000000"), ...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Delphi
Delphi
def combinations(m, range) { return if (m <=> 0) { [[]] } else { def combGenerator { to iterate(f) { for i in range { for suffix in combinations(m.previous(), range & (int > i)) { f(null, [i] + suffix) } } } } } }
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#MUMPS
MUMPS
IF A list-of-MUMPS-commands
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Racket
Racket
  ; this is a to-end-of-line coment   #| balanced comment, #| can be nested |# |#   #;(this expression is ignored)   #; ; the following expression is commented because of the #; in the beginning (ignored)    
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Raku
Raku
# the answer to everything my $x = 42;
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Common_Lisp
Common Lisp
(defun color-bars () (with-screen (scr :input-blocking t :input-echoing nil :cursor-visible nil) (dotimes (i (height scr)) (move scr i 0) (dolist (color '(:red :green :yellow :blue :magenta :cyan :white :black)) (add-char scr #\space :bgcolor color :n (floor (/ (width scr) 8))))) (refresh ...
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#XPL0
XPL0
code ChIn=7, Point=41, SetVid=45; int X, Y, W, C; [SetVid($13); \set 320x200 graphics mode in 256 colors for Y:= 0 to 200-1 do \for all the scan lines... [W:= Y/50 + 1; \width of stripe = 1, 2, 3, 4 C:= 0; \set color to black so first pixel becomes b...
http://rosettacode.org/wiki/Colour_pinstripe/Display
Colour pinstripe/Display
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and  ...
#Yabasic
Yabasic
w = 640 : h = 480 open window w, h h4 = h/4   FOR I=1 TO 4 COLIDX=0 YTOP=(I-1)*h4 FOR X=1 TO w STEP I IF mod(COLIDX, 8) = 0 RESTORE COLOURS READ R,G,B color R, G, B fill rectangle X,YTOP,X+I,YTOP+h4 COLIDX = COLIDX + 1 NEXT NEXT   label COLOURS DATA 0,0,0 DATA 255...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#11l
11l
[(() -> Int)] funcs L(i) 10 funcs.append(() -> @=i * @=i) print(funcs[3]())
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#E
E
def combinations(m, range) { return if (m <=> 0) { [[]] } else { def combGenerator { to iterate(f) { for i in range { for suffix in combinations(m.previous(), range & (int > i)) { f(null, [i] + suffix) } } } } } }
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Nanoquery
Nanoquery
if x = 0 foo() else if x = 1 bar() else if x = 2 baz() else boz() end
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Raven
Raven
# this is a comment
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#REBOL
REBOL
  ; This is a line comment.   { Multi-line strings can be used as comments if you like }  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Relation
Relation
  // This is a valid comment // A space is needed after the double slash  
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Delphi
Delphi
  unit Colour_barsDisplay;   interface   uses Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Forms;   type TfmColourBar = class(TForm) procedure FormPaint(Sender: TObject); procedure FormResize(Sender: TObject); private { Private declarations } public { Public declarations }...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#Ada
Ada
with Ada.Text_IO;   procedure Value_Capture is   protected type Fun is -- declaration of the type of a protected object entry Init(Index: Natural); function Result return Natural; private N: Natural := 0; end Fun;   protected body Fun is -- the implementation of a protected object en...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#EasyLang
EasyLang
n = 5 m = 3 len result[] m # func combinations pos val . . if pos < m for i = val to n - m result[pos] = pos + i call combinations pos + 1 i . else print result[] . . call combinations 0 0
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Nemerle
Nemerle
if (the_answer == 42) FindQuestion() else Foo(); when (stock.price < buy_order) stock.Buy(); unless (text < "") Write(text);
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Retro
Retro
( comments are placed between parentheses. A space must follow the opening parenthesis. )
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#REXX
REXX
/*REXX program that demonstrates what happens when dividing by zero. */ y=7 say 44 / (7-y) /* divide by some strange thingy.*/
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#EasyLang
EasyLang
col[] = [ 000 900 090 909 099 990 999 ] w = 100.0 / len col[] for i range len col[] color col[i] move w * i 0 rect w 100 .
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Factor
Factor
USING: accessors colors.constants kernel math sequences ui ui.gadgets ui.gadgets.tracks ui.pens.solid ; IN: rosetta-code.colour-bars-display   : colors ( -- ) [ horizontal <track> { COLOR: black COLOR: red COLOR: green COLOR: blue COLOR: magenta COLOR: cyan COLOR: yellow COLOR: white } [ <solid> gadget new swap...
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Forth
Forth
  \ Color Bars for TI-99 CAMEL99 Forth   NEEDS HCHAR FROM DSK1.GRAFIX \ TMS9918 control lexicon NEEDS CHARSET FROM DSK1.CHARSET \ restores default character data NEEDS ENUM FROM DSK1.ENUM \ add simple enumerator to Forth   \ Name TI-99 colors 1 ENUM CLR ENUM BLK ENUM MGRN ENUM LGRN ENUM BLU ...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#ALGOL_68
ALGOL 68
  [1:10]PROC(BOOL)INT squares;   FOR i FROM 1 TO 10 DO HEAP INT captured i := i; squares[i] := ((REF INT by ref i, INT by val i,BOOL b)INT:(INT i = by ref i; (b|by ref i := 0); by val i*i)) (captured i, captured i,) OD;   FOR i FROM 1 TO 8 DO print(squares[i](i MOD 2 = 0)) OD; print(new ...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#EchoLisp
EchoLisp
  ;; ;; using the native (combinations) function (lib 'list) (combinations (iota 5) 3) → ((0 1 2) (0 1 3) (0 1 4) (0 2 3) (0 2 4) (0 3 4) (1 2 3) (1 2 4) (1 3 4) (2 3 4)) ;; ;; using an iterator ;; (lib 'sequences) (take (combinator (iota 5) 3) #:all) → ((0 1 2) (0 1 3) (0 1 4) (0 2 3) (0 2 4) (0 3 4) (1 2 3) (1 2 4) (...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#NetRexx
NetRexx
-- simple construct if logicalCondition then conditionWasTrue() else conditionWasFalse()   -- multi-line is ok too if logicalCondition then conditionWasTrue() else conditionWasFalse()   -- using block stuctures if logicalCondition then do conditionWasTrue() ... end else do conditionWasFa...
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Ring
Ring
  //this is a single line comment #this also a single line comment!  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#RLaB
RLaB
  x = "code" # I am a comment x = "code" // Here I comment thee # matlab-like document line // C++ like document line  
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#FreeBASIC
FreeBASIC
' FB 1.05.0 Win64   ' Draw the color bars on an 80 x 25 console using the system palette of 16 colors ' i.e. 5 columns per color Width 80, 25 Shell "cls" Locate ,, 0 '' turn cursor off For clr As UInteger = 0 To 15 Color 0, clr For row As Integer = 1 to 25 Locate row, clr * 5 + 1 Print Space(5); Next ro...
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Gambas
Gambas
Public Sub Form_Open() Dim iColour As Integer[] = [Color.Black, Color.red, Color.Green, Color.Magenta, Color.Cyan, Color.Yellow, Color.white] Dim hPanel As Panel Dim siCount As Short   With Me .Arrangement = Arrange.Horizontal .Height = 300 .Width = 400 End With   For siCount = 0 To 6 hpanel = New Panel(Me) h...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#AntLang
AntLang
fns: {n: x; {n expt 2}} map range[10] (8 elem fns)[]
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#AppleScript
AppleScript
on run set fns to {}   repeat with i from 1 to 10 set end of fns to closure(i) end repeat   |λ|() of item 3 of fns end run   on closure(x) script on |λ|() x * x end |λ| end script end closure
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Egison
Egison
  (define $comb (lambda [$n $xs] (match-all xs (list integer) [(loop $i [1 ,n] <join _ <cons $a_i ...>> _) a])))   (test (comb 3 (between 0 4)))  
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#newLISP
newLISP
(set 'x 1) (if (= x 1) (println "is 1"))
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Robotic
Robotic
  . "This is a comment line"   . "Print Hello world" * "Hello world."   . "This is the only way to comment a line in Robotic"  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Ruby
Ruby
x = "code" # I am a comment   =begin hello I a POD documentation comment like Perl =end puts "code"
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Run_BASIC
Run BASIC
'This is a comment REM This is a comment   print "Notice comment at the end of the line." 'This is a comment print "Also notice this comment at the end of the line." : REM This is a comment  
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Go
Go
package main   import "github.com/fogleman/gg"   var colors = [8]string{ "000000", // black "FF0000", // red "00FF00", // green "0000FF", // blue "FF00FF", // magenta "00FFFF", // cyan "FFFF00", // yellow "FFFFFF", // white }   func drawBars(dc *gg.Context) { w := float64(dc.Width() ...
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Haskell
Haskell
#!/usr/bin/env stack -- stack --resolver lts-7.0 --install-ghc runghc --package vty -- -threaded   import Graphics.Vty   colorBars :: Int -> [(Int, Attr)] -> Image colorBars h bars = horizCat $ map colorBar bars where colorBar (w, attr) = charFill attr ' ' w h   barWidths :: Int -> Int -> [Int] barWidths nBars totalW...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#Axiom
Axiom
)abbrev package TESTP TestPackage TestPackage() : with test: () -> List((()->Integer)) == add test() == [(() +-> i^2) for i in 1..10]
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#Babel
Babel
((main { { iter 1 take bons 1 take dup cp {*} cp 3 take append } 10 times collect ! {eval %d nl <<} each }))
http://rosettacode.org/wiki/Circular_primes
Circular primes
Definitions A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will also be prime. For example: 1193 is a circular prime, since 1931, 9311 and 3119 are all also prime. Note that a number which is a cyclic permutation ...
#ALGOL_68
ALGOL 68
BEGIN # find circular primes - primes where all cyclic permutations # # of the digits are also prime # # genertes a sieve of circular primes, only the first # # permutation of each prime is flagged as TRUE # OP CIRCULARPRIMESIEVE = ( INT ...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Eiffel
Eiffel
    class COMBINATIONS   create make   feature   make (n, k: INTEGER) require n_positive: n > 0 k_positive: k > 0 k_smaller_equal: k <= n do create set.make set.extend ("") create sol.make sol := solve (set, k, n - k) sol := convert_solution (n, sol) ensure correct_num_of_sol: num_of...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Nim
Nim
if x == 0: foo() elif x == 1: bar() elif x == 2: baz() else: boz()
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Rust
Rust
// A single line comment   /* This is a multi-line (aka block) comment   /* containing nested multi-line comment (nesting supported since 0.9-pre https://github.com/mozilla/rust/issues/9468) */ */     /// Outer single line Rustdoc comments apply to the next item.   /** Outer multi-line R...
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#SAS
SAS
/* comment */   *another comment;   * both may be multiline;
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Sather
Sather
-- a single line comment
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Icon_and_Unicon
Icon and Unicon
link graphics,printf   procedure main() # generalized colour bars DrawTestCard(Simple_TestCard()) WDone() end   procedure DrawTestCard(TC) size := sprintf("size=%d,%d",TC.width,TC.height) &window := TC.window := open(TC.id,"g","bg=black",size) | stop("Unable to open window")   eve...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#Bracmat
Bracmat
( -1:?i & :?funcs & whl ' ( 1+!i:<10:?i & !funcs ()'(.$i^2):?funcs ) & whl'(!funcs:%?func %?funcs&out$(!func$)) );  
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#C
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/mman.h>   typedef int (*f_int)();   #define TAG 0xdeadbeef int _tmpl() { volatile int x = TAG; return x * x; }   #define PROT (PROT_EXEC | PROT_WRITE) #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) f_int dupf(int v) { size_t len = (void*)dupf - ...
http://rosettacode.org/wiki/Circular_primes
Circular primes
Definitions A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will also be prime. For example: 1193 is a circular prime, since 1931, 9311 and 3119 are all also prime. Note that a number which is a cyclic permutation ...
#ALGOL_W
ALGOL W
begin % find circular primes - primes where all cyclic permutations  %  % of the digits are also prime  %  % sets p( 1 :: n ) to a sieve of primes up to n % procedure Eratosthenes ( logical array p( * ) ; integer value n ) ; begin p( 1 ) := false; p( 2 ) := true; ...
http://rosettacode.org/wiki/Circular_primes
Circular primes
Definitions A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will also be prime. For example: 1193 is a circular prime, since 1931, 9311 and 3119 are all also prime. Note that a number which is a cyclic permutation ...
#Arturo
Arturo
perms: function [n][ str: repeat to :string n 2 result: new [] lim: dec size digits n loop 0..lim 'd -> 'result ++ slice str d lim+d   return to [:integer] result ]   circulars: new []   circular?: function [x][ if not? prime? x -> return false   loop perms x 'y [ if not? pri...
http://rosettacode.org/wiki/Collections
Collections
This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task. Collections are abstractions to represent sets of values. In statically-typed languages, the values are typically of a common data type. Task Create a collection, and add a fe...
#11l
11l
dc.l TrapString_Bus dc.l TrapString_Addr dc.l TrapString_Illegal dc.l TrapString_Div0 dc.l TrapString_chk dc.l TrapString_v dc.l TrapString_priv dc.l TrapString_trace   TrapString_Bus: dc.b "Bus error",255 even TrapString_Addr: dc.b "Address error",255 even TrapString_Illegal: dc.b "Illegal Instruction",25...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Elena
Elena
import system'routines; import extensions; import extensions'routines;   const int M = 3; const int N = 5;   Numbers(n) { ^ Array.allocate(n).populate:(int n => n) }   public program() { var numbers := Numbers(N); Combinator.new(M, numbers).forEach:(row) { console.printLine(row.toString()) ...
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Objeck
Objeck
  a := GetValue(); if(a < 5) { "less than 5"->PrintLine(); } else if(a > 5) { "greater than 5"->PrintLine(); } else { "equal to 5"->PrintLine(); };  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Scala
Scala
// A single line comment   /* A multi-line comment */
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Scheme
Scheme
; Basically the same as Common Lisp ; While R5RS does not provide block comments, they are defined in SRFI-30, as in Common Lisp :   #| comment ... #| nested comment ... |# |#   ; See http://srfi.schemers.org/srfi-30/srfi-30.html  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Scilab
Scilab
// this is a comment i=i+1 // this is a comment
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#J
J
load 'viewmat' size=: 2{.".wd'qm' NB. J6 size=: getscreenwh_jgtk_ '' NB. J7 'rgb'viewmat (|.size){. (>.&.(%&160)|.size)$ 20# 256#.255*#:i.8
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Java
Java
  import java.awt.Color; import java.awt.Graphics;   import javax.swing.JFrame;   public class ColorFrame extends JFrame { public ColorFrame(int width, int height) { this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setSize(width, height); this.setVisible(true); }   @Override public void paint(Graphics g) { ...
http://rosettacode.org/wiki/Closures/Value_capture
Closures/Value capture
Task Create a list of ten functions, in the simplest manner possible   (anonymous functions are encouraged),   such that the function at index   i   (you may choose to start   i   from either   0   or   1),   when run, should return the square of the index,   that is,   i 2. Display the result of runnin...
#C.23
C#
using System; using System.Linq;   class Program { static void Main() { var captor = (Func<int, Func<int>>)(number => () => number * number); var functions = Enumerable.Range(0, 10).Select(captor); foreach (var function in functions.Take(9)) { Console.WriteLine(functi...
http://rosettacode.org/wiki/Circular_primes
Circular primes
Definitions A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will also be prime. For example: 1193 is a circular prime, since 1931, 9311 and 3119 are all also prime. Note that a number which is a cyclic permutation ...
#AWK
AWK
  # syntax: GAWK -f CIRCULAR_PRIMES.AWK BEGIN { p = 2 printf("first 19 circular primes:") for (count=0; count<19; p++) { if (is_circular_prime(p)) { printf(" %d",p) count++ } } printf("\n") exit(0) } function cycle(n, m,p) { # E.G. if n = 1234 returns 2341 m = n ...
http://rosettacode.org/wiki/Collections
Collections
This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task. Collections are abstractions to represent sets of values. In statically-typed languages, the values are typically of a common data type. Task Create a collection, and add a fe...
#68000_Assembly
68000 Assembly
dc.l TrapString_Bus dc.l TrapString_Addr dc.l TrapString_Illegal dc.l TrapString_Div0 dc.l TrapString_chk dc.l TrapString_v dc.l TrapString_priv dc.l TrapString_trace   TrapString_Bus: dc.b "Bus error",255 even TrapString_Addr: dc.b "Address error",255 even TrapString_Illegal: dc.b "Illegal Instruction",25...
http://rosettacode.org/wiki/Combinations
Combinations
Task Given non-negative integers   m   and   n,   generate all size   m   combinations   of the integers from   0   (zero)   to   n-1   in sorted order   (each combination is sorted and the entire table is sorted). Example 3   comb   5     is: 0 1 2 0 1 3 0 1 4 0 2 3 0 2 4 0 3 4 1 2 3 1 2 4 1 3 4 2 3 4 ...
#Elixir
Elixir
defmodule RC do def comb(0, _), do: [[]] def comb(_, []), do: [] def comb(m, [h|t]) do (for l <- comb(m-1, t), do: [h|l]) ++ comb(m, t) end end   {m, n} = {3, 5} list = for i <- 1..n, do: i Enum.each(RC.comb(m, list), fn x -> IO.inspect x end)
http://rosettacode.org/wiki/Conditional_structures
Conditional structures
Control Structures These are examples of control structures. You may also be interested in: Conditional structures Exceptions Flow-control structures Loops Task List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions. Common conditional structures include ...
#Object_Pascal
Object Pascal
let condition = true   if condition then 1 (* evaluate something *) else 2 (* evaluate something *)
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#sed
sed
# a single line comment
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Seed7
Seed7
# A single line comment   (* A multi-line comment *)   (* In Seed7, (* comments can be nested. *) *)
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#SenseTalk
SenseTalk
  # Hashtag is a comment -- Dash dash is another comment // Slash slash is yet another comment — Alt/Option + Underscore creates an m-dash comment (* Parentheses and star is used for commenting blocks of code (* and can be nested *) *) set foo to true // all comments can append to statements  
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Julia
Julia
using Images   colors = [colorant"black", colorant"red", colorant"green", colorant"darkblue", colorant"purple", colorant"blue", colorant"yellow", colorant"white"] wcol = 60 # width of each color bar h, w = 150, wcol * length(colors) + 1 img = Matrix{RGB{N0f8}}(h, w); for (j, col) in zip(1:wcol:w, colors) ...
http://rosettacode.org/wiki/Colour_bars/Display
Colour bars/Display
Task Display a series of vertical color bars across the width of the display. The color bars should either use:   the system palette,   or   the sequence of colors:   black   red   green   blue   magenta   cyan   yellow   white
#Kotlin
Kotlin
import java.awt.Color import java.awt.Graphics import javax.swing.JFrame   class ColorFrame(width: Int, height: Int): JFrame() { init { defaultCloseOperation = EXIT_ON_CLOSE setSize(width, height) isVisible = true }   override fun paint(g: Graphics) { val colors = listOf(Colo...