H - Q -

From Esolang
Jump to navigation Jump to search

H - Q - is a golfing language based on 05AB1E, GolfScript and HQ9+.
Feel free to add any instructions you want, but please follow these rules:

  • Add your username (unless the instruction is added by me)
  • Please don't add any implementation-defined/UB instructions.
  • Please stick to the format.


   Type        How to push              Notes
   Number      123.45                   Numbers are 64-bit floating-point values.        
               456_ (negative values)
   String      "Hello, World!"          Escape codes are ¶ (newline),  → (tab), · (vertical tab), ← (backspace) and \xxxx (2/4/6 character unicode escape). 
               'Hello, World!'          Use \ to escape these characters (including quotes and the \ itself)
               ′f (one char string)

Numbers and strings are equal types, which means one will be converted into the other if the data is in the wrong type.


   H - Push "Hello World" on stack (by User:LEOMOK)
   Q - Push "Q" (I'm sorry)
   N - Push lyrics of "99 bottles of beer"
   Í - Infinity (=1/0)
   Ñ - NaN (=0/0)
   P - Pi
   E - Euler's Number
   + - Pop a, b, push b plus a.
   , - Pop a, b, push b concatenated to a.
   - - Pop a, b, push b minus a.
   * - Pop a, b, push b times a.
   × - Pop a, b, push b repeated a times.
   / - Pop a, b, push b divided by a (float division).
   ÷ - Pop a, b, push b integer divided by a.
   % - Pop a, b, push b remainder a.
   : - Pop a, b, push b to the power of a.
   √ - Pop a, push square root of a.
   ; - Pop a, b, push log base b of a.
   i - Same as 1+.
   d - Same as 1-.
   _ - Negate top of stack.
   a - Pop a, push absolute value of a.
   f - Pop a, push floor of a.
   c - Pop a, push ceiling of a.
   p - Pop a, push -1 if a is prime, else 0.
   \ - Pop a, b, push character at position a of b.
   l - Pop a, push length of a.
   j - Pop a, b, push integer indicating first instance of a in b.
   s - Pop a, b, c, push all characters between positions a and b of c.
   v - Pop a, b, c, push c with all b's replaced by a.
   [ - Pop a, push Unicode of a.
   ] - Pop a, push Unicode character with value a.
   { - Pop a, b, push string representation of a in base b.
   } - Pop a, b, parse a in base b, then push the result.
   ( - Same as 10{.
   ) - Same as 10}.
   = - Pop a, b, push -1 if b equals a, else 0 (NaN is equal to NaN).
   < - Same as =, but greater than.
   > - Same as =, but less than.
   & - Pop a, b, push bitwise and of a and b.
   | - Same as &, but bitwise or.
   ^ - Same as &, but bitwise xor.
   ~ - Pop a, push bitwise not of a.
   Σ - Sum up the whole stack.
   Π - Multiply up the whole stack.
   R - Pop a, b, push random integer between a and b (both included)
   ¿ - Push random floating point number between 0 and 1.
   r - Pop a, b, push integers from a to b onto stack.
   Stack manipulation
   D - Duplicate top value of stack.
   Đ - Pop a, b, push a b times.
   V - Pop.
   S - Swap.
   Š - Pop a, reverse the top a items.
   W - Pop a, dup the a stack item.
   Ŵ - Pop a, swap the a and top stack items
   Ř - Reverse the stack.
   ↑ - Move bottom value up.
   ↓ - Move top value down.
   ` - Do the next instruction without popping the stack 
   Control Flow
   $ - Pop string, then run as code.
   J - If statement. Pop a, b, if a is true (not zero, empty or NaN), run b.
   ? - If Else statement. Pop a, b, c, if a is true, run b, else run c.
   F - For loop, pop a and b, run b for (C=0, C<a+1, C++)
   W - While loop, pop b, run b until top of stack is false.
   T - Try catch. Pop a, b, if an error occurs while running a, run b instead.
   @ - Reduce. Pop a, run it until it can't be done anymore.
   Ï - Infinite loop. Pop a, run a forever.
   Č - Pop a, eval as JavaScript code, and push the stringified result.
   ß - Break out of loop (end program if not in loop)
   Þ - Loop continue.
   C - Loop counter.
   Input and output
   O - Print top of stack with a newline.
   Ø - Print top of stack without a newline.
   I - Push the next line of input.
   Ĭ - Pop a, open file named a
   Ö - Pop a, b, write b to last opened file and close it
   Implicit input: The first line of input is pushed to the stack.
   Implicit output: if nothing is printed when the program ends, print the pop of the stack.
   ← - Pop a, b, set variable named b to a.
   → - Pop a, push value of variable named a. All variables are set to empty string on default.
   Ṝ - Push the lyrics of https://www.youtube.com/watch?v=dQw4w9WgXcQ.

Version 2 adds a standard library (Å) and these commands:

   Π- Pop from the stack and push to the clipboard.
   œ - Pop from the clipboard and push to the stack.
   « - Pop a, b, push a left shifted by b.
   » - Pop a, b, push a right shifted by b
   ÅE - Pop a, write a to stderr.
   ÅN - Apply JS isNaN to top stack value. Equivalent to )Ñ=
   Åe - Push Number.EPSILON.
   ÅM - Push Number.MAX_SAFE_INTEGER.
   Åm - Push Number.MAX_VALUE.



(Fizzbuzz until input value)


(Collatz sequence starting from input value)

   1 0"`O`+"IF

(Fibonacci sequence until input value)


(Factorial of input value)




(Another quine)


(A third quine)

(Whatever you do, DON'T RUN THIS)