Quote:
Originally Posted by kerowo
R solves the for loop problem by working on sets of things all at once! It’s impossible to debug and doesn’t believe in telling where errors occurred, only that they did, but that’s a small price to pay for removing syntactical sugar...
I don't do much R but I used to teach a Matlab course. Matlab allows for loops but using them is usually a huge mistake. That was always lesson one in my class.
Like consider you have 2 arrays of the same length, a and b and you want to calculate sum(a[i]*b[i] for all i). Doing this using array math in matlab would be literally like 1000x faster than using a loop.
The EE department taught a class on numerical methods in EE and people would make these awful 2 and 3 dimensional loops to do numerical integration and wonder why their programs never finished.