小编Mar*_*erk的帖子

将 Python 翻译成 Scheme/Racket

我目前正在尝试翻译这个 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)

lisp scheme racket python-2.7

-2
推荐指数
1
解决办法
749
查看次数

标签 统计

lisp ×1

python-2.7 ×1

racket ×1

scheme ×1