-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e147ffa
commit 9748568
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-module(optimissedit). | ||
-export([coffee_to_code/0]). | ||
|
||
% Initial Function to create the Coffee str | ||
coffee_to_code() -> | ||
Coffee = "Coffee", | ||
io:format("~n~p ->", [Coffee]), | ||
coffee_to_code(Coffee). | ||
|
||
% Split coffee into substrings | ||
coffee_to_code(C) -> | ||
Head = string:substr(C,1,2), | ||
Len = string:length(C), | ||
Tail = string:substr(C, Len - 1, 1), | ||
coffee_to_code(Head, Tail). | ||
|
||
% Recombine substrings with a new character in the middle | ||
coffee_to_code(H, T) -> | ||
Half = string:concat(H, "d"), | ||
Full = string:concat(Half, T), | ||
io:format("~n~p\n", [Full]). | ||
|