HeaderVariable declarationConstant declarationFunction declarationLambda declarationWhile loopFor loopForeach loopDo .. while loopForeach index and element loopInfinite loopif ... else if ... elseTernary operatorTry ... CatchSwitchType of the %Top level constructorGet a line of STDINGet all STDINGet a char STDINPrint without a new line at the endPrint with a new line at the endImplicit conversion of bool to intImplicit conversion of char to intFormat a stringTemplate stringThree-Way operator
APLs←'a variable'∇ return←a_function argumenta_lambda←{⍵}:While b ... :EndWhile {...}⍣{~b}⍣b:For i :In ⍳n ... :EndFor {...}¨⍳n:For i :In a_list ... :EndFor {...}¨a_list:Repeat ... :Until ~b {...}⍣{~b}:ForEach i elem :In (⍳≢a_list) a_list ... :EndFor a_list{...}¨⍳≢a_list:Repeat ... :EndRepeat {...}⍣{0}:If b1 ... :ElseIf b2 ... :EndIf { b1:... b2:... ... }{ b: _true _false }:Trap 0 ... :Else ... :EndTrap { 0::... ... }:Select x :Case y ... :Else ... :EndSelect { x≡y:... ... }Floored x%y in APL is y|x⍞ ⎕{1005::r ⋄ ∇ r,←⊂⍞}r←0⍴⊂''⍞←s⎕←s⍕n 'format_string'⎕FMT n-⍤×
Cchar *s = "a variable"const char *s = "a constant"type a_function(type argument){ return argument; }while (b){...}for(int i = 0; i < n; i++){...}do{ ... }while (b)for(;;){...}if(b1){ ... } else if (b2) { ... } else { ... }b ? _true : _falseswitch (x){ case y: ... break; default: ... break; }Truncatedmain(){}scanf("%s",&s)getchar()printf("%s",s)printf("%s ",s)sprintf("%s",s)
C++auto s = "a variable"const auto s = "a constant"type a_function(type argument){ return argument; }while (b){...}for(int i = 0; i < n; i++){...}for(auto c:s){...}do{ ... }while (b)for(;;){...}if(b1){ ... } else if (b2) { ... } else { ... }b ? _true : _falseswitch (x){ case y: ... break; default: ... break; }Truncatedint main(){}scanf("%s",&s) std::cin >> s;getchar()printf("%s",s) std::cout << s;printf("%s\n",s) std::cout << s << "\n";sprintf("%s",s)<=>
C#string s = "a variable"const string s = "a constant"type AFunction(type argument) { return argument; }arg => argwhile (b) {...}for (int i = 0; i < n; i++) {...}foreach (var c in s) {...}do { ... } while (b)for (;;) {...}if (b1) { ... } else if (b2) { ... } else { ... }b ? _true : _falsetry { ... } catch (Exception e) { ... }switch (x) { case y: ... break; default: ... break; }Truncatedclass P {static void Main() {...}} However, it's not needed as top-level statements are supported.Console.ReadLine()Console.Read()Console.Write(s)Console.WriteLine(s)String.Format("{0}", s)$"{var1}, {var2}"
Clojure(def s "a variable")(def ^:const s "a constant")(defn f [arg] arg)(fn [arg] arg) #(...) ; Lambda where % is 1st arg, %2 is 2nd, etc.(while b (...))(dotimes [i n] (...))(doseq [c s] (...))(loop [] (...) (when b (recur)))(while true (...))(if b1 (...) (if b2 (...) (...))) (cond b1 (...) b2 (...) :else (...))(try (...) (catch Exception e (...)))(case x y (...) (default))(mod a b) - Floored (rem a b) - Truncated(read-line)(slurp *in*)(print s)(println s)(format "%s" s)(compare a b)
Gos := "a variable"const s = "a constant"func aFunction(argument type) { return argument }func(argument type) { return argument }for b {...}for i := 0; i < n; i++ {...}for _, c := range s {...}for idx, c := range s {...}for {...}if b1 { ... } else if b2 { ... } else { ... }switch x { case y: ... default: ... }Truncatedfunc main() {}import "fmt" var s string fmt.Scan(&s)import "os" import "io" io.ReadAll(os.Stdin)import "fmt" fmt.Print(s)import "fmt" fmt.Println(s)import "fmt" Sprintf("%s", s)
JavaString s = "a variable"final String s = "a constant"type aFunction(type argument) { return argument; }arg -> argwhile (b) {...}for (int i = 0; i < n; i++) {...}for (var c : s) {...}do { ... } while (b)for (;;) {...}if (b1) { ... } else if (b2) { ... } else { ... }b ? _true : _falsetry { ... } catch (Exception e) { ... }switch (x) { case y: ... break; default: ... break; }Truncatedinterface prog {static void main(String[] args) {...}}new java.util.Scanner(System.in).nextLine()System.in.read()System.out.print(s)System.out.println(s)String.format("%s", s)a.compareTo(b)
JavaScriptlet s = "a variable" var s = "a variable" s = "a variable"const s = "a constant"function a_function(argument){ return argument }a_lambda = argument => argumentwhile (b){...}for(let i = 0; i < n; i++){...}for (const elem of a_list){...}do{ ... }while (b)for(;;){...}if(b1){ ... } else if (b2) { ... } else { ... }b ? _true : _falsetry { ... } catch (e) { ... }switch (x){ case y: ... break; default: ... break; }Truncatedprompt()process.stdout.write(s)console.log(s)`${var1}, ${var2}`
Julias = "a variable"const s = "a constant"function a_function(argument) argument enda_lambda = argument -> argumentwhile b ... endfor i = 0:n-1 ... endfor elem in a_list ... endfor (i, elem) in enumerate(a_list) ... endwhile true ... endif b1 ... elseif b2 ... else ... endb ? _true : _falsetry ... catch e ... endTruncatedreadline()readlines()read(stdin, Char)print(s)println(s)@sprintf "%d" n"$var1, $var2"
Kotlinvar s = "a variable"val s = "a constant"fun <T> a_function(argument: T): T = argumenta_lambda = {argument -> argument}while (b) { ... }for (i in 0 til n) { ... }for (elem in a_list) { ... }do { ... } while (b)for ((i, elem) in a_list.withIndex()) { ... }while (true) { ... }if (b1) { ... } else if (b2) { ... } else { ... }if (b) _true else _falsetry { ... } catch (e: Exception) { ... }when (x) { y -> ... else -> ... }Truncatedfun main() { ... }readln()generateSequence(::readLine)System.`in`.read()print(s)println(s)"%d".format(n)"$var1, $var2"a.compareTo(b)
Lualocal s = "a variable"local s <const> = "a constant"function aFunction (argument) return argument endaLambda = function(argument) return argument endwhile b do ... endfor i = 0, n-1 do ... endfor _, elem in ipairs(aList) ... endrepeat ... until not bfor idx, elem in ipairs(aList) ... endwhile true ... endif b1 then ... elseif b2 then ... else ... endFlooredio.read()io.read("*a")io.read(1)io.write(s)print(s)string.format("%d", n)
OCamllet s = ref "a variable"let s = "a constant"let a_function argument = argumentlet a_lambda = fun argument -> argumentwhile b do ... donefor i = 0 to n - 1 do ... donefor elem in a_list do ... doneList.iteri (fun i elem -> ...) a_listwhile true do ... doneif b1 then ... else if b2 then ... else ...if b then _true else _falsetry ... with e -> ...match x with | y -> ... | _ -> ...Truncatedread_line()input_char stdinprint_string sprint_endline sPrintf.sprintf "%d" ncompare a b
PHP$s = "a variable"define("S", "a constant")function a_function($argument) { return $argument; }$a_lambda = function ($argument) { return $argument; }while ($b) {...}for ($i = 0; $i < $n; $i++) {...}foreach ($arr as $e) {...}do { ... } while ($b)foreach ($arr as $idx => $e) {...}for (;;) {...}if ($b1) { ... } elseif ($b2) { ... } else { ... }$b ? $true : $falsetry { ... } catch (Exception $e) { ... }switch ($x) { case $y: ... break; default: ... break; }Truncated<? else it's HTMLfgets(STDIN)`dd`fgetc(STDIN)echo $s ?><?= $s (if it's at the end)echo "$s\n" ?><?= "$s\n" (if it's at the end)sprintf("%s", $s)"$var {$expr}"<=>
Pythons = "a variable"def a_function(argument): return argumenta_lambda = lambda argument: argumentwhile b: ...for i in range(n): ...for i in a_list: ...for i,elem in enumerate(a_list): ...while 1: ...if b1: ... elif b2: ... else: ..._true if b else _false [_false, _true][b]try: ... except: ...match x: case y: ... case _: ...Flooredinput()open(0).read()print(s, end='')print(s)'%i'%nf'{var1}, {var2}'
Rakumy $s = "a variable"constant $s = "a constant"sub a_function($argument) { return $argument; }my $a_lambda = -> $argument {$argument};while $b { ... }for 0..$n-1 -> $i { ... }for @a_list -> $elem { say $elem; }for @a_list.kv -> $idx, $elem { say $elem; }loop{...}if $b1 { ... } elsif $b2 { ... } else { ... }$b ?? $true !! $falsegiven $x { when $y { ... } default { ... } }Flooredgetslurpgetcprint $ssay s put ssprintf("%s", $s)"$var1, $var2"<=>
Rubys = "a variable"S = "a constant"def a_function(argument) argument enda_lambda = -> argument{argument}while b do ... endfor i in 0...n (0...n).each { |i| ...}for i in a_list a_list.each {|elem| ...}begin ... end while ba_list.each_with_index {|elem, idx| ...}loop{...}if b1 ... elsif b2 ... else ... endb ? _true : _falsebegin ... rescue ... endcase x when y ... else ... endFlooredgets$<$<.getcprint s $><<sputs s p s'%i'%n"#{var1}, #{var2}"<=>
Sass$s: "a variable"@function a_function($argument){ @return argument; }@while $b { ... }@for $i from 0 to n { ... }@each $e in a_list { ... }@while 1{...}@if $b1 { ... } @else if $b2 { ... } @else { ... }if($b, $true, $false)get();see();getc();@debug"#{$var1}, #{$var2}"
Vyxal`a variable` →s@a_function:argument|←argument; @a_function:1|;λcode; →a_lambda{b|...}←n(...) ←n(i|...)←a_list(...)|←a_list(elem|...)←a_list ė(n÷) ←a_list ¨2...;{...}←b1 [...|←b2[...|...]]"i ¨i<truthyElement><falseyElement>Floored?,`%`%←var1 ←var2 `Π, Π`