Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 ira 1
irasnyd@duallie prolog $ cat inc.pl
2
% Written By: Ira Snyder
3
% Due Date:   03-09-2005
4
% Homework #: 14 (Exercise #22)
5
 
6
diff_one(0,1).
7
diff_one(X,Y) :- diff_one(A,B), X is A+1, Y is B+1.
8
 
9
 
10
inc([],[]).
11
inc([H1|T1],[H2|T2]) :- diff_one(H1,H2), inc(T1,T2).
12
 
13
irasnyd@duallie prolog $ pl
14
Welcome to SWI-Prolog (Multi-threaded, Version 5.1.13)
15
Copyright (c) 1990-2003 University of Amsterdam.
16
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
17
and you are welcome to redistribute it under certain conditions.
18
Please visit http://www.swi-prolog.org for details.
19
 
20
For help, use ?- help(Topic). or ?- apropos(Word).
21
 
22
?- [inc].
23
% inc compiled 0.00 sec, 1,272 bytes
24
 
25
Yes
26
?- inc([1,7,5],[2,8,6]).
27
 
28
Yes
29
?- inc([1,7,5],X).
30
 
31
X = [2, 8, 6]
32
 
33
Yes
34
?- inc([],X).
35
 
36
X = []
37
 
38
Yes
39
?- inc(X,[2,8,6]).
40
 
41
X = [1, 7, 5]
42
 
43
Yes
44
?-
45
% halt
46
irasnyd@duallie prolog $
47