Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
From: Tyson Williams Subject: ComS 342: HW3 problems Date: February 19, 2008 7:23:04 AM CST On Feb 19, 2008, at 3:25 AM, Tyson Williams wrote: > Another minor question is in relation to problem number 2. I cannot satisfy the > base case where the result is supposed to be the empty list. My code returns > the empty list inside another list. Maybe you have some different advice for > me, but I think I know what the problem is. "Blob" takes a variable number of > parameters, so when I pass in a list, it becomes the sole element of another > list. If I have a list, how can I pass all the elements of the list into a > function instead of the whole list (which is how "Blob" is designed to work)? Remember the "apply" procedure. "(apply f lst)" is the same as "(f d1 d2 d3 ...)", where lst is "(d1 d2 d3 ...)". The base case result should be generated by "blob", not "selective-blob". ----- From: Adam Audino Subject: iterate Date: February 18, 2008 11:05:55 PM CST On Feb 18, 2008, at 9:59 PM, Adam Audino wrote: > I am still having trouble with the iterate problem, although I do believe > that I am coming closer. This is currently what I have, and it winds up doing > nothing :( > > [partial solution omitted] > > Any hints about what I'm doing wrong? If you'll recall what I showed you during office hours today, we know that "(iterate f 0)" is equivalent to "(lambda (x) x)" [the identity function] "(iterate f 1)" is equivalent to "f" and "(iterate f 2)" is equivalent to "(lambda (x) (f (f x))" The "secret sauce" for this problem lies in trying to rewrite the equivalent form of "(iterate f 2)" in terms of "(iterate f 1)". What I tried to recall during office hours that just occurred to me while rewriting my own solution is the following: "(iterate f 1)" is equivalent to "f" ***HINT: [and "f" is, in turn, equivalent to "(lambda (x) (f x))"]*** Applying this hint while rewriting "(iterate f 2)" (as well as any call to iterate with n>2, for that matter) should get you to the right solution. ----- From: Adam Audino Subject: Blob? Date: February 17, 2008 10:45:14 AM CST On Feb 16, 2008, at 6:11 PM, Adam Audino wrote: > Steve, > I think the answers for the blob test might be wrong, or the description of > the test in the homework is wrong. When I run (test-hw3 "blob" the output is > > (blob '() '() '()) > ==> () > EXPECTED: (()) > (blob '(3 7 10) '(20 25 30) '(5 4 3)) > ==> (3 7 10 20 25 30 5 4 3) > EXPECTED: ((3 7 10) 20 25 30 5 4 3) > (blob '(20 25 30) '(5 4 3)) > ==> (20 25 30 5 4 3) > EXPECTED: ((20 25 30) 5 4 3) > (blob '(l i k) '(e) '(t h i s) '() '() '(o k) '()) > ==> (l i k e t h i s o k) > EXPECTED: ((l i k) e t h i s o k) > > just to make sure I was doing it correctly I then ran > > (blob '(3 7 10) '(20 25 30) '(5 4 3)) and got (3 7 10 20 25 30 5 4 3) as the output. > > According to the hw description I think my output looks correct. What should I do? I encourage you to re-examine the second and third examples in the homework description. (blob '(I am a blob) '()) ==> ((I am a blob)) (blob '(I am a blob) '(Beware of me) '(I creep and leap) '(and glide and slide) '(across the floor)) ==> ((I am a blob) Beware of me I creep and leap and glide and slide across the floor) If there is more than one argument list given, the first argument remains untouched in the resulting list (so the first argument of the result is itself a list) and the rest of the arguments are subsumed. The type for blob is still (-> ((list-of datum) ...) (list-of datum)) because (list-of datum) is also a datum! There are no errors in these homework tests. ----- From: Adam Audino Subject: Hw 2 #5 and 6 Date: February 3, 2008 5:26:45 PM CST On Feb 3, 2008, at 5:26 PM, Adam Audino wrote: > On question 5 and 6 you say "...procedure has a correct outline that follows the grammar for flat > lists...". So this means we are making sure it would follow a flat list? Or > create a flat list? It should "follow the grammar" for flat lists. This means that you need to "appropriately" (as we discussed in lecture) handle both the non-null and null cases according to the grammar for flat lists, which are those lists that do not contain lists inside of them. _____ From: Adam Audino Subject: hw2 #9 Date: February 3, 2008 5:02:06 PM CST On Feb 3, 2008, at 5:02 PM, Adam Audino wrote: > In question #9 you mention we can only use Scheme's append procedure, so this > means we can't use car or cdr? No, you're free to use "car" and "cdr" if you need them to manipulate a list. The restriction means you can only call "append" with two arguments, though "append" can take arbitrarily many arguments.