4 ms·
A different kind of "expressiveness." NB. naive k-nearest neighbors in J dist =: [:%:[:|[:+/(*:@:-) NB. dyad takes two vectors, returns euclidean d
by wyc 9y ago
A different kind of "expressiveness."
NB. naive k-nearest neighbors in J
dist =: [:%:[:|[:+/(*:@:-) NB. dyad takes two vectors, returns euclidean distance
data =: 1 2 3,2 2 3,2 3 3,1 2 3,:2 3 4
query =: 1 2 3
k =: 3
k {."1 /:"1 query&dist"1 data
- Dzugaru 9y agoMy eyes are bleeding already
- vidarh 9y agoWhenever I've seen K or J code and someone has actually explained how it works, it's turned out to be viable to implement the necessary primitives to get similar expressiveness without making it completely unreadable. I'd love to learn more about them, but I'm starting to feel that the terse syntax is mostly obscuring relatively simple/basic functionality that's easy to re-implement rather than any major language features.