Author Topic: Resource: listSupport.cs  (Read 900 times)

This is an old resource I made for tab-delimited list support. Obviously it is extendable and manipulatable. No credit necessary.

API:


ListAppend( list original, entry one )                :: Adds entry to list
ListClean( list original )                            :: Cleans empty elements from list
ListCollapse( list original )                         :: Removes repeated entries in lists.
ListCombine( list one, list two )                     :: Combines two lists.
ListExclude( list one, list two )                     :: Removes all entries of list two from list one.
ListIterate( list original, function name, arg1, ...) :: Iterates through the list calling "function" on each entry
                                                           in the manner of function(entry, arg1, ...) WARNING: Potentially unsafe.
ListZip( list one, list two )                         :: Pairs elements of list one and list two in a zippering fashion:
                                                           e.g. ListZip("1\t3", "2\t4") $= "1\t2\t3\t4"

ListTokenizeZipped( list original, ScriptObject recycle ) :: Creates a script object with value pairs with adjacent
                                                               entries being in TITLE\tPAIR format. Creates a new script object or recycles a provided one.
                                                               e.g. ListTokenizeZipped("Money\t15\tFood\t5").dump()
                                                                 Tagged Fields:
                                                                   elemCnt = "2"
                                                                   elemName0 = "Money"
                                                                   elemName1 = "Food"
                                                                   elemVal0 = "15"
                                                                   elemVal1 = "5"


Link: http://pastebin.com/qe8ss8vy

Example:
%tokens = ListTokenizeZipped(ListZip(%availableNodes, ListIterate(%availableNodes, "nodeDistance", %lastPos, %end, %stepSize)), %tokens);