Hi. I am very new to Prolog, but I'm trying to learn it.
I am more famiilar with C, and wrote a program whose output gave me a list of connections between nodes in the form of a matrix, which in its simplest case looks like this:
[ -1, 1]
[ 1, -1]
In the example above, Row 1 is Node 1's connections, and -1 means NO connection exists. Any non-"-1" value means a connection exists. So in the example above, Node 1 is connected to Node 2 (and Node 2, or Row 2, is subsequently connected to Node 1).
What I'm trying to do in prolog is to be able to supply this list of lists as a variable, say "Data," and have Prolog give me back each node's connections.
If I give it [-1, 1, 1, 1, -1, -1, 1], I want it to give me the list [Node#, 2, 3, 4, 7], where node# increments as it goes through the lists of Data.
Does that make sense?
I have been against a brick wall for about 3 hours now, trying different things out, but I can never get my rules and predicates to give me what I want.
I can get the list of lists to get bound correctly, but I cannot come up with something that can get a new list of lists created with the data I want...
Like I said I am very much a beginner at Prolog...it doesn't seem like it should be anywhere near as difficult as it has been for me.
Any thoughts, suggestions?