Difference between revisions of "User:Aelynn Akina"

From Second Life Wiki
Jump to navigation Jump to search
Line 13: Line 13:


<pre>
<pre>
// Qsort function. Pass it a list of floats and it will sort them
// in numerical order.
list qsort(list ls) {
list qsort(list ls) {
     //Make partition
     //Make partition
Line 27: Line 31:
      
      
     // Get the value at the random pivot value  
     // Get the value at the random pivot value  
     integer pivot_val = (integer) llList2Integer(ls, random_index);  
     float pivot_val = llList2Float(ls, random_index);  


     // Declare iterator and partition
     // Declare iterator and partition
     integer i;
     integer i;
     for ( i = 0; i < llGetListLength(ls); i++) {
     for ( i = 0; i < llGetListLength(ls); i++) {
         integer to_be_sorted = (integer)llList2Integer(ls, i);
         float to_be_sorted = llList2Float(ls, i);
         if ( to_be_sorted < pivot_val) {
         if ( to_be_sorted < pivot_val) {
             LESS += [to_be_sorted];
             LESS += [to_be_sorted];

Revision as of 21:31, 24 September 2007

Hello, this is my page on the Second Life wiki. Updates to come. :)

Profile

On Second Life, my profile reads:

"Hey I'm Aelynn. I'm the weaker version of Lolliipop she can push me off tables and chairs) except I'm taller and I'm not a furry or a dragon and not as crazy. I also am not from England I suppose. As in I don't live there. Nor was I ever from there. Also I don't have "loads" of English friends or anything. I wish I did sometimes.
I love my friends on SL. All of them. I think.... wait.. I'm not so sure.
I am now a spy for hire. Message for details :)"

Scripts

Herein I will describe some scripts that I wrote while bored.


// Qsort function. Pass it a list of floats and it will sort them
// in numerical order. 

list qsort(list ls) {
    //Make partition
    list LESS;
    list PIVOT;
    list GREATER;
    
    //Check if listlen is 1 or none
    if ( llGetListLength(ls) <= 1)
        return ls;

    // Get random pivot value 
    integer random_index = (integer) llFrand(llGetListLength(ls) - 1); 
    
    // Get the value at the random pivot value 
    float pivot_val = llList2Float(ls, random_index); 

    // Declare iterator and partition
    integer i;
    for ( i = 0; i < llGetListLength(ls); i++) {
        float to_be_sorted = llList2Float(ls, i);
        if ( to_be_sorted < pivot_val) {
            LESS += [to_be_sorted];
        } else if ( to_be_sorted == pivot_val) {
            PIVOT += [to_be_sorted];
        } else {
            GREATER += [to_be_sorted];
        }
    }
    // Do recursion and return
    return (  qsort(LESS) + PIVOT + qsort(GREATER) );
}