Efficient append of N lists after N findall calls

Hello,

Suppose you have a predicate that in its body has 5 findall calls, one performed after the other leading to 5 lists, Now suppose you want to append those 5 lists as a result of the predicate.

One can write four appends to combine them all and return the combined list. I wonder what the most efficient way to combine such N lists are.

I am wondering if one can do better, somehow, than simply appending them, e.g. with difference lists, altough each list is generated by findall…

Perhaps best if there was a findall version that generates a difference list as a result …

thanks,

Dan

If you want findall with open list (difference list) then consider findall/4.

Can your list be converted to a set?
If so then consider ord_union/2.

1 Like

Thanks!,

I never knew that findall has a difference list version – thank you for pointing this out to me …

i should have re-checked in the docu :slight_smile: