-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General issue of abaplint with FOR...IN... ? Scrabble Score #195
Comments
thanks at first sight I think its an issue with "pcre", try using old style "regex" instead in https://github.com/abaplint/transpiler/blob/main/packages/runtime/src/builtin/matches.ts |
okay rename variable "char" to something else, it is a reserved keyword in JavaScript, which is the runtime. In the future it will automatically workaround this restriction |
after renaming, METHOD score.
DATA letter TYPE c.
DATA offset TYPE i.
DATA char_tab TYPE STANDARD TABLE OF c WITH EMPTY KEY.
DO.
TRY.
letter = substring( val = input
off = offset
len = 1 ).
offset += 1.
APPEND to_upper( letter ) TO char_tab.
CATCH cx_sy_range_out_of_bounds.
EXIT.
ENDTRY.
ENDDO.
result = REDUCE i(
INIT score TYPE i
FOR foo IN char_tab
NEXT score = score + COND #(
WHEN matches( val = foo pcre = `[AEIOULNRST]` )
THEN 1
WHEN matches( val = foo pcre = `[DG]` )
THEN 2
WHEN matches( val = foo pcre = `[BCMP]` )
THEN 3
WHEN matches( val = foo pcre = `[FHVWY]` )
THEN 4
WHEN matches( val = foo pcre = `[K]` )
THEN 5
WHEN matches( val = foo pcre = `[JX]` )
THEN 8
WHEN matches( val = foo pcre = `[QZ]` )
THEN 10 ) ).
ENDMETHOD. |
try again its not perfect, but better. Helping with fixes is welcome. Currently I'm trying to not have totally misleading error messages, and getting code run with correct results |
Thanks Lars, with the provided corrections the code works now on exercism. Thanks. |
It seems there is a general issue using FOR...IN... maybe only in combination with REDUCE.
Can you please check the issue?
In my local environment the code works well.
The text was updated successfully, but these errors were encountered: