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,7 @@
if2() {
if eval "$1"; then
if eval "$2"; then eval "$3"; else eval "$4"; fi
else
if eval "$2"; then eval "$5"; else eval "$6"; fi
fi
}

View file

@ -0,0 +1,9 @@
if2 'test 7 -lt 9' 'test 7 -gt 9' '
echo both 1 and 2
' '
echo 1 but not 2
' '
echo 2 but not 1
' '
echo neither 1 nor 2
'

View file

@ -0,0 +1,9 @@
fn if2 cond1 cond2 body11 body10 body01 body00 {
# Must evaluate both conditions, and should do so in order.
# Negation ensures a boolean result: a true condition becomes
# 1 for false; a false condition becomes 0 for true.
let (c1 = <={! $cond1}; c2 = <={! $cond2}) {
# Use those values to pick the body to evaluate.
$(body$c1$c2)
}
}

View file

@ -0,0 +1,9 @@
if2 {test 1 -gt 0} {~ grill foo bar boo} {
echo 1 and 2
} {
echo 1 but not 2
} {
echo 2 but not 1
} {
echo neither 1 nor 2
}