File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -274,9 +274,9 @@ succeed assertion.
274
274
275
275
In the action class, we use calls to the C < succ > method to do set up (in this
276
276
case, we prepare a new element in C < @!numbers > ). In the C < digit > method,
277
- we convert an Arabic digit into a Devanagari digit and add it to the last
278
- element of C < @!numbers > . Thanks to C < succ > , the last element will always be
279
- the number for the currently parsed C < digit > digits.
277
+ we use the Arabic digit as an index into a list of Devanagari digits and add
278
+ it to the last element of C < @!numbers > . Thanks to C < succ > , the last element
279
+ will always be the number for the currently parsed C < digit > digits.
280
280
281
281
grammar Digifier {
282
282
rule TOP {
@@ -288,7 +288,7 @@ the number for the currently parsed C<digit> digits.
288
288
289
289
class Devanagari {
290
290
has @!numbers;
291
- method digit ($/) { @!numbers[*-1] ~= $/.ord.&[+](2358).chr }
291
+ method digit ($/) { @!numbers.tail ~= <० १ २ ३ ४ ५ ६ ७ ८ ९>[$/] }
292
292
method succ ($) { @!numbers.push: '' }
293
293
method TOP ($/) { make @!numbers[^(*-1)] }
294
294
}
You can’t perform that action at this time.
0 commit comments