Sorting algorithms/Merge sort: Difference between revisions
Content added Content deleted
(Tacit Recursive Solution added) |
m (→{{header|J}}) |
||
Line 4,170: | Line 4,170: | ||
<syntaxhighlight lang="j">case=. 1 * (0 = # x=. @:[) + 2 * (0 = # y=. @:]) |
<syntaxhighlight lang="j">case=. 1 * (0 = # x=. @:[) + 2 * (0 = # y=. @:]) |
||
merge=. ({.x , }.x $: ])`(({.y , }.y $: [))@.({.x > {.y)`]`[@.case |
merge=. ({.x , }.x $: ])`(({.y , }.y $: [))@.({.x > {.y)`]`[@.case |
||
mergesort=. (>: o ? o # ($: o {. merge $: (o=. @:) }.) ]) ^:(1 < #)</syntaxhighlight> |
mergesort=. (>: o ? o # ($: o {. merge $: (o=. @:) }.) ]) ^: (1 < #)</syntaxhighlight> |
||
Example use: |
Example use: |