Skip to main content
added 738 characters in body
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8
 

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFC Normalization under-the-hood). It seems to have earned the moniker "Unicode-ready". Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবা��/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র সো ম বু বৃ শু শ]>শ %]> /.elems;'  Bengali_DOW.txt
3
45
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFC Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র  ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8
 

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFC Normalization under-the-hood). It seems to have earned the moniker "Unicode-ready". Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র সো ম বু বৃ শু শ %]> /.elems;'  Bengali_DOW.txt
3
5
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

added 738 characters in body
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFGNFC Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র স ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFG Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র স ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFC Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র স ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

added 738 characters in body
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFG Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র স ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

https://raku.org

Using Raku (formerly known as Perl_6)

raku -ne 'put m:g/\"/.elems;' 

OR

raku -ne '.match( /\"/, :global).elems.put;'

Sample Input (task is to count " doublequotes):

zero
"two"
"two","four"
"two","four","six"
"two","four","six","eight"

Sample Output:

0
2
4
6
8

FYI, I try very hard to stump Raku with Unicode characters and the language performs very well (it does NFG Normalization under-the-hood). Below, counting Bengali letters with Raku:

Sample Input (Bengali days-of-the-week from Wikipedia):

~$ cat  Bengali_DOW.txt
রবিবার/সূর্যবার Rabibār/Sūryabār
সোমবার/চন্দ্রবার Somabār/Chandrabār
মঙ্গলবার Mangalbār
বুধবার Budhabār
বৃহস্পতিবার/গুরুবার Brihaspatibār/Gurubār
শুক্রবার Shukrabār
শনিবার Shanibār

Sample Output (testing with first letter of each line):

~$ raku -ne 'put m:g/ <[র স ম বু বৃ শু শ]> /.elems;'  Bengali_DOW.txt
3
4
2
2
3
3
2

https://docs.raku.org/language/unicode#Normalization
https://raku.org

simplify code
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21
Loading
second code example added
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21
Loading
second code example added
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21
Loading
Source Link
jubilatious1
  • 3.9k
  • 10
  • 21
Loading