How do I add variables together?

I dont want to share my code and would prefer figuring his out on my own. So I am using Swish.swi-prolog and I am having trouble understanding how to add variables together. I am trying to add two things together. So lets say I have person(tax, age, gender) in query, and in the rules I have a ton of different people with different info. what if I wanted to add the tax and something else from another thing like othertax(tax)?

Use is/2. I will let you figure out the details.

1 Like

is/2? where would I put it? would it be something like is/2(tax, money)?

It is done this way using is/2.

?- Money = 100, Tax = 4, Total is Money + Tax.
Money = 100,
Tax = 4,
Total = 104.

It can be done as a functor but that is not the custom.

?- Money = 100, Tax = 4, is(Total, Money + Tax).
Money = 100,
Tax = 4,
Total = 104.

Would this work in program too? It looks like u are typing it into query.
I am new to this also.

What game lol, and I’ll try.

Haha sorry dude, I think I got the hang of it. except I would prefer not writing outcome in the query like this sum(Money, Tax, Total), unless this is the only way. I got punished recently playing a game on PS5 for running people over in a truck lol

Too confusing to understand atm lol

A topic you might find of value: Useful Prolog References

Also check out the site RosettaCode that has coding exmaples done in many programming languages. Here is a list of the Prolog examples: Category:Prolog - Rosetta Code

Thanks for the insight on the tools. Much help!