Curly brackets7/29/2023 ![]() Using curly brackets speeds the program up by about 6%! So I did a little test, as follows: > a f g system.time(f(1000000)) It occurred to me that before rushing out and using this feature, I should check that it doesn’t introduce some horrible inefficiency, as might be the case if curly brackets were optimized for their more common use in grouping statements. I’m not sure that this was always the case - I vaguely recall otherwise with some earlier version (perhaps an early version of S). But it turns out that in R you can use both parentheses and curly brackets! The curly brackets are normally used to group statements, but an expression is one type of statement, and the last (or only) in the group provides the value. Typical programming languages use only parentheses, other brackets having been appropriated for other uses. ![]() In complex mathematical expressions, it’s common to use more than one type of bracket, so that it’s easier to pair them up visually. Second, something surprisingly slow about R’s implementation of a very common operation.įirst, the good thing I discovered about R. Or maybe not…įirst up, a useful feature of R that I hadn’t realized existed, which comes with a surprising gain in efficiency. Of course, some other people may already be quite familiar with these things. Today, though, I have some interesting (and useful) things to say about R, which I discovered in the last few days, and which shouldn’t take long to blog about. I see that it’s been over a year since my last post! I have a backlog of blog post ideas, but something else always seems to have higher priority.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |