JohnEarnest/ok

oK node.js REPL crashes/hangs

jordancurve opened this issue · 4 comments

Any of these expressions will crash/hang the oK 0.1 node.js REPL:

&~(2!|2!)/!4
~:/2
~:/+3 5!'/:!16
5!!10|3!!10

BTW this might be working as intended -- maybe those expressions are infinite loops or something. My K isn't that great.

I believe all of these are working as intended.

  • ~:/2 will repeatedly logically negate a value starting with 2. The fixed point operation halts if you revisit the initial term of the sequence (we won't, since ~: produces a 1 or 0 result) or the result doesn't change (this won't happen either, since the negation of a valid number is always different from the original). Same basic idea for ~:/+3 5!'/:!16 and (2!|2!)/!4.
  • 10|3!!10 is equivalent to 10#10. Taking "odometer" of this expression would generate an enormous result vector (10^10 elements) which is likely to exhaust available memory.

Purely out of curiosity, was there any process that lead you to trying those particular expressions?

I was just playing around with the interpreter to try to understand the language better.