S
Shot (Piotr Szotkowski)
--tgO4DUqb0GCKXXLG
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
(For those keeping track at home of my Ruby vs. Ruby/C vs. C++
adventures, I decided to go with pure Ruby and optimise afterwards
if/where needed and my supervisor agreed. I also started coding
yesterday, and would like to state that (a) Ruby test-driven development
is even more sexy than advertised and (b) humblelittlerubybook.com is
a really great book.)
On to my problem, then.
First, the terminology: a block is a set of
vectors (say, integers), a blanket is a set of blocks, and a blanket
might be, but in most cases isn=E2=80=99t, encoded =E2=80=93 i.e., might ha=
ve its blocks
named. Thus an example, unencoded two-block blanket might look like
this: {{1, 9, 4, 7}, {1, 9, 3, 7}}
My obvious first approach was to create a Block class with two
properties, a @vectors Set and an @encoding Symbol, and a Blanket
class with a @blocks Set.
Now that I think about it, though, most of the computing will happen
with unencoded blankets, and in this case there=E2=80=99s no need for a Blo=
ck
class at all; just a Blanket with a Set of Sets. First, this (I presume)
would make things a bit faster and less memory hungry; second, the
encoding makes sense only at the Blanket level, really.
Ufortunately, an encoded blanket screams to be represented as a Hash of
Sets (keyed with the encoding Symbols), while an unencoded blanket is
best represented as a Set of Sets, and can=E2=80=99t be a Hash.=20
What would be the best approach to this situation? An EncodedBlanket
subclass of Blanket? A Blanket class that is a Hash of Symbols keyed
with Sets (i.e., the other way around, with nil hash values for
unencoded blankets)? Something else? Basically, what I need is
a hash that doesn=E2=80=99t have to have keys=E2=80=A6
-- Shot
--=20
Can't you feel the peace and contentment in this block of code? Ruby
is the language Buddha would have programmed in. -- Sean Russell
--tgO4DUqb0GCKXXLG
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFFtypji/mCfdEo8UoRAu1wAKCaflIbvGee7dDRh8uqhrCk1fOXcwCeIbs4
r2zh1UFwXIHGEywH5hZSOH8=
=XavL
-----END PGP SIGNATURE-----
--tgO4DUqb0GCKXXLG--
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
(For those keeping track at home of my Ruby vs. Ruby/C vs. C++
adventures, I decided to go with pure Ruby and optimise afterwards
if/where needed and my supervisor agreed. I also started coding
yesterday, and would like to state that (a) Ruby test-driven development
is even more sexy than advertised and (b) humblelittlerubybook.com is
a really great book.)
On to my problem, then.
vectors (say, integers), a blanket is a set of blocks, and a blanket
might be, but in most cases isn=E2=80=99t, encoded =E2=80=93 i.e., might ha=
ve its blocks
named. Thus an example, unencoded two-block blanket might look like
this: {{1, 9, 4, 7}, {1, 9, 3, 7}}
My obvious first approach was to create a Block class with two
properties, a @vectors Set and an @encoding Symbol, and a Blanket
class with a @blocks Set.
Now that I think about it, though, most of the computing will happen
with unencoded blankets, and in this case there=E2=80=99s no need for a Blo=
ck
class at all; just a Blanket with a Set of Sets. First, this (I presume)
would make things a bit faster and less memory hungry; second, the
encoding makes sense only at the Blanket level, really.
Ufortunately, an encoded blanket screams to be represented as a Hash of
Sets (keyed with the encoding Symbols), while an unencoded blanket is
best represented as a Set of Sets, and can=E2=80=99t be a Hash.=20
What would be the best approach to this situation? An EncodedBlanket
subclass of Blanket? A Blanket class that is a Hash of Symbols keyed
with Sets (i.e., the other way around, with nil hash values for
unencoded blankets)? Something else? Basically, what I need is
a hash that doesn=E2=80=99t have to have keys=E2=80=A6
-- Shot
--=20
Can't you feel the peace and contentment in this block of code? Ruby
is the language Buddha would have programmed in. -- Sean Russell
--tgO4DUqb0GCKXXLG
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFFtypji/mCfdEo8UoRAu1wAKCaflIbvGee7dDRh8uqhrCk1fOXcwCeIbs4
r2zh1UFwXIHGEywH5hZSOH8=
=XavL
-----END PGP SIGNATURE-----
--tgO4DUqb0GCKXXLG--