<p>I find myself doing this sort of thing all the time.  I've been considering writing a macro/function to make this sort of thing easier, but it occurs to me that I'm probably reinventing the wheel.</p>

<p>Is there an existing function that will let me accomplish this same sort of thing more succinctly?</p>

<pre><code>(defun remove-low-words (word-list)   
  "Return a list with words of insufficient score removed."
  (let ((result nil))
    (dolist (word word-list)  
      (when (good-enough-score-p word) (push word result)))                                      
    result))  
</code></pre>

[{'answer_id': 38594, 'author': 'Chris Hanson', 'author_id': 714, 'author_profile': 'https://Stackoverflow.com/users/714', 'pm_score': -1, 'selected': False, 'text': '<p>There are a couple ways you can do this.  First, and probably most easily, you can do it recursively.</p>\n\n<pre><code>(defun remove-low-words (word-list)\n  (if (good-enough-score-p (car word-list))\n      (list word (remove-low-words (cdr word-list)))\n      (remove-low-words (cdr word-list))))\n</code></pre>\n\n<p>You could also do it with <code>mapcar</code> and <code>reduce</code>, where the former can construct you a list with failing elements replaced by <code>nil</code> and the latter can be used to filter out the <code>nil</code>.</p>\n\n<p>Either would be a good candidate for a "filter" macro or function that takes a list and returns the list filtered by some predicate.</p>\n'}, {'answer_id': 38823, 'author': 'Luís Oliveira', 'author_id': 2967, 'author_profile': 'https://Stackoverflow.com/users/2967', 'pm_score': 6, 'selected': True, 'text': '<p>There are several built-in ways of doing this. One way would be:</p>\n\n<pre><code>(remove-if-not \'good-enough-score-p word-list)\n</code></pre>\n\n<p>And another:</p>\n\n<pre><code>(loop for word in word-list  \n      when (good-enough-score-p word)\n      collect word)\n</code></pre>\n\n<p>And yet another:</p>\n\n<pre><code>(mapcan (lambda (word)\n          (when (good-enough-score-p word)\n            (list word)))\n        word-list)\n</code></pre>\n\n<p>Etc... There\'s also <a href="http://series.sourceforge.net/" rel="noreferrer">SERIES</a> and <a href="http://common-lisp.net/project/iterate/" rel="noreferrer">Iterate</a>. The Iterate version is identical to the LOOP version, but the SERIES version is interesting:</p>\n\n<pre><code>(collect (choose-if \'good-enough-score-p (scan word-list))))\n</code></pre>\n\n<p>So, yes, you\'re very likely to reinvent <em>some</em> wheel. :-)</p>\n'}, {'answer_id': 84036, 'author': 'Nathan Shively-Sanders', 'author_id': 7851, 'author_profile': 'https://Stackoverflow.com/users/7851', 'pm_score': 3, 'selected': False, 'text': '<p>The function you want is <code>remove-if-not</code>, which is built-in.</p>\n\n<pre><code>(defun remove-low-words (word-list)\n  (remove-if-not #\'good-enough-score-p word-list))\n</code></pre>\n\n<p>If you feel like you are re-inventing something to do with lists, you probably are. Check the Hyperspec to see.</p>\n\n<ul>\n<li><a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rm_rm.htm#remove-if-not" rel="nofollow noreferrer">The Hyperspec documentation on <code>remove-if-not</code></a></li>\n<li><a href="http://www.lispworks.com/documentation/HyperSpec/Body/c_sequen.htm" rel="nofollow noreferrer">All sequence functions</a></li>\n<li><a href="http://www.lispworks.com/documentation/HyperSpec/Body/c_conses.htm" rel="nofollow noreferrer">All list-specific functions</a></li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/38571', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/56456/']