User:RaiseAfloppaFan3925/Sandbox

From Esolang
Jump to navigation Jump to search

Hi welcome to my sandbox :D

Here, you might see some of my private languages Just experimenting with stuff.

Redshift

Shift everything away.

Commands

Command Action Example Memory Layout
lda Stores the cell at the pointer in Register A. self-explanatory
ldb Stores the cell at the pointer in Register B. self-explanatory
swap Swaps Register A and Register B. self-explanatory
sta Stores the value in Register A in the cell at the pointer. self-explanatory
stb Stores the value in Register B in the cell at the pointer. self-explanatory
si Copies the memory unit at absolute byte address N from the program memory into the current memory cell. si byte 0 Has options byte, short, word, and quad, which take up an extra byte
li Loads the current memory cell into the memory unit at absolute byte address N. li quad 8 Has options byte, short, word, and quad, which take up an extra byte
ica Increment the A register self-explanatory
icb Increment the B register self-explanatory
dca Decrement the A register self-explanatory
dcb Decrement the B register self-explanatory
add Adds A and B and stores the result in A. self-explanatory
sub Subtracts B from A (A - B) and stores the result in A. self-explanatory
shl Left-shifts the value in A by B bits. self-explanatory
shr Right-shifts the value in A by B bits. self-explanatory
up, down, left, right Moves the cell pointer in their respective directions. self-explanatory
in Takes in a UTF-32 character as input. self-explanatory
out Outputs the current cell as a UTF-32 character. self-explanatory
ge Sets the GE flag if A is greater than B. self-explanatory
sg Sets the GE flag unconditionally. self-explanatory
cg Clears the GE flag. self-explanatory
jge Jumps to the Nth byte, starting at zero. N is an absolute address. jge 5 jumps to the 6th BYTE, not instruction. 1 byte (instruction) followed by 16 bytes (target address)

Memory

Memory is stored in the form of a grid which is constantly expanding from the first memory cell at the "speed of light". The expansion follows Hubble's law, so cells farther from the pointer will move away faster than cells closer to the pointer.

Time 0 (pointer is represented with P)

A y 0 0 B
x a X b 0
0 Y P Z 0
0 c W d z
C 0 0 w D

Time 1
A 0 y 0 0 0 0 0 B
0 0 0 0 0 0 0 0 0
x 0 a 0 X 0 b 0 0
0 0 0 0 0 0 0 0 0
0 0 Y 0 P 0 Z 0 0
0 0 0 0 0 0 0 0 0
0 0 c 0 W 0 d 0 z
0 0 0 0 0 0 0 0 0
C 0 0 0 0 0 w 0 D

The pointer moves faster than the speed of light, so any memory location is accessible.

Examples

Infinite loop

sg
jge 1

With assembler extensions

sg
jge $

XKCD Random Number

ica
icb
add
; a = 2, b = 1
swap ; a = 1, b = 2
add
ica ; a = 4, b = 2
swap ; a = 2, b = 4
ica ; a = 3, b = 4
shl ; a = 48, b = 4
add ; a = 52
out ; '4'

Assembler Extensions

Redshift can be thought of as an assembly language, and so can have some extensions to the assembler. These only alter the syntax of the language, not the underlying behavior.

Base Extensions
Command Action Example Notes
$ The current absolute address. self-explanatory Address is in bytes, since some instructions (like jge) are multi-byte.
Labels (text followed by a colon) Gives an absolute memory address. label:

Redshift-A

Redshift-A is a higher-level version of Redshift with some syntactic abstractions. It compiles to Redshift.

Redshift-A Examples

Infinite Loop

while true do end

Generated Redshift

cg
jge 1

XKCD Random Number

store 52 ; same as setting a to 52 and storing a
out cell

Generated Redshift

ica (repeated 51 more times)
out

Hailstone

This is a draft for a WIP esolang (the esolang itself)

Hailstone is an esolang made by User:RaiseAfloppaFan3925 in January 2026.

Memory

Hailstone uses both variables and a stack.

Data types

Hailstone has a few core data types.

"Nullable" tri-states

Hailstone does not have traditional booleans, instead "nullable" tri-states. They have three valid states and one "null" state, @_@ (the null tri-state), which represents no valid choice.

The tri-states are ^v^, -_-, and =_=.

Integers

Hailstone has arbitrary-precision integers. Numbers can be written with either decimal or base-62. Base-62 literals must start with a leading zero.

 0123456789
00123456789
1ABCDEFGHIJ
2KLMNOPQRST
3UVWXYZabcd
4efghijklmn
5opqrstuvwx
6yz

Examples of numeric literals

12 /* 12 */
0a /* 10 */
010 /* 62 */
06T /* 401 */
0verycool /* 203053492849283 */
0isntthisamazing /* 556640392080993526278449680 */
0KASANETETO /* 273024326477340654 */

Floats

Floating-point values are written exclusively in base-62 starting with a & with a & for the decimal point. The decimal part is written like a normal base-62 number.

&1 /* 1 / 62 = 0.01612903... */
&D /* 31 / 62 = 0.5 */
&z /* 61 / 62 = 0.983870967... */
&1& /* 1 */
&3&tnbCOm /* approx. 3.9 (3.8999999999876761...) */
&3&8mHUcx /* approx. pi (3.141592653841159...) */

Strings

Strings are just strings. However, arithmetic and bitwise operations can be performed on them. Arithmetic and bitwise operations on strings operate on them as if they were giant hexadecimal numbers made of their UTF-32 codepoints. For example, the string "ABC" would be 0x000000410000004200000043.

Below is an example of abusing bitwise operations on strings.

str <- "ABC"
${str 64 ^ . | 言え} /* "A" */
${str 32 ^ | 言え} /* "B" */
${str 04gfFC3 . | 言え} /* "C" */
${'\n' | 言え}

Functions

See #Functions for a full description.

Functions are first-class values. The only operation that can be performed on a function is calling it.

factorial <- [
  n 2 <=> :?
    ^v^ [n n 1 - # *]<>
    =_= | -_- | @_@ [1]<>
  ?:
]<n>

Operators

Operators operate on the stack.

Relational operator

The relational operator or two-way arrow, is the comparison operator. It takes in two values and returns ^v^ if the first value is greater than the second, -_- if the first value is less than the second, =_= if both values are equal, and @_@ if both values cannot be compared.

a b <=>

Arithmetic operators

The arithmetic operators are + for addition, - for subtraction, * for multiplication, / for division, and % for modulo. If the operation cannot be performed on the two values, then @_@ is returned.

a b +
a b -
a b *
a b /
a b %

Bitwise operators

The bitwise operators are ~ for bitwise NOT, . for bitwise AND, : for bitwise OR, ; for bitwise XOR, ` for left shift, and ^ for right shift. Just like the arithmetic operators, they return @_@ if the operation cannot be performed.

x ~
a b .
a b :
a b ;
a b `
a b ^

Logical operators

The logical operators are ,. for logical AND and ,: for logical OR. Logical NOT doesn't exist because the "boolean" type is the nullable tri-state.

a b ,.
a b ,:

Variables

Defining and assigning to a variable both use the same syntax.

variable <- value

Functions

Functions are first-class values that can be created with this syntax

[body]<parameters>

To call a function, the "pipeline shell substitution" syntax should be used.

${arg1 arg2 arg3 | f}

Pipeline shell substitutions can be chained by simply adding more pipes. For example, h(g(f(x))) is written as:

${x | f | g | h}

A function can call itself using the # symbol. If # is used at the top level (outside of any function), it restarts the script but with the environment parameters replaced with whatever arguments were passed into it, if any.

This program is an infinite loop, as # calls the script it is in and never terminates.

#

I/O

Hailstone has two functions for I/O, 尋ねろ and 言え.

言え is used for printing and accepts an unlimited number of arguments. 言え is the only function that can accept an unlimited number of arguments. However, it does NOT print a newline.

x <- "x"
y <- ["y"]<>
z <- [["z"]<>]<>
${123 "abc" 'strings can use single quotes too' x ${y} ${${z}} '\n' | 言え}

尋ねろ is used for receiving user input. It can take either a variable where it stores the user input as a string, or nothing where it simply pushes the input to the stack.

x <- ${尋ねろ}

x <- ''
${x | 尋ねろ}

Pattern matching

Pattern matching is done with a :? ?: block. It takes the current stack top and matches it against a set of patterns. If a pattern is matched, then the function after it is called. ? matches any value that does not match any of the previous patterns.

x <- ''
${x | 尋ねろ}
x <- ${x | int}
x :?
  3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 |
    19 | 21 | 23 | 25 | 27 | 29 | 31
    [${'odd' | 言え}]<>
  2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 |
    18 | 20 | 22 | 24 | 26 | 28 | 30
    [${'even' | 言え}]<>
  ? [${'what is ' x | 言え}]<>
?:

Examples

Truth machine

val <- ''
${尋ねろ | val}
val '0' <=> :?
  ^v^ | -_- [${1 | 言え} #]<>
  =_= | [${0 | 言え}]<>
?:

Factorial (recursive)

fac <- [
  n 2 <=> :?
    ^v^ [n ${n 1 - | fac} *]<>
    =_= | -_- [1]<>
  ?:
]<n>

Simpler factorial

[
  n 2 <=> :?
    ^v^ [n ${n\ | #} *]<>
    =_= | -_- [1]<>
  ?:
]<n>

Golfed factorial (44 bytes)

[n 2<=>:?^v^[n${n 1-|#}]<>=_=|-_-[1]<>?:]<n>

Uiua page draft

DISCLAIMER: If you have come here to view the Uiua page, this is NOT the place. This is just a DRAFT.
This is my first time contributing to a page and it's likely to change around 5 KB or more of data so I'll do it in my sandbox
This draft is a stub

Year: 2023 (possibly earlier? first Git commit is Feb 27, 2023)

Reference implementation: uiua-lang/uiua

Influenced by: APL, J

Categories: 2023, Languages, Implemented, APL-like, Graphical Output, Audio Output

How do you safely pull information from official documentation?

Uiua is a tacit array programming language being developed since September 2023 [1] or earlier. [2]

Functions

Most built-in functions in Uiua use special Unicode characters. Alternatively, built-in functions also have names that can be used instead of Unicode characters. The built-in formatter automatically converts these names into Unicode characters.

Constants

Constants in Uiua are functions that return a constant value.

Commands Symbol Action Notes
eta η The number of radians in a quarter circle, equivalent to pi divided by 4
pi π The value of pi (3.14159265358979...)
tau τ The value of tau (6.28...), equivalent to 2 times pi
infinity The biggest number

Monadic functions

Monadic functions are functions that operate on a single array.

Function Symbol Action Example Note
box Turns an array into a box. A box is a container that can contain objects of any type. All boxes, regardless of their contents, are considered the same type. This allows mixed-type arrays. ° un □ box can be used to retrieve the contents of a box. TBA A shorthand syntax for an array full of boxes is curly braces ({}).

Modifiers

Modifiers are special functions that modify the behavior of an array.

Modifier Symbol Action Example Note
each Apply a function to each element of an array TBA deprecated, use ≡ rows or ⊞ table instead
rows Apply a function to each row of an array TBA
inventory Apply a function to the unboxed elements of an array then re-box the results. TBA Equivalent to ° un □ box
un ° Inverts the behavior of a function. TBA Only some functions are compatible with ° un.
under With two functions F and G, apply F to the array then apply G to the results then "un-apply" F. TBA All functions compatible with ° un are compatible with ⍜ under. However, some functions incompatible with ° un can still be used with ⍜ under.

External resources

  • Uiua official website

References

  1. The oldest changelog is at 2023-09-28.
  2. The first Git commit was on February 27, 2023.