SlideShare a Scribd company logo
CHAPTER
FORTYTHREE
STDLIB FUNCTIONS
In this chapter we are going to learn about functions in the stdlib.ring
Before using the functions in the library, We must load the library first
load "stdlib.ring"
Instead of using stdlib.ring we can use stdlibcore.ring
Using stdlibcore.ring we can use the StdLib functions (Without Classes)
This is useful when developing standalone console applications
Because using stdlib.ring (functions & classes) will load libraries like RingLibCurl, RingOpenSSL, etc.
43.1 Puts() function
print the value then print new line (nl)
Syntax:
puts(expr)
Example:
Load "stdlib.ring"
Puts("Hello, World!")
43.2 Print() function
print string - support n,t and r
Also we can use #{variable_name} to insert variables values.
Syntax:
print(string) ---> String
Example:
print("nHello, WorldnnHow are you? tt I'm fine!n")
x=10 y=20
print("nx value = #{x} , y value = #{y} n")
323
Ring Documentation, Release 1.6
43.3 Print2Str() Function
Syntax:
print2Str(string) ---> String
Example:
world = "World!"
mystring = print2str("Hello, #{world} nIn Year n#{2000+17} n")
see mystring + nl
Output:
Hello, World!
In Year
2017
43.4 GetString() function
Get input from the keyboard - return value as string
getstring() ---> string
43.5 GetNumber() function
Get input from the keyboard - return value as number
getnumber() ---> number
43.6 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
43.7 JustFilePath() function
Get the path of the file, remove the file name.
43.3. Print2Str() Function 324
Ring Documentation, Release 1.6
Syntax:
JustFilePath(cFile) ---> The path as String
Example:
load "stdlib.ring"
see justfilePath("b:ringapplicationsrnoternote.ring")
Output:
b:ringapplicationsrnote
43.8 JustFileName() function
Get the file, remove the file path.
Syntax:
JustFileName(cFile) ---> The file name as String
Example:
load "stdlib.ring"
see justfileName("b:ringapplicationsrnoternote.ring")
Output:
rnote.ring
43.9 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
43.10 Times() function
Execute a Function nCount times
Syntax:
43.8. JustFileName() function 325
Ring Documentation, Release 1.6
Times(nCount,function)
Example:
Load "stdlib.ring"
Puts("Test Times()")
Times ( 3 , func { see "Hello, World!" + nl } )
43.11 Map() function
Execute a Function on each list item
Syntax:
Map(alist,function) ---> List
Example:
Load "stdlib.ring"
Puts("Test Map()")
See Map( 1:10, func x { return x*x } )
43.12 Filter() function
Execute a Function on each list item to filter items
Syntax:
Filter(alist,function) ---> List
Example:
Load "stdlib.ring"
Puts("Test Filter()")
See Filter( 1:10 , func x { if x <= 5 return true else return false ok } )
43.13 Split() function
Convert string words to list items
Syntax:
Split(cstring,delimiter) ---> List
Example:
Load "stdlib.ring"
Puts("Test Split()")
See Split("one two three four five"," ")
43.11. Map() function 326
Ring Documentation, Release 1.6
43.14 SplitMany() function
Convert string words to list items. Allow many delimiters.
Syntax:
SplitMany(cstring,delimiters as string or list) --> List
Example:
Load "stdlib.ring"
Puts("Test SplitMany()")
See SplitMany("one,two,three,four and five"," ,")
43.15 NewList() function
Create a two dimensional list
Syntax:
NewList(nRows,nColumns) ---> new list
Example:
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
43.16 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")
43.14. SplitMany() function 327
Ring Documentation, Release 1.6
43.17 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
43.18 IsVowel() function
Check whether a character is vowel or not
Syntax:
IsVowel(char) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Isvowel()")
See "Isvowel = " + isVowel("c") + nl
43.19 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")
43.20 Factorial() function
Return the factorial of a number
Syntax:
Factorial(number) ---> number
Example:
43.17. IsSpecial() function 328
Ring Documentation, Release 1.6
Load "stdlib.ring"
Puts("Test Factorial()")
see "6 factorial is : " + Factorial(6)
43.21 Fibonacci() function
Return the fibonacci number
Syntax:
Fibonacci(number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Fibonacci()")
see "6 Fibonacci is : " + Fibonacci(6)
43.22 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
43.23 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
43.21. Fibonacci() function 329
Ring Documentation, Release 1.6
43.24 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")
43.25 File2List() function
Read text file and convert lines to list items
Syntax:
File2List(cFileName) ---> List
Example:
Load "stdlib.ring"
# Test File2List
Puts("Test File2List()")
see len(file2list("myfile.txt"))
43.26 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
43.27 EndsWith() function
Returns true if the given string ends with the specified substring.
Trailing white spaces are ignored.
43.24. List2File() function 330
Ring Documentation, Release 1.6
Syntax:
Endswith(string, substring) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Endswith()")
see endsWith("CalmoSoft", "Soft") + nl
43.28 GCD() function
Finding of the greatest common divisor of two integers.
Syntax:
Gcd(number,number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Gcd()")
see gcd (24, 32) + nl
43.29 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
43.30 SumList() function
Compute the sum of a list of integers.
Syntax:
sumlist(list) ---> number
Example:
Load "stdlib.ring"
Puts("Test Sumlist()")
43.28. GCD() function 331
Ring Documentation, Release 1.6
aList = [1,2,3,4,5]
see Sumlist(aList) + nl
43.31 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
43.32 EvenOrOdd() function
Test whether an integer is even or odd.
Result of test (1=odd 2=even).
Syntax:
evenorodd(number) ---> 1 (odd) or 2 (even)
Example:
Load "stdlib.ring"
Puts("Test Evenorodd()")
nr = 17
see Evenorodd(nr) + nl
43.33 Factors() function
Compute the factors of a positive integer.
Syntax:
factors(number) ---> list
Example:
Load "stdlib.ring"
Puts("Test Factors()")
n = 45
aList = factors(n)
see "Factors of " + n + " = "
for i = 1 to len(aList)
43.31. ProdList() function 332

More Related Content

PDF
The Ring programming language version 1.5.4 book - Part 34 of 185
PDF
The Ring programming language version 1.8 book - Part 39 of 202
PDF
The Ring programming language version 1.5.1 book - Part 32 of 180
PDF
The Ring programming language version 1.5.3 book - Part 34 of 184
PDF
The Ring programming language version 1.5.1 book - Part 33 of 180
PDF
The Ring programming language version 1.7 book - Part 37 of 196
PDF
The Ring programming language version 1.8 book - Part 40 of 202
PDF
The Ring programming language version 1.10 book - Part 43 of 212
The Ring programming language version 1.5.4 book - Part 34 of 185
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.3 book - Part 34 of 184
The Ring programming language version 1.5.1 book - Part 33 of 180
The Ring programming language version 1.7 book - Part 37 of 196
The Ring programming language version 1.8 book - Part 40 of 202
The Ring programming language version 1.10 book - Part 43 of 212

What's hot (20)

PDF
The Ring programming language version 1.6 book - Part 37 of 189
PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
PDF
The Ring programming language version 1.2 book - Part 24 of 84
PDF
The Ring programming language version 1.9 book - Part 42 of 210
PDF
The Ring programming language version 1.9 book - Part 33 of 210
KEY
(map Clojure everyday-tasks)
PDF
The Ring programming language version 1.4.1 book - Part 7 of 31
PPTX
Scala - where objects and functions meet
PDF
The Ring programming language version 1.5.4 book - Part 61 of 185
PDF
The Ring programming language version 1.7 book - Part 30 of 196
PDF
Hammurabi
PDF
The Ring programming language version 1.4.1 book - Part 3 of 31
PDF
JDD 2016 - Pawel Byszewski - Kotlin, why?
PDF
The Ring programming language version 1.5.3 book - Part 25 of 184
PDF
Kotlin Advanced - Apalon Kotlin Sprint Part 3
PDF
The Ring programming language version 1.5.1 book - Part 24 of 180
PDF
Futures e abstração - QCon São Paulo 2015
PDF
The Ring programming language version 1.10 book - Part 35 of 212
PDF
The Ring programming language version 1.8 book - Part 41 of 202
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.5.2 book - Part 33 of 181
The Ring programming language version 1.5.4 book - Part 35 of 185
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 33 of 210
(map Clojure everyday-tasks)
The Ring programming language version 1.4.1 book - Part 7 of 31
Scala - where objects and functions meet
The Ring programming language version 1.5.4 book - Part 61 of 185
The Ring programming language version 1.7 book - Part 30 of 196
Hammurabi
The Ring programming language version 1.4.1 book - Part 3 of 31
JDD 2016 - Pawel Byszewski - Kotlin, why?
The Ring programming language version 1.5.3 book - Part 25 of 184
Kotlin Advanced - Apalon Kotlin Sprint Part 3
The Ring programming language version 1.5.1 book - Part 24 of 180
Futures e abstração - QCon São Paulo 2015
The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.8 book - Part 41 of 202
Ad

Similar to The Ring programming language version 1.6 book - Part 36 of 189 (20)

PDF
The Ring programming language version 1.3 book - Part 25 of 88
PDF
The Ring programming language version 1.2 book - Part 23 of 84
PDF
The Ring programming language version 1.7 book - Part 38 of 196
PDF
The Ring programming language version 1.10 book - Part 44 of 212
PDF
The Ring programming language version 1.5.2 book - Part 34 of 181
PDF
The Ring programming language version 1.9 book - Part 43 of 210
PDF
The Ring programming language version 1.3 book - Part 26 of 88
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.9 book - Part 31 of 210
PDF
The Ring programming language version 1.5 book - Part 5 of 31
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.8 book - Part 29 of 202
PDF
The Ring programming language version 1.5.4 book - Part 24 of 185
PDF
The Ring programming language version 1.6 book - Part 26 of 189
PDF
The Ring programming language version 1.5.3 book - Part 24 of 184
PDF
The Ring programming language version 1.5.2 book - Part 26 of 181
PDF
The Ring programming language version 1.5.1 book - Part 25 of 180
PDF
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.3 book - Part 25 of 88
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.7 book - Part 38 of 196
The Ring programming language version 1.10 book - Part 44 of 212
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.9 book - Part 43 of 210
The Ring programming language version 1.3 book - Part 26 of 88
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.9 book - Part 31 of 210
The Ring programming language version 1.5 book - Part 5 of 31
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.8 book - Part 29 of 202
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.1 book - Part 25 of 180
The Ring programming language version 1.10 book - Part 31 of 212
Ad

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
CHAPTER 2 - PM Management and IT Context
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administration Chapter 2
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
medical staffing services at VALiNTRY
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
history of c programming in notes for students .pptx
PDF
AI in Product Development-omnex systems
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
ai tools demonstartion for schools and inter college
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
CHAPTER 2 - PM Management and IT Context
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administration Chapter 2
Reimagine Home Health with the Power of Agentic AI​
top salesforce developer skills in 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo Companies in India – Driving Business Transformation.pdf
medical staffing services at VALiNTRY
Understanding Forklifts - TECH EHS Solution
How Creative Agencies Leverage Project Management Software.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
history of c programming in notes for students .pptx
AI in Product Development-omnex systems
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
ai tools demonstartion for schools and inter college
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Which alternative to Crystal Reports is best for small or large businesses.pdf

The Ring programming language version 1.6 book - Part 36 of 189

  • 1. CHAPTER FORTYTHREE STDLIB FUNCTIONS In this chapter we are going to learn about functions in the stdlib.ring Before using the functions in the library, We must load the library first load "stdlib.ring" Instead of using stdlib.ring we can use stdlibcore.ring Using stdlibcore.ring we can use the StdLib functions (Without Classes) This is useful when developing standalone console applications Because using stdlib.ring (functions & classes) will load libraries like RingLibCurl, RingOpenSSL, etc. 43.1 Puts() function print the value then print new line (nl) Syntax: puts(expr) Example: Load "stdlib.ring" Puts("Hello, World!") 43.2 Print() function print string - support n,t and r Also we can use #{variable_name} to insert variables values. Syntax: print(string) ---> String Example: print("nHello, WorldnnHow are you? tt I'm fine!n") x=10 y=20 print("nx value = #{x} , y value = #{y} n") 323
  • 2. Ring Documentation, Release 1.6 43.3 Print2Str() Function Syntax: print2Str(string) ---> String Example: world = "World!" mystring = print2str("Hello, #{world} nIn Year n#{2000+17} n") see mystring + nl Output: Hello, World! In Year 2017 43.4 GetString() function Get input from the keyboard - return value as string getstring() ---> string 43.5 GetNumber() function Get input from the keyboard - return value as number getnumber() ---> number 43.6 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 43.7 JustFilePath() function Get the path of the file, remove the file name. 43.3. Print2Str() Function 324
  • 3. Ring Documentation, Release 1.6 Syntax: JustFilePath(cFile) ---> The path as String Example: load "stdlib.ring" see justfilePath("b:ringapplicationsrnoternote.ring") Output: b:ringapplicationsrnote 43.8 JustFileName() function Get the file, remove the file path. Syntax: JustFileName(cFile) ---> The file name as String Example: load "stdlib.ring" see justfileName("b:ringapplicationsrnoternote.ring") Output: rnote.ring 43.9 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 43.10 Times() function Execute a Function nCount times Syntax: 43.8. JustFileName() function 325
  • 4. Ring Documentation, Release 1.6 Times(nCount,function) Example: Load "stdlib.ring" Puts("Test Times()") Times ( 3 , func { see "Hello, World!" + nl } ) 43.11 Map() function Execute a Function on each list item Syntax: Map(alist,function) ---> List Example: Load "stdlib.ring" Puts("Test Map()") See Map( 1:10, func x { return x*x } ) 43.12 Filter() function Execute a Function on each list item to filter items Syntax: Filter(alist,function) ---> List Example: Load "stdlib.ring" Puts("Test Filter()") See Filter( 1:10 , func x { if x <= 5 return true else return false ok } ) 43.13 Split() function Convert string words to list items Syntax: Split(cstring,delimiter) ---> List Example: Load "stdlib.ring" Puts("Test Split()") See Split("one two three four five"," ") 43.11. Map() function 326
  • 5. Ring Documentation, Release 1.6 43.14 SplitMany() function Convert string words to list items. Allow many delimiters. Syntax: SplitMany(cstring,delimiters as string or list) --> List Example: Load "stdlib.ring" Puts("Test SplitMany()") See SplitMany("one,two,three,four and five"," ,") 43.15 NewList() function Create a two dimensional list Syntax: NewList(nRows,nColumns) ---> new list Example: 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 43.16 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") 43.14. SplitMany() function 327
  • 6. Ring Documentation, Release 1.6 43.17 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 43.18 IsVowel() function Check whether a character is vowel or not Syntax: IsVowel(char) ---> True/False Example: Load "stdlib.ring" Puts("Test Isvowel()") See "Isvowel = " + isVowel("c") + nl 43.19 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") 43.20 Factorial() function Return the factorial of a number Syntax: Factorial(number) ---> number Example: 43.17. IsSpecial() function 328
  • 7. Ring Documentation, Release 1.6 Load "stdlib.ring" Puts("Test Factorial()") see "6 factorial is : " + Factorial(6) 43.21 Fibonacci() function Return the fibonacci number Syntax: Fibonacci(number) ---> number Example: Load "stdlib.ring" Puts("Test Fibonacci()") see "6 Fibonacci is : " + Fibonacci(6) 43.22 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 43.23 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 43.21. Fibonacci() function 329
  • 8. Ring Documentation, Release 1.6 43.24 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") 43.25 File2List() function Read text file and convert lines to list items Syntax: File2List(cFileName) ---> List Example: Load "stdlib.ring" # Test File2List Puts("Test File2List()") see len(file2list("myfile.txt")) 43.26 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 43.27 EndsWith() function Returns true if the given string ends with the specified substring. Trailing white spaces are ignored. 43.24. List2File() function 330
  • 9. Ring Documentation, Release 1.6 Syntax: Endswith(string, substring) ---> True/False Example: Load "stdlib.ring" Puts("Test Endswith()") see endsWith("CalmoSoft", "Soft") + nl 43.28 GCD() function Finding of the greatest common divisor of two integers. Syntax: Gcd(number,number) ---> number Example: Load "stdlib.ring" Puts("Test Gcd()") see gcd (24, 32) + nl 43.29 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 43.30 SumList() function Compute the sum of a list of integers. Syntax: sumlist(list) ---> number Example: Load "stdlib.ring" Puts("Test Sumlist()") 43.28. GCD() function 331
  • 10. Ring Documentation, Release 1.6 aList = [1,2,3,4,5] see Sumlist(aList) + nl 43.31 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 43.32 EvenOrOdd() function Test whether an integer is even or odd. Result of test (1=odd 2=even). Syntax: evenorodd(number) ---> 1 (odd) or 2 (even) Example: Load "stdlib.ring" Puts("Test Evenorodd()") nr = 17 see Evenorodd(nr) + nl 43.33 Factors() function Compute the factors of a positive integer. Syntax: factors(number) ---> list Example: Load "stdlib.ring" Puts("Test Factors()") n = 45 aList = factors(n) see "Factors of " + n + " = " for i = 1 to len(aList) 43.31. ProdList() function 332