
Hello there, name's Frank-Andre Riess. Nice to meet you m(_ _)m So, well, my first question on this list is admittedly somewhat simple, but I managed to delay it long enough and now I think I should ask about it: Does ($) have any relevance at all except for being a somewhat handier version of parentheses? Thanks in advance for taking the time to enlighten me. Regards, FAR

On Thu, 2 Jun 2005, Frank-Andre Riess wrote:
name's Frank-Andre Riess. Nice to meet you m(_ _)m
Hello!
So, well, my first question on this list is admittedly somewhat simple, but I managed to delay it long enough and now I think I should ask about it: Does ($) have any relevance at all except for being a somewhat handier version of parentheses?
Well, it's nice to be able to pass ($) as an argument, a higher order function that does function application, so you can write things like, foldr ($) 6 [(/5),(+3),(*2)] and hopefully more useful things too. -- Mark

(oops, wanted to reply to the list, sent this directly the first time) It's not all that much, but there are some uses outside of getting rid of parentheses. What do you want for something defined as "f $ x = f x"? :) It's just the identity function restricted to functions. You might occasionally see something along the lines of "zipWith ($) fs xs" to apply each function in the list fs to the corresponding element of the list xs. While "zipWith id fs xs" also works, it's not quite as clear to the reader what is going on. ($) means "apply this function to this value" specifically, while id doesn't quite have that overtone. My take is that it's somewhat like otherwise = True. It's mostly there to clear up syntax and give some clues as to meaning. - Cale

Hello there,
name's Frank-Andre Riess. Nice to meet you m(_ _)m
Welcome.
So, well, my first question on this list is admittedly somewhat simple, but I managed to delay it long enough and now I think I should ask about it: Does ($) have any relevance at all except for being a somewhat handier version of parentheses?
That's mostly how it is used (although some will say that it is a terrible idea), but one can also do some pretty neat tricks with it as a higher-order function. Eg, zipWith ($) Is a function which takes a list of functions and a list of arguments and applies the functions pairwise with the arguments. In addition, because of the way the zip* functions work, you can create an infinite cycle of functions to apply to some arguments as in: zipWith ($) (cycle [sin,cos]) [1..5] which is equivalent to: [sin 1,cos 2,sin 3,cos 4,sin 5] I'm sure there are other more esoteric things, but this is about as complex as I try to go to avoid severe headaches :) Robert Dockins

At 20:53 02/06/05 +0200, Frank-Andre Riess wrote:
So, well, my first question on this list is admittedly somewhat simple, but I managed to delay it long enough and now I think I should ask about it: Does ($) have any relevance at all except for being a somewhat handier version of parentheses?
In addition to the other responses, I add this: The section expression ($v) -- for some value v appropriate appropriate to the source code context -- is sometimes very useful. (I think the other feature -- lower precedence of $ w.r.t normal function application -- is covered by your question.) #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact
participants (5)
-
Cale Gibbard
-
Frank-Andre Riess
-
Graham Klyne
-
Mark Carroll
-
robert dockins