What's happening is that you have multiple optional arguments chained
together. Optional arguments are passed as a list (or seq?) of arguments,
so if you pass them down to another function that also takes optional
arguments they get wrapped in yet another list. An option to stop this is
to use apply, e.g.:

user=> (defn foo [& stuff] stuff)
#'user/foo
user=> (defn bar [& things] (apply foo things))
#'user/bar
user=> (bar 1 2 3)
(1 2 3)


On Sat Feb 21 2015 at 9:58:00 AM Cecil Westerhof <cldwester...@gmail.com>
wrote:

> I want to work with default values. For this I use:
>     [& nr]
>
> This gives the value null to nr. So far so good.
>
> But I want to propagate the value, because I want to fill the default at a
> higher level.
>
> ​I have:
>     (defn test-lucky-numbers-all
>       "Test all lucky number performance"
>       [& nr]
>     (printf "all: %s\n\n" nr)
>       (time
>        (do (test-lucky-numbers-first   nr)
> and:
>     (defn test-lucky-numbers-first
>       "Performance test of lucky numbers (first)"
>       [& nr]
>     (printf "first: %s\n\n" nr)
>
> When I do:
>     (test-lucky-numbers-all)
> The first prints:
>     all: null
> but the second prints:
>     first: (nil)
>
> And when I do:
>     (test-lucky-numbers-all 1)​
> ​The first prints:
>     all: (1)
> and the second prints:
>     first: ((1))
>
> What is happening here and what can I do about it?
>
> I could write a general function to translate the nil, but I was wondering
> if there is a better option.​
>
> --
> 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.
>

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