• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision1243c3ba5627ec22a957a30299c1f1e56b1abb86 (tree)
l'heure2024-04-12 06:25:37
AuteurAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Message de Log

Aligned 'TheSieve blog code' with (manual) RPy code [See: Sieve_in_rPython/basic-1]

Change Summary

Modification

diff -r ccf9a61a3c92 -r 1243c3ba5627 CCastle/4.Blog/sieve-castle.irst
--- a/CCastle/4.Blog/sieve-castle.irst Tue Apr 09 22:12:11 2024 +0200
+++ b/CCastle/4.Blog/sieve-castle.irst Thu Apr 11 23:25:37 2024 +0200
@@ -8,6 +8,12 @@
88 implement Generator {
99 int maxValue;
1010
11+ init()
12+ {
13+ .maxValue = -1;
14+ }
15+
16+
1117 StartSieve.newMax(max) on .controll
1218 {
1319 .maxValue := max;
@@ -21,6 +27,7 @@
2127 i:=0;
2228 while (i < .maxValue) {
2329 .outlet.input(i);
30+ i +=1;
2431 }
2532 }
2633
@@ -53,6 +60,11 @@
5360 implement Finder {
5461 int count;
5562
63+ init()
64+ {
65+ .count = 0;
66+ }
67+
5668 SimpleSieve.input(foundPrime) on .newPrime
5769 {
5870 report(foundPrime)
diff -r ccf9a61a3c92 -r 1243c3ba5627 CCastle/4.Blog/sieve-main.irst
--- a/CCastle/4.Blog/sieve-main.irst Tue Apr 09 22:12:11 2024 +0200
+++ b/CCastle/4.Blog/sieve-main.irst Thu Apr 11 23:25:37 2024 +0200
@@ -10,13 +10,11 @@
1010 sub generator;
1111 sub finder;
1212 alias lastSieve; // The list of Sieve's grow dynamically!; keep track of the last one
13- ...
1413
1514
1615 .. code-tab:: ReasonML init()
1716
18- init()
19- {
17+ init() {
2018 super.init();
2119
2220 .generator := Generator();
@@ -28,38 +26,53 @@
2826 }
2927
3028
31- .. code-tab:: ReasonML try()
29+ .. code-tab:: ReasonML finder.found
3230
33- // We have extend the sieve-list (and reconnect) on a newly found prime ..
34- SimpleSieve.try(newPrime) on .finder.found
31+ // We have extend the sieve-list (and reconnect), for every newly found prime.
32+ SimpleSieve.input(newPrime) on .finder.found
3533 {
3634 alias s;
3735
3836 // Extent the sieve-list ...
3937 s:= Sieve(newPrime);
4038 insert_sieve(s);
39+ verifyCorrectPrime(newPrime);
4140 }
4241
42+ .. code-tab:: ReasonML local functions
4343
44- insert_sieve(alias:s)
45- {
46- // Connect s to the lastSieve, or the Generator
47- if (.lastSieve == Ground) { // .lastSieve == Ground, so not connected, so we have the first Sieve to connect to .generator
44+ insert_sieve(alias:s) {
45+ // Connect the input of S to the lastSieve, or to the Generator
46+ if (.lastSieve == Ground) { // .lastSieve == Ground, so not connected, so we have the first Sieve to connect to .generator
4847 .generator.outlet = s.try;
4948 } else {
5049 .lastSieve.coprime = s.try;
5150 }
5251
53- // And to the Finder, that is self
54- s.coprime = .finder.newPrime;
52+ s.coprime = .finder.newPrime; // Connect to output of S to the finder
53+ .lastSieve := s // a new lastSieve
5554 }
5655
56+ verifyCorrectPrime(int:gotPrime) {
57+ local int count:=0; ///Semantics: instance var, with function-local scope
58+ cons PRIMES:= [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
59+
60+ if count >= len(PRIMES) {
61+ print("Warning: Can only check {len(PRIMES)} primes, {gotPrime) is not verified")
62+ return
63+ }
64+
65+ expect := PRIMES[count]
66+ if expect != gotPrime {
67+ printf("ERROR: Prime no {count} should be {expect}, but got {gotPrime}”)
68+
69+ count += 1;
70+
71+
5772 .. code-tab:: ReasonML powerOn()
5873
59- powerOn() // this kick-starts “every main”
74+ powerOn(int:max=10) // this kick-starts “every main”
6075 {
61- int max := 10;
62-
6376 .generator.runTo(max);
6477 }
6578
diff -r ccf9a61a3c92 -r 1243c3ba5627 CCastle/DocParts/Design/50.notes/240408-aigr-machinery.rst
--- a/CCastle/DocParts/Design/50.notes/240408-aigr-machinery.rst Tue Apr 09 22:12:11 2024 +0200
+++ b/CCastle/DocParts/Design/50.notes/240408-aigr-machinery.rst Thu Apr 11 23:25:37 2024 +0200
@@ -46,9 +46,8 @@
4646 send_proto -> DispatchTable
4747
4848 class connection {
49- + out: <outport, component>
50- + in: <inport, component>
51- # protocol <indirect>
49+ + outport: <outport, component>
50+ + inport: <inport, component>
5251 }
5352 note top #aqua
5453 This is the result of
@@ -89,7 +88,6 @@
8988
9089 Event "1".. "*" EventHandler
9190 Event .> Protocol: > part of
92- Protocol ... connection
9391
9492 @enduml
9593