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.
- 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
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.
- 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
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
symbols that tell someone or something exactly what to do, step by step.
the written code a Kani weaver follows to make a pattern.
the designer who first draws the pattern on graph paper.
a small wooden spool carrying one coloured thread. The Kani shawl is named after them.
something that repeats in a way you can predict.
the smallest piece of a pattern that repeats.
an instruction to do the same steps again and again. In Scratch, the repeat block.
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.
Your missions
Draw one tooth
pairs7 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.
Loop it
pairs8 min- 4
Predict: if you repeat the tooth 10 times, how wide will the border be — half the stage, or all of it?
Only you can see this - 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?
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
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.What is a talim?
- AA type of wool
- BA written code that tells a weaver how to make a pattern
- CA kind of loom
- DThe 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?
- Amove
- Bturn
- Crepeat
- Dpen down
4.Match each word to its meaning:
- Naqash
- Talim
- Kani
- Loop
- a small wooden spool of coloured thread
- the code for the pattern
- repeating the same steps
- designs the pattern on graph paper
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) ]
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.