# How to evaluate code with function definitions in scribble

**URL:** <https://racket.discourse.group/t/how-to-evaluate-code-with-function-definitions-in-scribble/2888>\
**Category:** Questions & Answers\
**Created:** [April 27, 2024, 4:34am UTC](https://racket.discourse.group/t/how-to-evaluate-code-with-function-definitions-in-scribble/2888 "2024-04-27T04:34:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oomaschloom](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/oomaschloom/32/882_2.png) [@oomaschloom](https://racket.discourse.group/u/oomaschloom)\
**Post date:** [April 27, 2024, 4:34am UTC](https://racket.discourse.group/t/how-to-evaluate-code-with-function-definitions-in-scribble/2888/1 "2024-04-27T04:34:28Z")

</div>

Hi folks,

I can't get an example to evaluate when it has define in it. I've tried lots of stuff. The example in the scribble documentation works, but that uses typed racket. I don't want to use typed racket:

```scheme
@examples[#:eval my-evaluator
          (define (positive-integer? x)
            (and (positive? x)
                 (integer? x)))]

```

Earlier I tried:

```scheme
@examples[#:eval my-evaluator
          (define (positive-integer? x)
            (and (positive? x)
                 (integer? x)))
          (positive-integer? 42)]

```

DrRacket says "examples: exception raised in example  
error: "define: function definitions are not allowed in the interactions window; they must be in the definitions window""

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [April 27, 2024, 4:49am UTC](https://racket.discourse.group/t/how-to-evaluate-code-with-function-definitions-in-scribble/2888/2 "2024-04-27T04:49:22Z")

</div>

I would guess that your `my-evaluator` is configured to run a student language (e.g. Beginning Student Language), which prohibits definitions in the REPL. Maybe try the regular Racket evaluator? E.g. just the plain `(make-base-eval)`.

---

<div class="post-metadata">

**Author:** ![oomaschloom](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/oomaschloom/32/882_2.png) [@oomaschloom](https://racket.discourse.group/u/oomaschloom)\
**Post date:** [April 27, 2024, 4:53am UTC](https://racket.discourse.group/t/how-to-evaluate-code-with-function-definitions-in-scribble/2888/3 "2024-04-27T04:53:04Z")

</div>

Oh good on ya, perfect guess.

Thanks mate.
