Trigonometry with BPL Python
Yesterday
As part of my work for AnswerAI I've been exploring the Python API of [BasedPL](https://answerdotai.github.io/basedpl), which is a new programming language developed by Jeremy Howard based on APL, J and BQN. Its notation uses symbols called 'glyphs'. Below I show how to use [circle (`○`) glyph](https://answerdotai.github.io/basedpl/glyphs/circle.html) to get trigonometric functions.
from basedpl import circle
sin, cos, tan, sqrt_1py2, sinh, cosh, tanh, sqrt_m1my2 = map(
lambda k: k|circle, range(1, 9)
)
sin(3) # Array(0.14)
cos(3) # Array(-0.99)
tan(3) # Array(-0.14) `.undo` gives you the inverse:
asin, acos, atan, sqrt_y2m1, asinh, acosh, atanh, neg_sqrt_m1my2 = map(
lambda k: k|circle.undo, range(1, 9)
)
asin(1) # Array(1.57)
acos(0) # Array(1.57)
atan(1) # Array(0.79) With one argument `circle(x)` gives you the angle in radians:
circle(2) # Array((-0.42+0.91j)) `k|circle` adds `k` to the `circle` function, like `functools.partial` in Python.
