From the course: Programming Foundations: Discrete Mathematics

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Characters and strings

Characters and strings

From the course: Programming Foundations: Discrete Mathematics

Start my 1-month free trial

Characters and strings

- [Voiceover] Sometimes, it's necessary to use characters and strings when programming. SML has some very specific syntax that should be addressed in case your programs require these data types. To use a character in SML, it must be prefixed with the pound sign, followed by double quotes around the character. Here is an example. Pound sign, double quotes, a double quotes, semicolon, now when I hit enter, it creates a variable i-t, it, and it sets it to the letter a, which is a character. It is important to note that there are no spaces between the pound sign and the first double quote. A string on the other hand, is a sequence of characters and it is defined by simply enclosing it in double quotes. I'm going to go ahead and put double quotes, Peggy, space, Fisher, double quotes, semicolon, and now I've replaced the variable i-t with the string Peggy Fisher. Often times we need to concatenate or combine two strings. In SML we use the caret symbol. The caret symbol is located on the…

Contents