tybalt89 discovered a bug in Fun with logical expressions:
$ echo IEabEba | perl try.pl
Not a tautology
(a equals b) implies (b equals a) is a tautology but the program
fails to recognize it. With the fixed code below it generates this
Hosted by us at Broadbean. The address is Level 8, 9 Hunter Street, Sydney 2000.
The front doors close promptly at 6pm. If you arrive before 6pm, then walk straight in (there's no sign in process). When on the 8th floor, there's signs to say we're to the left. Come on in!
If you arrive after 6pm then please give Peter me a call. His number is 0414 331 769. Someone will then come and let you in.
Tonight Stuart Cooper will present a talk on using perl in a perl hostile environment. Ivan Wills will also present on a mystery topic. There will also be some house keeping discussions for the group to decide upon.
Test Driven Development is the topic of the night at MadMongers tomorrow night. If you’re in Madison, come, have a beer, and hear about TDD.
[From my blog.]
Here's a quickly thrown-together version of "Fun with logical expressions", written in Haskell:
The M4 language is a powerful macro processor, turing complete as well as a practical programming language. It is the core tool behind GNU Autoconf, in particular.
MarpaX::Languages::M4 package is a Marpa::R2/Moops powered implementation of it, 99% with the GNU M4 version () and have switches to alter its behaviour as wanted, so that one can have e.g. POSIX M4 as well.
MarpaX::Languages::M4 is distributed with an
m4pp command-line, with all the GNU M4 implementation options, plus some other handy items, for example:
- conversion to UNIX native end-of-line
- comment start and end delimiters
- string start and end delimiters
and some "advanced" options to alter the behaviour or extend M4 as you wish:
- buffers unwrap order at the end (LIFO or FIFO)
- any default can be altered on the command-line
- unlimited number of bits for eval arithmetic (thanks to the really remarquable Bit::Vector package)
- use perl or GNU Emacs regexps (via the new re::engine::GNU package)
Addendum 2: This set of rules is incomplete. See Fun with logical expressions 2 for an improved version.
Addendum: I've written a more or less equivalent Haskell version of this program.
Some programmers, when confronted with a boolean expression, think "I know, I'll use regular expressions". Now they have
This post was inspired by the TAUT exercise on SPOJ.
You're given a boolean expression consisting of variables (each being either
false), a unary operator (
not), and several binary operators (
equals). Your task is to determine whether the expression is a tautology, i.e. whether it evaluates to
true for all possible variable values.
To make parsing easier, we're going to use a very simplified syntax: