Oops. That is what I meant, but I don't know why I thought pre- and
post-conditions get stored in metadata. It would be handy for :pre. Thanks,
Ambrose.
To the OP, I would still recommend using metadata to store the
applicability test and also making it a precondition of the fn in a partial
functi
Hi John,
By :pre, do you mean function preconditions? eg. (fn [] {:pre [..]}) ?
How is :pre related to metadata and dispatch? AFAICT it's purely for
macroexpansion and
there is no metadata available on the precondition post-macroexpansion.
Thanks,
Ambrose
On Mon, May 27, 2013 at 9:00 PM, John D
On May 26, 2013 8:53 PM, "Mark Engelberg" wrote:
>
> Another possible design choice is to store a domain-testing predicate in
the function's metadata.
Using metadata would be a much more idiomatic choice than using arity.
Multiple arities are idiomatically used (like method overloading) to
defaul
Another possible design choice is to store a domain-testing predicate in
the function's metadata.
(with-meta (fn [x] ...) {:domain integer?})
(defn is-defined? [f x]
(-> f meta :domain x))
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To pos
Thanks!
On Sun, May 26, 2013 at 6:27 PM, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:
> Hi David,
>
> Clojure can generate auto-syms with a trailing #.
>
> user=> `(fn [x#] x#)
> (clojure.core/fn [x__349__auto__] x__349__auto__)
>
> Thanks,
> Ambrose
>
>
> On Mon, May 27, 2013
Hi David,
Clojure can generate auto-syms with a trailing #.
user=> `(fn [x#] x#)
(clojure.core/fn [x__349__auto__] x__349__auto__)
Thanks,
Ambrose
On Mon, May 27, 2013 at 9:08 AM, David Pollak wrote:
> Mark and James,
>
> Thank you for your input.
>
> There are two reasons why I don't want t
Mark and James,
Thank you for your input.
There are two reasons why I don't want to simply test for nil as the result
of running the pattern match:
- The right side of the pattern can be side-effecting. For example, if you
are servicing a web request, there may be database calls, etc. Therefore,
In Scala, PartialFunction is a trait, which in Clojure I'd represent using
a protocol:
(defprotocol Partial
(defined-at? [x]))
(defn partial-fn [guard f]
(reify
Partial
(defined-at? [x] (guard x))
clojure.lang.IFn
(invoke [f x]
{:pre [(guard x)]}
(f x
And then
The most common way to do this in Clojure is to define your function such
that if the input is not in the domain, the function returns nil.
Since nil and false are the only "falsey" values in Clojure, you can use
ordinary tests to determine if the function returned a result. The idiom
that lets y
Hello,
This is my first post to this group. If my post or the tone of my post is
not up to this communities standards, please give me feedback so that I can
integrate with the community.
I'm coming from Scala-land.
In Scala, there's a PartialFunction:
http://www.scala-lang.org/archives/downloads
10 matches
Mail list logo