5
$\begingroup$

This APIFunction takes a list as an argument:

func = APIFunction[{"x" -> DelimitedSequence["Integer", ","]}, #x^3 &]

func["x" -> Range[4]]

What I'd like to be able to do is place a constraint on the elements within the list. For example if I wanted to only have elements greater than or equal to zero this works to throw an error for elements that to do fit the criteria:

Interpreter[Restricted["Number", {1, \[Infinity], 1}]][Range[-4, 4]]

So therefore I thought this might work:

func = APIFunction[{"x" ->DelimitedSequence[Restricted["Integer", {1, \[Infinity], 1}],","]}, #x^3 &]

func["x" -> Range[-4, 4]]

but it did not.

Does anyone know how Restricted can be combined with DelimitedSequence or any way that constraints can be placed on elements in lists/arrays that are used as arguments in an APIFunction?

$\endgroup$
  • $\begingroup$ Mike if you can cross post this on Community I might be able to attract some attention from internal folks. I am curious myself. $\endgroup$ – Vitaliy Kaurov Apr 16 '17 at 10:55
  • $\begingroup$ @VitaliyKaurov I might send it to tech support and post the answer here $\endgroup$ – Mike Honeychurch Apr 16 '17 at 22:56
1
$\begingroup$

WRI tech support advise to use this syntax:

func = APIFunction["x" -> 
RepeatingElement[Interpreter[Restricted["Integer", {1,\[Infinity], 1}]]], #x^3 &]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.