-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathescape-sequences.hm
74 lines (57 loc) · 1.9 KB
/
escape-sequences.hm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Example program demonstrating all escape sequences in Hyper Matrix
// Define a custom escape sequence
"\define(Cpath,C:\)"
// Print standard escape sequences
println("Null: \0")
println("Bell: \a")
println("Escape: \e[0m")
println("Newline:\nNext line")
println("Tab:\tTabbed")
println("Vertical Tab:\vVertical Tab")
println("Carriage Return:\rOverwritten Line")
println("Backspace: abc\b\bX")
println("Form Feed:\fNew Page")
println("Single Quote: \'")
println("Double Quote: \"")
println("Backslash: \\")
// Unicode and Hex sequences
println("Unicode Heart: \u2764")
println("Hex Letter A: \x41")
println("Hex Emoji: \x{1F600}")
// Random character generation
println("Random ASCII: \?;")
println("Random from set: \?{abcde};")
println("Three Random Chars: \???")
println("Random Binary (length 3): \?{01}??")
// Repeated characters
println("Repeated Star: \#5*;")
println("Repeated String: \#3{hi};")
// Color formatting
println("\|red|This is red text\|<|")
println("\|#FF0000|This is RGB red text\|<|")
println("\|##00FF00|Green background\|<<|")
// Control characters
println("Control+C Escape: \cC")
// Named Unicode Characters
println("Named Unicode Heart: \M{heart}")
// Auto-incrementing counter
println("Counter:\N; \N.Hyper \N.Matrix \N.Language \N;\N:new")
println("Counter with ignored semicolon: \N \N\N; \N")
// Binary character escape
println("Binary Letter A: \B{01000001}")
// Rainbow text
println("\C[Colorful Text]")
// Date and Time
println("Today's Date: \D{yyyy-MM-dd}")
println("Current Time: \T{HH:mm:ss}")
// Using a defined escape sequence
println("C Path: \Cpath")
// Demonstrate parsing different number literals
var binaryNum = 0b100110
var hexNum = 0xFE14D5
var octalNum = 0o521237
var sciNum = 45e+2
println("Binary: " + binaryNum)
println("Hex: " + hexNum)
println("Octal: " + octalNum)
println("Scientific: " + sciNum)