string.lower implementation

86 points · 15 comments · view on lemmy.world

15 Comments

earmuff@lemmy.dbzer0.com · 24 pts · 2y

Now please publish it as a Node.js module and in 3 weeks, it will be in Top 10 most used modules, being used in 90% of Fortune 500 corporations.

SzethFriendOfNimi@lemmy.world · 13 pts · 2y (5 replies)

But… does it pass all the tests?

_stranger_@lemmy.world · 15 pts · 2y (4 replies)

If it does, they don't have enough of the right tests.

madcaesar@lemmy.world · 3 pts · 2y (3 replies)

Elaborate

48954246@lemmy.world · 7 pts · 2y (2 replies)

What would the output be for the following:

99 Beers on the Wall!

AnUnusualRelic@lemmy.world · 4 pts · 2y

Or for "CAFÉ"?

HelloHotel@lemmy.world · 1 pts · 1y

I think it would be

11 beers on the wall.

jet@hackertalks.com · 7 pts · 2y (2 replies)

This will not work on Unicode

Greek and Arabic have cases as well

MoSal@lemm.ee · 5 pts · 2y (1 reply)

This will not work on Unicode

Correct.

Greek and Arabic have cases as well

Who told you that?

jet@hackertalks.com · 8 pts · 2y

Brain fart, I meant Cyrillic but I wrote the wrong word! Good catch thanks!

Binette@lemmy.ml · 5 pts · 2y (1 reply)

I hope this is O(n!)

cadekat@pawb.social · 8 pts · 2y

This looks like O(n), because you don't include constants when calculating Big-O. It's still ~26 times slower than the implementation without the inner loop.

This looks like O(n^2) because of the sub.

I was right the first time. sub is "substring" and not "substitute".

jh29a@lemmy.blahaj.zone · 2 pts · 2y (1 reply)

here's a more nuanced question: in school iirc my teacher was implementing terminal 2-human tic-tac-toe with us and used an only slightly less egregious 7-by-3 AND/OR gate to see whether any player had won. because I didn't like all the repetition, my version iterated through a 7-by-3 list of lists of indecies instead. every toy programming problem I've seen since was so general that it didn't go well with this kind of hardcoding either

jet@hackertalks.com · 1 pts · 2y

When creating an example for beginning programmers, sometimes using a very inefficient data structure is more illustrative and a helpful educational tool.

azi@mander.xyz · 1 pts · 1y

Honestly as long as literals are properly converted, I don't see any other way to do this in an entirely encoding agnostic way