I tried both of the approaches. The first one worked, the second one didn't. I checked the parameters I passed to the function after Uhrwerk's post.

Conclusion: I messed up big time. I mixed up the parameters, passing a number and a vector instead of a vector and a number like the function expects me to. It's obvious why that won't work, and of course I didn't think of checking that. Instead, I spent a while fiddling around with a function that works perfectly fine and then posted about an error that doesn't exist.
I switched the parameters around and it works now. I thank you both for your efforts to help me out, and I apologize for wasting your time. frown