Re: strange behaviuor




"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


.



Relevant Pages

  • Re: Frequent Flyer Earn One Million Aeroplan Miles in One Month
    ... oops, typo, make that *two* months. ... Geoff ... Prev by Date: ...
    (rec.travel.air)
  • Re: Some SUSE info
    ... > I had sort of assumed that it was a ... > typo and it probably was going to be a 'partition'? ... Prev by Date: ...
    (alt.os.linux.suse)
  • Q: Table within a table
    ... has other tables as entries? ... Does anybody have an idea of how to do this sort of thing? ... Geoff ... Prev by Date: ...
    (microsoft.public.vb.database.ado)
  • Re: Conditional expression problem
    ... a great place to save time trying to sort out problems. ... JL - RMP Days are NOT always on weekends - hence the issue. ... Geoff ... Prev by Date: ...
    (microsoft.public.mac.office.excel)
  • Re: strange behaviuor
    ... >> Works here, sort of. ... So am I. Exercise for the reader:) ... Geoff ... Prev by Date: ...
    (comp.lang.prolog)