I generally prefer to pass in a sequence rather than use a variable
number of arguments. The only time variable arguments are really useful
is in functions like map (or maybe +) in which you rarely use more than
one (or two) arguments and it would be a pain to wrap the last argument
in a list.
e.
I always write a function to take a single seq argument because it can
also take varargs if I wrap them in a seq.
(defn add [nums]
(reduce + nums))
(add some-seq)
(add [1 2 3 4 5])
On Nov 19, 4:19 pm, Jarl Haggerty wrote:
> I always write a function to take varargs because it can also take a
I always write a function to take varargs because it can also take a
list using apply.
(+ 1 2 3 4 5)
(apply + [1 2 3 4 5])
On Nov 15, 9:52 am, Chris wrote:
> If you have a function that needs to treat multiple arguments as a
> group, what forces drive you to represent this as a single sequence
>
On Nov 15, 8:52 am, Chris wrote:
> If you have a function that needs to treat multiple arguments as a
> group, what forces drive you to represent this as a single sequence
> argument vs. an "&" argument? To give a concrete example, why does
> "+" work like
>
> (+ 1 2 3 4)
>
> instead of
>
> (+ [1
Ah, laziness... thanks Christophe. For my particular application
laziness doesn't matter (so that hadn't occurred to me) but that's a
good general principle to keep in mind.
Thanks,
Chris
On Tue, Nov 16, 2010 at 11:31 AM, Christophe Grand
wrote:
> Hi,
>
> On Tue, Nov 16, 2010 at 5:21 PM, Chris
Hi,
On Tue, Nov 16, 2010 at 5:21 PM, Chris Maier wrote:
> That makes sense... thanks, Meikel.
>
> Maybe my example of + wasn't the best, given its mathematical nature.
>
> Here's my situation: I'm writing some software to analyze some protein
> datasets, part of which entails generating a Venn di
That makes sense... thanks, Meikel.
Maybe my example of + wasn't the best, given its mathematical nature.
Here's my situation: I'm writing some software to analyze some protein
datasets, part of which entails generating a Venn diagram of their
intersections. Each dataset has a unique name, and m
Performance is part of it too. Allowing dispatch on arity leads to
faster code.
Many of the functions that operate on sequences are lazy so dispatch
on arity doesn't apply.
On Nov 15, 11:52 am, Chris wrote:
> If you have a function that needs to treat multiple arguments as a
> group, what force
Hi,
Am 15.11.2010 um 17:52 schrieb Chris:
> If you have a function that needs to treat multiple arguments as a
> group, what forces drive you to represent this as a single sequence
> argument vs. an "&" argument? To give a concrete example, why does
> "+" work like
>
> (+ 1 2 3 4)
>
> instead
On Mon, Nov 15, 2010 at 11:52 AM, Chris wrote:
> If you have a function that needs to treat multiple arguments as a
> group, what forces drive you to represent this as a single sequence
> argument vs. an "&" argument? To give a concrete example, why does
> "+" work like
>
> (+ 1 2 3 4)
>
> instea
If you have a function that needs to treat multiple arguments as a
group, what forces drive you to represent this as a single sequence
argument vs. an "&" argument? To give a concrete example, why does
"+" work like
(+ 1 2 3 4)
instead of
(+ [1 2 3 4])
Is it performance? Aesthetics? Composab
11 matches
Mail list logo