** Summary ** An instance of [Category Humor]. ** Description ** [Richard Suchenwirth] 2006-01-28: Exhibit A was found in the waste-paper bin of a defunct software company: ====== ################################################################## # # # add.tcl # # Implemented function: # # add # # Usage: add a b # # Input: # a a number # b another number # # Output: # # The sum of the numbers # # Side effects: # # None # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ACME SOFTWARE # DESIGN L.L.C. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. # ##################################################################### proc add { a b } \ { set sum [ expr "$a" * "$b" ]; return $sum; }; ##################################################################### # # Test suite: # # add 0 0 == 0 # # add 2 2 == 4 # # Passed on Apr 1, 2005 - phb # ##################################################################### ====== Acknowledgement: part of the documentation (the LEGALESE) was copied from [tclCarbonProcesses], which however does not imply that the said page is in any material or immaterial connection with the defunct company :^) ---- [Lars H]: Yuck! A really gross coding style -- no wonder the company went belly-up (well, one can at least meekly hope that "who evil does he evil fares" even in the dotcom era). You're wrong about the test suite though -- e.g. [[add 3 1.5]] should pass without any problem. However, had the specs said "int" instead of "number" then it would have been another matter ... [RS]: True indeed. I moved the note down to here, it said: "Note also that the test suite is absolutely maximal - you can't add any test without getting failures..." The question boils down to solutions for ====== a + b = a * b ====== which can be transformed to ====== b = a / (a-1) ====== and there's indeed infinitely many solutions - examples: ======none a b 0 0 1 undefined, divide by zero 2 2 3 1.5 5 1.25 101 1.01 ... ====== So even bad jokes can lead to good mathematical excursions... :^) [AvL]: Does it need to be mentioned that the code itself is an example of bad style, because of the unbraced expression? Probably not :-) [RS]: The code intentionally contains all bad features I could think of. Canonically, it would be ====== proc add {a b} { expr {$a + $b} } ====== [AMG]: Per [Math Operators as Commands], you could also do '''[interp alias] "" add "" ::[tcl::mathop]::[+]''', except this also supports argument counts other than two. ''([DKF]: It also does the right thing, in case you weren't watching...)'' ---- [willdye] Those who enjoyed this page might also find http://thedailywtf.com/ amusing. ---- [bjornh] Run, fools! It's "Passed on Apr 1, 2005" <> Category Humor | RS