words.anubis 1.22 KB


   *** (17) Word functions. 

   This section must be completed. 
   
public define Word32
   to_Word32
     (
       Word8 x
     ) =
   word32(word16(x,0),0). 
   
   
   

   
public define Word32
   Int x & Word32 y
     = 
   if to_Word32(x) is
   {
      [] then 0,
      [h . t] then h & y
   }.
   
public define Int
   Int x | Word32 y
     = 
   if to_Word32(x) is
   {
      [] then to_Int(y),
      [h . t] then to_Int([(h | y) . t])
   }.
      
   
   Transforming a list of Word8 into a list of Word32. 
   
define List(Word32)
   to_list_word32
     (
       List(Word8)  l
     ) =
   if l is 
     {
       [ ] then [ ], 
       [a1 . t1] then if t1 is 
         {
           [ ] then [word32(word16(0,0),word16(0,a1))],
           [a2 . t2] then if t2 is 
             {
               [ ] then [word32(word16(0,0),word16(a2,a1))],
               [a3 . t3] then if t3 is 
                 {
                   [ ] then [word32(word16(0,a3),word16(a2,a1))],
                   [a4 . t4] then [word32(word16(a4,a3),word16(a2,a1)) . to_list_word32(t4)]
                 }
             }
         }
     }.
   
   
   
 public define Nat
   to_Nat
     (
       List(Word8) l
     ) =
   to_Nat(to_list_word32(l)).