SlideShare a Scribd company logo
CHAPTER
THIRTYEIGHT
STDLIB FUNCTIONS
In this chapter we are going to learn about functions in the stdlib.ring
38.1 puts() function
print the value then print new line (nl)
Syntax:
puts(expr)
Example:
Load "stdlib.ring"
Puts("Hello, World!")
38.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")
38.3 getstring() function
Get input from the keyboard - return value as string
getstring() ---> string
218
Ring Documentation, Release 1.3
38.4 getnumber() function
Get input from the keyboard - return value as number
getnumber() ---> number
38.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
38.6 JustFilePath() function
Get the path of the file, remove the file name.
Syntax:
JustFilePath(cFile) ---> The path as String
Example:
load "stdlib.ring"
see justfilePath("b:ringapplicationsrnoternote.ring")
Output:
b:ringapplicationsrnote
38.7 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")
38.4. getnumber() function 219
Ring Documentation, Release 1.3
Output:
rnote.ring
38.8 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
38.9 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 } )
38.10 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 } )
38.8. value() function 220
Ring Documentation, Release 1.3
38.11 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 } )
38.12 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"," ")
38.13 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"," ,")
38.14 newlist() function
Create a two dimensional list
Syntax:
NewList(nRows,nColumns) ---> new list
Example:
38.11. filter() function 221
Ring Documentation, Release 1.3
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
38.15 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")
38.16 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
38.17 isvowel() function
Check whether a character is vowel or not
Syntax:
IsVowel(char) ---> True/False
Example:
38.15. capitalized() function 222
Ring Documentation, Release 1.3
Load "stdlib.ring"
Puts("Test Isvowel()")
See "Isvowel = " + isVowel("c") + nl
38.18 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")
38.19 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)
38.20 fibonacci() function
Return the fibonacci number
Syntax:
Fibonacci(number) ---> number
Example:
Load "stdlib.ring"
Puts("Test Fibonacci()")
see "6 Fibonacci is : " + Fibonacci(6)
38.18. linecount() function 223
Ring Documentation, Release 1.3
38.21 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
38.22 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
38.23 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")
38.24 file2list() function
Read text file and convert lines to list items
Syntax:
38.21. isprime() function 224
Ring Documentation, Release 1.3
File2List(cFileName) ---> List
Example:
Load "stdlib.ring"
# Test File2List
Puts("Test File2List()")
see len(file2list("myfile.txt"))
38.25 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
38.26 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
38.27 gcd() function
Finding of the greatest common divisor of two integers.
Syntax:
Gcd(number,number) ---> number
Example:
38.25. startswith() function 225
Ring Documentation, Release 1.3
Load "stdlib.ring"
Puts("Test Gcd()")
see gcd (24, 32) + nl
38.28 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
38.29 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
38.30 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
38.28. lcm() function 226
Ring Documentation, Release 1.3
38.31 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
38.32 factors() function
Compute the factors of a positive integer.
Syntax:
factors(list) ---> list
Example:
Load "stdlib.ring"
Puts("Test Factors()")
n = 45
aList = factors(n)
see "Factors of " + n + " = "
for i = 1 to len(aList)
see "" + aList[i] + " "
next
38.33 palindrome() function
Check if a sequence of characters is a palindrome or not.
Syntax:
Palindrome(String) ---> True/False
Example:
Load "stdlib.ring"
Puts("Test Palindrome()")
cString = "radar"
see Palindrome(cString)
38.31. evenorodd() function 227

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.8 book - Part 39 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 21 of 84
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.6 book - Part 36 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 31 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 33 of 181
Mahmoud Samir Fayed
 
PDF
Monadologie
league
 
PDF
The Ring programming language version 1.7 book - Part 37 of 196
Mahmoud Samir Fayed
 
PDF
TI1220 Lecture 6: First-class Functions
Eelco Visser
 
PDF
The Ring programming language version 1.5.4 book - Part 35 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 37 of 189
Mahmoud Samir Fayed
 
PDF
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 
PDF
The Ring programming language version 1.5.4 book - Part 22 of 185
Mahmoud Samir Fayed
 
PDF
Scala by Luc Duponcheel
Stephan Janssen
 
PDF
The Ring programming language version 1.5.2 book - Part 21 of 181
Mahmoud Samir Fayed
 
PDF
Functional Programming for OO Programmers (part 2)
Calvin Cheng
 
PDF
The Ring programming language version 1.3 book - Part 24 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 39 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 21 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 45 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 36 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 31 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 33 of 181
Mahmoud Samir Fayed
 
Monadologie
league
 
The Ring programming language version 1.7 book - Part 37 of 196
Mahmoud Samir Fayed
 
TI1220 Lecture 6: First-class Functions
Eelco Visser
 
The Ring programming language version 1.5.4 book - Part 35 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 37 of 189
Mahmoud Samir Fayed
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 
The Ring programming language version 1.5.4 book - Part 22 of 185
Mahmoud Samir Fayed
 
Scala by Luc Duponcheel
Stephan Janssen
 
The Ring programming language version 1.5.2 book - Part 21 of 181
Mahmoud Samir Fayed
 
Functional Programming for OO Programmers (part 2)
Calvin Cheng
 
The Ring programming language version 1.3 book - Part 24 of 88
Mahmoud Samir Fayed
 

Similar to The Ring programming language version 1.3 book - Part 25 of 88 (20)

PDF
The Ring programming language version 1.10 book - Part 44 of 212
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.5.3 book - Part 34 of 184
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.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.5.1 book - Part 33 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.5.4 book - Part 23 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 33 of 210
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.10 book - Part 35 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 29 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 25 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 22 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 16 of 88
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.5.3 book - Part 35 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 32 of 88
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.2 book - Part 34 of 181
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.9 book - Part 43 of 210
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.5.1 book - Part 33 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.5.4 book - Part 23 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 33 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 9 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 35 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 29 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 25 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 22 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 16 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 31 of 212
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.3 book - Part 32 of 88
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
 
Ad

Recently uploaded (20)

PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Designing Production-Ready AI Agents
Kunal Rai
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Biography of Daniel Podor.pdf
Daniel Podor
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 

The Ring programming language version 1.3 book - Part 25 of 88

  • 1. CHAPTER THIRTYEIGHT STDLIB FUNCTIONS In this chapter we are going to learn about functions in the stdlib.ring 38.1 puts() function print the value then print new line (nl) Syntax: puts(expr) Example: Load "stdlib.ring" Puts("Hello, World!") 38.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") 38.3 getstring() function Get input from the keyboard - return value as string getstring() ---> string 218
  • 2. Ring Documentation, Release 1.3 38.4 getnumber() function Get input from the keyboard - return value as number getnumber() ---> number 38.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 38.6 JustFilePath() function Get the path of the file, remove the file name. Syntax: JustFilePath(cFile) ---> The path as String Example: load "stdlib.ring" see justfilePath("b:ringapplicationsrnoternote.ring") Output: b:ringapplicationsrnote 38.7 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") 38.4. getnumber() function 219
  • 3. Ring Documentation, Release 1.3 Output: rnote.ring 38.8 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 38.9 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 } ) 38.10 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 } ) 38.8. value() function 220
  • 4. Ring Documentation, Release 1.3 38.11 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 } ) 38.12 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"," ") 38.13 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"," ,") 38.14 newlist() function Create a two dimensional list Syntax: NewList(nRows,nColumns) ---> new list Example: 38.11. filter() function 221
  • 5. Ring Documentation, Release 1.3 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 38.15 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") 38.16 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 38.17 isvowel() function Check whether a character is vowel or not Syntax: IsVowel(char) ---> True/False Example: 38.15. capitalized() function 222
  • 6. Ring Documentation, Release 1.3 Load "stdlib.ring" Puts("Test Isvowel()") See "Isvowel = " + isVowel("c") + nl 38.18 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") 38.19 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) 38.20 fibonacci() function Return the fibonacci number Syntax: Fibonacci(number) ---> number Example: Load "stdlib.ring" Puts("Test Fibonacci()") see "6 Fibonacci is : " + Fibonacci(6) 38.18. linecount() function 223
  • 7. Ring Documentation, Release 1.3 38.21 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 38.22 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 38.23 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") 38.24 file2list() function Read text file and convert lines to list items Syntax: 38.21. isprime() function 224
  • 8. Ring Documentation, Release 1.3 File2List(cFileName) ---> List Example: Load "stdlib.ring" # Test File2List Puts("Test File2List()") see len(file2list("myfile.txt")) 38.25 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 38.26 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 38.27 gcd() function Finding of the greatest common divisor of two integers. Syntax: Gcd(number,number) ---> number Example: 38.25. startswith() function 225
  • 9. Ring Documentation, Release 1.3 Load "stdlib.ring" Puts("Test Gcd()") see gcd (24, 32) + nl 38.28 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 38.29 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 38.30 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 38.28. lcm() function 226
  • 10. Ring Documentation, Release 1.3 38.31 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 38.32 factors() function Compute the factors of a positive integer. Syntax: factors(list) ---> list Example: Load "stdlib.ring" Puts("Test Factors()") n = 45 aList = factors(n) see "Factors of " + n + " = " for i = 1 to len(aList) see "" + aList[i] + " " next 38.33 palindrome() function Check if a sequence of characters is a palindrome or not. Syntax: Palindrome(String) ---> True/False Example: Load "stdlib.ring" Puts("Test Palindrome()") cString = "radar" see Palindrome(cString) 38.31. evenorodd() function 227