Updates and additions to 1989/jar.2

Add a hexa-layered chocolate fudge cake :-) (see below)

Added try.me.sh script which will take a list of files (if no arg
specified it has a default of files added, as described below) and feed
each one to jar.2.

The lisp files added are: fib.lisp from Yusuke Endoh; try.me.txt from
the author; and chocolate_cake.lisp from me. The cake one uses '(quote
...)' that the program supports but the other files do not and plus who
can't use a bit (or lot :-) ) of chocolate cake?

Made the entry look slightly more like the original by adding back the
macros that can't be used but still are part of the entry (#defines for
define and include).
This commit is contained in:
Cody Boone Ferguson committed 2023-10-20 06:53:20 -07:00
1 parent 212fa7cff6
commit d1cf700126
8 files changed
+99 -22

No files matched your search

+3 -2
View File
@@ -39,7 +39,7 @@ include ../../var.mk
# Common C compiler warnings to silence
#
CSILENCE= -Wno-implicit-function-declaration -Wno-missing-braces -Wno-parentheses \
-Wno-deprecated-non-prototype -Wno-pedantic -Wno-strict-prototypes
-Wno-deprecated-non-prototype -Wno-pedantic -Wno-strict-prototypes -Wno-implicit-int
# Common C compiler warning flags
#
@@ -130,8 +130,9 @@ all: data ${TARGET}
sandwich supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
@echo NOTE: invalid input will cause this entry to dump core.
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
@echo
@echo NOTE: invalid input will cause this entry to dump core. See README.md for details.
# alternative executable
#
+38 -20
View File
@@ -19,13 +19,31 @@ make all
```sh
./jar.2
[enter some lisp]
./jar.2 < some_lisp_file
```
NOTE: this entry will likely segfault on invalid input.
## Try:
```sh
./try.me.sh
cat chocolate_cake.lisp ; ./jar.2 < chocolate_cake.lisp
./try.me.sh chocolate_cake.lisp
./try.me.sh try.me.txt
```
## Judges' remarks:
This is the most useful program entered this year. It is a
This is the most useful program submitted this year. It is a
rather large subset of lisp. It has no error recovery, and
performs rather poorly in a number of cases. Even so, placing
all this functionality in such a small, densely packed program,
@@ -35,7 +53,7 @@ is impressive enough to win the Best of show award.
## Author's remarks:
This program implements a Lisp interpreter in 1465 bytes of source.
Some sophisticated features supported, eg. functionals and recursion.\
Some sophisticated features supported, e.g. functionals and recursion.
The special-forms/functions/variables implemented are:
- \+
@@ -61,24 +79,24 @@ prints out the return values. End execution by typing an end-of-file
character.
```lisp
(+ 2.5 3.1)
(defun fib (n)
(if (< n 2)
1
(+ (fib (- n 2)) (fib (- n 1)))))
(fib 10)
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
(! 7)
(defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
(defun fn2 (a b) (+ a b))
(fn1 (function +))
(fn1 (function fn2))
(fn1 (function (lambda (z1 z2) (+ z1 z2))))
(quote a)
(cons (quote (a b)) (quote (c d e)))
(cons (quote (f)) ())
(car (quote (a b c)))
(cdr (cdr (quote (g h i))))
(+ 2.5 3.1)
(defun fib (n)
(if (< n 2)
1
(+ (fib (- n 2)) (fib (- n 1)))))
(fib 10)
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
(! 7)
(defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
(defun fn2 (a b) (+ a b))
(fn1 (function +))
(fn1 (function fn2))
(fn1 (function (lambda (z1 z2) (+ z1 z2))))
(quote a)
(cons (quote (a b)) (quote (c d e)))
(cons (quote (f)) ())
(car (quote (a b c)))
(cdr (cdr (quote (g h i))))
```
+8
View File
@@ -0,0 +1,8 @@
(quote ......................)
(quote ||||||||||||||||||||||)
(quote [[[--hexa-layered--]]])
(quote [[[----layered-----]]])
(quote [[[---chocolate----]]])
(quote [[[-----fudge------]]])
(quote [[[-----cake-------]]])
(quote [[[[[[[[[[]]]]]]]]]]]])
+5
View File
@@ -0,0 +1,5 @@
(defun fib (n)
(if (< n 2)
1
(+ (fib (- n 2)) (fib (- n 1)))))
(fib 10)
+2
View File
@@ -1,4 +1,6 @@
#include <stdio.h>
#define d define
#define a include
#include <string.h>
#include <ctype.h>
#define p char*
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# demo for 1989/jar.2 - run entry with one or more files
make all || exit 1
if [[ "$#" -lt 1 ]]; then
FILES="try.me.txt fib.lisp chocolate_cake.lisp"
else
FILES="$*"
fi
for f in $FILES; do
if [[ -e "$f" && -r "$f" ]]; then
./jar.2 < "$f"
fi
done
+18
View File
@@ -0,0 +1,18 @@
(+ 2.5 3.1)
(defun fib (n)
(if (< n 2)
1
(+ (fib (- n 2)) (fib (- n 1)))))
(fib 10)
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
(! 7)
(defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
(defun fn2 (a b) (+ a b))
(fn1 (function +))
(fn1 (function fn2))
(fn1 (function (lambda (z1 z2) (+ z1 z2))))
(quote a)
(cons (quote (a b)) (quote (c d e)))
(cons (quote (f)) ())
(car (quote (a b c)))
(cdr (cdr (quote (g h i))))
+8
View File
@@ -538,6 +538,14 @@ code like:
He notes that there _is_ a way to get it (or something close to it) to work. Do
you know how?
Cody also provided the [try.me.sh](1989/jar.2/try.me.sh) script and the
supplementary files [try.me.txt](1989/jar.2/try.me.txt),
[fib.lisp](1989/jar.2/fib.lisp) and
[chocolate_cake.lisp](1989/jar.2/chocolate_cake.lisp). The `try.me.txt` comes
from the author and the `fib.lisp` comes from Yusuke. Cody wrote the script and
offered us some chocolate cake :-) See README.md for details on how to use the
script.
## [1989/ovdluhe](1989/ovdluhe/ovdluhe.c) ([README.md](1989/ovdluhe/README.md]))