Charred

From Esolang
Jump to navigation Jump to search
Charred
Paradigm(s) imperative
Designed by User:SpaceByte
Appeared in 2022
Memory system Cell-based
Dimensions one-dimensional
Computational class Unknown
Reference implementation [1]
File extension(s) .chr

Charred is a language created by User:SpaceByte on July 17th 2022. Charreds is an esolang like brainfuck, but with some differences, variables are stored as characters, with integer equivalents, charred does not use ASCII codes, charred only allows for spaces, and letters, charred does not have loops, instead it has if statements and goto commands, etc. Charred has a very similar base as brainfuck, but is to be considered its own original esolang.

Language description

Charred operates by storing variables as characters. Similarly, to brainfuck, it has an array of 30000 values, a pointer, etc. The commands +-<> are nearly exactly the same as in brainfuck, with the difference the variables they modify are characters. The default character, 0, is a space, followed by the english lowercase alphabet, and then the uppercase alphabet. This equates to 53 characters, so charred is incapable of storing variables over 52. Because variables are stored in characters, the regular print command simply prints the value of the variable, but there is also a command to print their integer equivalent, being the only way to print numbers.

The following table shall furnish an overview concerning the alphabet and its encoding, juxtaposed with the ASCII standard's character codes:

Charred code Character ASCII code
0 (space) 32
1 a 97
2 b 98
3 c 99
4 d 100
5 e 101
6 f 102
7 g 103
8 h 104
9 i 105
10 j 106
11 k 107
12 l 108
13 m 109
14 n 110
15 o 111
16 p 112
17 q 113
18 r 114
19 s 115
20 t 116
21 u 117
22 v 118
23 w 119
24 x 120
25 y 121
26 z 122
27 A 65
28 B 66
29 C 67
30 D 68
31 E 69
32 F 70
33 G 71
34 H 72
35 I 73
36 J 74
37 K 75
38 L 76
39 M 77
40 N 78
41 O 79
42 P 80
43 Q 81
44 R 82
45 S 83
46 T 84
47 U 85
48 V 86
49 W 87
50 X 88
51 Y 89
52 Z 90

Commands

Command Description
> Move the pointer to the right
< Move the pointer to the left
+ Increment the cell at the pointer (next character)
- Decrement the cell at the pointer (last character)
. Output the character stored in the value at pointer
, Input a character and store it in the value of the pointer location
' Output the integer (numeric) value of the variable at pointer
: Execute the next command only if the value at pointer is not 0
\ Print a linebreak
/ Go to the line number of the value at pointer.
| Clear the console

All commands whichs character is not +-<>,.'|:/\ are fully ignored by the interpreter, and not executed.

Example

Spam Alphabet

This program was discovered by User:SpaceByte by accident after she failed to create this program intentionally. Although the program prints a and b twice on its first iteration, it does work, and prints every character printable by the . command.

++
>.+
</

Hello World

This program outputs the message “Hello World”:

++++++++++++++++++++++++++++++++++.
-----------------------------.
+++++++..
+++.
---------------.
+++++++++++++++++++++++++++++++++++++++++++++++++.
----------------------------------.
+++.
------.
--------.

Cat program

An infinitely repeating cat program shall be adduced:

++
>
,.
</

Counter

This program outputs the letter “X” ten times utilizing the goto (/) and the conditional execution (:) facilities in conjunction:

[Line 1] Set output cell in memory(0) to the symbol X
++++++++++++++++++++++++++++++++++++++++++++++++++
[Line 2] Set the counter in memory(1) to 10
>++++++++++
[Line 3] Set the terminating goto cell in memory(2) to 8
>++++++++
[Line 4] Set the looping goto cell in memory(3) to 5
>+++++
[Line 5] Change to counter cell in memory(1)
<<
[Line 6] Output X and decrement the counter
<.>-
[Line 7] Either jump to [Line 5] via memory(3) or the end via memory(2)
:>>/

Interpreter

  • Common Lisp implementation of the Charred programming language.