Class 6 · Unit 5: Computational thinking · Lesson 5.2 · 40 min
The weaver's code
An old man reads out numbers — "three of red, two of green…" — and a weaver builds a shawl from them. Kashmiri weavers were running code long before computers.
Today you will: Find the part of a pattern that repeats · Write it as a short code, like a talim · Make Scratch draw a border with one loop
Story
In a small workshop in Kanihama, near Srinagar, a weaver sits at a wooden loom. He does not look at a picture of the shawl. Instead, an older man sits beside him and reads aloud from a paper full of numbers and signs.
He calls out: "Three of red, two of green, three of red…"
The paper is called the talim. A designer, the naqash, first draws the pattern on graph paper. Then a specialist turns the drawing into a code: which colour, and how many threads, in each row. The weaver follows the code row by row, using small wooden spools called kanis, each carrying a different coloured thread. That is how a Kani shawl gets its name.
Kashmiri weavers were following written instructions to build a pattern long before computers existed. That is exactly what a computer program is.
Watch
The talim: Kashmir's oldest computer code? — scan code 6.5.2 in the printed book.
Learn it
The weaver in Kanihama does not look at a picture of the shawl. He follows the talim, a written code that says which colour and how many threads, row by row. A computer program works the same way: a list of exact instructions. Shawl borders repeat, so the code does not write the same piece a hundred times. It writes the smallest piece once and says repeat it. In programming that is called a loop.
Words to know
- Code symbols that tell someone or something exactly what to do, step by step.
- Talim the written code a Kani weaver follows to make a pattern.
- Naqash the designer who first draws the pattern on graph paper.
- Kani a small wooden spool carrying one coloured thread. The Kani shawl is named after them.
- Pattern something that repeats in a way you can predict.
- Repeating unit the smallest piece of a pattern that repeats.
- Loop an instruction to do the same steps again and again. In Scratch, the
repeatblock.
Step by step: from border to code
Look at this border: red red green red red green red red green red red green
- Find the repeating unit: red red green. That is the smallest piece that repeats.
- Count the repeats: it appears 4 times.
- Write it as a talim:
4 × [red, red, green]. That is one short line instead of twelve colours. - Write it as a program:
repeat 4: draw red, draw red, draw green.
One unit, repeated by a rule. The khatamband ceilings from Lesson 3.2 work the same way, and AI starts by finding patterns in data, the way a weaver reads a design.
Careful: the unit must be the smallest piece that repeats. red red green red red green also repeats, but it is two units joined together. A loop of the smallest unit is shorter and easier to change.
On the laptop
You need: Scratch Desktop (offline, no account) — or scratch.mit.edu without signing in
Mission 1: Draw one tooth (pairs, 7 min)
- ☐1
Open Scratch. Click Extensions (bottom left) and add Pen.
- ☐2
Under when green flag clicked, drag in:
erase all→go to x: -220 y: 0→pen down→set pen size to 4. - ☐3
Add one zig-zag tooth:
set pen color to (red)→move 20→turn ↺ 45→move 15→turn ↻ 90→move 15→turn ↺ 45. Click the flag — that's your repeating unit.
Mission 2: Loop it (pairs, 8 min)
- ☐4
Predict: if you repeat the tooth 10 times, how wide will the border be — half the stage, or all of it?
- ☐5
Wrap the tooth blocks inside repeat (10). Run it. You have a border!
- ☐6
Inside the repeat, add
change pen color by (20)so the teeth change colour. - ☐7
Write your talim in a comment (right-click → Add Comment), e.g.
10 × [ red 20, up 15, down 15 ]. Swap laptops: can the next pair say what your border looks like before clicking the flag?
Finished early?
Add a second repeat that draws a matching border below the first (hint: go to x: -220 y: -40).
No laptop today?
On squared paper, colour a 3-square unit (red, red, green). Write its talim: 3 × [red, red, green]. Swap
with a partner — can they weave your border from the code alone?
Debate it
A computer can now copy any shawl pattern in seconds, and machines can weave fast. What is lost if the talim and the weavers who read it disappear? What does a person bring that a machine cannot?
Check yourself — practice, not a test
1. What is a talim?
- ○ A type of wool
- ○ A written code that tells a weaver how to make a pattern
- ○ A kind of loom
- ○ The name of a shawl colour
2. The smallest part of a pattern that repeats is called the repeating ______.
3. Which Scratch block makes the same steps happen many times?
- ○ move
- ○ turn
- ○ repeat
- ○ pen down
4. Match each word to its meaning:
Naqash · Talim · Kani · Loop
Match with: a small wooden spool of coloured thread · the code for the pattern · repeating the same steps · designs the pattern on graph paper
Remember
Find the part that repeats, write it once, and let the loop do the rest.
Typing practice
Practise top-row letters and brackets, because code uses symbols.
- typing.com: Beginner → Top row lessons
- Then type this line three times without mistakes:
repeat (10) [ move (20) turn (90) ]