Created
July 28, 2017 16:54
-
-
Save juan-reynoso/4b5fdac8aceff049e55c0f7b6bcc3af3 to your computer and use it in GitHub Desktop.
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
(defparameter *spam* "million") | |
(defparameter *emails* '("Reset your password" | |
"Happy birthday" | |
"Collect your million dollars now!")) | |
(defun spam-filter (emails spam) | |
"Filter emails and returns a list with good-emails and spam-emails" | |
(let ((spam-emails nil) | |
(good-emails nil)) | |
(dolist (email emails) | |
(if(search spam email) | |
;;spam email | |
(push email spam-emails) | |
;; good email | |
(push email good-emails))) | |
;; finally returns the emails filtered | |
(list good-emails spam-emails))) | |
CL-USER> (spam-filter *emails* *spam*) | |
(("Happy birthday" "Reset your password") ("Collect your million dollars now!")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment