A number of rules have been moved from entry `Makefile`s into the `1337.mk` include file to make it easier for these common rules to be updated or modified globally (by modifying the `1337.mk` include file). The entry level `Makefile`s are now similar in form to the /Makefile.example](https://github.com/ioccc-src/mkiocccentry/blob/master/Makefile.example) file from the other repo. The following make rules were moved into the `1337.mk` include file: - `make indent.c` - `make install` - `make diff_orig_prog` - `make diff_prog_orig` - `make diff_alt_prog` - `make diff_prog_alt` This simplifies the entry level `Makefile`s so that they mostly reflect the specifics of the particular entry. Mentioned in FAQ 4.2, that the make diff rules are in the `1337.mk` include file. Fixed invalid TAB character in `faq.md`. Removed `make clean` directives that removed `indent.c`. This file is now removed via `make indent_clean`, a clean rule that also removes `indent.c`. Removed `make clobber` directives that removed sandwich, This file is now removed via `make indent_clobber`, a clean rule that also removes `sandwich`. Added `make indent_clean` and `make indent_clobber` rules into the top level `Makefile` and the year level `YYYY/Makefile`. Performed `make quick_www` to accomplish the above and to test under macOS.
To build:
make
To use:
./prog
Try:
./try.sh
By default that will use indent(1) found by the shell type -P indent and
sed(1) found by the shell type -P sed but if you want to change these, say
to try a different beautifier, you can do it like:
INDENT=bcpp ./try.sh
which would change it to use bcpp(1) instead of indent(1). Do similar for
sed(1) only use the name SED.
Judges' remarks:
C11 features definitely help this entry to be as concise as it is.
The judges would like to think that they had almost understood how this entry works.
If you win a bet by demonstrating this entry, please let us know.
Author's remarks:
Remarks
- Computes the factorial function.
- No loops, no explicit recursion.
- Untyped C without any casts, using a
wword datatype. - Varargs not essential,
w(*)(w,w*)works just as well. - Conforming to ISO C.
- No warnings when compiled with
-std=c99 -Wall -Wextra -pedantic. - Comments in the code explain what this really is about.
- C as a functional programming language: untyped lambda calculus compiled to executable C functions.
- Untagged closures (just a function pointer followed by some values).
- Recursion implemented through Curry's paradoxical combinator
Y. - The readable implementation of
Yis on lines 29-30:
W_f = \x.f(xx)
Y = \f.W_f W_f
- A mixture of strict and lazy evaluation, with a
_force function (John Tromp notes that if Turing's fixed-point combinator(\xy.y\z.xxyz)(\xy.y\z.xxyz)had been used, all applications could have been strict). - Uses
Yto implement factorial on nativeints. - 10! seconds = 6 weeks.
- Answers the ultimate question of life, the universe and everything.