Program By Design - Functional Programming, Computing and Algebra

Functional Programming, Computing and Algebra

The starting point of ProgramByDesign is the observation that students act as computers in grade school courses on arithmetic and middle/high school courses on pre/algebra. Teachers program them with rules and run specific problems via exercises. The key is that students execute purely functional programs.

If we can turn students into teachers that create functional programs and run them on computers, we can reinforce this content and show students how writing down mathematics and how writing down functional programs creates lively animated scenes and even computer games.

Here is an example:

(require 2htdp/universe) (require 2htdp/image) ;; create an image from the current time (define (create-image t) (place-image APPLE 50 (* 1/10 t t) SPACE)) ;; names for basic images (define APPLE (circle 3 "solid" "red")) (define SPACE (empty-scene 100 100)) (animate create-image)

This short program simulates an apple falling from the top to the bottom of a small white canvas. It consists of three parts:

  • a function definition for create-image, which is a one-line function in mathematics, assuming an algebra of images with place-image, circle, and empty-scene have been introduced;
  • two abbreviations, where names are equated with some value, just as in "let x be 5" in an algebra text; and
  • one line for running the program.

A teacher can explain create-image as easily as any ordinary function in an algebra course. For example, one can first draw a table with two rows and n columns where each column contains t at the top and an appropriate image at the bottom. That is, if the numbers increase from left to right, then on each image the red dot is a little bit lower.

Finally the animate line applies the given function, create-image, at the rate of 28 ticks per second to 0, 1, 2, 3, and so on. The resulting images are displayed on the computer monitor at the same pace. That's how movies are made.

The background needed for such an example is little more than knowledge about making movies, about the algebra of pictures in DrRacket (which is like the one for numbers), and minimal pre-algebra. The ProgramByDesign project claims, however, that children would have more fun with such "live" functions than with algebraic expressions that count the number of garden tiles .

The ProgramByDesign project proposes that both traditional mathematics as well as science courses could benefit from an integration of this form of programming. In contrast to the traditional Basic or Visual Basic blocks in such books, a Racket program consists of as many lines as the mathematics. Moving between the mathematics and the program is thus straightforward. Better still, the meaning of the two are the same. DrRacket's algebraic stepper can illustrate how Racket evaluates the program as if it were a sixth or seventh grade student, step by step, using plain algebra.

Read more about this topic:  Program By Design

Famous quotes containing the words functional and/or algebra:

    Stay-at-home mothers, . . . their self-esteem constantly assaulted, . . . are ever more fervently concerned that their offspring turn out better so they won’t have to stoop to say “I told you so.” Working mothers, . . . their self-esteem corroded by guilt, . . . are praying their kids turn out functional so they can stop being defensive and apologetic and instead assert “See? I did do it all.”
    Melinda M. Marshall (20th century)

    Poetry has become the higher algebra of metaphors.
    José Ortega Y Gasset (1883–1955)