lists, vecotrs, and hashes all have an empty() method, so
(defn clone-coll
([coll clone-item] (clone-item (seq coll) coll clone-item))
([seq coll clone-item]
(if (not seq)
(.empty coll)
(cons (clone-item (first seq)) (clone-coll (rest seq) coll clone-
item))
)
)
)
will
On 15.11.2008, at 23:29, Stephen C. Gilardi wrote:
>> But there is no islist?, nor anything that looks equivalent. So how
>> do I test if form is a list? Or a vector? Or a map? For processing
>> general forms, I'd need to handle all of these, right? Or is there a
>> simpler way to do it?
>
> You
On Nov 15, 2008, at 5:15 PM, Konrad Hinsen wrote:
>
> I am trying to write a function (for use in a macro) that replaces a
> given keyword in a form by a given symbol, i.e.
>
> (replace-symbol :foo :bar form)
>
> should return the form with all occurences of :foo replaced by :bar.
> This turned o
I am trying to write a function (for use in a macro) that replaces a
given keyword in a form by a given symbol, i.e.
(replace-symbol :foo :bar form)
should return the form with all occurences of :foo replaced by :bar.
This turned out to be surprisingly difficult. I started out like this:
(d