Category talk:EasyLang: Difference between revisions

Replaced some procedures with equivalent functions
(Replaced some procedures with equivalent functions)
 
(One intermediate revision by the same user not shown)
Line 34:
===Lowercase===
<syntaxhighlight lang="easylang">
procfunc$ toLowercase string$ . result$ .
for i = 1 to len string$
code = strcode substr string$ i 1
Line 42:
result$ &= strchar code
.
return result$
.
</syntaxhighlight>
===Uppercase===
<syntaxhighlight lang="easylang">
procfunc$ toUppercase string$ . result$ .
for i = 1 to len string$
code = strcode substr string$ i 1
Line 54 ⟶ 55:
result$ &= strchar code
.
return result$
.
</syntaxhighlight>
Line 60 ⟶ 62:
This function is for number arrays:
<syntaxhighlight lang="easylang">
procfunc findInArray array[] item . index .
for i = 1 to len array[]
if array[i] = item
index = i
breakreturn 2index
.
.
return index = 0
.
</syntaxhighlight>
This function is for string arrays:
<syntaxhighlight lang="easylang">
procfunc findInStrArray array$[] item$ . index .
for i = 1 to len array$[]
if array$[i] = item$
index = i
breakreturn 2index
.
.
return index = 0
.
</syntaxhighlight>
Line 85 ⟶ 87:
==Sum and product of arrays==
<syntaxhighlight lang="easylang">
func sum array[] . sum .
for item in array[]
sumresult += item
.
return result
.
func product array[] . product .
productresult = 1
for item in array[]
productresult *= item
.
return result
.
</syntaxhighlight>
175

edits