Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Yarneo

    Longest Decreasing Subsequence

    Ok I have found the problem! I dont know why its like that, but when I tried duplicating the function setof() into my file and renamed it to setof2() like this: longest(List,SubList) :- setof2([Len,DecrSub],decreasing_sublist(List,Len,DecrSub),Ye),reverse(Ye,Y),funky(Y,SubList)...
  2. Yarneo

    Longest Decreasing Subsequence

    I thought of that but it isnt the case, i even changed the predicate name and it did the same thing. I tried this predicate: longest22(List,Ye) :- setof([Len,DecrSub],decreasing_sublist(List,Len,DecrSub),Ye). and this in the command line: 18 ?- longest22([5,7,4,9,3,2,1],SubList). and i got...
  3. Yarneo

    Longest Decreasing Subsequence

    these are the results I got for funky: my funky returned: 7 ?- funky([ [3, [3, 2, 1]], [3, [4, 3, 2]], [2, [2, 1]], [2, [3, 2]]], Result). Result = [3, 2, 1] ; Result = [4, 3, 2] ; false. and yours returned: 58 ?- funky2([ [3, [3, 2, 1]], [3, [4, 3, 2]], [2, [2, 1]], [2, [3, 2]]], Result)...
  4. Yarneo

    Longest Decreasing Subsequence

    hey kahleen, Ive tried tracing Ive tried every predicate individually. It all looks fine, also each predicate individually returns the result only once. Its only when they are encapsulated by my function it gives duplicates. I also noticed that when I use your funky, and I put an exclamation...
  5. Yarneo

    Longest Decreasing Subsequence

    First off, thanks for the gui tracer, I didnt know it existed and it certainly helps me alot. I used it, and it worked fine. The duplicate I get is when i do the ";" symbol after my first result. I tried to trace why it backtracks and does it all over and couldnt understand why. I do think it...
  6. Yarneo

    Longest Decreasing Subsequence

    Hey kahleen, I still get this: 4 ?- longest([5, 7, 4, 9, 3, 2, 1], Seq). Seq = [[7, 4, 3, 2, 1], [5, 4, 3, 2, 1]] ; Seq = [[7, 4, 3, 2, 1], [5, 4, 3, 2, 1]]. I use SWI-Prolog as instructed in our course. Furthermore, the professor insisted we dont use the ! symbol as to his opinion just covers...
  7. Yarneo

    Longest Decreasing Subsequence

    thanks so much for your reply. I understand my lack of efficiency on the first line of funky. But I do want all decreasing subsets. If I remove my second line of funky all i get is one long subsequence and not all the longest ones. Still, with the new funky, I do get duplicates even for one...
  8. Yarneo

    Longest Decreasing Subsequence

    Hi everyone, Im trying to code the Longest Decreasing Subsequences out of a given List in prolog. The problem is is that i get duplicates of the answers. here is my code: sublist([],[]). sublist([X|R],[X|S]):- sublist(R,S). sublist([_|R],S):- sublist(R,S). % longest(List,SubList)/2 with mode...

Part and Inventory Search

Back
Top