Cant write function to return opposite true/false

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

(define A (λ (b)
           ( = b 4 (number? b) (not b)))))
1 Like

Welcome @osman44

Are you after something like this?

#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)))
(is-equal-to-4 2) ; #t
(is-equal-to-4 4) ; #f

More information about the conditionals if, cond etc.; 3.12 Conditionals: if, cond, and, and or

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.

1 Like