Skip to content

Instantly share code, notes, and snippets.

@theSamyak
Last active May 25, 2024 13:35
Show Gist options
  • Save theSamyak/eb00e8b7331964c764de0b7248d27419 to your computer and use it in GitHub Desktop.
Save theSamyak/eb00e8b7331964c764de0b7248d27419 to your computer and use it in GitHub Desktop.
[FCC First class functions and Closures Blog] Passing Functions as Arguments
def double(n):
return n * 2
def map_function(func, values):
result = []
for value in values:
result.append(func(value))
return result
# Use the custom map function
doubled_values = map_function(double, [3, 6, 9, 12, 15])
print(doubled_values) # Output: [6, 12, 18, 24, 30]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment