User:Void Singer/Functions - Second Life Wiki

User:Void Singer/Functions

From Second Life Wiki

Second Life Wiki > User:Void Singer > User: Void Singer/Functions
Jump to: navigation, search

String: Get Reverse Order

Reverse String Order (faster version)

string uStringRevF( string vStrSrc ){
    integer vIntCnt = llStringLength( vStrSrc );
    @Loop; if (vIntCnt--){
        vStrSrc += llGetSubString( vStrSrc, vIntCnt, vIntCnt );
        jump Loop;
    }
    return llGetSubString( vStrSrc, llStringLength( vStrSrc ) >> 1, -1 );
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/

Reverse String Order (smaller memory version)

string uStringRevS( string vStrSrc ){
    integer vIntCnt = llStringLength( vStrSrc );
    @Loop; if (vIntCnt--){
        vStrSrc += llGetSubString( vStrSrc, vIntCnt, vIntCnt );
        vStrSrc = llDeleteSubString( vStrSrc, vIntCnt, vIntCnt );
        jump Loop;
    }
    return vStrSrc;
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/
Return to top

String: Find Last Index

Get Last Index of String Test in String Source

integer uGetStrIdxRev1( string vStrSrc, string vStrTst ){
    integer vIdxFnd =
      llStringLength( vStrSrc ) -
      llStringLength( vStrTst ) -
      llStringLength(
        llList2String(
          llParseStringKeepNulls( vStrSrc, (list)vStrTst, [] ),
          -1)
        );
    return (vIdxFnd | (vIdxFnd >> 31));
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/
Return to top

List: Get Reverse Order

Reverse List Order (faster version)

list uListRevF( list vLstSrc ){
    integer vIntCnt = (vLstSrc != []);
    @Loop; if (vIntCnt--){
        vLstSrc += llList2List( vLstSrc, vIntCnt, vIntCnt );
        jump Loop;
    }
    return llList2List( vLstSrc, (vLstSrc != []) >> 1, -1 );
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/

Reverse List Order (smaller memory version)

list uListRevS( list vLstSrc ){
    integer vIntCnt = (vLstSrc != []);
    @Loop; if (vIntCnt--){
        vLstSrc += llList2List( vLstSrc, vIntCnt, vIntCnt );
        vLstSrc = llDeleteSubList( vLstSrc, vIntCnt, vIntCnt );
        jump Loop;
    }
    return vLstSrc;
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/
Return to top

List: Find Last Index

  • This function is a companion to llListFindList.
    • SPECIAL NOTE: this is only designed to work on string data that will NOT contain the "•" character(alt+7)... please use a different character to suit your needs.

Get Last Index of List Test in List Source

integer uGetLstIdxRev( list vLstSrc, list vLstTst ){
    integer vIdxFnd =
      (vLstSrc != []) +
      ([] != vLstTst) +
      ([] != llParseString2List(
               llList2String(
                 llParseStringKeepNulls(
                   llDumpList2String( vLstSrc, "•" ),
                   (list)llDumpList2String( vLstTst, "•" ),
                   [] ),
                 -1 ),
               (list)"•",
               [] ));
    return (vIdxFnd | (vIdxFnd >> 31));
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/
Return to top

List: Multi-Find Index (First or Last)

Get First Index in List Source of any element in List Test

integer uMatchLstIdxFwd( list vLstSrc, list vLstTst ){
  return ((llParseString2List( 
             llList2String(
               llParseStringKeepNulls(
                 llDumpList2String( vLstSrc, ";" ),
                 vLstTst, [] ),
               0 ),
             (list)";", [] ) != []) + 1) %
         ((vLstSrc != []) + 1) - 1;
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/

Get Last Index in List Source of any element in List Test

integer uMatchLstIdxRev( list vLstSrc, list vLstTst ){
  return (vLstSrc != []) -
    (llParseString2List(
       llList2String(
         llParseString2List( 
           llDumpList2String( vLstSrc, ";" ),
           vLstTst, [] ),
         -1 ),
       (list)";",
       [] ) != []) - 1;
}
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]   //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                 --//*/
Return to top

Questions or Comments?

Feel free to leave me a note on my User Talk page.