5 ms·
I have no doubt English like syntax is a terrible idea but this seems like a surprisingly readable example.
by paddw 3y ago
I have no doubt English like syntax is a terrible idea but this seems like a surprisingly readable example.
- maxbond 3y agoAgreed, I rather like this line of code, but I must admit that the C-like version is perhaps better: sales_tax_amount = balance * state[42].tax_rate; (Assuming I've guessed the meaning of the Cobol correctly - perhaps that's the rub.) (ETA: Added semicolon.) (ETA2: Fixed critical indexing bug.)
- quickthrower2 3y ago#define MULTIPLY sales_tax_amount = balance * state[43].tax_rate; //
- phlakaton 3y agoYou forgot the semicolon. Note the semicolon is significant. Barbaric, I know.
- throwawaymobule 3y agoI think indexes start at 1 in COBOL. I had to look it up though. (aiui, they're called TABLEs and the index can start from any number) So that'd be state[42].
- maxbond 3y agoNot all heroes wear capes. I've put in a PR to upstream. LGTM