Skip to content

Add anonymous functions (lambda) to the functional programming chapter - #40

Merged
d-morrison merged 6 commits into
mainfrom
claude/project-thread-slhcky
Oct 29, 2026
Merged

d-morrison merged 6 commits into
mainfrom
claude/project-thread-slhcky

Conversation

@d-morrison

@d-morrison d-morrison commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Why

Ezra asked to bring Stanford's old functional programming material into CSCI 201. The chapter stopped at map and filter; lambda is the next step, and the Racket labs and the mcsg practice handout use it.

The Stanford sources and their licenses:

  • CS 107 (Jerry Cain, 2008, on SEE): course materials are CC BY-NC-SA, per Creative Commons' 2008 announcement. That is incompatible with this MIT-licensed repo, so CS 107 is linked, not adapted.
  • CS 242 (Fall 2019): no license, so linked only.
  • CS 99: CC BY-NC-SA, so linked only.
  • CS 258: has nothing online beyond a 1988 outline.

What

A new section, Anonymous functions (#sec-lambda-let), at the end of chapters/functional-programming.qmd:

  • an exercise and solution, pair-with, which is new: a map whose lambda uses a parameter of the enclosing function;
  • a definition of lambda, including that (define (f x) body) is shorthand for (define f (lambda (x) body)), followed by a video note linking CS 107 Lecture 22;
  • a remark on where the name comes from (the lambda calculus), citing and linking Will Crichton's CS 242 notes;
  • an example of a function that returns a function (adder).

Every stated return value was checked in Racket 8.

Follow-up

The planned follow-up (apply, let, a Scheme-to-Racket remark and more video links) will be written new, with CS 107 linked rather than adapted.

Checks

  • Rendered to HTML locally: no unresolved references, and check-rendered-page.py is clean. PDF and docx are left to CI, since this container has no TeX.
  • An adversarial subagent review and two rounds of Claude review were addressed. Round 2 corrected the license; see the PR comments.

🤖 Generated with Claude Code

https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch

…chapter

Stanford's CS 107 (Jerry Cain, Spring 2008) taught Scheme with free
lectures and handouts under CC BY 3.0 US. The chapter stopped at map and
filter; CS 107's handouts go on to lambda, functions that return
functions, apply and let, which students need for the Racket labs.

The new section adapts Cain's `translate` (as `shift-all`) and `average`,
with visible Source notes that link the license and say what changed,
and puts each CS 107 lecture video beside the item it supports.
A remark maps Scheme names to Racket's, and a further-reading remark
links CS 242's lambda calculus notes and CS 99 (Lean), linked rather
than adapted because neither license allows it here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch
…m further reading

The remark named cond, first and rest before the chapter defines them,
and its further-reading list pointed at worked solutions to the Lab 3
and Lab 4 topics (power sets, sorting).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch
The branch was over the PR size cap; this PR keeps lambda and
functions that return functions, and the rest follows once it merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@d-morrison d-morrison self-assigned this Oct 29, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…the wordlist

The 2008 SEE course package states CC BY 3.0 US on every page; SEE's
current default, CC BY-NC-SA 4.0, applies only where nothing else is
stated, and a CC license already granted cannot be withdrawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:24

Copy link
Copy Markdown
Contributor Author

Replies to the review, addressed in fd55384:

License (blocking): rebutted, with the source of the license now stated. The SEE FAQ's CC BY-NC-SA 4.0 is a default that applies only "unless otherwise expressly indicated". The 2008 CS 107 course package from SEE expressly indicates otherwise. Its index, lecture list, handouts, assignments, exams and resources pages each carry "This work is licensed under a Creative Commons Attribution 3.0 United States License", linking https://creativecommons.org/licenses/by/3.0/us/. Today's course page states no license of its own. A CC license, once granted, cannot be withdrawn for material already released under it, so the handouts remain usable under CC BY 3.0 US. The bib note and the Source note now say the license comes from the 2008 SEE course package. CS 99 is different: its current site states CC BY-NC-SA 4.0 on its own page.

Wordlist: fixed. Added Cain, Crichton and Stanford to inst/WORDLIST.

Media line outside the remark div: kept as is. The lab's rule for lecture notes puts each video or media link "in a short note right after the exercise, figure or definition it supports", not inside it. The subfile still holds one div, plus that note.


Posted by Claude Code (AI agent) --- not written by a human.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…nstead

The reviewer was right: Creative Commons' 2008 announcement of SEE says
the course materials are CC BY-NC-SA and only the general site content is
CC BY, and the CC BY badge in the 2008 package is the site footer. A
NonCommercial-ShareAlike adaptation cannot go into this MIT-licensed
repository, so shift-all (from Cain's translate) is replaced by a new
exercise, pair-with, and CS 107 is only linked, beside the lambda
definition. Also splits the comma splice in the lambda-calculus remark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9rJjY4bCnfxuBmX2Ch
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:28

Copy link
Copy Markdown
Contributor Author

The second review is right, and I withdraw my earlier rebuttal. Creative Commons' 2008 announcement of SEE says "All course materials are open for re-use under CC BY-NC-SA. The general site content on Stanford Engineering Everywhere is licensed CC BY." The CC BY badge I relied on is the page footer of the 2008 package, which is site content. The handout PDFs themselves carry no license.

A NonCommercial-ShareAlike adaptation can't go into this MIT-licensed repo, so e1a8580 does the following:

  • replaces shift-all (adapted from Cain's translate) with a new exercise, pair-with;
  • removes the adaptation claim from the chapter's Source note;
  • links CS 107 Lecture 22 beside the lambda definition, as a video note only;
  • splits the comma splice in the lambda-calculus remark.

The *Media:* line outside the remark div stays where it is, per the lab rule that each media link goes in a note right after the item it supports.


Posted by Claude Code (AI agent) --- not written by a human.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@d-morrison d-morrison changed the title Add anonymous functions (lambda) to the functional programming chapter, adapted from Stanford CS 107 Add anonymous functions (lambda) to the functional programming chapter Oct 29, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

Copy link
Copy Markdown
Contributor

Claude finished review — View run


Everything checks out. This round fully resolves both outstanding issues from the prior reviews.

Review: PR #40 — Add anonymous functions (lambda) to the functional programming chapter

What changed since the last round

Prior rounds reviewed up through commit e1a85806 (which itself landed mid-review: "Replace the CS 107 adaptation with a new exercise; link the lecture instead"). Since then, the only PR-authored change is a5b1d1b, "Keep each media note inside its div, so each subfile holds exactly one div," plus a merge commit (7dd75ce) that pulls in already-merged main (2e1084e, PR #39's sidebar change — not part of this PR's diff).

Resolved: license on the adapted exercise

The blocking finding from the first two rounds — that shift-all adapted Jerry Cain's CS107 handout under a misidentified CC BY 3.0 US license when SEE materials are actually CC BY-NC-SA — is now fully resolved:

  • _shift-all_exr.qmd and _shift-all_sol.qmd are deleted (confirmed gone from the working tree).
  • references.bib's cain2008cs107 entry is gone; replaced by cain2008cs107videos, which cites only a YouTube lecture (no adaptation claim).
  • CS107 is now only linked, not adapted: _lambda_def.qmd:21 — "Video: Jerry Cain uses lambda with map in Scheme... in [Stanford CS 107 Lecture 22]" — treating it the same "link only" way the PR already treated CS99/CS242.
  • functional-programming.qmd's Source note now accurately says "this chapter, its examples and its exercises are new" — true now that the only adapted content is gone, replaced by an original exercise, pair-with.
  • Both new URLs (stanford-cs242.github.io/f19/lectures/..., the YouTube video) resolve with HTTP 200.

Resolved: structural inconsistency in _lambda-calculus_rem.qmd

a5b1d1b moves the *Media:* line back inside the #rem-lambda-calculus div (and the *Video:* line in _lambda_def.qmd likewise), matching every sibling subfile's one-div-per-file convention. Verified in both files directly.

Other verification

  • check-unresolvable-refs.py passes clean on the full repo (771 files, no unresolvable cross-references) — all new refs (@def-lambda, @exr-pair-with, @sol-pair-with, @rem-lambda-calculus, @exm-adder) resolve.
  • inst/WORDLIST additions (Cain, Crichton, Stanford) are correctly placed in the file's existing ASCII-case sort order (all-caps/mixed-case block before lowercase block) — not out of order for this file's actual convention.
  • Hand-checked all Racket results in the new content: ((lambda (x) (* x x)) 7) → 49, (map (lambda (x) (* 2 x)) (list 1 2 3)) → '(2 4 6), (pair-with (list 1 2 3) "a") → '((1 "a") (2 "a") (3 "a")), ((adder 3) 4) → 7, (twice (adder 3) 10) → 16 (using twice's (f (f x)) definition), (map (adder 1) (list 5 7 9)) → '(6 8 10). All correct.
  • No non-standard characters introduced by this PR's files.
  • Bullet/numbered lists in the new subfiles all have a blank line before them.

No new issues found. This confirms the finding from the prior round (second review, posted 2026-10-29T20:26:59Z, #40) that the license attribution needed fixing — the author's follow-up commit e1a85806 did fix it by removing the adaptation entirely rather than re-licensing it, which fully addresses that concern.

Verdict

Ready for merge

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "7dd75cea18d9ae87c0e834a4192f65bbd7f36256",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "Checked chapters/functional-programming.qmd, the new _pair-with and _adder subfiles, references.bib, and inst/WORDLIST; the previously flagged shift-all license misattribution is gone because the adapted exercise was deleted and replaced with original content.",
  "holistic_assessment": "Cross-reference resolution, wordlist CI risk, link validity, and licensing scope concerns from prior rounds are all resolved with no new regressions introduced by the merge or media-note-placement commit."
}

Reviewed commit: a5b1d1b

@github-actions

Copy link
Copy Markdown
Contributor

💰 Cost: $0.5466 (review) — run

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.

2026-10-29 20:51 UTC

Copy link
Copy Markdown
Contributor Author

Merge note: check-pr-fully-clean.py reports this PR fully clean on head a5b1d1b, with a clean Claude review of that head and all 28 checks green. A cross-model review was not possible from this cloud session: opencode.ai returned 429 for the free model, so that review is waived. Ezra granted mwc in the project thread.


Posted by Claude Code (AI agent) --- not written by a human.


Generated by Claude Code

@d-morrison
d-morrison merged commit 4f1d435 into main Oct 29, 2026
28 checks passed
@d-morrison
d-morrison deleted the claude/project-thread-slhcky branch October 29, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants