For Programmers: Free Programming Magazines  


Home > Archive > Prolog > July 2004 > Re: Little problem please help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Little problem please help
Magellan

2004-07-03, 4:08 am

Nick Wedd <nick@maproom.co.uk> wrote in message news:<5f8bvPmOCe5AFAl3@maproom.demon.co.uk>...

> Try
> sublist( [H|T], X ) :-
> del( H, X, NX ),
> sublist( T, NX ).
> I don't guarantee this will work, it is late.


I tried but when i run this program it display message "Out of local
stack", or (because I'ma newbie) I don't run this program properly.

To run it I type: valid_sublist([1,2,3,4,5],S). and it doesn't work.

Can you try it,please?

set_length([],0).
set_length([_|O],L):-set_length(O,L1),L is L1+1.

sum([],0).
sum([G|O],L):-sum(O,L1),L is L1+G.

del(X,[X|T],T).
del(X,[H|T],[H|NT]):-del(X,T,NT).


sublist( [H|T], X ) :-
del( H, X, NX ),
sublist( T, NX ).

valid_sublist( L, S ) :-
sublist( L, S ),
set_length( S, Set_length ),
Set_length < 4,
sum( S, Sum),
Sum < 10.

Thanx in advance

Michael
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com