CloudExpression
CloudExpression["name"]
represents an expression whose value is persistently stored in the cloud.
CloudExpression["http://…"], CloudExpression["https://…"]
represents a cloud expression with a given URI.
CloudExpression[base,part1,part2,…]
represents the part of a cloud expression specified by the parti.
Details and Options
- CloudExpression["name"] immediately evaluates to CloudExpression[uri], where the path for the URI is determined by the value of $CloudExpressionBase.
- The value stored in a cloud expression can be any Wolfram Language expression.
- When the value consists of nested lists and associations, lookup and updating of parts is handled directly in the cloud.
- CloudExpression[…][part1,part2,…] retrieves the value of the specified part of the cloud expression.
- CloudExpression[…][] retrieves the value of the entire cloud expression.
- CloudExpression[…][part1,part2,…]=value sets the value of part of a cloud expression.
- The following operations can be performed on CloudExpression objects:
-
Get get the complete value of the cloud expression Put put a new complete value into the cloud expression Part return a cloud expression object that represents the part Set assign new values to parts of the cloud expression Unset remove parts from the cloud expression AppendTo append to a list or association within the cloud expression AssociateTo associate a new value to a key in an association AddTo,Increment,… add, increment, etc. parts in the cloud expression DeleteCloudExpression delete the cloud expression Length return the length of the cloud expression KeyExistsQ test if a key exists in the cloud expression SetOptions set options associated with the cloud expression Options get the options associated with the cloud expression SetPermissions set permissions of the cloud expression ClearPermissions clear permissions of the cloud expression - CloudExpression[…][[part1,part2,…]] gives CloudExpression[…,part1,part2,…], from which the value can be retrieved using Get.
- Cloud expressions have the following options, whose values are stored in the cloud:
-
PartProtection Automatic which parts are protected from change Permissions Automatic permissions for access etc. - After creating a cloud expression with CreateCloudExpression, options for cloud expressions can be retrieved using Options and changed using SetOptions.
- In associations, when a mutable operation is applied to a missing key, the associated value is initialized before the operation is applied.
-
Set associate the missing key to the value specified in Set AssociateTo initialize the value to an empty association AppendTo initialize the value to an empty list AddTo, Increment, ... initialize the value to 0 TimesBy, DivideBy initialize the value to 1
Examples
open allclose allBasic Examples (2)
Create an anonymous cloud expression storing a list:
Retrieve a part from the cloud expression:
Reset a part in the cloud expression:
Get the value of the whole cloud expression:
Append a value to the cloud expression:
Get the final value of the whole cloud expression:
Create an anonymous cloud expression storing an association:
Scope (9)
Store an integer as a cloud expression:
Increment the integer multiple times:
Decrement the value by number:
Set the sequence to a new value:
Store a list of lists as a cloud expression:
Retrieve the cloud expression and display it as a rectangular matrix:
Set the entire first column to 0:
Add 2 to the value of the last row:
Set the value of the last element of the last row:
Create a new cloud expression composed of an association:
Add a new key using AppendTo:
Looking up a key that does not exist will return a Failure object:
Attempting to update values associated with key "c" while PartProtection is set to Automatic produces a Failure object:
Change the PartProtection value to None, allowing arbitrary update operations:
Create a new cloud expression:
Define an unevaluated representation of the part "a" of the cloud expression:
Retrieve the value associated with key "a":
Add an element to the list associated with key "a":
Create a new cloud expression containing an integer and a real:
Cloud expressions support in-place addition when operating on machine-precision numbers:
Cloud expressions support in-place multiplication:
Cloud expressions support in-place division, where the results are coercing to real numbers:
Any expression can be stored in a cloud expression:
Part extraction on arbitrary expressions is not supported:
Create a new cloud expression containing a list of associations:
Cloud expressions support Length:
Parts of a cloud expression also support Length:
Create a new cloud expression containing a list of associations with different keys:
Cloud expressions support KeyExistsQ:
KeyExistsQ also works on parts of a cloud expression:
Options (2)
PartProtection (1)
Set its PartProtection to All, protecting it against any sort of update:
Trying to update any value produces a Failure object:
Properties & Relations (8)
Create a cloud expression storing a list:
The entire expression stored in a cloud expression can be replaced with Put:
The existing value can be retrieved with Get:
Get[CloudExpression[…]] is equivalent to the short form CloudExpression[…][]:
DeleteCloudExpression deletes a cloud expression:
Create a cloud expression storing a list:
AppendTo adds a new element at the end of the list:
AppendTo also works on Association:
If the key is not already in the association, the key-value pair is added:
AppendTo changes the value associated with an existing key:
Create a cloud expression storing an association:
AppendTo will add an entry at the end of the association, if the key does not already exist:
Existing keys are updated and moved to the end:
AssociateTo will not reorder the entry if it already exists:
Store a list of lists as a cloud expression:
Remove the last elements of each list with Unset:
Set part protection to None:
With part protection set to None, it is possible to remove the first list:
Cloud expressions can be used to efficiently count events. Start by storing an association in a cloud expression:
Increment the counters for a random set of users. Values are automatically initialized to zero before being incremented if they do not already exist:
Cloud expressions can be used to collect metadata from things like HTTP requests. Start by storing an association in a cloud expression:
Prepare a list of associations representing HTTP requests. Each contains the user name and the user-agent of a client making a request:
Collect metadata by randomly selecting users, representing clients making HTTP requests. Values are automatically initialized to an empty list before the AppendTo operation is performed if they do not already exist:
Use FileByteCount to get the cloud storage used by a cloud expression:
Possible Issues (4)
Cloud expressions do not support PrependTo:
Operations on nested missing keys within a cloud expression are not supported:
Associating a score value to a missing user returns a failure object:
If needed, KeyExistsQ can be used to initialize the value for the new keys:
Insert the nested key, automatically initializing "last_score" to an empty association prior to the Set operation:
Trying to set or delete a nonatomic value will fail if PartProtection->None is not set:
Use SetOptions to allow the modification:
Numbers that cannot be represented as 64-bit machine integers or real numbers can be stored in cloud expressions:
In-place arithmetic operations on extended-precision integers can cause the integer to be coerced to a real number:
If an arithmetic operation is attempted on an extended-precision integer or real number, and the number cannot be coerced to a machine-size number, a failure object will be returned and the operation will not be performed:
Neat Examples (3)
Store a family of polyhedra as an association:
Store the polyhedra in the cloud as an association:
Retrieve a polyhedron by its standard name:
Build a web form to perform a survey of vital statistics. First create a cloud expression to gather the data:
Create a form storing anonymous body information of the user:
Let users submit data. Then, build an histogram of the ages from the user inputs:
Compute the body mass index (BMI) associated to each submission:
Plot an histogram of the BMI values by sex:
Create a cloud expression to log usage of a form function:
Create a form function that identifies the language of the requested string. The form function will also log the result of the request, the ID of the cloud user making the request, and the time spent:
Deploy the form to a public cloud object:
Retrieve the list of identified languages after a few submissions:
Text
Wolfram Research (2016), CloudExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/CloudExpression.html (updated 2021).
CMS
Wolfram Language. 2016. "CloudExpression." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/CloudExpression.html.
APA
Wolfram Language. (2016). CloudExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CloudExpression.html