Skip to content

[IMPL] implement trigonometric functions #86

Description

@Doomsk

Implementation description

Implement basic trigonometric functions following the same logic used on the arithmetic functions, for instance:

@include_builtin_fn(
fn_entry=BaseFnKey(
fn_name=Symbol("add"),
fn_type=Symbol("int"),
args_names=(Symbol("a"), Symbol("b")),
args_types=(Symbol("int"), Symbol("int")),
),
fn_path=ARITHMETIC_MODULE_PATH,
)
def builtin_fn_int_add(*args: CoreLiteral, mem: MemoryManager) -> CoreLiteral:
"""Add two integer numbers `a+b` and return an integer `c`."""
return CoreLiteral(
str(reduce(lambda x, y: x + int(y.value), args[1:], int(args[0].value))),
lit_type="int",
)

Whether the argument type should be float or its own (e.g. radian), it's up to the implementer to decide. Of course, pinging relevant people and doing further discussions to help designing a more appropriate solution is welcome.

Expected behavior

The behavior should follow the same as in the arithmetic code. For now, relying on Python's libraries and/or more established and reliable ones, such as numpy, scipy, etc. when needed should suffice for this development stage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    deprecatedpythonPull requests that update Python code

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions