users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

backtracking over streams?


From: Jean-Paul Berger
Subject: backtracking over streams?
Date: Mon, 04 Feb 2002 17:05:22 +0000

hi,


i write a program that needs to backtrack over streams. but my predicate only backtracks over one instance and doesn't work for backtracking over two clauses.

is there any way to get the desired effect? (prolog or c - doesn't matter, which).


thank you.



PS: my tries so far...:

% back/2: back(+Stream_Or_Alias, ?Character_Code_List)

back(S, [A|B]) :-
        peek_code(S, A), A \= -1,
        get_code(S, A),
        (back(S, B) -> true ; ( unget_code(S, A), fail )).
back(_,[]).



% DOESN'T WORK:

identifier(A, B) :-
       character(A, C),
       identifier(A, D),
       atom_concat(C, D, B).
identifier(A, B) :-
       character(A, B).
character(A, B) :-
       lower(A, C),
       name(B, [C]).
lower(A, B) :-
       back(A, [B]),
member(B, [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]).


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx




reply via email to

[Prev in Thread] Current Thread [Next in Thread]