I've just been watching lecture 2, and when R example 2.1 comes up (35:00), you explain that
For those of you who don't use R, sapply is just a loop, it's just a function that loops over a list
Because R vectorises functions by default, you don't need to use sapply here. This might make the code flow clearer, since you wouldn't need to explain the purpose of sapply.
I've written a small counter-example that uses vectorisation rather than sapply:
I've just been watching lecture 2, and when R example 2.1 comes up (35:00), you explain that
Because R vectorises functions by default, you don't need to use sapply here. This might make the code flow clearer, since you wouldn't need to explain the purpose of sapply.
I've written a small counter-example that uses vectorisation rather than sapply:
Created on 2023-03-20 with reprex v2.0.2