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/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #SQL | SQL |
-- save these lines in a file called
-- setupworld.sql
-- turn off feedback for cleaner display
SET feedback off
-- 3 x 3 world
-- alive has coordinates of living cells
DROP TABLE alive;
CREATE TABLE alive (x NUMBER,y NUMBER);
-- three alive up the middle
-- *
-- *
-- *
INSERT INTO alive VALUES (... |
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 ... | #ARM_Assembly | ARM Assembly | .org 0x08000000 ;cartridge ROM begins here
b ProgramStart ;branch around the cartridge header
;;;; cartridge header goes here
.equ SCREEN_WIDTH,240 ;some labels for convenience
.equ SCREEN_HEIGHT,160
ProgramStart:
mov sp,... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #C.23 | C# | using System;
using System.Drawing;
using System.Windows.Forms;
class Program
{
static Color GetPixel(Point position)
{
using (var bitmap = new Bitmap(1, 1))
{
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(position, new Poin... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #C.2B.2B.2FCLI | C++/CLI | using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
[STAThreadAttribute]
int main()
{
Point^ MousePoint = gcnew Point();
Control^ TempControl = gcnew Control();
MousePoint = TempControl->MousePosition;
Bitmap^ TempBitmap = gcnew Bitmap(1,1);
Graphics^ g = Graphics::Fr... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #FreeBASIC | FreeBASIC | #include "fbgfx.bi"
Sub HSVtoRGB(h As Single, s As Integer, v As Integer, Byref r As Integer, Byref g As Integer, Byref b As Integer)
If s = 0 Then
r = v
g = v
b = v
Return
End If
h = h Mod 360
Dim As Single hue = h
Select Case h
Case 0f To 51.5f
hue... |
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 ... | #LSE | LSE | SI A ET B ALORS
AFFICHER [4X, 'A ET B = .VRAI.',/]
SINON
AFFICHER [4X, 'A ET B = .FAUX.',/]
FIN SI
SI A ET QUE B ALORS
AFFICHER [4X, 'A ET QUE B = .VRAI.',/]
SINON
AFFICHER [4X, 'A ET QUE B = .FAUX.',/]
FIN SI |
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.)
| #Neko | Neko | // Single line comment, of course!
/*
Multi line comment!
*/
/**
Documentation block
<doc>can include XML parsed nodes between doc tags</doc>
**/ |
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.)
| #Nemerle | Nemerle | // This comment goes up to the end of the line
/* This
is
a
multiline
comment */ |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Swift | Swift | struct Cell: Hashable {
var x: Int
var y: Int
}
struct Colony {
private var height: Int
private var width: Int
private var cells: Set<Cell>
init(cells: Set<Cell>, height: Int, width: Int) {
self.cells = cells
self.height = height
self.width = width
}
private func neighborCounts() -> [C... |
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 ... | #AutoHotkey | AutoHotkey | h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
hdc := CreateCompatibleDC()
hbm := CreateDIBSection(w, h)
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
OnExit, Exit
Gui -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui Show, NA
hwnd := WinExist()
colors := [0xFF00000... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Clojure | Clojure | (defn get-color-at [x y]
(.getPixelColor (java.awt.Robot.) x y)) |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Common_Lisp | Common Lisp | (in-package :cg-user)
(defun print-hex (n)
(let ((*print-base* 16.) (*print-radix* t))
(print n)) t)
(defun get-byte (n byte)
(logand (ash n (* byte -8)) #xFF))
(defun get-pixel (x y)
(let ((pixval (caar (contents (get-screen-pixmap :box (make-box x y (+ x 1) (+ y 1)))))))
(mapcar #'(lambda (i) (get... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #GML | GML |
for (var i = 1; i <= 360; i++) {
for (var j = 0; j < 255; j++) {
var hue = 255*(i/360);
var saturation = j;
var value = 255;
var c = make_colour_hsv(hue,saturation,value);
//size of circle determined by how far from the center it is
//if you just draw them too... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Go | Go | package main
import (
"github.com/fogleman/gg"
"math"
)
const tau = 2 * math.Pi
func hsb2rgb(hue, sat, bri float64) (r, g, b int) {
u := int(bri*255 + 0.5)
if sat == 0 {
r, g, b = u, u, u
} else {
h := (hue - math.Floor(hue)) * 6
f := h - math.Floor(h)
p := int(... |
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 ... | #LSE64 | LSE64 | t : " true" ,t
f : " false" ,t
true if t
false ifnot f
true ifelse t f |
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.)
| #NESL | NESL | % 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.)
| #NetRexx | NetRexx | /*
NetRexx comment block
*/
-- NetRexx line comment
|
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #SystemVerilog | SystemVerilog | module gol;
parameter NUM_ROWS = 20;
parameter NUM_COLS = 32;
bit [NUM_COLS:1] cell[1:NUM_ROWS];
bit clk;
initial begin
cell[10][10:8] = 3'b111;
cell[11][10:8] = 3'b100;
cell[12][10:8] = 3'b010;
repeat(8) #5 clk = ~clk;
end
always @(posedge clk) begin
foreach (cell[y,x]) begin
... |
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 ... | #BASIC256 | BASIC256 | w = 640 : h = 480
graphsize w, h
dim k = {black, red, green, blue, purple, cyan, yellow, white}
h /= 4
for i = 1 to 4
col = 0
y = (i-1) * h
for x = 1 to w step i
if col mod 8 = 0 then col = 0
colour k[col]
rect (x, y, x + i, y + h)
col += 1
next x
next i |
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 ... | #BBC_BASIC | BBC BASIC | SW_MAXIMIZE = 3
SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
VDU 26
W% = @vdu%!208 * 2
H% = @vdu%!212 / 2
COLOUR 1,9
COLOUR 2,10
COLOUR 3,12
COLOUR 4,13
COLOUR 5,14
COLOUR 6,11
COLOUR 7,15
Y% = H%*4
FOR P% = 1 TO 4
Y% -= H%
... |
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 ... | #Befunge | Befunge | "%":*3-"`"8*>4/::8%00p8/10p4*\55+"3P",,,:.\.5v
5+:,1vv\%2:%8/-g025:\-1_$$55+,\:v1+*8g01g00_@>
024,.<>2/:2%\2/...1+\:>^<:\0:\-1_$20g1-:20p^1p |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Delphi | Delphi |
program ScreenPixel;
{$APPTYPE CONSOLE}
uses
Windows,
SysUtils,
Graphics;
// Use this function in a GUI application to return the color
function GetPixelColourAsColor(const PixelCoords: TPoint): TColor;
var
dc: HDC;
begin
// Get Device Context of windows desktop
dc := GetDC(0);
// Read the color... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #J | J | rgbc=: {{1-x*0>.1<.(<.4&-)6|m+y%60}}
hsv=: 5 rgbc(,"0 1) 3 rgbc(,"0) 1 rgbc
degrees=: {{180p_1*{:"1+.^.y}}
wheel=: {{((1>:|)*|hsv degrees)j./~y%~i:y}}
require'viewmat'
'rgb' viewmat 256#.<.255*wheel 400 |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Java | Java | import java.awt.*;
import javax.swing.*;
public class ColorWheel {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ColorWheelFrame frame = new ColorWheelFrame();
frame.setVisible(true);
}
... |
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
... | #11l | 11l | F comb(arr, k)
I k == 0
R [[Int]()]
[[Int]] result
L(x) arr
V i = L.index
L(suffix) comb(arr[i+1..], k-1)
result [+]= x [+] suffix
R result
print(comb([0, 1, 2, 3, 4], 3)) |
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 ... | #Lua | Lua |
--if-then-elseif-then-else
if a then
b()
elseif c then
d()
else
e()
end
for var = start, _end, step do --note: end is a reserved word
something()
end
for var, var2, etc in iteratorfunction do
something()
end
while somethingistrue() do
something()
end
repeat
something()
until somethingistrue()
... |
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.)
| #NewLISP | NewLISP | ; 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.)
| #Nim | Nim | # Nim supports single-line comments
var x = 0 ## Documentation comments start with double hash characters.
var y = 0 ## Documentation comments are a proper part of the syntax (they're not discarded by parser, and a real part of AST).
#[
There are also multi-line comments
Everything inside of #[]# is commented.
]#... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Tcl | Tcl | package require Tcl 8.5
proc main {} {
evolve 3 blinker [initialize_tableau {3 3} {{0 1} {1 1} {2 1}}]
evolve 5 glider [initialize_tableau {4 4} {{0 1} {1 2} {2 0} {2 1} {2 2}}]
}
proc evolve {generations name tableau} {
for {set gen 1} {$gen <= $generations} {incr gen} {
puts "$name generatio... |
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 ... | #C | C |
#include<graphics.h>
#include<conio.h>
#define sections 4
int main()
{
int d=DETECT,m,maxX,maxY,x,y,colour=0,increment=1;
initgraph(&d,&m,"c:/turboc3/bgi");
maxX = getmaxx();
maxY = getmaxy();
for(y=0;y<maxY;y+=maxY/sections)
{
for(x=0;x<maxX;x+=increment)
{
setfillstyle(SOLID_FILL,(colour++)%16)... |
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 ... | #C.2B.2B | C++ |
#include <windows.h>
//--------------------------------------------------------------------------------------------------
class pinstripe
{
public:
pinstripe() { createColors(); }
void setDimensions( int x, int y ) { _mw = x; _mh = y; }
void createColors()
{
colors[0] = 0; co... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #F.23 | F# | open System.Drawing
open System.Windows.Forms
let GetPixel x y =
use img = new Bitmap(1,1)
use g = Graphics.FromImage(img)
g.CopyFromScreen(new Point(x,y), new Point(0,0), new Size(1,1))
let clr = img.GetPixel(0,0)
(clr.R, clr.G, clr.B)
let GetPixelAtMouse () =
let pt = Cursor.Position
G... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Go | Go | package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
// get position of mouse cursor
x, y := robotgo.GetMousePos()
// get color of pixel at that position
color := robotgo.GetPixelColor(x, y)
fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)
} |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Julia | Julia | using Gtk, Graphics, Colors
const win = GtkWindow("Color Wheel", 450, 450) |> (const can = @GtkCanvas())
set_gtk_property!(can, :expand, true)
@guarded draw(can) do widget
ctx = getgc(can)
h = height(can)
w = width(can)
center = (x = w / 2, y = h / 2)
anglestep = 1/w
for θ in 0:0.1:360
... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Kotlin | Kotlin | // Version 1.2.41
import java.awt.Color
import java.awt.Graphics
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
import kotlin.math.*
class BasicBitmapStorage(width: Int, height: Int) {
val image = BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR)
fun fill(c: ... |
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
... | #360_Assembly | 360 Assembly | * Combinations 26/05/2016
COMBINE CSECT
USING COMBINE,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
STM R14,R12,12(R13) prolog
ST R13,4(R15) "
ST R15,8(R13) "
... |
http://rosettacode.org/wiki/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 ... | #Luna | Luna | if char == "<" then Prepend "<" acc else acc |
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.)
| #Nix | Nix | # This comment goes up to the end of the line
/* This
is
a
multiline
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.)
| #NSIS | NSIS |
# This is a comment that goes from the # to the end of the line.
; This is a comment that goes from the ; to the end of the
/* This is a
multi-line
comment */
|
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... | #C | C | typedef struct oct_node_t oct_node_t, *oct_node;
struct oct_node_t{
/* sum of all colors represented by this node. 64 bit in case of HUGE image */
uint64_t r, g, b;
int count, heap_idx;
oct_node kids[8], parent;
unsigned char n_kids, kid_idx, flags, depth;
};
/* cmp function that decides the ordering in the heap... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Ursala | Ursala | #import std
#import nat
rule = -: ^(~&,~&l?(~&r-={2,3},~&r-={3})^|/~& length@F)* pad0 iota512
neighborhoods = ~&thth3hthhttPCPthPTPTX**K7S+ swin3**+ swin3@hNSPiCihNCT+ --<0>*+ 0-*
evolve "n" = next"n" rule**+ neighborhoods |
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 ... | #Common_Lisp | Common Lisp | (in-package :cg-user)
;;; We only need a bitmap pane - nothing fancy
(defclass draw-pane (bitmap-pane)())
;;; close it down by clicking on it
(defmethod mouse-left-down ((pane draw-pane) buttons data)
(declare (ignore buttons data))
(close pane))
;;; Create the window and draw the pinstripes
(defun make-draw-... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Groovy | Groovy | import java.awt.Robot
class GetPixelColor {
static void main(args) {
println getColorAt(args[0] as Integer, args[1] as Integer)
}
static getColorAt(x, y) {
new Robot().getPixelColor(x, y)
}
}
|
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Icon_and_Unicon | Icon and Unicon | link graphics,printf
procedure main()
WOpen("canvas=hidden") # hide for query
height := WAttrib("displayheight") - 45 # adjust for ...
width := WAttrib("displaywidth") - 20 # ... window 7 borders
WClose(&window)
W := WOpen("size="||width||","||height,"bg=black") |
s... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Lua | Lua |
local function hsv_to_rgb (h, s, v) -- values in ranges: [0, 360], [0, 1], [0, 1]
local r = math.min (math.max (3*math.abs (((h )/180)%2-1)-1, 0), 1)
local g = math.min (math.max (3*math.abs (((h -120)/180)%2-1)-1, 0), 1)
local b = math.min (math.max (3*math.abs (((h +120)/180)%2-1)-1, 0), 1)
local k1 = v*(1... |
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
... | #Action.21 | Action! | PROC PrintComb(BYTE ARRAY c BYTE len)
BYTE i
Put('()
FOR i=0 TO len-1
DO
IF i>0 THEN Put(',) FI
PrintB(c(i))
OD
Put(')) PutE()
RETURN
BYTE FUNC Increasing(BYTE ARRAY c BYTE len)
BYTE i
IF len<2 THEN RETURN (1) FI
FOR i=0 TO len-2
DO
IF c(i)>=c(i+1) THEN
RETURN (0)
FI
... |
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 ... | #M2000_Interpreter | M2000 Interpreter |
Module CheckIt {
Read a
If a>1 then {
Print "Top"
} else.if a>=-4 then {
Print "Middle"
} else {
Print "Bottom"
}
}
CheckIt 100
CheckIt 0
CheckIt -100
Module CheckIt {
Read a
\\ using end if without blocks
If a>1 then
Pr... |
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.)
| #Oberon-2 | Oberon-2 |
(* this is a comment *)
(*
and this is a
multiline comment
(* with a nested 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.)
| #Objeck | Objeck |
#This is a comment.
# This is other comment.
#~ This is a comment too. ~#
#~ This is a
multi-line
comment ~#
|
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... | #Common_Lisp | Common Lisp | (defpackage #:quantize
(:use #:cl
#:opticl))
(in-package #:quantize)
(defun image->pixels (image)
(check-type image 8-bit-rgb-image)
(let (pixels)
(do-pixels (y x) image
(push (pixel* image y x) pixels))
pixels))
(defun greatest-color-range (pixels)
(loop for (r g b) in pixels
... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Vedit_macro_language | Vedit macro language | IT("Generation 0 ") IN
IT(".O.") IN
IT(".O.") IN
IT(".O.")
#9 = 2 // number of generations to calculate
#10 = Cur_Line
#11 = Cur_Col-1
for (#2 = 1; #2 <= #9; #2++) {
Update()
Get_Key("Next gen...", STATLINE)
Call("calculate")
itoa(#2, 20, LEFT)
GL(1) GC(12) Reg_Ins(20, OVERWRITE)
}
EOF
Retu... |
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 ... | #Factor | Factor | USING: accessors arrays colors.constants kernel locals math
math.ranges opengl sequences ui ui.gadgets ui.render ;
CONSTANT: palette
{
COLOR: black
COLOR: red
COLOR: green
COLOR: blue
COLOR: magenta
COLOR: cyan
COLOR: yellow
COLOR: white
}
CONSTANT: bands 4
TUPLE: pinstripe < gadge... |
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 ... | #FreeBASIC | FreeBASIC | ' version 14-03-2017
' compile with: fbc -s console
' or compile with: fbc -s gui
Dim As UInteger ps, col, h, w, x, y1, y2
ScreenInfo w, h
' create display size window, 8bit color (palette), no frame
ScreenRes w, h, 8,, 8
h = h \ 4 : y2 = h -1
For ps = 1 To 4
col = 0
For x = 0 To (w - ps -1) Step ps
... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #J | J | GetDC=: 'user32.dll GetDC >i i'&cd NB. hdx: GetDC hwnd
GetPixel=: 'gdi32.dll GetPixel >l i i i'&cd NB. rgb: GetPixel hdc x y
GetCursorPos=: 'user32.dll GetCursorPos i *i'&cd NB. success: point |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Java | Java | public static Color getColorAt(int x, int y){
return new Robot().getPixelColor(x, y);
} |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Julia | Julia |
# Windows GDI version
function getpixelcolors(x, y)
hdc = ccall((:GetDC, "user32.dll"), UInt32, (UInt32,), 0)
pxl = ccall((:GetPixel, "gdi32.dll"), UInt32, (UInt32, Cint, Cint), hdc, Cint(x), Cint(y))
return pxl & 0xff, (pxl >> 8) & 0xff, (pxl >> 16) & 0xff
end
const x = 120
const y = 100
cols = getpixe... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #M2000_Interpreter | M2000 Interpreter |
Module Check {
\\ we use an internal object for Math functions (here for Atan2)
Declare Math Math
Const tau=2*Pi, Center=2
\\ change console size, and center it ( using ;) to current monitor
Window 12, 800*twipsX,600*twipsY;
\\ actual size maybe less (so can fit text exactly... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | r = 100;
Image[Table[
If[x^2 + y^2 <= r^2,
angle = Mod[ArcTan[N@x, y]/(2 Pi), 1];
List @@ RGBColor[Hue[angle, Sqrt[x^2 + y^2]/N[r], 1.0]]
,
{1, 1, 1}
], {x, -r, r}, {y, -r, r}]
] |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Nim | Nim | import math
import imageman
#---------------------------------------------------------------------------------------------------
func hsvToRgb(h, s, v: float): ColorRGBU =
## Convert HSV values to RGB values.
let hp = h / 60
let c = s * v
let x = c * (1 - abs(hp mod 2 - 1))
let m = v - c
var r, g, b... |
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
... | #Ada | Ada | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Combinations is
generic
type Integers is range <>;
package Combinations is
type Combination is array (Positive range <>) of Integers;
procedure First (X : in out Combination);
procedure Next (X : in out Combination);
procedure Put... |
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 ... | #Make | Make | # make -f do.mk C=mycond if
C=0
if:
-@expr $(C) >/dev/null && make -f do.mk true; exit 0
-@expr $(C) >/dev/null || make -f do.mk false; exit 0
true:
@echo "was true."
false:
@echo "was false." |
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.)
| #Objective-C | Objective-C | (* This a comment
(* containing nested comment *)
*)
(** This an OCamldoc documentation 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.)
| #OCaml | OCaml | (* This a comment
(* containing nested comment *)
*)
(** This an OCamldoc documentation comment *) |
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... | #D | D | import core.stdc.stdio, std.stdio, std.algorithm, std.typecons,
std.math, std.range, std.conv, std.string, bitmap;
struct Col { float r, g, b; }
alias Cluster = Tuple!(Col, float, Col, Col[]);
enum Axis { R, G, B }
enum round = (in float x) pure nothrow @safe @nogc => cast(int)floor(x + 0.5);
enum roundRGB... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Wortel | Wortel | @let {
life &m ~!* m &[a y] ~!* a &[v x] @let {
neigh @sum [
@`-x 1 @`-y 1 m @`x @`-y 1 m @`+x 1 @`-y 1 m
@`-x 1 @`y m @`+x 1 @`y m
@`-x 1 @`+y 1 m @`x @`+y 1 m @`+x 1 @`+y 1 m
]
@+ || = neigh 3 && v = neigh 2
}
blinker [
[0 0 0 0 0]
[0 0 0 0 0]
... |
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 ... | #Gambas | Gambas | 'WARNING this takes a time to display
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, siCounter, siSet As Short
With Me
.Arrangement = Arrange.Row
.Border = False
.Height = 1080
.Wi... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Kotlin | Kotlin | import java.awt.*
fun getMouseColor(): Color {
val location = MouseInfo.getPointerInfo().location
return getColorAt(location.x, location.y)
}
fun getColorAt(x: Int, y: Int): Color {
return Robot().getPixelColor(x, y)
} |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Lingo | Lingo | on getScreenPixelColor (x, y)
sx = xtra("ScrnXtra3").new()
img = sx.ScreenToImage(rect(x, y, x+1, y+1))
return img.getPixel(0, 0)
end |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Perl | Perl | use Imager;
use Math::Complex qw(cplx i pi);
my ($width, $height) = (300, 300);
my $center = cplx($width/2, $height/2);
my $img = Imager->new(xsize => $width,
ysize => $height);
foreach my $y (0 .. $height - 1) {
foreach my $x (0 .. $width - 1) {
my $vec = $center - $x - $y * 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
... | #ALGOL_68 | ALGOL 68 | # -*- coding: utf-8 -*- #
COMMENT REQUIRED BY "prelude_combinations_generative.a68"
MODE COMBDATA = ~;
PROVIDES:
# COMBDATA*=~* #
# comb*=~ list* #
END COMMENT
MODE COMBDATALIST = REF[]COMBDATA;
MODE COMBDATALISTYIELD = PROC(COMBDATALIST)VOID;
PROC comb gen combinations = (INT m, COMBDATALIST list, COMBDATALIST... |
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 ... | #Maple | Maple | if x > 0 then
res := x;
else
res := -x;
end if; |
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.)
| #Octave | Octave | # I am a comment till the end of line
% I am a comment till the end of line
%{
This comment spans
multiple lines
%}
|
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.)
| #Oforth | Oforth | // This is a comment... |
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... | #Go | Go | package main
import (
"container/heap"
"image"
"image/color"
"image/png"
"log"
"math"
"os"
"sort"
)
func main() {
f, err := os.Open("Quantum_frog.png")
if err != nil {
log.Fatal(err)
}
img, err := png.Decode(f)
if ec := f.Close(); err != nil {
log.... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #VBScript | VBScript |
option explicit
const tlcr=3, tlcc=3
const maxdim=15
dim a(15,15)
dim b(15,15)
dim ans0:ans0=chr(27)&"["
dim gen,n
erase a
'glider
a(0,1)=true:a(1,2)=true:a(2,0)=true:a(2,1)=true:a(2,2)=true
'blinker
a(3,13)=true:a(4,13)=true:a(5,13)=true
'beacon
a(11,1)=true:a(11,2)=true: a(12,1)=true:a(12,2)=true
a(13,3)=true:a... |
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 ... | #Go | Go | package main
import "github.com/fogleman/gg"
var palette = [8]string{
"000000", // black
"FF0000", // red
"00FF00", // green
"0000FF", // blue
"FF00FF", // magenta
"00FFFF", // cyan
"FFFF00", // yellow
"FFFFFF", // white
}
func pinstripe(dc *gg.Context) {
w := dc.Width()
h ... |
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 ... | #Icon_and_Unicon | Icon and Unicon | link graphics,numbers,printf
procedure main() # pinstripe
&window := open("Colour Pinstripe","g","bg=black") |
stop("Unable to open window")
WAttrib("canvas=hidden")
WAttrib(sprintf("size=%d,%d",WAttrib("displaywidth"),WAttrib("displayheight")))
WAttrib("canvas=maximal")
Colours := ["bl... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Logo | Logo | CLEARSCREEN
SHOW PIXEL
[255 255 255]
|
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #M2000_Interpreter | M2000 Interpreter |
Module CheckColor {
\\ Print hex code for color, and html code for color
Every 25 {
move mouse.x, mouse.y
color$=Hex$(-point, 3) ' point has a negative value
Print Over "0x"+color$+", #"+Right$(color$,2)+Mid$(color$, 3,2)+Left$(color$,2)
if mouse<>0 then e... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | getPixel[{x_?NumberQ, y_?NumberQ}, screenNumber_Integer: 1] := ImageValue[CurrentScreenImage[n], {x, y}] |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Phix | Phix | --
-- demo\rosetta\Colour_wheel.exw
-- =============================
--
-- Note: Made non-resizeable since maximising this is far too slow.
--
with javascript_semantics
include pGUI.e
constant title = "Colour wheel"
Ihandle dlg, canvas
cdCanvas cddbuffer, cdcanvas
function redraw_cb(Ihandle /*ih*/, integer /*posx*/,... |
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
... | #AppleScript | AppleScript | on comb(n, k)
set c to {}
repeat with i from 1 to k
set end of c to i's contents
end repeat
set r to {c's contents}
repeat while my next_comb(c, k, n)
set end of r to c's contents
end repeat
return r
end comb
on next_comb(c, k, n)
set i to k
set c's item i to (c's i... |
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 ... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | if x == 1
disp 'x==1';
elseif x > 1
disp 'x>1';
else
disp 'x<1';
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.)
| #ooRexx | ooRexx | /*
Multi-line comment block
*/
-- this type of comment works in ooRexx, NetRexx and some of the more popular REXX implementations like Regina
hour = 0 -- which is, like midnight, dude.
hour = 12 /* time for lunch! works as well (and really everywhere) */
|
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.)
| #Openscad | Openscad |
// This is a single line comment
/*
This comment spans
multiple lines
*/
|
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... | #Haskell | Haskell | import qualified Data.ByteString.Lazy as BS
import qualified Data.Foldable as Fold
import qualified Data.List as List
import Data.Ord
import qualified Data.Sequence as Seq
import Data.Word
import System.Environment
import Codec.Picture
import Codec.Picture.Types
type Accessor = PixelRGB8 -> Pixel8
-- Getters for ... |
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Vlang | Vlang | import rand
import strings
import time
struct Field {
mut:
s [][]bool
w int
h int
}
fn new_field(w int, h int) Field {
s := [][]bool{len: h, init: []bool{len: w}}
return Field{s, w, h}
}
fn (mut f Field) set(x int, y int, b bool) {
f.s[y][x] = b
}
fn (f Field) next(x int, y int) bool {
mut on := 0
fo... |
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 ... | #J | J | load 'viewmat'
size=. 2{.".wd'qm' NB. J6
size=. getscreenwh_jgtk_ '' NB. J7
'rgb'viewmat (4<.@%~{:size)# ({.size) $&> 1 2 3 4#&.> <256#.255*#:i.8 |
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 ... | #Java | Java | import java.awt.*;
import static java.awt.Color.*;
import javax.swing.*;
public class ColourPinstripeDisplay extends JPanel {
final static Color[] palette = {black, red, green, blue, magenta,cyan,
yellow, white};
final int bands = 4;
public ColourPinstripeDisplay() {
setPreferredSize(n... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Nim | Nim | import gtk2, gdk2, gdk2pixbuf
type Color = tuple[r, g, b: byte]
gtk2.nim_init()
proc getPixelColor(x, y: int32): Color =
var p = pixbufNew(COLORSPACE_RGB, false, 8, 1, 1)
discard p.getFromDrawable(getDefaultRootWindow().Drawable,
getDefaultScreen().getSystemColormap(), x, y, 0, 0, 1, 1)
result = cast[pt... |
http://rosettacode.org/wiki/Color_of_a_screen_pixel | Color of a screen pixel | Task
Get color information from an arbitrary pixel on the screen, such as the current location of the mouse cursor.
The mouse cursor may or may not have to be active in a GUI created by your program. These functions are OS related.
| #Perl | Perl | use strict;
use warnings;
use GD;
my $file = '/tmp/one-pixel-screen-capture.png';
system "screencapture -R 123,456,1,1 $file";
my $image = GD::Image->newFromPng($file);
my $index = $image->getPixel(0,0);
my($red,$green,$blue) = $image->rgb($index);
print "RGB: $red, $green, $blue\n";
unlink $file; |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Processing | Processing | size(300, 300);
background(0);
float radius = min(width, height) / 2.0;
float cx = width / 2;
float cy = width / 2;
for (int x = 0; x < width; x++) {
for (int y = 0; y < width; y++) {
float rx = x - cx;
float ry = y - cy;
float s = sqrt(sq(rx) + sq(ry)) / radius;
if (s <= 1.0) {
float h = ((atan... |
http://rosettacode.org/wiki/Color_wheel | Color wheel | Task
Write a function to draw a HSV color wheel completely with code.
This is strictly for learning purposes only. It's highly recommended that you use an image in an actual application to actually draw the color wheel (as procedurally drawing is super slow). This does help you understand how color wheels work and ... | #Python | Python | from PIL import Image
import colorsys
import math
if __name__ == "__main__":
im = Image.new("RGB", (300,300))
radius = min(im.size)/2.0
cx, cy = im.size[0]/2, im.size[1]/2
pix = im.load()
for x in range(im.width):
for y in range(im.height):
rx = x - cx
ry = y - ... |
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
... | #AutoHotkey | AutoHotkey | MsgBox % Comb(1,1)
MsgBox % Comb(3,3)
MsgBox % Comb(3,2)
MsgBox % Comb(2,3)
MsgBox % Comb(5,3)
Comb(n,t) { ; Generate all n choose t combinations of 1..n, lexicographically
IfLess n,%t%, Return
Loop %t%
c%A_Index% := A_Index
i := t+1, c%i% := n+1
Loop {
Loop %t%
i := t+1-A_Index, c ... |
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 ... | #MATLAB | MATLAB | if x == 1
disp 'x==1';
elseif x > 1
disp 'x>1';
else
disp 'x<1';
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.)
| #OxygenBasic | OxygenBasic |
' Basic line comment
; Assembly code line comment
// C line comment
/* C block 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.)
| #Oz | Oz | % one line comment
%% often with double "%" because then the indentation is correct in Emacs
/* multi line
comment
*/
|
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... | #J | J | kmcL=:4 :0
C=. /:~ 256 #.inv ,y NB. colors
G=. x (i.@] <.@* %) #C NB. groups (initial)
Q=. _ NB. quantized list of colors (initial
whilst.-. Q-:&<.&(x&*)Q0 do.
Q0=. Q
Q=. /:~C (+/ % #)/.~ G
G=. (i. <./)"1 C +/&.:*: .- |:Q
end.Q
) |
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... | #Julia | Julia |
const execstring =`convert Quantum_frog.png -dither None -colors 16 Quantum_frog_new.png`
run(execstring)
|
http://rosettacode.org/wiki/Conway%27s_Game_of_Life | Conway's Game of Life | The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.
Conway's game of life is described here:
A cell C is represented by a 1 when alive, or 0 when dead, in an m-by-m (or m×m) sq... | #Wren | Wren | import "random" for Random
import "timer" for Timer
var Rand = Random.new(0) // using a constant seed to produce same output on each run
// patterns
var BLINKER = 0
var GLIDER = 1
var RANDOM = 2
class Field {
construct new(w, h) {
_w = w
_h = h
_s = List.filled(h, null)
for (... |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic data retrieval without meaningful analysis or patterns.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic filtering that shows what data looks like but doesn't provide meaningful analysis or patterns.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.