home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3909 < prev    next >
Internet Message Format  |  1991-08-24  |  1KB

  1. Xref: wupost comp.text:5325 comp.org.usenix:1617 alt.sources:3909 comp.sources.bugs:1394 comp.unix.misc:2465 comp.unix.programmer:3029 comp.unix.shell:3318 talk.bizarre:49671 alt.tasteless:3744
  2. Newsgroups: comp.text,comp.org.usenix,comp.unix-wizards,alt.sources,comp.sources.bugs,comp.unix.misc,comp.unix.programmer,comp.unix.shell,talk.bizarre,alt.tasteless
  3. Path: wupost!uunet!psinntp!netlabs!lwall
  4. From: lwall@netlabs.com (Larry Wall)
  5. Subject: most egregious modulus program
  6. Message-ID: <1991Aug23.234156.21347@netlabs.com>
  7. Sender: lwall@netlabs.com (Larry Wall)
  8. Organization: NetLabs, Inc.
  9. Date: Fri, 23 Aug 1991 23:41:56 GMT
  10. Lines: 26
  11.  
  12. [Sorry 'bout all the crossposting, but there's no rec.nroff.abuse yet...]
  13.  
  14. The ;login: journal graciously printed my entry to the "Most Egregious
  15. Misuse of Unix Utilities" contest.  Unfortunately, the program suffered
  16. a certain amount of bitrot during the publishing process, and several folks
  17. have asked for the correct version.  Here's the original (per)version,
  18. for your viewing pleasure and/or nausea:
  19.  
  20.     Task: modulus operator program
  21.  
  22.     Implementation: use line wrapping and diversion in nroff
  23.  
  24.     #!/bin/sh
  25.     nroff <<EOF | wc -w
  26.     'di xx
  27.     'll $2
  28.     'll +$2
  29.     `echo "10^$1" | bc | tr -d 1 | sed 's/0/0 /g'` \&
  30.     'di
  31.     EOF
  32.  
  33. (You invoke it with two numeric arguments.  For example, if you say
  34. "modulus 23 10", it prints out 3.)
  35.  
  36. Larry Wall
  37. lwall@netlabs.com
  38.