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: Marco Antoniotti
Subject: Re: Help needed to simplify code for customisation
Date: Tue, 10 Mar 2009 09:53:39 -0700 (PDT)
User-agent: G2/1.0

On Mar 10, 12:42 pm, "William James" <address@hidden> 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.

Cheers
--
Marco





reply via email to

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