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