aboutsummaryrefslogtreecommitdiff
path: root/development/obcpl/examples
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-09-06 14:21:04 -0400
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2021-10-13 00:52:00 +0700
commitd932be9cd67647b92640ce5e21faf01e889eddc8 (patch)
tree2df5cda153eafdd6e6fba9dfd61e09a9a98f922b /development/obcpl/examples
parente4744bafbf98be5634cb4be76e4ef39bff19d595 (diff)
development/obcpl: Updated for version 0.9.8, fix build.
Signed-off-by: B. Watson <yalhcru@gmail.com> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'development/obcpl/examples')
-rw-r--r--development/obcpl/examples/Makefile17
-rw-r--r--development/obcpl/examples/README14
-rw-r--r--development/obcpl/examples/factorial.b9
-rw-r--r--development/obcpl/examples/hello.b6
4 files changed, 46 insertions, 0 deletions
diff --git a/development/obcpl/examples/Makefile b/development/obcpl/examples/Makefile
new file mode 100644
index 0000000000000..dbac82c9192fa
--- /dev/null
+++ b/development/obcpl/examples/Makefile
@@ -0,0 +1,17 @@
+# Makefile for obcpl/util
+
+BC=obcpl
+BFLAGS=-O
+
+all: hello factorial
+
+hello: hello.b
+ $(BC) $(BFLAGS) hello.b
+
+factorial: factorial.b
+ $(BC) $(BFLAGS) factorial.b
+
+install:
+
+clean:
+ rm -f hello factorial *.o
diff --git a/development/obcpl/examples/README b/development/obcpl/examples/README
new file mode 100644
index 0000000000000..14eb1dcccc87d
--- /dev/null
+++ b/development/obcpl/examples/README
@@ -0,0 +1,14 @@
+README for SlackBuilds.org development/obcpl examples
+-----------------------------------------------------
+
+This directory contains simple example programs written in BCPL.
+
+hello.b: The canonical Hello World program.
+Original source: https://github.com/leachim6/hello-world/
+
+factorial.b: Calculates the factorials of the integers 1 through 5.
+Original source: https://en.wikipedia.org/wiki/BCPL
+
+If you want to mess with this directory, it's best to copy it to your
+user's home directory (so you don't have to compile the programs as
+root). You can compile hello and factorial just by running "make".
diff --git a/development/obcpl/examples/factorial.b b/development/obcpl/examples/factorial.b
new file mode 100644
index 0000000000000..c6ea911cc3c5f
--- /dev/null
+++ b/development/obcpl/examples/factorial.b
@@ -0,0 +1,9 @@
+GET "LIBHDR"
+
+LET START() = VALOF $(
+ FOR I = 1 TO 5 DO
+ WRITEF("%N! = %I4*N", I, FACT(I))
+ RESULTIS 0
+$)
+
+AND FACT(N) = N = 0 -> 1, N * FACT(N - 1)
diff --git a/development/obcpl/examples/hello.b b/development/obcpl/examples/hello.b
new file mode 100644
index 0000000000000..976f70a6e6c51
--- /dev/null
+++ b/development/obcpl/examples/hello.b
@@ -0,0 +1,6 @@
+GET "LIBHDR"
+
+LET START() BE
+$(
+ WRITES("Hello World*N")
+$)