Exemplo n.º 1
0
from ramda.curry import curry
"""This functions takes two list and applies given function to it"""
zip_with = curry(lambda f, xs1, xs2: [f(x, y) for x, y in zip(xs1, xs2)])
Exemplo n.º 2
0
from ramda.curry import curry
"""This functions takes cross product of two list"""

xprod = curry(lambda xs1, xs2: [[x, y] for y in xs2 for x in xs1])
Exemplo n.º 3
0
from ramda.curry import curry
"""This functions applies function at given index"""
update = curry(
    lambda i, v, xs: [v if i == ind else x for ind, x in enumerate(xs)])
Exemplo n.º 4
0
from ramda.curry import curry

equals = curry(lambda x, y: x == y)
Exemplo n.º 5
0
from ramda.curry import curry

"""This functions takes two list and creates a dictionary with it"""
zip_obj = curry(lambda key, val: dict(zip(key, val)))
Exemplo n.º 6
0
from ramda.curry import curry

map = curry(lambda f, xs: [f(x) for x in xs])
Exemplo n.º 7
0
from ramda.curry import curry
import builtins

isinstance = curry(lambda type, v: builtins.isinstance(v, type))
Exemplo n.º 8
0
from ramda.curry import curry

"""Returns a new list without values in the first argument"""

a = [1, 2]
b = [1, 2, 1, 3, 4]

without = curry(lambda xs1, xs2: [x for x in xs2 if x not in xs1])
Exemplo n.º 9
0
from ramda.curry import curry
import re

replace = curry(re.sub)
Exemplo n.º 10
0
from ramda.curry import curry

getitem = curry(lambda key, collection: collection[key])
Exemplo n.º 11
0
from ramda.curry import curry


filter = curry(lambda p, xs: [x for x in xs if p(x)])