Skip to main content

mapfun

Project description

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 .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mapfun-0.0.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mapfun-0.0.5-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file mapfun-0.0.5.tar.gz.

File metadata

  • Download URL: mapfun-0.0.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for mapfun-0.0.5.tar.gz
Algorithm Hash digest
SHA256 82a265e1dabf52e681531684b6858404d49d3477e8a4ba7fe97ea83c22f88cc3
MD5 7347ca3bdfe94c8dee9ca813676207c9
BLAKE2b-256 928a5aabfc00e74ca8638b5d701139ca98171983db99ba196f0cde11e9e4f159

See more details on using hashes here.

File details

Details for the file mapfun-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: mapfun-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for mapfun-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d014dfece7ab243338c69b4ebe6cb8ae8353fce9f845a76fb611a4b784842d11
MD5 9349f6cf0ed4fc2ad0fff40c35a029b9
BLAKE2b-256 e7e8e638670616313ac7f93f631352f160a394d47fc361fd24228f5eeb0579a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page