Skip to main content

Timeline for Is there a name for #1@#2&?

Current License: CC BY-SA 3.0

15 events
when toggle format what by license comment
Jun 16, 2020 at 9:23 history edited CommunityBot
Commonmark migration
Apr 13, 2017 at 12:56 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Jul 19, 2013 at 14:24 vote accept Kuba
Jul 18, 2013 at 17:36 comment added Leonid Shifrin @Jagra Ok, done. Thanks for the upvote and feedback.
Jul 18, 2013 at 17:35 history edited Leonid Shifrin CC BY-SA 3.0
Added my comments on Function here, per request of Jagra
Jul 18, 2013 at 17:01 comment added Jagra +1, for the insight your answer and comments give into Mathematica's paradigm. Your comments relay so much information on this, I'd like to see them added to your answer. They really provide the larger context.
Jul 18, 2013 at 13:07 comment added Leonid Shifrin @Stefan Yes, Function is used to delay evaluation, basically as a run-time macro with delayed evaluation, but not to construct expressions from pieces. I guess this is a Mathematica - specific issue and may be unintuitive when viewed from viewpoints of some other languages. In a sense, there are no functions in Mathematica, just rules and evaluation procedure.
Jul 18, 2013 at 12:59 comment added Stefan @LeonidShifrin understand. thank you! but we could write something like FCall[a_,b_] := HoldForm[a[b]]. i know this will only work for 2 arguments, but that is what i did expect from Function in the first place, but not anymore after reading your explanation.
Jul 18, 2013 at 12:50 comment added Leonid Shifrin @Stefan ... Therefore, using Function in MapThread will be no different from any other head, which is what you can observe when substituting Function into MapThread in the original example. Put in other way, Function takes care of slots and the ampersand in #1@#2&, but not of @, which is the important thing here.
Jul 18, 2013 at 12:48 comment added Leonid Shifrin @Stefan So Function has to use lazy evaluation, to allow us to separate the process of defining a function expression, from calling that function with some arguments, from "definition-time" to run-time (thus Function is HoldAll). This is a different purpose from that of Compose and Composition (which, for example, don't carry Hold*-attributes, because they don't have to prevent any evaluation). By itself, Function is not able to syntactically construct an expression from its head and elements. And MapThread[f,{{a,b},{x,y}}] will return {f[a,x],f[b,y]} for a generic f...
Jul 18, 2013 at 12:43 comment added Leonid Shifrin @Stefan This is a syntactic issue. Compose is used basically to construct the square brackets, which is syntactically (and also semantically) non-trivial operation. You don't have to tie that to functions - you can think of Compose as a tool for programmatic building of normal expressions with non-trivial heads (the same is also true for Composition). Now, Function serves a different purpose - it allows to construct function calls programmatically by generating a function call code from a function (basically a macro with placeholders) and a sequence of arguments at run-time.
Jul 18, 2013 at 12:37 comment added Stefan @LeonidShifrin chapeau again and again (+1)...i have still one question, if we say that #@#2& is short for Function[#1[#2]] then i don't see why: MapThread[Function, {{a,b,c},{1,2,3}}] shouldn't work...the intention is clear.
Jul 18, 2013 at 12:28 comment added Leonid Shifrin @Kuba No problem :). This question was destined to emerge sooner or later.
Jul 18, 2013 at 12:26 comment added Kuba This is the first case when I do not see any reason to wait with accept :) But I will to be fair :) Thank You.
Jul 18, 2013 at 12:22 history answered Leonid Shifrin CC BY-SA 3.0