diff --git a/reference/BasicAlgo/BasicAlgo.cpp b/reference/BasicAlgo/BasicAlgo.cpp index 29efe418c..67750b7fe 100644 --- a/reference/BasicAlgo/BasicAlgo.cpp +++ b/reference/BasicAlgo/BasicAlgo.cpp @@ -24,15 +24,20 @@ CONSOLE_APP_MAIN{ DUMP(decode(2, 1, "one", 2, "two", 3, "three", "?")); DUMP(decode(5, 1, "one", 2, "two", 3, "three", "?")); - Vector empty; - Vector data = { 10, 5, 11, 9, 2 }; - // 0 1 2 3 4 + Vector data = { 10, 5, 11, 9, 2, 11 }; + // 0 1 2 3 4 5 + DUMP(FindIndex(data, 11)); DUMP(FindMin(data)); DUMP(FindMin(data, 0, 4)); DUMP(Min(data)); + + Vector empty; // DUMP(Min(empty)); // This is undefined (fails in ASSERT) DUMP(Min(empty, -99999)); + + DUMP(Count(data, 11)); + DUMP(CountIf(data, [=](int c) { return c >= 5; })); struct { int mul = 1; diff --git a/reference/CoWorkerResources/CoWorkerResources.cpp b/reference/CoWorkerResources/CoWorkerResources.cpp index 009abbdde..036b74203 100644 --- a/reference/CoWorkerResources/CoWorkerResources.cpp +++ b/reference/CoWorkerResources/CoWorkerResources.cpp @@ -7,7 +7,7 @@ struct Model { // some computation model that is not stateless, abstract definit virtual int Compute() = 0; }; -struct Model1 : Model { // concrete model (there would be more) +struct Model1 : Model { // concrete model (there would be more that this one) int n; virtual void Start(int i) { n = i; } @@ -19,9 +19,11 @@ CONSOLE_APP_MAIN Vector data; data.SetCount(3000); + // generate data using some model: + CoWorkerResources> res; for(auto& r : res) - r.Create(); + r.Create(); // all should be the same CoPartition(0, data.GetCount(), [&data, &res](int l, int h) { Model& m = *~res; // gets resource unique for worker diff --git a/reference/CoWorkerResources/CoWorkerResources.upp b/reference/CoWorkerResources/CoWorkerResources.upp index 6a828ecae..7ac2aea93 100644 --- a/reference/CoWorkerResources/CoWorkerResources.upp +++ b/reference/CoWorkerResources/CoWorkerResources.upp @@ -1,3 +1,5 @@ +description "CoWorkerResources provide per-worker-thread context\377"; + uses Core; diff --git a/reference/Format/Format.cpp b/reference/Format/Format.cpp index 385083929..cf31608a1 100644 --- a/reference/Format/Format.cpp +++ b/reference/Format/Format.cpp @@ -34,6 +34,7 @@ CONSOLE_APP_MAIN DUMP(Format("%n", 1234567.89)); DUMP(Format("%,n", 1234567.89)); DUMP(Format("%+n", 1234567.89)); + DUMP(Format("%+n", -1234567.89)); DUMP(Format("%2,n", 123.456)); DUMP(Format("%2,n", 123)); DUMP(Format("%2!,n", 123)); @@ -52,6 +53,7 @@ CONSOLE_APP_MAIN DUMP(Format("%[3%1:one;2:two;3:three;another]s", 20)); DUMP(Format("%month", 6)); + DUMP(Format(LNG_('C','S','C','Z'), "%month", 6)); DUMP(Format("%Month", 6)); DUMP(Format("%MONTH", 6)); DUMP(Format("%mon", 6));