Question

Thank you for all the help so far!

Today I'm working on a database for a datalog program. I've gotten myself a bit stuck logically, I thought I had it figured out, but I've run into some dead ends.

I have Scheme inputs so basically a string with A Name and a list of list names. Then I have Facts, basically these lists have a name and a list of values.

I need to process the schemes create a lists with the name of the scheme which are lists with the variables and append the info from matching facts to the list of variables.

EG

       Scheme
           listname A B C D
           other    C D
       Fact
           listname 1 2 3 4
           listname 2 3 4 5
           other    9 6

I would need to have generated the following lists

        A     B       C      D
        1     2       3      4
        2     3       4      5
                      9      6

The issue I'm running into is that because I don't know how many lists I'll need until I see the input I'm using vector>>. The issue here is that when I encounter an element that only matches two of the lists, I don't quite know what to do. The issue is just getting more complex than I think it should be.

How can I generate separate lists that are easier to look at, and can vary in size?

So far I have made it so that I can take per the example above listname under schemes and facts and generate a nice vector, but then I get stuck when I hit other types such as other above.

I don't usually like to post such open questions on here, but I'm not super experienced in programming and am having trouble wrapping my head around a good way to get this done.

Thank you for any input!

Was it helpful?

Solution

From what I can see, the data structure is dictated by the input data.

Scheme is a vector of SchemeItem objects.
SchemeItem is an object (struct/class) containing a name and a vector of variables.
Fact is a vector of FactItem objects.
FactItem is an object containing a name and a vector of values.

Create the data structure, read the data into it. Then the fun starts (but that would be another question).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top