source codes:
./main.ss
./lib/fibonacci.ss
./lib/fibonacciex.ss
main.ss
(import (chezscheme)
(lib fibonacci)
(lib fibonacciex))
(display "What's up?\n")
(printf "~a~%" (fib 5))
(define main
(lambda ()
(printf "This is the main procedure~%")
(printf "First, print fib(10) = ~a~%" (fib 10))
(printf "First 11 Fibonacci numbers: ~a~%" (fib-list 11))))
;;; Initialize the program
(define initialize
(lambda fns
(printf "This procedures initializes the program.~%")))
;;; This will be called by the boot-file
(scheme-start
(lambda fns
(initialize fns)
(main)))
(main)
fibonacci.ss
;;; fibonacci.ss
(library (lib fibonacci)
(export fib)
(import (rnrs))
(define fib
(lambda (n)
(if (<= n 2)
1
(+ (fib (- n 2)) (fib (- n 1))))))
)
fibonacciex.ss
(library (lib fibonacciex)
(export fib-list)
(import (rnrs)
(lib fibonacci))
(define fib-list
(lambda (n)
(if (zero? n)
'()
(cons (fib n)
(fib-list (- n 1))))))
)
Compile
(compile-imported-libraries #t)
(generate-wpo-files #t)
(compile-program "./main.ss")
(compile-whole-program "./main.wpo" "./main")
Run
chez --program main