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/Comma_quibbling | Comma quibbling | Comma quibbling is a task originally set by Eric Lippert in his blog.
Task
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
An input of no words produces the output string of just the two brace characters "{}".
An input of just one word, e.g. ["AB... | #XLISP | XLISP | (defun quibble (inputs &optional oxford-comma)
(define final
(if (and (caddr inputs) oxford-comma)
", and "
" and " ) )
(defun comma-quibble (words)
(cond
((null words) "")
((null (cdr words)) (car words))
(t (begin
(str... |
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.)
| #Logtalk | Logtalk | % single-line comment; extends to the end of the line |
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.)
| #LOLCODE | LOLCODE | OBTW This is a
multi line comment
TLDR |
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... | #Ruby | Ruby | def game_of_life(name, size, generations, initial_life=nil)
board = new_board size
seed board, size, initial_life
print_board board, name, 0
reason = generations.times do |gen|
new = evolve board, size
print_board new, name, gen+1
break :all_dead if barren? new, size
break :static if board == ... |
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 ... | #Julia | Julia |
function test(x, y)
if x < y
println("x is less than y")
elseif x > y
println("x is greater than y")
else
println("x is equal to y")
end
end
julia> test(1, 2)
x is less than y
julia> test(2, 1)
x is greater than y
julia> test(1, 1)
x is equal to y
|
http://rosettacode.org/wiki/Comma_quibbling | Comma quibbling | Comma quibbling is a task originally set by Eric Lippert in his blog.
Task
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
An input of no words produces the output string of just the two brace characters "{}".
An input of just one word, e.g. ["AB... | #XPL0 | XPL0 | include c:\cxpl\codes;
proc Quibble(N, S);
int N, S;
int I;
[ChOut(0, ^{);
for I:= 0 to N-1 do
[Text(0, S(I));
if I<N-2 then Text(0, ", ");
if I=N-2 then Text(0, " and ");
];
ChOut(0, ^});
];
int I;
for I:= 0 to 4 do
if I#3 then [Quibble(I, ["ABC", "DEF", "G", "H"]); CrLf(0)]
|
http://rosettacode.org/wiki/Comma_quibbling | Comma quibbling | Comma quibbling is a task originally set by Eric Lippert in his blog.
Task
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
An input of no words produces the output string of just the two brace characters "{}".
An input of just one word, e.g. ["AB... | #zkl | zkl | fcn quib(list){ text:=("{"+list.toString(*)[2,-1]+"}").replace("\"","");
if(list.len()<2) text;
else{
z:=(text=text.replace(",",", ")).rfind(",");
String(text[0,z]," and ",text[z+2,*])
}
} |
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.)
| #LotusScript | LotusScript | ' 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.)
| #LSE | LSE | * Ceci est un commentaire qui prend fin quand la ligne se termine
(* Ceci est un commentaire sur plusieurs lignes
comme vous pouvez le voir puisqu'il s'étend sur
plusieurs lignes justement... *)
(* Cette exemple est selon la revision LSE-2000 *) |
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... | #Rust | Rust |
use std::collections::HashMap;
use std::collections::HashSet;
type Cell = (i32, i32);
type Colony = HashSet<Cell>;
fn print_colony(col: &Colony, width: i32, height: i32) {
for y in 0..height {
for x in 0..width {
print!("{} ",
if col.contains(&(x, y)) {"O"}
... |
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 ... | #Kabap | Kabap |
if 1;
$result = "Execute";
if 0;
$result = "Ignored";
if 1; {
$result = "Block";
$result = "Execute";
}
if 0; {
$result = "Block";
$result = "Ignored";
}
if 1 == 1;
$result = "Execute";
if 1 < 2;
$result = "Execute";
if 1 <= 1;
$result = "Execute";
if 2 > 1;
$result = "Execute";
if... |
http://rosettacode.org/wiki/Comma_quibbling | Comma quibbling | Comma quibbling is a task originally set by Eric Lippert in his blog.
Task
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
An input of no words produces the output string of just the two brace characters "{}".
An input of just one word, e.g. ["AB... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 DATA 0
20 DATA 1,"ABC"
30 DATA 2,"ABC","DEF"
40 DATA 4,"ABC","DEF","G","H"
50 FOR n=10 TO 40 STEP 10
60 RESTORE n: GO SUB 1000
70 NEXT n
80 STOP
1000 REM quibble
1010 LET s$=""
1020 READ j
1030 IF j=0 THEN GO TO 1100
1040 FOR i=1 TO j
1050 READ a$
1060 LET s$=s$+a$
1070 IF (i+1)=j THEN LET s$=s$+" and ": GO TO 1090... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #C | C | #include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
bool colorful(int n) {
// A colorful number cannot be greater than 98765432.
if (n < 0 || n > 98765432)
return false;
int digit_count[10] = {};
int digits[8] = {};
int num_digits = 0;
for (int m = n; m > 0; m... |
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.)
| #LSE64 | LSE64 | # single line comment (space after # is required) |
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.)
| #Lua | Lua | -- A single line comment
--[[A multi-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... | #Scala | Scala |
;;An R6RS Scheme implementation of Conway's Game of Life --- assumes
;;all cells outside the defined grid are dead
;if n is outside bounds of list, return 0 else value at n
(define (nth n lst)
(cond ((> n (length lst)) 0)
((< n 1) 0)
((= n 1) (car lst))
(else (nth (- n 1) (cdr lst)))))
;... |
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 ... | #Keg | Keg | ?A>[The letter is larger than a|The letter is smaller than a] |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Factor | Factor | USING: assocs grouping grouping.extras io kernel literals math
math.combinatorics math.ranges prettyprint project-euler.common
sequences sequences.extras sets ;
CONSTANT: digits $[ 2 9 [a..b] ]
: (colorful?) ( seq -- ? )
all-subseqs [ product ] map all-unique? ;
: colorful? ( n -- ? )
[ t ] [ number>digit... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Go | Go | package main
import (
"fmt"
"rcu"
"strconv"
)
func isColorful(n int) bool {
if n < 0 {
return false
}
if n < 10 {
return true
}
digits := rcu.Digits(n, 10)
for _, d := range digits {
if d == 0 || d == 1 {
return false
}
}
set :=... |
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.)
| #M2000_Interpreter | M2000 Interpreter |
Module Comments {
Print "ok" ' comment at the end of line
Print "ok" \ comment at the end of line
\ comment in one line - different color with previous two
'comment in one line
Rem : Print "ok" ' statements after Rem skipped, but stay with syntax highlight
}
Comments
|
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.)
| #M4 | M4 | eval(2*3) # eval(2*3) "#" and text after it aren't processed but passed along
dnl this text completely disappears, including the new line
divert(-1)
Everything diverted to -1 is processed but the output is discarded.
A comment could take this form as long as no macro names are used.
divert |
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... | #Scheme | Scheme |
;;An R6RS Scheme implementation of Conway's Game of Life --- assumes
;;all cells outside the defined grid are dead
;if n is outside bounds of list, return 0 else value at n
(define (nth n lst)
(cond ((> n (length lst)) 0)
((< n 1) 0)
((= n 1) (car lst))
(else (nth (- n 1) (cdr lst)))))
;... |
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 ... | #Kotlin | Kotlin | // version 1.0.6
fun main(args: Array<String>) {
// conventional 'if/else if/else' statement
if (args.isEmpty()) println("No arguments were supplied")
else if (args.size == 1) println("One argument was supplied")
else println("${args.size} arguments were supplied")
print("Enter an integer : ")
... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Haskell | Haskell | import Data.List ( nub )
import Data.List.Split ( divvy )
import Data.Char ( digitToInt )
isColourful :: Integer -> Bool
isColourful n
|n >= 0 && n <= 10 = True
|n > 10 && n < 100 = ((length s) == (length $ nub s)) &&
(not $ any (\c -> elem c "01") s)
|n >= 100 = ((length s) == (length $ nub s)) && (... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #J | J | colorful=: {{(-:~.);<@(*/\)\. 10 #.inv y}}"0
I.colorful i.100
0 1 2 3 4 5 6 7 8 9 23 24 25 26 27 28 29 32 34 35 36 37 38 39 42 43 45 46 47 48 49 52 53 54 56 57 58 59 62 63 64 65 67 68 69 72 73 74 75 76 78 79 82 83 84 85 86 87 89 92 93 94 95 96 97 98
C=: I.colorful <.i.1e8
>./C
98746253
(~.,. #/.~) 10 <.@... |
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.)
| #Maple | Maple | x := 4: x; # Everything on this line, after this, is a comment.
17; (* This
is
a multiline comment *) 23.4; |
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.)
| #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | (*this is a 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... | #Scilab | Scilab | Init_state=[0 0 0;...
1 1 1;...
0 0 0];
console_output=%T;
if (atomsIsLoaded('IPCV') | atomsIsLoaded('SIVP')) & ~console_output then
Input=imread('initial_state.bmp'); //Comment this three lines in case
Init_state=~im2bw(Input,0.1); //there is no input image but
Init_state=1... |
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 ... | #LabVIEW | LabVIEW |
{if true then yes else no}
-> yes
{def switch
{lambda {:n}
{if {< :n 0}
then :n is negative
else {if {> :n 0}
then :n is positive
else :n is zero}}}}
{switch -12}
-> -12 is negative
{switch 12}
-> 12 is positive
{switch 0}
-> 0 is zero
|
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Java | Java | public class ColorfulNumbers {
private int count[] = new int[8];
private boolean used[] = new boolean[10];
private int largest = 0;
public static void main(String[] args) {
System.out.printf("Colorful numbers less than 100:\n");
for (int n = 0, count = 0; n < 100; ++n) {
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.)
| #MATLAB | MATLAB | %This is a comment
%% Two percent signs and a space are called a cell divider |
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.)
| #Maxima | Maxima | /* Comment
/* Nested comment */
*/ |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Ada | Ada | with Ada.Text_IO;
with PDF_Out;
procedure Color_Pinstripe_Printer
is
use PDF_Out;
package Point_IO
is new Ada.Text_Io.Float_IO (Real);
procedure Pinstripe (Doc : in out Pdf_Out_File;
Line_Width : Real;
Line_Height : Real;
... |
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... | #SenseTalk | SenseTalk | set starting_condition to ((0, 0), (1, 0), (2, 0), (-1, -1), (0, -1), (1, -1))
RunGameOfLife starting_condition
to printColony colonies
set xCoords to the first item of each item of colonies
set yCoords to the second item of each item of colonies
set min_x to the min of xCoords
set max_x to the max ... |
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 ... | #Lambdatalk | Lambdatalk |
{if true then yes else no}
-> yes
{def switch
{lambda {:n}
{if {< :n 0}
then :n is negative
else {if {> :n 0}
then :n is positive
else :n is zero}}}}
{switch -12}
-> -12 is negative
{switch 12}
-> 12 is positive
{switch 0}
-> 0 is zero
|
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Julia | Julia | largest = 0
function iscolorful(n, base=10)
0 <= n < 10 && return true
dig = digits(n, base=base)
(1 in dig || 0 in dig || !allunique(dig)) && return false
products = Set(dig)
for i in 2:length(dig), j in 1:length(dig)-i+1
p = prod(dig[j:j+i-1])
p in products && return false
... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | ClearAll[ColorfulNumberQ]
ColorfulNumberQ[n_Integer?NonNegative] := Module[{digs, parts},
If[n > 98765432,
False
,
digs = IntegerDigits[n];
parts = Partition[digs, #, 1] & /@ Range[1, Length[digs]];
parts //= Catenate;
parts = Times @@@ parts;
DuplicateFreeQ[parts]
]
]
Multicolumn[Select[Ran... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Perl | Perl | use strict;
use warnings;
use feature 'say';
use enum qw(False True);
use List::Util <max uniqint product>;
use Algorithm::Combinatorics qw(combinations permutations);
sub table { my $t = shift() * (my $c = 1 + length max @_); ( sprintf( ('%'.$c.'d')x@_, @_) ) =~ s/.{1,$t}\K/\n/gr }
sub is_colorful {
my($n) = @... |
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.)
| #MAXScript | MAXScript | -- Two dashes precede a single line comment
/* This is 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.)
| #MBS | MBS | ! A pling in a line starts a comment
INT n:=5 ! Comments can appear at the end of a line
/* A comment block can also be defined using climbstar and starclimb symbols.
This allows comments to be stretched across several lines */ |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #BBC_BASIC | BBC BASIC | PD_RETURNDC = 256
_LOGPIXELSY = 90
DIM pd{lStructSize%, hwndOwner%, hDevMode%, hDevNames%, \
\ hdc%, flags%, nFromPage{l&,h&}, nToPage{l&,h&}, \
\ nMinPage{l&,h&}, nMaxPage{l&,h&}, nCopies{l&,h&}, \
\ hInstance%, lCustData%, lpfnPrintHook%, lpfnSetupHook%, \
\ ... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #FreeBASIC | FreeBASIC | Dim As String exename
#ifdef __FB_WIN32__
exename = "mspaint.exe /pt"
#endif
#ifdef __FB_LINUX__
exename = "lp -o media=A4 "
#endif
Dim As Uinteger ps, col, h, w, x, y1, y2
' (A4) # 595 x 842 dots
w = 842 : h = 595
' create display size window, 8bit color (palette), no frame
Screenres w, h, 8,, 8
h \= 7 :... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Go | Go | package main
import (
"github.com/fogleman/gg"
"log"
"os/exec"
"runtime"
)
var palette = [8]string{
"000000", // black
"FF0000", // red
"00FF00", // green
"0000FF", // blue
"FF00FF", // magenta
"00FFFF", // cyan
"FFFF00", // yellow
"FFFFFF", // white
}
func pinstrip... |
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... | #SequenceL | SequenceL | life(Cells(2))[I, J] :=
let
numNeighbors := Cells[I-1,J-1] + Cells[I-1,J] + Cells[I-1,J+1] +
Cells[I,J-1] +/*current cell*/Cells[I,J+1] +
Cells[I+1,J-1] + Cells[I+1,J] + Cells[I+1,J+1];
in
0 when I=1 or J=1 or I=size(Cells) or J=size(Cells[I]) //On Border
else
0 when numNeighbors < 2 or numNeighbors... |
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 ... | #langur | langur | # using the fact that submatch() returns an empty array for no match ...
# ... and that a decoupling assignment returns a Boolean...
if val .alias, .name = submatch($re/^(\.idregex;)\\s*;\\s*(\.idregex;)/, .row) {
# success (2 or more values in array returned from submatch function)
# use .alias and .name her... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Phix | Phix | with javascript_semantics
function colourful(integer n)
if n<10 then return n>=0 end if
sequence digits = sq_sub(sprintf("%d",n),'0'),
ud = unique(deep_copy(digits))
integer ln = length(digits)
if ud[1]<=1 or length(ud)!=ln then return false end if
for i=1 to ln-1 do
for j=i... |
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.)
| #Metafont | Metafont | % this is "to-end-of-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.)
| #Microsoft_Small_Basic | Microsoft Small Basic | ' This is a comment
i = i + 1 ' You can also append comments to statements |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Julia | Julia |
using Colors, FileIO
const colors = [colorant"black", colorant"red", colorant"green", colorant"blue",
colorant"magenta", colorant"cyan", colorant"yellow", colorant"white"]
function getnumberwithprompt(prompt, t::Type)
s = ""
while (x = tryparse(t, s)) == nothing
print("\n", prompt,... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Nim | Nim | import gintro/[glib, gobject, gtk, gio, cairo]
const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
[0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
[255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
[255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
#--------------------------------------------... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Phix | Phix | (load "@lib/ps.l")
# Using circular lists for an endless supply of colors
# (black red green blue magenta cyan yellow white)
(setq
Red (0 100 0 0 100 0 100 100 .)
Green (0 0 100 0 0 100 100 100 .)
Blue (0 0 0 100 100 100 0 100 .) )
(c... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #PicoLisp | PicoLisp | (load "@lib/ps.l")
# Using circular lists for an endless supply of colors
# (black red green blue magenta cyan yellow white)
(setq
Red (0 100 0 0 100 0 100 100 .)
Green (0 0 100 0 0 100 100 100 .)
Blue (0 0 0 100 100 100 0 100 .) )
(c... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Python | Python |
from turtle import *
from PIL import Image
import time
import subprocess
"""
Only works on Windows. Assumes that you have Ghostscript
installed and in your path.
https://www.ghostscript.com/download/gsdnld.html
Hard coded to 100 pixels per inch.
"""
colors = ["black", "red", "green", "blue", "magenta", "c... |
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... | #SETL | SETL | program life;
const
initialMatrix =
[".....",
"..#..",
"...#.",
".###.",
"....."];
loop
init
s := initialLiveSet();
do
output(s);
nm := {[[x+dx, y+dy], [x, y]]: [x, y] in s, dx in {-1..1}, dy in {-1..1}};
s := {c: t = nm{c} | 3 in {#t, #(t less c)}};
end;
proc output(s);
system... |
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.
| #6502_Assembly | 6502 Assembly | LDA $0200 ;get the color of the top-left pixel of the screen
LDA $05FF ;get the color of the bottom-right pixel of the screen. |
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 ... | #LC3_Assembly | LC3 Assembly | BR or BRnzp ; unconditional branch, i.e.
; branch if (result < 0 || result == 0 || result > 0)
; ^ this is always true
BRn ; branch if (result < 0)
BRz ; branch if (result == 0)
BRp ; branch if (result > 0)
; or any combination of thes... |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Picat | Picat | colorful_number(N) =>
N < 10 ;
(X = N.to_string,
X.len <= 8,
not membchk('0',X),
not membchk('1',X),
distinct(X),
[prod(S.map(to_int)) : S in findall(S,(append(_,S,_,X),S != [])) ].distinct).
distinct(L) =>
L.len == L.remove_dups.len. |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Raku | Raku | sub is-colorful (Int $n) {
return True if 0 <= $n <= 9;
return False if $n.contains(0) || $n.contains(1) || $n < 0;
my @digits = $n.comb;
my %sums = @digits.Bag;
return False if %sums.values.max > 1;
for 2..@digits -> $group {
@digits.rotor($group => 1 - $group).map: { %sums{ [×] $_ }++ ... |
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.)
| #min | min | ; this is a comment
1 1 + ; add one and one together |
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.)
| #Mirah | Mirah | puts 'code' # I am a comment
/* This is
* a multiple
* line comment */
|
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Racket | Racket |
#lang racket/gui
(define parts 4)
(define dc (new printer-dc%))
(send* dc (start-doc "Colour Pinstripe") (start-page))
(define-values [W H] (send dc get-size))
(define parts 4)
(define colors
'("Black" "Red" "Green" "Blue" "Magenta" "Cyan" "Yellow" "White"))
(send dc set-pen "black" 0 'transparent)
(send dc s... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Raku | Raku | unit sub MAIN ($dpi = 300, $size = 'letter');
my $filename = './Color-pinstripe-printer-perl6.png';
my %paper = (
'letter' => { :width(8.5), :height(11.0) }
'A4' => { :width(8.2677), :height(11.6929)}
);
my ($w, $h) = %paper{$size}<width height> »*» $dpi;
# ROYGBIVK
my @color = (1,0,0),(1,.598,0)... |
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... | #Shen | Shen | (tc +)
(datatype subtype
(subtype B A); X : B;
_____________________
X : A;)
(datatype integer
if (integer? X)
___________
X: integer;
________________________
(subtype integer number);)
(datatype bit
if (< X 2)
_______
X: bit;
_____________________
(subtype bit integer);)
(datatyp... |
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.
| #8086_Assembly | 8086 Assembly | ;input: cx = x coordinate of pixel, dx = y coordinate of pixel, bh = page number
mov ah,0Dh
int 10h |
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.
| #Action.21 | Action! | PROC Main()
BYTE POINTER ptr
BYTE
w=[160],h=[160],x=[0],y=[0],c,k,update=[1],
CH=$02FC ;Internal hardware value for last key pressed
CARD size=[6400],i
Graphics(15) ;Graphics 160x160 with 4 colors with text window
ptr=PeekC(88)
; Fill screen with random colors
FOR i=1 TO size
DO
ptr^=Ra... |
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.
| #App_Inventor | App Inventor | PixelGetColor, color, %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 ... | #AppleScript | AppleScript |
choose color default color {0, 0, 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 ... | #LIL | LIL | if {$a > 10} {print "code evaluated on true"}
if {$a > 10} {print "again"} {print "code evaluated on false"} |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #Wren | Wren | import "./math" for Int, Nums
import "./set" for Set
import "./seq" for Lst
import "./fmt" for Fmt
var isColorful = Fn.new { |n|
if (n < 0) return false
if (n < 10) return true
var digits = Int.digits(n)
if (digits.contains(0) || digits.contains(1)) return false
var set = Set.new(digits)
var d... |
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.)
| #mIRC_Scripting_Language | mIRC Scripting Language | ;Single Line Comment
/*
Multiple
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.)
| #Modula-2 | Modula-2 | (* Comments (* can nest *)
and they can span multiple lines.
*) |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Tcl | Tcl | package require Tk
# Allocate a temporary drawing surface
canvas .c
# The cycle of colors we want to use
set colors {black red green blue magenta cyan yellow white}
# Draw the output we want
for {set y 0;set dx 1} {$y < 11*72} {incr y 72;incr dx} {
for {set x 0;set c 0} {$x < 8.5*72} {incr x $dx;incr c} {
.c crea... |
http://rosettacode.org/wiki/Colour_pinstripe/Printer | Colour pinstripe/Printer | The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence... | #Wren | Wren | import "graphics" for Canvas, Color, ImageData
import "dome" for Window
import "plugin" for Plugin
Plugin.load("printer")
import "printer" for Printer
class Main {
construct new() {
Window.title = "Color pinstripe - printer"
_width = 842
_height = 595
Canvas.resize(_width, _hei... |
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... | #Sidef | Sidef | var w = Num(`tput cols`)
var h = Num(`tput lines`)
var r = "\033[H"
var dirs = [[-1,-1], [-1, 0], [-1, 1], [ 0,-1],
[ 0, 1], [ 1,-1], [ 1, 0], [ 1, 1]]
var universe = h.of { w.of {1.rand < 0.1} }
func iterate {
var new = h.of { w.of(false) }
static rx = (^h ~X ^w)
for i,j in rx {
v... |
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 ... | #6502_Assembly | 6502 Assembly | define color $00
define looptemp $01
loop_1wide:
lda color
sta $0200,x
inc color
inx
bne loop_1wide
loop_2wide:
lda color
sta $0300,x
inx
sta $0300,x
inc color
inx
bne loop_2wide
lda #0
tax
tay
sta color
sta looptemp ;reset ram
loop_3wide:
lda color
sta $0400,x
inc looptemp
inx
sta $0400,x
inc looptemp
inx
... |
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.
| #AutoHotkey | AutoHotkey | PixelGetColor, color, %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.
| #AutoIt | AutoIt | Opt('MouseCoordMode',1) ; 1 = (default) absolute screen coordinates
$pos = MouseGetPos()
$c = PixelGetColor($pos[0], $pos[1])
ConsoleWrite("Color at x=" & $pos[0] & ",y=" & $pos[1] & _
" ==> " & $c & " = 0x" & Hex($c) & @CRLF) |
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 ... | #C.2B.2B | C++ | // colorwheelwidget.cpp
#include "colorwheelwidget.h"
#include <QPainter>
#include <QPaintEvent>
#include <cmath>
namespace {
QColor hsvToRgb(int h, double s, double v) {
double hp = h/60.0;
double c = s * v;
double x = c * (1 - std::abs(std::fmod(hp, 2) - 1));
double m = v - c;
double r = 0, g ... |
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 ... | #Lisaac | Lisaac | + n : INTEGER;
n := 3;
(n = 2).if {
IO.put_string "n is 2\n";
}.elseif {n = 3} then {
IO.put_string "n is 3\n";
}.elseif {n = 4} then {
IO.put_string "n is 4\n";
} else {
IO.put_string "n is none of the above\n";
}; |
http://rosettacode.org/wiki/Colorful_numbers | Colorful numbers | A colorful number is a non-negative base 10 integer where the product of every sub group of consecutive digits is unique.
E.G.
24753 is a colorful number. 2, 4, 7, 5, 3, (2×4)8, (4×7)28, (7×5)35, (5×3)15, (2×4×7)56, (4×7×5)140, (7×5×3)105, (2×4×7×5)280, (4×7×5×3)420, (2×4×7×5×3)840
Every product is unique.
2346 ... | #XPL0 | XPL0 | func IPow(A, B); \A^B
int A, B, T, I;
[T:= 1;
for I:= 1 to B do T:= T*A;
return T;
];
func Colorful(N); \Return 'true' if N is a colorful number
int N, Digits, R, I, J, Prod;
def Size = 9*8*7*6*5*4*3*2 + 1;
char Used(Size), Num(10);
[if N < 10 then return true; \single digit number is colorful
Fill... |
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.)
| #Modula-3 | Modula-3 | (* Comments (* can nest *)
and they can span 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.)
| #Monte | Monte |
# This comment goes to the end of the line
/** This comment is multi-line.
Yes, it starts with a two stars
and ends with only one.
These should only be used for docstrings. */
|
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... | #Simula | Simula | COMMENT A PORT OF AN R6RS SCHEME IMPLEMENTATION OF CONWAY'S GAME OF LIFE TO SIMULA --- ASSUMES ;
COMMENT ALL CELLS OUTSIDE THE DEFINED GRID ARE DEAD ;
BEGIN
COMMENT FIRST WE NEED CONS, CAR, CDR, LENGTH AND MAP TO SIMULATE SCHEME ;
CLASS ATOM;;
ATOM CLASS CELL(ALIVE); INTEGER ALIVE;;
ATOM CLASS LIST(A1, A2);... |
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 ... | #Action.21 | Action! | PROC Main()
BYTE
i,
CH=$02FC, ;Internal hardware value for last key pressed
PALNTSC=$D014, ;To check if PAL or NTSC system is used
PCOLR0=$02C0,PCOLR1=$02C1,
PCOLR2=$02C2,PCOLR3=$02C3,
COLOR0=$02C4,COLOR1=$02C5,
COLOR2=$02C6,COLOR3=$02C7,
COLOR4=$02C8
Graphics(10)
PCOLR0=$04 ;gra... |
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 ... | #ActionScript | ActionScript |
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
public class ColourPinstripe extends Sprite {
public function ColourPinstripe():void {
if (stage) init();
else addEventListener(Eve... |
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.
| #Axe | Axe | Disp pxl-Test(50,50)▶Dec,i |
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.
| #BaCon | BaCon | INCLUDE canvas
FULLSCREEN
color = GETINK(100, 100, 4)
WAITKEY |
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.
| #BASIC | BASIC | MOUSE ON
WHILE 1
m=MOUSE(0)
PRINT POINT(MOUSE(1),MOUSE(2))
WEND |
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 ... | #Delphi | Delphi |
program Color_wheel;
{$APPTYPE CONSOLE}
uses
Winapi.Windows,
System.SysUtils,
Vcl.Graphics,
System.Math,
Vcl.Imaging.pngimage;
const
TAU = 2 * PI;
function HSBtoColor(hue, sat, bri: Double): TColor;
var
f, h: Double;
u, p, q, t: Byte;
begin
u := Trunc(bri * 255 + 0.5);
if sat = 0 then
... |
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 ... | #Little | Little | int a = 3;
// if-then-else
if (a == 2) {
puts ("a is 2");
} else if (a == 3) {
puts ("a is 3");
} else {
puts("a is 4");
}
// unless
unless (a == 2) { // equivalent to if (a != 2)
puts ("a is 2"); // It will print this line
} else if (a == 3) {
puts ("a is 3");
} else {
puts("a is 4");
} ... |
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.)
| #MontiLang | MontiLang |
/# This is a comment #/
/#
comments can span multiple lines
nested comments are not supported #/
|
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.)
| #MOO | MOO | "String literals are technically the only long-term comment format";
// Some compilers will, however, compile // one-liners to string literals as well (and vice-versa)
/* Classical C-style comments are removed entirely during compile */ |
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... | #Smalltalk | Smalltalk |
"Blinker"
GameOfLife withAliveCells: { 4@2. 4@3. 4@4. 3@3. 4@3. 5@3 } ofSize: 10@10.
"Toad"
GameOfLife withAliveCells: { 2@4. 3@4. 4@4. 3@3. 4@3. 5@3 } ofSize: 10@10
|
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 ... | #Ada | Ada | with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
with SDL.Events.Events;
procedure Colour_Pinstripe_Display is
Width : constant := 1_200;
Height : constant := 800;
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL... |
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.
| #QBasic | QBasic |
'Example: Find color of a screen pixel in QBasic (adapted from QBasic Help file).
' POINT(x%, y%) returns color of pixel at coordinates x,y.
SCREEN 7 'Choose color graphics screen (1,2,4,7,8,9,11,12,13).
LINE (0, 0)-(100, 100), 2 'Draw diagonal line in color attribute 2.
LOCATE 14, 1 'Locate below ... |
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 | C |
#include <X11/Xlib.h>
void
get_pixel_color (Display *d, int x, int y, XColor *color)
{
XImage *image;
image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
color->pixel = XGetPixel (image, 0, 0);
XFree (image);
XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), 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 ... | #F.C5.8Drmul.C3.A6 | Fōrmulæ | #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 ... | #Logo | Logo | if :x < 0 [make "x 0 - :x]
ifelse emptyp :list [print [empty]] [print :list] |
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.)
| #Nanoquery | Nanoquery | // this is 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.)
| #NATURAL | NATURAL | * This is a comment and extends to the end of the line |
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.