%% %% lists.pl %% %% Author(s): %% %% CS 60 Hw 8, extra credit %% %% % some "nice" prolog settings... see assignment :- set_prolog_flag( prompt_alternatives_on, groundness ). :- set_prolog_flag(toplevel_print_options, [quoted(true), portray(true), attributes(portray), max_depth(999), priority(699)]). %% a couple of example predicates that might be helpful... % % member( E, L ) should be true if E is a top-level member of the list L % member should work when E is a variable or bound; L should be bound % member( E, [E|_] ). member( E, [_|R] ) :- member( E, R ). % % reverse( L, Rev ) should be true if Rev is the reverse of the list L % reverse should work when Rev is a variable or bound; L should be bound % reverse( [], [] ). % base case! reverse( [F|R], Rev ) :- reverse( R, Tmp ), append( Tmp, [F], Rev ). %% Here are commented-out placeholders for the two extra-credit predicates. %% %% Their descriptions are in the assignment itself. %% %% Be sure to comment each predicate you write! %% removeOne( E, L, NewL ) %% find( Pattern, Target, Index )