Sequence Routines
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 18, 2003
- 400 views
Hi, I'm not sure of the protocol here, but I recently sent a file to the RDS contributions section. In case anyone is interested, it contains a set of functions that perform some common sequence processing... -- remove_right -- (sequence pSource, integer pHowMany) -- Removes a specified number of elements from the end of a sequence. -- Returns the updated sequence -- remove_left -- (sequence pSource, integer pHowMany) -- Removes a specified number of elements from the start of a sequence. -- Returns the updated sequence -- remove_mid -- (sequence pSource, integer pHowMany, integer pFrom) -- Removes a specified number of elements from a sequence starting at a specified point. -- Returns the updated sequence -- insert -- (sequence pTarget, integer pPosition, object pNewData) -- Inserts some new elements into a sequence at a specified position. -- Returns the updated sequence -- last_element -- (sequence pSource) -- Returns the last element of a non-empty sequence, otherwise returns {} -- to_head -- (sequence pSource, integer pElement) -- Moves the specified element to the start of a sequence. -- Returns the updated sequence -- to_tail -- (sequence pSource, integer pElement) -- Moves the specified element to the end of a sequence. -- Returns the updated sequence -- move_back -- (sequence pSource, integer pElement, integer pIncrement) -- Moves the specified element towards the end of a sequence, by a specified increment. -- Returns the updated sequence -- move_forward -- (sequence pSource, integer pElement, integer pIncrement) -- Moves the specified element towards the start of a sequence, by a specified increment. -- Returns the updated sequence -- find_from -- (object pElement, sequence pSource, integer pFrom) -- Locates the specified element in a sequence, starting from a specified point. -- Returns the position relative to the start of the sequence or zero if not found. -- find_all -- (object pElement, sequence pSource) -- Locates the all the occurances of the specified element in a sequence -- Returns a sequence listing each occurance. If none found an empty sequence is returned. -- match_from -- (object pElements, sequence pSource, integer pFrom) -- Locates the specified element list in a sequence, starting from a specified point. -- Returns the position relative to the start of the sequence or zero if not found. -- match_all -- (sequence pElements, sequence pSource) -- Locates the all the occurances of the specified element list in a sequence -- Returns a sequence listing each occurance. If none found an empty sequence is returned. -- mid -- (sequence pSource, integer pFrom, integer pHowMany) -- Returns the specified number of elements of a sequence starting from a specified position -- Returns a sequence -- left -- (sequence pSource, integer pHowMany) -- Returns the specified number of elements from the start of a sequence. -- Returns a sequence -- right -- (sequence pSource, integer pHowMany) -- Returns the specified number of elements from the end of a sequence. -- Returns a sequence -- cheers, Derek