#include <set>
#include <algorithm>
#include "ycp/YCPBuiltinList.h"
#include "ycp/YCPList.h"
#include "ycp/YCPMap.h"
#include "ycp/YCPSymbol.h"
#include "ycp/YCPString.h"
#include "ycp/YCPBoolean.h"
#include "ycp/YCPInteger.h"
#include "ycp/YCPVoid.h"
#include "ycp/YCPCode.h"
#include "ycp/YCPCodeCompare.h"
#include "ycp/YCPTerm.h"
#include "ycp/StaticDeclaration.h"
#include "ycp/y2log.h"
Functions | |
static YCPValue | l_find (const YCPSymbol &symbol, const YCPList &list, const YCPCode &expr) |
Searches for the first occurence of a certain element in a list. | |
static YCPValue | l_prepend (const YCPList &list, const YCPValue &value) |
Prepends a list with a new element. | |
static YCPValue | l_contains (const YCPList &list, const YCPValue &value) |
Checks if a list contains an element. | |
static YCPValue | l_setcontains (const YCPList &list, const YCPValue &value) |
Checks if a sorted list contains an element. | |
static YCPValue | l_unionlist (const YCPList &list1, const YCPList &list2) |
Unions of lists. | |
static YCPValue | l_mergelist (const YCPList &list1, const YCPList &list2) |
Merges two lists into one. | |
static YCPValue | l_filter (const YCPSymbol &symbol, const YCPList &list, const YCPCode &expr) |
Filters a List. | |
static YCPValue | l_maplist (const YCPSymbol &symbol, const YCPList &list, const YCPCode &expr) |
Maps an operation onto all elements of a list and thus creates a new list. | |
static YCPValue | l_listmap (const YCPSymbol &symbol, const YCPList &list, const YCPCode &expr) |
Maps an operation onto all elements of a list and thus creates a map. | |
static YCPValue | l_flatten (const YCPList &list) |
Flattens List. | |
static YCPValue | l_toset (const YCPList &list) |
Sorts list and removes duplicates. | |
static YCPValue | l_sortlist (const YCPList &list) |
Sorts a List according to the YCP builtin predicate. | |
static YCPValue | l_sort (const YCPValue &sym1, const YCPValue &sym2, const YCPList &list, const YCPCode &order) |
Sort list using an expression. | |
static YCPValue | l_lsortlist (const YCPList &list) |
Sort A List respecting locale. | |
static YCPValue | l_splitstring (const YCPString &s, const YCPString &c) |
Split a string by delimiter. | |
static YCPValue | l_changelist (YCPList &list, const YCPValue &value) |
Changes a list. | |
static YCPValue | l_add (const YCPList &list, const YCPValue &value) |
Create a new list with a new element. | |
static YCPValue | l_size (const YCPValue &list) |
Returns size of list. | |
static YCPValue | l_remove (const YCPList &list, const YCPInteger &i) |
Removes element from a list. | |
static YCPValue | l_select (const YCPValue &list, const YCPValue &i, const YCPValue &def) |
Selects a list element (deprecated, use LIST[INDEX]:DEFAULT). | |
static YCPValue | l_foreach (const YCPValue &sym, const YCPList &list, const YCPCode &expr) |
Processes the content of a list. | |
static YCPValue | l_tolist (const YCPValue &v) |
Converts a value to a list (deprecated, use (list)VAR). | |
Variables | |
StaticDeclaration | static_declarations |
|
Create a new list with a new element. add
|
|
Changes a list. change
|
|
Checks if a list contains an element. contains
ELEMENT is contained in a list LIST .contains ([1, 2, 5], 2) -> true |
|
Filters a List. filter
|
|
Searches for the first occurence of a certain element in a list. find
EXPR to each element in the list and returns the first element the makes the expression evaluate to true, if VAR is bound to that element.
|
|
Flattens List. flatten
LIST and creates a single list that is the concatenation of those lists in LIST .flatten ([ [1, 2], [3, 4] ]) -> [1, 2, 3, 4] flatten ([ [1, 2], [6, 7], [3, 4] ]) -> [1, 2, 6, 7, 3, 4] |
|
Processes the content of a list. foreach
LIST the expression EXPR is executed in a new context, where the variable VAR is assigned to that value. The return value of the last execution of EXPR is the value of the foreach construct.
|
|
Maps an operation onto all elements of a list and thus creates a map. listmap
VAR of the list LIST in the expression EXPR is evaluated in a new context. The result is the map of those evaluations.The result of each evaluation must be a map with a single entry which will be added to the result map. listmap (integer k, [1,2,3], { return $[k:"xy"]; }) -> $[1:"xy", 2:"xy"] listmap (integer k, [1,2,3], { integer a = k+10; any b = sformat ("x%1", k); return $[a:b]; }) -> $[11:"x1", 12:"x2", 13:"x3"] |
|
Sort A List respecting locale. lsort
|
|
Maps an operation onto all elements of a list and thus creates a new list. maplist
LIST the expression EXPR is evaluated in a new context, where the variable VAR is assigned to that value. The result is the list of those evaluations.maplist (integer v, [1, 2, 3, 5], { return (v + 1); }) -> [2, 3, 4, 6] |
|
Merges two lists into one. merge
l1 are prior to elements from l2 .
|
|
Prepends a list with a new element. prepend
|
|
Removes element from a list. remove
|
|
Selects a list element (deprecated, use LIST[INDEX]:DEFAULT). select
INDEX 'th value of a list. The first value has the index 0. The call select([1,2,3], 1) thus returns 2. Returns DEFAULT if the index is invalid or if the found entry has a different type than the default value. Functionality replaced by syntax: list numbers = [1, 2, 3, 4]; numbers[2]:nil -> 3 numbers[8]:5 -> 5 select ([1, 2], 22, 0) -> 0 select ([1, "two"], 0, "no") -> "no" |
|
Checks if a sorted list contains an element. setcontains
|
|
Returns size of list. size
LIST size(["A", 1, true, "3", false]) -> 5 |
|
Sort list using an expression. sort sort_2
LIST . You have to specify an order on the list elements by naming formal variables x and y and specify an expression EXPR that evaluates to a boolean value depending on x and y . Return true if x >y to sort the list ascending.The comparison must be an irreflexive one, that is ">" instead of ">=". It is because we no longer use bubblesort (yuck) but std::sort which requires a <ulink url="href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">strict weak ordering</ulink>. sort (integer x, integer y, [ 3,6,2,8 ], ``(x < y)) -> [ 2, 3, 6, 8 ] sort (string x, string y, [ "A","C","B" ], ``(x > y)) -> ["C", "B", "A"] |
|
Sorts a List according to the YCP builtin predicate. sort sort_1
sort ([2, 1, true, 1]) -> [true, 1, 1, 2] |
|
Split a string by delimiter. splitstring
STR into sub-strings at delimiter chars DELIM . the resulting pieces do not contain DELIM
If
|
|
Converts a value to a list (deprecated, use (list)VAR). tolist
any l_1 = [1, 2, 3]; list <integer> l_2 = (list<integer>) l_1; |
|
Sorts list and removes duplicates. toset
|
|
Unions of lists. union
l1 are prior to elements from l2 .WARNING: quadratic complexity so far
|
|
|