euler trace of Graham's :maxTemperature and :meanValue test cases

C:\temp>java euler.EulerRunner testP testC
 {_:weatherToday_1 :hourlyTemperatures _:362000_1.
   {_:362000_1 rdf:first "10"^^xsd:integer.
    _:362000_1 rdf:rest _:2398389_1.
     {_:2398389_1 rdf:first "12"^^xsd:integer.
      _:2398389_1 rdf:rest _:2468673_1.
       {_:2468673_1 rdf:first "15"^^xsd:integer.
        _:2468673_1 rdf:rest _:933472_1.
         {_:933472_1 rdf:first "16"^^xsd:integer.
          _:933472_1 rdf:rest _:2172400_1.
           {_:2172400_1 rdf:first "14"^^xsd:integer.
            _:2172400_1 rdf:rest _:4312351_1.
             {_:4312351_1 rdf:first "17"^^xsd:integer.
              _:4312351_1 rdf:rest _:110499_1.
               {_:110499_1 rdf:first "13"^^xsd:integer.
                _:110499_1 rdf:rest _:3274522_1.
                 {_:3274522_1 rdf:first "12"^^xsd:integer.
                  _:3274522_1 rdf:rest _:5636586_1.
                   {_:5636586_1 rdf:first "10"^^xsd:integer.
                    _:5636586_1 rdf:rest _:1561175_1.
                     {_:1561175_1 rdf:first "9"^^xsd:integer.
                      _:1561175_1 rdf:rest _:7494106_1.
                       {_:7494106_1 rdf:first "7"^^xsd:integer.
                        _:7494106_1 rdf:rest _:6893794_1.
                         {_:6893794_1 rdf:first "6"^^xsd:integer.
                          _:6893794_1 rdf:rest rdf:nil} =>
                        {_:6893794_1 :maxNumber "6"^^xsd:integer}.
                        "7"^^xsd:integer math:greaterThan "6"^^xsd:integer}
=>
                      {_:7494106_1 :maxNumber "7"^^xsd:integer}.
                      "9"^^xsd:integer math:greaterThan "7"^^xsd:integer}
=>
                    {_:1561175_1 :maxNumber "9"^^xsd:integer}.
                    "10"^^xsd:integer math:greaterThan "9"^^xsd:integer} =>
                  {_:5636586_1 :maxNumber "10"^^xsd:integer}.
                  "12"^^xsd:integer math:greaterThan "10"^^xsd:integer} =>
                {_:3274522_1 :maxNumber "12"^^xsd:integer}.
                "13"^^xsd:integer math:greaterThan "12"^^xsd:integer} =>
              {_:110499_1 :maxNumber "13"^^xsd:integer}.
              "17"^^xsd:integer math:greaterThan "13"^^xsd:integer} =>
            {_:4312351_1 :maxNumber "17"^^xsd:integer}.
            "14"^^xsd:integer math:notGreaterThan "17"^^xsd:integer} =>
          {_:2172400_1 :maxNumber "17"^^xsd:integer}.
          "16"^^xsd:integer math:notGreaterThan "17"^^xsd:integer} =>
        {_:933472_1 :maxNumber "17"^^xsd:integer}.
        "15"^^xsd:integer math:notGreaterThan "17"^^xsd:integer} =>
      {_:2468673_1 :maxNumber "17"^^xsd:integer}.
      "12"^^xsd:integer math:notGreaterThan "17"^^xsd:integer} =>
    {_:2398389_1 :maxNumber "17"^^xsd:integer}.
    "10"^^xsd:integer math:notGreaterThan "17"^^xsd:integer} =>
  {_:362000_1 :maxNumber "17"^^xsd:integer}} =>
{_:weatherToday_1 :maxTemperature "17"^^xsd:integer}.
 {_:experiment_1 :samples _:555115_1.
   {_:555115_1 rdf:first _:s1_1.
    _:555115_1 rdf:rest _:1687682_1.
    _:s1_1 :value "10"^^xsd:integer.
    _:s1_1 :freq "2"^^xsd:integer.
     {_:1687682_1 rdf:first _:s2_1.
      _:1687682_1 rdf:rest _:3003101_1.
      _:s2_1 :value "20"^^xsd:integer.
      _:s2_1 :freq "5"^^xsd:integer.
       {_:3003101_1 rdf:first _:s3_1.
        _:3003101_1 rdf:rest _:7267180_1.
        _:s3_1 :value "30"^^xsd:integer.
        _:s3_1 :freq "6"^^xsd:integer.
         {_:7267180_1 rdf:first _:s4_1.
          _:7267180_1 rdf:rest
<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.
          _:s4_1 :value "40"^^xsd:integer.
          _:s4_1 :freq "3"^^xsd:integer.
          <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> :cumValue
"0"^^xsd:integer.
          (120 "0"^^xsd:integer) math:sum 120} =>
        {_:7267180_1 :cumValue 120}.
        (180 120) math:sum 300} =>
      {_:3003101_1 :cumValue 300}.
      (100 300) math:sum 400} =>
    {_:1687682_1 :cumValue 400}.
    (20 400) math:sum 420} =>
  {_:555115_1 :cumValue 420}.
   {_:555115_1 rdf:first _:s1_1.
    _:555115_1 rdf:rest _:1687682_1.
    _:s1_1 :freq "2"^^xsd:integer.
     {_:1687682_1 rdf:first _:s2_1.
      _:1687682_1 rdf:rest _:3003101_1.
      _:s2_1 :freq "5"^^xsd:integer.
       {_:3003101_1 rdf:first _:s3_1.
        _:3003101_1 rdf:rest _:7267180_1.
        _:s3_1 :freq "6"^^xsd:integer.
         {_:7267180_1 rdf:first _:s4_1.
          _:7267180_1 rdf:rest
<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>.
          _:s4_1 :freq "3"^^xsd:integer.
          <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> :cumFreq
"0"^^xsd:integer.
          ("3"^^xsd:integer "0"^^xsd:integer) math:sum 3} =>
        {_:7267180_1 :cumFreq 3}.
        ("6"^^xsd:integer 3) math:sum 9} =>
      {_:3003101_1 :cumFreq 9}.
      ("5"^^xsd:integer 9) math:sum 14} =>
    {_:1687682_1 :cumFreq 14}.
    ("2"^^xsd:integer 14) math:sum 16} =>
  {_:555115_1 :cumFreq 16}.
  (420 16) math:integerQuotient 26} =>
{_:experiment_1 :meanValue 26}.

--
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/

PS this was given

   _:weatherToday
     :hourlyTemperatures
       ( "10"^^xsd:integer "12"^^xsd:integer "15"^^xsd:integer
         "16"^^xsd:integer "14"^^xsd:integer "17"^^xsd:integer
         "13"^^xsd:integer "12"^^xsd:integer "10"^^xsd:integer
         "9"^^xsd:integer  "7"^^xsd:integer  "6"^^xsd:integer ) .

{?W :hourlyTemperatures ?L. ?L :maxNumber ?N} => {?W :maxTemperature ?N}.

{?A rdf:first ?M; rdf:rest rdf:nil} => {?A :maxNumber ?M}.
{?A rdf:first ?M; rdf:rest ?B. ?B :maxNumber ?N. ?M math:greaterThan ?N} =>
{?A :maxNumber ?M}.
{?A rdf:first ?M; rdf:rest ?B. ?B :maxNumber ?N. ?M math:notGreaterThan ?N}
=> {?A :maxNumber ?N}.

  _:experiment
    :samples ( _:s1 _:s2 _:s3 _:s4 ) .
  _:s1 :value "10"^^xsd:integer ;
       :freq  "2"^^xsd:integer .
  _:s2 :value "20"^^xsd:integer ;
       :freq  "5"^^xsd:integer .
  _:s3 :value "30"^^xsd:integer ;
       :freq  "6"^^xsd:integer .
  _:s4 :value "40"^^xsd:integer ;
       :freq  "3"^^xsd:integer .

{?E :samples ?L. ?L :cumValue ?C; :cumFreq ?D. (?C ?D) math:integerQuotient
?M} => {?E :meanValue ?M}.

rdf:nil :cumValue "0"^^xsd:integer.
{?A rdf:first ?M; rdf:rest ?B. ?M :value ?V; :freq ?F. ?B :cumValue ?N.
((?V ?F).math:product ?N) math:sum ?C} => {?A :cumValue ?C}.

rdf:nil :cumFreq "0"^^xsd:integer.
{?A rdf:first ?M; rdf:rest ?B. ?M :freq ?F. ?B :cumFreq ?N. (?F ?N)
math:sum ?C} => {?A :cumFreq ?C}.

Received on Friday, 27 February 2004 14:32:16 UTC