SourceForge.net Logo

Euphoria Standard Library
(ESL)

Home Page | Project Status | Contribute | Guidelines and Information



Euphoria Standard Library module:

seqops.e



1. Introduction


This module defines a variety of routines to do advanced yet commonly used manipulations on sequences.



2. Routines

count

Syntax: i = count(x, s)
Description: Counts how often object x is contained in sequence s.
Status: PROPOSED


depth

Syntax: i = depth(s)
Description: Returns the "depth" of an object. An atom returns 0, a string returns 1, a composite sequence returns 2 or more depending on how many sequences containing sequences it has. (Ricardo Forno had posted such a function in March 2002 on EUforum.)
Status: PROPOSED


find_all

Syntax: s = find_all(x, s)
Description: Like Euphoria's find(), but doesn't only return the first place where x was found in s, but a sequence that is a list of all places where x was found in s.
Status: PROPOSED



flatten

Syntax: s = flatten(s)
Description: Takes a sequence of arbitrary depth, and returns its contents as flat sequence (depth = 1). (Derek Parnell had posted such a function in June 2003 on EUforum.)
Status: PROPOSED


map, apply

Syntax: x = map(x, rid)
Description: Applies the function pointed to by rid to every element of x unless x is an atom in which case it returns the function called with x. For this reason all functions that rid points to should ideally take objects.
Status: PROPOSED


match_all

Syntax: s = find_all(x, s)
Description: Like Euphoria's match(), but doesn't only return the first place where x was matched in s, but a sequence that is a list of all places where x was matched in s.
Status: PROPOSED


replace_element

Syntax: s = replace_element(s, x1, x2)
Description: Replaces all occurances of x1 with x2 in source sequence s. In essence looks for all cases where find(x1, s) returns a value != 0, and replaces x1 with x2.
Status: PROPOSED