Hi,

Am 08.02.2009 um 00:40 schrieb samppi:

(defn conc* [tokens & subrules]
 (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens),
products []]
   (if (nil? subrule-queue)
     [products remaining-tokens]
     (let [[subrule-products subrule-remainder :as subrule-result]
           ((first subrule-queue) remaining-tokens)]
       (when-not (nil? subrule-result)
         (recur (rest subrule-queue) subrule-remainder
                (conj products subrule-products)))))))
(defmacro conc [& subrules]
 `(fn [tokens#]
    (conc* tokens# ~...@subrules)))

I had another function called factor=:
(defn factor= [factor subrule]
 (apply conc (replicate factor arg)))

When I changed conc to a macro, factor= didn't work anymore. Is there
no way of fixing factor=?

Why don't you call conc* directly?

(defn factor= [factor subrule]
  (fn [tokens]
    (apply conc* tokens (replicate factor subrule))))

That's another nice example why to pack as much as possible
into a function, which is then called by the expanded macro
code.

Sincerely
Meikel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to