Sorting a list of lists in the order of ascending length

"Norbert E. Fuchs" <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
Hi

I need all subsets of a list in the order of ascending length of the subsets. 

Thus I wrote a predicate 

  generate_subset(+List, -SubList) that generates a SubList of List 

and that is also used for other purposes, and a variant of insertion sort

  sort_list_of_lists_in_ascending_length(+ListOfLists, -SortedListOfList) that sorts ListOfLists into SortedListOfList 

and then called 

  findall(SubList, generate_subset(List, SubList), SubLists), sort_list_of_lists_in_ascending_length(SubLists, SortedSubLists)

This works quite nicely and efficiently, but nevertheless I wonder whether there isn't a simpler way to perform this operation. 

Regards.

   --- nef
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.