Mathematically denote an empty string

368 Views Asked by At

My background is computer science and im trying to properly document some of my code.

I have a list of strings and I want to mathematically denote a check if the string is empty. The string exists, it might just be empty. Here $S$ is my string and $l$ my list.

I dont think i can denote it as if $ S \notin \emptyset$ then because an empty string is still a string? quoting wiki empty string

The empty string should not be confused with the empty language ∅, which is a formal language (i.e. a set of strings) that contains no strings, not even the empty string

Or is it as simple as if $|S| = 0$ then

The wiki also mentions the empty string is denoted with ε or sometimes Λ or λ. I assume that if $S = \epsilon$ then is not correct.

1

There are 1 best solutions below

0
On

$\epsilon$ is a property of languages. This is more computer science theory rather than programming. You'll never see $\epsilon$ used in programming.

That being said, I'm not sure I fully understood your question, but there isn't a need to comment out simple stuff like this

For example, if you are using Python:

if (x):
    print("X is not empty")

In python or most languages, to denote a string is empty, you may declare it as such:

x = ""

This tells you two things.

a) It is a string since it is surrounded by quotes

b) The string is of length 0 since there is nothing between the quotes

There is no need to comment stuff like this. Anyone with a CS background would be able to understand what you are doing here.