SlideShare a Scribd company logo
Ring Documentation, Release 1.2
Example:
load "stdlib.ring"
# print even numbers from 10 to 0
for x = 10 to 0 step -2 {
print("#{x}n")
}
• For in Loop
Syntax:
for identifier in List/String [step expression] {
Block of statements
}
Example:
load "stdlib.ring"
aList = 1:10 # create list contains numbers from 1 to 10
for x in aList { print("#{x}n") } # print numbers from 1 to 10
Example:
load "stdlib.ring"
aList = 1:10 # create list contains numbers from 1 to 10
# print odd items inside the list
for x in aList step 2 {
print("#{x}n")
}
When we use (For in) we get items by reference.
This means that we can read/edit items inside the loop.
Example:
load "stdlib.ring"
aList = 1:5 # create list contains numbers from 1 to 5
# replace list numbers with strings
for x in aList {
switch x {
case 1 x = "one"
case 2 x = "two"
case 3 x = "three"
case 4 x = "four"
case 5 x = "five"
}
}
print(aList) # print the list items
17.3 Exceptions
17.3. Exceptions 80
Ring Documentation, Release 1.2
try {
Block of statements
catch
Block of statements
}
17.3. Exceptions 81
CHAPTER
EIGHTEEN
GETTING INPUT
We can get input from the keyboard using
• The Give Command
• The GetChar() Function
• The Input() Function
18.1 Give Command
Syntax:
Give VariableName
Example:
See "Enter the first number : " Give nNum1
See "Enter the second number : " Give nNum2
See "Sum : " + ( 0 + nNum1 + nNum2 )
Output:
Enter the first number : 3
Enter the second number : 4
Sum : 7
18.2 GetChar() Function
We can get one character from the standard input using the GetChar() function
Syntax:
GetChar() ---> Character
Example:
While True
See "
Main Menu
(1) Say Hello
(2) Exit
"
Option = GetChar()
82
Ring Documentation, Release 1.2
GetChar() GetChar() # End of line
# the previous two lines can be replaced with the next line
# Give Option
if Option = 1
see "Enter your name : " give cName
see "Hello " + cName
else
bye
ok
End
18.3 Input() Function
We can get input from the keyboard using the Input() function
Syntax:
Input(nCount) ---> string
The function will wait until nCount characters (at least) are read
Example:
See "Enter message (30 characters) : " cMsg = input(30)
See "Message : " + cMsg
18.3. Input() Function 83
CHAPTER
NINETEEN
FUNCTIONS
In this chapter we are going to learn about the next topics :-
• Define functions
• Call functions
• Declare parameters
• Send parameters
• Main Function
• Variables Scope
• Return Value
• Recursion
19.1 Define Functions
To define new function
Syntax:
func <function_name> [parameters]
Block of statements
Note: No keyword is required to end the function definition.
Example:
func hello
see "Hello from function" + nl
19.2 Call Functions
To call function without parameters, we type the function name then ()
Tip: We can call the function before the function definition and the function code.
Example:
84
Ring Documentation, Release 1.2
hello()
func hello
see "Hello from function" + nl
Example:
first() second()
func first see "message from the first function" + nl
func second see "message from the second function" + nl
19.3 Declare parameters
To declare the function parameters, after the function name type the list of parameters as a group of identifiers separated
by comma.
Example:
func sum x,y
see x+y+nl
19.4 Send Parameters
To send parameters to function, type the parameters inside () after the function name
Syntax:
funcname(parameters)
Example:
/* output
** 8
** 3000
*/
sum(3,5) sum(1000,2000)
func sum x,y see x+y+nl
19.5 Main Function
Using the Ring programming language, the Main Function is optional, when it’s defined, it will be executed after the
end of other statements.
if no other statements comes alone, the main function will be the first entry point
Example:
19.3. Declare parameters 85
Ring Documentation, Release 1.2
# this program will print the hello world message first then execute the main function
See "Hello World!" + nl
func main
see "Message from the main function" + nl
19.6 Variables Scope
The Ring programming language uses lexical scoping to determine the scope of a variable.
Variables defined inside functions (including function parameters) are local variables. Variables defined outside func-
tions (before any function) are global variables.
Inside any function we can access the variables defined inside this function beside the global variables.
Example:
# the program will print numbers from 10 to 1
x = 10 # x is a global variable.
func main
for t = 1 to 10 # t is a local variable
mycounter() # call function
next
func mycounter
see x + nl # print the global variable value
x-- # decrement
Note: Using the main function before the for loop declare the t variable as a local variable, It’s recommended to use
the main functions instead of typing the instructions directly to set the scope of the new variables to local.
19.7 Return Value
The function can return a value using the Return command.
Syntax:
Return [Expression]
Tip: the Expression after the return command is optional and we can use the return command to end the function
execution without returning any value.
Note: if the function doesn’t return explicit value, it will return NULL (empty string = “” ).
Example:
19.6. Variables Scope 86
Ring Documentation, Release 1.2
if novalue() = NULL
See "the function doesn't return a value" + nl
ok
func novalue
19.8 Recursion
The Ring programming language support Recursion and the function can call itself using different parameters.
Example:
see fact(5) # output = 120
func fact x if x = 1 return 1 else return x * fact(x-1) ok
19.8. Recursion 87
CHAPTER
TWENTY
PROGRAM STRUCTURE
In this chapter we will learn about using many source code files in the same project.
20.1 Source Code File Sections
Each source code file may contains the next sections (in the same order).
Source Code File Sections
Load Files
Statements and Global Variables
Functions
Packages and Classes
The application maybe one or more of files.
20.2 Using Many Source Code Files
To include another source file in the project, just use the load command.
Syntax:
Load "filename.ring"
Note: The Load command is executed directly by the compiler in the parsing stage
Tip: if you don’t know the file name until the runtime, or you need to use functions to get the file path, just use eval().
Example:
# File : Start.ring
Load "sub.ring"
sayhello("Mahmoud")
# File : sub.ring
func sayhello cName
see "Hello " + cName + nl
88
CHAPTER
TWENTYONE
LISTS
In this chapter we are going to learn how to deal with lists.
21.1 Create Lists
We can create new lists by defining the list items inside square bracts.
Example:
aList = [1,2,3,4,5]
Also we can create new lists using the : operator
Example:
aList = 1:5
aList2 = "a":"z"
Example:
aList = 5:1
aList2 = "z":"a"
Also we can create lists using the list() function
Syntax:
list = list(size)
Example
aList = list(10) # aList contains 10 items
Note: the list index start from 1
21.2 Add Items
To add new items to the list, we can use the Add() function.
Syntax:
Add(List,Item)
89

More Related Content

PDF
The Ring programming language version 1.2 book - Part 9 of 84
PDF
The Ring programming language version 1.2 book - Part 10 of 84
PDF
The Ring programming language version 1.2 book - Part 12 of 84
PDF
The Ring programming language version 1.3 book - Part 13 of 88
PDF
The Ring programming language version 1.5.1 book - Part 19 of 180
PDF
The Ring programming language version 1.8 book - Part 25 of 202
PDF
The Ring programming language version 1.5.2 book - Part 18 of 181
PDF
The Ring programming language version 1.3 book - Part 11 of 88
The Ring programming language version 1.2 book - Part 9 of 84
The Ring programming language version 1.2 book - Part 10 of 84
The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.5.1 book - Part 19 of 180
The Ring programming language version 1.8 book - Part 25 of 202
The Ring programming language version 1.5.2 book - Part 18 of 181
The Ring programming language version 1.3 book - Part 11 of 88

What's hot (20)

PDF
The Ring programming language version 1.9 book - Part 27 of 210
PDF
The Ring programming language version 1.7 book - Part 22 of 196
PPTX
Dictionary
PDF
The Ring programming language version 1.5.4 book - Part 19 of 185
PPTX
Iteration
PPTX
String Manipulation in Python
PDF
The Ring programming language version 1.8 book - Part 24 of 202
PDF
The Ring programming language version 1.4 book - Part 5 of 30
PDF
The Ring programming language version 1.5.1 book - Part 17 of 180
PDF
The Ring programming language version 1.5.2 book - Part 31 of 181
PDF
The Ring programming language version 1.5.3 book - Part 19 of 184
PPTX
Functions & Recursion
PDF
The Ring programming language version 1.2 book - Part 21 of 84
PDF
The Ring programming language version 1.4.1 book - Part 5 of 31
PDF
The Ring programming language version 1.6 book - Part 22 of 189
PDF
The Ring programming language version 1.10 book - Part 27 of 212
PDF
The Ring programming language version 1.3 book - Part 23 of 88
PPTX
Unit2 input output
PDF
The Ring programming language version 1.5.2 book - Part 20 of 181
PDF
The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 27 of 210
The Ring programming language version 1.7 book - Part 22 of 196
Dictionary
The Ring programming language version 1.5.4 book - Part 19 of 185
Iteration
String Manipulation in Python
The Ring programming language version 1.8 book - Part 24 of 202
The Ring programming language version 1.4 book - Part 5 of 30
The Ring programming language version 1.5.1 book - Part 17 of 180
The Ring programming language version 1.5.2 book - Part 31 of 181
The Ring programming language version 1.5.3 book - Part 19 of 184
Functions & Recursion
The Ring programming language version 1.2 book - Part 21 of 84
The Ring programming language version 1.4.1 book - Part 5 of 31
The Ring programming language version 1.6 book - Part 22 of 189
The Ring programming language version 1.10 book - Part 27 of 212
The Ring programming language version 1.3 book - Part 23 of 88
Unit2 input output
The Ring programming language version 1.5.2 book - Part 20 of 181
The Ring programming language version 1.9 book - Part 25 of 210
Ad

Viewers also liked (20)

PDF
Nk 03 2017_lr_englisch
PDF
The Ring programming language version 1.2 book - Part 8 of 84
PPTX
Gpl1 8-artikel-tutorial 1
PDF
Curriculum Vitae-Yeswanthvadlamoodi2016
PPTX
Docker with devops program
PDF
High Temperature Conveyor Belts
PDF
Guillermo Dumrauf - Calculo Financiero Aplicado (Parte 2 de 3)
PPTX
V. cholerae
PDF
人気プログラム 一覧
PDF
Ambientação ADM - dicas de navegação - 1º semestre 2017
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 13 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 29 of 84
PDF
The Ring programming language version 1.2 book - Part 32 of 84
PDF
The Ring programming language version 1.2 book - Part 28 of 84
PDF
The Ring programming language version 1.2 book - Part 30 of 84
PDF
The Ring programming language version 1.2 book - Part 35 of 84
Nk 03 2017_lr_englisch
The Ring programming language version 1.2 book - Part 8 of 84
Gpl1 8-artikel-tutorial 1
Curriculum Vitae-Yeswanthvadlamoodi2016
Docker with devops program
High Temperature Conveyor Belts
Guillermo Dumrauf - Calculo Financiero Aplicado (Parte 2 de 3)
V. cholerae
人気プログラム 一覧
Ambientação ADM - dicas de navegação - 1º semestre 2017
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 13 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 29 of 84
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 28 of 84
The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 35 of 84
Ad

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

PDF
The Ring programming language version 1.5.1 book - Part 20 of 180
PDF
The Ring programming language version 1.9 book - Part 28 of 210
PDF
The Ring programming language version 1.8 book - Part 26 of 202
PDF
The Ring programming language version 1.5 book - Part 4 of 31
PDF
The Ring programming language version 1.5.4 book - Part 21 of 185
PDF
The Ring programming language version 1.5.2 book - Part 21 of 181
PDF
The Ring programming language version 1.7 book - Part 24 of 196
PDF
The Ring programming language version 1.6 book - Part 23 of 189
PDF
The Ring programming language version 1.5.3 book - Part 21 of 184
PDF
The Ring programming language version 1.10 book - Part 29 of 212
PDF
The Ring programming language version 1.7 book - Part 25 of 196
PDF
PPTX
Functions
DOC
Functions
PDF
Python_Functions.pdf
PPTX
functioninpython-1.pptx
PPTX
Working with functions.pptx. Hb.
PPT
functions _
PPTX
ForLoopandUserDefinedFunctions.pptx
PPTX
Python_Functions_Unit1.pptx
The Ring programming language version 1.5.1 book - Part 20 of 180
The Ring programming language version 1.9 book - Part 28 of 210
The Ring programming language version 1.8 book - Part 26 of 202
The Ring programming language version 1.5 book - Part 4 of 31
The Ring programming language version 1.5.4 book - Part 21 of 185
The Ring programming language version 1.5.2 book - Part 21 of 181
The Ring programming language version 1.7 book - Part 24 of 196
The Ring programming language version 1.6 book - Part 23 of 189
The Ring programming language version 1.5.3 book - Part 21 of 184
The Ring programming language version 1.10 book - Part 29 of 212
The Ring programming language version 1.7 book - Part 25 of 196
Functions
Functions
Python_Functions.pdf
functioninpython-1.pptx
Working with functions.pptx. Hb.
functions _
ForLoopandUserDefinedFunctions.pptx
Python_Functions_Unit1.pptx

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
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Essential Infomation Tech presentation.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PDF
medical staffing services at VALiNTRY
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Softaken Excel to vCard Converter Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Reimagine Home Health with the Power of Agentic AI​
Navsoft: AI-Powered Business Solutions & Custom Software Development
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo POS Development Services by CandidRoot Solutions
Wondershare Filmora 15 Crack With Activation Key [2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Essential Infomation Tech presentation.pptx
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
Nekopoi APK 2025 free lastest update
medical staffing services at VALiNTRY
wealthsignaloriginal-com-DS-text-... (1).pdf

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

  • 1. Ring Documentation, Release 1.2 Example: load "stdlib.ring" # print even numbers from 10 to 0 for x = 10 to 0 step -2 { print("#{x}n") } • For in Loop Syntax: for identifier in List/String [step expression] { Block of statements } Example: load "stdlib.ring" aList = 1:10 # create list contains numbers from 1 to 10 for x in aList { print("#{x}n") } # print numbers from 1 to 10 Example: load "stdlib.ring" aList = 1:10 # create list contains numbers from 1 to 10 # print odd items inside the list for x in aList step 2 { print("#{x}n") } When we use (For in) we get items by reference. This means that we can read/edit items inside the loop. Example: load "stdlib.ring" aList = 1:5 # create list contains numbers from 1 to 5 # replace list numbers with strings for x in aList { switch x { case 1 x = "one" case 2 x = "two" case 3 x = "three" case 4 x = "four" case 5 x = "five" } } print(aList) # print the list items 17.3 Exceptions 17.3. Exceptions 80
  • 2. Ring Documentation, Release 1.2 try { Block of statements catch Block of statements } 17.3. Exceptions 81
  • 3. CHAPTER EIGHTEEN GETTING INPUT We can get input from the keyboard using • The Give Command • The GetChar() Function • The Input() Function 18.1 Give Command Syntax: Give VariableName Example: See "Enter the first number : " Give nNum1 See "Enter the second number : " Give nNum2 See "Sum : " + ( 0 + nNum1 + nNum2 ) Output: Enter the first number : 3 Enter the second number : 4 Sum : 7 18.2 GetChar() Function We can get one character from the standard input using the GetChar() function Syntax: GetChar() ---> Character Example: While True See " Main Menu (1) Say Hello (2) Exit " Option = GetChar() 82
  • 4. Ring Documentation, Release 1.2 GetChar() GetChar() # End of line # the previous two lines can be replaced with the next line # Give Option if Option = 1 see "Enter your name : " give cName see "Hello " + cName else bye ok End 18.3 Input() Function We can get input from the keyboard using the Input() function Syntax: Input(nCount) ---> string The function will wait until nCount characters (at least) are read Example: See "Enter message (30 characters) : " cMsg = input(30) See "Message : " + cMsg 18.3. Input() Function 83
  • 5. CHAPTER NINETEEN FUNCTIONS In this chapter we are going to learn about the next topics :- • Define functions • Call functions • Declare parameters • Send parameters • Main Function • Variables Scope • Return Value • Recursion 19.1 Define Functions To define new function Syntax: func <function_name> [parameters] Block of statements Note: No keyword is required to end the function definition. Example: func hello see "Hello from function" + nl 19.2 Call Functions To call function without parameters, we type the function name then () Tip: We can call the function before the function definition and the function code. Example: 84
  • 6. Ring Documentation, Release 1.2 hello() func hello see "Hello from function" + nl Example: first() second() func first see "message from the first function" + nl func second see "message from the second function" + nl 19.3 Declare parameters To declare the function parameters, after the function name type the list of parameters as a group of identifiers separated by comma. Example: func sum x,y see x+y+nl 19.4 Send Parameters To send parameters to function, type the parameters inside () after the function name Syntax: funcname(parameters) Example: /* output ** 8 ** 3000 */ sum(3,5) sum(1000,2000) func sum x,y see x+y+nl 19.5 Main Function Using the Ring programming language, the Main Function is optional, when it’s defined, it will be executed after the end of other statements. if no other statements comes alone, the main function will be the first entry point Example: 19.3. Declare parameters 85
  • 7. Ring Documentation, Release 1.2 # this program will print the hello world message first then execute the main function See "Hello World!" + nl func main see "Message from the main function" + nl 19.6 Variables Scope The Ring programming language uses lexical scoping to determine the scope of a variable. Variables defined inside functions (including function parameters) are local variables. Variables defined outside func- tions (before any function) are global variables. Inside any function we can access the variables defined inside this function beside the global variables. Example: # the program will print numbers from 10 to 1 x = 10 # x is a global variable. func main for t = 1 to 10 # t is a local variable mycounter() # call function next func mycounter see x + nl # print the global variable value x-- # decrement Note: Using the main function before the for loop declare the t variable as a local variable, It’s recommended to use the main functions instead of typing the instructions directly to set the scope of the new variables to local. 19.7 Return Value The function can return a value using the Return command. Syntax: Return [Expression] Tip: the Expression after the return command is optional and we can use the return command to end the function execution without returning any value. Note: if the function doesn’t return explicit value, it will return NULL (empty string = “” ). Example: 19.6. Variables Scope 86
  • 8. Ring Documentation, Release 1.2 if novalue() = NULL See "the function doesn't return a value" + nl ok func novalue 19.8 Recursion The Ring programming language support Recursion and the function can call itself using different parameters. Example: see fact(5) # output = 120 func fact x if x = 1 return 1 else return x * fact(x-1) ok 19.8. Recursion 87
  • 9. CHAPTER TWENTY PROGRAM STRUCTURE In this chapter we will learn about using many source code files in the same project. 20.1 Source Code File Sections Each source code file may contains the next sections (in the same order). Source Code File Sections Load Files Statements and Global Variables Functions Packages and Classes The application maybe one or more of files. 20.2 Using Many Source Code Files To include another source file in the project, just use the load command. Syntax: Load "filename.ring" Note: The Load command is executed directly by the compiler in the parsing stage Tip: if you don’t know the file name until the runtime, or you need to use functions to get the file path, just use eval(). Example: # File : Start.ring Load "sub.ring" sayhello("Mahmoud") # File : sub.ring func sayhello cName see "Hello " + cName + nl 88
  • 10. CHAPTER TWENTYONE LISTS In this chapter we are going to learn how to deal with lists. 21.1 Create Lists We can create new lists by defining the list items inside square bracts. Example: aList = [1,2,3,4,5] Also we can create new lists using the : operator Example: aList = 1:5 aList2 = "a":"z" Example: aList = 5:1 aList2 = "z":"a" Also we can create lists using the list() function Syntax: list = list(size) Example aList = list(10) # aList contains 10 items Note: the list index start from 1 21.2 Add Items To add new items to the list, we can use the Add() function. Syntax: Add(List,Item) 89