sclass BoolGuesserByWordAtIndex extends F1 { bool defaultValue; Set exceptions; int wordIndex; *() {} *(bool *defaultValue, Set *exceptions, int *wordIndex) {} Bool get(S s) { ret defaultValue ^ contains(exceptions, getWord(s, wordIndex)); } } static F1 boolGuesserByWordAtIndex(Map examples, final int wordIndex) { Map map = mapKeys(examples, func(S s) { getWord(s, wordIndex) }); int diff = countValues(map, true)-countValues(map, false); print("diff=" + diff); final bool defaultValue = diff > 0; final Set exceptions = new TreeSet(keysWithValue(map, !defaultValue)); ret BoolGuesserByWordAtIndex(defaultValue, exceptions, wordIndex); }