For example, consider the list defined below.
samplelist = {{{1,2,3,4}}, {{5,6,7,8}}};
How would I apply the Times
operator to the subsets {1,2,3,4}
and {5,6,7,8}
?
Neither Map
nor Apply
work (or at least not in the ways I've tried).
If somebody could please help me out, I'd greatly appreciate it. I seem to run into this problem of trying to circumvent extra curly brackets quite often.
Edit: Sorry for not clarifying. The desired output is {24,1680}
. Extra brackets are fine for something like {{24},{1680}}
since at this point, Flatten
can be used.
Apply[Times, Flatten[samplelist, 1]]
$\endgroup$Apply[Times, samplelist, {2}]
... andApply[Times, samplelist, -2]
will do it for a list of lists with differing depths... $\endgroup$