task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/Combinations_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...
#IS-BASIC
IS-BASIC
100 PROGRAM "Combinat.bas" 110 READ N 120 STRING D$(1 TO N)*5 130 FOR I=1 TO N 140 READ D$(I) 150 NEXT 160 FOR I=1 TO N 170 FOR J=I TO N 180 PRINT D$(I);" ";D$(J) 190 NEXT 200 NEXT 210 DATA 3,iced,jam,plain
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Phix
Phix
with javascript_semantics function P(integer n,k) return factorial(n)/factorial(n-k) end function function C(integer n,k) return P(n,k)/factorial(k) end function function lstirling(atom n) if n<10 then return lstirling(n+1)-log(n+1) end if return 0.5*log(2*PI*n) + n*log(n/E + 1/(12*E*n...
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...
#J
J
symbols=:256#0 ch=: {{1 0+x[symbols=: x (a.i.y)} symbols}} 'T0 token' =: 0 ch '%+-!(){};,<>=!|&' 'L0 letter' =: 1 ch '_',,u:65 97+/i.26 'D0 digit' =: 2 ch u:48+i.10 'S0 space' =: 3 ch ' ',LF 'C0 commen' =: 4 ch '/' 'C1 comment'=: 5 ch '*' 'q0 quote' =: 6 ch '''' 'Q0 dquote' =: 7 ch '"'   width=: 1+>./symbols defaul...
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"
#FreeBASIC
FreeBASIC
' FB 1.05.0 Win64   ' Program (myprogram.exe) invoke as follows: ' myprogram -c "alpha beta" -h "gamma"   Print "The program was invoked like this => "; Command(0) + " " + Command(-1) Print Print "Press any key to quit" Sleep
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"
#Free_Pascal
Free Pascal
  Program listArguments(input, output, stdErr);   Var i: integer; Begin writeLn('program was called from: ',paramStr(0)); For i := 1 To paramCount() Do Begin writeLn('argument',i:2,' : ', paramStr(i)); End; End.  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#C.2B.2B
C++
// 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.)
#Chapel
Chapel
// single line   /* multi 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...
#FunL
FunL
import lists.zipWithIndex import util.Regex   data Rule( birth, survival )   val Mirek = Regex( '([0-8]+)/([0-8]+)' ) val Golly = Regex( 'B([0-8]+)/S([0-8]+)' )   def decode( rule ) = def makerule( b, s ) = Rule( [int(d) | d <- b], [int(d) | d <- s] )   case rule Mirek( s, b ) -> makerule( b, s ) Golly( b, ...
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 ...
#Clipper
Clipper
IF x == 1 SomeFunc1() ELSEIF x == 2 SomeFunc2() ELSE SomeFunc() ENDIF
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...
#M2000_Interpreter
M2000 Interpreter
  Module CheckIt { Function Equal(Strings){ k=Each(Strings, 2, -1) a$=Array$(Strings, 0) =True While k { =False if a$<>array$(k) then exit =True } } Function LessThan(Strings){ ...
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...
#Maple
Maple
lexEqual := proc(lst) local i: for i from 2 to numelems(lst) do if lst[i-1] <> lst[i] then return false: fi: od: return true: end proc: lexAscending := proc(lst) local i: for i from 2 to numelems(lst) do if StringTools:-Compare(lst[i],lst[i-1]) then return false: fi: od: return true: end proc: tst := ["abc"...
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...
#EchoLisp
EchoLisp
  (lib 'match)   (define (quibble words) (match words [ null "{}"] [ (a) (format "{ %a }" a)] [ (a b) (format "{ %a and %a }" a b)] [( a ... b c) (format "{ %a %a and %a }" (for/string ([w a]) (string-append w ", ")) b c)] [else 'bad-input]))     ;; output   (for ([t ...
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...
#J
J
rcomb=: >@~.@:(/:~&.>)@,@{@# <
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...
#Java
Java
  import com.objectwave.utility.*;   public class MultiCombinationsTester {   public MultiCombinationsTester() throws CombinatoricException { Object[] objects = {"iced", "jam", "plain"}; //Object[] objects = {"abba", "baba", "ab"}; //Object[] objects = {"aaa", "aa", "a"}; //Object[] ...
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Python
Python
from __future__ import print_function   from scipy.misc import factorial as fact from scipy.misc import comb   def perm(N, k, exact=0): return comb(N, k, exact) * fact(k, exact)   exact=True print('Sample Perms 1..12') for N in range(1, 13): k = max(N-2, 1) print('%iP%i =' % (N, k), perm(N, k, exact), end='...
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...
#Java
Java
  // Translated from python source   import java.io.File; import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Map; import java.util.Scanner;   public class Lexer { private int line; private int pos; private int position; private char chr; private String s;   Map<Stri...
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"
#Frink
Frink
  println[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"
#FunL
FunL
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.)
#Chef
Chef
Comment Stew.   This is a comment. The other comment is a loop, but you can name it anything (single word only). You can also name ingredients as comments This is pseudocode.   Ingredients. Ingredient list   Method. Methods. SingleWordCommentOne the Ingredient. Methods. SingleWordCommentTwo until SingleWordCommentOned....
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.)
#ChucK
ChucK
  <-- Not common // Usual 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...
#Furor
Furor
  // Life simulator (game). Console (CLI) version. // It is a 'cellular automaton', and was invented by Cambridge mathematician John Conway.   // The Rules   // For a space that is 'populated': // Each cell with one or no neighbors dies, as if by solitude. // Each cell with four or more neighbors dies, as if by...
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 ...
#Clojure
Clojure
(if (= 1 1) :yes :no) ; returns :yes   (if (= 1 2) :yes :no) ; returns :no   (if (= 1 2) :yes) ; returns nil
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...
#Mathcad
Mathcad
-- define list of list of strings (nested vector of vectors of strings) -- Mathcad vectors are single column arrays. -- The following notation is for convenience in writing arrays in text form. -- Mathcad array input is normally via Mathcad's array operator or via one of the -- array-builder functions, such as stack ...
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...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
data1 = {"aaa", "aaa", "aab"}; Apply[Equal, data] OrderedQ[data]
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...
#Eiffel
Eiffel
  class APPLICATION   create make   feature   make -- Test of the feature comma_quibbling. local l: LINKED_LIST [STRING] do create l.make io.put_string (comma_quibbling (l) + "%N") l.extend ("ABC") io.put_string (comma_quibbling (l) + "%N") l.extend ("DEF") io.put_string (comma_quibbling...
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...
#JavaScript
JavaScript
<html><head><title>Donuts</title></head> <body><pre id='x'></pre><script type="application/javascript"> function disp(x) { var e = document.createTextNode(x + '\n'); document.getElementById('x').appendChild(e); }   function pick(n, got, pos, from, show) { var cnt = 0; if (got.length == n) { if (show) disp(got.joi...
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#R
R
perm <- function(n, k) choose(n, k) * factorial(k) print(perm(seq(from = 3, to = 12, by = 3), seq(from = 2, to = 8, by = 2))) print(choose(seq(from = 10, to = 60, by = 10), seq(from = 3, to = 18, by = 3))) print(perm(seq(from = 1500, to = 15000, by = 1500), seq(from = 55, to = 100, by = 5))) print(choose(seq(from = 100...
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...
#JavaScript
JavaScript
  /* Token: type, value, line, pos */   const TokenType = { Keyword_if: 1, Keyword_else: 2, Keyword_print: 3, Keyword_putc: 4, Keyword_while: 5, Op_add: 6, Op_and: 7, Op_assign: 8, Op_divide: 9, Op_equal: 10, Op_greater: 11, Op_greaterequal: 12, Op_less: 13, Op_Lessequal: 14, Op_mod: 15, Op_multiply: 16...
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"
#Gambas
Gambas
PUBLIC SUB main() DIM l AS Integer DIM numparms AS Integer DIM parm AS String numparms = Application.Args.Count FOR l = 0 TO numparms - 1 parm = Application.Args[l] PRINT l; " : "; parm NEXT 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"
#Genie
Genie
[indent=4] /* Command line arguments, in Genie   valac commandLine.gs ./commandLine sample arguments 'four in total here, including args 0' */   init   // Output the number of arguments print "%d command line argument(s):", args.length   // Enumerate all command line arguments for s in 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.)
#Clean
Clean
Start = /* This is a multi- line comment */ 17 // This is a single-line comment
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Clojure
Clojure
;; This is a comment (defn foo [] 123) ; also 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...
#Futhark
Futhark
  fun bint(b: bool): int = if b then 1 else 0 fun intb(x: int): bool = if x == 0 then False else True   fun to_bool_board(board: [][]int): [][]bool = map (fn (r: []int): []bool => map intb r) board   fun to_int_board(board: [][]bool): [][]int = map (fn (r: []bool): []int => map bint r) board   fun cell_neighbors(...
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 ...
#CMake
CMake
set(num 5)   if(num GREATER 100) message("${num} is very large!") elseif(num GREATER 10) message("${num} is large.") else() message("${num} is small.") message("We might want a bigger number.") endif()
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...
#MATLAB_.2F_Octave
MATLAB / Octave
alist = {'aa', 'aa', 'aa'} all(strcmp(alist,alist{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...
#Nanoquery
Nanoquery
// a function to test if a list of strings are equal def stringsEqual(stringList) // if the list is empty, return true if (len(stringList) = 0) return true end   // otherwise get the first value and check for equality toCompare = stringList[0] equal = true for (i = 1) (equal && (i < len(stringList))) (i = i + ...
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...
#Elixir
Elixir
defmodule RC do def generate( list ), do: "{#{ generate_content(list) }}"   defp generate_content( [] ), do: "" defp generate_content( [x] ), do: x defp generate_content( [x1, x2] ), do: "#{x1} and #{x2}" defp generate_content( xs ) do [last, second_to_last | t] = Enum.reverse( xs ) with_commas = for ...
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...
#Erlang
Erlang
  -module( comma_quibbling ).   -export( [task/0] ).   task() -> [generate(X) || X <- [[], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]]].       generate( List ) -> "{" ++ generate_content(List) ++ "}".   generate_content( [] ) -> ""; generate_content( [X] ) -> X; generate_content( [X1, X2] ) -> string:join( [X1, ...
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...
#jq
jq
def pick(n): def pick(n; m): # pick n, from m onwards if n == 0 then [] elif m == length then empty elif n == 1 then (.[m:][] | [.]) else ([.[m]] + pick(n-1; m)), pick(n; m+1) end; pick(n;0) ;
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...
#Julia
Julia
using Combinatorics   l = ["iced", "jam", "plain"] println("List: ", l, "\nCombinations:") for c in with_replacement_combinations(l, 2) println(c) end   @show length(with_replacement_combinations(1:10, 3))
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Racket
Racket
  #lang racket (require math) (define C binomial) (define P permutations)   (C 1000 10) ; -> 263409560461970212832400 (P 1000 10) ; -> 955860613004397508326213120000  
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Raku
Raku
multi P($n, $k) { [*] $n - $k + 1 .. $n } multi C($n, $k) { P($n, $k) / [*] 1 .. $k }   sub lstirling(\n) { n < 10 ?? lstirling(n+1) - log(n+1) !! .5*log(2*pi*n)+ n*log(n/e+1/(12*e*n)) }   role Logarithm { method gist { my $e = (self/10.log).Int; sprintf "%.8fE%+d", exp(self - $e*10.log), $e; } } mult...
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...
#Julia
Julia
struct Tokenized startline::Int startcol::Int name::String value::Union{Nothing, Int, String} end   const optokens = Dict("*" => "Op_multiply", "/" => "Op_divide", "%" => "Op_mod", "+" => "Op_add", "-" => "Op_subtract", "!" => "Op_not", "<" => "Op_less", "<=" => "Op_lessequal", ...
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"
#Global_Script
Global Script
λ 'as. impmapM (λ 'a. print qq{Argument: §(a)\n}) as
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"
#Go
Go
  package main import ( "fmt" "os" )   func main() { for i, x := range os.Args[1:] { fmt.Printf("the argument #%d is %s\n", i, x) } }  
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"
#Groovy
Groovy
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.)
#COBOL
COBOL
* an asterisk in 7th column comments the line 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.)
#CoffeeScript
CoffeeScript
# one line comment   ### 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...
#Go
Go
package main   import ( "bytes" "fmt" "math/rand" "time" )   type Field struct { s [][]bool w, h int }   func NewField(w, h int) Field { s := make([][]bool, h) for i := range s { s[i] = make([]bool, w) } return Field{s: s, w: w, h: h} }   func (f Field) Set(x, y int, b bool) { f.s[y][x] = b }   func (f ...
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 ...
#COBOL
COBOL
if condition-1 imperative-statement-1 else imperative-statement-2 end-if   if condition-1 if condition-a imperative-statement-1a else imperative-statement-1 end-if else if condition-a imperative-statement-2a else imperative-statement-2 end-if end-if
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...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols nobinary   runSample(arg) return   -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method isEqual(list = Rexx[]) public static binary returns boolean state = boolean (1 == 1) -- default to true loop ix = 1 while ix ...
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...
#F.23
F#
let quibble list = let rec inner = function | [] -> "" | [x] -> x | [x;y] -> sprintf "%s and %s" x y | h::t -> sprintf "%s, %s" h (inner t) sprintf "{%s}" (inner list)   // test interactively quibble [] quibble ["ABC"] quibble ["ABC"; "DEF"] quibble ["ABC"; "DEF"; "G...
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...
#Kotlin
Kotlin
// version 1.0.6   class CombsWithReps<T>(val m: Int, val n: Int, val items: List<T>, val countOnly: Boolean = false) { private val combination = IntArray(m) private var count = 0   init { generate(0) if (!countOnly) println() println("There are $count combinations of $n things take...
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#REXX
REXX
/*REXX program compute and displays a sampling of combinations and permutations. */ numeric digits 100 /*use 100 decimal digits of precision. */   do j=1 for 12; _= /*show all permutations from 1 ──► 12.*/ do k=1 for j ...
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...
#kotlin
kotlin
// Input: command line argument of file to process or console input. A two or // three character console input of digits followed by a new line will be // checked for an integer between zero and twenty-five to select a fixed test // case to run. Any other console input will be parsed.   // Code based on the Java versio...
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"
#Harbour
Harbour
PROCEDURE Main()   LOCAL i   FOR i := 1 TO PCount() ? "argument", hb_ntos( i ), "=", hb_PValue( i ) NEXT   RETURN
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"
#Haskell
Haskell
import System main = getArgs >>= print
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.)
#ColdFusion
ColdFusion
As ColdFusion's grammar is based around HTML syntax, commenting is similar to HTML. <!--- This is a comment. Nothing in this tag can be seen by the end user. Note the three-or-greater dashes to open and close the tag. ---> <!-- This is an HTML comment. Any HTML between the opening and closing of the tag will ...
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.)
#Common_Lisp
Common Lisp
;;;; This code implements the foo and bar functions   ;;; The foo function calls bar on the first argument and multiplies the result by the second. ;;; The arguments are two integers (defun foo (a b) ;; Call bar and multiply (* (bar a) ; Calling bar b))   ;;; The bar function simply adds 3 to the argument (...
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...
#Groovy
Groovy
  class GameOfLife {   int generations int dimensions def board   GameOfLife(generations = 5, dimensions = 5) { this.generations = generations this.dimensions = dimensions this.board = createBlinkerBoard() }   static def createBlinkerBoard() { [ [].withDefault{0}, [0,0,1].withDefault{0}, [0,0,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 ...
#CoffeeScript
CoffeeScript
  if n == 1 console.log "one" else if n == 2 console.log "two" else console.log "other"  
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...
#Nim
Nim
  func allEqual(s: openArray[string]): bool =   for i in 1..s.high: if s[i] != s[0]: return false result = true   func ascending(s: openArray[string]): bool =   for i in 1..s.high: if s[i] <= s[i - 1]: return false result = true   doAssert allEqual(["abc", "abc", "abc"]) doAssert not allEqua...
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...
#OCaml
OCaml
  open List;;   let analyze cmp l = let rec analyze' l prevs = match l with [] -> true | [s] -> cmp prevs s | s::rest -> (cmp prevs s) && (analyze' rest s) in analyze' (List.tl l) (List.hd l) ;;   let isEqual = analyze (=) ;; let isAscending = analyze (<) ;;   let test sample = List.iter pri...
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...
#Factor
Factor
USING: inverse qw sequences ;   : (quibble) ( seq -- seq' ) { { [ { } ] [ "" ] } { [ 1array ] [ ] } { [ 2array ] [ " and " glue ] } [ unclip swap (quibble) ", " glue ] } switch ;   : quibble ( seq -- str ) (quibble) "{%s}" sprintf ;   { } 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...
#Forth
Forth
  : read bl parse ; : not-empty? ( c-addr u -- c-addr u true | false ) ?dup-if true else drop false then ; : third-to-last 2rot ; : second-to-last 2swap ;   : quibble ." {" read read begin read not-empty? while third-to-last type ." , " repeat second-to-last not-empty? if type then not-empty? if ." and " type t...
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...
#LFE
LFE
  (defun combinations (('() _) '()) ((coll 1) (lists:map #'list/1 coll)) (((= (cons head tail) coll) n) (++ (lc ((<- subcoll (combinations coll (- n 1)))) (cons head subcoll)) (combinations tail n))))  
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...
#Lobster
Lobster
import std   // set S of length n, choose k   def choose(s, k, f): let got = map(k): s[0] let n = s.length   def choosi(n_chosen, at): var count = 0 if n_chosen == k: f(got) return 1 var i = at while i < n: got[n_chosen] = s[i] ...
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Ruby
Ruby
include Math   class Integer   def permutation(k) (self-k+1 .. self).inject( :*) end   def combination(k) self.permutation(k) / (1 .. k).inject( :*) end   def big_permutation(k) exp( lgamma_plus(self) - lgamma_plus(self -k)) end   def big_combination(k) exp( lgamma_plus(self) - lgamma_plu...
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...
#Lua
Lua
-- module token_name (in a file "token_name.lua") local token_name = { ['*'] = 'Op_multiply', ['/'] = 'Op_divide', ['%'] = 'Op_mod', ['+'] = 'Op_add', ['-'] = 'Op_subtract', ['<'] = 'Op_less', ['<='] = 'Op_lessequal', ['>'] = 'Op_greater', ['>='] = '...
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"
#HicEst
HicEst
DO i = 2, 100 ! 1 is HicEst.exe EDIT(Text=$CMD_LINE, SePaRators='-"', ITeM=i, IF ' ', EXit, ENDIF, Parse=cmd, GetPosition=position) IF(position > 0) WRITE(Messagebox) cmd ENDDO
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"
#Icon_and_Unicon
Icon and Unicon
procedure main(arglist) every write(!arglist) end
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Component_Pascal
Component Pascal
  (* 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.)
#Crystal
Crystal
# currently, Crystal only supports single-line comments   # This is a doc comment. Any line *directly* above (no blank lines) a module, class, or method is considered a doc comment # Doc comments are used to generate documentation with `crystal docs` class Foo 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...
#Haskell
Haskell
import Data.Array.Unboxed   type Grid = UArray (Int,Int) Bool -- The grid is indexed by (y, x).   life :: Int -> Int -> Grid -> Grid {- Returns the given Grid advanced by one generation. -} life w h old = listArray b (map f (range b)) where b@((y1,x1),(y2,x2)) = bounds old f (y, x) = ( c && (n == 2 || n ...
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 ...
#ColdFusion
ColdFusion
<cfif x eq 3> do something <cfelseif x eq 4> do something else <cfelse> do something else </cfif>
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...
#Oforth
Oforth
: lexEqual asSet size 1 <= ; : lexCmp(l) l l right( l size 1- ) zipWith(#<) and ;
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...
#ooRexx
ooRexx
/* REXX --------------------------------------------------------------- * 28.06.2014 Walter Pachl *--------------------------------------------------------------------*/ Call test 'ABC',.list~of('AA','BB','CC') Call test 'AAA',.list~of('AA','AA','AA') Call test 'ACB',.list~of('AA','CC','BB') Exit   test: Procedure Use ...
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...
#Fortran
Fortran
SUBROUTINE QUIBBLE(TEXT,OXFORDIAN) !Punctuates a list with commas and stuff. CHARACTER*(*) TEXT !The text, delimited by spaces. LOGICAL OXFORDIAN !Just so. INTEGER IST(6),LST(6) !Start and stop positions. INTEGER N,L,I !Counters. INTEGER L1,L2 !Fingers for the scan. INT...
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...
#Lua
Lua
function GenerateCombinations(tList, nMaxElements, tOutput, nStartIndex, nChosen, tCurrentCombination) if not nStartIndex then nStartIndex = 1 end if not nChosen then nChosen = 0 end if not tOutput then tOutput = {} end if not tCurrentCombination then tCurrentCombination = {} end   if nChosen == nMaxEl...
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Scheme
Scheme
  (define (combinations n k) (do ((i 0 (+ 1 i)) (res 1 (/ (* res (- n i)) (- k i)))) ((= i k) res)))   (define (permutations n k) (do ((i 0 (+ 1 i)) (res 1 (* res (- n i)))) ((= i k) res)))   (display "P(4,2) = ") (display (permutations 4 2)) (newline) (display "P(8,2) = ") (d...
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...
#M2000_Interpreter
M2000 Interpreter
  Module lexical_analyzer { a$={/* All lexical tokens - not syntactically correct, but that will have to wait until syntax analysis */ /* Print */ print /* Sub */ - /* Putc */ putc /* Lss */ < /* If */ if /* Gtr */ > /* Else */ else /* Leq */ <= /* Whi...
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"
#Io
Io
System args foreach(a, a println)
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"
#Ioke
Ioke
System programArguments each(println)
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"
#J
J
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.)
#D
D
void main() { // A single line comment.   /* This is a simple C-style comment that can't be nested. Comments mostly work similar to C, newlines are irrelevant. */   /+ This is a nestable comment /+ See? +/ +/   /// Documentation single line comment.   /** Simple C-style 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.)
#Dart
Dart
// This is a single line comment, which lasts until the end of the line. The Dart linter prefers this one.   /* This is also a valid single line comment. Unlike the first one, this one terminates after one of these -> */   /* You can use the syntax above to make multi line comments as well. Like this! */   /// Thes...
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...
#HolyC
HolyC
global limit   procedure main(args) n := args[1] | 50 # default is a 50x50 grid limit := args[2] | &null # optional limit to number of generations write("Enter the starting pattern, end with EOF") grid := getInitialGrid(n) play(grid) end   # This procedure reads in the initial pattern, inser...
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 ...
#Comal
Comal
IF condition THEN PRINT "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...
#PARI.2FGP
PARI/GP
allEqual(strings)=#Set(strings)<2 inOrder(strings)=Set(strings)==strings
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...
#Perl
Perl
use List::Util 1.33 qw(all);   all { $strings[0] eq $strings[$_] } 1..$#strings # All equal all { $strings[$_-1] lt $strings[$_] } 1..$#strings # Strictly ascending
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...
#FreeBASIC
FreeBASIC
  ' FB 1.05.0 Win64   Sub Split(s As String, sep As String, result() As String) Dim As Integer i, j, count = 0 Dim temp As String Dim As Integer position(Len(s) + 1) position(0) = 0 For i = 0 To Len(s) - 1 For j = 0 To Len(sep) - 1 If s[i] = sep[j] Then count += 1 position(count) = ...
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...
#Maple
Maple
with(combinat): chooserep:=(s,k)->choose([seq(op(s),i=1..k)],k): chooserep({iced,jam,plain},2); # [[iced, iced], [iced, jam], [iced, plain], [jam, jam], [jam, plain], [plain, plain]] numbchooserep:=(s,k)->binomial(nops(s)+k-1,k); numbchooserep({iced,jam,plain},2); # 6
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...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
DeleteDuplicates[Tuples[{"iced", "jam", "plain"}, 2],Sort[#1] == Sort[#2] &] ->{{"iced", "iced"}, {"iced", "jam"}, {"iced", "plain"}, {"jam", "jam"}, {"jam", "plain"}, {"plain", "plain"}}   Combi[x_, y_] := Binomial[(x + y) - 1, y] Combi[3, 2] -> 6 Combi[10, 3] ->220  
http://rosettacode.org/wiki/Combinations_and_permutations
Combinations and permutations
This page uses content from Wikipedia. The original article was at Combination. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) This page uses content from Wikipedia. The original article was at P...
#Sidef
Sidef
func P(n, k) { n! / ((n-k)!) } func C(n, k) { binomial(n, k) }   class Logarithm(value) { method to_s { var e = int(value/10.log) "%.8fE%+d" % (exp(value - e*10.log), e) } }   func lstirling(n) { n < 10 ? (lstirling(n+1) - log(n+1))  : (0.5*log(2*Num.pi*n) + n*log(n/Num.e + 1/(12*N...
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...
#Mercury
Mercury
% -*- mercury -*- % % Compile with maybe something like: % mmc -O4 --intermod-opt -E --make --warn-non-tail-recursion self-and-mutual lex %   :- module lex.   :- interface. :- import_module io. :- pred main(io::di, io::uo) is det.   :- implementation. :- import_module char. :- import_module exception. :- import_modul...
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"
#Java
Java
public class Arguments { public static void main(String[] args) { System.out.println("There are " + args.length + " arguments given."); for(int i = 0; i < args.length; i++) System.out.println("The argument #" + (i+1) + " is " + args[i] + " and is at index " + 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"
#JavaScript
JavaScript
process.argv.forEach((val, index) => { console.log(`${index}: ${val}`); });
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.)
#dc
dc
[Making and discarding a string acts like a comment] sz
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.)
#Delphi
Delphi
// single 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...
#Icon_and_Unicon
Icon and Unicon
global limit   procedure main(args) n := args[1] | 50 # default is a 50x50 grid limit := args[2] | &null # optional limit to number of generations write("Enter the starting pattern, end with EOF") grid := getInitialGrid(n) play(grid) end   # This procedure reads in the initial pattern, inser...