[m-dev.] A chemical equation balancer
Ralph Becket
rbeck at microsoft.com
Wed May 16 20:55:56 AEST 2001
A buglet:
$ ./chem.
h2 -> h3
The number of Hs don't match (2 vs 3)
h2 -> o2 <--- oh dear
h3 -> h3
In the deobfuscated version you need to apply
--- chem.m Wed May 16 11:51:06 2001
+++ chem.old Wed May 16 11:54:51 2001
@@ -25,7 +25,7 @@
( { parse(LHS, RHS, Chars, []) } ->
{ solutions((pred({L, M, N}::out) is nondet :-
member(LHS, L, N),
- M = ( if search(RHS, L, M0) then M0 else 0 ),
+ member(RHS, L, M),
N \= M
), Xs) },
foldl((pred({I, J, K}::in, di, uo) is det -->
- Ralph
> -----Original Message-----
> From: Thomas Conway [mailto:conway at cs.mu.OZ.AU]
> Sent: 16 May 2001 02:49
> To: mercury-developers at cs.mu.OZ.AU
> Subject: [m-dev.] A chemical equation balancer
>
> Hi
>
> Here is a slightly obfuscated chemical equation balancer that we
> might like to deobfuscate (in a little while)[1] and add to the
> samples.
>
> sample correct input:
> CO2 + 2H2O -> O2 + CH4
> --
> Thomas Conway )O+
> <conway at cs.mu.oz.au> 499 User error! Replace user, and press
any key.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list