3 # 2016, Mahmoud Fayed <msfclipper@yahoo.com>
4 # 2016, CalmoSoft <calmosoft@gmail.com>
11 # Execute a function nCount of times
13 Times ( 3 , func { see "Hello, World!" + nl } )
15 # Execute a function on each list item
17 See Map( 1:10, func x { return x*x } )
19 # Test the Value function to copy a list or object
23 # Test the Filter function
25 See Filter( 1:10 , func x { if x <= 5 return true else return false ok } )
27 # Test the Split function
29 See Split("one two three four five"," ")
31 # Test the Newlist function
32 Puts("Newlist() のテスト")
35 chrArray = newlist(a1,a2)
36 numArray = newlist(a1,a2)
37 chrArray[1][1] = "Hello"
38 numArray[1][1] = 987.2
39 See chrArray[1][1] + nl
40 See numArray[1][1] + nl
42 # Return a copy with the first letter capitalized
43 Puts("Capitalized() のテスト")
44 See capitalized("welcome to the Ring Programming Language")
46 # Test if the character is a special character?
47 Puts("Isspecial() のテスト")
48 See "Isspecial = " + isSpecial("%") + nl
50 # Test if the character is a vowel character?
51 Puts("Isvowel() のテスト")
52 See "Isvowel = " + isVowel("c") + nl
54 # Return the number of lines (lines count) in a text file
55 Puts("Linecount() のテスト")
56 See "the number of lines = " + lineCount("test.ring")
58 # Return the factorial of number
59 Puts("Factorial() のテスト")
60 see "6 factorial is : " + Factorial(6)
62 # Return the Fibonacci number
63 Puts("Fibonacci() のテスト")
64 see "6 Fibonacci is : " + Fibonacci(6)
66 # Check whether a number is prime or not
67 Puts("Isprime() のテスト")
69 if flag = 1 see "16 is a prime number"
70 else see "16 is not a prime number" ok
72 # Returns an Integer value indicating the sign of a number.
74 see "sign of 12 is = " + sign(12) + nl
77 Puts("List2File() のテスト")
78 list2file(1:100,"myfile.txt")
81 Puts("File2List() のテスト")
82 see len(file2list("myfile.txt"))
84 # Returns true if the given string ends with the specified substring. Trailing white spaces are ignored.
85 Puts("Endswith() のテスト")
86 see endsWith("CalmoSoft", "Soft") + nl
88 # Returns true if the given string starts with the specified substring. Leading white spaces are ignored.
89 Puts("Startswith() のテスト")
90 see Startswith("CalmoSoft", "Calmo") + nl
92 # Finding of the greatest common divisor of two integers.
96 # Compute the least common multiple of two integers.
100 # Compute the product of a list of integers.
101 Puts("Prodlist() のテスト")
103 see Prodlist(aList) + nl
105 # Compute the sum of a list of integers.
106 Puts("Sumlist() のテスト")
108 see Sumlist(aList) + nl
110 # Compute the sum of a list of integers.
111 Puts("Evenorodd() のテスト")
113 see Evenorodd(nr) + nl
115 # Compute the factors of a positive integer.
116 Puts("Factors() のテスト")
119 see "Factors of " + n + " = "
120 for i = 1 to len(aList)
121 see "" + aList[i] + " "
124 # Check if a sequence of characters is a palindrome or not.
125 Puts("Palindrome() のテスト")
129 # Check whether a given year is a leap year in the Gregorian calendar.
130 Puts("Isleapyear() のテスト")
132 if Isleapyear(year) see "" + year + " is a leap year."
133 else see "" + year + " is not a leap year." ok
135 # Compute the sequence of binary digits for a given non-negative integer.
136 Puts("Binarydigits() のテスト")
138 see "Binary digits of " + b + " = "
139 see Binarydigits(b) + nl
141 # Multiply two matrices together.
142 Puts("Matrixmulti() のテスト")
143 A = [[1,2,3], [4,5,6], [7,8,9]]
144 B = [[1,0,0], [0,1,0], [0,0,1]]
145 see Matrixmulti(A, B)
147 # Transpose an arbitrarily sized rectangular Matrix.
148 Puts("Matrixtrans() のテスト")
149 matrix = [[78,19,30,12,36], [49,10,65,42,50], [30,93,24,78,10], [39,68,27,64,29]]
150 see Matrixtrans(matrix)
152 # Return the day of the week of given date.
153 Puts("Dayofweek() のテスト")
155 see "Data : " + date + " - Day : " + Dayofweek(date) + nl
157 # Friday the 13th between start and end year.
158 Puts("Fridays() のテスト")
161 Fridays(year1, year2)
163 # Generates all permutations of n different numerals
164 Puts("Permutation() のテスト")
167 for i = 1 to len(list)
175 # Sleep for the given amount of time.
177 see "Wait 3 Seconds!"
181 # Read a file line by line.
182 Puts("Readline() のテスト")
183 fp = fopen("test.ring","r")
188 # Return a position of a substring starting from a given position in a string.
189 Puts("Substring() のテスト")
195 # Change substring from given position for given position with a substring.
196 Puts("Changestring() のテスト")
197 see Changestring("Rmasdg",2,5,"in")
200 print("\nHello, World\n\nHow are you? \t\t I'm fine!\n")
202 print("\nx value = #{x} , y value = #{y} \n")
205 see "Check dir : b:\ring "
206 puts( DirExists("b:\ring") )
207 see "Check dir : C:\ring "
208 Puts( DirExists("C:\ring") )
211 puts("ディレクトリの作成 : myfolder")
214 # GetString() and GetNumber() のテスト
215 See "Test getstring() and getnumber()"+nl
216 See "Enter your name ?"
218 see "Your name is : " + cName + nl
219 See "Enter your Age? "
222 See "Your age after 1 year : " + nAge + nl
224 # Sort a two-dimensional list on the first index.
225 Puts("sortFirstSecond() のテスト")
226 aList = [[2,2], [1,2], [3,2], [3,1], [1,1]]
227 sortFirstSecond(aList, 1)
229 for n=1 to len(aList)
231 see string(aList[n][m]) + " "
236 # Sort a two-dimensional list on the second index.
237 Puts("sortFirstSecond() のテスト")
238 aList = [[2,2], [1,2], [3,2], [3,1], [1,1]]
239 sortFirstSecond(aList, 2)
241 for n=1 to len(aList)
243 see string(aList[n][m]) + " "
249 see "IsMainSourceFile() : " + ismainsourcefile() + nl
250 See "Previous File Name : " + PrevFileName() + nl
251 see "IsMainSourceFile() : " + ismainsourcefile() + nl