[plt-scheme] creating nested lists in DrScheme

From: Aniket Karmarkar (akarmarkar at mail.bradley.edu)
Date: Fri May 7 22:42:50 EDT 2010

This is what I am trying to do.
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))
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.

Here's what I have:
(define nod ())
(define ma '('()))
(define (partialpaths L1 L2)
  (set! nod (equal L1 L2))
  (do()
    ;exit test
    ((null? (cdr nod)))
    (list ma (attach(cdr nod)L2))
    (set! nod (cdr nod))
  )
  ma
)

(define (attach List1 List2)
  (list (car List1) List2)
)

(define (equal L1 L2)
  (cond
    ((eq? (caar L1) (car L2)) (car L1))
    (else (equal (cdr L1) L2))
  )
)

On Fri, May 7, 2010 at 9:29 PM, Jon Rafkind <rafkind at cs.utah.edu> wrote:

>  (list 1 (list 2))
>
>
> On 05/07/2010 08:29 PM, Aniket Karmarkar wrote:
>
> I am really stuck. I want to create a nested list.
> Thanks,
> Aniket
>
>
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100507/3470383a/attachment.html>

Posted on the users mailing list.