-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoets.ml
More file actions
45 lines (39 loc) · 1.47 KB
/
Poets.ml
File metadata and controls
45 lines (39 loc) · 1.47 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
(** Using Private Set Intersection to find which poets are known to
the client and to the server. *)
(* Copyright Xavier Leroy. License: GPL 2 or later *)
open Printf
(* Server database *)
let poets = [
"Milton"; "Shakespeare"; "Chaucer"; "Yeats"; "Wordsworth"; "Keats";
"Blake"; "Eliot"; "Donne"; "Dickinson"; "Whitman"; "Pope";
"Browning"; "Stevens"; "Shelley"; "Byron"; "Tennysson"; "Spenser";
"Poe"; "Auden"; "Coleridge"; "Dryden"; "Pound"; "Bishop"; "Plath";
"Larkin"; "Longfellow"; "Cummings"; "Ginsberg"; "Thoreau"; "Dylan";
"Ronsard"; "Bellay"; "Malherbe"; "Hugo"; "Musset"; "Baudelaire";
"Rimbaud"; "Verlaine"; "Apollinaire"; "Eluard"; "Breton"; "Aragon";
"Desnos"; "Prévert"; "Queneau"; "Labé"; "Desbordes-Valmore";
"Noailles"; "Heredia"; "Gautier"; "Mallarmé"; "Chénier"
]
let usage () =
printf "Usage: mpirun -np 2 ./Poets.exe <name1> ... <nameN>\n";
printf "Use names of poets (English language or French language)\n"
let _ =
if Multiparty.num_participants() < 2 then begin
if Multiparty.self() = 0 then usage();
exit 2
end;
begin match Multiparty.self() with
| 0 ->
let my_names =
Array.to_list (Array.sub Sys.argv 1 (Array.length Sys.argv - 1)) in
let shared_names =
PSI.client ~server:1 my_names in
printf "Names in common with the server:";
List.iter (fun n -> printf " %s" n) shared_names;
printf "\n"
| 1 ->
PSI.server ~client:0 poets
| _ ->
()
end;
Multiparty.barrier()