seq.reduce(_:_:)
Last updated
Last updated
ๅช่ฆ่จญๅฎไธๅๅๅงๅผ (initialResult)๏ผๆญคๆนๆณๅฐฑๆไฝฟ็จ nextPartialResult ้ๅ closure ไพ้ฒ่ก็ดฏ็ฎ๏ผไธฆๅฐๆๅพ็็ดฏ็ฎ็ตๆๅๅณใ๐ ๆฏ่ผ๏ผseq.reduce(into:_:)
on every execution of the combine function, a brand-new array is being created by appending the transformed or included element to the previous one. This means that both these implementations are O(nยฒ), not O(n) ...
๐ Advanced Swift, p.37
.reduce(into:_:) is preferred over reduce(_:_:)
for efficiency when the result is a copy-on-write type, for example an Array or a Dictionary.
๐ .reduce(into:_:)