Restricted

Restricted[form,cond,]
represents a form for Interpreter and related functions restricted according to the conditions cond.

DetailsDetails

  • Restricted["Number",{min,max}] represents a number restricted to the range min to max inclusive.
  • Restricted["Number",{min,max,step}] represents a number restricted to the range min to max in steps of size step.
  • Restricted["Integer",] etc. works the same as for .
  • Restricted["String",patt] represents a string that must match the string pattern patt.
  • Restricted["String",patt,max] represents a string of maximum length max.
  • Restricted["String",patt,{min,max}] represents a string of length between min and max.
  • Restricted["Quantity","unit"] represents a quantity compatible with .
  • Restricted["Quantity","unit",{min,max}] represents a quantity whose magnitude lies between the quantities min and max.
  • Restricted["Quantity",QuantityVariable["pq"]] represents a physical quantity of type pq (such as ).
  • Restricted["Date",{min,max}] represents a date restricted to the range min to max.
  • Restricted["Date",{min,max, step}] represents a date restricted to the range min to max in steps of size step, where input is , , or .
  • Restricted["type",region] represents any type with an associated geographic location restricted to be in a particular region specified by an entity (such as a country), an entity class, or a polygon.
  • Restricted["type",EntityClass["type","class"]] represents an object of the specified type chosen from the list of entities in the specified entity class.
  • Restricted[form,{{val1,val2,}}] represents a form whose value is chosen from the list .
  • Restricted[DelimitedSequence[],max] represents a delimited sequence of at most max elements.
  • Restricted[DelimitedSequence[],{min,max}] represents a delimited sequence of between min and max elements.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Require an odd number between 1 and 99:

In[1]:=
Click for copyable input
Out[1]=

Require a quantity in whole meters between 0 and 100:

In[1]:=
Click for copyable input
Out[1]=

Require a city along the Silk Road:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)