Unicode in Python
Rustom Mody
rustompmody at gmail.com
Sun Apr 27 13:39:24 EDT 2014
On Wednesday, April 23, 2014 11:29:13 PM UTC+5:30, Rustom Mody wrote:
> On Wednesday, April 23, 2014 1:23:00 PM UTC+5:30, Steven D'Aprano wrote:
> > On Tue, 22 Apr 2014 23:57:46 -0700, Rustom Mody wrote:
> > > On the other hand when/if a keyboard mapping is defined in which the
> > > characters that are commonly needed are available, it is reasonable to
> > > expect the ∨,∧ to cost no more than 2 strokes each (ie about as much as
> > > an 'A'; slightly more than an 'a'. Which means that '∨' is expected to
> > > cost about the same as 'or' and ∧ to cost less than an 'and'
> > Oh, a further thought...
> > Consider your example:
> > return year%4=0 ∧ (year%100≠0 ∨ year%100 = 0)
> > vs
> > return year%4=0 and (year%100!=0 or year%100 = 0)
> > [aside: personally I like ≠ and if there was a platform independent way
> > to type it in any editor, I'd much prefer it over != or <> ]
I checked haskell and find the unicode support is better.
For variables (ie identifiers) python and haskell are much the same:
Python3:
>>> α = 1
>>> α
1
Haskell:
Prelude> let α = 1
Prelude> α
1
However in haskell one can also do this unlike python:
*Main> 2 ≠ 3
True
All that's needed to make this work is this set of new-in-terms-of-old definitions:
[The -- is comments for those things that dont work as one may wish]
--------------
import qualified Data.Set as Set
-- Experimenting with Unicode in Haskell source
-- Numbers
x ≠ y = x /= y
x ≤ y = x <= y
x ≥ y = x >= y
x ÷ y = divMod x y
x ⇑ y = x ^ y
x × y = x * y -- readability hmmm !!!
π = pi
-- ⌊ x = floor x
-- ⌈ x = ceiling x
-- Lists
xs ⤚ ys = xs ++ ys
n ↑ xs = take n xs
n ↓ xs = drop n xs
-- Bools
x ∧ y = x && y
x ∨ y = y || y
-- ¬x = not x
-- Sets
x ∈ s = x `Set.member` s
s ∪ t = s `Set.union` t
s ∩ t = s `Set.intersection` t
s ⊆ t = s `Set.isSubsetOf` t
s ⊂ t = s `Set.isProperSubsetOf` t
s ⊈ t = not (s `Set.isSubsetOf` t)
-- ∅ = Set.null
More information about the Python-list
mailing list