Page 1 of 1
Capitalize Lisp
Posted: Thu Sep 20, 2012 10:08 pm
by samohtvii
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
Re: Capitalize Lisp
Posted: Thu Sep 20, 2012 10:27 pm
by Kohath
The closest *function* would probably be
string-capitalize.
For just the
behaviour, try format's case conversion:
Code: Select all
(format nil "~@(~A~)" "this is a senTENce.")
Re: Capitalize Lisp
Posted: Thu Sep 20, 2012 11:38 pm
by Kompottkin
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.
Re: Capitalize Lisp
Posted: Sat Sep 22, 2012 9:32 pm
by samohtvii
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
Re: Capitalize Lisp
Posted: Sun Sep 23, 2012 12:44 am
by Goheeca
I've found
this document and in it is a function:
Code: Select all
(defun vowel-p (char) (find char "aeiou" :test #'char-equal))
I don't know if it is sufficient because vowels exist much more than only english vowels.