Re: Syntax across languages

2005-10-25 Thread gene tani
APL, i haven't thought about that in 15 years. I think it was (quad)CT for comparison tolerance, at least in IBM APL. Alex Martelli wrote: > Tom Anderson <[EMAIL PROTECTED]> wrote: >... > > What would approximate FP equality even mean? How approximate? > > In APL, it meant "to within [a certa

Re: Syntax across languages

2005-10-25 Thread Bengt Richter
On 25 Oct 2005 07:46:07 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: >Tim Roberts wrote: > >>> >>>- Nestable Pascal-like comments (useful): (* ... *) >> >> That's only meaningful in languages with begin-comment AND end-comment >> delimiters. Python has only begin-comment. Effectively, you CAN n

Re: Syntax across languages

2005-10-25 Thread Duncan Booth
Tim Roberts wrote: >> >>- Nestable Pascal-like comments (useful): (* ... *) > > That's only meaningful in languages with begin-comment AND end-comment > delimiters. Python has only begin-comment. Effectively, you CAN nest > comments in Python: I believe that the OP is mistaken. In standard Pas

Re: Syntax across languages

2005-10-24 Thread Tim Roberts
[EMAIL PROTECTED] wrote: >This post comes from a boring morning, if you are busy ignore this. >This post is only for relaxed people. > >I've found this page, "Syntax Across Languages", it contains many >errors and omissions, but it's interesting. >http://merd.sourceforge.net/pixel/language-study/s

Re: Syntax across languages

2005-10-24 Thread Fredrik Lundh
Tom Anderson wrote: > This is taken from the AI 754 standard, i take it? :) > > Seriously, that's horrible. Fredrik, you are a bad man, and run a bad > railway. > > However, looking at the page the OP cites, the only mention of that > operator i can find is in Dylan, and in Dylan, it's not

Re: Syntax across languages

2005-10-23 Thread Mike Meyer
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > On Sun, 23 Oct 2005 20:59:46 -0400, Mike Meyer <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > >> Hopefully user defined. Rexx has a global control that lets you set >> the number of digits to be considered significant in doing an

Re: Syntax across languages

2005-10-23 Thread bearophileHUGS
Thank you for all the answers, some people have already answered for me about most details I don't agree :-) Mike Meyer>Rexx has a global control that lets you set the number of digits to be considered significant in doing an FP equality test.< Mathematica too, I think. Tom Anderson>There are a

Re: Syntax across languages

2005-10-23 Thread Mike Meyer
Tom Anderson <[EMAIL PROTECTED]> writes: > On Sun, 23 Oct 2005, Fredrik Lundh wrote: >> [EMAIL PROTECTED] wrote: >>> - ~== for approximate FP equality >> str(a) == str(b) > This is taken from the AI 754 standard, i take it? :) > > Seriously, that's horrible. Fredrik, you are a bad man, and

Re: Syntax across languages

2005-10-23 Thread Alex Martelli
Tom Anderson <[EMAIL PROTECTED]> wrote: ... > What would approximate FP equality even mean? How approximate? In APL, it meant "to within [a certain quad-global whose name I don't recall] in terms of relative distance", i.e., if I recall correctly, "a=b" meant something like "abs(a-b)/(abs(a)+ab

Re: Syntax across languages

2005-10-23 Thread Tom Anderson
On Sun, 23 Oct 2005, Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > >> - ~== for approximate FP equality > > str(a) == str(b) This is taken from the AI 754 standard, i take it? :) Seriously, that's horrible. Fredrik, you are a bad man, and run a bad railway. However, looking at the

Re: Syntax across languages

2005-10-23 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Alex> I've seen enough occurrences of "lambda x: x" in Python code with > Alex> a generally functional style that I'd love to have > Alex> operator.identity (and a few more trivial functions like that) for > Alex> readability;-) > > But, but, but [Skip

Re: Syntax across languages

2005-10-23 Thread skip
Alex> I've seen enough occurrences of "lambda x: x" in Python code with Alex> a generally functional style that I'd love to have Alex> operator.identity (and a few more trivial functions like that) for Alex> readability;-) But, but, but [Skip gets momentarily apoplectic, then reco

Re: Syntax across languages

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > just curious, how can this identity function be used ? In haskell, > because all functions are curried, I can sort of visualize/understand > how id is used. Not quite understand how it can be used in python. There was a very recent example posted to

Re: Syntax across languages

2005-10-23 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > - Information about the current line and file as Ruby: > __LINE__ __FILE__ > Instead of the python version: > inspect.stack()[0][2] inspect.stack()[0][1] __file__ is around in Python, too, but there's no __line__ (directly). > - identity function: "identity" as

Re: Syntax across languages

2005-10-23 Thread garabik-news-2005-05
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> - comparison returns 4 values (i.e. inferior, equal, superior or not >> comparable), as in Pliant: "compare" > cmp("a", "b") > -1 cmp("a", "a") > 0 cmp("b", "a") > 1 cmp("ä", u"ä") > Traceback (most recent call last): > File "", l

Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
"beza1e1" wrote: > It has is uses. I had some kind of parser and had a dict like this: > {case: function, ...} It had to be a dict, because i wanted to > dynamically add and remove cases. In some cases nothing had to be done. > To represent this in the dict a identity function is needed. in Pytho

Re: Syntax across languages

2005-10-23 Thread [EMAIL PROTECTED]
just curious, how can this identity function be used ? In haskell, because all functions are curried, I can sort of visualize/understand how id is used. Not quite understand how it can be used in python. beza1e1 wrote: > >>> id("blub") > -1210548288 > > This is not identity in a mathematical view.

Re: Syntax across languages

2005-10-23 Thread beza1e1
>>> id("blub") -1210548288 This is not identity in a mathematical view. def identity(x): return x It has is uses. I had some kind of parser and had a dict like this: {case: function, ...} It had to be a dict, because i wanted to dynamically add and remove cases. In some cases nothing had to be d

Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Thank you Fredrik Lundh for showing everybody that indeed lot of people > feel the need of such function in Python too. you seem to be missing the point: all those versions are highly optimized, and tuned for the specific use-cases. a generic flatten would be useless i

Re: Syntax across languages

2005-10-23 Thread bearophileHUGS
Thank you Fredrik Lundh for showing everybody that indeed lot of people feel the need of such function in Python too. >to create a generic version, you have to decide which sequences to treat like >sequences< In my version I give the function some parameter(s) to define what I want to flatten. I

Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > >sure looks like four possible outcomes.< > > Right (but to me four explicit answers seem better than three answers > and an exception still). def cmp4(a, b): try: return cmp(a, b) except: return None -- http://mail.python.org/mailman/listi

Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > >if you can define the semantics, it's a few lines of code. if you're not > sure about the semantics, a built-in won't help you...< > > I think the language needs a fast built-in version of it. If something > is both inside Mathematica and Ruby, then probably it can be

Re: Syntax across languages

2005-10-23 Thread bearophileHUGS
Thank you for the comments, Fredrik Lundh. >(that's (mostly) CPython-dependent, and should be avoided)< Then a non CPython-dependent way of doing it can be even more useful. >sure looks like four possible outcomes.< Right (but to me four explicit answers seem better than three answers and an e

Re: Syntax across languages

2005-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > - Information about the current line and file as Ruby: > __LINE__ __FILE__ > Instead of the python version: > inspect.stack()[0][2] inspect.stack()[0][1] (that's (mostly) CPython-dependent, and should be avoided) > - ~== for approximate FP equality str(a) == str(b) >