考虑以下具有相应综合属性的语法:
(node:1691) UnhandledPromiseRejectionWarning: FetchError: request to http://localhost:3000/all/search_tracks failed, reason: socket hang up
at ClientRequest.<anonymous> (/Users/logileap/Desktop/musiczen/node_modules/node-fetch/lib/index.js:1455:11)
at ClientRequest.emit (events.js:198:13)
at Socket.socketOnEnd (_http_client.js:426:9)
at Socket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:1691) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1691) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
如果“ F.val”给出了上述语法中F生成的二进制分数的值,则输入中F.val的值 {0.110}是____________。(小数点后3位)
解决方案Solution的答案是0.875。我想知道他们如何计算L.value 我们可以看到 L.val = 0.75,实际上应该为1,因为:
F -> .L { F.val = L.val }
L -> LB { L.length = L.length`+ 1}{L.val = L.val + 2^ (-L.length) * B.val}
L -> B { L.length = 1, L.val = B.val/2}
B -> 0 { B.val = 0}
B -> 1 { B.val = 1}
答案 0 :(得分:0)
L.length = L.length + 1
像这样写下规则有点模棱两可,因为L
用于引用父节点和子节点。在这种情况下,很明显第一个L引用了父节点,第二个L引用了子节点(否则L.length = L.length ...
将是无限递归的),但这在符号中并未明确。为了解决这种歧义,我们通常向子节点添加索引,如下所示:
L -> L1 B { L.length = L1.length + 1}
现在明确指出L
指向父节点,L1
指向子节点。
牢记这种记号,让我们看一下与计算有关的规则:
L.val = L.val + 2 ^ (-L.length) * B.val
很明显,等号后的L.val
必须引用L1.val
,因为否则它将再次无限递归。但是L.length
实际上可以引用任何一个。也就是说,以上内容可以解释为:
L -> L1 B { L.length = L1.length + 1} { L.val = L1.val + 2 ^ (-L1.length) * B.val }
或作为:
L -> L1 B { L.length = L1.length + 1} { L.val = L1.val + 2 ^ (-L.length) * B.val }
使用前面的解释,L1.length
为1,并且计算结果的确为0.5 + 0.5 = 1
。但是,使用后一种解释,我们得到:
L.val = L1.val + 2 ^ (-L.length) * B.val
= 0.5 + 2^-2 * 1
= 0.5 + 0.25
= 0.75
因此后者必须是预期的解释。