shikanoko nokonoko 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
Published at
2024-08-11 08:37:04Event JSON
{
"id": "b01e2ffc6c9608ccac264b2227548a5e3cc8fc290f4f384dde7b7106bb1efb31",
"pubkey": "8e6ccedaf1b1240157c350716b2269af4f72a37bd961b77297ef92010dba371c",
"created_at": 1723365424,
"kind": 1,
"tags": [
[
"proxy",
"https://emacs.ch/@olav/112942476463936262",
"web"
],
[
"t",
"vim"
],
[
"t",
"lisp"
],
[
"t",
"c"
],
[
"t",
"emacs"
],
[
"proxy",
"https://emacs.ch/users/olav/statuses/112942476463936262",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://emacs.ch/users/olav/statuses/112942476463936262",
"pink.momostr"
],
[
"-"
]
],
"content": "I doubt anyone but me will try this, but here we go.\n\n Sunday programming challenge!\n\nImplement:\n\n$ grep -B n regex\n\n$ grep -A n regex\n\n$ grep -C n regex\n\nPlus points if it:\u003cli\u003eworks on line sequences (e.g split file contents on \\n)\u003c/li\u003e\u003cli\u003eworks on your platform's native reader type of your language (e.g java.lang.Reader or io.Reader)\u003c/li\u003e\u003cli\u003ehandles all edge cases\u003c/li\u003e\u003cli\u003e's realtime (e.g $ grep -A 1 foo will forward \"foo\" immediately, not wait until the next line is read)\u003c/li\u003e\u003cli\u003eimplements the command line interface\u003c/li\u003e\u003cli\u003eimplements the context span separators \"--\" (bsd grep doesn't implement this)\u003c/li\u003e\u003cli\u003euses your own bespoke regular expression engine\u003c/li\u003e\n\nand a star in my book if you find an appropriate generic abstraction capturing the essence of the problem! *couch*\u003cli\u003ePosting unfinished solutions is encouraged!\u003c/li\u003e\u003cli\u003ePosting revamps is encouraged!\u003c/li\u003e\u003cli\u003eTaking inspiration from other solutions is encouraged!\u003c/li\u003e\n\n(parenthesis! (of (pair (free (a (gets (Winner)))))))\n\nBe warned, this is very edgy so don't cut yourself!\n\nGood luck!\n\n#emacs #lisp #vim #c",
"sig": "5e44777e1f1843bc8096c8fcd4769c0934dda8493a6bf2aa96372df5b797aa205935279190e83e51d5d3b8744dffb4c4dd242fc82283a5e1ed46ca60a3b56a4b"
}