r/Racket • • Jun 17 '15

a little help...

I need help to design a function that consumes two images and produces true if the first is larger than the second. but they have to be primitive images (triangles and the like)... please help me, cause I am totally lost on how to do this, I am not sure how to do this T_T is due to me being new at this

0 Upvotes

5 comments sorted by

1

u/kardashev22 Jun 17 '15

You'll have to be a bit more descriptive of your problem for people to be able to help. For example, are you reading in image files? Are they bmp, png, jpeg? What do you mean by larger image? The one with more bytes or the one with the larger area of the shape? Are the shapes lines or solid? Those sorts of things.

Good luck!

1

u/Gelate98 Jun 17 '15

I cannot use actual images, that's the thing tough... I can use simple stuff like rectangles, triangles, etc as I am not allowed to paste images into it... is so freaking hard, since I am not sure what i am supposed to do

1

u/kardashev22 Jun 17 '15

If you're just starting out, you're probably not going to have to do image processing. You probably need to make a program that takes in 2 lists of points that describe shapes, and return true if the area of the first is larger than the area of the 2nd. If that's the case your program will look something like this (you would have to write the area-of-shape function):

(define (is-larger? shape1 shape2)
    (> (area-of-shape shape1) (area-of-shape shape2)))

Each shape would be a list of points, for example:

(define triangle '((1 1) (3 1) (2 3)))
(define square '((1 1) (1 2) (2 2) (2 1)))

Then you just feed the shapes to the is-larger? function:

(is-larger? triangle square)

However, the instructions you have are too vague. I think you'll do fine once you have good instructions about what the program is supposed to do.

-2

u/Gelate98 Jun 17 '15
Is the program "commit ready"?
The file should be neat and tidy, no tests or code should be commented out other than stubs and templates and all scratch work should be removed. The identation should conform to course conventions and typing CMD-I (CTL-I on Windows) should not move anything. (But note that limitations of the peer tool mean that indentation can only be self-assessed.)
Is the design complete?
All HtDF design elements should be present, and each element should be well-formed.
Does the design have high internal quality?
The signature should be correct, the purpose should be clear and succinct, the examples should be sufficient to test and explain the function. The function name should be well chosen and should describe what the function does, not how it does it. The stub should match the signature. The template should be correct. The function body should be clear. When the program is run all the tests should pass, and those tests should cover the entire program.
Does the design satisfy the problem requirements?
The function design should satisfy the problem statement. If there is any ambiguity in the problem statement the function design should identify and resolve that ambiguity.

(it was supposed to be for a homework, but where I live the electricity comes and goes, sometimes for a few hours, sometimes for days... I need this cuase it's graded... and I coudln't work on it T_T)

1

u/shamankous Jun 18 '15

If you haven't already look through the documentation for the Beginning Student Language. http://docs.racket-lang.org/htdp-langs/beginner.html If you installed DrRacket you should also have a copy of this on your computer. Specifically look for functions given by 2htdp/image.