Advertisement
jacknpoe

Illegal function call in (jurosParaAcrescimo 3.0)

Apr 27th, 2024 (edited)
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.19 KB | None | 0 0
  1. ;; FOO
  2.  
  3. ;; globals
  4. (defvar Quantidade 3)
  5. (defvar Composto 1)
  6. (defvar Periodo 30.0)
  7. (defvar Pagamentos '(30.0 60.0 90.0))
  8. (defvar Pesos '(1.0 1.0 1.0))
  9.  
  10. ;; function to sums Pesos()
  11. (defun getPesoTotal()
  12.   (_getPesoTotal(- Quantidade 1))
  13. )
  14.  
  15. ;; recursive function who REALLY sum Pesos()
  16. (defun _getPesoTotal(valor)
  17.   (if (= valor 0)
  18.     (nth 0 Pesos)
  19.     (+ (nth valor Pesos) (_getPesoTotal(- valor 1)))
  20.   )
  21. )
  22.  
  23. ;; this function doesn't works (it's incomplete either)
  24. (defun jurosParaAcrescimo(juros)
  25.   (if (or (or (<= juros 0.0) (<= Quantidade 0)) (<= Periodo 0.0))
  26.     0.0
  27.     (
  28.       (let pesoTotal (getPesoTotal))
  29.       (if (<= pesoTotal 0)
  30.         0.0
  31.         6.0  ;; FAKE, while I don't write the real calculation
  32.       )
  33.     )
  34.   )
  35. )
  36.  
  37. ;; tests
  38. (princ "Peso total = ")
  39. (write (getPesoTotal)) ;; this works
  40. (terpri)
  41. (princ "Acrescimo = ")
  42. (write (jurosParaAcrescimo 3.0)) ;; this doesn't works
  43.  
  44. ; ERROR:
  45. ; file: D:/Lisp/juros.lisp
  46. ; in: DEFUN JUROSPARAACRESCIMO
  47. ;     ((SETQ PESOTOTAL (GETPESOTOTAL))
  48. ;      (IF (<= PESOTOTAL 0)
  49. ;          0.0
  50. ;          6.0))
  51. ;
  52. ; caught ERROR:
  53. ;   illegal function call
  54. ;
  55. ; compilation unit finished
  56. ;   caught 1 ERROR condition
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement