From: Ben Bacarisse on 14 May 2010 21:40 Lie Ryan <lie.1296(a)gmail.com> writes: > On 05/13/10 21:14, Ben Bacarisse wrote: >> Lie Ryan <lie.1296(a)gmail.com> writes: >> >>> On 05/12/10 23:28, Ben Bacarisse wrote: >>>> Lie Ryan <lie.1296(a)gmail.com> writes: >>>> >>>>> On 05/10/10 18:12, Jussi Piitulainen wrote: >>>>>>>>>> Anything vaguely usable with three operands would do. Median of >>>>>>>>>> three numbers. Majority vote of three booleans. >>>>>>>> >>>>>>>> Many of these are just special cases of N-operand operators. The >>>>>>>> challenge is an operator syntax that allows an arbitrary number of >>>>>>>> operands (and which doesn't look like a single operand which happens >>>>>>>> to be a list, although that is another way of doing it). >>>>>> Yes, I have trouble thinking up any naturally ternary operations. As >>>>>> soon as the notation has brackets and a comma in it, it is natural to >>>>>> extend the number of operands arbitrarily. We do zero, one, two, many. >>>>> >>>>> Think again: function call is an N-ary operator >>>> >>>> Not always. Some languages consider it to be binary (Haskell, for >>>> example) and that works out quite neatly. >>> >>> in Haskell, function call is binary, which is a kind of N-ary. So the >>> statement still hold. > > s/binary/unary We may be talking about different things. I am talking about the function call operator. It takes two operands: a function and the thing to which the function is to be applied. Hence binary. (It's invisible in that Haskell writes it like multiplication in maths using nothing but juxtaposition.) >> You mean because N might equal 2 in the term N-ary? If so a smiley >> would have helped! If not I don't know what you mean and a definition >> might be needed. The context suggests that N-ary is being used to >> describe operators that don't have a single 'arity'. >> > > Why would smiley helps? That statement is just as serious as it can be. > In pure (functional) language, a function that takes 1 argument is 1-ary > operator; a function that takes 2 argument is 2-ary operator, and so on. > They can be generalized as "a function that takes N argument is N-ary > operator". In another post, Pascal J.B pointed out that a 'constant' can > conceptually be thought as a function that takes no argument i.e. a > constant is a function with zero argument is 0-arity operator; so the > statement holds true even when N == 0. You said "function call is an N-ary operator" and I just gave an example where it is not saying "not always". > The fact that the underlying language, in this case Haskell, restricts > function call to take only a single argument doesn't invalidate the > statement. It seems to me it does. Yes, binary is one example of an N-ary operator (with N=2) but I did not think you were saying something that literal and the above seems to confirm it. I agree that function call can be N-ary (in some languages) with N anything from 0 up, but I don't think it always is. In particular, making it binary can be a logical design decision. <snip> -- Ben.
From: Lie Ryan on 15 May 2010 04:03 On 05/15/10 11:40, Ben Bacarisse wrote: > Lie Ryan <lie.1296(a)gmail.com> writes: > >> On 05/13/10 21:14, Ben Bacarisse wrote: >>> Lie Ryan <lie.1296(a)gmail.com> writes: >>> >>>> On 05/12/10 23:28, Ben Bacarisse wrote: >>>>> Lie Ryan <lie.1296(a)gmail.com> writes: >>>>> >>>>>> On 05/10/10 18:12, Jussi Piitulainen wrote: >>>>>>>>>>> Anything vaguely usable with three operands would do. Median of >>>>>>>>>>> three numbers. Majority vote of three booleans. >>>>>>>>> >>>>>>>>> Many of these are just special cases of N-operand operators. The >>>>>>>>> challenge is an operator syntax that allows an arbitrary number of >>>>>>>>> operands (and which doesn't look like a single operand which happens >>>>>>>>> to be a list, although that is another way of doing it). >>>>>>> Yes, I have trouble thinking up any naturally ternary operations. As >>>>>>> soon as the notation has brackets and a comma in it, it is natural to >>>>>>> extend the number of operands arbitrarily. We do zero, one, two, many. >>>>>> >>>>>> Think again: function call is an N-ary operator >>>>> >>>>> Not always. Some languages consider it to be binary (Haskell, for >>>>> example) and that works out quite neatly. >>>> >>>> in Haskell, function call is binary, which is a kind of N-ary. So the >>>> statement still hold. >> >> s/binary/unary > > We may be talking about different things. I am talking about the > function call operator. It takes two operands: a function and the > thing to which the function is to be applied. Hence binary. (It's > invisible in that Haskell writes it like multiplication in maths using > nothing but juxtaposition.) Being implicit is why I considered Haskell's function call is unary. In other languages, the () makes it binary (or greater). Otherwise, you can think of function call as a binary operator, curried by the function's "name"[1] to become a unary operator[2]. So, in a sense, both viewpoints are equally valid in different layer of abstraction. [1] loosely speaking [2] ready to accept an argument >>> You mean because N might equal 2 in the term N-ary? If so a smiley >>> would have helped! If not I don't know what you mean and a definition >>> might be needed. The context suggests that N-ary is being used to >>> describe operators that don't have a single 'arity'. >>> >> >> Why would smiley helps? That statement is just as serious as it can be. >> In pure (functional) language, a function that takes 1 argument is 1-ary >> operator; a function that takes 2 argument is 2-ary operator, and so on. >> They can be generalized as "a function that takes N argument is N-ary >> operator". In another post, Pascal J.B pointed out that a 'constant' can >> conceptually be thought as a function that takes no argument i.e. a >> constant is a function with zero argument is 0-arity operator; so the >> statement holds true even when N == 0. > > You said "function call is an N-ary operator" and I just gave an example > where it is not saying "not always". I think I missed this, and I can't find which post contains that example, mind reposting it? >> The fact that the underlying language, in this case Haskell, restricts >> function call to take only a single argument doesn't invalidate the >> statement. > > It seems to me it does. Yes, binary is one example of an N-ary operator > (with N=2) but I did not think you were saying something that literal > and the above seems to confirm it. I agree that function call can be > N-ary (in some languages) with N anything from 0 up, but I don't think > it always is. In particular, making it binary can be a logical design > decision. the statement "function call is N-ary" is apparently ambiguous, I guess I should quantify that to: "for all P in programming languages, there exists N in natural number, such that, function call in P with M argument is an N-ary operator" (note: the set of natural number I'm using starts with 0, i.e. {0, 1, ....}, and M is a free variable) or stated more simply: "function iff operator" (i.e. function is an operator and operator is a function) the "N-ary"-part is rather redundant but is necessary given the context of the post I'm replying to. with Haskell, M is always exactly 2 (or 1, depending on the level of abstraction being used).
From: Ben Bacarisse on 15 May 2010 12:17
Lie Ryan <lie.1296(a)gmail.com> writes: > On 05/15/10 11:40, Ben Bacarisse wrote: >> Lie Ryan <lie.1296(a)gmail.com> writes: >> >>> On 05/13/10 21:14, Ben Bacarisse wrote: >>>> Lie Ryan <lie.1296(a)gmail.com> writes: >>>> >>>>> On 05/12/10 23:28, Ben Bacarisse wrote: >>>>>> Lie Ryan <lie.1296(a)gmail.com> writes: >>>>>> >>>>>>> On 05/10/10 18:12, Jussi Piitulainen wrote: >>>>>>>>>>>> Anything vaguely usable with three operands would do. Median of >>>>>>>>>>>> three numbers. Majority vote of three booleans. >>>>>>>>>> >>>>>>>>>> Many of these are just special cases of N-operand operators. The >>>>>>>>>> challenge is an operator syntax that allows an arbitrary number of >>>>>>>>>> operands (and which doesn't look like a single operand which happens >>>>>>>>>> to be a list, although that is another way of doing it). >>>>>>>> Yes, I have trouble thinking up any naturally ternary operations. As >>>>>>>> soon as the notation has brackets and a comma in it, it is natural to >>>>>>>> extend the number of operands arbitrarily. We do zero, one, two, many. >>>>>>> >>>>>>> Think again: function call is an N-ary operator >>>>>> >>>>>> Not always. Some languages consider it to be binary (Haskell, for >>>>>> example) and that works out quite neatly. >>>>> >>>>> in Haskell, function call is binary, which is a kind of N-ary. So the >>>>> statement still hold. >>> >>> s/binary/unary >> >> We may be talking about different things. I am talking about the >> function call operator. It takes two operands: a function and the >> thing to which the function is to be applied. Hence binary. (It's >> invisible in that Haskell writes it like multiplication in maths using >> nothing but juxtaposition.) > > Being implicit is why I considered Haskell's function call is unary. In > other languages, the () makes it binary (or greater). Otherwise, you can > think of function call as a binary operator, curried by the function's > "name"[1] to become a unary operator[2]. So, in a sense, both viewpoints > are equally valid in different layer of abstraction. > > [1] loosely speaking > [2] ready to accept an argument I don't follow this at all. The point I made seems to be to uncontentious. From the Haskell Report: "Function application is written e1 e2. Application associates to the left, so the parentheses may be omitted in (f x) y." This describes something that involves two expressions and associates to the left. I call such things binary operators, even when they are implicit in the text, but if you find your view clearer that is fine with me. I can't comment on whether it is clearer because I don't understand it. Maybe I should have quoted Haskell's $ operator that associates to the left and is visible in the text. Would you take that as an example of a binary function call operator? <snip> >> You said "function call is an N-ary operator" and I just gave an example >> where it is not saying "not always". > > I think I missed this, and I can't find which post contains that > example, mind reposting it? Both are quotes from direct ancestors to this message and the text in question remains quoted in this post. I'll re-post if I must but it is usually simple to verify quotes from direct ancestors. >>> The fact that the underlying language, in this case Haskell, restricts >>> function call to take only a single argument doesn't invalidate the >>> statement. >> >> It seems to me it does. Yes, binary is one example of an N-ary operator >> (with N=2) but I did not think you were saying something that literal >> and the above seems to confirm it. I agree that function call can be >> N-ary (in some languages) with N anything from 0 up, but I don't think >> it always is. In particular, making it binary can be a logical design >> decision. > > the statement "function call is N-ary" is apparently ambiguous, I guess > I should quantify that to: > > "for all P in programming languages, there exists N in natural number, > such that, function call in P with M argument is an N-ary operator" Hence my suggestion of a smiley! I even suggested that you might have meant this (i.e. that for Hakell N=2 and so, in this unhelpful sense, function application is N-ary in Haskell). So we agree. Function call is N-ary, for some value of N, in all languages. I am not sure that is worth saying, but I certainly agree with it. > (note: the set of natural number I'm using starts with 0, i.e. {0, 1, > ...}, and M is a free variable) > > or stated more simply: "function iff operator" (i.e. function is an > operator and operator is a function) > > the "N-ary"-part is rather redundant but is necessary given the context > of the post I'm replying to. > > with Haskell, M is always exactly 2 (or 1, depending on the level of > abstraction being used). (You mean "N is always exactly 2" I presume.) -- Ben. |