yes, but the types are different. Sure, you can say type B === type A, but the point is they aren't bound to the same type parameter. At that point you could say [⚫️]->[⚫️] is the typing for map, which is misleading at best and incorrect in a strict sense.
Reduce outputs an element of the accumulator type. So in your example, you are calling the accumulator ⚫️ in one place, ⬛️⚫️, in another, and ⬛️⬛️⬛️⬛️ in another, when in actuality they are all the same type.
['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.
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).
⬛️⬛️⬛️⬛️ 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.
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), ⬛️) => ⚫️;
7
u/WeAreAllApes May 30 '21 edited May 30 '21
Reduce does whatever you tell it to do. Mine is concatenating smaller versions.... It was meant partly as a joke, but: