words.anubis
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
*** (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)).