Skip to content

Add solution to Exercise 3.12 (append vs append_mutator)#1195

Merged
martin-henz merged 3 commits into
masterfrom
solution/ex-3-12-append-860
Jun 15, 2026
Merged

Add solution to Exercise 3.12 (append vs append_mutator)#1195
martin-henz merged 3 commits into
masterfrom
solution/ex-3-12-append-860

Conversation

@martin-henz

Copy link
Copy Markdown
Member

Adds a <SOLUTION> to Exercise 3.12 (ex:append) in xml/chapter3/section3/subsection1.xml. The exercise asks for the two missing tail(x) responses and a box-and-pointer explanation, and had no solution.

Responses

  • After const z = append(x, y): tail(x) is ["b", null]append copies the pairs of x and does not modify it.
  • After const w = append_mutator(x, y): tail(x) is ["b", ["c", ["d", null]]]append_mutator splices y onto the last pair of x, mutating x.

On the diagram correction

The explanation explicitly notes that the result z shares its last two pairs ["c", ["d", null]] with y (only the pairs holding "a" and "b" are freshly copied) — addressing your comment on the issue that the contributor's first diagram was wrong because it didn't show this sharing. I wrote the solution as prose (matching the JS-focused style of the adjacent ex:mystery solution) rather than embedding the contributed images, since no solution images exist in the repo and the first one was incorrect.

Also

  • Fixed a pre-existing typo in this exercise's printed value of z: ["a", ["b", ["c", ["d, null]]]]["d", null] (missing closing quote; the w value just below already had it right).

Checks

  • XML well-formed.
  • <JAVASCRIPTINLINE> quote style matches the surrounding solutions (literal ").

Closes #860

Adds a SOLUTION giving the two missing responses for tail(x):
["b", null] after append (x is not modified), and
["b", ["c", ["d", null]]] after append_mutator (x's last pair is
spliced to y). The explanation notes that z shares its last two pairs
["c", ["d", null]] with y, addressing the maintainer's correction on
the issue. Also fixes a typo in z's printed value (['d, null] -> ['d', null]).

Closes #860

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a syntax typo in a JavaScript output snippet and adds a detailed solution block explaining the difference between list copying in append and list mutation in append_mutator. The reviewer suggested improving the consistency of the solution block by replacing <P/> tags with blank lines and correcting a minor inaccuracy regarding structure sharing.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread xml/chapter3/section3/subsection1.xml
martin-henz and others added 2 commits June 15, 2026 09:44
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@martin-henz martin-henz enabled auto-merge (squash) June 15, 2026 01:45
@martin-henz martin-henz merged commit d947a6d into master Jun 15, 2026
4 checks passed
@martin-henz martin-henz deleted the solution/ex-3-12-append-860 branch June 15, 2026 01:46
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.

Solution to Exercise 3.12

1 participant