gtltem

From Esolang
Jump to navigation Jump to search

gtltem (greater than, less than, exclamation mark) is an esoteric language created by username qwerty12302 in 2015. The language consists only of three characters: <, > and !, to which the name of the language refers.

Memory

The gtltem memory consists of seven bits, which can store exactly one gtltemASCII character. The value of this memory place can be changed using < or >, < decrementing and > incrementing it. The value of the memory is set to zero in the beginning.

Syntax

A gtltem program would look like this:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!>!>!

Output:

ABC

This program prints out the first three letters of the alphabet, located in decimal places 33, 34 and 35 in ASCII. The > increments the value of the memory (hereafter value) by 1 and ! prints the corresponding ASCII character.

ASCII

gtltem uses gtltemASCII, which is ASCII without control characters:

Code Character
00
01 !
02 "
03 #
04 $
05 %
06 &
07 '
08 (
09 )
10 *
11 +
12 ,
13 -
14 .
15 /
16 0
17 1
18 2
19 3
20 4
21 5
22 6
23 7
24 8
25 9
26 :
27 ;
28 <
29 =
30 >
31 ?
32 @
33 A
34 B
35 C
36 D
37 E
38 F
39 G
40 H
41 I
42 J
43 K
44 L
45 M
46 N
47 O
48 P
49 Q
50 R
51 S
52 T
53 U
54 V
55 W
56 X
57 Y
58 Z
59 [
60 \
61 ]
62 ^
63 _
64 `
65 a
66 b
67 c
68 d
69 e
70 f
71 g
72 h
73 i
74 j
75 k
76 l
77 m
78 n
79 o
80 p
81 q
82 r
83 s
84 t
85 u
86 v
87 w
88 x
89 y
90 z
91 {
92 |
93 }
94 ~

Examples

Hello, World!

This program prints “Hello, World!”:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!>>>>>>>!!>>>!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<!<<<<<<<<<<<<!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!>>>>>>>>>>>>>>>>>>>>>>>>!>>>!<<<<<<!<<<<<<<<!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<!

Implementation

A simple implementation in Common Lisp shall follow:

(declaim (type (simple-string 95) +GTLTEMASCII-CHARACTER-TABLE+))

(defconstant +GTLTEMASCII-CHARACTER-TABLE+
  " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  "Maps gtltemASCII codes to characters.")

(defun gtltemASCII-character-for (code)
  "Returns for the gtltemASCII CODE the matching character."
  (declare (type (integer 0 94) code))
  (the character (schar +GTLTEMASCII-CHARACTER-TABLE+ code)))

(defun interpret-gtltem (code)
  "Interprets the piece of gtltem CODE and returns the NIL value."
  (declare (type string code))
  (let ((memory 0))
    (declare (type (unsigned-byte 7) memory))
    (loop for command of-type character across code do
      (case command
        (#\< (setf memory (mod (1- memory) 128)))
        (#\> (setf memory (mod (1+ memory) 128)))
        (#\! (write-char (gtltemASCII-character-for memory)))
        ((#\Space #\Tab #\Newline) NIL)
        (otherwise (error "Invalid command: ~s." command))))))