Skip to content

Instantly share code, notes, and snippets.

@juan-reynoso
Created July 28, 2017 16:54
Show Gist options
  • Save juan-reynoso/4b5fdac8aceff049e55c0f7b6bcc3af3 to your computer and use it in GitHub Desktop.
Save juan-reynoso/4b5fdac8aceff049e55c0f7b6bcc3af3 to your computer and use it in GitHub Desktop.
(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