[plt-scheme] HTDP 16.3.4

From: wooks . (wookiz at hotmail.com)
Date: Fri Sep 22 18:56:55 EDT 2006

>From: Matthias Felleisen <matthias at ccs.neu.edu>
>To: wooks . <wookiz at hotmail.com>
>CC: plt-scheme at list.cs.brown.edu
>Subject: Re: [plt-scheme] HTDP 16.3.4
>Date: Fri, 22 Sep 2006 18:15:08 -0400
>On Sep 22, 2006, at 5:28 PM, wooks . wrote:
>>I am looking at the last part of the section marked Challenge which  
>>requires a function
>>;;func-producing-list-of-lists: symbol directory-structure ->  [[symbol]]
>>;;produces a list of all the paths to files of the specified name  in the 
>>directory structure.
>Where is the definition of [[symbol]]? Where is the definition of  

Well I was paraphrasing to make the statement of my problem more concise. 
These are the definitions I have been working with.

(define-struct file (name size content))
(define-struct dir (name dirs files))

; A file is a structure:
;  (make-file n s x)
; where n is a symbol, s is a number, and x is some Scheme value.
; A list-of-files is either
;    1.  empty, or
;    2. (cons s lof) where s is a file and lof is a list of files.
; A dir is a structure:
;  (make-dir n ds fs)
; where n is a symbol, ds is a list of directories, and fs is a list of 
; A list-of-directories is either
;    1.  empty or
;    2. (cons s lod) where s is a dir and lod is a list of directories.

>Let's use the recipe. Presumably you have a template, one line in one  
>function and three in the other keeping in mind that the function(s)  
>really must return a list of paths. So

....and these are the templates I wrote for the first 2 parts of the problem 
.... find and find? both of which worked.

(define (func-for-dir sym folder)
       (dir-name folder) .....
       (func-for-lods (dir-dirs  folder))....
       (func-for-files (dir-files folder)))]))

(define (func-for-lods alods)
    [(empty? alods)....]
    [else ....(func-for-dir (first alods)).....
          (func-for-lods (rest alods))...]))
(define (func-for-files alofs)
    [(empty? alofs) ...]
    [else .... (file-n (first alofs))
          (file-s (first alofs))
          (file-x (first alofs))
          ....(func-for-files (rest alofs))..]))

>-- cases without cross or self-references: return a list, distinguish  
>success from failure. done
>-- cases with self- or cross-references: each recursive/cross call  
>produces a list of paths to the "successes".  The answer is a  combination 
>of those partial results, plus the knowledge that these  paths aren't 
>complete. Since you figured out how to do one path, I  bet that this part 
>is a minor little step. It really is just a help  function plus a line.

not on the same page with you yet Prof.

After perusing Dr Bloch's webpages I started out

; (define (func-returning-list-of-lists folder)
;   (cond
;     [..... empty]
;     [..... (cons (func-for-dir sym folder)
;                  (func-returning-list-of-lists folder))]))

but couldn't figure out how to return successive paths.
I'm not yet able to reconcile your input with my perception of the problem.

Posted on the users mailing list.