Skip to main content

COPERATOR

COPERATOR Usage

factory_operator usage

from coperator.myoperator import factory_operator


class Example:
    """Example."""

    def __init__(self, x: int) -> None:
        """__init__.

        :param x:
        :type x: int
        :rtype: None
        """
        self._x: int = self.set_x(x)

    def set_x(self, x: int) -> int:
        """set_x.

        :param x:
        :type x: int
        :rtype: int
        """
        return x

    def get_x(self) -> int:
        """get_x.

        :rtype: int
        """
        return self._x

    def __str__(self) -> str:
        """__str__.

        :rtype: str
        """
        return str(self.get_x())


@factory_operator(Example, Example, Example)
def op(A: Example, B: Example) -> Example:
    """op.

    :param A:
    :type A: Example
    :param B:
    :type B: Example
    :rtype: Example
    """
    return Example(A.get_x() + B.get_x())


E1: Example = Example(1)
E2: Example = Example(2)
E3: Example = Example(3)

print(E1 * op * E2 * op * E3)
6

monad usage

from coperator.monad import monad

 def neg(i):
     return -i

 print(monad("1")(int)(neg)(str)(None))
 print(monad("x")(int)(neg)(str)(None))

 def func1(i):
     return monad(i)(int)(neg)(str)(None)

 print(list(map(func1,["1",2,"z"])))
'-1'
None
['-1','-2',None]

LICENSE

MIT License

Copyright (c) 2020 Jean Carlo Jimenez Giraldo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for coperator 1.1.12

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

Source distribution (sdist)

Source distribution for coperator 1.1.12
File Size Uploaded
coperator-1.1.12.tar.gz 3.3 kB Details

Release files / coperator-1.1.12.tar.gz

Download URL coperator-1.1.12.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
596ff0c39515d81a218e384cbe1688d4e9b26cd1582fb48e454126c52f34ee75
BLAKE2b-256 checksum
How to use checksums
ac085ba36c1236fa5c56754d17594610593ac86373f490d477cecb96e75483cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.1.12 This release

1 release file

1.1.11

1 release file

1.1.10

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.2

1 release file

1.1.1

1 release file

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