Hacker News new | past | comments | ask | show | jobs | submit login

That is distressingly clever, and quite beautiful. It's one of those solutions that makes me wonder whether I could ever have come up with it.



It is almost like a magic trick.

You probably know some of them along the lines of : think of a number, then do a series of operations, and then I can guess the result. It can be done with cards too. In reality no matter what your initial choice is, the end result is always the same. The trick is to combine relatively complex functions (ex: "take the sum all digits of the number", "add 1 if odd") in a way that produce something simple (ex: "the result is 5").

Here the trick is to express the function "pos(x,y)=(0, y+1)" in term of the functions "pos(x,y)=(0,y)" and "pos(x,y)=if x<$column then (x+1,y) else (0,y+1).

It is also the basis of the "abstraction inversion" anti-pattern.


This is almost certainly going to be somebody's horrific programming interview question at some point in the next six months.


It's the kind of solution that were I to have come up with it, I would be both disgusted and impressed with myself.


You probably would feel the same if you would implement your own pty including re-implementing entire terminal emulation. That is until someone would show this solution.


Can't disagree with that, as that may be my hobby project in the next few weeks. I'm currently evaluating options for implementing a decent terminal emulator for jailbroken iPadOS. 95% chance I'm just gonna go with a webview and hterm just for simplicity on the development end, but there's a sick and twisted masochistic part of me that wants to write a full terminal emulator myself.

You'd think working tech support would've beaten the masochism out of me.


And also one of those things you stumble upon rather than think of on your own, I guess.


Necessity is the mother of invention.


Well, sure, but it doesn't necessarily incite to the most elegant solution. I mean, the article gives a sample of other possible approaches that one might fall into which are all far most eager it seems.

Even taking into account ComputerGuru insights on all the bumps of the actual implementation, it's still seem far more cleaver and elegant, at least to my mind.




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

Search: