Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

62
LINES

< > BotCompany Repo | #1005337 // Current Weekday [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5581L/37K/127K).

1  
!759
2  
3  
!include #1005325 // Logic 4
4  
5  
concept AtEachPointInTime {
6  
  new Ref what;
7  
  
8  
  public S toString() { ret shortClassName(this) + " " + what; }
9  
}
10  
11  
concept ItIs {
12  
  new Ref what;
13  
  
14  
  public S toString() { ret shortClassName(this) + " " + what; }
15  
}
16  
17  
concept ExactlyOne {
18  
  new Ref what;
19  
  
20  
  public S toString() { ret shortClassName(this) + " " + what; }
21  
}
22  
23  
concept Which {
24  
  new Ref what;
25  
  
26  
  public S toString() { ret shortClassName(this) + " " + what; }
27  
}
28  
29  
concept Weekday {
30  
  public S toString() { ret shortClassName(this); }
31  
}
32  
33  
p {
34  
  truly(AtEachPointInTime,
35  
    uniq(ItIs, uniq(ExactlyOne,
36  
      uniq(Weekday))));
37  
38  
  for (AtEachPointInTime statement : listActually(AtEachPointInTime)) {
39  
    print("Right now: " + statement.what);
40  
    Concept question = exactlyOneToWhich(statement.what!);
41  
    print("Question thus: " + question);
42  
  }
43  
  
44  
  saveConcepts();
45  
}
46  
47  
static Concept exactlyOneToWhich(Concept c) {
48  
  // conversion case we are looking for
49  
  if (c instanceof ExactlyOne)
50  
    ret cnew(Which, "what", exactlyOneToWhich((Concept) cget(c, "what")));
51  
    
52  
  // general recurse
53  
  L<Concept.Ref> refs = c.refs;
54  
  if (l(refs) == 0) ret c; // no references in it, keep original
55  
  
56  
  // clone and process references
57  
  Concept c2 = cnew(_getClass(c));
58  
  Collection<S> names = getRefNames(c);
59  
  for (S name : names)
60  
    cset(c2, name, exactlyOneToWhich((Concept) cget(c, name)));
61  
  ret c2;
62  
}

Author comment

Began life as a copy of #1005336

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005337
Snippet name: Current Weekday [dev.]
Eternal ID of this version: #1005337/1
Text MD5: f82f8c4fd0bc678e336f063af7f6e3f5
Transpilation MD5: ee2d4888fe230a4329b3e15c8edfd16b
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-07 19:36:25
Source code size: 1454 bytes / 62 lines
Pitched / IR pitched: No / No
Views / Downloads: 511 / 812
Referenced in: [show references]