[MLton] Word<N>
Neophytos Michael
nmichael@yahoo.com
Tue, 15 Mar 2005 13:01:22 -0800 (PST)
Thanks. I have followed your second suggestion more or less. I do everything
is Word8 and make sure I only use one bit.
Neophytos
--- Stephen Weeks <sweeks@sweeks.com> wrote:
>
> > I hope I am not missing something obvious but why is N > 1. Why not
> implement
> > Word1? Binary arithmetic is universally useful... just now I was trying to
> > write the code to compute a binary determinant of a binary matrix but alas
> > Word1 is not there. Maybe it was left out to keep it symmetric with the
> Int
> > case when Int1 would not make much sence. But word1 does...
>
> There is no good reason why Word1 isn't there. Until it is, if you're
> willing to live without source-level constants (0w0, 0w1), it is easy
> to implement yourself.
>
> structure Word1: WORD =
> struct
> datatype word = W0 | W1
>
> val op + =
> fn (W0, W0) => W0
> | (W0, W1) => W1
> | (W1, W0) => W1
> | (W1, W1) => W0
>
> ...
> end
>
> Or, you could implement it much as we implement the other unusual word
> sizes, by embedding in a larger word size, Word8.word probably being
> the right choice.
>
> _______________________________________________
> MLton mailing list
> MLton@mlton.org
> http://mlton.org/mailman/listinfo/mlton
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250