On 23/09/2018 3:31 PM, Jeff Newmiller wrote:

[lots of good stuff deleted]

Vectorize is
syntactic sugar with a performance penalty.

[More deletions.]

I would say Vectorize isn't just "syntactic sugar". When I use that term, I mean something that looks nice but is functionally equivalent.

However, Vectorize() really does something useful: some functions (e.g. outer()) take other functions as arguments, but they assume the argument is a vectorized function. If it is not, they fail, or generate garbage results. Vectorize() is designed to modify the interface to a function so it acts as if it is vectorized.

The "performance penalty" part of your statement is true. It will generally save some computing cycles to write a new function using a for loop instead of using Vectorize(). But that may waste some programmer time.

Duncan Murdoch
(writing as one of the authors of Vectorize())

P.S. I'd give an example of syntactic sugar, but I don't want to bruise some other author's feelings :-).

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to