HP Forums

Full Version: Text wrap mode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

Does hp have some kind of text wrap mode so that output such as 654765675865784866587657655555465 is displayed as:
6547656758
6578486658
7657655555
465
Instead of a list that goes off screen?

Use case: I need to find the divisors using idivis() of a four digit number and then examine that list to determine the factors that sum to a particular value.
You could display a number split into a set amount of numbers per line, as a string that was suitably formatted, using MSGBOX(), that would suffice to view what you have asked for.

If you want to use the numbers, you could set the list to be displayed around the screen, by programming the location of output text.

If you need to use the numbers you are displaying, you might be better to have them as a menu, where you can select them, after the list is converted into a menu, and a string, using DRAWMENU(), multiple times if necessary.
Thanks, I found the answer was to manipulate lists (see photos)
Unlike Python, CAS string is 1-based:

CAS> wrap(s,n) := transpose(makelist(k->s[k:k+n],1,len(s)+1,n))
CAS> s := "654765675865784866587657655555465"
CAS> wrap(s, 10)

\(\left(\begin{array}{c}
\mathrm{6547656758} \\
\mathrm{6578486658} \\
\mathrm{7657655555} \\
\mathrm{465}
\end{array}\right) \)
CAS> unwrap:=(sw)->(Σ(sw[n],n,1,length(sw)))[1]

CAS> unwrap(wrap(s,10))

"654765675865784866587657655555465"

-road
(06-28-2021 11:40 AM)Albert Chan Wrote: [ -> ]Unlike Python, CAS string is 1-based:

CAS> wrap(s,n) := transpose(makelist(k->s[k:k+n],1,len(s)+1,n))
CAS> s := "654765675865784866587657655555465"
CAS> wrap(s, 10)

\(\left(\begin{array}{c}
\mathrm{6547656758} \\
\mathrm{6578486658} \\
\mathrm{7657655555} \\
\mathrm{465}
\end{array}\right) \)
That works in XCas but gives syntax error on prime, with cursor at s[k:k+n ☆ ]
It works on my calculator. Make sure you are using makelist() and not MAKELIST()

-road
Reference URL's