You're replying to a comment by Patrick.

October 14, 2008, 08:31

A bash-only powerset could look like:

powerset_overkill() {
        local Set=$*
        if [ "${Set}" = "" ]; then
                return 
        fi
        echo ${Set}
        for i in ${Set}; do
                local Subset=${Set/${i}/}
                powerset_overkill ${Subset}
        done
}

powerset() {
        powerset_overkill $* | sort | uniq
}

time powerset 1 2 3 4 5 6  

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "apple": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.