;; Load Terracotta module (load "jstc.scm") ;; Start nodes (define pid1 (start-node "test1")) (define pid2 (start-node "test2")) ;; Define helper function (define (range min max) (let loop ((x max) (l '())) (if (< x min) l (loop (- x 1) (cons x l))))) ;; Load Fibonacci function definition into nodes (tc-load (list "test1" "test2") "(define (fib n) (cond ((= n 0) 0) ((= n 1) 1) (else (+ (fib (- n 1)) (fib (- n 2))))))" ) ;; Compute a sequence of Fibonacci numbers (define res (tc-map (list "test1" "test2") "fib" (range 1 20))) ;; Display the results (display res) (newline) ;; Stop the nodes - commented out because killing a thread in JScheme often generates tons of messages ;(stop-node pid1) ;(stop-node pid2)