I thought I knew python, but then I saw this: ?> sum::{+/x} :" sum + over / the array x :monad ?> sum([1 2 3]) 6 ?> count::{#x} :monad ?> count([1 2 3]) 3 What?
oooooooh I think I'm starting to see... sum::{} is the creation of a monadic function (which I just learned about because I don't have a CS background) :" is a comment sum([...]) is calling the function with a list, and the function will iterate over the list adding each of the elements count::{#x} is another monadic function that returns the number of elements, which then gets called
Embedding KlongPy in a Python block would look more like this (also from the docs):
from klongpy import KlongInterpreter
import numpy as np
data = np.array([1, 2, 3, 4, 5])
klong = KlongInterpreter()
# make the data NumPy array available to KlongPy code by passing it into the interpreter
# we are creating a symbol in KlongPy called 'data' and assigning the external NumPy array value
klong['data'] = data
# define the average function in KlongPY
klong('avg::{(+/x)%#x}')
# call the average function with the external data and return the result.
r = klong('avg(data)')
print(r) # expected value: 3
Note the calls to "klong('<some-str-of-klong-syntax')".