# (c) 2005 by Lousy Coder

**URL:** <https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722>\
**Category:** The BBQ Pit\
**Created:** [September 21, 2005, 3:48pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722 "2005-09-21T15:48:41Z")\
**Posts on this page:** 14\
**Page:** 4

<div class="post-metadata">

**Author:** ![tomndebb](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tomndebb](https://boards.straightdope.com/u/tomndebb)\
**Post date:** [September 25, 2005, 10:11pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/61 "2005-09-25T22:11:22Z")

</div>

> [@Crotalus](#):
>
> So, if they ever convert me from a mainframe dinosaur into a Java geek, my voice will change?

That’s been my observation.

---

<div class="post-metadata">

**Author:** ![Dead\_Badger](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Dead\_Badger](https://boards.straightdope.com/u/Dead_Badger)\
**Post date:** [September 25, 2005, 10:25pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/62 "2005-09-25T22:25:14Z")

</div>

```auto

response( N, "I AGREE!!!" ) :-
         N > 2000.
response( _, "THIS THREAD IS STUPID!!!" ).
?- response( Postcount, R ), write( R ), nl.

```

---

<div class="post-metadata">

**Author:** ![Mbossa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mbossa](https://boards.straightdope.com/u/Mbossa)\
**Post date:** [September 26, 2005, 12:39am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/63 "2005-09-26T00:39:11Z")

</div>

Ahh, to hell with it.

```auto

response :: Int -> String

response postcount
  | postcount > 2000 = "I AGREE!!!"
  | otherwise = "THIS THREAD IS STUPID!!!"

```

Or, if we want to be pointlessly inefficient and error prone,

```auto

response2 :: Int -> String

response2 = response2' 0
 where response2' 2001 _ = "I AGREE!!!"
       response2' _ 0 = "THIS THREAD IS STUPID!!!"
       response2' x y = response2' $ succ x $ pred y

```

---

<div class="post-metadata">

**Author:** ![Taran](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Taran](https://boards.straightdope.com/u/Taran)\
**Post date:** [September 26, 2005, 1:31am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/64 "2005-09-26T01:31:25Z")

</div>

> [@Mbossa](#):
>
> Ahh, to hell with it.
> 
> ```auto
> 
> response :: Int -> String
> 
> response postcount
> | postcount > 2000 = "I AGREE!!!"
> | otherwise = "THIS THREAD IS STUPID!!!"
> 
> ```
> 
> Or, if we want to be pointlessly inefficient and error prone,
> 
> ```auto
> 
> response2 :: Int -> String
> 
> response2 = response2' 0
> where response2' 2001 _ = "I AGREE!!!"
> response2' _ 0 = "THIS THREAD IS STUPID!!!"
> response2' x y = response2' $ succ x $ pred y
> 
> ```

Ergh, what language is that? It looks like ML, only not quite…

---

<div class="post-metadata">

**Author:** ![Mbossa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mbossa](https://boards.straightdope.com/u/Mbossa)\
**Post date:** [September 26, 2005, 1:48am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/65 "2005-09-26T01:48:54Z")

</div>

> [@Taran](#):
>
> Ergh, what language is that? It looks like ML, only not quite…

That would be Haskell. It’s a functional programming language like ML, but Haskell is ‘pure’ – functions can never have side-effects.

---

<div class="post-metadata">

**Author:** ![Taran](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Taran](https://boards.straightdope.com/u/Taran)\
**Post date:** [September 26, 2005, 2:05am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/66 "2005-09-26T02:05:57Z")

</div>

Ah yes, the language with the monads or, to quote my language design professor, “like ML only more so”. Thanks.

---

<div class="post-metadata">

**Author:** ![Mbossa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mbossa](https://boards.straightdope.com/u/Mbossa)\
**Post date:** [September 26, 2005, 5:18am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/67 "2005-09-26T05:18:02Z")

</div>

Now someone needs to produce a [brainfuck](http://en.wikipedia.org/wiki/Brainfuck) program to do it. I would, but I value my sanity.

---

<div class="post-metadata">

**Author:** ![Malacandra](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Malacandra](https://boards.straightdope.com/u/Malacandra)\
**Post date:** [September 26, 2005, 8:37am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/68 "2005-09-26T08:37:34Z")

</div>

> [@coop](#):
>
> It’s been a VERY long time… but:
> 
> EVALUATE POST-COUNT  
> WHEN \< 2000  
> PERFORM W100-STUPID  
> WHEN OTHER  
> PERFORM W200-AGREE  
> END-EVALUATE
> 
> would this be a little bit shorter??? 😃  
> Yeah, you’d still have to code the relevant sections and all… but I think my lines have less characters than yours… 😉

I’m not sure that compiles (WHEN \< 2000). Mind you, WHEN 0 THRU 1999 would compile just fine, and then we’re good to go.

And you meant “fewer” 😃

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [September 26, 2005, 9:40am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/69 "2005-09-26T09:40:32Z")

</div>

> [@Polerius](#):
>
> Re the OP, here’s something I sometimes find:
> 
> ```auto
> 
> // The speed of the vehicle
> int vehicleSpeed;
> 
> ```
> 
> WTF?

Whither WTF? - The redundant commenting? I don’t think it’s a particularly bad thing - excessive or redundant commenting is better than a shortage of it, or none at all.

---

<div class="post-metadata">

**Author:** ![Small\_Clanger](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Small\_Clanger](https://boards.straightdope.com/u/Small_Clanger)\
**Post date:** [September 26, 2005, 10:25am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/70 "2005-09-26T10:25:21Z")

</div>

> [@Mbossa](#):
>
> Now someone needs to produce a [brainfuck](http://en.wikipedia.org/wiki/Brainfuck) program to do it.

How about [Whitespace?](http://compsoc.dur.ac.uk/whitespace/index.php) Anyone care to reviews this version:

```auto

       
               
              
                  

                                       
                         
 

```

---

<div class="post-metadata">

**Author:** ![uglybeech](https://avatars.discourse-cdn.com/v4/letter/u/82dd89/32.png) [@uglybeech](https://boards.straightdope.com/u/uglybeech)\
**Post date:** [September 26, 2005, 11:33am UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/71 "2005-09-26T11:33:48Z")

</div>

(IF (\> (SETQ POSTCOUNT NUMBEROFOPSPOSTS) 2000) (PRINC “I AGREE”) (PRINC "THIS LIST IS STUPID))

© 2005 Uglybeech. All rights reserved. This code may not be reproduced, distributed, or criticized without express permission of the author. Violaters will be prosecuted to the fullest extend of the law. This code may not be used in the commission of crimes. This code does not express the opinions of Uglybeech. This code knows it’s made some very poor decisions recently, but it can give you its complete assurance that its work will be back to normal. It still has the greatest enthusiasm and confidence in the mission.

---

<div class="post-metadata">

**Author:** ![Metacom](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Metacom](https://boards.straightdope.com/u/Metacom)\
**Post date:** [September 26, 2005, 1:50pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/72 "2005-09-26T13:50:16Z")

</div>

> [@uglybeech](#):
>
> (IF (\> (SETQ POSTCOUNT NUMBEROFOPSPOSTS) 2000) (PRINC “I AGREE”) (PRINC "THIS LIST IS STUPID))

Why are you using the side-affecting special form SETQ to set POSTCOUNT to NUMBEROFPOSTS before you do the comparison?

And why did you capitalize all the symbols? Common Lisp (which I assume that is) will automatically capitalize all symbol names when they’re read; there’s no reason to capitalize symbols unless you’ve SETF’d READTABLE-CASE on _READTABLE_ to :PRESERVE.

Also, it just occured to me that the most succint way of doing this in Common Lisp would probably be to use the #'FORMAT function, like so:

```auto

(format t "~:[This list is stupid.~;I Agree.~]" (> number-of-posts 2000))

```

Overly pedantic Lisp criticism copyright (c) 2005 by **Metacom** , no rights reserved.

---

<div class="post-metadata">

**Author:** ![Mbossa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mbossa](https://boards.straightdope.com/u/Mbossa)\
**Post date:** [September 26, 2005, 8:21pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/73 "2005-09-26T20:21:48Z")

</div>

> [@uglybeech](#):
>
> (IF (\> (SETQ POSTCOUNT NUMBEROFOPSPOSTS) 2000) (PRINC “I AGREE”) (PRINC "THIS LIST IS STUPID))

That looks like an unterminated string ya got thar. 😛

---

<div class="post-metadata">

**Author:** ![Taran](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Taran](https://boards.straightdope.com/u/Taran)\
**Post date:** [September 26, 2005, 8:35pm UTC](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722/74 "2005-09-26T20:35:53Z")

</div>

> [@Mangetout](#):
>
> Whither WTF? - The redundant commenting? I don’t think it’s a particularly bad thing - excessive or redundant commenting is better than a shortage of it, or none at all.

I disagree. Every comment costs vertical screen space; the more comments there are, the fewer lines of code are visible. So comments with zero value make the rest of the program harder to see, and so hinder understanding.

Speaking of hindering understanding:

```auto

>>>>>> Byte 0 holds postcount bytes 1 2 3 4 5 left empty Postcount via character input left as an exercise
[->>+<<] >> Copy postcount into byte 2 leaving byte 0 empty
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Load byte 6 with 65 (the ASCII code for 'A')
[>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-] Fill 7 to 37 with 'A'
>+++++++++++++++++++ T
>+++++++ H
>+++++++++ I
>++++++++++++++++++ S
>-------------------------------- space
>+++++++++++++++++++ T
>+++++++ H
>+++++++++++++++++ R
>++++ E
> A
> +++ D
>-------------------------------- space
>++++++++ I
>++++++++++++++++++ S
>-------------------------------- space
>++++++++++++++++++ S
>+++++++++++++++++++ T
>++++++++++++++++++++ U
>+++++++++++++++ P
>++++++++ I
>+++ D
>------------------- Period
>--------------------------------------------------------------------------- Null terminator
>++++++++ I
>-------------------------------- space
> A
>++++++ G
>+++++++++++++++++ R
>++++ E
>++++ E
>------------------------------- !
>--------------------------------------------------------------------------- Null terminator
>++>++>++>++>++>++>++>++>++>++>++ move 2 into bytes 39 through 49
<<<<<<<<<<<[->+>+>+>+>+>+>+>+>+>+<<<<<<<<<<] 0 byte 39 4 in bytes 40-49
>[->+>+>+>+>+>+>+>+>+<<<<<<<<<] 0 byte 36; 8 in bytes 41-49
>[->+>+>+>+>+>+>+>+<<<<<<<<]
>[->+>+>+>+>+>+>+<<<<<<<]
>[->+>+>+>+>+>+<<<<<<]
>[->+>+>+>+>+<<<<<]
>[->+>+>+>+<<<<]
>[->+>+>+<<<]
>[->+>+<<]
>[->+<] Now 2048 is in byte 49
[<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-]Move 2048 into byte 3
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<------------------------------------------------Subtract 48 leaving exactly 2000 in byte 3
<<<+>>>>>+<<<< Set bytes 0 and 5 to 1
[>[->][<<+>[>>-<<][>>>>[.>]<[]]>>+<<[-<]>>+<[<<->>][>>>>>>>>>>>>>>>>>>>>>>>>>>>>[.>]<[]]>] The meat Exchange decrement bytes 2 and 3 testing for zero using the boundary bytes which are initially 1; they only remain 1 if the tested byte is 0 Printing is trivial say what you like about brainfuck it's very easy to print nullterminated strings After printing the program loops forever though it's not hard to do a program exit from there just imagine 60 or 70 pointer increments where the infinite loops are

```

The above assumes 16-bit cells. The original Brainfuck specification does not specify a cell size, and output is still assumed to be 8-bit, so this program is at least arguably conformant Brainfuck. Porting this code to a machine with 8-bit cells is left as an excercise to those who find it interesting; that I wrote the above is surely enough to prove a point of some sort. BF also doesn’t specify a comment character, hence the stream-of-consciousness commenting style: my “comments” are just characters that BF doesn’t happen to ascribe any particular meaning to. Also, the computation of 2^11 can be done more tersely.

_All this and more copyright **Taran** , every single right reserved. Wait, what does that text at the bottom of the page say? Oh balls._

[Previous page](https://boards.straightdope.com/t/c-2005-by-lousy-coder/322722.md?page=3)
