For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2004 > NEWBIE QUESTION: List Searching









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author NEWBIE QUESTION: List Searching
FirewallVictim

2004-04-28, 1:51 pm

Im after a little bit of help. Im new to prolog and I'm trying to
find an element within a prolog list. I can find the element if it is
at the beginning of the list but can't figure out how to find it
anywhere within the list. For example [ok,lets,quit].

quitprog([quit|_]) :-
write('QUIT'),nl,!.

Any help/advice is much appreciated. Thanks in advance.
Cesar Rabak

2004-04-28, 3:50 pm

FirewallVictim escreveu:
> Im after a little bit of help. Im new to prolog and I'm trying to
> find an element within a prolog list. I can find the element if it is
> at the beginning of the list but can't figure out how to find it
> anywhere within the list. For example [ok,lets,quit].
>
> quitprog([quit|_]) :-
> write('QUIT'),nl,!.
>
> Any help/advice is much appreciated. Thanks in advance.


Get a look at the problem P03 at "P-99: Ninety-Nine Prolog Problems" in
http://www.hta-bi.bfh.ch/~hew/informatik3/prolog/p-99/

HTH

--
Cesar Rabak

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com