diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-07-08 20:42:34 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-07-08 20:42:34 -0500 |
commit | 2aeb1d46e8bfa2c976c9db54033ab6995ad6c5b4 (patch) | |
tree | 419ae2aad31ed71b0724d56417e02f121588c680 /README.md | |
parent | 49b1053086af11a3fe8a143dfb981dd5bd11c748 (diff) |
another example
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -64,7 +64,30 @@ apears at the end of the document, following the tutorial. > (car (pick-out '(40) (fibs))) ;; 267914296 ``` - + +### A Kind Of Grep + +``` lisp + + +> (defmacro a-kind-of-grep (match-var key file &rest body) + `(for ,match-var (filter! (lambda (line) (search ,key line)) + (file-lines ,file)) + ,@body)) + +;; look for export lines in my .bashrc + +> (let ((count 0)) + (a-kind-of-grep line "export" "~/.bashrc" + (incf count) + (print line))) + +"export PATH=$HOME/.roswell/bin:$PATH" +"export PATH=$HOME/.local/bin:$PATH" +2 + +``` + ## Tutorial GTWIWTG is a tiny library for creating and using generators. |