differensort.scm
来自「A method to Sort a list of numbers in Sc」· SCM 代码 · 共 49 行
SCM
49 行
(define ls (list 3 1 2 4 5))
(define (sort lis)
(let ((i 0) (newls (list)) (j 1) (maxv 0) (templist (list)) (templ ls))
(let loop ((templ ls))
(let ((len (- (length templ) 1)))
(if (= (length templ) 1) (begin
(set! newls (append newls (list (list-ref templ 0))))
(display newls)
)
(begin
(if (> j len) (begin
(set! newls (append newls (list (list-ref templ maxv))))`
(set! maxv 0)
(set! j 1)
(set! i 0)
(set! templ templist)
(set! templist (list))
(loop templ)
)
(begin
(if (> (list-ref templ i) (list-ref templ j))
(begin
(set! templist (append templist (list (list-ref templ j))))
(set! maxv i)
(set! j (+ j 1))
(loop templ)
)
(begin
(set! templist (append templist (list (list-ref templ i))))
(set! maxv j)
(set! i j)
(set! j (+ j 1))
(loop templ))
)
)
)
)
)
)
)) )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?