TL;DR: I want to know best practices for designing functions with multiple
optional arguments.
Okay, so I'm working to build machine learning algorithms in Clojure, and
they tend to need many arguments. Being a long-time Ruby dev, I like to
provide sensible defaults for almost all potential
TL;DR: I want to know best practices for designing functions with multiple
optional arguments.
Use destructing:
(defn f [required {:keys [foo bar] :or {foo :default}}]
[required foo bar])
(f 3 :bar 1 :foo 2) ;= [3 2 1]
(f 3 :bar 1) ;= [3 :default 1]
--
You received this
Hi,
you can use destructuring to provide defaults. And you can easily curry in
options when passing things through.
(defn general-descend
[xy ys
{:keys [gradient-fn cost-fn yield-fn alpha iterations thetas]
:or {cost-fncost
yield-fn println
alpha
I'm not sure you read the whole question. I want to know how to delegate
optional arguments to other functions with the same method signatures.
On Friday, June 15, 2012 12:04:00 AM UTC-7, Vinzent wrote:
TL;DR: I want to know best practices for designing functions with multiple
optional
Ah I see, I didn't realize I could apply the general-descend algorithm to
both atoms and arrays to get a flattened list. Thanks!
On Friday, June 15, 2012 12:05:36 AM UTC-7, Meikel Brandmeyer (kotarak)
wrote:
Hi,
you can use destructuring to provide defaults. And you can easily curry in
I think the best is to use maps. It is rarly a good idea to have too many
arguments.
Am 15.06.2012 08:51 schrieb David Jacobs da...@wit.io:
TL;DR: I want to know best practices for designing functions with multiple
optional arguments.
Okay, so I'm working to build machine learning algorithms
Hello David.
I have a very similar scenario according to named parameters liker you.
Therefore I have written the library clojure.options which can be found
here:
https://github.com/guv/clojure.options
The latest version is also on clojars.
Greetings,
Gunnar
--
You received this message
Very cool, this is exactly what I wanted. Thanks.
On Friday, June 15, 2012 7:27:05 AM UTC-7, Gunnar Völkel wrote:
Hello David.
I have a very similar scenario according to named parameters liker you.
Therefore I have written the library clojure.options which can be found
here: