Remove letter at specific position in Ring !

87 views
Skip to first unread message

MOHANNAD ALDULAIMI

unread,
Jan 24, 2024, 10:42:36 AMJan 24
to The Ring Programming Language
Hello Ring Family.

I  have this code and I want to modify a specific letter or char. by reference ,

Yes I can remove it using substr function but I wanted to know if it is posable to do this without using deep copy...

sssss.png
BTW : Another solution is to create new variable and add the string to it then make a deep copy of it to the first one.
take a look :
ss2.png
 
Best wishes...
Mohannad

Ilir Liburn

unread,
Jan 25, 2024, 5:39:43 AMJan 25
to The Ring Programming Language
Hello Mohannad,

number and string as basic types are always copied in Ring. However, because you are allowed to pass lists by reference, keeping strings you want to modify inside the list, gives you possibility to modify strings without copy. Sadly, basic type rule applies for list items too, so entire list must be referenced.

Greetings,
Ilir


aList = ["Hello-World"]

fastSubStr(aList,1,"-"," ")

? aList[1]

aList = ["Hello- -World"]

fastSubStr(aList,1,"-","")

? aList[1]

func fastSubStr(aList,index,char,replace)
/* No copy case */
if replace
for ch in aList[index]
if ch = char
ch = replace
ok
next
/* Deep copy case */
else
aList[index] = substr(aList[index],char,replace);

ok


Mansour Ayouni

unread,
Jan 25, 2024, 5:57:31 AMJan 25
to Ilir Liburn, The Ring Programming Language
Hello Muhannad,

Here is the Softanza approach in enabling you de modify strings (or any other type) by reference or by copy :
  1. You create the object, say a stzString("R I N G")
  2. You use Replace(" ", "-") on that object, and its value is modified by reference
  3. You take a copy() from it and modify the copy, while the original string stays unmodified
Here is a snapshot of you case solved this way in SoftanzaLib:

image.png

PS: SoftanzaLib is still under testing.

All the 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/ce6120b6-f938-4b86-a99b-f7efc0b3643an%40googlegroups.com.

MOHANNAD ALDULAIMI

unread,
Feb 18, 2024, 6:03:19 AMFeb 18
to The Ring Programming Language
Hello Mansour, Ilir 

I had this code, it was perfect for this situation ..

But is it acceptable for different applications (console ,web ,GUI)?

Screenshot 2024-02-18 132930.png

Best wishes...
Mohannad

Ilir Liburn

unread,
Feb 18, 2024, 2:14:35 PMFeb 18
to The Ring Programming Language
Hello Mohannad,

Ring runs trough VM, so it is acceptable. There is no Ring to some other language translation yet (to say something cant' work: eval for example).

Greetings,
Ilir

Outnull

unread,
Mar 7, 2024, 10:45:46 PMMar 7
to The Ring Programming Language
Mansour, very nice example in Softanaza. May I kindly ask you to stop posting all of these cool samples until the library becomes available? Just kidding of course, but the anticipation is killing me over here! :D

Cheers, 
ON

Gary Chike

unread,
Mar 7, 2024, 10:56:56 PMMar 7
to The Ring Programming Language
Out of curiosity, when will Softanza become available? 🤓

Mansour Ayouni

unread,
Mar 8, 2024, 3:23:16 AMMar 8
to Gary Chike, The Ring Programming Language
Hello ON and Gary,

Be assures, it's a matter of few months not years :D

Hopefully your patience will be rewarded by all the beauty you will enjoy in using the library.

Seriously, the main cause of delay was that I decided to challenge Softanza and use it (partially) in some of my real-world projects. The feedback I got helped me strengthen many aspects and validate many assumptions.

Thank you very much!

Mansour

Reply all
Reply to author
Forward
0 new messages