home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7455 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.9 KB  |  55 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!claird
  3. From: claird@NeoSoft.com (Cameron Laird)
  4. Subject: In search of good idioms.
  5. Organization: NeoSoft Communications Services -- (713) 684-5900
  6. Date: Wed, 16 Dec 1992 14:24:52 GMT
  7. Message-ID: <BzCw1H.H24@NeoSoft.com>
  8. Lines: 45
  9.  
  10. I'm a newbie perl-plucker.  I'm working through some
  11. exercises I've set myself, in an effort to develop
  12. some taste in matters of perl style.  Current problem:
  13. write a permute program.  Such a program would, for
  14. example, when presented with input
  15.  
  16.     permute a1 zebra third
  17.  
  18. generate output something like
  19.  
  20.     a1 zebra third
  21.     a1 third zebra
  22.     zebra a1 third
  23.     zebra third a1
  24.     third a1 zebra
  25.     third zebra a1
  26.  
  27. I don't like any of the solutions I've conceived, and
  28. seek the judgment of those with more experience.  My
  29. current summary of the situation goes something like
  30. this:
  31.  
  32. The natural expressions of this problem involve an
  33. abstract data type, "collection of (sub)permutations",
  34. or its proceduralization by way of a parametrized re-
  35. cursion.  Procedure calls with more than one formal
  36. parameter look gross in perl (don't they?  Is there a
  37. way to handle them without clutter?), and there is no
  38. intrinsic support for data abstraction.  Therefore,
  39. all perl solutions of this problem look clunky.
  40.  
  41. Is this true?  Is there some slick way to use associative
  42. arrays to solve this?  Have I inadvertently hit on a
  43. well-known demo that's available on some ftp site I
  44. haven't yet visited?  I suspect that working through this
  45. to some conclusion will help me better understand the
  46. <<esprit de perl>>; thanks for any assistance.
  47.  
  48. I'm also having problems with wafe that the FAQ doesn't
  49. answer, but I'll save that for another time ...
  50. -- 
  51.  
  52. Cameron Laird
  53. claird@Neosoft.com (claird%Neosoft.com@uunet.uu.net)    +1 713 267 7966
  54. claird@litwin.com (claird%litwin.com@uunet.uu.net)      +1 713 996 8546
  55.