I’m working on a project and I have a problem with a predicate that needs to get the shortest list of all the lists in a list of lists. Let’s say we have the following list:
Listoflists = [[u,f,c,x,e], [a,v,c], [r,j,[m], [a,l,c,p]]
So what I want is a predicate shortest/2 that when asked
. The thing is that I can’t use maplist/3
because of restrictions of the project and that’s why I am asking myself instead of using others’ questions.
I’ve seen that keysort/2
is useful in these cases, but for that to work I need a list with pairs (list, listlength)
(or something similar, I’m not sure) and I don’t know how to get that. I’m working in Ciao Prolog if it’s of any help, and thank you for your answers.