diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-04-25 08:54:51 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-04-25 08:54:51 -0400 |
commit | 9958edd9d61f13b181a9f44ec12f713d5819451a (patch) | |
tree | 75a795be994e6bbac7ac1e92b39370733030912a | |
parent | 1a83132fec473c4a5c590acd8b50cf88e4d2965e (diff) |
actor: Add apply-effects procedure.
* sly/actor.scm (apply-effects): New procedure.
* doc/api/scripting.texi (Actors): Document it.
-rw-r--r-- | doc/api/scripting.texi | 6 | ||||
-rw-r--r-- | sly/actor.scm | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/doc/api/scripting.texi b/doc/api/scripting.texi index 299cf0f..77ef734 100644 --- a/doc/api/scripting.texi +++ b/doc/api/scripting.texi @@ -157,6 +157,12 @@ new actor containing the value returned from @var{proc}. The actor's action remains unchanged. @end deffn +@deffn {Scheme Procedure} apply-effects @var{effects} @var{world} +Apply each effect procedure in @var{effects} using @var{world} as an +initial value. Each successive effect is applied with the world +returned by the previous effect. +@end deffn + @node Actions @subsection Actions diff --git a/sly/actor.scm b/sly/actor.scm index 90803e7..b63a66d 100644 --- a/sly/actor.scm +++ b/sly/actor.scm @@ -35,6 +35,7 @@ update-actor actor-filter-update call-with-actor + apply-effects action-lift action-effect-lift @@ -92,6 +93,14 @@ containing the value returned from PROC." (let ((new (proc (actor-ref actor)))) (make-actor new (actor-action actor)))) +(define (apply-effects effects world) + "Apply each effect procedure in EFFECTS using WORLD as an initial +value. Each successive effect is applied with the world returned by +the previous effect." + (fold (lambda (effect world) (effect world)) + world + effects)) + ;;; ;;; Actions |