Strings x and y are anagrams if x -:&(/:~)&(-.&'. ')&tolower y .  That is,
compare them after reducing them to a standard form, by (converting to
lower case, then deleting spaces and dots (and whatever), then sorting
them).






On Mon, Jun 8, 2015 at 6:27 AM, Gian Medri <[email protected]> wrote:

> Is there a shorter or better method of finding
> if 2 strings are an anagram in one line code?
>
> Write an idiom that takes two character vectors as its left and right
> arguments and returns 1 if they are anagrams of each other. An anagram
> of a string uses all of the letters
>
> of the string ignoring word spacing, capitalisation, and dot.
>
>
>
>  anagram=: 13 : '(/:~(B,a.) {~ (A,a.) i.~~  (-.&'' .'')y)-:
> /:~(B=.((97+i.26){a.),a.) {~ (A=.((65+i.26){a.),a.) i.~~  (-.&''
> .'')x'
>
>
>
>
>
>    'Dr. K. E. Iverson' anagram 'Knives Or Red'
>
> 1
>
>
> Gian Medri
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to