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

From the README: <quote>We're going to declaratively define a parser for the tar format, and once we're done, our code will not only extract .tar files, but create them as well.</quote>

I recall reading about this somewhere, but haven't seen such nice real world example before. Well done.



I think if done right, this falls out of Prolog automatically, as you program in relations, rather than functions. Depending on which places you leave empty in a query, Prolog will work to fill in the empty places. One is probably the tar file and one is the folder being added to a tar archive, but none of the 2 is any more important than the other.


There's a cool little bencode library that also works like that, all of 30 short lines too.

https://github.com/mndrix/bencode/blob/master/prolog/bencode...

https://en.wikipedia.org/wiki/Bencode


Check out "Production Prolog" by Michael Hendricks on YouTube, which demonstrates the same thing, at a talk at StrangeLoop:

https://youtu.be/G_eYTctGZw8




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

Search: