On Mon, Jul 6, 2009 at 1:55 PM, Dan Bron<[email protected]> wrote:
> Can you implement Gnome Sort in a cute or elegant fashion?
>        http://www.cs.vu.nl/~dick/gnomesort.html

Um...

I would seriously be tempted to implement that one like this:

position=: 0 {...@i.@, [
swap=: ] A.~ *...@position * #...@[ !...@- <:@position
gnome=: swap~ 2 >/\ ]
gnomes=: gnome^:_

Because, that's how garden gnomes really work.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to