select / filter from list reddit / emacs ---------------------------------------------------------------------- pedzsanReddit · 2022-12-20 15:57 I am looking for is a function that takes two arguments: a predicate (a function that takes one argument and returns nil/non-nil) and a list and finds the first element of the list where predicate returns non-nil. It seems really basic but I can't find such a function. ---------------------------------------------------------------------- yyoncho · 2022-12-20 16:15 `seq-find` ---------------------------------------------------------------------- pedzsanReddit · 2022-12-20 16:27 Thanks! I was just in the process of coming back and putting an update. I used elisp-index-search of "filter" and was going through all the hits and came across seq-filter. see-find is better. I also found seq-remove which is another function I've been searching for. ---------------------------------------------------------------------- 00-11 · 2022-12-20 18:00 `cl-find-if` or `seq-find` You're not *filtering* the list/sequence; you're looking for the first element that satisfies some condition. Filtering would return a subsequence, not an element. ---------------------------------------------------------------------- JDRiverRun · 2022-12-20 18:45 And if you need to know the first matching *position* instead of the value, `cl-position-if`. ---------------------------------------------------------------------- lastnamebird · 2022-12-20 20:59 I find it is useful to look at the source code for other functions defined in the same file when I find a useful/similar function. In this case, they should all be in seq.el. ---------------------------------------------------------------------- [deleted] · 2022-12-20 21:47 [deleted]