Using collections:

(every? true? (map #(%1 %2) [func1 func2] (repeat common-argument)))

where func1 func2 are your functions. and common-argument is the
argument shared by them all.

Or something like this:

(every? true? (map #(%1 %2) [type-pred bounds-check contact] (repeat element)))

Granted this won't be the fastest method in the world (macros would
probably be better), as there's going to be a fair amount of object
creation going on, and now instead of invoking 3 functions, we're
invoking much more. But at least this code is readable, and fairly
easy to understand.

Timothy

On Fri, Nov 4, 2011 at 11:51 AM, Dennis Haupt <d.haup...@googlemail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> here's a part of my clojureoids-code:
>
>  (let [type-pred #()
>        bounds-check #()
>        contact #()
>        full-test (fn [element] (and (type-pred element) (bounds-check
> element) (contact element)))]
>  (filter full-test (:game-elements @world-atom))
>
> is there a way to write the full-test in a way that doesn't force me
> to repeat the "function <constant text>" pattern inside the and?
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJOtBgfAAoJENRtux+h35aGDTAP/RM2mXcu7+HlH0gVHPcZ2bH0
> 31MEGk5ysup06vgntmxOClaNV9PcxQ1g3bu44YTWDKy3S5RWiD+yB+LkAV0e8xvM
> p8A64giicfaxI2qncmEpgjodrUn8Yg4vde9X5pQRRaQaWTG56jlLUClorOy62W2q
> gsvNaehEZa6MZiG6yQOEQ1j0sS438bkmCsqxmHAs2ZmAkb9osTatKECK4sAZRx6l
> 31KHRFEWx8piiND5vxUGeqlf/CHC3r9VCgBc86q/nnH2CL4cofrkv6mXUYxHikPS
> AVbT8Qtuonh+twoGLH6t+TYCrVIgiAmnO9IOWFqpdkcX+us3V+ETvXSAVfuf6mCM
> +pS3Ps0+VndU31/ufZ0pdki/DxlMJiMVPSS1l/Z76671rCQe+dBjFDSU4e+4y9du
> sj0h1VNQ/tKzQ0jCGb9AF6MHoy51b4dpaqjwuJ4HQscH3L9ruG46dTZs5+IvWb5v
> 2htp5jQNY25e05qbT2tjPVTKT7C6kZ5S3dMlAfQnQxIaHrIm92IHzq3bhF3xMbgy
> Yh5sC66y/O4BPZnCvcKY6RF6wBlSZ/vLVOYAasvV89bWanUvv5vgFlNWysNoNF0o
> eCFhm1NQmvDoqTa0okx3kN5LeoVgGZdfmkEcVNIvVNUFYzht6ffGNaESb3YWFMlO
> buElt55CDSzWlvkBwqPU
> =A6jg
> -----END PGP SIGNATURE-----
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to