I came across this version of the factorial exercise and am completely at sea:
(我遇到了这种形式的阶乘练习,并且完全在海上:)
fac = lambda n: n and n * fac(n-1) or 1
It's the and/or part that I can't get my head around -- particularly the n and ... part.
(这是和/或部分,我不能左右我的头-尤其是N和...的一部分。)
Last: when you run this without the n and ...
part, it returns a "maximum recursion depth exceeded" error.
(上一个:如果您在不使用n and ...
部分的情况下运行此命令,则会返回“超出最大递归深度”错误。)
ask by Pascal80 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…