Welcome to FunctionalX.py’s documentation!¶
Contents:
lists¶
cart2()¶
-
FunctionalX.src.lists._cart2.
cart2
(list1: list, list2: list) → list¶ Cartesian product of two lists.
Parameters: Returns: a new list contains all Cartesian products of the two lists.
Return type: >>> cart2(['a','b'], [1,2]) [['a',1],['a',2],['b',1], ['b',2]]
cartn()¶
-
FunctionalX.src.lists._cartn.
cartn
(*all_lists: list) → list¶ Cartesian product of n lists.
Parameters: all_lists(vararg) (list) – variable number of lists Returns: a new list Return type: list >>> cartn(['a','b'], [1,2], ['A','B']) [['a', 1, 'A'], ['a', 1, 'B'], ['a', 2, 'A'], ['a', 2, 'B'], ['b', 1, 'A'], ['b', 1, 'B'], ['b', 2, 'A'], ['b', 2, 'B']]
cart_append()¶
dict2list()¶
-
FunctionalX.src.lists._dict2list.
dict2list
(d: dict) → list¶ Return an array given a dictionary”
Parameters: d (dict) – input dictionary object Returns: a list for possible combinations of keys/values Return type: list [[‘a’, 1, ‘A’], [‘a’, 2, ‘B’], [‘b’, 3, ‘C’], [‘b’, 4, ‘D’]] >>> dict2list({ "a": { 1: "A", 2: "B" }, "b": { 3: "C", 4: "D" } }) [['a', 1, 'A'], ['a', 2, 'B'], ['b', 3, 'C'], ['b', 4, 'D']]
head()¶
tail()¶
-
FunctionalX.src.lists._tail.
tail
(list1: list) → list¶ Return the tail of a list
Return the rest of the list (beyond the first element). If the input list is empty or has only one element, then return [].
Parameters: list1 (list) – input list Returns: a new list Return type: list >>> tail([]) []
>>> tail([1]) []
>>> tail([1,2,3]) [2,3]