racket Functions Simple Function Calls


Example

You can call a function in Racket by wrapping it in parentheses with the arguments after it. This looks like (function argument ...).

> (define (f x) x)
> (f 1)
1
> (f "salmon")
"salmon"
> (define (g x y) (string-append x y))
> (g "large" "salmon")
"largesalmon"
> (g "large " "salmon")
"large salmon"

Operations like + and * are functions as well, and they use the same syntax as calling f or g.

> (+ 1 2)
3
> (* 3 4)
12
> (+ (* 3 3) (* 4 4))
25

For more information and examples, see Function Calls in the Racket Guide.