Created
November 1, 2012 02:06
-
-
Save mattmoss/3991188 to your computer and use it in GitHub Desktop.
Given two sequences of equal length and corresponding items, can one sequence be filtered based on (a predicate fn applied to) the second?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Given two sequences (seq-a and seq-b) of equal length and corresponding | |
;; items, can one sequence be filtered according to a predicate function (pred?) | |
;; applied to the second? | |
(map second | |
(filter #(pred? (first %)) | |
(map list seq-a seq-b) |
Author
mattmoss
commented
Nov 1, 2012
(keep (fn [[a b]] (if (pred? b) a)) (map vector a-seq b-seq))
But this is a problem if b-seq can contain nil as a legitimate value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment