Initialization:
In[]:=
CloudSymbol["qpowerbug"]=
-1+n
q
Out[]=
-1+n
q
Where is the symbol?
In[]:=
$CloudSymbolBase
Out[]=
In[]:=
CloudObjects[$CloudSymbolBase]
Out[]=
The issue is how to tell Mathematica that is a numerator term, not a denominator term.
-1+n
q
Match to the pattern where power is greater than 0.
-1+n
q
power
base
In[]:=
MatchQ[/;power>0,CloudSymbol["qpowerbug"]]
power_
base_
Out[]=
False
The issue is this should return True, not False.
How can I get a True result?
In[]:=
Numerator[CloudSymbol["qpowerbug"]]
Out[]=
n
q
In[]:=
Denominator[CloudSymbol["qpowerbug"]]
Out[]=
q
For example to check something is a denominator term I could do Denominator[#]=!=1.
In[]:=
DenominatorQ=Denominator[#]=!=1&;
In[]:=
DenominatorQ[1]
Out[]=
False
In[]:=
DenominatorQ
1
b
Out[]=
True
In[]:=
DenominatorQ[CloudSymbol["qpowerbug"]]
Out[]=
True
But its also in the numerator:
In[]:=
NumeratorQ=Numerator[#]=!=1&;
In[]:=
NumeratorQ[r]
Out[]=
True
In[]:=
NumeratorQ[CloudSymbol["qpowerbug"]]
Out[]=
True
NumeratorQ and DenominatorQ return True. If both are true, then it could assumed its in the numerator.
In[]:=
NumeratorTermQ=WhichAnd@@{!NumeratorQ[#],DenominatorQ[#]}(*forexample*),False,And@@{NumeratorQ[#],!DenominatorQ[#]}(*forexampler*),True,And@@{NumeratorQ[#],DenominatorQ[#]}(*forexample*),True,And@@{!NumeratorQ[#],!DenominatorQ[#]},True(*forexample1withNumeratorTermQ[1]*)&;
1
b
n-1
q
Test:
In[]:=
NumeratorTermQ[1]
Out[]=
True
Does it work now?
In[]:=
NumeratorTermQ[CloudSymbol["qpowerbug"]]
Out[]=
True
I had to close Wolfram Desktop 13.2 and open Mathematica 13.3 to use TestCreate. One advantage of using CloudSymbol is when I move from Wolfram Mathematica to Desktop I don’t have to worry about conflicting definitions.
In[]:=
NumeratorTermQTestFunction//ClearAllNumeratorTermQTestFunction[input_,expectedoutput_]:=TestCreate[NumeratorQ[input],expectedoutput,TestID->Automatic]
In[]:=
CreateCloudExpression[{},"qpowerbugtests"]
Out[]=
CloudExpression
In[]:=
AppendTestsForNumeratorTerm//ClearAllAppendTestsForNumeratorTerm[test_]:=AppendTo[CloudExpression["qpowerbugtests"],test]
In[]:=
AppendTestsForNumeratorTerm[NumeratorTermQTestFunction[NumeratorTermQ[1],True]]
Out[]=
CloudExpression
See the function:
In[]:=
Get[CloudExpression["qpowerbugtests"]]
Out[]=
TestObject
Put the results in a cloud expression:
In[]:=
CreateCloudExpression[{},"QPowerBugTestResults"]
Out[]=
CloudExpression
In[]:=
AppendTo[CloudExpression["QPowerBugTestResults"],Echo[TestReport[TestEvaluate[Get[CloudExpression["qpowerbugtests"]]]]]]
»
TestReportObject
Out[]=
CloudExpression
Get the test reports:
In[]:=
CloudExpression["QPowerBugTestResults"][]
Out[]=
TestObject,TestReportObject
Storing the functions in CloudObjects
Storing the functions in CloudObjects
In[]:=
Names["Global`*"]
Out[]=
{a,AppendTestsForNumeratorTerm,b,ClosingSaveDialog,Composite,DenominatorQ,expectedoutput,h,input,max,min,n,NumeratorQ,NumeratorTermQ,NumeratorTermQTestFunction,n$,persistaftermathematicaisclosed,PrimeQCertificateCheck,q,RandomComposite,rtype,spec,t,test,tests,u,v,w,x,y}
In[]:=
Symbol/@%60
Out[]=
{a,AppendTestsForNumeratorTerm,b,ClosingSaveDialog,Composite,Denominator[#1]=!=1&,expectedoutput,h,input,max,min,n,Numerator[#1]=!=1&,Which[And@@{!NumeratorQ[#1],DenominatorQ[#1]},False,And@@{NumeratorQ[#1],!DenominatorQ[#1]},True,And@@{NumeratorQ[#1],DenominatorQ[#1]},True,And@@{!NumeratorQ[#1],!DenominatorQ[#1]},True]&,NumeratorTermQTestFunction,n$,42,PrimeQCertificateCheck,q,RandomComposite,rtype,spec,t,test,{},u,v,w,x,y}
I created a function that prevents overwriting or appending things stored with CloudSave, which does not have overwrite protection which Export does with OverwriteTarget->False.
In[]:=
CloudGet["/cloudfunctions/SaveCloudFunction"]
In[]:=
SaveCloudFunction[AppendTestsForNumeratorTerm,"AppendTestsForNumeratorTerm"]
Now saving doesn’t work:
In[]:=
SaveCloudFunction[AppendTestsForNumeratorTerm,"AppendTestsForNumeratorTerm"]
Out[]=
The cloud object at https://www.wolframcloud.com/obj/burbery1/cloudfunctions/AppendTestsForNumeratorTerm already exists. Delete the cloud object at https://www.wolframcloud.com/obj/burbery1/cloudfunctions/AppendTestsForNumeratorTerm then try to save.
Save DenominatorQ:
In[]:=
SaveCloudFunction[DenominatorQ,"DenominatorQ"]
Out[]=
SaveCloudFunction[Denominator[#1]=!=1&,DenominatorQ]
I need to save it as a full function.
In[]:=
DenominatorQ//ClearAllDenominatorQ[input_]:=Denominator[input]=!=1
I should also do this NumeratorQ.
Now I can save the functions:
What is the definition?
I can use Which to avoid a nested if else loop logic chain:
I just have two more functions to save:
I guess I already saved that.
I think I have all the functions stored in the cloud now.
Hopefully the function works now.