TypeOf

TypeOf[expr]

gives the type of expr without evaluating it.

TypeOf[expr,Typed[x,ty]]

assumes that instances of x in expr have type ty.

TypeOf[expr,{Typed[x1,ty1],Typed[x2,ty2],}]

assumes that xi has type tyi.

Details and Options

  • TypeOf can be used in both interpreted and compiled programs.
  • TypeOf uses the type inferencing system of the Wolfram Compiler.
  • TypeOf only accepts expressions and types that can be compiled by the Wolfram Compiler.

Examples

open allclose all

Basic Examples  (3)

Find the type of an expression:

Find the type of an expression while specifying only the type of a subexpression:

Compile a program using TypeOf:

Scope  (2)

Find the type of a program using arrays:

TypeOf does not evaluate its argument in compiled code, just as in evaluated code:

Properties & Relations  (2)

TypeOf infers the type of its input without evaluating it:

TypeOf effectively gives the return type of the CompiledCodeFunction generated by FunctionCompile but is much faster:

Possible Issues  (1)

TypeOf can only infer the types of compilable programs:

Wolfram Research (2022), TypeOf, Wolfram Language function, https://reference.wolfram.com/language/ref/TypeOf.html.

Text

Wolfram Research (2022), TypeOf, Wolfram Language function, https://reference.wolfram.com/language/ref/TypeOf.html.

CMS

Wolfram Language. 2022. "TypeOf." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TypeOf.html.

APA

Wolfram Language. (2022). TypeOf. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TypeOf.html

BibTeX

@misc{reference.wolfram_2024_typeof, author="Wolfram Research", title="{TypeOf}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TypeOf.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_typeof, organization={Wolfram Research}, title={TypeOf}, year={2022}, url={https://reference.wolfram.com/language/ref/TypeOf.html}, note=[Accessed: 21-December-2024 ]}