0

I have defined a color palette called tableau10 in Clingo:

tableau10(blue;orange;red;teal;green;yellow;purple;pink;brown;gray).

Is there a way to compare the colors by the order they appear in my color definition? (e.g., blue = 0, orange = 1, red = 2, ...)

My goal is to be able to claim things like blue < orange, blue < gray...

CherryQu
  • 3,343
  • 9
  • 40
  • 65

1 Answers1

1

The predicate tableau10 is unordered. To do such comparisons you'd have to encode order in one way or another. You could for example assign numbers to the colors value(blue, 1). value(orange, 2). ... and compare the associated numbers when necessary, or you could write lessthan(blue, orange). lessthan(orange, red). ... lessthan(brown,gray). and also add the transitivity rule lessthan(A, C) :- lessthan(A, B), lessthan(B, C).

vukk
  • 523
  • 2
  • 11
  • Thank you! I understand how to use `lessthan` to compare colors now. Could you elaborate on how to use `value` to compare the numbers associated with each color? – CherryQu Feb 18 '19 at 06:33
  • 1
    With the addition of the `value` predicate, `lessthan(blue, gray).` could be expressed as `value(blue, N), value(gray, M), N – vukk Feb 18 '19 at 13:44