Find if given element is present in list using prolog

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

КОМЕНТАРІ • 30

  • @amanrubey
    @amanrubey 3 роки тому +6

    how does computer get to know that member(X,[X|_]) means we have to look if X is a header in the list??

    • @FarahAlmujaljel
      @FarahAlmujaljel 8 місяців тому +1

      we put value using X ( upper case ) and the next atom _ which means don't read the 2 atom.

    • @amanrubey
      @amanrubey 8 місяців тому +1

      @@FarahAlmujaljel I don't even remember this shi* subject now 🤣 worst ever major ever

    • @FarahAlmujaljel
      @FarahAlmujaljel 8 місяців тому +1

      @@amanrubey bro so happy for you.

  • @MrNootka
    @MrNootka 3 роки тому +1

    thank you for this prolog playlist ^^

  • @stnzrvlnxo1730
    @stnzrvlnxo1730 3 роки тому +2

    Sir aapne abhut accha padhya hai

  • @stnzrvlnxo1730
    @stnzrvlnxo1730 3 роки тому +2

    👍👍👍isko jitni baar like karo kam hai.....

  • @channadissanayaka6450
    @channadissanayaka6450 5 місяців тому

    thank you very much

  • @abhishektanwar8070
    @abhishektanwar8070 4 роки тому +2

    I am getting this error "chat.pl:1:No permission to redefine imported procedure 'lists:member/2'" whenever I am trying to complie this code.Please help.

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

      same. Did you fix it?

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

      @@ThemisTheotokatos So , I found out that in this video , he is using the online prolog swi compiler. If you code in online compiler then you will not get this error ,otherwise on the compiler of your pc, you will get it. Hope , this helps.

    • @ThemisTheotokatos
      @ThemisTheotokatos 4 роки тому +2

      member is a reserved name?

  • @FarahAlmujaljel
    @FarahAlmujaljel 8 місяців тому

    you are kingggggg thank you !!

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

    unable to run this in swi prolog desktop app.

  • @MrNewtonJable
    @MrNewtonJable 3 роки тому

    what if the list is in a predicate, like a dictionary of words. im so stuck...

  • @MisterCK124
    @MisterCK124 5 років тому +2

    Thank you for trying to exlpain this. I however get the following error, if I do exactly what you do:
    ?- member(3,[1,2,3,4]).
    false.
    ?- trace(member).
    % lists:member/2: [call,redo,exit,fail]
    % member/2: [call,redo,exit,fail]
    true.
    [debug] ?- member(3,[1,2,3,4]).
    T Call: (8) member(3, [1, 2, 3, 4])
    T Call: (9) member(3, [2, 3, 4])
    T Call: (10) member(3, [3, 4])
    T Call: (11) member(3, [4])
    T Call: (12) member(3, [])
    T Fail: (12) member(3, [])
    T Fail: (11) member(3, [4])
    T Fail: (10) member(3, [3, 4])
    T Fail: (9) member(3, [2, 3, 4])
    T Fail: (8) member(3, [1, 2, 3, 4])
    false.
    Do you know what I am doing wrong?

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

      Can you pls share your facts which you defined as database for the given query to search on. Then only we can tell about error

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

      @@techdose4u thanks for responding
      These are the facts regarding member:
      % member(X,L) returns true if X is a member of list L
      L=[1,2,3,4]
      member(X,[X|_]).
      member(X,[_|T]):-member(X,T).

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

      Prolog rules and facts:-
      member(X,[X|_]).
      member(X,[_|T]):-member(X,T).
      Query:-
      member(3,[1,2,3,4]).
      Output: true
      This code is running fine.I don't see any problem. I ran it on online prolog ide (SWISH).

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

    Where is difinition of member() function??

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

      I am not getting your question. I have written everything. Please ask specifically.

    • @ManojKumar-qg9bw
      @ManojKumar-qg9bw 4 роки тому

      its just a name he declared, like how you would declare a variable by 'x' for instance.

  • @chandrashekhar-yv1dv
    @chandrashekhar-yv1dv 5 років тому +1

    Tq

  • @angelomarcone1448
    @angelomarcone1448 5 місяців тому

    oke

  • @samuraipiyush
    @samuraipiyush 11 місяців тому +1

    bhai tujhme kuch to baat h

  • @ungureanurobert2501
    @ungureanurobert2501 10 місяців тому

    y'all need to learn english before you try to make a video.