Is there any function to automatically make a string uppercase or lowercase or to capitalize the first letter?
I'm also looking to take a string and 'inspect' the first character so with : "example" i would want to get e as a variable.
THanks
Capitalize Lisp
-
- Posts: 61
- Joined: Mon Jul 07, 2008 8:06 pm
- Location: Toowoomba, Queensland, Australia
- Contact:
Re: Capitalize Lisp
The closest *function* would probably be string-capitalize.
For just the behaviour, try format's case conversion:
For just the behaviour, try format's case conversion:
Code: Select all
(format nil "~@(~A~)" "this is a senTENce.")
-
- Posts: 94
- Joined: Mon Jul 21, 2008 7:26 am
- Location: München, Germany
- Contact:
Re: Capitalize Lisp
samohtvii wrote:I'm also looking to take a string and 'inspect' the first character so with : "example" i would want to get e as a variable.
Code: Select all
CL-USER> (char "example" 0)
#\e
Re: Capitalize Lisp
Thanks guys. Both really helpful. One last question. What is the easiest way to check if the letter i extracted is a vowel.
instead of writing a lot of if statements is there a way to check all vowels at one?
Thanks
instead of writing a lot of if statements is there a way to check all vowels at one?
Thanks
Re: Capitalize Lisp
I've found this document and in it is a function:
I don't know if it is sufficient because vowels exist much more than only english vowels.
Code: Select all
(defun vowel-p (char) (find char "aeiou" :test #'char-equal))
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.