Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Catamorphism/BASIC256/catamorphism.basic
Normal file
40
Task/Catamorphism/BASIC256/catamorphism.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
arraybase 1
|
||||
global n
|
||||
dim n = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
|
||||
print " +: "; " "; cat(10, "+")
|
||||
print " -: "; " "; cat(10, "-")
|
||||
print " *: "; " "; cat(10, "*")
|
||||
print " /: "; " "; cat(10, "/")
|
||||
print " ^: "; " "; cat(10, "^")
|
||||
print "max: "; " "; cat(10, "max")
|
||||
print "min: "; " "; cat(10, "min")
|
||||
print "avg: "; " "; cat(10, "avg")
|
||||
print "cat: "; " "; cat(10, "cat")
|
||||
end
|
||||
|
||||
function min(a, b)
|
||||
if a < b then return a else return b
|
||||
end function
|
||||
function max(a, b)
|
||||
if a > b then return a else return b
|
||||
end function
|
||||
|
||||
function cat(cont, op$)
|
||||
temp = n[1]
|
||||
temp$ = ""
|
||||
for i = 2 to cont
|
||||
if op$ = "+" then temp += n[i]
|
||||
if op$ = "-" then temp -= n[i]
|
||||
if op$ = "*" then temp *= n[i]
|
||||
if op$ = "/" then temp /= n[i]
|
||||
if op$ = "^" then temp = temp ^ n[i]
|
||||
if op$ = "max" then temp = max(temp, n[i])
|
||||
if op$ = "min" then temp = min(temp, n[i])
|
||||
if op$ = "avg" then temp += n[i]
|
||||
if op$ = "cat" then temp$ += string(n[i])
|
||||
next i
|
||||
if op$ = "avg" then temp /= cont
|
||||
if op$ = "cat" then temp = int(string(n[1]) + temp$)
|
||||
return temp
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue