I have a (hopefully small) problem with some numerical integration algorithm, more specifically I want to integrate the imaginary part of a complex valued function, e.g. f[u_]:=Exp[-iuK] with $K\in\mathbb{R}$. As mentioned I am only interested in Im[f], in the example -Sin[u K].

NIntegrate will return a list when its argument is a list. Therefore I suggest you investigate under what circumstances your f is a list. With your example code, one way this could happen is if K is sometimes a list.
–
Andrew MoylanMar 2 '12 at 6:34

The simple example I gave doesn't reproduce the error, that's true. Probably some input arguments of NIntegrate cause the behavior, however, I'll use one of the answers below. Thank you all!
–
user13655Mar 2 '12 at 8:48

Generally speaking, you can recognize a list because it'll have List as its Head. For example:

Head[{1,2,3}]

will return List.

For your example conditional where you want to change what you do based on the Head of the resulting expression, you can use Switch, such as in:

Switch[result,
_List, what you want to do with a list,
_, what you want to do otherwise]

A pattern of the form _List means "only match expressions with the head List. The next pattern, _, means "match an expression with any head". Mathematica stops in a Switch at the first match, so List will be preferred over "anything else".

Some functions are intermittent about whether they wrap their results in a list. I'm not sure about NIntegrate, but Reap (for example) certainly does. For purposes of discussion, let's define such a function:

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.