diff options
author | Nic Ferrier <nferrier@ferrier.me.uk> | 2014-11-02 14:54:17 +0000 |
---|---|---|
committer | Nic Ferrier <nferrier@ferrier.me.uk> | 2014-11-02 14:54:17 +0000 |
commit | 693e3bc8b5ac4b500e92ab5de85006646b1cbbb9 (patch) | |
tree | c9843bd7e10820267387b85778e14901ac33ce6a | |
parent | f53fb2ef876b23ff43a2ce4d5adbe317a1062c4f (diff) |
add a named let macro
-rw-r--r-- | noflet.el | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -155,6 +155,21 @@ maintainers refuse to add the correct indentation spec to (indent noflet-indent-func)) `(cl-flet ,bindings ,@body)) +(defmacro* letn (tag bindings &rest body) + (declare (debug (sexp sexp &rest form)) + (indent 2)) + `(cl-labels ((,tag ,(-map 'car bindings) ,@body)) + (,tag ,@(-map 'cadr bindings)))) + +(defun ntake-all (f source) + (letn take-all ((result nil) + (src source)) + (if src + (let ((l (-take-while f src))) + (take-all (cons l result) + (nthcdr (+ 1 (length l)) src))) + result))) + (provide 'noflet) |