2017-09-06 12:44 GMT+02:00 Ray Miller <r...@1729.org.uk>:

> By the way does has clojure something like super? Using:
>
>> (defn create-pin-hex
>>   ([] (create-pin-hex 8))
>>
>> is asking for trouble. After copy/pasting from create-pin I almost forgot
>> to change it.
>>
>>
> If your base function takes chars as its first argument, you can use
> partial:
>
>  (defn create-pin-base
>   ([chars]
>
> ​​
> (create-pin chars 8))
>   ([chars n]
>    {:pre [(<= 4 n 16)]}
>    (apply str (repeatedly n #(rand-nth chars)))))
>
> (def create-pin (partial create-pin-base digits))
> (def create-pin-hex (partial create-pin-base hex-digits))
>

​Works great, thanks.
​

​By the way it shows why it is important. You had:​
​    ​(create-pin chars 8))
inste​ad of:
    ​(create-pin-base chars 8))

-- 
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