home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / prolog / 2334 < prev    next >
Encoding:
Text File  |  1993-01-08  |  976 b   |  36 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!mcsun!julienas!irisa!ridoux
  3. From: ridoux@irisa.fr (Olivier Ridoux)
  4. Subject: Grotesque
  5. Message-ID: <1993Jan8.090450.8875@irisa.fr>
  6. Sender: news@irisa.fr
  7. Organization: IRISA, Rennes (Fr)
  8. Date: Fri, 8 Jan 93 09:04:50 GMT
  9. Lines: 25
  10.  
  11.  
  12. > I realised a while back that you can use DCGs for many programs that
  13. > don't look like parsing.  My favorite (and most grotesque) is flatten:
  14. > flatten(List, FlattenedList):-
  15. >         phrase(flatten(List), FlattenedList).
  16. > flatten([]) --> [].
  17. > flatten([Head|Rest]) -->
  18. >         flatten(Head),
  19. >         flatten(Rest).
  20. > flatten(List) -->
  21. >         [List].
  22.  
  23. I cannot see what is so *grotesque* in trying to give a condensed
  24. expression of the regularities a computation contains.  
  25.  
  26. I suppose you disapprove of using DCG for something which seems the
  27. opposite of syntactic analysis.  However, especially in Prolog, one
  28. should be used with non-directional thinking.
  29.  
  30. Olivier Ridoux
  31.  
  32.