Category:CafeOBJ: Difference between revisions
→Examples
Line 39:
<lang CafeOB>
-- Run in CafeOBJ 1.5.5(PigNose0.99)
-- System settings
full reset
set step off
set print mode :fancy
set stats off
set verbose off
set quiet on
-- Here is a one line sorting program.
mod! SORTING-NAT {
pr(NAT) -- import
[Nat < List ] -- Nat is a sub-sort of List
-- Simple space seperated list structure
op nil : -> List
op
vars N N' : Nat
-- A very short sorting program using one transition equation in POA logic, which is a type of rewrite logic.
-- The program is in the form of a condition
--
}▼
▲}
**> Sorting natural numbers using exec command▼
open SORTING-NAT ▼
exec (3 . 2 . 1) .▼
▲open SORTING-NAT .
--> Gives (1 . 2 . 3):List▼
red (9 3 6 12 1 20) .
--> Gives (1 3 6 9 12 20):List
eof
</lang>
|