Using "/" on a stzString

20 views
Skip to first unread message

Mansour Ayouni

unread,
Nov 18, 2022, 11:39:18 AM11/18/22
to The Ring Programming Language

Hi All,


Five nice use cases of the / operator on a Softanza string:


# Usecase 1: Dividing the string into 3 equal parts
? Q("RingRingRing") / 3
# --> [ "Ring", "Ring", "Ring" ]


# Usecase 2: Splitting the string using a given char (or substring)
? Q("Ring;Python;Ruby") / ";"
# --> [ "Ring", "Python", "Ruby" ]


# Usecase 3: Splitting the string on each char verifying a condition
? Q("Ring:Python;Ruby") / W('Q(@Char).IsNotLetter()')
#--> [ "Ring", "Python", "Ruby" ]


# Usecase 4: Sharing the string equally between three stakeholders
? Q("RingRubyJava") / [ "Qute", "Nice", "Good" ]
# --> [ [ "Qute", "Ring" ], [ "Nice", "Ruby" ], [ "Good", "Java" ] ]


# Usecase 5: Specifying how mutch char we should give to every stakeholder
? Q("IAmRingDeveloper") / [
        :Subject = 1,
        :Verb = 2,
        :Noun1 = 4,
        :Noun2 = :RemainingChars
]
#--> [ :Subject = "I", :Verb = "Am", :Noun1 = "Ring", :Noun2 = "Developer" ]


Here it is running in Ring Notepad:


image.png
Best,
Mansour

Mahmoud Fayed

unread,
Nov 18, 2022, 1:11:53 PM11/18/22
to The Ring Programming Language
Hello Mansour

I like this example : ? Q("RingRingRing") / 3
Looks very natural

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Mansour Ayouni

unread,
Nov 18, 2022, 1:47:09 PM11/18/22
to Mahmoud Fayed, The Ring Programming Language
Thank you Mahmoud!
Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/9ef12d95-577d-4f0f-9c3c-57ff2d78fa0bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages