I wrote a function for permutation:
q) perm:{[a] $[2 = count a ; (a;reverse a);raze each[{ (first
x) ,/: perm[x _ 0]} ] each[{x rotate y}[;a]] til count a ]}
and
q) perm 1 2 3
works fine.
However, when i replace the recursive call to ‘perm’ with ‘.z.s’, it
gives error 'stack.
q) perm:{[a] $[2 = count a ; (a;reverse a);raze each[{ (first
x) ,/: .z.s[x _ 0]} ] each[{x rotate y}[;a]] til count a ]}
q)perm 1 2 3
GIVES ERROR:
'stack
@
{ (first x) ,/: .z.s[x _ 0]}
`int$()
Can anyone explain the reason for the same ?
Thanks