home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


Quicksort for Cubescript

by Hirato Kirata on 11/20/2012 07:56, 8 messages, last message: 11/28/2012 10:17, 1170 views, last view: 04/28/2024 06:57

I'll just leave these here, a cubescript hook for quicksort.
I made it as fast as I can without flagging the variables in question as IDF_READONLY.

The patch can be found here, on pastebin: http://pastebin.com/WbE333Pq


The syntax is of the form: quicksort list left right body
For example, this will sort the list of numbers in ascending order...

list = [ 1 10 15 6 9 11 2 5 8 ]
newlist = (quicksort $list a b [ < $a $b ])

echo $list
echo $newlist

   Board Index   

#1: ..

by Razgriz on 11/20/2012 21:36

interesting.. clarify the usage a bit? what is 'a' or 'b' supposed to be?

reply to this message

#2: Re: ..

by Hirato Kirata on 11/20/2012 23:10, refers to #1

They're like the 'i' in 'loop i 10 [dostuff]'

two aliases that are set for the sorting process, which are then used by the 4th argument to do the comparisons, which are used to do the actual sorting.


reply to this message

#3: Disregard the topic

by Hirato Kirata on 11/21/2012 16:32

This just in.

Eihrul created and committed a much better "sortlist" function with identical syntax.

reply to this message

#4: Re: Disregard the topic

by Razgriz on 11/21/2012 21:58, refers to #3

You'll forever be his subordinate >:D

reply to this message

#5: Re: Disregard the topic

by Zamwa on 11/22/2012 04:14, refers to #4

That's oonnee ugly pedobear grow expression! XD

reply to this message

#6: ..

by srbs on 11/27/2012 07:35

You know, I already implemented a sorting algorithm with cubesscript.. I just never did release it. Only downfall was that it was O(n^2) min, average, & max.

reply to this message

#7: Re: ..

by Hirato Kirata on 11/28/2012 03:14, refers to #6

Yeah.. I'm sure anyone of us could've managed with a bubble/insertion sort.

What I'm interesting in having is access to quicksort, heapsort, shellsort, or mergesort.

reply to this message

#8: Re: ..

by suicizer01 on 11/28/2012 10:17, refers to #7

I couldn't.

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53865185 visitors requested 71640331 pages
page created in 0.017 seconds using 10 queries
hosted by Boost Digital