<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def val2dzn(val, wrap=True):
 """Serializes a value into its dzn representation. The supported types are ``bool``, ``int``, ``float``, ``set``, ``array``. Parameters val The value to serialize wrap : bool Whether to wrap the serialized value. Returns ------- str The serialized dzn representation of the given value. """

    if _is_value(val):
        dzn_val = _dzn_val(val)
    elif _is_set(val):
        dzn_val = _dzn_set(val)
    elif _is_array_type(val):
        dzn_val =_dzn_array_nd(val)
    else:
        raise TypeError(
            'Unsupported serialization of value: {}'.format(repr(val))
        )

    if wrap:
        wrapper = _get_wrapper()
        dzn_val = wrapper.fill(dzn_val)

    return dzn_val