HP Forums
circular shift - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: circular shift (/thread-4393.html)



circular shift - roadrunner - 07-20-2015 08:24 PM

Functions for circular shift of lists and bints can be seen below.

For lists:
Code:

LOCAL s;

EXPORT listright(t)
BEGIN
 IF type(t)≠6 THEN RETURN ;END;
 s:=SIZE(t);
 RETURN CONCAT(t(s),SUB(t,1,s-1));
END;

EXPORT listleft(t)
BEGIN
 IF type(t)≠6 THEN RETURN ;END;
 s:=SIZE(t);
 RETURN CONCAT(SUB(t,2,s),t(1));
END;

For bints:
Code:

EXPORT bitleft(t)
BEGIN
 RETURN BITSL(t,1)+BITSR(t,GETBITS(t)-1);
END;

EXPORT bitright(t)
BEGIN
 RETURN BITSR(t,1)+BITSL(t,GETBITS(t)-1);
END;
Road