Re: functions with unlimeted variable arguments...

2005-06-19 Thread Xah Lee
definition with variable/default parameters is a basic issue a programer wants to know, and different languages differs very much in how they handle this. This is what i mean that the language doc should be programing oriented, as opposed to computer-sciency or implementation oriented... Xah [EMAIL

Re: Python documentation problem

2005-06-18 Thread Xah Lee
dustry geeking moron's need to computer-sciency speak with implementation infatuation. And in part it came to that really because they are comparative morons. for a more sincere, detailed account, please see: http://xahlee.org/perl-python/re-write_notes.html Thanks. Xah [EMAIL PROTEC

Re: Python documentation problem

2005-06-18 Thread Xah Lee
Apparently i tried it before posting eval '3' and got misleading errors because i forgot the parenthesis... This is a easy one to find in the doc... The unhelpful doc organization and past experiences confounded this case. Thanks. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/

Re: Python documentation problem

2005-06-18 Thread Xah Lee
i wanted to find out if Python supports eval. e.g. somecode='3+4' print eval(somecode) # prints 7 in the 14 hundred pages of python doc, where am i supposed to find this info? Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Python documentation problem

2005-06-18 Thread Xah Lee
e.org/perl-python/re-write_notes.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

functions with unlimeted variable arguments...

2005-06-18 Thread Xah Lee
how can i define a function with variable parameters? For example, f(a) would return [a] f(a,b) would return [a,b] f(a,b,...) would return [a,b,...] One solution is of course to make the argument as a list. i.e. f([a,b,...]) but are there other solutions? Xah [EMAIL PROTECTED] ∑ http

Re: tree functions daily exercise: Table

2005-06-17 Thread Xah Lee
l in processing tree structures, such as XML and many other things spurn from it today. Disclaimer: this project is not affiliated with Wolfram Research Inc. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

count string replace occurances

2005-06-12 Thread Xah Lee
if i have mytext.replace(a,b) how to find out many many occurances has been replaced? Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: tree functions daily exercise: Table

2005-06-12 Thread Xah Lee
approved by Wolfram Research Incorporated.) The first argument of Table function in Mathematica (mma) is a expression. Most other languages cannot have such symbolic expressions. In Perl, a string is choosen instead as the experssion, and it is being evalutade later as code. This may not be a practical choice but anyway it's just a exercise. Each other language should choose appropriate design for this emulation... Perl, Python, Java solutions will be posted by me in the coming days. Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

tree functions daily exercise: Range

2005-06-12 Thread Xah Lee
sions archived here: http://xahlee.org/tree/tree.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ Dear functional programers, i run services called a-python-a-day and a-java-a-day, where each day i give a tip or snippet of code in these languages, also as a way for me to learn these languages

Re: What are OOP's Jargons and Complexities?

2005-06-07 Thread Xah Lee
along with its 40 or so methods and other things. http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html (local copy) --- to be continued... This is part of an installment of the article “What are OOP's Jargons and Complexities” by Xah Lee, 20050128. The full text is at http://xahle

Re: What are OOP's Jargons and Complexities?

2005-06-03 Thread Xah Lee
argons and Complexities” by Xah Lee, 20050128. The full text is at http://xahlee.org/Periodic_dosage_dir/t2/oop.html © Copyright 2005 by Xah Lee. Verbatim duplication of the complete article for non-profit purposes is granted. The article is published in the following newsgroups: comp.lang.c,c

Re: What are OOP's Jargons and Complexities?

2005-05-31 Thread Xah Lee
ment of the article “What are OOP's Jargons and Complexities” by Xah Lee, 20050128. The full text is at http://xahlee.org/Periodic_dosage_dir/t2/oop.html © Copyright 2005 by Xah Lee. Verbatim duplication of the complete article for non-profit purposes is granted. The article is publish

Re: What are OOP's Jargons and Complexities?

2005-05-28 Thread Xah Lee
are usually treated as a special method at the language level, its concept and linguistic issues is a OOP machinery complexity, while the Accessor concept is a OOP engineering complexity. - to be continued tomorrow. This is part of an installment of the article “What are OOP's Jargons and

Re: What are OOP's Jargons and Complexities?

2005-05-26 Thread Xah Lee
/writ/jargons.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Xah Lee
of static versus instance members, is one complexity arising out of OOP. -- to be continued tomorrow. This is part of an installment of the article “What are OOP's Jargons and Complexities” by Xah Lee, 20050128. The full text is at http://xahlee.org/Periodic_dosage_dir/t2/oop.html

What are OOP's Jargons and Complexities?

2005-05-23 Thread Xah Lee
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } In advanced languages such as LISP family, it is not uncomm

What are OOP's Jargons and Complexities?

2005-05-23 Thread Xah Lee
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } In advanced languages such as LISP family, it is not uncomm

Re: tree functions daily exercise

2005-05-16 Thread xah
nline http://documents.wolfram.com/mathematica/ Xah [EMAIL PROTECTED] â http://xahlee.org/ sa wrote: > xah: > > i've provided k implementations here: > > http://www.nsl.com/k/xah.k > > of a dozen or so of the functions in your toolkit. many are trivial, > since they&

Re: Range function

2005-05-15 Thread Xah Lee
e not expected to be exemplary. These are exercises for all, also as a intro to functional programing to industry programers. Also, later on there will be non-trivial problems. # -*- coding: utf-8 -*- # Python # http://xahlee.org/tree/tree.html # Xah Lee, 2005-05 import math; def Range(iMin, iMax

Re: Range function

2005-05-15 Thread Xah Lee
Here's the Python solution. -- # -*- coding: utf-8 -*- # Python # http://xahlee.org/tree/tree.html # Xah Lee, 2005-05 # implementation note: When iStep is a decimal, rounding error # accumulates. For example, the last item returned from # Range(0,18,0.3) is 17.7 not 18. A remedy

Re: Range function

2005-05-15 Thread Xah Lee
Here's the Perl code. -- #! perl # http://xahlee.org/tree/tree.html # Xah Lee, 2005-05 #_ Range _ _ _ _ =pod B Range($iMax) generates the list [1, 2, ... , $iMax]. Range($iMin, $iMax) generates the list [$iMin, ... , $iMax]. Range($iMin, $iMax, $iStep)

Re: function with variable arguments

2005-05-14 Thread Xah Lee
, 6.5, 6.8] Range( 5, -4, -2); # returns [5,3,1,-1,-3] Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

function with variable arguments

2005-05-13 Thread Xah Lee
n't a solution. can this be done in Python? or, must the args be changed to a list? Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python regex Doc

2005-05-13 Thread Xah Lee
, either personally or as part of the Python collective, to behave properly. Xah [EMAIL PROTECTED] â http://xahlee.org/ Newsgroups: comp.lang.python From: Ron Adam <[EMAIL PROTECTED]> - Find messages by this author Date: Sat, 07 May 2005 20:23:35 -0400 Local: Sat,May 7 2005 8:23Âpm Su

[perl-python] Range function

2005-05-12 Thread Xah Lee
Today we'll be writing a function called Range. The Perl documentation is as follows. Perl & Python & Java Solutions will be posted in 48 hours. This is Perl-Python a-day. See http://xahlee.org/web/perl-python/python.html Xah [EMAIL PROTECTED] â http

[perl-python] Range function

2005-05-12 Thread Xah Lee
Today we'll be writing a function called Range. The Perl documentation is as follows. Perl & Python & Java Solutions will be posted in 48 hours. This is Perl-Python a-day. See http://xahlee.org/web/perl-python/python.html Xah [EMAIL PROTECTED] â http

Re: New Python regex Doc (was: Python documentation moronicities)

2005-05-07 Thread Xah Lee
x module is at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html See also: Responsible Software Licensing http://xahlee.org/UnixResource_dir/writ/responsible_license.html Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python regex Doc (was: Python documentation moronicities)

2005-05-06 Thread Xah Lee
erratum: the correct URL is: http://xahlee.org/perl-python/python_re-write/lib/module-re.html Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python regex Doc (was: Python documentation moronicities)

2005-05-06 Thread Xah Lee
is archived at: http://xahlee.org/perl-python/re-write_notes.html Xah [EMAIL PROTECTED] â http://xahlee.org/ â -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python regex Doc (was: Python documentation moronicities)

2005-05-05 Thread Xah Lee
s to be classified according to some Python idiosyncrasies or categorization by some forced âcomputer scienceâ outlook. The complete rewritten doc is here: http://xahlee.org/perl-python/python_re-write/lib/module-re.html - There were more issues and notes... but this will be it for today. Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python documentation moronicities (continued)

2005-04-25 Thread Xah Lee
Dear Steve Holden, the rewrite of the regex doc is instigated by your offer. it is published and announced here on April 18th. If you deem it proper, paypal me. It will be to your credit and easier to incorporate into the main doc. Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http

Re: Python documentation moronicities (continued)

2005-04-25 Thread Xah Lee
I have produced my doc. ( http://xahlee.org/perl-python/python_re-write/lib/module-re.html ) isn't there a hundred dollars due to me? Xah [EMAIL PROTECTED] â http://xahlee.org/PageTwo_dir/more.html Steve Holden wrote: > Xah Lee wrote: > [mountains of irrelevant drivel which no

Re: New Python regex Doc (was: Python documentation moronicities)

2005-04-19 Thread Xah Lee
send your feedbacks to Steve Holden. (http://www.holdenweb.com/) If he deem it proper, he will paypal me $100 bucks, and you can thank him for the instigation and betterment of the Python doc. Meanwhile, feel free to incorporate my edits into python doc. Xah [EMAIL PROTECTED] â http

New Python regex Doc (was: Python documentation moronicities)

2005-04-18 Thread Xah Lee
WRITERS or NEED EXAMPLE HERE. Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

re module methods: flags(), pattern()

2005-04-17 Thread Xah Lee
suppose the same for groupindex() ) thanks. Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode "em space" in regex

2005-04-17 Thread Xah Lee
t by null bytes here? Unprintable chars?? and the "\number" is meant to be decimal? and in what encoding? Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

unicode "em space" in regex

2005-04-16 Thread Xah Lee
how to represent the unicode "em space" in regex? e.g. i want do something like this: fracture=re.split(r'\342371*\|\342371*',myline,re.U) Xah [EMAIL PROTECTED] â http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] Python documentation moronicities (continued)

2005-04-12 Thread Xah Lee
the doc is talking about? But, can this doc be (re-)written effectively and easily so that any programers needn't do trial'n'error post-reading? The answer to the questions are resounding yeses, you fucking asses. paypal me a hundred dollars and i'll rewrite the whole re doc in a f

Re: EOL created by .write or .encode

2005-04-10 Thread Xah Lee
can any GNU person or emacs coder answer this? specifically: why does what-cursor-position give incorrect answer. Xah [EMAIL PROTECTED] â http://xahlee.org/PageTwo_dir/more.html â Xah Lee wrote: > I found the problem now. (after some one hour debug time) Python > didn't have pro

Re: EOL created by .write or .encode

2005-04-09 Thread Xah Lee
ursor position and the char's ascii code, says the EOL is ascii 10 when it is in fact ascii 13. Fuck the irresponsible fuckhead who is responsible for this. http://xahlee.org/UnixResource_dir/writ/responsible_license.html Xah [EMAIL PROTECTED] â http://xahlee.org/ Xah Lee wrote: > Why is

EOL created by .write or .encode

2005-04-04 Thread Xah Lee
happen. findreplace = [ (ur'', ur'''tt '''), ] ... inF = open(filePath,'rb') s=unicode(inF.read(),'utf-8') inF.close() for couple in findreplace: outtext=s.replace(couple[0],couple[1]) s=outtext outF = open(temp

Re: Python docs [was: function with a state]

2005-03-28 Thread Xah Lee
ing needs to be Python-as-is, as opposed to computer science framework. I'll might have to give more details in the future, but I've made some headway in this respect before; peruse: http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html Xah [EMAIL PROTECTED] â http://xahlee.org

Re: sorting matrixes

2005-03-27 Thread Xah Lee
2]: result.sort(lambda x,y: cmp(float(x[dir[0]]), float(y[dir[0]])) ) else: result.sort(lambda x,y: cmp(float(x[dir[0]]), float(y[dir[0]])), None, True ) return result m = [ [3, 99, 'a'], [2, 77, 'a'], [1, 77, '

[perl-python] limericks

2005-03-25 Thread Xah Lee
Better: there is a Python, pithy mighty, lissome, and tabby algorithms it puffs conundrums it snuffs and cherished by those savvy there is a camel, kooky ugly, petty, ungainly hacking it supports TIMTOWTDI it sports and transports DWIM-wit's fancy Xah [EMAIL PROTECTED] â http://xahle

Re: Python docs [was: function with a state]

2005-03-24 Thread Xah Lee
umm... looks like it should've been: Comparison can be chained, and is equivalent to a sequence of comparisons with âandâ in between. For example, âxhttp://xahlee.org/ Terry Reedy wrote: > >Comparisons can be chained, and is evaluated from left to right. For > >example, x < y <= z is equivalent t

Re: Python docs [was: function with a state]

2005-03-24 Thread Xah Lee
there is a Python, pithy mighty, lissome, and tabby algorithms it puffs tim-toady it engulfs and sways universality there is a camel, lanky ugly, petty, ungainly foolhardy comports hacking it supports and toadies eunuch's fancy Xah [EMAIL PROTECTED] â http://xahlee.org/PageTwo_dir/more

Re: Python docs [was: function with a state]

2005-03-24 Thread Xah Lee
common and does not indicate incompetence), being aware of it helps greatly in its exposition. This and past critics on Python documentation and IT doc in general is archived at http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html Xah [EMAIL PROTECTED] â http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] sorting matrixes

2005-03-22 Thread Xah Lee
Today we'll write a program that can sort a matrix in all possible ways. Here's the Perl documentation. I'll post a Perl and Python version in 2 days. --- sort_matrix( $matrix, [[$n1, $stringQ, $directionQ], [$n2, $stringQ, $directionQ], ...]) sorts a matrix by $n1 th column then $n2 th.

Re:[perl-python] a program to delete duplicate files

2005-03-20 Thread Xah Lee
Combo114.py Genpair114.py Here're the files: del_dup.zip - to get the code and full detail with latest update, please see: http://xahlee.org/perl-python/delete_dup_files.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html Claudio Grondi wrote: > >> I'

Re: [perl-python] unicode study with unicodedata module

2005-03-16 Thread Xah Lee
Fuck google incorporated for editing my subject name without permission. and fuck google incorporated for editing my message content without permission. http://xahlee.org/UnixResource_dir/writ/responsible_license.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http

Re: unicode study with unicodedata module

2005-03-16 Thread Xah Lee
, '|', name(x,'-') -- http://xahlee.org/perl-python/unicodedata_module.html anyone wants to supply a Perl version? Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html Brian McCauley wrote: > Xah Lee wrote: > > > i don't know what's the state of Perl's unicode. > > perldoc perlunicode -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode study with unicodedata module

2005-03-15 Thread Xah Lee
how do i get a unicode's number? e.g. 03ba for greek lowercase kappa? (or in decimal form) Xah Xah Lee wrote: > python has this nice unicodedata module that deals with unicode nicely. > > #-*- coding: utf-8 -*- > # python > > from unicodedata import * > > # each u

[perl-python] unicode study with unicodedata module

2005-03-15 Thread Xah Lee
27;s unicode. Is there something similar? -- this post is archived at http://xahlee.org/perl-python/unicodedata_module.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

python version anachronism

2005-03-15 Thread Xah Lee
"released ..." indicates the doc or the doc and the software? Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] a program to delete duplicate files

2005-03-09 Thread Xah Lee
e program. a absolute requirement in this problem is to minimize the number of comparison made between files. This is a part of the spec. feel free to write it however you want. I'll post my version in a few days. http://www.xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: function with a state

2005-03-09 Thread Xah Lee
Nevermind. I was thinking too much. :) Thanks. Xah Peter Hansen wrote: > Xah Lee wrote: > >>def myFun(var): > >> return var+1 > >>globe = 0 > >>globe = myFun(globe) > > > > this is intriguing. How does it work? > > not a rhetoric

Re: function with a state

2005-03-08 Thread Xah Lee
>def myFun(var): > return var+1 >globe = 0 >globe = myFun(globe) this is intriguing. How does it work? not a rhetorical question, but where in the python doc can i read about it? thanks. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python

Python docs [was: function with a state]

2005-03-08 Thread Xah Lee
nutshell, these people are spreading untruths and indirectly are causing massive harm in the computing industry. People, we need to stop it. This each of us can do by not accepting their attitudes or behavior. In online forums, work place, conventions, conversations etc., raise questions or otherwi

Re: convert gb18030 to utf16

2005-03-07 Thread Xah Lee
Truely superb! Thanks! Xah [EMAIL PROTECTED] http://xahlee.org/ [EMAIL PROTECTED] wrote: > Xah Lee <[EMAIL PROTECTED]> wrotE: > > > i have a bunch of files encoded in GB18030. Is there a way to convert > > them to utf16 with python? > > You will need CJKCod

function with a state

2005-03-06 Thread Xah Lee
ython doc is quite stilted. Where in the python doc is a programer supposed read about how the package/module system in Python works? (besides the tutorial that touches it) Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

convert gb18030 to utf16

2005-03-06 Thread Xah Lee
i have a bunch of files encoded in GB18030. Is there a way to convert them to utf16 with python? Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-03-06 Thread Xah Lee
if i understand correctly, forms such as (lambda x,y:x+y)(a,b) can only be gained thru experience? and not documented directly anywhere in the official docs? Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-03-03 Thread Xah Lee
PS sorry for the rude remarks out of nowhere. Xah -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-03-03 Thread Xah Lee
n throughly brainwashed by imperative shits. (and these morons don't even know it) i'll explain the ins and outs of expressions of functions some other day. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-03-02 Thread Xah Lee
once i have a expresson of a function, how to apply it to arguments? e.g. if i have lambda x,y:x+y i have to applied it to a,b in my code. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: [perl-python] generate all possible pairings

2005-03-01 Thread Xah Lee
t in range(s) @for a in partiSet[t] @for b in partiSet[s]] @ @ll=( [[9,1],[5],[2,8,7]]) @t=genpair(ll) @t2=genpair2(ll) @if (t.sort()==t2.sort()): print 'yay' Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] generate all possible pairings

2005-02-26 Thread Xah Lee
]] (we do not assume the given set has order, so the result is not ordered.) Perl code and Python code will be posted in 2 days. This is brought to you by the perl-python community. To subscribe, see http://xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir

Re: generic equivalence partition

2005-02-26 Thread Xah Lee
org/UnixResource_dir/writ/responsible_license.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html Xah Lee wrote: > folks: > > when using google to post a reply, it sometimes truncates the subject > line. i.e. [perl-python] is lost. This software error is obvious,

Re: generic equivalence partition

2005-02-26 Thread Xah Lee
rate a law suit and if such company do not take software correctness seriously, we must punish them. Please spread this awareness. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-02-26 Thread Xah Lee
guages are hardware-centric), as opposed to algorithm math concepts. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

function expression with 2 arguments

2005-02-26 Thread Xah Lee
is there a way to write a expression of a function with more than 1 argument? e.g., i want a expression that's equivalent to def f(x,y) return x+y Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: generic equivalence partition

2005-02-26 Thread Xah Lee
lee.org/perl-python/gen_parti_by_equiv.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] generic equivalence partition

2005-02-24 Thread Xah Lee
the predicate given. For example, in the given example, it tells us that the 2nd, 3rd, 4th elements are equivalent. And they are equivalent measured by the predicate function given, which basically tests if their last item are the same integer. (note that if we want to view the result as indexes, then it is 1-based index. i.e. counting starts at 1.) PS if you didn't realize yet, nested lists/dictionaries in perl is a complete pain in the ass. PS note that the code "sub {$_[0]->[3] == $_[1]->[3]}" is what's called the lambda form, in Perl. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: exercise: partition a list by equivalence

2005-02-23 Thread Xah Lee
rsions from Reinhold Birkenfeld, the one using graphs by bearophile ... since many of you have already collected and tested these... i wonder if anyone'd be interested to put together all the (working) code in a single message? (or even a webpage.) thanks. Xah [EMAIL PROTECTED] http

[perl-python] exercise: partition a list by equivalence

2005-02-20 Thread Xah Lee
| sets.get(x2, frozenset([x2]))) ©for i in newset: ©sets[i] = newset © ©return [list(aset) for aset in set(sets.itervalues())] it would be nice if the two working programs do not use some package. This problem shouldn't need to. Xah [EMAIL PROTECTED]

Re: exercise: partition a list by equivalence

2005-02-19 Thread Xah Lee
on, each number represent a computer file, there are up to tens of thousands of files, and much less than 0.1% is same as another, and for files that are same, each equivalent group number no more than 10 or so.) Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html John Machin wrote: &

Re: exercise: partition a list by equivalence

2005-02-19 Thread Xah Lee
break ©if (goto): ©goto=False ©break ©else: ©fin.append(group) comlete code is at: http://xahlee.org/perl-python/partition_by_equiv.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailma

[perl-python] exercise: partition a list by equivalence

2005-02-19 Thread Xah Lee
version can also use some clean up, or even rewrite as a program in the Python language proper. Addenda or Errata will be added on this page. PS all together there are some 3 or so solutions posted on the newsgroups. (one by private email) I will have to filter them out and study them. Any interesting or important Addenda or Errata will be emailed out later. In addition to being archived here: http://xahlee.org/perl-python/partition_by_equiv.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] exercise: partition a list by equivalence

2005-02-17 Thread Xah Lee
-python/python.html == Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: [perl-python] problem: reducing comparison (erratum)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python > and Java, in general it is not safe to delete > elements when looping thru a list-like entity. > (it screws up the iteration) One must make a > copy first, and work with the copy. Correction: When looping thru a l

Re: [perl-python] problem: reducing comparison (erratum)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python > and Java, in general it is not safe to delete > elements when looping thru a list-like entity. > (it screws up the iteration) One must make a > copy first, and work with the copy. Correction: When looping thru a l

Re: [perl-python] problem: reducing comparison (correction)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python and Java, in general it > is not safe to delete elements when looping thru a list-like entity. > (it screws up the iteration) One must make a copy first, and work with > the copy. Correction: When looping thru a list

Re: problem: reducing comparison

2005-02-16 Thread Xah Lee
ps.pop("%d,%d"%(j[1],k[0]),0) ©return ps © ©is reduce2 more efficient? It works entirely differently. I'll have to think about it... besides algorithmic... onto the minute academic diddling, i wonder if it is faster to delete entries in dict or add entries... Xah [EMAIL

Re: problem: reducing comparison

2005-02-15 Thread Xah Lee
my Python coding is not experienced. In this case, is ps.pop("%d,%d"%(j[1],k[1]),0) out of ordinary? if i have long paragraphs of documentation for a function, do i still just attach it below the fun def? Xah Xah Lee wrote: > here are the answers: > > ©Python code. > ©

Re: [perl-python] problem: reducing comparison

2005-02-15 Thread Xah Lee
on) One must make a copy first, and work with the copy. Note also that in Python there's already a function called reduce. (it is equivalent to Mathematica's Fold.) In Python, looks like user can over-ride default functions. This post is archived at http://xahlee.org/perl-python/pairing_redu

[perl-python] problem: reducing comparison

2005-02-14 Thread Xah Lee
should be. I'll post Perl and Python codes tomorrow for those interested. If you are a perl programer, try to code it in Python. (it's easy.) This is brought to you by the Perl-Python a-day community. To subscribe, see http://xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http

[perl-python] 20050211 generating expression by nested loops

2005-02-12 Thread Xah Lee
athematica.html # look for the function named Table. his is Perl-Python a-day. To subscribe, see http://xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: [perl-python] combinatorics fun

2005-02-10 Thread Xah Lee
range(1,n+1): ©m = ((i+j)-1) % n + 1 © if (i < m): ©result["%d,%d"%(i,m)]=(i,m) ©return result © ©print combo(4) So sweet. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] combinatorics fun

2005-02-10 Thread Xah Lee
bo ($) { my $max=$_[0]; my %hh=(); for (my $j=1; $j < $max; ++$j) { for (my $i=1; $i <= $max; ++$i) { my $m = (($i+$j)-1)%$max+1; if ($i < $m){ $hh{"$i,$m"}=[$i,$m];} } } return \%hh; } use Data::Dumper; $Data::Dumper::Indent=0; pr

Re: python code with indention

2005-02-09 Thread Xah Lee
i thought it is trivial for the Python parser to spit out a version with matching brackets. Similarly, perhaps some opensourcing student has modified a parser to read in a matching brackets delimited version of Python. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http

python code with indention

2005-02-07 Thread Xah Lee
is it possible to write python code without any indentation? Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] text pattern matching, and expressiveness

2005-02-07 Thread Xah Lee
ctical variation. These two contrasting ideas can be easily seen thru Perl vs Python languages, and as one specific example of their text pattern matching abilities. Perl is a language of syntactical variegations. Python on the other hand, does not even allow changes in code's indentation, bu

[perl-python] get web page programatically

2005-02-04 Thread Xah Lee
ve perl code. In many perl codes, they sport the Object Oriented syntax, often concomitantly with a normal syntax version as well. this post is from the perl-python a-day mailing list. Please see http://xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a tutorial

2005-02-02 Thread Xah Lee
st uses. Spending time to read this book of specialization, from economy perspective, is a waste of time. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

Re: how to write a tutorial

2005-02-02 Thread Xah Lee
; server = smtplib.SMTP(smtpServer) server.set_debuglevel(1) server.sendmail(fromAddr, toAddr, text) server.quit() Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] string pattern matching

2005-02-01 Thread Xah Lee
no"} if ( $text =~ [EMAIL PROTECTED]@) { print 'yes'} else {print "no"} # for detail of its much ado about nothing nature, # see perldoc perlre this is perl-python a-day mailing list. To subscribe, see http://xahlee.org/perl-python/python.html Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] find & replace strings for all files in a dir

2005-01-31 Thread Xah Lee
ne fileFilterQ to set which file will be checked or skipped. to do: * in the report, print the strings that are changed, possibly with surrounding lines. * allow just find without replace. * add the GNU syntax for unix command prompt. * Report if backup directory exists already, or provide togg

Q: quoting string without escapes

2005-01-31 Thread Xah Lee
in Python, is there a way to quote a string as to avoid escaping ' or " inside the string? i.e. like Perl's q or qq. thanks. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

[perl-python] sending email

2005-01-29 Thread Xah Lee
me discussion of the plethora of Perl mail modules and their short-cummings, see http://alma.ch/perl/mail.htm Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   >