help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help needed to simplify code for customisation


From: Kenneth Tilton
Subject: Re: Help needed to simplify code for customisation
Date: Wed, 11 Mar 2009 02:37:42 -0400
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Marco Antoniotti wrote:
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.


<sigh> What are we going to do with our boy Willy? He never does his Ruby assignmens any more and just plays with a Lisp all day. I say no television until we seem some work.

kt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]