# Cant write function to return opposite true/false

**URL:** <https://racket.discourse.group/t/cant-write-function-to-return-opposite-true-false/489>\
**Category:** RacketScript\
**Tags:** drracket\
**Created:** [December 29, 2021, 4:37pm UTC](https://racket.discourse.group/t/cant-write-function-to-return-opposite-true-false/489 "2021-12-29T16:37:57Z")\
**Posts on this page:** 3\
**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:** [December 29, 2021, 4:37pm UTC](https://racket.discourse.group/t/cant-write-function-to-return-opposite-true-false/489/1 "2021-12-29T16:37:57Z")

</div>

I have been trying to write a function in racket which takes one argument returns its opposite so in my example i have been trying to set b to equal 4 and if any other value is entered it should return true but in my case every value entered is false i would appreciate some help with this

```scheme
(define A (λ (b)
            (cond
           ( = b 4 (number? b) (not b)))))

```

---

<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:** [December 29, 2021, 5:14pm UTC](https://racket.discourse.group/t/cant-write-function-to-return-opposite-true-false/489/2 "2021-12-29T17:14:40Z")

</div>

Welcome @osman44

Are you after something like this?

```scheme
#lang racket

;; is-not-equal-to-4 : n : number -> boolean
;; this function checks if a number is not equal to 4,
;; and returns #true or #false

(define (is-not-equal-to-4 b) 
   (not (= b 4)))
;;tests
(is-equal-to-4 2) ; #t
(is-equal-to-4 4) ; #f

```

More information about the conditionals `if`, `cond` etc.; [3.12&nbsp;Conditionals: if, cond, and, and or](https://docs.racket-lang.org/reference/if.html)

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [December 29, 2021, 6:40pm UTC](https://racket.discourse.group/t/cant-write-function-to-return-opposite-true-false/489/3 "2021-12-29T18:40:14Z")

</div>

Can you be more clear about the inputs and outputs of your function? What kinds of values should you be able to call the function with? For a range of plausible inputs, what is the corresponding output? I can't figure it out from your description.
