What is Nostr?
Olav Fosse /
npub13ek…w73a
2024-08-11 08:37:04

Olav Fosse on Nostr: I doubt anyone but me will try this, but here we go. Sunday programming challenge! ...

I doubt anyone but me will try this, but here we go.

Sunday programming challenge!

Implement:

$ grep -B n regex

$ grep -A n regex

$ grep -C n regex

Plus points if it:<li>works on line sequences (e.g split file contents on \n)</li><li>works on your platform's native reader type of your language (e.g java.lang.Reader or io.Reader)</li><li>handles all edge cases</li><li>'s realtime (e.g $ grep -A 1 foo will forward "foo" immediately, not wait until the next line is read)</li><li>implements the command line interface</li><li>implements the context span separators "--" (bsd grep doesn't implement this)</li><li>uses your own bespoke regular expression engine</li>

and a star in my book if you find an appropriate generic abstraction capturing the essence of the problem! *couch*<li>Posting unfinished solutions is encouraged!</li><li>Posting revamps is encouraged!</li><li>Taking inspiration from other solutions is encouraged!</li>

(parenthesis! (of (pair (free (a (gets (Winner)))))))

Be warned, this is very edgy so don't cut yourself!

Good luck!

#emacs #lisp #vim #c
Author Public Key
npub13ekvakh3kyjqz47r2pckkgnf4a8h9gmmm9smwu5ha7fqzrd6xuwqhpw73a