# The true meaning of recursion in the SICP book

**URL:** <https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [October 15, 2023, 7:45am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388 "2023-10-15T07:45:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![syafiqfadillah](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/syafiqfadillah/32/1452_2.png) [@syafiqfadillah](https://racket.discourse.group/u/syafiqfadillah)\
**Post date:** [October 15, 2023, 7:45am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/1 "2023-10-15T07:45:43Z")

</div>

In chapter 1 subchapter 1.1.3 there is the sentence

> "First, observe that the first step dictates that in order to accomplish the evaluation process for a combination we must first perform the evaluation process on each element of the combination. Thus, the evaluation rule is recursive in nature; that is, it includes, as one of its steps, the need to invoke the rule itself."

shortly after this sentence in the book an example is given `(* (+ 2 (* 4 6)) (+ 3 5 7))`. The above example looks like a procedure calling another procedure rather than a procedure calling itself. My question is, I don't see any recursion in that example if the recursion in question is recursion in the general sense. Is there a special meaning of recursion in racket or other lisp dialects?

---

<div class="post-metadata">

**Author:** ![sschwarzer](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/sschwarzer/32/1940_2.png) [@sschwarzer](https://racket.discourse.group/u/sschwarzer)\
**Post date:** [October 15, 2023, 9:49am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/2 "2023-10-15T09:49:13Z")

</div>

> [@syafiqfadillah](#):
>
> Is there a special meaning of recursion in racket or other lisp dialects?

I think also in the Lisp/Racket context, "recursion" is _usually_ understood as a function calling itself or functions calling each other.

On the other hand, in the paragraph you quoted, "recursive" means that to evaluate a function call, all the inner calls must be evaluated first. To evaluate the inner calls, _their_ inner calls must be evaluated, and so on. That is, the innermost expressions are evaluated first and the outermost expression last.

So "recursion" as used in the SICP paragraph isn't the "true" meaning, but an alternative meaning. You could also say that the usual definition of "recursion" is a special case of "recursion" as used in the SICP paragraph.

---

<div class="post-metadata">

**Author:** ![syafiqfadillah](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/syafiqfadillah/32/1452_2.png) [@syafiqfadillah](https://racket.discourse.group/u/syafiqfadillah)\
**Post date:** [October 15, 2023, 1:32pm UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/3 "2023-10-15T13:32:36Z")

</div>

thanks for the answer!

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [October 15, 2023, 2:52pm UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/4 "2023-10-15T14:52:16Z")

</div>

> [@syafiqfadillah](#):
>
> 1.1.3

The book says the "evaluation rule" is recursive. That is, the rule used to evaluate the example expression is recursive, not the expression itself. Later, much later, in the book, you'll see how to define the "evaluation rule" in form of a little interpreter. Here you will see concretely how the evaluation rule is recursive.

---

<div class="post-metadata">

**Author:** ![syafiqfadillah](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/syafiqfadillah/32/1452_2.png) [@syafiqfadillah](https://racket.discourse.group/u/syafiqfadillah)\
**Post date:** [October 16, 2023, 7:37am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/5 "2023-10-16T07:37:50Z")

</div>

got it! thanks for the answer!

---

<div class="post-metadata">

**Author:** ![syafiqfadillah](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/syafiqfadillah/32/1452_2.png) [@syafiqfadillah](https://racket.discourse.group/u/syafiqfadillah)\
**Post date:** [October 21, 2023, 7:48am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/6 "2023-10-21T07:48:14Z")

</div>

can you give me the page number that shows how to define the evaluation rule in the book? i tried to look for it in the book, but i haven't found it yet. some people have their own assumptions about the recursion in question so i'm confused by people's answers, until now i'm still trying to understand the meaning of recursion from the sentence above. thanks.

---

<div class="post-metadata">

**Author:** ![sschwarzer](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/sschwarzer/32/1940_2.png) [@sschwarzer](https://racket.discourse.group/u/sschwarzer)\
**Post date:** [October 21, 2023, 8:55am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/7 "2023-10-21T08:55:56Z")

</div>

> [@syafiqfadillah](#):
>
> can you give me the page number that shows how to define the evaluation rule in the book?

I assume the SICP section @soegaard means is this:

[4.1 The Metacircular Evaluator](https://sarabander.github.io/sicp/html/4_002e1.xhtml#g_t4_002e1) .

> [@syafiqfadillah](#):
>
> some people have their own assumptions about the recursion in question

If you're referring to me: I agree with what @soegaard wrote [here](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/4). I missed the detail that the sentence from the book was referring to the _evaluation rule_, not the _evaluated expression_.

So there's actually no contradiction between what the book says and the common definition of recursion.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [October 21, 2023, 8:56am UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/8 "2023-10-21T08:56:38Z")

</div>

Wrt the recursive evaluation rule see chapter 4.  
The core of `eval` looks like this:

```scheme
(define (eval exp env)
  (cond ((self-evaluating? exp) exp)
        ((variable? exp) (lookup-variable-value exp env))
        ((quoted? exp) (text-of-quotation exp))
        ((assignment? exp) (eval-assignment exp env))
        ((definition? exp) (eval-definition exp env))
        ((if? exp) (eval-if exp env))
        ((lambda? exp)
         (make-procedure (lambda-parameters exp)
                         (lambda-body exp)
                         env))
        ((begin? exp) 
         (eval-sequence (begin-actions exp) env))
        ((cond? exp) (eval (cond->if exp) env))
        ((application? exp)
         (apply (eval (operator exp) env)
                (list-of-values (operands exp) env)))
        (else
         (error "Unknown expression type -- EVAL" exp))))

```

---

<div class="post-metadata">

**Author:** ![syafiqfadillah](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/syafiqfadillah/32/1452_2.png) [@syafiqfadillah](https://racket.discourse.group/u/syafiqfadillah)\
**Post date:** [October 21, 2023, 12:47pm UTC](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/9 "2023-10-21T12:47:00Z")

</div>

> [@sschwarzer](#):
>
> If you're referring to me: I agree with what @soegaard wrote [here](https://racket.discourse.group/t/the-true-meaning-of-recursion-in-the-sicp-book/2388/4). I missed the detail that the sentence from the book was referring to the _evaluation rule_, not the _evaluated expression_.

i want to clarify that i asked this question on several websites on the internet, one of which was on this website. some people answered similar to the answer here, some answered like you did and some answered like @soegaard. and the different answers confused me before.

> [@sschwarzer](#):
>
> I assume the SICP section @soegaard means is this:
> 
> [4.1 The Metacircular Evaluator](https://sarabander.github.io/sicp/html/4_002e1.xhtml#g_t4_002e1) .

> [@soegaard](#):
>
> Wrt the recursive evaluation rule see chapter 4.  
> The core of `eval` looks like this:

i just read the reference, now i quite understand the concept. thanks for helping!
