Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you don't know any array languages, it might explode your brain. Use at your own risk!

I've been around the block, don't think it'll be a problem picking up something new

> Here is a program that checks whether a number x is prime (for x>2): {&/x!:\2+!_x^1%2}

(closes laptop and goes outside)



I mean its not that bad.

You just go right to left. 1/2 applied to x^ so x^(0.5), _ is floor so floor of x^0.5. ! creates an array of numbers up until floor of x^0.5. 2+ just adds 2 to every number, and then I lost interest in learning the rest lol.

Yeah I like the python equivalent def is_prime(x): return x > 1 and all(x % i != 0 for i in range(2, x))


I wonder what the relative performance of the two snippets (Klong and Python) is.

Not at a computer now, can't check.


im not sure about about klong as it is a hobby project but official veriants of k and q(the wordified k that is somewhat popular in finance) are supposedly quite fast. In the world of industry that is actually these languages main claim to the niche fame they do have.


thanks. i had tried out q for a few days, some years ago. yes, I had read that they are supposed to be fast.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: