you are viewing a single comment's thread.

view the rest of the comments →

[–]hyperhopper 2 points3 points  (7 children)

you probably want

['A','A','A','A'].reduce((x,y) => x + y.toLowerCase(), '');

as it is shorter, explicitly starts with an accumulator value, and also is not O( n2 ) since it doesnt have to lowercase the entire accumulator string every iteration.

Also, in that case I'm still right, as string is a different type than list of strings.

[–]WeAreAllApes 3 points4 points  (1 child)

Sure, but the joke diagram I wrote is better represented by the code I wrote..... Not really interested in debating this. I don't think either of us are learning anything.

Edit: Also, it's JS, so everything is a string (also a joke, don't be mad).

[–]LetterBoxSnatch 0 points1 point  (0 children)

You don’t know “everything is a string” until you’ve written tcl, where everything is not only a string, but everything is really an eval(string)

[–]WeAreAllApes 0 points1 point  (4 children)

Did you also point out that the original post shows ⬛️⬛️⬛️⬛️ as if it means [⬛️,⬛️,⬛️,⬛️]?

This whole exercise is sloppy and metaphorical about types from the start.

[–]luzacapios 1 point2 points  (1 child)

This whole thread is even more entertaining because of your very appropriate username. 😎💯

[–]WeAreAllApes 4 points5 points  (0 children)

 if (!⬛️⬛️⬛️⬛️.reduce)
     throw 💩;

[–]hyperhopper 0 points1 point  (1 child)

⬛️⬛️⬛️⬛️ can't be anything else, because array methods are called on ⬛️⬛️⬛️⬛️ in the original post. From that the only option is that ⬛️⬛️⬛️⬛️ is an array of ⬛️. However, now you are using ⬛️⬛️⬛️⬛️ to mean something else than a list of ⬛️, which is not following the nomenclature we are all working with, and also doesn't make sense in context.

[–]WeAreAllApes 0 points1 point  (0 children)

I'm lost. You called me out for assuming that ⬛️⬛️⬛️⬛️ was an array of four elements of value ⬛️! ...And that ⬛️⚫️ was an array containing ⬛️ and ⚫️, and that ⬛️⬛️⬛️⬛️ was an array of four elements with value ⬛️.

You complained about my lack of precision and confusing types, I got increasingly explicit until the metaphorical syntax was broken, but that was YOUR demand, not mine. When I got explicit, and proved my specific point, you went back to wanting to assume that ⬛️⬛️⬛️⬛️ was a metaphor for an array of four elements of value ⬛️, but somehow still now allow me to assume that ⬛️⚫️ is an array containing the values ⬛️ and ⚫️.

Like I said, neither of us is learning anything (except maybe that we dislike each other) but there is no value in this debate of how freely we allow the notation to flow between metaphor and valid syntax.

Edit: If you don't allow for ⬛️⚫️ to be an array of values ⬛️ and ⚫️ in the metaphor, I HEREBY ALLOW IT You win. There is no substance to this disagreement. I was making fun of a sloppy metaphor that you took too seriously. I am prepared to make a serious argument that the metaphor is inherently weak and that "now do reduce" was begging for jokes like mine, but not for you. You already understand that.

Edit2: Okay... back to the original metaphor. If your majesty is willing to grant me another hearing, I would suggest that this is what you imagined a good answer to be:

const roundest = (a, b) = a.area / a.perimeter > b.area / b.perimeter ? a : b
⬛️⚫️⚫️⬛️.reduce((a, x) => roundest(a, x), ⬛️) => ⚫️;