
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
mapfun
is a function that applies a mapping function to an infinite number of input elements, with options to skip certain elements and selectively apply the mapping to keys and/or values of objects.mapfun
function has been developed in JavaScript and Python, offering the same functionality in different programming languages.pip install mapfun
from mapfun import mapfun
fun
: The mapping function that will be applied to each element in the input elements....X
:The elements to be mapped . { "skip" , "key" , "value" }
: Object with three optional properties :
"skip"
: specifies the elements to skip during the mapping process."key"
: boolean flag indicating whether to apply the mapping function to the keys of objects or not. The default value is false
"value"
: boolean flag indicating whether to apply the mapping function to the values of objects or not. The default value is true
print(mapfun(lambda a : a + 1,{},4))
# Expected return : 5
print(mapfun(lambda a : a + 1.0,{},4.2))
# Expected return : 5.2
print(mapfun(lambda a : len(a),{},"Ziko"))
# Expected return : 4
print(mapfun(lambda a : a + 5,{},[1, 2, 3, [4]]))
# Expected return : [6,7,8,[9]]
print(mapfun(lambda a : a + 5,range(0,10)))
print(mapfun(lambda a : a + 5,{},(1, 2, 3, [4])))
print(mapfun(lambda a : a + 5,{},{1,2,3}))
print(mapfun(lambda a : a + 5,frozenset({1,2,3})))
print(mapfun(lambda a : a + 5,{},{"a":1,"b":2,"c":3}))
print(mapfun(lambda x:x+1,{},1,2,3,[1,2]))
print(mapfun(lambda x:x+1,{},1,2,3,[1,2]))
Datatype | Support |
---|---|
int | ✅ |
str | ✅ |
Boolean | ✅ |
float | ✅ |
None | ✅ |
memoryview | ✅ |
list | ✅ |
object | ✅ |
dict | ✅ |
set | ✅ |
tuple | ✅ |
bytes | ✅ |
bytearray | ✅ |
range | ✅ |
complex | ❌ |
This projet is licensed under the terms of MIT License .
FAQs
mapfun
We found that mapfun demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.