Public feed
#528400
Invoke as: combine <depth> <words separated by blanks>E.g.: % combine 4 a b c(no errorhandling at all)--------------------------------#!/usr/bin/zshc=$1; shift# starts with 2 anyhow[ $c -le 2 ] && c=0 || ((c-=2))combine() { c=$1; shift # reassemble arrays words=(`for i in "$@"; do [ $i = "--" ] && break; echo $i; done`) combinations=(`shift ${#words[*]}; shift; for i in "$@"; do echo $i; done`) if [ $c -ge 0 ]; then ((c--)) com2=(`for i in $words; do for j in $combinations; do echo $i$j done done`) combine $c $words -- $com2 else for j in $combinations; do echo $j done fi}combine $c "$@" -- "$@"