# Arbitrary Thoughts On Arbitrary Parameters Functions

## versus λ-f()

5 min readMay 3, 2024

I came across a specific tasks that they have to be repeated with different values.

`def do_function_N_times(n, function_arbitary):`

"""

Call function_arbitary n times and return output of the n times.

"""

return [function_arbitary() for _ in range(n)]

# Example usage

import random

number_of_values_to_produce = 5

function_arbitary = lambda: random.randint(1, 2**64) # def function_arbitary

[a, b, c, x, y] = do_function_N_times(number_of_values_to_produce, function_arbitary)

Then some specific tasks have to be repeated with different values. For example, we have to print the above, 1 after another.

`def do_function_with_inputs(function_arbitrary, *args):`

"""

Call function_arbitrary with provided arguments

"""

return function_arbitrary(*args)

# Example usage

inputs = [a, b, c, x, y] # from the above

# Define the lambda function to print a list one by one

function_arbitrary = lambda lst: [print(item) for item in lst]

print(f"a, b, c, x, y >:")

do_function_with_inputs(function_arbitrary, inputs)

"""a, b, c, x, y >:

4122588640454319721

16743147703723349922

766815114989031979

4320467388028437636

2035106047778081284

"""

Can we obviate the call and use lamda function? In fact, it seems redundant at times…