-
Notifications
You must be signed in to change notification settings - Fork 0
/
storing.krl
72 lines (55 loc) · 944 Bytes
/
storing.krl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ruleset song_store {
meta {
name "storing"
description <<
Stores songs sung
>>
author "Michael Angell"
logging on
sharing on
provides songs, hymns, secular_music
}
global {
songs = function() {
ent:songs
}
hymns = function() {
ent:hymns
}
secular_music = function() {
ent:songs.values().difference(ent:hymns.values())
}
}
rule collect_songs {
select when explicit sung
pre {
m = event:attr("song");
a = (ent:songs) => ent:songs | {};
a = a.put([time:new()], m);
}
{ noop(); }
fired {
set ent:songs a;
}
}
rule collect_hymns {
select when explicit found_hymn
pre {
m = event:attr("song");
a = (ent:hymns) => ent:hymns | {};
a = a.put([time:new()], m);
}
{ noop(); }
fired {
set ent:hymns a;
}
}
rule clear_songs {
select when song reset
{ noop(); }
fired {
clear ent:songs;
clear ent:hymns;
}
}
}