Writing the Split() function/method in the Ring programming language

The first version of the Ring programming languages comes with many string functions but no Split() function or String class is included.

It’s very easy to write them as we will see in this example

See split(“one two three four five”)

Func split x Return str2list(substr(x,” “,nl))

In the previous code, we replace spaces with nl using the substr() function

After that we uses the str2list() to convert the output to a list of string

Instead of using the split() function we can start writing the String class

oString = new String(“one two three four five”)
See oString.Split()

Class String

func init x
cValue = x

func split
return str2list(substr(cValue,” “,nl))


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s