Add 2014/wiedijk/try.sh + formatting/typo checks
The try.sh allows one to override the default indent(1) and sed(1) tools and also verifies that they are executable. This means one can use, for example, bcpp, instead of indent, or if one wants to specify a different path to sed(1) they can. The README.md file explains this more. README.md file format/typo checked. This should complete the review of this entry.
This commit is contained in:
1 parent
bccf3b4cdb
commit
025191d8af
3 files changed
+86
-18
No files matched your search
+30
-18
@@ -15,9 +15,20 @@ make
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
cc -E prog.c | indent | sed '1,/5.*prog/d'
|
||||
./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:
|
||||
|
||||
```sh
|
||||
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:
|
||||
|
||||
@@ -32,31 +43,32 @@ If you win a bet by demonstrating this entry, please let us know.
|
||||
|
||||
### Remarks
|
||||
|
||||
- computes the factorial function
|
||||
- no loops, no explicit recursion
|
||||
- untyped C without any casts, using a `w` word datatype
|
||||
- varargs not essential, `w(*)(w,w*)` works just as well
|
||||
- conforming 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 `Y` is on lines 29-30:
|
||||
- Computes the factorial function.
|
||||
- No loops, no explicit recursion.
|
||||
- Untyped C without any casts, using a `w` word 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 `Y` is 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
|
||||
- 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 `Y` to implement factorial on native `int`s
|
||||
- 10! seconds = 6 weeks
|
||||
- answers the ultimate question of life, the universe and everything
|
||||
all applications could have been strict).
|
||||
- Uses `Y` to implement factorial on native `int`s.
|
||||
- 10! seconds = 6 weeks.
|
||||
- Answers the [ultimate question of life, the universe and
|
||||
everything](https://hitchhikers.fandom.com/wiki/42).
|
||||
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
Reference in new issue
Block a user