3 ms·
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
by MPSimmons 2y ago
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
- gshulegaard 2y agoI just briefly reviewed the README docs, I believe the KlongPy is a custom language which transpiles to Python. The REPL block you are trying to interpret is the KlongPy REPL not a Python one. 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')".
- itishappy 2y agoI'm new too, so take my opinion with a grain of salt, but I think you're right with one minor correction: name::{body} :" function declaration This isn't necessarily niladic or monadic or dyadic on it's own, it depends on the body. The bodies from the example all just happened to be monadic. +/x :" monadic : sum over argument x #x :" monadic : count of the argument x + :" dyadic : sum !10 :" niladic : an array from 0 to 9 I had to look up how calling a dyadic function looks in Klong: add::{+} add(2;3)
- MPSimmons 2y agoMan, that's so weird. Thanks for the clarification.