Skip to content

Commit aa38870

Browse files
Fix paper_examples functions _dyck1_ptf and dyckk_ptf (#5)
* Fix paper_examples functions _dyck1_ptf and dyckk_ptf * Fix dyck2 test case
1 parent 6beb557 commit aa38870

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

paper_examples.rasp

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ sort_by_most_freq = _sort_by_freq_bos("§",300);
5151

5252
def _dyck1_ptf() {
5353
up_to_self = select(indices,indices,<=);
54-
n_opens = (indices+1)*aggregate(up_to_self,indicator(tokens_str=="("));
55-
n_closes = (indices+1)*aggregate(up_to_self,indicator(tokens_str==")"));
54+
n_opens = round((indices+1)*aggregate(up_to_self,indicator(tokens_str=="(")));
55+
n_closes = round((indices+1)*aggregate(up_to_self,indicator(tokens_str==")")));
5656
balance = n_opens - n_closes;
5757
prev_imbalances = aggregate(up_to_self,indicator(balance<0));
5858
return "F" if prev_imbalances>0 else
@@ -68,8 +68,8 @@ def dyckk_ptf(paren_pairs) {
6868
opens = indicator(tokens_str in openers);
6969
closes = indicator(tokens_str in closers);
7070
up_to_self = select(indices,indices,<=);
71-
n_opens = (indices+1)*aggregate(up_to_self,opens);
72-
n_closes = (indices+1)*aggregate(up_to_self,closes);
71+
n_opens = round((indices+1)*aggregate(up_to_self,opens));
72+
n_closes = round((indices+1)*aggregate(up_to_self,closes));
7373
depth = n_opens - n_closes;
7474
delay_closer = depth + closes;
7575
depth_index = selector_width(select(delay_closer,delay_closer,==) and up_to_self);

tests/tgt/paper_examples.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ running example is: hello
2020
>> = [0, 2, 1, 2, 1, 2, 2, 4, 2, 1, 1, 1, 4, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1, 4, 1, 1] (ints)
2121
>> = [§, d, v, s, l, m, a, n, ,, k, x, §, §, §, §, §, §, §, §, §, §, §, §, §, §, §, §, §, §, §] (strings)
2222
>> = [P, T, P, P, P, P, P, T, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, T, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, T, F, F, F, F, F, F, F, F] (strings)
23-
>> = [P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, T, P, P, P, P, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F] (strings)
23+
>> = [P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, T, P, P, P, P, P, P, P, P, P, P, P, T, P, T, P, T, P, T, P, P, P, P, P, P, P, P, P, P, P, P, P, T, P, F, F, F, F] (strings)
2424
>> = [P, T, P, T, P, T, P, P, P, P, P, P, P, P, P, T, P, P, P, T, P, P, P, T, P, T, P, T, P, F, F, F, F, F, F, F, F, F, F, F, F, F, F] (strings)
2525
>> .. .. ..
2626

0 commit comments

Comments
 (0)