Reputation: 11
I am starting elisp, I want to write a function to divide 2 numbers without using the divison sign. I get the error 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)))
The same function I have written in 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.
Upvotes: 1
Views: 224
Reputation: 223133
You can't use flet
for recursive functions, you have to use labels
instead.
Upvotes: 3