jsource icon indicating copy to clipboard operation
jsource copied to clipboard

Convert isempty to C++

Open herwinw opened this issue 4 years ago • 2 comments

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 AN to something more descriptive, similar to the is_sparse function. However, this macro is used for assignment as well (see make_array), so I just left the C macro here. I think the consistency here is more important.

herwinw avatar Mar 10 '21 20:03 herwinw

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)

juntuu avatar Mar 11 '21 07:03 juntuu

That makes more sense than the epsilon how I read it

herwinw avatar Mar 16 '21 19:03 herwinw