Recursive search in PROLOG

Поділитися
Вставка
  • Опубліковано 13 гру 2024

КОМЕНТАРІ • 21

  • @vyhuynh7230
    @vyhuynh7230 4 роки тому +6

    super easy to understand and follow! Thank you!!

  • @isharathilina
    @isharathilina 5 років тому +3

    best explain, thank you..

  • @chandrachurmukherjeejucse5816
    @chandrachurmukherjeejucse5816 Рік тому +1

    Goated Lectures

  • @Huda-dq9tm
    @Huda-dq9tm 5 років тому +3

    Right so, I tried writing the same code and it showed an error that essentially meant that I was trying to overwrite the already defined member predicate. The error went away when I changed the name of the predicate to ismember.

    • @techdose4u
      @techdose4u  5 років тому

      Hmm.... But it ran on my system!!

    • @Huda-dq9tm
      @Huda-dq9tm 5 років тому

      @@techdose4u Guess our version is different.

  • @varunkumar7237
    @varunkumar7237 2 роки тому +2

    This is same as list membership right?

  • @_DikshaBhise
    @_DikshaBhise 2 роки тому +1

    thank you

  • @pradyumanagrawal6089
    @pradyumanagrawal6089 5 років тому

    Can you explain how the "member" function works when there are two 'harry' in the list with the stack implementation of function?

  • @keerthithejas.c.9098
    @keerthithejas.c.9098 5 років тому +1

    Hi,
    First of all, your videos are great and thank you for these amazing videos. You are doing a great job. I am trying to understand how the search tree looks like while backtracking during recursion and I am kind of lost.
    Say for Example the below lines of code, removes all the occurrences of an element from a list :
    remove_all(_, [], []).
    remove_all(El, [El|Tail], Tail2):-
    remove_all(El, Tail, Tail2).
    remove_all(El, [Head|Tail], [Head|Tail2]):-
    not(El = Head),
    remove_all(El, Tail, Tail2).
    Now I query the following ?- remove_all( 2, [1,4,2,3,5,2,7,2], X). I used the online SWISH Prolog to execute it with the trace and I got the following tree
    Call:remove_all(2, [1, 4, 2, 3, 5, 2, 7, 2], _4896)
    Call:not(2=1)
    Exit:not('10758ac0-dc91-4335-a0d8-48b7b11776c0' : (2=1))
    Call:remove_all(2, [4, 2, 3, 5, 2, 7, 2], _5128)
    Call:not(2=4)
    Exit:not('10758ac0-dc91-4335-a0d8-48b7b11776c0' : (2=4))
    Call:remove_all(2, [2, 3, 5, 2, 7, 2], _5146)
    Call:remove_all(2, [3, 5, 2, 7, 2], _5146)
    Call:not(2=3)
    Exit:not('10758ac0-dc91-4335-a0d8-48b7b11776c0' : (2=3))
    Call:remove_all(2, [5, 2, 7, 2], _5164)
    Call:not(2=5)
    Exit:not('10758ac0-dc91-4335-a0d8-48b7b11776c0' : (2=5))
    Call:remove_all(2, [2, 7, 2], _5182)
    Call:remove_all(2, [7, 2], _5182)
    Call:not(2=7)
    Exit:not('10758ac0-dc91-4335-a0d8-48b7b11776c0' : (2=7))
    Call:remove_all(2, [2], _5200)
    Call:remove_all(2, [], _5200)
    Exit:remove_all(2, [], [])
    Exit:remove_all(2, [2], [])
    Exit:remove_all(2, [7, 2], [7])
    Exit:remove_all(2, [2, 7, 2], [7])
    Exit:remove_all(2, [5, 2, 7, 2], [5, 7])
    Exit:remove_all(2, [3, 5, 2, 7, 2], [3, 5, 7])
    Exit:remove_all(2, [2, 3, 5, 2, 7, 2], [3, 5, 7])
    Exit:remove_all(2, [4, 2, 3, 5, 2, 7, 2], [4, 3, 5, 7])
    Exit:remove_all(2, [1, 4, 2, 3, 5, 2, 7, 2], [1, 4, 3, 5, 7])
    X = [1, 4, 3, 5, 7]
    What I am not able to understand is how the backtracking is happening in these lines of code
    Exit:remove_all(2, [], [])
    Exit:remove_all(2, [2], [])
    Exit:remove_all(2, [7, 2], [7])
    Exit:remove_all(2, [2, 7, 2], [7])
    Exit:remove_all(2, [5, 2, 7, 2], [5, 7])
    Exit:remove_all(2, [3, 5, 2, 7, 2], [3, 5, 7])
    Exit:remove_all(2, [2, 3, 5, 2, 7, 2], [3, 5, 7])
    Exit:remove_all(2, [4, 2, 3, 5, 2, 7, 2], [4, 3, 5, 7])
    Exit:remove_all(2, [1, 4, 2, 3, 5, 2, 7, 2], [1, 4, 3, 5, 7])
    How does the prolog interpreter perform recursion on this? Can you please explain.

    • @techdose4u
      @techdose4u  5 років тому +1

      Actually i am not doing prolog from a very long time and so I am not able to help you in this. I wish I could but please take help from community or your friends.

    • @keerthithejas.c.9098
      @keerthithejas.c.9098 5 років тому

      OK !! No Problem. Thank you :)

  • @hudadhiaa
    @hudadhiaa 2 роки тому

    hello I want a hill climbing code in prolog can you help me even if it is in the form of a pdf or url

  • @kumarpurushottam6737
    @kumarpurushottam6737 4 роки тому

    It is saying , no permission to define imported_procrdure list:member/2. What does this mean bro

  • @malekferhi5029
    @malekferhi5029 5 років тому +1

    it's the same content as the one in the video of element membership in a list ! ain't it ?

    • @techdose4u
      @techdose4u  5 років тому +1

      You can say so. For element membership check as well, we did recursive search.

    • @malekferhi5029
      @malekferhi5029 5 років тому

      @@techdose4u Nice job anyway (y) keep up the good work , waiting for the next videos

  • @robertungureanu7016
    @robertungureanu7016 10 місяців тому +1

    pay attention, dude. your friend has already made a video explaining the same exercise, and it only took him half the time😂😂

  • @ittehadabdullah8221
    @ittehadabdullah8221 2 роки тому

    if your native is hindi please explain in hindi, it'll bring you more audience