From: Tim Vaughan Date: Sun, 7 Jul 2019 21:06:27 +0000 (+0200) Subject: Added third factorial example. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=fbacbb91961bea3410f457012075aabd91c168c1;p=actors.git Added third factorial example. --- diff --git a/actors.scm b/actors.scm index 4ae01ed..fa6f1bb 100644 --- a/actors.scm +++ b/actors.scm @@ -1,6 +1,6 @@ (import srfi-69 matchable) -(define trace-enabled #t) +(define trace-enabled #f) ;;; ;;; Actor creation diff --git a/testing_factorial3.scm b/testing_factorial3.scm new file mode 100644 index 0000000..b3450aa --- /dev/null +++ b/testing_factorial3.scm @@ -0,0 +1,25 @@ +(load "actors.scm") + +(define trace-enabled #t) + +(define factorial + (make-actor-with-address + 'factorial + (lambda (self customer n) + (if (= n 0) + (send-message customer 1) + (let ((fact-acc (make-actor + (lambda (self m) + (send-message customer (* n m)) + 'done)))) + (send-message self fact-acc (- n 1)) + 'sleep))))) + +(define println + (make-actor-with-address 'println + (lambda (self . message) + (apply print message) + 'sleep))) + +(send-message factorial println 5) +(run)