On 3/30/20, Aron Zvi <[email protected]> wrote: > Hey guys > > In 22.3 Domain-Specific Languages: Configurations, the book introduces the > following data example and data definitions for FSM configurations > > > (define > <http://docs.racket-lang.org/htdp-langs/intermediate-lam.html#%28form._%28%28lib._lang%2Fhtdp-intermediate-lambda..rkt%29._define%29%29> > xm0 > '(machine ((initial "red")) > (action ((state "red") (next "green"))) > (action ((state "green") (next "yellow"))) > (action ((state "yellow") (next "red"))))) > > ; An XMachine is a nested list of this shape: > ; `(machine ((initial ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>)) [ > List-of > <https://www.htdp.org/2019-02-24/part_three.html#%28tech._sim-dd._list._of%29> > > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>]) > ; An X1T is a nested list of this shape: > ; `(action ((state ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>) ( > next ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>))) > I do no understand the XMachine data definition properly. In the definition > > it appears that it would be a list with 3 elements: > > 1*. *'machine > 2. `((initial ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>)) > 3. [List-of > <https://www.htdp.org/2019-02-24/part_three.html#%28tech._sim-dd._list._of%29> > > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>] > > However, from the data example (and the fact that it is an Xexpr > <https://www.htdp.org/2019-02-24/part_four.html#%28tech._xexpr%29>) I know > that the intention is different and that it is a list of the form: > > 1. 'machine > 2. `((initial ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>)) > 3. X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>-1 > ... > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>-n > > where is seems that [List-of > <https://www.htdp.org/2019-02-24/part_three.html#%28tech._sim-dd._list._of%29> > > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>]is > expanded and included in the list ([List-of > <https://www.htdp.org/2019-02-24/part_three.html#%28tech._sim-dd._list._of%29> > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>] is > consed > onto) > > Can you please explain how the given `(machine ((initial ,FSM-State > <https://www.htdp.org/2019-02-24/part_two.html#%28tech._fsm._state%29>)) [ > List-of > <https://www.htdp.org/2019-02-24/part_three.html#%28tech._sim-dd._list._of%29> > > X1T <https://www.htdp.org/2019-02-24/part_four.html#%28tech._x1t%29>]) > translates > to this? >
I think you are right. An XMachine should be a list of 3 elements by that data definition. The definition should probably have a "." (or use `cons`es): `(machine ((initial ,FSM-State)) . [List-of X1T]) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAFUu9R7z4NZMpvRmNMqFsgxoaWQReZDokS19E4o60GJX8rye-Q%40mail.gmail.com.

