Files
exercism-workspace/high-school-sweetheart/src/high_school_sweetheart.gleam
2025-11-08 11:39:33 +01:00

41 lines
874 B
Gleam

import gleam/list
import gleam/string
pub fn first_letter(name: String) {
case string.first(string.trim(name)) {
Error(_) -> ""
Ok(first) -> first
}
}
pub fn initial(name: String) {
first_letter(name) |> string.uppercase <> "."
}
pub fn initials(full_name: String) {
case string.split(full_name, " ") {
[] -> ""
[first, last] -> initial(first) <> " " <> initial(last)
_ -> ""
}
}
pub fn pair(full_name1: String, full_name2: String) {
"
****** ******
** ** ** **
** ** ** **
** * **
** **
** " <> initials(full_name1) <> " + " <> initials(full_name2) <> " **
** **
** **
** **
** **
** **
** **
***
*
"
}