Header | Variable declaration | Constant declaration | Function declaration | Lambda declaration | While loop | For loop | Foreach loop | Do .. while loop | Foreach index and element loop | Infinite loop | if ... else if ... else | Ternary operator | Try ... Catch | Switch | Type of the % | Top level constructor | Get a line of STDIN | Get all STDIN | Get a char STDIN | Print without a new line at the end | Print with a new line at the end | Implicit conversion of bool to int | Implicit conversion of char to int | Format a string | Template string | Three-Way operator |
---|
APL | s←'a variable' | | ∇ return←a_function argument | a_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 | | -⍤× |
C | char *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 : _false | | switch (x){
case y:
...
break;
default:
...
break;
} | Truncated | main(){} | 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 : _false | | switch (x){
case y:
...
break;
default:
...
break;
} | Truncated | int 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 => arg | while (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 : _false | try {
...
} catch (Exception e) {
...
} | switch (x) {
case y:
...
break;
default:
...
break;
} | Truncated | class 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) |
Go | s := "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:
...
} | Truncated | func 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) | | |
Java | String s = "a variable" | final String s = "a constant" | type aFunction(type argument) {
return argument;
} | arg -> arg | while (b) {...} | for (int i = 0; i < n; i++) {...} | for (var c : s) {...} | do {
...
} while (b) | | for (;;) {...} | if (b1) {
...
} else if (b2) {
...
} else {
...
} | b ? _true : _false | try {
...
} catch (Exception e) {
...
} | switch (x) {
case y:
...
break;
default:
...
break;
} | Truncated | interface 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) |
JavaScript | let s = "a variable"
var s = "a variable"
s = "a variable" | const s = "a constant" | function a_function(argument){
return argument
} | a_lambda = argument => argument | while (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 : _false | try {
...
} catch (e) {
...
} | switch (x){
case y:
...
break;
default:
...
break;
} | Truncated | | prompt() | | | process.stdout.write(s) | console.log(s) | | | | `${var1}, ${var2}` | |
Julia | s = "a variable" | const s = "a constant" | function a_function(argument)
argument
end | a_lambda = argument -> argument | while b
...
end | for i = 0:n-1
...
end | for elem in a_list
...
end | | for (i, elem) in enumerate(a_list)
...
end | while true
...
end | if b1
...
elseif b2
...
else
...
end | b ? _true : _false | try
...
catch e
...
end | | Truncated | | readline() | readlines() | read(stdin, Char) | print(s) | println(s) | | | @sprintf "%d" n | "$var1, $var2" | |
Kotlin | var s = "a variable" | val s = "a constant" | fun <T> a_function(argument: T): T = argument | a_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 _false | try {
...
} catch (e: Exception) {
...
} | when (x) {
y -> ...
else -> ...
} | Truncated | fun main() {
...
} | readln() | generateSequence(::readLine) | System.`in`.read() | print(s) | println(s) | | | "%d".format(n) | "$var1, $var2" | a.compareTo(b) |
Lua | local s = "a variable" | local s <const> = "a constant" | function aFunction (argument)
return argument
end | aLambda = function(argument)
return argument
end | while b do
...
end | for i = 0, n-1 do
...
end | for _, elem in ipairs(aList)
...
end | repeat
...
until not b | for idx, elem in ipairs(aList)
...
end | while true
...
end | if b1 then
...
elseif b2 then
...
else
...
end | | | | Floored | | io.read() | io.read("*a") | io.read(1) | io.write(s) | print(s) | | | string.format("%d", n) | | |
OCaml | let s = ref "a variable" | let s = "a constant" | let a_function argument = argument | let a_lambda = fun argument -> argument | while b do
...
done | for i = 0 to n - 1 do
...
done | for elem in a_list do
...
done | | List.iteri (fun i elem -> ...) a_list | while true do
...
done | if b1 then
...
else if b2 then
...
else
... | if b then _true else _false | try
...
with e ->
... | match x with | y -> ... | _ -> ... | Truncated | | read_line() | | input_char stdin | print_string s | print_endline s | | | Printf.sprintf "%d" n | | compare 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 : $false | try {
...
} catch (Exception $e) {
...
} | switch ($x) {
case $y:
...
break;
default:
...
break;
} | Truncated | <? else it's HTML | fgets(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}" | <=> |
Python | s = "a variable" | | def a_function(argument):
return argument | a_lambda = lambda argument: argument | while 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 _:
... | Floored | | input() | open(0).read() | | print(s, end='') | print(s) | | | '%i'%n | f'{var1}, {var2}' | |
Raku | my $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 !! $false | | given $x {
when $y { ... }
default { ... }
} | Floored | | get | slurp | getc | print $s | say s
put s | | | sprintf("%s", $s) | "$var1, $var2" | <=> |
Ruby | s = "a variable" | S = "a constant" | def a_function(argument)
argument
end | a_lambda = -> argument{argument} | while b do
...
end | for i in 0...n
(0...n).each { |i| ...} | for i in a_list
a_list.each {|elem| ...} | begin
...
end while b | a_list.each_with_index {|elem, idx| ...} | loop{...} | if b1
...
elsif b2
...
else
...
end | b ? _true : _false | begin
...
rescue
...
end | case x
when y
...
else
...
end | Floored | | gets | $< | $<.getc | print s
$><<s | puts 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 `Π, Π` | -± |