// Define a String as a list of Charname: String= ['G','u','i','l','l','a','u','m','e'];description: String= [' ','e','s','t',' ','b','e','a','u'];phone: [Int] = [0,7,8,3,8,7,1,6,0,8];
Strings are considered in GoMelan as list of Char type.
Therefore String <-> [Char]
Main Function
The main function in GoMelan demonstrates the use of various list operations and conversions.
fn main()-> Int{// Declare variables name: String= ['G','u','i','l','l','a','u','m','e']; description: String= [' ','e','s','t',' ','b','e','a','u']; phone: [Int] = [0,7,8,3,8,7,1,6,0,8]; height: Float=1.73; birthDate: String="11012003";// Concatenate two strings nameAndDescription: String= name + description;// Get a character at a specific index firstLetter: Char = name[0];// Get the length of a list nameLen: Int=len(name);// Convert a Float to an Int heightInt: Int=floatToInt(height);// Convert a String to an Int birthDateInt: Int=stringToInt(birthDate);return0;}
Results
Here are the results for each variable after executing the code:
nameAndDescription ="Guillaume est beau"firstLetter ='G'nameLen =9heightInt =1birthDateInt =11012003
These results demonstrate the concatenation of strings, accessing a character at a specific index, obtaining the length of a list, and converting both a Float and a String to Int.