Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!news.ecrc.de!ecrc!lyra!micha
From: micha@ecrc.de (Micha Meier)
Subject: Re: Can you do this?
Message-ID: <DGw7Jo.CAq@ecrc.de>
Sender: news@ecrc.de
Reply-To: micha@ecrc.de
Organization: European Computer-Industry Research Centre
References: <LUDEMANN.95Oct19121524@expernet5.expernet.com>
Date: Mon, 23 Oct 1995 08:28:36 GMT
Lines: 23

In article 95Oct19121524@expernet5.expernet.com, ludemann@expernet5.expernet.com (Peter Ludemann) writes:
>Not bad, but there's no need for append/3.  Use DCGs, to change this
>from O(N*2) to O(N) ("green" cuts would increase the efficiency, but
>not the correctness):
>
>get_nodes(X+Y) --> get_nodes(X), get_nodes(Y).
>get_nodes(X-Y) --> get_nodes(X), get_nodes(Y).
>get_nodes( +Y) -->               get_nodes(Y).
>get_nodes(X*Y) --> get_nodes(X), get_nodes(Y).
>get_nodes(X/Y) --> get_nodes(X), get_nodes(Y).
>get_nodes(X)   --> {atomic(X)}, [X].

It is really interesting how many wrong solutions people produce.
Hint: a-(b+c) :-)

--Micha

---
Micha Meier			------------------------------------------------
ECRC, Arabellastr. 17		The opinions expressed above are private
D-81925 Munich 81		and may not reflect those of my employer.
micha@ecrc.de, Tel. +49-89-92699-108, Fax  +49-89-92699-170

