Good case for a Lambda function?

I’m using: SWI-Prolog version 8.0.2.

Is the code below a good case for refactoring using a Lambda function for the findall() operation? If so, can someone show me how this would be done? The code seems a bit verbose too me (I wrote it so no one will be offended if you agree that it’s too vebose).

Also, I assume I would need to include the yall package and if so, will that package be allowed in the PEngines sandbox?

		% ----->>>>> adjective_filter_word.
		% These are the words that we don't want in the adjective words list 
		%	when building the an adjectival noun phrase.
		adjective_filter_word(unlocks) :- !.
		% ----->>>>> is_not_filter_word
		is_not_filter_word(AdjWordsList, Word) :-
			member(Word, AdjWordsList),
			\+ adjective_filter_word(Word).
		% Empty adjective words list.
		filter_adjective_words_list_1([], []) :- !.
		filter_adjective_words_list_1(AdjWordsList, FilteredWordsList) :-
			findall(Word, is_not_filter_word(AdjWordsList, Word), FilteredWordsList).

Wow, quite the Hall of Fame list of authors on that paper! Pretty much a programming dream team for any company running a production version of Prolog. :slight_smile:

Thanks for the link! That one should go in the forum introductory E-mail, my opinion.

1 Like