reverse String asHex

"Mildred Ki'Lya" <[email protected]> Thu, 8 Dec 2011 15:43:05 +0100
Newsgroups gmane.comp.lang.io
Message-ID <CAHU8Kxg4S+iEgG7G7pa2dGXrWDMDBtLT2OmUOBKDjUJqAMZFfg@mail.gmail.com>
Hi,

I have a string in the forme given by String asHex. That is a collection of
bytes, encoded using two hexadecimal characters, all concatenated together.
i'm trying to decode it back into a Sequence.

I came with the following solution, do you know is there is any better
solution?

Sequence fromHex := method(
  res := Sequence clone
  for(i, 1, self size, 2,
    res append(("0x" .. (self exSlice(i-1, i+1))) asNumber)
  )
  res
)

In particular I would prefer having String asNumber(base) instead of having
to do a concatenation.

Mildred