Defining procedures

Procedures are defined in Scheme with define

(define (function-name arg1 arg2 ... argn)

For example, we could define a procedure to calculate the average:

guile> (define (average x y) (/ (+ x y) 2))
guile> average
#<procedure average (x y)>

Once a procedure is defined, it is called by putting the procedure name and the arguments in a list. For example, we can calculate the average of 3 and 12:

guile> (average 3 12)

LilyPond — Extending v2.25.8 (development-branch).