-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
foth.4th
51 lines (41 loc) · 864 Bytes
/
foth.4th
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
#
# This file is loaded on-startup, if it is present.
#
# NOTE: Lines having a "#"-prefix will be skipped.
#
# This is not a standard approach to FORTH comments, but it makes
# sense for this particular implementation.
#
#
# CR: Output a carrige return (newline).
#
: cr 10 emit ;
#
# Star: Output a star to the console.
#
# Here 42 is the ASCII code for the "*" character.
#
: star 42 emit ;
#
# Stars: Show the specified number of stars.
#
# e.g. "3 stars"
#
: stars 0 do star loop 10 emit ;
#
# square: Square a number
#
: square dup * ;
#
# cube: cube a number
#
: cube dup square * ;
#
# 1+: add one to a number
#
: 1+ 1 + ;
#
# boot: output a message on-startup
#
: bootup 87 emit 101 emit 108 emit 99 emit 111 emit 109 emit 101 emit 32 emit 116 emit 111 emit 32 emit 102 emit 111 emit 116 emit 104 emit 33 emit 10 emit ;
bootup