# HG changeset patch # User Oleksandr Gavenko # Date 1358085428 -7200 # Node ID 7b1ae3e0c9e3c7f3e49c75eb83fc7f2d918cd8e2 # Parent 6c3765dd9ed2373819e7a9b04534fe9bf7431b34 Omit condition from loop. diff -r 6c3765dd9ed2 -r 7b1ae3e0c9e3 .emacs-my --- a/.emacs-my Sun Jan 13 15:01:14 2013 +0200 +++ b/.emacs-my Sun Jan 13 15:57:08 2013 +0200 @@ -77,16 +77,14 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "my defun, defmacro, defvar") -(defmacro my-filter (condfunc list) - "Construct list with elements from LIST which satisfy CONDFUNC." - `(let (r) +(defmacro my-filter (pred list) + "Construct list with elements from LIST which satisfy PRED." + `(let ( (r '(nil)) ) (mapc (lambda (item) - (when (,condfunc item) - (if r - (nconc r (cons item nil)) - (setq r (cons item nil))))) + (when (,pred item) + (nconc r (cons item nil)))) ,list) - r)) + (cdr r))) (defun my-fold (f x list) "Recursively applies (F i j) to LIST starting with X.