Re: Too complex!!!!!!!!!
- Posted by "Carl R. White"
Jun 11, 1997
On Mon, 9 Jun 1997, Lucius L Hilley III wrote:
> I created this code.
> It works great.
> BUT I can't figure out how to undo it.
[Space save snip]
> HERE is the Function.
[Space save snip]
> function Flatten(sequence s)
> sequence temp
> sequence sh
>
> sh = {length(s)}
> for a = 1 to sh[1] do
> if sequence(s[a]) then
> temp = Flatten(s[a])
> sh = sh & temp
> else
> sh = sh & {-1, s[a]}
> end if
> end for
> return sh
> end function
>
> --This one of my Vain attempts
> --function DeFlatten(sequence s)
> -- atom a, p
> -- sequence temp
> --
> -- a = 2
> -- p = 1
> -- temp = repeat({}, s[1])
> -- while a <= length(s) do
> -- if s[a] = -1 then
> -- a = a + 1
> -- temp[p] = s[a]
> -- p = p + 1
> -- else
> -- temp[p] = repeat({}, s[a])
> -- end if
> -- a = a + 1
> -- end while
> -- return temp
> --end function
I don't think it *can* be undone, because both
{{4}, 5 , {6, 7} ,8}
and
{4, {5, 6, 7}, 8}
compact to
{4, 5, 6, 7, 8}
.
How do you know which one was the original, when it's blatantly
obvious they both were (and several other possible combinations too)?
It's like saying sqrt(9) = 3 (which is what the function returns) but
(-3) * (-3) = 9, so how do you know what created the 9 in the first place?
Was it 3 or -3?
Sorry to burst the bubble...
--
Carl R White | e-mail...: crwhite- at -comp.brad.ac.uk
| finger...: crwhite- at -dcsun1.comp.brad.ac.uk
| web......: http://www.student.comp.brad.ac.uk/~crwhite/
Anti-Spam and Uncle-Pek measures in place & .sig fixed too...
|
Not Categorized, Please Help
|
|