How can i return the max price value of a struct list?

i am trying to write an expression which is supposed to return the highest price of a menu list..
as you can see below i have defined a struct and built a menu as a list of should return 6 becuase thats the most expensive price. i have tried to use apply max in this way and other ways to find the highest price in the menu from menu-item-price ,though it seems to fail each time i would get contract viloation errors,and i am stuck at this point

(apply max menu (menu-item-price))

( struct menu-item ( dish-name price )#:mutable)

(define menu (list
(menu-item "pizza" 6)
(menu-item "chilli" 5)
(menu-item "soup" 3) ))

Sadly I can't answer this question, because I don't have an edition of "How to Guess Programs", however libraries near you have a book called "How to Design Programs".

Emphasis Design, nobody wants to play "fix my program bingo" forever.

If you don't follow the advice and strategies you are given, then you don't learn to solve easy problems like this in a strategic way.

This is still "what does the function you call do?" like here:

Don't just assume you understand parts of the program, actually proof to yourself that everything works as you think it does. Because only if you test your assumptions, you will find the mistakes.

1 Like

sorry,this is not for the guess program

I totally agree with @simonls's answer: people around here gave you some suggestions about solving similar problems, so you should try to apply these suggestions every time you run into trouble. If you want to get better help, you should try to tell us where exactly following the suggestions failed, so that we know how exactly to help you.

For example, I took your code and ran it, which gave me this error:

; menu: undefined;
;  cannot reference an identifier before its definition
;   in module: …

What does this message tell you? How can you fix it? After fixing this error message, what is the next error message you get? How can you fix it? And so on.

Looking at the kinds of solutions you are trying, I have the impression that you have the tendency to test relatively complicated things before simple things. For example, using apply in you situation may indeed work in some cases, but are there simpler ways to achieve the behavior you want?

Learning how to program may be tedious and there is no royal road to programming, but it is always rewarding at the end. Follow the suggestions your were given and you will end up there one day.

1 Like

What is your english proficiency? I feel like maybe you just don't understand us that well.
The part about "How to Guess Programs" was a bit ironic/jokingly said (there isn't a book with that name) and it seems like you didn't pick up on that.

If you have trouble understanding us, that might be good for us to know, maybe you could find someone that speaks your mother tongue if it isn't english.

Learning two different skills at the same time, would make it way more difficult.
Also I think it would be good if you had some kind of tutoring.
Somebody that can help you in person, would have an easier time recognizing where you actually need guidance.