-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscalePath.ml
More file actions
38 lines (34 loc) · 754 Bytes
/
scalePath.ml
File metadata and controls
38 lines (34 loc) · 754 Bytes
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
let error () =
prerr_endline "first and only argument has to be the scale factor; \
and stdin should be the path";
exit 1
let scale =
try
float_of_string Sys.argv.(1)
with _ ->
error ()
let path =
let b = Buffer.create 8096 in
try
while true do
Buffer.add_string b (read_line());
Buffer.add_char b ' '
done;
assert false
with End_of_file ->
Buffer.contents b
let p = ExtractNumbers.f path
let _ =
let open ExtractNumbers in
let space = ref false in
List.iter (function
| Char c ->
print_char c;
space := false
| Number n ->
if !space then
print_char ' ';
Printf.printf "%g" @@ scale *. n;
space := true
)
p