Algebraic data types: Difference between revisions

Content added Content deleted
Line 1,021: Line 1,021:
if v[1] == R
if v[1] == R
if length(v[2]) == 4 && v[2][1] == R
if length(v[2]) == 4 && v[2][1] == R
return [R, [B, a, x, v[2][2]], v[2][3], [B, v[3], v[4]]]
return [R, [B, a, x, v[2][2]], v[2][3], [B, v[2][4], v[3], v[4]]]
elseif length(v[4]) == 4 && v[4][1] == R
elseif length(v[4]) == 4 && v[4][1] == R
return [R, [B, a, x, v[2]], v[3], [B, v[4][2], v[4][3], v[4][4]]]
return [R, [B, a, x, v[2]], v[3], [B, v[4][2], v[4][3], v[4][4]]]
Line 1,032: Line 1,032:
if v[1] == R
if v[1] == R
if length(v[2]) == 4 && v[2][1] == R
if length(v[2]) == 4 && v[2][1] == R
return [R, [B, a, x, v[2][2]], v[2][3], [B, v[3], v[4]]]
return [R, [B, a, x, v[2][2]], v[2][3], [B, v[2][4], v[3], v[4]]]
elseif length(v[4]) == 4 && v[4][1] == R
elseif length(v[4]) == 4 && v[4][1] == R
return [R, [B, a, x, v[2]], v[3], [B, v[4][2], v[4][3], v[4][4]]]
return [R, [B, a, x, v[2]], v[3], [B, v[4][2], v[4][3], v[4][4]]]
Line 1,068: Line 1,068:
</lang>{{out}}
</lang>{{out}}
<pre>
<pre>
[B, [R, [B, E, 2, E], 3, [B, E, 5, E]], 8, [R, [B, [R, E, 9, [R, E, 11, E]], 13, E], 14, [B, 20, E]]]
[B, [R, [B, [R, E, 1, E], 2, [R, E, 3, E]], 4, [B, E, 6, E]], 14, [B, E, 18, E]]]
</pre>
</pre>