| 1 | Subject: Re: What language would you use? | 
|---|
| 2 | From: Tom Christiansen <tchrist@mox.perl.com> | 
|---|
| 3 | Date: 6 Nov 1994 15:14:51 GMT | 
|---|
| 4 | Newsgroups: comp.lang.python,comp.lang.tcl,comp.lang.scheme,comp.lang.misc,comp.lang.perl | 
|---|
| 5 | Message-Id: <39irtb$3t4@csnews.cs.Colorado.EDU> | 
|---|
| 6 | References: <39b7ha$j9v@zeno.nscf.org> <39hhjp$lgn@csnews.cs.Colorado.EDU> <39hvsu$dus@mathserv.mps.ohio-state.edu> | 
|---|
| 7 |  | 
|---|
| 8 | [...] | 
|---|
| 9 | If you're really into benchmarks, I'd love it if someone were to code up | 
|---|
| 10 | the following problems in tcl, python, and scheme (and whatever else you'd | 
|---|
| 11 | like).  Separate versions (one optimized for speed, one for beauty :-) are | 
|---|
| 12 | ok.  Post your code so we can time it on our own systems. | 
|---|
| 13 |  | 
|---|
| 14 | 0)  Factorial Test  (numerics and function calls) | 
|---|
| 15 |  | 
|---|
| 16 | (we did this already) | 
|---|
| 17 |  | 
|---|
| 18 | 1)  Regular Expressions Test | 
|---|
| 19 |  | 
|---|
| 20 | Read a file of (extended per egrep) regular expressions (one per line), | 
|---|
| 21 | and apply those to all files whose names are listed on the command line. | 
|---|
| 22 | Basically, an 'egrep -f' simulator.  Test it with 20 "vt100" patterns | 
|---|
| 23 | against a five /etc/termcap files.  Tests using more elaborate patters | 
|---|
| 24 | would also be interesting.  Your code should not break if given hundreds | 
|---|
| 25 | of regular expressions or binary files to scan. | 
|---|
| 26 |  | 
|---|
| 27 | 2)  Sorting Test | 
|---|
| 28 |  | 
|---|
| 29 | Sort an input file that consists of lines like this | 
|---|
| 30 |  | 
|---|
| 31 | var1=23 other=14 ditto=23 fred=2 | 
|---|
| 32 |  | 
|---|
| 33 | such that each output line is sorted WRT to the number.  Order | 
|---|
| 34 | of output lines does not change.  Resolve collisions using the | 
|---|
| 35 | variable name.   e.g. | 
|---|
| 36 |  | 
|---|
| 37 | fred=2 other=14 ditto=23 var1=23 | 
|---|
| 38 |  | 
|---|
| 39 | Lines may be up to several kilobytes in length and contain | 
|---|
| 40 | zillions of variables. | 
|---|
| 41 |  | 
|---|
| 42 | 3)  System Test | 
|---|
| 43 |  | 
|---|
| 44 | Given a list of directories, report any bogus symbolic links contained | 
|---|
| 45 | anywhere in those subtrees.  A bogus symbolic link is one that cannot | 
|---|
| 46 | be resolved because it points to a nonexistent or otherwise | 
|---|
| 47 | unresolvable file.  Do *not* use an external find executable. | 
|---|
| 48 | Directories may be very very deep.  Print a warning immediately if the | 
|---|
| 49 | system you're running on doesn't support symbolic links. | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 | I'll post perl solutions if people post the others. | 
|---|
| 53 |  | 
|---|
| 54 |  | 
|---|
| 55 | --tom | 
|---|
| 56 | -- | 
|---|
| 57 | Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com | 
|---|
| 58 |  | 
|---|
| 59 | "But Billy! A *small* allowance prepares you for a lifetime of small | 
|---|
| 60 | salaries and for your Social Security payments."    --Family Circus | 
|---|