I'm having a problem to do with ordering. Its a real problem, to do with placing adjacent rectangles in a 2-dimensional space, but I'll try to distill it here to a simpler abstract problem.
Imagine that my source model is an ordered collection of objects with an integer-valued property "val", and I want to transform this into a collection of objects with an integer-valued property "cumVal", whose value is equal to the sum of all the preceding objects' "val" values (does that make sense?).
The problem I'm having is that I can't see how to do this using the BEFORE constraint, which can only constrain partial orders within a collection, not total orders. I can find the first value easily enough, doing something like
PATTERN cumVal(srcContainer, srcElement, cumVal)
WHERE IF NOT (el2 BEFORE srcElement IN srcContainer.contents)
THEN cumVal = 0
but I can't see how to do the rest.
Any tips?
Jim.