forked from rbrito/pkg-mp3packer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist2_test.ml
87 lines (67 loc) · 2.56 KB
/
list2_test.ml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(*******************************************************************************
This file is a part of mp3packer.
mp3packer is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
mp3packer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mp3packer; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************)
open List2;;
let q = create ();;
append q 1;;
prepend q 2;;
append q 3;;
rev_iter (fun x -> Printf.printf "%d\n" x) q;;
(*
let a = pop_last q;;
Printf.printf ">%d\n" a;;
*)
iter (fun x -> Printf.printf "%d\n" x) q;;
Printf.printf "+%d+\n" (fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 q);;
Printf.printf "+%d+\n" (rev_fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 q);;
Printf.printf " #1=%d\n" (nth q 2);;
let a = to_array q;;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
prepend q 666;;
ignore (take_first q);;
iter (fun x -> Printf.printf "%d\n" x) q;;
iteri (fun i x -> Printf.printf "%d: %d\n" i x) q;;
rev_iteri (fun i x -> Printf.printf "%d: %d\n" i x) q;;
ignore (take_first q);;
ignore (take_first q);;
Array.iteri (fun i x -> Printf.printf "A %d=%d\n" i x) a;;
let r = of_array a;;
Printf.printf "+%d+\n" (fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 r);;
Printf.printf "+%d+\n" (rev_fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 r);;
let l = to_list r;;
let s = of_list l;;
Printf.printf "+%d+\n" (fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 s);;
Printf.printf "+%d+\n" (rev_fold (fun a b -> Printf.printf "(%d,%d)" a b; a + b) 0 s);;
Printf.printf " List length %d\n" (List.length l);;