[racket] Possible bug with sine and cosine (simple floating-point issue?)

2011-01-06 Thread Sam Griff
I'm running the Windows build of 5.0.2 on 32bit Windows 7 and I've run into the following issues with sine and cosine. Here is a paste of my interaction with Racket: > (inexact->exact (sin 0)) 0 ; fine > (inexact->exact (cos 0)) 1 ; fine > (inexact->exact (sin (/ pi 2))) 1 ; fine > (inexact->exact

Re: [racket] Basic Racket Question

2010-12-21 Thread Sam Griff
You need to start over and slow down because you are getting the basic Scheme syntax wrong. The gross pay function is already given: (define (wage h) (* 12 h)) You could modify it according to the previous suggestions to make it more readable: ; By convention constants are named in upper case (d

Re: [racket] Math Guidance

2010-11-04 Thread Sam Griff
To bring the discussion back on topic: According to both the paper explaining the development of HtDP (PDF: http://www.ccs.neu.edu/scheme/pubs/jfp2004-fffk.pdf ) and the course in which it is used (Comp Sci I) the goal of HtDP is to introduce to you the types of math/programming problems that you w

[racket] [htdp] Can this be simplified?

2010-11-02 Thread Sam Griff
Here is my solution to a modified version of DNAprefix from exercise 17.6.6. I feel like it *should* be able to be written more clearly/simply but I can't think of the logic to make it work properly: Modify |DNAprefix| so that it returns the first item beyond the pattern in the search-string i

Re: [racket] [htdp] Help with Exercise 12.4.2

2010-07-07 Thread Sam Griff
> You're not consistent with the formatting of your documentation. Yeah... Sorry about that... I was mostly documenting the functions in a way that would most help me understand what was going on. I agree with you consistent documentation is important. > So, is that table really useful? I think so

Re: [racket] [htdp] Help with Exercise 12.4.2

2010-07-07 Thread Sam Griff
I think I got it! It produces the correct results, but I'm not sure if it follows the design pattern properly: ;; A word is either ;; 1. empty, or ;; 2. (cons s w) ;;where s is a symbol and w is a word ;; Examples: ;; (cons 'a empty) ;; (cons 'h (cons 'i empty)) ;; (cons 'c (cons 'a (cons 't

Re: [racket] [htdp] Help with Exercise 12.4.2

2010-07-07 Thread Sam Griff
> Isn't that too much help? I don't think so because I know there is a problem with the second clause and thinking recursively. I made a few charts like you suggested: s | w| (first w) | (insert-everywhere/in-single-word s (rest w)) | expect

Re: [racket] [htdp] Help with Exercise 12.4.2

2010-07-06 Thread Sam Griff
> Exercise 12.4.2 is notorius. When looking to (list 'a 'b 'c), you should > exspect 6 distinct permutations. > Jos Thanks for your response but that really doesn't help me much. I'm focusing on insert-everywhere/in-single-word now. I understand what arrangements does and what permutations to expe

[racket] [htdp] Help with Exercise 12.4.2

2010-07-06 Thread Sam Griff
Hello. Like many others working through HtDP I have hit the wall at this exercise. I'm not sure what I have so far is in line with the "proper" way to do this exercise and would appreciate any help/suggestions. Here is the code I have so far: ;; A list of words is either ;; 1. empty ;; 2. (cons w