# Having issues with cond

**URL:** <https://racket.discourse.group/t/having-issues-with-cond/765>\
**Category:** Questions & Answers\
**Tags:** question, drracket, creative-racket\
**Created:** [March 4, 2022, 5:28pm UTC](https://racket.discourse.group/t/having-issues-with-cond/765 "2022-03-04T17:28:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![osman44](https://avatars.discourse-cdn.com/v4/letter/o/85f322/32.png) [@osman44](https://racket.discourse.group/u/osman44)\
**Post date:** [March 4, 2022, 5:28pm UTC](https://racket.discourse.group/t/having-issues-with-cond/765/1 "2022-03-04T17:28:32Z")

</div>

i am working through the htdp book online and i came across and excerise which asks me to

Then create an expression that converts the value of in to a non-negative number. For a String, it determines how long the String is; for an Image, it uses the area; for a Number, it uses the absolut value; for #true it uses 10 and for #false 20. Hint Check out cond from the Prologue: How to Program (again).

the last part is the issue it wants to write a predicate which returns 10 or 20 depending on the value of inn. this is my code so far

```scheme
(define inn "abc")

(cond
  [(string? inn ) (string-length inn)]
  [(image? inn) ( + (image-width) (image-height))]
  [(number? inn) (abs inn)]
  [(boolean? inn #true) (boolean? inn #false)] 10 20)

```

so if put false as the input of the def inn it should return 20.

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 4, 2022, 5:40pm UTC](https://racket.discourse.group/t/having-issues-with-cond/765/2 "2022-03-04T17:40:17Z")

</div>

Hi,

I dot want to give you the answer and I have not tested(I may be wrong!) this but hopefully the following will help:

I think you need to split the last line into two separate cons clauses.

- a `cond` clause is activated when the first part is true so you don't need boolean as `inn` already is a boolean.

- how do you think you can get a `#true` when `inn` is `#false`? (hint: you might need a boolean operator)

You are very close - keep going 😃

best regards,  
Stephen

PS Check your area calculation

PPS: Use three backticks then the word scheme at the beginning and three backticks at the end to get nice formatting 😃

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/922b052098f62df0480a9a8f3f998f913d23db87.png)

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [March 4, 2022, 5:58pm UTC](https://racket.discourse.group/t/having-issues-with-cond/765/3 "2022-03-04T17:58:02Z")

</div>

Just a small note regarding formatting as code, `scheme` was set to be the default and thus can be omitted.

> [@Syntax Highlighting in Discourse?](https://racket.discourse.group/t/syntax-highlighting-in-discourse/240/3):
>
> abcd (define x 19) (define x 19) Ah! Okay. I had set scheme to be the default language highlight... but I had failed to add scheme to the list of legal highlight choices. Seems like there could be a warning about that, sigh... Ah well.

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [March 4, 2022, 6:12pm UTC](https://racket.discourse.group/t/having-issues-with-cond/765/4 "2022-03-04T18:12:50Z")

</div>

I fixed small syntactic mistakes in the last line:

```scheme
(require 2htdp/image)

(define inn "abc")

(cond
  [(string? inn ) (string-length inn)]
  [(image? inn) ( + image-width image-height)]
  [(number? inn) (abs inn)]
  [(boolean? inn) (if (boolean=? inn #false) 10 20)])

```

I restored another mistake so you aren’t “home” yet.

Recommendation: Open Help Desk. Search `boolean?`. Follow the link to the BSL version. Take a close look. ~~ While you’re there, explore some more of the functions that you might need | like | use in the future.
