improved indentation and whitespace for markdown code blocks
All code blocks in markdown have been intended by at least 4 spaces. We add `--tab-stop=8` to all `pandoc(1)` executions in order to set a better tab stop indentation, especially for tab intended code blocks. Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26" to "1.6 2024-03-31". Fixed `1991/brnstnd/sorta.README.md` so that the sorta code is code blocks. Removed unneeded paragraph group in copyright in `inc/footer.default.html`. Fixed excess whitespace after list Author on entry `index.html` page. Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26" to "1.6 2024-03-31". Performed `make www` to perform the above and test under macOS. TODO: Fix the problem of the initial line of code being extra intended. TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
1 parent
b84c27ce02
commit
a996f8d2b8
734 files changed
+16723
-16963
No files matched your search
+183
-167
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
The author provided an alternate version which has a simpler keyboard for the
|
||||
@@ -11,22 +11,22 @@ monkey Eric. See [Alternate code](#alternate-code) below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./weasel
|
||||
./weasel
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
|
||||
# For those who believe in '"intelligent" design' or want to see how easy it is
|
||||
# to prove evolution is a proven fact:
|
||||
./id.sh
|
||||
# For those who believe in '"intelligent" design' or want to see how easy it is
|
||||
# to prove evolution is a proven fact:
|
||||
./id.sh
|
||||
|
||||
# For those who want to see if Eric the monkey can type the word 'words' before
|
||||
# falling asleep or giving up:
|
||||
./monkey-words.sh
|
||||
# For those who want to see if Eric the monkey can type the word 'words' before
|
||||
# falling asleep or giving up:
|
||||
./monkey-words.sh
|
||||
```
|
||||
|
||||
NOTE: the [try.sh](try.sh) script will run the other two scripts but if the
|
||||
@@ -48,7 +48,7 @@ about this under the [keyboards](#keyboards) section, briefly referred to in the
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -60,15 +60,15 @@ Use `weasel.alt` as you would `weasel` above.
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
|
||||
# For those who believe in '"intelligent" design' or want to see how easy it is
|
||||
# to prove evolution is a proven fact:
|
||||
./id.alt.sh
|
||||
# For those who believe in '"intelligent" design' or want to see how easy it is
|
||||
# to prove evolution is a proven fact:
|
||||
./id.alt.sh
|
||||
|
||||
# For those who want to see if Eric the monkey can type the word 'words' before
|
||||
# falling asleep or giving up:
|
||||
./monkey-words.alt.sh
|
||||
# For those who want to see if Eric the monkey can type the word 'words' before
|
||||
# falling asleep or giving up:
|
||||
./monkey-words.alt.sh
|
||||
```
|
||||
|
||||
NOTE: the [try.alt.sh](try.alt.sh) script will run the other two scripts but if the
|
||||
@@ -81,7 +81,7 @@ make use of some of these.
|
||||
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
You can reconfigure certain values. These are described by the author in more
|
||||
@@ -108,7 +108,7 @@ while using more Cenozoic minded code migration, read [rpm.html](rpm.html).
|
||||
If you find yourself in an evolutionary dead end, try:
|
||||
|
||||
```sh
|
||||
man ./weasel.1
|
||||
man ./weasel.1
|
||||
```
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ if you want a quick rundown of the entry try what they suggest and view the man
|
||||
page (it explains all the options and describes the program briefly):
|
||||
|
||||
```sh
|
||||
man ./weasel.man
|
||||
man ./weasel.man
|
||||
```
|
||||
|
||||
If that isn't sufficient **I would recommend reading this section** *(and
|
||||
@@ -378,8 +378,9 @@ the target string (see below).
|
||||
|
||||
**Enable quiet output:**
|
||||
|
||||
-q
|
||||
|
||||
```
|
||||
-q
|
||||
```
|
||||
|
||||
This means don't print the generation and offspring output; only print (some) of
|
||||
the options set (this is always done but wouldn't usually be seen due to verbose
|
||||
@@ -387,16 +388,20 @@ output) and the final answer.
|
||||
|
||||
**Change the mutation rate to `<rate>`:**
|
||||
|
||||
-r<num>
|
||||
```
|
||||
-r<num>
|
||||
```
|
||||
|
||||
Please note that there cannot be a space between the `-r` and the number.
|
||||
This is to simplify the parsing of options. As for combining options you can do
|
||||
any of the following (amongst others):
|
||||
|
||||
-r5q
|
||||
-qr5
|
||||
-qr
|
||||
-q -r5
|
||||
```
|
||||
-r5q
|
||||
-qr5
|
||||
-qr
|
||||
-q -r5
|
||||
```
|
||||
|
||||
The third invocation will set quiet output and have no valid value to parse for
|
||||
the mutation rate and `strtol()` in this case returns 0. `strtol()` can
|
||||
@@ -412,14 +417,18 @@ following:
|
||||
|
||||
1. Enable quiet mode and set an invalid mutation range; for example specify:
|
||||
|
||||
-qr101
|
||||
```
|
||||
-qr101
|
||||
```
|
||||
|
||||
2. Take a look at the first few lines. Kill the program and try invoking it
|
||||
with the following options:
|
||||
|
||||
|
||||
-qr5
|
||||
\
|
||||
```
|
||||
-qr5
|
||||
```
|
||||
|
||||
3. Look at the first few lines again and compare it to the output of step \#1.
|
||||
With the default string most modern systems shouldn't take much time to - given
|
||||
decent parameters - come to an answer here but if necessary kill the program.
|
||||
@@ -436,25 +445,25 @@ specially by your shell e.g. parentheses. For instance if you just want to find
|
||||
`METHINKS` you could do one of:
|
||||
|
||||
```sh
|
||||
./weasel METHINKS
|
||||
./weasel "METHINKS"
|
||||
./weasel 'METHINKS'
|
||||
./weasel METHINKS
|
||||
./weasel "METHINKS"
|
||||
./weasel 'METHINKS'
|
||||
```
|
||||
|
||||
If you wanted `YOU ARE A MONKEY`:
|
||||
|
||||
```sh
|
||||
./weasel "YOU ARE A MONKEY"
|
||||
./weasel 'YOU ARE A MONKEY'
|
||||
./weasel "YOU ARE A MONKEY"
|
||||
./weasel 'YOU ARE A MONKEY'
|
||||
```
|
||||
|
||||
If you do one of:
|
||||
|
||||
```sh
|
||||
./weasel "METHINKS IT IS A" "MONKEY"
|
||||
./weasel METHINKS IT IS A MONKEY
|
||||
./weasel "METHINKS IT IS A" "MONKEY"
|
||||
./weasel METHINKS IT IS A MONKEY
|
||||
```
|
||||
\
|
||||
|
||||
It will search for `MONKEY` in both cases; in other words it's the last one.
|
||||
If the string is too long given the value of `S` (see\
|
||||
**[How to build](#build)**) it will be truncated.
|
||||
@@ -464,15 +473,15 @@ disable further parsing of options by using the `-` option itself; for
|
||||
example if you were to do any of:
|
||||
|
||||
```sh
|
||||
./weasel -q- -- -test
|
||||
./weasel -q- -test
|
||||
./weasel -q -- -test
|
||||
./weasel -q- -- -test
|
||||
./weasel -q- -test
|
||||
./weasel -q -- -test
|
||||
```
|
||||
|
||||
The target string will be: `-TEST`. This means though that here:
|
||||
|
||||
```sh
|
||||
./weasel -q -- -test -r5
|
||||
./weasel -q -- -test -r5
|
||||
```
|
||||
|
||||
The string to be searched would actually be `-r5` and the mutation rate
|
||||
@@ -482,13 +491,15 @@ command line. Because of the joining of arguments this means that the first two
|
||||
examples of the last set of three above are equivalent i.e. the following two
|
||||
are equivalent:
|
||||
|
||||
-q-\
|
||||
-q --
|
||||
\
|
||||
```
|
||||
-q-\
|
||||
-q --
|
||||
```
|
||||
|
||||
As for the caveat I referenced what does the following do?
|
||||
|
||||
```sh
|
||||
./weasel -qr 5
|
||||
./weasel -qr 5
|
||||
```
|
||||
|
||||
In fact it will set quiet output and set the target string to be '5'. So the
|
||||
@@ -500,27 +511,27 @@ the other options are in the command line it might still parse the options. Thus
|
||||
you have:
|
||||
|
||||
```sh
|
||||
$ ./weasel -qr-r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'METHINKS IT IS LIKE A WEASEL'
|
||||
mutation rate 5
|
||||
Generation 440 Offspring 20: METHINKS IT IS LIKE A WEASEL
|
||||
$ ./weasel -qr-r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'METHINKS IT IS LIKE A WEASEL'
|
||||
mutation rate 5
|
||||
Generation 440 Offspring 20: METHINKS IT IS LIKE A WEASEL
|
||||
```
|
||||
|
||||
Similarly this would set quiet output, then an invalid mutation rate and then a
|
||||
mutation rate of 5:
|
||||
|
||||
```sh
|
||||
./weasel --qrr5
|
||||
./weasel --qrr5
|
||||
```
|
||||
|
||||
|
||||
If you were instead to do one of (for example):
|
||||
|
||||
```sh
|
||||
./weasel -q -- -r
|
||||
./weasel -q -q- -r
|
||||
./weasel -q -- -r
|
||||
./weasel -q -q- -r
|
||||
```
|
||||
|
||||
Then it *would* set quiet output then see the `--` (the `-` option
|
||||
@@ -558,15 +569,15 @@ requested? There are at least two ways to go about it: I took the monkey safe
|
||||
it in the same invocation of `weasel`!
|
||||
|
||||
```sh
|
||||
$ ./weasel -qr101r5r101r1r test
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
mutation rate out of range
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 0
|
||||
monkey at typewriter
|
||||
Generation 16844 Offspring 22: TEST
|
||||
$ ./weasel -qr101r5r101r1r test
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
mutation rate out of range
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 0
|
||||
monkey at typewriter
|
||||
Generation 16844 Offspring 22: TEST
|
||||
```
|
||||
|
||||
So in this case I joined the options in the following order:
|
||||
@@ -623,12 +634,12 @@ in monkey mode.
|
||||
Another example:
|
||||
|
||||
```sh
|
||||
$ ./weasel -q -r101 test -r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 5
|
||||
Generation 109 Offspring 13: TEST
|
||||
$ ./weasel -q -r101 test -r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 5
|
||||
Generation 109 Offspring 13: TEST
|
||||
```
|
||||
|
||||
In this case I also enabled quiet mode but I didn't join the options; the
|
||||
@@ -639,13 +650,13 @@ which means that it'll use the genetic algorithm.
|
||||
One more example of monkey mode:
|
||||
|
||||
```sh
|
||||
$ ./weasel -q -mr101 test -r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 5
|
||||
monkey at typewriter
|
||||
Generation 465298 Offspring 10: TEST
|
||||
$ ./weasel -q -mr101 test -r5
|
||||
quiet output
|
||||
mutation rate out of range
|
||||
target 'test'
|
||||
mutation rate 5
|
||||
monkey at typewriter
|
||||
Generation 465298 Offspring 10: TEST
|
||||
```
|
||||
|
||||
Here I also requested quiet output and then *explicitly requested that Eric the
|
||||
@@ -661,15 +672,19 @@ When the program prints out each iteration (I'll give an example next) it goes a
|
||||
lot slower; this makes sense because it's an expensive operation. Here are the
|
||||
times for the same but without quiet output enabled:
|
||||
|
||||
real 0m17.065s
|
||||
user 0m1.245s
|
||||
sys 0m2.402s
|
||||
```
|
||||
real 0m17.065s
|
||||
user 0m1.245s
|
||||
sys 0m2.402s
|
||||
```
|
||||
|
||||
Whereas with quiet output:
|
||||
|
||||
real 0m0.127s
|
||||
user 0m0.125s
|
||||
sys 0m0.001s
|
||||
```
|
||||
real 0m0.127s
|
||||
user 0m0.125s
|
||||
sys 0m0.001s
|
||||
```
|
||||
|
||||
Of course it isn't only down to the printing but the point is it slows it down
|
||||
significantly. Adding an option to print every X lines would go over the limit
|
||||
@@ -679,29 +694,29 @@ Finally I'll show a default example in normal output (I omit many lines showing
|
||||
instead **[...]**). Note that the real/user/sys times are from the `time`
|
||||
bash shell built-in utility: that isn't output from my entry.
|
||||
|
||||
```
|
||||
target 'METHINKS IT IS LIKE A WEASEL'
|
||||
mutation rate 1
|
||||
Generation 0 Offspring 1: 4V YGY.GH/}_|>Q1M.R8;KD[=(05
|
||||
Generation 0 Offspring 2: Y_^S0_HZ399^/|9,MP%^{817"XX#
|
||||
Generation 0 Offspring 3: F%88H1&[V1P>QOI}- U]0[V-Y%*[
|
||||
[...]
|
||||
Generation 1 Offspring 23: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:| (mutation)
|
||||
Generation 1 Offspring 24: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
Generation 1 Offspring 25: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#1\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
**
|
||||
Generation 2 Offspring 1: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
Generation 2 Offspring 2: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'O>?~-S.;1A L|1<S:^ (mutation)
|
||||
[...]
|
||||
Generation 979 Offspring 1: METHINKS ITZIS LIKE A WEASEL -> METHINKS IT IS LIKE A WEASEL (mutation)
|
||||
[...]
|
||||
**
|
||||
Generation 979 Offspring 1: METHINKS IT IS LIKE A WEASEL
|
||||
|
||||
target 'METHINKS IT IS LIKE A WEASEL'
|
||||
mutation rate 1
|
||||
Generation 0 Offspring 1: 4V YGY.GH/}_|>Q1M.R8;KD[=(05
|
||||
Generation 0 Offspring 2: Y_^S0_HZ399^/|9,MP%^{817"XX#
|
||||
Generation 0 Offspring 3: F%88H1&[V1P>QOI}- U]0[V-Y%*[
|
||||
[...]
|
||||
Generation 1 Offspring 23: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:| (mutation)
|
||||
Generation 1 Offspring 24: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
Generation 1 Offspring 25: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#1\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
**
|
||||
Generation 2 Offspring 1: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
|
||||
Generation 2 Offspring 2: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'O>?~-S.;1A L|1<S:^ (mutation)
|
||||
[...]
|
||||
Generation 979 Offspring 1: METHINKS ITZIS LIKE A WEASEL -> METHINKS IT IS LIKE A WEASEL (mutation)
|
||||
[...]
|
||||
**
|
||||
Generation 979 Offspring 1: METHINKS IT IS LIKE A WEASEL
|
||||
|
||||
real 0m0.074s
|
||||
user 0m0.040s
|
||||
sys 0m0.001s
|
||||
|
||||
real 0m0.074s
|
||||
user 0m0.040s
|
||||
sys 0m0.001s
|
||||
```
|
||||
|
||||
Keep in mind the way I display the generations and the fact that generation 0
|
||||
has no parents; it is generation 1 that starts working towards the goal. You'll
|
||||
@@ -716,12 +731,14 @@ One final thing to consider is that **the program doesn't directly read from a
|
||||
file**. This combined with the way the shell works could possibly confuse some
|
||||
people. Take the following invocations:
|
||||
|
||||
(1) $ echo test > test
|
||||
(2) $ ./weasel test
|
||||
(3) $ ./weasel < test
|
||||
(4) $ cat test | ./weasel\
|
||||
(5) $ < test-strings.txt ./weasel
|
||||
(6) $ cat | ./weasel
|
||||
```
|
||||
(1) $ echo test > test
|
||||
(2) $ ./weasel test
|
||||
(3) $ ./weasel < test
|
||||
(4) $ cat test | ./weasel\
|
||||
(5) $ < test-strings.txt ./weasel
|
||||
(6) $ cat | ./weasel
|
||||
```
|
||||
|
||||
Only the first invocation of `./weasel` will search for `TEST` because
|
||||
the string `test` was explicitly passed to the program (If the file `test`
|
||||
@@ -752,18 +769,17 @@ file and pass each string to the program itself*. I've included a script
|
||||
`test.sh` and a file of sample input `test-strings.txt` that you can play
|
||||
with.
|
||||
|
||||
|
||||
Try:
|
||||
|
||||
```sh
|
||||
make test
|
||||
make test
|
||||
```
|
||||
|
||||
This will essentially make sure the program is compiled and then do:
|
||||
|
||||
```sh
|
||||
chmod +x test.sh
|
||||
./test.sh
|
||||
chmod +x test.sh
|
||||
./test.sh
|
||||
```
|
||||
|
||||
The script will first try compiling the program (if necessary) and if it fails
|
||||
@@ -778,7 +794,7 @@ You can pass additional options directly to the script but remember that it
|
||||
stops when there are no more strings in the file - so if you try:
|
||||
|
||||
```sh
|
||||
./test.sh -q test
|
||||
./test.sh -q test
|
||||
```
|
||||
|
||||
The final string `test` won't be searched for; it will however run the program
|
||||
@@ -810,11 +826,11 @@ keyboard doesn't have `'\n'` if you were to type a `'` and send a
|
||||
`'\n'` before the closing `'` you might see something like:
|
||||
|
||||
```sh
|
||||
$ ./weasel '!!
|
||||
> '
|
||||
$ ./weasel '!!
|
||||
> '
|
||||
|
||||
'
|
||||
' not in keyboard " !"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"
|
||||
'
|
||||
' not in keyboard " !"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"
|
||||
```
|
||||
|
||||
I showed that `'` is in the keyboard already; however the user sent a
|
||||
@@ -843,9 +859,9 @@ as well as some C keywords.
|
||||
2. The way `main()` is declared is:
|
||||
|
||||
```c
|
||||
/* Special C main() handler (encapsulation): */
|
||||
#define r(main) main
|
||||
r(k main(k a, E **V)) {
|
||||
/* Special C main() handler (encapsulation): */
|
||||
#define r(main) main
|
||||
r(k main(k a, E **V)) {
|
||||
```
|
||||
|
||||
It appears to be recursively defined but is it? And is it truly
|
||||
@@ -937,7 +953,7 @@ The Makefile simplifies how to reconfigure this value with the variable
|
||||
`MAX_SIZE`:
|
||||
|
||||
```sh
|
||||
make clobber MAX_SIZE=55 all
|
||||
make clobber MAX_SIZE=55 all
|
||||
```
|
||||
|
||||
The next macro that can be reconfigured, `M` (or `MAX_ATTEMPTS` in the
|
||||
@@ -950,7 +966,7 @@ The Makefile simplifies how to reconfigure this value with the variable
|
||||
`MAX_ATTEMPTS`:
|
||||
|
||||
```sh
|
||||
make clobber MAX_ATTEMPTS=100 all
|
||||
make clobber MAX_ATTEMPTS=100 all
|
||||
```
|
||||
|
||||
The final macro, `N` (or `OFFSPRING` in the Makefile), is the number of offspring
|
||||
@@ -967,7 +983,7 @@ The Makefile simplifies how to reconfigure this value with the variable
|
||||
`OFFSPRING`:
|
||||
|
||||
```sh
|
||||
make clobber OFFSPRING=55 all
|
||||
make clobber OFFSPRING=55 all
|
||||
```
|
||||
|
||||
|
||||
@@ -978,7 +994,7 @@ Skip to [Portability](#portability).
|
||||
The following options **must always be passed to the compiler:**
|
||||
|
||||
```sh
|
||||
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
|
||||
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
|
||||
```
|
||||
|
||||
which running `make` will always do.
|
||||
@@ -988,13 +1004,13 @@ If you want to increase the number of offspring to `50` (`N`) and the size of th
|
||||
chromosome to `75` (`S`) you would do:
|
||||
|
||||
```sh
|
||||
make clobber OFFSPRING=50 MAX_SIZE=75 everything
|
||||
make clobber OFFSPRING=50 MAX_SIZE=75 everything
|
||||
```
|
||||
|
||||
If you wanted to change `N` to `3`:
|
||||
|
||||
```sh
|
||||
make clobber OFFSPRING=3 everything
|
||||
make clobber OFFSPRING=3 everything
|
||||
```
|
||||
|
||||
Remember that it cannot be less than `3`; *more correctly if it's less than
|
||||
@@ -1005,7 +1021,7 @@ result. Remember too that `S` (`MAX_SIZE`) cannot be less than `38`. Both `S` an
|
||||
If you wanted to change the maximum number attempts to 100 you could do:
|
||||
|
||||
```sh
|
||||
make clobber MAX_ATTEMPTS=100 everything
|
||||
make clobber MAX_ATTEMPTS=100 everything
|
||||
```
|
||||
|
||||
|
||||
@@ -1023,40 +1039,40 @@ Originally I tested it on the below systems.
|
||||
#### Fedora 26:
|
||||
|
||||
```sh
|
||||
$ clang --version|head -n1
|
||||
clang version 4.0.1 (tags/RELEASE_401/final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
|
||||
$ /lib64/libc-2.25.so |head -n1|cut -d',' -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.25
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
$ clang --version|head -n1
|
||||
clang version 4.0.1 (tags/RELEASE_401/final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
|
||||
$ /lib64/libc-2.25.so |head -n1|cut -d',' -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.25
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
```
|
||||
|
||||
#### CentOS Linux release 7.4.1708 (Core)
|
||||
|
||||
```sh
|
||||
$ clang --version|head -n1
|
||||
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
|
||||
$ /lib64/libc-2.17.so |head -n1 |cut -d, -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.17
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
$ clang --version|head -n1
|
||||
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
|
||||
$ /lib64/libc-2.17.so |head -n1 |cut -d, -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.17
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
```
|
||||
|
||||
#### Fedora 27:
|
||||
|
||||
```sh
|
||||
$ clang --version|head -n1
|
||||
clang version 5.0.1 (tags/RELEASE_501/final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
|
||||
$ /lib64/libc-2.26.so |head -n1|cut -d, -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.26
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
$ clang --version|head -n1
|
||||
clang version 5.0.1 (tags/RELEASE_501/final)
|
||||
$ gcc --version|head -n1
|
||||
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
|
||||
$ /lib64/libc-2.26.so |head -n1|cut -d, -f1-1
|
||||
GNU C Library (GNU libc) stable release version 2.26
|
||||
$ lscpu |grep Endian
|
||||
Byte Order: Little Endian
|
||||
```
|
||||
|
||||
#### macOS:
|
||||
@@ -1065,14 +1081,14 @@ System Version: macOS 10.13.4 (17E199)
|
||||
Kernel Version: Darwin 17.5.0
|
||||
|
||||
```sh
|
||||
$ gcc -v
|
||||
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
|
||||
Apple LLVM version 9.1.0 (clang-902.0.39.1)
|
||||
Target: x86_64-apple-darwin17.5.0
|
||||
Thread model: posix
|
||||
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
|
||||
$ uname -srmv
|
||||
Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
|
||||
$ gcc -v
|
||||
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
|
||||
Apple LLVM version 9.1.0 (clang-902.0.39.1)
|
||||
Target: x86_64-apple-darwin17.5.0
|
||||
Thread model: posix
|
||||
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
|
||||
$ uname -srmv
|
||||
Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
|
||||
```
|
||||
|
||||
#### <a name="bugs">An aside</a>
|
||||
@@ -1194,8 +1210,8 @@ additional cryptic features and evolved into B, BCPL, and finally C. We stopped
|
||||
when we got a clean compile on the following syntax:
|
||||
|
||||
```c
|
||||
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
|
||||
8)%2))P("|"+(*u/4)%2);
|
||||
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
|
||||
8)%2))P("|"+(*u/4)%2);
|
||||
```
|
||||
|
||||
> "To think that modern programmers would try to use a language that allowed
|
||||
@@ -1237,10 +1253,10 @@ it's a bad thing; **on the contrary it makes all of us C programmers even more
|
||||
talented! :)** I do wonder if he tested that bit of C code though:
|
||||
|
||||
```c
|
||||
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
|
||||
8)%2))P("|"+(*u/4)%2);
|
||||
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
|
||||
8)%2))P("|"+(*u/4)%2);
|
||||
```
|
||||
\
|
||||
|
||||
How is `R=;` valid? Since I don't have the context maybe there is something
|
||||
I'm missing but either way it's a funny piece. It could also be for irony itself
|
||||
(actually I had previously thought of somehow implementing something like that
|
||||
|
||||
+130
-132
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,21 +141,21 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>The author provided an alternate version which has a simpler keyboard for the
|
||||
monkey Eric. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co"># to prove evolution is a proven fact:</span></span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./id.sh</span></span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># to prove evolution is a proven fact:</span></span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./id.sh</span></span>
|
||||
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
|
||||
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co"># falling asleep or giving up:</span></span>
|
||||
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./monkey-words.sh</span></span></code></pre></div>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
|
||||
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># falling asleep or giving up:</span></span>
|
||||
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./monkey-words.sh</span></span></code></pre></div>
|
||||
<p>NOTE: the <a href="try.sh">try.sh</a> script will run the other two scripts but if the
|
||||
first one, <a href="id.sh">id.sh</a> is terminated early in the try script, the second one,
|
||||
<a href="monkey-words.sh">monkey-words.sh</a> will not be run.</p>
|
||||
@@ -168,26 +167,26 @@ make use of some of these.</p>
|
||||
about this under the <a href="#keyboards">keyboards</a> section, briefly referred to in the
|
||||
<a href="#what">what it is</a> section.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>weasel.alt</code> as you would <code>weasel</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co"># to prove evolution is a proven fact:</span></span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./id.alt.sh</span></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># to prove evolution is a proven fact:</span></span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./id.alt.sh</span></span>
|
||||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="co"># falling asleep or giving up:</span></span>
|
||||
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./monkey-words.alt.sh</span></span></code></pre></div>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># falling asleep or giving up:</span></span>
|
||||
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./monkey-words.alt.sh</span></span></code></pre></div>
|
||||
<p>NOTE: the <a href="try.alt.sh">try.alt.sh</a> script will run the other two scripts but if the
|
||||
first one, <a href="id.alt.sh">id.alt.sh</a> is terminated early in the try script, the second one,
|
||||
<a href="monkey-words.alt.sh">monkey-words.alt.sh</a> will not be run.</p>
|
||||
<p>You can reconfigure certain values. These are described by the author in more
|
||||
detail in the <a href="#constants">S, M and N Constants</a> section. The script above will
|
||||
make use of some of these.</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<p>You can reconfigure certain values. These are described by the author in more
|
||||
detail in the <a href="#constants">S, M and N Constants</a> section. The script above will
|
||||
make use of some of these.</p>
|
||||
@@ -204,7 +203,7 @@ from the phylogenetic tree of life.</p>
|
||||
<p>If you wish your computer to maintain one branch in the Cretaceous C code era,
|
||||
while using more Cenozoic minded code migration, read <a href="rpm.html">rpm.html</a>.</p>
|
||||
<p>If you find yourself in an evolutionary dead end, try:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ./weasel.1</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">man</span> ./weasel.1</span></code></pre></div>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<ol start="0" type="1">
|
||||
<li>Preface</li>
|
||||
@@ -229,7 +228,7 @@ didn’t want to reveal as much publicly and many people don’t like to read lo
|
||||
texts. To resolve this I think the best way is referencing the judges’ remarks:
|
||||
if you want a quick rundown of the entry try what they suggest and view the man
|
||||
page (it explains all the options and describes the program briefly):</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ./weasel.man</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">man</span> ./weasel.man</span></code></pre></div>
|
||||
<p>If that isn’t sufficient <strong>I would recommend reading this section</strong> <em>(and
|
||||
possibly the next)</em> where I attempt to give a brief explanation of the sections
|
||||
to make reading it easier and faster. In addition I want to point out a few
|
||||
@@ -440,13 +439,15 @@ an option I’ve mentioned and the other one is to do with the number of
|
||||
offspring)! If you want something of a walk through I suggest you follow the
|
||||
following:</p>
|
||||
<ol type="1">
|
||||
<li><p>Enable quiet mode and set an invalid mutation range; for example specify:</p>
|
||||
<pre><code>-qr101</code></pre></li>
|
||||
<li><p>Take a look at the first few lines. Kill the program and try invoking it
|
||||
with the following options:</p>
|
||||
<pre><code>-qr5</code></pre>
|
||||
<p><br />
|
||||
</p></li>
|
||||
<li>Enable quiet mode and set an invalid mutation range; for example specify:</li>
|
||||
</ol>
|
||||
<pre><code> -qr101</code></pre>
|
||||
<ol start="2" type="1">
|
||||
<li>Take a look at the first few lines. Kill the program and try invoking it
|
||||
with the following options:</li>
|
||||
</ol>
|
||||
<pre><code> -qr5</code></pre>
|
||||
<ol start="3" type="1">
|
||||
<li><p>Look at the first few lines again and compare it to the output of step #1.
|
||||
With the default string most modern systems shouldn’t take much time to - given
|
||||
decent parameters - come to an answer here but if necessary kill the program.</p></li>
|
||||
@@ -460,27 +461,26 @@ it must be a single parameter which means you’ll need to quote the string if i
|
||||
has more than one word (that is it contains spaces) or anything else interpreted
|
||||
specially by your shell e.g. parentheses. For instance if you just want to find
|
||||
<code>METHINKS</code> you could do one of:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> METHINKS</span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="st">"METHINKS"</span></span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="st">'METHINKS'</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> METHINKS</span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="st">"METHINKS"</span></span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="st">'METHINKS'</span></span></code></pre></div>
|
||||
<p>If you wanted <code>YOU ARE A MONKEY</code>:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="st">"YOU ARE A MONKEY"</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="st">'YOU ARE A MONKEY'</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="st">"YOU ARE A MONKEY"</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="st">'YOU ARE A MONKEY'</span></span></code></pre></div>
|
||||
<p>If you do one of:</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="st">"METHINKS IT IS A"</span> <span class="st">"MONKEY"</span></span>
|
||||
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> METHINKS IT IS A MONKEY</span></code></pre></div>
|
||||
<p><br />
|
||||
It will search for <code>MONKEY</code> in both cases; in other words it’s the last one.
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="st">"METHINKS IT IS A"</span> <span class="st">"MONKEY"</span></span>
|
||||
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> METHINKS IT IS A MONKEY</span></code></pre></div>
|
||||
<p>It will search for <code>MONKEY</code> in both cases; in other words it’s the last one.
|
||||
If the string is too long given the value of <code>S</code> (see<br />
|
||||
<strong><a href="#build">How to build</a></strong>) it will be truncated.</p>
|
||||
<p>If you actually do want to search for a string starting with a <code>-</code> you must
|
||||
disable further parsing of options by using the <code>-</code> option itself; for
|
||||
example if you were to do any of:</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q-</span> <span class="at">--</span> <span class="at">-test</span></span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q-</span> <span class="at">-test</span></span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-test</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q-</span> <span class="at">--</span> <span class="at">-test</span></span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q-</span> <span class="at">-test</span></span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-test</span></span></code></pre></div>
|
||||
<p>The target string will be: <code>-TEST</code>. This means though that here:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-test</span> <span class="at">-r5</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-test</span> <span class="at">-r5</span></span></code></pre></div>
|
||||
<p>The string to be searched would actually be <code>-r5</code> and the mutation rate
|
||||
will remain the default because after the <code>-</code> option is seen it will no
|
||||
longer parse additional options: only target strings if anything left on the
|
||||
@@ -489,9 +489,8 @@ examples of the last set of three above are equivalent i.e. the following two
|
||||
are equivalent:</p>
|
||||
<pre><code> -q-\
|
||||
-q --</code></pre>
|
||||
<p><br />
|
||||
As for the caveat I referenced what does the following do?</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-qr</span> 5</span></code></pre></div>
|
||||
<p>As for the caveat I referenced what does the following do?</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-qr</span> 5</span></code></pre></div>
|
||||
<p>In fact it will set quiet output and set the target string to be ‘5’. So the
|
||||
mutation rate will be out of range, thus enabling that Easter egg, but it will
|
||||
likely come to an answer fairly quickly because it’s just a single character. A
|
||||
@@ -499,18 +498,18 @@ note on the parsing of the <code>-</code> option; if the program is currently pa
|
||||
<code>argv[N]</code>, for example, and it encounters a <code>--</code> then depending on where
|
||||
the other options are in the command line it might still parse the options. Thus
|
||||
you have:</p>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./weasel <span class="at">-qr-r5</span></span>
|
||||
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="ex">quiet</span> output</span>
|
||||
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a><span class="ex">target</span> <span class="st">'METHINKS IT IS LIKE A WEASEL'</span></span>
|
||||
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Generation</span> 440 Offspring 20: METHINKS IT IS LIKE A WEASEL</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./weasel <span class="at">-qr-r5</span></span>
|
||||
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiet</span> output</span>
|
||||
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">target</span> <span class="st">'METHINKS IT IS LIKE A WEASEL'</span></span>
|
||||
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Generation</span> 440 Offspring 20: METHINKS IT IS LIKE A WEASEL</span></code></pre></div>
|
||||
<p>Similarly this would set quiet output, then an invalid mutation rate and then a
|
||||
mutation rate of 5:</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">--qrr5</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">--qrr5</span></span></code></pre></div>
|
||||
<p>If you were instead to do one of (for example):</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-r</span></span>
|
||||
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">-q-</span> <span class="at">-r</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">--</span> <span class="at">-r</span></span>
|
||||
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./weasel</span> <span class="at">-q</span> <span class="at">-q-</span> <span class="at">-r</span></span></code></pre></div>
|
||||
<p>Then it <em>would</em> set quiet output then see the <code>--</code> (the <code>-</code> option
|
||||
itself) and then the target string would <em>literally</em> be set to <code>-r</code> because
|
||||
it no longer cares about the <code>-</code> for option parsing. In other words options
|
||||
@@ -537,15 +536,15 @@ monkey mode be disabled? If yes how do we know if monkey mode was specially
|
||||
requested? There are at least two ways to go about it: I took the monkey safe
|
||||
(‘fool safe’) method; *if you explicitly request monkey mode you cannot disable
|
||||
it in the same invocation of <code>weasel</code>!</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./weasel <span class="at">-qr101r5r101r1r</span> test</span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="ex">quiet</span> output</span>
|
||||
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-6"><a href="#cb26-6" aria-hidden="true" tabindex="-1"></a><span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb26-7"><a href="#cb26-7" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate 0</span>
|
||||
<span id="cb26-8"><a href="#cb26-8" aria-hidden="true" tabindex="-1"></a><span class="ex">monkey</span> at typewriter</span>
|
||||
<span id="cb26-9"><a href="#cb26-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Generation</span> 16844 Offspring 22: TEST</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./weasel <span class="at">-qr101r5r101r1r</span> test</span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiet</span> output</span>
|
||||
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb26-6"><a href="#cb26-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb26-7"><a href="#cb26-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate 0</span>
|
||||
<span id="cb26-8"><a href="#cb26-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">monkey</span> at typewriter</span>
|
||||
<span id="cb26-9"><a href="#cb26-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">Generation</span> 16844 Offspring 22: TEST</span></code></pre></div>
|
||||
<p>So in this case I joined the options in the following order:</p>
|
||||
<ol type="1">
|
||||
<li><p><code>-q</code></p>
|
||||
@@ -576,24 +575,24 @@ matter</em> because of truncation but I do in any case specifically check for <c
|
||||
<p>Given that it was a short string it did find the answer relatively quickly, even
|
||||
in monkey mode.</p>
|
||||
<p>Another example:</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./weasel <span class="at">-q</span> <span class="at">-r101</span> test <span class="at">-r5</span></span>
|
||||
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a><span class="ex">quiet</span> output</span>
|
||||
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a><span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Generation</span> 109 Offspring 13: TEST</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./weasel <span class="at">-q</span> <span class="at">-r101</span> test <span class="at">-r5</span></span>
|
||||
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiet</span> output</span>
|
||||
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Generation</span> 109 Offspring 13: TEST</span></code></pre></div>
|
||||
<p>In this case I also enabled quiet mode but I didn’t join the options; the
|
||||
<code>-r101</code> reports that it’s out of range and sets monkey mode. I then specify
|
||||
the target string and then set a valid mutation rate. This disabled monkey mode
|
||||
which means that it’ll use the genetic algorithm.</p>
|
||||
<p>One more example of monkey mode:</p>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./weasel <span class="at">-q</span> <span class="at">-mr101</span> test <span class="at">-r5</span></span>
|
||||
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="ex">quiet</span> output</span>
|
||||
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a><span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a><span class="ex">monkey</span> at typewriter</span>
|
||||
<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a><span class="ex">Generation</span> 465298 Offspring 10: TEST</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./weasel <span class="at">-q</span> <span class="at">-mr101</span> test <span class="at">-r5</span></span>
|
||||
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiet</span> output</span>
|
||||
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate out of range</span>
|
||||
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">target</span> <span class="st">'test'</span></span>
|
||||
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">mutation</span> rate 5</span>
|
||||
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">monkey</span> at typewriter</span>
|
||||
<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">Generation</span> 465298 Offspring 10: TEST</span></code></pre></div>
|
||||
<p>Here I also requested quiet output and then <em>explicitly requested that Eric the
|
||||
monkey types.</em> After this I set the mutation rate to be 101 which would have
|
||||
set monkey mode (<em>in this case only temporarily as I later set it to a valid
|
||||
@@ -677,10 +676,10 @@ file and pass each string to the program itself</em>. I’ve included a script
|
||||
<code>test.sh</code> and a file of sample input <code>test-strings.txt</code> that you can play
|
||||
with.</p>
|
||||
<p>Try:</p>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> test</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> test</span></code></pre></div>
|
||||
<p>This will essentially make sure the program is compiled and then do:</p>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="fu">chmod</span> +x test.sh</span>
|
||||
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./test.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">chmod</span> +x test.sh</span>
|
||||
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./test.sh</span></span></code></pre></div>
|
||||
<p>The script will first try compiling the program (if necessary) and if it fails
|
||||
for any reason it will exit; else it will read each line in the file
|
||||
<code>test-strings.txt</code> (if the file doesn’t exist or can’t be read the script will
|
||||
@@ -690,7 +689,7 @@ string it’ll sleep approximately 2 seconds and then read the next string
|
||||
processed).</p>
|
||||
<p>You can pass additional options directly to the script but remember that it
|
||||
stops when there are no more strings in the file - so if you try:</p>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./test.sh</span> <span class="at">-q</span> test</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./test.sh</span> <span class="at">-q</span> test</span></code></pre></div>
|
||||
<p>The final string <code>test</code> won’t be searched for; it will however run the program
|
||||
in all invocations with quiet output enabled. The following are some notes about
|
||||
how the shell and the program interact with each other:</p>
|
||||
@@ -714,11 +713,11 @@ and the fact the program does not accept spaces other than a literal space<br />
|
||||
program prints an error message and then exits (returning 1). But since the
|
||||
keyboard doesn’t have <code>'\n'</code> if you were to type a <code>'</code> and send a
|
||||
<code>'\n'</code> before the closing <code>'</code> you might see something like:</p>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./weasel <span class="st">'!!</span></span>
|
||||
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a><span class="st">> '</span></span>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./weasel <span class="st">'!!</span></span>
|
||||
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a><span class="st"> > '</span></span>
|
||||
<span id="cb36-3"><a href="#cb36-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a><span class="st">'</span></span>
|
||||
<span id="cb36-5"><a href="#cb36-5" aria-hidden="true" tabindex="-1"></a><span class="st">'</span> not in keyboard <span class="st">" !"</span>#$<span class="op"><</span>%:<span class="op">>&</span><span class="st">'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"</span></span></code></pre></div>
|
||||
<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a> <span class="st">'</span></span>
|
||||
<span id="cb36-5"><a href="#cb36-5" aria-hidden="true" tabindex="-1"></a><span class="st"> '</span> not in keyboard <span class="st">" !"</span>#$<span class="op"><</span>%:<span class="op">>&</span><span class="st">'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"</span></span></code></pre></div>
|
||||
<p>I showed that <code>'</code> is in the keyboard already; however the user sent a
|
||||
<code>\n</code> (hence the secondary prompt <code>></code> on line two) before literally typing the
|
||||
closing <code>'</code> (also line two). But in order to make it clear what character is invalid I
|
||||
@@ -738,9 +737,9 @@ rather confusing and hard to read.</p>
|
||||
as well as some C keywords.</p></li>
|
||||
<li><p>The way <code>main()</code> is declared is:</p></li>
|
||||
</ol>
|
||||
<div class="sourceCode" id="cb37"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* Special C main() handler (encapsulation): */</span></span>
|
||||
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#define r</span><span class="op">(</span><span class="pp">main</span><span class="op">)</span><span class="pp"> main</span></span>
|
||||
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a>r<span class="op">(</span>k main<span class="op">(</span>k a<span class="op">,</span> E <span class="op">**</span>V<span class="op">))</span> <span class="op">{</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb37"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a> <span class="co">/* Special C main() handler (encapsulation): */</span></span>
|
||||
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define r</span><span class="op">(</span><span class="pp">main</span><span class="op">)</span><span class="pp"> main</span></span>
|
||||
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a> r<span class="op">(</span>k main<span class="op">(</span>k a<span class="op">,</span> E <span class="op">**</span>V<span class="op">))</span> <span class="op">{</span></span></code></pre></div>
|
||||
<p>It appears to be recursively defined but is it? And is it truly
|
||||
encapsulation? And is it executing code of any kind? It mightn’t seem like it
|
||||
isn’t encapsulation and also isn’t executing code but assuming it’s
|
||||
@@ -814,7 +813,7 @@ won’t spoil; yes this ironically and amusingly means I’ve left a rotten egg
|
||||
somewhere!).</p>
|
||||
<p>The Makefile simplifies how to reconfigure this value with the variable
|
||||
<code>MAX_SIZE</code>:</p>
|
||||
<div class="sourceCode" id="cb38"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber MAX_SIZE=55 all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb38"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber MAX_SIZE=55 all</span></code></pre></div>
|
||||
<p>The next macro that can be reconfigured, <code>M</code> (or <code>MAX_ATTEMPTS</code> in the
|
||||
Makefile), is the maximum attempts before giving up. This was added as another
|
||||
feature in 2024 but it was not made an alt version because there already is an
|
||||
@@ -822,7 +821,7 @@ alt version. This macro allows for seeing what happens when reaching the maximum
|
||||
number attempts without waiting for a very long time.</p>
|
||||
<p>The Makefile simplifies how to reconfigure this value with the variable
|
||||
<code>MAX_ATTEMPTS</code>:</p>
|
||||
<div class="sourceCode" id="cb39"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber MAX_ATTEMPTS=100 all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb39"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber MAX_ATTEMPTS=100 all</span></code></pre></div>
|
||||
<p>The final macro, <code>N</code> (or <code>OFFSPRING</code> in the Makefile), is the number of offspring
|
||||
per generation.</p>
|
||||
<p>Anything less than 4 will be set to 3 (that’s not a typo!) and this is part of
|
||||
@@ -832,23 +831,23 @@ both individually and together the program will use varying amounts of memory
|
||||
and the larger the values the more memory it’ll require.</p>
|
||||
<p>The Makefile simplifies how to reconfigure this value with the variable
|
||||
<code>OFFSPRING</code>:</p>
|
||||
<div class="sourceCode" id="cb40"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber OFFSPRING=55 all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb40"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber OFFSPRING=55 all</span></code></pre></div>
|
||||
<h3 id="compilation"><a name="compiling">Compilation</a></h3>
|
||||
<p>Skip to <a href="#portability">Portability</a>.</p>
|
||||
<p>The following options <strong>must always be passed to the compiler:</strong></p>
|
||||
<div class="sourceCode" id="cb41"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a><span class="ex">-DQ=</span><span class="st">'typedef'</span> <span class="at">-D</span><span class="st">'g(o)'</span><span class="op">=</span><span class="st">'goto o;'</span> <span class="at">-D</span><span class="st">'w(x)'</span><span class="op">=</span><span class="st">"x:"</span> <span class="at">-D</span><span class="st">'H(main)'</span><span class="op">=</span><span class="st">'r(main)'</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb41"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">-DQ=</span><span class="st">'typedef'</span> <span class="at">-D</span><span class="st">'g(o)'</span><span class="op">=</span><span class="st">'goto o;'</span> <span class="at">-D</span><span class="st">'w(x)'</span><span class="op">=</span><span class="st">"x:"</span> <span class="at">-D</span><span class="st">'H(main)'</span><span class="op">=</span><span class="st">'r(main)'</span></span></code></pre></div>
|
||||
<p>which running <code>make</code> will always do.</p>
|
||||
<p>If you want to increase the number of offspring to <code>50</code> (<code>N</code>) and the size of the
|
||||
chromosome to <code>75</code> (<code>S</code>) you would do:</p>
|
||||
<div class="sourceCode" id="cb42"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber OFFSPRING=50 MAX_SIZE=75 everything</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb42"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber OFFSPRING=50 MAX_SIZE=75 everything</span></code></pre></div>
|
||||
<p>If you wanted to change <code>N</code> to <code>3</code>:</p>
|
||||
<div class="sourceCode" id="cb43"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber OFFSPRING=3 everything</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb43"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber OFFSPRING=3 everything</span></code></pre></div>
|
||||
<p>Remember that it cannot be less than <code>3</code>; <em>more correctly if it’s less than
|
||||
4 it’s redefined to 3</em> so you could have passed in <code>-DN=2</code> (or <code>MAX_SIZE=2</code>) and have the same
|
||||
result. Remember too that <code>S</code> (<code>MAX_SIZE</code>) cannot be less than <code>38</code>. Both <code>S</code> and
|
||||
<code>N</code> are capped at <code>SIZE_MAX - 1</code> or whatever <code>M</code> (<code>MAX_ATTEMPTS</code>) is set to.</p>
|
||||
<p>If you wanted to change the maximum number attempts to 100 you could do:</p>
|
||||
<div class="sourceCode" id="cb44"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber MAX_ATTEMPTS=100 everything</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb44"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber MAX_ATTEMPTS=100 everything</span></code></pre></div>
|
||||
<h3 id="portability"><a name="portability">Portability</a></h3>
|
||||
<p>Skip to <a href="#bugs">An aside on bugs</a>.</p>
|
||||
<p>This entry requires at least C99 even if you translate digraphs. The program
|
||||
@@ -858,43 +857,43 @@ smaller and this I believe includes <code>SIZE_MAX</code>). I don’t think Wind
|
||||
ports would have many issues (if any) either but I have no way to test this.
|
||||
Originally I tested it on the below systems.</p>
|
||||
<h4 id="fedora-26">Fedora 26:</h4>
|
||||
<div class="sourceCode" id="cb45"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> version 4.0.1 <span class="er">(</span><span class="ex">tags/RELEASE_401/final</span><span class="kw">)</span></span>
|
||||
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb45-4"><a href="#cb45-4" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">7.3.1</span> 20180130 <span class="er">(</span><span class="ex">Red</span> Hat 7.3.1-2<span class="kw">)</span></span>
|
||||
<span id="cb45-5"><a href="#cb45-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> /lib64/libc-2.25.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span><span class="kw">|</span><span class="fu">cut</span> <span class="at">-d</span><span class="st">','</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb45-6"><a href="#cb45-6" aria-hidden="true" tabindex="-1"></a><span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.25</span>
|
||||
<span id="cb45-7"><a href="#cb45-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb45-8"><a href="#cb45-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb45"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> version 4.0.1 <span class="er">(</span><span class="ex">tags/RELEASE_401/final</span><span class="kw">)</span></span>
|
||||
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb45-4"><a href="#cb45-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">7.3.1</span> 20180130 <span class="er">(</span><span class="ex">Red</span> Hat 7.3.1-2<span class="kw">)</span></span>
|
||||
<span id="cb45-5"><a href="#cb45-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> /lib64/libc-2.25.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span><span class="kw">|</span><span class="fu">cut</span> <span class="at">-d</span><span class="st">','</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb45-6"><a href="#cb45-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.25</span>
|
||||
<span id="cb45-7"><a href="#cb45-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb45-8"><a href="#cb45-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<h4 id="centos-linux-release-7.4.1708-core">CentOS Linux release 7.4.1708 (Core)</h4>
|
||||
<div class="sourceCode" id="cb46"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> version 3.4.2 <span class="er">(</span><span class="ex">tags/RELEASE_34/dot2-final</span><span class="kw">)</span></span>
|
||||
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb46-4"><a href="#cb46-4" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">4.8.5</span> 20150623 <span class="er">(</span><span class="ex">Red</span> Hat 4.8.5-16<span class="kw">)</span></span>
|
||||
<span id="cb46-5"><a href="#cb46-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> /lib64/libc-2.17.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span> <span class="kw">|</span><span class="fu">cut</span> <span class="at">-d,</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb46-6"><a href="#cb46-6" aria-hidden="true" tabindex="-1"></a><span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.17</span>
|
||||
<span id="cb46-7"><a href="#cb46-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb46-8"><a href="#cb46-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb46"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> version 3.4.2 <span class="er">(</span><span class="ex">tags/RELEASE_34/dot2-final</span><span class="kw">)</span></span>
|
||||
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb46-4"><a href="#cb46-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">4.8.5</span> 20150623 <span class="er">(</span><span class="ex">Red</span> Hat 4.8.5-16<span class="kw">)</span></span>
|
||||
<span id="cb46-5"><a href="#cb46-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> /lib64/libc-2.17.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span> <span class="kw">|</span><span class="fu">cut</span> <span class="at">-d,</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb46-6"><a href="#cb46-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.17</span>
|
||||
<span id="cb46-7"><a href="#cb46-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb46-8"><a href="#cb46-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<h4 id="fedora-27">Fedora 27:</h4>
|
||||
<div class="sourceCode" id="cb47"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> version 5.0.1 <span class="er">(</span><span class="ex">tags/RELEASE_501/final</span><span class="kw">)</span></span>
|
||||
<span id="cb47-3"><a href="#cb47-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb47-4"><a href="#cb47-4" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">7.3.1</span> 20180303 <span class="er">(</span><span class="ex">Red</span> Hat 7.3.1-5<span class="kw">)</span></span>
|
||||
<span id="cb47-5"><a href="#cb47-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> /lib64/libc-2.26.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span><span class="kw">|</span><span class="fu">cut</span> <span class="at">-d,</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb47-6"><a href="#cb47-6" aria-hidden="true" tabindex="-1"></a><span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.26</span>
|
||||
<span id="cb47-7"><a href="#cb47-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb47-8"><a href="#cb47-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb47"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> clang <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> version 5.0.1 <span class="er">(</span><span class="ex">tags/RELEASE_501/final</span><span class="kw">)</span></span>
|
||||
<span id="cb47-3"><a href="#cb47-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> gcc <span class="at">--version</span><span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span></span>
|
||||
<span id="cb47-4"><a href="#cb47-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="er">(</span><span class="ex">GCC</span><span class="kw">)</span> <span class="ex">7.3.1</span> 20180303 <span class="er">(</span><span class="ex">Red</span> Hat 7.3.1-5<span class="kw">)</span></span>
|
||||
<span id="cb47-5"><a href="#cb47-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> /lib64/libc-2.26.so <span class="kw">|</span><span class="fu">head</span> <span class="at">-n1</span><span class="kw">|</span><span class="fu">cut</span> <span class="at">-d,</span> <span class="at">-f1-1</span></span>
|
||||
<span id="cb47-6"><a href="#cb47-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">GNU</span> C Library <span class="er">(</span><span class="ex">GNU</span> libc<span class="kw">)</span> <span class="ex">stable</span> release version 2.26</span>
|
||||
<span id="cb47-7"><a href="#cb47-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> lscpu <span class="kw">|</span><span class="fu">grep</span> Endian</span>
|
||||
<span id="cb47-8"><a href="#cb47-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Byte</span> Order: Little Endian</span></code></pre></div>
|
||||
<h4 id="macos">macOS:</h4>
|
||||
<p>System Version: macOS 10.13.4 (17E199)
|
||||
Kernel Version: Darwin 17.5.0</p>
|
||||
<div class="sourceCode" id="cb48"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> gcc <span class="at">-v</span></span>
|
||||
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Configured</span> with: <span class="at">--prefix</span><span class="op">=</span>/Library/Developer/CommandLineTools/usr <span class="at">--with-gxx-include-dir</span><span class="op">=</span>/usr/include/c++/4.2.1</span>
|
||||
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Apple</span> LLVM version 9.1.0 <span class="er">(</span><span class="ex">clang-902.0.39.1</span><span class="kw">)</span></span>
|
||||
<span id="cb48-4"><a href="#cb48-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Target:</span> x86_64-apple-darwin17.5.0</span>
|
||||
<span id="cb48-5"><a href="#cb48-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Thread</span> model: posix</span>
|
||||
<span id="cb48-6"><a href="#cb48-6" aria-hidden="true" tabindex="-1"></a><span class="ex">InstalledDir:</span> /Library/Developer/CommandLineTools/usr/bin</span>
|
||||
<span id="cb48-7"><a href="#cb48-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> uname <span class="at">-srmv</span></span>
|
||||
<span id="cb48-8"><a href="#cb48-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Darwin</span> 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018<span class="kw">;</span> <span class="ex">root:xnu-4570.51.1~1/RELEASE_X86_64</span> x86_64</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb48"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> gcc <span class="at">-v</span></span>
|
||||
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Configured</span> with: <span class="at">--prefix</span><span class="op">=</span>/Library/Developer/CommandLineTools/usr <span class="at">--with-gxx-include-dir</span><span class="op">=</span>/usr/include/c++/4.2.1</span>
|
||||
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Apple</span> LLVM version 9.1.0 <span class="er">(</span><span class="ex">clang-902.0.39.1</span><span class="kw">)</span></span>
|
||||
<span id="cb48-4"><a href="#cb48-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Target:</span> x86_64-apple-darwin17.5.0</span>
|
||||
<span id="cb48-5"><a href="#cb48-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Thread</span> model: posix</span>
|
||||
<span id="cb48-6"><a href="#cb48-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">InstalledDir:</span> /Library/Developer/CommandLineTools/usr/bin</span>
|
||||
<span id="cb48-7"><a href="#cb48-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> uname <span class="at">-srmv</span></span>
|
||||
<span id="cb48-8"><a href="#cb48-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Darwin</span> 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018<span class="kw">;</span> <span class="ex">root:xnu-4570.51.1~1/RELEASE_X86_64</span> x86_64</span></code></pre></div>
|
||||
<h4 id="an-aside"><a name="bugs">An aside</a></h4>
|
||||
<p>Skip to <a href="#rpm">Installing</a>.</p>
|
||||
<p>Any undocumented bugs are the result of insolent monkeys tampering with any
|
||||
@@ -1013,8 +1012,8 @@ When we found others were actually trying to programs with A, we quickly added
|
||||
additional cryptic features and evolved into B, BCPL, and finally C. We stopped
|
||||
when we got a clean compile on the following syntax:</p>
|
||||
</blockquote>
|
||||
<div class="sourceCode" id="cb49"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(;</span>P<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">),</span>R<span class="op">=;</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">))</span><span class="cf">for</span><span class="op">(</span>e<span class="op">=</span>C<span class="op">;</span>e<span class="op">=</span>P<span class="op">(</span><span class="st">"_"</span><span class="op">+(*</span>u<span class="op">++/</span></span>
|
||||
<span id="cb49-2"><a href="#cb49-2" aria-hidden="true" tabindex="-1"></a><span class="dv">8</span><span class="op">)%</span><span class="dv">2</span><span class="op">))</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">+(*</span>u<span class="op">/</span><span class="dv">4</span><span class="op">)%</span><span class="dv">2</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb49"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(;</span>P<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">),</span>R<span class="op">=;</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">))</span><span class="cf">for</span><span class="op">(</span>e<span class="op">=</span>C<span class="op">;</span>e<span class="op">=</span>P<span class="op">(</span><span class="st">"_"</span><span class="op">+(*</span>u<span class="op">++/</span></span>
|
||||
<span id="cb49-2"><a href="#cb49-2" aria-hidden="true" tabindex="-1"></a> <span class="dv">8</span><span class="op">)%</span><span class="dv">2</span><span class="op">))</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">+(*</span>u<span class="op">/</span><span class="dv">4</span><span class="op">)%</span><span class="dv">2</span><span class="op">);</span></span></code></pre></div>
|
||||
<blockquote>
|
||||
<p>“To think that modern programmers would try to use a language that allowed
|
||||
such a statement was beyond our comprehension! We actually thought of selling
|
||||
@@ -1055,10 +1054,9 @@ person to talk about it with is more than welcome!</em>). Ken suggested that the
|
||||
is a lack of common sense but since he was part of its creation I don’t think
|
||||
it’s a bad thing; <strong>on the contrary it makes all of us C programmers even more
|
||||
talented! :)</strong> I do wonder if he tested that bit of C code though:</p>
|
||||
<div class="sourceCode" id="cb50"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(;</span>P<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">),</span>R<span class="op">=;</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">))</span><span class="cf">for</span><span class="op">(</span>e<span class="op">=</span>C<span class="op">;</span>e<span class="op">=</span>P<span class="op">(</span><span class="st">"_"</span><span class="op">+(*</span>u<span class="op">++/</span></span>
|
||||
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a><span class="dv">8</span><span class="op">)%</span><span class="dv">2</span><span class="op">))</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">+(*</span>u<span class="op">/</span><span class="dv">4</span><span class="op">)%</span><span class="dv">2</span><span class="op">);</span></span></code></pre></div>
|
||||
<p><br />
|
||||
How is <code>R=;</code> valid? Since I don’t have the context maybe there is something
|
||||
<div class="sourceCode" id="cb50"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(;</span>P<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">),</span>R<span class="op">=;</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">))</span><span class="cf">for</span><span class="op">(</span>e<span class="op">=</span>C<span class="op">;</span>e<span class="op">=</span>P<span class="op">(</span><span class="st">"_"</span><span class="op">+(*</span>u<span class="op">++/</span></span>
|
||||
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a> <span class="dv">8</span><span class="op">)%</span><span class="dv">2</span><span class="op">))</span>P<span class="op">(</span><span class="st">"|"</span><span class="op">+(*</span>u<span class="op">/</span><span class="dv">4</span><span class="op">)%</span><span class="dv">2</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>How is <code>R=;</code> valid? Since I don’t have the context maybe there is something
|
||||
I’m missing but either way it’s a funny piece. It could also be for irony itself
|
||||
(actually I had previously thought of somehow implementing something like that
|
||||
for the contest but decided for the message by itself in the end). I would
|
||||
|
||||
Reference in new issue
Block a user