Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If so, an audience of computer scientists would probably have understood the following better

I'm a very experienced programmer (>25 years) and I don't know the language you're using in your notation (Python maybe?). The kind of mathematical notation Lamport is using is much more universal (at least after he explains its particular peculiarities). Also, reading your notation, I assume that you're describing a list, while he's describing a set.



Yes, it is Python. Python has become a lingua franca in the programming world, and you'd be well-advised to learn it. It creates a list but that is inconsequential. Here is the fixed code (to actually generate permutations) and examples:

    >>> from itertools import *
    >>> [s for s in product(range(2), repeat=2) if len(set(s))==2]
    [(0, 1), (1, 0)]
    >>> [s for s in product(range(3), repeat=3) if len(set(s))==3]
    [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
    >>> len([s for s in product(range(4), repeat=4) if len(set(s))==4])
    24
    >>> len([s for s in product(range(5), repeat=5) if len(set(s))==5])
    120


> Python has become a lingua franca in the programming world

I don't think so. Probably depends on your section of the industry. In mine, C, Java and Matlab are all better known than Python.

> you'd be well-advised to learn it

I did; a few times, actually. I just keep forgetting because I never get an opportunity to use it. Once you've used well over 10 languages, you don't even try to maintain your skills as that would be a waste of time. You just relearn the language next time you need it, especially as popular languages come and go. Standard mathematical notation, however, has been with us, pretty much unchanged, for about 100 years now.

In any event, you can't express in Python nearly everything you can express in standard mathematical notation, unless Python has gained some features that allow it to express uncomputable objects since last time I used it. Does the itertools library support infinite sequences? How about uncountable sets?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: