2

DrRacket使用技巧总结

 2 years ago
source link: https://pingao777.github.io/2018/12/03/DrRacket%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7%E6%80%BB%E7%BB%93/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

引用其他文件的函数

假设test.scm想引用max-two.scm中的一个函数max-two,可以这样,

test.scm

#lang sicp

(#%require rackunit)
(#%require "max-two.scm")

(max-two 2 3 4)

max-two.scm

#lang sicp

;; 千万别忘了这一句
(#%provide (all-defined))

(define (max-two x y z)
  (define (min-three x y z)
    (cond ((>= x y) (if (>= y z) z y))
          (else (if (>= x z) z x))))
  (- (+ x y z) (min-three x y z)))

Window10安装sicp包

7.1版本ui界面安装pkg报错cadr: contract violation,可以使用命令行安装,命令如下:

raco pkg install --auto sicp

从Vim中运行scheme程序

可以做如下配置:

augroup scheme
    autocmd!
    " 加上<esc>可以避免弹出命令行必须按两次enter才能回到代码
    autocmd filetype scheme nnoremap <F9> :w<cr>:! racket %<cr><esc>
augroup end

这样直接按下F9就能运行了


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK