Racket Error:arity mismatch;

I am trying to create a function in which takes two aruguments in my case i want the function to return true only when both arguements are true and false otherwise.So in my function i want it to ask the user to "whats the capital city of france" which is equal to Paris and "whats the capital city of England which is equal to London.and it should return true if both are true or false if not i also want to ask the questions one after each other and return the true or false after both have been entered.I have ran into an error i have been trying for ages i am new to racket i would really someone to help me out.Here is my code

define AND (λ (C D)
(cond
((and (string? C (string? D (boolean? C D (string? C ="London") (string? D = "Paris") "Whats the captial city of England" "Whats the captial city of France"))))))))

Error code AND: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1

I see a whole bunch of issues here, both syntactic and conceptual.

I'm guessing this is for a class, which is not necessarily a problem, but knowing whether it's for a class informs the kinds of help you need. For instance: does your function need to print a prompt and accept input? Your code seems to suggest that that's your plan, but it's going to make your function much more complicated, and if it's not required, you should leave it out.

1 Like

Could you help me correct the code because I have tried

Yes, I'd like to help you. Specifically, I asked several questions in the last post:

  1. Is this task part of a course you're taking? If so, maybe you can share the relevant portion of the assignment.
  2. Is there a compelling reason your function needs to write output and accept input?

Thanks!

John

Yes it’s part of my university assignment and here is a photo outlining the details of it I would like to include an output and input as I will gain points from it thanks

it’s question C

1 Like

Okay, makes sense. I see that there is no need for this function to print anything out, or read anything in. Forget about both of those, you're making this problem much much more complicated than it needs to be.

What you really need to do is to follow the steps for designing a function, as specified in HtDP:

https://www.htdp.org/

I can get you started, though. First, choose a name for this function (sounds like the assignment has done that for you). Next, write down a purpose statement, a one-line description of what the function should do. Next, write a "signature" or "contract": how many arguments should this function accept, and what kinds of things should they be?

2 Likes