You may want to look at
https://clojuredocs.org/clojure.core/case
https://clojuredocs.org/clojure.core/cond

On Friday, February 20, 2015 at 11:01:43 AM UTC+1, Cecil Westerhof wrote:
>
> I have a function to check the parameters of another function:
>     (defn params-correct-lucky-numbers
>       [upto]
>       (let [max (* 10 1000 1000)]
>         (if (< upto 1)
>             (do
>                 (println "The parameter upto should at least be 1")
>                 false)
>           (if (> upto max)
>               (do
>                   (printf "The parameter upto should be below %d\n" (inc 
> max))
>                   false)
>             true))))
>
> I am used to something like:
> ​    Boolean params-correct-lucky-numbers(int upto) {
>         final int MAX = 10_000_000;
>
>         if (upto < 1) {
>                System.out.println("The parameter upto should at least be 
> 1");
>             return false;
>         }
>         if (upto > MAX) {
>                System.out.printf("The parameter upto should be below 
> %d\n", MAX + 1);
>             return false;
>         }
>         return true;
>     }
>
> Personally I find this clearer. In this case it is not a big deal, but 
> when you have to check 20 parameters …
>
> Could the Clojure function be rewritten into something resembling the Java 
> function? (In a functional way of-course.)​
>
> -- 
> Cecil Westerhof
>  

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to