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/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #PowerShell | PowerShell | $i = 0
foreach ($s in $args) {
Write-Host Argument (++$i) is $s
} |
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.)
| #Fortran | Fortran | C This would be some kind of comment
C Usually one would avoid columns 2-6 even in 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.)
| #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64
' This a single line comment
REM This is another way of writing a single line comment
/'
This is a
multi-line
comment
'/
/'
Multi-line comments
/'
can also be nested
'/
like this
'/ |
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... | #Maxima | Maxima | life(A) := block(
[p, q, B: zerofor(A), s],
[p, q]: matrix_size(A),
for i thru p do (
for j thru q do (
s: 0,
if j > 1 then s: s + A[i, j - 1],
if j < q then s: s + A[i, j + 1],
if i > 1 then (
s: s + A[i - 1, j],
if j > 1 then s: s + A[i - 1, j... |
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 ... | #F.23 | F# |
printfn "%s" (if 3<2 then "3 is less than 2" else "3 is not less than 2")
|
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #Vlang | Vlang | fn all_equal(strings []string) bool {
for s in strings {
if s != strings[0] {
return false
}
}
return true
}
fn all_less_than(strings []string) bool {
for i := 1; i < strings.len(); i++ {
if !(strings[i - 1] < s) {
return false
}
}
return true
} |
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #Wren | Wren | import "/sort" for Sort
var areEqual = Fn.new { |strings|
if (strings.count < 2) return true
return (1...strings.count).all { |i| strings[i] == strings[i-1] }
}
var areAscending = Fn.new { |strings| Sort.isSorted(strings) }
var a = ["a", "a", "a"]
var b = ["a", "b", "c"]
var c = ["a", "a", "b"]
var d = ["... |
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... | #OCaml | OCaml | open Printf
let quibble list =
let rec aux = function
| a :: b :: c :: d :: rest -> a ^ ", " ^ aux (b :: c :: d :: rest)
| [a; b; c] -> sprintf "%s, %s and %s}" a b c
| [a; b] -> sprintf "%s and %s}" a b
| [a] -> sprintf "%s}" a
| [] -> "}" in
"{" ^ aux list
let test () =
[[];
["ABC"];
... |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #TXR | TXR | txr -p "(rcomb '(iced jam plain) 2)" |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #Ursala | Ursala | #import std
#import nat
cwr = ~&s+ -<&*+ ~&K0=>&^|DlS/~& iota # takes a set and a selection size
#cast %gLSnX
main = ^|(~&,length) cwr~~/(<'iced','jam','plain'>,2) ('1234567890',3) |
http://rosettacode.org/wiki/Compiler/lexical_analyzer | Compiler/lexical analyzer | Definition from Wikipedia:
Lexical analysis is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of tokens (strings with an identified "meaning"). A program that performs lexical analysis may be called a lexer, tokenizer, or scanner (though "scanner" is als... | #Zig | Zig |
const std = @import("std");
pub const TokenType = enum {
unknown,
multiply,
divide,
mod,
add,
subtract,
negate,
less,
less_equal,
greater,
greater_equal,
equal,
not_equal,
not,
assign,
bool_and,
bool_or,
left_paren,
right_paren,
left_br... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Pure | Pure |
using system;
printf "There are %d command line argumants\n" argc;
puts "They are " $$ map (puts) argv;
|
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #PureBasic | PureBasic | If OpenConsole()
Define n=CountProgramParameters()
PrintN("Reading all parameters")
While n
PrintN(ProgramParameter())
n-1
Wend
Print(#CRLF$+"Press Enter")
Input()
CloseConsole()
EndIf |
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.)
| #Frink | Frink |
// This is a single-line comment
/* This is a comment
that spans multiple lines
and so on.
*/
|
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.)
| #Futhark | Futhark |
-- Single-line comment
-- Multi-line
-- comment (yes, just several single-line comments).
|
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... | #MiniScript | MiniScript | // Conway's Game of Life
clear
rows = 64; rowRange = range(0, rows-1)
cols = 96; colRange = range(0, cols-1)
// prepare two tile displays, in display layers 4 and 5
img = Image.create(2, 1); img.setPixel 1, 0, color.white
grids = []
for dispIdx in [4,5]
display(dispIdx).mode = displayMode.tile
td = display(dispIdx)
... |
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 ... | #Factor | Factor |
t 1 2 ? ! returns 1
|
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #XProfan | XProfan | Proc allsame
Parameters long liste
var int result = 1
var int cnt = GetCount(liste)
Case cnt == 0 : Return 0
Case cnt == 1 : Return 1
WhileLoop 1, cnt-1
If GetString$(liste,&loop - 1) <> GetString$(liste,&loop)
result = 0
BREAK
EndIf
EndWhile
Return result
EndProc
... |
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #zkl | zkl | fcn allEQ(strings){ (not strings.filter1('!=(strings[0]))) }
fcn monoUp(strings){
strings.len()<2 or
strings.reduce(fcn(a,b){ if(a>=b) return(Void.Stop,False); b }).toBool()
} |
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... | #Oforth | Oforth | : quibbing(l) -- string
| i s |
StringBuffer new "{" <<
l size dup 1- ->s loop: i [
l at(i) <<
i s < ifTrue: [ ", " << continue ]
i s == ifTrue: [ " and " << ]
]
"}" << dup freeze ; |
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... | #Ol | Ol |
(define (quibble . args)
(display "{")
(let loop ((args args))
(unless (null? args) (begin
(display (car args))
(cond
((= 1 (length args)) #t)
((= 2 (length args))
(display " and "))
(else
(display ", ")))
(loop (... |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #VBScript | VBScript | ' Combinations with repetitions - iterative - VBScript
Sub printc(vi,n,vs)
Dim i, w
For i=0 To n-1
w=w &" "& vs(vi(i))
Next 'i
Wscript.Echo w
End Sub
Sub combine(flavors, draws, xitem, tell)
Dim n, i, j
ReDim v(draws)
If tell Then Wscript.Echo "list of cwr("& flavors &","& draws &") :"
Do While True
For... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Python | Python | import sys
program_name = sys.argv[0]
arguments = sys.argv[1:]
count = len(arguments) |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #R | R | R CMD BATCH --vanilla --slave '--args a=1 b=c(2,5,6)' test.r test.out |
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.)
| #FutureBasic | FutureBasic |
// Single line comment
' Single line comment
rem Single line comment
/* Single line comment */
/*
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.)
| #FUZE_BASIC | FUZE BASIC | //Comment (No space required)
# Comment (Space required)
REM Comment (Space require)
PRINT "This is an inline comment."//Comment (No space required)
END |
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... | #Nim | Nim | import os, strutils, random
randomize()
var w, h: int
if paramCount() >= 2:
w = parseInt(paramStr(1))
h = parseInt(paramStr(2))
if w <= 0: w = 30
if h <= 0: h = 30
# Initialize
var univ, utmp = newSeq[seq[bool]](h)
for y in 0..<h:
univ[y].newSeq w
utmp[y].newSeq w
for x in 0 ..< w:
if rand(9) < 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 ... | #FALSE | FALSE | condition[body]? |
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #zonnon | zonnon |
module CompareStrings;
type
Vector = array * of string;
var
v,w: Vector;
i: integer;
all,ascending: boolean;
begin
v := new Vector(3);
v[0] := "uno";
v[1] := "uno";
v[2] := "uno";
all := true;
for i := 1 to len(v) - 1 do
all := all & (v[i - 1] = v[i]);
end;
w := new Vector(3);
w[0] := "abc";
w[1] ... |
http://rosettacode.org/wiki/Compare_a_list_of_strings | Compare a list of strings | Task
Given a list of arbitrarily many strings, show how to:
test if they are all lexically equal
test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
Each of those two tests should result in a single true or false value, which could be used as t... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 FOR j=160 TO 200 STEP 10
20 RESTORE j
30 READ n
40 LET test1=1: LET test2=1
50 FOR i=1 TO n
60 READ a$
70 PRINT a$;" ";
80 IF i=1 THEN GO TO 110
90 IF p$<>a$ THEN LET test1=0
100 IF p$>=a$ THEN LET test2=0
110 LET p$=a$
120 NEXT i
130 PRINT 'test1'test2
140 NEXT j
150 STOP
160 DATA 3,"AA","BB","CC"
170 DATA 3,"AA",... |
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... | #PARI.2FGP | PARI/GP | comma(v)={
if(#v==0, return("{}"));
if(#v==1, return(Str("{"v[1]"}")));
my(s=Str("{",v[1]));
for(i=2,#v-1,s=Str(s,", ",v[i]));
Str(s," and ",v[#v],"}")
};
comma([])
comma(["ABC"])
comma(["ABC", "DEF"])
comma(["ABC", "DEF", "G", "H"]) |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #Wren | Wren | var combrep // recursive
combrep = Fn.new { |n, lst|
if (n == 0 ) return [[]]
if (lst.count == 0) return []
var r = combrep.call(n, lst[1..-1])
for (x in combrep.call(n-1, lst)) {
var y = x.toList
y.add(lst[0])
r.add(y)
}
return r
}
System.print(combrep.call(2, ["iced",... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Racket | Racket | #lang racket
(current-command-line-arguments) |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Raku | Raku | # with arguments supplied
$ raku -e 'sub MAIN($x, $y) { say $x + $y }' 3 5
8
# missing argument:
$ raku -e 'sub MAIN($x, $y) { say $x + $y }' 3
Usage:
-e '...' x y |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #RapidQ | RapidQ | PRINT "This program is named "; Command$(0)
FOR i=1 TO CommandCount
PRINT "The argument "; i; " is "; Command$(i)
NEXT 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.)
| #Gambas | Gambas |
' This whole line is a comment and is ignored by the gambas interpreter
print "Hello" ' Comments after an apostrophe are ignored
'' A bold-style comment
' TODO: To Do comment will appear in Task Bar
' FIXME: Fix Me comment will appear in Task Bar
' NOTE: Note commnet will appear in Task Bar
|
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.)
| #GAP | GAP | # Comment (till end of line) |
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... | #OCaml | OCaml | let get g x y =
try g.(x).(y)
with _ -> 0
let neighbourhood g x y =
(get g (x-1) (y-1)) +
(get g (x-1) (y )) +
(get g (x-1) (y+1)) +
(get g (x ) (y-1)) +
(get g (x ) (y+1)) +
(get g (x+1) (y-1)) +
(get g (x+1) (y )) +
(get g (x+1) (y+1))
let next_cell g x y =
let n = neighbourhood g x y 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 ... | #Fancy | Fancy | if: (x < y) then: {
"x < y!" println # will only execute this block if x < 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... | #Pascal | Pascal |
program CommaQuibbling;
uses
SysUtils,
Classes,
StrUtils;
const
OuterBracket =['[', ']'];
type
{$IFNDEF FPC}
SizeInt = LongInt;
{$ENDIF}
{ TCommaQuibble }
TCommaQuibble = class(TStringList)
private
function GetCommaquibble: string;
procedure SetCommaQuibble(AValue: string);
p... |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #XPL0 | XPL0 | code ChOut=8, CrLf=9, IntOut=11, Text=12;
int Count, Array(10);
proc Combos(D, S, K, N, Names); \Generate all size K combinations of N objects
int D, S, K, N, Names; \depth of recursion, starting value of N, etc.
int I;
[if D<K then \depth < size
[for I:= S to N-1 do
[Array(D... |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #zkl | zkl | fcn combosK(k,seq){ // repeats, seq is finite
if (k==1) return(seq);
if (not seq) return(T);
self.fcn(k-1,seq).apply(T.extend.fp(seq[0])).extend(self.fcn(k,seq[1,*]));
} |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Raven | Raven | ARGS print
stack (6 items)
0 => "raven"
1 => "myprogram"
2 => "-c"
3 => "alpha beta"
4 => "-h"
5 => "gamma" |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #REALbasic | REALbasic | Function Run(args() as String) As Integer
For each arg As String In args
Stdout.WriteLine(arg)
Next
End Function |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #REXX | REXX | say 'command arguments:'
say arg(1) |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #gecho | gecho | ( this is a test comment... o.O ) 1 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.)
| #Gema | Gema | ! comment starts with "!" and continues to end of line |
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... | #OCTAVE | OCTAVE |
clear all
x=55; % Size of the Lattice (same as LAWE)
z(1:1:x^2)=0; % Initialise the binary lattice
z_prime=z; % prepare the z prime
idx=7*x+2; % Origin
z(idx+4)=1; % Populate the binary lattice with the Gosper Glider
z(idx+x+4)=1;
z(idx+1+4)=1;
z(idx+x+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 ... | #Forth | Forth | ( condition ) IF ( true statements ) THEN
( condition ) IF ( true statements ) ELSE ( false statements ) THEN |
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... | #Perl | Perl | sub comma_quibbling(@) {
return "{$_}" for
@_ < 2 ? "@_" :
join(', ', @_[0..@_-2]) . ' and ' . $_[-1];
}
print comma_quibbling(@$_), "\n" for
[], [qw(ABC)], [qw(ABC DEF)], [qw(ABC DEF G H)]; |
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... | #Phix | Phix | function quibble(sequence words)
if length(words)>=2 then
words[-2..-1] = {words[-2]&" and "&words[-1]}
end if
return "{"&join(words,", ")&"}"
end function
constant tests = {{},
{"ABC"},
{"ABC","DEF"},
{"ABC","DEF","G","H"}}
for i=1 to length... |
http://rosettacode.org/wiki/Combinations_with_repetitions | Combinations with repetitions | The set of combinations with repetitions is computed from a set,
S
{\displaystyle S}
(of cardinality
n
{\displaystyle n}
), and a size of resulting selection,
k
{\displaystyle k}
, by reporting the sets of cardinality
k
{\displaystyle k}
where each member of those sets is chosen from
S... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 READ n
20 DIM d$(n,5)
30 FOR i=1 TO n
40 READ d$(i)
50 NEXT i
60 DATA 3,"iced","jam","plain"
70 FOR i=1 TO n
80 FOR j=i TO n
90 PRINT d$(i);" ";d$(j)
100 NEXT j
110 NEXT i |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Ring | Ring |
see copy("=",30) + nl
see "Command Line Parameters" + nl
see "Size : " + len(sysargv) + nl
see sysargv
see copy("=",30) + nl
for x = 1 to len(sysargv)
see x + nl
next
|
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Ruby | Ruby | #! /usr/bin/env ruby
p ARGV |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Rust | Rust | use std::env;
fn main(){
let args: Vec<_> = env::args().collect();
println!("{:?}", args);
} |
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.)
| #Genie | Genie | // Comment continues until end of line
/* Comment lasts between delimiters */ |
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.)
| #GML | GML | // comment starts with "//" and continues to the end of the line |
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... | #Ol | Ol |
#!/usr/bin/ol
(import (otus random!))
(define MAX 65536) ; should be power of two
; size of game board (should be less than MAX)
(define WIDTH 170)
(define HEIGHT 96)
; helper function
(define (hash x y)
(let ((x (mod (+ x WIDTH) WIDTH))
(y (mod (+ y HEIGHT) HEIGHT)))
(+ (* y MAX) x)))
; helper ... |
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 ... | #Fortran | Fortran | if ( a .gt. 20.0 ) then
q = q + a**2
else if ( a .ge. 0.0 ) then
q = q + 2*a**3
else
q = q - a
end 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... | #PHP | PHP | <?php
function quibble($arr){
$words = count($arr);
if($words == 0){
return '{}';
}elseif($words == 1){
return '{'.$arr[0].'}';
}elseif($words == 2){
return '{'.$arr[0].' and '.$arr[1].'}';
}else{
return '{'.implode(', ', array_splice($arr, 0, -1) ). ' and '.$arr[0].'}';
}
}
$te... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #S-lang | S-lang | variable a;
foreach a (__argv)
print(a);
|
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Sather | Sather | class MAIN is
main(args:ARRAY{STR}) is
loop
#OUT + args.elt! + "\n";
end;
end;
end; |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Scala | Scala | object CommandLineArguments extends App {
println(s"Received the following arguments: + ${args.mkString("", ", ", ".")}")
} |
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.)
| #gnuplot | gnuplot | # this is a comment
# backslash continues \
a comment to the next \
line or 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.)
| #Go | Go | // this is a single line comment
/* this is
a multi-line
block comment.
/* It does not nest */ |
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... | #ooRexx | ooRexx | /* REXX ---------------------------------------------------------------
* 07.08.2014 Walter Pachl Conway's Game of life graphical
* Input is a file containing the initial pattern.
* The compute area is extended when needed
* (i.e., when cells are born outside the current compute area)
* When computing the pattern se... |
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 ... | #FreeBASIC | FreeBASIC | Dim a As Integer = 1
If a = 1 Then
sub1
ElseIf a = 2 Then
sub2
Else
sub3
End 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... | #PicoLisp | PicoLisp | (for L '([] ["ABC"] ["ABC", "DEF"] ["ABC", "DEF", "G", "H"])
(let H (head -1 L)
(prinl
"{"
(glue ", " H)
(and H " and ")
(last L)
"}" ) ) ) |
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... | #PL.2FI | PL/I | *process or(!);
quib: Proc Options(main);
/*********************************************************************
* 06.10.2013 Walter Pachl
*********************************************************************/
put Edit*process or(!);
quib: Proc Options(main);
/**************************************************... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Scheme | Scheme | (define (main args)
(for-each (lambda (arg) (display arg) (newline)) args)) |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Seed7 | Seed7 | $ include "seed7_05.s7i";
const proc: main is func
local
var integer: i is 0;
begin
writeln("This program is named " <& name(PROGRAM) <& ".");
for i range 1 to length(argv(PROGRAM)) do
writeln("The argument #" <& i <& " is " <& argv(PROGRAM)[i]);
end for;
end func; |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Sidef | Sidef | say ARGV; |
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.)
| #Golfscript | Golfscript | # 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.)
| #Gri | Gri | # this is a comment
show 123 # this too 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... | #Oz | Oz | declare
Rules = [rule(c:1 n:[0 1] new:0) %% Lonely
rule(c:1 n:[4 5 6 7 8] new:0) %% Overcrowded
rule(c:1 n:[2 3] new:1) %% Lives
rule(c:0 n:[3] new:1) %% It takes three to give birth!
rule(c:0 n:[0 1 2 4 5 6 7 8] new:0) %% Ba... |
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 ... | #friendly_interactive_shell | friendly interactive shell | set var 'Hello World'
if test $var = 'Hello World'
echo 'Welcome.'
else if test $var = 'Bye World'
echo 'Bye.'
else
echo 'Huh?'
end |
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... | #PL.2FM | PL/M | 100H:
/* COPY A STRING (MINUS TERMINATOR), RETURNS LENGTH (MINUS TERMINATOR) */
COPY$STR: PROCEDURE(SRC, DST) ADDRESS;
DECLARE (SRC, DST) ADDRESS;
DECLARE (SCH BASED SRC, DCH BASED DST) BYTE;
DECLARE L ADDRESS;
L = 0;
DO WHILE SCH <> '$';
DCH = SCH;
SRC = SRC + 1;
DST = DST... |
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... | #Plain_English | Plain English | To quibble four words:
Add "ABC" to some string things.
Add "DEF" to the string things.
Add "G" to the string things.
Add "H" to the string things.
Quibble the string things.
To quibble one word:
Add "ABC" to some string things.
Quibble the string things.
To quibble some string things:
Quibble the string things giv... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Slate | Slate | StartupArguments do: [| :arg | inform: arg] |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Smalltalk | Smalltalk | (1 to: Smalltalk getArgc) do: [ :i |
(Smalltalk getArgv: i) displayNl
] |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Standard_ML | Standard ML | print ("This program is named " ^ CommandLine.name () ^ ".\n");
val args = CommandLine.arguments ();
Array.appi
(fn (i, x) => print ("the argument #" ^ Int.toString (i+1) ^ " is " ^ x ^ "\n"))
(Array.fromList args); |
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.)
| #Groovy | Groovy | 100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code": REM comment after statement |
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.)
| #GW-BASIC | GW-BASIC | 100 REM Standard BASIC comments begin with "REM" (remark) and extend to the end of the line
110 PRINT "this is code": REM comment after statement |
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... | #PARI.2FGP | PARI/GP | step(M)={
my(N=M,W=matsize(M)[1],L=#M,t);
for(l=1,W,for(w=1,L,
t=sum(i=l-1,l+1,sum(j=w-1,w+1,if(i<1||j<1||i>W||j>L,0,M[i,j])));
N[l,w]=(t==3||(M[l,w]&&t==4))
));
N
};
M=[0,1,0;0,1,0;0,1,0];
for(i=1,3,print(M);M=step(M)) |
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 ... | #Futhark | Futhark |
if <condition> then <truebranch> else <falsebranch>
|
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... | #PowerShell | PowerShell |
function Out-Quibble
{
[OutputType([string])]
Param
(
# Zero or more strings.
[Parameter(Mandatory=$false, Position=0)]
[AllowEmptyString()]
[string[]]
$Text = ""
)
# If not null or empty...
if ($Text)
{
# Remove empty strings from the arra... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Swift | Swift | let args = Process.arguments
println("This program is named \(args[0]).")
println("There are \(args.count-1) arguments.")
for i in 1..<args.count {
println("the argument #\(i) is \(args[i])")
} |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Tailspin | Tailspin |
$ARGS -> !OUT::write
|
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Tcl | Tcl | if { $argc > 1 } {
puts [lindex $argv 1]
} |
http://rosettacode.org/wiki/Comments | Comments | Task
Show all ways to include text in a language source file
that's completely ignored by the compiler or interpreter.
Related tasks
Documentation
Here_document
See also
Wikipedia
xkcd (Humor: hand gesture denoting // for "commenting out" people.)
| #Haskell | Haskell | i code = True -- I am a comment.
{- I am also
a comment. {-comments can be nested-}
let u x = x x (this code not compiled)
Are you? -}
-- |This is a Haddock documentation comment for the following code
i code = True
-- ^This is a Haddock documentation comment for the preceding code
{-|
This is a Haddoc... |
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.)
| #Haxe | Haxe | // Single line commment.
/*
Multiple
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... | #Pascal | Pascal | program Gol;
// Game of life
{$IFDEF FPC}
//save as gol.pp/gol.pas
{$Mode delphi}
{$ELSE}
//for Delphi save as gol.dpr
{$Apptype Console}
{$ENDIF}
uses
crt;
const
colMax = 76;
rowMax = 22;
dr = colMax+2; // element count of one row
cDelay = 20; // delay in ms
(*
expand field by one row/column ... |
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 ... | #GAP | GAP | if <condition> then
<statements>
elif <condition> then
<statements>
else
<statements>
fi; |
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... | #Prolog | Prolog | words_series(Words, Bracketed) :-
words_serialized(Words, Serialized),
atomics_to_string(["{",Serialized,"}"], Bracketed).
words_serialized([], "").
words_serialized([Word], Word) :- !.
words_serialized(Words, Serialized) :-
append(Rest, [Last], Words), %% Splits the list ... |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #Toka | Toka | [ arglist array.get type cr ] is show-arg
[ dup . char: = emit space ] is #=
1 #args [ i #= show-arg ] countedLoop |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #TXR | TXR | @(next :args)
@(collect)
@arg
@(end)
@(output)
My args are: {@(rep)@arg, @(last)@arg@(end)}
@(end) |
http://rosettacode.org/wiki/Command-line_arguments | Command-line arguments | Command-line arguments is part of Short Circuit's Console Program Basics selection.
Scripted main
See also Program name.
For parsing command line arguments intelligently, see Parsing command-line arguments.
Example command line:
myprogram -c "alpha beta" -h "gamma"
| #UNIX_Shell | UNIX Shell | WHOLELIST="$@" |
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.)
| #HicEst | HicEst | ! a comment starts with a "!" and ends at 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.)
| #Hope | Hope | ! All Hope comments begin with "!" and extend to the end of the line |
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... | #Perl | Perl | life.pl numrows numcols numiterations
life.pl 5 10 15
|
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.