OPS5: Official Production System 5

[top]

  1. Rule based paradigm.
  2. Example: a program which calculate sum of integers upto user input upper limit.

    ; Sumup program written in OPS5
    (startup
       (watch 0)
       (make start)
       (run) )
    
    (p initial
       (start)
     -->
       (remove 1)
       (write (crlf) |input number :|)
       (make upto (accept))
       (make sum 0)
       (make count 1) )
    
    (p count-going
       (sum {<s> <=> 0})
       (count {<c> <=> 0})
     -->
       (modify 1 ^value (compute <s> + <c>))
       (modify 2 ^value (compute <c> + 1)) )
    
    (p count-done
       (upto <u>)
       (count > <u>)
       (sum <s>)
     -->
       (remove 1 2 3)
       (write (crlf) |sum is | <s>)
       (halt) )
    

[top]