Commits

arkdro  committed d501cd1

separate code for list multiply

  • Participants
  • Parent commits 5f77a42

Comments (0)

Files changed (1)

File ocaml/src/odec_port.ml

   | _ ->
     ET_Tuple [ET_Atom "error"; ET_Atom "not_decimal"]
 
+let multiply_list list =
+  match t_mult2 list with
+  | Some (ET_Bignum r) ->
+    let res2 = create_decimal r in
+    Some list, ET_Tuple [ET_Atom "ok"; res2]
+  | None ->
+    Some list, ET_Tuple [ET_Atom "error"; ET_Atom "no_data"]
+
 let port_command_dispatcher old_value = function
   | ET_Tuple [ET_Atom "forget"; _] ->
     None, ET_Atom "ok"
   | ET_Tuple [ET_Atom "mult_list"; (ET_List [_]) as t] ->
     Some t, ET_Tuple [ET_Atom "error"; ET_Atom "need_list_to_multiply"]
   | ET_Tuple [ET_Atom "mult_list"; (ET_List _) as t] ->
-    (
-      match t_mult2 t with
-      | Some (ET_Bignum r) ->
-        let res2 = create_decimal r in
-        Some t, ET_Tuple [ET_Atom "ok"; res2]
-      | None ->
-        Some t, ET_Tuple [ET_Atom "error"; ET_Atom "no_data"]
-    )
+    multiply_list t
   | ET_Tuple [ET_Atom "sum_list"; (ET_List list) as t] ->
     let res = sum_list list in
     Some t, ET_Tuple [ET_Atom "ok"; res]