Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

compare element in a list prolog
hi all,
im new to prolog

and im trying to make this pred.

compare[a,a,a,a].
yes


compare[a,e,a,t].
no


so if the element of the list are the same then its a yes  if not then its a
 no

how can i do this?

i was trying this but it didnt work

compare([H|T]):-
element(H, [H|T]).
element(H, [H|T]):-
element(H,T).

but this is wronge.  anyone can help me plz?

Report this thread to moderator Post Follow-up to this message
Old Post
kimos
09-24-04 01:59 AM


Re: compare element in a list prolog
urdad@hotmail.com (kimos) writes:

> hi all,
> im new to prolog
>
> and im trying to make this pred.
>
> compare[a,a,a,a].
> yes
>
>
> compare[a,e,a,t].
> no
>
>
> so if the element of the list are the same then its a yes  if not then its
 a no
>
> how can i do this?
>
> i was trying this but it didnt work
>
> compare([H|T]):-
> element(H, [H|T]).
> element(H, [H|T]):-
> element(H,T).
>
> but this is wronge.  anyone can help me plz?

What is element's base case?  It needs a fact to know if the recursive
procedure is successful by stating how the final step should appear.

Hopefully this hint will provoke you to add a simple line of code.
--
gnupg fingerprint: 4055 65EC 24D1 1DC2 700C  6654 6009 4AB9 F4C3 3E7E

Report this thread to moderator Post Follow-up to this message
Old Post
david emile lamy
09-24-04 08:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:27 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.