Add existing scripts
This commit is contained in:
1 parent
2ab5a42c2b
commit
3c05d74104
31 files changed
+1138
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# Original sum function, only allows for two values
|
||||
orig_sum() {
|
||||
local value1=$1
|
||||
local value2=$2
|
||||
local result=$(( value1 + value2 ))
|
||||
echo "The sum of ${value1} and ${value2} is ${result}"
|
||||
}
|
||||
|
||||
# Improved sum function that allows as many as required
|
||||
sum() {
|
||||
local total=0
|
||||
for value in $@; do
|
||||
total=$(( total + value ))
|
||||
done
|
||||
|
||||
# Write the result
|
||||
echo "Summed $# values for a total of: ${total}"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user