IfCompiled

IfCompiled[comp,uncomp]

gives comp when compiled and uncomp when evaluated.

Details

  • IfCompiled[comp,uncomp] ignores uncomp when compiling and ignores comp when evaluating.
  • Compilation for IfCompiled is carried out by FunctionCompile and related functions.
  • IfCompiled can be useful to migrate evaluated code to the compiler.

Examples

open allclose all

Basic Examples  (1)

Define a function that uses IfCompiled:

During normal evaluation, this function returns the uncompiled result:

Compile the function. FunctionCompile compiles with the compiled branch of IfCompiled:

Check that the compiled result is returned:

Scope  (1)

Evaluation  (1)

In evaluated mode, IfCompiled only processes the uncompiled argument:

In compiled mode, IfCompiled only processes the compiled argument:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

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