Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Prolog simple problem

Prolog simple problem

Scheduled Pinned Locked Moved Algorithms
questionhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quake2Player
    wrote on last edited by
    #1

    Hello, I have some facts like: asdf(a,b). asdf(b,c). asdf(c,d). etc. I'd like to do some function givemelettersinvolved(L) that instantiates in L a list that contains the constants involved in those facts for example asdf(a,b). asdf(b,c). givemelettersinvolved(L) would give L = [a, b, c] How can I make this? I was trying with ...(L) :- asdf(A,B), member(A,L), member(B,L). But its not working

    L 1 Reply Last reply
    0
    • Q Quake2Player

      Hello, I have some facts like: asdf(a,b). asdf(b,c). asdf(c,d). etc. I'd like to do some function givemelettersinvolved(L) that instantiates in L a list that contains the constants involved in those facts for example asdf(a,b). asdf(b,c). givemelettersinvolved(L) would give L = [a, b, c] How can I make this? I was trying with ...(L) :- asdf(A,B), member(A,L), member(B,L). But its not working

      L Offline
      L Offline
      Lanyards12
      wrote on last edited by
      #2

      Got it. You did a great job! But you should check out Personalized Water Bottles here. It's really cheap and useful!

      Q 1 Reply Last reply
      0
      • L Lanyards12

        Got it. You did a great job! But you should check out Personalized Water Bottles here. It's really cheap and useful!

        Q Offline
        Q Offline
        Quake2Player
        wrote on last edited by
        #3

        wtf are you talkin about anyway the answer was to use findall(X, predicate(X), List)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups