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

Prolog syntax
Hello,

there are two elements of Prolog syntax that I do not understand:

a) =.. and []

What are "=.." and "[]" used for here ?

vp(vt,VS,Form) :-
mappend(V,SS,VS),
word(vt,V,S,Form),
member(Type,S),
Type =.. [TYPE],
Cat =.. [TYPE,SS],
Cat.

2) Var-Var

What does "G0-G" (and others) mean in this example ?

vp(Vform,G0-G) -->
v(obj_equi,Vform),
np(G0-G1),
vp(inf,G1-G).

Thanks for your help !



Report this thread to moderator Post Follow-up to this message
Old Post
myname
03-24-08 12:18 AM


Re: Prolog syntax
myname wrote:
> Hello,
>
> there are two elements of Prolog syntax that I do not understand:
>
> a) =.. and []
>
> What are "=.." and "[]" used for here ?
>
> vp(vt,VS,Form) :-
>     mappend(V,SS,VS),
>     word(vt,V,S,Form),
>     member(Type,S),
>     Type =.. [TYPE],
>     Cat =.. [TYPE,SS],
>     Cat.
>
> 2) Var-Var
>
> What does "G0-G" (and others) mean in this example ?
>
> vp(Vform,G0-G) -->
>     v(obj_equi,Vform),
>     np(G0-G1),
>     vp(inf,G1-G).
>
> Thanks for your help !
>
>

*)
[] is the notation for lists, so [TYPE] is a list of length one
containing only the variable TYPE.

the predicate append relates two lists to the concatenation of those, so
the query (copy & paste from swi prompt):

?- append([a,b],X,[a,b,c]).

finds X as the list containing only c:

X = [c] ;


*)
=.. decomposes a term into a list with its first element the predicate
name followed by the predicate's arguments.

you can also try this on the commandline:

?- pred(p1,p2,X,p4) =.. List.

List = [pred, p1, p2, X, p4] ;

it also works in the reverse way:
?- P =..  [pred, p1, p2, X, p4] .

P = pred(p1, p2, X, p4) ;

in your example TYPE contains the predicate name to be called, so Cat
becomes the predicate starting with TYPE and a single parameter SS, in
the last line "Cat.", the just built predicate is called.


*)
- is an infix defined function symbol and originally used to build
arithmetic expressions (calculation takes place via the "is" predicate).
if you don't use "is", you can build expressions of any content:

?- X=5-(3+1).

X = 5- (3+1) ;

works as well as

?- X = a - b.

X = a-b ;

so writing G0-G could also be written as pair(G0, G) to denote a pair of
variables, but the - is often used to make a predicate more readable (by
removing brackets).


i hope it's clearer now, but i'm a student and far behind the regular
posters here, so corrections and feedback are always welcome :)

greetings Martin

Report this thread to moderator Post Follow-up to this message
Old Post
Martin Riener
03-24-08 12:18 AM


Re: Prolog syntax
"Martin Riener" <martin.riener@gmail.com> a écrit dans le message de news:
47e6d280$0$11610$3b214f66@tunews.univie.ac.at...¨

[snip]

Perfect ! Thanks a lot !



Report this thread to moderator Post Follow-up to this message
Old Post
myname
03-24-08 01:10 PM


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:10 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.