SlideShare a Scribd company logo
Ring Documentation, Release 1.2
setattribute(o1,"nSalary",1000000)
setattribute(o1,"aColors",["white","blue","yellow"])
see o1
see o1.aColors
Class Person
cName
nSalary
aColors
Output:
cname: Mahmoud
nsalary: 1000000.000000
acolors: List...
white
blue
yellow
36.28 mergemethods() Function
We can share methods between classes without inheritance using the MergeMethods() function
This function merge class methods to another class.
Syntax:
MergeMethods(cClassNameDestination,cClassNameSource)
Example:
mergemethods("count","share")
mergemethods("count2","share")
o1 = new count { test() }
o1 = new count2 { test() }
Class Share
func one
see "one" + nl
func two
see "two" + nl
func three
see "three" + nl
Class Display
Func printline
see copy("*",20) + nl
Class Count from Display
Func test
printline()
one()
two()
three()
printline()
36.28. mergemethods() Function 200
Ring Documentation, Release 1.2
Class Count2 from Display
Func test
three()
two()
one()
printline()
Output:
********************
one
two
three
********************
three
two
one
********************
36.28. mergemethods() Function 201
CHAPTER
THIRTYSEVEN
STDLIB FUNCTIONS
In this chapter we are going to learn about functions in the stdlib.ring
37.1 puts() function
print the value then print new line (nl)
Syntax:
puts(expr)
Example:
Load "stdlib.ring"
Puts("Hello, World!")
37.2 print() function
print string - support n,t and r
Also we can use #{variable_name} to insert variables values.
Syntax:
print(string)
Example:
Load "stdlib.ring"
print("nHello, WorldnnHow are you? tt I'm fine!n")
x=10 y=20
print("nx value = #{x} , y value = #{y} n")
37.3 getstring() function
Get input from the keyboard - return value as string
getstring() ---> string
202
Ring Documentation, Release 1.2
37.4 getnumber() function
Get input from the keyboard - return value as number
getnumber() ---> number
37.5 apppath() function
Get the path of the application folder
Syntax:
AppPath() ---> The path as String
Example:
Load "stdlib.ring"
# Application Path
Puts("Test AppPath()")
See AppPath() + nl
37.6 value() function
create a copy from a list or object
Syntax:
value(List) ---> new list
Example:
Load "stdlib.ring"
aList = 1:10
del(value(aList),1) # delete first item
see aList # print numbers from 1 to 10
37.7 times() function
Execute a Function nCount times
Syntax:
Times(nCount,function)
Example:
Load "stdlib.ring"
Puts("Test Times()")
Times ( 3 , func { see "Hello, World!" + nl } )
37.4. getnumber() function 203
Ring Documentation, Release 1.2
37.8 map() function
Execute a Function on each list item
Syntax:
Map(alist,function)
Example:
Load "stdlib.ring"
Puts("Test Map()")
See Map( 1:10, func x { return x*x } )
37.9 filter() function
Execute a Function on each list item to filter items
Syntax:
Filter(alist,function)
Example:
Load "stdlib.ring"
Puts("Test Filter()")
See Filter( 1:10 , func x { if x <= 5 return true else return false ok } )
37.10 split() function
Convert string words to list items
Syntax:
Split(cstring,delimiter)
Example:
Load "stdlib.ring"
Puts("Test Split()")
See Split("one two three four five"," ")
37.11 newlist() function
Create a two dimensional list
Syntax:
NewList(nRows,nColumns) ---> new list
Example:
37.8. map() function 204
Ring Documentation, Release 1.2
Load "stdlib.ring"
Puts("Test Newlist()")
a1 = 3
a2 = 5
chrArray = newlist(a1,a2)
numArray = newlist(a1,a2)
chrArray[1][1] = "Hello"
numArray[1][1] = 987.2
See chrArray[1][1] + nl
See numArray[1][1] + nl
37.12 capitalized() function
Return a copy of a string with the first letter capitalized
Syntax:
Capitalized(string) ---> string
Example:
Load "stdlib.ring"
Puts("Test Capitalized()")
See capitalized("welcome to the Ring Programming Language")
37.13 isspecial() function
Check whether a character is special or not
Syntax:
IsSpecial(char) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Isspecial()")
See "Isspecial = " + isSpecial("%") + nl
37.14 isvowel() function
Check whether a character is vowel or not
Syntax:
IsVowel(char) ---> True/False
Example:
37.12. capitalized() function 205
Ring Documentation, Release 1.2
Load "stdlib.ring"
Puts("Test Isvowel()")
See "Isvowel = " + isVowel("c") + nl
37.15 linecount() function
Return the lines count in a text file.
Syntax:
LineCount(cFileName) ---> Lines Count as number
Example:
Load "stdlib.ring"
Puts("Test Linecount()")
See "the number of lines = " + lineCount("test.ring")
37.16 factorial() function
Return the factorial of a number
Syntax:
Factorial(number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Factorial()")
see "6 factorial is : " + Factorial(6)
37.17 fibonacci() function
Return the fibonacci number
Syntax:
Fibonacci(number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Fibonacci()")
see "6 Fibonacci is : " + Fibonacci(6)
37.15. linecount() function 206
Ring Documentation, Release 1.2
37.18 isprime() function
Check whether a number is prime or not
Syntax:
isprime(number) ---> Number
Example:
Load "stdlib.ring"
Puts("Test Isprime()")
if isPrime(16) see "16 is a prime number"
else see "16 is not a prime number" ok
37.19 sign() function
Returns an integer value indicating the sign of a number.
Syntax:
Sign(number) ---> number ( -1 = negative , 0 , 1 (positive) )
Example:
Load "stdlib.ring"
Puts("Test Sign()")
see "sign of 12 is = " + sign(12) + nl
37.20 list2file() function
Write list items to text file (each item in new line).
Syntax:
List2File(aList,cFileName)
Example:
Load "stdlib.ring"
# Test List2File
Puts("Test List2File()")
list2file(1:100,"myfile.txt")
37.21 file2list() function
Read text file and convert lines to list items
Syntax:
37.18. isprime() function 207
Ring Documentation, Release 1.2
File2List(cFileName) ---> List
Example:
Load "stdlib.ring"
# Test File2List
Puts("Test File2List()")
see len(file2list("myfile.txt"))
37.22 startswith() function
Returns true if the given string starts with the specified substring.
Leading white spaces are ignored.
Syntax:
StartsWith(string, substring) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Startswith()")
see Startswith("CalmoSoft", "Calmo") + nl
37.23 endswith() function
Returns true if the given string ends with the specified substring.
Trailing white spaces are ignored.
Syntax:
Endswith(string, substring) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Endswith()")
see endsWith("CalmoSoft", "Soft") + nl
37.24 gcd() function
Finding of the greatest common divisor of two integers.
Syntax:
Gcd(number,number) ---> number
Example:
37.22. startswith() function 208
Ring Documentation, Release 1.2
Load "stdlib.ring"
Puts("Test Gcd()")
see gcd (24, 32) + nl
37.25 lcm() function
Compute the least common multiple of two integers.
Syntax:
lcm(number,number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Lcm()")
see Lcm(24,36) + nl
37.26 sumlist() function
Compute the sum of a list of integers.
Syntax:
sumlist(list) ---> number
Example:
Load "stdlib.ring"
Puts("Test Sumlist()")
aList = [1,2,3,4,5]
see Sumlist(aList) + nl
37.27 prodlist() function
Compute the product of a list of integers.
Syntax:
prodlist(list) ---> number
Example:
Load "stdlib.ring"
Puts("Test Prodlist()")
aList = [1,2,3,4,5]
see Prodlist(aList) + nl
37.25. lcm() function 209

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.5.4 book - Part 34 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 37 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 32 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 22 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 83 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 24 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5 book - Part 6 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 33 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 33 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 22 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 9 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 34 of 196
Mahmoud Samir Fayed
 
PDF
7 Habits For a More Functional Swift
Jason Larsen
 
PDF
The Ring programming language version 1.5.1 book - Part 29 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 94 of 202
Mahmoud Samir Fayed
 
PDF
JDD 2016 - Pawel Byszewski - Kotlin, why?
PROIDEA
 
PDF
Scala by Luc Duponcheel
Stephan Janssen
 
PDF
The Ring programming language version 1.5.1 book - Part 34 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 29 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 34 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 37 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 32 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 22 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 83 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 24 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 6 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 33 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 33 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 22 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 9 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 34 of 196
Mahmoud Samir Fayed
 
7 Habits For a More Functional Swift
Jason Larsen
 
The Ring programming language version 1.5.1 book - Part 29 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 94 of 202
Mahmoud Samir Fayed
 
JDD 2016 - Pawel Byszewski - Kotlin, why?
PROIDEA
 
Scala by Luc Duponcheel
Stephan Janssen
 
The Ring programming language version 1.5.1 book - Part 34 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 32 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 29 of 202
Mahmoud Samir Fayed
 

Viewers also liked (20)

PDF
The Ring programming language version 1.2 book - Part 21 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 25 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 26 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 34 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 33 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 37 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 18 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 1 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 15 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 20 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 19 of 84
Mahmoud Samir Fayed
 
PDF
Variables Python
Armando Rodriguez L
 
PDF
How to make font transparent in PowerPoint
Presentitude
 
PDF
The Ring programming language version 1.2 book - Part 27 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 14 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 13 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 21 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 25 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 26 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 34 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 33 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 37 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 18 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 1 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 15 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 20 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 19 of 84
Mahmoud Samir Fayed
 
Variables Python
Armando Rodriguez L
 
How to make font transparent in PowerPoint
Presentitude
 
The Ring programming language version 1.2 book - Part 27 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 14 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 13 of 84
Mahmoud Samir Fayed
 
Ad

Similar to The Ring programming language version 1.2 book - Part 23 of 84 (20)

PDF
The Ring programming language version 1.6 book - Part 36 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 39 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 38 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 44 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 37 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 40 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 26 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 43 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 6 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 35 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 45 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 35 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 31 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4.1 book - Part 10 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 35 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 36 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 39 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 34 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 38 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 33 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 44 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 35 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 34 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 37 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 40 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 26 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 43 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 6 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 35 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 45 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 35 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 31 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 10 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 35 of 196
Mahmoud Samir Fayed
 
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 

Recently uploaded (20)

PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Human Resources Information System (HRIS)
Amity University, Patna
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 

The Ring programming language version 1.2 book - Part 23 of 84

  • 1. Ring Documentation, Release 1.2 setattribute(o1,"nSalary",1000000) setattribute(o1,"aColors",["white","blue","yellow"]) see o1 see o1.aColors Class Person cName nSalary aColors Output: cname: Mahmoud nsalary: 1000000.000000 acolors: List... white blue yellow 36.28 mergemethods() Function We can share methods between classes without inheritance using the MergeMethods() function This function merge class methods to another class. Syntax: MergeMethods(cClassNameDestination,cClassNameSource) Example: mergemethods("count","share") mergemethods("count2","share") o1 = new count { test() } o1 = new count2 { test() } Class Share func one see "one" + nl func two see "two" + nl func three see "three" + nl Class Display Func printline see copy("*",20) + nl Class Count from Display Func test printline() one() two() three() printline() 36.28. mergemethods() Function 200
  • 2. Ring Documentation, Release 1.2 Class Count2 from Display Func test three() two() one() printline() Output: ******************** one two three ******************** three two one ******************** 36.28. mergemethods() Function 201
  • 3. CHAPTER THIRTYSEVEN STDLIB FUNCTIONS In this chapter we are going to learn about functions in the stdlib.ring 37.1 puts() function print the value then print new line (nl) Syntax: puts(expr) Example: Load "stdlib.ring" Puts("Hello, World!") 37.2 print() function print string - support n,t and r Also we can use #{variable_name} to insert variables values. Syntax: print(string) Example: Load "stdlib.ring" print("nHello, WorldnnHow are you? tt I'm fine!n") x=10 y=20 print("nx value = #{x} , y value = #{y} n") 37.3 getstring() function Get input from the keyboard - return value as string getstring() ---> string 202
  • 4. Ring Documentation, Release 1.2 37.4 getnumber() function Get input from the keyboard - return value as number getnumber() ---> number 37.5 apppath() function Get the path of the application folder Syntax: AppPath() ---> The path as String Example: Load "stdlib.ring" # Application Path Puts("Test AppPath()") See AppPath() + nl 37.6 value() function create a copy from a list or object Syntax: value(List) ---> new list Example: Load "stdlib.ring" aList = 1:10 del(value(aList),1) # delete first item see aList # print numbers from 1 to 10 37.7 times() function Execute a Function nCount times Syntax: Times(nCount,function) Example: Load "stdlib.ring" Puts("Test Times()") Times ( 3 , func { see "Hello, World!" + nl } ) 37.4. getnumber() function 203
  • 5. Ring Documentation, Release 1.2 37.8 map() function Execute a Function on each list item Syntax: Map(alist,function) Example: Load "stdlib.ring" Puts("Test Map()") See Map( 1:10, func x { return x*x } ) 37.9 filter() function Execute a Function on each list item to filter items Syntax: Filter(alist,function) Example: Load "stdlib.ring" Puts("Test Filter()") See Filter( 1:10 , func x { if x <= 5 return true else return false ok } ) 37.10 split() function Convert string words to list items Syntax: Split(cstring,delimiter) Example: Load "stdlib.ring" Puts("Test Split()") See Split("one two three four five"," ") 37.11 newlist() function Create a two dimensional list Syntax: NewList(nRows,nColumns) ---> new list Example: 37.8. map() function 204
  • 6. Ring Documentation, Release 1.2 Load "stdlib.ring" Puts("Test Newlist()") a1 = 3 a2 = 5 chrArray = newlist(a1,a2) numArray = newlist(a1,a2) chrArray[1][1] = "Hello" numArray[1][1] = 987.2 See chrArray[1][1] + nl See numArray[1][1] + nl 37.12 capitalized() function Return a copy of a string with the first letter capitalized Syntax: Capitalized(string) ---> string Example: Load "stdlib.ring" Puts("Test Capitalized()") See capitalized("welcome to the Ring Programming Language") 37.13 isspecial() function Check whether a character is special or not Syntax: IsSpecial(char) ---> True/False Example: Load "stdlib.ring" Puts("Test Isspecial()") See "Isspecial = " + isSpecial("%") + nl 37.14 isvowel() function Check whether a character is vowel or not Syntax: IsVowel(char) ---> True/False Example: 37.12. capitalized() function 205
  • 7. Ring Documentation, Release 1.2 Load "stdlib.ring" Puts("Test Isvowel()") See "Isvowel = " + isVowel("c") + nl 37.15 linecount() function Return the lines count in a text file. Syntax: LineCount(cFileName) ---> Lines Count as number Example: Load "stdlib.ring" Puts("Test Linecount()") See "the number of lines = " + lineCount("test.ring") 37.16 factorial() function Return the factorial of a number Syntax: Factorial(number) ---> number Example: Load "stdlib.ring" Puts("Test Factorial()") see "6 factorial is : " + Factorial(6) 37.17 fibonacci() function Return the fibonacci number Syntax: Fibonacci(number) ---> number Example: Load "stdlib.ring" Puts("Test Fibonacci()") see "6 Fibonacci is : " + Fibonacci(6) 37.15. linecount() function 206
  • 8. Ring Documentation, Release 1.2 37.18 isprime() function Check whether a number is prime or not Syntax: isprime(number) ---> Number Example: Load "stdlib.ring" Puts("Test Isprime()") if isPrime(16) see "16 is a prime number" else see "16 is not a prime number" ok 37.19 sign() function Returns an integer value indicating the sign of a number. Syntax: Sign(number) ---> number ( -1 = negative , 0 , 1 (positive) ) Example: Load "stdlib.ring" Puts("Test Sign()") see "sign of 12 is = " + sign(12) + nl 37.20 list2file() function Write list items to text file (each item in new line). Syntax: List2File(aList,cFileName) Example: Load "stdlib.ring" # Test List2File Puts("Test List2File()") list2file(1:100,"myfile.txt") 37.21 file2list() function Read text file and convert lines to list items Syntax: 37.18. isprime() function 207
  • 9. Ring Documentation, Release 1.2 File2List(cFileName) ---> List Example: Load "stdlib.ring" # Test File2List Puts("Test File2List()") see len(file2list("myfile.txt")) 37.22 startswith() function Returns true if the given string starts with the specified substring. Leading white spaces are ignored. Syntax: StartsWith(string, substring) ---> True/False Example: Load "stdlib.ring" Puts("Test Startswith()") see Startswith("CalmoSoft", "Calmo") + nl 37.23 endswith() function Returns true if the given string ends with the specified substring. Trailing white spaces are ignored. Syntax: Endswith(string, substring) ---> True/False Example: Load "stdlib.ring" Puts("Test Endswith()") see endsWith("CalmoSoft", "Soft") + nl 37.24 gcd() function Finding of the greatest common divisor of two integers. Syntax: Gcd(number,number) ---> number Example: 37.22. startswith() function 208
  • 10. Ring Documentation, Release 1.2 Load "stdlib.ring" Puts("Test Gcd()") see gcd (24, 32) + nl 37.25 lcm() function Compute the least common multiple of two integers. Syntax: lcm(number,number) ---> number Example: Load "stdlib.ring" Puts("Test Lcm()") see Lcm(24,36) + nl 37.26 sumlist() function Compute the sum of a list of integers. Syntax: sumlist(list) ---> number Example: Load "stdlib.ring" Puts("Test Sumlist()") aList = [1,2,3,4,5] see Sumlist(aList) + nl 37.27 prodlist() function Compute the product of a list of integers. Syntax: prodlist(list) ---> number Example: Load "stdlib.ring" Puts("Test Prodlist()") aList = [1,2,3,4,5] see Prodlist(aList) + nl 37.25. lcm() function 209