QuantumGolf

From Esolang
Jump to navigation Jump to search

QuantumGolf is a QOO-OOKALAN extension for even shorter codes.

Language Addictions

Basic Syntax

 // Assignment returns value (like JavaScript)
 x = 5        // Assigns 5 to x, returns 5
 // Implicit output: last expression is printed
 x + 3        // If this is the final command, outputs 8 when x=5
 // Instant casting
 out 1        // Outputs '1' (automatically converted to string)
 out "1"      // Outputs '1'

Special Commands

QuantumGolf Commands
QuantumGolf Python Description
# N/A The line executes in reversed order instead of standard order
a>b range(a, b) Range shorthand for ..
a..b range(a, b) Range list generation
in in Like Python's in keyword, but after counted-based loop can define bounds
@ in Shortened membership keyword
x%%y x % y == 0 Checks if x is multiple of y
c Custom Chooses which value a is multiple of, otherwise returns nothing
s~b,c s[b-1:c] String slicing (1-indexed) from b to c
out s print(s) Printing function
~code~ exec("code") Shorthand for dynamic execute.
n*v v = n Creates anonymous variable that only exists in current line
cn n * c Multiplication golfing (c must be constant, n must be variable)
Omitting assignment Custom Uses system register for temporary storage when result omitted
! None Null value
~n n + 1 Returns n+1 (increment)
`n n - 1 Returns n-1 (decrement)
^n n % 2 Returns n mod 2
array\n array[n] Quick array item selection
c&code Custom Chooses value a is multiple of, otherwise executes code
func param1,param2 func(param1, param2) No parentheses needed for function calls
module import module Module importing
param => expr lambda param: expr Arrow syntax for lambdas
func`arg Custom Tagged function calls
a op= b a = a op b Compound assignment operators
Implicit output Custom Final expression result is automatically printed
Instant casting Custom Automatic type conversion in assignments and output

Notes

  • Functions can be called with less or more parameters than definition and unvalued parameters is None.