Re: strange behaviuor
- From: "Geoffrey Summerhayes" <sRuEmMrOnVoEt@xxxxxxxxxxx>
- Date: Wed, 11 Jan 2006 13:33:18 -0500
"Marco" <cimmo@xxxxxxxxx> wrote in message
news:43c3df1c$0$347$5fc30a8@xxxxxxxxxxxxxxxxxx
>
> initial_state([
> domandefatte([]),
> risposte([]),
> status([asking])
> ]).
>
>
> get_state(State, domandefatte, N) :-
> member(domandefatte(Done), State),
> member(N, Done).
>
>
> casual(S,N,N1):-N is random(3),casuale(S,N,N1).
> casuale(S,N,N1):-not(get_state(S,domandefatte,N)), N1 is N.
> casuale(S,N,N1):-get_state(S,domandefatte,N), N2 is
> random(3),casuale(S,N2,N1,B).
I assume this is a typo and reads casuale(S,N2,N1).
>
> start:-initial_state(Old),casual(Old, N, N1).
4 ?- initial_state(Old),casual(Old,N,N1).
Old = [domandefatte([]), risposte([]), status([asking])]
N = 2
N1 = 2 ;
No
Works here, sort of.
I'd tackle this a different way.
generate(N,L,L1) :- length(L,X), X > 0, Y is random(X),
remove_nth(Y,L,N,L1).
then
generate(N,[1,2,3],L1).
to get
N = 2
L1 = [1,3]
--
Geoff
.
- Follow-Ups:
- Re: strange behaviuor
- From: Marco
- Re: strange behaviuor
- References:
- strange behaviuor
- From: Marco
- strange behaviuor
- Prev by Date: Re: for loop in prolog
- Next by Date: Permutations on lists
- Previous by thread: Re: strange behaviuor
- Next by thread: Re: strange behaviuor
- Index(es):
Relevant Pages
|
|