Timeline for Difference between @ and @@
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 15, 2013 at 13:10 | comment | added | rcollyer | Interesting. I'll have to play with it at some point. | |
Nov 15, 2013 at 7:24 | comment | added | Hector |
@rcollyer: Apparently, the criteria is not AtomQ but Length[exp]==0 . See Anon's comment in this follow-up question.
|
|
Nov 15, 2013 at 4:42 | comment | added | Hector |
@george2079: An "exception" to what rcollyer wrote about AtomQ is the following: myAtom /: AtomQ[myAtom[__]] := True; f@@myAtom[1, 2, 3] returns f[1, 2, 3] even though AtomQ[myAtom[1, 2, 3]] returns True . I'll write a full question about this.
|
|
Nov 15, 2013 at 4:22 | comment | added | rcollyer |
@george2079 an "exception" to what Hector said about explicit heads is Complex . AtomQ[Complex[1, 2]] returns True , but it is interpreted as a single indivisible (except mathematically) unit.
|
|
Nov 14, 2013 at 21:41 | comment | added | Hector | @hongchaniyi: After you read this link: Everything is an Expression, play with TreeForm. | |
Nov 14, 2013 at 21:35 | comment | added | Hector |
@george2079: In f@@5 , the problem is not about "discarding" the f but rather that there is no (explicit) head to be replaced. Again, f@@Integer[5] = f[5] because Integer[5] has an explicit head Integer . On the other hand, 5 also has head Integer but it is implicit. Implicit heads are useful for pattern matching, but they are not really there ...
|
|
Nov 14, 2013 at 21:35 | comment | added | user10568 | @Hector Thanks for your comment. It makes sense to me. Could you say more about the meaning of 'Head'. The help document gives some examples, but doesn't give a description or a definition. | |
Nov 14, 2013 at 21:25 | comment | added | george2079 |
Even understanding that distinction, is there some sense to f@@5 simply discarding the f ? Some example where that is actually used?
|
|
Nov 14, 2013 at 20:39 | history | edited | Hector | CC BY-SA 3.0 |
added 524 characters in body
|
Nov 14, 2013 at 20:28 | comment | added | rcollyer |
The chief difference between the two is the whether AtomQ returns True or not. If it does, then Apply doesn't work on it.
|
|
Nov 14, 2013 at 20:24 | history | edited | Hector | CC BY-SA 3.0 |
added 19 characters in body
|
Nov 14, 2013 at 20:14 | history | edited | Hector | CC BY-SA 3.0 |
added 3 characters in body
|
Nov 14, 2013 at 20:09 | history | answered | Hector | CC BY-SA 3.0 |