langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View 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

View file

@ -0,0 +1,12 @@
fn accumulator n {
result @ i {
n = `{echo $n + $i | bc}
result $n
}
}
fn-x = <={accumulator 1}
x 5
fn-y = <={accumulator 3}
echo <={x 2.3}
echo <={y -3000}