CSE 130 - Programming Assignment #7 FAQ

  1. Can we create helper rules?

  2. Yes.

  3. I output all the correct values, but in different order from the problem writeup. Is this ok?

  4. Yes.

  5. How to I store all things matching a query in a list?

  6. Read the documentation for bagof.

  7. Can we use findall? How is it different from bagof?

  8. You can use either. For the purposes of this assignment they are very similar. A good example of their differences can be found here: http://cs.union.edu/~striegnk/learn-prolog-now/html/node97.html

  9. What does \= mean?

  10. Means that the two terms cannot be unified.

  11. Is there length in Prolog?

  12. You have to implement it if you want to use it.

  13. Can we use sum_list?

  14. Nope. That would be no fun.

  15. Having trouble with arithmetic! Why does this happen:
    helper(One,Two,Three) :- Three = One + Two.
    ?- helper(1,X,4).
    false.
    ?- helper(X,Y,Z).
    Z = X+Y.
    
    ?

  16. The "=" sign does not signify arithmetic equality, instead it performs unification. You probably want the "is" keyword.

  17. What additional tests should I run?

  18. Get creative! The usual suspects such as empty lists, and substituting things with variables are good things to try.