JavaScript Developer’s Post

  • graphical user interface, application
Huda Mustakim

IoT Application Developer at CAD-IT Consultants (ASIA) Pte Ltd

4y

So true....for loops are much easier to understand

Like
Reply

Those scary symbols are not just for loops. Those are “just” sum and product. Number 1 is a perfect example where a bit of Math knowledge wouldn’t hurt. If one knew that that sum can be computed in a single operation: 3 * 4 * (4 + 1) / 2 which is of order O(1), instead of doing a for loop like a dumbass, costing you O(n) which is one order of magnitude higher : ) Math is your friend.

I feel like Carl Friedrich Gauss now

Like
Reply

but it's ugly! check if your language allows something like `stream{0 to 4}.map(x -> 3x).reduce(x, y -> x + y) I used pseudo-kinda-java, but there are others too; this way you express your intent better "this is a sum/product"

If I knew that some years ago my life at college would be easier lol

Like
Reply

On my PHD I was always amazed how those 30 page math papers on wavelets just boiled down to a 50 line algorithm. It is academic flexing for the most part.

See more comments

To view or add a comment, sign in

Explore content categories