Form character return scheme + *
How can I define in schema language this function returning if x>0 + else *
as:
plus_or_muliti(int x) {
if (x>0) return +;
else return *;
}
I try this and it doesn't work on the racket:
(define (plus_or_multi x)
(if (>= x 0) + *))
i got this error
+: expected a function call, but there is no open parenthesis before this function
source to share
This code is great for implementing the complete schema (in this case, Racket), but based on the error you are getting, it looks like you are using the initial learners language, one of several languages ββthat the Racket system comes to with. BSL is designed to help avoid some of the common beginner mistakes when using Schema-based languages, and all teaching languages ββare designed to be used in tandem with How to Build Programs . In fact, several libraries that ship with Racket are in a module htdp
or htdp2
and are extracted from this book, although they can be used for general purpose applications. In the menu DrRacket Language β Choose Language you can select the full language version, which will allow you to use ... the full language.
source to share