Library learning - Internet Explorer
Address
https://freetolearn.world/library-learning.html
free to learn.world
← Course Directory

AI & engineering · 7 chapters · Free

Library learning

Several small drawing programs repeat the same corner. Turn the repeat into a function, count what the function costs, and check that every program still draws the same path.

Start the course

What you’ll be able to do

  • Predict where a move-and-turn drawing program ends and which way it faces.
  • Write generalize, which turns two programs into one function with parameters for the parts that differ.
  • Write totalCost, which counts each definition once plus every program, calls included, and use it to decide whether the function saves space.
  • Write sameTrace, which checks that a rewrite keeps every drawn segment and the final position and heading.
  • If you choose the library decision project: decide whether one of the supplied functions is worth adding to a set of programs, write the rewrite, and make the decision again on a changed set.

The course checks each of these with cases in your browser or in the downloaded project. Passing them shows that your answer agrees with those cases, not that your code is correct for every input.

Before you start

JavaScript functions, arrays, objects and recursion, and reading a nested array as a tree. No machine learning background. Code runs in your browser; optional project downloads run with Node.js. No account, API key or paid tools.

Time: about 2 to 3 hours. This is the author’s estimate; no learner’s completion time has been measured yet.

Your code, predictions and revisions stay in your browser. Export your notebook to keep a copy.

same_picture.txt - Notepad

A: move(2), turn(1), move(2)
B: move(2), turn(1), move(2), turn(1)

Both draw the same two lines.

Can B replace A?

Add one more move.
Compare the paths.

Give feedback on this course →

Course overviewInternet
Mission.txt - Notepad

Learning without paywalls.

Find what people pay to learn.
Build a great course. Give it away.

One course at a time.

Usage & privacy

Start