PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

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