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.
Implementation description
Implement basic trigonometric functions following the same logic used on the arithmetic functions, for instance:
hhat_lang/python/src/hhat_lang/dialects/heather/code/builtins/fns/math/arithmetic/fn_def.py
Lines 39 to 54 in f6ddaf2
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.