in_range = int(input("range: "))
fibo_list = []
a = 0
b = 1
count = 0
if in_range < 0:
print("faulty")
elif in_range == 0:
print("faulty")
else:
while count < in_range:
c = a + b
a = b
b = c
count += 1
fibo_list.append(a)
print(fibo_list)
Run Code Online (Sandbox Code Playgroud)
这段代码的范围输入1000时,会产生很多椭圆形状,有些是很难看出来的。这似乎只发生在斐波那契数列中,而没有其他长数链。为什么是这样?
我正在尝试制作一个宏来实现在 Common Lisp 中的部分应用。这是我如何在伪代码中实现它的想法:
If my argument list is null, return the function body
Otherwise, cons together "lambda" with the first argument with a recursive call to "partial-lambda" again
(lambda (x y z) (+ x y z) => (lambda (x) (lambda (y) (lambda (z) (+ x y z))))
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
If my argument list is null, return the function body
Otherwise, cons together "lambda" with the first argument with a recursive call to "partial-lambda" again
(lambda (x y z) (+ x …Run Code Online (Sandbox Code Playgroud)