Re: Syntax across languages

2005-10-25 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/syntax

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 Pascal

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 nest comments

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 certain

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 nothing

Syntax across languages

2005-10-23 Thread bearophileHUGS
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/syntax-across-languages.html

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) -

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

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 useful

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 /F --

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.

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 in

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 done.

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. def

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 Python,

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 stdin, line 1, in ? UnicodeDecodeError: 'ascii'

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 in

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 this

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

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 gets

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 page

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)+abs(b))

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 run a bad

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 MeyerRexx 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 AndersonThere are all

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 FP