Category talk:EasyLang: Difference between revisions

Content added Content deleted
(Replaced some procedures with equivalent functions)
 
Line 34: Line 34:
===Lowercase===
===Lowercase===
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
proc toLowercase string$ . result$ .
func$ toLowercase string$ .
for i = 1 to len string$
for i = 1 to len string$
code = strcode substr string$ i 1
code = strcode substr string$ i 1
Line 42: Line 42:
result$ &= strchar code
result$ &= strchar code
.
.
return result$
.
.
</syntaxhighlight>
</syntaxhighlight>
===Uppercase===
===Uppercase===
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
proc toUppercase string$ . result$ .
func$ toUppercase string$ .
for i = 1 to len string$
for i = 1 to len string$
code = strcode substr string$ i 1
code = strcode substr string$ i 1
Line 54: Line 55:
result$ &= strchar code
result$ &= strchar code
.
.
return result$
.
.
</syntaxhighlight>
</syntaxhighlight>
Line 60: Line 62:
This function is for number arrays:
This function is for number arrays:
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
proc findInArray array[] item . index .
func findInArray array[] item .
for i = 1 to len array[]
for i = 1 to len array[]
if array[i] = item
if array[i] = item
index = i
index = i
break 2
return index
.
.
.
.
index = 0
return index
.
.
</syntaxhighlight>
</syntaxhighlight>
This function is for string arrays:
This function is for string arrays:
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
proc findInStrArray array$[] item$ . index .
func findInStrArray array$[] item$ .
for i = 1 to len array$[]
for i = 1 to len array$[]
if array$[i] = item$
if array$[i] = item$
index = i
index = i
break 2
return index
.
.
.
.
index = 0
return index
.
.
</syntaxhighlight>
</syntaxhighlight>
Line 85: Line 87:
==Sum and product of arrays==
==Sum and product of arrays==
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
proc sum array[] . sum .
func sum array[] .
for item in array[]
for item in array[]
sum += item
result += item
.
.
return result
.
.
proc product array[] . product .
func product array[] .
product = 1
result = 1
for item in array[]
for item in array[]
product *= item
result *= item
.
.
return result
.
.
</syntaxhighlight>
</syntaxhighlight>