Your Turn!
Now it’s your turn. Download this document for a recap of the blocks we covered in this lesson and some hands-on exercises for you to explore.
What You Have Learned in This Lesson
In this lesson you have learned about different programming paradigms.
A programming paradigm is a high-level approach to designing and coding a program. It describes the overall style of structuring and implementing a solution, including which programming language or features of a programming language are used to build it.
Imperative programming
In the imperative programming paradigm, you work with explicit step by step instructions (commands) to describe how a program should operate.
You use control structures like loops and conditionals to manage the execution flow of your program. Imperative programs often have state changes, meaning that e.g. variable values are updated (mutated) or attributes of an object change while a program is running.
The example for an imperative program in this lesson was Alonzo visiting his friends.
The actions are performed sequentially using the for each loop. You can see the result of each step of the computation happening on the stage as Alonzo is changing his position.

Functional programming
The functional programming paradigms treats functions as first-class (also check Unit 2 Lesson 1 and 2) – they can be used as an input or output to another function and can be assigned to variables.
You construct programs by nesting functions and applying them to values. The outcome of a program written with the functional programming paradigm is the result of a series of function evaluations performed on the start value.
Functional programs avoid state and mutable data.
In this lesson you saw the example of map and keep– two higher order functions (HOFs) often used in functional programming. A higher order function is a block that takes a function as an input or reports a function as an output.
Using the map block with the distance to _ function on the list of Alonzo’s friends (my other sprites) resulted in a new list containing the distance value from Alonzo to each other sprite.

Keeping the friends whose distance to Alonzo is smaller than 150 steps filtered the list of all friends and reported a new list containing just the ones for which the condition returns true.

Hyperdimensional programming
Hyperdimensional programming is an approach often used in data science and for artificial intelligence. Information is represented as vectors (lists in Snap!) and functions can directly operate on those vectors; processing entire sets of values in one step.
In the video hyperdimensional programming was visualized through the custom average block. If you put in a list of numbers, the average block will report a single number, the arithmetic mean of the numbers in the input list. If you input a table (e.g. like the position of my other sprites), it reports a list, each item in that list being the arithmetic mean of the corresponding column of the original table.
