aksharvarma, to programming
@aksharvarma@mathstodon.xyz avatar

Evolution of how I think of while :

  1. When I first learned "loops":

while (condition is true) {do these things, adjust things so a slightly new condition is checked}

// That's where I first saw infinite loop and how there are intentional infinite loops.

  1. A small step to move condition update out of the loop body:

for (i=0; i< N; i++) {do these things}

// After the couple of days it took to get used to them, I found them neater and closer to how I think of things.

  1. Most of the time, the i from before is indexing into something, so let's directly deal with the item being indexed:

for item in collection:
do stuff

After the few days to rewire syntax muscle memory, going back would decidedly feel like a step back.

I don't want to give up automatic (and transparent) out-of-bound checks.

  1. There are actually only about 3/4 things one does inside a loop:

map/fold/scan/filter function-to-call collection-to-traverse-through

;; Getting rid of explicit indexing was just step one.
-- After a few days/months/years, I now realize that it is more important and less buggy if I think only of the function to call (and whether I want to end up with a new (maybe pruned) collection, a single thing, or "both" (that's how I think of scans))


Alternatively, my evolution as I learned new languages idioms:
-->
or -->
-->
or --> ???

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • rosin
  • thenastyranch
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • InstantRegret
  • Youngstown
  • vwfavf
  • slotface
  • everett
  • osvaldo12
  • kavyap
  • anitta
  • khanakhh
  • tester
  • Durango
  • tacticalgear
  • GTA5RPClips
  • cisconetworking
  • ethstaker
  • cubers
  • normalnudes
  • modclub
  • provamag3
  • Leos
  • JUstTest
  • All magazines