```
#include <array/length-prefix.h>
#include <stdlib.h>
```

morph_seqseq_valsep_uint8 (T: Type, SrcDelim: T, DstDelim: T)
      < Seq <Seq T> >
    ~ < ValueSep SrcDelim T >
    ~ < Seq~<LengthPrefix native.UInt64> T >

-->   < Seq <Seq T> >
    ~ < ValueSep DstDelim T >
    ~ < Seq~<LengthPrefix native.UInt64> T >
```
    PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, clear)( dst );

    uint8_t * dst_items = dst->items;
    for( uint64_t i = 0; i < src->len; ++i ) {
        if( src->items[i] == SrcDelim ) {
            PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, DstDelim );
        } else if( src->items[i] == DstDelim ) {
            if( DstDelim == '\n' ) {
                PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, '\\' );
                PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, 'n' );
            }
        } else {
            PRESCAN_LENGTH_PREFIX_CALL(nativeUInt64, T, push)( dst, src->items[i] );
        }
    }
```


morph_seqseq_as_valsep_to_lenpfx (T: Type, Delim: T, EscKey: T)
      < Seq <Seq T> >
    ~ < ValueSep T Delim >
    ~ < Seq~<LengthPrefix native.UInt64> T >

--> < Seq~<LengthPrefix native.UInt64>
        <Seq~<LengthPrefix native.UInt64> T >
        ~ <RefMut < Seq~<LengthPrefix native.UInt64> T>>
        ~ native.Address
        ~ native.UInt64
    >
```
    length_prefix_nativeUInt64_array_nativeUInt64_clear( dst );

    struct LengthPrefix_nativeUInt64_Array_nativeUInt8 * cur_item = NULL;

    uint8_t const * start = &src->items[0];
    uint8_t const * cur = start;
    uint8_t const * end = &src->items[src->len];

    while( cur < end ) {
        if( *cur == Delim || cur+1 == end ) {
            uint64_t len = cur - start;

            cur_item = malloc( sizeof(uint64_t) + sizeof(uint8_t) * len );
            cur_item->len = len;
            memcpy( cur_item->items, start, len );

            length_prefix_nativeUInt64_array_nativeUInt64_push( dst, (uint64_t)cur_item );
            start = ++cur;
        } else {
            cur++;
        }
    }
```

morph_seqeq_as_lenpfx_to_valsep (T: Type, Delim: T, EscKey: T)
    < Seq~<LengthPrefix native.UInt64>
        <Seq~<LengthPrefix native.UInt64> T >
        ~ <RefMut < Seq~<LengthPrefix native.UInt64> T>>
        ~ native.Address
        ~ native.UInt64
    >
-->   < Seq <Seq T> >
    ~ < ValueSep T Delim >
    ~ < Seq~<LengthPrefix native.UInt64> T >
```
    length_prefix_nativeUInt64_array_nativeUInt8_clear( dst );

    for( uint64_t i = 0; i < src->len; ++i ) {
        LengthPrefix_nativeUInt64_Array_nativeUInt8_t * item = src->items[i];

        for( uint64_t j = 0; j < item->len; ++j ) {
            length_prefix_nativeUInt64_array_nativeUInt8_push( items->items[j] );
        }

        if( i+1 < src->len ) {
            length_prefix_nativeUInt64_array_nativeUInt8_push( Delim );
        }
    }
```