PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/guile/simple/example.scm

#
Lisp | 28 lines | 18 code | 8 blank | 2 comment | 0 complexity | feb01d50957f360a484a1d98d3388a44 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. ;;; example.scm
  2. (define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'?
  3. (for-each display args)
  4. (newline))
  5. (mdisplay-newline (get-time) "My variable = " (My-variable))
  6. (do ((i 0 (1+ i)))
  7. ((= 14 i))
  8. (mdisplay-newline i " factorial is " (fact i)))
  9. (define (mods i imax j jmax)
  10. (if (< i imax)
  11. (if (< j jmax)
  12. (begin
  13. (My-variable (+ (My-variable) (mod i j)))
  14. (mods i imax (+ j 1) jmax))
  15. (mods (+ i 1) imax 1 jmax))))
  16. (mods 1 150 1 150)
  17. (mdisplay-newline "My-variable = " (My-variable))
  18. (exit (and (= 1932053504 (fact 13))
  19. (= 745470.0 (My-variable))))
  20. ;;; example.scm ends here