List Commands Library for 50g
|
03-09-2018, 05:07 PM
Post: #272
|
|||
|
|||
RE: List Commands Library for 50g
SPLIT is now a tiny bit slower than my previous report due to an extra step being required to handle results that would contain leading 0s for numeric arguments. Still reasonably fast, though. Approximate numbers (reals) are handled as was previously described:
The first post in this thread has now been updated to contain what I hope to be the final beta release before a general release of version 1.1.3. I've attempted to consider a wide range of arguments while testing SPLIT and RSPLT, but there may be some that I've missed. I'd be most appreciative if those commands could receive some extra attention for anyone willing to check them out. Here's the updated command descriptions for those two: ______________________________________________________________________________ SPLIT (List/String/Number Split) (aliases: LSPLT, LSPLIT) Input 2: { a list of 0 or more objects } or "String" or number 1: integer (first group size) Output 2: { the designated objects } or "First Substring" or first sub-digit number 1: { the objects after the designated list } or "Last Substring" or last sub-digit number Splits a list, string, or number into two parts where the length of the first object is given as the numeric argument. The result is both sub-objects as separate stack entries. A negative group size is treated the same as 0. A group size greater than the number of elements in the object will be treated the same as the object length. If the group size argument equals the object size, the object and an empty object are returned. If 0, an empty object and the object are returned. Only the integer part of approximate numbers are considered, and the absolute value of those must be less than 1E12. The sign of numbers is maintained for both constituent parts in the result. Examples: { a b c d e f g h i j k l m n o p } 5 SPLIT => { a b c d e } { f g h i j k l m n o p } { a b c d e } 5 SPLIT => { a b c d e } { } { a b c d e } 0 SPLIT => { } { a b c d e } { a b c d e } 99 SPLIT => { a b c d e } { } "ABCDEFG" 2 SPLIT => "AB" "CDEFG" "ABCDEFG" 0 SPLIT => "" "ABCDEFG" "ABCDEFG" -99 SPLIT => "" "ABCDEFG" "ABCDEFG" 99 SPLIT => "ABCDEFG" "" 123456789 3 SPLIT => 123 456789 -555 8 SPLIT => -555 0 123000456 3 SPLIT => 123 456 123456.789 2 SPLIT => 12. 3456. 100000. 5 SPLIT => 10000. 0. ______________________________________________________________________________ RSPLT (List/String/Number Right Split) (aliases: LRSPL, LSPLITR) Input 2: { a list of 0 or more objects } or "String" or number 1: integer (second group size) Output 2: { the objects prior to the designated list } or "First Substring" or first sub-digit number 1: { the designated objects } or "Last Substring" or last sub-digit number Splits a list, string, or number into two parts where the length of the second object is given as the numeric argument. The result is both objects as separate stack entries. A negative group size is treated the same as 0. A group size greater than the number of elements in the object will be treated the same as the object length. If the group size argument equals the object size, an empty object and the object are returned. If 0, the object and an empty object are returned. Only the integer part of approximate numbers are considered, and the absolute value of those must be less than 1E12. The sign of numbers is maintained for both constituent parts in the result. Examples: { a b c d e f g h i j k l m n o p } 5 RSPLT => { a b c d e f g h i j k } { l m n o p } { a b c d e } 5 RSPLT => { } { a b c d e } { a b c d e } 0 RSPLT => { a b c d e } { } { a b c d e } 99 RSPLT => { } { a b c d e } "ABCDEFG" 2 RSPLT => "ABCDE" "FG" "ABCDEFG" 0 RSPLT => "ABCDEFG" "" "ABCDEFG" -99 RSPLT => "ABCDEFG" "" "ABCDEFG" 99 RSPLT => "" "ABCDEFG" 123456789 3 RSPLT => 123456 789 -555 8 RSPLT => 0 -555 123000456 3 RSPLT => 123000 456 123456.789 2 RSPLT => 1234. 56. 100000. 5 RSPLT => 1. 0. ______________________________________________________________________________ |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)