Why School is like Functional Programming

Filter, Map, Reduce: A Metaphor for Education

Nuwan I. Senaratna
On Economics

--

Think of 5 single-digit numbers.

Let’s suppose they are,

nums = [1, 4, 2, 3, 2]

Let’s imagine that these 5 numbers represent 5 students who are about to enter school.

Suppose the higher numbers represent the kind of students that schools like to admit, perhaps because they are smart, or well behaved, or have the right sort of parents. And similarly, the lower numbers represent the opposite.

Filter

Most schools have some sort of admissions criteria, interviews, and often only select a subset of the candidates who have applied. In our example, let’s assume that only students numbered 2 or greater are selected.

In programming (as in real life), this process is known as “filtering”. “Filter” (along with “Map” and “Reduce”, which we will come to soon) belong to a branch of programming called Functional Programming.

I won’t go into the details, but in the programming language Python, we can filter all the numbers in our list that are 2 or greater as follows:

list(filter(lambda x: x >= 2, nums))
>> [4, 2, 3, 2]

As you can see, the unfortunate “1” is removed from the list.

You don’t need to know how functional programming or Python works. The important thing to remember is there is such a thing as filtering.

Map

Most of us would agree that school is beneficial, and that when students exit school they are in better shape (educationally) than when they entered. For example, a student that entered as a “3” might exit as a “6”, and similarly for all the students.

In programming, we can take a list of numbers, and “map” these to another set of numbers. For example, suppose “school” doubled the “number” of all the students.

list(map(lambda x: x * 2, nums)
>> [8, 4, 6, 4]

Obviously, this is a very crude simplification. School will affect different students in different ways, chance and randomness will play its part, and there are billions of factors at place, not just a single number.

But as before, the important thing to keep in mind is that programming includes the concept of “mapping”. And similarly, school is, in a sense, a process of “mapping” a student into a different sort of student.

Reduce

Finally, after many years of education, the students are ready to leave school. They might seek employment, or further education, say at university. Most educational systems have a “big exam” at the end of the road — “Advanced Levels” in the case of Sri Lanka, and many other places.

Not everyone passes the “big exam”, and even if they do, not everyone will pass well enough to get a place on the next rung of the ladder (e.g. University). In a sense, “big exams” take a bunch of students and “reduce” them into a smaller set of students.

For example, in our set of 4 students, perhaps only one has a place at university.

As you might have guessed, programming has a concept of “reducing”. The following snippet of python code reduces out list of students and finds the “best” student.

from functools import reduce
reduce(lambda a, b: a if a > b else b, nums)
>> 8

Apologies and Questions

You might think this “Filter, Map, Reduce” metaphor is simplistic, trivial, or even frivolous. And, I agree, it is all of these things.

But then, like many metaphors, it does motivate us to ask some interesting questions.

  1. Do we really need Filtering at the beginning? Don’t all students deserve an education? Also, isn’t Filtering a good way for schools and other educational institutions to be lazy? After all, if you just filter the good students, then you don’t really have to do much do you?
  2. Also, doesn’t Filtering promote Elitism? Where schools turn into “clubs” for a certain type of student, or one with a certain type of parent? More generally, does the “filtering” process at the beginning create a bias that persists throughout the education system? How can we ensure equal opportunities for all students? How can we improve the “filtering” process to identify potential rather than just current ability or socio-economic status? How does the “filtering” process affect the diversity of the student body, and consequently, the richness of the learning environment?
  3. Do schools really “map” students into better students? Or are they simply running on luck and advantageous filtering? Do we rigorously measure the value add that schools produce? And the exact nature of the “mapping function”? Is the “mapping” process in schools transparent and accountable? How can parents and students be more involved in this process?
  4. Is the “mapping” process in schools standardized or personalized? Should it be more tailored to individual students’ needs and abilities? Does the “mapping” process in schools adequately prepare students for the real world, or is it actually too focused on “reducing”?
  5. How does the existence of a “reducing” process impact students’ self-esteem and future opportunities? Is there a fair and comprehensive evaluation method? What is its opportunity cost? How can we make the “reducing” process less stressful and more supportive for students, while still maintaining high standards?
  6. Is the “reducing” process too focused on academic performance? Should it consider a broader range of skills and talents? How can we ensure that the “reducing” process in schools doesn’t just enhance academic skills but also incentivizes social, emotional, and practical skills?
DALL.E

--

--

Nuwan I. Senaratna
On Economics

I am a Computer Scientist and Musician by training. A writer with interests in Philosophy, Economics, Technology, Politics, Business, the Arts and Fiction.