Hello,

On Thu, Jan 19, 2012 at 10:38:53PM -0800, Martin DeMello wrote:
>       let a = match (out, value) with
>         (true, true)  -> [o; v]
>       | (false, true) -> [v]
>       | (true, false) -> [o]
>       | (false, false) -> []

The code looks fine for me.

More concise does not always mean better readable or more performant.
You apply the same kind of selection for both values.

Something that would aequivalent would be of type 'a option.
But I doubt that using option type here would make it more concise.

Would it make it Better readable? Not necessarily.

But at least it would show the operation more clear.

But not sure if you want to handle option type in your result.

I think a fold could do the selection of the raw values afterwards.

If out is derived from o and v is derived from v and both are selected
by the same function, you could use that function inside a fold.
But would that really be more readable?
It might be more generic.
But if both selections are not done by the same function application to your
result values, this also does not make sense.

Do you see what I mean?

Ciao,
   Oliver

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to