Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Removing repeating code
@ 2013-01-18  4:57 Ivan Gotovchits
  2013-01-18  6:13 ` Erkki Seppala
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Gotovchits @ 2013-01-18  4:57 UTC (permalink / raw)
  To: caml-list


Hi!

It was difficult to find a proper phrase for a subject field, sorry. But
in ocaml it is really easier to formulate, so going right to the
question.

Are there any possibility to remove code dublicating in a following
function:

  let f = let g = Array.length in function
    | Strings a -> g a
    | Floats a -> g a

which have a type

  val f : value -> int

where value is

  type value =
    | Strings of string array
    | Floats of float array

May be there is some trick?

Thanks in advance!
  

-- 
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
...."Have you mooed today?"...

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-18 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-18  4:57 [Caml-list] Removing repeating code Ivan Gotovchits
2013-01-18  6:13 ` Erkki Seppala
2013-01-18  6:32   ` Ivan Gotovchits
2013-01-18  7:08     ` Erkki Seppala
2013-01-18 14:14       ` Gabriel Scherer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox