#lang racket ; this predicate is true if we are at the base case (define AtBase? (lambda (current-x) (<= current-x 1))) ; this function defines the result at the base case (define BaseCase (lambda (base-x) 1)) ; this function breaks the current case into a smaller one (define Decomp (lambda (current-x) (- current-x 1))) ; this function says how to combine the current case and the result of ; the recursion on the smaller case into the result for the current case (define Combine (lambda (current-x smaller-result) (* current-x smaller-result))) ; here is the general definition of a function in terms of these 4 basic ; components (define fn (lambda (current-x) (if (AtBase? current-x) (BaseCase current-x) (Combine current-x (fn (Decomp current-x))) ) ) )