sieve.mlton

Stephen Weeks MLton@sourcelight.com
Sun, 10 Jun 2001 23:24:36 -0700


--Z0MrqX0xm3
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit


Here is a version of sieve that uses a bool array instead of a
Word8Array.array and also has the nested loop in a more idiomatic style.  On my
machine, it runs in about 65% of the time of your version, for reasons I don't
understand.



--Z0MrqX0xm3
Content-Type: application/octet-stream
Content-Disposition: attachment;
	filename="sieve.mlton"
Content-Transfer-Encoding: base64

KCogLSotIG1vZGU6IHNtbCAtKi0KICogJElkOiBzaWV2ZS5tbHRvbix2IDEuMyAyMDAxLzA2LzEw
IDA1OjU5OjM0IGRvdWcgRXhwICQKICogaHR0cDovL3d3dy5iYWdsZXkub3JnL35kb3VnL3Nob290
b3V0LwogKikKCnZhbCBmbGFnczogYm9vbCBhcnJheSA9IEFycmF5LmFycmF5ICg4MTkzLCBmYWxz
ZSkKCmZ1biBtaWRkbGVfbG9vcCAoaSwgY250KSA9CiAgICBpZiBpIDwgODE5MyB0aGVuCglpZiBB
cnJheS5zdWIgKGZsYWdzLCBpKQoJICAgdGhlbgoJICAgICAgbGV0CgkJIGZ1biBpbm5lcl9sb29w
IGsgPQoJCSAgICBpZiBrIDwgODE5MwoJCSAgICAgICB0aGVuIChBcnJheS51cGRhdGUgKGZsYWdz
LCBrLCBmYWxzZSkKCQkJICAgICA7IGlubmVyX2xvb3AgKGsgKyBpKSkKCQkgICAgZWxzZSAoKQoJ
ICAgICAgaW4KCQkgaW5uZXJfbG9vcCAoaSArIGkpCgkJIDsgbWlkZGxlX2xvb3AgKGkgKyAxLCBj
bnQgKyAxKQoJICAgICAgZW5kCgllbHNlIG1pZGRsZV9sb29wIChpICsgMSwgY250KQogICAgZWxz
ZSBjbnQKCmZ1biBpbml0X2ZsYWdzIGkgPQogICAgaWYgaSA8IDgxOTMgdGhlbgoJKCBBcnJheS51
cGRhdGUgKGZsYWdzLCBpLCB0cnVlKSA7IGluaXRfZmxhZ3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