emacs - 开始 elisp 如何在不实际使用除号的情况下编写除号

标签 emacs lisp elisp

我正在开始使用 elisp,我想编写一个函数来除以 2 个数字而不使用除号。我收到错误 Symbol's value as variable is void: div

(cl-flet ((div (x y z)
            (cond ((< x y) (message "hello world"))
                  ((> x y) (div (- x y) y (+ 1 z))))))
  (let ((a 30) (b 10))
    (div a b 1)))

我用erlang写的同样的功能:

start(A, B)->
    ds(A, B, 0).

ds(A, B, C) when ( A -  ( B * (C + 1))) >=  0 ->
    ds(A, B, C+1);
ds(_A, _B, C) ->
 C.

最佳答案

递归函数不能使用flet,必须使用labels

关于emacs - 开始 elisp 如何在不实际使用除号的情况下编写除号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27139351/

相关文章:

scheme - 截断(受限) Racket 中的列表

emacs - 无法在 emacs 中设置变量值?

emacs - 列出某个 emacs 模式的所有键绑定(bind)

scheme - "How to Design Programs"(HTDP) 第一版和第二版的区别

vim - 您会为初学者程序员推荐 vim/emacs 吗?

lisp - 简单的 LISP 问题

emacs - 在 Emacs 中如何防止同一个缓冲区出现在​​同一帧的不同窗口中?

emacs - 在 Emacs 中如何仅在代码区域中操作(即搜索)?

emacs - 通过emacs加载绘图程序

emacs - 异步复制