satishrajdev Posted March 12, 2015 Posted March 12, 2015 Hi, I can get String length by STRLEN but How to determine that String length is even or odd? I want to give different conditions for even and odd stringlength. waiting... Quote
BIGAL Posted March 12, 2015 Posted March 12, 2015 Another is number even or oddd ? (if (= (- (/ Numb 2.0) (fix (/ Numb 2.0))) 0.50)) its odd as it will be 0.5 for integers. Quote
hanhphuc Posted March 12, 2015 Posted March 12, 2015 (edited) (logand (strlen str) 1) ;EDIT: integer only (boole 1 (strlen str) 1) TEST: -10 to 10 ((lambda(i) (repeat 21 (princ (strcat "\n"(itoa i) " -> " (itoa (Boole 1 i 1)))) (setq i (1+ i)) (princ)) ) ;_ end of lambda [color="green"] -10[/color] ) -10 -> 0-9 -> 1 ... ... -1 -> 1 0 -> 0 .. .. 10 -> 0 Edited March 12, 2015 by hanhphuc Quote
BIGAL Posted March 13, 2015 Posted March 13, 2015 Nice one hanhphuc one of those you put away for a rainy day Quote
hanhphuc Posted March 13, 2015 Posted March 13, 2015 Nice one hanhphuc one of those you put away for a rainy day Thank you sir Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.