HP Forums
Would it be useful if Round worked on strings in lists? - 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: Would it be useful if Round worked on strings in lists? (/thread-13475.html)



Would it be useful if Round worked on strings in lists? - StephenG1CMZ - 08-18-2019 05:28 PM

Whilst debugging, I sometimes find it useful to output a rounded list of numbers.
The good thing is that Round works on lists as well as numbers, so you don't need to round every item in the list.
Unfortunately, Round doesn't work with strings.
Code:
 
EXPORT TRYER()
BEGIN
   ROUND({            π,2*π},2);
 //ROUND({"Answers: ",π,2*π},2);
 
END;

Would it be nice if the strings were ignored rather than generate an error?
Or would that break something?


RE: Would it be useful if Round worked on strings in lists? - John Keith - 08-18-2019 06:05 PM

(08-18-2019 05:28 PM)StephenG1CMZ Wrote:  Whilst debugging, I sometimes find it useful to output a rounded list of numbers.
The good thing is that Round works on lists as well as numbers, so you don't need to round every item in the list.
Unfortunately, Round doesn't work with strings.
Code:
 
EXPORT TRYER()
BEGIN
   ROUND({            π,2*π},2);
 //ROUND({"Answers: ",π,2*π},2);
 
END;

Would it be nice if the strings were ignored rather than generate an error?
Or would that break something?

Rounding strings would certainly be unusual. Couldn't you just do something like

Code:
 
EXPORT TRYER()
BEGIN
   lst := CONCAT ( "Answer: ", ROUND({            π,2*π},2));
 
 
END;