Tag Archives: Permutations

Generate all permutations in q/KDB+

My solution : perm:{[s] $[(count s)=1;s;[p:(rotate[1]\)s;raze((string first each p),/:’perm each 1_/:p)]]} Results : perm “a” “a” perm “ab” “ab” “ba” perm “abc” “abc” “acb” “bca” “bac” “cab” “cba” The kdb+ personal developers blog contains a thread on generating all the … Continue reading

Posted in Q, Regular Expressions | Tagged , | 2 Comments