Hello all

Still here and I've done all the days in J except for day 7, But that's not
why I'm here.

So now I've done the first part, and I have a function that is too long to
copy that does comparisons in an iterative way (I had some stack problems).
Now I'm wanting to sort the elements using this function, but I don't know
how.

All the sorting is done using the standard comparison, all the grading is
numerical, the quicksort implementation in
https://www.jsoftware.com/help/dictionary/cif.htm (and in
https://code.jsoftware.com/wiki/Essays/Quicksort) is giving me an error
even when trying with numbers.

sel=: 1 : 'x # ['

quicksort=: 3 : 0

if. 1 >: #y do. y

else.

(quicksort y <sel e),(y =sel e),quicksort y >sel e=.y{~?#y

end.

)

quicksort 15 2 9 10 4 0 13 13 18 7

|noun result was required: quicksort

| x#[

|[-0]


And the tacit version, which I hope I modified correctly, it's also giving
me a stack error.

less=:{{x comp2 y}}

great=:{{y comp2 x}}

quicksort=: (($:@(less#[) , (=#[) , $:@(great#[)) ({~ ?@#)) ^: (1<#)

quicksort pp

|stack error: comp2

| y comp2 x


Any idea how can I sort the elements or correct the errors I have?

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

Reply via email to