Init submit the testing Code

This commit is contained in:
YuCheng Hu 2024-01-05 21:22:49 -05:00
parent d8df72fb1e
commit 6643772ab5
2 changed files with 23 additions and 0 deletions

View File

View File

@ -0,0 +1,23 @@
; https://www.isharkfly.com/t/mumps-character-counting/15224
SET array("a")="adsakljasdira"
SET array("D")="DDD"
DO countCharsInAry(.array, .countByChar)
set name=""
f s name=$O(countByChar(name)) q:name="" w !,countByChar(name)
QUIT
countCharsInAry(ary,countByChar)
SET name=""
FOR SET name=$O(ary(name)) QUIT:name="" DO SET countByChar(name)=$$getCount(ary(name),name)
QUIT
getCount(str,subStr)
SET count=0
SET position=0
FOR {
SET position=$FIND(str, subStr, position)
QUIT:position=0
SET count=count+1
SET position=position
}
QUIT count