Re: a better way to write this
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
Re: a better way to write this
This is slightly shorter: full-test (fn [element] (every? #(% element) [type-pred bounds-check contact])) On Friday, November 4, 2011 10:51:43 AM UTC-6, HamsterofDeath 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
Re: a better way to write this
You could try using every-pred to combine your predicates, which I think would be equivalent: (let [full-test (every-pred type-pred bounds-check contact)] ... On Nov 4, 9:51 am, Dennis Haupt d.haup...@googlemail.com wrote: (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? -- 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
Re: a better way to write this
Oh that is cool! On Friday, November 4, 2011 12:11:43 PM UTC-6, Paul Mooser wrote: You could try using every-pred to combine your predicates, which I think would be equivalent: (let [full-test (every-pred type-pred bounds-check contact)] ... On Nov 4, 9:51 am, Dennis Haupt d.ha...@googlemail.com wrote: (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? -- 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
Re: a better way to write this
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 my favorite :) thx Am 04.11.2011 20:32, schrieb Benny Tsai: Oh that is cool! On Friday, November 4, 2011 12:11:43 PM UTC-6, Paul Mooser wrote: You could try using every-pred to combine your predicates, which I think would be equivalent: (let [full-test (every-pred type-pred bounds-check contact)] ... On Nov 4, 9:51 am, Dennis Haupt d.ha...@googlemail.com wrote: (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? -- 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 - -- -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.14 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJOtE78AAoJENRtux+h35aGS7EP/ihZ8EgpG4q6WTNuzeBLsBg8 sv+etYJByD+EWg03cIWM5mop1i7YfqslOcg3nZCj7DrFYud9kCxDlxa2fTc6wxHu +gq6VLzIi4ddcH5skfpKhqHd9ahXiWQDOXalRtKol7eL7Py208ij7NNfGjNEDbNV OzodeDGtbywqRdgMLe4xtS3OGaQBAw8dVclcgg97h2eVkjjb61YoKex1fdCkPTsv aSS+K4BSvfzueG+KG95Zac3az4dFtiloqMocCKN5D9FKeopDBp7JhZVwGr/BBoTx xmU4wjI1lyxIgwPI2AcMxzawzauzGXivaavCopJ2O4NGFBfyMqHlNujRvYz1zbLh faFePfWgOjAk8M9+ZZUpGiDHV1p9RWleAH7dmJV/qkQWBARA6WN9aM6N+wVdpVRb aqnQVhYSAMfYNzLQw68/hJLWnnuqpli9ZHB0fCx4bdLxnsrAOP+IhLIHtq6lsO5Q 5ortpvL1334DAw24JXjGZQJoy0hNU+7VifLxMiNrwNbfTYU7tXPfUlJC1GYn2uNz oTKXlSES1kJy4CxI1f3yCqq5UU+cW3H2Nz7VPfp/qa0tPCesArZYoe0e0FhZdypL J9BPnne4nBX1aeB/oSC1r3x+SaVek556+qhbuFP4L0utD6PIY9PB00Ex2M0nqnco YON/jqusioTsqOuYNOC+ =1xzD -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