jsource
jsource copied to clipboard
Convert isempty to C++
A branch I had around. It's pretty much a direct copy from the C function, with a few remarks:
- I'm not sure what the return type of the call for a sparse array is. It calls
jteps, which confuses me a lot. I'm not even sure why it does this. - I thought about rewriting
ANto something more descriptive, similar to theis_sparsefunction. However, this macro is used for assignment as well (seemake_array), so I just left the C macro here. I think the consistency here is more important.
About the first point: jteps(jt, needle, haystack) implements x e. y which is "member in".
So in english, for sparse array jtisempty checks if zero is in the shape of the array (as the comment also says in j).
Generally the functions often have commented the corresponding j phrase, if not t.c is good place to check for primitives. Here for example jtrazein is the monadic case, and jteps is dyadic case of e.. https://github.com/codereport/jsource/blob/de91efce021f9e184113527d01a1e3bb373b3079/jsrc/t.c#L816 (and j nuvoc to see what the primitive does)
That makes more sense than the epsilon how I read it