Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
15
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh
Normal file
15
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
quibble() {
|
||||
printf '{'
|
||||
while (( $# > 2 )); do
|
||||
printf '%s, ' "$1"
|
||||
shift
|
||||
done
|
||||
if (( $# )); then
|
||||
printf '%s' "$1"
|
||||
shift
|
||||
fi
|
||||
if (( $# )); then
|
||||
printf ' and %s' "$1"
|
||||
fi
|
||||
printf '%s\n' '}'
|
||||
}
|
||||
15
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh
Normal file
15
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
quibble() {
|
||||
printf '{'
|
||||
while [ $# -gt 2 ]; do
|
||||
printf '%s, ' "$1"
|
||||
shift
|
||||
done
|
||||
if [ $# -gt 0 ]; then
|
||||
printf '%s' "$1"
|
||||
shift
|
||||
fi
|
||||
if [ $# -gt 0 ]; then
|
||||
printf ' and %s' "$1"
|
||||
fi
|
||||
printf '%s\n' '}'
|
||||
}
|
||||
5
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-3.sh
Normal file
5
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-3.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
quibble() {
|
||||
printf '{'
|
||||
if (( $# > 1 )) printf '%s and ' ${(j:, :)@[1,-2]}
|
||||
printf '%s}\n' $@[-1]
|
||||
}
|
||||
4
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-4.sh
Normal file
4
Task/Comma-quibbling/UNIX-Shell/comma-quibbling-4.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
quibble
|
||||
quibble ABC
|
||||
quibble ABC DEF
|
||||
quibble ABC DEF G H
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
quibble() {
|
||||
# Here awk(1) is easier than sed(1).
|
||||
awk 'BEGIN {
|
||||
for (i = 1; i < ARGC - 2; i++) s = s ARGV[i] ", "
|
||||
i = ARGC - 2; if (i > 0) s = s ARGV[i] " and "
|
||||
i = ARGC - 1; if (i > 0) s = s ARGV[i]
|
||||
printf "{%s}\n", s
|
||||
exit 0
|
||||
}' "$@"
|
||||
}
|
||||
|
||||
quibble
|
||||
quibble ABC
|
||||
quibble ABC DEF
|
||||
quibble ABC DEF G H
|
||||
Loading…
Add table
Add a link
Reference in a new issue