beuleal Posted April 5, 2012 Report Share Posted April 5, 2012 Olá amigos, estu estudando Xlisp, porem estou com dificuldades em realizar uma funcao de divisao, por enquanto somente com positivos.Segue meu cod:(defun div(x y) (cond ((equal x 0) (equal y 0) 0) ((equal x y) 1) ((equal y 1) x) ((equal x 0) 0) ((equal y 0) 0) ('t (soma(div (subt (x y)) y) +1)))) (defun negativo (x) (cond ((equal x 0) 'nil) ('t (neg x x)))) (defun neg (a d) (cond ((equal a 0) 't) ((equal d 0) 'nil) ('t (neg (1+ a) (1- d))))) (defun soma (x y) (cond ((equal y 0) x) ((negativo y) (soma (1- x) (1+ y))) ('t (soma (1+ x) (1- y))))) (defun subt (x y) (cond ((equal y 0) x) ((negativo y) (subt (1+ x) (1+ y))) ('t (subt (1- x) (1- y))))) Quote Link to comment Share on other sites More sharing options...
0 Jhonas Posted April 6, 2012 Report Share Posted April 6, 2012 vejahttp://fit.faccat.br/~everton/lp/lisp.dochttp://www.pcmasmas.com/viewtopic.php?t=31189http://www.estig.ipbeja.pt/~jasnau/Intelig...icial/guias.pdfabraço Quote Link to comment Share on other sites More sharing options...
0 beuleal Posted April 6, 2012 Author Report Share Posted April 6, 2012 eu noa posso usar funcoes predefinidas como / e *... Isso esta me enchendo o saco. Quote Link to comment Share on other sites More sharing options...
0 Jhonas Posted April 6, 2012 Report Share Posted April 6, 2012 em um dos links vai achar a respostaabraço Quote Link to comment Share on other sites More sharing options...
Question
beuleal
Olá amigos, estu estudando Xlisp, porem estou com dificuldades em realizar uma funcao de divisao, por enquanto somente com positivos.
Segue meu cod:
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.