TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CHulse on August 04, 2018, 07:55:01 PM

Title: Null vs empty?
Post by: CHulse on August 04, 2018, 07:55:01 PM
Hi folks

In looping through a list of lists, I encounter the first empty row ("" "" "" "" "" "" "" "" "" "" "" "" ""). I'm having trouble testing for the first "" value to escape the program. I've tried

Code - Auto/Visual Lisp: [Select]
  1. (if (not (null (car x)))...

So is the "" value something other than "null"?

Thanks
Title: Re: Null vs empty?
Post by: CHulse on August 04, 2018, 07:58:55 PM
OK, I'm sorry. I have no idea why this posted 3 times.
Title: Re: Null vs empty?
Post by: kdub_nz on August 04, 2018, 09:32:40 PM
See if any of there help

Code - Auto/Visual Lisp: [Select]
  1. ;; (KDUB:emptystring-p "1") ->nil
  2. ;; (KDUB:emptystring-p "") ->T
  3. ;; (KDUB:emptystring-p " ") ->T
  4. ;;
  5. ;; (KDUB:notemptystring-p "x") -> T
  6. ;; (KDUB:notemptystring-p "") -> nil
  7. ;; (KDUB:notemptystring-p " ") -> nil
  8. ;;
  9. ;; (KDUB:validstring-p "x") -> T
  10. ;; (KDUB:validstring-p "") -> nil
  11. ;; (KDUB:validstring-p " ") -> T
  12. (defun kdub:string-p (arg) (= (type arg) 'str))
  13. (defun kdub:validstring-p (arg) (and (= (type arg) 'str) (/= 0 (strlen arg))))
  14. (defun kdub:emptystring-p (arg)
  15.   (and (= (type arg) 'str) (= 0 (strlen (vl-string-trim " " arg))))
  16. )
  17. (defun kdub:notemptystring-p (arg)
  18.   (and (= (type arg) 'str) (/= 0 (strlen (vl-string-trim " " arg))))
  19. )
  20.  
Title: Re: Null vs empty?
Post by: Lee Mac on August 05, 2018, 05:49:18 AM
To test whether the entire row is empty, you could use:

Code - Auto/Visual Lisp: [Select]
  1. (= "" (apply 'strcat x))

And yes, the empty string is not considered a null value, only nil is null.
Title: Re: Null vs empty?
Post by: Grrr1337 on August 05, 2018, 06:37:30 AM
Alternatively to Lee's suggestion:

Code - Auto/Visual Lisp: [Select]
  1. (not (apply '= (cons "" x)))
Title: Re: Null vs empty?
Post by: CHulse on August 05, 2018, 08:54:08 AM
Thanks folks, I think I've got it working now. Much appreciated.
Title: Re: Null vs empty?
Post by: JohnK on August 06, 2018, 11:26:45 AM
Just a word of advice on this topic.
Given a list:
Code: [Select]
(setq x ("" "" "" "" "" "" "" "" "" "" "" "" ""))
Both Lee's and Grrr1337's suggestions will work.

However, if given a list:
Code: [Select]
(setq x ("" "" "" "" "" "" "" "" "" "" "" "" "" 1))
The first method will fail because strcat assumes a string.
-i.e.
Code - Auto/Visual Lisp: [Select]
  1. (= "" (apply 'strcat x)
  2. ; will fail if non-string entry is found.
  3.  
  4. (not (apply '= (cons "" x))))
  5. ; will still work in case of non-string entry
  6.  

In other programming languages you will spend quite a bit of time developing type safe routines and procedures. I would approach this much the same way kdub did and his type checking.
Title: Re: Null vs empty?
Post by: Lee Mac on August 06, 2018, 01:29:02 PM
I think it ultimately depends on the use case - in this particular example, I would hazard a guess that the list has been obtained from reading a delimited file, in which case it is guaranteed that the list will only contain strings and any type checking would therefore be superfluous.
Title: Re: Null vs empty?
Post by: JohnK on August 06, 2018, 01:50:26 PM
Okay, but my point is that you *should not* do that (assume) because it's more of a matter of time before you get burned and a "stringp" error, being caused in a far-flung section of code will/is not fun to locate; it's far easier and better for everyone if people/you/me/them/Mickey Mouse adds simple "type safety" check into functions like this.

Perhaps I wasn't clear on my second point of my post as well so here is further explanation.
Grrr1337's example code doesn't toss a wobbly when passed the non-string value but I would still--if I were typing--use a (eq (type... function just for extra readability because it works by obscurity (it's not clear that it will pass the type check) to most people.
Title: Re: Null vs empty?
Post by: CHulse on August 07, 2018, 07:01:35 AM
Thanks guys. I'm still learning.
But in this case, Lee is correct in assuming since he wrote most of the original routine I use. I've added to it over the years, but it relies on his string break function. So I was looking for a way to get the main routine to see the "end" of that list (i.e. The first empty row of strings). I've been working to make it more stupid proof and less reliant on the user.
So thanks again Lee, the tree block insertion routine has been a huge help and we use it almost daily.
Title: Re: Null vs empty?
Post by: JohnK on August 07, 2018, 08:37:44 AM
That sounds like a wonderful way to get out of many of my engineering tasks; I don't need to do any of these calculations because I will just assume it will never happen or always remain the way it is now. Maybe we should design roads that way too; we can post big signs saying no more then ten cars per hour allowed (and no trucks...or livestock). Brilliant!
Title: Re: Null vs empty?
Post by: dgorsman on August 07, 2018, 10:16:10 AM
Outside of libraries it's uncommon to have an unbounded "problem space".  One of the key parts to planning software, either top-level or in the weeds, is to create that limited and well defined "problem space" so you don't go cross-eyed trying to handle every possible eventuality.
Title: Re: Null vs empty?
Post by: ronjonp on August 07, 2018, 10:21:07 AM
Outside of libraries it's uncommon to have an unbounded "problem space".  One of the key parts to planning software, either top-level or in the weeds, is to create that limited and well defined "problem space" so you don't go cross-eyed trying to handle every possible eventuality.
Agreed .. if you know what data you're passing ( and you should ) why add overhead to check the data.
Title: Re: Null vs empty?
Post by: JohnK on August 07, 2018, 11:48:07 AM
*blink-blink* Whaaat?

We are talking overhead measured in milliseconds if you chose to be type-safe (and, honestly, I'd bet that Grr1337's snip is faster to begin with because I think CONS is quicker then STRCAT). Even if it wasn't faster/more overhead, I'd still choose to adopt the method employed by Grrr1337's snip to take on type-safe vs not at all. ...Being redundant in a type-safe check is a little overboard (to add an "eq(type..." to that snip, for example)--I'll give you that--but I've never heard advice about when it is okay to NOT be type-safe.
Title: Re: Null vs empty?
Post by: owenwengerd on August 07, 2018, 01:10:58 PM
... I've never heard advice about when it is okay to NOT be type-safe.

To the extent that type safety hides violations of an API contract (i.e. when it's best to crash definitely and immediately), I think it is a very bad idea. And in my opinion, it's a very bad idea in this case, where non-strings mean that something is already wrong.
Title: Re: Null vs empty?
Post by: JohnK on August 07, 2018, 03:03:38 PM
I totally agree a non-string would signify something wrong but a programmer should check the returned value(s) and take appropriate action(s) depending on the return value(s).

Code - Auto/Visual Lisp: [Select]
  1. (setq x '("" "" "" "" "" "" 1))
  2.  
  3. (defun test-str (x)
  4.   (= "" (apply 'strcat x))
  5. )
  6.  
  7. (defun test-str-2 (x)
  8.   (if (not (apply '= (cons "" x)))
  9.     (princ "exit")
  10.     (princ "pass")
  11.     )
  12.   )
  13.  
  14. (test-str x)
  15. (test-str-2 x)
Title: Re: Null vs empty?
Post by: Grrr1337 on August 07, 2018, 04:03:33 PM
For my suggestion theres one thing to be aware of - require checking if 'x' is not null:

Code - Auto/Visual Lisp: [Select]
  1. _$ (apply '= (cons "" nil))
  2. T
Title: Re: Null vs empty?
Post by: ronjonp on August 07, 2018, 04:22:00 PM


Code: [Select]
(setq l '("" "" "" "" "" """" "" "" "" "" """" "" "" "" "" """" "" "" "" "" """" "" "" "" "" """" "" "" "" "" ""))
(defun test-str (l) (= "" (apply 'strcat l)))
(defun test-str-2 (l) (apply '= (cons "" l)))
(defun _allemptystrings (l) (defun _chk (x) (and (= 'str (type x)) (= x ""))) (vl-every '_chk l))
(benchmark '((test-str l) (test-str-2 l) (_allemptystrings l)))
;;;    (TEST-STR-2 L)...........1922 / 2.25 <fastest>
;;;    (TEST-STR L).............2062 / 2.10
;;;    (_ALLEMPTYSTRINGS L).....4328 / 1.00 <slowest>
Title: Re: Null vs empty?
Post by: VovKa on August 07, 2018, 04:40:17 PM
Code: [Select]
(defun test-str-3 (l) (not (vl-remove "" l)))
Title: Re: Null vs empty?
Post by: Lee Mac on August 07, 2018, 04:47:15 PM
Whilst I agree that type checking is necessary when the function is capable of being supplied with arbitrary data (which in itself is a rare occurrence since even AutoLISP data acquired from a user is typically either of a predetermined data type or null), if a function is being evaluated from within a program, the data type of the arguments supplied to the function is known in advance by the programmer and so additional type checking is redundant and superfluous.

Aside, note that the standard AutoLISP functions operate in much the same way -
Code - Auto/Visual Lisp: [Select]
  1. _$ (rtos "1")
  2. ; error: bad argument type: numberp: "1"
Title: Re: Null vs empty?
Post by: MP on August 07, 2018, 05:50:45 PM
Agree with Lee, Owen etc. Link (http://www.theswamp.org/index.php?topic=9709.msg124496#msg124496).
Title: Re: Null vs empty?
Post by: JohnK on August 07, 2018, 08:06:45 PM
Tired of painting the bikeshed; why does the scope keep changing to suite diffferent points?

This is not overhead, complicated, or difficult. You do it a thousand times when you write code. You are not calling or creating an API, you are not creating a library, or reinventing the steam locomotive, you are mearly accepting data (from a source you may not have control of--user or text file for example) and you should check to make sure it is of the type/scope/range you expect before you go off "dividing by zero" or some other weird thing.

It is the same as:
Code - C++: [Select]
  1. if (n <= 0) {
  2.         printf("The number should be positive.\n");
  3. } else {
  4.         for (int i = 1; i <= n; ++i) {
Are [you] honestly telling me this is not "correct". -i.e. in this code the program exits (falls out of the IF statement) if the number isnt postive; are [you] telling me the programmer should have just "preformed math" or "entered a loop" or "launched N rockets" on/with a negative number?

In the two examples we have been using I mearly made the point that STRCAT will fail (not "exit" or "fall out". "fail") in the instance that the argument was not a string (it is like saying the "<=", above, is not able to check numbers and something else should be used).

Of course native functions (and library functions) will fail if they receive a value not in their wheel house. You cannot expect RTOS to accept strings nor should you expect STRCAT to accept numbers (absolutely nothing shocking here).
Title: Re: Null vs empty?
Post by: ronjonp on August 07, 2018, 10:03:13 PM
Agree with Lee, Owen etc. Link (http://www.theswamp.org/index.php?topic=9709.msg124496#msg124496).
Same mindset here.
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 08:48:11 AM
Code: [Select]
(defun test-str-3 (l) (not (vl-remove "" l)))
You win! :)
Quote
    (TEST-STR-3 L)...........1375 / 2.77 <fastest>
    (TEST-STR-2 L)...........1688 / 2.26
    (TEST-STR L).............1781 / 2.14
    (_ALLEMPTYSTRINGS L).....3813 / 1.00 <slowest>
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 09:52:23 AM
...
You win! :)
...

Nope. Doesn't meet the criteria to fail.

Code: [Select]
Command: (setq x '("" "" "" "" "" "" 1))
("" "" "" "" "" "" 1)

Command: (defun test-str-3 (l) (not (vl-remove "" l)))
TEST-STR-3

Command: (test-str-3 x)
nil
Title: Re: Null vs empty?
Post by: Grrr1337 on August 08, 2018, 09:54:09 AM
Recursive one -

Code - Auto/Visual Lisp: [Select]
  1. (defun test-str-4 ( L )
  2.   (or (null L)
  3.     (and (= (car L) "") (test-str-4 (cdr L)))
  4.   )
  5. )

:)
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 10:01:56 AM
...
You win! :)
...

Nope. Doesn't meet the criteria to fail.

Code: [Select]
Command: (setq x '("" "" "" "" "" "" 1))
("" "" "" "" "" "" 1)

Command: (defun test-str-3 (l) (not (vl-remove "" l)))
TEST-STR-3

Command: (test-str-3 x)
nil
Looks good to me? You gave it a 1 and it said NO not all empty strings?
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 10:03:26 AM
Looks good to me? You gave it a 1 and it said NO not all empty strings?

According to you guys, it is supposed to fail.
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 10:05:01 AM
Recursive one -

Code - Auto/Visual Lisp: [Select]
  1. (defun test-str-4 ( L )
  2.   (or (null L)
  3.     (and (= (car L) "") (test-str-4 (cdr L)))
  4.   )
  5. )

 :)
And the numbers are in :)
Quote
    (TEST-STR-3 L)...........1344 / 2.86 <fastest>
    (TEST-STR-2 L)...........1703 / 2.26
    (TEST-STR L).............1735 / 2.22
    (TEST-STR-4 L)...........3172 / 1.21
    (_ALLEMPTYSTRINGS L).....3844 / 1.00 <slowest>
Title: Re: Null vs empty?
Post by: Grrr1337 on August 08, 2018, 10:09:09 AM

And the numbers are in :)
Quote
    (TEST-STR-3 L)...........1344 / 2.86 <fastest>
    (TEST-STR-2 L)...........1703 / 2.26
    (TEST-STR L).............1735 / 2.22
    (TEST-STR-4 L)...........3172 / 1.21
    (_ALLEMPTYSTRINGS L).....3844 / 1.00 <slowest>

Doh, recursion is slow no matter what :geek:

BTW I think if you externally define '_chk' (outside of _allemptystrings) it should perform drastically faster, since it wont redefine the subfoo each time.
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 10:12:10 AM
Looks good to me? You gave it a 1 and it said NO not all empty strings?

According to you guys, it is supposed to fail.
OK .. maybe I'm missing something. My argument is that data that is passed should be checked before using this function as to not be 'superfluous' as Lee stated. My benchmark shows that there is definitely a performance hit if you don't check the data prior.
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 10:14:20 AM

And the numbers are in :)
Quote
    (TEST-STR-3 L)...........1344 / 2.86 <fastest>
    (TEST-STR-2 L)...........1703 / 2.26
    (TEST-STR L).............1735 / 2.22
    (TEST-STR-4 L)...........3172 / 1.21
    (_ALLEMPTYSTRINGS L).....3844 / 1.00 <slowest>

Doh, recursion is slow no matter what :geek:

BTW I think if you externally define '_chk' (outside of _allemptystrings) it should perform drastically faster, since it wont redefine the subfoo each time.
Pretty similar:

Quote
_$


("" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
TEST-STR
TEST-STR-2
TEST-STR-3
TEST-STR-4
_CHK
_ALLEMPTYSTRINGS Benchmarking ...................Elapsed milliseconds / relative speed for 65536 iteration(s):


    (TEST-STR-3 L)...........1360 / 2.81 <fastest>
    (TEST-STR-2 L)...........1719 / 2.23
    (TEST-STR L).............1750 / 2.19
    (TEST-STR-4 L)...........3203 / 1.20
    (_ALLEMPTYSTRINGS L).....3828 / 1.00 <slowest>

Title: Re: Null vs empty?
Post by: MP on August 08, 2018, 10:52:15 AM
(http://i.imgflip.com/2fi7kp.jpg)
Title: Re: Null vs empty?
Post by: Mark on August 08, 2018, 11:07:20 AM
:-)
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 11:41:54 AM
OK .. maybe I'm missing something. My argument is that data that is passed should be checked before using this function as to not be 'superfluous' as Lee stated. My benchmark shows that there is definitely a performance hit if you don't check the data prior.

The scope keeps changing; you guys talk among'st yourselves and come to a consensus. ...I can't really keep up but as far as I can keep straight, = should work just fine for you guys.
Code: [Select]
(= "" "" "")
I'm out of here.
Title: Re: Null vs empty?
Post by: ronjonp on August 08, 2018, 12:02:07 PM
OK .. maybe I'm missing something. My argument is that data that is passed should be checked before using this function as to not be 'superfluous' as Lee stated. My benchmark shows that there is definitely a performance hit if you don't check the data prior.

The scope keeps changing; you guys talk among'st yourselves and come to a consensus. ...I can't really keep up but as far as I can keep straight, = should work just fine for you guys.
Code: [Select]
(= "" "" "")
I'm out of here.
Sure .. but the data is in a list .. and I'm outta here too :P.
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 01:06:59 PM
Ah, well that would be a simple fix but after some "huge contemplation" *eye-roll* EQ will not fail so I quickly penned two alternates (#6 & #7) which should fail ungracefully (per spec).

Code - Auto/Visual Lisp: [Select]
  1. (defun test-str-5 ( aList ) (apply '= aList))
  2. (defun test-str-6 ( aList )
  3.   (zerop (apply '+ (mapcar '(lambda (x) (ascii x)) aList))) )
  4. (defun test-str-7 ( aList ) (foreach x aList (zerop (ascii x))) )
  5.  
Title: Re: Null vs empty?
Post by: Lee Mac on August 08, 2018, 01:23:36 PM
It is the same as:
Code - C++: [Select]
  1. if (n <= 0) {
  2.         printf("The number should be positive.\n");
  3. } else {
  4.         for (int i = 1; i <= n; ++i) {
Are [you] honestly telling me this is not "correct". -i.e. in this code the program exits (falls out of the IF statement) if the number isnt postive; are [you] telling me the programmer should have just "preformed math" or "entered a loop" or "launched N rockets" on/with a negative number?

Why are you not checking that 'n' is a numerical data type first?
Title: Re: Null vs empty?
Post by: MP on August 08, 2018, 01:27:05 PM
Because trees.
Title: Re: Null vs empty?
Post by: Lee Mac on August 08, 2018, 01:29:38 PM
You are mearly[sic] accepting data (from a source you may not have control of--user or text file for example)

On this point, could you provide an AutoLISP example in which a user or file can supply a function with data of an unknown data type? Perhaps I'm overlooking something obvious, but reading a file in AutoLISP can only ever return strings, and obtaining input from a user is restricted by the various getXXX/entsel/ssget/grread functions which return known data types.
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 05:37:57 PM
> n is numerical
Because C based languages work differently. I do that in my argument list (I specify that I only accept INT values for example). -e.g. "int FOO ( int PARAMETER )", the compiler helps enforce stuff like this. And this is where Owens comment about API stuff comes into play (we have stuff like destructors).

> sterile list
So then back up.
Given: (setq aList '("" ""))
Why
(= "" (apply 'strcat aList))
and not just
(apply '= aList)
or being more specific (and compairing the list to a "key")
(apply '= (cons "" aList))
?

-i.e. If this list is sterile then why concatenate for comparison? And, if it's not sterile (the assumption I was under caused by multiple statements so far and/like: the OP said they were in the process of iterating this list(s)) then why are you passing it through "extra stuff" without "type checking" (and how is a hard stop failure with concatenate--and unverified data--better then failing, with a return, via a generic comparison)?
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 05:45:01 PM
Because trees.

Mean.
Title: Re: Null vs empty?
Post by: kdub_nz on August 08, 2018, 08:36:15 PM
That's the issue with travelling ... I missed all the exciting discussion
Title: Re: Null vs empty?
Post by: JohnK on August 08, 2018, 08:47:45 PM
Exciting? More like one sided, vague, confusing, and mean from this perspective.

Did you have a good trip?
Title: Re: Null vs empty?
Post by: Marc'Antonio Alessi on August 10, 2018, 10:29:26 AM
Another (slower):
Code: [Select]
(defun test-str-9 (l) (eq (1+ (strlen (vl-string-trim "()" (vl-princ-to-string l)))) (length l)))
Title: Re: Null vs empty?
Post by: JohnK on August 10, 2018, 12:24:13 PM
Another (slower):
Code: [Select]
(defun test-str-9 (l) (eq (1+ (strlen (vl-string-trim "()" (vl-princ-to-string l)))) (length l)))

Nice and it's probably pretty quick but it doesn't meet the specifications--to error upon non-string entries (int, nil, list, etc).
Title: Re: Null vs empty?
Post by: ronjonp on August 10, 2018, 12:37:22 PM
Ok the horse is dead.
Code - Auto/Visual Lisp: [Select]
  1. ;; Make John happy ( but maybe not )
  2. (defun _chk (k l) (apply '= (cons k l)))
  3. (_chk "" (setq l '("" "" "" "" "" "" "" "")))
  4. (_chk 1 '(1 1 1 1 1 1 1))
  5. (_chk nil '(nil nil nil nil nil nil nil))
  6.  
Title: Re: Null vs empty?
Post by: JohnK on August 10, 2018, 12:52:02 PM
Ok the horse is dead.
Code - Auto/Visual Lisp: [Select]
  1. ;; Make John happy ( but maybe not )
  2. ...
  3.  

Ha! Sorry, not my rule. The rule (as I understand it) is that the function should fail/error/whatever--because there will/should never be anything other than a string in the list--immediately (no check, no return, no cleanup).

Here is a very quick tally of the posted functions that pass specifications (double check please. I don't think I got them all and I didn't see test-str-8.).
Code - Auto/Visual Lisp: [Select]
  1.              (test-str l)
  2.              ;; (test-str-2 l)          ;; does not error
  3.              ;; (_allemptystrings l)    ;; does not error
  4.              ;; (test-str-3 l)          ;; does not error
  5.              ;; (test-str-4 l)          ;; does not error
  6.              ;; (test-str-5 l)          ;; does not error
  7.              (test-str-6 l)
  8.              (test-str-7 l)
  9.              ;; (test-str-9 l)          ;; does not error
  10.  
Title: Re: Null vs empty?
Post by: ronjonp on August 10, 2018, 01:02:27 PM
If you're comparing a key to a list ( function above ) why should it 'fail'? It's either T or nil and can accept multiple datatypes to test. Perhaps happiness is not in the cards for you.  ;)  Have a nice weekend.
Title: Re: Null vs empty?
Post by: JohnK on August 10, 2018, 02:06:41 PM
If you're comparing a key to a list ( function above ) why should it 'fail'? It's either T or nil and can accept multiple datatypes to test. Perhaps happiness is not in the cards for you.  ;)  Have a nice weekend.
How should I know why it `has to fail'?! I asked several different times/ways.
I agree (and the "Key comparison method" is one of the most efficient methods for this task) but I was told otherwise when I raised that very point.

You ask; I don't have the reputation points to get a reply.

Wait a minute. If happiness isn't in the cards for me do you really think my weekend will be nice? :)
Title: Re: Null vs empty?
Post by: ronjonp on August 10, 2018, 02:23:19 PM
If you're comparing a key to a list ( function above ) why should it 'fail'? It's either T or nil and can accept multiple datatypes to test. Perhaps happiness is not in the cards for you.  ;)  Have a nice weekend.

Wait a minute. If happiness isn't in the cards for me do you really think my weekend will be nice? :)
There is a very small possibility  :)  ... no really, have a nice weekend.
Title: Re: Null vs empty?
Post by: JohnK on August 10, 2018, 02:26:51 PM
Anytime with the wife and kids is nice! You too.
Title: Re: Null vs empty?
Post by: Marc'Antonio Alessi on August 11, 2018, 02:17:48 AM
Another (slower):
Code: [Select]
(defun test-str-9 (l) (eq (1+ (strlen (vl-string-trim "()" (vl-princ-to-string l)))) (length l)))

Nice and it's probably pretty quick but it doesn't meet the specifications--to error upon non-string entries (int, nil, list, etc).
Code: [Select]
; (test-str-3 + test-str)
(defun AllEmptyStrings (l / o)
  (cond
    ( (not (setq o (vl-remove "" l))) )
    ( (not (apply 'strcat o)) )
  )
)
(AllEmptyStrings '("" "" "" )) ==> T
(AllEmptyStrings '("" "" "1")) ==> nil
(AllEmptyStrings '("" "" 1  )) ==> error
(AllEmptyStrings '("" "" nil)) ==> error
(AllEmptyStrings '("" "" '())) ==> error
Title: Re: Null vs empty?
Post by: Marc'Antonio Alessi on August 11, 2018, 09:14:51 AM
<…>
Here is a very quick tally of the posted functions that pass specifications (double check please. I don't think I got them all and I didn't see test-str-8.).
Code - Auto/Visual Lisp: [Select]
  1.              (test-str l)
  2.              ;; (test-str-2 l)          ;; does not error
  3.              ;; (_allemptystrings l)    ;; does not error
  4.              ;; (test-str-3 l)          ;; does not error
  5.              ;; (test-str-4 l)          ;; does not error
  6.              ;; (test-str-5 l)          ;; does not error
  7.              (test-str-6 l)
  8.              (test-str-7 l)
  9.              ;; (test-str-9 l)          ;; does not error
  10.  
Command: (test-str-7 '("" "1" "" ""))
T