第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

有人可以用外行的術(shù)語(yǔ)向我解釋這個(gè)折疊示例嗎?

有人可以用外行的術(shù)語(yǔ)向我解釋這個(gè)折疊示例嗎?

慕桂英3389331 2021-07-01 14:11:40
我試圖確切地了解這個(gè)功能是如何運(yùn)作的,但無(wú)法在我的大腦中弄清楚。請(qǐng)您能顯示代碼的分步過(guò)程嗎?我一直坐在這里,試圖在我的電腦上使用計(jì)算器在我的腦海中弄清楚這個(gè)例子,并在我的腦海中多次運(yùn)行代碼,但它只是沒(méi)有加起來(lái)。雙關(guān)語(yǔ)不是故意的。constructor(values) {  this.values = values || []}const list = new List([1,2,3,4])expect(list.foldl((acc, el) => el / acc, 24)).toEqual(64);foldl(fn, initialValue) {  let acc = initialValue;  for (let i in this.values) {    acc = fn(acc, this.values[i]);  }  return acc; // 64... HOW??!}好的,這就是我如何在腦海中運(yùn)行它。請(qǐng)你向我解釋為什么我錯(cuò)了,并告訴我偽代碼中什么是正確的,就像我在下面所做的那樣。```// accumulator is 24 and therefore we divide the first element of the array which is 1 by 24 which equals .041666667// the accumulator now ACCUMULATES which means 24 plus .041666667 is equal to 24.041666667// now the accumulator is 24.041666667 and we divide the second element of the array which is 2 by 24 which equals .083333333// the accumulator which is 24.041666667 now adds .083333333 which equals 24.874999997// now the accumulator is 24.874999997 and we divide the third element of the array which is 3 by 24.874999997 which equals .120603015 等等...我在這里缺少什么?
查看完整描述

1 回答

?
陪伴而非守候

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超8個(gè)贊

積累并不意味著增加。這意味著運(yùn)行您傳入的函數(shù)foldl。此外,24 的值僅在第一次使用;之后,累加意味著它使用上次的返回值。這是正確的值序列:


acc = 24

el = 1

acc = 1/24

el = 2

acc = 2/(1/24) = 48

el = 3

acc = 3/48 = 1/16

el = 4

acc = 4/(1/16) = 64


查看完整回答
反對(duì) 回復(fù) 2021-07-08
  • 1 回答
  • 0 關(guān)注
  • 197 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)