{"id":20253716,"url":"https://github.com/willprice/little-schemer","last_synced_at":"2026-02-15T03:31:04.235Z","repository":{"id":66989964,"uuid":"67349810","full_name":"willprice/little-schemer","owner":"willprice","description":"Exercises from The Little Schemer (4th Ed) by Daniel P. Friedman and Matthias Felleisen","archived":false,"fork":false,"pushed_at":"2016-09-26T08:43:54.000Z","size":64,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T08:43:54.407Z","etag":null,"topics":["book","exercise","lisp","little-schemer","racket","recursion","rkt","scheme"],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willprice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-04T14:33:59.000Z","updated_at":"2024-04-14T20:45:31.000Z","dependencies_parsed_at":"2023-05-18T02:30:21.045Z","dependency_job_id":null,"html_url":"https://github.com/willprice/little-schemer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/willprice/little-schemer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willprice%2Flittle-schemer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willprice%2Flittle-schemer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willprice%2Flittle-schemer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willprice%2Flittle-schemer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willprice","download_url":"https://codeload.github.com/willprice/little-schemer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willprice%2Flittle-schemer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29466929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"online","status_checked_at":"2026-02-15T02:00:07.449Z","response_time":118,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["book","exercise","lisp","little-schemer","racket","recursion","rkt","scheme"],"created_at":"2024-11-14T10:27:06.219Z","updated_at":"2026-02-15T03:31:04.218Z","avatar_url":"https://github.com/willprice.png","language":"Racket","readme":"# The Little Schemer\n\n[![Build Status](https://travis-ci.org/willprice/little-schemer.svg?branch=master)](https://travis-ci.org/willprice/little-schemer)\n[![codecov](https://codecov.io/gh/willprice/little-schemer/branch/master/graph/badge.svg)](https://codecov.io/gh/willprice/little-schemer)\n\n[![The Little Schemer](https://mitpress.mit.edu/sites/default/files/imagecache/booklist_node/9780262560993.jpg)](https://mitpress.mit.edu/books/little-schemer)\n\nMany little exercises with little test suites written in [racket](https://racket-lang.org/).\n\n## Types\n\n| Type                    | Parameter name | Description                                                                                                      |\n|-------------------------|----------------|------------------------------------------------------------------------------------------------------------------|\n| *Atom*                  | `a`            | A string of characters (not containing parenthesis or starting with numerics)                                    |\n| *List*                  | `l`            | A series of S expressions separated by spaces enclosed in parenthesis                                            |\n| *Number*                | `n`            | A series of numeric characters (excluding floating point numbers)                                                |\n| *S Expression*          | `sexp`         | Any of the above                                                                                                 |\n| *Flat list*             | `lat`          | A list containing no lists as children                                                                           |\n| *Tuple*                 | `tup`          | A list containing only numbers                                                                                   |\n| *Arithmetic Expression* | `nexp`         | A 3 item list, the 1st and 3rd entries are also `nexp`, the 2nd is an atom representing an operation or a number |\n| *Set*                   | `set`          | A list of atoms containing no duplicates                                                                         |\n| *Pair*                  | `p`            | A list of length 2                                                                                               |\n| *Relation*              | `rel`          | A set of pairs                                                                                                   |\n| *Function*              | `fun`          | A relation where the first element of each pair forms a set                                                      |\n| *Test*                  | `test?`        | A lambda which compares two s expressions for equality                                                           |\n| *Expression*            | `e`            | A S expression representing a computation                                                                        |\n\n### Compound types\nSometimes we write functions with parameters that take multiple types, there are\nsome conventions for these types.\n\n| Paramter naming convention   | Implicit types   |\n| ---------------------------- | ---------------- |\n| `sorn`                       | Symbol, Number   |\n| `pora`                       | Pair, Atom       |\n\n\n## Lambdas\n### Naming conventions\n* `*`-lambdas: Recurse over a list.\n* `multi`-lambdas: Recurse over a list performing an action multiple times.\n* `\u0026co`-lambdas: Recurse over a list performing the collector lambda each time.\n\n### Total vs Partial\n(Relevant from chapter 9 onwards)\n\nTotal functions are guaranteed to terminate however partial functions may not\nterminate. Total functions are referred to as `natural` and partial as\n`unnatural`.\n\n### Primitives\nWe assume the existence of the following functions:\n\n| Function  | Parameters           |\n|-----------|----------------------|\n| `define`  | `(a l)`              |\n| `lambda`  | `(args body)`        |\n| `cond`    | `(((bool) (sexp))+)` |\n| `atom?`   | `(sexp)`             |\n| `eq?`     | `(a1 a2)`            |\n| `null?`   | `(l)`                |\n| `quote`   | `(sexp)`             |\n| `car`     | `(l)`                |\n| `cdr`     | `(l)`                |\n| `cons`    | `(sexp l)`           |\n| `not`     | `(bool)`             |\n| `and`     | `(sexp+)`            |\n| `or`      | `(sexp+)`            |\n| `add1`    | `(n)`                |\n| `sub1`    | `(n)`                |\n| `zero?`   | `(n)`                |\n| `number?` | `(sexp)`             |\n\n\n### Derived\nWe write a lot of functions using the primitive functions we've been given.\n\n#### [Equality lambdas](equality.rkt)\n* `(eq? a1 a2)` - Checks equality of non-numeric atoms. (builtin)\n* `(eqan? a1 a2)` - Checks equality of atoms and numbers.\n* `(eqlist? l1 l2)` - Checks equality of two lists.\n* `(equal? s1 s2)` - Checks equality of two S-expressions. (builtin)\n\n#### [List lambdas](lists.rkt)\n* `(firsts l)`\n* `(length l)`\n* `(rember* a l)`\n* `(occur* a l)`\n* `(insertR* new old l)`\n* `(insertL* new old l)`\n* `(subst* new old l)`\n* `(member* a l)`\n* `(leftmost l)`\n* `(eqlist? l1 l2)`\n* `(third l)`\n* `(evens-only* l)`\n\n#### [Flat list lambdas](lats.rkt)\n* `(lat? l)`\n* `(member? a lat)`\n* `(rember a lat)`\n* `(insertR new old lat)`\n* `(insertL new old lat)`\n* `(subst new old lat)`\n* `(subst2 new o1 o2 lat)`\n* `(multirember new old lat)`\n* `(multiinsertR new old lat)`\n* `(multiinsertL new old lat)`\n* `(multisubst new old lat)`\n* `(pick n lat)`\n* `(rempick n lat)`\n* `(no-nums lat)`\n* `(all-nums lat)`\n* `(occur a lat)`\n* `(multiinsertLR new oldL oldR lat)`\n* `(looking a lat)`\n* `(keep-looking a sorn lat)`\n\n#### [Number lambdas](numbers.rkt)\n* `(+ n m)`\n* `(- n m)`\n* `(× n m)` (note this is a unicode multiplication sign and not the letter x)\n* `(\u003e n m)`\n* `(\u003c n m)`\n* `(= n m)`\n* `(↑ n m)`\n* `(÷ n m)`\n* `(one? n)`\n\n#### [Arithmetic expression lambdas](expressions.rkt)\n* `(numbered? aexp)`\n* `(value nexp)`\n* `(operator nexp)`\n* `(1st-sub-exp nexp)`\n* `(2nd-sub-exp nexp)`\n* `(atom-to-function x)`\n\n#### [Tuple lambdas](tups.rkt)\n* `(tup? l)`\n* `(addtup tup)`\n* `(tup+ tup1 tup2)`\n\n\n#### [Set lambdas](sets.rkt)\n* `(set? lat)`\n* `(makeset lat)`\n* `(subset? set1 set2)`\n* `(eqset? set1 set2)`\n* `(intersect? set1 set2)`\n* `(intersect set1 set2)`\n* `(union set1 set2)`\n* `(intersectall l-set)`\n\n#### [Pair lambdas](pairs.rkt)\n* `(a-pair? x)`\n* `(first p)`\n* `(second p)`\n* `(build s1 s2)`\n* `(revpair p)`\n* `(shift p)`\n* `(length* pora)`\n* `(weight* pora)`\n* `(shuffle pora)` (partial)\n\n\n#### [Relation lambdas](rels.rkt)\n* `(fun? rel)`\n* `(revrel rel)`\n* `(fullfun? rel)` (aka `one-to-one?`)\n\n#### [Higher order lambdas](higher-order.rkt)\nWhere a function returns a function, I have noted the parameters of the\nreturned function after a `-\u003e` followed by a `_` to represent the anonymous\nfunction.\n\n* `(rember-f test?) -\u003e (_ a l)`\n* `(eq-c? a) -\u003e (_ x)`\n* `(insertL-f test?) -\u003e (_ new old l)`\n* `(insertR-f test?) -\u003e (_ new old l)`\n* `(insert-g seq) -\u003e (_ new old l)`\n\n#### [Collector lambdas](collectors.rkt)\n* `(multirember\u0026co a lat col)`\n    * `(a-friend x y)`\n    * `(new-friend x y)`\n    * `(latest-friend x y)`\n    * `(last-friend x y)`\n* `(multiinsertLR\u0026co new oldL oldR lat col)`\n* `(evens-only*\u0026co l col)`\n\n#### [Misc](misc.rkt)\n* `(sero? n)`\n* `(edd1 n)`\n* `(zub1 n)`\n\n#### [Table lambdas](tables.rkt)\n*Tables* are composed of *entries* which are *pairs* of lists (of the\nsame length), the first list is *names*, the second is *values*\nthus representing the binding of names to values.\n\nLookup lambdas take a `-f` lambda that runs in the case the `name` is\nnot found in the entry/table. The lambda is passed the `name` that was\nnot found.\n\n* `(new-entry names values)`\n* `(look-up-in-entry name entry entry-f)`\n* `(extend-table entry table)`\n* `(look-in-table name table)`\n\n\n#### [Interpreter lambdas](interpreter.rkt)\n`e` stands for expression.\n\n![`value` dependencies](./media/value-deps.svg)\n\n* `(value e)`\n* `(expression-to-action e)`\n* `(atom-to-action e)`\n* `(list-to-action e)`\n* `(meaning e table)`\n* `(*const e table)`\n* `(*quote e table)`\n* `(*identifier e table)`\n* `(*lambda e table)`\n    * `(table-of non-primitive-lambda)`\n    * `(formals-of non-primitive-lambda)`\n    * `(body-of non-primitive-lambda)`\n* `(*cond e table)`\n* `(*application e table)`\n    * `(function-of e)`\n    * `(arguments-of e)`\n* `(primitive? lambda-meaning)`\n* `(non-primitive? lambda-meaning)`\n* `(initial-table name)`\n* `(evcon lines table)`\n* `(evlis args table)`\n* `(apply-primitive name vals)`\n* `(apply-closure closure vals)`\n* `(apply fun vals)`\n\n## Contributing\n* Fork the repository.\n* Add function(s) with associated test suite(s).\n* Run tests with\n```\n$ ./test.sh\n```\n* Add an entry to the README with the function, it's signature and purpose.\n  Hyperlink the function name to the source of the function.\n* Commit with a description of the function added.\n* Rebase onto the main branch.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillprice%2Flittle-schemer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillprice%2Flittle-schemer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillprice%2Flittle-schemer/lists"}