~burner/xsb/debianized-xsb

« back to all changes in this revision

Viewing changes to examples/chr/dom.chr

  • Committer: Michael R. Head
  • Date: 2006-09-06 22:11:55 UTC
  • Revision ID: burner@n23-20060906221155-7e398d23438a7ee4
Add the files from the 3.0.1 release package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* File:      dom.chr
 
2
** Author(s): Tom Schrijvers
 
3
** Contact:   xsb-contact@cs.sunysb.edu
 
4
** 
 
5
** Copyright (C) ECRC 1990
 
6
** 
 
7
** XSB is free software; you can redistribute it and/or modify it under the
 
8
** terms of the GNU Library General Public License as published by the Free
 
9
** Software Foundation; either version 2 of the License, or (at your option)
 
10
** any later version.
 
11
** 
 
12
** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
 
13
** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
14
** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
 
15
** more details.
 
16
** 
 
17
** You should have received a copy of the GNU Library General Public License
 
18
** along with XSB; if not, write to the Free Software Foundation,
 
19
** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
**
 
21
** $Id: dom.chr,v 1.2 2003/10/03 14:50:37 tschrijvers Exp $
 
22
** 
 
23
*/
 
24
:- chr_module(dom).
 
25
 
 
26
:- import member/2 from basics.
 
27
 
 
28
:- constraints dom/2. 
 
29
 
 
30
dom(X,[]) <=> fail.
 
31
dom(X,[Y]) <=> X = Y.
 
32
dom(X,L1), dom(X,L2) <=> intersection(L1,L2,L3), dom(X,L3).
 
33
 
 
34
intersection([],_,[]).
 
35
intersection([H|T],L2,[H|L3]) :-
 
36
        member(H,L2), !,
 
37
        intersection(T,L2,L3).
 
38
intersection([_|T],L2,L3) :-
 
39
        intersection(T,L2,L3).
 
40