Documentation topicsStrings
Lexical Structure
Control Flow
Functions & Scope
Lists & Built-ins
Reference
MarathiCode v0.2.0
Strings
मजकूर
Strings are written in double quotes and can contain Marathi, English or any other text.
strings.mr
चल नाव = "अमित"
छापा("नमस्कार, " + नाव)Output (आउटपुट)
नमस्कार, अमित
Escape sequences
| Write | To get |
|---|---|
| \n | a line break |
| \t | a tab |
| \" | a double quote |
| \\ | a backslash |
escapes.mr
छापा("पहिली ओळ\nदुसरी ओळ")
छापा("तो म्हणाला, \"हो\"")Output (आउटपुट)
पहिली ओळ दुसरी ओळ तो म्हणाला, "हो"
Any other backslash sequence is kept exactly as written.
Joining with +
If either side of + is a string, the other side is converted to text and the two are joined. Booleans become खरे / खोटे:
join.mr
चल वय = 18
छापा("वय: " + वय)
छापा("उत्तीर्ण: " + खरे)Output (आउटपुट)
वय: 18 उत्तीर्ण: खरे
Length, indexing and comparison
लांबी(s)gives the length in Unicode code points.s[i]gives the character at positioni(starting at 0).<,>,<=,>=compare strings character by character, by Unicode code point.- Strings cannot be changed in place:
s[0] = "x"is an error.
string_ops.mr
चल शब्द = "abc"
छापा(लांबी(शब्द))
छापा(शब्द[0])
छापा("अ" < "ब")Output (आउटपुट)
3 a खरे