Softanza
StartFrançais
Softanza
The book · Chapter 7 · The proof of each chapter

Declare what, not how

This chapter has 5 cells and writes 11 promises. In each of its four editions its cells were run in one fresh process on 2026-10-08 20:15: English, 5 cells ran, 11 promises kept; Français, 5 cells ran, 11 promises kept; العربية, 5 cells ran, 11 promises kept; Hausa, 5 cells ran, 11 promises kept. The four editions make the same promises, cell for cell. No edition stores any output.

The guard

The course's guard is course_narrated.ring(opens in a new tab): it runs every chapter in all four languages, compares the promises from one edition to the next, and has every exercise prove itself on its wrong and right answers. This page asked the same questions of the same objects, in one process inside the library, at commit 0e72e2e2c. To prove this chapter alone, from your copy of the repository:

cd libraries/stzlib/base/test/education
# run course_narrated with the repository's runtime, for this chapter:
#   course_narrated declare-what-not-how

run on 2026-10-08 20:15 inside the library at commit 4a184e6f0, in 246.4 s for the whole book · The four editions of the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

The reader stores no output, by the course's own law; this page is the record of a run, made for it. The code is shown in Haro's name: where the chapter was written before the language took its present name, the name was changed and nothing else, and the chapter was run again that way. The source link leads to the text as it was written.

The cells, run

Cell 1 · 1. Find where a condition holds

Softanza
o = new stzList([ 4, 7, 10, 3, 8 ])
? @@( o.FindW("{ @item > 5 }") )
#--> [ 2, 3, 5 ]
? @@( o.ItemsW("{ @item > 5 }") )
#--> [ 7, 10, 8 ]
? o.CountW("{ @item > 5 }")
#--> 3
Output of this run
[ 2, 3, 5 ]
[ 7, 10, 8 ]
3

ran: the promise is kept · in all four editions

This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

Cell 2 · 2. Any question can be the condition

Softanza
? @@( o.FindW("{ IsEven(@item) }") )
#--> [ 1, 3, 5 ]
? o.CheckW("{ isNumber(@item) }")
#--> TRUE
Output of this run
[ 1, 3, 5 ]
1

ran: the promise is kept · in all four editions

This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

Cell 3 · 3. A rule is data: keep it, and apply it anywhere

Softanza
cRule = "{ @item > 20 }"
oA = new stzList([ 12, 0, 30, -5, 18, 25 ])
oB = new stzList([ 3, 40, 9 ])
? oA.CountW(cRule)
#--> 2
? oB.CountW(cRule)
#--> 1
Output of this run
2
1

ran: the promise is kept · in all four editions

This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

Cell 4 · 4. Act where the rule holds

Softanza
? @@( oA.ItemsW(cRule) )
#--> [ 30, 25 ]
oA.RemoveW(cRule)
? @@( oA.Content() )
#--> [ 12, 0, -5, 18 ]
Output of this run
[ 30, 25 ]
[ 12, 0, -5, 18 ]

ran: the promise is kept · in all four editions

This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

Cell 5 · 5. The same word on words

Softanza
oS = new stzList([ "haro", "PHP", "C#", "ruby", "GO" ])
? @@( oS.FindW("{ IsUppercase(@item) }") )
#--> [ 2, 3, 5 ]
? @@( oS.ItemsW("{ Q(@item).IsLowercase() }") )
#--> [ "haro", "ruby" ]
Output of this run
[ 2, 3, 5 ]
[ "haro", "ruby" ]

ran: the promise is kept · in all four editions

This cell in the chapter: English(opens in a new tab) · Français(opens in a new tab) · العربية(opens in a new tab) · Hausa(opens in a new tab)

The exercises

Every exercise proves itself: its wrong answers are refused and its right answers accepted.

ex-07-01 · Exercise 7.1 · Where the big amounts are

2 of 2 wrong answers refused, 2 of 2 right answers accepted

01-gives-the-items.ring refused · 02-wrong-boundary.ring refused · 01-find-where.ring accepted · 02-without-braces.ring accepted

The exercise's folder(opens in a new tab)

ex-07-02 · Exercise 7.2 · One rule, two days

2 of 2 wrong answers refused, 2 of 2 right answers accepted

01-two-rules.ring refused · 02-prints-the-rule.ring refused · 01-one-rule-twice.ring accepted · 02-count-the-items.ring accepted

The exercise's folder(opens in a new tab)