Article View: comp.lang.prolog
Article #1106Deterministic predicate question
From: F0O
Date: Tue, 28 Aug 1990 02:47
Date: Tue, 28 Aug 1990 02:47
32 lines
1269 bytes
1269 bytes
The build_board predicates will set up a beginning tic-tac-toe board.
The predicates work ok, but they are both non-deterministic. However,
our old friend length is deterministic.
I'm curious as to why length is deterministic where both of the
build_board predicates are not. Also, is there a way to make one of the
build_board predicates deterministic, without using the cut?
build_board1(10).
build_board1(SquareNum) :-
NextSquare = SquareNum + 1,
build_board1(NextSquare),
assert(board(SquareNum," ")).
build_board2(10).
build_board2(SquareNum) :-
assert(board(SquareNum," ")),
NextSquare = SquareNum + 1,
build_board2(NextSquare).
length([],0).
length([_|T],Len) :-
length(T,Tmp),
Len = Tmp + 1.
Thanks muchly,
[Tim]
Technical Details
Message-ID:
<90239.224751F0O@psuvm.psu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!psuvm!f0oShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!psuvm!f0o From: F0O@psuvm.psu.edu Newsgroups: comp.lang.prolog Subject: Deterministic predicate question Message-ID: <90239.224751F0O@psuvm.psu.edu> Date: 28 Aug 90 02:47:51 GMT Organization: Penn State University Lines: 32