Concrete Abstractions: Chapter 6

Exercise 6.23
A three-dimensional (3D) vector has x, y, and z coordinates, which are numbers. 3D vectors can be constructed and accessed using the following abstract interface:

(make-3D-vector x y z)
(x-coord vector)
(y-coord vector)
(z-coord vector)

a. Using this abstract interface, define procedures for adding two vectors, finding the dot-product of two vectors, and scaling a vector by a numerical scaling factor.
b. Choose a representation for vectors and implement make-3D-vector, x-coord, y-coord, and z-coord.

Solution: a.

(define add-vectors
  (lambda (a b)
    (make-3D-vector 
     (+ (x-coord a) (x-coord b))
     (+ (y-coord a) (y-coord b))
     (+ (z-coord a) (z-coord b)))))

(define dot-vectors
  (lambda (a b)
    (+
     (* (x-coord a) (x-coord b))
     (* (y-coord a) (y-coord b))
     (* (z-coord a) (z-coord b)))))

(define scale-vector
  (lambda (a s)
    (make-3D-vector (* s (x-coord a))
                    (* s (y-coord a))
                    (* s (z-coord a)))))

b.

(define make-3D-vector
  (lambda (x y z)
    (cons x (cons y z))))

(define x-coord
  (lambda (a)
    (car a)))

(define y-coord
  (lambda (a)
    (car (cdr a))))

(define z-coord
  (lambda (a)
    (cdr (cdr a))))

This was a quite short chapter. However chapter 7 is rather long. This exercise above covers pretty much the whole chapter, it was just about cons, car and cdr.

#49/111: How to Write & Sell Simple Information for Fun and Profit

What is it about?

Writing a novel and becoming a full-time author is a dream of lots of people. But it is really hard. How about writing a how-to book? Robert W. Bly shows how to write how-to texts and how to market and sell them.

What can I learn?

Research your topic: Before writing your article, blog post or booklet, you should research your topic. You can conduct interviews or read books about this topic. Though, the best thing is to actually do it by yourself. If you want to write an article about fishing, go fishing. If you want to write an article about online marketing, do some online marketing.

Clarity, Concise, Compelling: These are the main guidelines for writing good how-to content. That is, you should write as few words as possible and use a clear structure (headlines, sub headlines, etc.). Furthermore, your content should be easy to read, i.e. no unusual words or too much jargon. Lastly, use examples to give your articles more life.

Break your content down to steps: The last thing to remember is breaking your instruction down to several steps. It’s easier to follow for your readers and supports the structure. In addition, people like lists. Think of Top 3 ways of X, Top 10 Y on twitter or How to eat healthier in three steps.

Conclusion

Originally I read the book because I wanted to know how to improve my writing style. Sadly, only 12 of about 220 pages explain how to write better. The rest is about various formats (books, booklets, articles, etc.) for your content and its marketing. Though, if you want to make money with writing how-to texts this is a great book for you.