[plt-scheme] HTDP 16.3.4
I'm sure they can.
The greater part of my brain has been occupied of late reading these
wonderful little books that have elephant drawings on them learning about
how letrec and define can be "defined" with applicative order Y combinators,
finally understanding collectors to the point where I was able to use them
to write a program to evaluate poker hands and getting my head around
continuations and trying to figuring out their wider applicability. The
material was tough to grok and I had to go over it over and over again. I'm
in the middle of writing a small regular expression parser and figured I had
better come back to HTDP to see what it had to say about backtracking once
I had revised and filled in the holes on the work I did on the book this
summer.
It seems that in the mix of all this some design recipe has slipped out of
short term memory before making it to long term memory and in moments like
these you sometimes need the proverbial cardboard cut out programmer to give
you a nudge.
So thank you for assisting me. I have been able to complete that exercise.
>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 19:15:43 -0400
>
>Figure out what each expression in the template computes, just as the
>recipe says. Then figure out how you can combine those values (lists) into
>a single value (list). That's all. My freshmen can do it, w/o help --
>Matthias
>
>
>On Sep 22, 2006, at 6:56 PM, wooks . wrote:
>
>>
>>
>>
>>>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
>>>"directory-structure"?
>>>
>>
>>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))
>>
>>; DATA ANALYSIS
>>; 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
>>files.
>>;
>>; 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)
>> (....sym....
>> (dir-name folder) .....
>> (func-for-lods (dir-dirs folder))....
>> (func-for-files (dir-files folder)))]))
>>
>>(define (func-for-lods alods)
>> (cond
>> [(empty? alods)....]
>> [else ....(func-for-dir (first alods)).....
>> (func-for-lods (rest alods))...]))
>>(define (func-for-files alofs)
>> (cond
>> [(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
>>
>>; OUTPUT TEMPLATE FOR FIND
>>; (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.
>>
>>
>