Skip to main content

mapfun

  • 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.
  • The mapfun function has been developed in JavaScript and Python, offering the same functionality in different programming languages.

Install

pip install mapfun

Import

from mapfun import mapfun

Arguments

  • 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

Examples

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]))

Supported Datatypes

Datatype Support
int ✅
str ✅
Boolean ✅
float ✅
None ✅
memoryview ✅
list ✅
object ✅
dict ✅
set ✅
tuple ✅
bytes ✅
bytearray ✅
range ✅
complex ❌

Alternatives

Javascript

License

This projet is licensed under the terms of MIT License .

Metadata

Release files for mapfun 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mapfun 0.0.5
File Size Uploaded
mapfun-0.0.5.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mapfun 0.0.5
File Interpreter ABI Platform
mapfun-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / mapfun-0.0.5.tar.gz

Download URL mapfun-0.0.5.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82a265e1dabf52e681531684b6858404d49d3477e8a4ba7fe97ea83c22f88cc3
BLAKE2b-256 checksum
How to use checksums
928a5aabfc00e74ca8638b5d701139ca98171983db99ba196f0cde11e9e4f159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / mapfun-0.0.5-py3-none-any.whl

Download URL mapfun-0.0.5-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d014dfece7ab243338c69b4ebe6cb8ae8353fce9f845a76fb611a4b784842d11
BLAKE2b-256 checksum
How to use checksums
e7e8e638670616313ac7f93f631352f160a394d47fc361fd24228f5eeb0579a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page