Hi,

I would like to clarify some basic doubts:-

1) Are rules and facts declared by type variables or pred and 
func? I have seen the examples but they are shown as
member(X, [_ | Xs]) :- member(X, Xs).
as a predicate rule.
Here is some syntax for declaring for declaring rules and 
predicates.  I want to verify whether I am right. Plz tell me if I 
am :
a) Predicate Rule
:- type member(X, [_ | Xs]) :- member(x, Xs).

Predicate Rule
:- type member(X, [_ | Xs]).
This can also be written when the body in the previous statement 
is true.

b) Function Rule
:- type member(X, [_ | Xs]) = string :- member(x, Xs).

Function Rule
:- type member(X, [_ | Xs]) = string.
This can also be written when the body in the previous statement 
is true.

2) Consider an example for example for a goal,
member(X, As) => member(X, Bs).
Can any variable like As and Bs having 's' as suffix be called as 
a List??

I have some more queries :-
1) In the manual, or-nodes and and-nodes are defined as, or-nodes 
are constructors that can be used to construct terms of that 
particular type and and-nodes are types of arguments of 
constructors. Mode Information is attached to or-nodes of type 
trees.
a) What is a type tree?
b) I am bit confused... There are certain examples from the manual 
I mentioning below.
:- type employee
 	---> employee(
 		name :: string,
 		age :: int,
 		department :: string
 	).
Is this an and-node???

c)
:- type strange
 	---> foo(int)
 		; bar(string).
Is this an or-node?

d) What about this...
:- type fruit
 	---> apple
 		; orange
 		; banana
 		; pear.

e) Could I have type like this...
:- type fruit
 	---> apple
 		; orange
 		; banana(weight :: int,
 			quality :: string)
 		; pear(int).
What node would this be called?

2) In the manual, an example shows mode names are defined and then 
used. The example is below.
:- mode out_listskel ==
 	free >> listskel.
:- mode in_listskel ==
 	listskel >> listskel.

:- func length(list(T)) = int.
:- mode length(in_listskel) = out.
:- mode length(out_listskel) = int.

a)First out_listskel and in_listskel are defined. Why isn't pred 
or func being defined first?
b) Can modes be used inside other modes, or is it just that 
in_listskel and out_listskel just show how the arguments would be 
bound as the above example?
c) Should listskel be defined before it is used, if yes then as 
what?

Thanks,

Noel
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------

