Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fuss:lsl [2019/11/12 16:46] – [Ternary Operator] officefuss:lsl [2024/08/11 01:19] (current) – [Generic Notecard Reader] office
Line 180: Line 180:
 ====== Generic Notecard Reader ====== ====== Generic Notecard Reader ======
  
-This is a generic notecard loader. In this variation, it does not set a timer to check whether the notecard has been loaded. Thus, all the notecards should have an ending newline for this system to work properly.+This is a generic notecard loader. All the notecards should have [[/fuss/computer_science#definition_of_a_line_of_text|an ending newline]].
  
 **Globals** **Globals**
Line 264: Line 264:
 //    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // //    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
 /////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
-integer stringComparer(string a, string b) { +integer stringComparer(string a, string b, integer ASCENDING) { 
-    list alph = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",  +    list alph = [  
-                      "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ]; +        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",  
-    return llListFindList(alph, (list)a) <= llListFindList(alph, (list)b);+        "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"  
 +    ]; 
 +     
 +    integer l = llListFindList( 
 +        alph,  
 +        [ llToLower(a) 
 +    ); 
 +     
 +    integer r = llListFindList( 
 +        alph,  
 +        [ llToLower(b) 
 +    ); 
 +     
 +    if(ASCENDING) { 
 +        return l > r; 
 +    } 
 +     
 +    return l <= r;
 } }
  
Line 287: Line 304:
    
     do {     do {
-        if(stringComparer(llList2String(a, 0), llList2String(pivot_a, 0)) == TRUE) {+        if(stringComparer(llList2String(a, 0), llList2String(pivot_a, 0), TRUE) == TRUE) {
             less += llList2List(a, 0, 0);             less += llList2List(a, 0, 0);
             less_b += llList2List(b, 0, 0);             less_b += llList2List(b, 0, 0);
Line 298: Line 315:
         b = llDeleteSubList(b, 0, 0);         b = llDeleteSubList(b, 0, 0);
     } while(llGetListLength(a));     } while(llGetListLength(a));
-    return wasDualQuicksort(less, less_b) + pivot_a + pivot_b + wasDualQuicksort(more, more_b);+     
 +    return wasDualQuicksort(less, less_b) +  
 +        pivot_a +  
 +        pivot_b +  
 +        wasDualQuicksort(more, more_b);
 } }
    
Line 805: Line 826:
 ====== TRNG ====== ====== TRNG ======
  
-True random-number generator, based on FPS fluctuations of region frame-rates as discussed on the page at [[drafts:randomness_entropy_and_statistics|Randomness, Entropy and Statistics]].+True random-number generator, based on FPS fluctuations of region frame-rates.
  
 <code lsl2> <code lsl2>
Line 856: Line 877:
 ====== Compute Capping System Delays ====== ====== Compute Capping System Delays ======
  
-A calculator to compute the random amount of time needed (in seconds) to wait between executing some capped action as discussed in our article [[drafts:randomness_entropy_and_statistics|Randomness, Entropy and Statistics]].+A calculator to compute the random amount of time needed (in seconds) to wait between executing some capped action.
  
 <code lsl2> <code lsl2>
Line 2071: Line 2092:
 which returns [↗] where ↗ is the next position of the arrow. which returns [↗] where ↗ is the next position of the arrow.
  
-You can find some collected sets of spinners on the [[assets/databases/character_art/spinners|spinner asset page]] which you can set the ''spinChars'' list to.+You can find some collected sets of spinners on the [[/assets/databases/spinners/text|spinner asset page]] which you can set the ''spinChars'' list to.
 ====== Decompose a Number into Prime Factors ====== ====== Decompose a Number into Prime Factors ======
  
Line 4154: Line 4175:
 Remarkably, the expression preserves the same type constraints that a ternary operator would have: the type of ''a'' will be the same as either elements of the list (in this case converted via ''llList2String'') and the type of the variables ''c'' and ''b'' are free under the contraints of variables ''a'' and the values that ''a'' will hold (however, variables ''c'' and ''b'' must be of the same type). Remarkably, the expression preserves the same type constraints that a ternary operator would have: the type of ''a'' will be the same as either elements of the list (in this case converted via ''llList2String'') and the type of the variables ''c'' and ''b'' are free under the contraints of variables ''a'' and the values that ''a'' will hold (however, variables ''c'' and ''b'' must be of the same type).
  
 +====== Clamping Vector Components ======
 +
 +''wasVectorClamp'' takes a vector ''v'' and ensures that all vector components will fall within the closed interval $[min, max]$.
 +
 +<code lsl2>
 +///////////////////////////////////////////////////////////////////////////
 +//    Copyright (C) 2022 Wizardry and Steamworks - License: GNU GPLv3    //
 +///////////////////////////////////////////////////////////////////////////
 +vector wasVectorClamp(vector v, float min, float max) {
 +    return
 +        <
 +            llListStatistics(
 +                LIST_STAT_MAX,
 +                [
 +                    llListStatistics(
 +                        LIST_STAT_MIN,
 +                        [
 +                            v.x,
 +                            max
 +                        ]
 +                    ),
 +                    min
 +                ]
 +            ),
 +            llListStatistics(
 +                LIST_STAT_MAX,
 +                [
 +                    llListStatistics(
 +                        LIST_STAT_MIN,
 +                        [
 +                            v.y,
 +                            max
 +                        ]
 +                    ),
 +                    min
 +                ]
 +            ),
 +            llListStatistics(
 +                LIST_STAT_MAX,
 +                [
 +                    llListStatistics(
 +                        LIST_STAT_MIN,
 +                        [
 +                            v.z,
 +                            max
 +                        ]
 +                    ),
 +                    min
 +                ]
 +            )
 +        >;
 +}
 +</code>
  

fuss/lsl.1573577186.txt.gz · Last modified: 2019/11/12 16:46 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.