Download Jar. Libraryless. Click here for Pure Java version (3630L/23K).
1 | !7 |
2 | |
3 | static SS map = unstructMap([[lhm{null="assumed", "what is a bear?"="rejected", "a bear is an animal"="assumed", "a bear is dangerous"="assumed", "\"dude\" is a word for someone"="assumed", "Pouet is a website"="assumed", "an integer is a whole number"="assumed", "what is a small bird"="rejected", "what is a good joke"="assumed", "peter is a fun guy"="confirmed", "john is a person"="confirmed"}]]); |
4 | |
5 | static L<S> tests = ll("what is a bunny", "klaus is a fool", "john is a joker"); |
6 | |
7 | p { |
8 | dropValuesFromMapOtherThan(map, 'confirmed, 'rejected); |
9 | |
10 | final int wordIndex = 0; |
11 | L<S> input = map(func(S s) { getWord(s, wordIndex) }, keys(map)); |
12 | L<S> output = valuesList(map); |
13 | Map<S, Bool> map = mapValuesToBool(twoListsToHashMap(input, output), 'confirmed); |
14 | int diff = countValues(map, true)-countValues(map, false); |
15 | print("diff=" + diff); |
16 | final bool defaultValue = diff > 0; |
17 | final Set<S> exceptions = new TreeSet(keysWithValue(map, !defaultValue)); |
18 | O decider = func(S s) { contains(exceptions, getWord(s, wordIndex)) ? !defaultValue : defaultValue }; |
19 | |
20 | for (S test : tests) |
21 | print(" " + test + " => " + callF(decider, test)); |
22 | } |
Began life as a copy of #1010868
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010883 |
Snippet name: | Decide by word at index v2 [OK] |
Eternal ID of this version: | #1010883/11 |
Text MD5: | 867d193641a2c75369c5b79780a15a64 |
Transpilation MD5: | fe0c3a7d566f1f7b56dcd5f0cc8111f1 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-05 14:55:16 |
Source code size: | 1173 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 609 / 1249 |
Version history: | 10 change(s) |
Referenced in: | [show references] |