« Return to Thread: Working with Maps

Working with Maps

by Gerald Cantor :: Rate this Message:

Reply to Author | View in Thread

I have a Map in working memory. The Map has Strings as keys and Integers as values. It has 7 keys (REG301, REG302, ... REG307). I'm looking for a way to incorporate the following into the LHS of a rule:

For keys 301, 302, 303, compute the total of the Integer values (total 1)
For keys 301, 302, 303, compute the number of keys that have greater than 0 values (total 2)
Divide total 1 by total 2 (if total 2 > 0) and check against a range

For keys 304, 305, 306, 307, compute the total of the Integer values (total 3)
For keys 304, 305, 306, 307, compute the number of keys that have greater than 0 values (total 4)
Divide total 3 by total 4 (if total 4 > 0) and check against a range

I have not seen a way to collect / sum over select Map elements.

Any insight as to how I would compute the above totals using collect / sum would be very much appreciated.

Thanks in advance,
Gerald

 « Return to Thread: Working with Maps