Primitives¶
-
basic_utils.primitives.
natural_nums
(start=0, end=None)[source]¶ Yields a lazy sequence of natural numbers
>>> from itertools import islice >>> list(islice(natural_nums(5), 3)) [5, 6, 7]
Return type: Iterator
[int
]
-
basic_utils.primitives.
identity
(x)[source]¶ Returns the same values passed as arguments
>>> x = (10, 20) >>> identity(x) (10, 20)
Return type: Any
-
basic_utils.primitives.
comp
(*funcs)[source]¶ Takes a set of functions and returns a fn that is the composition of those functions
Return type: Callable
-
basic_utils.primitives.
complement
(fn)[source]¶ Takes a function fn and returns a function that takes the same arguments as fn with the opposite truth value.
>>> not_five = complement(lambda x: x == 5) >>> not_five(6) True
Return type: Callable
-
basic_utils.primitives.
compose
(*funcs)¶ Takes a set of functions and returns a fn that is the composition of those functions
Return type: Callable