I tried the following code (ignoring the warning messages):

{#, # &, Function[{x}, #], Function[{#}, x], Function[{#}, #]} &@7
(*result: {7, #1 &, Function[{x}, 7], Function[{7}, x], Function[{7}, 7]}*)

I wonder why #& was not changed into 7&. I saw a "possible issue" similar to this mentioned in ref/Slot, but I couldn't find further documentation about it. Is it a bug or it is specially designed this way?

  • 1
    $\begingroup$ # & creates a pure function as the second element of the list. Then after the end of the list } you create another pure function and the slots of that function are then filled with 7. $\endgroup$ – Natas Aug 7 at 8:28
  • 1
    $\begingroup$ I think the following set is a bit more illustrative: {Function[#] &[7], Function[Null, #] &[7], Function[x, #] &[7], With[{t = #}, Function[t]] &[7]} $\endgroup$ – J. M.'s discontentment Aug 7 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.