Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Created June 8, 2021 00:19
Show Gist options
  • Save acdimalev/3f744998c64790654ee9e0a0c823cb2c to your computer and use it in GitHub Desktop.
Save acdimalev/3f744998c64790654ee9e0a0c823cb2c to your computer and use it in GitHub Desktop.
all() {
case $# in
0) false ;;
*) (
result=0
while read x; do
if ! "$@" "$x"; then
result=1
fi
done
return "$result"
) ;;
esac
}
any() {
case $# in
0) false ;;
*) (
result=1
while read x; do
if "$@" "$x"; then
result=0
fi
done
return "$result"
) ;;
esac
}
list() {
case $# in
1) (
lit "$1" |
while read x; do
printf %s\\n "$x"
done
) ;;
*) false ;;
esac
}
lit() {
case $# in
1) printf %s "$1" ;;
*) false
esac
}
safety() {
case "$#" in
0) false ;;
*) (
"$@"
result="$?"
printf -- ---
return "$result"
) ;;
esac
}
listpad() {
case "$#" in
0) (
while read x; do
printf %s\\n "$x"
done
lit ---
) ;;
*) false ;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment