assoc.quantity

assoc.quantity, function

def vector assoc.quantity(
    left:          text,
    leftQuantity:  number,
    right:         text,
    rightQuantity: number)  : number

Associates quantities between two sets connected by edges. For each edge, it assigns the minimum of the remaining quantities on the left and right nodes, then subtracts that amount from both.

Examples

table Edges = with
  [| as Left, as LeftQuantity, as Right, as RightQuantity |]
  [| "A", 10, "X", 6 |]
  [| "A", 10, "Y", 4 |]
  [| "B", 8, "X", 6 |]
  [| "B", 8, "Z", 3 |]

Edges.Result = assoc.quantity(
  Edges.Left,
  Edges.LeftQuantity,
  Edges.Right,
  Edges.RightQuantity) sort Edges.Left

show table "Assoc Quantity" with
  Edges.Left
  Edges.Right
  Edges.Result

Output:

Left Right Result
A X 6
A Y 4
B X 0
B Z 3

See also

User Contributed Notes
0 notes + add a note