(c) 2005 by Lousy Coder

That’s been my observation.


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

Ahh, to hell with it.



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,



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…

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

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

Now someone needs to produce a brainfuck program to do it. I would, but I value my sanity.

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” :smiley:

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.

How about Whitespace? Anyone care to reviews this version:


       
               
              
                  

                                       
                         
 

(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.

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:



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


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

That looks like an unterminated string ya got thar. :stuck_out_tongue:

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:


>>>>>> 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.