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:
  • list1 (list) – input list 1
  • list2 (list) – input list 2
Returns:

a new list contains all Cartesian products of the two lists.

Return type:

list

>>> 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']]

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]

FunctionalX

FunctionalX package

Subpackages

FunctionalX.src package
Subpackages
FunctionalX.src.lists package
Module contents
Module contents
FunctionalX.tests package
Subpackages
FunctionalX.tests.lists package
Subpackages
FunctionalX.tests.lists.cart2 package
Submodules
FunctionalX.tests.lists.cart2.test_1 module
Module contents
Module contents
Module contents

Module contents

Indices and tables