Jump to content

Discussion on new proposed strided list functions.


Lucia Nightfire
 Share

You are about to reply to a thread that has been inactive for 938 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Here is the feature request: https://jira.secondlife.com/browse/BUG-231545

The particular benefits are the indexing options and the strided alternatives with list sort and list find.

I normally spotlight functions that are already being worked on, but it seems this newly filed feature request is going to have promoted priority over "other" things.

Opinions?

  • Thanks 2
Link to comment
Share on other sites

The main case I can see for llList2ListSlice is already covered by:

http://wiki.secondlife.com/wiki/LlList2ListStrided
list ListStridedFirstElement(list src, integer start, integer end, integer stride) {
     //start must be a multiple of stride or you won't get the first element of the stride.
     return llList2ListStrided(llList2List(src, start, end), 0, -1, stride);
}

llListSortStrided is something I've wished for in the past, but it would be even better to have a function that can sort based on multiple elements of the stride. Consider the following 2-strided list:

list double_sort =
[ 1,0.75, 
  1,0.5, 
  1,0.25,
  2,0.85,
  2,0.75,
  2,0.4,
  2,0.25
];

it is sorted primarily by its first element, but if the first element of the stride is equal, it is sorted in opposite order by the second element. Depending on the sort algorithm used, it might be possible to get a shuffled version of this list into this order by sorting (descending) by the second element then sorting (ascending) by the first, I'm no sort algorithm expert, but I'd like to see any new function allow for that possibility either directly or indirectly.

(Edit: I might propose:)

Function: list llListSortStrided( list src, integer stride, list keyIndexes, integer ascendingMap );

Returns a list that is src sorted by the entry keyIndexes[-1], then keyIndexes[-2]. . . keyIndexes[0] in each stride.

    list      src          –    List to be sorted.    
    integer   stride       –    number of entries per stride, if less than 1 it is assumed to be 1    
    list      keyIndexes    - The element of each stride to use as the sort key, with fallbacks if elements are equal.
    integer   ascendingMap –    if (1<<n & ascendingMap), then sorts by the nth keyIndex are ascending, descending otherwise.

llListFindListStrided also seems nice, although it's not something that's overly difficult to do without the function.

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

I can't remember the last time I used llList2ListStrided() that didn't also have llListSort() in the script somewhere, so the proposed llListSortStrided() is particularly interesting, and I agree with Tessa that being able to sort on multiple keys would be good (that is, practically indispensable, if only infrequently).

As noted in the user group discussion, one advantage of using library functions rather than writing equivalent LSL is that a library function keeps script memory free of all the garbage generated by intermediate call-by-value copying. (That's in addition to the obvious advantage of sharing a common implementation everywhere the functionality is needed.)

  • Like 2
Link to comment
Share on other sites

about the function llList2ListSlice

I think it would be good if 'index' was multi-column: indexstart,indexend

llList2ListSlice( list src, integer start, integer end, integer stride, integer indexstart, integer indexend);


a thing. As soon as we have a list slice function then we will want all the other functions that this implies. Like:

llListInsertListSlice
llDeleteSubListSlice
llListReplaceListSlice
llListFindListSlice

able to merge, unmerge and update columns of a strided list

the most used application of these I think would be the parameter list of llSetPrimitiveParams. Particularly llListReplaceListSlice. Prim and face attribute changeouts for example

  • Like 1
Link to comment
Share on other sites

13 hours ago, Quistess Alpha said:

llListSortStrided is something I've wished for in the past, but it would be even better to have a function that can sort based on multiple elements of the stride. Consider the following 2-strided list:

 

i like this thought

i would add that 'list keyIndexes' be a paired parameter list, the second of the pair being the ascending order flag

example:

keyIndexes:  [2, TRUE, 3, FALSE, 1, TRUE]

  • Like 1
Link to comment
Share on other sites

I think with the functions already given in the jira it is going to be possible to have a list on which one can do some matrix transforms, such as 

 

list [A1,A2,A3,A4,B1,B2,B3,B4,C1,C2,C3,C4,D1,D1,D2,D3,D4] 

Via the vertical slices in four successive takes going to 

list2 [A1,B1,C1,D1,A2,B2,C2,D2,A3,B3,C3,D3,A4,B4,C4,D4]

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 938 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...