MarvelousPy


NameMarvelousPy JSON
Version 0.0.0.3 PyPI version JSON
download
home_pagehttps://github.com/dg-developer/MarvelousPy
SummaryAmazing functional programming interface for Python.
upload_time2023-09-17 00:55:39
maintainer
docs_urlNone
authorDavid Gayman
requires_python>=3.9,<4.0
licenseApache-2.0
keywords amazing marvelous functional functional programming fp utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MarvelousPy

Amazing functional programming interface for Python.

# Pipelines

Data pipelines are defined which connect blocks.

# Blocks

Blocks are fundamental units composing pipelines.

# Types of Blocks

## Switch

Defines piecewise-defined switch block.

Define the matching function.

Define cases, composed of:
- Case expression
- Value expression

Cases are defined

## Binary Switch

A binary switch provides similar operation as the standard switch block, but restricts possible case values to True and False.

A binary switch may be defined trivially, and is applicable to use cases which require splitting the input data.

```
sw = binary_switch(lambda x: x == 4)
case(1, "One")
case(2, "Two")
default("Unknown")
apply([0, 1, 2])  # Returns [ "Unknown", "One", "Two"]



data_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999]
expected_data_list = ["Not Four", "Not Four", "Not Four", "FOUND FOUR", "Not Four", "Not Four", "Not Four",
      "Not Four", "Not Four", "Not Four", "Not Four"]

# Set up the switch
data_pipe = binary_switch(lambda x: x == 4)

# Assign values (default implicitly assigned through the False case)
case_true(data_pipe, "FOUND FOUR")
case_false(data_pipe, "Not Four")

# Apply the switch
out_iterator = apply(data_pipe, data_list)
self.assertListEqual(list(out_iterator), expected_data_list)
```


        Defines a switch block.

            # Anatomy of a switch block declaration
            switch(<match expression>)
            case(<case expression>, <value expression>)
            default(<default value expression>)

            # Build a pure mapping function
            switch()
            default(lambda x: <transform>)

            # Build a switch block, switching based on raw value, generating a value
            switch()
            case(1, "One")
            case(2, "Two")
            default("Unknown")
            apply([0, 1, 2])  # Returns [ "Unknown", "One", "Two"]

            # Build a switch block, switching based on the value transformed through the match expression, generating
                a value
            switch(lambda x: x + 1)
            case(1, "One")
            default("Unknown")
            apply([0, 1, 2])  # Returns [ "One", "Unknown", "Unknown"]

            # Build a switch block, switching based on the case expression matched to the value processed by the match
                expression, generating an expression
            switch(lambda x: x + 1)
            case(lambda x: x == 4, lambda x: x*x)
            default("Unknown")
            apply([1, 2, 3])  # Returns [ "Unknown", "Unknown", 9]
            # Explanation:
            #   Consider value 3
            #   Match expression evaluates to 3 + 1
            #   Case expression evaluates to 4 == 4
            #   Value expression generates 3 * 3. Note that the item under consideration, not the result of the
                match expression, is plugged into the value expression.

        :param match_expression_function: Silent transformation function used to transform input prior to comparison with
            case lookup tables.
        :param pipe_from:
        :param pipe_to:


## Map

Perform 1:1 mapping operation for the input.






        :param case_lookup: Values or expressions mapped to output values or expressions. None key denotes default case. Example:

                {
                    1: "One",                   # Maps a value to a value
                    lambda x: x == 2: "Two",    # Evaluates the match expression (computed from the item), and if the function returns true the value "Two" is returned.
                    3: lambda x: "Three",       # Maps a value to a function which is executed on the item.
                    None: "Unknown"             # Provides a default value. If not provided, None is used as the default.
                 }

        :return:
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dg-developer/MarvelousPy",
    "name": "MarvelousPy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "amazing,marvelous,functional,functional programming,fp,utility",
    "author": "David Gayman",
    "author_email": "drg.developer.2@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/24/95/c6cde38c76fb621f15801d056b4f3542156baa2677ec31f52d5f008c3762/marvelouspy-0.0.0.3.tar.gz",
    "platform": null,
    "description": "# MarvelousPy\n\nAmazing functional programming interface for Python.\n\n# Pipelines\n\nData pipelines are defined which connect blocks.\n\n# Blocks\n\nBlocks are fundamental units composing pipelines.\n\n# Types of Blocks\n\n## Switch\n\nDefines piecewise-defined switch block.\n\nDefine the matching function.\n\nDefine cases, composed of:\n- Case expression\n- Value expression\n\nCases are defined\n\n## Binary Switch\n\nA binary switch provides similar operation as the standard switch block, but restricts possible case values to True and False.\n\nA binary switch may be defined trivially, and is applicable to use cases which require splitting the input data.\n\n```\nsw = binary_switch(lambda x: x == 4)\ncase(1, \"One\")\ncase(2, \"Two\")\ndefault(\"Unknown\")\napply([0, 1, 2])  # Returns [ \"Unknown\", \"One\", \"Two\"]\n\n\n\ndata_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999]\nexpected_data_list = [\"Not Four\", \"Not Four\", \"Not Four\", \"FOUND FOUR\", \"Not Four\", \"Not Four\", \"Not Four\",\n      \"Not Four\", \"Not Four\", \"Not Four\", \"Not Four\"]\n\n# Set up the switch\ndata_pipe = binary_switch(lambda x: x == 4)\n\n# Assign values (default implicitly assigned through the False case)\ncase_true(data_pipe, \"FOUND FOUR\")\ncase_false(data_pipe, \"Not Four\")\n\n# Apply the switch\nout_iterator = apply(data_pipe, data_list)\nself.assertListEqual(list(out_iterator), expected_data_list)\n```\n\n\n        Defines a switch block.\n\n            # Anatomy of a switch block declaration\n            switch(<match expression>)\n            case(<case expression>, <value expression>)\n            default(<default value expression>)\n\n            # Build a pure mapping function\n            switch()\n            default(lambda x: <transform>)\n\n            # Build a switch block, switching based on raw value, generating a value\n            switch()\n            case(1, \"One\")\n            case(2, \"Two\")\n            default(\"Unknown\")\n            apply([0, 1, 2])  # Returns [ \"Unknown\", \"One\", \"Two\"]\n\n            # Build a switch block, switching based on the value transformed through the match expression, generating\n                a value\n            switch(lambda x: x + 1)\n            case(1, \"One\")\n            default(\"Unknown\")\n            apply([0, 1, 2])  # Returns [ \"One\", \"Unknown\", \"Unknown\"]\n\n            # Build a switch block, switching based on the case expression matched to the value processed by the match\n                expression, generating an expression\n            switch(lambda x: x + 1)\n            case(lambda x: x == 4, lambda x: x*x)\n            default(\"Unknown\")\n            apply([1, 2, 3])  # Returns [ \"Unknown\", \"Unknown\", 9]\n            # Explanation:\n            #   Consider value 3\n            #   Match expression evaluates to 3 + 1\n            #   Case expression evaluates to 4 == 4\n            #   Value expression generates 3 * 3. Note that the item under consideration, not the result of the\n                match expression, is plugged into the value expression.\n\n        :param match_expression_function: Silent transformation function used to transform input prior to comparison with\n            case lookup tables.\n        :param pipe_from:\n        :param pipe_to:\n\n\n## Map\n\nPerform 1:1 mapping operation for the input.\n\n\n\n\n\n\n        :param case_lookup: Values or expressions mapped to output values or expressions. None key denotes default case. Example:\n\n                {\n                    1: \"One\",                   # Maps a value to a value\n                    lambda x: x == 2: \"Two\",    # Evaluates the match expression (computed from the item), and if the function returns true the value \"Two\" is returned.\n                    3: lambda x: \"Three\",       # Maps a value to a function which is executed on the item.\n                    None: \"Unknown\"             # Provides a default value. If not provided, None is used as the default.\n                 }\n\n        :return:",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Amazing functional programming interface for Python.",
    "version": "0.0.0.3",
    "project_urls": {
        "Documentation": "https://github.com/dg-developer/MarvelousPy",
        "Homepage": "https://github.com/dg-developer/MarvelousPy",
        "Repository": "https://github.com/dg-developer/MarvelousPy"
    },
    "split_keywords": [
        "amazing",
        "marvelous",
        "functional",
        "functional programming",
        "fp",
        "utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62014e9bd875c9058200ff763023ba2b96fb878992b5171a282703ac65102e4a",
                "md5": "81ea0e61d8821dab0cba0536ad475533",
                "sha256": "7e90714b4e2e3cb9bc3cc951dd34170c0d732a60874e1e765f4f49b387f7c362"
            },
            "downloads": -1,
            "filename": "marvelouspy-0.0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81ea0e61d8821dab0cba0536ad475533",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 13687,
            "upload_time": "2023-09-17T00:55:37",
            "upload_time_iso_8601": "2023-09-17T00:55:37.934592Z",
            "url": "https://files.pythonhosted.org/packages/62/01/4e9bd875c9058200ff763023ba2b96fb878992b5171a282703ac65102e4a/marvelouspy-0.0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2495c6cde38c76fb621f15801d056b4f3542156baa2677ec31f52d5f008c3762",
                "md5": "90c6bc86e69bfbd6ed9fe20bf937ea3a",
                "sha256": "fde95c2039a7cdaf1d6120d818f194633add1db527c6e03d3e4c6e2173b49f65"
            },
            "downloads": -1,
            "filename": "marvelouspy-0.0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "90c6bc86e69bfbd6ed9fe20bf937ea3a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 10708,
            "upload_time": "2023-09-17T00:55:39",
            "upload_time_iso_8601": "2023-09-17T00:55:39.444597Z",
            "url": "https://files.pythonhosted.org/packages/24/95/c6cde38c76fb621f15801d056b4f3542156baa2677ec31f52d5f008c3762/marvelouspy-0.0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-17 00:55:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dg-developer",
    "github_project": "MarvelousPy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "marvelouspy"
}
        
Elapsed time: 0.11369s