From: Tim Vaughan Date: Sun, 7 Jul 2019 20:00:19 +0000 (+0200) Subject: Broke out example into separate file. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=758646ce472f2610b3100779fcf2b8ad15481a4e;p=actors.git Broke out example into separate file. --- diff --git a/actors.scm b/actors.scm index 8a581b9..4ae01ed 100644 --- a/actors.scm +++ b/actors.scm @@ -120,24 +120,3 @@ (apply send-message (cons actor message)) (run)) -;;; -;;; Testing -;;; - -(define factorial - (make-actor-with-address 'factorial - (lambda (self customer . message) - (match message - ((n) (send-message self customer n 1) 'sleep) - ((0 acc) (send-message customer acc) 'done) - ((n acc) (send-message self customer (- n 1) (* acc n)) 'sleep))))) - -(define println - (make-actor-with-address 'println - (lambda (self . message) - (apply print message) - 'sleep))) - -(send-message factorial println 5) -(send-message factorial println 7) -(run) diff --git a/testing_factorial1.scm b/testing_factorial1.scm new file mode 100644 index 0000000..09aafda --- /dev/null +++ b/testing_factorial1.scm @@ -0,0 +1,19 @@ +(load "actors.scm") + +(define factorial + (make-actor-with-address 'factorial + (lambda (self customer . message) + (match message + ((n) (send-message self customer n 1) 'sleep) + ((0 acc) (send-message customer acc) 'sleep) + ((n acc) (send-message self customer (- n 1) (* acc n)) 'sleep))))) + +(define println + (make-actor-with-address 'println + (lambda (self . message) + (apply print message) + 'sleep))) + +(send-message factorial println 5) +(send-message factorial println 7) +(run)