Created
March 26, 2012 03:31
-
-
Save hgarcia/2202665 to your computer and use it in GitHub Desktop.
Lerning Erlang 4
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
1> c(htmltags). | |
{ok,htmltags} |
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
anchor({Src, Txt}) -> | |
"<a src=\"" ++ Src ++ "\">" ++ Txt ++ "</a>"; | |
anchor({Classes, Src, Txt}) -> | |
"<a src=\"" ++ Src ++ "\" class=\"" ++ Classes ++ "\">" ++ Txt ++ "</a>"; | |
anchor(Default) -> | |
"<a src=\"" ++ Default ++ "\">" ++ Default ++ "</a>". |
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
^Chernan@hernan-ubuntu:~/DynamicProg/erlang/code$ ll | |
total 24 | |
drwxrwxr-x 2 hernan hernan 4096 2012-03-26 00:00 ./ | |
drwxrwxr-x 5 hernan hernan 4096 2012-03-25 15:11 ../ | |
-rw-rw-r-- 1 hernan hernan 720 2012-03-26 00:00 htmltags.beam | |
-rw-rw-r-- 1 hernan hernan 299 2012-03-25 23:33 htmltags.erl |
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
-module(htmltags). | |
-export([anchor/1]). | |
anchor({Src, Txt}) -> | |
"<a src=\"" ++ Src ++ "\">" ++ Txt ++ "</a>"; | |
anchor({Classes, Src, Txt}) -> | |
"<a src=\"" ++ Src ++ "\" class=\"" ++ Classes ++ "\">" ++ Txt ++ "</a>"; | |
anchor(Default) -> | |
"<a src=\"" ++ Default ++ "\">" ++ Default ++ "</a>". |
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
1> htmltags:anchor({"http://www.erlang.org/", "Erlang lang"}). | |
"<a src=\"http://www.erlang.org/\">Erlang lang</a>" | |
2> htmltags:anchor({"rounded menuitem", "http://www.erlang.org/", "Erlang lang"}). | |
"<a src=\"http://www.erlang.org/\" class=\"rounded menuitem\">Erlang lang</a>" | |
3> htmltags:anchor("http://www.erlang.org/"). | |
"<a src=\"http://www.erlang.org/\">http://www.erlang.org/</a>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment