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"
#Neko
Neko
/* command line arguments, neko */ var argc = $asize($loader.args)   /* Display count and arguments, indexed from 0, no script name included */ $print("There are ", argc, " arguments\n")   var arg = 0 while arg < argc $print($loader.args[arg ++= 1], "\n")
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Elena
Elena
//single line comment   /*multiple line comment*/
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Elixir
Elixir
  # 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...
#Julia
Julia
julia> Pkg.add("CellularAutomata") INFO: Installing CellularAutomata v0.1.2 INFO: Package database updated   julia> using CellularAutomata   julia> gameOfLife{T<:Int}(n::T, m::T, gen::T) = CA2d([3], [2,3], int(randbool(n, m)), gen) gameOfLife (generic function with 1 method)   julia> gameOfLife(15, 30, 5) 30x15x5 Cellu...
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 ...
#Dragon
Dragon
if(a == b) { add() } else if(a == c) less() //{}'s optional for one-liners else { both() }
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...
#Raku
Raku
[eq] @strings # All equal [lt] @strings # Strictly ascending
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...
#Red
Red
Red []   list1: ["asdf" "Asdf" "asdf"] list2: ["asdf" "bsdf" "asdf"] list3: ["asdf" "asdf" "asdf"]   all-equal?: func [list][ 1 = length? unique/case list ] sorted?: func [list][ list == sort/case copy list ]  ;; sort without copy would modify list !   print all-equal? list1 print sorted? list1   print all-equal? ...
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...
#Lasso
Lasso
#!/usr/bin/lasso9   local(collection = array( array, array("ABC"), array("ABC", "DEF"), array("ABC", "DEF", "G", "H") ) )   with words in #collection do { if(#words -> size > 1) => { local(last = #words -> last) #words -> removelast stdoutnl('{' + #words -> join(', ') + ' and ' + #last'}') else(#words...
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...
#Liberty_BASIC
Liberty BASIC
  do read in$ if in$ ="END" then wait w =wordCount( in$) select case w case 0 o$ ="{}" case 1 o$ ="{" +in$ +"}" case 2 o$ ="{" +word$( in$, 1) +" and " +word$( in$, 2) +"}" case else ...
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...
#R
R
library(gtools) combinations(3, 2, c("iced", "jam", "plain"), set = FALSE, repeats.allowed = TRUE) nrow(combinations(10, 3, repeats.allowed = TRUE))
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...
#Racket
Racket
  #lang racket (define (combinations xs k) (cond [(= k 0) '(())] [(empty? xs) '()] [(append (combinations (rest xs) k) (map (λ(x) (cons (first xs) x)) (combinations xs (- k 1))))]))  
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...
#QB64
QB64
dim shared source as string, the_ch as string, tok as string, toktyp as string dim shared line_n as integer, col_n as integer, text_p as integer, err_line as integer, err_col as integer, errors as integer   declare function isalnum&(s as string) declare function isalpha&(s as string) declare function isdigit&(s as 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"
#Nemerle
Nemerle
using System; using System.Console;   module CLArgs { Main(args : array[string]) : void { foreach (arg in args) Write($"$arg "); // using the array passed to Main(), everything after the program name Write("\n");   def cl_args = Environment.GetCommandLineArgs(); // also gets program name...
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"
#NetRexx
NetRexx
/* NetRexx */ -- sample arguments: -c "alpha beta" -h "gamma" say "program arguments:" 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"
#Nim
Nim
import os echo "program name: ", getAppFilename() echo "Arguments:" for arg in commandLineParams(): echo arg
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.)
#Elm
Elm
  -- a single line comment   {- a multiline comment {- can be nested -} -}  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Emacs_Lisp
Emacs Lisp
; This is a comment
http://rosettacode.org/wiki/Conway%27s_Game_of_Life
Conway's Game of Life
The Game of Life is a   cellular automaton   devised by the British mathematician   John Horton Conway   in 1970.   It is the best-known example of a cellular automaton. Conway's game of life is described   here: A cell   C   is represented by a   1   when alive,   or   0   when dead,   in an   m-by-m   (or m×m)   sq...
#Kotlin
Kotlin
// version 1.2.0   import java.util.Random   val rand = Random(0) // using a seed to produce same output on each run   enum class Pattern { BLINKER, GLIDER, RANDOM }   class Field(val w: Int, val h: Int) { val s = List(h) { BooleanArray(w) }   operator fun set(x: Int, y: Int, b: Boolean) { s[y][x] = 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 ...
#DWScript
DWScript
if a: pass elseif b: pass else: # c, maybe? pass
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...
#REXX
REXX
/* REXX --------------------------------------------------------------- * 28.06.2014 Walter Pachl *--------------------------------------------------------------------*/ Call mklist 'ABC','AA','BB','CC' Call test 'ABC' Call mklist 'AAA','AA','AA','AA' Call mklist 'ACB','AA','CC','BB' Call test 'AAA' Call test 'ACB' Exi...
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...
#Logo
Logo
to join :delimiter :list [:result []] output cond [ [ [empty? :list]  :result ] [ [empty? :result] (join :delimiter butfirst :list first :list) ] [ else (join :delimiter butfirst :list (word :result :delimiter first :list)) ] ] end   to quibble :list...
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...
#Lua
Lua
function quibble (strTab) local outString, join = "{" for strNum = 1, #strTab do if strNum == #strTab then join = "" elseif strNum == #strTab - 1 then join = " and " else join = ", " end outString = outString .. strTab[strNum] .. join ...
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...
#Raku
Raku
my @S = <iced jam plain>; my $k = 2;   .put for [X](@S xx $k).unique(as => *.sort.cache, with => &[eqv])
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...
#REXX
REXX
/*REXX pgm displays combination sets with repetitions for X things taken Y at a time*/ call RcombN 3, 2, 'iced jam plain' /*The 1st part of Rosetta Code task. */ call RcombN -10, 3, 'Iced jam plain' /* " 2nd " " " " " */ exit ...
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...
#Racket
Racket
  #lang racket (require parser-tools/lex)   (define-lex-abbrevs [letter (union (char-range #\a #\z) (char-range #\A #\Z))] [digit (char-range #\0 #\9)] [underscore #\_] [identifier (concatenation (union letter underscore) (repetition 0 +inf.0 (union lett...
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"
#Oberon-2
Oberon-2
  MODULE CommandLineArguments; IMPORT NPCT:Args, Out := NPCT:Console;   BEGIN Out.String("Args number: ");Out.Int(Args.Number(),0);Out.Ln; Out.String("0.- : ");Out.String(Args.AsString(0));Out.Ln; Out.String("1.- : ");Out.String(Args.AsString(1));Out.Ln; Out.String("2.- : ");Out.String(Args.AsString(2));Out...
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"
#Objeck
Objeck
  class Line { function : Main(args : String[]) ~ Nil { each(i : args) { args[i]->PrintLine(); }; } }  
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Erlang
Erlang
% Erlang comments begin with "%" and extend to the end of the line.
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#ERRE
ERRE
  ! Standard ERRE comments begin with ! and extend to the end of the line   PRINT("this is code") ! 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...
#Lua
Lua
local function T2D(w,h) local t={} for y=1,h do t[y]={} for x=1,w do t[y][x]=0 end end return t end   local Life = { new = function(self,w,h) return setmetatable({ w=w, h=h, gen=1, curr=T2D(w,h), next=T2D(w,h)}, {__index=self}) end, set = function(self, coords) for i = 1, #coords, 2 do self.curr[coo...
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 ...
#D.C3.A9j.C3.A0_Vu
Déjà Vu
if a: pass elseif b: pass else: # c, maybe? pass
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...
#Ruby
Ruby
strings.uniq.one? # all equal? strings == strings.uniq.sort # ascending?
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...
#Rust
Rust
fn strings_are_equal(seq: &[&str]) -> bool { match seq { &[] | &[_] => true, &[x, y, ref tail @ ..] if x == y => strings_are_equal(&[&[y], tail].concat()), _ => false } }   fn asc_strings(seq: &[&str]) -> bool { match seq { &[] | &[_] => true, &[x, y, ref tail @ ..] 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...
#M2000_Interpreter
M2000 Interpreter
  Module Checkit { function f$ { what$=mid$(trim$(letter$),2) what$=Left$(what$, len(what$)-1) flush ' erase any argument from stack Data param$(what$) m=stack.size document resp$="{" if m>2 then { shift m-1, 2...
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...
#Maple
Maple
Quibble := proc( los ) uses StringTools; Fence( proc() if los = [] then "" elif numelems( los ) = 1 then los[ 1 ] else cat( Join( los[ 1 .. -2 ], ", " ), " and ", los[ -1 ] ) end if end(), "{", "}" ) end proc:
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...
#Ring
Ring
  # Project : Combinations with repetitions   n = 2 k = 3 temp = [] comb = [] num = com(n, k) combinations(n, k) comb = sortfirst(comb, 1) see showarray(comb) + nl   func combinations(n, k) while true temp = [] for nr = 1 to k tm = random(n-1) + 1 add(temp, tm) ...
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...
#Ruby
Ruby
possible_doughnuts = ['iced', 'jam', 'plain'].repeated_combination(2) puts "There are #{possible_doughnuts.count} possible doughnuts:" possible_doughnuts.each{|doughnut_combi| puts doughnut_combi.join(' and ')}   # Extra credit possible_doughnuts = [*1..1000].repeated_combination(30) # size returns the size of the enum...
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...
#Raku
Raku
grammar tiny_C { rule TOP { ^ <.whitespace>? <tokens> + % <.whitespace> <.whitespace> <eoi> }   rule whitespace { [ <comment> + % <ws> | <ws> ] }   token comment { '/*' ~ '*/' .*? }   token tokens { [ | <operator> { make $/<operator>.ast } | <keyword> { make $/<keyword>...
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"
#Objective-C
Objective-C
NSArray *args = [[NSProcessInfo processInfo] arguments]; NSLog(@"This program is named %@.", [args objectAtIndex:0]); NSLog(@"There are %d arguments.", [args count] - 1); for (i = 1; i < [args count]; ++i){ NSLog(@"the argument #%d is %@", i, [args objectAtIndex: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"
#OCaml
OCaml
let () = Printf.printf "This program is named %s.\n" Sys.argv.(0); for i = 1 to Array.length Sys.argv - 1 do Printf.printf "the argument #%d is %s\n" i Sys.argv.(i) done
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.)
#Euphoria
Euphoria
-- This is a comment
http://rosettacode.org/wiki/Conway%27s_Game_of_Life
Conway's Game of Life
The Game of Life is a   cellular automaton   devised by the British mathematician   John Horton Conway   in 1970.   It is the best-known example of a cellular automaton. Conway's game of life is described   here: A cell   C   is represented by a   1   when alive,   or   0   when dead,   in an   m-by-m   (or m×m)   sq...
#ksh
ksh
  #!/bin/ksh # # Version AJM 93u+ 2012-08-01   # Conway's Game of Life   # # Variables: # integer RAND_MAX=32767 LIFE="�[07m �[m" NULL=" " typeset -a char=( "$NULL" "$LIFE" )   # # Input x y or default to 30x30, positive integers only # integer h=${1:-30} ; h=$(( h<=0 ? 30 : h )) # Height (y) integer w=${2:-30} ; w=...
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 ...
#E
E
if (okay) { println("okay") } else if (!okay) { println("not okay") } else { println("not my day") }
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...
#S-lang
S-lang
define equal_sl(sarr) { variable n = length(sarr), a0, i; if (n < 2) return 1;   a0 = sarr[0]; _for i (1, length(sarr)-1, 1) if (sarr[i] != a0) return 0;   return 1; } define ascending_sl(sarr) { variable n = length(sarr), a0, i; if (n < 2) return 1;   _for i (0, length(sarr)-2, 1) if (sarr[...
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...
#Scala
Scala
  def strings_are_equal(seq:List[String]):Boolean = seq match { case Nil => true case s::Nil => true case el1 :: el2 :: tail => el1==el2 && strings_are_equal(el2::tail) }   def asc_strings(seq:List[String]):Boolean = seq match { case Nil => true case s::Nil => true case el1 :: el2 :: tail => el1...
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...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
quibble[words___] := ToString@{StringJoin@@ Replace[Riffle[{words}, ", "], {most__, ", ", last_} -> {most, " and ", last}]}
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...
#MATLAB_.2F_Octave
MATLAB / Octave
  function r = comma_quibbling(varargin) if isempty(varargin) r = ''; elseif length(varargin)==1; r = varargin{1}; else r = [varargin{end-1},' and ', varargin{end}]; for k=length(varargin)-2:-1:1, r = [varargin{k}, ', ', r]; end end end;  
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...
#Rust
Rust
  // Iterator for the combinations of `arr` with `k` elements with repetitions. // Yields the combinations in lexicographical order. struct CombinationsWithRepetitions<'a, T: 'a> { // source array to get combinations from arr: &'a [T], // length of the combinations k: u32, // current counts of each ...
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...
#Scala
Scala
  object CombinationsWithRepetition {   def multi[A](as: List[A], k: Int): List[List[A]] = (List.fill(k)(as)).flatten.combinations(k).toList   def main(args: Array[String]): Unit = { val doughnuts = multi(List("iced", "jam", "plain"), 2) for (combo <- doughnuts) println(combo.mkString(","))   val b...
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...
#RATFOR
RATFOR
###################################################################### # # The Rosetta Code scanner in Ratfor 77. # # # How to deal with FORTRAN 77 input is a problem. I use formatted # input, treating each line as an array of type CHARACTER--regrettably # of no more than some predetermined, finite length. It is a very...
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"
#Oforth
Oforth
System.Args 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"
#Oz
Oz
functor import Application System define ArgList = {Application.getArgs plain} {ForAll ArgList System.showInfo} {Application.exit 0} 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.)
#F.23
F#
// this comments to the end of the line (* this comments a region which can be multi-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.)
#Factor
Factor
! Comments starts with "! " #! Or with "#! " ! and last until the end of the line   USE: multiline /* The multiline vocabulary implements C-like multiline 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...
#M2000_Interpreter
M2000 Interpreter
  Module Life { Font "courier new" Form 40, 18 Cls 3,0 Double Report 2, "Game of Life" Normal Cls 5, 2 Const Mx=20, My=10 Dim A(0 to Mx+1, 0 to My+1)=0 Flush REM Data (2,2),(2,3),(3,3),(4,3),(5,4),(,3,4),(5,3),(6,2),(8,5),(5,8) Data (5,3) Data (5,4) Data (5,5) generation=1 While not empty (A, B)=Array...
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 ...
#EasyLang
EasyLang
i = random 10 if i mod 2 = 0 print i & " is divisible by 2" elif i mod 3 = 0 print i & " is divisible by 3" else print i & " is not divisible by 2 or 3" .
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...
#Scheme
Scheme
  (define (compare-strings fn strs) (or (null? strs) ; returns #t on empty list (null? (cdr strs)) ; returns #t on list of size 1 (do ((fst strs (cdr fst)) (snd (cdr strs) (cdr snd))) ((or (null? snd) (not (fn (car fst) (car...
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...
#Seed7
Seed7
$ include "seed7_05.s7i";   const func boolean: allTheSame (in array string: strings) is func result var boolean: allTheSame is TRUE; local var integer: index is 0; begin for index range 2 to length(strings) until not allTheSame do if strings[pred(index)] <> strings[index] then allTheSam...
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...
#MAXScript
MAXScript
  fn separate words: = ( if words == unsupplied or words == undefined or classof words != array then return "{}" else ( local toReturn = "{" local pos = 1 while pos <= words.count do ( if pos == 1 then (append toReturn words[pos]; pos+=1) else ( if pos <= words.count-1 then (append to...
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...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols nobinary   runSample(arg) return   -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method quibble(arg) public static parse arg '[' lst ']' lst = lst.changestr('"', '').space(1) lc = lst.lastpos(',') if lc > 0 th...
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...
#Scheme
Scheme
(define (combs-with-rep k lst) (cond ((= k 0) '(())) ((null? lst) '()) (else (append (map (lambda (x) (cons (car lst) x)) (combs-with-rep (- k 1) lst)) (combs-with-rep k (cdr lst))))))   (display (combs-with-rep 2 (list "iced" "jam" "plai...
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...
#Scala
Scala
  package xyz.hyperreal.rosettacodeCompiler   import scala.io.Source import scala.util.matching.Regex   object LexicalAnalyzer { private val EOT = '\u0004'   val symbols = Map( "*" -> "Op_multiply", "/" -> "Op_divide", "%" -> "Op_mod", "+" -> "Op_add", "-" -> "Op_minus", ...
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"
#Pascal
Pascal
my @params = @ARGV; my $params_size = @ARGV; my $second = $ARGV[1]; my $fifth = $ARGV[4];
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"
#Perl
Perl
my @params = @ARGV; my $params_size = @ARGV; my $second = $ARGV[1]; my $fifth = $ARGV[4];
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Falcon
Falcon
  /* Start comment block My Life Story */   // set up my bank account total bank_account_total = 1000000 // Wish this was the case  
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.)
#FALSE
FALSE
{comments are in curly braces}
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...
#MANOOL
MANOOL
  { {extern "manool.org.18/std/0.3/all"} in : let { N = 40; M = 80 } in : let { G = 99 } in : let { Display = { proc { B } as  : for { I = Range[N]$ } do  : do Out.WriteLine[] after  : for { J = Range[M]$ } do Out.Write[{if B[I; J] <> 0 then "*" else " "}] } } in : var { B = {array N of: ar...
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 ...
#Efene
Efene
  show_if_with_parenthesis = fn (Num) { if (Num == 1) { io.format("is one~n") } else if (Num === 2) { io.format("is two~n") } else { io.format("not one not two~n") } }   show_if_without_parenthesis = fn (Num) { if Num == 1 { io.format("is one~n") } els...
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...
#SenseTalk
SenseTalk
analyze ["AA","BB","CC"] analyze ["AA","AA","AA"] analyze ["AA","CC","BB"] analyze ["AA","ACB","BB","CC"] analyze ["single_element"]   to analyze aList put "List: " & aList put " " & (if allEqual(aList) then "IS" else "Is NOT") && "all equal" put " " & (if isAscending(aList) then "IS" else "Is NOT") && "strictly...
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...
#Sidef
Sidef
1..arr.end -> all{ arr[0] == arr[_] } # all equal 1..arr.end -> all{ arr[_-1] < arr[_] } # 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...
#Nim
Nim
proc commaQuibble(s: openArray[string]): string = result = "" for i, c in s: if i > 0: result.add (if i < s.high: ", " else: " and ") result.add c result = "{" & result & "}"   var s = @[@[], @["ABC"], @["ABC", "DEF"], @["ABC", "DEF", "G", "H"]] for i in s: echo commaQuibble(i)
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...
#Sidef
Sidef
func cwr (n, l, a = []) { n>0 ? (^l -> map {|k| __FUNC__(n-1, l.slice(k), [a..., l[k]]) }) : a }   cwr(2, %w(iced jam plain)).each {|a| say a.map{ .join(' ') }.join("\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...
#Scheme
Scheme
  (import (scheme base) (scheme char) (scheme file) (scheme process-context) (scheme write))   (define *symbols* (list (cons #\( 'LeftParen) (cons #\) 'RightParen) (cons #\{ 'LeftBrace) (cons #\} 'RightBrace) ...
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"
#Phix
Phix
with javascript_semantics constant cmd = command_line() ?cmd if cmd[1]=cmd[2] then printf(1,"Compiled executable name: %s\n",{cmd[1]}) else printf(1,"Interpreted (using %s) source name: %s\n",cmd[1..2]) end if if length(cmd)>2 then puts(1,"Command line arguments:\n") for i = 3 to length(cmd) do printf(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"
#PHP
PHP
<?php $program_name = $argv[0]; $second_arg = $argv[2]; $all_args_without_program_name = array_shift($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.)
#Fancy
Fancy
# Comments starts with "#" # and last until 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.)
#Fermat
Fermat
Function Foo(n) = {Comments within a function are enclosed within curly brackets.} {You can make multi-line comments such as this one.} n:=n^2 + 3n - 222; {Comments can go after a semicolon.} n:=n+1; n.   ; comments between functions are preceded by semicolons, like this   Function Bar(n)...
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...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
CellularAutomaton[{224,{2,{{2,2,2},{2,1,2},{2,2,2}}},{1,1}}, startconfiguration, steps];
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 ...
#Ela
Ela
if x < 0 then 0 else x
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...
#Tailspin
Tailspin
  // matcher testing if the array contains anything not equal to the first element templates allEqual when <[](..1)> do 1 ! when <[<~=$(1)>]> do 0 ! otherwise 1 ! end allEqual   templates strictAscending def a: $; 1 -> # when <$a::length..> do 1 ! when <?($a($) <..~$a($+1)>)> do $ + 1 -> # otherwise 0 !...
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...
#Tcl
Tcl
tcl::mathop::eq {*}$strings; # All values string-equal tcl::mathop::< {*}$strings; # All values in strict order
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...
#Oberon-2
Oberon-2
  MODULE CommaQuibbling; IMPORT NPCT:Args, Strings, Out;   VAR str: ARRAY 256 OF CHAR;   PROCEDURE Do(VAR s: ARRAY OF CHAR); VAR aux: ARRAY 128 OF CHAR; i,params: LONGINT; BEGIN params := Args.Number() - 1; CASE params OF 0: COPY("{}",s) |1: Args.At(1,aux); ...
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...
#Standard_ML
Standard ML
let rec combs_with_rep k xxs = match k, xxs with | 0, _ -> [[]] | _, [] -> [] | k, x::xs -> List.map (fun ys -> x::ys) (combs_with_rep (k-1) xxs) @ combs_with_rep k xs
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...
#Stata
Stata
function combrep(v,k) { n = cols(v) a = J(comb(n+k-1,k),k,v[1]) u = J(1,k,1) for (i=2; 1; i++) { for (j=k; j>0; j--) { if (u[j]<n) break } if (j<1) return(a) m = u[j]+1 for (; j<=k; j++) u[j] = m a[i,.] = v[u] } }   combrep(("iced","jam","plain"),2)   a = combrep(1..10,3) rows(a)
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...
#Standard_ML
Standard ML
(*------------------------------------------------------------------*) (* The Rosetta Code lexical analyzer, in Standard ML. Based on the ATS and the OCaml. The intended compiler is Mlton or Poly/ML; there is a tiny difference near the end of the file, depending on which compiler is used. *)   (*--------------...
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"
#Picat
Picat
main(ARGS) => println(ARGS). main(_) => true.
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"
#PicoLisp
PicoLisp
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l   (de c () (prinl "Got 'c': " (opt)) )   (de h () (prinl "Got 'h': " (opt)) )   (load T) (bye)
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"
#PL.2FI
PL/I
  /* The entire command line except the command word itself is passed */ /* to the parameter variable in PL/I. */ program: procedure (command_line) options (main); declare command_line character (100) varying;   ...   end program;  
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.)
#Fish
Fish
v This is the Fish version of the Integer sequence task >0>:n1+v all comments here ^o" "< still here And of course here :)
http://rosettacode.org/wiki/Comments
Comments
Task Show all ways to include text in a language source file that's completely ignored by the compiler or interpreter. Related tasks   Documentation   Here_document See also   Wikipedia   xkcd (Humor: hand gesture denoting // for "commenting out" people.)
#Forth
Forth
\ The backslash skips everything else on the line ( The left paren skips everything up to the next right paren on the same 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...
#MATLAB
MATLAB
life
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 ...
#Erlang
Erlang
case X of {N,M} when N > M -> M; {N,M} when N < M -> N; _ -> equal end.
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...
#VBA
VBA
  Private Function IsEqualOrAscending(myList) As String Dim i&, boolEqual As Boolean, boolAsc As Boolean   On Error Resume Next If UBound(myList) > 0 Then If Err.Number > 0 Then IsEqualOrAscending = "Error " & Err.Number & " : Empty array" On Error GoTo 0 Exit Functio...
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...
#VBScript
VBScript
  Function string_compare(arr) lexical = "Pass" ascending = "Pass" For i = 0 To UBound(arr) If i+1 <= UBound(arr) Then If arr(i) <> arr(i+1) Then lexical = "Fail" End If If arr(i) >= arr(i+1) Then ascending = "Fail" End If End If Next string_compare = "List: " & Join(arr,",") & vbCrLf &_ ...
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...
#Objeck
Objeck
class Quibbler { function : Quibble(words : String[]) ~ String { text := "{";   each(i : words) { text += words[i]; if(i < words->Size() - 2) { text += ", "; } else if(i = words->Size() - 2) { text += " and "; }; }; text += "}";   return text; }   ...
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...
#Swift
Swift
func combosWithRep<T>(var objects: [T], n: Int) -> [[T]] { if n == 0 { return [[]] } else { var combos = [[T]]() while let element = objects.last { combos.appendContentsOf(combosWithRep(objects, n: n - 1).map{ $0 + [element] }) objects.removeLast() } return combos } } print(combosWithRep...
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...
#Tcl
Tcl
package require Tcl 8.5 proc combrepl {set n {presorted no}} { if {!$presorted} { set set [lsort $set] } if {[incr n 0] < 1} { return {} } elseif {$n < 2} { return $set } # Recursive call set res [combrepl $set [incr n -1] yes] set result {} foreach item $set { foreach inn...
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...
#Wren
Wren
import "/dynamic" for Enum, Struct, Tuple import "/str" for Char import "/fmt" for Fmt import "/ioutil" for FileUtil import "os" for Process   var tokens = [ "EOI", "Mul", "Div", "Mod", "Add", "Sub", "Negate", "Not", "Lss", "Leq", "Gtr", "Geq", "Eq", "Neq", "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"
#Pop11
Pop11
lvars arg; for arg in poparglist do printf(arg, '->%s<-\n'); endfor;
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"
#PowerBASIC
PowerBASIC
? "args: '"; COMMAND$; "'"