(import actors
        matchable)

(enable-trace)

(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)