Differences between revisions 4 and 5
 ⇤ ← Revision 4 as of 2006-02-24 22:50:06 → Size: 1085 Editor: OlegKobchenko Comment: tacit ← Revision 5 as of 2008-12-08 10:45:34 → ⇥ Size: 1088 Editor: anonymous Comment: converted to 1.6 markup Deletions are marked like this. Additions are marked like this. Line 52: Line 52: * [:Essays/Permutations] * [:Essays/Permutation Index] * [:JPhrases/Permutations] * [[Essays/Permutations]] * [[Essays/Permutation Index]] * [[JPhrases/Permutations]] Line 56: Line 56: [[BR]] <
>

Dyadic A. is Anagram. From Dictionary:

• The expression k A. b permutes items of b by the permutation of order #b whose anagram index is k.

```divmod=: <.@% , |~

anag=: (4 : 0)^:(1: < #@])
'q n'=. x. divmod !<:#y.
(q{y.) , n anag (q{.y.) , (>:q)}.y.
)```

Examples

```   4 anag '123'
312
999999 anag '0123456789'
2783915460
999999 anag i.10
2 7 8 3 9 1 5 4 6 0
4 anag i.3 2
4 5
0 1
2 3```

Some tacit variations

```if2=: ^:(1: < #@])

an1=: ((divmod !@<:@#) (({.@[ { ]) , {:@[ \$: ({.@[ {. ]) , >:@{.@[ }. ]) ]) if2

an2=: ((divmod !@<:@#) (({~ {.)~ , {:@[ \$: ({.~ {.)~ , (}.~ >:@{.)~) ]) if2

an3=: ((divmod !@<:@#) (({~ {.)~ , {:@[ \$: ({~ <@<@<@{.)~) ]) if2

an4=: ((divmod !@<:@#) (({~ {.)~ , {:@[ \$: ({~ <^:3:@{.)~) ]) if2

2 -:/\ 999999 (A. ; anag ; an1 ; an2 ; an3 ; an4) i.10
1 1 1 1 1```