diff options
| author | James Smith <js5@sanger.ac.uk> | 2022-06-15 07:50:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-15 07:50:23 +0100 |
| commit | bcd2fe8e555ce84e0d957e860d8f7cc216a39c5c (patch) | |
| tree | 59477556f96204f782ee61a0751b361fe5892b65 /challenge-169 | |
| parent | 657910d89286dd5eefdf995a93612b1077bd6b9e (diff) | |
| download | perlweeklychallenge-club-bcd2fe8e555ce84e0d957e860d8f7cc216a39c5c.tar.gz perlweeklychallenge-club-bcd2fe8e555ce84e0d957e860d8f7cc216a39c5c.tar.bz2 perlweeklychallenge-club-bcd2fe8e555ce84e0d957e860d8f7cc216a39c5c.zip | |
Y.O.D.A Yoda
Diffstat (limited to 'challenge-169')
| -rw-r--r-- | challenge-169/james-smith/README.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/challenge-169/james-smith/README.md b/challenge-169/james-smith/README.md index e51614d1ea..3e9971e507 100644 --- a/challenge-169/james-smith/README.md +++ b/challenge-169/james-smith/README.md @@ -40,6 +40,8 @@ The output in each row is the brilliant number and the two primes which are it's **Note:** Both in this and the next challenge we utilise a classic "c-style" `for`-loop. This construct allows us to combine the variable initialized (and declaration), the end condition, and the increment of the number into a single statement. We code rewrite this a postfix `for(each)` in this case, but would need an declaration/initialisation statement for `$n` and `@f` anyway. Also in challenge 2 it isn't possible to use a postfix for `for` as this doesn't allow us to use the `next` trick to short cut the `grep` inside the `gcd` call. +**Note:** to make the code easier to read we use a *Yoda* condition, where we reverse the value and the code evaluation - so instead if say `$a == 2` we say `2 == $a`. + **Moan:** Why is there no `sayf` function similar to `printf` - using `say sprintf` seems a bit "messy" each time... ``` |
