我目前正在尝试翻译这个 python 2 代码:
import math
def worstCaseArrayOfSize(n):
if n == 1:
return [1]
else:
top = worstCaseArrayOfSize(int(math.floor(float(n) / 2)))
bottom = worstCaseArrayOfSize(int(math.ceil(float(n) / 2)))
return map(lambda x: x * 2, top) + map(lambda x: x * 2 - 1, bottom)
Run Code Online (Sandbox Code Playgroud)
进入球拍/方案代码,并且遇到困难。
这是我到目前为止:
(define (msortWorstCase n)
(cond
[(equal? 1 n) 1]
[else (let* ([top (msortWorstCase(floor (/ n 2)))] [bottom (msortWorstCase (ceiling (/ n 2)))])
(append (map (lambda (x) (* x 2)) (list top)) (map (lambda (x) (- (* x 2) …Run Code Online (Sandbox Code Playgroud)