Greetings,

I'm working through HtDP alone and am currently stuck.  All the relevant code 
can be found here: 
https://gist.github.com/simalaia/d5b50e9a0bd36b89128aecb43de71cf8

As suggested in the book I start with  (insert-everywhere/in-all-words)  and 
design a new function with signature  1String Word -> List-of-Words  and the 
purpose statement "insert 1String into every position of Word", I get stuck 
here.

I used the table method to try and work out what the next function I need to 
design is, however everything I try results in me coming up with needing 
exactly the function that I started with, along with the problem that I started 
with.

Every attempt at directly solving it (but see below on how this 'solving' is 
being done) without an auxiliary function results in some tests failing.  For 
example  (f "x" (list "a")) -> (("x" "a") ("a" "x"))  but this fails when given 
length zero or two words.  I have not managed any improvements on this.

There seems to be a fairly obvious solution along the lines of  (map append 
(prefixes w) (map (λ (x) (cons s x)) (suffixes w)))  however that seems to 
require the simultaneous processing chapter and is based more on intuition than 
design.  I am, either way, not asking as to the solution for this problem.

What I can't work out is where my understanding of the design recipe is 
failing?  The implementation I have so far is based on my extrapolation from 
the list-of-lists recipe to how trees would likely be processed and based on a 
pure intuitive guess rather than systematic application of the recipe.  The 
table method also doesn't seem to be producing any results that I understand.  
Nor are the tests helping...

Hence, could someone assist with debugging my understanding of the recipe?

Regards.

-- 
Sent with https://mailfence.com
Secure and private email

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1801521434.203448.1620219317116%40ichabod.co-bxl.

Reply via email to