Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specific character strings variables #111

Open
kilianmh opened this issue Dec 9, 2023 · 2 comments
Open

Add specific character strings variables #111

kilianmh opened this issue Dec 9, 2023 · 2 comments

Comments

@kilianmh
Copy link
Collaborator

kilianmh commented Dec 9, 2023

Since some functions (such as concat) only accept strings.
Therefore sometimes it is convenient to have characters as strings.
E.g.

(defvar new-line (string #\Newline))

The we could use it in concat like this:

(str:concat "Hello" new-line "world") 

It could be useful, especially for the whitespace characters (e.g. for space) but maybe also others.
What do you think?

@vindarel
Copy link
Owner

Some functions have been worked out to also accept characters:

(str:join #\Newline '( "hello" "test"))

so I think we should allow characters for all, including concat.

@kilianmh
Copy link
Collaborator Author

we should allow characters for all, including concat

good idea. Could concat also accept numbers?

The only annoying thing with characters is the special syntax #\. So what you think if we define e.g. whitespace-characters as variable / constant to make it more "lispy" working with characters. For example:

(defvar new-line #\Newline)
(defconstant tab #\Tab)

Also one idea was introducing functions such as new-lines (or new-line?), that contain multiple times the same characters:

(defun new-lines (lines)
  (let ((result ""))
    (dotimes (var lines)
    (setf result (str:concat result "
")))
    result))
CL-USER> (new-lines 2)
"

"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants