2
$\begingroup$

I would like to write the following code line without the signs @#%^&*?!

Sequence @@ (XMLNote[#1, m] &) /@ attributes

I have made this code but it seems that it should be a slight difference since I no longer the good result in my program

Apply[Sequence, Map[(XMLNote[#1, m]) &, attributes]]

In fact, I started to use Mathematica not a long time ago and for the moment, I prefer to use a more explicit syntax in my code.

Thank you for you help.

$\endgroup$
6
  • 2
    $\begingroup$ If you detest the nonalphanumerics, you can certainly go further: Apply[Sequence, Map[Function[z, XMLNote[z, m]], attributes]] $\endgroup$ May 23, 2015 at 14:41
  • $\begingroup$ perfect, thank you. And what was the mistake in my translation? Otherwise, I don't detest the nonalphanumerics but when I have nested functions, I'm a bit lost when I have too much nonalphanumerics $\endgroup$
    – Bendesarts
    May 23, 2015 at 15:01
  • $\begingroup$ Before that: could you clarify the " I no longer the good result in my program"? Why did you say that it didn't work anymore after making things all explicit? $\endgroup$ May 23, 2015 at 15:03
  • $\begingroup$ Sorry I made a mistake. The two codes were equivalent. Thank you for your help. $\endgroup$
    – Bendesarts
    May 23, 2015 at 15:07
  • $\begingroup$ @Bichoy Thank you for your answer. Very interesting and useful for me. $\endgroup$
    – Bendesarts
    May 28, 2015 at 6:31

1 Answer 1

3
$\begingroup$

How about getting Mathematica to do the work for us?

FullForm[Sequence @@ (XMLNote[#1, m] &) /@ attributes ] // HoldForm

Which yields:

Apply[Sequence,Map[Function[XMLNote[Slot[1],m]],attributes]]

These two expressions are formally equivalent in every single way (they are a different syntax for the same thing). If they yield different results, there must be a bug in some other place in the code, or in how each of them is actually used.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.