NL and writing the Print() function in the Ring programming language

We can use “See” to print text on the screen

See “Hello”

To print new line after the text we can use + nl
Example

See “Hello” + nl

We can create a function to do this

print(“Hello”)
print(“How are you?”)
Func Print x See x + nl

But our print() function in the previous example expect the input to be a string
We can write a general function

print(“Hello”)  print(5) print([1,2,3])

Func Print x

if isstring(x) see x + nl

but isnumber(x) see “”+x+nl

else see x

ok

Output

Hello
5
1
2
3

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s