04-20-2014, 03:38 PM
Post: #1
 Eddie W. Shore Senior Member Posts: 1,150 Joined: Dec 2013
HP Prime: EC (Custom Menu of One Argument CAS Functions)

Functions featured:
head: 1st element of a list
tail: all elements of a list except the 1st
l2norm: L-2 norm of a vector
ker: kernel of a matrix
even: is the number even?

Input: EC(argument)

Code:
EXPORT EC(x) BEGIN // CAS Custom  Menu // EWS 2014-04-20 LOCAL m,m1,mx,my; WHILE MOUSE(1)≥0 DO END; RECT; TEXTOUT_P("Choose the function.",1,1,4); TEXTOUT_P("head: 1st element of a list",1,18,4); TEXTOUT_P("tail: all elements of a list except the 1st",1,35,4); TEXTOUT_P("l2norm: L-2 norm of a vector",1,52,4); TEXTOUT_P("ker: kernel of a matrix",1,69,4); TEXTOUT_P("SPECRAD: spectral radius of a matrix",1,86,4); TEXTOUT_P("even: is the number even?",1,103,4); DRAWMENU("head","tail","l2norm","ker","SPECRAD","even"); REPEAT m:=MOUSE; m1:=m(1); UNTIL SIZE(m1)>0; mx:=m1(1); my:=m1(2); IF my≥220 AND my≤239 THEN IF mx≥0 AND mx≤51 THEN RETURN SUB(x,1,1); END; IF mx≥53 AND mx≤104 THEN RETURN SUB(x,2,SIZE(x)); END; IF mx≥106 AND mx≤157 THEN RETURN exact(ABS(x)); END; IF mx≥159 AND mx≤210 THEN RETURN ker(x); END; IF mx≥212 AND mx≤263 THEN RETURN CAS.SPECNORM(x); END; IF mx≥265 AND mx≤319 THEN RETURN even(x); END; END; END;
04-20-2014, 04:33 PM (This post was last modified: 04-20-2014 04:34 PM by rprosperi.)
Post: #2
 rprosperi Senior Member Posts: 4,470 Joined: Dec 2013
(04-20-2014 03:38 PM)Eddie W. Shore Wrote:  HP Prime: EC (Custom Menu of One Argument CAS Functions)

Functions featured:
head: 1st element of a list
tail: all elements of a list except the 1st
l2norm: L-2 norm of a vector
ker: kernel of a matrix
even: is the number even?

Eddie: