User:Mike92591/CoPL, expressions
Appearance
Arithmetic
[edit]Integer
[edit]a+b | a-b | a*b | a/b | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Integer | Floating point | Complex | Integer | Floating point | Complex | Integer | Floating point | Complex | Integer | Floating point | Complex | |
C (C99) | ||||||||||||
C++ (STL) | ||||||||||||
C# | ||||||||||||
Java | ||||||||||||
Objective-C | ||||||||||||
Common Lisp | ||||||||||||
Scheme | ||||||||||||
Pascal | ||||||||||||
Visual Basic | ||||||||||||
Visual Basic .NET | ||||||||||||
Perl | ||||||||||||
Python | ||||||||||||
JavaScript | — | — | — | — | ||||||||
S-Lang | ||||||||||||
FORTRAN 77 | ||||||||||||
Ruby | ||||||||||||
Windows PowerShell | ||||||||||||
OCaml | add a b | sub a b | mul a b | div a b | ||||||||
Standard ML | ||||||||||||
Haskell (GHC) | a :+ b |
Complex
[edit]lib | basic | i | |
---|---|---|---|
C (C99) | #include <complex.h> | ||
C++ (STL) | |||
C# | |||
Java | |||
Objective-C | |||
Common Lisp | #C(re im) or (complex re im) |
||
Scheme | ni | ||
Pascal | |||
Visual Basic | |||
Visual Basic .NET | |||
Perl | use Math::Complex; | cplx(re, im) | i |
Python | complex(re, im) | nj | |
JavaScript | — | — | — |
S-Lang | ni or nj | ||
FORTRAN 77 | |||
Ruby | require "complex" | Complex(re, im) | n.im |
Windows PowerShell | |||
OCaml [1] | open Complex;; | let x = { re = re; im = im } | i |
Standard ML | |||
Haskell (GHC) | import Complex |
Conditional expressions
[edit]Pattern matching | conditional expression | |
---|---|---|
C (C99) | — | condition ? valueIfTrue : valueIfFalse |
Objective-C | ||
C++ (STL) | ||
Java | ||
JavaScript | ||
PHP | ||
C# | ||
Windows PowerShell | ||
Perl | condition ? valueIfTrue : valueIfFalse | |
Ruby | ||
Common Lisp | (if condition valueIfTrue valueIfFalse) | |
Scheme | ||
Pascal | ||
Visual Basic | IIf(condition, valueIfTrue, valueIfFalse) | |
Visual Basic .NET | If(condition, valueIfTrue, valueIfFalse) | |
Python | — | valueIfTrue if condition else valueIfFalse |
S-Lang | ||
FORTRAN 77 | ||
Forth | condition IF valueIfTrue ELSE valueIfFalse THEN | |
OCaml | match value with
| pattern2 -> expression ... «| _ -> expression»[a] |
if condition then valueIfTrue else valueIfFalse |
F# | ||
Standard ML | case value of
| pattern2 => expression ... «| _ => expression»[a] | |
Haskell (GHC) | case value of {
pattern2 -> expression; ... «_ -> expression» | |
select case | conditional expression |
^a This is pattern matching and is similar to select case but not the same. It is usually used to deconstruct algebraic data types.