Anonymous user
Empty string: Difference between revisions
→{{header|Common Lisp}}
Deadmarshal (talk | contribs) (Added Modula-3) |
|||
Line 942:
(let ((s "")) ;; Binds the lexical variable S to the empty string ""
(= (length s) 0) ;; Check if the string is empty
(> (length s) 0
;; (length s) returns zero for any empty sequence. You're better off using type checking:
(typep s '(string 0)) ;; only returns true on empty string
(typep s '(and string
(not (string 0))))) ;; only returns true on string that is not empty
</lang>
|