On Mar 10, 12:42 pm, "William James" <w_a_x_...@yahoo.com> wrote:
TomSW wrote:
(require 'cl)
(defvar my-accounts-alist
'(("richardriley" "root" "richardriley")
("rileyrgdev" "rileyrgdev"))
"Associate email accounts with sender addresses: an alist each item
of
which is a list whose first member is the account name and any
following
members are regular expressions to match against a sender address.")
(defun my-get-account (from)
(car (find-if (lambda (regexps)
(some (lambda (regexp)
(string-match regexp from))
regexps))
from my-accounts-alist
:key 'cdr)))
Clojure:
(def my-accounts-map
{ "richardriley" [#"root" #"richardriley"],
"rileyrgdev" [#"rileyrgdev"] } )
(defn my-get-account [from]
(ffirst
(filter
(fn [[acct re-list]] (some #(re-find % from) re-list))
my-accounts-map)))
Hey. That is not the homework you are supposed to hand in.