(define pythagoras
(lambda (a b)
(sqrt
(+
(* a a)
(* b b)
)
)
)
)
(display (pythagoras 3 4))
(newline)
Note
(define myvar ((lambda (a) (* 2 a)) 10))
(define myfunc
(lambda (a b)
(display a)
(display "+")
(display b)
(display "=")
(+ a b)
)
)
(display (myfunc 5 6))
(newline)
(define a 500)
(define myfunc
(lambda ()
(define a 6)
(display a)
(newline)
)
)
(myfunc)
(display a)
(newline)
(define a "a_old_value")
(define b "b_old_value")
(define myfunc
(lambda ()
(define a 30)
(set! a "a_new_value")
(set! b "b_new_value")
)
)
(display a)
(newline)
(display b)
(newline)
(define display_sums
(lambda (a b c d e f)
(define display_sum
(lambda (one two)
(display one)
(display "+")
(display two)
(display "=")
(display (+ one two))
(newline)
)
)
(display_sum a b)
(display_sum c d)
(display_sum e f)
)
)
(if #f
(display_sum 5 6)
)
(define make-counter
(lambda (start_from)
(define increment
(lambda ()
(set! start_from (+ start_from 1))
start_from
)
)
increment
)
)
(define counter (make-counter 100))
(display (counter))
(newline)
(display (counter))
(newline)
(define second-counter (make-counter 100))
(display (second-counter))
(newline)
(display (counter))
(newline)
(define myfunc 0)
(set! myfunc (lambda (h) (* 3 h)))
(define twice (lambda (func x)
(func (func x))
))
(display (twice myfunc 2))
(newline)