defines a resource function that can be applied to arguments to give the same result as f[…].
DefineResourceFunction[f,name]
uses name as the name of the resource function.
DefineResourceFunction
defines a resource function that can be applied to arguments to give the same result as f[…].
DefineResourceFunction[f,name]
uses name as the name of the resource function.
Details and Options
- DefineResourceFunction[…] returns ResourceFunction[…].
- DefineResourceFunction[f,…] immediately stores all definitions on which f[…] depends. If the definitions change later, values obtained from ResourceFunction[…][…] will not be affected.
- In DefineResourceFunction[f,…], f can be any expression.
- In DefineResourceFunction[f], the resource function produced will have name SymbolName[f] if f is a symbol.
- DefineResourceFunction[Unevaluated[f],…] defines a resource function for a symbol f, without evaluating the symbol.
- If a name cannot be inferred from f, a unique name will be assigned.
- The definitions set up by DefineResourceFunction will not persist past the end of the session.
- CloudDeploy, CloudPublish, LocalCache, etc. can be used to store persistent versions of a resource function.
- Use a definition notebook from File ▶ New ▶ Repository Item ▶ Function Repository Item to create a resource function with properties.
Examples
open all close allBasic Examples (2)
Create a new ResourceFunction:
DefineResourceFunction[1 + #&, "Add One"]Create a ResourceFunction from a symbol:
RedPlot[args___] := Plot[args, PlotStyle -> Red]rf = DefineResourceFunction[RedPlot]Apply the resulting function to arguments:
rf[Sin[x], {x, 0, Pi}]Properties & Relations (2)
Dependencies are automatically included in the resource:
randomCities[n_] := RandomEntity["City", n];
getPopulation[city_] := EntityValue[city, "Population"];
mapCitiesBySize[cities_] := GeoBubbleChart[Normal@AssociationMap[getPopulation, cities]];
RandomCityMap[n_] := mapCitiesBySize[randomCities[n]]rf = DefineResourceFunction[RandomCityMap, "RandomCityMap"]rf[6]The resource works even if the original definitions are cleared:
Clear[getPopulation, randomCities]rf[6]If no name is given for a pure function, an "Untitled" name is automatically generated:
DefineResourceFunction[Factorial[#] / # ^ 3&]See Also
ResourceFunction ResourceObject ResourceData Save CloudSave
Function Repository: ResourceFunctionInput CreateResourceFunctionSymbols
Related Guides
History
Text
Wolfram Research (2019), DefineResourceFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/DefineResourceFunction.html.
CMS
Wolfram Language. 2019. "DefineResourceFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DefineResourceFunction.html.
APA
Wolfram Language. (2019). DefineResourceFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DefineResourceFunction.html
BibTeX
@misc{reference.wolfram_2026_defineresourcefunction, author="Wolfram Research", title="{DefineResourceFunction}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/DefineResourceFunction.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_defineresourcefunction, organization={Wolfram Research}, title={DefineResourceFunction}, year={2019}, url={https://reference.wolfram.com/language/ref/DefineResourceFunction.html}, note=[Accessed: 12-June-2026]}