Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Accumulator-factory/UNIX-Shell/accumulator-factory.sh
Normal file
18
Task/Accumulator-factory/UNIX-Shell/accumulator-factory.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
accumulator() {
|
||||
# Define a global function named $1
|
||||
# with a global variable named ${1}_sum.
|
||||
eval "${1}_sum=\$2"
|
||||
eval "$1() {
|
||||
${1}_sum=\$(echo \"(\$${1}_sum) + (\$2)\" | bc)
|
||||
eval \"\$1=\\\$${1}_sum\" # Provide the current sum.
|
||||
}"
|
||||
}
|
||||
|
||||
accumulator x 1
|
||||
x r 5
|
||||
accumulator y 3
|
||||
x r 2.3
|
||||
echo $r
|
||||
y r -3000
|
||||
echo $r
|
||||
Loading…
Add table
Add a link
Reference in a new issue