<div dir="ltr"><div><div><div>;Gentlemen, I'm having difficulties with X-expressions. I decided to make up examples for each type that appears as a way to engage myself in the business, but I fail to be sure whether my examples are correct.</div><div><br></div><div>; An Xexpr.v0 (short for X-expression) is </div><div>;   (cons Symbol '())</div><div>(define sv0.0 (cons 'machine empty))</div><div>(define sv0.1 (cons 'another empty))</div><div><br></div><div>;These v0 I'm confident.</div><div><br></div><div>; An Xexpr.v1 is </div><div>;   (cons Symbol [List-of Xexpr.v1])</div><div>(define sv1.0 (cons 'machine empty))</div><div>; <machine> </div><div>;  <initial></initial> </div><div>;  <state></state> </div><div>;  <state></state> </div><div>; </machine></div><div>(define initial (cons 'initial empty))</div><div>(define state1 (cons 'state empty))</div><div>(define state2 (cons 'state empty))</div><div>(define a-machine (cons 'machine (list initial state1 state2)))</div><div><br></div><div>;I made up the XML example to be able to translate it piece by piece to make it easier. I claim now that a-machine represents the XML expression above.</div><div><br></div><div>; An Xexpr.v2 is </div><div>; – (cons Symbol [List-of Xexpr.v2])</div><div>; – (cons Symbol (cons [List-of Attribute] [List-of Xexpr.v2]))</div><div><br></div><div>(define a-cluster (cons 'a-cluster (list a-machine a-machine)))</div><div><br></div><div>;Our sample data representations from above suggest this definition for Attribute:</div><div><br></div><div>; An Attribute is </div><div>;   (cons Symbol (cons String '()))</div><div><br></div><div>(define a-name-attr (cons 'name (cons "cluster x" empty)))</div><div>(define a-named-cluster (cons 'a-named-cluster (cons (list a-name-attr) (list a-machine a-machine))))</div><div><br></div><div>; At first at least, it's difficult to write these expressions and be sure they conform. I'm using other definitions to write less long expressions.</div><div><br></div><div>; Exercise 302. Eliminate the use of List-of from the data definition Xexpr.v2. #</div><div><br></div><div>; I think I don't get the spirit of this exercise. If I eliminate the use of List-of from Xexpr.v2, how can I get lists of attributes or lists of x-expr.v2? But see my attempt below.</div><div><br></div><div>; (*) Solution</div><div><br></div><div>; A ListOfAttributes is</div><div>;  - empty</div><div>;  - (cons Attribute ListOfAttributes)</div><div><br></div><div>; A ListOfXexpr.v2 is</div><div>;  - empty</div><div>;  - (cons Xexpr.v2 ListOfXexpr.v2)</div><div><br></div><div>; So we can express Xexpr.v2 without the List-of operator by using these types above.</div><div><br></div><div>; An Xexpr.v2 is </div><div>; – (cons Symbol ListOfXexpr.v2)</div><div>; – (cons Symbol (cons ListOfAttributes ListOfXexpr.v2))</div><div><br></div><div>; Is this what the exercise expects? Thank you.</div></div></div></div>