ycitm
Joined 13 years ago
Joined 13 years ago
https://www.richard-towers.com/2023/03/11/typescripting-the-...
https://www.typescriptlang.org/play?#code/PTAEEkDsAsEMBsCmAa...
I've corrected this, and credited you in the errata - https://www.richard-towers.com/2023/03/11/typescripting-the-...
I considered forking the compiler to set a deeper limit, but at some point Typescript itself is going to stack overflow. Also that probably goes a bit beyond what Criss is expecting in an interview...
There's a recursion depth limit of 500 on the TypeScript compiler, which prevents this solution working for N > 7
Even Aphyr's original Haskell solution only demonstrates N = 6, so in some sense this is an improvement on the state of the art for type-level N Queens solutions /s
This post is a pastiche of https://aphyr.com/posts/342-typing-the-technical-interview
Ideally, I would have written:
type Nil = unique symbol
Which would ensure the Nil type wouldn't match with anything but itself. Unfortunately, the compiler doesn't allow unique symbol other than on const variables initialised with Symbol(). So I needed some meaningless symbols.I could also have done
type Nil = "nil"
But then it would have looked like the string meant something.I've found a really simple way of authoring and sharing notes is to write them in Org mode and then push them to a wiki on github. Github understands how to render Org markup nicely, so you get a nicely formatted wiki pretty much for free.
As an added benefit I can now touch type :)