Re: [racket] Generative recursion

2010-11-07 Thread David Yrueta
If you've solved the permutations problem, then in my opinion, you have the ability to solve any problem in the book. Sounds like you're just having a weird block. Don't worry -- my guess is it happens to everyone! The question Wooks put to you in one of his previous posts -- how can you preserv

Re: [racket] Generative recursion

2010-11-07 Thread Matthias Felleisen
On Nov 7, 2010, at 1:29 AM, Ken Hegeland wrote: > I felt very dumb trying to figure this problem out. You shouldn't feel dumb. I suspect that this problem needs to go because it doesn't drive home the points I had had in mind when I wrote it. Sorry -- Matthias _

Re: [racket] Generative recursion

2010-11-06 Thread Ken Hegeland
I am able to define a generative function for tabulate the divisors of 20, so hopefully tomorrow I can figure out how to abstract it, Im sure I might have a bit more trouble with the final step I need to figure out for abstraction. I just wanted to say thanks to wooks and anyone else, I felt ver

Re: [racket] Generative recursion

2010-11-06 Thread Ken Hegeland
Yes, I have completed all the previous challenges, I have completed most 3 times, and some 2 times. For the most part with all the previous challenges I never had too much trouble. The only other problems that gave me a decent amount of trouble were the permutation function, and computing natura

Re: [racket] Generative recursion

2010-11-06 Thread David Yrueta
Hi Ken -- Just a quick question to make sure we are all on the "same page," as it were: have you completed all exercises in prior sections? Dave On Sat, Nov 6, 2010 at 2:24 PM, Ken Hegeland wrote: > Something that looks like this: > > (define(tabulate1 n i) > (cond > [(> i n)empty] > [(=(remai

Re: [racket] Generative recursion

2010-11-06 Thread Ken Hegeland
Something that looks like this: (define(tabulate1 n i) (cond [(> i n)empty] [(=(remainder n i)0)(cons i(tabulate1 n(add1 i)))] [else(tabulat1 n(add1 i))])) (define(tabulate n) (tabulate1 n 1)) I feel like I understand how it works recursively, just the generative recursion method makes me stru

Re: [racket] Generative recursion

2010-11-06 Thread wooks .
An alternative approach. 1. Write a program called tabulate-20 that returns all the factors of 20 starting from 1. 2. Abstract tabulate-20 so that it works for numbers other than 20. _ For list-related

Re: [racket] Generative recursion

2010-11-06 Thread wooks .
I tried to get you to approach this as though nobody had told you about generative recursion. In which case you would/should have tried the tried and tested formula you know, which should have led you to (tabulate-div 20) and the simple recursion that follows is (tabulate-div 19). You have

Re: [racket] Generative recursion

2010-11-06 Thread Ken Hegeland
I have been trying to take a break for the weekend and I am going to try to go back at it with a fresh perspective Monday. One thought I did have though, you said tabulate-div means we want all the divisors of 20, so the next step would be tab-div(sub1 n), or 19, Im thinking that would mean a

Re: [racket] Generative Recursion

2010-11-05 Thread wooks .
Forget about the term generative recursion for a second. I've coined a phrase that for me encapsulates much of the approach of the Design Recipe - I call it Delta Programming. Why - well you have a result you would like, you have your input and you have in your template a bunch of expressions

Re: [racket] Generative recursion

2010-11-05 Thread Luke Jordan
#x27;; lukejor...@gmail.com > > *Cc:* users@racket-lang.org > *Subject:* Re: [racket] Generative recursion > > Actually there is one more way. We only have to check numbers 1 up to the > integer-sqrt of n. For each check whose remainder is 0, we immediately have > two divisors, the ch

Re: [racket] Generative recursion

2010-11-05 Thread Jos Koot
0 12:06 To: 'Todd O'Bryan'; lukejor...@gmail.com Cc: users@racket-lang.org Subject: Re: [racket] Generative recursion Actually there is one more way. We only have to check numbers 1 up to the integer-sqrt of n. For each check whose remainder is 0, we immediately have two divisors, th

Re: [racket] Generative recursion

2010-11-05 Thread Jos Koot
-)) Jos _ From: users-boun...@racket-lang.org [mailto:users-boun...@racket-lang.org] On Behalf Of Todd O'Bryan Sent: 05 November 2010 10:31 To: lukejor...@gmail.com Cc: users@racket-lang.org Subject: Re: [racket] Generative recursion There are really two ways of doing this problem

Re: [racket] Generative recursion

2010-11-05 Thread Todd O'Bryan
There are really two ways of doing this problem. The way I'd probably use is to make a list of all the *possible* divisors and then use the filter function to pull out the actual divisors. The way you're probably thinking of requires a helper function for the recursion, because you need to keep tr

Re: [racket] Generative recursion

2010-11-03 Thread Luke Jordan
I found implementing this trickier than grasping the solution as well. Stick with it. I don't see that you need any functions related prime numbers. Perhaps if input is prime that is a trivial case, but try to focus on what the output is: A list of numbers that can evenly divide the input. Thos