[SOLVED] Given (|) in programming? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: [SOLVED] Given (|) in programming? (/thread-6318.html) |
[SOLVED] Given (|) in programming? - CH3791 - 05-29-2016 04:57 AM Hi, I am trying to make a program that calculates x intercepts. Right now, it can calculate the answer, but I can't make it restrict the domain. I understand you can do this directly in the CAS app: solve(SIN(x)=0,x)|{(x>-10) AND (x<10)} {-3*pi, -2*pi, -pi, 0, pi, 2*pi, 3*pi} But when I put that kind of syntax into my program, it returns "Error: Invalid input". Code:
Any ideas? RE: Given (|) in programming? - roadrunner - 05-29-2016 08:24 AM I'm not sure that syntax, using the "|" operator, is valid within a program; but using assume() and additionally() does appear to work. See modified program below: Code: EXPORT XINT1(expression,domainlow,domainhigh) RE: Given (|) in programming? - CH3791 - 05-29-2016 08:47 AM Thanks roadrunner, your code works perfectly. One thing I would add though is: purge(x); at the very end just before RETURN "done", so that the domain gets deleted and won't affect future calculations involving x. |