Your request looks vaguely familiar. I swear that someone posted this same question recently. Try a search on the word "alphabet".
Registered forum members do not see this ad.
Learnt all numbers in a list, all alphabets in a list.
but how if both in the same?
such as
(count-alpha '(8 0 b 7 h u 6 d ) ) -> 4
(count-no '(8 0 b 7 h u 6 d ) ) -> 4
Your request looks vaguely familiar. I swear that someone posted this same question recently. Try a search on the word "alphabet".
"I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police
Eat brains...gain more knowledge!
Things like this ...
Code:(mapcar (function (lambda (x) (if (numberp x) (setq n (cons x n)) (setq a (cons x a)) ) ) ) '(8 0 b 7 h u 6 d) )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
Anther with the use of foreach function ....
Would return the same result as the first codes .Code:(foreach item '(8 0 b 7 h u 6 d) (if (numberp item) (setq numbers (cons item numbers)) (setq alpha (cons item alpha)) ) )
numbers = ( 6 7 0 8 )
alpha = ( D U H B )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
Code:(defun count-alpha ( l ) (length (vl-remove-if 'numberp l)) ) (defun count-no ( l ) (length (vl-remove-if-not 'numberp l)) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Error: Attempt to take the value of the unbound variable `N'.Code:(mapcar (function (lambda (x) (if (numberp x) (setq n (cons x n)) (setq a (cons x a)) ) ) ) '(8 0 b 7 h u 6 d) )
[condition type: UNBOUND-VARIABLE]
Error: attempt to call `FOREACH' which is an undefined function.Code:(foreach item '(8 0 b 7 h u 6 d) (if (numberp item) (setq numbers (cons item numbers)) (setq alpha (cons item alpha)) ) )
[condition type: UNDEFINED-FUNCTION]
Error: attempt to call `VL-REMOVE-IF' which is an undefined function.Code:(defun count-alpha ( l ) (length (vl-remove-if 'numberp l)) ) (defun count-no ( l ) (length (vl-remove-if-not 'numberp l)) )
[condition type: UNDEFINED-FUNCTION]
What CAD application are your using in fact?!? Those don't appear as AutoLISP error messages...
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Or are you talking in fact of LISP language? Then please pay attention that this Forum is dedicated to AutoLISP, a dialect of LISP used under AutoCAD editor; so I'm afraid that will have to find other resource for help on your issue.
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
It appears to be an error message formatting from the Common Lisp language.
"The thing about quotes on the internet is that you cannot confirm their validity." - Abraham Lincoln
I -edit- a lot, sorry.
The rotary engine is the most efficient way of converting fuel to noise ever invented.
If my post sounds offensive, but can be meant in a non-offensive manner...I meant the latter.
Registered forum members do not see this ad.
In which case: Using ECL's Lisp Shell:Code:(length (remove-if-not (lambda (a) (stringp a)) '(1 3 6 "34" 5 "name"))) 2
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Bookmarks