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

PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
PDF
The Ring programming language version 1.6 book - Part 183 of 189
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
The Ring programming language version 1.9 book - Part 41 of 210
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.10 book - Part 43 of 212
PDF
The Ring programming language version 1.3 book - Part 25 of 88
PDF
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.3 book - Part 25 of 88
The Ring programming language version 1.6 book - Part 35 of 189

What's hot (20)

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

Viewers also liked (20)

PDF
The Ring programming language version 1.2 book - Part 21 of 84
PDF
The Ring programming language version 1.2 book - Part 25 of 84
PDF
The Ring programming language version 1.2 book - Part 26 of 84
PDF
The Ring programming language version 1.2 book - Part 34 of 84
PDF
The Ring programming language version 1.2 book - Part 17 of 84
PDF
The Ring programming language version 1.2 book - Part 33 of 84
PDF
The Ring programming language version 1.2 book - Part 37 of 84
PDF
The Ring programming language version 1.2 book - Part 18 of 84
PDF
The Ring programming language version 1.2 book - Part 1 of 84
PDF
The Ring programming language version 1.2 book - Part 15 of 84
PDF
The Ring programming language version 1.2 book - Part 20 of 84
PDF
The Ring programming language version 1.2 book - Part 16 of 84
PDF
The Ring programming language version 1.2 book - Part 19 of 84
PDF
Variables Python
PDF
How to make font transparent in PowerPoint
PDF
The Ring programming language version 1.2 book - Part 27 of 84
PDF
The Ring programming language version 1.2 book - Part 14 of 84
PDF
The Ring programming language version 1.2 book - Part 38 of 84
PDF
The Ring programming language version 1.2 book - Part 36 of 84
PDF
The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.2 book - Part 21 of 84
The Ring programming language version 1.2 book - Part 25 of 84
The Ring programming language version 1.2 book - Part 26 of 84
The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 33 of 84
The Ring programming language version 1.2 book - Part 37 of 84
The Ring programming language version 1.2 book - Part 18 of 84
The Ring programming language version 1.2 book - Part 1 of 84
The Ring programming language version 1.2 book - Part 15 of 84
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 19 of 84
Variables Python
How to make font transparent in PowerPoint
The Ring programming language version 1.2 book - Part 27 of 84
The Ring programming language version 1.2 book - Part 14 of 84
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 13 of 84
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
PDF
The Ring programming language version 1.8 book - Part 39 of 202
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
PDF
The Ring programming language version 1.7 book - Part 38 of 196
PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
PDF
The Ring programming language version 1.10 book - Part 44 of 212
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
PDF
The Ring programming language version 1.6 book - Part 37 of 189
PDF
The Ring programming language version 1.8 book - Part 40 of 202
PDF
The Ring programming language version 1.3 book - Part 26 of 88
PDF
The Ring programming language version 1.9 book - Part 43 of 210
PDF
The Ring programming language version 1.4 book - Part 6 of 30
PDF
The Ring programming language version 1.5.3 book - Part 35 of 184
PDF
The Ring programming language version 1.10 book - Part 45 of 212
PDF
The Ring programming language version 1.5.1 book - Part 35 of 180
PDF
The Ring programming language version 1.9 book - Part 31 of 210
PDF
The Ring programming language version 1.4.1 book - Part 10 of 31
PDF
The Ring programming language version 1.10 book - Part 31 of 212
PDF
The Ring programming language version 1.7 book - Part 35 of 196
The Ring programming language version 1.6 book - Part 36 of 189
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.7 book - Part 38 of 196
The Ring programming language version 1.5.1 book - Part 33 of 180
The Ring programming language version 1.10 book - Part 44 of 212
The Ring programming language version 1.5.4 book - Part 35 of 185
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.8 book - Part 40 of 202
The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.9 book - Part 43 of 210
The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.10 book - Part 45 of 212
The Ring programming language version 1.5.1 book - Part 35 of 180
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.4.1 book - Part 10 of 31
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.7 book - Part 35 of 196

More from Mahmoud Samir Fayed (20)

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

Recently uploaded (20)

PPTX
Introduction to Artificial Intelligence
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
medical staffing services at VALiNTRY
PDF
Nekopoi APK 2025 free lastest update
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
Introduction to Artificial Intelligence
2025 Textile ERP Trends: SAP, Odoo & Oracle
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Reimagine Home Health with the Power of Agentic AI​
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Odoo Companies in India – Driving Business Transformation.pdf
Odoo POS Development Services by CandidRoot Solutions
medical staffing services at VALiNTRY
Nekopoi APK 2025 free lastest update
Internet Downloader Manager (IDM) Crack 6.42 Build 41
CHAPTER 2 - PM Management and IT Context
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms I-SECS-1021-03
How to Migrate SBCGlobal Email to Yahoo Easily

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