動機

bash可以寫rucursive!!

code

下面除了遞迴外,還有用到bash function不用寫args list的特性,去塞acc

charset="0 1";
ret=""
function perm() {
        [ "$1" = "0" ] && { f $2; return; }
        for char in $charset
        do
                perm "$((${1} - 1 ))" "$char $2"
        done
}

perm 4