prot ot ype in high level language as execut able specif
play

Prot ot ype in high-level language as execut able specif icat ion - PowerPoint PPT Presentation

Prot ot ype in high-level language as execut able specif icat ion Shigeru KUSAKABE, Keij iro Araki Kyushu Universit y, J apan I nt roduct ion High level programming languages support abst ract and rigorous descript ion st yles like f


  1. Prot ot ype in high-level language as execut able specif icat ion Shigeru KUSAKABE, Keij iro Araki Kyushu Universit y, J apan

  2. I nt roduct ion � High level programming languages support abst ract and rigorous descript ion st yles like f ormal specif icat ion languages. abst ract f ormal moderat ely specif icat ion abst ract , language rigorous and execut able high level programming det ailed language

  3. Approach � Prot ot yping � Model in VDM language � VDMTools � Program in Haskell, a f unct ional language � compilers, in addit ion t o int erpret er � libraries and t ools

  4. Quicksort in VDM++ qui cksor t : seq of nat - > seq of nat qui cksor t ( l ) == cases l : [ ] - > [ ] , - ^[ x] ^- - > qui cksor t ( [ y | y i n set el em s l & y < x] ) ^ [ x] ^ qui cksor t ( [ y | y i n set el em s l & y > x] ) end

  5. Quicksort in Haskell qsor t : : O r d a => [ a] - > [ a] qsor t [ ] = [ ] qsor t ( x: xs) = qsor t el m _l t _x ++ [ x] ++ qsor t el m _gr eq_x wher e el m _l t _x = [ y | y <- xs, y < x] el m _gr eq_x = [ y | y <- xs, y >= x]

  6. Quicksort in C qsor t ( a, l o, hi ) i nt a[ ] , hi , l o; { i nt h, l , p, t ; i f ( l o < hi ) { l = l o; h = hi ; p = a[ hi ] ; do { whi l e ( ( l < h) && ( a[ l ] <= p) ) l = l +1; whi l e ( ( h > l ) && ( a[ h] >= p) ) h = h- 1; i f ( l < h) { t = a[ l ] ; a[ l ] = a[ h] ; a[ h] = t ; } } whi l e ( l < h) ; t = a[ l ] ; a[ l ] = a[ hi ] ; a[ hi ] = t ; qsor t ( a, l o, l - 1 ) ; qsor t ( a, l +1, hi ) ; } }

Recommend


More recommend