Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 21:02 Mar 06, 2019 |
Turns out that if you eliminate all blank lines, all comments, and all trace lines, (none of which I'm recommending) the Python and Haskel files have approximately the same number of lines of executable code. Last edited by rabbott at
21:15 Mar 06, 2019.
|
rabbott
Posts: 1649
|
Posted 21:36 Mar 06, 2019 |
An interesting feature of the Python code is that it uses metaclasses. A metaclass is to a class as a class is to an object. The Python code uses classes rather than labels for the roads: A, B, C. A road segment of length n on road A is A(n), i.e., an instance of Road A. But the roads themselves are often treated as objects, e.g., when one wants to define their The Haskell code uses a number of user-created operators. We can't do that in Python, but we can repurpose operators. The function to join two Paths into a single combined Path is given to the You can do the same thing with numbers:
(Leaving out the parentheses around the 1 produces a syntax error.) Similarly,
As the Python documentation says, everything is an object, even numbers.
Last edited by rabbott at
21:56 Mar 06, 2019.
|