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

I read through the Julia documentation and a couple tutorials last weekend, and I'm looking forward to building some things with it.

one note - this code could be better optimized by the compiler if you broke everything down into functions, especially the nested for loops (according to the optimization section of the docs).



It is a lot of fun, quite addictive! Let us know what you cook up at the julia-users google group. Re: optimization, that is indeed usually true, although I imagine the actual sudoku solve time dominates the request time. From a code design perspective I'd probably pull the validation/change-to-matrix stuff entirely and stick it in a module which would achieve the same thing. The way I build the "pretty" table is also pretty inefficient, using an IOBuffer is probably the right way to go. Tried to go for clarity for new-comers to the language.


That's a good tip in general, but it's mostly aimed at addressing type instability. For example, if you have

   x = 1
   f(x)
   x = "foobar"
   f(x)
then each call to f will be optimized for the current type of x. On the other hand, if your code is type stable, as it appears to be here, it will be properly optimized in place by the Julia JIT compiler and there's no need split it into separate functions.




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

Search: