From dima@solvo.ru  Mon Nov 27 14:25:16 2000
Received: from dual.solvo.ru (IDENT:root@dual.solvo.ru [195.201.44.111] (may be forged))
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA00986
	for <prolog@swi.psy.uva.nl>; Mon, 27 Nov 2000 14:25:15 +0100 (MET)
Received: from sx.loc.solvo.spb.su by dual.solvo.ru with esmtp
	(Smail3.2.0.111 #2) id m140OHY-001VNtC; Mon, 27 Nov 2000 16:25:20 +0300 (MSK)
Date: Mon, 27 Nov 2000 16:27:03 +0300 (MSK)
From: Dmitry Kuzmin <dima@solvo.ru>
X-Sender: dima@sx.loc.solvo.spb.su
To: prolog@swi.psy.uva.nl
Subject: please, answer on my FAQ (fwd)
Message-ID: <Pine.LNX.4.21.0011271625040.27912-100000@sx.loc.solvo.spb.su>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


Sorry for sending its all to Jan :) May be on promise me ?

see \|/

---------- Forwarded message ----------
Date: Mon, 27 Nov 2000 16:19:14 +0300 (MSK)
From: Dmitry Kuzmin <dima@solvo.ru>
To: jan@swi.psy.uva.nl
Subject: please, answer on my FAQ

About flag/3:

in SWI-Prolog 3.4.2 Reference Manual on flag/3 I not found info about
lifetime of flag or info about how see current flags in program
(monitoring, erase) (found only use). Please, add some comments for this
(I be afraid that programs with flag may grow and grow).

And how about
	succeeds_n_times((...,succeeds_n_times((...),Times2),...),Times1)
etc.

	And on example:
	how this work ?
	 
I use it how ->
I do it like ->

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% times counters
%--------------------------------------------------------------------------
% count +Goal success in ?Times or try +Goal +Times
n_times(Goal, Times) :-
	gensym(n_times,Name),
	flag(Name, _N, 0),!,
	repeat,
	( Goal,
		flag(Name, N, N+1),
		fail
	; flag(Name, Times, _N)
	).
%--------------------------------------------------------------------------
% try +Goal +Times times, successes count in Success
Success try_n_times(Goal, Times, Success) :-
	gensym(try_n_times,Name),
	flag(Name, _, 0),!,
	repeat,
	( Goal,
		flag(Name, N, N+1),
		flag(Name, Times, Times),
		Success=Times
	; flag(Name, Success, 0)
	).
%--------------------------------------------------------------------------

Sorry, if I harm you worktime or You don't undestand me. 

Good luck.

dima@solvo.ru


