Пример #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)])
Пример #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])
Пример #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)])
Пример #4
0
from ramda.curry import curry

equals = curry(lambda x, y: x == y)
Пример #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)))
Пример #6
0
from ramda.curry import curry

map = curry(lambda f, xs: [f(x) for x in xs])
Пример #7
0
from ramda.curry import curry
import builtins

isinstance = curry(lambda type, v: builtins.isinstance(v, type))
Пример #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])
Пример #9
0
from ramda.curry import curry
import re

replace = curry(re.sub)
Пример #10
0
from ramda.curry import curry

getitem = curry(lambda key, collection: collection[key])
Пример #11
0
from ramda.curry import curry


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