# Create library for exercises in Concrete Abstractions, Chapter 2, Recursion

**URL:** <https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646>\
**Category:** General\
**Created:** [January 5, 2024, 8:21am UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646 "2024-01-05T08:21:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartoffel](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/kartoffel/32/1620_2.png) [@Kartoffel](https://racket.discourse.group/u/Kartoffel)\
**Post date:** [January 5, 2024, 8:21am UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/1 "2024-01-05T08:21:15Z")

</div>

I would like to create a library with my own factorial, in order to call it when I need it without writing again or copying again the code.

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/9/9f01bd6050cc940f08f659714b0744e529d757c4.png)

How should I save it, and how do I have to import it where I will need it (compiler lines such import / provide)?

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [January 5, 2024, 12:26pm UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/2 "2024-01-05T12:26:48Z")

</div>

1. Save as factorial.rkt.

2. Add `(provide factorial)`

3. Use `(require factorial)`

(But I notice that there’s no language specified. Are you using the Teaching languages?)

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [January 5, 2024, 5:54pm UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/3 "2024-01-05T17:54:47Z")

</div>

The `(require factorial)` would only work if it's `main.rkt` in a `factorial` collection. If it's not part of a collection, `(require "factorial.rkt")` works in the same directory. More at [https://docs.racket-lang.org/guide/module-paths.html](https://docs.racket-lang.org/guide/module-paths.html) (Guide).

---

<div class="post-metadata">

**Author:** ![Kartoffel](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/kartoffel/32/1620_2.png) [@Kartoffel](https://racket.discourse.group/u/Kartoffel)\
**Post date:** [January 5, 2024, 9:31pm UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/4 "2024-01-05T21:31:06Z")

</div>

I would like to start putting the file providing the factorial in the same folder where the program that requires has its place.

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/3/3df00d687c650e7c6065050dd8f7b20989e9e444.png)

Here is the result

 ![Help](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/5/5aed76e946a78b5c2cb49a7e63ab1aa44647c029.jpeg)

---

<div class="post-metadata">

**Author:** ![Kartoffel](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/kartoffel/32/1620_2.png) [@Kartoffel](https://racket.discourse.group/u/Kartoffel)\
**Post date:** [January 5, 2024, 9:35pm UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/5 "2024-01-05T21:35:36Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/3/3917622901d90f1bb29143e85afc36aa4425a9d6.png)  
Both files saved as indicated. Error persists.

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [January 5, 2024, 10:01pm UTC](https://racket.discourse.group/t/create-library-for-exercises-in-concrete-abstractions-chapter-2-recursion/2646/6 "2024-01-05T22:01:06Z")

</div>

`(require “factorial.rkt”)`
