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:
  • Getget the complete value of the cloud expression
    Putput a new complete value into the cloud expression
    Partreturn a cloud expression object that represents the part
    Setassign new values to parts of the cloud expression
    Unsetremove parts from the cloud expression
    AppendToappend to a list or association within the cloud expression
    AssociateToassociate a new value to a key in an association
    AddTo,Increment,add, increment, etc. parts in the cloud expression
    DeleteCloudExpressiondelete the cloud expression
    Lengthreturn the length of the cloud expression
    KeyExistsQtest if a key exists in the cloud expression
    SetOptionsset options associated with the cloud expression
    Optionsget the options associated with the cloud expression
    SetPermissionsset permissions of the cloud expression
    ClearPermissionsclear 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 Automaticwhich parts are protected from change
    Permissions Automaticpermissions 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.
  • Setassociate the missing key to the value specified in Set
    AssociateToinitialize the value to an empty association
    AppendToinitialize the value to an empty list
    AddTo, Increment, ...initialize the value to 0
    TimesBy, DivideByinitialize the value to 1

Examples

open allclose all

Basic 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:

Delete a value:

Get the final value of the whole cloud expression:

Create an anonymous cloud expression storing an association:

Update the value of a key:

Add a new key:

Delete a key:

Get the final value of the whole cloud expression:

Scope  (9)

Store an integer as a cloud expression:

Increment the integer multiple times:

Get the latest value:

Decrement the value by number:

Get the latest value:

Store a list of integers:

Retrieve a part:

Retrieve a sequence of parts:

Set the sequence to a new value:

Retrieve the sequence:

Update a part:

Append a part:

Retrieve the final value:

Store a list of lists as a cloud expression:

Retrieve the cloud expression and display it as a rectangular matrix:

Retrieve the first row:

Retrieve the first column:

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:

Delete the last row:

Create a new cloud expression composed of an association:

Look up a key:

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:

Update the cloud expression:

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:

Retrieve the values:

Cloud expressions support in-place multiplication:

Retrieve the values:

Cloud expressions support in-place division, where the results are coercing to real numbers:

Retrieve the value:

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)

Create a cloud expression:

Set its PartProtection to All, protecting it against any sort of update:

Trying to update any value produces a Failure object:

Permissions  (1)

Create a cloud expression:

Set cloud expression permissions to public, allowing access by any cloud user:

Use a permission group to grant read permission to any users in a named group:

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[][]:

Create a cloud expression:

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:

Prepare a list of users:

Increment the counters for a random set of users. Values are automatically initialized to zero before being incremented if they do not already exist:

Retrieve the result:

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:

The stored values are exact:

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:

Deploy the form to the cloud:

Let users submit data. Then, build an histogram of the ages from the user inputs:

Gather the data by sex:

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:

Plot the date histogram from the data collected:

Get a detailed report of a given user activity:

Wolfram Research (2016), CloudExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/CloudExpression.html (updated 2021).

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

BibTeX

@misc{reference.wolfram_2024_cloudexpression, author="Wolfram Research", title="{CloudExpression}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/CloudExpression.html}", note=[Accessed: 10-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_cloudexpression, organization={Wolfram Research}, title={CloudExpression}, year={2021}, url={https://reference.wolfram.com/language/ref/CloudExpression.html}, note=[Accessed: 10-October-2024 ]}