Note

The wasCircularListNext function takes as input a circular list and a node within that list and returns the next element in the list. An example call is the following:

list a = [ 1, 2, 3, 4, 5 ];
a = wasCircularListNext(a, [5]);

the returned list will contain:

1

Code

///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2014 - License: GNU GPLv3      //
///////////////////////////////////////////////////////////////////////////
list wasCircularListNext(list input, list node) {
    integer i = llListFindList(input, node);
    if(i == -1) return [];
    integer m = (i+1) % llGetListLength(input);
    return llList2List(input, m, m);
}