On Apr 16, 2021, at 14:51 PM, Elliot Temple <cu...@curi.us
> On Apr 16, 2021, at 7:28 AM, Justin Mallone <jus...@justinmallone.com
>> I'm confused about something in The Little Schemer Chapter 9.
>> I was gonna write about the substance here, but then I realized I
>> wanted to screenshot images from the book. I decided that posting on
>> my blog and linking the post would be the best solution, so:
>> I tried to go through small parts and say what I did and didn't
>> understand about each.
> It’s hard to tell what you wrote and what’s from the book,
Oh that's useful feedback. I put a black border around my images at some
point to make them stick out on the page more - maybe I should make it
thicker and be more careful about spacing my own text so that it stands
> and also it’d be helpful to state what “shift” and “build”
> do in words. This “shift” appears to be substantially different
> than the ruby function by the same name.
Their description of shift is "The function shift takes a pair whose
first component is a pair and builds a pair by shifting the second part
of the first component into the second component."
So for (shift '((a b) c)) you get (a (b c)) as output,
or for (shift ((a b) (c d)) you get (a (b (c d))) as output.
The code for shift is:
(build (first (first pair))
(build (second (first pair))
I think build is more straightforward - I can use my own words. Build
takes two arguments, and cons'es the first argument onto the result of
cons'ing the second argument onto the empty list:
(lambda (s1 s2)
(cons s1 (cons s2 '()))))