This is what I am trying to do.<div><span class="Apple-style-span" style="font-family: monospace; font-size: medium; white-space: pre; ">Write the function partialpaths, of two arguments. The
first argument is a list of lists, representing a graph(adjacency list
representation of a graph). The second argument is a partial path in the
reverse order, for example the path "from a to b to c" is represented by
the list (c b a). The function should return a list of sublists containing
all possible expansions of this partial path by one node.
For example:
(partialpaths '( (a b c) (b c d) (c d a) (d)) '(b a))
should return:
( (c b a) (d b a))
</span><br></div><div>I get the (b c d) part now I need to attach the cdr of this to b a multiple times so I try putting it in a loop. </div><div><br></div><div>Here's what I have:</div><div><div>(define nod ())</div>
<div>(define ma '('()))</div><div>(define (partialpaths L1 L2)</div><div> (set! nod (equal L1 L2))</div><div> (do()</div><div> ;exit test</div><div> ((null? (cdr nod)))</div><div> (list ma (attach(cdr nod)L2))</div>
<div> (set! nod (cdr nod))</div><div> )</div><div> ma</div><div>)</div><div><br></div><div>(define (attach List1 List2)</div><div> (list (car List1) List2)</div><div>)</div><div><br></div><div>(define (equal L1 L2)</div>
<div> (cond</div><div> ((eq? (caar L1) (car L2)) (car L1))</div><div> (else (equal (cdr L1) L2))</div><div> )</div><div>)</div></div><div><br><div class="gmail_quote">On Fri, May 7, 2010 at 9:29 PM, Jon Rafkind <span dir="ltr"><<a href="mailto:rafkind@cs.utah.edu">rafkind@cs.utah.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff">
(list 1 (list 2))<div><div></div><div class="h5"><br>
<br>
On 05/07/2010 08:29 PM, Aniket Karmarkar wrote:
</div></div><blockquote type="cite"><div><div></div><div class="h5">
<pre>I am really stuck. I want to create a nested list.
Thanks,
Aniket
</pre>
</div></div><pre><fieldset></fieldset>
_________________________________________________
For list-related administrative tasks:
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br></div>