# SICP: Section 2.2.2

The sections introduces us to trees using pairs as the underlying structure.

### Section example

Each exercise of SICP makes me think more about recursion. The following exercise made me think more about how to model recursion and what the returns are to be when recursing multiple layers inside a tree.

### Exercise 2.31

Exercise 2.32 could have been written better if currying was available. I am not sure whether scheme supports currying functions, and hence the regular lambda expression.

# SICP: Section 2.2.1

Exercise 2.20 deals with functions that take arbitrary number of arguments. This is extremely useful in the context of scheme because it allows you to use less brackets :).

### Exercise 2.20

I used reverse followed by the same-parity-iter because I did not want to use the inefficient append function.

The sections also introduces us to the map higher order function.

But why map? Quoting SICP

The different between the two definitions is not that the computer is performing a different process (it isn’t) but that we think about the process differently. In effect, map helps establish an abstraction barrier that isolates the implementation of procedures that transforms lists from the details of how the elements of the list are extracted and combined.

This is the most succint way to put across the need for abstractions. Abstractions are invented to help us think differently and care about different things.

### Exercise 2.22

Interchanging the arguments of cons does not work as it will generate a list of lists instead of generating a single list.

# Starting SICP

I recently got gifted the book Structure and Interpretation of Programs(SICP) on my birthday. I have had a long desire to go through the complete book and complete all the exercises. Inspired by Eli Bendersky’s, I am going to spend the next 6 months or maybe a year going through the book. I have already finished the first chapter of the book. Hence I will be blogging only from chapter 2. I am going to follow the plan laid out by Eli Bendersky, the plan being

• See all the video lectures by Sussman and Abelson
• Do all the exercises in the book.
• Write about the exercises and the things that I have learnt from it.

# GSoC Last Week

This happens to be the last week of GSoC. The major things that I accomplished this week are

• Got pylab to work interactively.
• Made more changes to the documentation of plotting module.

I have a pull request for the restructured plotting module at here. There has been lots of discussions on how the new plot API should look like in the pull request. The API as of now has 5 functions:

• plot_line which plots 2D line plots, which I think I will change to plot.
• plot_parametric which plots 2D parametric plots.
• plot3D which plots 3D plots.
• plot3D_parametric which plots 3D parametric line plots. I think I will have to change it into plot_parametric3D.
• plot3D_surface which plots 3D parametric surfaces.

The names are slightly confusing, but the alternative to these names are big. If you have any good names for 3D plots, please leave it in the comments.

I will have another post describing the things I learnt over this GSoC period.

# GSOC Week 11

I got my adaptive sampling branch merged last week. Now the plots are sampled adaptively and is more accurate. I also added a lot of tests to the implicit plotting branch and the coverage now is greater than 90%.

One of the major things decided in the previous week was to restructure the plot function. Presently plot is a single function, which depending on its input, renders an 2d or an 3d plot. Though it plots the right kind of plot, the plot function is quite complex and it was decided to split the plot function into smaller functions that plots a particular type of plot. I tried an approach where all 2D plots are plotted by a plot2d function, the 3D plots by plot3D and the existing plot_implicit plots to plot regions and implicit equations. Aaron mentioned that the API is still very complex as I was using tuples and lists to differentiate between a parametric plot and a 2d line plot and he was right. It is a bit complex and it was decided to have a functions for each kind of plot.

I think i can have the new plot functions as an PR by next week and I would like to try getting a Mayavi backend ready by the end of my GSoC period.

I forgot to mention why I deviated from my what I said I would do in my GSoC application. I tried getting a svgfig backend ready for almost one and a half week, and it was quite difficult. svgfig is not being updated and I had a hard time getting the axis ticks labelling to work most of the time. I wrote to the project maintainer many times and he helped me with a lot of things, but the library was not polished enough to use it with Sympy Live. So plotting for SymPy Live should be attempted with a javascript plotting library rather than a python backend. If we get matplotlib support on GAE, then it would be awesome.