On Wednesday 07 July 2010, Gabor Szabo wrote:
> Hi,
>
> > On Thu, Jul 1, 2010 at 5:35 PM, Dov Grobgeld <[email protected]>
wrote:
> >>
> >> Then "python" might look like:
> >>
> >> ∀ n ∈ names:
> >> if n ≠ "foo":
> >> α ← n
> >> ß = re∘search〈"foo", α〉
> >>
>
> I have not done any math for a long, long time. Would you mind explaining
> what would the above do?
>
To complement Haran's reply, the translation of the above exposes why this
wouldn't necessarily be a good idea:
for n in names:
if n != "foo":
a = n
b = re.search("foo",a)
But the differences matter:
Dov chooses to use the function composition operator ∘ for attribute access;
to me, this makes little sense, but perhaps I'm missing something.
Why he avoids the use of parentheses for function application also escapes me.
But most importantly, the use of ∀ (for all) in the loop construct implies
parallelism, or, more accurately, independence between the code applied to
each member of the set -- where Python forces an order and allows
dependencies.
I haven't been in academia for quite some time, but as far as I recall, people
only used ∀ when defining conditions (e.g, """ ∀ n ∈ names: n ≠ "foo" """ as a
boolean expression) using read-only operations; when state-modifying iteration
was intended, people tended to use "for".
My 2 cents,
Shai.
_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il