32
$\begingroup$

I was surprised to see Graph objects are atomic. Is there a way (through documentation or programmatically) to find all atomic heads?

The ones I know of are:

Integer
Rational
Real
Complex
Symbol
String
SparseArray
StructuredArray
SymmetrizedArray
Image (* since v9 *)
Image3D
Graph
ColorProfileData
Association
MeshRegion
BoundaryMeshRegion
Language`ArrayObject
ByteArray
NumericArray
QuantityArray
RawArray
RawData
Audio
Video

Are there any others?

Special Structured Matrices

VandermondeMatrix
CauchyMatrix
ToeplitzMatrix
HankelMatrix
FourierMatrix
HilbertMatrix

Others mentioned in the comments

Internal`Bag
System`Utilities`HashTable
System`RawArray
BooleanFunction
Dispatch (* since v10 *)
Dataset

Neural net functionality

AggregationLayer
BasicRecurrentLayer
BatchNormalizationLayer
CatenateLayer
ConstantArrayLayer
ConstantPlusLayer
ConstantTimesLayer
ContrastiveLossLayer
ConvolutionLayer
CrossEntropyLossLayer
DeconvolutionLayer
DotLayer
DropoutLayer
ElementwiseLayer
EmbeddingLayer
FlattenLayer
GatedRecurrentLayer
ImageAugmentationLayer
InstanceNormalizationLayer
LinearLayer
LocalResponseNormalizationLayer
LongShortTermMemoryLayer
MeanAbsoluteLossLayer
MeanSquaredLossLayer
NetChain
NetDecoder
NetEncoder
NetEvaluationMode
NetExtract
NetFoldOperator
NetGraph
NetInitialize
NetMapOperator
NetModel
NetNestOperator
NetPairEmbeddingOperator
NetPort
NetPortGradient
NetReplacePart
PaddingLayer
PartLayer
PoolingLayer
ReplicateLayer
ReshapeLayer
ResizeLayer
SequenceAttentionLayer
SequenceLastLayer
SequenceMostLayer
SequenceRestLayer
SequenceReverseLayer
SoftmaxLayer
SpatialTransformationLayer
SummationLayer
ThreadingLayer
TotalLayer
TransposeLayer
UnitVectorLayer
$\endgroup$
19
  • 7
    $\begingroup$ Strangely, SparseArrays are actually not atomic, but just treated for most purposes as if they were. They are the only non-atomic atoms, though, as far as I know. And in addition to your list, there are several other undocumented atomic objects as well, such as the Internal`Bag, the System`Utilities`HashTable, the System`RawArray, and probably others besides. Several objects that should be atomic (by the standards of the SparseArray) aren't, such as CompiledFunction and LibraryFunction. $\endgroup$ Commented Apr 27, 2014 at 3:38
  • 5
    $\begingroup$ The same question on Stack Overflow: (5964469) $\endgroup$
    – Mr.Wizard
    Commented Apr 28, 2014 at 19:19
  • 6
    $\begingroup$ What is atomic and what isn't changes with versions. Image isn't atomic in v7 and v8. $\endgroup$
    – Szabolcs
    Commented Apr 29, 2014 at 16:54
  • 4
    $\begingroup$ @ChipHurst AtomQ is defined as "an expression which cannot be divided into subexpressions", and has notes such as "You can use AtomQ in a recursive procedure to tell when you have reached the bottom of the tree corresponding to an expression." and "AtomQ gives True for any object whose subparts cannot be accessed using functions like Map". Clearly Association should not be AtomQ by these measures. But as you point out, it is also not NormalQ (which would mean that it behaves like its FullForm), if we had such a thing. AtomQ and NormalQ are currently "mixed together", we should separate them. $\endgroup$ Commented Jul 17, 2014 at 18:20
  • 3
    $\begingroup$ @TaliesinBeynon ... With[{a = Association[1 -> 2]}, Hold[a]]. But it doesn't, there are differences (again, part extraction, pattern matching). Also consider SparseArray, which also has parts, but again doesn't behave identically to its FullForm. SparseArray is also marked as AtomQ for this reason. Perhaps you could consider changing the description of AtomQ in the documentation instead of letting AtomQ return False for associations. What AtomQ really means is a bit complicated, but it's valuable to have it, and changing it would break either consistency ... $\endgroup$
    – Szabolcs
    Commented Aug 5, 2014 at 14:39

2 Answers 2

17
$\begingroup$

You can executive the code in mma 10 or above version

EntityClass["WolframLanguageSymbol", "Atomic"]//EntityList

But is not all atomic function,as I know.

$\endgroup$
6
  • $\begingroup$ Wow, very nice! $\endgroup$
    – Greg Hurst
    Commented Sep 23, 2015 at 22:23
  • $\begingroup$ I'm accepting this because only a few (documented System heads) are missing: Integer, String, Symbol, QuantityArray. The first three make sense I think. For example you can't create an integer using the head Integer. $\endgroup$
    – Greg Hurst
    Commented Nov 17, 2017 at 15:36
  • 1
    $\begingroup$ Tell me how to. :) $\endgroup$
    – yode
    Commented Nov 17, 2017 at 15:39
  • $\begingroup$ @yode You can create a true symbol still: a = Symbol["s"];s === a $\endgroup$
    – Acus
    Commented Nov 17, 2017 at 16:37
  • $\begingroup$ @user18792 Ah, right. I guess Integer and String are the only 2 then. $\endgroup$
    – Greg Hurst
    Commented Nov 17, 2017 at 20:52
6
$\begingroup$

Since it's the only "answer" I can see to post (as CW) there is also BooleanFunction as originally pointed out by Sasha.


In version 10 Dispatch tables are atomic.(1)

Array[# -> 2 # &, 5] // Dispatch // AtomQ
True
$\endgroup$
2
  • $\begingroup$ The same as association. <|a -> 1|> // AtomQ gives True. $\endgroup$
    – Yi Wang
    Commented Jul 14, 2014 at 15:55
  • $\begingroup$ @YiWang Association is already mentioned in the Question body above, but yes. $\endgroup$
    – Mr.Wizard
    Commented Jul 14, 2014 at 23:36

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.