From 2fdee568e3a9bf352092e94a8d5dcc50b7bd0c71 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 29 Dec 2013 07:55:05 +0100 Subject: [PATCH] Repairing composing systems example * src/examples/composing-systems.scm: used the old way of making systems with a lambda; current way is similar to let syntax --- src/examples/composing-systems.scm | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/examples/composing-systems.scm b/src/examples/composing-systems.scm index 5af39c0..7742b81 100644 --- a/src/examples/composing-systems.scm +++ b/src/examples/composing-systems.scm @@ -20,27 +20,25 @@ #:use-module (ice-9 receive)) -(define-system (s1 l) - (lambda (e) - (sleep 3) - (map - (lambda (e1) - (set-entity-components (car e1) `(l . ,(cons 1 (cdadr e1))))) - e))) +(define-system s1 ((with-l (l))) + (sleep 3) + (map + (lambda (e) + (set-entity-components (get-key e) `(l . ,(cons 1 (get-component 'l e))))) + with-l)) -(define-system (s2 l) - (lambda (e) - (sleep 4) - (map - (lambda (e1) - (set-entity-components (car e1) `(l . ,(cons 2 (cdadr e1))))) - e))) +(define-system s2 ((with-l (l))) + (sleep 4) + (map + (lambda (e) + (set-entity-components (get-key e) `(l . ,(cons 2 (get-component 'l e))))) + with-l)) (define (composing-with-join) (let ((entities '()) (components '())) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - ((join-systems s1 s2) e c)))) + (((join-systems s1 s2) e c))))) (export composing-with-join) @@ -49,7 +47,7 @@ (let ((entities '()) (components '())) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - ((threaded-systems s1 s2) e c)))) + (((threaded-systems s1 s2) e c))))) (export composing-with-threaded) @@ -59,14 +57,14 @@ (components '()) (t (current-time))) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - (receive (e c) ((join-systems s1 s2) e c) + (receive (e c) (((join-systems s1 s2) e c)) (format #t "~a~%~a~%Time: ~a~%~%" e c (- (current-time) t))))) (let ((entities '()) (components '()) (t (current-time))) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - (receive (e c) ((threaded-systems s1 s2) e c) + (receive (e c) (((threaded-systems s1 s2) e c)) (format #t "~a~%~a~%Time: ~a~%~%" e c (- (current-time) t)))))) (export join-vs-threaded) -- 2.39.2