We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Analysis Summary
Worth Noting
Positive elements
- This video provides a practical look at the mathematical logic (deltas) required to automate code generation for simple arithmetic progressions.
Influence Dimensions
How are these scored?About this analysis
Knowing about these techniques makes them visible, not powerless. The ones that work best on you are the ones that match beliefs you already hold.
This analysis is a tool for your own thinking — what you do with it is up to you.
Related content covering similar topics.
Transcript
when teaching or learning for Loops you usually start with a couple of concrete examples here's a concrete example of a for Loop how can we possibly know which values I will take well we can simply log I to the terminal and observe the output right so that's simple from code to the values but we can flip that around and start with the desired values and then generate the for loop from that that's the latest tool that I wrote so you can see this is the first uh variant that was demonstrated at the start of the video where we say we start at one up to and including 9 a closed range or we could also say we start at one up to end not including 11 and in both cases of course we want to increment by two and this would be a half open range because the 11 is not included in the desired values okay and sometimes C++ programmers prefer to write not equals instead of less than because some types um offer equality comparisons but not less than comparisons for example forward iterators okay and then uh we can play around with it for example if we remove the last value notice that only the condition changes to a smaller value and if we remove the first value we can see that only the initial value changes right I think that's quite valuable or if we remove the five then of course the Delta will change okay um what happens if we only provide a single value then we get an error message because you don't really need a loop if you only have a single value and if um the values are always the same then we also get an error message because it would be quite hard to know when to stop right you can't use the loop counter itself to decide when to stop when sometimes you want to keep going and sometimes you want to stop okay and um what happens if we for example observe the uh prime numbers this also doesn't work with the simple F Lo because here we have a difference of one whereas for the other numbers we have a difference of two so so that's how the tool works it computes the differences the Deltas between the numbers and if they are all the same for example in the uh example like this they would all be two and then of course uh trivially the two can be generated here right the initial value is of course the initial value and the last value is here and if you add the last value and the Delta then you get this limit here okay does it also work for descending sequences let's say this example for example notice how the operator will change yeah instead of plus equals we get minus equals and that also works and note that of course here this operator also changes because now we approach from the um from the top down instead of the other way around but notice that this operator does not change though that's maybe the biggest appeal of this Terminator variant okay um something that doesn't work is if you want to for example generate the square numbers let's say maybe up to and including here um that doesn't work because the datas are different but you can see that the if you compute the Deltas again then you have a meta Delta of two two two two and two so in theory we could do this with a for loop with two Loop counters and I Loop counter and a Delta Loop counter that you increment by two every time but I think it's not really worth worth it making the for Loop generator more complicated for rare cases such as this but feel free to Fork the rapo it's linked in the description and add your own features to your own Fork
Video description
https://frectures.github.io/for-gen