On 7/19/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> let receive idList msg =
> match message with
> None -> None
>
> | Register( REQUEST_KEY, id ) -> begin
> match idList with
> [] -> Register(SUCCESS, id)
> | l when (List.mem id l) -> Register(Success, (next_available_id
> l))
> | _ -> Register(Success, id)
> ;;
For the inner match, why you even both with it is beyond me. All you
are doing is wrapping List.mem in an unnecessary test.
It should be:
| Register(REQUEST_KEY,id) ->
if List.mem id idList then
Register(Success, next_available_id l)
else
Register(Success, id)
Perhaps the fact that your example makes no sense (it's not a complete
definition, nor is Success defined anywhere, nor does Register even
accept the constructor Success) doesn't help here.